Repository navigation
feat(objectql): a record in a closed state, and its lines, are closed to change (closedStates, ADR-0162) — trunk - #38497
Closed
objectstack-fleet[bot] wants to merge 47 commits into
Closed
objectstack-fleet[bot] wants to merge 47 commits into
objectstack-fleet[bot] wants to merge 47 commits into
Conversation
…s (ADR-0162 D1) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…nd generated docs (ADR-0162 D1) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…ale, changesets (ADR-0162 D1) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…the closedStates row Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…tes (ADR-0162 D1) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…operty, closedStates (ADR-0162 D1) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…leaves on its status mirror (ADR-0162 item 8, readings 3-6) A node failing after a decision strands the run and the field keeps the first step's outcome; a later step that cannot open (empty slate under `fail`, another approval pending) strands it, or completes the run down a `fault` edge with the step never asked; a parent cancelled above a pending child leaves the decision admitted, the door reporting a clean resume and the parent's next step never asked. The dead-run sweep changes nothing after any of them. Claude-Session: https://claude.ai/code/session_01L6bhgX7z5dcSkTqEAWNMsP Co-authored-by: Claude <noreply@anthropic.com>
…loses on is reported, and refuses an approval's first opening (ADR-0162 item 8) On a field the object closes on at `approved` or `rejected`, the mirror's write that a validation rule, an option's `visibleWhen` or a hook refuses is no longer swallowed at `warn`. At an approval's first request the `pending` is written right after the row; a refusal voids the row as `cancelled`, empties the approver index, notes the timeline and fails the run at that step with the refusal's own message. Every other refused write is reported: an `error` line, a line with no actor on the request's timeline, and a notice to the organization's administrators (`approval.status_mirror_refused`). Objects with no closed state keep the `warn`. Claude-Session: https://claude.ai/code/session_01L6bhgX7z5dcSkTqEAWNMsP Co-authored-by: Claude <noreply@anthropic.com>
…ouble ledger for the refused-mirror writes and the readings pins Claude-Session: https://claude.ai/code/session_01L6bhgX7z5dcSkTqEAWNMsP Co-authored-by: Claude <noreply@anthropic.com>
… to change (ADR-0162 D2-D7, D10) Every write a system context does not make is judged against the stored row: an update or delete of a closed record, and a line create, update, delete or move under a closed master, are refused 409 RECORD_LOCKED. A many-row write is refused whole before any row is written, by one existence probe or the write's one read of its matched rows under the per-row ceiling. A cascade that reaches a closed record removes no row; a restore under a live closed master is refused. The lock runs after the middleware gates and before the before-hooks. Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…st (ADR-0162 D1) An extension's redeclaration that removes, retypes, makes multi-value or narrows a field the served declaration names is refused at the fold (the field stands, the fold logs once, the rest of the extension lands). A tenant overlay may add closed values and may not shorten the package's list or break a field it names. Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…jectql (ADR-0162) The liveness row flips to live with the engine's reads and the dogfood suite as evidence; state counts regenerated. The error-code ledger names objectql as an emitter of RECORD_LOCKED. Changeset for objectql (minor). Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…r (row 29g, ADR-0162 D5) The census reads boundByClosedStates as an elevation read site; the row names it and the site register is regenerated. Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…is closed (ADR-0162 D4) The master check is one existence probe per chunk of ids with the closed predicate in its where, never a read of state columns tested in process. The cascade set is judged the same way: one probe per chunk for its own state, and for its lines the predicate door's semi-join where the store runs it; only a store that cannot keeps the read of the lines' keys, then one probe of their masters. Where the fold restores a package's field over a tenant overlay, the overlay's closed values for that field are served only where the package's field declares them. Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…DR-0162 item 8) Claude-Session: https://claude.ai/code/session_01L6bhgTCFhayR5cBZXM7XPP Co-authored-by: Claude <noreply@anthropic.com>
…ts status mirror Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…s writers Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…n its status mirror Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…o request can hold Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
… trunk (ADR-0162 item 7) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2
…o-steps stamp (slice B) ADR-0162 Execution item 7 "The check", as revised on 2026-11-27. At an approval's first request the plugin reads the approval whole (the root run's flow and every subflow/map body, to any depth) and: - stamps the between-two-steps set on the request (new engine-written column between_steps_json); later requests of the approval copy it; - refuses the opening, VALIDATION_FAILED with one sentence per gap in the run's locale, where a step mirrors onto a field its object closes on at a request status and a D5 condition fails, where a flow cannot be read, or where the host runs no job service. Not judged: no object declares closedStates; no root run; a later request; a request that cannot be placed. The writing-node condition is withdrawn and pinned as not refused. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nzgcVrZ8Neqqd1AFi
…bjectstack-ai/objectstack into claude/project-thread-fkdrk9
9 tasks done
This was referenced Nov 30, 2026
Merged
This was referenced Dec 1, 2026
Contributor
Author
|
repo:objectstack#3 · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z Superseded by #38810. This trunk's two refreshes (#38791, #38797) were squash-merged into it, so its history no longer shares a base with |
2 tasks
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…ce.documentBy`); record search groups by it by default (objectstack-ai#38564) <!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XDXvJPPtrTGfdDYhWWpihq5)_ Part of objectstack-ai#38537 Clause-②: yes (widening) Metadata-protocol: added ## 维护者速读 - 用户能看到什么变化:知识源可以声明“文档单位”(指向父记录的字段);AI 按记录检索时,同一份父记录(如一份制度)下的多条子记录(条款)只返回一条命中,原来是每条子记录各一条;Studio 知识源表单多了一个“文档单位”选择框。 - 为什么做:属于“知识源声明文档单位、按父记录计数与聚合”专题,替把段落写成子记录的应用(例如制度下的条款)解决按记录检索时同一份制度刷屏的问题,也是云端按父记录计文档数的前置。 - 出错会怎样:只有声明了该字段的知识源受影响,索引内容不变、不触发重建;若分组有误,AI 检索会多返回或少返回命中,删掉该字段即恢复原行为。 - 要你做什么:无。 ## What changes PR 1 of 2 for the card. This PR lands the key, its parse rule, its save-time refusal and its first reader; the `os validate` rule (in the lint package, held by another seat until it is released) is PR 2, which closes the card. - **Spec** — `ObjectKnowledgeSourceSchema` gains `documentBy?: string`. A refinement refuses a value that `metadataFields` does not list, with a message that names the field, the list, and the fix (add it to `metadataFields`, name a listed field, or remove the key). The refinement is a cross-key rule JSON Schema cannot state, so it is ledgered in `dropped-refinements.baseline.json` (two schemas plus the four installed-package response schemas that embed a source; header totals updated). - **Parent-link rule, exported** — `knowledge-search-scope.ts` now exports `parentLinkRule(schema)` (the rule `scopeTermsFor` already used, factored out of the private `parentLinksOf`, which now calls it; scope behaviour unchanged) and `documentUnitOf(field, schema)` (the rule plus "not `multiple: true`"). Both are pure functions of the object definition, so PR 2 can call them with no knowledge service. - **Save door** — `admitAuthoredSource` refuses a `documentBy` that `metadataFields` lists and that is not a single-valued parent link: `400 VALIDATION_ERROR`, `field` set, after the "does not exist" arm and before every permission arm. The sentence is built by `documentUnitRefusalText` in `knowledge-source-admission.ts`, one wording per reason (undeclared, withheld, not a link, no readable target, multiple). A `documentBy` that `metadataFields` does not list is left to the parse, which already names that fix. - **Reader (ADR-0049, ADR-0161 K4)** — in `searchByKey`, with record granularity and no `groupBy`, `groupKeyOf` now asks `documentKeyOf(hit, documentBy)`: `parent:SOURCE#VALUE` when the hit's source declares `documentBy` and the hit carries a parent, else the existing per-record key. The explicit `groupBy` path, `sourcesGroupableBy` and chunk granularity are untouched. - **Tool** — `hitOf` sets `groupValue` to the parent under the default grouping too (absent for a record with no parent). `documentUnitValueOf` is the one predicate both the service key and the tool read. Like its `groupBy` arm, the tool serves the parent only for a source that lists `documentBy` in `metadataFields`. - **Hashes** — `documentBy` is in neither the index fingerprint nor the recipe hash (both enumerate their inputs explicitly); `__tests__/index-fingerprint.test.ts` is unchanged and green. - **Form** — the form-coverage gate (`metadata-form-zod-reconciliation.test.ts`) refused the key without a form row, so the single picker is added beside `metadataFields` (`widget: 'field-ref'`, `dependsOn: 'object'`) with its form test. **This folds in the form half of objectstack-ai#38538**; the docs and `skills/**` half stays there. The row brings its regenerated translation bundles (ja-JP, es-ES and zh-CN authored, the rest the extractor's fill) and the catalog's positive-control count (866 to 867). - Regenerated: authorable-surface, the reference page, the liveness ledger row and counts. - **Changeset** — `minor` for `@objectstack/spec` (the new authorable key), `@objectstack/service-knowledge` (the reader and the save refusal) and `@objectstack/platform-objects` (the form row's translated label and help), with `Metadata-protocol: added`: a new key a metadata author can write. ## Zone 2 choices - **Where the parent value is read from:** the hit's own `metadata[documentBy]`, the value assembly stored beside the passage. The parse holds `documentBy` in `metadataFields`, so every hit of such a source carries it; grouping runs over the hits the adapters already answered and reads no record (SQL first: no per-hit read was added). The freshness check and the permission re-check are unchanged. - **Default key spelling:** `parent:` + index key of the hit's source + `#` + `String(value)`. The source key keeps two sources apart on equal parent ids; the `parent:` prefix keeps it apart from `record:` and `document:` keys; `String()` compares values as a scope term does. A value that is absent, null, empty, or not a string or finite number falls back to the per-record key, so those records are never dropped. - **Form row:** forced by the gate (it reported `knowledge_source.source: accepted by the Zod but unauthorable in the form — documentBy`), so it is in this PR. ## Acceptance | Card acceptance line | Test | |:--|:--| | Parse refuses `documentBy` absent from `metadataFields` | `knowledge-source.test.ts` › "refuses a `documentBy` that `metadataFields` does not list…", "…when `metadataFields` is omitted…" | | Save refuses a text field, a `user` field, an `internal` lookup and a `multiple` lookup, each naming the fix | `document-by-38537.test.ts` › "refuses a text field / a user field / an internal lookup / a multiple lookup, 400 VALIDATION_ERROR, naming the field and the fix" (+ positive controls: lookup and master_detail admitted) | | 6 records under 2 parents + 1 null parent, record granularity, topK 10 → 3 hits | `document-by-38537.test.ts` › "6 records under 2 parents plus 1 with no parent…: 3 hits" | | Explicit `groupBy: 'clause_hash'` unchanged; a source without `documentBy` unchanged | `document-by-38537.test.ts` › "an explicit groupBy is answered as before…", "a source without documentBy is answered as before…", "chunk granularity is answered as before" | | Fingerprint pins unchanged | `index-fingerprint.test.ts` unchanged and green; `document-by-38537.test.ts` › "the fingerprint and the recipe hash are the same with and without documentBy" | | Default key includes the source; `hitOf` sets `groupValue` | "two sources never share a group…", "search_knowledge: each hit carries its parent as groupValue…" | ## Ablation Both legs run with `scripts/ablation-replace.mjs` (mutation verified on disk, restore verified as blob equal to HEAD and an empty `git diff HEAD`). No build was needed: both suites import the subject from `src/`. <details><summary>Reader reverted (default key back to the per-record key): 4 red</summary> Anchor `if (groupBy === undefined) return documentKeyOf(...)` replaced with `return recordKeyOf(hit)` in `knowledge-service.ts`. `document-by-38537.test.ts`: 4 failed / 12 passed — the 3-hit test, the empty-parent test, the two-sources test and the `groupValue` test. Restored: blob c98a036 equals HEAD. </details> <details><summary>Parse rule removed (the refinement dropped): 2 red</summary> Anchor `.superRefine(refuseDocumentByOutsideMetadataFields)` removed from `knowledge-source.zod.ts`. `knowledge-source.test.ts`: 2 failed / 35 passed — both refusal tests. Restored: blob 211cb6d equals HEAD. (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.) </details> <details><summary>Delta round 1: the tool's metadataFields guard removed: 1 red</summary> The condition `&& objSource.metadataFields?.includes(objSource.documentBy)` removed from `hitOf` in `knowledge-tools.ts` (on-disk count 0). `document-by-38537.test.ts`: 1 failed / 16 passed, the stub-service test ("expected … to not have property groupValue"). Restored from a copy (on-disk count 1) before commit `12cd7dc8a6`, whose blob `e49165a005` carries the condition. This leg used a copy-and-restore, not `ablation-replace.mjs`. </details> ## Tests **Delta round 1 (contract review 7254573293, PASS with S1 open), head `e0ebb9ad8e`.** S1: the `documentBy` docblock names the save refusal alone, and says a source registered in code or installed with a package meets no save and is not judged yet. N1: the docblock and the changeset say where each surface carries the parent: `metadata[documentBy]` on `IKnowledgeService.search`, and also `groupValue` on a `search_knowledge` hit. N2: the form help reads "Setting it rebuilds nothing; adding the field to Filter fields does." The changeset says the same, and the zh-CN, ja-JP and es-ES help is retranslated. The eleven bundles are regenerated: `check:i18n` reports all in sync, and `check:i18n-stale-fill` finds no new stale fill. N3: the `hitOf` guard, pinned by one stub-service test with a positive control. Claim widening: the contract TSDoc and the tool description above. Readings on `e0ebb9ad8e`: - `@objectstack/service-knowledge`: test 23/23 files, 803/803 tests; the new test file 17/17 after its type fix; typecheck exit 0. - `@objectstack/spec` test: 913/913 files, 28896 passed, 1 todo. - `@objectstack/platform-objects` test: 130/130 files, 2218/2218 tests. - spec `check:generated`: all 14 artifacts up to date, against a dist built after the spec edits. - Changeset and byte gates, each exit 0: `check-changeset-no-major` with this body as its event payload (level axis `yes (widening)` / `added`), `check-empty-changeset`, `check-adr-0087-registration`, `check-changeset-fixed`, `check-nul-bytes`, `check-spec-docblock-symbol-anchors`. - overlap-check: origin/main merges cleanly; it conflicts only with objectstack-ai#38550 and objectstack-ai#38497, on the hand-maintained counters as before. **Delta round 1, second commit, head `43de68d58f`.** The claim was amended to add the `topK` TSDoc and the tool's `granularity` input description. Both now say what the fixed docblocks say: "for a source that declares `documentBy` (its document unit), one hit per parent record instead". So do the other record-unit sentences in the two files (see Acceptance notes). Readings on `43de68d58f`: - `@objectstack/service-knowledge`: test 23/23 files, 803/803 tests; typecheck exit 0. This covers the `granularity` refusal sentence: no test pins its text. - spec `check:generated`: all 14 artifacts up to date, against a dist built after the edit. - `check-spec-docblock-symbol-anchors` and `check-nul-bytes`: each exit 0. - overlap-check: unchanged (origin/main clean; conflicts only with objectstack-ai#38550 and objectstack-ai#38497 on the counters). The `@objectstack/mcp` knowledge-tool tests compare the listed description with the definition itself and pin no text, so they were not re-run here. Earlier, the head was `5bbac4b457`, a clean merge of main that brings in objectstack-ai#38509 (the record sync change in `knowledge-service.ts`). Re-checked on that head: `@objectstack/service-knowledge` test 23/23 files, 802/802 tests; its typecheck exits 0; `@objectstack/spec` `check:generated` reports all 14 artifacts up to date; overlap-check finds origin/main merges cleanly. Below it, `231e7c6339` changes only the changeset (level `minor`, `Metadata-protocol: added`); the changeset families were re-run there (`check-changeset-no-major` with this body as its event payload, `check-empty-changeset`, `check-adr-0087-registration`, all exit 0). The gate union was re-run after the last code commit, at `a92874657e` (the translation commit landed while it ran, and the families that read it, `check:i18n`, `check:i18n-stale-fill` and `check:nul-bytes`, were run again on `a92874657e`). <details><summary>Package suites and typecheck</summary> - `pnpm --filter @objectstack/service-knowledge test` — Test Files 23 passed (23), Tests 788 passed (788). `typecheck` (tsc + test layer) — exit 0. - `pnpm --filter @objectstack/spec test` — Test Files 912 passed / 1 failed (913), Tests 28895 passed / 1 failed: the dropped-refinements ledger's header totals; corrected, `scripts/dropped-refinements.test.ts` re-run 30/30. `typecheck` — exit 0. - `pnpm --filter @objectstack/platform-objects test` — Test Files 130 passed (130), Tests 2218 passed (2218). `typecheck` — exit 0. - `pnpm --filter @objectstack/spec check:generated` — two stale artifacts found (reference page, liveness counts), regenerated with `--fix`, re-checked green. </details> <details><summary>Derived gate families (dispatch-gates --commands, 120)</summary> `node scripts/pm/dispatch-gates.mjs --ran` — "120 derived, 120 run, 0 NOT-MEASURED, 0 UNRUN"; every family exit 0 on the re-run. On the first run three families refused with exit 3 (prerequisite not met: no built CLI, client-react or package dists); each was built and re-run green, and `check:i18n` then reported the form row's bundles drifted, regenerated in this PR. </details> Not run locally: `check:i18n-coverage` (not derived for this diff; prerequisite needs the example apps built) and every CI-only family; CI reports them on this PR. Dogfood: n/a (no `!` in the title, no `(narrowing)` arm). ## Acceptance notes - **Files beyond the original claim's list, each forced by a Zone 1 line (recorded by the claim amendment on the card):** the save refusal is wired in `admitAuthoredSource` in `knowledge-service.ts` (the save-time admission lives there, not in `knowledge-source-admission.ts`, which holds the sentence); `dropped-refinements.baseline.json` (the parse rule is a refinement, which the spec build refuses unledgered); the platform-objects translation bundles and the catalog positive control (forced by the form row the gate required). - **Spec contract prose:** with the widened claim, this PR now updates the TSDoc of `KnowledgeSearchOptions.granularity` and `groupBy` (`packages/spec/src/contracts/knowledge-service.ts`) and the `search_knowledge` description: a source's `documentBy` sets the unit for record-level results. After the claim's second amendment, every other sentence in those two files that stated the record-level unit as "record" now names the document unit too: the `topK` TSDoc and the `groupBy` "instead of by record" line in the contract; in the tool, the `topK`, `granularity` and `groupBy` input descriptions, the matching `SearchKnowledgeInput` and `SearchKnowledgeOutput.hits` TSDoc, and the `granularity` refusal sentence. Left for objectstack-ai#38538, outside those two files: `content/docs/ai/knowledge-rag.mdx` (the `granularity` row) and `content/docs/protocol/knowledge.mdx` (the record-level paragraph). - **Not judged:** a source registered in code passes the parse (membership in `metadataFields`) but no save door, so the parent-link rule does not judge it; PR 2's `os validate` rule covers packaged sources. - **For PR 2 (the `os validate` rule), left undecided here:** `@objectstack/lint` does not depend on `@objectstack/service-knowledge`, and `parentLinkRule` / `documentUnitOf` are pure over the object definition (they read `@objectstack/core`'s withheld-field collectors and the spec's `referenceTargetOf`). Two ways for PR 2 to call them: (A) add the `@objectstack/lint` to `@objectstack/service-knowledge` dependency and import the functions, which first need a line in that package's `index.ts`: today they are module exports only, not on its `exports` surface; (B) move the pure rule to a package lint already reads (for example `@objectstack/core`) and have `knowledge-search-scope.ts` import it from there. PR 2 chooses. - **Live check:** no pgvector or turso live suite touches record granularity or `groupBy` (grouping runs in the service over adapter answers), so no live cluster was started. - **Overlap:** `overlap-check` is clean against `main` and objectstack-ai#38509 (shares `knowledge-service.ts`). It reports textual conflicts with two open drafts on hand-maintained counters: objectstack-ai#38550 (the dropped-refinements ledger and the catalog positive control) and objectstack-ai#38497 (the positive control). Whichever lands second re-applies its lines. ## Read first 1. `packages/services/service-knowledge/src/knowledge-service.ts` — `groupKeyOf` / `documentKeyOf` (the reader) and the new arm in `admitAuthoredSource`. 2. `packages/services/service-knowledge/src/knowledge-search-scope.ts` — `parentLinkRule` replaces the body of `parentLinksOf`; check the scope still behaves the same. 3. `packages/spec/src/ai/knowledge-source.zod.ts` — the key and its refinement. **Two-minute check:** `pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/document-by-38537.test.ts` — 16 passed, including "…: 3 hits, each parent's best and the orphan". Session: https://claude.ai/code/session_01FEkQ5oQLfL8thb6wtUHnTb 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…sabled packages hold answer their own 404 (objectstack-ai#38633) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_ Fixes objectstack-ai#34261 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:搭建者在环境地址下打开某个名字的草稿、草稿预览或分层视图,而这个名字只由已停用的包持有时,现在看到“不存在”,不再看到点名那个停用包的冲突提示;普通读取早已如此。 - 为什么做:同一地址换个开关答案就不同,违背维护者“停用就该全部消失”的原则;本卡把剩下的三种读法补齐。 - 出错会怎样:最坏情况是本该显示的草稿被答成“不存在”,或停用包重新出现在冲突提示里;不会泄露其他包的草稿(有专门测试守住),撤回这个改动即可恢复原样。 - 要你做什么:无。 ## What changes `GET /meta/:type/_env/:name` answered `404` for a name only disabled packages hold since objectstack-ai#33385. For a caller `mayReadPendingDrafts` admits, three spellings of that read still answered `409 RESOURCE_CONFLICT` naming the disabled package. Each now answers its bare by-name read's 404 and names no package, on `RestServer` and the runtime dispatcher alike: | read at `_env` | before | after | |---|---|---| | `?state=draft` (any case) | `409 RESOURCE_CONFLICT` naming the disabled holder | `404 NO_DRAFT` (the by-name draft read's answer, per the ADR-0150 2026-11-26 note) | | `?preview=draft` | `409` | `404 RESOURCE_NOT_FOUND` | | `?layers=true` | `409` | `404 RESOURCE_NOT_FOUND` | **Mechanism (measured, and it changes the suggested route).** The marked refusal (`DISABLED_HOLDERS_ONLY_REFUSAL`) used to be swallowed only for the plain read. If the three arms were simply judged by the plain read too, a leak opens. In the test with a draft-reading engine double, an enabled package C held a stored draft of the name and the registry did not hold it. The bare `?state=draft` and `?preview=draft` served C's draft to an admitted builder while the plain read withheld the name. So `_env` would have served C's draft. That ablation reds the new guard pin on all 20 types, on both transports. So `admitEnvironmentAddress` now judges **the read the caller is answered**: - the plain read must withhold the name, as before; - for an admitted draft switch, that same draft read (`getMetaItem` with `state: 'draft'` / `previewDrafts: true`, the arguments the item read sends) must withhold it as well. Its `404 NO_DRAFT` counts as withheld. If it serves an item or throws anything else, the refusal stands; - the layered view (`?layers=`, when the protocol has a layered read) is judged by the plain read. Its chain (`createMetaLayeredAnswer` step 1b) withholds every layer whenever the plain read withholds a disabled holder's item. The pins show this with C's draft and with C's unhydrated active row. The judge reads no draft switch of its own. It receives the switches the call site already declared with their `mayReadPendingDrafts` admission (`isDraftRead`, `previewDrafts` in the runtime, `answeredRead` on REST). So the `[objectstack-ai#20338]` draft-switch census in `meta-draft-read-builder-gate.test.ts` still counts exactly its ledgered sites. Landing: `packages/rest/src/meta-qualified-item-route.ts` and `packages/runtime/src/domains/meta.ts`, plus their tests and the changeset. One more file, outside the claimed surface: `scripts/engine-double-contract.pinned.json` gains two add-only rows. It is written by `node scripts/check-engine-double-contract.mjs --write`, because the two test files' `findOne` doubles now route through `assertEngineFindOnePredicate` and the gate's ledger records that pinned coverage. The producer of the mark, `packages/metadata-protocol/src/protocol-exact-qualifier.ts`, is untouched. **ADR text this makes stale (outside this PR's surface, `docs/adr/**`).** In ADR-0150's 2026-11-26 note, this sentence: "Three reads at `_env` still answer `409` at this head (`?state=draft`, `?preview=draft`, `?layers=true`), and card objectstack-ai#34261 carries their move to `404`." Proposed replacement: "At `_env`, `?state=draft` answers `404 NO_DRAFT` and `?preview=draft` and `?layers=true` answer `404`, each judged by the read the caller is answered; an enabled package's stored draft that the plain read does not see keeps the `409` for the draft reads (objectstack-ai#34261)." ## Tests - `packages/rest/src/meta-qualified-item-route.test.ts` and `packages/runtime/src/domains/meta-qualified-item-read.test.ts`: objectstack-ai#33995's CONTROL ("an admitted draft switch or the layered view refuses 409, as on main") is replaced, per type over `PACKAGE_SCOPED_READ_TYPES` (20 types), by two pins: - **the flip**: `_env` with `state=draft` / `DRAFT` answers `[404, NO_DRAFT]`, and `preview=draft` / `layers=true` answer `[404, RESOURCE_NOT_FOUND]`. This holds with no row and with a package-less draft (the holder's customization) stored, and the answer never names the holder or the draft. A caller not admitted to drafts still gets `[404, RESOURCE_NOT_FOUND]`. CONTROL: once re-enabled, each of the four refuses `409` naming the holder. - **the guard**: an enabled package's stored draft. The bare `?state=draft`, `?preview=draft` and `?package=C&state=draft` serve it (named, so the `409` leg cannot pass vacuously). `_env` draft reads answer `[409, RESOURCE_CONFLICT]` and never that draft. `?layers=true` answers 404 at the bare read and at `_env`. With C's unhydrated active row, `_env?layers=true` follows the plain read: `409` on the four row-served types, else `404`. CONTROL: an enabled registry holder's own draft is still served at the bare read, and `_env` refuses it naming that holder. - The engine doubles' `findOne` now reads the stored rows, behind a per-pin opt-in (`findOneReadsStoredRows`, reset in `beforeEach`). The old CONTROL's draft row was never readable through the old `findOne → null`. ## Acceptance notes - The `409` that remains for a draft read over an enabled package's stored draft names the disabled registry holder as its candidate, not the enabled package that holds the draft. Plain `_env` over an unhydrated active row already pins the same thing as a CONTROL (review#2 S4). This PR leaves it unchanged. - The FROM→TO 404 pins of objectstack-ai#33385 (plain `_env`) are unchanged. ## Verification All readings are on `objectstack-ai/objectstack`. The final head is `e24d418ae`, and the base is `7213177e`. <details><summary>Package suites (final head e24d418)</summary> - `pnpm --filter @objectstack/rest test`: Test Files 441 passed (441), Tests 9073 passed, 351 skipped (9424) - `pnpm --filter @objectstack/runtime test`: Test Files 656 passed (656), Tests 12521 passed, 25 skipped (12546) - `pnpm --filter @objectstack/rest --filter @objectstack/runtime typecheck`: exit 0, and `check:test-typecheck: OK` on both </details> <details><summary>Ablations (each restored with git checkout HEAD)</summary> - Draft-arm judge removed (the plain-read-only route), final head: REST 20 failed of 437, runtime 20 failed of 443. All failures are the stored-draft guard pin, one per type, and the assertion bodies show the gamma draft served at `_env`. - Source restored to base `7213177e` (test files kept): REST 40 failed of 437, runtime 40 failed of 443. Those are the flip pin (409 where 404 is pinned) and the guard pin's layered leg, 20 types each. </details> <details><summary>Local gate subset (dispatch-gates --commands, 83 families, final head)</summary> - 82 exit 0. `check:engine-double-contract` was red at the first head, because the `findOne` doubles did not route through the predicate. It is fixed in this PR and exits 0. - NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs --self-test` exits 3. Its pinned positive-control commit `621a4876` cannot be reached from this clone even after `git fetch --deepen=1500`. CI runs it. - `dispatch-gates --ran`: 83 derived, 83 run, 0 UNRUN. - `overlap-check.mjs`: VERDICT clean, merging cleanly against origin/main and against objectstack-ai#38497, which shares the pinned ledger file. </details> Two-minute check: `pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2 src/meta-qualified-item-route.test.ts -t "answers its own 404"` should show 20 tests passing. Then revert the `withholds(switches)` line in `meta-qualified-item-route.ts`: the "stored draft" pins should go red, with the gamma draft served in the assertion body. Read first: `packages/rest/src/meta-qualified-item-route.ts` `admitEnvironmentAddress` (the two-step judge), `packages/runtime/src/domains/meta.ts` (the same judge and its call site's `layeredView` choice), then the guard pin in either test file. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmRar3Kkg6SpwVgaaVE --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…ng declares (objectstack-ai#38648) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JeHmqv6CKCkW8ewrPBLekk)_ Fixes objectstack-ai#38623 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在 Studio、元数据接口或 AI 助手里保存或发布一条翻译时,如果它指向一个已经不存在的对象、字段、校验规则、里程碑或权限集,保存结果里会多出一条提示;以前保存显示一切正常,什么都不说。 - 属于“错误的元数据要被明确指出”这项构建能力:本地校验早就会报这类问题,线上保存却静默通过,这次替在 Studio 和 AI 助手里写翻译的作者补上这个缺口。 - 出错的最坏情况是对一条其实有效的翻译多报一条提示,保存本身照常成功、不会被拒;应用的导航菜单和应用名这类翻译这次仍不检查,可以直接撤回这次改动。 - 无。 ## What changes A `translation` item saved (active) or published over the metadata API now runs `validateTranslationReferences` at the runtime publish gate. An orphan key comes back as a `translation-target-unknown` **advisory** on the save and publish answer (`advisories`, severity `warning`). Before this, no rule ran on a `translation` write (`runtimeAuthoringRulesFor('translation')` was `[]`): the item was accepted as valid while `os validate` refused the same key. **Never a refusal.** Every finding on a translation write is a `warning`, so it lands in `advisories` and never in the 422 `errors`. A published item that names a key an upgrade removed still loads and saves. `os validate` keeps reporting the same key at `error`. **Families the door judges** (the ones the per-write snapshot carries, `RuntimeStackContext`: objects, permissions, books, datasets): - `objects.NAME`, only when the gate did not narrow `objects` to the write's package closure. The i18n layer is process-wide, so a translation may legitimately name an object outside its package's closure. - `objects.NAME.fields.FIELD`, and the field's `options` keys, only for a field that declares options inline. A picklist-bound field's served options are not in the snapshot. - `objects.NAME._validations.RULE` - `objects.NAME._milestones.FIELD.VALUE` - `permissions.NAME` **Not judged at the door:** apps and their navigation (platform-contributed nav items included), `_views`, `_sections`, `_tabs`, `_relatedLists`, `_actions`, `globalActions`, `dashboards`, `forms`, `pages`, `picklists`, `positions`, `reports`, `mappings`, `books` (the implicit per-package book is named by a package id the snapshot never sees), `flows`, `hooks`. Each resolves into a collection no per-write snapshot carries, so the door never guesses a key there unknown; `os validate` still judges all of them. Judging apps and navigation at the door would mean carrying served apps in the snapshot. That is a separate decision and not this card. The changes: - `authoring-rules.ts`: the `validateReferenceIntegrity` entry's `runtimeTypes` gains `translation`, so a translation write dispatches the suite. - `reference-integrity-suite.ts`: the `validateTranslationReferences` member gains `runtimeTypes: ['flow', 'translation']` and still hands its run context straight through. - `validate-translation-references.ts`: the rule reads `runtimeWriteType === 'translation'` off that context as its save-door reading. That is the signal the suite's other members already read for `wholeCollection`. In that reading the rule treats the entry as one item (keyed by its own `locale`), reduces the item to the judged families, and maps every finding to `warning`. - `runtime-gate.ts`: `TYPE_TO_STACK_KEY` gains `translation: 'translations'`. No context row is added, and no metadata-protocol source changes. - `scripts/engine-double-contract.pinned.json`: the three engine doubles the new protocol pin uses (`delete`, `findOne`, `update`) are recorded, written by `check-engine-double-contract --write`. - `content/docs/deployment/validating-metadata.mdx`: the "Reference integrity" row's runtime-publish cell gains `translation` (`✓ᶠᵛᵒᵈᵗʳᵖᵃᶜᵗ`), and its text says what a translation write runs. The superscript legend gains `✓ᵗ` `translation`, and the longest-first note now covers it. Nothing else on the page changes. The CLI reading is byte-identical: without `runtimeWriteType` the rule takes its old path, the whole rule at its own severities. **Control pins moved** (each held `translation` as the ungated control; it now crosses, so the control moves to a type that stays ungated; `tool`'s own control is untouched): - `packages/lint/src/authoring-rule-wiring.test.ts` ("a type nobody gated returns nothing"): `translation` → `doc` - `packages/lint/src/runtime-gate.test.ts` ("runs nothing for a metadata type no rule gates"): `translation` → `doc` - `packages/lint/src/runtime-gate.test.ts` ("returns null for an unmapped type"): `translation` → `doc` - `packages/lint/src/runtime-gate.inert-type-writes.test.ts` ("crossing these five widened no OTHER type s roster"): `translation` → `capability` - `packages/lint/src/runtime-gate.datasource-writes.test.ts` ("the types still awaiting their own readings are untouched"): `translation` → `capability`, and the comment says `translation` crossed on its own reading The seat's reading (7260663888 on objectstack-ai#38623) takes this card as the `translation` reading that the ADR-0049 group B line defers the wiring to. **Read these first** (ranked by risk): 1. `packages/lint/src/validate-translation-references.ts`: `doorJudgedSubset` and the `localeEntries` / `atSaveDoor` lines in `validateTranslationReferences`. This hunk decides what the door may judge; a family added here without its collection in the snapshot is a false advisory on every save. 2. `packages/lint/src/reference-integrity-suite.ts`: the member's `runtimeTypes`. 3. `packages/lint/src/authoring-rules.ts`: the entry's `runtimeTypes`. **Two-minute verification:** `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/runtime-gate.translation-writes-38623.test.ts` shows 9 passing. The removed field key, the orphan object, rule and milestone, and the orphan permission set come back in `advisories` with `errors` empty. Live keys and the unjudged families come back with neither. ## Tests New files, named for this card: - `packages/lint/src/runtime-gate.translation-writes-38623.test.ts`, through the gate's own entry (`runRuntimeAuthoringRules`): - the dispatch: suite on `translation`, exactly the translation member - a removed field → advisory, `errors` `[]` - an orphan object, validation rule and milestone → advisories - an orphan permission set → advisory - live keys → none - apps, navigation, global actions, positions, views and sections → not judged - a picklist-bound field's option keys → not judged - under a package closure, an object outside it is not judged while its sibling's removed field still is - the CLI reading is unchanged (a bundle, at `error`) - `packages/metadata-protocol/src/protocol.translation-target-door-38623.test.ts`, through the real `saveMetaItem` / `publishMetaItem` write path over a stub engine: - an active save naming a removed field → `success`, the advisory, and the row landed - a draft save says nothing (D1), and its publish answers with the advisory - a permission-set orphan → advisory - live keys → none - an already-published orphan neither blocks nor rides on an unrelated translation write <details><summary>Test runs: the new files at 8775b06; the whole-package readings at 66c22be (before the main merge, which brought no lint or metadata-protocol file)</summary> - At head 8775b06, under the verify lock, after a fresh build of the `@objectstack/metadata-protocol...` closure: `protocol.translation-target-door-38623.test.ts` Tests 5 passed (5), `runtime-gate.translation-writes-38623.test.ts` Tests 9 passed (9), `VERDICT command-exit 0`. The later docs commit changes no code. - `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2` (whole package): Test Files 247 passed (247), Tests 9977 passed (9977) - `pnpm --filter @objectstack/lint typecheck`: exit 0 (`tsc --noEmit` and `check:test-typecheck` OK) - `pnpm --filter @objectstack/metadata-protocol typecheck`: exit 0 - `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.translation-target-door-38623.test.ts`: Tests 5 passed (5) - The 29 metadata-protocol test files that mention `translation`: Test Files 29 passed (29), Tests 862 passed (862) </details> <details><summary>Ablation: the entry widening reverted</summary> `'translation'` removed from the entry's `runtimeTypes` through `scripts/ablation-replace.mjs`: - The anchor hit once and the mutation landed (blob 663f139 → 3068dd8e9df2). - lint was rebuilt, and `ablation-dist-preflight.mjs @objectstack/lint '"page", "action", "translation"]' --absent` confirmed the marker absent from all 20 built files. It had been present in the pristine `dist/runtime.js` and `dist/index.js`. Results on the mutant: - lint file: 5 failed / 4 passed. The dispatch case, the removed field, the orphan object, rule and milestone, the permission set and the closure case went quiet. Live keys stayed clean, and so did the unjudged-families, picklist and CLI cases. - protocol file: 4 failed / 1 passed. The active save, the draft publish and the permission set went quiet. The live-key save stayed clean. The already-published-orphan case also fails, because its first save asserts the advisory as a precondition. Restored: blob == HEAD (663f139) and `git diff HEAD` empty. lint was rebuilt, and the protocol file then read 5 passed (5). </details> ## Acceptance notes - **False positives, measured on `examples/app-showcase`'s real `ShowcaseTranslationBundle`** (en + zh-CN; context = the showcase's objects, permissions, books and datasets): - whole-stack `validateTranslationReferences`: 0 findings - the rule unrestricted on the door's snapshot: 85 phantom `translation-target-unknown`. By family: `_views` 28, `_sections` 19, positions 10, flows 10, dashboards 6, `_tabs` 4, reports 4, `globalActions` 2, apps 1, mappings 1. That is why the door judges only the families listed above. - this PR, through `runRuntimeAuthoringRules({ type: 'translation' })` per locale: errors 0, advisories 0 - the lit control on the same context (a removed `showcase_project` field) comes back as one `warning` advisory - A draft save is still never gated (objectstack-ai#4463 D1). The advisory appears on an active save and on publishing a draft, not on the draft save itself. - Found while measuring, not changed here: `os validate` refuses a bundle key under the platform `studio` app at the app level, whatever the navigation id (`translations[0]["zh-CN"].apps.studio`, "which this stack neither defines nor contributes into"), even for a live id such as `nav_api_console`. The lint's apps rung has no platform-app ladder; the objects rung has `isPlatformProvidedObjectName`. Reported to the seat with the CLI reproduction. ## Verification <details><summary>Local gates, derived with dispatch-gates --commands</summary> At head 9b075e6. Gates were derived with `node scripts/pm/dispatch-gates.mjs --commands` (105 families) and each exit code was captured before any pipe. The `--ran` reconciliation reads: 105 derived, 103 run, 2 NOT MEASURED (derived from a recorded exit 3), 0 unrun. - 68 code families were read at the code head: 266bea7, then 8775b06 for the ledger. The docs commit 9b075e6 changes only the page. - 37 families the docs path adds, all at 9b075e6: exit 0. They include `check-adr-links` with its self-test (the local half of Check Documentation Links; lychee runs only in CI, and the edit adds no link), `check:doc-anchors`, `check:doc-frontmatter`, `check:docs-redirects`, `check:docs-single-h1`, `check:docs-spec-enumerations`, `check:docs-audit-scope` and `@objectstack/spec` `check:docs`. - `@objectstack/spec` `check:skill-examples` first exited 3 (PREREQUISITE NOT MET: client SDK not built). After building `@objectstack/client-react...` and `@objectstack/client...` under the lock, it exits 0: "352 prose examples type-check across 3 surface(s)". - `pnpm check:engine-double-contract`: exit 1 before the ledger commit, exit 0 after it at 8775b06. - `pnpm check:objectql-double-limit`: exit 0 ("none new"). - `node scripts/check-nul-bytes.mjs`: exit 0. - `node scripts/pm/overlap-check.mjs --branch=HEAD` at 9b075e6: `VERDICT clean exit 0`. The branch merges cleanly with origin/main and with objectstack-ai#38643, objectstack-ai#38642, objectstack-ai#38594, objectstack-ai#38550 and objectstack-ai#38497. - NOT MEASURED: - `node scripts/check-plugin-teardown-shape.mjs --self-test`: exit 3 (shallow checkout). - `pnpm check:dual-build-cjs-loads`: exit 3 (needs a full `pnpm build`). - `pnpm check:dts-closure`: exit 1. The self-test passed. The scan's red came from a local build that skipped declaration output in an earlier worktree. `@objectstack/lint` and `@objectstack/metadata-protocol` were not among the packages it named. CI's fresh build gives the real reading. The families CI runs (the repo-wide lint, `test:repo`, Check Documentation Links' lychee step, the artifact roster) are read from this PR's check-runs. They were not re-run here. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmSwS4mQyXWrddL4r6B --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
… a flow the deployment does not hold (objectstack-ai#38594) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Jianguo** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbJg9RAhiuDxvothojbXXC9Z)_ Fixes objectstack-ai#35143 Supersedes objectstack-ai#38241 (closed, 7256687325) Clause-②: yes (narrowing) Metadata-protocol: narrowed Skills-docs: follow-up objectstack-ai#38259 — skills/objectstack-automation/SKILL.md (the `subflow` row says `os validate` warns `flow-subflow-unknown`; it does not say the publish refuses a call to a flow nothing in the deployment holds), skills/objectstack-automation/evals/flows-triggers-approvals.json (the eval that names `flow-subflow-unknown`) ## 维护者速读 - 用户能看到什么变化:搭建者(包括 AI)发布一个流程时,如果其中“调用子流程”或“逐项调用流程”的步骤写了一个整个环境里都不存在的流程名,发布现在会直接被拒并说明原因;以前能发布成功,但每次运行到这一步都会失败。命令行校验仍然只给警告。 - 为什么做:属于“开源框架先拦住云端构建检查才拦得住的问题”这一族收尾(流程族最后两条),替写流程的搭建者挡住“发布成功、运行必失败”。 - 出错会怎样:这是一次收紧——以前能发布的这类流程下次发布会被拒;被调用的流程只要以草稿形式存在、或在同一批次发布、或在同一个软件包安装里(顺序不限)、或由已安装的软件包提供,都不会被拒;用另一个命名空间安装的软件包副本若有流程调用同包流程,安装会被整体拒绝并回滚(改名没有改到调用处,以前装得上但这一步必失败);撤回本改动即恢复原样。 - 要你做什么:无 ## What changes The card's last two open lines, re-verified on `main` (1208460) first. **F1, option label in decision-node and edge conditions: already covered on `main`, no change here.** `flow-condition-option-label` reads every edge condition and every `decision` node's `conditions[].expression` (and query filter operands) since objectstack-ai#37491 (`optionLabelsBeyondStart` in `validate-flow-trigger-readiness.ts`, at `error`, same id, runtime gate and CLI). Its positive and negative pins are in `flow-publish-checks-second-batch.test.ts`, describe "past the start condition". The card gets a line saying so. **F6, a `subflow` / `map` step calling a flow that does not exist: now refused at the publish gate.** It was a CLI-only warning because the gate's per-write snapshot holds just the written flow. The gate now judges the call against the names of every flow the deployment holds, which the host states on a flow publish: - every installed package's flows (the registry, read with `includeDisabledPackages`, so a disabled package's are included); - the stored flow rows of **every state**, drafts included, so two new flows that call each other can still be published one at a time; - the flows the same publish batch carries (`pending.flows`), so a package that ships a flow with its caller publishes; - the flows the same unmanaged package install writes (`copyPlanFlowNames`, new in this head), so a package whose flow calls a sibling it declares later installs; - every flow the automation engine holds (`listFlows`), so a flow registered straight into the engine with no metadata row resolves. A call that names none of them, and is not the written flow itself, is an `error` (`flow-subflow-unknown`): `execute` answers `Flow 'X' not found` on every run. Severity per door: - **CLI** (`os validate` / `lint` / `compile` / `build`): `warning`, unchanged. The stack is one app, and another installed package may ship the called flow. - **Runtime publish gate, names stated and non-empty**: `error`. The set is the whole deployment, so "held nowhere" is decided, the objectstack-ai#24668 reading of a whole collection. - **Runtime publish gate, no names or an empty set**: no verdict. That covers no automation service, a failed store read or a failed `listFlows` (each logged once at `warn`) and an empty set. A missing `sys_metadata` table is no stored flow: the other sources still decide. An empty set with no closure is no universe (objectstack-ai#24668). - **Package closure**: the set is never narrowed to the written package's closure. So a call the engine's package-scoped resolution would refuse (ADR-0150 D3, `outside-closure`) is not judged here. This rule never refuses a call the engine would accept. Wiring: - `@objectstack/lint`: `validateFlowSubflowTargets(stack, { deploymentFlowNames })`, the `AuthoringRuleContext.deploymentFlowNames` input, and `runRuntimeAuthoringRules({ deploymentFlowNames })`. The rule's registry entry moves to `tier: 'gating'`, `surfaces: CLI_AND_RUNTIME`, `runtimeTypes: ['flow']`. Its runtime pass judges nothing without stated names. The rule's explanation text is updated. - `@objectstack/metadata-protocol`: `evaluateRuntimeAuthoringGate({ deploymentFlowNames })` adds the batch's flow drafts. `judgeRuntimeAuthoringRules` reads the names only on a flow write whose body calls another flow (`flowCallsAnotherFlow` in `runtime-authoring-gate.ts`; `deploymentFlowNamesOf`, `automationFlowNames`, `registeredFlowsWithDisabled` in `protocol-authoring-gate.ts`), through the host's existing `servicesRegistry`; the registry is listed with its disabled packages, since the served listing drops their items. The stored names are one `sys_metadata` read, `type` `$in` both spellings, projected to `fields: ['name']`. `saveMetaItem` takes a server-only `copyPlanFlowNames` (`protocol-door-requests.ts`), which `importUnmanagedPackage` states on each flow write and the save door hands the gate as `pending.flows`. `protocol.ts` moves no line: one docblock (the `pending` field) is reworded in place. - `@objectstack/spec`: the ADR-0087 entry `publish-refuses-flows-that-save-and-do-not-run` now counts eight errors at the publish gate, seven of them also on the CLI: its `surface` names the `subflow` / `map` refusal, the warnings sentence says which door each warning is silent at, the acceptance line is no longer seven, and the reason says what holds for a package install. No rule is added, so no "author-time rules (N)" count moves. ## Rework on contract review 7238045522 (FAIL at `bc21970eab`) This PR continues objectstack-ai#38241 (seat 6's branch `claude/issue-35143-flows-leftovers`, whose dev ran out of budget). It starts at that head, merges `main`, and closes every open item of the review: - **M1** (an unmanaged install refused a package whose flow calls a sibling declared after it): `importUnmanagedPackage` states its plan's flow names on each flow write (`copyPlanFlowNames`), which reach the gate as `pending.flows`, the batch's channel. Pinned in `package-unmanaged-install.test.ts`, describe "a flow calling a sibling flow of the same package": a package declaring `crm_parent` (calls `crm_child`) before `crm_child`, on a protocol whose automation service holds another flow, installs both; the control (a call to a flow nothing holds) is still refused 422 and leaves no row and no base. `duplicatePackage` is unchanged: it copies stored rows, which the gate's stored read already holds (the review's own reading). - **S1** (every flow body read for names, on every flow publish): one read, both type spellings, `fields: ['name']`; none at all for a flow that calls no other flow, or only itself. Pinned on the shared harness. - **S2** (the entry still counted seven): `surface`, `reason` and `acceptanceCriteria` rewritten as above. - **S3** (three no-verdict exits unpinned): one pin each through `saveMetaItem` on the shared harness: a store read that throws (accepted, one `warn`), a `listFlows` that throws (accepted, one `warn`), and a missing `sys_metadata` table (no `warn`; a call to an engine or registry flow is accepted and a call to nothing is still refused). - **N1**: the `sealedFlowNodeTypeVocabulary` docblock is back above its function. N2–N5 are left as the review graded them (no effect on correctness); see the acceptance notes. ## Patch round on contract review 7257069704 (PASS, S4 open at `a7c00fdd85`) - **S4** (the texts said a disabled package's flows count; the gate read the served registry listing, which drops them): the first closing condition. The names read lists the registry with `includeDisabledPackages: true` (`registeredFlowsWithDisabled`), so a call to a disabled package's flow is let through, as a draft is: the flow is held, and runs once its package is enabled. The docblock, the changeset and this body now say what the code does. Pinned through `saveMetaItem`; removing the option fails the pin. - **N6, N7, N8** in the same commit: the entry's `reason` gives the right cause (the install states its flow names) and says the rename covers prefixed names only; the `pending` docblocks, the lint docblocks and the `os explain` text name a package install's flows and a disabled package's; the changeset's Exports bullet names `saveMetaItem`'s `copyPlanFlowNames` and no longer names `evaluateRuntimeAuthoringGate`. N9 and N10 stand as accepted. ## Why objectstack-ai#35143 "Done when": each line is a rule with its pins, or a line on the card saying which rule covers it. F1 is the second case and F6 is now the first. The hosted copy of the subflow check can be deleted. ## Tests <details><summary>Lint: new pins in flow-publish-checks-second-batch.test.ts (describe flow-subflow-unknown)</summary> - CLI: still exactly one `warning`. - Runtime gate refuses a call to a name the stated set lacks: `error`, path `flows[0].nodes[1].config.flowName`, message opening, `rulesRun` names the rule. - A `map` call inside a loop body: `error` at `flows[0].nodes[1].config.body.nodes[0].config.flowName`. - Silent: a name the stated set holds, the written flow calling itself. - No verdict: no stated names, an empty set. </details> <details><summary>Metadata-protocol: the describe in protocol.runtime-authoring-gate.test.ts (the shared harness), end to end through saveMetaItem</summary> - 422 `INVALID_METADATA`, issue `flow-subflow-unknown` at the path, nothing stored. - Accepted: a flow only the automation engine holds, an installed package's flow (registry), a stored draft, a stored active flow. - No automation service: accepted (no verdict). - New (S4): a flow only a DISABLED package ships (listed by the registry only with `includeDisabledPackages`) resolves; a call to nothing in the same case is still a 422. - New (S1): the stored names are read once, `{ where: { type: { $in: ['flow', 'flows'] } }, fields: ['name'] }`; a flow calling only itself, and a flow with no call, read nothing. - New (S3): a store read that throws, accepted with one `warn` naming the cause; a `listFlows` that throws, the same; a missing `sys_metadata` table, no `warn`, engine and registry flows still resolve and a call to nothing is still a 422. - `evaluateRuntimeAuthoringGate`: a flow in `pending.flows` resolves; without it the call is refused. </details> <details><summary>Metadata-protocol: new describe in package-unmanaged-install.test.ts (M1)</summary> - A package declaring `crm_parent` (a `subflow` step calling `crm_child`) before `crm_child`, with an automation service holding `other_flow`: installs, both flows stored active. - Control: `crm_parent` calling `crm_nowhere`: refused 422 with `flow-subflow-unknown`, no active row left, the base `com.example.crm-copy` removed. - Reading, not pinned: the same package installed with `targetNamespace: 'crm2'` is refused 422 (`flow 'crm2_parent' could not be written … flows[0].nodes[1].config.flowName [flow-subflow-unknown]`) and rolled back, because the rename does not rewrite `config.flowName`; see the acceptance notes. </details> <details><summary>Ablations (each fix removed on disk from the committed head, then restored with git checkout HEAD)</summary> - `importUnmanagedPackage` states no `copyPlanFlowNames`: "installs a package that declares the calling flow before the flow it calls" fails (1 failed / 1 passed). - The names read for every flow write (the `flowCallsAnotherFlow` guard dropped): "reads the stored names once …" fails (1 failed / 7 passed). - At 93f3643, the registry read without `includeDisabledPackages`: "lets a call through to a disabled package's flow …" fails (1 failed). </details> <details><summary>Suites (head 93f3643, main merged at 3014176; under os-verify-lock)</summary> - `@objectstack/lint` test: 246 files / 9962 tests passed. typecheck exit 0. - `@objectstack/metadata-protocol` test: 372 passed / 9 skipped files, 23660 passed / 45 skipped tests. typecheck exit 0. `protocol.runtime-authoring-gate.test.ts` + `package-unmanaged-install.test.ts`: 383/383. - `@objectstack/spec` `src/migrations`: 5 files / 209 tests. - Dogfood battery: head 93f3643, `pnpm --filter @objectstack/dogfood test` under the lock after a clean closure build (exit 0): VERDICT command-exit 0, Test Files 495 passed / 3 skipped (498), Tests 4187 passed / 68 skipped (4255), no failure. </details> ## Acceptance notes - Not judged: whether the engine's package-scoped name resolution lets the calling flow reach the called one (ADR-0150 D3). The set is the whole deployment, so an `outside-closure` call still fails at run time. Judging that would need the resolver's verdict at the door. - A call to a stored draft, or an archived or deprecated row, is let through. The step fails until that flow is active. This keeps two new flows that call each other publishable one at a time. - The stored read for names is not filtered for legacy organization rows. An extra name can only let a call through. - A package install under another namespace (`targetNamespace`) renames its flows but not the `config.flowName` that calls them, so a package whose flow calls a sibling is now refused and rolled back unless the deployment holds the old name. On `main` it installed with a step that fails on every run. Making the rename follow flow names is outside this card; reported to the seat as a finding. - A plan flow name counts even if that flow's own write then fails: the install then rolls back whole, so no caller is left pointing at it. - Not addressed, as graded (nits): N2 `listFlows` is read with no seal; N3 the empty-set exit depends on the door; N4 the "did you mean" suggestion draws on the unfiltered stored read; N5 `rulesRun` names the rule on a write where it judged nothing. ## Verification - Read first: `packages/metadata-protocol/src/protocol-package-commits.ts` `importUnmanagedPackage` (`copyPlanFlowNames`) with `protocol-save.ts` (where it becomes `pending.flows`); `packages/metadata-protocol/src/protocol-authoring-gate.ts` `deploymentFlowNamesOf` (the union, the projected read, the no-verdict exits), `packages/lint/src/authoring-rules.ts` the `validateFlowSubflowTargets` entry (runtime pass with no names = nothing), `packages/lint/src/validate-flow-trigger-readiness.ts` `validateFlowSubflowTargets`. - Two minutes: `pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.runtime-authoring-gate.test.ts src/package-unmanaged-install.test.ts -t '35143|sibling flow'`. Expect 11 passed, among them a 422 naming `flow-subflow-unknown` and a package install of a caller before its callee. <details><summary>Gates (head 93f3643)</summary> - `dispatch-gates --ran` at 93f3643, run after the closure build: 103 derived, 102 run (all exit 0), 1 NOT MEASURED, 0 unrun (`✓ dispatch-gates --ran: 103 derived famil(ies) accounted for`). - `check:dual-build-cjs-loads` exit 3: needs a full workspace build. Left to CI. - `overlap-check` (`--exclude-pr=38241`) at a7c00fd: clean against origin/main 3014176 and the two open PRs sharing a file (objectstack-ai#38550, objectstack-ai#38497). The 93f3643 commit touches only files of this PR. - `protocol.ts` moves no line, so `check:facade-delegation-only`'s ceiling is untouched (exit 0 in the sweep). </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (CI-owned run). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: only a migration entry's text, no generated artifact moves. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QsR2jSjBfkaFUVwRa3pdUK <!-- signed: repo:objectstack#1 · zhuangjianguo · session_01QsR2jSjBfkaFUVwRa3pdUK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…s own flows (objectstack-ai#38642) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_ Fixes objectstack-ai#38595 Clause-②: no Metadata-protocol: none ## 维护者速读 - 管理员把一个应用包以新的命名空间安装或复制之后,复制出来的流程调用的是复制包自己的子流程,按钮触发的也是复制包自己的流程;以前调用的是原包的流程,或者因为找不到流程而每次运行都失败。复制时如果调用方流程排在被调用流程前面,现在两个流程都会复制成功,不再被保存检查拒掉调用方;如果被调用的流程本身复制失败,调用它的流程也一并列为失败并撤回,不会留下指向不存在流程的调用。 - 属于"软件包安装与复制"这块能力,替用新命名空间安装应用包、或复制一份应用包来改的管理员解决"复制后流程跑不起来或串到原包"的问题。 - 只影响带新命名空间的安装和复制;如果改名规则出错,复制包里的某个流程调用会指向错误的名字,原包不受影响,可以直接撤回这次合并恢复原来的行为。 - 无 ## What changes `planNamespaceRename` (`packages/metadata-protocol/src/package-namespace-rename.ts`), the one rename engine behind the unmanaged install's `targetNamespace` and `duplicatePackage`, renamed a package flow under the prefix swap (`crm_child` to `crm2_child`) but rewrote no name that calls it. It now builds a flow rename map from the package's own `flow` items and rewrites a value that EQUALS a renamed flow name, whole, at: - the derived index's `flow` sites, `REFERENCE_SITES.byTarget.get('flow')`, read the same way the object sites are (by property, wherever it occurs). Dumped at runtime on this tree it holds `{fromType:'flow', property:'flowName'}` and `{fromType:'translation', property:'flows'}`, so a `subflow` step's `config.flowName` and a translation's `flows` keys follow; - the one hand-written site, commented as such in the code: a `target` whose sibling executor is `'flow'`. That is `type: 'flow'` on an action (`ActionSchema`, an object's `actions[]`, an inline action, an `action:group` member, an API endpoint) and `actionType: 'flow'` on an `action:button` / `action:icon` page block, where `type` is the component. The index cannot carry `target`, because on every other executor it names a URL, script, page, endpoint or form, and a property-wide site would rewrite those too and list them in the "Used by" answer. A flow the package does not hold keeps its name, a flow the prefix swap keeps keeps its name, and nothing is substring-rewritten. A value that is not a renamed flow name falls through to the rules every string already took, so nothing that read the same before reads differently now. Collisions work as they do for objects: a renamed flow name that meets a name the item already holds at that site (a translation keyed by both `crm_child` and `crm2_child`) refuses the item, and the refusal names the flow. The internal `atReference: boolean` of the walk became the site's rename map (object or flow), so both kinds share one walk and one collision rule. **This round (delta after PR objectstack-ai#38594 merged as d33183a).** `origin/main` was merged into this branch with a merge commit (3a7134a, no conflicts). With both changes on one tree, a parent-first `duplicatePackage` was refused by the publish gate (measurement below). So the `duplicatePackage` leg's `host.saveMetaItem` call in `protocol-package-commits.ts` now passes `copyPlanFlowNames` on a flow write, the unmanaged-install leg's way: the copy names (`rename.copyName`) of every flow row the same duplicate writes. On a non-flow write nothing is passed. The gate's rule itself is not touched; the names are additive (`pending.flows`), so they can let a call to a flow of the same copy through and refuse nothing. **Third round (L1 REWORK 7267334209, route per claim amendment 7267347516).** `duplicatePackage` is best-effort, so a planned flow can still land in `failed[]` after the gate passed its caller on the plan's word. The duplicate leg now closes its flow plan after the copy loop. Each copied flow whose `subflow` / `map` step calls a planned flow (its copy name) that was not written is taken back out of the copy, through the same `undoBatchRowWrite` the object settle uses. It is reported in `failed[]` with an error that names that callee. This repeats until nothing changes, so a caller's caller goes too. The loop reads a caller's address before and after its write for that undo, only when the caller calls a planned flow. The plan is now one list built before the loop (`planFlowSources`). The callee walk uses the spec's `FLOW_REGION_SLOTS_BY_TYPE`, the region table the publish gate walks. The install leg is not touched. ## Tests <details><summary>Engine pins, package-namespace-rename.test.ts (7 new cases)</summary> `flowName` follows; `other_flow`, an unprefixed `bare_child` and a superstring `crm_child_v2` keep their names; a flow action's `target` follows while `modal` / `script` / `api` targets equal to the same string do not; the object `actions[]`, API endpoint and page `actionType` spellings; translation `flows` keys; the collision refusal; and a copy that keeps the source namespace renames nothing. </details> <details><summary>Door pins, new package-namespace-rename-flow-refs-38595.test.ts (6 cases)</summary> The harness (`makeEngine`, `crmBody`) is copied from `package-unmanaged-install.test.ts`, which is not edited. Its automation service answers `listFlows`, so a gate that judges a step's called flow has a non-empty universe. - an unmanaged install with `targetNamespace: 'crm2'` installs, and the stored `crm2_parent` calls `crm2_child`; - the copied flow action reads `target: 'crm2_child'`, and the `modal` control keeps `target: 'crm_child'`; - with the source package installed under its own names beside the copy, the copy's `crm2_parent` calls `crm2_child`; - a call to `other_flow` keeps its name; - `duplicatePackage` into `crm2` gives the same result with the source installed, and the source still calls `crm_child`; - parity: the duplicate and the import into `crm2` store identical flow and action items. </details> <details><summary>Stacking measurement (this round), new describe in package-namespace-rename-flow-refs-38595.test.ts (2 cases)</summary> The source package is installed with its stored flow rows in the order `crm_parent` (a `subflow` step calling `crm_child`), then `crm_child`; the test asserts that order. It is then duplicated into `crm2`. The automation service holds `other_flow`, `crm_child`, `crm_parent`, never `crm2_child`. Measured at 2af21e1 (merge of `main` plus the test, before the fix), the gate refuses. `duplicated.failed` was, verbatim: ``` [{ type: 'flow', name: 'crm_parent', error: 'flow/crm2_parent failed author-time validation: 1 issue — flows[0].nodes[1].config.flowName [flow-subflow-unknown]' }] ``` and only `crm2_child` was copied (`Tests 2 failed | 6 passed (8)`). With the fix (300cf74) the case passes: `failed` is empty, both flows are stored and `crm2_parent` calls `crm2_child`. CONTROL, the gate is live in this harness: a third flow `crm_caller` calls `crm_ghost`, which the engine holds at the source install and no longer at the copy, and the package holds no such flow. The copy keeps the name `crm_ghost`, and with the fix the duplicate still refuses exactly `flow/crm_caller` with `flow-subflow-unknown` while both other flows are copied. So the plan names let through only the copy's own flows. </details> <details><summary>Withdrawal pins (third round), same describe (2 cases)</summary> - (a) L1's parent-first case. `crm_parent` calls `crm_child`, and `crm_child` calls `crm_ghost`, which the engine holds at the source install and drops before the duplicate. `failed` holds `flow/crm_child` and `flow/crm_parent`, and the parent's error names `'crm2_child'`. No flow of the copy is stored, no stored copied flow calls a flow the deployment does not hold, and the copy's object is still copied. - (b) A two-level chain, `crm_a` to `crm_b` to `crm_c`, with `crm_c` calling the dropped `crm_ghost`. All three end in `failed[]` (the errors of `a` and `b` name `'crm2_b'` and `'crm2_c'`). `crm2_solo`, outside the chain, is the only copied flow, and nothing copied calls a missing flow. - The success pins and the `crm_ghost` CONTROL pass unchanged: `Tests 10 passed (10)` for the card file at 712fda7. Ablations, each run after the fix commit 28e4856 with `scripts/ablation-replace.mjs`: - Cascade off: `if (withdrawn.length === 0) break;` became `if (withdrawn.length >= 0) break;` (blob `4ca8e112244c` to `6eec66471fb7`). Result: `Tests 2 failed | 8 passed (10)`. (a) fails with `expected [ 'flow/crm_child' ] to deeply equal [ 'flow/crm_child', 'flow/crm_parent' ]`, which is L1's measured state, and (b) fails with `expected [ 'flow/crm_c' ] …`. - Transitive step off: the line that marks a withdrawn caller as not written was deleted (blob `4ca8e112244c` to `378006812f35`). Result: `Tests 1 failed | 9 passed (10)`. Only (b) fails, with `expected [ 'flow/crm_b', 'flow/crm_c' ] …`. - Both times the tool restored the file: blob equal to HEAD, and `git diff HEAD` empty. </details> <details><summary>Ablation of the second round's line</summary> The fix was committed first (300cf74). `node scripts/ablation-replace.mjs` replaced the guard `...(singular === 'flow'` of the new spread with `...(false` (anchor 1 to 0, blob `d064b03b149a` to `f110fae517f4`). The card test file then failed both new cases (`Tests 2 failed | 6 passed (8)`): the parent-first case with the refusal above, the CONTROL because `crm2_parent` was refused beside `crm_caller`. The tool restored the file: blob equal to HEAD, `git diff HEAD` empty. </details> <details><summary>Package run at 712fda7 (third round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2` under the verify lock: `VERDICT command-exit 0`, `Test Files 374 passed | 9 skipped (383)`, `Tests 23690 passed | 45 skipped (23735)`. The 69 families `dispatch-gates --commands` derives for this round's four paths: 67 exit 0. `check:dual-build-cjs-loads` and `check:lean-entry-closure` exit 3 (PREREQUISITE NOT MET: they read every package's `dist`), so they are NOT MEASURED here and left to CI. `overlap-check`: clean. </details> <details><summary>Package run at 964a326 (second round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2` under the verify lock, after building the closure (`pnpm --filter '@objectstack/metadata-protocol^...' build`): `VERDICT command-exit 0`, `Test Files 374 passed | 9 skipped (383)`, `Tests 23688 passed | 45 skipped (23733)`. The card pins after the merge (`package-namespace-rename-flow-refs-38595.test.ts`, `package-namespace-rename.test.ts`, `package-unmanaged-install.test.ts`): `Test Files 3 passed (3)`, `Tests 152 passed (152)`. </details> <details><summary>Package run at 5ec669b (first round)</summary> `pnpm --filter @objectstack/metadata-protocol typecheck && … exec vitest run --maxWorkers=2` under the verify lock: `VERDICT command-exit 0`, `Test Files 373 passed | 9 skipped (382)`, `Tests 23670 passed | 45 skipped (23715)`. The typecheck program lists the test files. </details> <details><summary>Ablation</summary> The fix commit came first. Then `scripts/ablation-replace.mjs` swapped the one line that fills the flow rename map for a no-op (anchor 1 to 0, blob `e90813508b99` to `114356add0b3`). With that in place, 9 of the 13 new cases failed (`Tests 9 failed | 26 passed (35)`): every rewrite pin on both test files. The four that stayed green were the three controls and the parity case, which stays equal when both doors are equally wrong. The tool then restored the file: the blob matched HEAD again and `git diff HEAD` was empty. </details> <details><summary>Under PR objectstack-ai#38594's gate (head 93f3643)</summary> In a throwaway tree at that head, with this branch's two commits cherry-picked, the closure was built and both test files passed (`Tests 42 passed`). With the same ablation there, the install pins fail with the gate's own 422: `INVALID_METADATA`, `flow-subflow-unknown` at `flows[0].nodes[1].config.flowName`, "calls flow 'crm_child' … Did you mean crm2_child". So the gate is live in this harness and the pins pass under it, without depending on its code. The tree was removed afterwards. </details> ## Acceptance notes - **The parent-first duplicate is fixed in this PR now.** The first round reported that with this branch and PR objectstack-ai#38594 both applied, a parent-first `duplicatePackage` fails `flow-subflow-unknown` and writes only the child. PR objectstack-ai#38594 merged without a copy-plan on its duplicate leg, so the seat routed the fix here (claim amendment 7266007014). It was re-measured on the merged tree (see Tests) and fixed on the duplicate leg's `saveMetaItem` call alone. - The `copyPlanFlowNames` doc comment in `protocol-door-requests.ts` said "`duplicatePackage` copies stored rows, which the gate's own read of the stored flows already holds". That stopped being true once the copy's calls name the copy's flows. Per claim amendment 7266793287, 48420e0 rewords that comment only: both copy doors state the field, the names the same copy writes under their written names. In the third round (712fda7), the comment and the changeset sentence say the gate is told the flows the copy PLANS to write. They also say that on the duplicate, a caller whose planned callee was not written is withdrawn with it. No logic changes; metadata-protocol typecheck exits 0, and the 48 families `dispatch-gates --commands` derives for that path ran with 46 at exit 0 and `check:dual-build-cjs-loads` / `check:lean-entry-closure` at exit 3 (PREREQUISITE NOT MET, left to CI). - Measured with the same engine probe, outside this card: the names of other non-object items (dashboard, page, report) are renamed by the prefix swap, but their references are not. That covers app navigation's `dashboardName` / `pageName` / `reportName` and a translation's `dashboards` / `pages` / `reports` keys. A dashboard header action with `actionType: 'flow'` keeps its `actionUrl`. These are reported to the seat as one family. They are not fixed here. - Outside the dispatched file surface, added by the PM's amendment: `scripts/engine-double-contract.pinned.json` gains 3 rows (15 lines) for the new test file's copied stub engine, produced by `node scripts/check-engine-double-contract.mjs --write`. No existing row changed, and `pnpm check:engine-double-contract` exits 0 at fb44b0f and again at 964a326. - Local gates at 964a326: the 77 families `dispatch-gates --commands` derives for this diff were run; 75 exit 0, and `check:dual-build-cjs-loads` and `check:lean-entry-closure` exit 3 (`PREREQUISITE NOT MET`: they read every package's built `dist`, which this worktree built only for the closure), so those two are NOT MEASURED here and are left to CI. `overlap-check`: clean against `origin/main`, objectstack-ai#38618 and objectstack-ai#38497. - Read, not changed (for the seat): whether `importUnmanagedPackage` has the same gap on partial failure. It does not, as read at 712fda7. Its prepare pass refuses the whole install before the base exists if any item fails to convert or rename (422 or the rename refusal). Its `copyPlanFlowNames` is built from `prepared`, which is exactly the items the write loop writes. Any `saveMetaItem` throw in that loop, and any object the batch settle refuses, goes through `rollBackUnmanagedImport`, which deletes the whole new base. So on success every planned flow is written, and on failure nothing remains. The one residue is a rollback that itself fails. It is not silent: `console.error`, plus an answer saying the base could NOT be fully removed and must be uninstalled. ## Verification Read first, by risk: 1. `protocol-package-commits.ts`, the `duplicatePackage` leg's close: the withdrawal block after the copy loop (the fixpoint, the undo and the error text), and `plannedCalleesOf` with `planFlowSources` above the loop. Check that a withdrawn caller is removed from `copied` and pushed to `failed[]` exactly once. 2. `package-namespace-rename.ts`, the `deepRewrite` object branch: the child-site expression `referenceSiteOf(k) ?? (site && k === 'name' ? site : flowTargetSite(v, k))` replaced the old boolean. Object sites must behave exactly as before. 3. `package-namespace-rename-flow-refs-38595.test.ts`: the parent-first duplicate and its CONTROL, the source-still-installed case and the duplicate parity. (`flowTargetSite` and `FLOW_EXECUTOR_KEYS` in `package-namespace-rename.ts`, the one hand-written site, were read in the first round's review.) Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/package-namespace-rename-flow-refs-38595.test.ts src/package-namespace-rename.test.ts` should report 2 files and 39 tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQJUGAAa5rz9Yi2DvW <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmQJUGAAa5rz9Yi2DvW --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
… whose documentBy is not a single-valued parent link (objectstack-ai#38662) <!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8Xj6YfMRKw8XnmTA1ohBr6K)_ Fixes objectstack-ai#38537 Clause-②: no Metadata-protocol: none **Lands after objectstack-ai#38594** (merged 2026-11-30T01:10Z; main merged into this branch at `d1e1ba3f03`). Both PRs are seat 2's. The overlap is two files (`packages/lint/src/index.ts`, `packages/lint/src/rule-explanations.ts`), in hunks far apart; `overlap-check` reads both clean against each other and main. ## 维护者速读 - 用户能看到什么变化:知识源的“文档单位”(`documentBy`)如果填的不是指向父记录的单值查找字段,`os validate` / `os build` / `os lint` 和发布时都会报错并说明怎么改。之前只有在 Studio / 元数据 API 保存时才会拒绝。 - 为什么做:随包发布或代码注册的知识源不经过保存这道门,填错了没人拦,检索按父记录聚合会悄悄失效。这是 objectstack-ai#38537 的第二个也是最后一个 PR。 - 出错会怎样:只影响声明了 `documentBy` 的知识源;规则误判会让正确的知识源发布失败,删掉 `documentBy` 即可绕开。 - 要你做什么:无。 ## What changes - **New rule** `knowledge-source-document-by-not-parent-link` (`error`) in `validate-knowledge-source.ts`. It refuses a `source.documentBy` that `metadataFields` lists and that is not a single-valued parent link of the indexed object. The checks run in the save door's order: declared by the object, neither credential-class nor `internal`, a `lookup` / `master_detail` type, a target `referenceTargetOf` can read, and not `multiple: true`. Each reason gets its own message, worded like the save door's `documentUnitRefusalText`, naming the field and the fix. Path: `knowledgeSources[i].source.documentBy`. - **Where it runs.** The rule rides the existing `validateKnowledgeSource` registry entry, so it reaches `os validate` / `build` / `lint` and the runtime publish gate (`knowledge_source` writes) with no new wiring. This is what judges a source a package ships or code registers; until now only the metadata API's save door did (objectstack-ai#38564). - **Not judged twice.** A `documentBy` that `metadataFields` does not list is left to the parse, which already names that fix. A member the object does not have is reported once, as `knowledge-source-field-unknown`. An object with no readable field map is not judged. - **Published and explained.** The rule id is re-exported from the root barrel (`index.ts`, one line in the knowledge block). `rule-explanations.ts` gets its `os explain` entry and table row beside the five sibling rules. - **Census pin** (`packages/core/src/security/second-object-read-exposure.pin.test.ts`): the new `referenceTargetOf` import makes `validate-knowledge-source.ts` a caller of the reference-target arbiter, so it is classified `not-a-served-read` beside the other lint callers. It only asks whether a target is declared, and reads and serves nothing of the target. Admitted by the seat for this fix after CI's Test Core (8/12) flagged the unclassified caller. Locally: 1 failed / 3 passed before the entry, 4/4 after. - **Changeset** `patch` for `@objectstack/lint`. ## Route chosen for the parent-link rule (objectstack-ai#38564's PR 2 question) objectstack-ai#38564 left PR 2 two ways to reach `parentLinkRule` / `documentUnitOf` (`service-knowledge`'s `knowledge-search-scope.ts`). The seat accepted a third: - **A: lint imports `@objectstack/service-knowledge`.** Not taken. `@objectstack/lint`'s package description says it "Depends on @objectstack/spec; never on a runtime", and service-knowledge is a runtime service. It would also need a new line on service-knowledge's `exports` surface. - **B: move the rule to "a package lint already reads, for example `@objectstack/core`".** Not taken. Lint does not depend on `@objectstack/core`; its workspace dependencies are `formula`, `metadata-core`, `sdui-parser` and `spec`. Moving it to `spec` would put runtime-shaped logic into the protocol package and widen this PR well past its card. - **C (taken): compose the verdict in lint from the spec predicates `parentLinkRule` itself asks.** Withheld = `isMaskedOnReadFieldType(type, managedBy)` or `internal === true`. That is the reading this file already takes for `knowledge-source-field-never-indexed`, and the one `collectCredentialWriteResponseFields` / `collectInternalWriteResponseFields` compute in core. Target = `referenceTargetOf` (`@objectstack/spec/data`). The type pair `lookup` / `master_detail` is spelled locally, as eight other lint rule files already spell it. Cost: the four-part rule now lives in two places. No test pins their agreement, because no package that depends on both can import `documentUnitOf` without one more barrel line in service-knowledge. The module header names the save door's function so a change to one points at the other. ## Why ADR-0161 K4: "a packaged item meets the gates that need no principal in `os validate` and at publish". `documentBy` is such a gate: it reads only the object definition. objectstack-ai#38564 left it judged at save only, and its body says "PR 2's `os validate` rule covers packaged sources." ## Clause-② and Metadata-protocol, measured from the diff `Clause-②: no` / `Metadata-protocol: none`, a judgement call stated here for review. The rule refuses values of `source.documentBy`, a key objectstack-ai#38564 added in this same prerelease line. Its changeset `.changeset/38537-knowledge-document-by.md` is still pending (not moved to `.changeset/pre/`), so no published version carries the key and nothing an author could write against a release is refused. The metadata API's save door already refuses the same values. Read against `main` instead, a packaged source with a non-parent-link `documentBy` passed `os validate` before this PR and fails it after. If review prefers that reading, the lines become `Clause-②: no (narrowing)` / `Metadata-protocol: narrowed` (level `minor` and an ADR-0087 disposition). ## Verification ### Acceptance (the card's `os validate` half) | Card line | Test (`validate-knowledge-source.document-by.test.ts`) | |:--|:--| | Refuse a text field, a `user` field, an `internal` lookup and a `multiple` lookup, each naming the fix | "refuses a text field / a user field / an internal lookup / a multiple lookup as the document unit, naming the field and the fix" | | (the save door's other reasons) | "… a credential-class field", "… a lookup with no readable target", "… a system column the platform adds" | | Positive controls | "CONTROL: a lookup and a master_detail to the parent are admitted", "CONTROL: a source without documentBy is judged as before" | | Same verdict at publish | "refuses the publish with the words os validate prints", "CONTROL: a single-valued parent link publishes with nothing to report" | | Published id + `os explain` | "the root barrel re-exports it", "os explain answers it" | ### Ablation (`scripts/ablation-replace.mjs`, each mutation verified on disk, each restore verified blob == HEAD `d9f63681062f` with an empty `git diff HEAD`) <details><summary>Call site disabled (<code>const refusal = documentUnitRefusal(…)</code> → <code>undefined</code>): 9 red</summary> `validate-knowledge-source.document-by.test.ts`: 9 failed / 8 passed. All seven refusal tests, "a fields array is read like a field map", and "refuses the publish with the words os validate prints". The controls stay green. </details> <details><summary><code>multiple</code> arm deleted: 1 red</summary> 1 failed / 16 passed: "refuses a multiple lookup as the document unit…". </details> <details><summary><code>internal</code> half of the withheld arm removed: 1 red</summary> 1 failed / 16 passed: "refuses an internal lookup as the document unit…". (A first attempt was refused by the tool before running anything, because its replacement text already occurred in the file; it was re-run with a distinct replacement.) </details> ### Package suite and typecheck - `pnpm --filter @objectstack/lint test`: Test Files 248 passed (248), Tests 9989 passed / 5 skipped. Exit 0. - `pnpm --filter @objectstack/lint typecheck` (tsc + test layer): exit 0. - `eslint` on the four changed source files: exit 0. - `overlap-check`: VERDICT clean exit 0. origin/main merges cleanly, and so do the 7 open PRs sharing a file (objectstack-ai#38651, objectstack-ai#38650, objectstack-ai#38643, objectstack-ai#38605, objectstack-ai#38594, objectstack-ai#38550, objectstack-ai#38497). ### Derived gate families (`dispatch-gates.mjs --commands`, 70) - First pass, captured per the tool's idiom: `--ran` reports "70 derived famil(ies) accounted for — 66 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)". All 66 that ran exited 0, including `check-changeset-no-major --base origin/main`, `check-adr-0087-registration --base origin/main`, `check:doc-authoring`, `check:issue-citations` and `check:cross-package-test-inputs`. - The four exit-3 families each had a prerequisite missing. Three were re-run after fixing it, each exit 0: `check-plugin-teardown-shape --self-test` (needed `git fetch --unshallow`), `check:docs-transcript-drift` (needed the built lint) and `check:lean-entry-closure` (needed the built objectql). These re-runs were by hand, outside the `--ran` record. - `check:dual-build-cjs-loads` was not measured locally: it reads every package's `dist/`, which needs a full build. CI's `Build Core` job runs it on this PR. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (spec untouched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (eslint on the changed files). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block is the maintainer's Chinese brief). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. ## Read first 1. `packages/lint/src/validate-knowledge-source.ts`: `documentUnitRefusal` and the call site after `judgeMembers('metadataFields')`. 2. `packages/services/service-knowledge/src/knowledge-search-scope.ts`: `parentLinkRule` / `documentUnitOf`, the save door's rule this one restates. **Two-minute check:** `pnpm --filter @objectstack/lint exec vitest run src/validate-knowledge-source.document-by.test.ts`. Expect 17 passed. Dogfood: n/a (no `!` in the title, no `(narrowing)` arm). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JQwxbWsSJprjGydwaCH1gD <!-- signed: repo:objectstack#2 · os-warren · session_01JQwxbWsSJprjGydwaCH1gD --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…an authored one (objectstack-ai#38755) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi92EfsyzCyjwc8X5TRpmNj6z)_ Fixes objectstack-ai#38690 Clause-②: no (narrowing) Metadata-protocol: narrowed Skills-docs: none — no `skills/**` text taught the lowered exemption; the one docs page that did (`content/docs/deployment/validating-metadata.mdx`, the two capability rows) is corrected here ## 维护者速读 - 用户能看到什么变化:挂在字符串 handler / target 旁的钩子和脚本动作函数体(构建产物,或手写的)现在也会被校验权限声明,缺权限时在发布和 os validate 时就报错,而不是上线后每次运行被沙箱拒掉;同时构建能认出 `ctx.log?.info(…)` 这类可选链、空白、注释写法,自动补上权限。 - 为什么做:这是「钩子与动作函数体权限校验」这张卡的第二步;取消当时为构建产物留的豁免,并把构建的推断补到与校验规则逐个写法一致。 - 出错会怎样:手写在字符串 handler / target 旁、漏声明权限的函数体,以及构建后丢了权限的产物,发布会被拒并点名缺的权限;首方示例与连接器应用实测零新增拒绝,可整 PR 撤回。 - 要你做什么:无。 ## What changes `validate-action-body-capabilities` (`@objectstack/lint`) skipped a body it took for one the build lowered: a hook body `os build` / `os verify` lowered from an inline `handler`, and at the runtime publish doors any hook body beside a string `handler` (`isLoweredHandlerBody`); and any action body beside a string `target`, judged for `api.write` alone (`isLoweredTargetBody`). The skip covered a body written by hand beside a string ref as well, since the rule cannot tell the two apart. The reason was that the build's capability inference did not read every gated call the rule reads. Step 1 of this card (PR objectstack-ai#38731) and objectstack-ai#38653 (PR objectstack-ai#38686) closed that gate by gate; this PR closes it spelling by spelling. So this PR: - drops both skips and the three helpers that only served them (`isLoweredHandlerBody`, `isLoweredTargetBody`, `loweredActionBodyPaths`). `validateActionBodyCapabilities` no longer takes the `loweredHookRefs` context, and its registry entry passes the stack alone. Neither function was on the package's barrel. - makes the CLI extractor (`packages/cli/src/utils/extract-hook-body.ts`) infer each gated call in each spelling the rule reads. Its `ctx`-anchored member patterns, and their rebound siblings for a renamed or destructured hook context, were literal `ctx.log.info`: `ctx.log?.info(…)`, `ctx?.crypto.randomUUID()`, `ctx.activity?.append(…)`, `ctx.email?.send(…)`, `ctx . log . info(…)` and `ctx.title?.(field)` lowered without their token, and the rule read each as the gated call. Each step now takes `?.` and whitespace, `title` takes the optional call, and inference also reads a comment-blanked copy of the source (the rule's own walk, strings kept), so a comment between steps no longer hides a call. Every change widens: what inferred a token before still does. A hook handler that calls `ctx.email.send` in any of these spellings now lowers with the grant and is refused at build by the hook parse, as `ctx.email.send(…)` already was. - exports `SANDBOX_CAPABILITY_GATES` and `type SandboxCapabilityGate` from the lint barrel, and moves the step-1 CLI enumeration pin off its hand-kept mirror onto that table. - adds a PARITY pin in the CLI. Every gate, leaf, receiver shape and face, in each spelling the rule reads (plain, `?.` before the member, before the leaf and before the call, whitespace, a block or line comment between steps), is lowered through `extractLoweredBody` and judged by `runAuthoringRules('build', …)` twice: ungranted it must draw the gate's finding (so the rule reads that spelling and the pin is not vacuous), lowered it must draw none. A REBOUND block does the same through a hook handler's renamed and destructured context parameter. The one exclusion is a hook body's `email.send`, pinned instead as a build refusal in every spelling. - corrects the text that described the exemption: the two `os explain` entries, the docs rule table, the rule's docblock and the comment over the `lowerCallables` target-shape pin. - registers the narrowing as ADR-0087 semantic entry `lowered-hook-and-action-bodies-capabilities-judged`, with a BREAKING changeset carrying FROM → TO for both authors (a body lowered by the build or written by hand beside a string ref) and the remedy for each: rebuild, or declare the token. - corrects the pending objectstack-ai#37815 changeset and its semantic entry, whose sentences this PR makes false (see Deliberate correction). The limit, stated: the build's reading covers the rule's by the pin's enumeration (census × receivers × spellings × faces), not by proof. Where the two differ outside it, the build reads more (a renamed context root, a spelling inside a string), and the over-inferred grant is one the sandbox never checks, except `email.send` on a hook, which is refused at build as before. Measured cost before the change, on `origin/main` at `f782a12033` (scratch script, not committed): every first-party stack (`examples/app-crm`, `app-multi-package` with its two packages, `app-showcase`, `app-starter`, `app-todo`, `packages/apps/connector-docusign`, `connector-github`, `connector-stripe`) loaded, normalized, lowered and parsed as `judgeAuthorTimeRules` does, then judged by the shipped rule and by the rule with both skips emulated away. 70 hook and action bodies, 1 of them lowered (app-crm's opportunity hook): 0 findings shipped, 0 without the skips, **0 newly refused**. The population holds one lowered body, so it bounds authored bodies; the lowered side is bounded by the PARITY pin. ## Tests - New `packages/lint/src/validate-action-body-capabilities.lowered-38690.test.ts` (26 tests). Per removed skip, a lowered body calling each gate ungranted, spelled directly and through an alias: refused (hook: `os validate` / `build` / `lint` and the hook save door; action: top level, object-inline, `os validate` / `build` / `lint`, the action and object doors). Controls: the same lowered body granted is not refused. A lowered body's write keeps its own id beside the other tokens. - `packages/cli/test/extract-hook-body-local-alias-38690.test.ts` (284 tests): the mirror table is deleted; ENUMERATION reads `SANDBOX_CAPABILITY_GATES` and spells every leaf in every spelling through seven receivers; PARITY and REBOUND as above; a hook handler calling `ctx.email.send` in seven spellings plus a renamed context is refused by `HookSchema` after `lowerCallables`. Red first, each fix: - PARITY harness: the earlier PARITY judged the extracted record without `language: 'js'`, which the rule skips, so it could not go red. With the body record the build writes and the widened spellings, against the old extractor: 51 failed. - Extractor `?.` / whitespace / optional call / rebound: the pins against the extractor at `a68c0a41cc`: 76 failed of 247 (ENUMERATION 27, PARITY 24, REBOUND 25). Hook mail in the new spellings: 4 failed of 8 (they built clean before). - Comment between steps: against the extractor at `2aec12e986`: 210 failed of 284, every one a comment spelling. Ablations at the head (`scripts/ablation-replace.mjs`, restore proven blob == HEAD): `MEMBER_STEP` back to a plain `\.`: 84 failed (ENUMERATION 32, PARITY 28, REBOUND 20, mail 4). `title` without the optional call: 11 failed. Inference over the raw source only: 210 failed. The skips re-inserted in the rule, per removed skip: hook 14 failed / 12 passed, non-write action 12 failed / 14 passed of the lint file. Forced test edits, named: - `packages/lint/src/validate-action-body-capabilities.hook-and-tokens-37815.test.ts`: two describe blocks deleted, `authored hook bodies only: a body lowered from a handler is not judged (objectstack-ai#37815 route C)` and `authored action bodies only past the writes: a body lowered from a target is judged for api.write alone (objectstack-ai#37815 M1)`. They pinned the two skips this PR removes; the new file pins the opposite. Their authored-body halves stay covered by the same file's arm (a)/(b) cases. The two predicate imports go with them. - `packages/cli/test/lower-callables.test.ts`: comment only, over the `[objectstack-ai#38653]` target-shape pin, which named `isLoweredTargetBody`. The pin itself is unchanged. ## Acceptance notes - The lowered hook finding's path stays `hooks[N].body.capabilities` on the seat's answer (claim amendment 5). Its premise, that a fresh build never draws the finding, holds again at this head for every spelling the PARITY pin enumerates; for an artifact that lost a grant, or a hand-written body, that key is the right one. ## Deliberate correction `Check Changeset` (`check-empty-changeset`) is red on purpose: this PR edits a pending release note it did not add. DELIBERATE CORRECTION, not a collision; ⛔ do not restore the base text. Both files below are unreleased (merged after 19.0.0-next.2) and ship in the same release as this PR, and this PR makes their sentences about lowered bodies false. Text only: no code, no entry id, no level or disposition line changes. Scope per claim amendment 5 (7276409399); rewrites 2 and 4 of the changeset and 3 and 4 of the entry re-trued per L2 7278772654. **`.changeset/37815-body-capabilities-every-gate.md`** 1. BREAKING paragraph. Before: "whose authored L2 body calls a member". After: "whose L2 body calls a member". 2. `hook-body-capability-undeclared` bullet. Before: "an authored L2 hook body that calls any of those gates" … "Only a body the author wrote is judged: a hook body `os build` / `os verify` lowered from an inline `handler` is not, since its grant is the build's inference (the lowered reading is objectstack-ai#38653)." After: "an L2 hook body that calls any of those gates" … "A hook body `os build` / `os verify` lowered from an inline `handler` is judged the same way: its grant is the one the build inferred from its calls, and the build reads each gated call in each spelling the rule reads." 3. `action-body-capability-undeclared` bullet. Before: "an authored L2 action body that calls a gate other than the writes without its token. An action body `os build` / `os verify` lowered from an inline `target` function is not judged for these tokens, since its grant is the build's inference (the lowered reading is objectstack-ai#38653); its writes are still judged under `action-body-write-capability-undeclared`." After: "an L2 action body that calls a gate other than the writes without its token. An action body `os build` / `os verify` lowered from an inline `target` function is judged the same way, against the grant the build inferred from its calls." 4. Paragraph after FROM → TO. Before: "A hook whose body was lowered from an inline `handler` is unchanged: FROM and TO alike, it is not judged by this rule. So is an action whose body was lowered from an inline `target` function, for every token but `api.write`: … TO, it still builds clean, and its writes are judged as before." After: "A hook written as an inline `handler`, and an action written as an inline `target` function, need no change: the build infers the grant from each gated call in each spelling the rule reads (`?.`, whitespace or a comment between steps, the optional call), so the body it lowers carries the token. … TO, it still builds clean, its lowered body granted `api.transaction`." **`packages/spec/src/migrations/entries/semantic/19.hook-and-action-bodies-calling-an-ungranted-gate-refused.ts`** (entry `hook-and-action-bodies-calling-an-ungranted-gate-refused`, id unchanged) 1. Header comment. Before: "an authored L2 hook body that calls". After: "an L2 hook body that calls". 2. `surface`. Before: "only a body the author wrote (a hook body lowered from an inline handler is not judged, and an action body lowered from an inline target function is judged for its writes alone, as before)". After: "whether the author wrote the body or os build lowered it from an inline handler or target function". 3. `replacement`, last sentence. Before: "needs no change for the other tokens: its lowered body is not judged for them (a later change carries the lowered reading)." After: "needs no change: os build infers the grant from each gated call in each spelling the rule reads (?., whitespace or a comment between steps, the optional call), so the body it lowers carries the token, and that lowered body is judged like an authored one." 4. `reason`. Before: "A hook body os build lowered from an inline handler is not judged, and an action body it lowered from an inline target function is judged only for api.write, as before: such a grant is the build's inference, not the author's, and the inference does not yet read every gated shape, so a hook written as a handler and an action written as a target function are unchanged." After: "A hook body os build lowered from an inline handler, and an action body it lowered from an inline target function, are judged the same way: their grant is the build's inference, which reads each gated call in each spelling the rule reads, pinned spelling by spelling against the rule, so a hook written as a handler and an action written as a target function build clean." ## Verification Two-minute check: `pnpm --filter @objectstack/cli exec vitest run test/extract-hook-body-local-alias-38690.test.ts`. Expect 1 file, 284 tests passed. With `MEMBER_STEP` in `extract-hook-body.ts` set back to a plain `\.`, 84 of them fail. Read first: the `MEMBER_STEP` / `memberLeafRx` / `blankComments` block and the inference loop in `packages/cli/src/utils/extract-hook-body.ts`, then the PARITY block in the test above, then the two removed skips in `packages/lint/src/validate-action-body-capabilities.ts`. <details><summary>Local gates at 3ca3538 (head)</summary> - Derived round: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` listed 122 commands (the 119 of the last round plus `check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity`); each ran with stdin closed and its exit recorded before any pipe: 121 :: exit 0, and `node scripts/check-empty-changeset.mjs --base origin/main` :: exit 1, the DELIBERATE CORRECTION refusal above, by design. `dispatch-gates --ran`: 122 derived, 122 run, 0 NOT-MEASURED, 0 UNRUN. - Packages: `pnpm --filter @objectstack/lint test` 252 files / 10106 tests passed; cli `vitest run --project unit` 451 files / 6737 tests passed; `pnpm --filter @objectstack/lint typecheck` and `pnpm --filter @objectstack/cli typecheck` exit 0; spec rebuilt, `src/migrations` 5 files / 209 tests passed. - `node scripts/check-changeset-no-major.mjs --base origin/main --event` over this body: exit 0 (level axis: `@objectstack/lint` minor carries `Metadata-protocol: narrowed`; ADR-0087 `registered lowered-hook-and-action-bodies-capabilities-judged`). - `node scripts/pm/overlap-check.mjs` at this head: clean against origin/main (f576dee), objectstack-ai#38497 and objectstack-ai#38192. - Not run locally: the cli `integration` layer and `test:repo` (CI's Test Core); the dogfood battery is CI's on this head (`!` title, narrowing arm). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSa9QNE6qXdrFAvnUr)_ <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmSa9QNE6qXdrFAvnUr --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…jectstack-ai#38795) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99QsuPTPkC1uKm2mViUT3Rf)_ Part of objectstack-ai#34770 Clause-②: no Metadata-protocol: none `Part of`, not the closing form: the catalog-size line of the card's Done-when is not met by this PR. This is PR 4 of the per-skill split, under claim 7280537583 and its amendment 7280758590. ## 维护者速读 - 用户能看到什么变化:用户无感。发给 AI 的「表达式与公式」技能说明,入口文件从约 24 KB 缩到 9 KB:入口只留开工前四项检查、一段可照抄的示例、一份可用函数名单、八个「写得通过却算错或被拒」的坑,以及其余内容去哪里查的指路表。 - 为什么做:这是「技能目录瘦身」的第七份(界面、数据、自动化、平台、跨大版本升级、多语言翻译六份已完成)。入口文件每次都整份装进 AI 的上下文,越长越贵,也越容易漏读。 - 出错会怎样:只动教 AI 的文字,没有产品行为变化;风险是 AI 少读一段后答错。改动前后都跑了评测:十四道题每题三遍共四十二次,最新一版通过三十九次,改动前是三十二次;没有哪一题是改动后才每遍都不过的。合约审查提的两处应改(示例里一条判断在新建记录时会报错;一句「算不出就中止写入」说得过宽)已在入口内改好。可整笔撤回。 - 要你做的:无。席位核对与合约审查通过后,会按治理规则请审批人批准。 ## Rulings this executes - **Card Scope** (decision record on the card, S3 = A): the entry file holds first checks, at most about 8 traps and a routing list; 6–9 KB, hard cap 500 lines; restated option lists and function tables go behind a pointer; no trap is removed until a publish-time check covers it or it stays inline. - **7128031203** fork 4 = A: ratchet rows are pinned at the measurement with zero headroom, and the sum of ceilings does not rise. Here no row rises and none is added. - **7168461386** = A: text an eval shows the entry lost goes back into the entry, paid inside the entry. Used three times in this PR (see Eval parity). - **Ruling record 7249189592**, the parity rule: a case whose result flips between runs on both trees is unstable on both and does not block; a case that fails on every run of the head while `main` passes is a regression. - **Seat order for this PR** (claim amendment 7280758590): same shape as PR 3 (objectstack-ai#38663); no new file under `skills/` (a new file needs a new ratchet row, which stays with a human); the cut, not a move, lowers the catalog total. ## What changes **The entry file becomes a router.** `skills/objectstack-formula/SKILL.md`: 24,377 → 8,999 bytes, 485 → 135 lines, 6,088 → 2,243 tokens. Frontmatter (description, tags) is byte-identical. It now holds: - `## First checks`, four: the installed contract wins over the `compatibility` line; read the object's declared fields and the contract of the key that takes the expression, and never recall a function; bare CEL under the `F`, `P` or `cel` tag, never braces round a field reference, with the Salesforce spellings it keeps; verify with `os validate`, `os build` or the `validate_expression` agent tool. - One type-checked block, eight lines: a text formula with every nullable operand coalesced, a guarded divisor, the two date wraps, a `label()` formula, a null-guarded predicate, the transition predicate behind its insert guard (`previous != null && …`), a seed value. - `## Scope and functions`: the roots an expression can read, and every advertised function name as a call form, in five lines. - `## Traps`, eight: `has()` is not a null check on a server-evaluated predicate; action `visible` / `disabled` are the exception; a transition compares `previous`; a list field is never compared with a scalar; a `date` / `datetime` field is its ISO text; `label()` and the working-day functions belong to a formula or a stored field's `expression`; a dynamic seed value is the `cel` tag; a `template` is not CEL. - `## Where to go`: six rows (the contract, the published formulas page, and the four sibling skills). Three run-time facts ride the rows that send them elsewhere: a `formula` field is virtual; a view filter is not CEL; a form-view `visibleWhen` faults open. **No text moved.** This skill has no hand-written reference file (`references/_index.md` is generated), and a new file needs a new ratchet row. So what left the entry was cut, each behind what now answers it: | Old entry section | Now | |:--|:--| | Opening callout (bare CEL, no braces) | First check 3, which describes the mistake and no longer spells it. | | Skill Boundaries | The frontmatter description and the routing table. | | Core contract | The opening paragraph (the envelope, the three dialects, no `js`) and first check 3 (structured output carries the envelope). Cut: the engine behind each dialect and the helper column; the block shows the three CEL tags, and the `cron` and `tmpl` tags are in the contract. | | CEL syntax cheat-sheet | The roots line of `## Scope and functions`, with `os.org` still limited to `id` and `tier`. Cut: the operator rows, which are plain CEL. The list-equality paragraph is trap 4, with the three positive membership forms; the three negated forms are cut (the same guard, negated). | | `has()` is NOT a null check | Traps 1 and 2. The publish-time refusal, the flow condition's bare name and the action guard all stay. | | ObjectStack CEL standard library | The function list keeps every name. Cut to the published page: what each function returns and the per-function notes. Kept as traps: the date text rule and the helpers that replace date arithmetic (5), the option label and the working-day placement (6). | | Mandatory patterns 1 to 5 | The type-checked block carries one line for each; trap 7 is the seed rule and trap 3 the `previous` rule. Cut: the wrong-on-purpose examples, and the table of where `previous` is bound with the per-row rewrite rule, both of which `skills/objectstack-data/references/data-hooks.md` carries. Kept in trap 3: a hook `condition` that cannot evaluate aborts the write, and the 10 000-row refusal. | | Mechanical translation table | First check 3 keeps nine rows (the five operators, `ISBLANK`, `OLD` / `NEW`, the bare field). The rest is on the published page; each legacy spelling fails the build. The flow exception is in trap 1. | | Surfaces that take an Expression | Cut to the contract. Kept: a bare-string `defaultValue` is a literal (first check 3); a `formula` field is virtual and a view filter is not CEL (routing row 3); a form-view `visibleWhen` faults open (routing row 6); a `SharingRule` condition must lower to a filter (trap 4). | | Cron and template surfaces | Trap 8 keeps the template grammar, the empty render of a missing path and the two currency forms. Cut: the cron grammar and both dialects' carriers (the contract). | | Verify your work, See also | First check 4 and routing row 1. | **Sizes** (bytes · lines · ratchet tokens): | | before (`main` at `6cc2024e`, merged in) | after (`50530b6b`) | |:--|--:|--:| | `SKILL.md` (entry) | 24,377 · 485 · 6,088 | 8,999 · 135 · 2,243 | | `skills/objectstack-formula/**` (4 files) | 37,883 · 701 | 22,505 · 351 | | all 14 `SKILL.md` together | 180,656 · 3,406 | 165,278 · 3,056 | | whole `skills/` tree (115 files) | 1,214,886 | 1,199,508 | | whole tree without `evals/` (73 files) | 855,732 | 840,354 | | ratchet: authored tokens = sum of all ceilings | 196,275 | 192,430 | | ratchet: bundle total, tokens | 300,926 | 297,081 | The `main` column moved since the first delivery (it was read on `f576dee5`): `main` lowered another skill's row by one token, so its sum of ceilings is 196,275. The bundle total on `main` is the head's reading plus this row's fall; the entry is the only file under `skills/` that differs. **Budget reading:** the entry is 8,999 B, inside the card's 6–9 KB line, and 135 lines against the 500-line cap. The whole catalog is 15,378 bytes smaller, all of it cut. **Ratchet row** (`scripts/check-skills-token-ratchet.mjs`), pinned AT its measurement, zero headroom: `skills/objectstack-formula/SKILL.md` 6088 → 2243 (−3,845): `ceil((8999 − 27) / 4) = ceil(8972 / 4) = 2243`. It is the skill's only row. The sum of all ceilings goes 196,275 → 192,430. The first delivery pinned the row at 2237 (8,974 bytes); the review round's two fixes cost 27 bytes, one blank line and one comma pay 2, and the row follows the measurement up by 6 tokens. Against `main` no row rises. ## Tests ### Eval parity Judged by ruling record 7249189592. **No case fails on every run of the head while `main` passes.** On the current head (`50530b6b`, the review round's text) the with-skill arm passes 39 of 42 turns against 32 of 42 on `main`'s text; on the first delivery's text (`327903f6`) it passed 41 of 42. The three misses on the current head are two runs of case 7, which flips on both trees, and one run of case 13, a correct condition written without the `P` tag; case 13 read 6 of 6 on a second reading. Skill evals, both arms, one command line for every full round: `pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-formula --repeats 3 --concurrency 4`, with the model and effort flags PR 3's rounds used (the extra readings add `--case` and `--repeats 6`); CLI 2.1.332, subscription login. 14 behaviour cases in `evals/cel-predicates-formulas.json` and 7 trigger cases in `evals/triggers.json`, both untouched. | reading | tree | with-skill | no-skill | with-skill cases below 3/3 | |:--|:--|--:|--:|:--| | before round | `f576dee5` | 32/42 | 0/42 | 4 (0/3) · 7 (2/3) · 8 (2/3) · 9 (2/3) · 12 (0/3) · 14 (2/3) | | first router head | `75b00bcc` | 37/42 | 0/42 | 10 (0/3) · 11 (2/3) · 12 (2/3) | | second head | `b93fb9bf` | 40/42 | 0/42 | 11 (1/3) | | third head | `9643441f` | 40/42 | 0/42 | 7 (1/3) | | third head, cases 7 and 11, six repeats | `9643441f` | 8/12 | 0/12 | 7 (3/6) · 11 (5/6) | | `main`'s text, cases 7 and 11, six repeats | `f576dee5` text | 7/12 | 0/12 | 7 (1/6) | | fourth head | `822cd547` | 40/42 | 0/42 | 4 (2/3) · 7 (2/3) | | first delivery's text, full round | `327903f6` | 41/42 | 0/42 | 11 (2/3) | | **review round's text, full round** | `50530b6b` | **39/42** | 0/42 | 7 (1/3) · 13 (2/3) | | review round's text, case 13, six repeats | `50530b6b` | 6/6 | 0/6 | none | Trigger cases, every full round on every tree: loaded when it should 15/15, left alone when it should not 6/6. - **Case 10** (a `datetime` field as `YYYY-MM-DD` text) was a real loss on the first head: 3/3 on `main`, 0/3 on `75b00bcc`. Every answer gave the right formula; each then quoted the refused form, which the case forbids, because the first head's sentence said "the build refuses the bare field there". The sentence reads as it did before the cut ("wrap it in `date()` first") and the two wraps are lines of the type-checked block: 3/3 on every later head. - **Cases 10 and 11, a missing `F` tag** on the first head (one run each wrote the formula bare or as an envelope): the first head named no tag in its first checks. First check 3 now says which tag a formula, a predicate and a seed value take. - **Case 3** (the transition predicate, the case the review round's two fixes bear on) is 3/3 on `50530b6b`, as on every earlier reading. All three answers write `previous != null && previous.status != 'escalated' && record.status == 'escalated'` and say why the guard is there. So did the three answers on each of `9643441f`, `822cd547` and `327903f6`, from trap 3's text; on `main`'s text all three wrote the unguarded line. The fix makes the block agree with what the answers already gave. - **Case 13** (a hook `condition` on a `tags` field) is 2/3 on `50530b6b` and was 3/3 on every earlier reading of both trees. The miss gives the right membership form, null-guarded and parenthesised, in a fenced block without the `P` tag, the literal the case requires. A second reading of the case alone, six repeats on the same head, is 6/6: 8 of 9 on this head. The round's edits do not touch the tag sentence or trap 4. - **Case 9** (a record-change flow's edge condition, the site S2 separates from a hook) is 3/3 on `50530b6b`. - **Case 7** (compare the stored value, never the option label) flips on both trees: 3 of 9 on `main`'s text, 15 of 21 across the first five heads and 1 of 3 on `50530b6b`. Every failing answer compares the stored value and then says a predicate cannot call `label()`, which is the literal the case forbids. One failing answer on `822cd547` did show a loss of precision: it carried the action guard over to a form-view `visibleWhen`, because one trap named both as client-side. Trap 2 is about action `visible` / `disabled` alone again, and the form-view fact moved to the routing row: 3/3 on `327903f6`. The two failing answers on `50530b6b` are of the first kind: each compares the stored value and names `label()` as the thing a predicate cannot call. - **Case 11** (a multi-select's labels as text) passes 9 of 9 on `main`'s text, 16 of 21 across the first five heads (by head: 2/3, 1/3, 8/9, 3/3, 2/3) and 3 of 3 on `50530b6b`. Four of the five failing answers give `label(record.no_margin_reasons)` under the `F` tag and add a sentence that names `joinNonEmpty` (as the thing not to use, or as an option for another separator), the literal the case forbids; the fifth is the first head's missing tag. It fails on every run of no head, so the parity rule does not block on it. It is the one case where `main` is steadier than the head, and it is reported as that: a likely cause is that the function list now sits one section above the trap, where `main` had it in a table further up a longer file. - **Cases 4, 9, 12 and 14** pass more often on the head. Case 4 (0/3 on `main`, 14 of 15 across the first five heads, 3/3 on `50530b6b`) and cases 9 and 14 failed on `main` when a correct answer quoted a wrong form the old entry spelled out (the JavaScript date constructor, the brace form); the router describes those mistakes in words and does not spell them. Case 12 (0/3 on `main`) failed there because every answer wrapped the field in `date()` inside `addDays`; the block now carries `isoDate(addDays(record.due_date, 7))` as a line. Three restorations under ruling 7168461386 came out of these rounds, each paid inside the entry: the date sentence (case 10), the tag sentence (cases 10 and 11), and the action-only guard (case 7). A fourth edit came from reading the contract text, not from an eval: a flow condition's bare name is the field only where no flow variable or node id holds it. <details><summary>Round records</summary> - Before round on `f576dee5`: 105 of 105 turns, 4.6 min. - Rounds on `75b00bcc`, `b93fb9bf`, `9643441f`, `822cd547` and `327903f6`: 105 of 105 turns each, 4.5 min each. - Extra reading on `9643441f`, cases 7 and 11, six repeats: 24 of 24 turns, 1.1 min. - Extra reading on `main`'s text, same cases and repeats: 24 of 24 turns, 1.1 min. The runner has no flag for a second tree, so `main`'s `SKILL.md` was restored into the working tree for this one reading and put back (`git hash-object` equal before and after); its round header names `9643441f` "with uncommitted changes under the runner or skills/". - No full round ran on `77804a7a`: it differs from `327903f6` by two sentences of the changeset, and the turn never reads a changeset. - Review round, full round on `50530b6b`: 105 of 105 turns, 4.3 min. Extra reading on `50530b6b`, case 13, six repeats: 12 of 12 turns. A full round was run and not only the cases the two sentences bear on (3, 9 and 13): the edited line sits in the block every answer copies from. - Every `must_contain` literal of the 14 cases that the entry carried before, it still carries (35 literals read; 28 carried before and after, 0 lost, 1 gained; 6 appear in neither tree and come from the prompts). </details> ### Other tests On `50530b6b`, under the verify lock (`VERDICT command-exit 0` each), and with the same counts on `9643441f`, `822cd547`, `327903f6` and `77804a7a`: - `pnpm --filter @objectstack/formula exec vitest run --maxWorkers=2 src/skill-catalog-sync.test.ts src/cel-stdlib-drift.test.ts` (the first reads this entry and requires every advertised function in it as a call form): `Test Files 2 passed (2)`, `Tests 5 passed (5)`. - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 scripts/platform-catalog.test.ts scripts/skill-map-guards.test.ts` (the suite that names the ratchet script, and the one that names this skill): `Test Files 2 passed (2)`, `Tests 57 passed (57)`. - `pnpm --filter create-objectstack exec vitest run --maxWorkers=2 src/created-summary.test.ts` (it names the skill in its catalog list): `Test Files 1 passed (1)`, `Tests 12 passed (12)`. - `pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/hook-condition-previous-scope.test.ts` and `pnpm --filter @objectstack/trigger-record-change exec vitest run --maxWorkers=2 src/bulk-write-per-row-context.test.ts` (each names the skill in a comment; neither reads it): 25 and 4 tests passed. No ablation: the diff changes prose and one ledger, no tested behaviour. ## Acceptance notes Review round (contract review 7286361695 on `77804a7a`, VERDICT PASS, no must-fix; the L1 note 7286117663 raised S1 first): - **S1, fixed.** The checked block's transition line carries `previous != null && ` in front, the form trap 3 prescribes. Unguarded it faults on insert, where `previous` is `null`, and the build does not refuse it (the null-guard gate judges ordering and arithmetic operators, and the line uses `!=`). Eval case 3's required literals still match, 3/3. - **S2, fixed.** Trap 3's sentence reads "A hook `condition` that cannot evaluate (…) ABORTS the write with no `onError` escape". The cut had widened it to every site the trap lists; a record-change trigger's run fails while the write lands (`validate-null-guards.ts`, outcome `run-fails`; trap 1 says so for a flow), and an advisory validation rule is skipped, so the sentence names the hook alone, as `main`'s text did. - **Paid inside the entry**: +27 bytes for the two fixes, −1 for the doubled blank line after the frontmatter, −1 for a comma; 8,974 → 8,999 bytes. The ratchet row is re-pinned at the new measurement. The changeset's line count (135) and its sentence on the abort are corrected to match. - **N1, N2 and N3 are left**, as the review accepts them: no byte is free under the 9 KB line. - **`main` is merged in** (`6cc2024e`, a plain merge commit): it moved one other ratchet row, the textual merge was clean, and the workspace was rebuilt before any gate ran. Ruled by the contract review, recorded here as it stands in the entry: - **The function names stay inline (ruled A)** (about 0.9 KB of the entry's 9.0 KB) and are not cut to a pointer. The card's shape line sends function tables behind a pointer, and `packages/formula/src/skill-catalog-sync.test.ts` requires every name of `CEL_STDLIB_FUNCTIONS` in this file as a call form. That test is outside this claim's file surface, and `@objectstack/formula` ships `dist` only, so an installed project has no source to read the list from. So the tables became a list of call forms and what each function returns went to the published page. If the list should leave too, the test moves first, in its own change. Decided here (small, no shipped behaviour), each open to reversal in review: - **"No trap is removed unless a publish-time check covers it or it stays inline" was read as: an expression that parses and then fails or reads wrong at run time stays inline.** Inline: the eight traps and the three facts on the routing rows. Cut to a pointer, each loud at the build: an unknown function, a legacy spelling, a malformed envelope, the retired `titleFormat` key. - **Four traps stay inline although the build refuses them** (the nullable operand, the list compared with a scalar, the date text in a timestamp call, date arithmetic): the refusal says what is wrong, and the entry carries the form to write instead, which is what the eval cases about them ask for (2, 4, 5, 9, 10, 12, 13 and 14). - **The entry describes wrong forms and no longer spells them** (the brace form, the JavaScript date, a number added to `today()`, `CONCAT`). An answer that quotes a wrong form fails the cases that forbid it, on either tree. The contract review ruled the brace example stays in words (A). - **A version check opens the first checks**, as in the other router entries; the old entry had none. Paid by dropping the cron grammar sentence. - **Section anchors of the entry changed.** The changeset lists every anchor that left `SKILL.md`. No file in this repository links one of them. - **Four lines in the summary above, not six**: the standing order for this card thread asks for six, and the agent file that binds the dev fixes four named lines and wins on conflict. - **Footer form**: this body ends with the single block AGENTS.md prescribes for a PR body. Noted, not changed: - The literals of eval cases 4, 7 and 11 fail correct answers (above). The parity rule treats the cases as fixed, so this PR does not touch them. - The published formulas page lists the legacy rows the entry dropped, except four of the five functions the old table marked as having no CEL counterpart (`MID`, `LEFT`, `RIGHT`, `SUBSTITUTE`; it has `MONTH_DIFF`). Each fails the build as an unknown function, with or without a row. - The version PR objectstack-ai#38192 touches the entry's stamp line, and objectstack-ai#38787 and objectstack-ai#38790 touch other rows of the ratchet table; `overlap-check` reads each as merging cleanly. It reads objectstack-ai#38497 as a conflict in the ratchet script: that PR conflicts with `main` itself there, in one hunk on the `objectstack-ai` row, and the hunk is byte-identical with and without this branch; the formula row is outside it. ## Verification Read first, by risk: 1. `skills/objectstack-formula/SKILL.md`, the whole file: is anything a model needs before opening the contract missing? The risk hunks are `## Traps` (eight items replace most of the old file) and the function list. 2. `.changeset/34770-formula-skill-router.md`: the "what left, and what answers it now" list is the record of every cut. 3. `scripts/check-skills-token-ratchet.mjs`: the one `objectstack-formula` row. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints `ratcheted (authored) 192430 / 192430 (+0)` and `skills/objectstack-formula/SKILL.md 2243 / 2243 (+0)`; `wc -c skills/objectstack-formula/SKILL.md` prints 8999. Gates, local, each exit code captured before any pipe. The whole derived list ran on `50530b6b`, and before it on `9643441f`, `822cd547`, `327903f6` and `77804a7a`, 69 of 69 each time. <details><summary>Derived families on `50530b6b`: 69 derived, 69 run green, 0 NOT MEASURED</summary> - Reconciliation: `✓ dispatch-gates --ran: 69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED (a DERIVED zero — all 69 recorded an exit code and none of them is 3).` - `node scripts/check-skills-token-ratchet.mjs`: `✓ check-skills-token-ratchet: 61 authored bundle file(s) within their ceilings; 11 generator-owned file(s) and 42 eval fixture(s) measured, not ratcheted.` (`ratcheted (authored) 192430 / 192430 (+0)`, `bundle total 297081`); its `--self-test`: `111 cases pass`. - `pnpm check:dual-build-cjs-loads`: `126 published require entry point(s) across 74 package(s) load; 2593 emitted CommonJS file(s) parse`. It reads every package's built `dist/`; a full `pnpm build --concurrency=2` ran first on the merged tree under the verify lock (`VERDICT command-exit 0`, 123 tasks). - `pnpm check:dts-closure`: `123 built package(s) swept - 324/324 declared declaration file(s) present`. - `pnpm check:skill-links`: `290 relative link(s) in 76 published skill file(s) resolve; 161 fragment(s) name a real heading under GitHub's slug rule.` - `pnpm check:skill-identifier-liveness`: `Leg 1: 527 citation(s) over 76 published file(s) ...; Leg 2: 11 registered exhaustive section(s), 0 ledgered gap(s).` - `pnpm --filter @objectstack/spec run check:skill-docs`, `pnpm --filter @objectstack/lint run check:doc-formula-expressions`, `pnpm check:skill-compatibility`, `check:skill-frame-sync`, `check:role-word`, `check:corpus-claim-drift`, `check:doc-authoring`, `check:published-files`, `check:nul-bytes`, `check:cross-package-test-inputs`: exit 0. - The changeset gates (`check-changeset-no-major`, `check-empty-changeset`, `check-adr-0087-registration`, `check:changeset-gate-self-tests`): exit 0. `pnpm check:pm-dispatch-gates`: exit 0. </details> <details><summary>Beside the derived list, on `50530b6b`, all exit 0 but the last</summary> - `pnpm --filter @objectstack/spec run check:skill-examples`: `347 prose examples type-check across 3 surface(s)`. The entry's one block is among them. - `pnpm --filter @objectstack/spec run check:skill-refs`: `10 generated files in sync with packages/spec`. - `pnpm --filter @objectstack/spec run check:skill-served-sections`: `24 served section(s), each heading exactly once in its file` (the hosted door serves no section of this skill). - `pnpm check:doc-anchors`: `1184 internal #fragment link(s) across 368 source file(s) all resolve to a real heading`. - `pnpm check:published-readme-links`: `566 outbound link(s) across 168 published markdown file(s)`, `99 docs-site page(s) resolved`; the formulas page the entry links is one of them. - `pnpm check:skill-top-level-keys`: exit 0. - `pnpm --filter @objectstack/spec check:generated` after the merge and the rebuild: exit 0. - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: `0 anchored files in the change set — nothing judged.` - `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` at each push of the first delivery (on the second it ran right after). Before the review round's push: `VERDICT overlap exit 1`, for objectstack-ai#38497 alone, whose conflict in the ratchet script is its own against `main` (see Noted above); `main`, objectstack-ai#38787, objectstack-ai#38790 and objectstack-ai#38192 merge cleanly. </details> Base: the branch is cut from `f576dee5` and carries one merge of `main` at `6cc2024e` (merge commit `b9e30211`); `main` had not moved further at the review round's push. CI on the head is the seat's reading. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS)_ <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…ooted code as a pair (objectstack-ai#38803) _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9SSdM6AYsxMukn8uhMeGEh7)_ Part of objectstack-ai#37111 — PR 3 (the card's two remaining acceptance items). PR 1 is objectstack-ai#38613 (`1d959b0910`) and PR 2 is objectstack-ai#38748 (`c4472c8631`). The seat closes the card once this PR merges. Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:把 `.custom` 定制包当作代码启动的部署,升级时定制包自己那张旧写法表单会搬成它自己的表单行,不再被误拦住;定制包代码里自己也带这个表单名时同样如此。公开地址前后应答不变。 - 另一项只加钉子:在一个真正强制「一槽一行」的存储上,证明两个计划抢同一槽时升级照旧被拦,什么都不写。 - 要你做什么:Tier H 的 draft,审核后按受管流程批准。 - 风险:小。普查只多认出一种已知形状;其余计划不变(planner、引擎、rest 全套件绿)。 ## What changes - **③ a pair held as booted code** (`protocol-stored-form-migration.ts`). A `.custom` pair registered as code is read-only, so the census reads it at a `base` address. It then asked the pair door for a pair of the pair, which ADR-0146 D3 never gives. Measured before the change: the pair's own old-shape row held the upgrade with the refusal "is itself a paired customization package". The census now reads the pair by what its package is (`customizationBasePackageId`), not by the address kind: - the pair's own old-shape row moves into the pair's own `form` row (`pair_form`, no `overrides`), as ADR-0159 D7 already states for the pair's own row; - a stored `form` row already there is kept. This holds on both destination routes: where the pair's code ships no form of the name, and where it ships the name itself (an old-shape form among its items; review 7292231403 S1). On the second route the store's seal is still read first: where the pair ships the name as a sealed `form` item, the hold is the seal's, naming the pair. The pair door is not asked. Two other shapes were measured over the same booted pair and were already right, so they are unchanged: a declared override in the pair, and a row bound to the base. - **Step 7 of ruling record 7265816895: one slot, one row, on a store that enforces it.** Measured first: neither the engine tests' memory store nor the rest tests' SQL store refuses a second active row in a slot as booted, because the overlay unique index is built by `ensureOverlayIndex`. The new rest pin builds that index and proves the store refuses a second active row in a pair's slot (control). Then, with the pair's own `form` row beside a row planned into that pair, it asserts that the census holds both, `--apply` writes nothing, the slot keeps its one row byte-equal, every stored row is byte-equal, and both doors answer the same. ## Why These are the two acceptance items objectstack-ai#38748 left owed on objectstack-ai#37111, with their reasons (the `③` note of record 7253682863 on `pairFormDestination`, and step 7 of ruling record 7265816895). The seat's ruling of 2026-11-30T20:09Z puts them on this card as PR 3 (claim amendment 6, 7290758981). N7 of contract review 7282065700 does not fit here: the early route has no destination that could be read as a move. It stays where the seat put it. The operator page (`content/docs/deployment/stored-forms-upgrade.mdx`) gains one clause (review 7292231403 N1): a row of a `.custom` package the deployment holds as code stays in that package as its own form. ## Verification Head `0a1bb19fd8`. - **Red first** (the pins run against `origin/main`'s planner): planner "③ a pair held as booted code…" 2 red; rest "③ a pair held as booted code…" red. For S1 (the pins run against `5a6cb82666`'s planner): planner "where the pair's code ships the name itself…" 3 red (the first two held, the third named the pair door's refusal instead of the seal); rest "③ a pair held as booted code that ships the name itself…" red (it held). The step 7 pin pins behaviour that already held, so the ablation below is its proof. - **Ablations** (`scripts/ablation-replace.mjs`, each restored to `HEAD`): - Reading the pair from the address kind where the pair ships no form of the name: the two ③ planner pins and the ③ rest pin red; engine 38/38. - Reading the pair from the address kind where the pair ships the name itself: exactly the three S1 planner pins and the S1 rest pin red; engine 38/38. - Not keeping the pair's own `form` row where it stands: exactly the planner "its stored `form` row is kept" pin red. - Dropping the hold of a pair slot two plans claim: the step 7 rest pin red, with 9 planner and 7 engine contested-slot pins. - **Suites at the head:** planner 112/112, engine 38/38, rest 97/97; metadata-protocol type-check clean. - **Derived gates:** `dispatch-gates --commands` derived 95 commands; all 95 exit 0, each run with `< /dev/null`; `dispatch-gates --ran`: 95 run, 0 NOT-MEASURED. - **`overlap-check`:** clean against `origin/main`. Two open trunk pulls of the approvals lane are named. objectstack-ai#38797 merges cleanly. objectstack-ai#38497 conflicts in the planner test file only because its head predates objectstack-ai#38748, which those files came from; neither authors a change to these files. - **Not measured locally, CI owns:** the type-check lanes and the CI-only jobs the derivation names. ## Deviations - **File surface** (claim amendment 6): the planner and the rest pin file; the planner's own test file and the changeset are implicit. The operator page is added by the seat's order on review 7292231403 (N1). No other path. - **`Clause-②: no`** differs from the claim's standing `yes`, which was written for PR 2's exports (review 7292231403 N2). This PR changes no export, type, route or schema, so nothing an author writes or a consumer imports changes. - **No ADR change.** ADR-0159 D7 already says the pair's own row moves into the pair's own `form` row; the code now agrees with it for a pair held as booted code. - **N7 of record 7282065700 is not built.** The seat records it as an accepted deviation when it closes the card. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No `packages/spec` change.) - [x] 2. Every name I added uses the casing for its kind. - [ ] 3. No formatter ran; `pnpm lint` was not run locally (CI's lint lane owns it). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmQrGTjSRSiwWSe6AhK <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmQrGTjSRSiwWSe6AhK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
… views: as lists only (objectstack-ai#38790) Fixes objectstack-ai#37105 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:让 AI 助手照着平台技能包搭应用的人,以后得到的表单只有一种写法(表单单独登记,公开表单或由按钮打开),不再被教把表单写进列表视图里;平台本身的行为没有变。 - 为什么做:属于「表单独立成一种元数据」专题的教学收口,让技能包教的写法和平台现在实际收的写法一致。 - 出错会怎样:最坏是技能包里的说明写错,AI 照着写出不对的表单定义;这次只改说明文字和评测题,可以直接撤回。 - 要你做什么:看一眼「旧写法」那一句。卡上允许写成「旧写法已被拒绝,用迁移命令搬走」,但主干上旧写法目前仍被接受、迁移也还没有,所以这一句只写了「不要这样写,见到就搬到表单登记处」。 ## What changes The published `objectstack-ui` skill now teaches one way to declare a form and no other (ADR-0159 D1 and D5, as shipped on `main`). - `skills/objectstack-ui/rules/list-views.md`: the section *Form Views* is now *Forms*. - A form is a `form` item in the stack's `forms:`, written with `defineForm` in a `*.form.ts`: `name` (`OBJECT.KEY`, the prefix equal to `object`), `object`, and the body at the top level. `views:` holds lists only. - What is `form` content: a public form (it declares `sharing.publicLink`) or one an action of `type: 'form'` opens by its `target`. With neither, `os validate` warns `form-consumer-less`. - What is not: the record's New and Edit forms. They are the object's `fieldGroups` and are never a `form` item. - The two refusals: `viewKind`, `config` and `data` are refused on a `form` item (a form is bound with `object`); a form left open on a public address another form holds is refused, naming both (`form-public-address-taken` from `os validate`, `409 FORM_ADDRESS_TAKEN` from a save), and a switched-off form that keeps its `publicLink` still holds the address. - Translations: under `forms.NAME` (`.label`, `.title`, `.description`, `.submitBehavior.*`, `.sections.SECTION.*`); a section with no key there reads `objects.OBJECT._sections.SECTION`. - One type-checked `defineForm` example. The `defineView` container example lists `list` and `listViews` only; no example authors a form inside a view. - `skills/objectstack-ui/SKILL.md`: Trap 1, the routing table's form row (`*.form.ts`) and the Action Types `form` row name the `form` item. - `skills/objectstack-ui/evals/views-apps-actions-pages.json`: case 25 now expects a `form` item an action opens (with its sections' `columns`); new case 28 expects a public `form` item on an address a switched-off form still holds. Cases 1, 6 and 19 keep their prompts and no longer name a form authored inside a view. - `scripts/check-skills-token-ratchet.mjs`: three `objectstack-ui` CEILINGS rows follow their files down to the measurement (numbers below). - `.changeset/37105-skills-teach-forms.md`: `@objectstack/skills` patch. The one migration sentence, the only thing the card's grep returns (`rules/list-views.md`, the last bullet of *Forms*): > ⛔ Never author a form inside a view (a container's `form:` or `formViews`, a `viewKind: 'form'` item). Move one an action opens, or with a `publicLink` or `overrides`, to `forms:`; delete only the rest: New and Edit never loaded it. Round 2 (head `5a3a19bd`, L2 S1 of 7285578664): the bullet now moves only a form an action opens or one with a `publicLink`, and deletes any other, as ADR-0159 ("Internal record forms are not moved", ruling item 3) rules. The clause is paid for by nine word trims inside the same *Forms* section; `rules/list-views.md` is 18035 bytes, 4509 tokens, so its CEILINGS row stays at 4509 (headroom 0). Cases 25 and 28 were rerun at `5a3a19bd`: with-skill 2/2, no-skill 0/2. The changeset's sentence about the bullet follows. Round 3 (head `8cd68a8e`, L2 delta M1 of 7287432289): a form whose item or container declares `overrides` moves too, whatever its body and slot (ADR-0159 D7-b: nothing prescribes deleting it, since an override with no link is what keeps a base form's public address closed); only the rest is deleted. N4 ("the object's fields"), N5 ("a rarely filled section") and N6 (the CEILINGS row comment's arithmetic, now `ceil(18035 / 4)`) are fixed in the same commit; `rules/list-views.md` stays 18035 bytes, 4509 tokens, row unmoved. Evals at `8cd68a8e`: cases 19 and 25 with-skill 1/1, no-skill 0/1; case 28 not measured (the runner's rate-limit guard stopped the round), its sentences byte-equal to `5a3a19bd`, where it passed. `overlap-check` exits 1 only against draft PR objectstack-ai#38497, on two files this branch does not change (the same at `5a3a19bd`); pushed on the zone's ruling. Dev reports 7288496594 and 7288555864. **Read first** 1. `skills/objectstack-ui/rules/list-views.md`, the hunk that replaces *Form Views* with *Forms*: every sentence there is a claim about what `main` does (the refusals, the lint rule names, the `409`, the translation keys). 2. `skills/objectstack-ui/evals/views-apps-actions-pages.json`, cases 25 and 28: the grader is literal, so a wrong `must_contain` token passes or fails for the wrong reason. 3. `scripts/check-skills-token-ratchet.mjs`, the three lowered rows: a row above or below its measurement is red. ## Tests All readings below are at head `b3d7dc22` unless a line says otherwise; rounds 2 (`5a3a19bd`) and 3 (`8cd68a8e`) changed only `rules/list-views.md`, the changeset and (round 3) one ratchet row comment; their readings are in the paragraphs above and in the grep and size rows, which show `8cd68a8e`. **Every `form` example parses with `FormSchema`** (built `packages/spec/dist` of this tree; the fenced block is run with `defineForm` swapped for a recorder, the two eval answers are parsed as written): ``` PARSES rules/list-views.md (fenced block) "crm_lead.web_to_lead" PARSES evals/views-apps-actions-pages.json case 25 (expected_output) "crm_account.intake" PARSES evals/views-apps-actions-pages.json case 28 (expected_output) "crm_lead.contact_us" 3 form example(s), 0 refused ``` Negative controls on the same schema: a `form` item carrying `data`, one carrying `viewKind` with `config`, one whose name prefix differs from `object`, and one carrying `isDefault` are each refused. **The card's grep** ``` $ git grep -nE "formViews|viewKind: 'form'" -- skills skills/objectstack-ui/rules/list-views.md:376:- ⛔ Never author a form inside a view (a container's `form:` or `formViews`, skills/objectstack-ui/rules/list-views.md:377: a `viewKind: 'form'` item). Move one an action opens, or with a `publicLink` ``` **The two size readings** (tokens are the ratchet's count, `ceil(utf8 bytes / 4)`; `SKILL.md` is priced without its stamp line) | file | lines before → after | bytes before → after | tokens before → after | |:--|--:|--:|--:| | `skills/objectstack-ui/SKILL.md` | 164 → 164 | 8937 → 8933 | 2228 → 2227 | | `skills/objectstack-ui/rules/list-views.md` | 414 → 407 | 18039 → 18035 | 4510 → 4509 | | `skills/objectstack-ui/rules/navigation.md` | 192 → 192 | 10235 → 10222 | 2559 → 2556 | | `skills/objectstack-ui/evals/views-apps-actions-pages.json` (measured, not ratcheted) | 275 → 287 | 29995 → 32080 | 7499 → 8020 | | `skills/objectstack-ui/evals/README.md` (measured, not ratcheted) | 56 → 57 | 2729 → 2809 | 683 → 703 | | whole pack | before → after | |:--|--:| | all 14 `SKILL.md`, lines | 3406 → 3406 | | all 14 `SKILL.md`, bytes | 180659 → 180655 | | ratcheted authored files, tokens | 196276 → 196271 (−5) | | eval fixtures, tokens (measured, not ratcheted) | 89819 → 90360 (+541) | | whole shipped tree, tokens | 300941 → 301477 (+536) | Growth is paid by deletion in the same file. Cut from `rules/list-views.md`: the *Field Conditional Rules in Forms* section (now one clause that points at objectstack-data's Conditional Field Rules), the third copy of the `defineView` scaffold (the `userActions: { search: false }` example, now its one key inline), and a sentence of Master-Detail item 1 that `SKILL.md` Trap 2 states word for word. No ceiling is raised; the three rows are lowered because a row above its measurement is red: `SKILL.md` 2228 → 2227, `rules/list-views.md` 4510 → 4509, `rules/navigation.md` 2559 → 2556. **Skill evals** (the runner, `pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-ui`, live, on the container's subscription login; no key was needed and none was written anywhere) - The two form cases: case 25 (a `form` item an action opens) and case 28 (a public `form` item) pass with the skill in two rounds each and fail without it in both. - The whole bundle, one sample per case: 37 of 44 behaviour cases pass with the skill (views 23 of 28, analytics 8 of 9, record-page 5 of 6, report-period-export 1 of 1); triggers 7 of 8. - The seven with-skill failures and the one trigger failure are not form cases. Six of the seven and the trigger failure fail the same way with the base tree's `skills/objectstack-ui` restored in place; the seventh (views case 7) passed 4 of 4 on a four-sample rerun at head. By the parity ruling (record 7249189592 on objectstack-ai#34770) a case flipping on both trees, or within one tree, does not block. <details> <summary>Per-case readings of the failing cases, head and base</summary> ``` case head (with-skill) base tree (with-skill) views case 6 fail: missing master_detail fail: missing master_detail views case 7 fail 1 of 1 (forbidden orderBy: 'stage'), then 4/4 pass 1 of 1 views case 8 fail: forbidden ${record.name} fail: forbidden ${record.name} views case 15 fail: forbidden type: 'grid' fail: forbidden type: 'grid' views case 23 fail: missing perRecord, bulkActions: [, ctx.record; forbidden { succeeded fail: forbidden { succeeded analytics-inline-vs-dataset 2 fail: forbidden dateGranularity fail: forbidden dateGranularity record-page 2 fail: forbidden mode: 'split' fail: forbidden mode: 'split' triggers 6 (should not load) loaded (read-only) loaded (read-only) ``` Driver line of every round: `claude-code-cli 2.1.332, login oauth_token, no API key`. The base-tree round restored only `skills/objectstack-ui` from the merge base `f576dee5` in the working tree and was reverted afterwards (`git status` clean); its runner line therefore still prints `b3d7dc22`. The first round of cases 25 and 28 ran at `b2fbb50b`, the second at `b3d7dc22`; the skill files are byte-identical between the two commits. </details> **Gates** `node scripts/pm/dispatch-gates.mjs --commands` derives 70 commands for this diff; all 70 were run at `b3d7dc22`, each exit code recorded before any pipe, and reconciled: ``` ✓ dispatch-gates --ran: 70 derived famil(ies) accounted for — 69 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3). ``` 69 exit 0. NOT MEASURED: `pnpm check:dual-build-cjs-loads` (exit 3, PREREQUISITE NOT MET: it needs a whole-repo build), left to CI. <details> <summary>The 70 commands and the verdict lines of the gates this diff is about</summary> ``` ✓ check-skills-token-ratchet: 61 authored bundle file(s) within their ceilings; 11 generator-owned file(s) and 42 eval fixture(s) measured, not ratcheted. ✓ check-skills-token-ratchet self-test: 111 cases pass. ✓ check-skill-links: 289 relative link(s) in 76 published skill file(s) resolve; 160 fragment(s) name a real heading under GitHub's slug rule. ✓ check-skill-served-sections: 24 served section(s), each heading exactly once in its file (6 json, 2 json+ts, 16 neutral); 10 JSON fence(s) parse and pass their spec validators. ✅ 351 prose examples type-check across 3 surface(s) (check:skill-examples, outside the derived list, run under the verify lock: VERDICT command-exit 0) ✅ check-scripts-symbol-anchors: 4719 anchors across 311 scripts check-nul-bytes: OK (scanned 29016 text file(s); no raw ASCII control bytes) ✓ dispatch-gates self-test (fast tier): 2904 cases pass; 9 slow section(s) deferred. ``` Exit 0 at `b3d7dc22`: `check-adr-0087-registration` (and self-test), `check-changeset-no-major`, `check-closing-keyword-parity` (and self-test), `check-comment-mask-corpus`, `check-declaration-mirrors` (and self-test), `check-doc-route-spelling` (advisory and self-test), `check-dts-emitted` self-test, `check-empty-changeset` (and self-test), `check-self-test-wired` (and self-test), `check-self-test-workflow-commands` (and self-test), `check-skills-token-ratchet` (and self-test), `check-temporal-live-filter` (and self-test), `check-whole-set-label-write` (and self-test), the self-tests of `ci/assert-turbo-remote-cache`, `ci/plan-test-core-shards`, `ci/prune-turbo-cache`, `ci/snapshot-next`, `pm/bare-root-worklist`, `pm/check-governed-queue-guard`, `pm/release-rehearsal-clone` and `release-pending-publish`, `@objectstack/lint check:doc-formula-expressions`, `@objectstack/spec check:skill-docs` and `check:skill-served-sections`, and `pnpm check:` `adr-anchors`, `agent-test-spelling`, `bash32-floor`, `changeset-gate-self-tests`, `ci-filter-parity`, `cli-command-ids`, `closed-ceremony-text`, `corpus-claim-drift`, `cross-package-test-inputs`, `doc-authoring`, `driver-memory-census`, `dts-closure`, `entry-guard`, `gitlink-declared`, `lean-entry-closure`, `merge-driver`, `nul-bytes`, `parse-guard`, `pm-dispatch-gates`, `pm-expected-skips`, `pm-governed-merges`, `pm-skill-id-lint`, `pnpm-filter-targets`, `pnpm-flag-spellings`, `published-files`, `ratchet-remedy-authority`, `refd-timer-probe`, `role-word`, `scripts-symbol-anchors`, `skill-compatibility`, `skill-frame-sync`, `skill-identifier-liveness`, `skill-links`, `sourcemap-no-sources-content`, `watch-hint-literal`. Exit 3 (NOT MEASURED): `pnpm check:dual-build-cjs-loads`. </details> The changeset gate went the publishing way: `skills/**` ships in `@objectstack/skills`, so the diff carries a patch changeset and no `skip-changeset` label (`check-empty-changeset` and `check-changeset-no-major` exit 0; `Metadata-protocol: none` reads as patch). The repo-wide `pnpm lint` and the package test suites are CI's runs; no package source is touched. `node scripts/pm/overlap-check.mjs` before each push and again at `b3d7dc22` against `origin/main` `c4472c86`: exit 0, merges cleanly with `main` and with the two open pulls that share a file (objectstack-ai#38732 shares the ratchet script, objectstack-ai#38192 shares `skills/objectstack-ui/SKILL.md`). ## Acceptance notes - **The migration sentence does not say "refused" and does not name `os migrate meta`.** The card allows one sentence that says so, and the dispatch says to teach only what the code does on `main`. Measured on `main`: a view container with `formViews` still parses and is still projected, and `packages/spec/src/conversions/entries/19` holds no forms conversion; the ADR's execution plan puts the tombstone and the conversion in a later card that waits on this one. The sentence is therefore an authoring prohibition that is true before and after that card. When the tombstone lands, the sentence wants its second half; that card's surface does not include `skills/**`, so this needs a carrier. - **Two files beyond the three the claim names**, both under `skills/objectstack-ui/**`: `rules/navigation.md` linked the heading this diff renames (`check:skill-links` is red without the edit) and said "form view" of the same thing; `evals/README.md` describes the eval file's cases. Three CEILINGS rows moved, not one: each of the three ratcheted files measured below its row. - **Renamed anchors**: `rules/list-views.md#form-views` is `#forms`; `#field-conditional-rules-in-forms` is gone. No file in the repo links either (the one hit is a past CHANGELOG entry). - **Not edited, by the card's fence**, and still using the old vocabulary: the `SKILL.md` frontmatter description ("list / form / kanban / calendar views"; changing it regenerates `skills/README.md` and `content/docs/ai/skills-reference.mdx`), `skills/README.md` ("named form view"), `skills/objectstack-automation/references/examples-flows.md`, `skills/objectstack-api/SKILL.md` (a `FormViewSchema` pointer), `skills/objectstack-i18n/SKILL.md` and its eval file (`_views` keys as a form's heading), `skills/objectstack-data/rules/validation.md` ("named and public forms"). `ui/skills/` does not exist in this checkout. - **Eval grader observations, not acted on**: views case 6 requires the token `master_detail`, which `skills/objectstack-ui` teaches nowhere on either tree; several `must_not_contain` tokens fire on a correct answer that quotes the token inside a prohibition (views cases 7, 8, 15, analytics case 2, record-page case 2). - **Stray file**: a mistyped shell line in this run wrote a 10-byte file `g16.exit` at the container's filesystem root (outside the repo and the worktree). Removing it was refused by the tool's safety check and was not retried another way. ## Verification Two-minute check: run `git grep -nE "formViews|viewKind: 'form'" -- skills` on this branch. Expected: exactly the two lines of `skills/objectstack-ui/rules/list-views.md` quoted above (376 and 377), the one sentence (it ends on 378). Second look, if wanted: `node scripts/check-skills-token-ratchet.mjs` prints `61 authored bundle file(s) within their ceilings`. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No spec file is touched.) - [x] 2. Every name I added uses the casing for its kind. - [ ] 3. No formatter ran; `pnpm lint` passes. (No formatter ran. The repo-wide lint is CI's run and was not run locally.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. (Branched at `f576dee5`; `main` has moved 10 commits since, none touching these files.) - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (Not touched.) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done, with item 3's reading as above. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmPDtfMCw4FJfyFfQ7v)_ <!-- signed: repo:objectstack#3 · os-steve · session_01ADHkmPDtfMCw4FJfyFfQ7v --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…stack-ai#38802) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99QsuPTPkC1uKm2mViUT3Rf)_ Part of objectstack-ai#34770 Clause-②: no Metadata-protocol: none `Part of`, not the closing form: the catalog-size line of the card's Done-when is not met by this PR. This is PR 5 of the per-skill split, under claim 7280537583 and its amendments 7280758590 and 7288186602. ## 维护者速读 - 用户能看到什么变化:用户无感。发给 AI 的「接口设计」技能说明,入口文件从约 21 KB 缩到 9 KB:入口只留开工前四项检查、平台自动提供的接口清单、一个对象可以开放的六种操作、一段可照抄的自定义接口示例、六个「写得通过、上线后却答错或被拒」的坑,以及其余内容去哪里查的指路表。 - 为什么做:这是「技能目录瘦身」的第八份(界面、数据、自动化、平台、跨大版本升级、多语言翻译、表达式与公式七份已完成)。入口文件每次都整份装进 AI 的上下文,越长越贵,也越容易漏读。 - 出错会怎样:只动教 AI 的文字,没有产品行为变化;风险是 AI 少读一段后答错。改动前后各跑完一轮评测(八道题每题三遍,共二十四次):改动后通过十次,改动前九次;没有哪一道题是改动后才每遍都不过的。有四道题前后都是每遍不过,原因前后一样:三道是答案内容对、却没写出题目要求的某个词,一道是 AI 没有打开这份技能说明;这是题目和触发方式的问题,本次没有动。这两轮是经你同意、越过本周额度九成保护线跑的。可整笔撤回。 - 要你做什么:无。席位核对、合约审查与评测对比都已有结果,接下来由席位按治理规则请审批人批准。 ## Rulings this executes - **Card Scope** (decision record on the card, S3 = A): the entry file holds first checks, at most about 8 traps and a routing list; 6–9 KB, hard cap 500 lines; restated option lists and tables go behind a pointer; no trap is removed until a publish-time check covers it or it stays inline. - **7128031203** fork 4 = A: ratchet rows are pinned at the measurement with zero headroom, and the sum of ceilings does not rise. Here no row rises and none is added. - **7168461386** = A: text an eval shows the entry lost goes back into the entry, paid inside the entry. Not used: the two full rounds show no fact the entry lost (see Eval parity). - **Ruling record 7249189592**, the parity rule: a case whose result flips between runs on both trees is unstable on both and does not block; a case that fails on every run of the head while `main` passes is a regression. Read below: no case is one. - **Seat order for this PR** (claim amendment 7288186602, PR 5 = `objectstack-api`): same shape as PR 3 (objectstack-ai#38663) and PR 4 (objectstack-ai#38795); no new file under `skills/` (a new file needs a new ratchet row, which stays with a human); the cut, not a move, lowers the catalog total. ## What changes **The entry file becomes a router.** `skills/objectstack-api/SKILL.md`: 21,359 → 8,986 bytes, 438 → 151 lines, 5,333 → 2,240 tokens. Frontmatter (description, tags) is byte-identical. It now holds: - `## First checks`, four: the installed contract wins over the `compatibility` line, and an `apis:` block written before protocol 17 turns live; read the stack's `apis`, its `manifest.namespace` and the object's `apiMethods`, and prefer a generated route; read the contract and never recall a key or a code; verify with `os validate` or `os build` and read the publish rejection, which carries the fix. - `## Generated routes`: one listing (the `data` routes, the two `batch` routes, import and export, the metadata read), the two routes that do not exist (`/bulk`, a `GET` aggregate), and the two request contracts a client gets wrong: the metadata list's closed query set with `?names=`, and an import mapping's entry form, the only one that carries `applyOn`. - `## API Methods (Operations)`: the six authorable primitives and what each of the eight derived operations derives from. The heading and the six names are held by a gate (see Acceptance notes). - `## A declared endpoint`: the two servable `type` values, one type-checked example (the path carve-out, `object_operation` with `objectParams`, `cacheTtlSeconds`), and the mapping rule (move and rename only; `transform` is rejected). - `## Traps`, six: an anonymous endpoint needs an armed budget (`rateLimit.enabled: true`); an app never mounts on `http.server`, handler code runs in a flow, an inbound webhook is a `type: 'api'` flow, and three cases have no app surface; `DELETE` is not final (the recycle bin, the restore door, the two grants); a `PATCH` with no version token skips the concurrency check; a public form answers `404 FORM_NOT_FOUND` unless its `sharing` declares all three keys, strips fields outside its sections, and is withheld on a walled posture with only a warning; `userMessage` is the sentence for a person. - `## Where to go`: six rows (the endpoint contract and its page, the HTTP protocol page, the error contracts and catalog, the auth contract, the forms page, the three sibling skills). **No text moved.** This skill has no hand-written reference file (`references/_index.md` is generated), and a new file needs a new ratchet row. So what left the entry was cut, each behind what now answers it: | Old entry section | Now | |:--|:--| | Skill Boundaries | The frontmatter description and the last routing row. | | Auto-Generated APIs | The routes listing, with the two absent routes. | | Metadata API (`/meta`) | The first note under the listing: the closed query set, `?names=`, the two refusals. Cut to the HTTP protocol page: the one metadata type whose list refuses `names`. | | Public (anonymous) Form Endpoints | Trap 5: the three `sharing` keys, the two doors, what the declaration grants, the stripped fields and the hook to write, the walled-posture withholding. Cut to the forms page: the file-field rule (an error at `os validate` and at publish), the `guest_portal` name, the two form contracts. | | Declarative Endpoints; Choosing between `apis:` and a code handler | `## A declared endpoint` and trap 2. | | The path carve-out | The example's two comments (`manifest.namespace` is required and never derived; the path shape). | | Five publish gates, each with a prescription | First check 4 (read the rejection, it carries the fix) and routing row 1. The entry no longer counts the gates. | | `authRequired` and the D6 pairing | Trap 1, whole: the default, the armed budget, why `windowMs` / `maxRequests` alone meter nothing, the separate metering. | | Mapping keys: projection only | One sentence under the example. Cut, each a publish refusal that names the key: `inputMapping` on a `find` / `get` / `delete` operation, two entries writing one target path. | | Upgrading a pre-17 stack | First check 1 names the upgrade guide's entry; the steps are there. | | Endpoint Naming Conventions | Cut. Its two patterns are not paths an app can declare (see Acceptance notes). | | API Methods (Operations) | Kept under the same heading, as prose: the six primitives, the eight derived operations and their sources, `upsert` having no route. Cut: the per-primitive route table (the routes listing carries the routes) and the size of the `ApiOperation` vocabulary. | | Discovery & Health | Cut: discovery to the HTTP protocol page; the health routes are not a thing a stack declares. | | Dispatcher Error Codes | Routing row 3 (`api/dispatcher.zod.ts`). | | Realtime Subscriptions | Cut: `references/_index.md` lists both contract files, and first check 3 sends there. | | Authentication & Authorization | Routing row 4: `AuthProvider` with its six members, `LoginRequestSchema`, and that an endpoint has `authRequired` and no nested `auth` block. Cut to the contract: the login request's field list, and the flat `public` + `permissions` pair of the plugin route registry. | | Error Envelopes & the Code Ledger | Routing row 3 (a code in no ledger fails CI) and trap 6. Cut to the contract and the error catalog: the two envelope shapes, the two-tier vocabulary, the downstream-ledger recipe, the locale ladder's subtag steps, the `advisories[]` element. | | Best Practices | First check 2 (prefer a generated route), the `upsert` clause, and the routes listing. Cut: the envelope shapes (the contract). | | Common Pitfalls | Traps 4 and 3. Cut to the two protocol pages, each loud when hit: the quoted-empty entity tag, the four restore refusals, the list / purge / empty doors. | | Verify your work; References | First checks 4 and 3. | **Sizes** (bytes · lines · ratchet tokens): | | before (`main` at `2fba8349`, merged in) | after (head `2b912f16`) | |:--|--:|--:| | `SKILL.md` (entry) | 21,359 · 438 · 5,333 | 8,986 · 151 · 2,240 | | `skills/objectstack-api/**` (3 files) | 33,220 · 569 | 20,847 · 282 | | all 14 `SKILL.md` together | 165,278 · 3,056 | 152,905 · 2,769 | | whole `skills/` tree (115 files) | 1,200,447 | 1,188,074 | | whole tree without `evals/` (73 files) | 841,293 | 828,920 | | ratchet: authored tokens = sum of all ceilings | 192,665 | 189,572 | | ratchet: bundle total, tokens | 297,316 | 294,223 | The head column is measured. The tree and bundle figures of the `main` column are the head's reading plus this entry's fall: the entry is the only file under `skills/` that differs (`git diff --stat origin/main HEAD -- skills`: 1 file). The sum of ceilings on `main` is read from `main`'s own table (61 rows). **Budget reading:** the entry is 8,986 B, inside the card's 6–9 KB line, and 151 lines against the 500-line cap. The whole catalog is 12,373 bytes smaller, all of it cut. **Ratchet row** (`scripts/check-skills-token-ratchet.mjs`), pinned AT its measurement, zero headroom: `skills/objectstack-api/SKILL.md` 5333 → 2240 (−3,093): `ceil((8986 − 27) / 4) = ceil(8959 / 4) = 2240`. It is the skill's only row. The sum of all ceilings goes 192,665 → 189,572. No row rises and none is added. ## Tests ### Eval parity Judged by ruling record 7249189592. **No case fails on every run of the head while `main` passes.** The with-skill arm passes 10 of 24 turns on the head against 9 of 24 on `main`'s text. Three cases pass 3/3 on both trees, four fail 3/3 on both trees for the same reason on each, and one (case 6) goes 0/3 → 1/3. Both arms, one command line for both rounds: `pnpm --filter @objectstack/scenarios skill-evals --skills objectstack-api --repeats 3 --concurrency 4 --max-utilization 0.99`, with the model and effort flags PR 3's rounds used; CLI 2.1.333, subscription login. The two rounds ran back to back in one window (2026-12-01 00:32Z to 00:38Z), each from a clean checkout of its commit. 8 behaviour cases in `evals/endpoints-auth-routes.json`, untouched; this skill has no trigger file, so there is no trigger reading to give. | reading | tree | with-skill | no-skill | with-skill cases below 3/3 | |:--|:--|--:|--:|:--| | before round | `2fba8349` (`main`'s text; the entry is unchanged on `main` since) | 9/24 | 0/24 | 3 (0/3) · 4 (0/3) · 5 (0/3) · 6 (0/3) · 8 (0/3) | | **after round** | `2b912f16` (this head) | **10/24** | 0/24 | 3 (0/3) · 4 (0/3) · 5 (0/3) · 6 (1/3) · 8 (0/3) | | case | subject | `main` | head | what the failing answers have in common, on both trees | |:--|:--|--:|--:|:--| | 1 | a declared `GET` feed | 3/3 | 3/3 | | | 2 | an anonymous endpoint's budget | 3/3 | 3/3 | | | 3 | a signed inbound webhook | 0/3 | 0/3 | Every answer refuses to mount on `http.server` and sends the Stripe callback to a `type: 'api'` flow whose start node declares the vendor header as `config.signature`. That is what both entries and the contract say; the case requires the literal `x-objectstack-signature`, the platform's own header, which a Stripe answer has no reason to name. Two of three answers on `main` and one of three on the head also leave out `functions`. | | 4 | sign-in providers | 0/3 | 0/3 | Every answer names `AuthProvider`, `auth.zod.ts`, `google` and `github` and stops because the project has no files; none names `LoginRequestSchema`, the fifth required literal. Both entries carry it. | | 5 | `apiMethods`, `/batch`, the recycle bin | 0/3 | 0/3 | Every answer gives the primitives, the absent `/bulk` route, the derived `restore` and the recycle-bin restore route; none writes the table name `sys_recycle_bin`. Both entries carry it. One head answer also names the import route and not `/batch` (all three `main` answers name `/batch`). | | 6 | an import mapping's `applyOn` | 0/3 | 1/3 | Two of three turns on each tree answer without opening the skill, and fail. The one turn that opens it passes on the head and fails on `main`, where the entry form (`sourceField`, `targetField`) was not in the entry. | | 7 | the metadata list's `?names=` | 3/3 | 3/3 | | | 8 | `userMessage` on a batch publish | 0/3 | 0/3 | No turn on either tree opens the skill; every answer builds the per-code translation table the case forbids. The description that decides whether the skill is opened is the frontmatter, byte-identical in this PR. | - **No restoration under ruling 7168461386**: no failing answer on the head traces to a sentence the cut removed. The literals the failing answers miss (`x-objectstack-signature`, `LoginRequestSchema`, `sys_recycle_bin`, `userMessage`) are all carried by the head's entry, and by `main`'s. - **Case 5, one observation that is not a regression under the rule**: one of the three head answers does not name `/batch`. The case fails on every run of both trees on another literal, so the rule does not read it; the head's entry names `/batch` in the routes listing and in the `apiMethods` paragraph. It is reported as seen, one run. - **Cases 3, 4, 5 and 8 cannot show a regression as they stand**: they fail on every run of `main`. Cases 3 to 5 fail on a literal a correct answer need not write, and cases 6 and 8 mostly on the skill not being opened. The parity rule treats the cases as fixed, so this PR does not touch them (see Acceptance notes). - **No extra repeats were run**: no case flips in the direction the rule reads, and the window is short. Before the full rounds, the same check that calls no model: of the 27 `must_contain` literals of the 8 cases, the entry carried 24 before and after, lost 0 and gained 2 (`sourceField`, `targetField`, case 6); 1 is in neither tree (`/api/v1/meta/object`, which an answer composes from the route). No `must_not_contain` literal appears in either tree's entry. <details><summary>Round records</summary> - Before round on `2fba8349`: 48 of 48 turns, 2.4 min, exit 0. After round on `2b912f16`: 48 of 48 turns, 2.6 min, exit 0. No turn timed out. - Quota: the runner's guard was raised from its default 0.9 to 0.99 for these two rounds, on the maintainer's answer in the project chat (2026-12-01 00:30Z, option B of the three put to him: run now past the 0.9 line). Seven-day window as each turn reported it: 0.95 on every turn of the before round; 0.95 rising to 0.96 during the after round; status `allowed_warning` throughout, no turn rejected. - The first attempt, on 2026-11-30, was stopped by the guard at its default after 4 of 48 turns on each tree (utilization 0.90 and 0.91; cases 1 and 2 passed once each on both trees). Those stopped rounds ran on CLI 2.1.332 and are not counted in the table above. </details> ### Other tests On tree `d53fb207` (local head `57c7738b`, the same tree as the pushed head `2b912f16`), under the verify lock (`VERDICT command-exit 0` each): - `pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 scripts/platform-catalog.test.ts scripts/skill-map-guards.test.ts` (the suite that names the ratchet script, and the skill-map guards): `Test Files 2 passed (2)`, `Tests 57 passed (57)`. - `pnpm --filter create-objectstack exec vitest run --maxWorkers=2 src/created-summary.test.ts` (the one test file in the tree that names this skill): `Test Files 1 passed (1)`, `Tests 12 passed (12)`. No ablation: the diff changes prose and one ledger, no tested behaviour. ## Acceptance notes Held by a gate, recorded here as it stands in the entry: - **The heading `## API Methods (Operations)` and the six primitive names stay inline.** `scripts/check-skill-identifier-liveness.mjs` registers that section of this file as exhaustive for `ApiMethod` and requires every member in it. That script is outside this claim's file surface. So the section became four lines of prose under its old heading, and the route table went to the routes listing. If the section should leave too, the registration moves first, in its own change. Decided here (small, no shipped behaviour), each open to reversal in review: - **"No trap is removed unless a publish-time check covers it or it stays inline" was read as: a declaration or a call that passes and then answers wrong at run time stays inline.** Inline: the six traps and the two request contracts under the routes listing. Cut to a pointer, each loud when hit: a wrong endpoint key (the strict shape refuses it and names the key to write), the publish gates one by one, the two further mapping refusals, the restore refusals, the quoted-empty entity tag. - **Two traps stay inline although a check exists.** Trap 1: the gate refuses `authRequired: false` without an armed budget, and the entry carries the form to write, which is what eval case 2 asks for. Trap 5's walled-posture sentence: its check only warns at save and publish, and a warning is not a refusal, so the consequence (the form is withheld) and the declaration that resolves it stay, the standard PR 3 applied to its own warning-only rules. - **The endpoint naming table is cut, not moved.** Its two patterns (an object-scoped action path and a domain action path) are not paths an app can declare: a declared path lives under the app's own carve-out, and the endpoint matcher has no path-template syntax. The table taught a form the publish gate rejects. - **`AuthProvider` keeps its six members inline** (0.1 KB): a provider name that is not a member is an authoring mistake the entry can stop before the contract is opened, and eval case 4 asks for the names. - **The health routes are cut with no pointer.** Nothing in a stack declares them, and the HTTP protocol page has no health section, so a pointer there would be untrue. - **The entry no longer counts the publish gates.** The published pages count them differently (four on one, five on another, for the same checks); the entry says the rejection arrives one gate at a time and carries its fix. - **Trap 6 is scoped to the sites where it is true**: "show `userMessage`, never `message`" is said of a batch publish's `probes.issues[]` alone, and the flow door's order (`userMessage`, then `details.innerRefusal`, then `message`) is given beside it. The locale sentence is said of platform text. - **A version check opens the first checks**, as in the other router entries; here it also carries the one upgrade fact that changes what an old `apis:` block does. - **Section anchors of the entry changed.** The changeset lists every anchor that left `SKILL.md` (24) and the five new ones; `#api-methods-operations` stays. No file in this repository links one of the old ones. - **Four lines in the summary above, not six**: the standing order for this card thread asks for six, and the agent file that binds the dev fixes four named lines and wins on conflict. - **Footer form**: this body ends with the single block AGENTS.md prescribes for a PR body. Noted, not changed: - Four eval cases fail on every run of both trees (Eval parity). Case 3's expected answer says an inbound `type: 'api'` flow verifies only the platform's own signature header, while `main`'s entry and the contract (`automation/api-trigger-signature.zod.ts`) also give a vendor's HMAC header declared as `config.signature`, and every answer on both trees follows the contract. Cases 4 and 5 each require one name (`LoginRequestSchema`, `sys_recycle_bin`) that a correct answer leaves out. Case 8 never opens the skill, and case 6 does in one turn of three. The parity rule treats the cases as fixed and the frontmatter is byte-identical by order, so this PR touches neither. Carrier: none; noted for whoever owns the case file and the description. - `main` moved during the work: PR 4 of this split (objectstack-ai#38795) and a rise of one `objectstack-data` row merged. `main` is merged in (`2fba8349`, a plain merge commit); the textual merge was clean and the workspace was rebuilt before any gate ran. ## Verification Read first, by risk: 1. `skills/objectstack-api/SKILL.md`, the whole file: is anything a model needs before opening the contract missing? The risk hunks are `## Traps` (six items replace most of the old file) and trap 2, which carries the whole "no handler code" teaching. 2. `.changeset/34770-api-skill-router.md`: the "what left, and what answers it now" list is the record of every cut. 3. `scripts/check-skills-token-ratchet.mjs`: the one `objectstack-api` row. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` prints `ratcheted (authored) 189572 / 189572 (+0)` and `skills/objectstack-api/SKILL.md 2240 / 2240 (+0)`; `wc -c skills/objectstack-api/SKILL.md` prints 8986. Gates, local, each exit code captured before any pipe. The whole derived list ran on tree `d53fb207` (local head `57c7738b`; the pushed head `2b912f16` carries the same tree, `main` unmoved at `2fba8349`), after the merge of `main` and a full rebuild. <details><summary>Derived families on tree `d53fb207`: 69 derived, 69 run green, 0 NOT MEASURED</summary> - Reconciliation: `✓ dispatch-gates --ran: 69 derived famil(ies) accounted for — 69 run, 0 NOT-MEASURED (a DERIVED zero — all 69 recorded an exit code and none of them is 3).` No STALE TREE warning. - `node scripts/check-skills-token-ratchet.mjs`: `✓ check-skills-token-ratchet: 61 authored bundle file(s) within their ceilings; 11 generator-owned file(s) and 42 eval fixture(s) measured, not ratcheted.` (`ratcheted (authored) 189572 / 189572 (+0)`, `bundle total 294223`); its `--self-test`: `111 cases pass`. - `pnpm check:dual-build-cjs-loads`: `126 published require entry point(s) across 74 package(s) load; 2593 emitted CommonJS file(s) parse`. It reads every package's built `dist/`; a full `pnpm build --concurrency=2` ran first on the merged tree under the verify lock (`VERDICT command-exit 0`, 123 tasks). - `pnpm check:dts-closure`: `123 built package(s) swept - 324/324 declared declaration file(s) present`. - `pnpm check:skill-links`: `290 relative link(s) in 76 published skill file(s) resolve; 160 fragment(s) name a real heading under GitHub's slug rule.` - `pnpm check:skill-identifier-liveness`: `Leg 1: 517 citation(s) over 76 published file(s) ...; Leg 2: 11 registered exhaustive section(s), 0 ledgered gap(s).` - `pnpm --filter @objectstack/spec run check:skill-docs`, `pnpm --filter @objectstack/lint run check:doc-formula-expressions`, `pnpm check:skill-compatibility`, `check:skill-frame-sync`, `check:role-word`, `check:corpus-claim-drift`, `check:doc-authoring`, `check:published-files`, `check:nul-bytes`, `check:cross-package-test-inputs`, `check:ratchet-remedy-authority`: exit 0. - The changeset gates (`check-changeset-no-major`, `check-empty-changeset`, `check-adr-0087-registration`, `check:changeset-gate-self-tests`): exit 0. `pnpm check:pm-dispatch-gates`: exit 0. </details> <details><summary>Beside the derived list, on tree `d53fb207`, all exit 0</summary> - `pnpm --filter @objectstack/spec run check:skill-examples`: `347 prose examples type-check across 3 surface(s)`. The entry's one block is among them. - `pnpm --filter @objectstack/spec run check:skill-refs`: `10 generated files in sync with packages/spec`. - `pnpm --filter @objectstack/spec run check:skill-served-sections`: `24 served section(s), each heading exactly once in its file`. - `pnpm check:doc-anchors`: `1186 internal #fragment link(s) across 368 source file(s) all resolve to a real heading`. - `pnpm check:published-readme-links`: `566 outbound link(s) across 168 published markdown file(s)`, `99 docs-site page(s) resolved`; the four pages the entry links are among them. - `pnpm check:skill-top-level-keys`: exit 0. - `pnpm --filter @objectstack/spec check:generated` after the merge and the rebuild: `All 14 generated artifacts are up to date`. - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: `0 anchored files in the change set — nothing judged.` - `node scripts/check-nul-bytes.mjs`: exit 0; a control-byte scan of the three changed files finds none. </details> Not run locally: `test:repo` (CI's). Base: the router commit was written on a local branch cut from `f7252bc3` while PR objectstack-ai#38795 held this branch; after objectstack-ai#38795 landed, the thread branch took `main` at `2fba8349` (merge `840c3aa8`) and the router commit was cherry-picked onto it as `2b912f16`, whose tree is the gated tree `d53fb207`. `overlap-check` before the push: origin/main, objectstack-ai#38797, objectstack-ai#38790 and objectstack-ai#38192 merge cleanly; objectstack-ai#38497 conflicts in the ratchet file against `main` itself (another skill's row), not this branch's. CI on the head is the seat's reading. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmSM46qymk97AyqPzoS)_ <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
…d to change and held for its whole approval (closedStates, ADR-0162) (objectstack-ai#38810) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9HqHpbnZfMBnSP27W5MzeEY)_ Part of objectstack-ai#37768 Part of objectstack-ai#37766 Part of objectstack-ai#37767 Clause-②: yes (narrowing) Metadata-protocol: semantic Skills-docs: follow-up objectstack-ai#38425 **This PR supersedes objectstack-ai#38497** (the approvals trunk `claude/o5-data-approvals-trunk` → `main`). The trunk took its two `main` refreshes as squashes, which left its history without `main` and objectstack-ai#38497 in conflict with `main` again. This branch is the trunk with its history joined to `main`: it carries every commit on the trunk, and `main` up to `2fba83493b`. The Part-of lines and the two declarations above are objectstack-ai#38497's; Clause-② carries the narrowing arm of piece 5 (objectstack-ai#38746, `feat(approvals)!`), which landed on the trunk after objectstack-ai#38497's body was written. objectstack-ai#38497's description follows unchanged below, under "The trunk (from objectstack-ai#38497)". ## 维护者速读 - 改了什么:objectstack-ai#38497 的全部内容(单据关闭态锁定 ADR-0162 的 A/B/C 各片、objectstack-ai#37766 各片、审批 objectstack-ai#37767 各块,含第 5 块「审批全程锁单」),改由这个 PR 落到 main;objectstack-ai#38497 由席位关闭。 - 为什么换 PR:主干两次刷新都被 squash 合入,主干和 main 的历史断开,objectstack-ai#38497 又与 main 冲突;这条分支内容等于主干加最新 main,历史里带着 main,所以对 main 是干净的。 - 谁受影响:同 objectstack-ai#38497 下文说明;声明了 `closedStates` 的对象受影响,没声明的照旧。 - 要你做什么:待 battery、L1 与非实现方契约复审之后,由席位交棒。 ## How this branch is built - Trunk head `a5f33621e3` (objectstack-ai#38797, squashed; its tree is `85aea4d1c2`). - `77e94868d0` merges `8ff2442358`, the gated head objectstack-ai#38797 squashed: same tree `85aea4d1c2`, no content change; it puts `main` up to `fc198b2847` into the history. - `2f344f7b1d` merges `origin/main` at `2fba83493b` (7 commits after `fc198b2847`) through `scripts/pm/os-regen-merge.sh`: no conflict, and none of the 7 commits touches a file the trunk's own changes touch. ## Trunk refreshes with `main`, and their records - objectstack-ai#38791 (`main` at `59faf74c6f`): L1-b ACCEPT 7284982294, contract review PASS 7285519382, seat record 7285551596; DELIBERATE CORRECTION declaration 7284894883. - objectstack-ai#38797 (`main` at `fc198b2847`): L1-b ACCEPT 7289462740, contract review PASS 7289911344, seat record 7289942965; DELIBERATE CORRECTION declaration 7289249692. ## Measured on this head - `scripts/pm/dispatch-gates.mjs` against `main`: 147 derived, 147 run, 0 NOT-MEASURED, all exit 0. - Regeneration from this tree (`gen:schema`, `gen:docs`, `gen:liveness-counts`, then `check:generated` and `check-system-context-census.mjs`): exit 0, and the tree was unchanged after it. - Tests and typecheck green: objectql, metadata-protocol, platform-objects, plugin-approvals, core, service-automation, spec, runtime; cli tests green; dogfood 500 files / 4295 tests passed. - A trial merge of this head with `main` at `0fc9eab900` has no conflict. ## The trunk (from objectstack-ai#38497) > **Trunk moved (seat repo:objectstack#5, area o5-data).** This PR replaces objectstack-ai#38421, the same closed-state trunk handed back by seat 2 (clock-out brief 7250342397 on objectstack-ai#34478). The trunk branch is now `claude/o5-data-approvals-trunk`, cut from `claude/project-thread-yxheps` at `bfe2df88b` and written only by area `o5-data`. Since the hand-back it carries objectstack-ai#37766 slice C (PR objectstack-ai#38485, merged into this trunk as `07f0923c5c` with `--no-ff`). Still to land on this trunk before it leaves draft: objectstack-ai#37766 slices B and D, objectstack-ai#37767 pieces 3–5, objectstack-ai#37768 slice C (Release-order lines on those cards). The sections below are objectstack-ai#38421's, for slices A and B of objectstack-ai#37768 and piece 2 of objectstack-ai#37767; the slices added since are described in their own PRs. > **Since landed on this trunk** (all in this PR's diff): objectstack-ai#37766 slices B and D: objectstack-ai#38499, objectstack-ai#38546, objectstack-ai#38562, objectstack-ai#38563; objectstack-ai#37767 pieces 3–5: objectstack-ai#38540 (piece 3), objectstack-ai#38618 (piece 4), objectstack-ai#38746 (piece 5), with the ADR-0162 revision objectstack-ai#38601; objectstack-ai#37768 slice C: objectstack-ai#38516. Two refreshes with `main`: objectstack-ai#38791, objectstack-ai#38797. > (objectstack-ai#38497 as written) Clause-②: yes (widening: one new optional authorable key, `ObjectSchema.closedStates`, and the engine's enforcement of it) > (objectstack-ai#38497 as written) Metadata-protocol: added > (objectstack-ai#38497 as written) Skills-docs: follow-up objectstack-ai#38425 ### 维护者速读 - 用户能看到什么变化:对象上写了「哪些状态算已关闭」后,单据一旦进入这些状态(比如发票已付款、已作废),它和它的明细行就不能再被普通用户改、删、挪动明细或加明细,系统返回 409「记录已锁定」;批量操作只要碰到一条已关闭的单据就整批不执行。系统自身的写(汇总重算、审批回写状态)照常落地。没写这个键的对象完全不变。 - 为什么做:单据关闭态锁定(ADR-0162)的第一、二部分:A 定下这个键和编写规则,B(本次新增)让平台真正按它锁单据,应用不用再手写锁定代码,也第一次能挡住「删一条明细」这种以前挡不住的改动。 - 出错会怎样:只影响写了这个新键的对象。最坏情况是该锁的没锁(回到今天的样子),或者某个平台内部写被误锁(已逐条列出并测试)。分支在拒绝文案(C 部分)和审批两张卡落地前不合并,所以不会单独发布。 - 要你做什么:无。有一条覆盖层的发现交座位判断是否要上决策卡(见 Acceptance notes「Overlay」)。 ### What changes #### Slice A — the key (ADR-0162 D1) Slice A of objectstack-ai#37768 (ADR-0162 D1, the key), on the card's trunk branch. Slices B (the engine's judgement, D2–D7, D10) and C (the refusal, D8) land on this same branch; it does not merge before the card's `Release-order` line is met, so the key is never published without its enforcement (ADR-0078, ADR-0162 D10). **Spec (`packages/spec`)** - `ObjectSchema.closedStates`: optional map from a field of the object to the list of that field's values that close a record, e.g. `{ status: ['paid', 'void'], approval_status: ['approved'] }`. The record is guarded against a `__proto__` key like `fields`. No default, so no parsed object grows a key. TSDoc and `.describe()` state the contract D1–D5 give. - `refuseDishonestClosedStates` (`src/data/closed-states.ts`, outside the barrel, the `stage-field-kinds.ts` precedent), called from the object's `superRefine`. One located `custom` issue each, at `['closedStates', FIELD]` or `['closedStates', FIELD, i]`: a key naming no field of the object; a field that is not a single-value `select` (another type, `radio` included, or `multiple: true`); a select with no inline `options` (a `picklist`-backed one); an empty list; a value that is not one of the field's options; a repeated value. Because the object document is judged whole, the same refusals cover removing or retyping a named field and removing a listed option: the next version leaves a declaration that names what the edit took away. - Studio object form row (Advanced section, JSON row beside `uiReadonlyWhen`). - Liveness row `object.closedStates`: **`planned`**, evidence `closed-states.ts#refuseDishonestClosedStates` (the refusals, live at parse) — the `enable.aiReadable` precedent. It turns `live`, with its runtime proof, in slice B: nothing on this branch reads the key at runtime yet. See Acceptance notes. - Regenerated: reference docs (`content/docs/references/data/object.mdx`, `packages/spec/docs/references/**`), the authorable-surface record (`data/Object:closedStates`), liveness state counts (object: planned 1 → 2). **Other packages** - `metadata-core` FLS scrub: `closedStates` classified as a map keyed by this object's fields (`recordOf(keep, true)`): an entry whose field is denied to the caller is left out of the served definition, an emptied map is deleted, and the values (option codes) are literals, never read as references. - `platform-objects`: the form row's label and help text authored in all ten translated metadata-forms locales (ar, de, es-ES, fr, ja-JP, ko, pt-BR, ru, zh-CN, zh-Hant), `en` regenerated by `check-i18n-bundles --write`; two derived leaf-count pins moved (+2 leaves in `advanced`, +1 translated label). - Three changesets: `@objectstack/spec` minor, `@objectstack/metadata-core` patch, `@objectstack/platform-objects` patch (the `uiReadonlyWhen` precedent). #### Slice B — the engine's judgement (ADR-0162 D2–D7, D10) **Engine (`packages/objectql`)** - `closed-state-lock.ts` (new): the one judgement every write door calls. A record is closed when its STORED row holds a listed value (D2); its unit is the record plus its direct `master_detail` lines, and a junction row is a line of both masters (D3). Every write a system context does not make is bound, and a write with no context is bound (D5). The refusal is `409 RECORD_LOCKED` with `reason` (`record_closed` · `master_closed` · `cascade_reaches_closed` · `cannot_judge`), `object`, `blockingObject`, `lockReason: 'closed_state'`; the message names no id and no state value. D8's sentences are slice C. - Wired doors: by-id update and delete (`engine-update.ts`, `engine-delete-and-aggregate.ts`, judged against the prior row the write already reads); predicate update and delete (refused whole before any row is written: one existence probe on the record, and for lines one semi-join probe where the store compiles the composed `ReadableIds` leaf, else the write's one read of its matched rows under `MAX_BULK_PER_ROW_HOOK_ROWS`); insert and insertMany (a line under a closed master; partial-mode insertMany is refused whole); the cascade set where it is planned (`engine-cascade-planning.ts`, D6); restore (`recycle-bin/restore.ts`, D7). - Placement (D10): after the middleware gates, before the before-hooks. A master the write NAMES goes through the caller's own read door first (`masterDetailHeadersCallerReads`), so an unreadable master answers as before and the lock never confirms that a record the caller cannot read exists; a STORED master is read by the engine. - `closed-state-values.ts` (new): `closedValuesOf`, split out so the registry does not import the write path. **Registry fold (seat review S1, `registry-closed-state-fold.ts`, new)** - An extension that redeclares a field the served `closedStates` names, and removes it, retypes it, makes it multi-value or narrows its options past a listed value (or leaves it with no inline options), has THAT redeclaration refused: the field stands as the fold had it, the fold logs it once naming the package, and the rest of the extension lands. One test per case. The four guarantee sentences of slice A stand as written. - A tenant overlay (the fold's base) may ADD closed values; the served declaration is the package's list with the overlay's added, and a field the package's list names keeps the package's definition where the overlay broke it. **Other** - Liveness `object.closedStates` → **`live`**, evidence the engine's reads and the dogfood suite; state counts regenerated. - Error-code ledger: `RECORD_LOCKED` registered under `@objectstack/objectql` (third emitter beside plugin-approvals and rest). This is a D8 ledger line pulled forward because B already throws the code; C keeps the sentences. - Changeset `@objectstack/objectql` minor; the spec changeset gains the ledger line. **After the seat's delta review (7249320091, PASS), head 8e95b36** - S2: every master check is asked of the store: one existence probe per chunk of ids with the closed predicate in its `where` and `fields: ['id']` (`anyClosedAmong`), never a read of state columns tested in process. The cascade set is judged the same way: one probe per chunk for its own state, and for its lines the predicate door's semi-join where `lineProbeServes` says the store runs it; only a store that cannot keeps the read of the lines' keys, then one probe of their masters (D4's stated fallback). Pinned per shape by `a cascade that reaches a line of a closed record is refused …` (probe store: no read of the master; no-probe store: one probe carrying the predicate, `fields: ['id']`). - N2: where the fold restores the package's field over an overlay that broke it, the overlay's added closed values for that field are served only where the package's field declares them. - CI on a0d9493: the system-context census row for `boundByClosedStates` (row 29g on `content/docs/permissions/system-context.mdx`, register regenerated). The local census had passed before the commit because it walks tracked files only. - Carried to slice C by the seat: tests for the assignment-rule and approval-mirror system writes, a plugin-security-level D10 test, and the API names in the developer `message`. #### Engine-derived writes (Done-when list) | Write | Context it runs in | What the lock does | Test | |---|---|---|---| | Referential clear of a deleted record's references (`set_null`) | system (reference-cleanup elevates; the clear also carries the referential-clear marker) | lands: exactly the cleared field | `a referential clear lands on a closed record` | | Recycle-bin relink on restore | caller, carrying `REFERENTIAL_CLEAR_OPTION` | lands (a bare reference restore, the clear's inverse) | `the recycle-bin relink puts a cleared reference back on a closed record, for the caller` | | Roll-up summary recompute | `{ ...caller, isSystem: true }` | lands | `the summary recompute writes the closed invoice in a system context, and lands` | | Cascade legs of a planned delete | caller | judged ONCE, at the planned set (D6); legs are not judged again | `a delete whose cascade reaches a closed record removes no row`, with and without transactions | | Change Owner (`changeRecordsOwner`) | **caller** | bound: each closed record (and line) is a `RECORD_LOCKED` failure, the open ones move | Change Owner block (4 tests) | | Banned-user hand-over (`transferUserAssignedWork`) | **caller** | bound: closed records stay with the user, counted as failures | `the hand-over of a user's work leaves the closed records …` | | Assignment rules | system | lands | not added here (system, unbound by D5) | | Approval status mirror | system, attributed | lands | measured below | The two writes that run in the CALLER's context (Change Owner and the hand-over) are bound, not exempted, and are reported to the seat as the card asks. #### Measured: the approval mirror and the request's finalisation They do **not** share one unit of work. `ApprovalService` finalises the request (`engine.update('sys_approval_request', …, { context: SYSTEM_CTX })`, `approval-service.ts` ~6305) and then calls `mirrorStatusField` (~6312), which issues its own `engine.update` with no transaction handle and swallows a failure into a warning (`approval-service.ts` ~4989–5015). The same order holds at recall, reject, return and the dead-run abandon (~7110, ~7726, ~7768, ~9810). A mirror that fails leaves a finalised request and an unmirrored record. The lock does not change this: the mirror is a system write and lands on a closed record. #### Hook-supplied master (N14) A master a `beforeInsert` / `beforeUpdate` hook supplies is **not** judged: the lock runs before the before-hooks (D10), so it judges the master the caller named. Pinned by `a master a beforeInsert hook supplies is not judged by the lock`. ### Why ADR-0162 (merged as `972114df`), Execution item 1, on the maintainer's rulings recorded on objectstack-ai#32004 (7073676422) and objectstack-ai#36253 (7200732942, 7201405662, 7205949718). Apps that must freeze a decided document hand-code it today and cannot guard the removal of a line at all. ### Tests **Slice B** - `packages/qa/dogfood/test/closed-state-lock.test.ts` (new, 69): on SQLite in two store shapes, each pinned, a store that runs the line probe and one that declares `readableIdsLeaf: false` (the MongoDB / OData shape). Every row of D4's table, for a record and for a line, single-row and many-row, on both shapes; the read shape of each (probe: one statement on the line table; no probe: the matched rows plus one read of their masters); the three cannot-judge cases (a master named by something that is not one id, a state read that fails, a many-row line write past the per-row ceiling with 10,001 seeded lines, with the probe-store control that lands); the closing write lands whole and the next is refused; no context refused; system writes, deletes and restores; the cascade removes no row with and without transactions; restore; engine-derived writes; a refused write runs no before-hook; an object that declares nothing reads nothing extra; Change Owner and the hand-over. - `packages/objectql/src/registry-closed-state-fold.test.ts` (new, 13): the four extension breaches each refused with the rest of the extension applied, two controls; overlay may add, may add to an object with none, may not shorten (key left out, fewer values), may not break a named field, relabel control, and an overlay's added value for a field the package's version of which is restored is not served (N2). Measured: with the two guards disabled, 7 of the first 12 fail. **Slice A** - `packages/spec/src/data/closed-states.test.ts` (new, 22 cases): the ADR example parses and keeps its value; absent stays absent; no tie to a `state_machine` rule either way; `create()` keeps it; each refusal above, one located issue each, with its message's subject; one issue per offending entry with a sound entry untouched; removing the field, retyping it, making it multi-value and removing a listed option each refused, with the control that removing an unlisted option lands; the save and publish door (`getMetadataTypeSchema('object')`) and the stack door refuse at the same path; a line object needs no declaration and may declare its own. - `metadata-core` `object-schema-fls-references.test.ts`: a denied field's entry dropped and the readable one kept; a map left empty deleted; CONTROL: a value spelled like the denied field is served as written. - Moved pins, each with a history line: `compose-stacks-merge-collection-refusal.test.ts` and `compose-stacks-collection-pipe-arm.test.ts` — `closedStates` is an object-level collection, so `composeStacks` `objectConflict: 'merge'` refuses two stacks that declare it differently (new `it.each` row), and it is the first collection key on the real shape behind a preprocess stage, which the landed reading carries and the in-only reading does not (the invariance case now pins exactly that); `protocol.meta-types-degenerate-derivation.test.ts` object 53 → 54 top-level properties; the two `platform-objects` echo-decision counts. <details><summary>Slice A local runs (head 5d8b45b)</summary> - `pnpm --filter @objectstack/spec test`: 913/915 files on the first run; the two red files were the composeStacks pins above, re-run green after the move (92/92). - `pnpm --filter @objectstack/metadata-core --filter @objectstack/platform-objects test`: 29/29 files, 1121 tests; 130/130 files, 2218 tests. - `pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.meta-types-degenerate-derivation.test.ts`: 18/18. - `typecheck` of spec, metadata-core, platform-objects: exit 0. - `pnpm --filter @objectstack/spec check:generated`: all artifacts up to date (after `--fix` rebuilt the dist; it wrote nothing). - `pnpm check:i18n`: OK, all bundles in sync. - `node scripts/pm/dispatch-gates.mjs --ran`: 122 derived, 120 run, every one exit 0; 2 NOT MEASURED (exit 3, prerequisite: other packages' builds) — `check:skill-examples` (client SDK dist) and `check:dual-build-cjs-loads` (a full build); CI runs both. - `node scripts/pm/overlap-check.mjs`: clean against `origin/main`, no open PR shares a file. - No full dogfood battery: no `!` in the title and no `(narrowing)` arm. </details> <details><summary>Slice B local runs</summary> On 8e95b36: objectql full suite 644/644 files, 14559/14559 tests; dogfood `closed-state-lock.test.ts` 69/69 on a rebuilt dist; fold 13/13; typecheck objectql and dogfood, `check:facade-delegation-only`, `check:system-context-census` green. Head 1f399d9. - `pnpm --filter @objectstack/objectql exec vitest run`: 643/644 files, 14557/14558 tests on the first run; the red file was `federated-injected-column-readers.test.ts`, which asks every engine use of `isFederatedObject()` for a disposition: the line probe's federated-master decline got its row (`exempt`, reads no row) and the file re-ran green (5/5). - `pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.ts` against a rebuilt objectql dist: 67/67. - `pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts`: 12/12; with the two fold guards disabled, 7 of 12 fail. - `typecheck` of objectql (with `check:test-typecheck`) and dogfood: exit 0. - `node scripts/pm/dispatch-gates.mjs --ran`: 101 derived, 101 run, every one recorded `exit 0`. First run: 94 green, 7 red, each re-run after its fix: five spec dist-reading gates and `check:generated` answered exit 3 / 1 on a spec dist older than the ledger edit (green after `pnpm --filter @objectstack/spec build`); `check:facade-delegation-only` was red because `engine.ts` grew 7 lines past its ceiling (the new host members now share existing lines, 6856 ≤ 6857). - `pnpm check:system-context-census`: OK (the lock reads `isSystem` through `boundByClosedStates`, inside the census). - `node scripts/pm/overlap-check.mjs`: clean against `origin/main`, no open PR shares a file. - No full dogfood battery: no `!` in the title and no `(narrowing)` arm. </details> Slice A CI on 5d8b45b: 65 checks passed, 11 skipped, none failed. ### Acceptance notes - **Overlay (card Done-when, for the seat).** Verified and pinned: an overlay may ADD `closedStates`, and before this branch it already could (an overlay body is a full object document, and the fold serves it as the base), so a subscriber's admin can freeze records of a packaged object in states the package did not close. Before the guard an overlay could also SHORTEN the package's list (leave the key out or list fewer values), which unlocked what the package locks; it no longer can. Whether "may add" stays is a product question: if it changes what a subscriber may do to a packaged document, it goes back to the seat as a decision card, as the card says. The pin is `may ADD: an overlay that declares closed values of its own is served with them`. - **The fold "refuses" by keeping the field, not by failing registration.** An extension is a separate package that may load in any order; failing its whole registration over one field would take its other objects and fields down with it. The redeclaration of the named field is dropped, the fold logs it once with the package id, and the rest applies. - **D10 gate placement** is proven in the engine by order (the lock runs inside the write after the middleware chain and before the before-hooks, pinned by `a refused write runs no before-phase hook`); no plugin-security-level test was added for "a caller denied the object gets the same answer on a closed record". - **Liveness (slice A: `planned`; slice B: `live`)** (confirmed by the seat, claim revision 7248339226). The claim's file surface names "the liveness ledger row with its runtime proof (ADR-0054)". On this slice there is no runtime reader to prove: the engine's judgement is slice B. A `live` row now would cite a consumer that does not exist. Slice A set the row `planned`; slice B flips it to `live` with the engine reads and the dogfood suite as evidence. - **Narrow readings of D1, decided here (small, listed for the seat):** `radio` is refused (D1 says `select`); a `picklist`-backed select is refused because its options are not on the object and this is the one door every save passes (the `stageField` precedent); an empty map `closedStates: {}` is accepted and closes nothing (D1 refuses an empty list, not an empty map). "Stored" needs no check of its own: a computed value is a `formula` field, never a `select`. - **Publish door.** The removal and retype refusals ride the object's whole-document parse, which the save and publish door runs (pinned at `getMetadataTypeSchema('object')`). A field removed through a tool that rewrites the object document reaches the same parse. - **Not in this slice (the card's other Done-when lines):** the overlay question moved to slice B (claim revision 7248339226) and is answered above. The `skills/**` follow-up is objectstack-ai#38425; the docs card (item 5) and an eval that exercises a declaration are owed by the card, named here as the card asks. - The Metadata-protocol line was `added` on objectstack-ai#38497, the card's own value for the key (the seat's claim revision 7248339226). This PR declares `semantic`: it also carries objectstack-ai#38746, whose changeset `.changeset/37767-hold.md` declares `Metadata-protocol: semantic` (a record that declares `closedStates` is now held for its whole approval, with no change to what an author writes), and AGENTS.md takes the strongest of several kinds, `narrowed` over `semantic` over `added`. - Branch is the trunk `claude/o5-data-approvals-trunk` (cut from seat 2's `claude/project-thread-yxheps`), not `claude/issue-37768-*`. ### Verification Two-minute check: `pnpm --filter @objectstack/spec exec vitest run src/data/closed-states.test.ts` — expect 22 passed; `pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts` — expect 13 passed; after `pnpm --filter @objectstack/objectql build`, `pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.ts` — expect 69 passed. ### Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (CI). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request (the card's trunk branch). - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmPpwJymVUdp5AnRPBq <!-- signed: repo:objectstack@os-steve · os-steve · session_01ADHkmSAjFEZHRpRq3WCj6z --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Nenzyz
pushed a commit
to Nenzyz/objectstack
that referenced
this pull request
Dec 1, 2026
… notes across three records) (objectstack-ai#38809) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBHuLciv5hYVYUu4pypDP48J)_ Fixes objectstack-ai#38438 Clause-②: no Metadata-protocol: none This pull request carries the card's last four rows. The first seven landed with the first pull request of this card, objectstack-ai#38774, merged 2026-11-30. ## 维护者速读 - 用户能看到什么变化:用户无感;只在三份设计记录里补了四条带日期的说明,写明主线现在实际怎么做,原有的决定文字一个字没动。 - 为什么做:属于「每周设计记录修订」滚动清单(11 月 29 日这一周);上一张合并请求已带走七行,这次补齐剩下四行,这份清单就此收口。 - 出错会怎样:最坏是某条说明写得不准,照着设计记录干活的人会被带偏;纯文档、只增不删,可以直接撤回,不影响任何功能。 - 要你做什么:请审这四条说明并批准一次(设计记录须由你本人批)。 ## What changes Three ADR files gain four notes dated 2026-12-01. Every diff line is an addition: 43 lines added, 0 removed. No original decision text is rewritten, and no decision changes. Each note follows the note convention its own record already uses, and each says that the passage it is read with is left as written. Each row's "what is true now" was read against the code on `main` before its note was written. All four rows hold. Where a row's wording did not match the tree, the note says what `main` does; the last column says so and the list under the table gives the detail. | ADR · section | Was (the record's words) | Now (what the note records) | Source PR | Row on the card · result | |:---|:---|:---|:---|:---| | ADR-0161 · Consequences, the bullet "A stored fingerprint and recipe hash are the only index state the service relies on" | "The service keeps none of its own" | The service keeps a sync state for each source: its last build, and the record syncs that failed and are not yet repaired. Where the knowledge plugin can keep it, it is one durable record per source; otherwise the last build is kept in the process and failed syncs are not counted. Whether an index is due for a build is still read from the stored fingerprint and recipe hash, so the bullet's first sentence stands for that decision. The K8 note of 2026-11-28 already names this state | objectstack-ai#38307 | Card body row · **written, corrected to the tree** (the in-process case) | | ADR-0161 · K7, the components table, row "Split algorithm version" | "a constant the splitter exports; it changes when the splitter gives different passages for the same text and settings" | The version is kept per split strategy, and the fingerprint reads the entry for the strategy the source resolves to. A change to one strategy's passages starts a new generation only for the sources that resolve to it. The single exported constant is retired, with no alias | objectstack-ai#38375, objectstack-ai#38452 | Card body row · **written, corrected to the tree** (no version value is written) | | ADR-0085 · the note of 2026-11-27, and the note of 2026-11-30 under it | "Neither key is in the spec yet", and in the later note "The second half stands: `fieldTabs` is not in the spec" | `fieldTabs` is in the spec, an optional list of `{ key, groups }` entries on `ObjectSchema`, so both keys are built. The parse refuses a group the object does not declare, a group two tabs name, a group that places a related list, and a repeated `key`. The tabs are drawn on every tier of the standard record page: the full page, the side preview and a phone. Only the standard record page reads the key, and an object extension does not carry it | objectstack-ai#38742 | 7282251133 · **written** | | ADR-0084 · the table "What the amendment replaces", row "Entries that are not a type", and three sentences that count four entries | "The organization's own flows retire when the door that moves loose items ships."; "The menu also holds four entries that open no type's list"; "Of the four entries that are not a type, the cross-package directory is to leave the menu"; "The four entries that are not a type are 高级 on a package" | The door has shipped and the flows have retired, the entry and the package-less scope it opened alike. Four changes carried it, each named with what it did. The three sentences count the rows of the table under "Entries that are not a type" as it was first written. The note names the entries of a package's menu that open no type's list today: 概览 Overview, the default sharing overview, Diagnostics and 全部类型 All types | objectstack-ai#38185, objectstack-ai#38389, objectstack-ai#38545, objectstack-ai#38598 | 7283216315 · **written, corrected to the tree** (names and no count; a third sentence; the change that built the door) | Every prerequisite of the four rows is merged on `main`: objectstack-ai#38307, objectstack-ai#38375, objectstack-ai#38452, objectstack-ai#38742, objectstack-ai#38185, objectstack-ai#38389, objectstack-ai#38545 and objectstack-ai#38598, and objectstack-ai#38679 and objectstack-ai#38401, which two of the notes point back to. The newest comment on the card when this was opened is the claim amendment, 7296007044; a row added after it is not in this pull request. ### Where a note differs from its row - **ADR-0161, Consequences.** The row says the service keeps a sync state per source. On the tree that state is a durable record only where the knowledge plugin can keep it, with its object registered and a data engine bound. Otherwise the last build is kept in the process and failed syncs are not counted. The note says both. It also says what the row asks for: the stored fingerprint and recipe hash are still what a build is decided from, at boot and on reload alike. - **ADR-0161, K7.** The row says no fingerprint value moves. That is true of the change that brought the table in, and the note says so in those terms. It is not true of every entry since: one strategy's entry has been raised on `main` for a change to its own passages. So the note writes no version value, and says that an entry raised since was raised for its own strategy. - **ADR-0161, the header.** This record lists every dated note in its header, one "Amended" line each. The two notes add two such lines, the seventh and the eighth. That is the record's own convention and it is why the file gains 17 lines for two notes. - **ADR-0085.** The first pull request of this card wrote a note dated 2026-11-30 that says "The second half stands". That sentence was true for one day. The new note is placed under it and names both sentences it is read with; neither older note is edited. It does not repeat what the 2026-11-30 note says of `pinOverview`. The three tiers are read from the code: the list of field tabs is built with no regard to the tier. No test names the three tiers one by one. - **ADR-0084.** The row asks for the entry count as it now stands. The note names the entries and writes no number, since a count in a record goes stale with the next entry. The row names two sentences that count four entries with no note beside them: the one that opens "Entries that are not a type", and "Of the four entries that are not a type, the cross-package directory is to leave the menu", in the note of 2026-11-26 under "The two tiers". The note reads both. It also reads a third, which the row does not name and which has no note either: "The four entries that are not a type are 高级 on a package", under the same heading, quoted as it renders (the record links part of it). So the note says three. As first pushed, the note said two and left out the sentence the row asks about; the contract review found it, and `128528c5` corrects the note. The row names three pull requests. The note names four and says which did which part: the door itself was built by objectstack-ai#38185. The note stays in step with the two ADR-0084 notes of the first pull request, which it does not touch. ## Tests Docs only. No package source is touched, so no package test and no type check is owed for the change. No tested behaviour changed, so there is no ablation. Checked on the committed text: - Each phrase a note quotes from its ADR is in that file as it stands on `main`. A script compared them. One quotation, in the ADR-0084 note, reads as the sentence renders. - Each path a note cites exists on the tree, and each of the seven symbols a note anchors is a declaration in the file named. `pnpm check:adr-symbol-anchors` judges the same and is green. - A probe on the spec source: `ObjectSchema` accepts `fieldTabs` with a declared group. It refuses a group the object does not declare, a group two tabs name, and a repeated `key`. `ObjectExtensionSchema` refuses `fieldTabs` as an unrecognised key, with its guidance. - `ui/packages/app-shell/src/views/studio-design/studioMenuPlacement.test.ts` reads ADR-0084's type table from disk. It was run under the verify lock on the final commit `128528c5`: `Test Files 1 passed (1)`, `Tests 21 passed (21)`. It read the same on `808e249f`, the first commit of the notes. The local gate set is the `dispatch-gates --commands` derivation for this change set, 21 commands, run on the final commit `128528c5`. Each exit code was captured before any pipe. Reconciliation: `Run reconciliation — 21 derived, 21 run, 0 NOT-MEASURED, 0 UNRUN`. The same 21 were derived and run on `808e249f` and on `f7bae5cfb`, with the same result. On `128528c5` the derivation warns that the branch is one commit behind `main` and that one file it derives from changed there. The branch does not merge `main` again while this pull request is open and mergeable, so the list was derived a second time on a throwaway tree of `main` (`d97aaaea9a`) plus this branch: the same 21 commands, and no warning. <details><summary>ADR gates on 128528c (all exit 0)</summary> | Command | Exit | Verdict line | |:---|:---|:---| | `pnpm check:adr-symbol-anchors` | 0 | `check-adr-symbol-anchors: 4606 anchors across 165 records resolve — 1726 symbol (1697 declaration, 29 literal)`, 0 line anchors survive. Seven of the symbol anchors are new with this change. | | `node scripts/check-adr-links.mjs` | 0 | `check-adr-links: 1284 relative link destination(s) under docs/adr/ resolve` | | `node scripts/check-adr-links.mjs --self-test` | 0 | | | `pnpm check:adr-anchors` | 0 | `check-adr-anchors: OK (135 anchored file(s), every governing ADR still referenced` | | `pnpm check:adr-index` | 0 | `adr-index --report: OK — docs/adr/README.md is current, every record parsed` | | `pnpm check:doc-authoring` | 0 | | | `pnpm check:nul-bytes` | 0 | `check-nul-bytes: OK (scanned 29077 text file(s)`, no raw control bytes | | `pnpm check:closed-ceremony-text` | 0 | | | `pnpm check:pm-governed-merges` | 0 | | | `pnpm --filter @objectstack/lint run check:doc-formula-expressions` | 0 | run after building the build closure of `@objectstack/lint` under the verify lock | </details> <details><summary>The other derived families on 128528c (all exit 0)</summary> `node scripts/check-closing-keyword-parity.mjs` and its `--self-test`, `node scripts/check-comment-mask-corpus.mjs` (`24511 files, 0 disagree, 0 unparseable`), `node scripts/ci/plan-test-core-shards.mjs --self-test`, `pnpm check:ci-filter-parity`, `pnpm check:cross-package-test-inputs`, `pnpm check:driver-memory-census`, `pnpm check:gitlink-declared`, `pnpm check:pm-prior-rulings`, `pnpm check:refd-timer-probe`, `pnpm check:watch-hint-literal`. Before the last push: `node scripts/check-commit-card-trailers.mjs --range origin/main..HEAD` exit 0, three commit messages, no card relation and no model identifier in the trailer pair. </details> <details><summary>The overlap check answers exit 1 against one open pull request, objectstack-ai#38812; the reading is below</summary> `node scripts/pm/overlap-check.mjs` on `128528c5`: - Against `main` (`d97aaaea9a`): `origin/main: merges cleanly`. - Against the open pull request objectstack-ai#38812 (a draft opened after this one, head `f3cd7dba76`, one file, 17 lines added to ADR-0161): `VERDICT overlap exit 1`, with the conflict named in the ADR-0161 file. No other open pull request shares a file with this branch. What the conflict is made of, measured on the two heads: - Both add to the header list of dated notes in ADR-0161, at the same place, under its sixth line. This branch adds two lines, "a seventh dated note" and "an eighth dated note". objectstack-ai#38812 adds one line, and it also says "a seventh dated note". - That is the only conflict hunk. The notes themselves sit apart and merge: this branch's under K7 and under Consequences, the other's under K8 with a cross-reference at K1. So this overlap is real, and it is more than text: the two pull requests number their notes from the same count. Whichever lands second has to merge `main`, keep all three header lines, and renumber its own. See the acceptance notes. An earlier reading, on `f7bae5cfb`, answered 1 against the approvals trunk, objectstack-ai#38497. That pull request has since ended without a merge (2026-12-01T01:02Z), and the check no longer lists it. </details> Not run locally: the repository test project behind `test:repo`, and every package suite. CI runs them on the pull request and on the merge group. Every other family CI runs is read from this pull request's check runs, not re-run here. ## Acceptance notes - **Changeset.** None, and the pull request carries `skip-changeset`. `docs/adr/**` ships in no package. - **Governed surface.** `docs/adr/**` lands on the maintainer's approval. This pull request stays a draft; the seat arranges the review at the tier this surface owes and hands it over. - **Why this one ends the card.** The card says it ends when its pull request merges. Seven rows landed with the first pull request and these four are the rest, so every row is carried. The card is open and is not waiting on a decision. - **Claim binding.** The claim amendment, 7296007044, names this branch on a line spelled `Branch (round 2):`, which the guard "The card this PR closes must claim this branch" does not read. The seat restated the claim in the shape the guard reads (comment 7296908473 on the card), and the guard is green on this pull request. - **Landing order against objectstack-ai#38812.** Both pull requests add header lines to ADR-0161 at the same place, and both call their note the seventh; the overlap check answers 1 for that file. Whichever lands second merges `main`, keeps all three header lines and renumbers its own. If this one lands second, its two lines become the eighth and the ninth. If objectstack-ai#38812 lands second, its line becomes the ninth. The seats set the order: this pull request first, by claim stamp (seat 2's `Notify: serial · objectstack-ai#38676 behind objectstack-ai#38438`, mailbox objectstack-ai#38766 comment 7297489558); objectstack-ai#38812 renumbers its line after this lands. - **Seen and left alone.** Outside the four rows, and not changed here. - ADR-0084's table "What the amendment replaces" has a row on the cross-package directory that says "In force until it moves". The amendment of 2026-11-26 moved that entry to Setup, and the menu model on this tree has no entry kind for it. A candidate row for the next weekly card. - The items the first pull request of this card listed under this heading stand as listed there. ## Verification ### Read first 1. `docs/adr/0161-knowledge-platform-boundary-platform-owns-assembly-sync-split-record-return-knowledge-source-is-a-governed-type.md`, the note of 2026-12-01 under the list of Consequences. The highest-risk hunk: it says a sentence of the record no longer describes `main`, and it draws the line between the state a build is decided from and the state that only reports. Check the sentence pair "Where the knowledge plugin can keep it" and "Otherwise", and the bullet "What decides a build is unchanged". 2. `docs/adr/0084-application-builder-information-architecture.md`, the amendment of 2026-12-01 under the table "What the amendment replaces". It says which of four pull requests did which part, it names the three sentences that count four entries, and it names a package's menu entries where the record counts them. Check the four attributions, the three quoted sentences and the four names. 3. `docs/adr/0085-object-semantic-roles-over-surface-hint-blocks.md`, the note of 2026-12-01. It answers a sentence that the note of the day before wrote, and its claim of three tiers is read from code with no test that names them. Check the tier sentence and the list of what the parse refuses. ### Two-minute check Run `git diff --numstat origin/main...HEAD` on this branch. Expect three rows under `docs/adr/`, each with `0` in the removed column, and 43 added lines in total (2, 24 and 17). Then run `pnpm check:adr-symbol-anchors` and expect exit 0 with a line that contains `anchors across 165 records resolve`. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzhPdWmTd47Fi2bKYZS)_ <!-- signed: repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhPdWmTd47Fi2bKYZS --> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Leehom · project thread
Part of #37768
Part of #37766
Part of #37767
Clause-②: yes (widening: one new optional authorable key,
ObjectSchema.closedStates, and the engine's enforcement of it)Metadata-protocol: added
Skills-docs: follow-up #38425
维护者速读
What changes
Slice A — the key (ADR-0162 D1)
Slice A of #37768 (ADR-0162 D1, the key), on the card's trunk branch. Slices B (the engine's judgement, D2–D7, D10) and C (the refusal, D8) land on this same branch; it does not merge before the card's
Release-orderline is met, so the key is never published without its enforcement (ADR-0078, ADR-0162 D10).Spec (
packages/spec)ObjectSchema.closedStates: optional map from a field of the object to the list of that field's values that close a record, e.g.{ status: ['paid', 'void'], approval_status: ['approved'] }. The record is guarded against a__proto__key likefields. No default, so no parsed object grows a key. TSDoc and.describe()state the contract D1–D5 give.refuseDishonestClosedStates(src/data/closed-states.ts, outside the barrel, thestage-field-kinds.tsprecedent), called from the object'ssuperRefine. One locatedcustomissue each, at['closedStates', FIELD]or['closedStates', FIELD, i]: a key naming no field of the object; a field that is not a single-valueselect(another type,radioincluded, ormultiple: true); a select with no inlineoptions(apicklist-backed one); an empty list; a value that is not one of the field's options; a repeated value. Because the object document is judged whole, the same refusals cover removing or retyping a named field and removing a listed option: the next version leaves a declaration that names what the edit took away.uiReadonlyWhen).object.closedStates:planned, evidenceclosed-states.ts#refuseDishonestClosedStates(the refusals, live at parse) — theenable.aiReadableprecedent. It turnslive, with its runtime proof, in slice B: nothing on this branch reads the key at runtime yet. See Acceptance notes.content/docs/references/data/object.mdx,packages/spec/docs/references/**), the authorable-surface record (data/Object:closedStates), liveness state counts (object: planned 1 → 2).Other packages
metadata-coreFLS scrub:closedStatesclassified as a map keyed by this object's fields (recordOf(keep, true)): an entry whose field is denied to the caller is left out of the served definition, an emptied map is deleted, and the values (option codes) are literals, never read as references.platform-objects: the form row's label and help text authored in all ten translated metadata-forms locales (ar, de, es-ES, fr, ja-JP, ko, pt-BR, ru, zh-CN, zh-Hant),enregenerated bycheck-i18n-bundles --write; two derived leaf-count pins moved (+2 leaves inadvanced, +1 translated label).@objectstack/specminor,@objectstack/metadata-corepatch,@objectstack/platform-objectspatch (theuiReadonlyWhenprecedent).Slice B — the engine's judgement (ADR-0162 D2–D7, D10)
Engine (
packages/objectql)closed-state-lock.ts(new): the one judgement every write door calls. A record is closed when its STORED row holds a listed value (D2); its unit is the record plus its directmaster_detaillines, and a junction row is a line of both masters (D3). Every write a system context does not make is bound, and a write with no context is bound (D5). The refusal is409 RECORD_LOCKEDwithreason(record_closed·master_closed·cascade_reaches_closed·cannot_judge),object,blockingObject,lockReason: 'closed_state'; the message names no id and no state value. D8's sentences are slice C.engine-update.ts,engine-delete-and-aggregate.ts, judged against the prior row the write already reads); predicate update and delete (refused whole before any row is written: one existence probe on the record, and for lines one semi-join probe where the store compiles the composedReadableIdsleaf, else the write's one read of its matched rows underMAX_BULK_PER_ROW_HOOK_ROWS); insert and insertMany (a line under a closed master; partial-mode insertMany is refused whole); the cascade set where it is planned (engine-cascade-planning.ts, D6); restore (recycle-bin/restore.ts, D7).masterDetailHeadersCallerReads), so an unreadable master answers as before and the lock never confirms that a record the caller cannot read exists; a STORED master is read by the engine.closed-state-values.ts(new):closedValuesOf, split out so the registry does not import the write path.Registry fold (seat review S1,
registry-closed-state-fold.ts, new)closedStatesnames, and removes it, retypes it, makes it multi-value or narrows its options past a listed value (or leaves it with no inline options), has THAT redeclaration refused: the field stands as the fold had it, the fold logs it once naming the package, and the rest of the extension lands. One test per case. The four guarantee sentences of slice A stand as written.Other
object.closedStates→live, evidence the engine's reads and the dogfood suite; state counts regenerated.RECORD_LOCKEDregistered under@objectstack/objectql(third emitter beside plugin-approvals and rest). This is a D8 ledger line pulled forward because B already throws the code; C keeps the sentences.@objectstack/objectqlminor; the spec changeset gains the ledger line.After the seat's delta review (7249320091, PASS), head 8e95b36
whereandfields: ['id'](anyClosedAmong), never a read of state columns tested in process. The cascade set is judged the same way: one probe per chunk for its own state, and for its lines the predicate door's semi-join wherelineProbeServessays the store runs it; only a store that cannot keeps the read of the lines' keys, then one probe of their masters (D4's stated fallback). Pinned per shape bya cascade that reaches a line of a closed record is refused …(probe store: no read of the master; no-probe store: one probe carrying the predicate,fields: ['id']).boundByClosedStates(row 29g oncontent/docs/permissions/system-context.mdx, register regenerated). The local census had passed before the commit because it walks tracked files only.message.Engine-derived writes (Done-when list)
set_null)a referential clear lands on a closed recordREFERENTIAL_CLEAR_OPTIONthe recycle-bin relink puts a cleared reference back on a closed record, for the caller{ ...caller, isSystem: true }the summary recompute writes the closed invoice in a system context, and landsa delete whose cascade reaches a closed record removes no row, with and without transactionschangeRecordsOwner)RECORD_LOCKEDfailure, the open ones movetransferUserAssignedWork)the hand-over of a user's work leaves the closed records …The two writes that run in the CALLER's context (Change Owner and the hand-over) are bound, not exempted, and are reported to the seat as the card asks.
Measured: the approval mirror and the request's finalisation
They do not share one unit of work.
ApprovalServicefinalises the request (engine.update('sys_approval_request', …, { context: SYSTEM_CTX }),approval-service.ts~6305) and then callsmirrorStatusField(~6312), which issues its ownengine.updatewith no transaction handle and swallows a failure into a warning (approval-service.ts~4989–5015). The same order holds at recall, reject, return and the dead-run abandon (~7110, ~7726, ~7768, ~9810). A mirror that fails leaves a finalised request and an unmirrored record. The lock does not change this: the mirror is a system write and lands on a closed record.Hook-supplied master (N14)
A master a
beforeInsert/beforeUpdatehook supplies is not judged: the lock runs before the before-hooks (D10), so it judges the master the caller named. Pinned bya master a beforeInsert hook supplies is not judged by the lock.Why
ADR-0162 (merged as
972114df), Execution item 1, on the maintainer's rulings recorded on #32004 (7073676422) and #36253 (7200732942, 7201405662, 7205949718). Apps that must freeze a decided document hand-code it today and cannot guard the removal of a line at all.Tests
Slice B
packages/qa/dogfood/test/closed-state-lock.test.ts(new, 69): on SQLite in two store shapes, each pinned, a store that runs the line probe and one that declaresreadableIdsLeaf: false(the MongoDB / OData shape). Every row of D4's table, for a record and for a line, single-row and many-row, on both shapes; the read shape of each (probe: one statement on the line table; no probe: the matched rows plus one read of their masters); the three cannot-judge cases (a master named by something that is not one id, a state read that fails, a many-row line write past the per-row ceiling with 10,001 seeded lines, with the probe-store control that lands); the closing write lands whole and the next is refused; no context refused; system writes, deletes and restores; the cascade removes no row with and without transactions; restore; engine-derived writes; a refused write runs no before-hook; an object that declares nothing reads nothing extra; Change Owner and the hand-over.packages/objectql/src/registry-closed-state-fold.test.ts(new, 13): the four extension breaches each refused with the rest of the extension applied, two controls; overlay may add, may add to an object with none, may not shorten (key left out, fewer values), may not break a named field, relabel control, and an overlay's added value for a field the package's version of which is restored is not served (N2). Measured: with the two guards disabled, 7 of the first 12 fail.Slice A
packages/spec/src/data/closed-states.test.ts(new, 22 cases): the ADR example parses and keeps its value; absent stays absent; no tie to astate_machinerule either way;create()keeps it; each refusal above, one located issue each, with its message's subject; one issue per offending entry with a sound entry untouched; removing the field, retyping it, making it multi-value and removing a listed option each refused, with the control that removing an unlisted option lands; the save and publish door (getMetadataTypeSchema('object')) and the stack door refuse at the same path; a line object needs no declaration and may declare its own.metadata-coreobject-schema-fls-references.test.ts: a denied field's entry dropped and the readable one kept; a map left empty deleted; CONTROL: a value spelled like the denied field is served as written.compose-stacks-merge-collection-refusal.test.tsandcompose-stacks-collection-pipe-arm.test.ts—closedStatesis an object-level collection, socomposeStacksobjectConflict: 'merge'refuses two stacks that declare it differently (newit.eachrow), and it is the first collection key on the real shape behind a preprocess stage, which the landed reading carries and the in-only reading does not (the invariance case now pins exactly that);protocol.meta-types-degenerate-derivation.test.tsobject 53 → 54 top-level properties; the twoplatform-objectsecho-decision counts.Slice A local runs (head 5d8b45b)
pnpm --filter @objectstack/spec test: 913/915 files on the first run; the two red files were the composeStacks pins above, re-run green after the move (92/92).pnpm --filter @objectstack/metadata-core --filter @objectstack/platform-objects test: 29/29 files, 1121 tests; 130/130 files, 2218 tests.pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.meta-types-degenerate-derivation.test.ts: 18/18.typecheckof spec, metadata-core, platform-objects: exit 0.pnpm --filter @objectstack/spec check:generated: all artifacts up to date (after--fixrebuilt the dist; it wrote nothing).pnpm check:i18n: OK, all bundles in sync.node scripts/pm/dispatch-gates.mjs --ran: 122 derived, 120 run, every one exit 0; 2 NOT MEASURED (exit 3, prerequisite: other packages' builds) —check:skill-examples(client SDK dist) andcheck:dual-build-cjs-loads(a full build); CI runs both.node scripts/pm/overlap-check.mjs: clean againstorigin/main, no open PR shares a file.!in the title and no(narrowing)arm.Slice B local runs
On 8e95b36: objectql full suite 644/644 files, 14559/14559 tests; dogfood
closed-state-lock.test.ts69/69 on a rebuilt dist; fold 13/13; typecheck objectql and dogfood,check:facade-delegation-only,check:system-context-censusgreen.Head 1f399d9.
pnpm --filter @objectstack/objectql exec vitest run: 643/644 files, 14557/14558 tests on the first run; the red file wasfederated-injected-column-readers.test.ts, which asks every engine use ofisFederatedObject()for a disposition: the line probe's federated-master decline got its row (exempt, reads no row) and the file re-ran green (5/5).pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.tsagainst a rebuilt objectql dist: 67/67.pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts: 12/12; with the two fold guards disabled, 7 of 12 fail.typecheckof objectql (withcheck:test-typecheck) and dogfood: exit 0.node scripts/pm/dispatch-gates.mjs --ran: 101 derived, 101 run, every one recordedexit 0. First run: 94 green, 7 red, each re-run after its fix: five spec dist-reading gates andcheck:generatedanswered exit 3 / 1 on a spec dist older than the ledger edit (green afterpnpm --filter @objectstack/spec build);check:facade-delegation-onlywas red becauseengine.tsgrew 7 lines past its ceiling (the new host members now share existing lines, 6856 ≤ 6857).pnpm check:system-context-census: OK (the lock readsisSystemthroughboundByClosedStates, inside the census).node scripts/pm/overlap-check.mjs: clean againstorigin/main, no open PR shares a file.!in the title and no(narrowing)arm.Slice A CI on 5d8b45b: 65 checks passed, 11 skipped, none failed.
Acceptance notes
closedStates, and before this branch it already could (an overlay body is a full object document, and the fold serves it as the base), so a subscriber's admin can freeze records of a packaged object in states the package did not close. Before the guard an overlay could also SHORTEN the package's list (leave the key out or list fewer values), which unlocked what the package locks; it no longer can. Whether "may add" stays is a product question: if it changes what a subscriber may do to a packaged document, it goes back to the seat as a decision card, as the card says. The pin ismay ADD: an overlay that declares closed values of its own is served with them.a refused write runs no before-phase hook); no plugin-security-level test was added for "a caller denied the object gets the same answer on a closed record".planned; slice B:live) (confirmed by the seat, claim revision 7248339226). The claim's file surface names "the liveness ledger row with its runtime proof (ADR-0054)". On this slice there is no runtime reader to prove: the engine's judgement is slice B. Aliverow now would cite a consumer that does not exist. Slice A set the rowplanned; slice B flips it tolivewith the engine reads and the dogfood suite as evidence.radiois refused (D1 saysselect); apicklist-backed select is refused because its options are not on the object and this is the one door every save passes (thestageFieldprecedent); an empty mapclosedStates: {}is accepted and closes nothing (D1 refuses an empty list, not an empty map). "Stored" needs no check of its own: a computed value is aformulafield, never aselect.getMetadataTypeSchema('object')). A field removed through a tool that rewrites the object document reaches the same parse.skills/**follow-up is skills: the data skill teaches the closedStates key (after #37768) #38425; the docs card (item 5) and an eval that exercises a declaration are owed by the card, named here as the card asks.added, the card's own value (the seat's claim revision 7248339226 settles it).claude/o5-data-approvals-trunk(cut from seat 2'sclaude/project-thread-yxheps), notclaude/issue-37768-*.Verification
Two-minute check:
pnpm --filter @objectstack/spec exec vitest run src/data/closed-states.test.ts— expect 22 passed;pnpm --filter @objectstack/objectql exec vitest run src/registry-closed-state-fold.test.ts— expect 13 passed; afterpnpm --filter @objectstack/objectql build,pnpm --filter @objectstack/dogfood exec vitest run test/closed-state-lock.test.ts— expect 69 passed.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses (CI).main, one pull request (the card's trunk branch).packages/spectouched: its generated artifacts are regenerated and committed.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01FEkQ5phEgfPTCgvPqh4ER2