Repository navigation
fix(objectql): a state machine judges every write from the stored state, a clear included - #36127
Conversation
…te, a clear included Clearing the state field is a transition to the empty value and is judged against the machine's transitions like any other, so no sequence of writes leaves a state the machine would refuse to leave in one write. A state meant to be clearable lists '' among its targets. Claude-Session: https://claude.ai/code/session_017xRBcSYaW9hZEkvXQFhPpn Co-authored-by: Claude <noreply@anthropic.com>
…ded; add changeset Claude-Session: https://claude.ai/code/session_017xRBcSYaW9hZEkvXQFhPpn Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xRBcSYaW9hZEkvXQFhPpn Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. 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 8593e887efbdab16a96129a98f292ad470d23adf && git checkout 8593e887efbdab16a96129a98f292ad470d23adf
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8925d5bcb1a96beb59ff6ae35fada6f69f4f893d ba0b9bbfaf37cb093c474b986c0c9b62b1414d25 && git checkout -B drift-repro 8925d5bcb1a96beb59ff6ae35fada6f69f4f893d && git merge --no-ff ba0b9bbfaf37cb093c474b986c0c9b62b1414d25
node scripts/docs-audit/affected-docs.mjs --json 8925d5bcb1a96beb59ff6ae35fada6f69f4f893d |
|
security#2 · sunhaolin · session_017xRBcSYaW9hZEkvXQFhPpn {
"issue": null,
"status": "needs_decision",
"branch": "claude/sec2-v5c7",
"pr": "https://github.com/objectstack-ai/objectstack/pull/36127",
"session": "session_017xRBcSYaW9hZEkvXQFhPpn",
"premise_still_valid": true,
"summary": "Item 1 reproduced on base over REST and is fixed at its producer, objectql checkStateMachine: an update is judged from the stored state, and clearing the state field (null or '') is a transition to the empty value '' refused unless the stored state lists '' among its targets. The refusal keeps its shape and code (VALIDATION_FAILED/400, invalid_transition, constraint {from, to: ''}). Docs page states the enforced rule; patch changeset with BREAKING banner and ADR-0087 not-required marker. Item 2 reproduced on base and is reported as a fork (needs_decision); no code touched for it. status needs_decision is for item 2 only; item 1 is complete and CI-green.",
"tests": "New packages/objectql/src/engine-state-machine-stored-state.test.ts (real ObjectQL engine over a store-backed driver; by-id and multi-row doors; 16 cases; refusals assert code+status+field code+constraint; controls: direct illegal still refused, declared transition lands, listed clear lands, empty-to-empty and state-untouched not judged). Base (rule-validator.ts restored from db9e34ad, blob verified): Tests 8 failed | 8 passed (16), lock VERDICT command-exit 1; restored blob == HEAD, git diff HEAD empty. Fix: Tests 16 passed (16). Ablation 1 via scripts/ablation-replace.mjs (clear exemption restored, anchor 1->0, blob c5cc20c1->c42a4471): Tests 8 failed | 8 passed; restored blob == HEAD, git diff HEAD empty. Ablation 2 (empty target spelled raw): Tests 10 failed | 6 passed; restored, git diff HEAD empty. Ablations run from src (relative imports, no dist in path). A third, redundant no-change guard was removed rather than left unpinned (commit 41c61abb). pnpm --filter @objectstack/objectql test: Test Files 626 passed (626), Tests 14241 passed (14241), VERDICT command-exit 0 (tree 41c61abb; later commits change only the changeset). pnpm --filter @objectstack/objectql typecheck: exit 0 (incl. check:test-typecheck OK). eslint --no-inline-config on both changed TS files: exit 0. REST measurement (scratch dogfood file, not committed): base red, fix green as recorded in the private findings.",
"gates": "Local: node scripts/pm/dispatch-gates.mjs --commands derived 101 commands at 41c61abb (4 paths); all 101 run: 97 exit 0, 4 exit 3 PREREQUISITE NOT MET; --ran reconciliation: 101 derived, 97 run, 4 NOT-MEASURED, 0 UNRUN. Re-run at final head a5125564: check-adr-0087-registration --base origin/main exit 0, check-changeset-no-major exit 0, check-empty-changeset exit 0, check:nul-bytes exit 0, check:type-check-debt (under lock, full packages build) exit 0, then check:dual-build-cjs-loads exit 0 and spec check:skill-examples exit 0 (both prerequisites met by that build). Remaining NOT MEASURED: node scripts/check-plugin-teardown-shape.mjs --self-test, reason: shallow clone cannot reach its pinned fixture commit (checker-health only, not a PR verdict). CI on head a5125564 (PR check-runs): Lint & Repo Gates success, TypeScript Type Check success, Test Core success (10/10 shards success), Build Core success, Governed Surface Queue Guard success, Test UI success, Live E2E UI success, Dogfood Regression Gate success, Check Changeset success, Build Docs success, Spec property liveness success, Check PR Size success; Lint UI / Type Check UI / Build & E2E UI skipped by path filter; dogfood shards skipped on pull_request (queue runs them).",
"dogfood_battery": "a5125564 · os-verify-lock VERDICT command-exit 0 (held 40m16s) · Test Files 483 passed | 3 skipped (486) · Tests 4101 passed | 68 skipped (4169) · no failures",
"mcp_calls": "1 — mcp__github__pull_request_read (get_check_runs); no write tool. Plus claude-code-remote subscribe_pr_activity (session subscription, not a GitHub write).",
"api_writes": "3 — git push (not REST); relay advisory_read (read, fleet-write run 44916579512); relay pr_create (run 44919079587, POST pulls draft + assignees sunhaolin, read-back identical 5376 bytes); post-stamped comment on #36127 (this report). No labels written (not a skip-changeset diff; no labels named by the order).",
"out_of_scope_findings": [
"carrier: none · Planned file surface held: the producer is objectql's rule-validator (no other package). The skills reference on state machines does not claim a clear is exempt, so no skills/** edit was owed (governed surface untouched)."
],
"open_questions": [
{
"question": "Item 2 of the order (WITHHELD here — mechanism and measured evidence are in the private final report): authoring matter or platform rule?",
"options": [
"A authoring matter — teaching plus an advisory lint; no runtime change",
"B platform rule — the runtime changes how the lock is judged",
"C both"
],
"recommendation": "Not decided by this dev, per the order. The order supplied no decision axes, so options carry cost and effort only (private report); the security seat rules. needs_decision."
},
{
"question": "Spelling of an admitted clear: a state is clearable when its targets list the empty value '' (the empty value of a choice field). Keep '' as the one spelling, or make a clear never admissible from a declared state?",
"options": [
"A '' in the targets admits the clear (shipped: it is what the evaluator already did for a raw '' write; docs state it)",
"B no clear from any declared state, ever; drop the '' reading"
],
"recommendation": "A, because it adds no key or value to the contract, keeps the refusal shape, and gives an app that clears on purpose a one-line fix named in the refusal's from/to pair. Recorded as a trade-off, not a fork."
},
{
"question": "Declaration kind: Metadata-protocol: none with a patch changeset (as the order says) vs semantic (minor).",
"options": [
"A none — no key, value or metadata type moves; every declaration means what its transitions say; the narrowed thing is a runtime write",
"B semantic — the enforced meaning of an existing declaration changes"
],
"recommendation": "A, matching the order's patch level and the house precedent for a runtime-only narrowing (BREAKING banner plus ADR-0087 not-required marker are in the changeset). Check Changeset is green."
},
{
"question": "A further same-family item was measured on the way (WITHHELD here — in the private final report's security_findings).",
"options": [
"A a separate security order",
"B fold into this PR"
],
"recommendation": "A — it is outside this order's rule and file surface; not fixed here."
}
],
"security_findings": "withheld"
} |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov Contract-tier review (L2) of item 1 — PASS · head Declarations:
Spelling of a clear: keep Non-blocking, for follow-ups:
Items 2 and 3 of the order are with the maintainer. |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov Contract reviewServed-tier: ① Derived judgmentsItem 1 of the order: a state machine judges every update from the stored state, and clearing the state field ( ② Semver level
③ Boundary flagsThe spelling of a clear ( ④ Design judgmentThe narrowing makes the declared transition graph real against the stored state and takes no declared capability away. Implemented-by: VERDICT: PASS |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov 席位记录 · ACCEPT · head 维护者速读
席位意见:ACCEPT。本 PR 只交付派发令里的第 1 项。第 2、3 项已按您的裁定(③ C、④ A)作为单独的派发令,留给下一任。 席位核对
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 44999732595 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov 席位分诊:队列构建 44999732595 的失败与本 PR 无关。
|
… state may be cleared (objectstack-ai#36719) Fixes objectstack-ai#36567 Clause-②: no Metadata-protocol: none ## 维护者速读 - 管理员在 Studio 的校验规则面板里编辑状态机时,每一行流转多了一个「可清空」勾选框;改动前后其它界面不变。 - 为什么做:状态机规则把清空状态字段算作一次流转,只有勾了「可清空」的状态才允许;以前面板写不出这个设置,编辑已有规则时还会把它悄悄删掉,用户随后清空字段就被拒绝。 - 出错会怎样:最坏是某个状态的「可清空」设置被写错,用户清空字段时被误拒或误放行;不涉及数据丢失,可直接撤回本次合并。 - 无。 ## What changes `TransitionsField` in `ObjectValidationsPanel.tsx` parsed a row's next states with `.split(',').map(trim).filter(Boolean)`, so the empty-string target (a clear of the field, allowed from that state since PR objectstack-ai#36127) could never be authored, and any edit to a row that already listed it dropped it. The display side lost it too: `['open', '']` rendered as `open, ` and `['']` as an empty box. Now: - The "Next states" box shows and edits the named targets only. - Each row has a "May be cleared" checkbox (zh: 可清空, with a hover hint) that adds or removes the `''` target. - Editing the box keeps an existing `''`; it is written as the row's last target (targets are a set), so `paused: ['open', '']` is written back unchanged. Measured against the dispatch's mechanism hypotheses: the parse in the targets box is the only parse site in the panel (`split(` occurs once in the file at 9348f02); the display side (`to.join(', ')`) also lost the `''` and is fixed in the same change. Nothing changes on the server or in the spec (ADR-0020 D1/D3 shape and enforcement unchanged). New strings: `engine.studio.rules.transitionClearable` and `engine.studio.rules.transitionClearableHint` in the studio namespace's `en` and `zh` catalogues (the only two that namespace ships; it is not a zh-Hant generation target). ## Tests New pin: `ObjectValidationsPanel.clearableState-36567.test.tsx`. - "a rule with paused: ['open', ''] round-trips through a row edit unchanged": the box shows `open`, the row's checkbox is checked; an edit to `open, closed` writes `['open', 'closed', '']`, and an edit back to `open` writes the original `transitions` map exactly. Each written rule passes a full `ValidationRuleSchema.safeParse`. - "the checkbox adds and removes the empty-string target". <details><summary>Panel suites at 26b3836: 14 files, 135 tests, all pass</summary> `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/studio-design/ObjectValidationsPanel packages/app-shell/src/views/metadata-admin/previews/ValidationPreview.test.tsx` (under `os-verify-lock.sh`): ``` Test Files 14 passed (14) Tests 135 passed (135) os-verify-lock: VERDICT command-exit 0 ``` `pnpm --dir ui exec vitest run --maxWorkers=2 packages/i18n/`: Test Files 106 passed (106), Tests 1978 passed, 13 skipped (1991), VERDICT command-exit 0. `pnpm --filter @object-ui/app-shell type-check && pnpm --filter @object-ui/i18n type-check` (the app-shell script includes `tsconfig.test.json`, which compiles the test files): VERDICT command-exit 0. </details> <details><summary>Red on main: the pin fails against the base panel</summary> Panel and both catalogues restored from 9348f02 into the worktree (unstaged), then put back with `git checkout HEAD --`; `git diff HEAD` empty afterwards. ``` × a rule with paused: ['open', ''] round-trips through a row edit unchanged × the checkbox adds and removes the empty-string target Test Files 1 failed (1) Tests 2 failed (2) ``` </details> <details><summary>One ablation: the box edit drops the kept target</summary> Done after the fix was committed, through `node scripts/ablation-replace.mjs`, with a restore trap on `git checkout HEAD --`. The anchor was the box's `filter(Boolean), to.includes(''))` and the replacement passes `false` for `to.includes('')`. Expected direction: red on the round-trip case only. ``` ablation-replace: ok mutation landed: anchor 1 -> 0, blob 259e85f -> 9d93a6bd26bb × a rule with paused: ['open', ''] round-trips through a row edit unchanged AssertionError: expected [ 'open', 'closed' ] to deeply equal [ 'open', 'closed', '' ] Test Files 1 failed (1) Tests 1 failed | 1 passed (2) ablation-replace: ok restored: blob == HEAD (259e85f) and `git diff HEAD` is empty ``` Observed as predicted: the round-trip case went red and the checkbox case stayed green. The subject is imported from source, so no build leg was needed. </details> ## Acceptance notes - Landing point is the expected one (`ObjectValidationsPanel.tsx`) plus its two catalogue files. No edit under the fenced trees. - Not run locally, and declared to CI's `Test UI`: the full `@object-ui/app-shell` suite. A local run held the shared verification lock for more than 35 minutes without finishing and was stopped. The panel's own 13 suites, the preview suite and the i18n package ran green. - Out of scope, reported to the seat and not fixed here: (1) a comma typed at the end of the "Next states" box is eaten. The controlled box re-renders from the parsed list, so typing `done, c` key by key leaves `donec`. A throwaway probe confirmed this at 26b3836; the base runs the same parse expression. The cause is the same parse expression, but the fix (a text buffer) is a design change. (2) The metadata-admin validation preview renders an `''` target as a trailing ` | ` (`open | `), or as a blank where neither a target nor "dead end" shows (`closed → `). A throwaway probe confirmed it. ## Verification Read first: the `TransitionsField` row in `ObjectValidationsPanel.tsx` (the box's `onChange` and the new checkbox), then `rowTargets` above it. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/studio-design/ObjectValidationsPanel.clearableState-36567.test.tsx`. Expect `Tests 2 passed (2)`. <details><summary>Local gates at 26b3836 (derived by dispatch-gates --commands, reconciled by --ran: 38 derived, 38 run)</summary> All 38 exit 0, each with its exit code recorded before any pipe. `--ran` verdict: "38 derived famil(ies) accounted for — 38 run, 0 NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of them is 3)". `check:test-source-alias` was red on the first sweep (the new pin reached three dynamic imports in clocked windows). The pin now imports them at module top, as its sibling suites do. `check:type-check-debt` first returned PREREQUISITE NOT MET (lock queue-timeout behind this PR's own suite run), then exit 0 under the lock. Every family CI runs is read from this PR's check-runs. `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0 before each push. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_011y7As6kDA9BVrMsBR9rmrJ)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #36161
维护者速读
What changes
A
state_machinevalidation now judges every update from the record's stored state, and clearing the state field (writingnullor'') is a transition like any other — a transition to the empty value''. A clear from a state that has a key intransitionsis refused unless that state lists''among its targets. The refusal is the existing one, unchanged in shape and code:VALIDATION_FAILED/ 400, field codeinvalid_transition,constraint: { from, to: '' }.checkStateMachineinpackages/objectql/src/validation/rule-validator.ts(the one evaluator every write path calls: insert, update by id, multi-row update, the validate dry-run).content/docs/protocol/objectql/state-machine.mdx, Enforcement semantics, now states the enforced rule and how to keep a state clearable (paused: ['open', ''])..changeset/sec2-v5c7.md,patchon@objectstack/objectql, with its BREAKING banner and its ADR-0087 disposition (not-required).Unchanged: a write that does not touch the state field, an unchanged value, a declared transition, a stored state with no key in
transitions(still lenient), inserts andinitialStates, and the seed / historical-import exemptions.Why
A declared state machine is a promise that the record cannot be moved by a sequence of writes the machine would refuse as one write. The empty value is a value the field can hold, so moving to it is a transition the machine has to admit.
Tests
New file
packages/objectql/src/engine-state-machine-stored-state.test.ts: the realObjectQLengine over a store-backed driver, a state field that is notrequired, run through both the update-by-id and the multi-row door (16 cases).code+status+ field code +constraint: a clear written asnulland as''from a declared dead-end, with the state still stored and the next move out of it still refused; a clear from a state that does not list''; the same for an elevated caller.Red on base, green after, guard ablation
db9e34ad, the file restored from base, blob verified on disk):Tests 8 failed | 8 passed (16)— every refusal case red, every control green. Restored, blob equal to HEAD,git diff HEADempty.Tests 16 passed (16).scripts/ablation-replace.mjs, anchor 1 → 0:Tests 8 failed | 8 passed (16); restored, blob == HEAD,git diff HEADempty.Tests 10 failed | 6 passed (16)(the listed-clear control goes red as well); restored, blob == HEAD,git diff HEADempty.bootStackengine (a scratch measurement, not committed): red on base; on the fix the clear answers400 VALIDATION_FAILED, fieldinvalid_transition,constraint {from: closed, to: ""}, the state stays stored, and the next move out of the dead-end answers the same refusal.pnpm --filter @objectstack/objectql test:Test Files 626 passed (626),Tests 14241 passed (14241).pnpm --filter @objectstack/objectql typecheck: exit 0.Acceptance notes
''in that state's targets; the refusal'sfrom/topair names the state.Verification
Two-minute check:
pnpm --filter @objectstack/objectql exec vitest run src/engine-state-machine-stored-state.test.ts— expect16 passed.Read first, by risk:
packages/objectql/src/validation/rule-validator.ts(checkStateMachine, the update arm), then the new test file, then the changeset.Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code