Skip to content

fix(metadata-protocol)!: the save door refuses every hook with no body, including one with neither a body nor a handler (#21689) - #21706

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-21689-hook-no-body-save-door
Oct 4, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-21689-hook-no-body-save-door

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #21689
Clause-②: no (narrowing)

This carries out triage's ruling on #21689 (comment 5977077883, unlocked in 5977495602): one predicate. The metadata save door refuses any hook with no body, with a named error and the prescription "give it a body". The handler-only refusal that #21658 landed (PR #21686, ced217ca30) is now one case of it. HookSchema is untouched.

What changes

runtimeHookWithoutBodyRefusal in packages/metadata-protocol/src/protocol.ts keeps its name, its one call site in saveMetaItem and its one envelope. Its predicate widens from "a non-empty handler string and no body object" to "no body object". It is the same judgement install-local's collectHooksWithoutBody makes on its own door (hookCarriesBody in packages/runtime/src/app-artifact-handlers.ts).

The PM's mechanism hypotheses, measured (at 1db5322ba2, then rerun on the merged head 15402d98f8)

# Hypothesis Reading
H1 Widen the existing predicate, one function, one call site, one code. Holds. One early return removed, and the message chosen by whether handler names a function. The measured messages read right for both shapes (quoted above; the sweep's failure output below shows the neither text verbatim as the door produced it).
H2 Five suites use a bare hook as their schema-valid probe; report any others. Holds, with two more. With the predicate widened and every probe untouched, the full metadata-protocol suite went 7 failed / 3461 passed (4 files), and the full objectql suite went 6 failed / 7446 passed (3 files). The five named suites, plus metadata-protocol protocol.save-receipt-wording and objectql metadata-validation-sweep. A grep of runtime, rest, plugins/*, services/*, cli, verify, qa and examples/** for hook saves through this door (type: 'hook' items, /meta/hook paths) found only runtime's two pin tests, which already carry bodies. See the fixture triage below.
H3 migrateStoredMetadata and duplicatePackage surface a stored bare row as their recorded failure; stored rows keep their bytes. Holds. Measured with a one-off harness that is not committed (the stub engine of protocol.stored-residue-resave.test.ts). duplicatePackage over a package holding one bare hook row and one body hook row answered { success: false, copiedCount: 1, failedCount: 1 } with this refusal in failed[0].error, and the source rows' bytes were unchanged. migrateStoredMetadata({ apply: true }) over a bare row answered { scanned: 1, canonical: 1, rewritten: 0, failed: 0 } with the bytes unchanged. Population of stored bare hooks reachable from this repository: zero. examples/** and packages/qa/** seed no sys_metadata hook rows (zero type: 'hook' items).
H4 A built artifact's handler hook never passes saveMetaItem. Holds at 1db5322ba2. Every production call site either saves a fixed type other than hook (automation.ts and flow-credential-migration.ts for flow, packages.ts for app, permission-set-projection.ts for permission) or forwards an author's or a stored row's type. The forwarding callers are the REST PUT /meta/:type/:name (rest-server.ts), the dispatcher's metadata save (domains/meta.ts), migrateStoredMetadata and duplicatePackage. AppPlugin, loadArtifactBundle, the install-local door and the boot path make zero saveMetaItem calls. The composed pin's X and Z controls hold it end to end.
H5 No first-party authoring path emits a hook with neither field through this door. Holds for what this repository holds. os meta register forwards the author's own file and emits no hook of its own. The os create and scaffold templates author defineStack sources, which reach the artifact door and never this one. packages/mcp has no hook tool. Studio is at the objectui pin ab18797215, unchanged since #21658's census, which read its hook skeleton carrying a body. Not measured: the cloud AI build agent's metadata tools, which live outside this repository.

Fixture triage: seven probe suites move to a body-carrying hook

Each probe item gains body: { language: 'js', source: 'return;' } and nothing else. No probe is deleted, and no assertion is changed or loosened.

Suite What the probe measures Still measures it
metadata-protocol protocol.code-only-types (2 probes) The #5086 code-only gate does not catch hook (allowRuntimeCreate only) on either kernel; the #5264 matrix shows a hook save answers a repository receipt. Yes: success: true and one row on both kernels, and the receipt fields.
metadata-protocol protocol.meta-types-mint-door-agreement PUT /meta/hook behaves as /meta/types advertises (declared, creatable), read off one fact. Yes: both cases are green.
metadata-protocol protocol.unrecognised-meta-type A declared runtime-create-only type still saves past the unrecognised-type refusal. Yes.
objectql overlay-precedence (3 probes: hook, plural hooks, single-kernel bypass) The two-tier verdict: brand-new items of allowRuntimeCreate types pass the overlay whitelist, and a single kernel bypasses the overlay gate. Yes.
objectql protocol-meta (3 probes) The PR-10d.7 two-tier model: an artifact-backed hook is refused NOT_OVERRIDABLE / 403; a brand-new hook and an edit of a DB-only hook are accepted. Yes. The NOT_OVERRIDABLE probe was green before the move too, because the provenance gate runs first. It moved anyway, so that the refusal it measures can only be the provenance gate's. The registry-seeded items there are scenery for provenance, not saves through the door, and keep their bytes.
Beyond the five: metadata-protocol protocol.save-receipt-wording (OVERLAYLESS_PROBES.hook) The receipt sentence for a brand-new overlay-less type. Yes.
Beyond the five: objectql metadata-validation-sweep (FIXTURES.hook) Valid gets 200; invalid gets the schema's 422 naming events. Yes. The invalid fixture carries the body too, so it stays the valid fixture minus the one field the schema must name.

The enumeration pin, on the real door (ADR-0112: each refusal asserts code and status)

Composed kernel, packages/runtime/src/hook-handler-package-scope.pin.test.ts, through PUT /api/v1/meta/hook/NAME as the signed-in administrator:

Pin Case Asserts
1. A body hook saves. ②b (existing) 2xx; it binds and runs, and so does one with both fields.
2. A handler-only hook is refused. ② (existing) 400 VALIDATION_ERROR, naming the hook and the function and prescribing a body; GET by name answers 404.
3. A hook with neither field is refused. ②c (new) 400 VALIDATION_ERROR, naming the hook and prescribing a body; GET by name answers 404.
(2 and 3) Nothing bound. "② and ②c nothing bound" (widened) After ②b's re-sync, the binder recorded no refusal of either hook and no skip of the bare one (skipsOf, a new reader of the engine logger's skipping hook warns).
4. A built artifact's handler hook through its own door is unchanged. X and Z controls (existing) App X's hook naming its own functions entry binds and runs. App Z's hook naming a function its --artifact runtime module exports binds and runs.

At unit level, section 8 of protocol.invalid-metadata-422-face-inventory.test.ts is new. It covers publish and draft with neither field, and an empty handler. Each case asserts code, status, the named hook, the prescription and an empty store. Section 7 (#21658) is unchanged and still green.

Reverse verification (the fix committed first, at 0c32c32bb1)

Mutation. node scripts/ablation-replace.mjs restored the old handler-only guard after the body test: typeof hook.handler !== 'string' || hook.handler === '' returns undefined, behind a marker constant ABLATED_21689_NEITHER. The anchor count went 1 to 0 and the blob went 3059168d5703 to 237d2559c48b. @objectstack/metadata-protocol was rebuilt, and node scripts/ablation-dist-preflight.mjs @objectstack/metadata-protocol ABLATED_21689_NEITHER found the marker in dist/index.js and dist/index.cjs. A shell trap restore on EXIT, INT and TERM wrapped the whole run.

The first attempt was a no-op, and it is disclosed here. Its replacement re-contained the anchor line, so ablation-replace refused it ("the anchor count moved 1 to 1"), ran nothing and proved the restore. The second attempt re-spelled the body test (typeof hook.body === 'object' && hook.body, the same truth table), so the anchor left the file.

Prediction: pin 3 red, and pins 1, 2 and 4 green. Observed:

  • Unit (src), sections 4 to 8: 3 failed, all three section 8 cases (publish neither, draft neither, empty handler). 15 passed, including all of section 7 (handler-only refused in both modes, the body CONTROL, body beside handler, malformed body 422).
  • Composed (dist):
    • ②c failed. It received { status: 200 } with Saved hook 'scope_authored_bare' (env-wide, state=active).
    • "② and ②c nothing bound" failed. skipsOf('scope_authored_bare') held 3 binder skips, which also proves the new reader fires.
    • ① ✓, X control ✓, Z control ✓, ② ✓ and ②b ✓: 2 failed, 5 passed.

Restore.

  • ablation-replace restored the file. The blob equals HEAD (3059168d5703) and git diff HEAD is empty. The outer trap's hash compare agreed.
  • Whole-tree git status --porcelain is empty.
  • After a rebuild, the --absent preflight found the marker in none of the 24 built files, and the tree was clean.
  • The reruns are green: 26/26 (face inventory) and 7/7 (composed).

Tests (at 15402d98f8, after merging origin/main 8843505d91, which carries PR #21693)

  • pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2: 210 files passed and 3 skipped; 3578 tests passed and 19 skipped.
  • pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 --project local: 372 files and 7455 tests passed.
  • Runtime hook-handler-package-scope.pin.test.ts and stored-metadata-body-boundary.pin.test.ts: 14/14.
  • Typecheck, exit 0 for all three packages:
    • metadata-protocol tsc --noEmit. Its program includes all five edited test files (--listFiles, one hit each).
    • objectql and runtime: tsc plus check:test-typecheck, OK, with the debt ledgers held. Their test layers compile under tsconfig.test.json (include: src/**/*).
  • Dependency closure: pnpm turbo run build --filter='@objectstack/runtime^...' --concurrency=2, 29/29. packages/spec moved on main's side, so pnpm --filter @objectstack/spec check:generated also ran: all 15 generated artifacts are up to date.
  • The rest of packages/runtime's suite is declared to CI.

Gates (at 15402d98f8)

Every family below ran first at 623b4a0b94 and ran again in full on the merged head 15402d98f8. The figures are the second run's.

Derived. node scripts/pm/dispatch-gates.mjs --commands (no paths) derives 66 families, the same list on both heads, and all 66 ran.

  • All 66 exited 0. That includes check:dual-build-cjs-loads: 106 published require entry points across 66 packages load. On the first head it had exited 3, PREREQUISITE NOT MET, for want of a full build.
  • --ran reconciliation: 66 accounted for, 66 run, 0 NOT-MEASURED (a derived zero), 0 UNRUN.

Artifact-roster block (54 families, outside the derived total). All 54 ran.

  • 51 exited 0. These include check:error-status-conformance, check:error-code-casing, check:authz-resolver, check:route-ledger-census, check-changeset-fixed and check:engine-double-contract.
  • 3 exited 2, NOT WIRED without PR context: check-closing-target-claim, check-partof-closing-keyword and check-single-claim-paths. They are rerun with this PR's context, and the results go in the os-dev report.

Symbol-anchor sweeps, all exit 0:

  • check:adr-symbol-anchors: 2167 anchors across 140 records.
  • check:scripts-symbol-anchors: 3760 anchors across 282 scripts.
  • check:spec-docblock-symbol-anchors: 4867 anchors across 1861 spec sources.
  • check:adr-anchors: OK.

Lint. CI owns pnpm lint. This PR records a proven narrowing instead:

  • Population: eslint.config.mjs lints files: ['**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'].
  • Count: eslint --no-inline-config --format json over the 10 changed TS files reports 10 files, 0 errors and 0 warnings.
  • Invariance: the config enables no type-aware linting (no parserOptions.project), so this diff cannot move the verdict of any untouched file.

Changeset

.changeset/21689-hook-no-body-save-door.md: minor for @objectstack/metadata-protocol, Clause-②: no (narrowing), the BREAKING banner, and the ADR-0087 marker not-required (no-migration-prescription) with the census above. check-adr-0087-registration --base origin/main accepts it.

Landing point

As the claim predicted: packages/metadata-protocol/src/protocol.ts, runtimeHookWithoutBodyRefusal (saveMetaItem, type hook), plus the seven probe suites. No producer elsewhere needs a change. No governed surface is touched. PR #21693, which edits the read region and the import block of protocol.ts, landed on main before this PR opened. It is merged in here; the merge was clean, and this diff touches neither region.

Acceptance notes


Generated by Claude Code

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol, touching 2 documentable anchor(s).

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

  • content/docs/concepts/metadata-lifecycle.mdx (via saveMetaItem (symbol, a method of class ObjectStackProtocolImplementation))
  • content/docs/deployment/validating-metadata.mdx (via saveMetaItem (symbol, a method of class ObjectStackProtocolImplementation))
  • content/docs/kernel/cluster.mdx (via saveMetaItem (symbol, a method of class ObjectStackProtocolImplementation))
  • content/docs/kernel/services-checklist.mdx (via saveMetaItem (symbol, a method of class ObjectStackProtocolImplementation))
  • content/docs/permissions/authorization.mdx (via saveMetaItem (symbol, a method of class ObjectStackProtocolImplementation))
What this run could not see
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 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 — 11 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 16d241a6af00be4acce9883190fc333a5f560825 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8889850e9246d840185c39e6f5c672a9d5e42417 — the merge of head 15402d98f8760f77e30a3058208925c460035ba6 into base 16d241a6af00be4acce9883190fc333a5f560825, 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 8889850e9246d840185c39e6f5c672a9d5e42417 && git checkout 8889850e9246d840185c39e6f5c672a9d5e42417
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 16d241a6af00be4acce9883190fc333a5f560825 15402d98f8760f77e30a3058208925c460035ba6 && git checkout -B drift-repro 16d241a6af00be4acce9883190fc333a5f560825 && git merge --no-ff 15402d98f8760f77e30a3058208925c460035ba6

node scripts/docs-audit/affected-docs.mjs --json 16d241a6af00be4acce9883190fc333a5f560825

⚠️ 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 16d241a6af00be4acce9883190fc333a5f560825 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

ACCEPT — PR #21706 at head 15402d98f8

domain:engine#1 · session_017ErfyP2Rx7XWHJA27QjyUi · read at 2026-10-04T08:26Z. The os-dev report is on #21689. Judged against GitHub and the branch, not against the report.

  • Shape: draft, base main, assignee os-project-manager.

    • The first lines are Fixes #21689 and Clause-②: no (narrowing).
    • The closing-keyword scan finds #21689 only. #21658, #21686, #21693, #5086 and #5264 appear in the body with no verb next to them.
  • Scope: 11 files, +202/-54:

    • protocol.ts, one helper's predicate and message;
    • seven probe suites;
    • the 422 face inventory and the composed pin;
    • the changeset.

    NOT governed. No packages/spec file is touched. A local git merge-tree against origin/main is clean. PR fix(metadata-protocol): the read envelope's lock / editable / deletable report the write doors' locked-base verdict #21693 is merged in, and its regions are untouched.

  • The diff, read: one predicate, as ruled.

  • Fixtures: seven suites, the five triage named plus protocol.save-receipt-wording and metadata-validation-sweep, found by running the widened predicate.

    • Each probe item only gained body: { language: 'js', source: 'return;' }, with a comment saying what the suite still measures.
    • The seat read every hunk: no expect line was removed or changed.
    • metadata-validation-sweep's invalid case still lacks events, so it still measures the schema refusal.
    • protocol-meta's NOT_OVERRIDABLE probe was moved too, so the refusal it measures can only be the provenance gate's. Accepted.
  • Pins: the enumeration, on the real door.

    • The composed kernel's PUT /api/v1/meta/hook/NAME: ② handler-only refused, ②c neither refused ({ status: 400, code: 'VALIDATION_ERROR' }, by-name GET 404), and ②b body saves. Neither refused hook reaches the binder after the re-sync.
    • The X and Z controls hold the artifact door unchanged.
    • The 422 face inventory asserts { code, status } for both shapes in draft and in publish mode (ADR-0112).
  • Reverse verification: the old handler guard was restored behind a marker, and the dist preflight found it in the built files. Exactly the neither-shape cases went red (3 unit cases, plus ②c and the nothing-bound case composed), and the rest stayed green. The restore was proved by blob equality, an empty git diff HEAD and status, and an --absent preflight.

  • Clause-②: no (narrowing) — accepted. The door refuses one more shape it used to answer 200. Nothing widens, no code is added, and there is no path leg, so no contract review is owed.

  • Changeset, checked sentence by sentence:

    • minor, the BREAKING banner, and adr-0087: not-required (no-migration-prescription) with its census.
    • "One rule … the same envelope and the same message" matches the code.
    • "Before and after" matches pin ②c.
    • "What still saves" matches ②b and the both-fields case.
    • "What is unchanged" matches HookSchema and the artifact door, held by X and Z.
    • "Rows stored before" matches the dev's one-off H3 readings: duplication copied 1 and failed 1, and the stored migration left the row canonical and unchanged.
  • Census:

    • H2: 7 probe suites.
    • H3: 0 stored bare hooks reachable.
    • H4: forwarding callers only.
    • H5: 0 first-party emitters of the neither shape in this repository. The cloud AI build agent is NOT MEASURED, which the changeset states.
  • Evidence: metadata-protocol passes 3578 tests, objectql 7455, and the runtime pins 14 of 14. Typecheck exits 0 for all three packages, with the ledgers held.

  • Gates:

  • Deviations — accepted: seven suites rather than five, the probe moved for clarity, one no-op ablation attempt that the tool refused, two merges of main, and the attribution following AGENTS.md.

  • CI: read by the seat at landing. The seat lands only once every check is green or an expected skip.

Out-of-scope findings — Acceptance notes, not filed: none has a measured public-door reach.


Generated by Claude Code

@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 37190715356 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

失败的 job(日志抽取,best effort):

  • Console Pin Gate — 失败步骤: Build the Console SPA at the pinned objectui SHA

    ✗ Built console still carries the PUBLISHED @objectstack/spec.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • ⚠️ 本次没有可用的聚合签名(日志里没有能解析出测试文件名的 FAIL 行)—— 这不是「没有同签名的其他 PR」,是这一轮没测到。跨 PR 聚合本次不可用,请手工比对其他 PR 的同类评论。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 6 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

akarma-synetal pushed a commit to akarma-synetal/framework that referenced this pull request Oct 7, 2026
…t blocks[i].dataset, naming the block (objectstack-ai#21702) (objectstack-ai#21712)

Fixes objectstack-ai#21702
Clause-②: yes (narrowing)

Triage direction `5977861131` (enforce), claim `5977924610`. The joined
arm of `ReportSchema`'s refinement now refuses each block of a `joined`
report that binds no `dataset`, at `blocks[i].dataset`, naming the
block, with the prescription to bind the block to a dataset. The
refinement comment "each block dataset-bound" and the reports guide's
type-table cell "(each block dataset-bound)" were declarations; they are
now enforced.

## What changes

- **The refusal** (`packages/spec/src/ui/report.zod.ts`). A per-block
arm inside the joined branch of `ReportSchema`'s `superRefine`, right
after the existing "needs `blocks`" check. For each block whose
`dataset` is undefined it adds one `custom` issue at `['blocks', i,
'dataset']`. The message comes from a module-private builder,
`joinedBlockDatasetRequired`, worded like the neighbouring joined
refusals:

  ```text
a `joined` report draws each block from that block's own `dataset`, and
block `NAME` binds none, so nothing queries it and it draws no rows.
Bind the block to a dataset: set its `dataset` to the dataset whose
measures (`values`) and dimensions (`rows`) it shows.
  ```

`NAME` is the block's `name`. A block whose `name` is empty (its own
`too_small` issue, which does not stop the refinement) is named by
position instead, as `blocks[1]`.
- **What stays accepted.** `JoinedReportBlockSchema.dataset` stays
`.optional()`: `blocks` is read on a `joined` report only, so the
requirement lives on the joined arm, and a block on a non-joined report
is not judged (pinned). No type, export or JSON Schema key changes. The
block's `dataset` `.describe()` now reads "Dataset name to bind
(ADR-0021); a joined report refuses a block without one", and
`content/docs/references/ui/report.mdx` is regenerated with `gen:docs`
(two table rows).
- **The ADR-0087 kit**, in objectstack-ai#21687's shape:
- the D3 semantic entry
`entries/semantic/18.ui-report-joined-block-dataset-required.ts`;
- its step-18 rationale fragment in `STEP18_RATIONALE` at **order 77**,
inserted where its id sorts. 77 is the next free order: the highest on
`main` is 76, re-read at `7e0066af7a` just before this PR. objectstack-ai#21699 (74 to
76) and objectstack-ai#21698 landed before this branch's base `16d241a6af`, so no
merge was needed;
  - `registry.ts` regenerated with `gen:migration-registry`;
- one BREAKING `@objectstack/spec` `minor` changeset,
`.changeset/21702-joined-report-block-dataset-required.md`, carrying the
`Clause-②` line, the `adr-0087: registered
ui-report-joined-block-dataset-required` disposition marker and a FROM →
TO table.

The fragment and entry text state each decision in words and carry no
tracker number. No tombstone (no key is removed) and no D2 conversion
(only the author knows which dataset a block was meant to show).
- **`content/docs/ui/reports.mdx`: no edit.** No sentence there became
false; the type-table cell became true. See Acceptance notes.

## Census, at base `16d241a6af`, before any edit

`git grep` for a `type: 'joined'` report across `examples/**`,
`packages/**`, `skills/**`, `content/docs/**`, `docs/**`, `scripts/**`
and `apps/**` gave 33 lines in 15 files: CHANGELOG quotations, the
spec's own comments, and these reports:

| where | joined reports | unbound blocks |
|:--|:--|:--|
| `examples/app-showcase` `TaskOverviewReport` | 1 | 0 |
| `content/docs/ui/reports.mdx` example | 1 | 0 |
| `packages/lint` `validate-chart-bindings.test.ts` (raw stacks, never
parsed) | 4 | 0 |
| `packages/platform-objects` `report-form-echo-decisions.test.ts` | 2 |
0 |
| `packages/spec` tests (`report.test.ts`,
`filter-save-door-face-parity.test.ts`,
`joined-report-block-type.test.ts`) and the
`report-joined-chart-removed` conversion fixture | 10 | 0 |
| `packages/metadata-protocol`
`protocol.invalid-metadata-422-face-inventory.test.ts` | 1 | **1**,
unbound on purpose (below) |
| `skills/**` | 0 | 0 |

- Triage measured hotcrm `4054ec26` (1 joined report, 0 unbound blocks)
and cloud `2205b530` (none). I took those readings as given. I read
hotcrm's `src/sales/reports/churn.report.ts` once, to shape the
preservation fixture. Every block binds a dataset: three bind
`account_metrics` and the fourth, `recently_closed_lost`, binds
`opportunity_metrics`. So triage's line "every block binds
`account_metrics`" is slightly off; its conclusion, zero unbound blocks,
stands.
- **objectui (read only, at `2e818d0b51` and at this repo's pin
`ab18797215`).** Studio's joined-report authoring **can** save a block
with no `dataset`. That producer is this narrowing's reach:
- `ReportDefaultInspector.tsx` renders the blocks through `SchemaForm`
with the spec `reportForm` "Joined blocks" repeater;
- `RepeaterField`'s `add()` seeds a blank row with every column
`undefined`;
- the row's `dataset` column is free text and not required (the block's
derived JSON Schema `required` is `["name"]`, measured);
- the bundled `ReportSchema` (`clientValidation.ts`) and the save door
both accepted the result.

Filed as objectstack-ai/objectui#11601: category ①, no labels, dedupe
query and hit count in its body. After the spec bump, Studio's live
validation and the save door both refuse such a block at
`blocks.N.dataset`.
- The renderers, at the pin: `DatasetReportRenderer`'s joined branch
passes `String(block.dataset ?? '')` to each block's table, and that
table's query hook goes idle on an empty name (`:443`). A report whose
blocks all lack one fails `isDatasetReport` and falls through to the
presentation bridge. `DrillDownDrawer`'s `isDatasetBoundReport` lists
the records instead of drawing it.

## Fixture triage: one test-only file outside the claim's file surface

`protocol.invalid-metadata-422-face-inventory.test.ts` section 5 (the
joined-report `chart` door pins) left its block **unbound on purpose**:
the door's author-time gate refuses an unresolvable dataset with
`chart-dataset-unknown`, and the stub engine had no dataset universe.
The new refusal turned 2 of its 23 tests red (`Tests 2 failed | 21
passed`): the container case got a second issue at `blocks.0.dataset`,
and the CONTROL was refused at `blocks.0.dataset`. That second red is
the metadata save door (`422 INVALID_METADATA`, `writeFace:
'meta-envelope'`) refusing the probe shape.

- **Disposition: add the declaration.** The block binds `task_metrics`,
and the harness gains an optional `makeProtocol({ datasets })`, which
registers that dataset through `registry.listItems('dataset')`. Every
other caller passes nothing, so the registry lists nothing, as before.
Result: `Tests 23 passed (23)`.
- **The registration is load-bearing.** I mutated the CONTROL to call
`makeProtocol()` without datasets (`scripts/ablation-replace.mjs`,
anchor 1 → 0, blob `f718099c2d` → `9dc51bd7b8`). Predicted 1 red / 22
green; observed `Tests 1 failed | 22 passed`. The failure was
`chart-dataset-unknown` at `reports[0].blocks[0].dataset`, "Declared
datasets: (none)". Restore: blob back to `f718099c2d`, which equals
HEAD, and `git diff HEAD` is empty.
- This file is outside the claim's declared file surface. It is reported
in the dev report as a deviation.
- Queue check: objectstack-ai#21706, queued at this writing, appends a section to the
same file at line 570 and later. A local `git merge-tree` of this head
with that queue head exits 0. The file is not `merge=os-regen` routed,
so that local answer is also GitHub's.

## Doors, tested and probed

- **Pins** (`packages/spec/src/ui/report-joined-block-dataset.test.ts`,
16 tests):
- the triage probe shape is refused once per block at `blocks.0.dataset`
and `blocks.1.dataset`, each naming its block; a bound block beside an
unbound one draws one issue, at the unbound index; an empty name is
named by position;
- the new issue joins the other joined-arm refusals rather than
replacing them;
  - taking the advice parses;
- CONTROLS: a block on a non-joined report, and
`JoinedReportBlockSchema` parsed on its own, both still parse;
- doors: `defineReport` throws; the registered `report` type schema
refuses (and accepts the bound report); `ObjectStackDefinitionSchema`,
the stack parse `objectstack validate` runs, refuses at
`reports.1.blocks.{0,1}.dataset`; `defineStack` answers
`STACK_SCHEMA_INVALID` / 422;
- preservation: the showcase `TaskOverviewReport` (mirrored byte for
byte) parses with output equal to its input, and a fixture shaped like
hotcrm's `customer_churn_signals` parses, gaining only the `drilldown`
default;
- ledger: one D3 entry at protocol 18 with no conversion; the step-18
rationale names it; no `JoinedReportBlock:dataset` tombstone, with a
control on a known tombstone.
- **`objectstack validate`, the real CLI** (`packages/cli/bin/run.js`,
built here). Fixtures were temporary, in the session scratchpad, outside
the repo; `@objectstack/spec` resolved to this worktree's build.
- The triage probe stack (two blocks, each only `name` + `label`):
**exit 1**, `"code": "STACK_SCHEMA_INVALID"`, `defineStack validation
failed (2 issues)` at `reports.0.blocks.0.dataset` and
`reports.0.blocks.1.dataset`, each with the message above.
- CONTROL, the same report with both blocks bound to a declared dataset:
**exit 0**, `"valid": true`.
- The showcase app (`examples/app-showcase/objectstack.config.ts`, four
reports including `TaskOverviewReport`): **exit 0**, `"valid": true`.
- **The CLI door's verdict is this arm's, proven through `dist`.** The
CLI reads `@objectstack/spec` through `dist`, so the mutation was
rebuilt:
- mutated leg: the `ctx.addIssue` of the new arm became a `globalThis`
marker assignment (anchor 1 → 0, blob `fadd536165` → `2cbfdb9feb`);
`@objectstack/spec` rebuilt; `ablation-dist-preflight.mjs` found the
marker in `dist` (exit 0); the probe then gave **exit 0**, `"valid":
true`. That reproduces the card's reading at `main`;
- restore leg: blob back to `fadd536165`, which equals HEAD, and `git
diff HEAD` is empty; rebuilt; `--absent` found the marker in none of 228
built files (exit 0); the probe gave **exit 1** `STACK_SCHEMA_INVALID`
again.

## Ablation of the refusal, at the pins (predicted first)

`scripts/ablation-replace.mjs` replaced the arm's `ctx.addIssue(...)`
with a no-op (anchor 1 → 0, blob `fadd536165` → `45f34370c5`). The pins
import `./report.zod` relatively, which resolves to `src`, so no build
was needed. Predicted: 8 red, the 4 refusal pins and the 4 door pins; 8
green, the advice, the 2 controls, the 2 preservation pins and the 3
ledger pins; `report.test.ts` untouched. Observed: `Tests 8 failed | 80
passed (88)` over the pin file and `report.test.ts`. The 8 were exactly
the predicted ones. Restore: blob equals HEAD (`fadd536165`), and `git
diff HEAD` is empty.

## Verification (all at head `c4e3ab9631` unless noted)

- `@objectstack/spec` full suite (`vitest run --project local
--maxWorkers=2`): `Test Files 613 passed (613)`, `Tests 18201 passed | 1
todo`.
- `pnpm --filter @objectstack/spec typecheck` (tsc, scripts, test layer:
`check:test-typecheck: OK`) and `pnpm --filter
@objectstack/metadata-protocol typecheck`: exit 0. `--listFiles` shows
both edited test files in their programs.
- Consumers that parse a joined report: `platform-objects`
`report-form-echo-decisions.test.ts` 35 passed; `lint`
`validate-chart-bindings.test.ts` 47 passed;
`@objectstack/example-showcase` whole suite `32 files, 399 passed`;
`metadata-protocol` face-inventory 23 passed.
- `pnpm --filter @objectstack/spec check:generated`: one artifact stale
before regeneration (`content/docs/references/**`), regenerated with
`gen:docs`; then `check:generated` exit 0.
- Derived gates: `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 115 commands. Every one was run,
with its exit code recorded before any pipe. `--ran` reconciled **115
derived, 115 run, 0 NOT-MEASURED, 0 UNRUN**.
- Two first exited 3 (prerequisite not met, packages with no `dist`):
`check:skill-examples` and `check:dual-build-cjs-loads`. Both were
re-run green after building those packages. All 115 exited 0.
- Among them: `check:adr-0087-registration`, `check:changeset-no-major`,
`check:migration-registry`, `check:spec-changes`, `check:upgrade-guide`,
`check:authorable-surface`, `check:api-surface`, `check:docs`,
`check:doc-authoring`, `check:issue-citations`, `check:nul-bytes`,
`check:cross-package-test-inputs`.
- eslint, narrowed and proven:
1. population: `eslint.config.mjs`'s `**/*.{ts,…}` block covers all five
changed `.ts` files;
  2. `--format json`: 5 files, 0 errors, 0 warnings;
3. invariance: the config enables no type-aware linting (no
`parserOptions.project`, as its own comment states), so this diff cannot
move a verdict on an untouched file.

  The repo-wide `pnpm lint` is CI's.
- Declared to CI: the path-scheduled jobs (Test Core shards, Dogfood,
Temporal Conformance, Build Core), the whole-workspace type-check lanes
and every downstream consumer suite of `@objectstack/spec` beyond the
four above.

## Acceptance notes (observations, not filed)

- `reports.mdx` says a `joined` report "must declare at least one
block". That is still true, but it no longer names every requirement:
each block must now also bind a `dataset`. Not edited, under the claim's
rule that only a sentence this change makes false is edited. Carrier:
none.
- The block row in the spec's own `reportForm`
(`packages/spec/src/ui/report.form.ts`, "Joined blocks" repeater) offers
`dataset` with no `ref:dataset` widget and no `required`.
objectstack-ai/objectui#11601 names this as a possible spec-side fix for
the Studio producer, to be measured first. Carrier:
objectstack-ai/objectui#11601's acting seat.
- The requirement is a refinement, so the published JSON Schema does not
carry it. `ui/Report` already sits in
`dropped-refinements.baseline.json`, and the new arm adds no site there.
The `.describe()` text is now the JSON-Schema-visible hint.
- The joined arm, this check included, does not run while a block
carries an unknown key or a wrong-typed member: that issue aborts the
refinement. The dataset refusal then arrives after that first issue is
fixed. This is existing behaviour shared by every arm of the refinement.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01T9u38rswFp5Rw8DswRUReJ)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
akarma-synetal pushed a commit to akarma-synetal/framework that referenced this pull request Oct 7, 2026
… instead of a tracker number (stage 10) (objectstack-ai#21713)

Part of objectstack-ai#20749
Clause-②: no

Stage 10 of this card, and the first area of class (e): the test strings
shipped under `packages/spec/src`, as ruled in `5902360492` on objectstack-ai#20513.
This stage takes the whole `automation/` directory. Its 105 test-title
and test-message literals carried 110 tracker ids citing 55 records.
Each id now either states what its record decided, in words (form D), or
is dropped where the title already says it. Text only: no assertion,
fixture value, test count or code comment changes.

## Census at the base (`7e0066af7a`, the claim's base)

Instrument: stage 9's `census.cjs` (md5
`6e42a45a926d375013c32d62f16a296e`, byte-identical), plus one added
classification pass. A literal counts as a test title when its folded
message is argument 0 of a `describe` / `it` / `test` call, `.each` /
`.skip` / `.only` chains included. Everything else is an "other" string.

Reference: the same instrument reads **1803 messages / 1919 ids in 425
files at `9b8c7f38d7`**, stage 9's reading exactly. Since then, objectstack-ai#21699
added 1 / 1 (`ui/component-props-unknown-members.pin.test.ts:143`) and
objectstack-ai#21700 moved 3 / 3 (the two reader literals it re-anchored), which gives
1801 / 1917 at the base.

| directory | files | titles msg / ids | other msg / ids | total msg /
ids | excluded files |
|:--|--:|--:|--:|--:|:--|
| `data/` | 95 | 445 / 475 | 23 / 26 | 468 / 501 | |
| `ui/` | 81 | 374 / 397 | 18 / 18 | 392 / 415 | `report.test.ts` 3 / 3
|
| `api/` | 40 | 181 / 193 | 8 / 8 | 189 / 201 | |
| `system/` | 34 | 128 / 138 | 26 / 27 | 154 / 165 | `job.test.ts` 4 / 4
|
| (files directly in `src/`) | 30 | 117 / 119 | 1 / 1 | 118 / 120 | |
| **`automation/`** (this PR) | 21 | 101 / 106 | 4 / 4 | **105 / 110** |
|
| `kernel/` | 36 | 92 / 96 | 10 / 10 | 102 / 106 | |
| `shared/` | 21 | 73 / 81 | 12 / 14 | 85 / 95 | |
| `contracts/` | 25 | 59 / 70 | 4 / 4 | 63 / 74 | |
| `conversions/` | 9 | 34 / 34 | 0 | 34 / 34 | |
| `security/` | 8 | 28 / 28 | 0 | 28 / 28 | |
| `ai/` | 9 | 13 / 15 | 5 / 5 | 18 / 20 | |
| `identity/` | 6 | 14 / 14 | 1 / 1 | 15 / 15 | |
| `integration/` | 4 | 13 / 13 | 1 / 1 | 14 / 14 | |
| `migrations/` | 2 | 9 / 12 | 0 | 9 / 12 | |
| `marketplace/`, `meta-spelling/`, `studio/` | 5 | 7 / 7 | 0 | 7 / 7 |
|
| **total** | **426** | **1688 / 1798** | **113 / 119** | **1801 /
1917** | 7 / 7 |

- **Excluded, in flight under this seat:** `system/job.test.ts` carries
objectstack-ai#16292 (`:92`), objectstack-ai#14478 (`:471`), objectstack-ai#4667 (`:836`) and objectstack-ai#19184 (`:881`), and
`ui/report.test.ts` carries objectstack-ai#20161 (`:233`), objectstack-ai#3916 (`:334`) and objectstack-ai#5013
(`:426`). All seven sit in titles. They wait for a later stage, after
objectstack-ai#21703 and objectstack-ai#21702.
- **Controls.** Lit, single line: `automation/approval.test.ts:135`
reads one title with objectstack-ai#3508. Lit, multi-line:
`api/discovery-environment-subset.pin.test.ts:63-66`, a `+` chain, reads
as ONE message with its id on `:65`. Dark: the `// objectstack-ai#3508` comment at
`automation/approval.test.ts:131` reads 0. Planted in a scratch copy of
the head file: an id in a title reads 1 / 1, and an id in a comment
reads 0.
- **A wider pattern** (any `#` plus digits, so two-digit and six-digit
numbers too) reads the same 105 / 110 in `automation/` at the base, and
0 / 0 at the head.
- **At the head:** 1696 messages / 1807 ids in 405 files. `automation/`
reads 0 / 0. Nothing else moved.

## How the area was chosen

The directories are ranked by id count, and a stage takes whole
directories up to about 100 ids. The four busiest each exceed that bound
alone: `data/` (501), `ui/` (415), `api/` (201) and `system/` (165). The
files directly in `src/` (120) are 20% over. `automation/` (110) is the
busiest whole directory within about 10% of the bound, so it is this
stage. The rule picked it before any card was read.

Its 55 records (53 in this repository, 2 in objectui) were all readable
in one pass. 54 answer 200. objectstack-ai#6362 answers 404, and its decision was read
from its landing commit `b5404f496`.

**Named for the next stages** (by directory, from the table): `data/`
(about five stages, by subdirectory or file group; `data/driver/` alone
is 52), `ui/` (about four), `api/` (two), `system/` (two), the files
directly in `src/` (one), `kernel/` (one), `shared/` (one), `contracts/`
with `conversions/` (one, 108), and `security/`, `ai/`, `identity/`,
`integration/`, `migrations/`, `marketplace/`, `meta-spelling/` and
`studio/` together (one, 96). The seven excluded ids join `system/` and
`ui/` once their owners land.

## What each id became

38 literals (40 ids) now state a decision in words. 67 literals (70 ids)
drop a citation the title already explains. Each record was read with
its comments through REST, and where a record has no comments, from what
landed.

| record | ids | result |
|:--|--:|:--|
| objectstack-ai#3508 | 2 | `APPROVER_VALUE_BINDINGS`: "an approver value is picked
from the records the engine resolves". `APPROVER_VALUE_SOURCES` (the
follow-up): "where each picker finds its candidates, published on the
wire". |
| objectui#2955 | 1 | "for the decision dialog to render and enforce":
both decision entry points collect the typed outputs, and `required` is
enforced. |
| objectstack-ai#3810 | 1 | "names the match-everything-write hazard": a filter
emptied by interpolation matches every row, and the node is refused
instead. The test pins the words `match-everything write`. |
| objectstack-ai#4001 | 13 | "strict as of objectstack-ai#4001 批 9" becomes "an unknown key is
refused, not stripped" (5 titles). Also "refused, not stripped", "an
unknown key is refused, per shape" and "the unknown-key gate". Dropped
from 5 titles that already read "unknown keys are rejected, not
stripped". |
| objectui#2670 | 1 | "so the flow designer renders it as a template":
the designer's loop and region rendering reads this marker. |
| objectstack-ai#4396 | 2 | "a function that writes says so; pure is the default", and
"the authoring surface where a function declares its effect" (landed
`eb4204b`). |
| objectstack-ai#4697 | 2 | `defaultValue`: "a declared variable is bound on every
path" (ruling A). Dropped once. |
| objectstack-ai#3896 | 3 | "outputSchema retired: declared, never validated" (the
audit close-out's reason, as `flow.zod.ts`'s tombstone records it).
Dropped twice. |
| objectstack-ai#4247 | 1 | "maxRetries — one default, and no zero-attempt “retry”"
(landed `a648e96`). |
| objectstack-ai#16134, objectstack-ai#15713 | 7 | "a region node reusing a top-level id is refused
— one node-id space now spans every region" (ruling, batch 61). Dropped
from 5 titles that state uniqueness. |
| objectstack-ai#9205 | 5 | "template reference — notify content localized through an
email template" (the ruled emailTemplates route). Three titles say "the
template path" where they said "pre-objectstack-ai#9205". Dropped once. |
| objectstack-ai#7086 | 1 | "severity — the closed info \| warning \| critical
vocabulary" (the enum route). |
| objectstack-ai#4415 | 3 | "FlowNodeSchema parses its own regions" (ruling
2026-08-07, direction 1). Dropped from 2 titles that already say it. |
| objectstack-ai#4347 | 1 | "collectFlowGraphs — every region is walked, not only the
top level" (landed `31e0be9`). |
| objectstack-ai#4401 | 2 | "FLOW_REGION_SLOTS, the one declaration of where regions
live" (landed `4bfd455`). Dropped once. |
| objectstack-ai#4414 | 1 | "`condition` is pointed at the out-edges, NOT given the
one-edit rename" (one working routing model, landed `5293114`). |
| objectstack-ai#15429 | 1 | "taking every true branch must be declared" (ruling item
2: explicit `inclusive`). |
| objectstack-ai#14149 | 3 | "every entry older than the value role" (ruling A: a
value-role CEL slot on `assignment`). Dropped twice. |
| objectstack-ai#19938 | 4 | "the CRUD `fields.*` value slots added exactly two rows".
Dropped three times. |
| objectstack-ai#15572 | 3 | "predicateSlotRefusal — a predicate slot holds bare CEL
text", and "the other two doors refuse it". Dropped once. |
| objectstack-ai#15662 | 1 | "structuralConditionRefusal — a structural condition is
CEL text or an expression". |
| objectstack-ai#15792, objectstack-ai#15807 | 4 | "REFUSES an `ast`-only envelope — admitted at
first, refused once an evaluated slot required a `source`". Dropped from
2 titles that state the rule. |
| objectstack-ai#17493 | 3 | Table row "a blank string — blanks are refused" (ruling
A). Dropped twice. |
| objectstack-ai#14945 | 4 | "EndConfigSchema — the `end` node contract: it may refuse
the run with a message" (ruling 2′). Dropped three times. |
| objectstack-ai#15617 | 4 | "`failed` is the fold INCLUDING what a delegating node
rolled up from its child — it answers what the run caused" (ruling
option 1). Dropped three times. |
| dropped only | 36 | objectstack-ai#3196, objectstack-ai#3266, objectstack-ai#4158, objectstack-ai#4277, objectstack-ai#4343 (2), objectstack-ai#4389,
objectstack-ai#4525, objectstack-ai#4738, objectstack-ai#4964 (2), objectstack-ai#6758, objectstack-ai#7085, objectstack-ai#9106, objectstack-ai#12278, objectstack-ai#14964, objectstack-ai#15430,
objectstack-ai#15646 (3), objectstack-ai#16752, objectstack-ai#17306, objectstack-ai#17852, objectstack-ai#18102, objectstack-ai#18112 (2), objectstack-ai#18847, objectstack-ai#19151,
objectstack-ai#19961 (4), objectstack-ai#20316 (2): each title already states the pinned decision.
For objectstack-ai#4988 and objectstack-ai#6414, the two expect messages already say what was
retired. |
| objectstack-ai#6362 (404) | 1 | Dropped. The title "PRESERVES all seven envelope
keys — measured, not assumed" carries the decision recorded in
`b5404f496` (`webhook` was measured, and all seven keys survive). |

## Readers

- **Test-name filters:** none. A tracked-tree search for `-t` and
`--testNamePattern` finds only `packages/qa/dogfood/README.md:142` (`-t
"owner-scoped"`), which is unrelated.
- **Snapshots:** none. `automation/` has no `__snapshots__` and no
`toMatchSnapshot`.
- **Titles by substring:** every old title, plus a window around each id
(250 needles), was searched across the tracked tree outside its own
file. No gate, doc or script matches one. The hits are other files' own
titles with the same words: `identity/`, `security/` and `automation/`
siblings, a later stage's lot. There are also two code comments in
`flow.zod.ts` and `flow-function.zod.ts`, which belong to the comment
lane.
- **Twin tables, not readers:**
`packages/lint/src/validate-expressions.test.ts:4442/4445` and
`packages/services/service-automation/src/decision-branch-expression-absent.test.ts:61/64`
repeat the `flow-decision-branch-expression-absent` table's row names.
Nothing compares them mechanically: the "same table" parity is prose in
the headers, and it covers assertions, not names. They are outside this
stage's surface (see Acceptance notes).

## Text-only proof

A scratch tool (`textonly10.cjs`) compares base and head file by file on
three legs:
1. **Skeleton:** the full AST, with string pieces masked. It must be
identical.
2. **Comments:** every comment, byte-equal.
3. **Strings:** each string leaf that changed must sit in a test-call
title position, or on one of the 4 declared lines
(`flow-decision-branch-expression-absent.test.ts:63` and `:66`, table
`name` values that feed `$name` titles; `sync-retirement.test.ts:120`
and `:158`, expect messages). It must carry a tracker id before and no
`#` plus digits after.

- **Result:** 21 of 21 files SAME, 105 changed (101 title, 4 declared),
on all three legs.
- **Diff hunks:** exactly the 105 planned lines, with every file keeping
its line count.
- **Controls (10 of 10 as predicted, on scratch copies, each anchor hit
once):** identifier rename DIFF; numeric literal DIFF; comment edit
COMMENT DIFF; a non-title string with an id VIOLATION; a rewritten title
given a new id VIOLATION; a title that was id-free at base edited
VIOLATION; one title reverted to base SAME (104 changed); a declared
string keeping an id VIOLATION; an undeclared expect message changed
VIOLATION; a title re-split into a `+` chain DIFF.

**Test counts:** the 21 files run at the base (in a separate base
worktree) and at the head: 801 / 801 tests on both sides, with the same
count and status sequence per file in 21 of 21. 560 full test names
change, and each equals the base name with the planned replacements
applied.

## Changeset: `skip-changeset`

Measured, not assumed:
- `npm pack --dry-run` of `@objectstack/spec` lists 2068 files, under
`files[]` (`dist`, `src/**/*.zod.ts` and the rest). 0 of the 21 touched
files are in it, and 0 `*.test.ts` at all. The control
`src/automation/flow.zod.ts` is in it.
- In `dist/`, three new phrases and three old ones each read in 0 files.
The control `A predicate slot holds BARE CEL TEXT` reads in 2.

So this PR publishes nothing, and no changeset is added.

## Verification (at `f3dc3fab03`)

- `pnpm turbo run build` over all packages: 71 / 71.
- `@objectstack/spec`: `vitest run --project local`, 612 files and 18185
passed, 1 todo. `typecheck` exit 0, including `check:test-typecheck`,
whose program holds all 21 touched files.
- **Gates:** `dispatch-gates --commands` derived 79 families, and all 79
exit 0. `--ran` reconciles: 79 derived, 79 run, 0 NOT-MEASURED, 0 UNRUN.
- **ESLint, a proven narrowing:** `--no-inline-config` over the 21
files, 0 errors and 0 warnings. The population comes from ESLint's own
config: 21 configured, 0 ignored. No `parserOptions.project` or
`projectService`, so no untouched file's verdict can move.
- `check-governed-merges --test`: NOT governed, 210 changed lines.

## Acceptance notes

- **Twin row names in other packages:** the lint and service-automation
copies of the decision-branch table keep their `the objectstack-ai#19961 shape` and
`the objectstack-ai#17493 control` row names, and their twin `describe` titles keep
their ids. The lint copy is this card's own later share (the
`packages/lint` test strings). The service-automation copy belongs to
that package's lane.
- **Code comments still carry ids** in these 21 files (for example
`approval.test.ts:56`, `:69` and `:131`). They are the comment lane's,
untouched here.
- **`origin/main` moved** three commits past the base before this PR
opened (objectstack-ai#21701, objectstack-ai#21707, objectstack-ai#21706). None touches `packages/spec`, so
nothing was merged.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01T9u38rswFp5Rw8DswRUReJ)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
akarma-synetal pushed a commit to akarma-synetal/framework that referenced this pull request Oct 7, 2026
…nfig kernel too, and the diagnostics locked count reads the item envelope derivation (objectstack-ai#21694) (objectstack-ai#21715)

Fixes objectstack-ai#21694
Clause-②: no (narrowing)

## Arm 1a: no recorded reason exempts a host-config kernel

I measured H1 before writing any code.

- **Where the short-circuit came from.** `if (this.environmentId ===
undefined) return null;` opened both `lockWriteRefusal` and
`assertLockAllowsDelete`. It arrived in 8eca8f3 (2026-05-29, "Update
files", then in `packages/objectql/src/protocol.ts`), and neither
docblock gave a reason. The only rationale ever written is the title of
the test that pinned it: "environmentId=undefined bypasses L3
(control-plane bootstrap)"
(`packages/objectql/src/protocol-lock-enforcement.test.ts`). 2796a1f
(objectstack-ai#1775) later called the bypass "intentional" in the registry-shadow
suite's docblock, again without a reason.
- **ADR-0010 records no carve-out.** The §3.3 lock table has no topology
column. §6 Phase 1 places `_lock` enforcement in save, publish, delete
and rollback. The "single-process dev / bootstrap" sentence in §3.8 is
about the `OS_METADATA_WRITABLE` type hatch, which this gate never read.
- **objectstack-ai#6710's precedent refutes the inference.** The
`MetadataAuthoringChannel` docblock and the comment in
`assertRuntimeAuthoringRules` record three facts. `environmentId` is a
row-scoping key. The CLI's host-config assembler (`serve.ts`, `new
ObjectQLPlugin()` with no options) leaves it undefined while it serves
end-user `PUT /api/v1/meta/*`. That assembler is the showcase's own boot
shape. objectstack-ai#6710 re-keyed the ADR-0005 carve-out to a declared
`authoringChannel`, and objectstack-ai#5086, objectstack-ai#7674 and objectstack-ai#9380 retired the same proxy
elsewhere.
- **`getEffectiveLock` has no topology term.** Its artifact limb reads
the registry, and its overlay limb reads `sys_metadata` through the
engine. It does resolve a lock on a host-config kernel: pin 1 is refused
there with both `source=overlay` and `source=artifact`.

So the gate refuses on every topology, as `packagedBaseRefusal` does. I
kept no exemption for the declared `package-author` channel either. No
ADR or comment records one for L3, and no assembly in this repository
declares that channel (`git grep` finds 0 non-test declarations). H3
(arm 1b) is not taken.

## What changed

Only `packages/metadata-protocol/src/protocol.ts` changes at runtime.

1. **The gate.** `lockWriteRefusal` and `assertLockAllowsDelete` lose
the short-circuit. `publishMetaItem` (through `promoteDraftForPublish`)
and `rollbackMetaItem` already call them unconditionally, so those two
verbs now refuse on a host-config kernel too.
2. **The two call sites inside `if (this.environmentId !==
undefined)`.** `saveMetaItem` and `deleteMetaItem` asked the gate inside
that block, behind their package doors, so removing the short-circuit
alone would not reach them. The gate moves out of the block, and it
keeps its rank on both kernels: it runs only when `packagedBaseRefusal`
admits the write.
- On an environment kernel the package door has already thrown by that
point, so nothing changes there.
- On a host-config kernel the package door is the repository's
(`SysMetadataRepository.assertAllowed`, at the write), so a packaged
base it refuses keeps that answer.
- Without the rank, a packaged app or object that declares `_lock` would
answer `ITEM_LOCKED` on a host-config kernel and `NOT_OVERRIDABLE` on an
environment kernel. That would be a new topology split in the refusal
code. Ablation 2 below pins it.
3. **The count.** `getMetaDiagnostics().stats[type].locked` now counts
items whose `servedLockState(...)` reports a lock other than `'none'`.
That is the same derivation `getMetaItem` and `getMetaItemLayered`
publish. The field's docblock says so.

No `packages/spec/src/**` file is touched, so no contract review is owed
on that ground. No governed surface is touched.

## Reach: correcting the card's "no shipped producer"

Triage graded p3 on the premise that "every `protection.lock` in
`platform-objects` is on `object`". Three apps carry one too: `setup`,
`studio` and `account` (`packages/platform-objects/src/apps/*.app.ts`,
`protection.lock: 'full'`). `app` has `supportsOverlay: true`, so the
objectstack-ai#6960 carve-out lets a removal past the package door, and only the
`_lock` gate stood behind it.

- **At the base (16d241a).** I ran the real
`ObjectStackProtocolImplementation` over an in-memory double, without an
`environmentId`. Deleting a packaged app that declares `_lock: 'full'`
answered success. An environment kernel answered `403 ITEM_LOCKED`.
- **On this branch, on a live showcase.** I started a fresh dev server
(`pnpm dev -- --fresh -p 38694`) and signed in as the seeded admin.
`DELETE /api/v1/meta/object/sys_organization` answered `200` ("No
customization overlay found"), where an environment kernel answers `403
NOT_OVERRIDABLE`, so the server is host-config.
- `GET /api/v1/meta/app/setup` answers `lock: full`, `editable: false`,
`deletable: false`.
- `DELETE /api/v1/meta/app/setup` answers `403 ITEM_LOCKED` ("app/setup
is locked (_lock=full, source=artifact)").

The grade is the seat's call. This corrects the premise behind it.

## What moves (H2)

- **The dev server's own boot.** The fresh showcase boot above logged no
`ITEM_LOCKED`, no "is locked (_lock=" and no "metadata store could not
be read" (0 hits in 72 lines). Nothing the boot writes is refused.
- **`examples/**`.** No example declares `_lock` or `protection:` (`git
grep`: 0 hits).
- **Writers that now meet the gate on a host-config kernel**, as they
already did on an environment kernel:
- `os migrate meta --stored --apply` (`migrateStoredMetadata`): a row
whose effective lock refuses the write is reported failed instead of
rewritten.
- `deletePackage` and `discardPackageDrafts`: a locked item becomes a
`failed[]` row.
  - `duplicatePackage`.
  - plugin-security's permission-set projection.
  - service-automation's flow-credential migration.
- the `/automation` doors, which write through `saveMetaItem` and
`deleteMetaItem`.
- **A host-config deployment that relied on writing a `_lock`ed item.**
Its saves, publishes, rollbacks and deletes are refused now, as on an
environment kernel. A stored row that declares `full` can no longer be
written or removed through `/meta` on any kernel. The ADR-0010 §3.8
override path is not implemented, and that is unchanged here.
- **Fail-closed read.** On a host-config kernel the gate's own
`sys_metadata` read now runs first. A failed read is answered `503
SERVICE_UNAVAILABLE`, with the driver error on `cause` (objectstack-ai#5706), before
anything is written. A delete used to reach the store and answer with
the driver's code or a `500`.
- **NOT MEASURED: the cloud control-plane assembly.** It is outside this
repository, and if it declares `package-author` and writes `_lock`ed
items through `saveMetaItem`, it now meets the gate.
- **Tests that moved: 14 cases in 6 files, all fixtures, none a product
regression.** Each one leaned on the bypass:
- `metadata-protocol/protocol.delete-rewrap-envelope.test.ts` (4 cases).
The fault was injected into the first `sys_metadata` read, which is now
the gate's own read and fails closed with a 503. The fault now arms once
the lock verdict is in, so it lands on the probe read this file pins.
- `objectql/protocol-lock-enforcement.test.ts` (1 case). It pinned the
bypass itself. It now pins `ITEM_LOCKED` on save and delete, and asserts
no `update` or `delete` reached the engine.
- `objectql/plugin.authoring-channel.test.ts` (1 case). The bare `new
ObjectQLPlugin()` kernel had no driver, so the gate's read failed closed
with a 503 before the authoring gate could answer. It now registers a
memory driver, as `serve.ts` does, and also asserts that nothing is
stored.
- `objectql/protocol-meta.test.ts` (1 case). "Fail fast when findOne is
unavailable" now asserts the gate's `503 SERVICE_UNAVAILABLE`, with
`cause` being the driver error. The test title loses its "500".
- `objectql/protocol-publish-package-drafts.test.ts` (3 cases). The
double stubbed `assertLockAllowsWrite`, but since objectstack-ai#8594 the publish path
asks `lockWriteRefusal`. The stub moves to `lockWriteRefusal`.
- `objectql/protocol-registry-shadow.test.ts` (4 cases). The suite wrote
its overlay row through a `PUT` that the bypass admitted. The row is now
written before the package's lock arrives, which is the pre-dating
overlay that the envelope graft exists for. The two removal cases use
`no-overlay`, because `full` now refuses removal on every kernel, and
the first case also asserts that a further `PUT` is refused.

## The count's cost (H4)

`servedLockState` makes no store read. It is `resolveLockState` (pure),
plus two `packagedBaseRefusal` calls (registry lookups, which build an
`Error` only for a refused item), plus `isArtifactBacked` (registry).
The list items already carry the merged artifact protection
(`mergeArtifactProtection` in `getMetaItems`), which is the same
document shape the item read derives from. So the sweep stays bounded at
one registry walk per item, and the store reads are unchanged.

## One authority (H5)

I grepped `packages/metadata-protocol/src` and `packages/rest/src`
(non-test) for `_lock` readers.

- **What remains.** `getEffectiveLock` remains for the doors,
`servedLockState` for the read and now for the count, and
`mergeArtifactProtection` copies the envelope.
- **What went.** The declared-`_lock` count was the only second
predicate, and it is gone.
- **`rest`.** It has none.
- **`runtime`.** The `/automation` doors ask `packagedBaseRefusal`, then
write through `saveMetaItem` and `deleteMetaItem`, so the `_lock` gate
covers them.
- One same-family disagreement is left, and it is not topological. It is
in the acceptance notes and the report.

## Pins

`packages/metadata-protocol/src/protocol.lock-door-read-agree.test.ts`
runs the real doors and the real reads. Each refusal asserts `code` and
`status` (ADR-0112).

1. **Pin 1, host-config.**
- An overlay `view` row is tried with each of the four `_lock` states.
Save and delete do what `editable` and `deletable` say:
`ITEM_LOCKED`/403 where the read says no, and admitted past the gate
where it says yes. Admission is proved by spying on the gate (reached,
answered `null`).
   - A publish of a `full` row is refused.
- A packaged `app` declaring `full` is refused on delete with
`ITEM_LOCKED`/403. Its save keeps `NOT_OVERRIDABLE`/403, and the gate is
not reached.
2. **Pin 2, both kernels.** `stats[type].locked` equals the number of
items whose `getMetaItem` envelope reads locked, for `flow`, `action`,
`app` and `view`.
   - Lit control: the tiles are `{flow: 1, action: 1, app: 2, view: 2}`.
- A count of declared `_lock` would give `{0, 0, 1, 2}`. The flow,
action and second app are locked by the package door alone.
3. **Pin 3, environment kernel, unchanged.** An overlay `full` row is
refused `ITEM_LOCKED` on save and delete, and a `no-delete` row passes
the gate on save and is refused on delete. A packaged app keeps
`NOT_OVERRIDABLE` on save and `ITEM_LOCKED` on delete, the same codes
the host-config kernel now gives.

## Reverse verification

Both ablations ran from the committed fix (HEAD 2ec0a2c), through
`scripts/ablation-replace.mjs`, inside a script with an `EXIT INT TERM`
trap that restores from `HEAD`. The pin file imports `./protocol.js`
(source), so no rebuild is in the path. The predicted direction was
declared before running.

1. **Ablation 1 restored the short-circuit in both helpers and the
declared-`_lock` count.**
- The anchors landed on disk: the gate anchor went from 2 to 0 with 2
markers on disk, and the count anchor from 1 to 0 with 1 marker. The
blob went from 185d138 to 5b338f26488f.
- The result was as predicted. In pin 1, 5 cases went red, and the
`_lock=none` control stayed green. Both pin 2 cases went red. All 3 pin
3 cases stayed green. Total: 7 failed, 4 passed (11).
2. **Ablation 2 removed the rank at both call sites (`true ||` before
`packagedBaseRefusal`).**
   - The anchor went from 2 to 0, with 2 markers on disk.
- Only the packaged-app case went red, because the save answered
`ITEM_LOCKED` instead of `NOT_OVERRIDABLE`. Pin 3's environment twin
stayed green. Total: 1 failed, 10 passed.

**Restore.** After each ablation the blob equals the `HEAD` blob
185d138, `git diff HEAD` on the file is empty and `git status
--porcelain` is empty. The tool proved this on each leg, and so did the
trap.

## Tests

On the merged head 4265c6b (after objectstack-ai#21706):

- `@objectstack/metadata-protocol`: `vitest run`, 211 files passed and 3
skipped, 3589 tests passed and 19 skipped. `typecheck` (`tsc --noEmit`)
is green, and `--listFiles` shows it compiles 214 test files, including
both test files touched here.
- `@objectstack/objectql`: `vitest run --project local`, 372 files and
7458 tests passed. `typecheck` (tsc, tsconfig.scripts,
`check:test-typecheck`) is green.

On 2ec0a2c (before the second merge of main, which touched neither
package's lock path):

- `@objectstack/rest` (`--project local`): 260 files, 4897 tests passed,
326 skipped.
- `@objectstack/runtime` (`--project local`): 321 files, 4563 tests
passed, 19 skipped.
- `@objectstack/plugin-security` (the 7 files that call the write
verbs): 150 tests passed.
- `@objectstack/service-automation` (2 files): 24 tests passed.

These four were run because the order asked to measure which tests move.
They are downstream consumers, and this is not a public-surface change.

## Gates

Run on head 4265c6b, after the final commit. Each command's exit code
was captured before any pipe.

- **Derived set.** `node scripts/pm/dispatch-gates.mjs --commands` (no
paths) derives 74 families. All 74 exit 0, and the `--ran`
reconciliation reads "74 derived, 74 run, 0 NOT-MEASURED, 0 UNRUN".
These include `check:adr-0087-registration` (the
`no-migration-prescription` disposition is accepted),
`check:empty-changeset`, `check:changeset-no-major` (its level axis is
PR-scoped and reads this body in CI), `check:engine-double-contract`,
`check:nul-bytes`, `check:doc-authoring`,
`check:cross-package-test-inputs`, `check:test-source-alias`,
`check:published-files` and `check:dts-closure`.
- **`check:engine-double-contract`.** At first it asked for the new pin
file's `findOne` double to be recorded. `--write` added one row to
`scripts/engine-double-contract.pinned.json`, with "0 added or grown, 0
lost", and that row is committed here.
- **Artifact-roster block.** The derivation prints 54 roster commands
outside its total, and all 54 were run. 51 exit 0.
`check-closing-target-claim`, `check-partof-closing-keyword` and
`check-single-claim-paths` exit 2 NOT WIRED, because they read a pull
request (`PR_NUMBER` / `PR_BODY`). I ran the body gate locally against
this body before opening the PR, and the other two run in CI on this PR.
- **The four symbol-anchor sweeps**, which no path derives for a source
change. All four exit 0:
  - `check:adr-symbol-anchors`: 2167 anchors across 140 records resolve.
- `check:scripts-symbol-anchors`: 3760 anchors across 282 scripts
resolve.
- `check:spec-docblock-symbol-anchors`: 4877 anchors across 1865 spec
sources resolve.
  - `check:adr-anchors`: green.

NOT MEASURED locally, owned by CI:

- the Dogfood Regression Gate. The live showcase checks above cover its
door for the setup app.
- the Temporal Conformance live-database job.
- the whole-workspace type-check lanes.
- the full `pnpm lint`.

## Acceptance notes

- **Same family, not topological (reported, not filed).** An env-wide
`view` row declares `_lock: 'full'`. An org-scoped read (`getMetaItem`
with `organizationId: 'org_a'`) serves that row and reports `lock:
full`, `editable: false`. The `_lock` gate for an `org_a` save admits,
because `getEffectiveLock`'s overlay limb looks up `organization_id =
org_a` only. Measured on both kernels with the protocol over a double:
the save went on to validation. This is the door and the read
disagreeing on the org axis, and ADR-0010 §3.3 rejects overlay writes
under `full`. The report names it for the seat.
- **Pre-existing on a host-config kernel, untouched here.**
- Deleting a packaged object with no overlay row is a no-op success,
while the read says `deletable: false`. That is the package door objectstack-ai#21670
accepted, not the `_lock` gate, which ranks below it.
- A stored row of a code-only type that declares `_lock` now answers
`ITEM_LOCKED`, where an environment kernel answers `NOT_CREATABLE`. The
host-config protocol has no `NOT_CREATABLE` door. No producer writes
such a row.
- **Two `lockSource` vocabularies.** The door's sentence names the limb
(`source=artifact` or `source=overlay`), while the envelope carries the
declared `MetadataLockSource` (`package` for the setup app). This is
pre-existing.
- **The objectstack-ai#21670 table.** Its host-config door is the repository gate
alone, and its items declare no `_lock`, so it stays valid. The `_lock`
limb on that kernel is covered by pin 1 here.

---
_Generated by [Claude
Code](https://claude.ai/code/session_017ErfyP2Rx7XWHJA27QjyUi)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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 size/m tests tooling

Projects

None yet

2 participants