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 c19dbcd
Browse filesBrowse the repository at this point in the historyBrowse files
fix(spec): refuse refusals on a hook with no js body, and a {{ }} hole in a refusal message (#26170)
Contract review FAIL-2: a catalogue beside an in-process `handler` (or an
expression body) was saved, its translations demanded by `os i18n`, and never
answered. HookSchema now refuses it at `refusals`, naming the remedy.
A refusal message is plain text; a `{{ }}` hole is refused by a pattern the
published JSON Schema carries too, so a later params slot stays additive.
The liveness note no longer claims the build lowers every handler to a body.
The changeset names @object-ui/i18n and @object-ui/app-shell, which move.
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzfyVQuRsL6SRGuKCem
Copy file name to clipboardExpand all lines: .changeset/26170-hook-refusal-catalogue.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
'@objectstack/objectql': minor
5
5
'@objectstack/cli': minor
6
6
'@objectstack/lint': minor
7
+
'@object-ui/i18n': patch
8
+
'@object-ui/app-shell': patch
7
9
---
8
10
9
11
feat(spec): a hook declares its refusal catalogue, and its body refuses by code, answered in the caller's language
@@ -13,10 +15,11 @@ Metadata-protocol: added
13
15
14
16
A hook can now declare `refusals`: one entry per SCREAMING_SNAKE code, each with the `message` the user reads and an optional 4xx `status` (default `400`). A sandboxed `body` then refuses by code only: it throws an error carrying a declared `code`, and the body runner answers with the entry. The message is translated through `hooks.<hook>.refusals.<CODE>.message` in the caller's locale, the code reaches the caller's error envelope as `declaredCode` (beside the status's registered `code`), and the status is the entry's. The body's own error text and `status` are not what the caller reads.
15
17
16
-
-**Spec.**`HookSchema.refusals` (`HookRefusalSchema`: `message`, `status?`). A new `hooks` group on the translation bundle, `hooks.<hook>.refusals.<CODE>.message`, and `hookRefusalMessageKey`. `HookContext.session.locale` declares the caller's locale.
17
-
-**Undeclared codes are refused loudly.** A code the body throws literally (`{ code: 'X' }`, or `e.code = 'X'; throw e`) that the catalogue does not declare fails the save at `body.source`. Any other undeclared code, and a throw with no code, is a `500` fault at run time that names the hook and the code. This applies only to a hook that declares `refusals`; a hook without one is answered exactly as before.
18
+
-**Spec.**`HookSchema.refusals` (`HookRefusalSchema`: `message`, `status?`). A new `hooks` group on the translation bundle, `hooks.<hook>.refusals.<CODE>.message`, and `hookRefusalMessageKey`. A message is plain text: a `{{ }}` hole is refused at save, so a later parameter slot stays additive. `HookContext.session.locale` declares the caller's locale.
19
+
-**Undeclared codes are refused loudly.** A code the body throws literally (`{ code: 'X' }`, or `e.code = 'X'; throw e`) that the catalogue does not declare fails the save at `body.source`. Any other undeclared code, and a throw with no code, is a `500` fault at run time that names the hook and the code. A catalogue on a hook with no sandboxed `js` body (an in-process `handler`, an expression body) is refused at save, since nothing would answer it. All of this applies only to a hook that declares `refusals`; a hook without one is answered exactly as before.
18
20
-**Runtime.** The body runner resolves the throw against the catalogue and picks the translation through the `i18n` service, negotiated against the locales it holds. An error a `ctx.api` call raised that the body lets leave unchanged, a crash, and the sandbox's own faults pass through untouched. ObjectQL copies the request's locale onto the hook session.
19
21
-**CLI.**`os i18n extract` scaffolds one key per declared entry and `os i18n check` counts them, in a new `hook` coverage bucket.
20
22
-**Lint.** A translation keyed to a hook the stack does not define, or to a code its `refusals` does not declare, is reported as `translation-target-unknown`.
23
+
-**Console.** The translation preview shows a `hooks` category (en/zh labels), and the translation loader lists `hooks` among the spec groups.
21
24
22
25
Nothing to do for existing hooks. To use it, declare `refusals` on a sandboxed hook and throw its codes.
Copy file name to clipboardExpand all lines: content/docs/references/data/hook.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
84
84
85
85
| Property | Type | Required | Description |
86
86
| :--- | :--- | :--- | :--- |
87
-
|**message**|`string`| ✅ | The sentence the user reads when the body throws this code — plain text in the source locale, translated whole through hooks.`<hook>`.refusals.`<CODE>`.message in the caller's locale; no`{{ }}`holes are filled|
87
+
|**message**|`string`| ✅ | The sentence the user reads when the body throws this code — plain text in the source locale, translated whole through hooks.`<hook>`.refusals.`<CODE>`.message in the caller's locale; a`{{ }}`hole is refused|
88
88
|**status**|`integer`| optional | HTTP status the refusal is answered with (4xx; a refusal is never a fault). Absent: 400. A status the body itself sets on the throw is not read — the catalogue decides |
89
89
90
90
@@ -179,7 +179,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
179
179
180
180
| Property | Type | Required | Description |
181
181
| :--- | :--- | :--- | :--- |
182
-
|**message**|`string`| ✅ | The sentence the user reads when the body throws this code — plain text in the source locale, translated whole through hooks.`<hook>`.refusals.`<CODE>`.message in the caller's locale; no`{{ }}`holes are filled|
182
+
|**message**|`string`| ✅ | The sentence the user reads when the body throws this code — plain text in the source locale, translated whole through hooks.`<hook>`.refusals.`<CODE>`.message in the caller's locale; a`{{ }}`hole is refused|
183
183
|**status**|`integer`| optional | HTTP status the refusal is answered with (4xx; a refusal is never a fault). Absent: 400. A status the body itself sets on the throw is not read — the catalogue decides |
Copy file name to clipboardExpand all lines: packages/spec/liveness/hook.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -104,7 +104,7 @@
104
104
"evidence": "packages/runtime/src/sandbox/hook-refusal-catalogue.ts#resolveHookRefusal (the refusal carries the declared `status`, else 400; the status the body set on its own throw is not read)"
105
105
}
106
106
},
107
-
"note": "[#26170, maintainer ruling 6431311681 letter A] Seeded `live` together with its reader: the key, the body runner that answers it, the translation group and the coverage count land in one change (Prime Directive 10). Read on the sandboxed `body` path only; an in-process `handler` is answered as before (the build lowers an inline handler to a `body`, which is the path a served runtime runs). An error a host call raised and the body let through unchanged, a nested hook's refusal, a crash and a sandbox fault pass through untouched. DRILLED to the entry's two keys: the entry face is closed (`.strict()`)."
107
+
"note": "[#26170, maintainer ruling 6431311681 letter A] Seeded `live` together with its reader: the key, the body runner that answers it, the translation group and the coverage count land in one change (Prime Directive 10). Read on the sandboxed `body` path only, so the schema refuses `refusals` on a hook with no `js` body (an in-process `handler`, an expression body): a catalogue nothing would answer is never saved. An error a host call raised and the body let through unchanged, a nested hook's refusal, a crash and a sandbox fault pass through untouched. DRILLED to the entry's two keys: the entry face is closed (`.strict()`)."
0 commit comments