You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Delete: the set_null walk's clear of a readonly lookup is stripped by the read-only rule, so rows keep the deleted record's id #34899
Found by the hotcrm lane's probe for hotcrm#2618 (report: hotcrm#2618 comment 6952320824) on @objectstack 18.5.0, local SQLite. Read in code on objectstack mainfc5913e.
What happens
A lookup crm_time_entry.crm_billing_milestone declared readonly: true (default deleteBehavior, so set_null). An admin deletes the referenced crm_billing_milestone row: the delete answers 200, and the time entries still hold the deleted row's id. The server logs Field 'crm_billing_milestone' on 'crm_time_entry' is read-only: the caller-supplied value was DROPPED and the update is being COMMITTED WITHOUT IT. Discriminator: the same delete with the lookup not readonly clears it to null.
Why, in code
packages/objectql/src/engine-cascade-planning.ts ~1145–1183: the walk writes the clear with this.update(childName, { id: depId, [fieldName]: null }, { context: referentialCtx }), where referentialCtx is the caller's context plus __referentialFieldClear: true. It is not isSystem.
packages/objectql/src/validation/rule-validator.ts: the read-only strip runs on !context.isSystem (doc ~2054, message readonlyStripWarning ~2790). Nothing in the strip reads __referentialFieldClear (grep: the marker is read only in engine-middleware-and-context.ts and engine-master-detail-related.ts).
So the engine's own referential cleanup is treated as a forged caller write and dropped.
Consequence
A dangling id survives every delete of a referenced row whenever the lookup is readonly, which is the normal shape for a stamp a system writes (here: "billed on" a plan step). The row then looks linked forever: in hotcrm's design, entries billed on a deleted step look billed and are never billed again. Not cross-package specific.
Asked
The referential clear written by the delete walk passes the read-only strip (it is the engine's write, not the caller's). Pin it with a test: readonly lookup, delete the target, the reference reads null.
Done when
Deleting a record clears every set_null reference to it, readonly or not, and no read-only DROPPED line is logged for that clear.
First touch (R1198, 15:5xZ): p1 · domain:server → pm:queue.
Theme: HotCRM usable, with a named effect. A readonly lookup keeps a deleted record's id through the set_null walk, so HotCRM rows look linked forever. This is data integrity on a normal schema shape. So p1.
Claim: PM loop round 1 · 2026-11-17T16:53Z
Session: session_01WGufzgNCAXyGfBQFZBwixH
Account: os-support-ai
Branch: claude/issue-34899-set-null-readonly-lookup
Worktree: objectstack-issue-34899
Domain: domain:server
Seat: repo:objectstack#3
File surface: packages/objectql/src/validation/rule-validator.ts (the update-side read-only strip), packages/objectql/src/engine-cascade-planning.ts (the set_null walk's clear), the engine update assembly in packages/objectql/src/engine*.ts only if the marker has to be handed to the strip there, new card-named tests, root .changeset/ (stop on breach; explain in the report)
Container & model: M, mode:subagent (area o3-G), model: TIER_DEFAULT (dispatch-gates --tier on objectql cascade-planning + rule-validator paths: no path-derived mandate), effort: high
Clause-②: no
Metadata-protocol: none
Responsibility: objectstack's own engine (packages/objectql, this repo) | the delete walk writes its set_null clear with the caller's context plus the operation-private __referentialFieldClear marker, not isSystem, and the update-side read-only strip keys on !context.isSystem alone and never reads the marker | reached by every delete of a row that a readonly: true lookup points at under the default set_null; found by hotcrm#2618 (crm_time_entry.crm_billing_milestone)
Thread-read: 6953208762
Premise: holds (area code read at origin/main 189358f: engine-cascade-planning.ts:1145-1183 writes the clear with { ...callerContext, __referentialFieldClear: true, __referentialFieldClearCause }, no isSystem; rule-validator.ts strip runs on !context.isSystem (doc :2054, warning :2216) and reads no __referentialFieldClear, which only engine-middleware-and-context.ts:193 and engine-master-detail-related.ts:475-494 read; packages/core/src/security/operation-private-keys.ts owns the __ key stripping rule. The dev's red test decides.)
Serial constraints cleared: PR #34752 (roll-up summary read-only on update) is open on objectql's read-only rule: overlap-check against it before every push; no other in-flight claim of this seat on packages/objectql validation
Pre-claim lane: domain:server — packages/objectql/**; routed to area o3-G by seat 3 (16:52Z)
Pre-claim deps: no Blocked-by:; reported from hotcrm#2618 (comment 6952320824)
Prior rulings read: delete,set_null,walk,clear,readonly,lookup,stripped,read-only,rule,rows,deleted,record → 273 hits; ADR-0148 D1 (recycle-bin restore under original ids: what a restore does with a set_null clear is read, not changed), ADR-0146 D11, ADR-0029 D9.7, ADR-0045 §6, ADR-0055 §1/§3, ADR-0056 D9 keyword-only; thread: triage 6953208762 only.
Lease o3-G (seat post #34584). Route: the strip lets through exactly the engine's referential clear: the field the walk is clearing, to null (or the multi-value lookup's remaining ids), on a write the engine marked with the operation-private __referentialFieldClear that a caller cannot forge through a transport. Every other read-only field in that write is still stripped, and no isSystem is granted to the walk.
{
"issue": 34899,
"status": "done",
"branch": "claude/issue-34899-set-null-readonly-lookup",
"pr": "https://github.com/objectstack-ai/objectstack/pull/34952",
"session": "session_01WGufzgNCAXyGfBQFZBwixH",
"premise_still_valid": true,
"summary": "The delete walk (engine-cascade-planning.ts:1153-1170) now passes the holder row and lookup it clears on a module-private symbol option, REFERENTIAL_CLEAR_OPTION (engine-top-level.ts:5245). This is the ADR-0142 D4 WRITE_PRECONDITION_OPTION shape; the symbol is not re-exported and no built .d.ts names it. update() (engine-update.ts:282-300) turns it into a one-key ReferentialClearExemption {field, value}, only on the by-id write of the row and object the walk named. It hands the exemption to the hide-from-hooks pass, both by-id readonlyWhen strips, their stored view and the static strip. rule-validator isReferentialClear (:1015) keeps that key only while it still holds the walk's value. isSystem is not granted. The context marker is NOT the exemption: REST and MCP cannot carry it (assemble-execution-context.ts:295-430, closed entryFields) and hook ctx.api cannot carry it outside a cleanup dispatch (engine-object-repository.ts:83-88 overrides context), but a hook's ctx.api write inherits it during a cleanup dispatch (engine-middleware-and-context.ts:183-187). So the exemption keys on what only the walk holds. ADR-0148: restore was not changed, but this fix changes what restore sees. The readonly clear now lands, and restore's re-link (recycle-bin/restore.ts:701, caller-context update) is then stripped with a DROPPED line: the field stays null while restore() still counts it in `relinked`. Measured with a temporary readonly copy of restore.test.ts: relinked 2, primary_account null. See open_questions.",
"tests": "Head fbe36bf78. Red first on main code (commit 4b1c7dae0): new file 8 failed / 5 passed, e.g. \"the deleted record's id is gone: expected 'r_1' to be null\" and \"expected [ 'r_1', 'r_2' ] to deeply equal [ 'r_2' ]\". The walk logged \"Field 'billed_on' on 'ro_entry' is read-only: the caller-supplied value was DROPPED and the update is being COMMITTED WITHOUT IT\" (captured by a throwaway probe outside the lock, then deleted). Green: src/engine-set-null-readonly-lookup-clear.test.ts 13/13, VERDICT command-exit 0. pnpm --filter @objectstack/objectql test: Test Files 607 passed (607), Tests 13669 passed (13669), VERDICT command-exit 0. pnpm --filter @objectstack/objectql typecheck: tsc clean, check:test-typecheck OK (39 files / 233 errors held, unchanged), VERDICT 0. Ablations via scripts/ablation-replace.mjs; the subject resolves to src through relative imports, so no dist rebuild. (1) rule-validator `return exemption !== undefined` became `return false && ...`: anchor 1 to 0, blob cb5c7a24af8e to 7c529516591a, 8 failed / 5 passed, restored (blob == HEAD, git diff HEAD empty). (2) The walk stops passing the symbol: blob d941938d7c4b to e7d59f666fb7, 6 failed / 7 passed (engine cases red, unit cases green as expected), restored to HEAD. Restore impact probe: a temporary copy of recycle-bin/restore.test.ts with readonly primary_account showed relinked 2, primary_account null and a DROPPED line; the copy was deleted.",
"gates": "Local: dispatch-gates --commands (no paths; merge base d576509c8; 7 paths) derived 71 commands. All ran on fbe36bf78 with each exit captured before any pipe: 69 exit 0. Two exit 3 PREREQUISITE NOT MET, read as NOT MEASURED: check-plugin-teardown-shape --self-test (checker health only; pinned fixture commit unreachable on the shallow checkout) and check:dual-build-cjs-loads (self-test 93 cases pass; the scan needs every package dist, only the objectql closure was built). dispatch-gates --ran with exit codes: '71 derived famil(ies) accounted for — 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. No exported symbol was renamed or removed (check-platform-checklist not applicable); the public .d.ts surface is unchanged. Overlap check: VERDICT clean exit 0 at fbe36bf78 against origin/main d576509c80 and #34817, #34811, #34752, #34709. The first run was exit 1 on #34709 (an import-line conflict in engine-update.ts), cleared by importing the symbol on its own line. CI check-runs on PR #34952: in_progress / not yet read; CI convergence is the seat's.",
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "0",
"api_writes": "3 — fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft; POST /repos/objectstack-ai/objectstack/issues/34952/assignees os-support-ai); post-stamped comment POST /repos/objectstack-ai/objectstack/issues/34899/comments. Plus git push (not REST).",
"open_questions": [
{
"question": "ADR-0148 restore of a readonly lookup: now that the set_null clear lands, restore's re-link (recycle-bin/restore.ts:701, engine.update under the caller's context) is stripped by the static readonly rule. The field stays null after restore, and restore() still counts it in `relinked`. The same happens today after a system-context delete followed by a user restore. The ruling said read, do not change. How should it be carried?",
"options": [
"A: Same PR, on the seat's word: restore's re-link carries its own module-private exemption (same shape: field + relinkedValue), and `relinked` counts only re-links that landed. About 30 lines plus 2 pins.",
"B: File a separate card (class a, reach: restore door), with Blocked-by or a Seam on this PR. This PR lands as is: delete is fixed, restore of a readonly lookup re-links nothing.",
"C: Hold this PR until the restore half is ruled."
],
"recommendation": "A or B. A if the seat can widen the claim's file surface to recycle-bin/restore.ts: the restore half is the same defect class with the same mechanical shape, and without it this PR turns a silent dangling id into a silent unrestored link. Otherwise B. Not C: the delete defect is the bigger data-integrity hit."
},
{
"question": "PR body tail: the dispatch mandates a final HTML comment `signed: ...`. os-dev.md bans HTML comments in GitHub text except the harness's attribution line. I followed the dispatch (relay read-back: 10569 bytes sent, 10569 stored, identical). Which rule stands?",
"options": [
"A: Keep the dispatch's signed comment (seat mechanic)",
"B: Drop it per os-dev.md"
],
"recommendation": "A for this seat, and amend os-dev.md's exception list so the two stop disagreeing."
},
{
"question": "The dispatch named a new card-named test file. AGENTS.md (ruling record 6583487846) says a new pin for a component with a shared harness file goes into that file. No shared harness file exists for this set_null clear: the sibling engine-referential-clear-write-context.test.ts carries its own stub driver. I took the new file. Confirm.",
"options": [
"A: Keep the new file",
"B: Move into engine-referential-clear-write-context.test.ts as a top-level describe"
],
"recommendation": "A: the stubs are per-file copies, not a shared harness."
}
],
"security_findings": "withheld",
"out_of_scope_findings": [
"class: a · reach: public restore door (POST recycle-bin restore after a delete that cleared a readonly set_null lookup; measured in-engine: restore() answers relinked 2 while the readonly lookup stays null, with a DROPPED log line) · evidence: recycle-bin/restore.ts:701 re-links through engine.update under the caller's context, which the static readonly strip (rule-validator stripReadonlyFields, !isSystem) drops; reachable before this PR via a system-context delete plus a user restore · dedupe words: restore relink readonly lookup stripped, relinked count, clearedReferences readonly, ADR-0148 re-link DROPPED"
]
}
Seat 3 widens the claim on this card to packages/objectql/src/**/restore.ts (ADR-0148 restore re-link), route A from o3-G's report on PR #34952. Why: once the set_null clear lands, restore's caller-context re-link of a readonly lookup is dropped by the static strip and logged DROPPED while relinked still counts it, leaving a silently unrestored link. Scope: a private re-link exemption of the same shape as the delete-side clear, relinked counting only landed re-links, plus two pins (re-link lands under caller context; a refused re-link is not counted). About 30 lines. Same PR, same L1-d delta; if the exemption changes what a caller can write, the PR declares it and the seat L2 follows.
{
"issue": 34899,
"status": "done",
"branch": "claude/issue-34899-set-null-readonly-lookup",
"pr": "https://github.com/objectstack-ai/objectstack/pull/34952",
"session": "session_01WGufzgNCAXyGfBQFZBwixH",
"premise_still_valid": true,
"summary": "Fix round S1 (route A, amendment 6956936802), head fbe36bf78 to 326cea5a80. recycle-bin/restore.ts: the re-link and its undo pass {object, id, field} on the same module-private REFERENTIAL_CLEAR_OPTION. update() builds the existing one-key exemption from it, only on the by-id write of the row and object named, at the value the restore writes. No isSystem, and no use of the __ marker. relinked now counts a re-link only when a read-back of the row after the write holds the id. A strip or a hook taking the key out is not counted. The doc text on the option, the exemption and the update() comment now names both writers. The changeset gained a restore paragraph (same patch on @objectstack/objectql; Clause-②: no, Metadata-protocol: none unchanged). The undo leg carries the channel but has no separate pin: no harness drives a restore failing after a re-link outside a transaction. pr_body_text gives the exact text for the seat to apply to the PR body's What changes, Acceptance notes and Tests.",
"pr_body_text": {
"what_changes_add": "- `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-private `REFERENTIAL_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 a `readonly` / `readonlyWhen` lookup is re-linked under the caller's context instead of stripped. It is not `isSystem`, and it is not the `__referentialFieldClear` marker. `relinked` now 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.",
"acceptance_notes_replace_first_bullet": "- **ADR-0148 restore (fixed here, route A, claim amendment 6956936802).** Without the restore half, a readonly lookup's clear now landed, but the restore's caller-context re-link was stripped. The field stayed `null`, a DROPPED line was logged, and `restore()` still counted it in `relinked`. The re-link and its undo now ride the engine's private channel, and `relinked` counts 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.",
"tests_add": "Restore pins, a top-level describe in `recycle-bin/restore.test.ts` (the restore harness): (1) readonly `set_null` lookup, delete, restore: the reference holds `acc1` again, `relinked` is 1, and no drop line is logged across the delete and the restore. (2) A holder `beforeUpdate` that keeps the stamp empty: the row stays `null` and `relinked` is 0. (3) A caller `update` carrying the option's shape through the normal door (a `Symbol('objectql.referentialClear')` key, a `Symbol.for('objectql.referentialClear')` key, and `__referentialFieldClear` on the context) is still stripped and logs one DROPPED line. A JSON transport cannot carry a symbol key at all. Ablations at head a0f8fd1cd6: 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 326cea5a80: objectql 607/607 files, 13672/13672 tests."
},
"tests": "Head 326cea5a80. New restore pins are in recycle-bin/restore.test.ts as a top-level describe, following the shared-harness rule. src/recycle-bin/restore.test.ts plus src/engine-set-null-readonly-lookup-clear.test.ts: 65/65, VERDICT command-exit 0. Ablations via scripts/ablation-replace.mjs at a0f8fd1cd6. (1) Re-link without [REFERENTIAL_CLEAR_OPTION]: blob 1575a1823475 to 62125398a3f0, 1 failed / 51 passed ('the reference holds the restored id again ...': expected +0 to be 1), restored (blob == HEAD, git diff HEAD empty). (2) Count without the read-back: the first attempt was refused by the tool because the replacement text was a substring of the anchor (the replacement count rose by 0), so nothing ran and that reading is void. Rerun with a distinct replacement: blob 1575a1823475 to 7d48b83b8b98, 1 failed / 51 passed ('a re-link that does not land is not counted': expected 1 to be +0), restored. pnpm --filter @objectstack/objectql typecheck: tsc clean, check:test-typecheck OK (39 files / 233 errors, unchanged). pnpm --filter @objectstack/objectql test: Test Files 607 passed (607), Tests 13672 passed (13672), VERDICT command-exit 0. The touched package is objectql only.",
"gates": "On 326cea5a80, dispatch-gates --commands derived the same 71 commands (9 paths). Re-run on the new head with exits captured before any pipe: 69 exit 0. check:lean-entry-closure first answered exit 3 because this fresh worktree had no objectql dist; after `pnpm --filter @objectstack/objectql build` (VERDICT 0) it answered exit 0, and check:published-files and check:dts-closure were re-run on the built dist with exit 0. Two remain NOT MEASURED (exit 3, PREREQUISITE NOT MET), as last round: check-plugin-teardown-shape --self-test and check:dual-build-cjs-loads. --ran: '71 derived famil(ies) accounted for — 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. overlap-check before push: VERDICT clean exit 0 at 326cea5a80 against origin/main c81f498b5f and #34817, #34811, #34752, #34709. CI on 326cea5a80: not yet read; the seat owns convergence and the delta read.",
"dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
"mcp_calls": "0",
"api_writes": "1 this round — post-stamped comment POST /repos/objectstack-ai/objectstack/issues/34899/comments (fix-round report). Plus git push fbe36bf78c..326cea5a80 (not REST). The PR body was not touched.",
"open_questions": [],
"security_findings": "none",
"out_of_scope_findings": []
}
PR #34952 merged to main at 0465f4aa40 and closed this card (Fixes). Deleting a record now clears every set_null reference to it, readonly and readonlyWhen lookups included, single- and multi-value. The clear logs no read-only DROPPED line. The engine's walk passes the row and lookup it is clearing on a module-private channel that only it holds. It does not use isSystem or the __referentialFieldClear context marker, so a caller update that carries the marker is still stripped. ADR-0148 restore re-links such a lookup through the same channel, and relinked now counts only re-links that landed (claim amendment 6956936802).
Reviews: L1-d ACCEPT 6956937328 and delta ACCEPT 6958092846. Rows that already hold a deleted record's id keep it; the changeset says so. pm:dispatched and lease:o3-G removed in this stroke.
Activity
objectstack-fleet commentedon Nov 17, 2026
triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH
First touch (R1198, 15:5xZ): p1 · domain:server →
pm:queue.Theme: HotCRM usable, with a named effect. A readonly lookup keeps a deleted record's id through the set_null walk, so HotCRM rows look linked forever. This is data integrity on a normal schema shape. So p1.
objectstack-fleet commentedon Nov 17, 2026
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
Claim: PM loop round 1 · 2026-11-17T16:53Z
Session:
session_01WGufzgNCAXyGfBQFZBwixHAccount:
os-support-aiBranch:
claude/issue-34899-set-null-readonly-lookupWorktree:
objectstack-issue-34899Domain:
domain:serverSeat:
repo:objectstack#3File surface:
packages/objectql/src/validation/rule-validator.ts(the update-side read-only strip),packages/objectql/src/engine-cascade-planning.ts(the set_null walk's clear), the engine update assembly inpackages/objectql/src/engine*.tsonly if the marker has to be handed to the strip there, new card-named tests, root.changeset/(stop on breach; explain in the report)Container & model:
M,mode:subagent(area o3-G),model: TIER_DEFAULT (dispatch-gates --tier on objectql cascade-planning + rule-validator paths: no path-derived mandate),effort: highClause-②: no
Metadata-protocol: none
Responsibility:
objectstack's own engine (packages/objectql, this repo) | the delete walk writes its set_null clear with the caller's context plus the operation-private __referentialFieldClear marker, not isSystem, and the update-side read-only strip keys on !context.isSystem alone and never reads the marker | reached by every delete of a row that a readonly: true lookup points at under the default set_null; found by hotcrm#2618 (crm_time_entry.crm_billing_milestone)Thread-read: 6953208762
Premise: holds (area code read at origin/main 189358f:
engine-cascade-planning.ts:1145-1183writes the clear with{ ...callerContext, __referentialFieldClear: true, __referentialFieldClearCause }, noisSystem;rule-validator.tsstrip runs on!context.isSystem(doc :2054, warning :2216) and reads no__referentialFieldClear, which onlyengine-middleware-and-context.ts:193andengine-master-detail-related.ts:475-494read;packages/core/src/security/operation-private-keys.tsowns the__key stripping rule. The dev's red test decides.)Serial constraints cleared:
PR #34752 (roll-up summary read-only on update) is open on objectql's read-only rule: overlap-check against it before every push; no other in-flight claim of this seat on packages/objectql validationPre-claim lane:
domain:server—packages/objectql/**; routed to area o3-G by seat 3 (16:52Z)Pre-claim deps: no
Blocked-by:; reported from hotcrm#2618 (comment 6952320824)Prior rulings read: delete,set_null,walk,clear,readonly,lookup,stripped,read-only,rule,rows,deleted,record → 273 hits; ADR-0148 D1 (recycle-bin restore under original ids: what a restore does with a set_null clear is read, not changed), ADR-0146 D11, ADR-0029 D9.7, ADR-0045 §6, ADR-0055 §1/§3, ADR-0056 D9 keyword-only; thread: triage 6953208762 only.
Lease
o3-G(seat post #34584). Route: the strip lets through exactly the engine's referential clear: the field the walk is clearing, to null (or the multi-value lookup's remaining ids), on a write the engine marked with the operation-private__referentialFieldClearthat a caller cannot forge through a transport. Every other read-only field in that write is still stripped, and noisSystemis granted to the walk.objectstack-fleet commentedon Nov 17, 2026
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
os-dev-report
{ "issue": 34899, "status": "done", "branch": "claude/issue-34899-set-null-readonly-lookup", "pr": "https://github.com/objectstack-ai/objectstack/pull/34952", "session": "session_01WGufzgNCAXyGfBQFZBwixH", "premise_still_valid": true, "summary": "The delete walk (engine-cascade-planning.ts:1153-1170) now passes the holder row and lookup it clears on a module-private symbol option, REFERENTIAL_CLEAR_OPTION (engine-top-level.ts:5245). This is the ADR-0142 D4 WRITE_PRECONDITION_OPTION shape; the symbol is not re-exported and no built .d.ts names it. update() (engine-update.ts:282-300) turns it into a one-key ReferentialClearExemption {field, value}, only on the by-id write of the row and object the walk named. It hands the exemption to the hide-from-hooks pass, both by-id readonlyWhen strips, their stored view and the static strip. rule-validator isReferentialClear (:1015) keeps that key only while it still holds the walk's value. isSystem is not granted. The context marker is NOT the exemption: REST and MCP cannot carry it (assemble-execution-context.ts:295-430, closed entryFields) and hook ctx.api cannot carry it outside a cleanup dispatch (engine-object-repository.ts:83-88 overrides context), but a hook's ctx.api write inherits it during a cleanup dispatch (engine-middleware-and-context.ts:183-187). So the exemption keys on what only the walk holds. ADR-0148: restore was not changed, but this fix changes what restore sees. The readonly clear now lands, and restore's re-link (recycle-bin/restore.ts:701, caller-context update) is then stripped with a DROPPED line: the field stays null while restore() still counts it in `relinked`. Measured with a temporary readonly copy of restore.test.ts: relinked 2, primary_account null. See open_questions.", "tests": "Head fbe36bf78. Red first on main code (commit 4b1c7dae0): new file 8 failed / 5 passed, e.g. \"the deleted record's id is gone: expected 'r_1' to be null\" and \"expected [ 'r_1', 'r_2' ] to deeply equal [ 'r_2' ]\". The walk logged \"Field 'billed_on' on 'ro_entry' is read-only: the caller-supplied value was DROPPED and the update is being COMMITTED WITHOUT IT\" (captured by a throwaway probe outside the lock, then deleted). Green: src/engine-set-null-readonly-lookup-clear.test.ts 13/13, VERDICT command-exit 0. pnpm --filter @objectstack/objectql test: Test Files 607 passed (607), Tests 13669 passed (13669), VERDICT command-exit 0. pnpm --filter @objectstack/objectql typecheck: tsc clean, check:test-typecheck OK (39 files / 233 errors held, unchanged), VERDICT 0. Ablations via scripts/ablation-replace.mjs; the subject resolves to src through relative imports, so no dist rebuild. (1) rule-validator `return exemption !== undefined` became `return false && ...`: anchor 1 to 0, blob cb5c7a24af8e to 7c529516591a, 8 failed / 5 passed, restored (blob == HEAD, git diff HEAD empty). (2) The walk stops passing the symbol: blob d941938d7c4b to e7d59f666fb7, 6 failed / 7 passed (engine cases red, unit cases green as expected), restored to HEAD. Restore impact probe: a temporary copy of recycle-bin/restore.test.ts with readonly primary_account showed relinked 2, primary_account null and a DROPPED line; the copy was deleted.", "gates": "Local: dispatch-gates --commands (no paths; merge base d576509c8; 7 paths) derived 71 commands. All ran on fbe36bf78 with each exit captured before any pipe: 69 exit 0. Two exit 3 PREREQUISITE NOT MET, read as NOT MEASURED: check-plugin-teardown-shape --self-test (checker health only; pinned fixture commit unreachable on the shallow checkout) and check:dual-build-cjs-loads (self-test 93 cases pass; the scan needs every package dist, only the objectql closure was built). dispatch-gates --ran with exit codes: '71 derived famil(ies) accounted for — 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. No exported symbol was renamed or removed (check-platform-checklist not applicable); the public .d.ts surface is unchanged. Overlap check: VERDICT clean exit 0 at fbe36bf78 against origin/main d576509c80 and #34817, #34811, #34752, #34709. The first run was exit 1 on #34709 (an import-line conflict in engine-update.ts), cleared by importing the symbol on its own line. CI check-runs on PR #34952: in_progress / not yet read; CI convergence is the seat's.", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "3 — fleet-write relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft; POST /repos/objectstack-ai/objectstack/issues/34952/assignees os-support-ai); post-stamped comment POST /repos/objectstack-ai/objectstack/issues/34899/comments. Plus git push (not REST).", "open_questions": [ { "question": "ADR-0148 restore of a readonly lookup: now that the set_null clear lands, restore's re-link (recycle-bin/restore.ts:701, engine.update under the caller's context) is stripped by the static readonly rule. The field stays null after restore, and restore() still counts it in `relinked`. The same happens today after a system-context delete followed by a user restore. The ruling said read, do not change. How should it be carried?", "options": [ "A: Same PR, on the seat's word: restore's re-link carries its own module-private exemption (same shape: field + relinkedValue), and `relinked` counts only re-links that landed. About 30 lines plus 2 pins.", "B: File a separate card (class a, reach: restore door), with Blocked-by or a Seam on this PR. This PR lands as is: delete is fixed, restore of a readonly lookup re-links nothing.", "C: Hold this PR until the restore half is ruled." ], "recommendation": "A or B. A if the seat can widen the claim's file surface to recycle-bin/restore.ts: the restore half is the same defect class with the same mechanical shape, and without it this PR turns a silent dangling id into a silent unrestored link. Otherwise B. Not C: the delete defect is the bigger data-integrity hit." }, { "question": "PR body tail: the dispatch mandates a final HTML comment `signed: ...`. os-dev.md bans HTML comments in GitHub text except the harness's attribution line. I followed the dispatch (relay read-back: 10569 bytes sent, 10569 stored, identical). Which rule stands?", "options": [ "A: Keep the dispatch's signed comment (seat mechanic)", "B: Drop it per os-dev.md" ], "recommendation": "A for this seat, and amend os-dev.md's exception list so the two stop disagreeing." }, { "question": "The dispatch named a new card-named test file. AGENTS.md (ruling record 6583487846) says a new pin for a component with a shared harness file goes into that file. No shared harness file exists for this set_null clear: the sibling engine-referential-clear-write-context.test.ts carries its own stub driver. I took the new file. Confirm.", "options": [ "A: Keep the new file", "B: Move into engine-referential-clear-write-context.test.ts as a top-level describe" ], "recommendation": "A: the stubs are per-file copies, not a shared harness." } ], "security_findings": "withheld", "out_of_scope_findings": [ "class: a · reach: public restore door (POST recycle-bin restore after a delete that cleared a readonly set_null lookup; measured in-engine: restore() answers relinked 2 while the readonly lookup stays null, with a DROPPED log line) · evidence: recycle-bin/restore.ts:701 re-links through engine.update under the caller's context, which the static readonly strip (rule-validator stripReadonlyFields, !isSystem) drops; reachable before this PR via a system-context delete plus a user restore · dedupe words: restore relink readonly lookup stripped, relinked count, clearedReferences readonly, ADR-0148 re-link DROPPED" ] }objectstack-fleet commentedon Nov 17, 2026
repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG
Claim amendment · 2026-11-17T18:19Z
Seat 3 widens the claim on this card to
packages/objectql/src/**/restore.ts(ADR-0148 restore re-link), route A from o3-G's report on PR #34952. Why: once the set_null clear lands, restore's caller-context re-link of a readonly lookup is dropped by the static strip and logged DROPPED whilerelinkedstill counts it, leaving a silently unrestored link. Scope: a private re-link exemption of the same shape as the delete-side clear,relinkedcounting only landed re-links, plus two pins (re-link lands under caller context; a refused re-link is not counted). About 30 lines. Same PR, same L1-d delta; if the exemption changes what a caller can write, the PR declares it and the seat L2 follows.objectstack-fleet commentedon Nov 17, 2026
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
os-dev-report
Fix round (S1, route A) — head 326cea5.
{ "issue": 34899, "status": "done", "branch": "claude/issue-34899-set-null-readonly-lookup", "pr": "https://github.com/objectstack-ai/objectstack/pull/34952", "session": "session_01WGufzgNCAXyGfBQFZBwixH", "premise_still_valid": true, "summary": "Fix round S1 (route A, amendment 6956936802), head fbe36bf78 to 326cea5a80. recycle-bin/restore.ts: the re-link and its undo pass {object, id, field} on the same module-private REFERENTIAL_CLEAR_OPTION. update() builds the existing one-key exemption from it, only on the by-id write of the row and object named, at the value the restore writes. No isSystem, and no use of the __ marker. relinked now counts a re-link only when a read-back of the row after the write holds the id. A strip or a hook taking the key out is not counted. The doc text on the option, the exemption and the update() comment now names both writers. The changeset gained a restore paragraph (same patch on @objectstack/objectql; Clause-②: no, Metadata-protocol: none unchanged). The undo leg carries the channel but has no separate pin: no harness drives a restore failing after a re-link outside a transaction. pr_body_text gives the exact text for the seat to apply to the PR body's What changes, Acceptance notes and Tests.", "pr_body_text": { "what_changes_add": "- `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-private `REFERENTIAL_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 a `readonly` / `readonlyWhen` lookup is re-linked under the caller's context instead of stripped. It is not `isSystem`, and it is not the `__referentialFieldClear` marker. `relinked` now 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.", "acceptance_notes_replace_first_bullet": "- **ADR-0148 restore (fixed here, route A, claim amendment 6956936802).** Without the restore half, a readonly lookup's clear now landed, but the restore's caller-context re-link was stripped. The field stayed `null`, a DROPPED line was logged, and `restore()` still counted it in `relinked`. The re-link and its undo now ride the engine's private channel, and `relinked` counts 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.", "tests_add": "Restore pins, a top-level describe in `recycle-bin/restore.test.ts` (the restore harness): (1) readonly `set_null` lookup, delete, restore: the reference holds `acc1` again, `relinked` is 1, and no drop line is logged across the delete and the restore. (2) A holder `beforeUpdate` that keeps the stamp empty: the row stays `null` and `relinked` is 0. (3) A caller `update` carrying the option's shape through the normal door (a `Symbol('objectql.referentialClear')` key, a `Symbol.for('objectql.referentialClear')` key, and `__referentialFieldClear` on the context) is still stripped and logs one DROPPED line. A JSON transport cannot carry a symbol key at all. Ablations at head a0f8fd1cd6: 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 326cea5a80: objectql 607/607 files, 13672/13672 tests." }, "tests": "Head 326cea5a80. New restore pins are in recycle-bin/restore.test.ts as a top-level describe, following the shared-harness rule. src/recycle-bin/restore.test.ts plus src/engine-set-null-readonly-lookup-clear.test.ts: 65/65, VERDICT command-exit 0. Ablations via scripts/ablation-replace.mjs at a0f8fd1cd6. (1) Re-link without [REFERENTIAL_CLEAR_OPTION]: blob 1575a1823475 to 62125398a3f0, 1 failed / 51 passed ('the reference holds the restored id again ...': expected +0 to be 1), restored (blob == HEAD, git diff HEAD empty). (2) Count without the read-back: the first attempt was refused by the tool because the replacement text was a substring of the anchor (the replacement count rose by 0), so nothing ran and that reading is void. Rerun with a distinct replacement: blob 1575a1823475 to 7d48b83b8b98, 1 failed / 51 passed ('a re-link that does not land is not counted': expected 1 to be +0), restored. pnpm --filter @objectstack/objectql typecheck: tsc clean, check:test-typecheck OK (39 files / 233 errors, unchanged). pnpm --filter @objectstack/objectql test: Test Files 607 passed (607), Tests 13672 passed (13672), VERDICT command-exit 0. The touched package is objectql only.", "gates": "On 326cea5a80, dispatch-gates --commands derived the same 71 commands (9 paths). Re-run on the new head with exits captured before any pipe: 69 exit 0. check:lean-entry-closure first answered exit 3 because this fresh worktree had no objectql dist; after `pnpm --filter @objectstack/objectql build` (VERDICT 0) it answered exit 0, and check:published-files and check:dts-closure were re-run on the built dist with exit 0. Two remain NOT MEASURED (exit 3, PREREQUISITE NOT MET), as last round: check-plugin-teardown-shape --self-test and check:dual-build-cjs-loads. --ran: '71 derived famil(ies) accounted for — 69 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)'. overlap-check before push: VERDICT clean exit 0 at 326cea5a80 against origin/main c81f498b5f and #34817, #34811, #34752, #34709. CI on 326cea5a80: not yet read; the seat owns convergence and the delta read.", "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm", "mcp_calls": "0", "api_writes": "1 this round — post-stamped comment POST /repos/objectstack-ai/objectstack/issues/34899/comments (fix-round report). Plus git push fbe36bf78c..326cea5a80 (not REST). The PR body was not touched.", "open_questions": [], "security_findings": "none", "out_of_scope_findings": [] }objectstack-fleet commentedon Nov 17, 2026
repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH
Delivered · 2026-11-17T20:31Z
PR #34952 merged to
mainat0465f4aa40and closed this card (Fixes). Deleting a record now clears everyset_nullreference to it,readonlyandreadonlyWhenlookups included, single- and multi-value. The clear logs no read-only DROPPED line. The engine's walk passes the row and lookup it is clearing on a module-private channel that only it holds. It does not useisSystemor the__referentialFieldClearcontext marker, so a caller update that carries the marker is still stripped. ADR-0148 restore re-links such a lookup through the same channel, andrelinkednow counts only re-links that landed (claim amendment 6956936802).Reviews: L1-d ACCEPT 6956937328 and delta ACCEPT 6958092846. Rows that already hold a deleted record's id keep it; the changeset says so.
pm:dispatchedandlease:o3-Gremoved in this stroke.