Repository navigation
fix(objectql): deleting a record clears a read-only lookup that points at it - #34952
Conversation
…red on main) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
… the read-only strips The delete walk hands update() the holder row and lookup it clears on a module-private symbol option; update() exempts exactly that key, at the value the walk wrote, from the static readonly strip, the readonlyWhen strip and the hide-from-hooks pass. The operation-private context marker grants nothing, and isSystem is not granted. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
Keeps the shared engine-top-level import list untouched, which an open sibling PR also edits. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 21 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 c3361a40bd7911a8e2730cc7a14eaf3a1c313f88 && git checkout c3361a40bd7911a8e2730cc7a14eaf3a1c313f88
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c81f498b5f0614157864d9586da718dbe02121b1 326cea5a8064f490096a8217c6574e213130a15f && git checkout -B drift-repro c81f498b5f0614157864d9586da718dbe02121b1 && git merge --no-ff 326cea5a8064f490096a8217c6574e213130a15f
node scripts/docs-audit/affected-docs.mjs --json c81f498b5f0614157864d9586da718dbe02121b1
|
|
repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa L1 review (L1-d) · 2026-11-17T18:19ZL1: ACCEPT Read against claim 6954800432 and os-dev report 6956449432 on #34899.
What holds
Must-fixNone. Should-fix
Notes
Landing: not governed. Area o3-G lands it once CI is fully green on this exact head and the seat has ruled on S1. A later push owes a delta read. |
…d counts only landed re-links The re-link and its undo ride the engine's module-private referential channel, so update() leaves exactly that key on that row to the engine; relinked is read back from the store. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH
|
repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa L1 review (L1-d) · 2026-11-17T19:08ZL1: ACCEPT This is a delta read from my ACCEPT at
What holds
Must-fixNone. Should-fixNone. Notes
Landing: not governed. Area o3-G lands it once CI is fully green on this exact head. A later push owes a delta read. |
|
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH Landing · 2026-11-17T19:10Z
Ready + auto-merge into the queue. Area o3-G (repo:objectstack#3) watches it to MERGED and closes out #34899. |
Requested by Yibo Wang · project thread
Fixes #34899
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
维护者速读
set_null)。现在即使这个 lookup 是只读(readonly或readonlyWhen)也能清空,且不再打印 "DROPPED" 警告。packages/objectql/src/engine-update.ts(豁免的构造,约 :282-300)、packages/objectql/src/validation/rule-validator.ts(isReferentialClear与两处跳过)、packages/objectql/src/engine-cascade-planning.ts(删除流程传入私有选项,约 :1153-1170)。pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-set-null-readonly-lookup-clear.test.ts,预期 13/13 通过。What changes
Deleting a record makes the engine clear every optional lookup pointing at it (
set_null, the default) with an UPDATE of the holder under the caller's context. The update-side read-only strip runs on!context.isSystemand never read the walk's marker, so on areadonly: truelookup it dropped the clear and loggedField 'billed_on' on 'ro_entry' is read-only: the caller-supplied value was DROPPED and the update is being COMMITTED WITHOUT IT. The delete answered 200 and the holder kept the deleted id. AreadonlyWhen-locked lookup failed the same way.The fix:
engine-top-level.ts: a module-privateREFERENTIAL_CLEAR_OPTIONsymbol, the shape of the ADR-0142 D4WRITE_PRECONDITION_OPTION. It is not re-exported fromindex.tsorcore.ts, and no.d.tsof the built package names it.engine-cascade-planning.ts: the walk passes{ object, id, field }of the holder row and lookup on that symbol, next to the unchangedreferentialCtx.engine-update.ts:update()turns the option into aReferentialClearExemption { field, value }. It does this only on the by-id write of the row and object the walk named, withvaluetaken from the entry snapshot. It hands the exemption to the hide-from-hooks pass, thereadonlyWhenstrips (FK settlement and the main pass), the stored view those read, and the static strip.rule-validator.ts:isReferentialClear(data, name, exemption)is true only forname === fieldwhile the key still holdsvaluebyObject.is. The static strip keeps that key and logs nothing for it. ThereadonlyWhenstrip does not judge it. Every other key is judged exactly as before.recycle-bin/restore.ts(ADR-0148 D2, claim amendment 6956936802): the restore's re-link of a cleared reference, and that re-link's undo when a restore fails partway, now pass{ object, id, field }on the same module-privateREFERENTIAL_CLEAR_OPTION.update()builds the same one-key exemption from it, only on the by-id write of the row and object the restore names, at the value the restore writes. So areadonly/readonlyWhenlookup is re-linked under the caller's context instead of stripped. It is notisSystem, and it is not the__referentialFieldClearmarker.relinkednow counts a re-link only when a read-back of the row after the write shows it holds the id (relinkedValue(...) === undefined). A write that a strip or a hook took the key out of is not counted.Why a symbol and not the context marker. The ruling asked whether
__referentialFieldClearcan be forged before relying on it. Findings:assembleExecutionContext(packages/core/src/security/assemble-execution-context.ts:295-430, closedentryFields) builds the inbound envelope from a closed field set with no__key.ctx.apiwrites outside a cleanup dispatch: no.ObjectRepository.updateoverridescontextwith the hook's own (packages/objectql/src/engine-object-repository.ts:83-88).packages/objectql/src/engine-middleware-and-context.ts:183-187).The exemption therefore keys on neither the marker nor
isSystem. It keys on a value only the walk can hold. A caller carrying the marker gets nothing, and a test pins this.The multi-value branch is covered. On a
multiple: truelookup the walk writes the remaining ids, and the exemption is that exact array.Tests
New file
packages/objectql/src/engine-set-null-readonly-lookup-clear.test.ts: realObjectQL, stub driver, the siblingengine-referential-clear-write-context.test.tsharness plus$in/$contains. It pins:nullafter its target is deleted, under a user context and under none, with no drop line, and the holder'sbeforeUpdatesees thenull;[a, b]becomes[b]);readonlyWhen: 'true'lookup is cleared;updatecarrying__referentialFieldClearand its cause through the normal door is still stripped and logged once, still locked byreadonlyWhen, and still refused understrictReadonlyWrites(codeERR_READONLY_FIELD_REJECTED,fields['billed_on'], row unchanged);readonlyWhen).Restore pins, a top-level describe in
recycle-bin/restore.test.ts(the restore harness): (1) readonlyset_nulllookup, delete, restore: the reference holdsacc1again,relinkedis 1, and no drop line is logged across the delete and the restore. (2) A holderbeforeUpdatethat keeps the stamp empty: the row staysnullandrelinkedis 0. (3) A callerupdatecarrying the option's shape through the normal door (aSymbol('objectql.referentialClear')key, aSymbol.for('objectql.referentialClear')key, and__referentialFieldClearon the context) is still stripped and logs one DROPPED line. A JSON transport cannot carry a symbol key at all. Ablations at head a0f8fd1: re-link without the option gives pin 1 red (expected +0 to be 1); counting without the read-back gives pin 2 red (expected 1 to be +0); both restored to HEAD by blob. Suite at 326cea5: objectql 607/607 files, 13672/13672 tests.Red on main (test commit 4b1c7da, engine unchanged)
The walk's own write logged, on main:
Field 'billed_on' on 'ro_entry' is read-only: the caller-supplied value was DROPPED and the update is being COMMITTED WITHOUT IT ...Green, package suite, typecheck (head fbe36bf)
Ablations (head fbe36bf, scripts/ablation-replace.mjs, test imports src directly)
rule-validator.ts:return exemption !== undefinedbecamereturn false && exemption !== undefined. The anchor count went 1 to 0 and the blob changed cb5c7a24af8e to 7c529516591a. Result: 8 failed, 5 passed (the six engine cases and both exemption units). Restore: blob equals HEAD,git diff HEADempty.engine-cascade-planning.ts: the walk stops passing the symbol (const clearOptions = { context: referentialCtx };). Mutation landed (d941938d7c4b to e7d59f666fb7). Result: 6 failed, 7 passed (the six engine cases; the units stay green as expected). Restored: blob equals HEAD.Acceptance notes
null, a DROPPED line was logged, andrestore()still counted it inrelinked. The re-link and its undo now ride the engine's private channel, andrelinkedcounts only re-links that landed. The undo leg carries the channel too. It is not pinned separately, because no harness drives a restore that fails after a re-link outside a transaction; it is the same call shape as the pinned forward write.Verification
Local gates (head fbe36bf)
node scripts/pm/dispatch-gates.mjs --commands(no paths; change set from merge base d576509, 7 paths) derived 71 commands. All 71 ran on fbe36bf. Each exit code was captured before any pipe.node scripts/check-plugin-teardown-shape.mjs --self-test: checker health only. Its pinned fixture commit is unreachable on this shallow checkout.pnpm check:dual-build-cjs-loads: its self-test passed (93 cases). The scan needs every package'sdist/, and only the objectql closure was built. CI runs it.--ranreconciliation:71 derived famil(ies) accounted for — 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).check-platform-checklist --changed-fromdoes not apply. The builtdist/*.d.tsnames neitherReferentialClearExemptionnor the symbol, so the public surface is byte-unchanged.!and there is no(narrowing)arm.test:repowas not run locally (CITest Core).Overlap:
node scripts/pm/overlap-check.mjs --branch=claude/issue-34899-set-null-readonly-lookup,VERDICT clean exit 0against origin/main d576509 and #34817, #34811, #34752, #34709. The first run was red on #34709, an import-line conflict inengine-update.ts. It was cleared by importing the symbol on its own line.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH