You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 4031cd5
Browse filesBrowse the repository at this point in the historyBrowse files
feat(spec)!: read a thrown reasons list only as a direct member, and declare the narrowing it brings
The save reader now takes a `reasons: [` list only when it is a direct
member of the thrown object literal, the one key the run reads; a list
nested under `params` is the body's own data, as before (control pins on
both save checks). Two docblocks now say what the code does: a reason
reaches the wire as the label of a rendered line, and a listed reason is
read under every code.
The changeset declares the narrowing (`Clause-②: yes (narrowing)`,
`Metadata-protocol: narrowed`) with its BREAKING banner, the FROM → TO
migration for the three sources now refused, and the ADR-0087 semantic
entry it registers. It no longer claims `details.refusals` keeps every
sentence: the closing line is only on `userMessage`, which `/data` bounds.
Claude-Session: https://claude.ai/code/session_01Utp6CXvMJTCqCs1b69pCH7
Co-authored-by: Claude <noreply@anthropic.com>
**BREAKING** accept-set narrowing beside a widening, shipped as `minor`. The widening is the new `reasons` list below. The narrowing is what that list makes of a `reasons` key that was ignored before: three sources that save and run on the previous release are refused now (see the migration at the end).
11
15
12
16
A hook or a `script` action that declares `refusals` can now refuse with several declared sentences at once, for example when it checks a whole selection and refuses all of it. Under one declared code it throws an ordered list of the code's declared reasons, each with its own `params`, instead of one `reason`:
- Each listed reason's sentence is picked in the caller's locale and its holes are filled from that reason's own `params`, as a single reason's sentence is. The answer's `userMessage` is those sentences joined by a line break, in the order thrown, then the code's own `message` as the last line (its holes are filled from the throw's top-level `params`). The code's status and the code on the wire are unchanged.
22
-
- Every door that answers the refusal also carries the sentences structured, as `details.refusals: [{ reason, message }, …]`. The `/data` door bounds `userMessage` at 500 characters as before; `details.refusals`keeps every sentence whole.
23
-
- Every listed reason must be one the code declares under `reasons`. One that is not makes the whole throw the loud `500` fault naming the hook or action, the code and the reason. Under a code that declares no `reasons`, every listed reason is undeclared. A literal list in the source (`throw { code, reasons: [{ reason: 'x' }] }`, or `e.reasons = [{ reason: 'x' }]` on an error the body throws) is refused when the hook or action is saved.
26
+
- Every door that answers the refusal also carries each listed reason's sentence structured, as `details.refusals: [{ reason, message }, …]`. The `/data` door bounds `userMessage` at 500 characters as before, and `details.refusals`is not bounded, so each listed line stays whole there. The closing line (the code's own `message`) is not on `details.refusals`: on a list long enough that `/data` cuts `userMessage`, the closing line is lost on that door. A client that renders the list reads the lines from `details.refusals`.
27
+
- Every listed reason must be one the code declares under `reasons`. One that is not makes the whole throw the loud `500` fault naming the hook or action, the code and the reason. Under a code that declares no `reasons`, every listed reason is undeclared. A literal list in the source (`throw { code, reasons: [{ reason: 'x' }] }`, or `e.reasons = [{ reason: 'x' }]` on an error the body throws) is refused when the hook or action is saved. Only a `reasons` key that is a direct member of the thrown object is a list; one nested deeper (`params: { reasons: [ … ] }`) is the body's own data, as before.
24
28
- A throw that carries both a `reason` and a `reasons` list, an empty list, or a `reasons` value that is not a list of `{ reason, params? }` is the same loud fault.
25
29
- The sandboxed body and the in-process hook handler read the list the same way and answer byte-identically.
26
30
27
31
The catalogue entry (`message`, `status`, `reasons`, `params`) and the translation keys do not change, so no `os i18n` key is added. A throw with one `reason`, or none, is answered exactly as before.
28
32
29
33
New exports: `@objectstack/spec` adds `isUndeclaredThrownReason`, `unreadableHookRefusalListAtRun`, `unreadableActionRefusalListAtRun` and the `HookRefusalThrownReason` and `RefusalListProblem` types (`data`); `hookRefusalReasonsThrownIn` now answers `HookRefusalThrownReason[]` (a listed pair carries `listed: true`). `@objectstack/types` adds `declaredRefusalLines` and the `DeclaredRefusalLine` type. `@objectstack/runtime` adds no export; its `SandboxError` gains an optional `refusals`, the list the doors read.
34
+
35
+
**Migration (FROM → TO).** Each row was accepted and answered as if the `reasons` key were absent; it is refused now.
36
+
37
+
| FROM (accepted before, refused now) | Where it is refused | TO |
38
+
|:---|:---|:---|
39
+
| A literal `throw { code: 'X', reasons: [{ reason: 'y' }] }` where `X` declares no `reasons` (a literal `y` under a code that declares `reasons` without it was already refused) | At save: `HookSchema` / `ActionSchema` at `body.source` (the metadata save door, `defineStack`, `os validate`, compile, an artifact's parse) | Declare `reasons` on `X` with `y` and its `message`, or remove the `reasons` key |
40
+
|`e.code = 'X'; e.reasons = [{ reason: 'y' }]; throw e` with `y` undeclared under `X`| At save, as above | Declare `y` under `refusals.X.reasons`, or remove the `e.reasons` assignment |
41
+
| A body that throws a declared code with a `reasons` property of its own: an empty list, a value that is not a list of `{ reason, params? }`, a list beside a `reason`, or a list naming an undeclared reason | At run: the loud `500` fault naming the hook or action and the code, where the declared sentence and status answered before | Rename the body's own property (for example to `items`, or put it under `params`), or throw it as the declared list |
42
+
43
+
One-line fix: a `reasons` key on a thrown refusal is now the declared list, so name only reasons the code declares there, or rename the key.
0 commit comments