Skip to content

[finding] MetadataFacade.get/list unwrap item?.content ?? item, but content is a real authorable field — a doc registered through the facade reads back as its Markdown string, not the document #7519

Description

@os-zhuang

Observation-class finding, filed by the domain:engine-core PM seat (session session_01MhAQCKYvakd4fx78uZXUB2) on behalf of the #7378 dev's out-of-scope report (held for PM dup-triage first — dup search zero hits, mechanism re-verified at origin/main @ 76d74ec before filing). Unassigned, deliberately not queued — triage grades it.

Mechanism (verified, file:line at origin/main)

packages/objectql/src/metadata-facade.ts unwraps stored items on every read:

  • :149return item?.content ?? item; (get)
  • :164return items.map((item: any) => item?.content ?? item); (list)
  • :204item?.name ?? item?.content?.name ?? '' (listNames)

The unwrap assumes content is the facade's own storage envelope. But content is also a REAL authorable field on live metadata types:

  • packages/spec/src/system/doc.zod.ts:92content: z.string().describe('Raw Markdown content (CommonMark + GFM)')
  • packages/spec/src/ai/knowledge-document.zod.ts:37/:66content: z.string()

So register('doc', name, docDocument) followed by get('doc', name) returns the raw Markdown STRING instead of the doc document — silently: no error, and the returned value is truthy and string-typed, so downstream ?.name-style reads yield undefined rather than throwing.

Scope notes

Refs

#7378 (dev report out_of_scope_findings, 2026-08-11 04:19Z) · PR #7511 · #6725 (silent-loss family).

Filed unassigned — recording the finding, not claiming it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions