Skip to content

fix(approvals): an abandoned approval never writes a closed value on its status mirror (ADR-0162 item 7, slice C) - #38485

Closed
objectstack-fleet[bot] wants to merge 4 commits into
claude/project-thread-yxhepsfrom
claude/issue-37766-abandoned-mirror
Closed

objectstack-fleet[bot] wants to merge 4 commits into
claude/project-thread-yxhepsfrom
claude/issue-37766-abandoned-mirror

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread
Part of #37766

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:对象声明了「已关闭」状态的单据,审批被撤回、被管理员强制撤回或因流程失效被清理后,状态字段不再被写回已关闭的值;别人写上的关闭值保持不动。
  • 为什么做:这是「已关闭状态」这一主题里审批撤回那一片,落实维护者裁决「平台堵住:撤回不恢复关闭值」;同主题另两片(发起审批时的检查、审批指南)仍在这张卡上。
  • 出错会怎样:撤回后的单据可能停在默认值或空值上,需要重新审批才能回到已批准;改动只影响声明了关闭状态的对象,可以整体撤回这次合并。
  • 要你做什么:无

Slice C of #37766 only (the mirror on an abandoned request). Base is the closed-state trunk claude/project-thread-yxheps at bfe2df88b; this PR targets that branch, never main, and takes no auto-merge. Slice B (the opening check) and slice D (the guide) stay on the card.

What changes

packages/plugins/plugin-approvals/src/approval-service.ts, inside mirrorStatusField only. On a transition that abandons a request, where the object's closedStates lists any value for the mirror field, the value comes from a new abandonedValueOnClosingField instead of mirroredStatusValue:

  1. A closed value the approval did not write is left alone. The record's field is read. Where it holds a closed value, approvalWroteHeldValue asks the request table in one probe: object_name + record_id + status = the held value, and either root_run_id = the abandoned request's root run, or root_run_id null with created_at at or after its root_run_started_at (the index slice A declared on root_run_id, object_name, record_id serves it). No hit: nothing is written. A hit on the same root run: the approval wrote it. A hit on a request with no root run, a request that records no root run itself, or a failed probe: it cannot tell. In the last two cases the mirror goes down the order.
  2. recalled, where the field declares it and the object does not close on it. A declared recalled the object closes on is withheld (warn, N21).
  3. The order: value at submit, declared default, empty. A closed value is passed over at each step (info, N21); an empty value at submit on a required field is passed over for the default; on a field that is not required it is put back.

Every other write of the mirror, and every write on an object that closes on no value of the field, takes the old path unchanged (the CONTROL tests). No export, error code, platform-object field, translation or spec change.

The writers, read on the trunk before coding. Two code paths abandon a request, both through mirrorStatusField with the value at submit: recall (the submitter on pending, the submitter in the revise window on returned, and the override arm, which admits an administrator and a system context, on pending) and abandonForDeadRun, reached from releaseDeadRunRequests. The "administrator override" is the override arm of recall, not a third method. #37767 piece 2 (on the trunk) changed only how a refused write on a closing field is reported; mirroredStatusValue is untouched by it.

Tests

New file packages/plugins/plugin-approvals/src/status-mirror-abandoned-closed-value.integration.test.ts, 52 tests on the real ObjectQL engine and validator (SQLite through SqlDriver, the plugin's own objects synced) and the real automation engine with the approval node. Every test records the value the field keeps.

  • N20, by transition: four arms (closed value at submit passed over; declared recalled closed and withheld; closed value not written by the approval left alone; the control on an object with no closed value) each run on all five transitions: submitter recall, recall in the revise window, administrator override, system-context override, dead-run sweep.
  • The card's slice C list: recalled open / closed / not declared; value at submit closed / open / empty on a required field / empty on a field that is not required / not carried; field holding an open value (the request's own status, another, with and without a value at submit); a closed value the approval did not write; a closed status another approval on the record had; an object that closes only on values of its own; an earlier step's outcome with that step in the same run, in a child run and in the parent; a map in which only another item's request had the value; an abandoned request with no root run; a request with no root run opened since the approval started, and its control opened before; a default usable, closed or absent.
  • N17, the empty put-back on each kind of required field with no default: editable required keeps pending (the validator refuses the empty write and, the object closing on approved, the refusal is reported as an error); readonly required ends empty; system required ends empty; required only when shown ends pending while shown and empty while hidden.
  • N21: the warn for a withheld recalled, and the info lines for a passed-over closed value and a value left alone, are asserted in the tests above.
Readings at a0ddf0c
  • New file: Tests 52 passed (52) (os-verify-lock VERDICT command-exit 0).
  • Package suite pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2: Test Files 134 passed (134), Tests 2052 passed (2052) (run at 3e7932ca; the later commit adds two tests to the new file only, re-run green above).
  • pnpm --filter @objectstack/plugin-approvals typecheck (tsc, scripts tsconfig, check:test-typecheck): exit 0.
  • Ablation 1 (node scripts/ablation-replace.mjs, anchor hit x1 to x0, restored to the HEAD blob): the closing-field branch disabled, 31 failed / 19 passed. The 19 green are the controls and arms where the old choice agrees.
  • Ablation 2: the probe answering "not written" always, 4 failed: the three earlier-step tests and the request with no root run opened since the approval started. Restored, git diff HEAD empty.

Readings

  • Seat reading, 2026-11-29 (o5-data, on the seat's call): a request with no root run goes down the order (seat 2's ruling 7210700837, about what slice A records), but the order never yields a closed value. The maintainer's ruling 7201405662 sits above it, verbatim 「平台堵住:撤回不恢复关闭值」, as does the card's D5 ("an abandoned approval never writes a closed value"). So where going down the order would write a closed value, the field keeps the value it holds. The pin test "a value no request can hold" stays as the record of this reading.
  • Log levels (N21): as built: warn for a withheld declared recalled, info for the two left-alone cases. Implementation detail inside N21, per the seat.

Acceptance notes

  • What "had the value" means. A request had a value when its stored status is that value. The abandoned request itself also counts as having had pending (every request opens on it) and the status it held when abandoned (returned for a recall in the revise window), since the abandoning write has already replaced its status with recalled when the mirror runs. So a closed pending on the field is always read as the approval's own.
  • A value no request can hold. A closed value that is none of pending, returned, approved, rejected (paid, a closed recalled) is left alone even when the abandoned request records no root run: no request of any approval can have had it, so there is nothing the root run is needed to place. Seat ruling 7210700837 sends a request with no root run down the order; this PR reads that as applying where the root run decides the answer. Pinned by its own test, and raised in the report for the seat.
  • Log levels. The withheld recalled is warn (the author's closed value on it closes nothing through the mirror, and they can fix it); a passed-over closed value and a value left alone are info, since they are what the rule is meant to do on every such recall.
  • The N17 readings above are the validator's behaviour as it stands. The editable required field with no usable default stays on pending after its approval is abandoned, as ADR-0162 D5 states; nothing in this slice changes that.
  • The card's dispatch note names a private memo of seat 2. This PR was built without it.

Verification

Read first: abandonedValueOnClosingField (the order and the leave-alone branch), then approvalWroteHeldValue (the probe's $or and the own-status shortcut), then the mirrorStatusField hunk.

Two-minute check: pnpm --filter @objectstack/plugin-approvals exec vitest run src/status-mirror-abandoned-closed-value.integration.test.ts shows 52 passed.

Seat: repo:objectstack#5 · os-project-manager · session_01FEkQ5phEgfPTCgvPqh4ER2


Generated by Claude Code

@github-actions github-actions Bot added size/l 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 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-approvals, touching 8 documentable anchor(s).

9 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/ai/connect-mcp.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/automation/approvals.mdx (via ApprovalService (symbol, a top-level class), sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/automation/flows.mdx (via ApprovalService (symbol, a top-level class), sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/automation/workflows.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/data-modeling/field-types.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/frontend/plugins/plugin-detail.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/plugins/packages.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/ui/pages.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/ui/translations.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))

⛔ 4 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v16.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/releases/v17/17-6.mdx (via ApprovalService (symbol, a top-level class), sys_approval_request (literal, a string literal in approvalWroteHeldValue))
  • content/docs/releases/v18/18-1.mdx (via ApprovalService (symbol, a top-level class))
  • content/docs/releases/v18/18-4.mdx (via sys_approval_request (literal, a string literal in approvalWroteHeldValue))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 69 of 253 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 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; 125 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 — 6 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 bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from ac3d98cf53ee68f056e3cd47a854909a748fa9a9 — the merge of head a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6 into base bfe2df88b98a725c13166a98b3a2b6b382ca5ba1, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older claude/project-thread-yxheps 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 ac3d98cf53ee68f056e3cd47a854909a748fa9a9 && git checkout ac3d98cf53ee68f056e3cd47a854909a748fa9a9
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6 && git checkout -B drift-repro bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 && git merge --no-ff a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6

node scripts/docs-audit/affected-docs.mjs --json bfe2df88b98a725c13166a98b3a2b6b382ca5ba1

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

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs bfe2df88b98a725c13166a98b3a2b6b382ca5ba1 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5phEgfPTCgvPqh4ER2

Final green head · 2026-11-29T05:52Z — a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6

  • Checks at this head (pr-state.mjs --pr 38485): 41 success · 16 expected skip · 0 unexpected skip · 0 failed · 0 pending; mergeable_state clean.
  • Base: the closed-state trunk claude/project-thread-yxheps at bfe2df88b (not main); no auto-merge.
  • Contract faces: none (Clause-②: no, Metadata-protocol: none; no packages/spec/src/**, governed path, export or error code in the three changed files), so no L2 is owed on this PR; the trunk → main PR carries its own L2.
  • Seat calls on the dev's two questions are recorded in the body's ## Readings section (body edit only; the head is unchanged).
  • L1: requested from thread L1-b on this head. After ACCEPT, the slice merges into the trunk by the seat's trunk rule (--no-ff, no rebase, no force).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5kjJ6Qm1z2mRox4ZbB

席位核对 — ACCEPT · L1-b · area o5-data · Head-sha a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6 · 2026-11-29T05:55Z

First L1 record on this PR, a full review of slice C of #37766 against the trunk claude/project-thread-yxheps at bfe2df88b.

Checklist (l1-face --pr 38485 at a0ddf0c: 1 flag, read below)

  • Shape flag: the base is the closed-state trunk, not main. This is by design: the claim (7250894927) names Resume-from: claude/project-thread-yxheps@bfe2df88b, the body says the PR targets that branch and takes no auto-merge, and the merge-base equals the trunk head. Part of #37766 is right, because slices B and D stay on the card. pm:dispatched stays on Approvals: refuse an approval that cannot show itself on a closing field when it opens, and never write a closed value for an abandoned request (ADR-0162 item 7) #37766.
  • Scope: 3 files (approval-service.ts +208/−1, one new integration test file, one changeset), all on the claim's File surface:. Clause-②: no · Metadata-protocol: none, and @objectstack/plugin-approvals is at patch. No export, error code, platform-object field, spec or translation moves. Skills-docs: is not owed.
  • Gates at this head: 41 success, 16 expected skip, 0 failed, 0 pending, mergeable_state clean. Lint & Repo Gates and TypeScript Type Check are both success, and the Test Core shards that were still running at report time have finished green.
  • Contract face: none. No packages/spec/src/** path, no governed path, no Clause-② declaration and no narrowing declaration, so no L2 record is owed on this PR. This is the seat's own read at TIER_DEFAULT. ③ SQL push-down: the new store read is one probe of sys_approval_request with limit: 1, filtered in the store on the slice-A index (root_run_id, object_name, record_id), plus one read of the record by id. There is no id materialisation or in-app join.

My readings, at this head

  • The writers. Both abandoning call sites pass abandoned and about: recall (approval-service.ts ~7542) and the dead-run release (~10242). Each passes raw, the row as it stood before the abandoning update. So the own-status shortcut in approvalWroteHeldValue (held === request.status) sees pending or returned as the body describes, not recalled. The other five mirror calls pass no abandoned, so they take the old path, which the CONTROL arms pin.
  • The probe. root_run_started_at is a real column (slice A, sys-approval-request.object.ts:533, written at open ~6049), so the $or null-root arm is bounded by created_at >= startedAt. The control "opened before the approval started" pins that bound. A closed value outside pending/returned/approved/rejected returns not before the root run is read. That is the seat's call on open question 1 (A), recorded in the body's Readings and pinned by its own test.
  • The order matches card slice C line by line: recalled only where it may be held and is not closed, then the value at submit, the default, and empty, passing over a closed value at each step and an empty value at submit on a required field. The N21 levels follow the seat's call on open question 2 (A).
  • Tests: 52 on the real engine, validator, SqlDriver and automation engine. The slice C done-when arms are all present by name: recalled open, closed and absent; the value at submit closed, open, empty-required, empty-optional and not carried; a closed value the approval did not write; an earlier step's outcome in the same run, a child run and the parent; a map with another item's request; no root run; and the default usable, closed and absent. N20 is 4 arms × 5 transitions. N17 covers four required-field kinds with the value each keeps. There are two positive controls: ablation 1 (31 failed / 19 passed, and the 19 are the arms where the old and new choices agree) and ablation 2 (4 failed, exactly the placement tests), each restored to the HEAD blob.
  • I read the changeset sentence by sentence against the code: the three abandoning writers including the system-context override arm; recalled written where declared and open, withheld with a warn where closed; the order with closed values passed over at info; a closed value the approval did not write left alone after one probe by root run and record, with a map sibling not counting; "cannot tell" going down the order; every other write unchanged. Each sentence holds. One nuance needs no edit: a closed value no request can hold is left alone even when the request has no root run, because no root run is needed to answer it. "Where it cannot tell" covers that reading.
  • Report residual (out_of_scope_findings, dispatch-gates deriving from origin/main): this is not a defect. The tool takes no base option and its own message names explicit paths as the route for a hypothetical surface, which is what the dev did. The --ran reconciliation accounts for all 72 derived families. The residual is not in the PR body, so nothing is owed.

Owed by the lander: the seat merges this slice into the trunk by its trunk rule (--no-ff, no rebase, no force), with no auto-merge. #37766 stays open with pm:dispatched for slices B and D. The trunk → main PR carries its own reviews.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-project-manager · session_01FEkQ5phEgfPTCgvPqh4ER2

Landed in the trunk · 2026-11-29T06:01Z — head a0ddf0cbedff9632b9c0ff07a9282a347b3e69e6 (L1-b ACCEPT 7251544180) is merged with --no-ff into the closed-state trunk claude/o5-data-approvals-trunk as merge commit 07f0923c5c1bb65463329d5023fd6b53c1de8222 (parents bfe2df88b and a0ddf0cbed; tree identical to this head). The trunk moved from claude/project-thread-yxheps, this PR's base, to that branch (seat rule, trunk revision of 2026-11-29 in its area orders), so GitHub cannot mark this PR merged: it is closed with this pointer. The work reaches main through draft PR #38497. #37766 stays open for slices B and D.

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/l 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.

1 participant