Skip to content

Commit 76ca106

Browse files
committed
docs(kernel): document the evidenced contract members added for #4251
The IDataEngine and IMetadataService contract references enumerate the interface surface member by member, so the two additions (driver registry lookups; registerInMemory) were stale-by-omission — flagged by the docs drift check on #4321. Both interface listings and the per-member sections now match packages/spec/src/contracts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AWW5xEALZNU5VBXfGyWPGz
1 parent 322f4c3 commit 76ca106

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

content/docs/kernel/contracts/data-engine.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export interface IDataEngine {
5252

5353
// Raw Command Escape Hatch (optional)
5454
execute?(command: any, options?: Record<string, any>): Promise<any>;
55+
56+
// Driver Registry (optional — engines that own named drivers)
57+
getDefaultDriverName?(): string | undefined;
58+
getDriverByName?(name: string): IDataDriver | undefined;
5559
}
5660
```
5761

@@ -365,6 +369,21 @@ const result = await engine.execute?.(
365369
);
366370
```
367371

372+
### getDefaultDriverName / getDriverByName (Driver Registry)
373+
374+
Look up the engine's registered drivers. Only engines that own a named-driver
375+
registry implement these (ObjectQL does; test fakes and remote/virtual engines
376+
need not) — always probe with `?.`:
377+
378+
```typescript
379+
const driverName = engine.getDefaultDriverName?.();
380+
const driver = driverName ? engine.getDriverByName?.(driverName) : undefined;
381+
```
382+
383+
This is the surface the runtime uses to re-register the default driver as a
384+
`driver.<name>` kernel service, which is where `os migrate` and serve's storage
385+
detection locate drivers.
386+
368387
---
369388

370389
## Error Codes

content/docs/kernel/contracts/metadata-service.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ definition for a type.
3030
export interface IMetadataService {
3131
// Core CRUD (by type + name)
3232
register(type: string, name: string, data: unknown): Promise<void>;
33+
registerInMemory?(type: string, name: string, data: unknown): void;
3334
get(type: string, name: string): Promise<unknown | undefined>;
3435
list(type: string): Promise<unknown[]>;
3536
unregister(type: string, name: string): Promise<void>;
@@ -166,6 +167,26 @@ await metadataService.unregister('object', 'project');
166167
To inspect what would break before removing an item, call `getDependents('object', 'project')` — it returns the items that reference this one.
167168
</Callout>
168169

170+
### registerInMemory
171+
172+
Optional. Seeds an item into the in-memory registry **only** — never persisted
173+
to the DB store, never announced to `watch` subscribers. This is the boot-time
174+
path for source-control-owned artefacts that must be *listable* without
175+
creating DB drift — e.g. code-defined datasources (`origin: 'code'`), which is
176+
how the default datasource appears in Setup → Datasources:
177+
178+
```typescript
179+
metadataService.registerInMemory?.('datasource', 'default', {
180+
name: 'default',
181+
label: 'Default',
182+
driver: 'sqlite',
183+
origin: 'code',
184+
});
185+
```
186+
187+
Callers that mutate metadata mid-run want `register`, which persists and
188+
announces.
189+
169190
---
170191

171192
## Bulk Operations

0 commit comments

Comments
 (0)