Skip to content

feat(approvals): the service that owns an approval step can refuse a decision before it is recorded - #39143

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-39126-decision-admission
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/issue-39126-decision-admission

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #39126

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:审批人在拥有该审批步骤的服务明确不允许时去批准、驳回或退回(包括退回次数用尽后自动变成驳回的那一次),现在直接收到「无权」提示和对方给出的原因,申请仍是待审,什么都不会被记下;以前是先记成已决定,再报服务器错误。
  • 为什么做:云端市场包审核遇到了这个问题(组织管理员借管理员兜底批准了旧的审核申请),按维护者选定的方案一,让拥有审批流程的服务在记录之前先判。
  • 出错会怎样:只有主动登记了这种检查的服务才会受影响,其他审批流程行为不变;检查本身出错时一律拒绝且不写任何东西;可以直接撤回本次改动。
  • 要你做什么:无。

What changes

  • A declared admission, asked before anything is recorded. IApprovalService gains an optional registerDecisionAdmission({ flow, check }) (ApprovalDecisionAdmission, ApprovalDecisionAdmissionInput, ApprovalDecisionRefusal, ApprovalDecisionVerb in @objectstack/spec/contracts). The service that owns a flow registers one check per flow name; the approvals service asks it for every decision on an approval step of that flow.
  • Where it runs. decideNode asks it last among its refusals and before its first write (the audit row), so every approve and reject reaches it: the REST routes, the action door, the action link, the SLA sweep's auto-decision, a slot holder and the administrator override alike. sendBack asks it too, before its audit row, as what it records: revise, or reject once the step's revision budget is spent (that arm records a reject row, sets the request rejected and resumes the reject edge, so a rule "anyone may send back, only X may reject" holds there too; the budget read moved above the check, and it is a read). The check receives the request's facts (id, flow, package, node, run, object, record, organization, submitter), the verb, the person the decision would be recorded against, viaOverride, the comment and the decider's context.
  • Refusal. A check that answers { userMessage, message? } refuses: the service throws FORBIDDEN: ... with status: 403, code: 'FORBIDDEN' and the check's userMessage, the shape the approvals doors already answer as 403 FORBIDDEN with userMessage at the top of the body. Nothing is written: no action row, the request stays pending on the same slate, the approver index and the status mirror are untouched, the run stays parked, and no notification goes out. A blank userMessage still refuses, without one.
  • Fail closed. Any non-nullish answer that is not a refusal object (false, a string) refuses too, without a userMessage. A check that throws fails closed: its throw propagates unchanged (a throw declaring its own status/code answers them at the door, any other a 5xx) and nothing is recorded.
  • Registration. Sync or async. One admission per flow name: a second registration throws and the first stands; the returned function removes only its own registration. A flow with no admission behaves exactly as before.
  • Where it lives. approval-service.ts is far past the size where a new concern gets its own module, so the registry and the refusal live in packages/plugins/plugin-approvals/src/decision-admission.ts; the service holds one instance, a delegating registerDecisionAdmission, and two calls.
  • No ADR. AGENTS.md Prime Directive 13 asks for an ADR when a recorded decision is reversed; this adds a seam and reverses none. ADR-0019-approval-as-flow-node already puts the decision's authorization with the owning service and the resume behind it; the admission runs inside that authorization, before the record. The decision of record is the maintainer ruling 7344644972 on this card (option A), cited where the code implements it.
  • Generated: packages/spec/api-surface/contracts.json and packages/spec/export-origins/contracts.json gain the four new exports (check:generated --fix, only the two it proved stale). scripts/engine-double-contract.pinned.json records the new suite's two engine doubles (check-engine-double-contract.mjs --write, 0 lost).
  • Contract jsdoc. viaOverride is documented as the arm the decision took, not the decider's standing (an override actor who reassigned the request to themselves decides as a slot holder); a rule about who decides reads actorId and context. The contract also says recall is not asked.
  • Guide. One paragraph in content/docs/automation/approvals.mdx under "The decision" names the seam (not a governed path).
  • Changeset: @objectstack/spec and @objectstack/plugin-approvals, patch (Metadata-protocol: none).

Tests

packages/plugins/plugin-approvals/src/decision-admission.test.ts (14 tests), a real AutomationEngine with the real approval node and an owning node that refuses any decider but the platform administrator:

  • CONTROL, no admission registered: an organization administrator's override approval answers RESUME_FAILED and leaves the request approved, the owning node never applied and no outcome notice sent. This is the measured defect, unchanged where nothing is registered.
  • With the admission: the override approval, a slot holder's reject and a send-back are each refused with code: 'FORBIDDEN', status: 403 and the check's userMessage; every stored row is equal before and after, the request is pending on its slate, the run is still suspended, no message was emitted and the owning node never ran. The check saw the request's facts, decision, actorId and viaOverride: true for the override.
  • A send-back past its revision budget, under a check that admits revise and refuses reject: refused, 403 with the userMessage, nothing recorded, the check asked once as reject. CONTROL with budget left: the same check admits the send-back, asked as revise, and the request is returned.
  • The SLA sweep's auto_approve under a refusing check: the check is asked as approve with actorId: null, viaOverride: true (a system context holds no slot) and context.isSystem; no decision is recorded, the request is pending on its slate, the run is parked, no outcome notice. The sweep's own escalate marker, written before it decides, stays, so the next sweep does not ask again (pinned).
  • An admitted decision (the platform administrator's own slot) is recorded, resumed, applied by the owning node and the submitter is told.
  • A non-object answer (false, 'no', 0) refuses with no userMessage, nothing recorded.
  • An async refusal; a throwing check (its own error object reaches the caller, nothing recorded); a blank userMessage (refused, no member); a flow the admission was not registered for is never asked; one owner per flow, malformed registrations refused, the disposer.
Ablations (each via scripts/ablation-replace.mjs against the committed source; restore verified by blob hash)
  • A1, the decideNode call removed: 6 failed / 4 passed. The six are every decide refusal case; each now reads RESUME_FAILED: the ... decision was recorded on request .... Restore: blob d1126da3f038 equals HEAD, git status clean.
  • A2, the sendBack call removed: 1 failed / 9 passed (the send-back case). Restore: blob d1126da3f038 equals HEAD.
  • Round 2, at e0bed8150: A3, the send-back verb forced back to revise: 1 failed / 13 passed, the budget-spent case, which then reads RESUME_FAILED: the auto-rejection was recorded ... (the bypass the review named). A1 again with the new suite: 8 failed / 6 passed, the SLA case among them. Both restores: blob 5e578ece1828 equals HEAD, git status clean.
  • The suite imports the service by relative path (source, not dist/), so no rebuild leg applies.

Acceptance notes

  • Recall is not asked, and the override reaches it. On a pending request recall admits the submitter, a system context and the administrator override actor. The ruling names decideNode, so recall is outside this PR. It still finalises the request recalled and resumes the run down the reject edge with decision = 'recall'. So an organization administrator can still recall a marketplace review through the override, and cloud's finalize refuses after the record: the card's defect shape on a third door. The PM files a card for it; whether the admission gains a recall verb is the maintainer's ruling.
  • A refused SLA auto-decision is single-shot. The sweep writes its escalate marker (ADR-0042's idempotency row) before it decides, so a request whose auto-decision the check refuses stays pending, overdue, and is not escalated again. This is the existing behaviour for any auto-decision that throws (a required decision output, for one); it is pinned here and not changed.
  • Keyed by flow name. A package-scoped flow (ADR-0150) shares its name with any other package's flow of the same name; the check receives packageId and nodeId to narrow. A host-registered flow such as the marketplace review carries no package.
  • The REST door was not re-driven end to end here. The throw's shape (FORBIDDEN: prefix plus userMessage) is the one rest-approvals-wire-codes.test.ts already pins as 403 { code: 'FORBIDDEN', error, userMessage } on the decide route.

Verification

Local runs at the head named in the report
  • pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 at e0bed8150: 148 files, 2364 tests passed.
  • pnpm --filter @objectstack/plugin-approvals typecheck (build, scripts and the test program) and pnpm --filter @objectstack/spec typecheck: exit 0.
  • pnpm --filter @objectstack/spec build && pnpm --filter @objectstack/spec check:generated: 2 stale before the regeneration commit (api-surface, export-origins), all current after.
  • node scripts/pm/dispatch-gates.mjs --commands at e0bed8150, reconciled with --ran: 127 derived, 124 run, 3 NOT-MEASURED (check:dual-build-cjs-loads and check:i18n refuse without a full workspace build; check:type-check-debt outruns the local timeout), 0 UNRUN. The os-dev report addendum on the card has each exit line.

Read first: the two decisionAdmissions.admit calls in approval-service.ts (their placement before the first write is the whole fix, and the sendBack one picks reject past the budget), packages/plugins/plugin-approvals/src/decision-admission.ts (the registry and the refusal shape), then packages/spec/src/contracts/approval-service.ts (ApprovalDecisionAdmission).

Two-minute check: pnpm --filter @objectstack/plugin-approvals exec vitest run src/decision-admission.test.ts, expect 14 passed.


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 Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/plugin-approvals, @objectstack/spec, touching 57 documentable anchor(s). ⚠️ 2 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

58 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5.

⛔ 20 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json) — pages documenting those are invisible to this run
  • 2 anchor(s) matched too much of the corpus to be a work list: organization_id (symbol, 43 pages), recordId (symbol, 39 pages)
  • 7 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 183 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 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 78595f0d22dd76038adc53a4dd5ae570de1e6cc6 — the merge of head e0bed815055696132e13675ca7451691305a4689 into base 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5, 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 78595f0d22dd76038adc53a4dd5ae570de1e6cc6 && git checkout 78595f0d22dd76038adc53a4dd5ae570de1e6cc6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5 e0bed815055696132e13675ca7451691305a4689 && git checkout -B drift-repro 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5 && git merge --no-ff e0bed815055696132e13675ca7451691305a4689

node scripts/docs-audit/affected-docs.mjs --json 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5

⚠️ 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 3dfffef80a0aa8e8b73a17dfe2b30a2bb94e61d5 → 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:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 333d173661826287c6239331856e8136bcf03340
Local-runs: none
Scope: packages/spec/src/contracts/approval-service.ts + packages/plugins/plugin-approvals/src/decision-admission.ts, packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/decision-admission.test.ts, packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json, .changeset/39126-decision-admission.md
Security-touching: yes
Rule-change-verified: none

PR #39143, card #39126, ruling record 7344644972 (option A). Read: the diff origin/main...333d17366, decideNode / sendBack / recall / the SLA sweep at the head (git show, no checkout), ADR-0019-approval-as-flow-node, packages/rest/src/approvals-routes.ts, the dev report 7347620331, cloud's packages/service-cloud/src/marketplace-review-flow.ts. Check-runs on this head were still in progress when read (Build Core, Test Core 1-12, Type Check workspace and consumer gates, the UI jobs): NOT MEASURED here.

① Derived judgments

  • Public surface, add-only: right. Four new exports from @objectstack/spec/contracts (ApprovalDecisionAdmission, ApprovalDecisionAdmissionInput, ApprovalDecisionRefusal, ApprovalDecisionVerb) and one OPTIONAL member IApprovalService.registerDecisionAdmission. ApprovalService is the only implementer in the tree (implements IApprovalService, one hit), so no proxy or double is left without a forward. No Zod schema, no authorable key, no wire shape changes.
  • Accept set of decide: narrowed only for a flow that registered an admission; unchanged for every other flow: right. admit returns before any call when the row's process_name is not flow:NAME or no admission holds NAME.
  • Placement in decideNode: right. Everything above the admit call is a read or a throw (resolveActor, the row read, refuseUnreadableRequest, takenSlot, the two own-approval refusals, the outputs checks, assertAttachmentsUploadedByCaller, assertRunResumable); the next statement is the sys_approval_action insert, the first write. decideNode has one caller in source, decideAndResume, which decide (REST, the action door, the action link at approval-service.ts 11236) and the SLA sweep's auto_approve / auto_reject (13009) both go through. No other source writes approved or an approve action row.
  • Placement in sendBack: right for the send-back, wrong for its auto-reject arm. See ④ M1.
  • Refusal shape: right. FORBIDDEN: prefix, status 403, code FORBIDDEN, userMessage set only when non-blank; approvals-routes.ts maps /^FORBIDDEN/ to 403 FORBIDDEN (line 268) and carries a marked userMessage to the body (line 332). A non-nullish answer that is not an object (false, a string) refuses with no message: fail closed.
  • A throwing check: right, and the right failure mode. await admission.check(input) is not caught, so the throw leaves decideNode before the first write; nothing is recorded. Fail closed is correct for an authorization seam: a 5xx with the request still pending is recoverable, an admitted decision is not. A throw that declares its own status / code answers them.
  • Generated files: right. Both JSONs gain exactly the four names with kinds matching the source (three interfaces, one type). scripts/engine-double-contract.pinned.json records the new suite's two doubles.

② Semver level

patch on @objectstack/spec and @objectstack/plugin-approvals, Metadata-protocol: none: correct. Nothing a metadata author can write changes, and AGENTS.md "Before you finish" 3 ships a non-protocol widening as patch. Clause-②: yes with no arm is well-formed: the arm is optional ("at most one arm"), and check-adr-0087-registration.mjs reads a bare yes as "a widening declared through the value alone" (its own battery row). The PR body and the changeset body carry the same two lines. yes (widening) would read the same; no change is owed.

③ Boundary flags

  • Dev deviation (3), the bare Clause-②: yes: answered in ②, accepted.
  • Dev deviations (1) and (2), two vitest runs outside the lock and a backgrounded gate runner: process, no effect on the diff; the seat's to accept.
  • open_questions: none.
  • Out-of-scope finding "recall is not asked" (carrier: none, noted, not filed): not accepted as written; escalate. The dev calls recall "the submitter's withdrawal". recall also admits the Approval routed to an empty position permanently locks the record (no admin override, no recovery) #3424 override actor on a pending request (overrideAdmits, approval-service.ts 9767-9768) and a system context. An organization administrator can therefore still recall a marketplace review through the override: the request is finalised recalled, the run resumes down the reject edge with decision = 'recall', and cloud's marketplace.finalize refuses after the record. That is the card's measured defect shape on a third door. The ruling names decideNode, so it is outside this PR's letter and not a must-fix here, but it needs a card (a recall verb on the admission widens the ruling and is the maintainer's to rule), and the PR's Acceptance note must say that the override arm reaches recall.
  • Out-of-scope finding "cloud#4639 adopts by registering" (carrier: cloud): accepted, with the adoption caution under ④.
  • No ADR: PD#13 owes an ADR only when a recorded decision is reversed; this reverses none and the ruling id is in the code and the jsdoc. ADR-0019 keeps a dated addendum for every seam on this trust boundary (automation: the generic run-resume route needs an authorization gate keyed on the suspended node #3801, automation: the #3801 resume gate follows subflow: but not map:, and the resume body can write engine-internal variables #3853, automation: signal.output reopens the reserved-variable forgery #3853 closed on inputs #3879), so a dated addendum naming the admission is worth a separate add-only PR. It must not ride this one: docs/adr/** is a governed surface and would change this PR's tier. Should-fix as a follow-up, not a blocker.
  • scripts/adr-anchors/: anchors cite ADR ids; the placement cites a ruling record, and ablations A1 / A2 pin it. Nothing owed.
  • SQL push-down: no new query, id materialisation or in-app join. Nothing to flag.

④ Design judgment

packages/spec/src/contracts/approval-service.ts against ruling 7344644972 and its first consumer (cloud#4639):

  • M1, must-fix. A rejection is recorded that the check was never asked about as a rejection. sendBack asks the admission once, as revise, then on an exhausted revision budget (priorSendBacks >= maxRevisions, approval-service.ts 10439-10452) inserts a reject action row under the decider's actor_id, sets the request rejected, clears the slate and resumes the run down the reject edge. The published contract says the opposite in three places: ApprovalDecisionVerb is "spelled as the ApprovalActionKind each one records", ApprovalDecisionAdmission says "every decision on an approval step of that flow is asked of it first", and the PR body says "every approve and reject reaches it". An owner whose rule is "anyone on the slate may send back, only X may reject" is bypassed by any slot holder once the budget is spent. Cloud's verb-blind rule is not affected, which is why the suite did not see it. Fix in the diff's own files: priorSendBacks is a read computed before the first write, so move its computation above the admit call and ask the admission as reject when the budget is exhausted (or ask both verbs), and pin it with one test (a check that admits revise and refuses reject, send-back at the budget: 403, nothing recorded). If the maintainer prefers the arm to stay unasked, the jsdoc and the changeset must say so; the present text cannot stand.
  • Shape: minimal and typed. One optional member, one registration object, one refusal object. Every input field is read off the stored row or the resolved context; ApprovalDecisionInput.actorId, the caller's claim, is rightly not passed. actorId: string | null matches sys_approval_action.actor_id. context gives the check isSystem, which the consumer needs (below).
  • Optional member with a loud absence: right for a contract with one implementer and a consumer pinned to a release; the jsdoc tells the owner to probe and refuse to start.
  • One admission per flow name, second registration throws, disposer removes only its own: right. Keying by flow name with packageId / nodeId passed for narrowing is stated in the jsdoc and adequate for a host-registered flow.
  • Nit: viaOverride is not a standing test on its own. An override actor can reassign the request to themselves and then decide as a slot holder, viaOverride: false. The check still receives actorId and context, so a rule written on the person holds. One jsdoc sentence on viaOverride ("an audit fact, not the decider's standing") would stop an owner from keying on it.
  • Nit: a non-nullish, non-object answer refuses with no message. Fail closed and correct; the jsdoc names only undefined / null as admission and could say so.
  • Nit: flow:${input.flowName ?? input.nodeId} (line 8197) files a request with no engine-seeded flow name under its node id, which a flow-name admission would not match. The approval node always passes $flowName; edge only.
  • Nit: content/docs/automation/approvals.mdx describes the service's doors and gains no line for the new seam. Follow-up.

decision-admission.ts and the two calls in approval-service.ts against the contract: the code agrees with the jsdoc everywhere except M1. admit builds the input from the stored row only, awaits the check, treats null / undefined as admission and throws the 403 otherwise.

decision-admission.test.ts: a real AutomationEngine with the real approval node and an owning node that refuses after the record; the data engine is a declared double, recorded in the engine-double ledger. Red-first is shown by the CONTROL case (no admission: RESUME_FAILED, row approved) and by ablations A1 (6 red) and A2 (1 red) with restore blobs equal to HEAD. "Nothing recorded" is asserted on a snapshot of every stored row plus the emitted messages, which is the right strength. Gaps, both should-fix with M1: no case for the send-back auto-reject arm, and no case driving the SLA sweep's auto-decision through a refusing check (it goes through decideNode, so it is covered by construction, not by a pin; a refused sweep stays pending and is asked again on each sweep).

Cloud adoption (cloud#4639), is the contract sufficient: yes, without weakening the rule, provided the system arm is written narrowly. closeReviewFlow calls approvals.decide under { isSystem: true, userId: actorId ?? undefined }, so the check sees actorId: null when cloud's door names no user. The dev's suggested arm, "admit when the version is no longer pending_review", must NOT stand alone: closeReviewFlow is best-effort, so a pending request can outlive its listing transition, and an organization administrator's override approval of that stale request would then be admitted, which is the card's original report. The check has what it needs to close this: admit when actorId holds platform-admin standing, or when context.isSystem === true AND the version's listing_status has already moved to the state decision names; refuse everything else. isSystem is set by in-process callers only, never by the REST door.

Open items

  1. M1 (must-fix): ask the admission as reject on sendBack's auto-reject arm before any write, with a test; or state the exception in the jsdoc, changeset and PR body on the maintainer's word.
  2. Should-fix: correct the "Recall is not asked" note (the override arm recalls) and file a card for the recall door; a recall verb is the maintainer's ruling.
  3. Should-fix: pin the SLA auto-decision under a refusing check.
  4. Follow-up: a dated addendum on ADR-0019 for the admission seam, in its own add-only PR.
  5. Cloud adoption note: the system arm is isSystem AND listing state matches decision, never listing state alone.
  6. Nits: viaOverride jsdoc sentence; non-object answer documented; approvals.mdx line; Clause-②: yes stays as written.
  7. CI on this head was in progress at review time; the next record reads it.

Implemented-by: claude/issue-39126-decision-admission
Reviewed-by: session_01TsNV8Bsjqmw7aXCo2QuLU1

VERDICT: FAIL

…reject it records

The decision admission now asks sendBack's auto-reject arm as reject, before
any write; pins for that arm, the SLA auto-decision under a refusing check and
a non-object answer; contract jsdoc on viaOverride, fail-closed answers and
recall; one paragraph in the approvals guide.

Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: e0bed815055696132e13675ca7451691305a4689
Local-runs: none
Scope: packages/spec/src/contracts/approval-service.ts + packages/plugins/plugin-approvals/src/decision-admission.ts, packages/plugins/plugin-approvals/src/approval-service.ts, packages/plugins/plugin-approvals/src/decision-admission.test.ts, packages/spec/api-surface/contracts.json, packages/spec/export-origins/contracts.json, .changeset/39126-decision-admission.md, content/docs/automation/approvals.mdx
Security-touching: yes
Rule-change-verified: none

Delta re-review of PR #39143 (card #39126, ruling record 7344644972, option A) after the FAIL record 7347782447 at 333d17366. Read: the delta 333d17366..e0bed8150 (5 files, +130 / -13), sendBack, decideNode, runEscalations and escalateRequest at the head (git show, no checkout), the dev addendum 7349355494, the replaced PR body, and the head's check-runs. Nothing was built or run locally.

Check-runs on e0bed8150 as read: 63 completed success, 14 completed skipped (opt-in and matrix-placeholder jobs), 0 failed, 1 in progress. The one in progress is a second Check Changeset run started after the PR body was replaced; the first Check Changeset run on this head completed success, and the second PR-body guards run completed success. Build Core, Test Core 1-12, Test UI 1-16, Type Check (workspace, consumer gates, source gates, debt ledger), every Lint job, Governed Surface Queue Guard and Spec property liveness are success. The in-progress run is NOT a pass and is the seat's to read before the queue.

① Derived judgments

  • M1, closed. sendBack asks before any write, with the verb it records. approval-service.ts 10411-10421 reads the budget (maxRevisions from the stored node config, priorSendBacks by one engine.find), and 10422-10430 calls admit with decision: priorSendBacks >= maxRevisions ? 'reject' : 'revise'. Everything above it in sendBack (10392-10409) is a read or a throw: resolveActor, loadPendingRow, takenSlot, the not-a-pending-approver refusal, assertReviseEdge, assertRunResumable. The first write is the revise audit row at 10435. The predicate the admission is asked with is the same expression, on the same two locals, that selects the auto-reject arm at 10442, so the verb asked and the arm taken cannot disagree within one call.
  • The fix is pinned both ways. decision-admission.test.ts: budget spent (maxRevisions: 0) under a check that admits revise and refuses reject answers 403 with the userMessage, every stored row equal before and after, asked once as reject; the CONTROL with budget left is admitted, asked as revise, request returned. The dev's ablation A3 (verb forced back to revise) reds exactly the budget-spent case with RESUME_FAILED: the auto-rejection was recorded, which is the bypass the first review named.
  • SLA auto-decision, closed as a pin; the dev's correction is right and the first review's sentence was wrong. escalateRequest inserts the escalate action row at 12977-12992 and only then calls decideAndResume at 13011-13015; runEscalations skips any request that already carries an escalate row (11502-11506) and catches a throwing request (11510-11514). A refused auto-decision is therefore asked once and never again. The test pins: asked once as approve, actorId: null, viaOverride: true, context.isSystem, request pending on its slate, no approve row, one escalate row, run parked, no approval.approved, and a second sweep does not ask again. viaOverride: true is the code's truth: isOverrideActor answers true for a system context and the sweep holds no slot (8724-8734).
  • Refusal shape for a non-object answer: pinned. false, 'no' and 0 each answer 403 FORBIDDEN with no userMessage member and nothing recorded; decision-admission.ts admits on refusal == null only.
  • Public surface: unchanged by the delta. No export, member or signature moves; the delta in packages/spec is jsdoc only, so the two generated JSONs are untouched and check:generated has nothing to regenerate (CI Lint and Spec property liveness success).

② Semver level

Unchanged and still correct: patch on @objectstack/spec and @objectstack/plugin-approvals, Clause-②: yes, Metadata-protocol: none, the same two lines on the PR body and the changeset. The delta adds no surface.

③ Boundary flags

  • Recall note (prior should-fix 2): closed. The PR body's Acceptance note now says the override actor and a system context reach recall on a pending request and that this is the card's defect shape on a third door; the contract jsdoc says the same (approval-service.ts contract, "When it runs"); the follow-up is filed as objectstack#39145 (open). Whether the admission gains a recall verb stays the maintainer's ruling. Nit: the PR body still reads "The PM files a card for it"; it can name Approvals: recall admits the org-admin override actor and resumes the reject edge without the owning flow's decision admission (follow-up of objectstack#39126) #39145.
  • Dev out-of-scope finding "a refused SLA auto-decision is single-shot" (carrier: none, noted, not filed): not accepted as "noted"; file a card and tell the maintainer. It is not a must-fix here: the ordering is ADR-0042's and predates this PR, the request is not lost (it stays pending on its slate, a slot holder the check admits can still decide, the submitter can still recall), and the outcome is fail closed. But the admission turns a rare failure into a designed, repeatable one, and the result is quieter than the PR body says. When the check refuses, decideAndResume throws out of escalateRequest, so the code after it never runs: the submitter's SLA notice (13032 onward, notifySubmitter) is skipped, the pending approvers are told nothing, and the only trace is a warn log line plus an escalate audit row whose comment reads auto_approve or auto_reject with no "not applied" suffix, where the two other not-applied arms of the same function do write one. An author who declares escalation.action: auto_approve on a step of a flow whose owner registers a check refusing a machine decider (actorId: null) gets, on every request, an overdue request that the sweep will never visit again and that nobody was told about. Suggested card: on a refused or throwing auto-decision, fall back to the notify arm (as a reassign with no target already does) and mark the escalate row "not applied". That changes ADR-0042 behaviour, so it is the maintainer's to rule and does not belong in this PR.
  • Dev deviation (1), no merge of origin/main on resume: right; AGENTS.md multi-agent §10 governs. Deviations (2) and (3) are process with no effect on the diff; the seat's to accept.
  • open_questions: none.
  • content/docs/automation/approvals.mdx is not governed: confirmed. scripts/pm/check-governed-merges.mjs 613 ("content/docs/** prose needs nothing: it was never on the register") and its own battery row at 9665 (testVerdict(['content/docs/a.mdx']).governed === false). The file does not change this PR's tier; CI Governed Surface Queue Guard, Build Docs and Check Documentation Links are success.
  • ADR-0019 dated addendum (prior item 4): still owed as a separate add-only PR; nothing in this diff, correctly.
  • SQL push-down: the delta adds no query. The priorSendBacks find moved 14 lines up unchanged. Nothing to flag.

④ Design judgment

packages/spec/src/contracts/approval-service.ts against ruling 7344644972 and the code at the head:

  • ApprovalDecisionVerb jsdoc: accurate. "A send-back past the step's revision budget records a reject (and resumes the reject edge), so it is asked as reject, never as revise" matches 10427-10428 and 10442-10474.
  • ApprovalDecisionAdmission "When it runs": accurate, including the recall sentence (submitter, system context, administrator override).
  • "Admission": accurate against refusal == null.
  • viaOverride: the added sentence is right (an override actor who reassigned to themselves decides as a slot holder; judge who decides on actorId and context).
  • Nit N1: viaOverride still opens "admitted only by the administrator override". A system context takes the same arm, and the new test pins viaOverride: true with actorId: null for the SLA sweep. One clause ("or a system context, such as the SLA sweep's auto-decision") would make the field read true for the machine decider. The added "judge on actorId and context" sentence keeps an owner from being misled, so this is a nit.
  • Nit N2: the contract jsdoc names the SLA sweep as a door but not the single-shot consequence. The changeset and the PR body both say it; the contract is where the owner writing a check reads. One sentence under "Refusal" would do. It rides the follow-up card above if the behaviour changes.
  • Nit N3: past the budget only reject is asked, and the revise intent row is still written first (10435). An owner rule "X may reject, nobody sends back" admits X's budget-spent send-back and the trail reads revise then reject. The terminal outcome is the one the check admitted and the jsdoc states "never as revise", so the contract is honest; noted, nothing owed.

.changeset/39126-decision-admission.md: accurate against the code in every added clause (verb by budget, recall not asked, non-nullish answer refuses, the SLA marker already written so the sweep does not ask again).

content/docs/automation/approvals.mdx 920-927: accurate. Every approve, reject and send-back is asked; the budget-spent verb, the 403 FORBIDDEN with userMessage, "nothing is recorded", pending and parked, recall not asked all hold. It sits directly after the paragraph on the decision door, the right place. It omits fail-closed and the SLA case, which is acceptable for a guide paragraph that points at the contract.

PR body (replaced by the seat): agrees with the head. "What changes" states the verb choice and that the budget read moved above the check; "Tests" lists the three new groups; the Acceptance notes carry the corrected recall note and the single-shot SLA note; the ablation block keeps round 1's counts and adds round 2's. Two small points: the SLA note calls it "existing behaviour for any auto-decision that throws", which is true but understates that the notices are skipped too (③); and "The PM files a card" can now cite #39145.

decision-admission.test.ts: the new cases use the suite's existing snapshot / expectNothingRecorded strength; boot(reviewConfig) only overlays the review node's config on REVIEW_FLOW, so the earlier cases are unchanged. No new engine double (the ledger row stands).

Cloud adoption (cloud#4639): the dev accepted the system-arm caution (context.isSystem === true AND the listing state already moved to what decision names, never listing state alone). Adopting code should also know the SLA point: a check that refuses actorId: null must not sit under a step that declares an auto-decision until the follow-up lands.

Prior findings

  1. M1 (must-fix): CLOSED. approval-service.ts 10411-10430; test "a send-back past its revision budget records a reject, so it is asked as reject".
  2. Recall note (should-fix): CLOSED. PR body Acceptance note, contract jsdoc, objectstack#39145.
  3. SLA auto-decision pin (should-fix): CLOSED. Test "the SLA sweep's auto-decision is asked too"; the single-shot reading verified at 12977-12992, 13011-13015, 11502-11506.
  4. ADR-0019 addendum: OPEN as a separate follow-up PR, not a blocker.
  5. Cloud adoption caution: ACCEPTED by the dev; carried to cloud#4639.
  6. Nits: viaOverride sentence CLOSED (N1 remains on its first clause); non-object answer CLOSED and pinned; approvals.mdx CLOSED.
  7. CI: read on this head, above.

Open items (none blocks this PR)

  1. Should-fix, follow-up card, maintainer to know: a refused SLA auto-decision is single-shot and silent (no approver notice, no submitter notice, the escalate row reads as applied). Propose a fallback to notify plus a "not applied" marker; an ADR-0042 behaviour change, the maintainer's ruling.
  2. Follow-up: ADR-0019 dated addendum for the admission seam, own add-only PR.
  3. Nits N1, N2, N3; PR body can cite Approvals: recall admits the org-admin override actor and resumes the reject edge without the owning flow's decision admission (follow-up of objectstack#39126) #39145.
  4. The second Check Changeset run on this head was in progress when read.

Implemented-by: claude/issue-39126-decision-admission
Reviewed-by: session_01TsNV8Bsjqmw7aXCo2QuLU1

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1

席位核对 · ACCEPT · 2026-12-02T15:01Z

Head: e0bed815055696132e13675ca7451691305a4689

  • Form:

    • IApprovalService.registerDecisionAdmission, with the four spec types.
    • plugin-approvals/src/decision-admission.ts.
    • decideNode and sendBack admit before their first write. Past its budget, sendBack is asked as reject.
    • Tests, the approvals.mdx paragraph and the changeset.

    Not governed. Fixes #39126, ruling 「39126 A」. Declarations: Clause-②: yes (a widening), Metadata-protocol: none.

  • Contract review:

    • FAIL at 333d17366 (7347782447; M1: an exhausted send-back records a reject but was asked as revise).
    • Delta PASS at this head (7349533827): M1 closed, and the verb asked and the arm taken come from one expression. The recall note is closed, the SLA pin is closed, and the docs are accurate.
  • Follow-ups filed:

    • objectstack#39145: recall does not reach the admission (needs-user-decision).
    • objectstack#39155: a refused SLA auto-decision is single-shot and silent (needs-user-decision).

    The ADR-0019 dated addendum stays owed as its own add-only PR. Nits N1–N3 are recorded in the review.

  • Tests (dev):

    • The new suite is 14/14 on a real engine. plugin-approvals: 148 files, 2,364 tests.
    • Ablations: A3, send-back back to revise, turns 1 red and reproduces the bypass. A1, the admit call removed, turns 8 red.
    • dispatch-gates --ran: 127 derived, 124 run, 3 NOT-MEASURED, all left to CI.
  • CI: read at this record.

  • Cloud adoption (cloud#4639):

    • The system arm is isSystem AND the listing state already matches the decision.
    • No check refusing actorId: null may sit under a step with an auto-decision until objectstack#39155 is ruled.
  • Landing: an ordinary queue landing (ready, then auto-merge).

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

  • Dogfood Regression Gate (2/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/external-member-directory.dogfood.test.ts > [#25233] an external organization member reads its own identity rows and its explicit grants only
      ↳ 失败原因: @objectstack/dogfood:test: Error: assertArmed(): this fixture is DISARMED: 1 of 6 control(s) it measures are not engaged on the booted stack, so its assertions would pass without testing anything.
    

↳ 失败原因 是判读的关键:超时(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,按失败测试文件聚合):

历史信号:

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

分诊清单:

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

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

Merged via the queue into main with commit 08255e0 Dec 2, 2026
79 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-39126-decision-admission branch December 2, 2026 15:52
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

2 participants