Skip to content

fix(objectql): a state machine judges every write from the stored state, a clear included - #36127

Merged
os-zhuang merged 4 commits into
mainfrom
claude/sec2-v5c7
Nov 22, 2026
Merged

os-zhuang merged 4 commits into
mainfrom
claude/sec2-v5c7

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: follow-up #36161

维护者速读

  • 用户能看到的变化:带状态机的记录,清空状态字段现在和其他状态变更一样要过状态机;状态机没允许的清空会被拒绝,接口仍返回原来的"非法状态变更"错误。
  • 为什么做:让状态机说到做到,任何一串写入都不能把记录带出状态机本来一步就会拒绝离开的状态。
  • 出错会怎样:原本依赖清空状态字段的应用会在清空时收到 400;作者在该状态的目标里加上空值即可恢复,改动可直接撤回。
  • 要你做什么:无。

What changes

A state_machine validation now judges every update from the record's stored state, and clearing the state field (writing null or '') is a transition like any other — a transition to the empty value ''. A clear from a state that has a key in transitions is refused unless that state lists '' among its targets. The refusal is the existing one, unchanged in shape and code: VALIDATION_FAILED / 400, field code invalid_transition, constraint: { from, to: '' }.

  • Producer: checkStateMachine in packages/objectql/src/validation/rule-validator.ts (the one evaluator every write path calls: insert, update by id, multi-row update, the validate dry-run).
  • Docs: content/docs/protocol/objectql/state-machine.mdx, Enforcement semantics, now states the enforced rule and how to keep a state clearable (paused: ['open', '']).
  • Changeset: .changeset/sec2-v5c7.md, patch on @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 and initialStates, 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 real ObjectQL engine over a store-backed driver, a state field that is not required, run through both the update-by-id and the multi-row door (16 cases).

  • Refused, asserting code + status + field code + constraint: a clear written as null and 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.
  • Controls: the direct illegal transition is still refused; a declared transition lands; a clear the machine lists lands; an empty field written empty again, and a write that leaves the state alone, are not judged.
Red on base, green after, guard ablation
  • Base (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 HEAD empty.
  • Fix: Tests 16 passed (16).
  • Ablation 1 (the clear judged as a transition, reverted to the old exemption) via scripts/ablation-replace.mjs, anchor 1 → 0: Tests 8 failed | 8 passed (16); restored, blob == HEAD, git diff HEAD empty.
  • Ablation 2 (the clear's target spelled as the empty value, reverted to the raw value): Tests 10 failed | 6 passed (16) (the listed-clear control goes red as well); restored, blob == HEAD, git diff HEAD empty.
  • Through the REST door on a real bootStack engine (a scratch measurement, not committed): red on base; on the fix the clear answers 400 VALIDATION_FAILED, field invalid_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

  • Contract-tier (L2) review of this change is owed to the security seat.
  • Narrowing: an app that clears a state field on purpose needs '' in that state's targets; the refusal's from/to pair names the state.

Verification

Two-minute check: pnpm --filter @objectstack/objectql exec vitest run src/engine-state-machine-stored-state.test.ts — expect 16 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

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.

Generated by Claude Code

…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>
@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 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 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
  • the SDK route bridge reached 67 of 249 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • 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 8925d5bcb1a96beb59ff6ae35fada6f69f4f893d → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 8593e887efbdab16a96129a98f292ad470d23adf — the merge of head ba0b9bbfaf37cb093c474b986c0c9b62b1414d25 into base 8925d5bcb1a96beb59ff6ae35fada6f69f4f893d, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcSYaW9hZEkvXQFhPpn
os-dev-report

{
  "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"
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract-tier review (L2) of item 1 — PASS · head a51255640e. The reviewer was an isolated CONTRACT_REVIEW_TIER thread, read-only. The PR merges cleanly into origin/main, and all 55 check-runs are green. The rule was traced to every write door: by id, predicate/multi-row, batch upsert, import, REST, MCP and the engine API. Each one reads the stored state first and meets the one check.

Declarations:

Spelling of a clear: keep '' in the targets, as shipped. It adds no key, and the default is refusal.

Non-blocking, for follow-ups:

Items 2 and 3 of the order are with the maintainer.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: ba0b9bbfaf37cb093c474b986c0c9b62b1414d25
Local-runs: none
Scope: packages/objectql/src/engine-state-machine-stored-state.test.ts, packages/objectql/src/validation/rule-validator.ts + none

① Derived judgments

Item 1 of the order: a state machine judges every update from the stored state, and clearing the state field (null or '') is a transition to the empty value, refused with the existing invalid_transition unless the stored state lists '' among its targets. Traced to every write door (by id, predicate and multi-row, batch upsert, import, REST, MCP, engine API). Full review: comment 7066258435 at a51255640e. This head is that head plus a merge of origin/main only (ba0b9bbf: parents a51255640 and 8925d5bcb); 40 check-runs success, 15 expected skips, 0 failed.

② Semver level

patch with the BREAKING banner, as declared (Clause-②: no (narrowing), Metadata-protocol: none).

③ Boundary flags

The spelling of a clear ('' in the targets) is accepted as shipped. Items 2 and 3 of the order are ruled by the maintainer as separate orders. SQL push-down: none added.

④ Design judgment

The narrowing makes the declared transition graph real against the stored state and takes no declared capability away. Skills-docs: follow-up #36161. No must-fix or should-fix is open at this head; nits only, recorded in the full review.

Implemented-by: session_017xRBcSYaW9hZEkvXQFhPpn
Reviewed-by: session_017xRBcW9L8Noz9BxEwjwiov

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

席位记录 · ACCEPT · head ba0b9bbfaf37cb093c474b986c0c9b62b1414d25

维护者速读

  • 改了什么:状态机对每一次修改都按「库里现存的状态」判断;把状态字段清空也算一次状态转移。只有当前状态允许转到「空」时才放行,否则拒绝。
  • 为什么:加固工单、审批等流程状态的完整性(安全席位无卡派单)。
  • 若出错:只会多拒,不会多放;想让某个状态可清空,在它的目标里加上 '' 即可;可以直接撤回。
  • 要你做什么:请用授权账号批准当前 head ba0b9bbf(签名契约审核记录:评论 7075178691)。批准后,由席位翻 ready、入队、落地。

席位意见:ACCEPT。本 PR 只交付派发令里的第 1 项。第 2、3 项已按您的裁定(③ C、④ A)作为单独的派发令,留给下一任。

席位核对

  1. 形态: draft PR,以 main 为基,无卡。改动 objectql(patch)、一个文档页和一个 changeset。当前 head 是完整审核时那个 head,再合入 origin/main,没有其他改动。
  2. 前提实测: 第 1 项先在基座上通过 REST 复现为红,修后转绿,守卫消融后会变红。
  3. 门禁: 当前 head 上 40 个 check-run 成功、15 个预期跳过、0 个失败。landing-k OK(K = 4)。dogfood 套件在完整审核时的 head 上已全绿。
  4. 接受的偏差: 清空状态的写法定为 '',即在目标列表里写 '',按现有行为保留。
  5. 范围外去向,Skills-docs:: Skills-docs: follow-up #36161。Studio 面板写不了 '' 目标,这件事已记在 objectstack-automation state-machine reference teaches that a clearable state lists '' among its targets #36161 上,交给 ui 车道。
  6. 落地条款:
    • 本 PR 申报为收窄,落地需要两半同时在案:授权账号对当前 head 的批准,以及本 head 上的签名契约审核 PASS。
    • 两半齐备后,执行 pr_ready 与 automerge_enable。
    • 合并后,公告保持草稿,直到第 2、3 项落地。合并本身记入台账。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 22, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 22, 2026 07:22
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 44999732595 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (10/10) — 失败步骤: Run this shard's tests

    @objectstack/plugin-auth:test:  FAIL  src/password-reset-ends-added-access.test.ts > where the OAuth provider is mounted, a completed reset and a forced reset end the apps authorized to the account > 
      ↳ 失败原因: @objectstack/plugin-auth:test: AssertionError: expected false to be true // Object.is equality
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • src/password-reset-ends-added-access.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 2 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

席位分诊:队列构建 44999732595 的失败与本 PR 无关。

@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 4101f1f Nov 22, 2026
61 checks passed
@os-zhuang
os-zhuang deleted the claude/sec2-v5c7 branch November 22, 2026 08:49
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
… 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>
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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue 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.

3 participants