Skip to content

fix(objectql): an update's multi-value wrap and first value check run on the payload left after the read-only strips - #33319

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/update-normalizes-after-strip
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/update-normalizes-after-strip

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:更新(update)路径的多值整理与首轮值校验,改为在两道只读剥离之后、对剩下的载荷进行;按 id 与批量两条路径一致,与插入路径的顺序相同。
  • 为什么改:多值整理与首轮值校验只作用于只读剥离之后剩下的载荷,与插入路径对齐。
  • 风险与回滚:任一道只读剥离移除的字段上的畸形值,现在被剥离并经 onFieldsDropped 报告(strict 模式下拒绝),不再整单 VALIDATION_FAILED;可写字段的校验不变;update 模式的校验预览对这类字段可能比更新本身更严(安全方向)。回滚即 revert 本 PR。
  • 先看:packages/objectql/src/engine-update.ts(judgeStrippedPayload 与 inStoredMultiValueShape 两个闭包,及两条路径的调用点);packages/objectql/src/engine-update-multi-value-after-strip.test.ts。
  • 两分钟验证:pnpm --filter @objectstack/objectql exec vitest run --maxWorkers=2 src/engine-update-multi-value-after-strip.test.ts,预期 13 个用例全部通过。
  • 需要你做的:无,席位落地。

What changes

ObjectQL.update (packages/objectql/src/engine-update.ts) now follows the insert path's order on both the by-id branch and the bulk (predicate) branch. First come the two read-only strips (readonlyWhen, then static readonly). Then come the multi-value wrap (normalizeMultiValueFields, scope 'skip') and the first validateRecord pass. Both run in one closure, judgeStrippedPayload, which each branch calls right after its strips. The rule this diff holds: the multi-value wrap and the first value check run on the payload left after the read-only strips.

readonlyWhen predicates still read multi-valued fields in their stored list form. Each strip's stored view goes through inStoredMultiValueShape, which wraps a copy and never the payload, so record stays "the payload the write stores" (#19887). The second pass (validateRecordInScope(…, 'only') for readonly values) is unchanged.

One changeset: @objectstack/objectql patch.

Tests

New file: packages/objectql/src/engine-update-multi-value-after-strip.test.ts. It runs the real engine against an in-memory driver and has 13 cases:

  • by id and bulk: a locked multi-valued field (multiselect, and select with multiple: true) keeps its stored value, whatever form the caller writes it in. onFieldsDropped reports it under readonly_when.
  • by id and bulk: a value the lock removes is not judged, and the update stores what is left.
  • by id and bulk, under strictReadonlyWrites: such a value is refused as a read-only write (ERR_READONLY_FIELD_REJECTED), and nothing is written.
  • CONTROLS for the paths this change leaves alone:
    • an unlocked multi-valued field still stores a single value in its list form (by id and bulk);
    • a hook-written value on a locked field is still the server's and is stored in list form;
    • a value that is not a list at all is still refused on an unlocked field with VALIDATION_FAILED / invalid_type;
    • a lock whose predicate reads a multi-valued field still reads it in list form.

Acceptance notes

  • What callers see, in the changeset: a malformed value on a field that either read-only strip removes used to fail the update with VALIDATION_FAILED. It is now dropped and reported (or refused under strictReadonlyWrites). Writable fields are judged exactly as before.
  • Also in the changeset: for such a field, an update-mode validation preview can now refuse a row the update accepts. That is the safe direction. No spec edit is in this PR.
  • No open PR touches engine-update.ts or validation/rule-validator.ts. I checked all 30 open PRs at the time of writing.

Verification

Rule tests before and after, and ablation
  • Origin/main, before the fix: Tests 2 failed | 6 passed (8) on the first version of the file. Every control was green.
  • With the fix: Tests 10 passed (10).
  • Ablation 1: I restored engine-update.ts to its base blob (on-disk hash compared). Result: Tests 3 failed | 7 passed (10), red on the two rule cases and the not-judged case. Restored to the HEAD blob, with git diff HEAD empty.
  • Ablation 2 (scripts/ablation-replace.mjs): I dropped the wrap inside inStoredMultiValueShape. Result: Tests 1 failed | 9 passed (10), red on the predicate-view control. Restored to the HEAD blob, with git diff HEAD empty.
Package suite and gates (head 126f932)
  • pnpm --filter @objectstack/objectql test on 126f932: Test Files 596 passed (596), Tests 12952 passed (12952), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/objectql typecheck on 126f932: tsc --noEmit clean, check:test-typecheck: OK (ledger unchanged).
  • The new file on 126f932: Tests 10 passed (10).
  • dispatch-gates --commands derived 64 families for this diff, and all 64 ran on 126f932. 63 exited 0, including check:engine-double-contract, check:objectql-double-limit, check:where-matcher, check:nul-bytes, check:type-check-debt (re-measure OK), check:adr-0087-registration, check:changeset-no-major and check:empty-changeset. check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET: it needs a whole-repo build), so it is NOT MEASURED locally and is left to CI. --ran reconciliation: 64 derived, 63 run, 1 NOT-MEASURED, 0 UNRUN.
  • Changes from origin/main were merged in before opening this PR, at e93485a.
Review patch round (head a1f3c59)
  • This round touches text and tests only. Engine logic is unchanged; the edits are one comment in engine-update.ts and the ReadonlyValueScope jsdoc in validation/record-validator.ts.
  • The new file: Tests 13 passed (13).
  • pnpm --filter @objectstack/objectql test: Test Files 596 passed (596), Tests 12955 passed (12955). typecheck: check:test-typecheck: OK, lock VERDICT command-exit 0.
  • dispatch-gates --commands derived 68 families. 67 exited 0. check:lean-entry-closure first exited 3 (prerequisite) and exited 0 when re-run after dist/ was present. check:dual-build-cjs-loads exited 3 (PREREQUISITE NOT MET: it needs a whole-repo build), so it is NOT MEASURED locally and is left to CI. --ran reconciliation: 68 derived, 67 run, 1 NOT-MEASURED, 0 UNRUN.

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 14, 2026
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 1 changed file(s) yielded no anchor (packages/objectql/src/validation/record-validator.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/objectql/src/validation/record-validator.ts) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 87330e8959070c0e0a18d1a48981c981642926b7 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f

Contract-review-handoff: review#2 — CONTRACT_REVIEW_TIER unavailable (the maintainer routes contract-tier reviews to the review seat, 2026-11-14T16:48Z) · head 93e7d49

A no-card security#1 order; the reviewer reads the advisory through the relay as the order names it. Seat notes:

  • Head 93e7d49f64 reverts one test-only commit, and its tree is identical to 126f932d67, the head the dev's readings cover (objectql 596/596 files, 12952 tests; 63 of 64 gates, 1 NOT-MEASURED for lack of the full dist).
  • One declared visible change, in the body: a malformed value on a locked field is dropped and reported instead of failing the update.

Generated by Claude Code

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 14, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 93e7d49 · 2026-11-14T16:50Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 93e7d49f64302aaa020e3f04812cd7e62f9fc34f
Local-runs: none
Scope: none (no hits; owed by the security#1 hand-off) + packages/objectql/src/engine-update.ts

① Derived judgments

  • Order of the update door, by-id and predicate branches: the two read-only strips now run before the multi-value wrap and the first value check (judgeStrippedPayload). Right: it is the insert door's order, and it is what Field.readonlyWhen already publishes on main (the server ignores writes to a field whose readonlyWhen is TRUE).
  • readonlyWhen predicate view: inStoredMultiValueShape wraps a copy of the stored view at all four strip call sites, so a predicate still reads a multi-valued field in list form. Right; same scope and input as before.
  • Second pass (normalizeMultiValueFields / validateRecordInScope with 'only'): untouched. Right: every value that survives the strips is still judged before the driver call.
  • Declared visible change (a malformed value on a field whose readonlyWhen holds is dropped and reported, or refused under strictReadonlyWrites): right as behaviour. It is not a narrowing: no declared capability is taken away, no value is newly storable, and the spec says such a write is ignored. No migration note or BREAKING banner is owed.
  • Undeclared second instance of the same change: a runtime-owned field (RUNTIME_OWNED_FIELD_TYPES) with no readonly: true is taken by the static strip, so a malformed value there is now dropped under readonly instead of refused. Same direction; nit N1.
  • Hand-off claim that the head's tree equals 126f932d67: confirmed (same tree).
  • Gate verdicts on this head when read: 23 success, 20 skipped, 0 failed, 11 still in progress (Test Core 1/8 to 8/8, Build Core, two Type Check jobs). This record covers the design; landing still needs those green.

② Semver level

  • @objectstack/objectql patch: right. A fix in a released package, no public export or option added. Check Changeset is green.
  • Clause-②: no: right. A call that was refused now completes without the dropped field, but no accepted value and no public surface widens, and the result is the behaviour the spec declares.
  • Metadata-protocol: none: right.

③ Boundary flags

  • No card and no dev report, so no dev flags or open_questions to answer.
  • The hand-off's one declared visible change is answered in ① and ②.
  • PR author is objectstack-fleet[bot]: no off-relay author note is owed.

④ Design judgment

packages/objectql/src/engine-update.ts: the reorder holds against the code it cites. Read and not broken: parent reads that now precede the value check bind only a scalar; a dropped value reaches only its own lock's verdict (settleReadonlyWhenDrops); judgeStrippedPayload sits outside the isSystem and payloadHasReadonlyWhen gates, so every caller is still judged on both branches; no early return sits between the old and new positions; no other update path calls the value check.

Findings:

  • should-fix S1 — UpdateFacet.update, both branches: the rule as titled ("judges and stores the payload left after the fields the caller may not write are removed") is held here for the multi-value wrap and the first value check only, not yet for every engine pass that precedes the strips in those branches. Required: hold the same order for the remaining pass in this PR, or scope the stated rule (title, changeset first line, test header) to what this diff moves and route the remainder through the security#1 seat. Detail held by review#2.
  • should-fix S2 — read against ValidateDataResponseSchema and the import row report in packages/spec/src/api: their named limit says an update-mode preview can report fewer drops than the update. After this change the preview can also refuse a row the update accepts (the safe direction). Required: the changeset names this preview divergence, and a follow-up card widens the two limit sentences. No spec edit in this PR.
  • nit N1 — changeset and PR body say "One visible change"; the runtime-owned case in ① is a second instance. Prose fix: "a field either strip removes".
  • nit N2 — ReadonlyValueScope jsdoc in packages/objectql/src/validation/record-validator.ts still describes the old order. Outside the diff: follow-up.
  • nit N3 — a value-check refusal on a writable field now arrives after the strips have already reported their drops; later refusals already behaved this way. Accepted deviation.
  • nit N4 — the changeset's strictReadonlyWrites arm and the predicate-branch arm have no pin in the new test file. Follow-up.

S1 and S2 earn a delta review of their fix by this seat.

Implemented-by: claude/update-normalizes-after-strip
Reviewed-by: session_01FEkQ5nhu4dRbKVQKDB4CDB

VERDICT: PASS

@objectstack-fleet objectstack-fleet Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 14, 2026
…d first value check; pin the strict and bulk arms

Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet objectstack-fleet Bot changed the title fix(objectql): an update judges and stores the payload left after the fields the caller may not write are removed fix(objectql): an update's multi-value wrap and first value check run on the payload left after the read-only strips Nov 14, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head a1f3c59 · 2026-11-14T17:54Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a1f3c59126af74d9254c04893b364819701a475a
Local-runs: none
Scope: none (no hits; owed by the security#1 hand-off) + packages/objectql/src/engine-update.ts, packages/objectql/src/validation/record-validator.ts

① Derived judgments

Delta review of record 6881097452 (head 93e7d49f64302aaa020e3f04812cd7e62f9fc34f). One commit sits on top of that head; it touches the changeset, the test file, one comment in engine-update.ts and the ReadonlyValueScope jsdoc in record-validator.ts.

  • Engine logic: unchanged since round 1. The only engine-update.ts hunk in the delta is the comment above judgeStrippedPayload; every round-1 judgment on the reorder, inStoredMultiValueShape and the untouched second pass stands.
  • record-validator.ts: a jsdoc-only hunk; no export, type or behaviour change. Right.
  • Round-1 findings, graded on this head:
    • S1: closed, on the scoping arm. Title, changeset first line and body, test header, describe title, the judgeStrippedPayload comment and the PR body now state the rule for the multi-value wrap and the first value check only; no sentence claims the whole payload is judged after the strips. The routing half is not visible from the PR; see ③.
    • S2: closed for the changeset (its last paragraph names the update-mode preview divergence and its direction). The follow-up card is not named on the PR; nit N5.
    • N1: closed ("either read-only strip"; the runtime-owned field is listed).
    • N2: closed; the 'skip' bullet now describes the order this PR ships (reviewed in ④).
    • N3: accepted deviation, unchanged.
    • N4: closed. Three new cases pin the by-id strictReadonlyWrites arm, the bulk not-judged arm and the bulk strictReadonlyWrites arm.
  • Gate verdicts on this head when read: 36 success, 18 skipped, 0 failed, 1 in progress (a second Check Changeset run; the first is green). Test Core 1/8 to 8/8, Build Core and all Type Check jobs are green.

② Semver level

  • @objectstack/objectql patch: right, unchanged; the delta publishes nothing new.
  • Clause-②: no and Metadata-protocol: none: right, unchanged.
  • The changeset's first line now equals the PR title, and both match what the diff moves.

③ Boundary flags

  • No card and no dev report, so no dev flags or open_questions to answer.
  • S1's remainder was to be routed through the security#1 seat. That routing is the security#1 seat's and is not verifiable from the PR; this record does not attest it.
  • The new text (changeset, test file, comments, jsdoc, commit message) names only the read-only strips, the multi-value wrap and the value check.

④ Design judgment

packages/objectql/src/engine-update.ts: the comment above judgeStrippedPayload agrees with the code below it for the two passes the closure runs; both branches still call it once, directly after their two strips.

packages/objectql/src/validation/record-validator.ts: the 'skip' bullet of ReadonlyValueScope agrees with the two call sites in UpdateFacet.update and with the 'only' bullet.

Findings (nits only; none affects correctness or the contract):

  • nit N5 — the follow-up card that widens the two limit sentences in packages/spec/src/api (S2) is not named on the PR. Name it in the PR body before landing.
  • nit N6 — changeset, last paragraph: "For such a field" reads as every field a read-only strip removes; the preview divergence is on a field whose readonlyWhen holds. Prose fix.
  • nit N7 — engine-update.ts, the by-id second-pass comment still says the first validateRecord judged ahead of the strip, which this PR made false. Follow-up.
  • nit N8 — the test header and the judgeStrippedPayload comment say the strips meet the payload as the caller sent it; say that this holds for the multi-value form this diff moves. Follow-up.

Nits alone end this round. N7 and N8 move the head if fixed here, so they go to a follow-up.

Implemented-by: claude/update-normalizes-after-strip
Reviewed-by: session_01FEkQ5nhu4dRbKVQKDB4CDB

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f

席位核对

ACCEPT at Head-sha: a1f3c59126af74d9254c04893b364819701a475a (2026-11-15T03:56Z).

  • Shape:
    • A no-card order from the security#1 seat. 4 files, +291 / −30.
    • Not governed (check-governed-merges.mjs --pr 33319: 0 of 4 paths).
    • Declarations: Clause-②: no · Metadata-protocol: none. A patch on @objectstack/objectql.
    • The seat widened the file surface by one comment-only jsdoc in validation/record-validator.ts.
  • Rule: an update's multi-value wrap and first value check run on the payload left after the read-only strips, on the by-id and bulk branches alike, as on insert.
  • Premise measured:
    • Before: on main, a locked multi-valued field took a caller's scalar, stored in list form and unreported. The rule cases were red.
    • After: the field keeps its stored value and is reported. Under strictReadonlyWrites it is refused.
    • Ablations: two, each red, each restored.
  • Gates:
    • CI on this head: 37 success, 18 skipped, 0 failed.
    • Locally: the objectql suite (596 files, 12955 tests) and typecheck pass. 68 derived commands: 67 exit 0 and 1 NOT-MEASURED (whole-repo dist, which CI runs).
  • Review: review#2 at CONTRACT_REVIEW_TIER. PASS (record 6881097452), then a delta PASS on this head (record 6881826142).
  • Accepted deviations:
    • The stated rule is scoped to what this diff moves (S1). The remaining engine pass is carried separately by this seat.
    • A value check on a writable field now reports after the strips have reported their drops (N3, accepted by the review).
  • Out of scope, filed: spec: the update-mode validation preview's named limit should also say it can refuse a row the update accepts #33643 (S2: the spec's preview-limit sentences).
  • Landing: the seat lands it through the merge queue (pr_ready + automerge_enable).

Implemented-by: os-dev (security#1 order, session_017xRBcT1w3zpekijraHJE4f) · Reviewed-by: review#2 (session_01FEkQ5nhu4dRbKVQKDB4CDB).


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 03:57
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 0a6f193 Nov 15, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/update-normalizes-after-strip branch November 15, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants