Repository navigation
fix(approvals): RESUME_FAILED carries the refusal that stranded the run - #34619
Conversation
A decision whose next step is refused by a record hook answers 500 RESUME_FAILED (#13807 B, unchanged), but the body did not say which refusal stranded the run: the engine reported innerRefusal / userMessage (ruling B' on #24914) and serviceResume dropped them. - @objectstack/types: StrandedDecisionDetails gains optional innerRefusal and userMessage; the recogniser validates them and drops a malformed one without dropping the four facts. - plugin-approvals: serviceResume keeps the engine's refusal members and resumeRecordedOutcome attaches them to the stranded-decision envelope. - rest: the RESUME_FAILED body spreads them (comment only; the recogniser decides). - Pins: the card's flow end to end (real engine, real update_record, a declared hook refusal) with no fault edge, with a fault edge (routed, the decision answers normally), and a fault-only reverse control; wire and recogniser pins. - Docs: approvals guide teaches the fault edge for this case. Claude-Session: https://claude.ai/code/session_01ADHkmT4f9MMpnjemPU3Esb Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 4 package(s): 8 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 6 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 178 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 014882d3a5fdb388a6bab6f2ed2a439d9789cd1d && git checkout 014882d3a5fdb388a6bab6f2ed2a439d9789cd1d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 97defd60674b4b7dc795c0e30103818020a6f2c9 95eae72668321d7f8eb2233f80753911e1202288 && git checkout -B drift-repro 97defd60674b4b7dc795c0e30103818020a6f2c9 && git merge --no-ff 95eae72668321d7f8eb2233f80753911e1202288
node scripts/docs-audit/affected-docs.mjs --json 97defd60674b4b7dc795c0e30103818020a6f2c9
|
The new hook-refusal-after-decision double drops its unused findOne (the gate requires the ObjectQL predicate on any findOne), and the ledger learns the update/delete pins. The wire-codes test pays the objectql load at collection (check:test-source-alias). Claude-Session: https://claude.ai/code/session_01ADHkmT4f9MMpnjemPU3Esb Co-authored-by: Claude <noreply@anthropic.com>
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract-review-claim: session_01ADHkmP44onN8RMzsPMqjRq · head 95eae72 · 2026-11-17T04:19Z |
|
repo:objectstack#2 · os-steve · session_01ADHkmQVWXw7KT8ThxT4CBy 席位核对L1 verdict: ACCEPT · PR #34619 · card #34579 · first review · L1-c of seat repo:objectstack#2 · read 2026-11-17T04:24Z Head-sha: Read from GitHub at this head ( Checklist
Spot checks (mine)
Deviations recorded (not L1 defects)
L2 owed: yes. It is owed at Landing tier: |
|
l2-review#4 · os-steve · session_01ADHkmP44onN8RMzsPMqjRq Contract reviewServed-tier: Inputs read: card #34579 (body and all four comments, including premise correction 6936860860 and the final-head report 6938126740), PR #34619 (body, file list, net diff against Check-runs on this head: every completed run concluded ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Implementing files, sentence by sentence:
Break attempts that did not break it: a carrier with a code outside the ledger, a missing message, a string in place of the object, a blank No must-fix, no should-fix. Nits, both left as accepted deviations (a fix on these files would move the head):
Observation outside the diff, not a finding on this head: Implemented-by: VERDICT: PASS |
…t submitter notice read in the reader's language (objectstack-ai#36846) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB9Gqqp1VYZwEqbXEm1YsTjU)_ Fixes objectstack-ai#36463 Clause-②: yes (widening) Metadata-protocol: none repo:objectstack#3 · os-support-ai · session_01WGufziH9MVhWYLVCiw5eXB ## 维护者速读 - 用户能看到什么变化:提交人自己点「批准」被拒时,审批详情页和审批中心弹出的提示改用用户自己的语言(中文用户整句都是中文);没人能审批时发给提交人的通知,即使列了好几个岗位,也整句按收件人的语言显示。 - 为什么做:属于「审批收尾」这一组工作,补上上一轮留下的两处英文残留。 - 出错会怎样:只影响这两句提示的文字,审批是否被拒、拒绝的规则和已保存的审计记录都不变,可以直接撤回。 - 要你做的:无。 ## Widened door response (Clause-②) The approvals routes (`packages/rest/src/approvals-routes.ts`, all nine that share `handleApprovalError`) now carry a marked `userMessage` at the top level of their flat `{ code, error }` refusal body on any mapped row whose thrown error is marked, the same member objectstack-ai#34619 added for `RESUME_FAILED` on this door and that `ApiErrorSchema` already declares and `@objectstack/client` already lifts. Producers today: the two self-approve decide refusals, both on the `403 FORBIDDEN` row (`excludeSubmitter`, and the override self-approve kept under maintainer ruling 2026-11-17 option B). The member is absent when no producer marked one, so every other refusal body is byte-identical. Additive, so `yes (widening)`, patch, `Metadata-protocol: none` (precedents objectstack-ai#34619, objectstack-ai#35811; L1 S1 7122520696). ## Census - **The console reader that shows a decide refusal.** Two places: - The request page's Approve button is the declared `type: 'api'` action `approval_approve`. Its failure text is read by `refusalEnvelopeMessage` in `ui/packages/app-shell/src/utils/flowResponse.ts`, through `apiActionRefusalResult`. Both callers use it: the `apiHandler` in `useConsoleActionRuntime` and the one in `RecordDetailView`. Before this PR it read only `error.userMessage` of the ADR-0112 envelope. The approvals door answers the flat `{ code, error }` body, so the toast showed the English `error`. - The Approval Center's inline Approve: `humanizeError` in `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx`, called by `inlineApprove`. It answered every `FORBIDDEN` with the generic "You are not allowed to perform this action.", so the remedy was lost. - **Which channel was reused.** A producer marks `userMessage` on the thrown error. The plugin already does this in `lockedError` (`lifecycle-hooks.ts`) and `snapshotQueryRefusal` (`payload-predicate-guard.ts`). The approvals mapper carries it at the top level of its flat body, the member its `RESUME_FAILED` stranded envelope already uses for `userMessage`. `@objectstack/client` lifts `userMessage` from that member too (`errorBody?.userMessage ?? errorBody?.error?.userMessage`). Where this differs from the dispatch: the `declaredUserMessage` block around `recognisedRefusal` relays an engine resume refusal. It is not a producer of approvals' own refusal text, so it was not the pattern used here. - **The two refusals.** Both `excludeSubmitter` and the override self-approve now throw through one local helper, `refuseOwnApproval`. It keeps the `message` byte for byte (the existing English pins are unchanged and green) and sets `userMessage` from `submitterRefusalUserMessage` (`no-approver-note.ts`). That text uses the decider's `readerLabels(context).sentence`, with the position labels from the same `notePositionLabels` read. If the decider asked in no language, or the pack lacks one of the sentences, the whole text is English and names no user id. It is never half one language and half the other. - **The submitter notice.** The messaging layer renders at delivery, per recipient (`NotificationTextRenderer.render`). It resolves a keyed param with `t(key, locale)` and no params, so a hole holds one text or one hole-free key. One list param cannot carry translated clauses, and the plugin cannot compose a list per reader, because the emit does not know the recipient's locale. This falsifies the dispatch's flatten-into-one-param route as stated. The route taken flattens the list into the **sentence** instead. `approvalNoApproverHoldingSlots2` to `…Slots8` are derived in every pack from that pack's own `approvalNoApproverHolding`, `approvalNoApproverSlot` and `approvalNoApproverSlotSeparator`. Each slot is a keyed `typeN` / `valueN` pair, the single-slot shape repeated. Nothing is translated twice, the messaging contract does not move, and the notice reads exactly what the timeline reads for the same slate (pinned for every pack and every size 2 to 8). - **The timeline overlay** (`localizeRoutingNotes`) uses the same `noApproverWho` composition, through `noApproverNoteText(note, labels.sentence, …)`. It already renders any number of slots in the reader's language and is not touched. ## What changes - `packages/plugins/plugin-approvals/src/translations/messages.ts`: - five authored sentences, `approvalDecideRefusedSubmitterExcluded`, `…OverrideOwnRequest`, `…AnotherApprover`, `…OverrideAnotherApprover` and `…OverrideWithdraw`, in all eleven packs; - the derived `approvalNoApproverHoldingSlotsN` sentences, built in `slotListSentences` and added to every shipped locale by `withSlotLists`; - `NO_APPROVER_NOTICE_MAX_SLOTS = 8`. - `no-approver-note.ts`: `noApproverNotice` spells 2 to 8 slots inline (shared `slotParams`). It adds `submitterRefusalUserMessage`. - `approval-service.ts`: the two decide refusals go through `refuseOwnApproval`. Behaviour is unchanged: both still refuse, with the same English `message`. - `packages/rest/src/approvals-routes.ts`: `handleApprovalError` adds `userMessage` (read once through `declaredUserMessage`) to every mapped row when the producer marked one. An unmarked refusal gets exactly the body it had before. - `ui/packages/app-shell/src/utils/flowResponse.ts`: `refusalBodyUserMessage` reads the envelope's `error.userMessage`, else a flat body's top-level `userMessage`. These are the two members the client lifts, through one predicate. - `ui/apps/console/src/pages/system/ApprovalsInboxPage.tsx`: `humanizeError` shows a marked refusal first. - Changeset `.changeset/36463-no-approver-text-in-reader-language.md`, patch for `@objectstack/plugin-approvals`, `@objectstack/rest`, `@object-ui/console` and `@object-ui/app-shell` (private, inert). Prior rulings that govern the edited lines (check-prior-rulings over the touched files; quoted as they stand in the tree): - `[Maintainer ruling 2026-11-17, option B]` on the override refusal: "The objectstack-ai#3424 override never approves a request its actor submitted, whatever `excludeSubmitter` says." Kept exactly. Only the language of its text changes. - `ApiErrorSchema.userMessage` (`packages/spec/src/api/contract.zod.ts`), "ruling record 6819749037, option C: text addressed to the end user comes back in the request's language, composed where it is produced". The `userMessage` is composed in the service, in the decider's language, with `en` as the last rung. - The mapper's `[objectstack-ai#13807, maintainer ruling 2026-09-04 batch objectstack-ai#37]` stranded envelope and the code-anchored prefix strip ("converged here by the 2026-08-31 ruling") are not changed. The stranded spread still comes last. ## First reads (by risk) 1. `packages/plugins/plugin-approvals/src/no-approver-note.ts`: `submitterRefusalUserMessage` (the all-or-nothing English fallback) and the multi-slot arm of `noApproverNotice`. 2. `packages/plugins/plugin-approvals/src/translations/messages.ts`: `slotListSentences`, and the change of `enMessages` into the authored set plus the derived set. 3. `ui/packages/app-shell/src/utils/flowResponse.ts`: `refusalBodyUserMessage`. It is shared by every `type: 'api'` action, so the top-level read is gated by the same `declaredUserMessage` predicate. ## Tests - `no-approver-note.test.ts`: - the two-slot keyed shape; - zh-CN delivery is entirely Chinese, with each position by its pack label or else as stored; - every pack and every size 2 to 8 equals the timeline's sentence; - 9 slots keep one English `who`; - both refusals are entirely Chinese in zh-CN; - every pack composes every refusal with no hole left; - English when there is no reader language, and the whole text is English when a pack lacks any one sentence. - `exclude-submitter.integration.test.ts`: each refusal carries the zh-CN `userMessage` while its `message` keeps the English byte for byte; a decider with no locale gets English that names no id; the control (another approver on the slate) gets the English "another approver" text. - `admin-rescue-named-slate.integration.test.ts`: a two-slot submitter notice goes through the real `NotificationTextRenderer`, entirely Chinese in zh-CN, in Japanese for ja-JP, and with the English literal body unchanged. - `rest-approvals-wire-codes.test.ts`: `403 FORBIDDEN` with `userMessage` at the top level, `ApiErrorSchema` parse green; control: unmarked and blank markings add no member. - `flowLaunch.preDispatchRefusal-36390.test.tsx`: a flat approvals refusal's top-level `userMessage` is the toast, through a real `ActionRunner`; control: an unmarked or blank one shows the `error`. - `ApprovalsInboxPage.inlineActionsVisible-34587.test.tsx`: the inline Approve's failure toast is the marked text; control: the generic line. ## Acceptance notes - **Slates of more than 8 slots.** The notice still names their slots in English inside the recipient's sentence, as every multi-slot notice did before this PR. Naming any number of slots would need a list-shaped keyed param in `@objectstack/service-messaging`, which is outside this card's surface. 8 is a declared constant, and the derived sentences cost one bundle entry per size per pack. - **A deployment override** of `messages.approvalNoApproverHolding` does not reach the derived `…SlotsN` sentences. Those are their own catalog keys and can be overridden the same way. - **The Approval Center's bulk approve** still reports failures by record title only. It shows no reason for any refusal, as before. ## Verification Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec vitest run --maxWorkers=2 src/no-approver-note.test.ts`. Expect every test to pass, including "a zh-CN decider reads each refusal entirely in Chinese, the position by its label". <details><summary>Local readings at 869d5de</summary> - Dependency closure build (`@objectstack/plugin-approvals^...`, `@objectstack/rest^...`): lock VERDICT command-exit 0. - `pnpm --filter @objectstack/plugin-approvals --filter @objectstack/rest typecheck`: VERDICT command-exit 0 (both include `check:test-typecheck`). - Full `@objectstack/plugin-approvals` vitest: Test Files 127 passed (127), Tests 1899 passed (1899). - Full `@objectstack/rest` vitest: Test Files 433 passed (433), Tests 9114 passed, 376 skipped (9490). - UI: `pnpm --dir ui exec vitest run` on the two touched UI test files: Test Files 2 passed, Tests 17 passed. `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed, 2 skipped (174). `pnpm check:new-line-citations` (ui): 0 new, exit 0. - `pnpm check:i18n`: OK, 10 packages, all bundles in sync, exit 0 (after its declared prerequisite build). - Derived gate list (`dispatch-gates.mjs --commands`, 78 commands): 76 exit 0, 2 exit 3 (PREREQUISITE NOT MET, so NOT MEASURED): `check-plugin-teardown-shape --self-test` (shallow checkout) and `check:dual-build-cjs-loads` (needs a full workspace build). `--ran` with exit codes: "78 derived famil(ies) accounted for — 76 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)". - NOT MEASURED: `type-check` of `@object-ui/app-shell` and `@object-ui/console`. Locally every error is TS2307 module-not-found for unbuilt `@object-ui/*` declarations, with none in the touched files. CI `Type Check UI` is the reading. - Ablations, each through `scripts/ablation-replace.mjs` with the restore proven by `git diff HEAD` empty and blob equal to HEAD: - the mapper's `userMessage` spread deleted: `rest-approvals-wire-codes` 1 failed / 15 passed; - the service's `err.userMessage` assignment voided: `exclude-submitter` 2 failed / 23 passed. - `overlap-check --branch=HEAD`: VERDICT clean exit 0. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufziH9MVhWYLVCiw5eXB)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufziH9MVhWYLVCiw5eXB --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Fixes #34579
Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: follow-up #34637
维护者速读
POST /api/v1/approvals/requests/{id}/rejectreturns 500 while its effect lands AND strands the workflow run — three inconsistent outcomes from one call #13807 裁决仍是 500,决定照旧记下;错误体新增innerRefusal(拒绝码和原文)和userMessage(钩子声明的、按调用者语言的那句话),审批人能看到为什么。POST /api/v1/approvals/requests/{id}/rejectreturns 500 while its effect lands AND strands the workflow run — three inconsistent outcomes from one call #13807 B、[Decision] Workflow resume ordering: a thrown node today leaves the run terminally unresumable — which of three shapes, given that the current order buys exactly-once across a crash? #13937 形态 4 两条裁决不动);钩子没拒绝而是崩溃时,两个新字段都不出现。@objectstack/types的StrandedDecisionDetails加两个可选成员,属放宽,需契约复审。What changes
The card's preferred route (dry-run the post-decision step and keep the request pending) conflicts with ruling #13807 B and the #13937 shape-4 ruling. Per the seat's premise correction (comment 6936860860), this PR ships the fallback inside those rulings.
@objectstack/types—StrandedDecisionDetailsgains two optional members:innerRefusal?: FlowInnerRefusal— the engine'sAutomationResult.innerRefusal(ruling B′ on A screen flow whose write node is refused shows the end user the engine's raw node text, in English, with the node id and the object API name ("Node 'create_account' failed: create_record(crm_account) failed: …") #24914), the same member every flow door serves inFLOW_FAILEDdetails;userMessage?: string— the refusal's producer-marked end-user text (the engine'sAutomationResult.userMessage).strandedDecisionDetailsvalidates both (ErrorCodefor the code,declaredUserMessagefor the text) and drops a malformed one while keeping the fourPOST /api/v1/approvals/requests/{id}/rejectreturns 500 while its effect lands AND strands the workflow run — three inconsistent outcomes from one call #13807 facts. The four facts stay all-or-nothing; a refusal member never rescues a partial envelope.@objectstack/plugin-approvals—serviceResumekeeps the engine'sinnerRefusal/userMessagebesideresumeCode/resumeStatusinstead of dropping them, andresumeRecordedOutcomeattaches them to the stranded-decision envelope. Every decision door that resumes throughresumeRecordedOutcome(approve, reject, revise, resubmit, the restored-run continuation) carries them.@objectstack/rest— no logic change:handleApprovalErroralready spreads the recognised envelope into theRESUME_FAILEDbody, so both members reach the wire at the top level. Comment updated.@objectstack/spec—ApprovalDecisionResult.resumeddocblock (contracts/approval-service.ts) names the two members and thefault-edge route. Comment only; no schema or generated artifact moves.Docs —
content/docs/automation/approvals.mdxgains a callout: what the 500 body carries when the step after the decision is refused, and how afaultedge on that step handles it instead.Why
userMessageas well asinnerRefusalMeasured, not assumed: for a hook that declares a
refusalscatalogue, the runtime'sSandboxErrorkeeps the diagnostichook '<name>' threw: …as.messageand puts the declared, localized sentence on.userMessage(resolveHookRefusal/resolveInProcessHookRefusal,runtime/src/sandbox/hook-refusal-catalogue.ts).refusalCarriedBybuildsinnerRefusal.messagefrom.message, soinnerRefusalalone does not give the approver the hook's readable sentence. The flow doors serve the same pair (detailsinnerRefusal+ top-leveluserMessage,flow-dispatch-status.ts), so this reuses that vocabulary and adds none.Why
The engine already reported the refusal on the stranded exit (
run-resume.ts,...readCarriedRefusal(err)), and the approvals door dropped it one line before building the envelope, the same place #13807 foundstatusbeing dropped.Verification
packages/plugins/plugin-approvals/src/hook-refusal-after-decision.test.ts(new): the card's flow end to end with a realAutomationEngine, the realupdate_recordnode and approval node, and a data double that throws a declared hook refusal in the runtime's shape.RESUME_FAILED, decisionapproved, plan stillsubmitted, andstrandedDecisionDetails(err)equals the four facts plusinnerRefusal: { code: 'VALIDATION_FAILED', message }and the hook'suserMessage.faultedge on the step: the refusal is routed to the handler,decideanswersfinalized: true, resumed: true, nothing left parked. (Pins existing engine behaviour; green before and after the fix.)approval-service.tsreverted toorigin/main, case 1 goes red (expected { finalized: true, …(3) } to deeply equal { finalized: true, …(5) }); cases 2 and 3 stay green.packages/rest/src/rest-approvals-wire-codes.test.ts: new case — the 500 body carriesinnerRefusalanduserMessageat the top level, exact key set pinned. The existingPOST /api/v1/approvals/requests/{id}/rejectreturns 500 while its effect lands AND strands the workflow run — three inconsistent outcomes from one call #13807 exact-key-set pins are unchanged and still green.packages/types/src/stranded-decision.test.ts: round-trip, malformed members dropped with the four facts kept, and a refusal member never rescues a partial envelope. The existing "exactly the four declared keys" pin is unchanged and still green.95eae72668321d7f8eb2233f80753911e1202288:dispatch-gates --commandsderived 125; all 125 exit 0;--ranreconcile: 125 run, 0 NOT-MEASURED, 0 UNRUN.plugin-approvals122 files / 1723 tests,types40 / 923,rest419 / 8865 (373 skipped), all green;typecheckgreen fortypes,plugin-approvalsandrest. The second commit only touches the two new/edited test files (an unusedfindOnedropped from the new double forcheck:engine-double-contract, and a module-topimport '@objectstack/objectql'forcheck:test-source-alias) plusscripts/engine-double-contract.pinned.json; both test files re-ran green on the final head.git merge-treeat the final head: clean againstorigin/main(97defd6), feat(spec, runtime, lint, core): a hook writes the sentences it declares in the organization's language (ctx.text) #34545 (df9ac15) and fix(metadata-protocol): a compile-cache bucket opened by a counter move keeps the row sets read within the last bound #34592 (a6661f5).No existing test was changed to accommodate the fix.
Human Minimum
packages/specholds no runtime logic.pnpm lintpasses.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (Comment only; no artifact moves.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmT4f9MMpnjemPU3Esb