create-ailk 0.46.6 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,10 @@ export const ENV_CATALOG = {
7
7
  description: "The hub API origin this site's server calls (forms, flows, listings). Server-only; never NEXT_PUBLIC_.",
8
8
  secret: false,
9
9
  },
10
+ AILK_PUBLIC_API_URL: {
11
+ description: "The hub API's own public origin. A hub's MCP server resolves stored images onto it; unset leaves stored images out of its reads.",
12
+ secret: false,
13
+ },
10
14
  AILK_AUTH_PASSWORD_RESET: {
11
15
  description: 'Set to "1" or "true" to offer password reset once the server-side reset flow is wired.',
12
16
  secret: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ailk",
3
- "version": "0.46.6",
3
+ "version": "0.47.0",
4
4
  "description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "tar": "^7.5.21"
29
29
  },
30
30
  "devDependencies": {
31
- "@working-theory/schema": "0.80.0",
32
- "@working-theory/templates": "0.80.0"
31
+ "@working-theory/schema": "0.81.0",
32
+ "@working-theory/templates": "0.81.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
@@ -301,3 +301,21 @@ STRIPE_WEBHOOK_SECRET=whsec_xxx
301
301
  # unknown_site_key, which is the correct closed default but gives no clue at
302
302
  # boot — so set this if the deployment accepts listings.
303
303
  # AILK_LISTING_PUBLIC_KEY=
304
+
305
+ # --- Asset file storage (#12428) ---
306
+ # Where the workspace asset store keeps its files. Chosen once per process:
307
+ # - both store tokens set → Vercel Blob, one public and one private store
308
+ # - neither, AILK_ASSET_DIR set (not production) → a local folder
309
+ # - otherwise → the database rows, as before the move
310
+ # One token without the other is a misconfiguration: the hub keeps the
311
+ # database and logs `asset-files.misconfigured` once. The tokens are the
312
+ # read-write tokens Vercel writes when the hub's two stores are connected to the
313
+ # API project's PRODUCTION environment with the prefixes ASSETS_PUBLIC_BLOB and
314
+ # ASSETS_PRIVATE_BLOB (runbook: docs/internal/runbooks/asset-file-move.md). A
315
+ # hub not on Vercel sets the same two names. Never set them on a preview, the
316
+ # Admin or a site.
317
+ # ASSETS_PUBLIC_BLOB_READ_WRITE_TOKEN=
318
+ # ASSETS_PRIVATE_BLOB_READ_WRITE_TOKEN=
319
+ #
320
+ # A development hub keeps files in a folder, so nothing needs a live store.
321
+ # AILK_ASSET_DIR=./.data/assets
@@ -104,6 +104,7 @@ Routes are versioned under `/v1/*`:
104
104
  - `/v1/workspaces/:workspaceId/content` (GET, POST), `/v1/workspaces/:workspaceId/content/:type/:slug` (GET, PATCH), `/v1/workspaces/:workspaceId/content/:type/:slug/{publish,unpublish}` (POST) — the tenant-guarded content editor's write surface (#5853, `src/routes/workspaces/content.ts`): list, create, read/save the draft tip (under `X-Draft-Version`; `If-Match` still accepted for one release, #10264), and publish/unpublish, all over `Artifact`/`ArtifactVersion`. `:type` is validated against the page-type registry (`z.enum(SCHEMA_ORG_TYPES)`) rather than accepted as a free string on every addressed operation — an unregistered type is a 400 before any lookup, since it is echoed back and passed to `notifyRevalidate` as the site's cache tag. Role floors from `@working-theory/validation`'s permission table (#7636 D2): publish and unpublish need `content-publish`, and create, read and save need `content-edit` (both owner, admin — an admin builds, a member operates). The list serves `content-edit` the editor's full view and a caller holding only `docs-read` (a member) a published-only projection (D4): draft rows dropped, every row `status: "published"`, `version: null`, `valid: true`, and a `published_with_draft` page's `type`/`tags` read from its PUBLISHED version — applied before every filter, so a member's `?status=draft` or a draft tip's `?tag=` matches nothing. **The GET list is a UNION of page artifacts and DOCUMENT assets** (#6093, D1/D9 — "one store, two views"): every row carries `tags: string[]` (never null, read from the draft tip's stored content for a page, from `Asset.tags` for a file) and a DERIVED `kind: "page" | "post" | "file"` (`BlogPosting` alone maps to `"post"`; an asset row is always `"file"`) — an optional `?tag=<slug>` filters the union AFTER it is built, so a file is returned under either its own tag or a shared one. The asset half of the union (`DOCUMENT_CONTENT_TYPES`, i.e. `application/pdf`) is skipped entirely when `locale`/`type` is supplied or `status` names anything but `"published"`, since a file row can never satisfy those. A foreign `:workspaceId` costs zero artifact **and** zero asset queries. MCP parity: on `/mcp/workspace`, the create's twin is `create_page` (#10956), the draft read and save are `read_report` and `save_draft` (#10336), and the publish is `publish_draft` (#10661); the list and unpublish have none, as `tests/parity/README.md` and the registry record. `POST /v1/workspaces/:workspaceId/documents/save` (#11811) saves a `Document` — agent context or a plugin-owned document — in the common shape, its address in the body as `POST …/assets/save`'s is: `content-edit` is checked before the body (an agent without it `403 agent_refused`, audited), `version: null` creates and a version edits under a compare-and-swap on the tip, a moved tip or a `null` on an existing document is `409 stale` with `currentVersion`, and a wrong field or word — a plugin contract's misfit included — is `422 invalid` with each issue's path; it never publishes. Its twin is `save_document`; the page save (`PUT …/content/:type/:slug`, `save_page`) also takes an editorial page, whose words are `{ body }`, carrying its stored layout forward. While both ways live, `create_page`, `save_draft` and `save_structure` say they are deprecated. `GET /v1/workspaces/:workspaceId/content/:type/:slug/open?locale=&as=` (#11808, #11882) opens a page laid out in sections as the page envelope: `content-edit` is checked before the query or any read, `as` is `record` (the default: its `fields` and its `words`, the stored layout with the body's words applied) or `working-copy` (a `workingCopy`, `{ document, settings }`, in their place) — `form` is its old name, answered until the release after #11882, and the two sent with different values are `422 invalid` at `as` — a type not laid out in sections is `422 invalid` at `address.type` (a `Document` naming `open_document`), a missing page — or one the caller may not read — a blank built in memory and never stored (#11809): `version` and `structureToken` `null`, `state: "draft"`, `report: null`, `fields: {}` and its template's starting sections headed by the slug, in the shape asked for, a page not in the section form, or whose body's words do not apply cleanly to its layout, `409 not_outlined`, and a page whose working copy would lose a value or exceed the working copy's bounds `409 not_representable` with each issue's path; it never writes or audits, and is limited to 60 calls a minute per workspace. Its twin is `open_page`.
105
105
  - `/v1/workspaces/:workspaceId/library/pages` (GET, `?type=&status=&limit=&page=`) and `/v1/workspaces/:workspaceId/library/assets` (GET, `?tag=&type=&limit=&page=`) — the library reads, each answering `{ workspace: { id, name }, items, total, page, nextPage }` newest first (`limit` 1–200, default 50; `page` from 1; `libraryPageListQuerySchema` / `libraryAssetListQuerySchema` in `@working-theory/validation`). The page list (`packages-paid/api-content-write/src/routes/workspaces/library-pages.ts`, in the content-write tenant scope) serves every page, drafts included, as `{ id, type, slug, locale, title, status, updatedAt }`; `status` is the Docs list's rule — `disabled` when switched off, else `live` when a version is published (a newer draft included), else `draft` — and the route needs `content-edit` (`allows`, so an agent needs the grant). A disabled page is asked for only on a person's behalf: `tenantDb` keeps every disabled row from an agent. The asset list (`packages-paid/api-workspace/src/routes/assets/manage.ts`, beside the manage list, `assets-read`) serves each file's whole record (#11801), `{ id, key, filename, title, description, version, type, size, dimensions, audience, tags, url, updatedAt }` — `title` and `description` with hidden code points removed (`null` when none is written, never left out), `version` the file's record version (`r<n>`, #11803), `type` the content type, `size` its bytes, `dimensions` a raster image's `{ width, height }` as the Admin's Details panel shows it — read from the head of the file — the few bytes a PNG, GIF or WebP needs, at most 64 KiB for a JPEG or AVIF (`tenantDb.assets.fileHeads`, which never reads a private, Knowledge or disabled file) for the answered page's images alone, a JPEG's Exif and an AVIF's `irot` quarter-turn swapping the two (`routes/assets/dimensions.ts`) — and `null` for an SVG, any other file, or a header that does not say, `audience` who may read it, `url` the public read's path, `updatedAt` when the current file was uploaded — the `createdAt` of the version `currentVersion` names (`tenantDb.assets.currentVersionTimes`), so a replace moves it, a restore takes the restored version's upload time, and a metadata edit does not move it; the list is ordered by it, newest first — narrowed by an exact `tag` and a `type` that is a whole content type (`image/png`) or its top-level part (`image`); a file tagged `private` never lists, `?tag=private` included. MCP parity: `list_workspace_pages` and `list_assets` on `/mcp/workspace`.
106
106
  - `/v1/workspaces/:workspaceId/assets/save` (POST, #11803) — save a file's title, description and type: the body is `assetSaveBodySchema` (`{ address: { key }, version: "r<n>" | null, words: { title?, description? }, fields?: { type? } }`, strict at every level; `fields.type` (#11879) is one of the ten asset types and replaces the one the file held, every other tag kept; a type-only save sends `words: {}`), and the answer `{ kind: "asset", address, version, fields: { type }, words, state: "live" }` with the new record version. `assets-write` (`allows`, so an agent may hold it by grant) before the body is read; a wrong body is `422 invalid` with `details.issues` (`{ path, message }`, at most 20); a file the caller may not reach — for an agent also a disabled, private or Knowledge one — the plugin's one `404 not_found`; a save based on another record version, or on `null`, `409 stale` with `details.currentVersion`. One conditional UPDATE (`tenantDb.assets.saveRecord`) writes only `title`, `description`, the type tag and `record_version`, whose `where` carries the version and the reach — and, with a type, the tags it read, so a concurrent tags write reruns it. Every agent call that reaches the body is audited (`assets.save`). An agent's `PATCH …/assets/:assetId` is refused `403 agent_refused`; a person's PATCH of a title or description moves the record version. MCP parity: `save_asset` on `/mcp/workspace`.
107
+ - `/v1/workspaces/:workspaceId/assets/from-url` (POST, #12418; `packages-paid/api-workspace/src/routes/assets/from-url.ts`, registered by `workspaceAssetManageRoutes`, so it shares that plugin's tenant scope and JSON body) — the fetch door: the hub fetches an image from a public `https` address an agent or a person sends and stores it as a NEW public file. The body is `assetFromUrlBodySchema` (`{ url, key, type, title? }`, strict; `url` `https:` with no user name, at most 2,048 characters; `type` one of the ten). Order: `assets-write` (`allows`) before the body; the per-minute limits (`chargeWriteBudget` scope `asset-from-url`, fail closed: 10 per caller keyed as `language.ts` keys its writes, 30 per workspace, `429 rate_limited`; the store unable to count `503 fetch_unavailable`); the body (`422 invalid` with `details.issues`); the key (`tenantDb.assets.keyTaken`, then the Live-page scan — `403 agent_refused` for an agent, `409 key_taken` for a person); the daily cap from the workspace's own rows (`tenantDb.assets.fetchedSince`: 200 files or 500 MB, `429 fetch_quota`); four fetches per process and two per workspace per 10 seconds (`503 fetch_busy`); 400 starts a day (`429 fetch_quota`); then the fetch — every hop's name, every address it resolves to through c-ares (never `dns.lookup`) and the address its socket dials, checked before TLS; at most three redirects; `200`, a raster type proven by its signature, `identity`-encoded, within `assetUploadLimit` and 10 seconds — its metadata stripped to an allowlist without re-encoding and its pixel size bounded; the page scan again; and the write through #12428's seam (`blob`: written with `ttlDays: 1`, recorded with `replace({ createOnly: true, type, title, sourceUrl })`, kept only after the record commits). A refusal answers its own code (`fetch_not_public`, `fetch_bad_redirect`, `fetch_too_many_redirects`, `fetch_type_refused`, `fetch_type_mismatch`, `fetch_image_refused`, `fetch_too_large`, `fetch_unreachable`, `fetch_bad_status`, `fetch_timed_out`) and stores nothing; success is `201` with the open envelope plus `file: { url, contentType, size, version }`. No log line carries the address, its host, the key or the title. `GET …/assets/open` answers `source`, the address the file's first version was fetched from (origin and path only), `null` for an upload. MCP parity: `create_asset_from_url` on `/mcp/workspace`.
107
108
  - `/v1/workspaces/:workspaceId/overview` (GET) — the workspace overview (#11806; `packages-paid/api-content-write/src/routes/workspaces/workspace-overview.ts`, in the content-write tenant scope beside the knowledge-base reads), any tenant of the workspace; any query key is 400 `validation_failed` (`Invalid query`, the key never echoed). It answers `{ site: { name, description, defaultLocale }, knowledge: { documents, complete }, language: { term, faq, topic, proof }, magnets: { draft, live }, withheld: [{ part, reason }] }`, each part by the code and under the gate of the read it replaces: the identity and SEO blobs (any tenant), `addressLocale(undefined)`, the knowledge list's own rows for `context: "knowledge"` (`docs-read`, at the list's reading role) with `version` — the draft tip's id — only where `content-edit` holds and the caller's own role reads the doc's audience, the Language count per kind (`docs-read`, at the caller's own role, one `groupBy`, no cap), and the magnet count per state through `magnetListView` (`draft` only for `magnets-manage`; the part needs `multi-tenant` or `signal-collectors`). A part the caller may not read is `null` (or, for `version` and `draft`, absent) and named in `withheld` with reason `grant` or `module` — never a refusal of the read. At most six queries in one `Promise.all`; the answer is re-parsed against `workspaceOverviewSchemaFor` (a version or draft count the caller may not see is a 500, never a leak); `Cache-Control: private, no-store`; an agent read logs one `agent_read` line, and the knowledge or Language part withheld for its grant one `denied_read` line each, naming the `part`, none naming a document. MCP parity: `get_workspace_overview` on `/mcp/workspace`.
108
109
  - `/v1/workspaces/:workspaceId/documents/open` (`?type=Document&slug=&locale=&as=`, #11808 #11853 #11882 — `as` is `record` or, at a plugin-owned address only, `working-copy`, else `422 invalid` at the key sent; `form` is its old name, as the page open's), `/v1/workspaces/:workspaceId/language/:kind/:slug/open` (`?locale=`) and `/v1/workspaces/:workspaceId/assets/open` (`?key=`) (all GET; the latter two #11809) — open a document, a Language item or a file's record under the common names, beside `open_page`'s route (#11808): each sits beside the read it parallels and takes that read's gate (`content-edit`, `docs-read`, `assets-read`) before any store read, and answers the thing in the common envelope with the `version` its save takes. Nothing at the address — or a thing the caller's read could not see — answers a blank built in memory and never stored: `version: null`, `state: "draft"` and the kind's starting layout (a contract document's `contract`/`contract_version` and required headings, an item's empty words); a file is never blank (`404 not_found`, under the reach `save_asset` gives an agent, for every caller). No open writes or audits. MCP parity: `open_document`, `open_language_item` and `open_asset` on `/mcp/workspace`.
109
110
  - `/v1/workspaces/:workspaceId/page-types` (GET) and `/v1/workspaces/:workspaceId/tag-vocabulary` (GET) — the site-vocabulary reads (#11680; `packages-paid/api-content-write/src/routes/workspaces/site-vocabulary.ts`, in the content-write tenant scope), any tenant of the workspace, no query, no row read. `page-types` answers `{ types: [{ type, route, fixed, template, headings }] }`: every page-type registry entry that is a page, in registry order, with its template's headings as `PAGE_TEMPLATES` states them (`key`, `text`, `required`, `section`, `hint`), filtered per request by the module map `pageTypeModule` in `@working-theory/validation` (the one create-ailk's page-types reference generator reads): `marketing` types always, `scheduling` and `signal-collectors` types when `isModuleEnabled`, and `docs-blog` types when `AILK_ENABLED_MODULES` names `docs-blog` — a site that carries the blog and docs sets that key, since `docs-blog` has no API module. `tag-vocabulary` answers `tagVocabulary()`: `{ classes, topics, status }`, each a list of `{ tag, means, setBy }`. MCP parity: `list_page_types` and `get_tag_vocabulary` on `/mcp/workspace`.
@@ -35,7 +35,7 @@
35
35
  */
36
36
 
37
37
  import { createHmac } from 'node:crypto';
38
- import { PassThrough } from 'node:stream';
38
+ import { PassThrough, Readable } from 'node:stream';
39
39
 
40
40
  import type { VercelRequest, VercelResponse } from '@vercel/node';
41
41
  import Fastify from 'fastify';
@@ -245,7 +245,7 @@ jest.mock('@working-theory/license', () => ({
245
245
  jest.mock('@working-theory/analytics/server', () => ({
246
246
  track: jest.fn().mockResolvedValue(undefined),
247
247
  }));
248
- // eslint-disable-next-line no-restricted-syntax -- lib/prisma.ts wraps the external DB boundary (PrismaClient requires a live connection); __mocks__/prisma.ts is the repo-standard test double for this boundary.
248
+
249
249
  jest.mock('@working-theory/api/lib/prisma.js');
250
250
 
251
251
  /** Stripe's v1 scheme: `t=<ts>,v1=<hex HMAC-SHA256(secret, "<ts>.<payload>")>`. */
@@ -671,3 +671,177 @@ describe('vercel-handler — the request log carries no query string (#5970)', (
671
671
  expect(inject.mock.calls[0][0]).toMatchObject({ url: '/v1/webhooks/stripe/whk_SECRETTOKEN123' });
672
672
  });
673
673
  });
674
+
675
+ // ── #12428 D4: a deliverable leaves the handler as a stream ─────────────────
676
+ //
677
+ // Vercel refuses a whole response over 4.5 MB; a streamed one is exempt. A
678
+ // `GET`/`HEAD` under `/v1/deliverables/` is injected with `payloadAsStream`
679
+ // and piped into `res`; every other request keeps the whole-payload `send`.
680
+
681
+ /** A writable `res` that records what is piped into it. */
682
+ function makeStreamRes() {
683
+ const res = Object.assign(new PassThrough(), {
684
+ headersSent: false,
685
+ _status: undefined as number | undefined,
686
+ _headers: {} as Record<string, string>,
687
+ _sent: undefined as unknown,
688
+ chunks: [] as Buffer[],
689
+ ended: false,
690
+ status(code: number) {
691
+ this._status = code;
692
+ return this;
693
+ },
694
+ setHeader(key: string, value: string) {
695
+ this._headers[key] = value;
696
+ return this;
697
+ },
698
+ getHeader(key: string) {
699
+ return this._headers[key];
700
+ },
701
+ send(body: unknown) {
702
+ this._sent = body;
703
+ return this;
704
+ },
705
+ json(body: unknown) {
706
+ this._sent = body;
707
+ return this;
708
+ },
709
+ });
710
+ res.on('data', (chunk: Buffer) => res.chunks.push(chunk));
711
+ res.on('finish', () => {
712
+ res.ended = true;
713
+ });
714
+ return res;
715
+ }
716
+
717
+ function asStreamResponse(stub: ReturnType<typeof makeStreamRes>): VercelResponse {
718
+ // @ts-expect-error: a PassThrough carrying the MockRes surface satisfies the
719
+ // subset of VercelResponse the handler calls (status/setHeader/getHeader/
720
+ // send/json, plus the Writable `pipe` writes to).
721
+ return stub;
722
+ }
723
+
724
+ describe('vercel-handler — a deliverable answer leaves as a stream (#12428 D4)', () => {
725
+ const FILE = Buffer.from([0x25, 0x50, 0x44, 0x46, 0x2d, 0x80, 0xff, 0xfe, 0x00, 0x01]);
726
+ let app: ReturnType<typeof Fastify>;
727
+
728
+ beforeEach(async () => {
729
+ jest.resetModules();
730
+ app = Fastify();
731
+ app.get('/v1/deliverables/:grantId', async (_request, reply) => {
732
+ reply
733
+ .header('content-type', 'application/pdf')
734
+ .header('content-disposition', 'attachment; filename="report.pdf"')
735
+ .header('cache-control', 'private, no-store');
736
+ return reply.send(Readable.from([FILE.subarray(0, 4), FILE.subarray(4)]));
737
+ });
738
+ // `/late` fails after the first chunk has gone out; `/early` fails before
739
+ // the handler has read the stream at all.
740
+ app.get('/v1/deliverables/broken/:when', async (request, reply) => {
741
+ const { when } = request.params as { when: string };
742
+ const failure = new Error('store said https://x.private.blob.vercel-storage.com/a');
743
+ let reads = 0;
744
+ const failing = new Readable({
745
+ read() {
746
+ if (when === 'early') {
747
+ this.push(FILE.subarray(0, 4));
748
+ this.destroy(failure);
749
+ } else if (reads++ === 0) {
750
+ this.push(FILE.subarray(0, 4));
751
+ } else {
752
+ setImmediate(() => this.destroy(failure));
753
+ }
754
+ },
755
+ });
756
+ reply.header('content-type', 'application/pdf');
757
+ return reply.send(failing);
758
+ });
759
+ app.get('/v1/other', async () => ({ ok: true }));
760
+ await app.ready();
761
+ });
762
+
763
+ afterEach(async () => {
764
+ await app.close();
765
+ });
766
+
767
+ it('pipes a GET under /v1/deliverables/ with payloadAsStream and no Location', async () => {
768
+ const inject = jest.spyOn(app, 'inject');
769
+ jest.doMock('../server', () => ({ build: jest.fn().mockResolvedValue(app) }));
770
+ const handler = loadHandler();
771
+ const res = makeStreamRes();
772
+ const send = jest.spyOn(res, 'send');
773
+
774
+ await handler(
775
+ asRequest({ method: 'GET', url: '/v1/deliverables/grant_1', headers: {}, body: undefined, query: {} }),
776
+ asStreamResponse(res),
777
+ );
778
+
779
+ expect(inject.mock.calls[0][0]).toMatchObject({ payloadAsStream: true });
780
+ expect(send).not.toHaveBeenCalled();
781
+ expect(res._status).toBe(200);
782
+ expect(res._headers['content-type']).toBe('application/pdf');
783
+ expect(res._headers['content-disposition']).toBe('attachment; filename="report.pdf"');
784
+ expect(Object.keys(res._headers).map((k) => k.toLowerCase())).not.toContain('location');
785
+ expect(res.ended).toBe(true);
786
+ expect(Buffer.compare(Buffer.concat(res.chunks), FILE)).toBe(0);
787
+ });
788
+
789
+ it('streams a HEAD under /v1/deliverables/ too', async () => {
790
+ const inject = jest.spyOn(app, 'inject');
791
+ jest.doMock('../server', () => ({ build: jest.fn().mockResolvedValue(app) }));
792
+ const handler = loadHandler();
793
+ const res = makeStreamRes();
794
+
795
+ await handler(
796
+ asRequest({ method: 'HEAD', url: '/v1/deliverables/grant_1', headers: {}, body: undefined, query: {} }),
797
+ asStreamResponse(res),
798
+ );
799
+
800
+ expect(inject.mock.calls[0][0]).toMatchObject({ payloadAsStream: true });
801
+ expect(res._status).toBe(200);
802
+ expect(res.ended).toBe(true);
803
+ });
804
+
805
+ it.each(['late', 'early'])('ends the response when the stream fails (%s) and logs the error name only', async (when) => {
806
+ jest.doMock('../server', () => ({ build: jest.fn().mockResolvedValue(app) }));
807
+ const handler = loadHandler();
808
+ const res = makeStreamRes();
809
+
810
+ await handler(
811
+ asRequest({ method: 'GET', url: `/v1/deliverables/broken/${when}`, headers: {}, body: undefined, query: {} }),
812
+ asStreamResponse(res),
813
+ );
814
+
815
+ const { logger } = require('@working-theory/observability') as {
816
+ logger: { error: jest.Mock };
817
+ };
818
+ const failure = logger.error.mock.calls.find(
819
+ ([, msg]) => msg === '[Vercel Handler] Streamed response failed',
820
+ );
821
+ expect(failure?.[0]).toEqual({ err: 'Error' });
822
+ expect(JSON.stringify(logger.error.mock.calls)).not.toContain('blob.vercel-storage.com');
823
+ // `pipeline` destroys the response on a failure: the download aborts.
824
+ expect(res.ended || res.destroyed).toBe(true);
825
+ });
826
+
827
+ it.each([
828
+ ['GET', '/v1/other'],
829
+ ['POST', '/v1/deliverables/grant_1'],
830
+ ])('keeps the whole payload for %s %s', async (method, url) => {
831
+ const rawPayload = Buffer.from('{"ok":true}');
832
+ const inject = jest.fn().mockResolvedValue({
833
+ statusCode: 200,
834
+ headers: { 'content-type': 'application/json' },
835
+ body: rawPayload.toString(),
836
+ rawPayload,
837
+ });
838
+ jest.doMock('../server', () => ({ build: jest.fn().mockResolvedValue({ inject }) }));
839
+ const handler = loadHandler();
840
+ const res = makeRes();
841
+
842
+ await handler(asRequest({ method, url, headers: {}, body: undefined, query: {} }), asResponse(res));
843
+
844
+ expect(inject.mock.calls[0][0]).not.toHaveProperty('payloadAsStream');
845
+ expect(res._sent).toBe(rawPayload);
846
+ });
847
+ });
@@ -213,6 +213,22 @@ export const prisma = {
213
213
  upsert: jest.fn(),
214
214
  deleteMany: jest.fn(),
215
215
  },
216
+ // #12400 D2 — the site navigation and its versions: the accessor's guarded
217
+ // save, list and read, and the workspace-delete helper's `deleteMany`.
218
+ workspaceSiteNavigation: {
219
+ findUnique: jest.fn(),
220
+ findMany: jest.fn(),
221
+ createManyAndReturn: jest.fn(),
222
+ updateManyAndReturn: jest.fn(),
223
+ deleteMany: jest.fn(),
224
+ },
225
+ workspaceSiteNavigationVersion: {
226
+ findUnique: jest.fn(),
227
+ findFirst: jest.fn(),
228
+ findMany: jest.fn(),
229
+ create: jest.fn(),
230
+ deleteMany: jest.fn(),
231
+ },
216
232
  // `findUnique` — the public meetings read (`lib/public-meetings-config.ts`),
217
233
  // which a spoke's meeting-types read and booking gate reach (#7532 D3/D4).
218
234
  workspaceMeetings: {
@@ -3,6 +3,8 @@
3
3
  * This file wraps the Fastify server for Vercel's serverless functions
4
4
  */
5
5
 
6
+ import { pipeline } from "node:stream";
7
+
6
8
  import type { VercelRequest, VercelResponse } from "@vercel/node";
7
9
  import { redactLogPath } from "@working-theory/api";
8
10
  import { logger } from "@working-theory/observability";
@@ -240,7 +242,18 @@ export default async function handler(
240
242
  query: req.query as Record<string, string>,
241
243
  };
242
244
 
243
- const response = await server.inject(fastifyRequest as InjectOptions);
245
+ // A deliverable's file leaves as a STREAM (#12428 D4): Vercel refuses a
246
+ // whole response over 4.5 MB, and a streamed one is exempt. Every other
247
+ // request keeps the whole-payload path below, byte for byte.
248
+ const streamed =
249
+ (method === "GET" || method === "HEAD") &&
250
+ pathname.startsWith("/v1/deliverables/");
251
+
252
+ const response = await server.inject(
253
+ (streamed
254
+ ? { ...fastifyRequest, payloadAsStream: true }
255
+ : fastifyRequest) as InjectOptions,
256
+ );
244
257
 
245
258
  logger.info(
246
259
  { status: response.statusCode },
@@ -264,7 +277,24 @@ export default async function handler(
264
277
  res.setHeader("Content-Type", "application/json");
265
278
  }
266
279
 
267
- if (!res.headersSent) {
280
+ if (streamed && !res.headersSent) {
281
+ // A stream that fails mid-file ends the response — `pipeline` destroys
282
+ // it, so the client sees an aborted download, never a short file as if
283
+ // whole — and the log names the error alone, never its message (which
284
+ // could carry a store address). It also destroys the file stream when
285
+ // the client goes away, so an aborted download holds no store read open.
286
+ await new Promise<void>((resolve) => {
287
+ pipeline(response.stream(), res, (error) => {
288
+ if (error) {
289
+ logger.error(
290
+ { err: error.name },
291
+ "[Vercel Handler] Streamed response failed",
292
+ );
293
+ }
294
+ resolve();
295
+ });
296
+ });
297
+ } else if (!res.headersSent) {
268
298
  // Forward the raw bytes light-my-request kept alongside `.body` — the
269
299
  // decoded-as-UTF-8-string form corrupts any non-UTF-8 response (a
270
300
  // generated PDF, any binary payload) by replacing every invalid byte
@@ -105,6 +105,14 @@ MCP_ABUSE_BLOCKED_USER_AGENTS=
105
105
  # Required ONLY on a hub's CONTENT_ADAPTER=database — never on a spoke.
106
106
  # DATABASE_URL=
107
107
 
108
+ # A hub's CONTENT_ADAPTER=database only (#12420): the hub API's public URL —
109
+ # the SAME value the hub's apps/api holds. A page's stored images (asset:<key>)
110
+ # resolve onto its origin, so read_content, list_pages and search_content
111
+ # answer the address the API's routes do. Unset or not http(s), stored images
112
+ # are left out of every read and the server writes one stderr line saying so.
113
+ # A spoke reads its hub's API, which resolves them: leave it unset there.
114
+ # AILK_PUBLIC_API_URL=
115
+
108
116
  # ── STEALTH ──────────────────────────────────────────────────────────────────
109
117
 
110
118
  # Optional. Set to "true" on this server's own hosting project to keep its
@@ -204,7 +204,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
204
204
  - **apps/mcp checks only the key's shape.** The key is attached as the SDK's `req.auth` for that
205
205
  request alone and reaches a tool as `extra.authInfo.token`. apps/api is the one place it is
206
206
  checked, and its tenant guard and the caller's clamped role decide every answer.
207
- - **Ninety tools (eighty-seven plus three deprecated aliases), each a `twin`.** The catalog rows carry `surface: "workspace"`, `tier: "pro"`
207
+ - **A hundred tools (ninety-seven plus three deprecated aliases), each a `twin`.** The catalog rows carry `surface: "workspace"`, `tier: "pro"`
208
208
  and `modulesAnyOf` (the modules any one of which registers the tool — its twin route's gate):
209
209
  `get_agent_context`, (#9683) `get_workspace_knowledge` — twin of `GET
210
210
  /v1/workspaces/:workspaceId/knowledge`: the business's shown offerings, live magnets, listed
@@ -226,7 +226,7 @@ here. Spec: `docs/specs/3591-tenant-scoped-agent-auth-secure-spec.md` D13–D16.
226
226
  tools, `list_proposals` and `create_proposal`, twinning `GET`/`POST
227
227
  /v1/workspaces/:workspaceId/people/:personId/proposals` with the same grant: a proposal is
228
228
  private to one client, `payments` says whether approval leads to a Stripe page, and an agent's
229
- price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12) and `workspaceId` when the connection reaches several workspaces (#11753), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address) — a page type laid out in sections sent no words (no body, an empty one, or only its template's headings) starts from its template (#11793): the hub lays out the template's sections, each headed by its default headline with an empty field to write under, and stores the words and the layout together, refusing a title or description the words rules refuse, or a `sections` key, 422 `invalid` — never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#11791) `save_page`, twinning `PUT …/content/:type/:slug` with the `content-edit` grant, under the common names of `docs/internal/decisions/one-way-common-names.md`: it saves a page laid out in sections — its `fields` and its `words` (its sections in order, each `{ id, type, data }`) — in one draft version that holds the body the hub builds from the words and the layout together; `address` (type, slug, locale) rides the URL, and `version` with `structureToken` is what the save was based on, both `null` for a new page; a save whose basis is no longer the tip, or `null` for a page that exists, answers 409 `stale` with `currentVersion` and `currentStructureToken`, and a wrong field or word 422 `invalid` with `issues` (`path`, `message`), the one refusal pair whose details reach the tool; it never publishes; since #11811 it also saves an editorial page, whose `words` are `{ body }`, its Markdown, carrying the stored layout forward; since #11808 (#11852) a page laid out in sections may send `workingCopy`, `{ document, settings }` — the two tabs of a working copy as exported — in place of `fields` and `words`: the hub converts it against the tip it was based on (409 `stale` before converting), keeps the stored fields a Settings table cannot carry, refuses a wrong copy 422 `invalid` at `workingCopy.settings`, `workingCopy.document` or the envelope path, and answers the page as a working copy — and (#11811) `save_document`, twinning `POST …/documents/save` with the `content-edit` grant: it saves a `Document` (Instructions, Knowledge or a plugin-owned document) in the same common shape — `address` (`type` always `Document`, slug, locale) rides the body, as `save_asset`'s does, `version` is `null` for a new document, `fields` are the page save's, and `words` is `{ body }`; a moved tip or a `null` on an existing document answers 409 `stale` with `currentVersion` alone, and a wrong field or word — a plugin contract's misfit included, each issue at its path (`fields.contract_version`, `words.body`) — 422 `invalid`, both details rebuilt in `workspace-server.ts`; a document never goes live; since #11808 it takes, at a plugin-owned contract address only, `workingCopy` (`{ document, settings }`, the two tabs of a working copy as exported) in place of `fields` and `words`, which the hub converts against the tip it was based on and answers in the same form (the record form when the copy would outgrow its bounds) — and (#11808) `open_document`, twinning `GET …/documents/open` with the `content-edit` grant: the read twin of `save_document`, its `address` in the query, answering the envelope as the record or, with `as: "working-copy"` and only at a plugin-owned address (else 422 `invalid` at the key sent), the working copy (409 `not_representable` when it would outgrow its bounds); since #11882 `open_page` and `open_document` take `as` where they took `form`, which stays the old name for one release (the catalog keeps it, so the SDK never strips it), and the route refuses the two sent with different values 422 `invalid` at `as`; it never writes, and its `invalid` keeps `issues` (`path`, `message`, each cut to 200 characters). — and (#11809) `open_language_item` and `open_asset` (`mcp-workspace`'s `language.ts` and `library.ts`), twinning `GET …/language/:kind/:slug/open` and `GET …/assets/open` under the gate of the read each parallels (`docs-read`, `assets-read`): each takes `{ workspaceId, address }` (plus `locale` for an item) and answers the thing in the common envelope with the `version` its save takes, or — nothing at the address, or nothing the caller may read there — an item's blank, `version: null` and its kind's empty words, which the save with `version: null` starts; a file is never blank (`404 not_found`); and `open_page` and `open_document` answer the same kind of blank where they answered 404 — a page its template's starting sections, headed by the slug, and a document at a plugin-owned contract address its contract's constant fields and required headings, else nothing; no open writes, and the section map lists `open_` tools as reads. While both ways live, `create_page`, `save_draft` and `save_structure` open their descriptions with a deprecation naming `save_page` or `save_document`; nothing else about them changes until the removal (#11811 D2, D6) — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#11806) `get_workspace_overview`, twin of `GET /v1/workspaces/:workspaceId/overview` (`mcp-workspace`'s `workspace_overview.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`, no query): a command's starting picture in one call — the site identity's name and SEO description, the default locale, the Knowledge docs `read_knowledge` lists for the caller with each one's draft `version` where `read_report` would answer it (`content-edit`, and the caller's own role reads the doc), and the Language items by kind and the magnets by state (`draft` only with `magnets-manage`); a part the caller's grants or the site's modules do not allow is `null` or left out and named in `withheld` (`grant` or `module`), never a refusal of the read — and (#12015) `get_command_craft`, twin of `GET /v1/workspaces/:workspaceId/craft/:command` (`mcp-workspace`'s `command_craft.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`): one command's craft for the session, `{ command, pack, minShellVersion, craft }`, served only to a workspace that has the command's pack; a `pack_required` refusal carries `details` rebuilt from `pack`, `name` and `where` alone, and a `craft_unavailable` carries `service` alone (`entitlements`, `delivery` or `null`) — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the six Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed — `live: false` is how an agent takes an item off the site; the `DELETE` has no tool, by decision (#11802): it is permanent (nothing restores the item and its slug stays taken), so a person deletes in the Admin and the route refuses every agent `agent_refused`; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and (#11810) `POST …/magnets/save` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the save body whole, the magnet's `id` in it, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot set or change what a magnet charges (`403 magnet_pricing_needs_person`); with no `id` and `version: null` it creates a draft magnet — a slug another magnet holds is `409 stale` with its `currentVersion`, a slug the site reads by name `409 slug_reserved`, and the plan check is the Admin create's; the Admin's PATCH and create (which refuses every agent `403 agent_refused`) and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's whole record (#11801) — its public path, title, description and record version, its size, an image's pixel size as the Admin's Details panel shows it, and its audience — for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11803) `save_asset` (`library.ts`, `gate: { allows: "assets-write" }`), twinning `POST …/assets/save`: it saves a file's title and description — and (#11879) its type, `fields.type`, one of the ten asset types — by its key, based on the record version `list_assets` returned; a stale save is `409 stale` and its tool error carries `details.currentVersion`, a wrong argument `422 invalid` with `details.issues` (`{ path, message }`, at most twenty, each cut to 200 characters, rebuilt in `workspace-server.ts`); it never replaces, renames, re-privacies or deletes a file, and never reaches a private, Knowledge or disabled one — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row; and (#11790) the third, `list_section_types` (same file, registration and gate), twinning `GET …/section-types` with an optional `type`: every section type a page's layout can hold with every field of its data — words or data, the Markdown form, whether it is required and inside which optional field, its values and bounds — plus its bounded lists and rules, or that one section type's; platform data, read no row; and (#11805) the fourth, `list_kinds` (same file, registration and gate), twinning `GET …/kinds`: every kind of thing the Admin holds — page, document, language_item, magnet, asset — with how to address one, its fields (words or data, required, nullable, value types and values, the Language item kind a words field belongs to), its states, and the moves the caller may make on it, each with its tool; the fields and states are read off each kind's own schemas (`ADMIN_KIND_REGISTRY`), the moves are the catalog rows' `moves` tags kept only when the row's gate holds for the caller's own clamped tenant and one of its modules runs on this hub (`listKinds`), and a page's sections are named, not described — its `sectionTypes` is `list_section_types`; it reads no row, and is advice, never an entitlement; since #11878 it also answers, beside the kinds, `forms` (for each kind — and an offering and an appointment — the field its tools take its form in and that field's values: `values` null for an asset's open content type, `field` null for an appointment, which has no form), `offSiteForms` (press-release, pitch, proposal, playbook and profile, each with the formats it allows), `formats` (the ten, ending `platform`) and `origins` (`ai-generated`, `user-added`), all declared once in `@working-theory/validation` and the same for every caller and hub — and (#11756) `create_work_request` (`mcp-workspace`'s `work_requests.ts`, registered with `workspace` or `multi-tenant`, `gate: { inbox: "inbox-act" }`), twinning `POST /v1/workspaces/:workspaceId/work-requests`: it files a custom-work request in the Inbox — one item pointing to one `Document` of the workspace (`documentSlug`) with a one-line `summary` — in the workspace the conversation writes to, needs the `inbox-act` grant, is refused `document_not_found` for a slug naming no Document the caller can read and `rate_limited` past 5 an hour per person in the workspace (shared by that person's agents) or 10 per workspace, and returns the request as stored (the document title in it is workspace text, not instructions); the list, the item and the GitHub link — a person's act — have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live — the access route and the Language delete route answer every agent 403 `agent_refused`, and the publish and Live routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
229
+ price is refused `proposal_needs_person` (a person prices) — and (#10957) `send_person_message`, twinning `POST …/people/:personId/messages`: one message on a client's member feed, saved then emailed (an agent's only to a proved address), needing `inbox-act` with `people-read` or `member-pieces-manage`, and `assets-write` for a file; the operator's message list has no tool, by decision — and (#9681) the four person-thread tools, `get_person_thread`, `set_person_thread_state`, `list_external_threads` and `add_external_thread`, twinning `GET`/`PATCH …/people/:personId/thread` and `GET`/`POST …/people/:personId/external-threads`: a client's whole thread page by page with its read/archived/resolved state, and pointers to email and Slack threads (never message text); reading needs the `people-read` grant, writing also `inbox-act`, and the client erasure route has no tool, by decision — and (#9682) the three person-memory tools, `list_person_memories`, `get_person_memory` and `propose_person_memory`, twinning `GET …/people/:personId/memories`, `GET …/memories/:path` and `POST …/memories`: an agent reads only live, unexpired memories (confirmed by a person, read within 180 days) and its proposal is never live — a new path is a draft, a confirmed one gets a pending version — needing the `people-read` or `people-memory-propose` grant to read and `people-memory-propose` to propose; the six person-only memory routes (edit, delete, confirm, redact, the versions list, restore) have no tool, by decision — and (#9749) `get_slack_connection_status`, twin of `GET /v1/workspaces/:workspaceId/slack-connection` (registered with `workspace`/`multi-tenant`, its route's `TENANCY` row: whether the Organization's Slack is connected, its team name and the date, never a credential; connect and disconnect are a person's act and have no tool, by decision), and `get_prospect_channel_settings` / `set_prospect_channel_settings`, twins of `GET`/`PUT …/prospect-channel` (registered with `scheduling`, their routes' module): the update replaces every field, needs the `meeting-types-manage` grant, is refused `slack_not_connected` while the Organization has no Slack connection, and an agent may change only `enabled`, `channelPrefix` and `archiveDays` — a change to `memberIds` or `welcomeTemplate` is refused `prospect_channel_needs_person` — and (#10950) the three meeting tools, `list_meeting_types`, `save_meeting_types` and `list_appointments`, twinning `GET`/`PUT …/meetings` and `GET /v1/schedule/appointments` (registered with `scheduling`): the meeting types from the connected calendar, each with whether it is Live (`enabled`) and who can book it (`visibility`: `public`, `private` or `authenticated`), the provider's `providerEventTypeId` and `createdAt` when it serves them, and, with the `meeting-types-manage` grant, `providerEditUrl` — the read takes no `include` (#11122 D4); the save needs that grant and its required `enabledSlugs` replaces the Live list, while `customerSlugs` (Authenticated) and `privateSlugs` (Private) are exclusive — a slug in both is refused — and an omitted one keeps the stored list less the sent list's slugs, and no price is set there; the appointments read is every role's, and an agent's only with the `people-read` grant (#10986), takes `eventTypeId` for one type's bookings (#11122 D12) and `workspaceId` when the connection reaches several workspaces (#11753), and its attendee names and emails are public-written text; the three scheduling-connection routes have no tool, by decision — and (#10218) the content-suggestion pair, `draft_page_suggestions` and `decide_page_suggestion` — and (#10336) the draft pair, `save_draft` and `read_report`, twinning `PATCH`/`GET …/content/:type/:slug` with the `content-edit` grant: `save_draft` takes the page's `content` whole as the PATCH body and its `version` as `X-Draft-Version`, writes a draft version that never goes live, and answers 409 `conflict` with `currentVersion` when the draft moved; `read_report` returns the draft tip, the version a save must send, the page's stored layout (`structure`, #10962) and the token `save_structure` must send, its open suggestions and the route's check report (`ready`, `needs repair` or `needs your words`), computed by the route and never by the tool — and (#10956) `create_page`, twinning `POST …/content` with the `content-edit` grant: it creates a page and its first draft from `content` sent whole (its `type` and `slug` are the address) — a page type laid out in sections sent no words (no body, an empty one, or only its template's headings) starts from its template (#11793): the hub lays out the template's sections, each headed by its default headline with an empty field to write under, and stores the words and the layout together, refusing a title or description the words rules refuse, or a `sections` key, 422 `invalid` — never publishes, and answers 409 `conflict` when the page exists and 409 `slug_taken` when another page holds the link — and (#11791) `save_page`, twinning `PUT …/content/:type/:slug` with the `content-edit` grant, under the common names of `docs/internal/decisions/one-way-common-names.md`: it saves a page laid out in sections — its `fields` and its `words` (its sections in order, each `{ id, type, data }`) — in one draft version that holds the body the hub builds from the words and the layout together; `address` (type, slug, locale) rides the URL, and `version` with `structureToken` is what the save was based on, both `null` for a new page; a save whose basis is no longer the tip, or `null` for a page that exists, answers 409 `stale` with `currentVersion` and `currentStructureToken`, and a wrong field or word 422 `invalid` with `issues` (`path`, `message`), the one refusal pair whose details reach the tool; it never publishes; since #11811 it also saves an editorial page, whose `words` are `{ body }`, its Markdown, carrying the stored layout forward; since #11808 (#11852) a page laid out in sections may send `workingCopy`, `{ document, settings }` — the two tabs of a working copy as exported — in place of `fields` and `words`: the hub converts it against the tip it was based on (409 `stale` before converting), keeps the stored fields a Settings table cannot carry, refuses a wrong copy 422 `invalid` at `workingCopy.settings`, `workingCopy.document` or the envelope path, and answers the page as a working copy — and (#11811) `save_document`, twinning `POST …/documents/save` with the `content-edit` grant: it saves a `Document` (Instructions, Knowledge or a plugin-owned document) in the same common shape — `address` (`type` always `Document`, slug, locale) rides the body, as `save_asset`'s does, `version` is `null` for a new document, `fields` are the page save's, and `words` is `{ body }`; a moved tip or a `null` on an existing document answers 409 `stale` with `currentVersion` alone, and a wrong field or word — a plugin contract's misfit included, each issue at its path (`fields.contract_version`, `words.body`) — 422 `invalid`, both details rebuilt in `workspace-server.ts`; a document never goes live; since #11808 it takes, at a plugin-owned contract address only, `workingCopy` (`{ document, settings }`, the two tabs of a working copy as exported) in place of `fields` and `words`, which the hub converts against the tip it was based on and answers in the same form (the record form when the copy would outgrow its bounds) — and (#11808) `open_document`, twinning `GET …/documents/open` with the `content-edit` grant: the read twin of `save_document`, its `address` in the query, answering the envelope as the record or, with `as: "working-copy"` and only at a plugin-owned address (else 422 `invalid` at the key sent), the working copy (409 `not_representable` when it would outgrow its bounds); since #11882 `open_page` and `open_document` take `as` where they took `form`, which stays the old name for one release (the catalog keeps it, so the SDK never strips it), and the route refuses the two sent with different values 422 `invalid` at `as`; it never writes, and its `invalid` keeps `issues` (`path`, `message`, each cut to 200 characters). — and (#11809) `open_language_item` and `open_asset` (`mcp-workspace`'s `language.ts` and `library.ts`), twinning `GET …/language/:kind/:slug/open` and `GET …/assets/open` under the gate of the read each parallels (`docs-read`, `assets-read`): each takes `{ workspaceId, address }` (plus `locale` for an item) and answers the thing in the common envelope with the `version` its save takes, or — nothing at the address, or nothing the caller may read there — an item's blank, `version: null` and its kind's empty words, which the save with `version: null` starts; a file is never blank (`404 not_found`); and `open_page` and `open_document` answer the same kind of blank where they answered 404 — a page its template's starting sections, headed by the slug, and a document at a plugin-owned contract address its contract's constant fields and required headings, else nothing; no open writes, and the section map lists `open_` tools as reads. While both ways live, `create_page`, `save_draft` and `save_structure` open their descriptions with a deprecation naming `save_page` or `save_document`; nothing else about them changes until the removal (#11811 D2, D6) — and (#10661) `publish_draft`, twinning `POST …/content/:type/:slug/publish` with the `content-publish` grant: it publishes the draft tip (or a named version) exactly as a person holding that permission does, an agent without the grant is refused 403 `agent_refused` before anything is read, and it never widens Audience or re-enables a doc — and (#10345) the knowledge-base pair, `read_knowledge` and `read_knowledge_doc`, twinning `GET …/knowledge-base` and `GET …/knowledge-base/:type/:slug` with no grant (`docs-read` is every role's): the docs a named member may read (`userId`, by default the agent's own person), at the lower of the agent's person's role and that member's, so naming someone only narrows; Live does not gate them and a disabled doc never appears; `filter: "workspace-memory"` answers the always-loaded set with its `totalTokens` and an 8000-token `warning` — and (#10951) `get_workspace_settings`, twin of `GET /v1/workspaces/:workspaceId/general` (`mcp-workspace`'s `workspace_settings.ts`, no grant): the workspace's name, its own logo (`null` when the organization's applies) and the deployment's deliverable sender (`null` when none is configured, so a magnet's results and completion emails do not go out); the PUT, which renames the workspace and sets its logo, has no tool, by decision — it needs `workspace-settings`, which is never agent-grantable — and (#11806) `get_workspace_overview`, twin of `GET /v1/workspaces/:workspaceId/overview` (`mcp-workspace`'s `workspace_overview.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`, no query): a command's starting picture in one call — the site identity's name and SEO description, the default locale, the Knowledge docs `read_knowledge` lists for the caller with each one's draft `version` where `read_report` would answer it (`content-edit`, and the caller's own role reads the doc), and the Language items by kind and the magnets by state (`draft` only with `magnets-manage`); a part the caller's grants or the site's modules do not allow is `null` or left out and named in `withheld` (`grant` or `module`), never a refusal of the read — and (#12015) `get_command_craft`, twin of `GET /v1/workspaces/:workspaceId/craft/:command` (`mcp-workspace`'s `command_craft.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"`): one command's craft for the session, `{ command, pack, minShellVersion, craft }`, served only to a workspace that has the command's pack; a `pack_required` refusal carries `details` rebuilt from `pack`, `name` and `where` alone, and a `craft_unavailable` carries `service` alone (`entitlements`, `delivery` or `null`) — and the six site-profile tools, `get_site_identity`, `set_site_identity`, `get_site_seo`, `set_site_seo`, `get_welcome_email` and `set_welcome_email` (`mcp-workspace`'s `site_profile.ts`), twinning `GET`/`PUT …/identity`, `…/seo` and `…/welcome-email`: any member reads; each write needs the `site-profile` grant (`ailk:site-profile`), under which every logo and every SEO field but the description — robots and indexing above all — must be sent as read, else `site_profile_field_locked`; the theme pair has no tool, by decision — and (#10733, issue 10905, #10952) the six Language tools, `list_language_items`, `get_language_item`, `save_language_item`, `set_language_item_live`, `list_language_item_pages` and `get_topic_brief`, twinning `GET …/language`, `GET`/`PUT …/language/:kind/:slug`, `POST …/language/:kind/:slug/live`, `GET …/language/:kind/:slug/appears-on` and `GET …/language/topic/:slug/brief` (`mcp-workspace`'s `language.ts`): a workspace's glossary terms, FAQs and topics; reading needs no grant, saving the `content-edit` grant (`version: null` creates, a tip id updates, 409 `slug_taken` / `stale` otherwise), the Live switch `content-publish` with the `version` the person reviewed — `live: false` is how an agent takes an item off the site; the `DELETE` has no tool, by decision (#11802): it is permanent (nothing restores the item and its slug stays taken), so a person deletes in the Admin and the route refuses every agent `agent_refused`; tags are the hub's and never written by a tool; a topic is a keyword cluster for agents and is never shown to visitors, and `get_topic_brief` reads it as a writing brief — its kept rows scored best bets first, from the Live version when Live; the Topic's Keyword Planner import and the value-thresholds pair are a person's and have no tool, by decision — and (#10948) the three magnet tools, `list_magnets`, `get_magnet` and `save_magnet`, twinning `GET …/magnets`, `GET …/magnets/:id` and (#11810) `POST …/magnets/save` (`mcp-workspace`'s `magnets.ts`, registered with `multi-tenant` or `signal-collectors`): with the `magnets-manage` grant every magnet in full, without it only live ones as `{ id, slug, kind, title, landingPage, tags }`; `save_magnet` takes the save body whole, the magnet's `id` in it, so going live is `status: "live"` and the route alone refuses it (`402 plan_required`, `409 conversion_needs_email`), and an agent cannot set or change what a magnet charges (`403 magnet_pricing_needs_person`); with no `id` and `version: null` it creates a draft magnet — a slug another magnet holds is `409 stale` with its `currentVersion`, a slug the site reads by name `409 slug_reserved`, and the plan check is the Admin create's; the Admin's PATCH and create (which refuses every agent `403 agent_refused`) and the four captured-people lists have no tool, by decision — and (#10949) `get_workspace_offerings`, twin of `GET /v1/workspaces/:workspaceId/offerings` (registered with `multi-tenant` alone, its route's module; `mcp-workspace`'s `offerings.ts`): the Offerings tab's view — unavailable with `no_commerce` or `no_connection`, or the Organization's enabled products with this workspace's shown Prices and Recommended — read with no grant; its PUT, which switches a Price on or off, needs `workspace-settings`, which is never agent-grantable, and has no tool, by decision — and the two library reads, `list_workspace_pages` and `list_assets` (`mcp-workspace`'s `library.ts`, registered with `workspace` or `multi-tenant`), twinning `GET …/library/pages` and `GET …/library/assets`: every page with drafts included and its status (`live`, `draft`, or `disabled` — a person editor's alone), needing the `content-edit` grant, and the asset library read-only with each file's whole record (#11801) — its public path, title, description and record version, its size, an image's pixel size as the Admin's Details panel shows it, and its audience — for every role; both filter, page and name the workspace `{ id, name }` they read, and uploading has no tool — and (#11803) `save_asset` (`library.ts`, `gate: { allows: "assets-write" }`), twinning `POST …/assets/save`: it saves a file's title and description — and (#11879) its type, `fields.type`, one of the ten asset types — by its key, based on the record version `list_assets` returned; a stale save is `409 stale` and its tool error carries `details.currentVersion`, a wrong argument `422 invalid` with `details.issues` (`{ path, message }`, at most twenty, each cut to 200 characters, rebuilt in `workspace-server.ts`); it never replaces, renames, re-privacies or deletes a file, and never reaches a private, Knowledge or disabled one — and (#11680) the two site-vocabulary reads, `list_page_types` and `get_tag_vocabulary` (`mcp-workspace`'s `site_vocabulary.ts`, registered with `workspace` or `multi-tenant`, `gate: "tenant"` — any tenant of the workspace, no grant), twinning `GET …/page-types` and `GET …/tag-vocabulary`: the page types this hub's site can serve (the registry filtered by the modules the hub runs), each with its address, whether a site has only one, its template and that template's headings, and the context classes, Knowledge topic tags and status tags, each with what it means and who may set it; both are platform data and read no row; and (#11790) the third, `list_section_types` (same file, registration and gate), twinning `GET …/section-types` with an optional `type`: every section type a page's layout can hold with every field of its data — words or data, the Markdown form, whether it is required and inside which optional field, its values and bounds — plus its bounded lists and rules, or that one section type's; platform data, read no row; and (#12419) `list_image_slots` (`mcp-workspace`'s `content_draft.ts`, registered with `workspace` or `multi-tenant`, `gate: { allows: "content-edit" }`), twinning `GET …/image-slots` with an optional `address` and `sectionType`: what each section image slot needs — its shapes, how it is drawn (`fit`), its smallest useful width and height and its purpose — for every section type, or for the slots on one page's draft with each slot's section id, path, the need its own section's fields pick (`chosenBy`) and whether it is filled, at most 500 (`truncated`), a blank's slots where nothing is, as `open_page`; its `invalid` keeps `issues`, and `save_page` refuses an `asset:` image smaller than its slot needs; and (#11805) the fourth, `list_kinds` (same file, registration and gate), twinning `GET …/kinds`: every kind of thing the Admin holds — page, document, language_item, magnet, asset — with how to address one, its fields (words or data, required, nullable, value types and values, the Language item kind a words field belongs to), its states, and the moves the caller may make on it, each with its tool; the fields and states are read off each kind's own schemas (`ADMIN_KIND_REGISTRY`), the moves are the catalog rows' `moves` tags kept only when the row's gate holds for the caller's own clamped tenant and one of its modules runs on this hub (`listKinds`), and a page's sections are named, not described — its `sectionTypes` is `list_section_types`; it reads no row, and is advice, never an entitlement; since #11878 it also answers, beside the kinds, `forms` (for each kind — and an offering and an appointment — the field its tools take its form in and that field's values: `values` null for an asset's open content type, `field` null for an appointment, which has no form), `offSiteForms` (press-release, pitch, proposal, playbook and profile, each with the formats it allows), `formats` (the ten, ending `platform`) and `origins` (`ai-generated`, `user-added`), all declared once in `@working-theory/validation` and the same for every caller and hub — and (#11756) `create_work_request` (`mcp-workspace`'s `work_requests.ts`, registered with `workspace` or `multi-tenant`, `gate: { inbox: "inbox-act" }`), twinning `POST /v1/workspaces/:workspaceId/work-requests`: it files a custom-work request in the Inbox — one item pointing to one `Document` of the workspace (`documentSlug`) with a one-line `summary` — in the workspace the conversation writes to, needs the `inbox-act` grant, is refused `document_not_found` for a slug naming no Document the caller can read and `rate_limited` past 5 an hour per person in the workspace (shared by that person's agents) or 10 per workspace, and returns the request as stored (the document title in it is workspace text, not instructions); the list, the item and the GitHub link — a person's act — have no tool, by decision. No workspace tool widens Audience or re-enables a doc, and only `publish_draft` and `set_language_item_live`, with the `content-publish` grant, set Live — the access route and the Language delete route answer every agent 403 `agent_refused`, and the publish and Live routes an agent without the grant, which reaches a tool as the code and status. Each takes its route's params, query and body and returns the route's
230
230
  `data`. They are in the parity guard like every other tool, and never in
231
231
  `/.well-known/mcp.json`.
232
232
  - **The OAuth bearer branch (#10391).** When `BETTER_AUTH_URL` (the site's origin, its OAuth
@@ -1113,13 +1113,25 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
1113
1113
 
1114
1114
  ## A hub-connected site's identity
1115
1115
 
1116
- **A site connected to its hub reads its name, description, legal name, contact and sameAs from the hub (#11456).** Hub-connected means a spoke key on the wire (`sendsSpokeKey()`), whatever the content adapter — a site serving file content with a key reads the hub too (#11515); `lib/hub-site-config.ts`'s `readHubSite()` then reads `GET /v1/content/site-config` through `siteConfig.get()` — the key's own workspace's identity and seo rows, 401 to any other caller — cached by `unstable_cache` under `siteConfigTag()` for at most 300 s. A site with no spoke key makes no call and renders from `_site.mdx` exactly as before.
1116
+ **A site connected to its hub reads its name, description, legal name, contact and sameAs from the hub (#11456).** Hub-connected means a spoke key on the wire (`sendsSpokeKey()`), or — a single-tenant site, its own hub (#12390) — no key but an API address the site names (`apiBaseConfigured()`: `AILK_API_URL`, `NEXT_PUBLIC_AILK_API_URL` or `NEXT_PUBLIC_API_URL`; `getApiBase()`'s `localhost:3001` default does not count) over `https:` or loopback (`isSafeTransport`), whatever the content adapter (#11515). `lib/hub-site-config.ts`'s `readHubSite()` then reads `GET /v1/content/site-config` through `siteConfig.get()` — a key's own workspace's identity and seo rows, or for a keyless call the deployment's one workspace's on a deployment that has exactly one and is not a hub; 401 to any other caller — cached by `unstable_cache` under `siteConfigTag()` for at most 300 s, keyed by the spoke key's digest or, keyless, `keyless:` plus the API address's digest. A site with neither a key nor an API address makes no call and renders from `_site.mdx` exactly as before.
1117
+
1118
+ - **A refused keyless read is "no rows".** A 401 to a keyless read resolves `{ identity: null, seo: null }` inside the cached callback, so the refusal is held for the cache's lifetime with one `console.warn`, and the site renders from `_site.mdx` — the hub's own web app and a site on a multi-workspace deployment land here. A keyed 401 still throws, so a spoke whose key was revoked keeps its last good value. Any other failed keyless read makes the instance wait 15 s (`HUB_SITE_RETRY_SECONDS`) before asking again.
1117
1119
 
1118
1120
  - **Who reads it.** `resolveSiteBrand()` (`lib/site-brand.tsx`) gives the locale layout's title, description, og/twitter copy, Nav/Footer `siteName` and copyright holder, and both llms.txt headings; `lib/site-identity.ts` registers a JSON-LD reader (`setSiteIdentityReader`) whose registration keeps the file's `baseUrl`, so no hub value moves an `@id`; the contact email and the closing footer's contact lines read the value the last read resolved (`heldHubSite()`), because their seam is synchronous. `SITE_NAME`'s other readers (og image, icons, auth, mcp.json) keep the file value. The seo row's `robots.index` (the retired Allow search indexing) is read by nothing (#11978 D7).
1119
1121
  - **A hub row is the whole identity.** A field the operator cleared is absent, never refilled from the file; only a missing row, an unreadable one or a failed read falls back to `_site.mdx`. The file's top-level `contactEmail` stays the contact email's fallback. Hub values are collapsed to one line.
1120
- - **A save shows without a redeploy.** A 200 PUT of `identity` or `seo` sends the signed `site-config` revalidate event (`notifySiteConfigRevalidate`) to the site and its spokes; `app/api/revalidate/route.ts` answers it by purging `siteConfigTag()`. The 300 s expiry is the net for a spoke with no `revalidateUrl`.
1122
+ - **A save shows without a redeploy.** A 200 PUT of `identity` or `seo` sends the signed `site-config` revalidate event (`notifySiteConfigRevalidate`) to the env site target (`CONTENT_REVALIDATE_URL`) and the hub's spokes; `app/api/revalidate/route.ts` answers it by purging `siteConfigTag()`. The 300 s expiry is the net for a site with no revalidate target.
1121
1123
  - **A hub outage never breaks a page**: a failed read writes no cache entry and serves the instance's last good value, else the file.
1122
1124
 
1125
+ ## A site's navigation from its hub
1126
+
1127
+ **A hub-connected site renders its header and footer from its workspace's navigation record when its hub read carries one (#12401).** The record (#12400, `siteNavigationSchema` in `@working-theory/validation`) rides the identity read: `readHubSite()` (`lib/hub-site-config.ts`) answers `navigation: { version, record } | null` beside `identity` and `seo`, in the same request, the same `unstable_cache` entry under `siteConfigTag()` and the same 300 s expiry, so the `site-config` purge a save sends refreshes it on the next request. The cache key carries a shape part (`nav1`), so an entry written by older site code is never served as this shape.
1128
+
1129
+ - **What is read as no record.** An absent `navigation` key (a hub older than #12400), `null`, a version that is not a positive integer, or a record this site's schema refuses — the last two with one warning per distinct refused field path (`[hub-site-config] navigation unreadable at <path>`), never a value. The schema check is the only barrier between a hub value and a link (`localeHref` passes any scheme through), so only its parsed output is kept; `identity` and `seo` are parsed as before in every case.
1130
+ - **One translator.** `lib/site-navigation.ts`'s `navigationChrome(record, locale)` turns the record into the existing `Nav` and `Footer` props — no `@working-theory/ui` prop changes. A `page` target goes to the page's public path (`pagePath` at `SERVICES_PATH`, then `toPublicDocsHref`); a `path` or `url` target is used as stored, and the layout's three rewrite passes never run on a record. A label is the visitor's locale's text (a case-insensitive `byLocale` match), else its default text. Keys are positional and every one contains a dot (`rec.h0`, `rec.h1.g0.l2`, `rec.f0`), so a record label never replaces a `nav` message. Order is the record's; the hub has already removed every item whose page is not live. Every emitted address must be a site path or an `http:`/`https:` URL, else it throws; `safeNavigationChrome` catches that, logs one `[site-navigation] record not rendered (<error name>)` and answers `null`.
1131
+ - **The layout.** With a translation (`app/[locale]/layout.tsx`), the header items and menus, the header button (its Sign in display the record's where it sets one, else `_site.mdx`'s `header.signIn`), the footer columns, the bottom bar (the record's links, then the cookie-settings link; no FAQ) and the closing footer's locality and actions come from it; a part the record leaves out is absent, never refilled from the files. The legal bar, the mark-only rule, "Your account", the bare header's back arrow, the social links and the logo are unchanged. Every page carries one `<meta name="ailk-nav-source">` in `<head>`, `content="record"` with `data-version="<n>"` or `content="files"`, whatever the header style; the element wrapping the site header, when one renders, carries the same as `data-nav-source` / `data-nav-version` (for #12403's and #12404's proof of render).
1132
+ - **Styles.** `resolveHomeChrome` (`lib/page-chrome.ts`) lays the record's `header.style`, `footer.style` and each route family's `header` / `footer` over `_site.mdx`'s through `withNavigationStyles`, where the record sets them, and only when the record renders: a record the translator refuses renders the files under the files' styles. A family's `path` stays the file's, and a page's own frontmatter still wins over both. It answers the rendered record as `navigation`, which is the layout's one read of it.
1133
+ - **The fallback, until #12404.** With no record, no hub read, or a failed read with nothing held, every page renders from `lib/nav-config.ts`, its `nav` labels and `_site.mdx` exactly as before; those stay read on every request until #12404 removes them.
1134
+
1123
1135
  ## AEO & performance
1124
1136
 
1125
1137
  - Static rendering is the default. Don't introduce client rendering without a reason.
@@ -1136,7 +1148,11 @@ A list page whose frontmatter sets `navOnly: true` (valid on a registry list typ
1136
1148
  - Don't reach into `apps/api` or `apps/mcp` from `apps/web`. They're peer apps — talk via HTTP/MCP.
1137
1149
  - Don't commit images to `screenshots/` — only the `.gitkeep` is tracked.
1138
1150
 
1139
- Last updated: 2026-11-24 — § Pricing page: the billing toggle's three `pricingOfferings` keys, placed on every pricing section by `renderPage` (#12284) — verified against `messages/en.json` and `packages/page-renderer/src/{index.tsx,billing-toggle-labels.ts}`; 2026-11-24 — § Pricing page: every pricing section with a shown or hidden billing toggle follows the `ailk:billing-period` event, so two sections on one page show one period (#12281) — verified against `packages/ui/src/sections/Pricing.tsx`; 2026-11-24 — § Pricing page: a plan column's price carries the product's Stripe unit label, as its card's does (#12280) — verified against `lib/offerings-pricing.ts` and `packages/ui/src/blocks/PlanBar.tsx`.
1151
+ Last updated: 2026-11-26 — § A site's navigation from its hub: the hub read carries the workspace's navigation record, one translator turns it into the Nav and Footer props, the record's styles win over `_site.mdx`'s where it sets them and only when it renders, and the `<head>` meta and the header wrapper name its source (#12401) — verified against `lib/{hub-site-config,site-navigation,page-chrome}.ts` and `app/[locale]/layout.tsx`.
1152
+
1153
+ Prior: 2026-11-25 — § A hub-connected site's identity: a single-tenant site with no spoke key reads its one workspace's identity and seo when it names an API address over `https:` or loopback, a refused keyless read is held as no rows, and a failed one waits 15 s (#12390) — verified against `lib/hub-site-config.ts`, `packages/api-client/src/http.ts`, `packages/api/src/routes/content/site-config.ts` and `packages/api/src/services/revalidation.ts`.
1154
+
1155
+ Prior: 2026-11-24 — § Pricing page: the billing toggle's three `pricingOfferings` keys, placed on every pricing section by `renderPage` (#12284) — verified against `messages/en.json` and `packages/page-renderer/src/{index.tsx,billing-toggle-labels.ts}`; 2026-11-24 — § Pricing page: every pricing section with a shown or hidden billing toggle follows the `ailk:billing-period` event, so two sections on one page show one period (#12281) — verified against `packages/ui/src/sections/Pricing.tsx`; 2026-11-24 — § Pricing page: a plan column's price carries the product's Stripe unit label, as its card's does (#12280) — verified against `lib/offerings-pricing.ts` and `packages/ui/src/blocks/PlanBar.tsx`.
1140
1156
 
1141
1157
  Prior: 2026-11-23 — § Pricing page: a comparison table's plan columns — the plan column, `withPlanColumns`, `offeringsPlanColumns`, the start period and the billing event, the unresolved column and its advisory finding, the checkout cell-link rule — and the retired `with-comparison-table` read as a pricing section and a comparison table (#12246) — verified against `lib/pricing-page.ts`, `lib/offerings-pricing.ts`, `packages/validation/src/schemas/{page-sections,offerings}.ts`, `packages/ui/src/blocks/PlanBar.tsx` and `packages/ui/src/sections/ComparisonTable.tsx`.
1142
1158