Skip to content

Commit d57611d

Browse files
baozhoutaoclaude
andauthored
docs: mark IMetadataService interface fence as an excerpt, restore getDiagnosed/subscribe (#17407)
* docs(kernel): mark the IMetadataService interface fence as an excerpt and restore getDiagnosed/subscribe The `## Interface Definition` fence on metadata-service.mdx was introduced as the interface itself and silently omitted 4 of 38 members declared in packages/spec/src/contracts/metadata-service.ts. Reframe it explicitly as a non-exhaustive excerpt pointing at the contract source, and restore getDiagnosed and subscribe — the two omissions that contradicted a subsection the page itself devotes to their pattern (diagnosed-twin reads, watch/subscribe). loadMany and matchEndpoint are left out of the excerpt; neither backs a pattern the page teaches in prose. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU * docs(kernel): add the MetadataWatchEvent row this PR's own fence now depends on Restoring subscribe? to the Interface Definition fence brought in MetadataWatchEvent, the only Metadata* type in that fence without a row in the page's own Types Reference table. Read the shape from its actual declaration (packages/spec/src/system/metadata-persistence.zod.ts, MetadataWatchEventSchema) rather than inferring it from MetadataWatchCallback's differently-shaped event. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012GKcPZbMoGq7WPzKLfRBTU --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 456a0af commit d57611d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@ For the **data path** behind this contract — Repository → Change Log → Cac
2424
per-shape methods like `createObject` / `getField`; you register and read the whole
2525
definition for a type.
2626

27+
The excerpt below groups the interface's members by concern; it is **not** the full
28+
declaration and is not held equal to it by any check. For the authoritative, complete
29+
member list see `IMetadataService` in
30+
[`packages/spec/src/contracts/metadata-service.ts`](https://github.com/objectstack-ai/objectstack/blob/main/packages/spec/src/contracts/metadata-service.ts).
31+
2732
```typescript
33+
// Excerpt — grouped by concern, not exhaustive. See packages/spec/src/contracts/metadata-service.ts for the full declaration.
2834
export interface IMetadataService {
2935
// Core CRUD (by type + name)
3036
register(type: string, name: string, data: unknown): Promise<void>;
3137
registerInMemory?(type: string, name: string, data: unknown): void;
3238
get(type: string, name: string): Promise<unknown | undefined>;
39+
getDiagnosed?(type: string, name: string): Promise<{ data: unknown | undefined; degraded: boolean; errors: string[] }>;
3340
list(type: string): Promise<unknown[]>;
3441
listDiagnosed?(type: string): Promise<{ items: unknown[]; degraded: boolean; errors: string[] }>;
3542
unregister(type: string, name: string): Promise<void>;
@@ -64,6 +71,7 @@ export interface IMetadataService {
6471

6572
// Watch / subscribe (optional)
6673
watch?(type: string, callback: MetadataWatchCallback): MetadataWatchHandle;
74+
subscribe?(type: string, callback: (event: MetadataWatchEvent) => void | Promise<void>): () => void;
6775

6876
// Import / export (optional)
6977
exportMetadata?(options?: MetadataExportOptions): Promise<unknown>;
@@ -320,6 +328,7 @@ console.log(result.failed); // failed
320328
| `MetadataBulkResult` | Result of `bulkRegister` / `bulkUnregister` |
321329
| `MetadataWatchCallback` | `(event: { type, metadataType, name, data? }) => void` |
322330
| `MetadataWatchHandle` | `{ unsubscribe(): void }` |
331+
| `MetadataWatchEvent` | `subscribe`'s callback argument: `{ type: 'added' \| 'changed' \| 'deleted', path, name?, stats?, metadataType?, data?, timestamp? }` |
323332
| `PackagePublishResult` | `{ success, packageId, version, publishedAt, itemsPublished, validationErrors? }` |
324333

325334
---

0 commit comments

Comments
 (0)