Skip to content

refusals: one throw answers one declared sentence — an action that refuses a selection for several reasons at once cannot list them in the person's language (after #34273) #36877

Description

@sunhaolin

What

Since #34273 a type: 'script' action can declare a refusals catalogue, and the server answers a refusal in the request's Accept-Language. That works — but one throw answers exactly one declared sentence: one code, at most one reason, one flat params object.

An action that checks a whole selection and refuses all-or-nothing has several things to say at once — one sentence per offending record, each with its own reason and its own values. That answer cannot be expressed through the catalogue, so such an action has to choose between a list in the author's language and a single reason in the person's language.

The resolver is shared with hooks (resolveSandboxedRefusal), so a hook that wants to name several reasons in one refusal meets the same limit. Only the action side was measured.

Where we hit it

HotCRM 6.6.0, crm_expense.submit_for_reimbursement and submit_trip_for_reimbursement (one shared script body). A person selects expenses and submits them; when some cannot go, nothing is submitted and the answer lists why, today as English literals:

Expense Taxi 12 is already on an expense report.
Expense Hotel 7 is already approved.
Travel request TR-00001 is not approved yet. Only an approved travel request can be reported against.
2 selected expenses are not yours, or no longer exist.
Nothing was submitted.

In a zh-CN console the person reads this in English (objectstack-ai/hotcrm#2759). Moving it into refusals is not possible without either dropping the list or leaving it untranslated.

Measured on 18.6.0

Booted stack through @objectstack/verify, POST /api/v1/actions/crm_expense/submit_for_reimbursement, once with accept-language: en and once with zh-CN. Probe catalogue on the action, with zh-CN rows under objects.crm_expense._actions.submit_for_reimbursement.refusals.…:

refusals: {
  PROBE_PLAIN: { message: 'Probe plain sentence.' },
  PROBE: {
    message: 'Probe entry {{ name }} x{{ count }}.',
    status: 409,
    params: ['name', 'count'],
    reasons: {
      on_report: { message: 'Expense {{ name }} is already on an expense report ({{ count | number }}).' },
      approved: { message: 'Expense {{ name }} is already approved.' },
    },
  },
},
The body throws an Error carrying Answer
{ code: 'PROBE_PLAIN' } 400, declaredCode: PROBE_PLAIN; Probe plain sentence. / 探针:普通句子。 — works
{ code: 'PROBE', reason: 'on_report', params: { name: 'Taxi 12', count: 3 } } 409; Expense Taxi 12 is already on an expense report (3). / 费用 Taxi 12 已在报销单上(3)。 — works
params.name = ['Taxi 12', 'Hotel 7'] the array is rendered as JSON: Expense ["Taxi 12","Hotel 7"] is already on an expense report (2).
reason: ['on_report', 'approved'] ignored — the entry sentence, once
reasons: [ … ] ignored — the entry sentence, once
refusals: [ { code, reason, params }, … ] ignored — the entry sentence with empty holes: Probe entry x.
params: [ { … }, { … } ] ignored — holes empty
an undeclared reason or code (computed at run), no code with its own userMessage, a plain Error, an AggregateError 500 INTERNAL_ERROR
a declared code plus its own userMessage and status both ignored; the catalogue sentence and status answer

In source (@objectstack/runtime readRefusalAddress / declaredAnswer): the address read off the error is reason only when it is a non-empty string and params only when it is a non-array object. The template dialect's formatters (upper lower trim number currency percent date datetime truncate default json) have no list or repeat construct, so "one line per record" cannot be written inside one declared sentence either.

Expected

One refusal can name several declared reasons, each with its own params, and the answer carries each one's sentence in the person's language, in the order thrown. For example a throw carrying, under one declared code, an ordered list of { reason, params } — every reason checked against the catalogue as a single reason is today (refused at save when written literally, a fault at run otherwise), each rendered from its translated sentence, the entry's own message available as the closing line (Nothing was submitted.). How the list is shaped on the wire and in the console is yours to rule; the app only needs each declared sentence to arrive translated.

A list formatter in the template would cover the simplest case (the same sentence over several names) but not this one, where the lines have different reasons.

Workaround

None that keeps the rule that no hook or action composes language itself. Once refusals is declared, text outside the catalogue never reaches the person (the rows above), which is the right contract — and the reason the app cannot bridge this. Pre-rendering the lines into a string param leaves the list in the author's language inside a translated frame; refusing on the first problem alone drops the list the person relies on. HotCRM leaves these sentences in English and waits: objectstack-ai/hotcrm#2759 is blocked by this card.

Activity

  1. added
    enhancement
    priority:p2
    pm:queue
    area:i18n
    domain:server
    on Nov 24, 2026
  2. objectstack-fleet commented on Nov 24, 2026

    @objectstack-fleet
    Contributor

    triage#1 · os-warren · session_01JQwxbZKP5YM48rWMWTS7wE

    Triage: lands in area:ux · domain:server · priority:p2 · Feature · pm:queue · size M. area:i18n is not a North Star area. The p2 grade was set by a person, and it stands.
    Rationale: this is a new capability, one refusal naming several declared reasons, each translated. That makes it a Feature. Its purpose is that the person reads every reason in their language, so it sits with the i18n experience work in area:ux. It is the refusal-side twin of #36853, which needs a list-shaped keyed param in service-messaging for approval notices. The claiming seat should look at both together. objectstack-ai/hotcrm#2759 is blocked by this card.

  3. added and removed
    area:i18n
    on Nov 24, 2026
  4. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6Ca6EBDpTBZk8v46Jjv

    Decision inbox · 2026-11-25T23:33Z · zone o5-U (seat repo:objectstack#5)

    • Not claimed. Pre-claim read: the card leaves the contract shape to the platform, verbatim: "How the list is shaped on the wire and in the console is yours to rule". A multi-reason refusal widens the published refusals answer (new throw shape, new wire shape), so the route is a product/contract choice the seat may not take (SKILL.md, escalation: a real split on public contract shape that no existing text settles).
    • Coupled: triage 7124063832 names 审批“无人可批”通知:超过 8 个席位时,席位名仍是英文(需要 service-messaging 支持列表型参数) #36853 (list-shaped keyed param in service-messaging) as the twin; the ruling should say whether one list shape serves both.
    • pm:queue → needs-user-decision. The options, recommendation and four-axis analysis follow from a decision thread (fable); the maintainer rules on this card.
  5. added
    needs-user-decision
    and removed
    pm:queue
    on Nov 25, 2026
  6. objectstack-fleet commented on Nov 25, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6CaacEFVpyQ6C5mcRQs

    Decision analysis · 2026-11-25T23:47Z · decision thread for zone o5-U (inbox 7177747783)

    维护者速读

    • 问题:一个动作一次检查多条记录、整体拒绝时要说好几句话(这条已报销、那条未审批……)。现在的拒绝语目录一次只能回一句,所以 HotCRM 的「提交报销」在中文界面下只能给用户看英文清单。
    • 选项:A 一次抛出可以带多条已登记的原因,每条按用户语言翻译后逐行回出,约 1 个服务端 PR 加 1 个控制台小 PR;B 只给模板加一个「列表」格式器,同一句话套多个名字可以,不同原因混在一起仍不行;C 平台不改,应用只报第一条问题;D 维持现状,HotCRM 继续英文。
    • 推荐 A:拒绝本来就是一组已登记的句子,而不是一句话;用户要看完整清单才知道哪几条要处理。
    • 不定会怎样:HotCRM 的报销提交继续英文,hotcrm#2759 持续挂起;后续其它批量动作(批量审批、批量转移)遇到同样的墙。

    Background

    Since #34273 (PR #34719) an action may declare a refusals catalogue and the server answers a declared code in the caller's locale; since #33214 (PR #33641) an entry may hold several sentences keyed by reason, each with params. The throw address is one reason string and one non-array params object (SandboxRefusalAddress), and declaredAnswer picks exactly one sentence. An all-or-nothing selection check has one sentence per offending record with different reasons, so it cannot be expressed. HotCRM 6.6.0 crm_expense.submit_for_reimbursement keeps English literals (hotcrm#2759 blocked on this card). The resolver is shared with hooks (resolveSandboxedRefusal, resolveInProcessHookRefusal), so any ruling reaches both.

    Governing text

    • packages/spec/src/data/hook.zod.ts docblock (ruling 6431311681 letter A): "A hook's refusal catalogue names every refusal its code may throw. The runtime answers a declared code with the declared message in the caller's locale; it refuses a code the catalogue does not declare, loudly." — grep -n "ruling 6431311681" packages/spec/src/data/hook.zod.ts
    • packages/spec/src/data/declared-entry.zod.ts reasons describe: "Further sentences under this same code, keyed by the snake_case reason the hook throws beside the code ({ code, reason }): { message }. The wire code and status stay this entry's. A reason not declared here is refused loudly." — grep -n "Further sentences under this same code" packages/spec/src/data/declared-entry.zod.ts
    • ADR-0112 amendment 2026-08-17: error.code closed at every door, declaredCode the open sibling, userMessage the sentence for the person; ApiErrorSchema.details: z.unknown() "Additional error context (e.g. field validation errors)" — grep -n "declaredCode\|details:" packages/spec/src/api/contract.zod.ts
    • NORTH-STAR feature row: "② · The whole application speaks the customer's language … notifications land in the right language too · i18n" — grep -n "speaks the customer's language" docs/NORTH-STAR.md

    Protocol

    The catalogue entry schema (message, status, reasons, params) does not change and no translation key changes. What widens is what a body may throw (the address) and what the wire answer carries. Metadata-protocol: added (the body's throw shape is authored metadata; nothing accepted today is refused).

    Premises (each with a re-check)

    1. The address reads reason only as a non-empty string and params only as a non-array object — sed -n 2683,2700p packages/runtime/src/sandbox/quickjs-runner.ts
    2. declaredAnswer renders one sentence per throw — sed -n 383,413p packages/runtime/src/sandbox/hook-refusal-catalogue.ts
    3. The template dialect has no list/repeat construct (formatters are scalar) — sed -n 2270,2282p packages/formula/src/validate.ts
    4. The wire carries userMessage: string and details: unknown; the console shows a refusal's first sentence with the rest behind "More" — grep -n "userMessage\|details:" packages/spec/src/api/contract.zod.ts; sed -n 10,20p ui/packages/app-shell/src/components/RefusalMessage.tsx
    5. Twin 审批“无人可批”通知:超过 8 个席位时,席位名仍是英文(需要 service-messaging 支持列表型参数) #36853 is a different layer: NotificationTextRenderer resolves a keyed param with t(key, locale) and no params — grep -n "t(key" packages/services/service-messaging/src/notification-text.ts
    6. Both run paths (sandboxed body, in-process handler) answer through one declaredAnswer and are pinned byte-identical (PR feat(spec,runtime): hook refusals on handler hooks, with declared reasons and params #33641) — grep -n "declaredAnswer(" packages/runtime/src/sandbox/hook-refusal-catalogue.ts

    The question in one sentence

    When an action refuses a whole selection for several different reasons, the person reads either one translated sentence or an English list; nothing lets every reason arrive in their language.

    Options × real cost × workload

    What What the person sees Workload
    A One throw may carry an ordered list of declared reasons, each with its own params, under one declared code: { code, reasons: [{ reason, params? }, …] }. Each reason is checked against the catalogue exactly as a single reason is today (undeclared literal refused at save; undeclared at run ⇒ 500 fault for the whole throw). Each sentence renders translated; userMessage is the sentences joined by newline, with the entry's own message as the closing line when a list was thrown; details.refusals: [{ reason, message }] carries the list structured. Console renders a multi-line userMessage as a list. Hooks get it through the shared resolver. Every line in their language, in the order the body chose; the closing line ("Nothing was submitted.") last. domain:server 1 PR, size L (runtime address + resolver + spec literal-reason reader + lint + docs + parity tests). Precedent: PR #33641 (+2110/−174, reasons+params+handler path, wider than this); PR #34719 (+2037/−316). Estimate well under either. domain:ui 1 PR, size S (RefusalMessage lines → list), no measured precedent.
    B A list formatter in the template ({{ names | list }}) only. Same sentence over several names translates; different reasons in one answer still cannot. HotCRM's case is not covered. domain:server 1 PR, size M (formula formatter + i18n list join). No precedent. Does not close the card.
    C Platform unchanged; the app refuses on the first offending record only. One translated sentence; the person fixes one record, resubmits, meets the next. 0 platform PRs; HotCRM rewrites its action.
    D Status quo; the app pre-renders the list into a string param, or keeps English literals. English lines inside a translated frame, or all English. 0 PRs; violates the rule that no action composes language; hotcrm#2759 stays blocked.

    Business translation: A = a validation result is a list of findings (as a bulk save returns per-record errors on every mainstream platform); B = a nicer sentence for one kind of problem; C = one problem at a time, more round trips; D = a Chinese UI that speaks English in its most frequent batch action.

    Four axes (business stance)

    • Real business need (②) — measured: HotCRM 6.6.0 expense submission answers five English lines to a zh-CN user; hotcrm#2759 is blocked on this card; the same downstream app already moved 83 hook refusals and two action refusals into catalogues (actions: an action body has no refusal catalogue — a person-facing throw from an action stays in the author's language #34273 body). Every batch action (bulk approve, bulk reassign, bulk close) has the same shape, so this is a class, not one screen.
    • Long-term fit (①) — a refusal is a set of declared sentences, not one. Two years out, the platform's refusal answer reads: one declared code, an ordered list of declared reasons each in the person's language, structured on the wire so an agent (MCP) and the console can both list them; this is how bulk DML results and RFC 9457 problem-detail errors[] are modelled elsewhere. A is an array of what already exists (declared reasons + params), under the existing details channel; B invents a second expressive channel inside sentences; C/D leave a hole every batch action falls into.
    • AI-error-proofing (③) — with A every sentence stays in the catalogue: an AI that writes an undeclared reason meets a publish refusal (literal) or a loud 500 (computed); the person never sees untranslated prose. With D the AI's natural move is params: { lines: '…English…' } and the English ships silently inside a translated frame. With B/C the AI keeps writing throw new Error(list). A is the loud option.
    • Startup focus (④) — A adds no catalogue key, no translation key, no gate, no new formatter grammar; it widens one throw shape and one wire field that already exists (details). B adds grammar that does not close the case.

    os-decision-facets
    ① Long-term fit: A reuses declared reasons/params and the existing details channel; no new concept, one shape widened (list of what exists).
    ② Business pull: HotCRM 6.6.0 expense submit, hotcrm#2759 blocked; every all-or-nothing batch action has the same shape.
    ③ AI-error-proofing: every line stays catalogue-declared, undeclared ⇒ save refusal / loud 500; the alternative is English inside a translated frame, silently.
    ④ Startup focus: no new key, no new translation key, no gate; B would add template grammar without closing the card.
    Prior rulings read: refusal · refusals · 36853 · multi-reason → 0 hits in coordinator/rulings.md and decisions/待决汇总.md; ADR-0112 amendment (declaredCode/userMessage) read; rulings 6431311681 A and 6879477573 A read in hook.zod.ts; thread: none.

    Recommendation: A

    Self-check: 只看①选 A;②③④ 是否翻转:否。

    Confidence gaps: (a) hotcrm's action source is not in this container; the five lines are taken from the card's probe table on 18.6.0. (b) The console half (list rendering) has no measured precedent; it is a small change to RefusalMessage. (c) Whether MCP's refusal envelope relays details is not re-measured here; the dev checks it on claim.

    Not taken: B does not cover different reasons in one answer; C trades the list the person relies on for round trips; D breaks the one rule that makes translation possible.

    Twin #36853

    Different layer (notification text, service-messaging keyed params), different card (Bug, pm:queue, Blocked-by #36846). It stays its own card. Shared only in principle: both join a list per locale; if the dev of either finds a reusable per-locale list join in @objectstack/spec i18n helpers, both use it. Not a requirement of this ruling.

    Execution after the ruling (A)

    1. Zone o5-U claims refusals: one throw answers one declared sentence — an action that refuses a selection for several reasons at once cannot list them in the person's language (after #34273) #36877 (domain:server, size L, mode:subagent or thread by the runbook). Dispatch premise: the dev re-runs premises 1–6 first; a failed premise reports a fork.
    2. Server PR: (a) the sandbox address accepts reasons: [{ reason, params? }] beside the existing reason/params form; both on one throw ⇒ fault; (b) declaredAnswer checks every listed reason against the entry; one undeclared ⇒ the whole throw is the loud fault, naming the reason; (c) each sentence renders translated and param-filled as today; userMessage = lines joined by \n, the entry's message appended as the last line only when a list was thrown; details.refusals: [{ reason, message }]; (d) the spec literal reader (hookRefusalReasonsThrownIn and the action twin) reads reasons inside an array literal too; lint unchanged otherwise; (e) parity pin: sandboxed body and in-process handler answer byte-identical for a list throw (PR feat(spec,runtime): hook refusals on handler hooks, with declared reasons and params #33641 pattern); (f) Clause-②: yes, Metadata-protocol: added, Skills-docs: follow-up for skills/objectstack-data/references/data-hooks.md and skills/objectstack-ui/rules/actions.md.
    3. UI follow-up card under refusals: one throw answers one declared sentence — an action that refuses a selection for several reasons at once cannot list them in the person's language (after #34273) #36877 (domain:ui, size S): RefusalMessage renders a multi-line userMessage as a list in the same alert box (first line no longer hides the rest behind "More").
    4. hotcrm#2759 unblocks on the release that carries the server PR.
  7. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6CaacEFVpyQ6C5mcRQs

    Ruled: 2026-11-26T00:03Z · option A — one throw carries an ordered list of declared reasons, each translated.

    • Authority: Bill (os-bill), decision card in the project app at 2026-11-26T00:01Z, option verbatim 「A 一次抛多条原因逐行翻译」; analysis and options in comment 7178064820 (decision thread, fable).
    • Governing text: hook.zod.ts docblock (rulings 6431311681 A, 6879477573 A); declared-entry.zod.ts reasons describe; ADR-0112 amendment (declaredCode / userMessage / details).
    • Ruled terms (execute as comment 7178064820 §"Execution after the ruling (A)"): (1) throw shape { code, reasons: [{ reason, params? }, …] } beside the existing single reason/params form; both on one throw ⇒ fault. (2) Every listed reason is checked against the entry: an undeclared literal is refused at save, an undeclared reason at run makes the whole throw the loud 500 fault naming it. (3) Each sentence renders translated and param-filled as today; userMessage = the lines joined by \n, the entry's own message appended as the last line only when a list was thrown; details.refusals: [{ reason, message }] carries the list structured. (4) Hooks share it through the one resolver; sandboxed body and in-process handler answer byte-identical (parity pin). (5) Catalogue schema and translation keys unchanged; Clause-②: yes, Metadata-protocol: added, Skills-docs: follow-up owed. (6) Console: a ui follow-up card under this one renders a multi-line userMessage as a list in the alert box.
    • Premise clause: the dev re-runs premises 1–6 of comment 7178064820 before writing; a failed premise is reported as a fork, not worked around and not quietly switched to another option.
    • Twin 审批“无人可批”通知:超过 8 个席位时,席位名仍是英文(需要 service-messaging 支持列表型参数) #36853 stays its own card (notification layer); not folded.
    • State: needs-user-decision → pm:queue in this write; zone o5-U (seat repo:objectstack#5) claims.
  8. added
    pm:queue
    and removed
    needs-user-decision
    on Nov 26, 2026
  9. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6Ca6EBDpTBZk8v46Jjv

    Claim: PM loop round 1 · zone o5-U (area:ux p1/p2; the maintainer, verbatim, 2026-11-25T23:27Z project thread: 「再开两个专区,接ai ux 的 p1 p2 任务」) · 2026-11-26T00:57Z
    Session: session_01Utp6Ca6EBDpTBZk8v46Jjv
    Thread session: session_01Utp6CXvMJTCqCs1b69pCH7
    Account: os-bill
    Area: o5-U
    Branch: claude/project-thread-t35ilq
    Worktree: objectstack-issue-36877
    Domain: domain:server
    Seat: repo:objectstack#5
    File surface: packages/runtime/src/sandbox/** (address reader, hook-refusal-catalogue.ts declaredAnswer, the in-process twin), the spec literal readers hookRefusalReasonsThrownIn and the action twin (packages/spec/src/data/hook.zod.ts, hook-refusal-codes.ts, packages/spec/src/ui/action.zod.ts) with their tests, liveness rows and regenerated spec artifacts, parity pins, root .changeset/. Not ui/** (ruling term 6 card), not service-messaging (#36853), not skills/**, not the catalogue schema. Stop on breach and report.
    Container & model: L, mode:thread, model: default — dispatch-gates --tier: "no path-derived mandate" (served claude-opus-5-5 per the thread's first report), effort: high
    Clause-②: yes
    Metadata-protocol: added
    Responsibility: n/a — not a defect card
    Thread-read: 7178348458
    Premise: holds as ruled — premises 1–6 of the analysis 7178064820 carry re-check commands; the thread re-runs them before writing, a failed one is a fork (ruling 7178348458)
    Serial constraints cleared: no open PR touches packages/runtime/src/sandbox/** or the named spec readers at claim; twin #36853 stays separate (ruling)
    Pre-claim lane: domain:server (packages/runtime) plus the spec literal readers, kept in lane per area-lease 留道; L2 contract review owed (Clause-② yes)
    Pre-claim deps: none
    Prior rulings read: ruling 7178348458 (option A, Bill 2026-11-26T00:01Z); governing text hook.zod.ts docblock (rulings 6431311681 A, 6879477573 A), declared-entry.zod.ts reasons, ADR-0112 amendment
    Skills-docs: follow-up owed — skills/objectstack-data/references/data-hooks.md, skills/objectstack-ui/rules/actions.md (filed by the zone before ACCEPT)

  10. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 26, 2026
  11. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    Contributor

    repo:objectstack#5 · os-bill · session_01Utp6Ca6EBDpTBZk8v46Jjv

    Claim amendment · 2026-11-26T00:59Z · zone o5-U · #36877 (claim 7179289156)
    File surface widened: packages/types/src/thrown-http-error.ts (resolveThrownHttpError), packages/types/src/data-error-classification.ts (mapDataError / withDeclaredUserMessage), one shape reader for a refusals list of { reason, message } beside userMessage (the candidates precedent), and their tests.
    Why: ruling 7178348458 term (3) puts details.refusals on the wire; each door builds details from a closed set of fields read in @objectstack/types, so the term cannot be met from packages/runtime/src/sandbox/** alone (card thread reading, premises 1–6 re-run on d558de0a). Same lane (domain:server covers types); no new error code; no spec schema change. No open PR touches either file at this amendment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:uxdomain:serverenhancementpm:dispatchedpriority:p2

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions