Skip to content

Commit c64d1f5

Browse files
committed
Update docs: machine-caller identity resolution (CL-6286)
Document RouteDeps.callerResolver / createMemory({ callerResolver }) in AGENTS.md's "authenticate nothing" invariant, ARCHITECTURE.md's identity section, and CHANGELOG.md.
1 parent 9b6c44e commit c64d1f5

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎AGENTS.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ CI runs `typecheck` + `test` — both must pass before any push.
3535

3636
## Non-negotiable invariants
3737

38-
1. **Authenticate nothing.** Identity is `c.get("principal")` from the
39-
Interchange context; authorization goes through the host's grant store
40-
(`@intx/authz`). Never add API keys, sessions, or OAuth here.
38+
1. **Authenticate nothing.** Identity defaults to `c.get("principal")` from
39+
the Interchange context; a host may instead supply `callerResolver`
40+
(`src/routes/deps.ts`) to resolve a non-browser caller (e.g. a
41+
workflow-run child's own sidecar bearer token) — but resolving that
42+
token is 100% host logic, called through the seam, never implemented
43+
here. Either way authorization goes through the host's grant store
44+
(`@intx/authz`) via the same `requireGrant` path. Never add API keys,
45+
sessions, or OAuth here.
4146
2. **One Postgres**: `DATABASE_URL`, the engine's own vector plane, under the
4247
`memory` schema — never the host's control-plane DB. No foreign keys into
4348
control-plane tables; cross-refs (`tenant_id`, `principal_id`) are plain

‎ARCHITECTURE.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ helpers are optional multi-writer / backfill — not the primary path.
4545
- **Runtime**: Bun + Hono, mounted on the host app. **DB**: own pgvector
4646
Postgres (`DATABASE_URL`) unless `documentStore` is injected.
4747
**Types**: arktype at every route boundary.
48-
- **No auth of its own.** Interchange resolves the caller and puts `principal`
49-
+ `tenant` on context; routes read identity from there
50-
(`tenantId = principal.tenantId`, `principalId = principal.id`).
48+
- **No auth of its own.** By default, Interchange resolves the caller and
49+
puts `principal` + `tenant` on context; routes read identity from there
50+
(`tenantId = principal.tenantId`, `principalId = principal.id`). A host
51+
with a non-browser caller (e.g. a workflow-run child with its own sidecar
52+
bearer token) may instead pass `callerResolver` (`RouteDeps` /
53+
`createMemory`) — the host still does 100% of the authenticating, it just
54+
hands the resolved `{ tenantId, principalId }` in through the seam instead
55+
of setting context itself. Either way the resolved identity, never
56+
anything from the request body, is what `grantGuard` authorizes.
5157
- **Grants delegate to the host.** Pass `grantStore` + `conditionRegistry`;
5258
routes use `createRequireGrant("memory", action)`.
5359
- **Dependencies**: `@intx/hub-api`, `@intx/authz`, `@intx/log`, Hono, Drizzle,

‎CHANGELOG.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- `RouteDeps.callerResolver` / `createMemory({ callerResolver })` — an
13+
optional host-supplied resolver from a request to a `{ tenantId,
14+
principalId }` scope, for a caller that never goes through the host's
15+
tenant-session middleware (e.g. a workflow-run child authenticating with
16+
its own sidecar bearer token). Unset by default: every route still reads
17+
identity from `c.get("principal")` exactly as before. When set, the
18+
resolved identity is seated as the request's principal/tenant ahead of
19+
`grantGuard`, so the same `requireGrant` authorization path applies to a
20+
machine caller — never a separate, weaker one. Identity from the resolver
21+
always wins over anything a request body claims.
22+
1023
### Fixed
1124

1225
- Feed `nextCursor` advances past the examined raw page after grant-tag

0 commit comments

Comments
 (0)