Repository navigation
feat(approvals): the service that owns an approval step can refuse a decision before it is recorded - #39143
Conversation
…a decision is recorded (WIP) Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 Co-authored-by: Claude <noreply@anthropic.com>
…on admission contract Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 Co-authored-by: Claude <noreply@anthropic.com>
…nned ledger Claude-Session: https://claude.ai/code/session_01TsNV8Bsjqmw7aXCo2QuLU1 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 58 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 20 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 183 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 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
|
|
repo:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1 Contract reviewServed-tier: PR #39143, card #39126, ruling record 7344644972 (option A). Read: the diff ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Cloud adoption (cloud#4639), is the contract sufficient: yes, without weakening the rule, provided the system arm is written narrowly. Open items
Implemented-by: 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>
|
repo:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1 Contract reviewServed-tier: Delta re-review of PR #39143 (card #39126, ruling record 7344644972, option A) after the FAIL record 7347782447 at Check-runs on ① Derived judgments
② Semver levelUnchanged and still correct: ③ Boundary flags
④ Design judgment
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.
Cloud adoption (cloud#4639): the dev accepted the system-arm caution ( Prior findings
Open items (none blocks this PR)
Implemented-by: VERDICT: PASS |
|
repo:cloud#3 · zhuangjianguo · session_01TsNV8Bsjqmw7aXCo2QuLU1 席位核对 · ACCEPT · 2026-12-02T15:01ZHead:
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46909801413 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
Fixes #39126
Clause-②: yes
Metadata-protocol: none
维护者速读
What changes
IApprovalServicegains an optionalregisterDecisionAdmission({ flow, check })(ApprovalDecisionAdmission,ApprovalDecisionAdmissionInput,ApprovalDecisionRefusal,ApprovalDecisionVerbin@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.decideNodeasks 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.sendBackasks it too, before its audit row, as what it records:revise, orrejectonce the step's revision budget is spent (that arm records arejectrow, sets the requestrejectedand 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.{ userMessage, message? }refuses: the service throwsFORBIDDEN: ...withstatus: 403,code: 'FORBIDDEN'and the check'suserMessage, the shape the approvals doors already answer as403 FORBIDDENwithuserMessageat the top of the body. Nothing is written: no action row, the request stayspendingon the same slate, the approver index and the status mirror are untouched, the run stays parked, and no notification goes out. A blankuserMessagestill refuses, without one.false, a string) refuses too, without auserMessage. A check that throws fails closed: its throw propagates unchanged (a throw declaring its ownstatus/codeanswers them at the door, any other a 5xx) and nothing is recorded.approval-service.tsis far past the size where a new concern gets its own module, so the registry and the refusal live inpackages/plugins/plugin-approvals/src/decision-admission.ts; the service holds one instance, a delegatingregisterDecisionAdmission, and two calls.packages/spec/api-surface/contracts.jsonandpackages/spec/export-origins/contracts.jsongain the four new exports (check:generated --fix, only the two it proved stale).scripts/engine-double-contract.pinned.jsonrecords the new suite's two engine doubles (check-engine-double-contract.mjs --write, 0 lost).viaOverrideis 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 readsactorIdandcontext. The contract also says recall is not asked.content/docs/automation/approvals.mdxunder "The decision" names the seam (not a governed path).@objectstack/specand@objectstack/plugin-approvals, patch (Metadata-protocol: none).Tests
packages/plugins/plugin-approvals/src/decision-admission.test.ts(14 tests), a realAutomationEnginewith the real approval node and an owning node that refuses any decider but the platform administrator:RESUME_FAILEDand leaves the requestapproved, the owning node never applied and no outcome notice sent. This is the measured defect, unchanged where nothing is registered.code: 'FORBIDDEN',status: 403and the check'suserMessage; every stored row is equal before and after, the request ispendingon 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,actorIdandviaOverride: truefor the override.reviseand refusesreject: refused, 403 with theuserMessage, nothing recorded, the check asked once asreject. CONTROL with budget left: the same check admits the send-back, asked asrevise, and the request isreturned.auto_approveunder a refusing check: the check is asked asapprovewithactorId: null,viaOverride: true(a system context holds no slot) andcontext.isSystem; no decision is recorded, the request ispendingon its slate, the run is parked, no outcome notice. The sweep's ownescalatemarker, written before it decides, stays, so the next sweep does not ask again (pinned).false,'no',0) refuses with nouserMessage, nothing recorded.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)
decideNodecall removed: 6 failed / 4 passed. The six are every decide refusal case; each now readsRESUME_FAILED: the ... decision was recorded on request .... Restore: blobd1126da3f038equals HEAD,git statusclean.sendBackcall removed: 1 failed / 9 passed (the send-back case). Restore: blobd1126da3f038equals HEAD.e0bed8150: A3, the send-back verb forced back torevise: 1 failed / 13 passed, the budget-spent case, which then readsRESUME_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: blob5e578ece1828equals HEAD,git statusclean.dist/), so no rebuild leg applies.Acceptance notes
recalladmits the submitter, a system context and the administrator override actor. The ruling namesdecideNode, so recall is outside this PR. It still finalises the requestrecalledand resumes the run down therejectedge withdecision = '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 arecallverb is the maintainer's ruling.escalatemarker (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.packageIdandnodeIdto narrow. A host-registered flow such as the marketplace review carries no package.FORBIDDEN:prefix plususerMessage) is the onerest-approvals-wire-codes.test.tsalready pins as403 { 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=2ate0bed8150: 148 files, 2364 tests passed.pnpm --filter @objectstack/plugin-approvals typecheck(build, scripts and the test program) andpnpm --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 --commandsate0bed8150, reconciled with--ran: 127 derived, 124 run, 3 NOT-MEASURED (check:dual-build-cjs-loadsandcheck:i18nrefuse without a full workspace build;check:type-check-debtoutruns the local timeout), 0 UNRUN. The os-dev report addendum on the card has each exit line.Read first: the two
decisionAdmissions.admitcalls inapproval-service.ts(their placement before the first write is the whole fix, and thesendBackone picksrejectpast the budget),packages/plugins/plugin-approvals/src/decision-admission.ts(the registry and the refusal shape), thenpackages/spec/src/contracts/approval-service.ts(ApprovalDecisionAdmission).Two-minute check:
pnpm --filter @objectstack/plugin-approvals exec vitest run src/decision-admission.test.ts, expect14 passed.Generated by Claude Code