Repository navigation
fix(metadata-protocol): leave a denied audit row for every documented refusal code at the save, publish, rollback and delete doors - #28393
Conversation
…at carry none Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
…l code Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
…dit row; add changeset Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
…it in the engine-double ledger Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 29 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin de5b3784698c45ed4d007ecd96058f1cab544740 && git checkout de5b3784698c45ed4d007ecd96058f1cab544740
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8c8c5b5255109a7d039225e48e8f6b718247a9af b50e93b45477292c07f9f6df12749cfe2aeae615 && git checkout -B drift-repro 8c8c5b5255109a7d039225e48e8f6b718247a9af && git merge --no-ff b50e93b45477292c07f9f6df12749cfe2aeae615
node scripts/docs-audit/affected-docs.mjs --json 8c8c5b5255109a7d039225e48e8f6b718247a9af
|
…t shapes from local aliases; mark the D6b audit codes in the pins Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
…ssert it instead of no insert Claude-Session: https://claude.ai/code/session_01QUs3Bs2hELyx9Go8Efyui5 Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#4 · os-zhuang · session_01QUs3BtyH9zgxKzYrJiH18J ACCEPT · PR #28393 · Head-sha 维护者速读
席位意见:在入口出口统一记账,覆盖以后新加的拒绝点;映射表封闭、不铸新值, 席位核对
|
Requested by Sam · project thread
Fixes #28355
Clause-②: no
Metadata-protocol: none
维护者速读
NOT_OVERRIDABLE/NOT_CREATABLE/INVALID_METADATA/DESTRUCTIVE_CHANGE拒绝时,会在sys_metadata_audit里写一条denied记录。/audit的人会以为被拒的尝试从未发生。packages/metadata-protocol/src/protocol-refusal-audit.ts(映射表与去重标记),protocol.ts四个入口的包装段,protocol.refusal-audit-rows.test.ts。pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.refusal-audit-rows.test.ts,预期 12 个用例全绿。What changes
protocol-refusal-audit.ts. A closed map from the four catalogued refusal codes to the lower-case valuessys_metadata_audit.codealready documents (not_overridable,not_creatable,invalid_metadata,destructive_change),refusalAuditEntry(the row a refusal owes at a door, or none), andwithRefusalAudit(run the door, record the row on such a refusal, rethrow the same error).saveMetaItem,publishMetaItem,rollbackMetaItemanddeleteMetaItemkeep their names and signatures; each is now a short wrapper over aprotected …Unauditedbody holding the unchanged code. The row is written where the door hands the refusal back, so a refusal raised by any gate inside the door (including shared helpers such as the ADR-0131 D6 organization-scoped refusal) is covered, and so is one added later.outcome: 'denied',operationthe door,actor/sourceas the door's allowed row records them,note=clientFacingFailureText(the sentence the caller was already shown; the column is wire-visible), andtypefolded to the canonical singular (the writer refuses anything else).INVALID_REQUEST,RESOURCE_CONFLICT, driver faults, 5xx) writes nothing; the column's set stays closed.item_lockedandmetadata_conflictare not in the map, so their own gates' rows are not duplicated. A refusal handed back through two wrapped doors is recorded once (a marker on the error). The batch publish keeps itsbatch_abortedrow.item_lockedwas already stamped (see Acceptance notes), so nothing is trimmed.Why
sys_metadata_auditpromised denial rows that never appeared, so an operator or agent reading/auditfor a metadata name concluded that a refused authoring attempt never happened. Triage's lean (enforce at the refusing door, besidemetadata_conflict) is followed.Tests
protocol.refusal-audit-rows.test.ts(new, 12 cases), driven through the real doors with a fake engine that persists audit inserts: one denied row per enforced code on the save door (not_creatable,not_overridable,destructive_change,invalid_metadata), the plural spelling filed under the canonical type, the publish / rollback / delete doors each stamping their ownoperation, plus an allowed control (oneallowed/okrow, no denied row), an out-of-map refusal (INVALID_REQUEST) writing nothing, the closed map, and a refusal through two doors recorded once.protocol.code-only-types.test.ts(saveMetaItem 的 legacy raw-engine 分支在 #5086 的门之后已不可达 —— 一段 grep 找得到、运行时永不执行的代码 #5264 block),protocol.lock-org-axis-agree.test.ts,protocol.tenant-authored-write.test.ts: the only engine call a refusal makes is now its owndeniedaudit row, asserted exactly (table, operation, code), and still nosys_metadatawrite.protocol.read-verb-canonical-fold.test.ts,protocol.view-expansion-reconcile-call-sites.test.ts: the fold and the stored-row writes now live in the…Unauditedbodies; the rosters name those members (and the method scan admitsprotected, which only these four use).scripts/engine-double-contract.pinned.json: the new test's fake engine is recorded, ascheck:engine-double-contractrequires.Acceptance notes
item_locked(the dispatch asked): it is already stamped.assertLockAllowsWrite/assertLockAllowsDelete/lockWriteRefusalinprotocol-lock-version-gates.tswritecode: 'item_locked'withlock_stateon all four doors, and the batch publish re-records it outside its transaction (recordPendingDenialAudit). Not measured: whether the repository's own read-only-base refusal (SysMetadataRepository.readOnlyBaseOverrideError,ITEM_LOCKEDwithlockSource: 'package') is ever reached past that gate without a row; it is deliberately not in the map, so a lock-gate refusal cannot be written twice.sys-metadata-audit.object.tsis unchanged: its documented vocabulary is now true, so no trim was needed.scripts/engine-double-contract.pinned.json, the gate's own ledger entry for the new test double.Verification
All readings are on head
7e9960c8da(merged withorigin/mainatfc5d5093b), in a dedicated worktree.pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2(under the verify lock) →Test Files 285 passed | 4 skipped (289),Tests 21872 passed | 26 skipped (21898). Before the five pins were reconciled the same run was 15 red in exactly those five files.pnpm --filter @objectstack/metadata-protocol typecheck→ exit 0 (itstsconfig.jsonincludessrc/**/*, so the test files are compiled).node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 69 commands; all 69 ran and exited 0.--ranreconciliation:69 derived, 69 run, 0 NOT-MEASURED, 0 UNRUN, every family carrying its exit code. The two real reds on the first pass were fixed in this PR (check:objectql-double-limit: the newfinddouble now applieslimit;check:engine-double-contract: the double is recorded in the ledger).pnpm lint→ exit 0.check:platform-checklistnot run: no exported symbol is renamed or removed (the four doors keep their names and signatures).!in the title, no(narrowing)arm).Ablation of the audit write (one-off, not kept)
Predicted before running: the nine denied-row cases red, the allowed control, the
INVALID_REQUESTno-row case and the closed-map case green.node scripts/ablation-replace.mjsonpackages/metadata-protocol/src/protocol-refusal-audit.ts, anchorif (entry) {, replaced by a guard that is always false (entry && Date.now() is negative), runningvitest run src/protocol.refusal-audit-rows.test.tsunder it.4b5d1b1c9c20→35ebe7c00ab9Tests 9 failed | 3 passed (12), exactly as predicted4b5d1b1c9c20== HEAD,git diff HEADemptyThe unit suite imports
./protocol.jsfrom source, so no rebuild was involved.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: n/a, not touched.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code