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 da607a7
Browse filesBrowse the repository at this point in the historyBrowse files
docs(spec): a hook's published `body` description says a hook body cannot send mail
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The `body` key of `HookSchema` now states the rule its parse already holds: a `js` hook body granted `email.send` is refused, because a message cannot be taken back if the write that runs the hook rolls back, and mail on a record change goes through an action, a job or a flow. It also says a hook body may add a timeline entry (`activity.append`), which commits or rolls back with the write. The generated hook reference page carries the same sentence. No key, value or check changes; what a hook accepts is unchanged.
The data-hooks reference names the two body doors, `ctx.email.send` (`email.send`) and `ctx.activity.append` (`activity.append`), in its sandbox `ctx` table and capability list. A hook body cannot send mail; mail on a record change goes through an action, a job or a flow. An activity entry's `type` is the app's own value, never a platform type, and the call stays outside `ctx.api.transaction`.
|**body**|`{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }`| optional | Hook body — expression (L1) or sandboxed JS (L2). A hook body cannot send mail: a js body granted email.send is refused, because a message cannot be taken back if the write that runs the hook rolls back; send mail on a record change from an action, a job or a flow. A hook body may add a timeline entry (activity.append), which commits or rolls back with the write.|
Copy file name to clipboardExpand all lines: docs/NORTH-STAR.md
+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
@@ -112,8 +112,8 @@
112
112
113
113
**Priority**:
114
114
1. Security and data integrity always come first and do not wait for the road.
115
-
2. The road broken, or a capability on the checklist broken ⇒ P0/P1; runs but goes wrong ⇒ P2; neither on the road nor on the checklist ⇒ p3 or not taken on. Grading reads "Features on the road": change that table to change priority, ⛔ never re-grade card by card.
116
-
3. While a lane's queue still holds an open P0/P1, that lane dispatches no p2/p3 tooling card or contract-hygiene card; an instrument card that unblocks a product P0/P1 inherits its priority along the chain.
115
+
2. The road broken, or a capability on the checklist broken ⇒ P0/P1; data silently wrong or lost ⇒ P1, subject to the grading rules' reach discount; any other run that goes wrong ⇒ P2; neither on the road nor on the checklist ⇒ p3 or not taken on. Grading reads "Features on the road": change that table to change priority, ⛔ never re-grade card by card — except for one re-grade pass when the grading rules themselves change, and none otherwise.
116
+
3. While a lane's queue still holds an open P0/P1, that lane dispatches no p2/p3 tooling card or contract-hygiene card; a process or tooling card that blocks other work is P2 and carries `pm:blocking`; it does not inherit priority up the chain.
117
117
4. Because AI writes it and AI uses it: the ontology must be writable by AI — what is wrong must be loudly refused with a prescription, never silently stored; and usable by people and agents — declared objects, actions and agent / tool / skill metadata are honoured at runtime, what the MCP surface exposes is what the application really can do, and an agent that oversteps is stopped by permissions and leaves a trace. The half people use has a standard too: an author who writes not one line of UI code gets a UI that looks as if a designer had handled it — one design system, one layout; looking wrong is as much a defect as failing to render, and is refused at the "see it" step. One wrong sentence in the documentation and skills written for AI is a product defect.
118
118
119
119
**Stage posture**: speed over compatibility. Few people use it: a retirement takes effect at once, with no transition window and no alias double-spelling; compatibility layers, migration windows and the like default to p3; keys declared but not honoured are retired in batches per release, not one card per key.
| Runs in | An isolated **QuickJS VM** (edge-safe, capability-gated) | The host process (**full Node**) |
319
-
| Ships as | Plain JSON inside the build artifact — travels everywhere | Lowered at build to a string ref + a sibling `.mjs` runtime module |
320
314
| Status |**Preferred for new code**|**Deprecated** (`HookSchema`: *"prefer `body`"*) |
321
315
| Both present? | Runtime uses **`body`** and ignores `handler`| — |
322
316
323
-
Because a `body` is pure metadata, it is what AI-authored hooks, Studio-authored
324
-
hooks, and any `objectstack build` artifact carry. The rest of this section is
325
-
the contract for that sandbox.
326
-
327
317
### The `body` shape
328
318
329
319
```jsonc
@@ -362,6 +352,8 @@ The sandbox is handed a **JSON snapshot** of these (built by
362
352
|`ctx.api`| object | Cross-object CRUD. Gated by `api.read` / `api.write` — see below. |
363
353
|`ctx.log`|`{ debug, info, warn, error }`| Gated by `log`. Call **`ctx.log.info(msg, data?)`** — `ctx.log` is an **object, not** callable as `ctx.log(msg)`. Emission is **best-effort** (see Troubleshooting). |
364
354
|`ctx.crypto`|`{ randomUUID }`| Gated by `crypto.uuid`. |
355
+
|`ctx.email`|`{ send }`| Gated by `email.send`; not in a hook body. |
356
+
|`ctx.activity`|`{ append }`| Gated by `activity.append`. |
365
357
|`ctx.notice`|`(message) => void`|**Tell the saver what this save set in motion** — answered as the create/update `notice`, shown on the save toast. No capability; insert/update only; last call wins. [`rules/lifecycle.md` § Save Notice](../rules/lifecycle.md#save-notice). |
366
358
|`ctx.title`|`(field?) => Promise<string \| null>`|**Name the record, not its id.**`ctx.title()` resolves this object's `nameField`, a **formula** included (no extra read); `ctx.title('account_id')` resolves a lookup's title (needs `api.read`). `null` when there is no title, never the id. **Per door:**`body` has it; a deprecated `handler` gets it at runtime, undeclared on `HookContext` (TS2339 when annotated) — use `body`; `ql.registerHook` and a bare `ObjectQL``bindHooks` lack it. |
367
359
@@ -431,7 +423,7 @@ single-record form is `update({ id, ...fieldsToChange })` — e.g.
431
423
A body may only touch a `ctx` API it declared in `capabilities`. Calling an
432
424
undeclared one **throws inside the VM** — `capability '<token>' not granted to
433
425
hook '<name>' …` — which surfaces as a hook error (see Troubleshooting). The full
434
-
set of legal tokens (`HookBodyCapability`) is exactly five:
426
+
set of legal tokens (`HookBodyCapability`) is exactly seven:
435
427
436
428
| Token | Unlocks |
437
429
|:--|:--|
@@ -440,6 +432,8 @@ set of legal tokens (`HookBodyCapability`) is exactly five:
440
432
|`api.transaction`|`ctx.api.transaction(async () => { … })` — runs the callback's `ctx.api` ops in **one driver transaction** (commit on return, rollback on throw). Pair it with `api.write`. |
|`email.send`|`ctx.email.send({ to, subject, text })` — mail via the mail service; sender, user and organization are stamped (`BodyMailSendInputSchema`). **Not in a hook body** (refused at parse and at bind): a message cannot be taken back if the hook's write rolls back. Mail on a record change goes through an action, a job or a flow. |
436
+
|`activity.append`|`ctx.activity.append({ object, recordId, type, summary })` — one record-timeline entry; actor and origin are stamped (`BodyActivityAppendInputSchema`). `type` is the app's own, never a `SYS_ACTIVITY_PLATFORM_TYPES` value (403 `PERMISSION_DENIED`, aborting the write under `onError: 'abort'`); never inside `ctx.api.transaction` (409 `RESOURCE_CONFLICT`). Commits or rolls back with the write that runs the body. |
443
437
444
438
There is **no `http.fetch` capability** by design — outbound calls go through
0 commit comments