Repository navigation
feat(rest): the cross-object batch refusal names the failing operation, and a multi-pick related-list add names that record - #35811
Conversation
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…peration Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…rd the server's refusal points at Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
…eration Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ
📓 Docs Drift Check3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 19 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 d9e6d20f4a8e07a7f6fa9b4ab0f52c41151bc992 && git checkout d9e6d20f4a8e07a7f6fa9b4ab0f52c41151bc992
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7878cf0557737ecfde78dfa9cff7a1046a289a4a d6b03538fc4843e560c83ded2038f5c9fd938bc2 && git checkout -B drift-repro 7878cf0557737ecfde78dfa9cff7a1046a289a4a && git merge --no-ff d6b03538fc4843e560c83ded2038f5c9fd938bc2
node scripts/docs-audit/affected-docs.mjs --json 7878cf0557737ecfde78dfa9cff7a1046a289a4a |
|
repo:objectstack#5 · os-bill · session_01Utp6CXsZsKmgG1EcKp5bY4 维护者速读
席位核对ACCEPT · head Routing: Checked:
For the L2 (ux-2's two questions):
Required before landing:
No other item. |
|
repo:objectstack#5 · os-bill · session_01Utp6CbUb7TcZK1XUAddUmQ Seat contract note — PASS · head
|
|
repo:objectstack#5 · os-bill · session_01Utp6CZrgaiMgTJCnswR6jQ Landing · area ux-2 · 2026-11-20T09:44Z
State: draft → ready + auto-merge (merge queue). |
…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>
Fixes #35726
Part of #35601
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
Server (
@objectstack/rest,batch-routes.ts). A refusal of the cross-objectPOST {basePath}/batchnow carriesfailedOperation: { index, object }besideerror/code/userMessagewhen ONE op is the cause:update/deleteop refused up front for naming no row (400 VALIDATION_FAILED, therequires an idrefusal);404 RECORD_NOT_FOUND,400 VALIDATION_FAILEDfrom a validation rule or a required field,409 RESOURCE_CONFLICT), an unresolved$ref(400 BATCH_UNRESOLVED_REF), or a fault.It is absent on a refusal of the request as a whole (schema
VALIDATION_FAILED,BATCH_NOT_ATOMIC,BATCH_TOO_LARGE, the501 NOT_IMPLEMENTEDno-transaction answers), on the two object-level gates (API exposure and the API-key management rule, judged once per object and action, so no single op is the cause), and on a failure after the last op ran (the commit). The in-transaction case goes through the shared error door unchanged (handleRouteError): a thin response wrapper adds the one key to the body the door wrote, so status, code, sentence anddetails.candidatesare the door's.Unchanged: the success body, the all-or-none outcome (ADR-0119 D4, ADR-0035 section 5), the
#14147option C create routing and the A-prime update-response comment blocks (no line in either was edited), every other route.Spec. No spec edit. The cross-object batch's refusal envelope is not declared in
packages/spec:CrossObjectBatchResponseSchemadeclares the success body only, the error-code ledger declares codes, not body keys, and the route ledger row named/batch(DEFAULT_BATCH_ROUTES) is the per-object/data/:object/batchdoor. Declaring a new refusal schema would be a new export, which this card did not rule on (see Acceptance notes).Client pass-through. No client edit.
@objectstack/clientalready hands a flat refusal body with nodetailsof its own over aserr.details, andObjectStackAdapter.batchTransactionrethrows that error as it is, so the key reaches the console aserr.details.failedOperation.Console (
@object-ui/plugin-detail,RelatedList.tsxhandleAddRecordsonly). The add keeps the picked record behind each op, index-aligned with the ops it sends (a pick with no value is skipped, so pick index and op index can differ). On a refusal whosefailedOperation.indexfalls inside the ops sent, the inline error readsLABEL: REASON, where LABEL is the record's value in the picker's display field (add.picker.labelField, elsename, as the picker shows it; the picked id when that is empty) and REASON is today's message. Without such an index the inline error is the server's reason alone, as before.Why
PR #35725 made a multi-pick related-list add one atomic batch: all rows or none. Its refusal then repeated the server's sentence, which names the record for a not-found or permission refusal but only the field for a validation refusal, so a reader of a three-pick add could not tell which pick failed.
Tests
packages/rest/src/cross-object-batch-failed-operation.test.ts(new, realObjectQL+ SQLiteSqlDriver+ real protocol + real route): 3 ops whose 2nd addresses no row answers404 RECORD_NOT_FOUNDwithfailedOperation: { index: 1, object: 'fop_beta' }and both tables empty; 3 ops whose 2nd misses a required field answers400 VALIDATION_FAILEDwith index 1 and both tables empty. CONTROLS: a committing 3-op batch has nofailedOperation;atomic: false(BATCH_NOT_ATOMIC) names no op. The route has no non-atomic run to pin:atomic: falseis refused before any op runs.packages/rest/src/rest-batch-blank-id.test.ts: the exact-body pins of the missing-id refusal now carryfailedOperation, index 0 for a one-op batch and index 1 for the create-then-blank-update batch.packages/rest/src/rest-batch-endpoint.test.ts: the package-scoped409exact-body pins carryfailedOperation: { index: 0, object: 'account' }besidedetails.candidates.ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx: a 3-pick add whose refusal names op 1 showsBravo: Field 'title' is required(not Alpha, not Charlie), sends one batch and does not re-read the list. CONTROLS: nofailedOperation, and an index outside the ops sent, each show the server message alone.Every reading below was taken in this worktree on
objectstack-ai/objectstack, branch base1e018d6ed.rest: targeted batch files, full package suite, typecheck
pnpm --filter @objectstack/rest exec vitest run --maxWorkers=2over the six cross-object batch files (new file, blank-id, no-rollback driver, exposure, API-key credential, request refusal fields):Test Files 6 passed (6),Tests 49 passed (49), lockVERDICT command-exit 0.vitest run --project local --maxWorkers=2atc6fe2c39(before the package-scoped pins were updated):Test Files 1 failed | 422 passed (423),Tests 9 failed | 8623 passed | 351 skipped; the 9 were exactly the package-scoped exact-body pins inrest-batch-endpoint.test.ts, which this PR updates. After the update:rest-batch-endpoint+ new file + blank-idTest Files 3 passed (3),Tests 56 passed (56).d6b03538,vitest run --project local --maxWorkers=2:Test Files 423 passed (423),Tests 8632 passed | 351 skipped (8983), lockVERDICT command-exit 0.pnpm --filter @objectstack/rest typecheck(tsc +check:test-typecheck):VERDICT command-exit 0,0 file(s) / 0 error(s)in the test-typecheck debt.plugin-detail: target file, full package, type-check
pnpm --dir ui exec vitest run --maxWorkers=1 packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx:Test Files 1 passed (1),Tests 16 passed (16)(13 before, 3 new).pnpm --dir ui exec vitest run --maxWorkers=1 packages/plugin-detail/:Test Files 391 passed | 1 skipped (392),Tests 3568 passed | 18 skipped (3586), lockVERDICT command-exit 0.pnpm --filter @object-ui/plugin-detail type-check(after building its dependency closure):VERDICT command-exit 0.Ablations (scripts/ablation-replace.mjs, one per pin, each restored)
Both subjects resolve from source (the rest test imports
./rest-server, the UI test imports../RelatedList), so nodist/leg applies.failedOperation = { index, object: op.object };replaced with a comment,anchor 1 -> 0, blobf321bb114e1e -> c9a261104266. Run:Tests 2 failed | 2 passed (4), the two index-1 cases red, both controls green. Restore:blob == HEAD (f321bb114e1e) and git diff HEAD is empty.const failedIndex = err?.details?.failedOperation?.index;replaced withconst failedIndex: unknown = undefined;, blobacdaba8815ce -> 11bd61acb2ea. Run:Tests 1 failed | 15 passed (16), the naming case red, both controls green. Restore:blob == HEAD (acdaba8815ce) and git diff HEAD is empty.Gates (dispatch-gates --commands, narrowed by this diff)
node scripts/check-plugin-teardown-shape.mjs --self-test(the shallow clone cannot reach its pinned positive-control commit) andpnpm check:dual-build-cjs-loads(reads built output of every package; this worktree built only the two closures). CI runs both.pnpm check:route-envelopeexit 0 (the batch module's dialect counts did not move),pnpm check:doc-authoringexit 0,pnpm check:type-check-debtexit 0,pnpm --dir ui exec vitest run scripts/Tests 5092 passed | 2 skipped.dispatch-gates --ranreconciliation:72 derived, 70 run, 2 NOT-MEASURED, 0 UNRUN(the 2 derived from a recorded exit 3).node scripts/check-platform-checklist.mjs --changed-from origin/main: OK, 0 anchors lost.check-nul-bytesexit 0.Acceptance notes
405/403 OBJECT_API_DISABLED, the API-key management403) carry nofailedOperation. They are judged once per object and action, so naming the first op would make the related-list add name one picked record for a refusal that holds for every pick; andbatch-op-exposure-object-read.test.tspins the exposure body equal to the bulk data door's.details(the package-scoped409withdetails.candidates) keepsfailedOperationon the body, but@objectstack/clientexposes only thatdetailsaserr.details, so the console shows the reason alone there. Reaching it would take a client-side read of the raw body, which the client does not keep; not done here.packages/spec(see What changes). Declaring aCrossObjectBatchErrorSchemawould be a new public export and a contract decision, so it is reported, not done.ObjectStackAdapter.batchTransactionon a backend that does NOT declarecapabilities.transactionalBatchtreats a404as "no batch endpoint" and falls back to the non-atomic emulation, so on such a backend a404 RECORD_NOT_FOUNDrefusal is read as a missing endpoint and the ops are replayed through that emulation, which carries nofailedOperation. Documented legacy behaviour for pre-capability backends; not changed.origin/mainwas not merged before opening: it moved 187 files past the base, none of them a file this diff touches (batch-routes.ts, the three rest test files,RelatedList.tsx, its test). The PR CI runs on the merge ref.Verification
Read first, by risk:
packages/rest/src/batch-routes.ts:namingFailedOperationand the twofailedOperationassignments inrunOps(set per op, cleared after the loop).ui/packages/plugin-detail/src/RelatedList.tsx:handleAddRecords, theopPicksalignment and the catch block.packages/rest/src/cross-object-batch-failed-operation.test.ts.Two-minute check:
pnpm --filter @objectstack/rest exec vitest run src/cross-object-batch-failed-operation.test.tsprintsTests 4 passed (4).Human Minimum
packages/specholds no runtime logic.pnpm lintpasses. (No formatter ran;pnpm lintis CI's run.)main, one pull request. (Branched offmainat1e018d6ed; not re-merged before opening, see Acceptance notes.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code