Skip to content

Commit efbf75c

Browse files
committed
chore(spec): ledgers name the body door record type and the caller-scope read
Clause-②: no Metadata-protocol: none Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwV8gsjrvCXCqKoaiG
1 parent 6fa971f commit efbf75c

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎.changeset/body-mail-activity-doors.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Metadata-protocol: added
1717

1818
- **`@objectstack/spec`:** two new body capabilities, `email.send` and `activity.append`, and their inputs `BodyMailSendInputSchema` and `BodyActivityAppendInputSchema` (`@objectstack/spec/data`). The sender, the sending user, the organization, the actor and the origin are stamped by the platform and are not inputs: a key outside either shape is refused. `SYS_ACTIVITY_PLATFORM_TYPES` names the timeline types only the platform records.
1919
- **`@objectstack/runtime`:** a hook, action or job body that declares the capability calls `ctx.email.send({ to, subject, text })` or `ctx.activity.append({ object, recordId, type, summary })`. A message is sent from the configured sender, as the calling user, under the caller's organization; a timeline entry is written with the calling user as its actor and the package and body as its origin. A record the call points at must be one the caller can read. A message names at most 50 recipients, and an organization's mail is held to `OS_EMAIL_APP_SEND_HOURLY_LIMIT` messages an hour (default 200) before the door refuses another. A body with no calling user (a job) sends and writes with no user recorded.
20-
- **`@objectstack/cli`:** the build infers both capabilities from a handler's calls, under a renamed or destructured context too.
20+
- **`@objectstack/cli`:** the build infers both capabilities from a handler's calls, under a renamed or destructured context too. `ExtractedBody.capabilities` on `@objectstack/cli/hook-body` may now hold `'email.send'` and `'activity.append'`.
2121
- **`@objectstack/core`:** the bounds a caller-sent message is held to (the sending user, the organization, the configured sender) are one function, `boundCallerMail`, shared by the REST mail door and the body door.
2222
- **`@objectstack/rest`:** the REST mail door reads its bounds from `boundCallerMail`; its answers are unchanged.
2323
- **`@objectstack/plugin-email`:** a mail-log row the mail service did not write is delivered from the configured sender.

‎content/docs/permissions/system-context.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,16 @@ One of the largest consumers of the flag;
223223

224224
### 6. Reads that only carry the flag onward
225225

226-
Not behaviours: these four sites read the flag solely to copy it into another
227-
context or envelope. They are listed because the census counts them, and because
226+
Not behaviours: these five sites read the flag solely to copy it into another
227+
context or envelope, or to take it off one. They are listed because the census counts them, and because
228228
a reader tracing where elevation travels needs them.
229229

230230
| # | Symbol | Package | What it does |
231231
|:--|:---|:---|:---|
232232
| 63 | `buildSession` | objectql | Propagates `isSystem` into the hook session so hooks can tell engine self-writes from user writes |
233233
| 64 | `isSystem` | objectql | `ScopedContext.isSystem` getter — re-exposes the underlying execution context's flag |
234234
| 65 | `executionContextFromHook` | runtime | Rebuilds an `ExecutionContext` from a hook session, carrying the flag across |
235+
| 65b | `callerScopeOf` | runtime | Takes a script body's own elevation off its caller's envelope (the app-automation mark and the flag it came with), so `ctx.email.send` and `ctx.activity.append` read the record a body points at in the caller's scope. It removes the flag and grants nothing |
235236
| 66 | `toolCallPrincipalOf` | mcp | Projects the host's resolved `ExecutionContext` into the frozen principal an installed MCP tool-call interceptor reads, carrying `isSystem: true` only for a system caller. It decides nothing: the tool still runs under its own context |
236237

237238
---
@@ -681,6 +682,7 @@ and CI refuses one that differs from what the tree produces.
681682
| `packages/runtime/src/domains/permission-set-clone.ts#handlePermissionSetCloneWrite` | 2 | 50 |
682683
| `packages/runtime/src/domains/security.ts#handleSecurityRequest` | 1 | 52 |
683684
| `packages/runtime/src/flow-start-admission.ts#flowStartRefusal` | 1 | 57 |
685+
| `packages/runtime/src/sandbox/body-doors.ts#callerScopeOf` | 1 | 65b |
684686
| `packages/runtime/src/sandbox/body-runner.ts#executionContextFromHook` | 1 | 65 |
685687
| `packages/services/service-automation/src/runtime-identity.ts#stampSystemInsertOwner` | 1 | 60 |
686688
| `packages/services/service-knowledge/src/knowledge-service.ts#applyPermissionFilter` | 1 | 46 |

‎packages/cli/test/published-subpath-hook-body.pin.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ type ExtractedBodyHasExactlyTheseThreeFields = Expect<Equals<keyof ExtractedBody
283283
type ExtractedBodyMembersKeepTheirRatifiedTypes = Expect<
284284
Equals<
285285
ExtractedBody,
286-
{ source: string; capabilities: Array<'api.read' | 'api.write' | 'crypto.uuid' | 'log'>; isExpression: boolean }
286+
{ source: string; capabilities: Array<'api.read' | 'api.write' | 'crypto.uuid' | 'log' | 'email.send' | 'activity.append'>; isExpression: boolean }
287287
>
288288
>;
289289

‎packages/spec/src/data/hook-body-doors.zod.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const BodyDoorRecordRefSchema = z
4848
})
4949
.strict()
5050
.describe('A record the door reads in the caller\'s scope before it acts');
51-
export type BodyDoorRecordRef = z.infer<typeof BodyDoorRecordRefSchema>;
51+
export type BodyDoorRecordRef = z.input<typeof BodyDoorRecordRefSchema>;
5252

5353
/**
5454
* `ctx.email.send(input)` — a message a body hands to the mail service.

‎packages/spec/src/type-alias-convention.pin.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ import type * as M65 from './data/feed.zod.js';
137137
import type * as M66 from './data/field.zod.js';
138138
import type * as M67 from './data/filter.zod.js';
139139
import type * as M68 from './data/hook-body.zod.js';
140+
import type * as M206 from './data/hook-body-doors.zod.js';
140141
import type * as M69 from './data/hook.zod.js';
141142
import type * as M70 from './data/object.zod.js';
142143
import type * as M71 from './data/query.zod.js';
@@ -303,7 +304,7 @@ import type * as M204 from './ai/dataset-tools.zod.js';
303304
import type * as M205 from './ai/object-query-source.zod.js';
304305

305306
// ---------------------------------------------------------------------------
306-
// 853 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared.
307+
// 854 isomorphic aliases: `z.input` === `z.infer`, so no `XParsed` is declared.
307308
//
308309
// That number is machine-checked, not hand-kept. The runtime companion at the
309310
// bottom of this file recomputes the pin count from the source and asserts that
@@ -949,6 +950,9 @@ export type Iso_data_filter__QueryFilterSchema = Assert<Eq< z.input< typeof M67.
949950
export type Iso_data_hookBody__ExpressionBodySchema = Assert<Eq< z.input< typeof M68.ExpressionBodySchema >, z.infer< typeof M68.ExpressionBodySchema > >>;
950951
export type Iso_data_hookBody__HookBodyCapability = Assert<Eq< z.input< typeof M68.HookBodyCapability >, z.infer< typeof M68.HookBodyCapability > >>;
951952

953+
// data/hook-body-doors.zod.ts
954+
export type Iso_data_hookBodyDoors__BodyDoorRecordRefSchema = Assert<Eq< z.input< typeof M206.BodyDoorRecordRefSchema >, z.infer< typeof M206.BodyDoorRecordRefSchema > >>;
955+
952956
// data/hook.zod.ts
953957
export type Iso_data_hook__HookContextSchema = Assert<Eq< z.input< typeof M69.HookContextSchema >, z.infer< typeof M69.HookContextSchema > >>;
954958
export type Iso_data_hook__HookEvent = Assert<Eq< z.input< typeof M69.HookEvent >, z.infer< typeof M69.HookEvent > >>;
@@ -1825,7 +1829,7 @@ describe('ADR-0122 type-alias convention', () => {
18251829
// this title and the section header above the pin list — are now asserted
18261830
// against the recomputed count below, so neither can go stale without a red
18271831
// test naming it.
1828-
it('still declares all 853 isomorphic pins', () => {
1832+
it('still declares all 854 isomorphic pins', () => {
18291833
// The truth of each pin is proved by tsc, not here — an `Assert<Eq<...>>`
18301834
// that stops holding is a compile error with the alias named. What tsc
18311835
// cannot notice is a pin that was DELETED: removing the assertion removes
@@ -2884,7 +2888,11 @@ describe('ADR-0122 type-alias convention', () => {
28842888
// `FilterConditionSchema` tree (itself typed with one shape for both
28852889
// states), no default and no transform
28862890
// (Iso_ai_objectQuerySource__ObjectQuerySourceSchema). +1 added.
2887-
expect(pins).toHaveLength(853);
2891+
// 853 -> 854 is the record a script body's door reads before it acts
2892+
// (`data/hook-body-doors.zod.ts` `BodyDoorRecordRefSchema`): two bounded
2893+
// strings, strict, no default and no transform
2894+
// (Iso_data_hookBodyDoors__BodyDoorRecordRefSchema). +1 added.
2895+
expect(pins).toHaveLength(854);
28882896

28892897
// The count is stated in PROSE twice as well — this case's title and the
28902898
// section header above the pin list — and until commit c6b05c76a nothing read either

0 commit comments

Comments
 (0)