Skip to content

fix(metadata): a metadata file read or written by name stays inside the loader's root, under a known type - #39118

Queued
objectstack-fleet[bot] wants to merge 13 commits into
mainfrom
claude/metadata-file-read-root-rule
Queued

objectstack-fleet[bot] wants to merge 13 commits into
mainfrom
claude/metadata-file-read-root-rule

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Requested by bob · project thread

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: updated here

维护者速读

  • 用户能看到的变化:应用的元数据只来自编译产物和已存储的元数据;放在项目里按类型命名的目录下的元数据文件默认不再读取,需显式开启才读;开启时按名称读写也只在应用自己的元数据目录、已知类型的目录内进行。
  • 为什么做:按维护者指令立即处理的一项加固工作,并按维护者“无产物启动也不读文件”的裁决收口。
  • 出错会怎样:若有项目仍把元数据当散文件放在项目目录下,这些元数据会读不到;改为写进源码并重新构建即可,也可显式开启;改动可直接撤回。
  • 要你做什么:无。维护者已用 os-zhuang 批准,并授权席位审核后直接落地(2026-12-03 02:14 UTC)。这是行为收窄,changeset 已标 BREAKING 并写明迁移;版本仍是 patch。

What changes

The rule: metadata is served from the compiled artifact and stored metadata; a metadata file is read only on an explicit opt-in, and a file read or written by name stays inside the loader's root, under the directory of a known metadata type.

  • MetadataPlugin reads metadata files under rootDir/TYPE/ only with the new filesystemLoader: true option. Without it (the default, and every composition os serve, os start, os dev and os verify build) it registers no file loader, whatever its bootstrap mode or artifact source. bootstrap: 'artifact-only' never reads files, even with the opt-in.
  • When files are read: a type is one directory name with no glob characters, and a name may contain / to reach a nested file under its type directory.
  • No part of a type or name may be empty, absolute, contain a backslash or NUL, begin with ., consist only of dots and spaces, or be node_modules.
  • A file counts as inside the root only after symbolic links are followed, and the file that is read is the resolved one. The check runs on every read, including a cached lookup.
  • A by-name write is refused unless the nearest existing directory above the target, after symbolic links are followed, is the root or inside it.
  • A NodeMetadataManager that has a type registry reads a directory as metadata only for a type it knows exactly (its type registry, or a type the in-memory registry already holds an item of). Its filesystemLoader: false option reads and watches no files, even with watch: true.
  • A by-name write holds the same resolved-path rule as a read for the file it writes, its backup and its temp file, not only for the directory; the temp file takes a fresh name and is created exclusively.
  • A read that breaks the rule is answered as not found. A by-name save that breaks it is refused before anything is written.

Packages touched:

  • @objectstack/metadata: loaders/contained-path.ts (new), FilesystemLoader (new optional admitsType option), NodeMetadataManager (new optional filesystemLoader option, NodeMetadataManagerOptions exported), MetadataPlugin (new optional filesystemLoader option, default off).
  • @objectstack/metadata-fs: layout.ts and FileSystemRepository.
  • Tests in @objectstack/runtime.

Both published packages get a patch changeset with a migration note: move metadata files into TypeScript source and run os build, or opt in.

Tests

Package New suite Cases
@objectstack/metadata src/loaders/filesystem-loader-root-confinement.test.ts 49 passed
@objectstack/metadata-fs test/item-path-stays-in-root.test.ts 18 passed
@objectstack/runtime src/domains/meta-item-read-stays-in-root.test.ts 63 passed

Each suite holds labelled CONTROL cases for the legitimate shapes beside the refused ones, including a composition that opts in and is served its files.

Acceptance notes

  • MetadataManager.typeRegistry is now protected so the Node subclass can tell an empty registry from a populated one.
  • database-loader.test.ts exercises the eager file-priming pass, so its MetadataPlugin constructions now pass filesystemLoader: true.
  • Measured with no opt-in: the metadata-fs repository still attaches; the save door writes through the repository as before. MetadataManager.save with no saving loader registered throws No loader available for saving type; no non-test code calls it.

Verification

Package tests and typecheck, at 20a1ca5
  • pnpm --filter @objectstack/metadata test: 85 files, 2971 tests passed. typecheck: exit 0.
  • pnpm --filter @objectstack/metadata-fs test: 12 files, 92 tests passed. typecheck: exit 0.
  • @objectstack/runtime: src/domains 250 files, 7593 passed, 6 skipped. typecheck: exit 0.
  • Compositions that build a MetadataPlugin in objectql, metadata-protocol, runtime, verify and cli tests (including the host-config endpoint-index pins): all passed.
Derived gate families, at 20a1ca5

node scripts/pm/dispatch-gates.mjs --commands derived 76 families. 74 exited 0, and --ran reconciles all 76. Two are NOT MEASURED locally and left to CI, each refusing with its own prerequisite (exit 3):

  • check-plugin-teardown-shape --self-test
  • check:dual-build-cjs-loads

Heads after 20a1ca5 change only the changeset and docs: the changeset now declares the narrowing arm, a BREAKING line with its FROM → TO mapping and an ADR-0087 disposition (not-required (runtime-interface-only)); content/docs/protocol/kernel/metadata-service.mdx and content/docs/permissions/capabilities.mdx now state the opt-in. At 4af0a37 the derived list grew to 108 families; the changeset family (including check:adr-0087-registration) and all 32 docs families exited 0, and --ran reconciles 108 (106 run, the same 2 NOT MEASURED).

Contract review at CONTRACT_REVIEW_TIER: the record on 947790b (PASS, three should-fix) and its delta on ea68b47 (S1–S3 and N1 closed; PASS, no must-fix, no should-fix) are on this PR. The fixes at ea68b47: the spec jsdoc, the metadata README and a CLI comment now state the opt-in; a manager that reads no files starts no watcher; a by-name save keeps its target, backup and temp file inside the root. At ea68b47: @objectstack/metadata 2981 passed, metadata-fs 92, spec 29219, verify 515, cli unit 7156; dispatch-gates --ran 127 families, 126 run, 1 NOT MEASURED (check:dual-build-cjs-loads, left to CI). A @objectstack/spec changeset line for the comment-only jsdoc change is omitted by choice (nit N5): spec is in the same fixed release group and moves with this patch.

Read first:

  1. packages/metadata/src/plugin.ts constructor: the opt-in.
  2. packages/metadata/src/loaders/contained-path.ts: the rule.
  3. packages/metadata/src/loaders/filesystem-loader.ts resolveStats and save: the resolved read and the write check.

Two-minute check: pnpm --filter @objectstack/metadata exec vitest run --maxWorkers=2 src/loaders/filesystem-loader-root-confinement.test.ts. Expect 55 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_012dn2AfG9txpigxdt2zFADB

…he loader's root, under a known type

Claude-Session: https://claude.ai/code/session_012dn2AfG9txpigxdt2zFADB
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 4 package(s): @objectstack/cli, @objectstack/metadata-fs, @objectstack/metadata, @objectstack/spec, touching 40 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/cli/src/utils/metadata-file-name.ts, packages/metadata/README.md, packages/metadata/src/node.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

15 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/skills-reference.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/ai/skills.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/concepts/metadata-lifecycle.mdx (via DEFAULT_METADATA_TYPE_REGISTRY (symbol, a top-level const object), FileSystemRepository (symbol, a top-level class))
  • content/docs/deployment/cli.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/deployment/self-hosting.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/frontend/plugins/index.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/frontend/quick-start.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/frontend/theming.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/frontend/troubleshooting.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))
  • content/docs/kernel/contracts/metadata-service.mdx (via loadManyKeyed (symbol, a method of class FilesystemLoader))
  • content/docs/permissions/capabilities.mdx (via filesystemLoader (symbol, a field of interface MetadataPluginOptions; a field of interface NodeMetadataManagerOptions))
  • content/docs/plugins/adding-a-metadata-type.mdx (via DEFAULT_METADATA_TYPE_REGISTRY (symbol, a top-level const object))
  • content/docs/protocol/kernel/metadata-service.mdx (via FilesystemLoader (symbol, a top-level class), MetadataPluginConfigSchema (symbol, a top-level const), NodeMetadataManager (symbol, a top-level class), filesystemLoader (symbol, a field of interface MetadataPluginOptions; a field of interface NodeMetadataManagerOptions))
  • content/docs/protocol/objectui/concept.mdx (via DEFAULT_METADATA_TYPE_REGISTRY (symbol, a top-level const object))
  • content/docs/upgrading.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-3.mdx (via FilesystemLoader (symbol, a top-level class))
  • content/docs/releases/v18/18-0.mdx (via node_modules (literal, a string literal in isPlainPath; a string literal in isPlainSegment))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/cli/src/utils/metadata-file-name.ts, packages/metadata/README.md, packages/metadata/src/node.ts) — pages documenting those are invisible to this run
  • 8 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 256 client-bound route-ledger rows — the other 185 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 185: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 125 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 195 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 7449ea3487d442504a848de448a47d832039f138 — the merge of head ea68b4724cae18fa2c37737426cb97adaccfaf78 into base 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 7449ea3487d442504a848de448a47d832039f138 && git checkout 7449ea3487d442504a848de448a47d832039f138
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6 ea68b4724cae18fa2c37737426cb97adaccfaf78 && git checkout -B drift-repro 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6 && git merge --no-ff ea68b4724cae18fa2c37737426cb97adaccfaf78

node scripts/docs-audit/affected-docs.mjs --json 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 1fe9c6287f2f058c7d1f1972cdfa4ebcd58803b6 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added size/xl and removed size/l labels Dec 2, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review December 3, 2026 00:58
@os-zhuang
os-zhuang added this pull request to the merge queue Dec 3, 2026
Any commits made after this event will not be merged.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 3, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bob · os-bob · session_012dn2AfG9txpigxdt2zFADB

Contract-review-claim: session_012dn2AfG9txpigxdt2zFADB · head 947790b · 2026-12-03T01:29Z

The merge queue refused this PR because its declared narrowing owes a same-head contract review at CONTRACT_REVIEW_TIER plus an authorized approval. The seat runs the review on this head now.

…a manager that reads no files watches none

Claude-Session: https://claude.ai/code/session_012dn2AfG9txpigxdt2zFADB
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bob · os-bob · session_012dn2AfG9txpigxdt2zFADB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 947790bdd9f06a8e5d5eb537d78dc19953903173
Local-runs: none
Security-touching: yes
Scope: packages/metadata/src/loaders/contained-path.ts, packages/metadata/src/loaders/filesystem-loader.ts, packages/metadata/src/metadata-manager.ts, packages/metadata/src/node-metadata-manager.ts, packages/metadata/src/node.ts, packages/metadata/src/plugin.ts, packages/metadata-fs/src/layout.ts, packages/metadata-fs/src/repository.ts, packages/metadata/src/loaders/database-loader.test.ts, packages/metadata/src/loaders/filesystem-loader-root-confinement.test.ts, packages/metadata-fs/test/item-path-stays-in-root.test.ts, packages/runtime/src/domains/meta-item-read-stays-in-root.test.ts, packages/cli/src/commands/serve-host-config-metadata-door.pin.test.ts, packages/verify/src/harness.quiet-boot.test.ts + read, not reviewed: packages/spec/src/kernel/metadata-plugin.zod.ts, packages/spec/src/kernel/metadata-loader.zod.ts, packages/metadata/README.md, packages/cli/src/commands/serve.ts, packages/runtime/src/standalone-stack.ts, packages/verify/src/harness.ts, packages/cli/src/utils/metadata-file-name.ts, packages/metadata-fs/src/index.ts, .changeset/metadata-file-read-stays-in-root.md

Read on this head: the PR body, the file list (17 paths), the net diff against the merge base 7f72b4945f, and the check-runs. Every check-run on the head concluded success or skipped; none failed (Test Core 1 to 12, Type Check, Lint and repo gates, Check Changeset, Governed Surface Queue Guard, Dogfood battery shards 1 to 3, Build Core, Build Docs, PR-body guards). Nothing was built or run locally.

① Derived judgments

Each accept-set and public-surface change the diff implies, read in the tree:

  • MetadataPlugin default: no file loader. Right. The constructor passes filesystemLoader: bootstrapMode !== 'artifact-only' && options.filesystemLoader === true to its manager, so only the literal true opts in, and artifact-only registers no file loader whatever the option reads. The three shipped compositions (serve.ts two sites, standalone-stack.ts, verify/harness.ts) pass no opt-in and watch: false. This matches the ruling quoted in the body (no file reads without the opt-in, with or without an artifact).
  • Eager priming pass still runs without the opt-in. Right. _loadFromFileSystem walks the registered loaders; with no file loader it primes stored rows only. The database-loader.test.ts edits add the opt-in to rigs that build the plugin and keep or replace its loaders; they change no assertion.
  • NodeMetadataManager default unchanged (filesystemLoader omitted reads files), new false reads none. Right, and stated in the changeset. A manager constructed with its own loaders is unaffected.
  • Type admission. admitsFilesystemType admits a type when the type registry lists it exactly OR the in-memory registry holds an item under it (getRegisteredTypes). The code and its jsdoc agree; the PR body states only the first half. See N3.
  • Name and type accept-set (containedTypeDir, containedItemPath, itemPath). Right against the stated rule: non-empty, relative, no backslash or NUL, no segment that begins with ., is only dots and spaces, or is node_modules; a type is one segment and, in the loader, carries no glob metacharacter. The lexical check is followed by a resolved-inside check. Every type of DEFAULT_METADATA_TYPE_REGISTRY and every filePatterns stem passes it, so no declared type or declared file name is newly refused.
  • Reads resolve links and read the resolved path. Right. resolveStats, exists, probeFile, ownFiles (shared by list and loadManyEntries), and in metadata-fs get, the index build and the external-change handler all go through realPathInside and read the path it returns. The check runs on a remembered resolution too. A caller-supplied patterns entry cannot widen the walk: the walk runs with cwd at the type directory and every match is re-admitted by containedItemPath.
  • Walk output narrows. A file under a type directory whose path has a dot-led segment is no longer listed or loaded, and parseItemPath no longer reports such a file. Right, and consistent: what is listed is what a by-name read can serve.
  • By-name write. FilesystemLoader.save and FileSystemRepository.put/delete refuse a pair the path rule cannot address before any write; put and save also require the nearest existing directory to resolve inside the root. Holds for the directory. FilesystemLoader.save does not yet hold it for the file itself: see S3. An explicit options.path is taken as given, as the changeset says.
  • MetadataManager.typeRegistry private to protected. A published type-surface change (a subclass member of that name now has to be compatible). Additive in practice; not named in the changeset beyond the PR body's acceptance note. Acceptable under a patch here.
  • New exports. NodeMetadataManagerOptions is exported from @objectstack/metadata/node. FilesystemLoaderOptions, the type of the new fourth constructor parameter of the exported FilesystemLoader, is not. See N1.
  • metadata-fs itemPath now answers string | null. Not a public change: index.ts exports only the FsLayout type from layout.ts, and every in-package caller handles null.

② Semver level

patch on @objectstack/metadata and @objectstack/metadata-fs is the level AGENTS.md prescribes: no metadata key, accepted value or metadata type changes, so Metadata-protocol: none is the right kind, and a non-protocol breaking change ships patch with its banner. The changeset and the PR body both carry the line Clause-②: no (narrowing), and it is right: the default the diff changes is a narrowing, and the changeset has the BREAKING banner, the FROM to TO mapping, the one-line migration (move into source and os build, or pass filesystemLoader: true), and one ADR-0087 marker (not-required (runtime-interface-only …)). Check Changeset concluded success on this head. The two new optional options ride the same patch; AGENTS.md ties the level to the protocol kind alone, so that is in policy.

③ Boundary flags

  • Acceptance note, typeRegistry now protected: answered in ①; accepted.
  • Acceptance note, database-loader.test.ts rigs pass the opt-in: answered in ①; accepted.
  • Acceptance note, with no opt-in MetadataManager.save has no saving loader and throws, and the save door still writes through the metadata-fs repository: confirmed in the tree. No non-test caller of MetadataManager.save exists on this head; the repository attaches in every mode but artifact-only.
  • Two gate families the body left NOT MEASURED locally (check-plugin-teardown-shape --self-test, check:dual-build-cjs-loads): the head's lint and build check-runs concluded success; answered by CI.
  • No open_questions entry is raised in the body. None escalated.
  • SQL push-down: the diff touches no query, driver or data path. No new id materialisation and no in-app join. Nothing to find.

④ Design judgment

The question for this face: does the narrowing take a declared capability away at the consumer, or make the spec's own refusal real?

Read against packages/spec on main. The spec declares bootstrap (eager, lazy, artifact-only), MetadataManagerConfig.rootDir and each type's filePatterns. Its schema surface is unchanged by this PR and every value still parses and still runs. Reading loose files stays deliverable (the opt-in on the plugin, the default on a self-built NodeMetadataManager), so no declared capability is removed; a maintainer ruling fixes the default; and artifact-only, which the spec already declares as never reading the filesystem, now registers no file loader at all, which makes that declared refusal real. The path rule narrows only pairs that name no file under rootDir/TYPE/, which no declaration promised. On that reading the narrowing is sound, with three places where the tree does not yet hold what it states:

S1 (should-fix) — The published spec still declares the opposite default. packages/spec/src/kernel/metadata-plugin.zod.ts on this head says of bootstrap: "eager (default) — Scan filesystem and prime every type listed in DEFAULT_METADATA_TYPE_REGISTRY", says of lazy that it "Skip[s] the filesystem priming pass", and says of filePatterns that its glob reader is reached on "eager bootstrap (the default) AND no options.artifactSource". After this PR none of those is true without filesystemLoader: true, an option the spec does not mention. packages/metadata/README.md, which ships in the npm package, repeats it ("eager (default) … Scans filesystem") and shows new MetadataPlugin({ rootDir: './src', watch: … }) as the way to serve files, which now serves none. The consumer changed a default the spec's own text declares; the declaration has to move with it (state the opt-in in the spec jsdoc and the README), in this PR or in a follow-up that lands before the next release. The same stale sentence sits in the comment of packages/cli/src/utils/metadata-file-name.ts.

S2 (should-fix) — With watch: true and no opt-in, a file that is not read as metadata still changes what is served. NodeMetadataManager.handleFileEvent is not gated on the file loader: for any event at rootDir/DIR/…/STEM.EXT it calls invalidateForForeignWrite(DIR, STEM), which deletes the in-memory registry entries of that pair, and then announces a changed/added/deleted event for it. Before this PR the file loader then served the file in the entry's place; now nothing does, so an item that lives only in the in-memory registry is dropped, and subscribers are told an item changed or was deleted, on account of a file the rule says is not metadata. The rule the body states (metadata is served from the artifact and stored metadata; a file counts only on the opt-in) fails for this combination. No shipped composition builds it (all pass watch: false), and the new suite's watch: true case asserts reads only. Either the watcher follows the same switch as the loader, or the event handler does nothing for a manager with no file loader.

S3 (should-fix) — A by-name FilesystemLoader.save holds the resolved-path rule for the directory only. A by-name save must hold the resolved-path rule for the file it writes, its backup and its temp file, not only the directory. The read side already holds it for the file it reads, and the suite's write cases cover directories only. metadata-fs is not affected. Fix: refuse a by-name save whose existing target, backup or temp path does not resolve inside the root.

N1 (nit) — FilesystemLoaderOptions is not re-exported from @objectstack/metadata/node beside FilesystemLoader, while NodeMetadataManagerOptions is. A caller can still pass the object literal. Follow-up.

N2 (nit) — The PR body's maintainer summary asks for approval at "head 4af0a37" and its verification block is measured at 20a1ca5c; the head is 947790bd. Prose face; correct the sha in the body.

N3 (nit) — The PR body says a manager with a type registry reads a directory "only for a type its registry lists exactly"; the code also admits any type the in-memory registry holds an item of. The jsdoc and the changeset ("a type it knows exactly") are accurate; the body is the short one. Prose face.

Tried and held: a name or pattern with .., an absolute or drive-led spelling, a dot-led or dots-only segment, a node_modules segment, a type with a separator or glob characters, a linked file and a linked directory under a type directory on read, a linked or missing directory on write, a root reached through a link, a remembered resolution whose file later changed, a plural type spelling, and all three transports of the item read on all three rigs. Each is refused or served as the rule says, and the suites pin a labelled control beside the refusals.

No must-fix. Three should-fix (S1, S2, S3) are open on this head and each earns a delta review of its fix.

Implemented-by: claude/metadata-file-read-root-rule
Reviewed-by: session_012dn2AfG9txpigxdt2zFADB

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bob · os-bob · session_012dn2AfG9txpigxdt2zFADB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ea68b4724cae18fa2c37737426cb97adaccfaf78
Local-runs: none
Security-touching: yes
Scope: packages/spec/src/kernel/metadata-plugin.zod.ts + packages/metadata/src/loaders/contained-path.ts, packages/metadata/src/loaders/filesystem-loader.ts, packages/metadata/src/node-metadata-manager.ts, packages/metadata/src/node.ts, packages/metadata/src/loaders/filesystem-loader-root-confinement.test.ts, packages/metadata/src/node-metadata-manager-reads-no-files-watch.test.ts, packages/metadata/src/plugin.test.ts, packages/cli/src/utils/metadata-file-name.ts; read, not reviewed: packages/metadata/README.md, .changeset/metadata-file-read-stays-in-root.md

Delta review of 947790bdd9..ea68b4724c (three commits, 11 paths) against the findings of the record on 947790bdd9f06a8e5d5eb537d78dc19953903173. Everything that record judged outside these hunks is unchanged and stands.

Check-runs on this head at the time of reading: Governed Surface Queue Guard, Auto Label, Check PR Size, filter and the PR-body guards concluded success; 9 are skipped; 25 are still in_progress, among them Check Changeset, Build Core, Build Docs, Spec property liveness, all Type Check and Lint jobs, Plan Test Core shards (the Test Core shards have not started) and the three Dogfood battery shards. Their conclusions are the gate verdicts; this record judges the diff and does not stand in for them.

① Derived judgments

  • By-name save, file rule. Right. writableFileInside admits a target that does not exist, or one that resolves inside the root with links followed; a link whose destination does not exist is refused. save applies it to the target and, when a backup is asked for, to the backup path, before anything is written. The temp file takes a fresh random name and is opened exclusive-create, so it never reuses a name a file already holds. An explicit options.path is still taken as given, as declared.
  • Watcher follows the read switch. Right. A NodeMetadataManager built with filesystemLoader: false starts no watcher even with watch: true, and handleFileEvent returns before invalidating or announcing. MetadataPlugin without the opt-in therefore watches nothing; with it, watch: true behaves as before. The existing plugin suite's watcher cases now pass the opt-in, and one new case pins the absent watcher.
  • Export. FilesystemLoaderOptions is now exported from @objectstack/metadata/node. Additive.
  • Published spec hunk (metadata-plugin.zod.ts). Every changed line is inside a jsdoc block or a line comment. No schema key, enum value, default, .describe() string or registry entry moves, so the accept-set and the generated JSON schema are unchanged; only the declaration text carried into the type declarations changes. The new text is right against the tree: eager primes from files only without an artifact source and with filesystemLoader: true; lazy primes nothing beyond an artifact source; artifact-only never reads metadata files; the filePatterns glob is reached only on the opt-in.

② Semver level

Unchanged and still right: patch on @objectstack/metadata and @objectstack/metadata-fs, Metadata-protocol: none, and the Clause-②: no (narrowing) declaration on the body and the changeset. The changeset's two edited sentences match the code (the file rule for a by-name save; no watching without file reads). The delta adds no protocol kind. On the spec hunk see N5.

③ Boundary flags

  • The dev's report that the spec change is comment-only with the schema shape and .describe() strings unchanged: confirmed by reading the hunk. The report that the generated schema is clean is left to the Lint and Build check-runs, still in progress.
  • No new open_questions entry. None escalated.
  • SQL push-down: the delta touches no query, driver or data path.

④ Design judgment

S1: closed
S2: closed
S3: closed
N1: closed

What closed each: for S1, the spec's bootstrap and filePatterns text, the README (mode table, class summaries, the kernel-plugin example now carrying the opt-in) and the CLI comment all state the opt-in. For S2, the watcher and its event handler follow the same switch as the loader; the new suite pins that a held item survives and nothing is announced, with a control for a manager that reads files. For S3, the save holds the resolved-path rule for the target, the backup and the temp file; the new cases cover each, a destination that does not exist yet, and a control that resolves inside the root. N2 and N3 are PR-body prose and are the seat's.

Schema face, judged on its own: the hunk changes what the spec says, not what it accepts, and what it now says is what the first consumer (MetadataPlugin) does. It declares the filesystemLoader option by name while the option itself lives on the plugin's TypeScript options, not in MetadataPluginConfigSchema; that is where the PR put it under the maintainer ruling, and the spec text points at it correctly.

N4 (nit) — A NodeMetadataManager given its own loaders together with filesystemLoader: false and watch: true now watches nothing, though a file loader it was handed still reads. The jsdoc states it ("registers no filesystem loader and watches no files"), and no composition in the tree builds it. Accepted deviation.

N5 (nit) — By the letter of AGENTS.md step 3 (a changeset for anything that publishes) a '@objectstack/spec': patch line is owed: jsdoc ships in the package's type declarations. It changes no version, because @objectstack/spec sits in the same fixed group as @objectstack/metadata and moves with this patch either way, and it changes nothing an author can write or import; its only effect is an entry in the spec CHANGELOG. Add the line on the changeset face, or accept the omission.

No must-fix, no should-fix.

Implemented-by: claude/metadata-file-read-root-rule
Reviewed-by: session_012dn2AfG9txpigxdt2zFADB

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-bob · os-bob · session_012dn2AfG9txpigxdt2zFADB

维护者速读

  • 结论:通过 L1 与达档契约评审(含增量),CI 与完整回归测试全绿,由席位送入合并队列。
  • 用户能看到的变化:散放在项目里按类型命名目录下的元数据文件默认不再读取,需 filesystemLoader: true 开启;开启时按名读写都只在根目录内。
  • 出错会怎样:单个 PR,可直接撤回;迁移方法写在 changeset。
  • 要你做什么:无。维护者已用 os-zhuang 批准,并在项目线程授权“审核之后可以直接落地”(2026-12-03 02:14 UTC)。

ACCEPT — L1 at head ea68b4724cae18fa2c37737426cb97adaccfaf78.

席位核对

  • Shape: @objectstack/metadata + @objectstack/metadata-fs patch changeset, Clause-②: no (narrowing), Metadata-protocol: none, BREAKING line with FROM → TO and migration, one ADR-0087 disposition; spec jsdoc text only.
  • Contract review: record on 947790b (PASS, S1–S3 should-fix) and delta on ea68b47 (S1–S3, N1 closed; no must-fix, no should-fix), both at CONTRACT_REVIEW_TIER, on this PR.
  • Human half: APPROVED review by os-zhuang.
  • Check-runs at this head: 68 success, 12 expected skips, 0 failed; Dogfood battery (opt-in) success.
  • Accepted deviations: N4 (a self-built manager with its own loaders plus filesystemLoader: false watches nothing; documented, no composition builds it); N5 (no @objectstack/spec changeset line for comment-only jsdoc; same fixed release group).
  • Landing: K = 0.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 3, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation needs:dogfood-battery size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants