diff --git a/.changeset/36029-book-audience-system-permission.md b/.changeset/36029-book-audience-system-permission.md
index 524e3b7c36a..e0516c53f2a 100644
--- a/.changeset/36029-book-audience-system-permission.md
+++ b/.changeset/36029-book-audience-system-permission.md
@@ -17,7 +17,7 @@ Skills-docs: none — no `skills/` page teaches the book audience forms; `conten
A book's `audience` (ADR-0046 §6.7) takes a fourth form, `{ systemPermission: 'TOKEN' }`: the book's pages are read by a signed-in caller who holds that capability through any permission set, the same caller an app with `requiredPermissions: ['TOKEN']` opens for. `{ permissionSet }` names one set, so it could not gate a manual on a capability several sets grant (`setup.access` comes with `organization_admin`, `admin_full_access` and any delegated-admin set an application authors).
-- **`@objectstack/spec`.** `BookAudienceSchema` and `BookAudience` gain the arm. It is strict, so `{ systemPermission, label }` is refused at parse; an object that also carries `permissionSet` still parses as the older, non-strict `{ permissionSet }` arm with the other key dropped, as before. `BookAudience` is a wider union now: TypeScript code that reads `.permissionSet` after a bare `typeof audience === 'object'` check narrows by key instead (`'permissionSet' in audience`). `AudienceCaller` gains `systemPermissions`, and `audienceAllows` admits the arm only when that list holds the token; an absent list denies (fail closed). Every other form answers as before.
+- **`@objectstack/spec`.** `BookAudienceSchema` and `BookAudience` gain the arm. It is strict, so `{ systemPermission, label }` is refused at parse, and an object that also carries `permissionSet` is refused too: an audience names one gate. `BookAudience` is a wider union now: TypeScript code that reads `.permissionSet` after a bare `typeof audience === 'object'` check narrows by key instead (`'permissionSet' in audience`). `AudienceCaller` gains `systemPermissions`, and `audienceAllows` admits the arm only when that list holds the token; an absent list denies (fail closed). Every other form answers as before.
- **`@objectstack/rest`.** The docs audience reads the caller's own `systemPermissions` (the list every `requiredPermissions` arm of the `/meta` read gate reads) when some book carries the new form, on `GET /meta/doc` (with and without `?include=content`), `GET /meta/doc/:name`, `GET /meta/book`, `GET /meta/book/:name/tree` and the app-nav `doc` entries. New: `anySystemPermissionAudience`, and the optional `resolveAudienceSystemPermissions` port on `MetaReadGateAudienceSources` for a transport whose audience reads someone else's holdings.
- **`@objectstack/runtime`.** The MCP docs tools (`search_package_docs`, `read_package_doc`) gate on the same form; on an OAuth grant they read the delegating person's own capabilities, never the token's ceiling.
- **`@objectstack/setup`, `@objectstack/studio`.** Each package now ships a manual (`setup_manual`, `studio_manual`) claiming its package's doc namespace (`setup_*`, `studio_*`), gated on `setup.access` / `studio.access`. Before, those docs were claimed by no book, so they fell back to `org`: listed to administrators only by the Console's docs index, but readable at their address, and through `?include=content`, by every signed-in member. Now a member who cannot open Setup gets `setup_overview` in neither list and a `403 PERMISSION_DENIED` on its read; an administrator reads it as before. The docs' Console address now names the manual (`/apps/com.objectstack.setup/docs/setup/setup_overview`) in place of the package's implicit one; the flat `/docs/setup_overview` permalink still finds it.
diff --git a/.changeset/37613-book-audience-one-gate.md b/.changeset/37613-book-audience-one-gate.md
new file mode 100644
index 00000000000..67dbaa1e90d
--- /dev/null
+++ b/.changeset/37613-book-audience-one-gate.md
@@ -0,0 +1,22 @@
+---
+'@objectstack/spec': minor
+'@objectstack/lint': minor
+---
+
+fix(spec)!: a book audience names one gate, and a gated book claims its pages by name
+
+Clause-②: yes (narrowing)
+Metadata-protocol: narrowed
+Skills-docs: none — no `skills/` page teaches the book audience forms; `content/docs/ui/doc-pages.mdx` documents both refusals in this change
+
+
+
+**BREAKING** for two book shapes (ADR-0046 §6.7) that were accepted and meant less than they said. Stored books are not rewritten or refused at boot; the next save or publish of such a book is refused with the fix named.
+
+- **`@objectstack/spec`.** `BookAudienceSchema` refuses an `audience` naming both `permissionSet` and `systemPermission`. The older `{ permissionSet }` arm is a plain object, so the pair used to parse as the set form with the capability stripped: the author believed the book was gated on a capability, and it was gated on one set. `defineStack`, `os validate` and the `/meta` save now refuse it, and the message says which key to keep. Only the second gate key is refused: every other shape that parsed before still parses the same way.
+- **`@objectstack/lint`.** New error `book-gated-catch-all-include` (`validateBookAudienceClaims`): a book whose `audience` is `{ permissionSet }` or `{ systemPermission }` with a group claiming docs by `include: '*'`. A package scope leaves out only a doc stamped with another package, so a stored doc bound to no package is in every scope, and the catch-all claimed it too and hid it from every reader outside the audience. It runs on `os validate`, `os build` and `os lint`, and at the runtime publish gate on a book write (Studio, REST `/meta`, MCP).
+
+## FROM → TO
+
+- `audience: { permissionSet: 'crm_admin', systemPermission: 'setup.access' }` → `audience: { systemPermission: 'setup.access' }` (everyone holding the capability through any set) or `audience: { permissionSet: 'crm_admin' }` (the holders of that one set).
+- `audience: { systemPermission: 'crm.runbook' }` with `groups: [{ key: 'all', label: 'All', include: '*' }]` → `include: 'crm_runbook_*'` (the package's doc namespace), a tag include `{ tag: 'runbook' }`, or pinned `pages`.
diff --git a/content/docs/deployment/cli.mdx b/content/docs/deployment/cli.mdx
index 4f8873b9e80..686f77c642e 100644
--- a/content/docs/deployment/cli.mdx
+++ b/content/docs/deployment/cli.mdx
@@ -937,7 +937,7 @@ os compile --json # JSON output for CI pipelines
→ Normalizing stack definition...
→ Lowering inline handlers...
→ Validating protocol compliance...
- → Running author-time rules (85)...
+ → Running author-time rules (86)...
→ Checking that every required capability has a provider installable in this edition...
→ Collecting package docs (ADR-0046)... 0 collected
→ Writing artifact...
diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx
index c26b0ffc8a1..72c0ea627a1 100644
--- a/content/docs/deployment/validating-metadata.mdx
+++ b/content/docs/deployment/validating-metadata.mdx
@@ -549,6 +549,7 @@ orthogonal to both, and no cell here can carry it; it is written out in
| Advisory: credential literals in a flow — an `http` node's headers or url query, a node's `connectorConfig.input` (`flow-credential-literal`, #20698) | ✓ | ✓ | ✓ | ✓ᶠ |
| Advisory: credential literals in a connector — its header and environment maps, and a stdio MCP credential route (`connector-credential-literal`, #29424) | ✓ | ✓ | ✓ | ✓ᶜ |
| `views[]` and page-component conditional-visibility predicates — CEL syntax, parse budget, bare identifiers, binding-root layer; schema path refs on `views[]` only (ADR-0089 D3b, #7010; page components at the save door #24491); an app navigation entry's `visible` at the save door (#28663) | ✓ | ✓ | ✓ | ✓ᵛᵖᵃ |
+| Gated book claims — a book whose `audience` is `{ permissionSet }` or `{ systemPermission }` claiming docs by `include: '*'`, which also takes every doc bound to no package away from readers outside the audience (`book-gated-catch-all-include`, ADR-0046 §6.7) | ✓ | ✓ | ✓ | ✓ᵇ |
| Advisory: record titles, semantic field pointers (ADR-0085), action placement, seed replay/state safety, capability references | ✓ | ✓ | ✓ | — |
| Advisory: form-section layout | ✓ | ✓ | ✓ | ✓ᵛ |
| Advisory: liveness | ✓ | ✓ | ✓ | ✓ᵉᵐᵈˢ |
@@ -869,7 +870,7 @@ A clean run walks the registry and reports timing:
Config: /path/to/support-desk/objectstack.config.ts
Load time: 21ms
→ Validating against ObjectStack Protocol...
- → Running author-time rules (85)...
+ → Running author-time rules (86)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...
diff --git a/content/docs/getting-started/build-with-claude-code.mdx b/content/docs/getting-started/build-with-claude-code.mdx
index 1050043c233..e6e21789448 100644
--- a/content/docs/getting-started/build-with-claude-code.mdx
+++ b/content/docs/getting-started/build-with-claude-code.mdx
@@ -318,7 +318,7 @@ visible: 'status != "resolved"'
◆ Validate
────────────────────────────────────────
→ Validating against ObjectStack Protocol...
- → Running author-time rules (85)...
+ → Running author-time rules (86)...
✗ Author-time rules failed (1 issue)
• stack · action 'resolve_ticket' visible: bare reference `status` — a
diff --git a/content/docs/references/system/book.mdx b/content/docs/references/system/book.mdx
index 607ff345a4f..28886e7c9d2 100644
--- a/content/docs/references/system/book.mdx
+++ b/content/docs/references/system/book.mdx
@@ -63,6 +63,13 @@ const result = BookSchema.parse(data);
| **_lockDocsUrl** | `string` | optional | Optional documentation link surfaced next to _lockReason. |
| **overrides** | `{ package: string; basedOn: string }` | optional | Override declaration (ADR-0146 D2): `{ package, basedOn }` — this item of "``.custom" replaces the base package's same-named item whole. `basedOn` is recorded and never gates; a base's upgrade plan reads it only as advice. |
+### Nested Shape: `Book.audience[option 3]`
+
+| Property | Type | Required | Description |
+| :--- | :--- | :--- | :--- |
+| **permissionSet** | `string` | ✅ | |
+| **systemPermission** | `never` | optional | Not accepted beside `permissionSet`: an audience names one gate |
+
### Nested Shape: `Book.groups[number]`
| Property | Type | Required | Description |
@@ -110,6 +117,7 @@ Type: `'public'`
| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **permissionSet** | `string` | ✅ | |
+| **systemPermission** | `never` | optional | Not accepted beside `permissionSet`: an audience names one gate |
---
diff --git a/content/docs/ui/doc-pages.mdx b/content/docs/ui/doc-pages.mdx
index 02d420d3365..10571819f42 100644
--- a/content/docs/ui/doc-pages.mdx
+++ b/content/docs/ui/doc-pages.mdx
@@ -252,12 +252,16 @@ capability through any permission set — the same caller an app with
`requiredPermissions: ['crm.read_runbook']` opens for. Use the capability form for the
manual of an app gated on a capability several sets grant: naming one of those sets would
shut out the holders of every other one. A caller whose holdings cannot be resolved is
-denied — the gate fails closed.
+denied — the gate fails closed. An audience names one gate: an object carrying both
+`permissionSet` and `systemPermission` is refused when the book is parsed, and the message
+says which key to keep.
Claim a gated book's pages by name (a namespace glob such as `include: 'crm_runbook_*'`, or
pinned `pages`), not with `include: '*'`. A package scope leaves out only a doc stamped with
*another* package, so a stored doc bound to no package is in every scope: a catch-all gated
book would claim it as well and take it away from every reader outside the audience.
+`os validate`, `os build` and `os lint` refuse such a group (`book-gated-catch-all-include`),
+and so does saving the book through Studio, REST `/meta` or MCP.
The gate is a **capability** reference, never a distribution one: packages own permission
diff --git a/content/docs/ui/react-pages.mdx b/content/docs/ui/react-pages.mdx
index 42f0c623de9..7d50343038e 100644
--- a/content/docs/ui/react-pages.mdx
+++ b/content/docs/ui/react-pages.mdx
@@ -404,7 +404,7 @@ objectstack validate
────────────────────────────────────────
→ Loading configuration...
→ Validating against ObjectStack Protocol...
- → Running author-time rules (85)...
+ → Running author-time rules (86)...
→ Checking that every required capability has a provider installable in this edition...
→ Checking package docs (ADR-0046)...
diff --git a/packages/apps/setup/package.json b/packages/apps/setup/package.json
index ba0071679f0..8f093dd486a 100644
--- a/packages/apps/setup/package.json
+++ b/packages/apps/setup/package.json
@@ -21,6 +21,7 @@
},
"scripts": {
"build": "tsup && node ../../../scripts/check-dts-emitted.mjs",
+ "test": "vitest run",
"typecheck": "tsc --noEmit"
},
"dependencies": {
diff --git a/packages/apps/setup/src/manual-claims-docs.test.ts b/packages/apps/setup/src/manual-claims-docs.test.ts
new file mode 100644
index 00000000000..b49c97bfcff
--- /dev/null
+++ b/packages/apps/setup/src/manual-claims-docs.test.ts
@@ -0,0 +1,58 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * [ADR-0046 §6.7] Every doc this package registers is claimed by its manual,
+ * and gated as the manual is.
+ *
+ * The Setup manual claims its pages by the package's doc namespace
+ * (`include: 'setup_*'`), and nothing else holds the package's docs to that
+ * prefix: `docs/namespace-prefix` runs in `os build`, and this package is built
+ * by tsup. So this pin reads what the plugin really registers, the shipped
+ * constants and nothing copied, and resolves the audiences the docs doors
+ * resolve. A doc named outside the prefix is claimed by no book and falls back
+ * to `org`; the constant put back to `'*'` also claims the control doc bound to
+ * no package. Either turns this red.
+ */
+
+import { describe, expect, it } from 'vitest';
+import { resolveDocAudiences, type AudienceBook, type ResolverDoc } from '@objectstack/spec/system';
+import { createSetupAppPlugin, SETUP_APP_PACKAGE_ID, SETUP_MANUAL_BOOK } from './index.js';
+
+interface Registered {
+ id: string;
+ docs: Array<{ name: string; label?: string }>;
+ books: AudienceBook[];
+}
+
+async function registeredManifest(): Promise {
+ const registered: Registered[] = [];
+ const manifest = { register: (m: Registered) => registered.push(m) };
+ await createSetupAppPlugin().start({ getService: (name: string) => (name === 'manifest' ? manifest : undefined) });
+ expect(registered, 'start() registers one manifest').toHaveLength(1);
+ return registered[0]!;
+}
+
+describe('setup_manual claims every doc @objectstack/setup registers', () => {
+ it('registers the manual beside its docs', async () => {
+ const m = await registeredManifest();
+ expect(m.id).toBe(SETUP_APP_PACKAGE_ID);
+ expect(m.books).toEqual([SETUP_MANUAL_BOOK]);
+ expect(m.docs.length, 'a package with no docs pins nothing').toBeGreaterThan(0);
+ });
+
+ it('gives every registered doc the manual\'s audience, and leaves a doc bound to no package alone', async () => {
+ const m = await registeredManifest();
+ // The metadata layer stamps each registered item with its package.
+ const books: AudienceBook[] = m.books.map((b) => ({ ...b, packageId: m.id }));
+ const docs: ResolverDoc[] = [
+ ...m.docs.map((d) => ({ name: d.name, label: d.label, packageId: m.id })),
+ // Control: a stored doc bound to no package is in every package scope.
+ { name: 'unbound_page', label: 'Unbound' },
+ ];
+ const audiences = resolveDocAudiences(books, docs);
+ for (const doc of m.docs) {
+ expect(audiences.get(doc.name), `${doc.name} is not claimed by setup_manual`).toEqual([SETUP_MANUAL_BOOK.audience]);
+ }
+ expect(audiences.get('unbound_page'), 'the manual claims a doc bound to no package').toEqual(['org']);
+ });
+});
diff --git a/packages/apps/setup/tsconfig.json b/packages/apps/setup/tsconfig.json
index b93023e07c8..abe88b93996 100644
--- a/packages/apps/setup/tsconfig.json
+++ b/packages/apps/setup/tsconfig.json
@@ -7,5 +7,5 @@
"declarationMap": true
},
"include": ["src/**/*"],
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
+ "exclude": ["node_modules", "dist"]
}
diff --git a/packages/apps/setup/vitest.config.ts b/packages/apps/setup/vitest.config.ts
new file mode 100644
index 00000000000..27ec77c5fe5
--- /dev/null
+++ b/packages/apps/setup/vitest.config.ts
@@ -0,0 +1,32 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+import { defineConfig } from 'vitest/config';
+import path from 'node:path';
+
+export default defineConfig({
+ test: {
+ // A late console.* must not redden a green suite: vitest's worker forwards
+ // console output over RPC and a write landing after teardown is rejected
+ // into an unhandled error. Mechanism and measured costs:
+ // examples/app-showcase/vitest.config.ts; enforced repo-wide by
+ // scripts/check-console-intercept-disarm.mjs.
+ disableConsoleIntercept: true,
+ },
+ resolve: {
+ // The manual pin (`src/manual-claims-docs.test.ts`) reads this package's
+ // registered docs and book through the spec's own audience resolver, so
+ // both specifiers resolve to SOURCE, never to a `dist/` that may be behind
+ // it (`pnpm check:test-source-alias`). Array form with anchored patterns:
+ // the object form matches by prefix and would swallow sibling subpaths.
+ alias: [
+ {
+ find: /^@objectstack\/platform-objects\/apps$/,
+ replacement: path.resolve(__dirname, '../../platform-objects/src/apps/index.ts'),
+ },
+ {
+ find: /^@objectstack\/spec\/system$/,
+ replacement: path.resolve(__dirname, '../../spec/src/system/index.ts'),
+ },
+ ],
+ },
+});
diff --git a/packages/apps/studio/package.json b/packages/apps/studio/package.json
index 222326d3916..d3038b29afe 100644
--- a/packages/apps/studio/package.json
+++ b/packages/apps/studio/package.json
@@ -21,6 +21,7 @@
},
"scripts": {
"build": "tsup && node ../../../scripts/check-dts-emitted.mjs",
+ "test": "vitest run",
"typecheck": "tsc --noEmit"
},
"dependencies": {
diff --git a/packages/apps/studio/src/manual-claims-docs.test.ts b/packages/apps/studio/src/manual-claims-docs.test.ts
new file mode 100644
index 00000000000..51ddcbbcfa2
--- /dev/null
+++ b/packages/apps/studio/src/manual-claims-docs.test.ts
@@ -0,0 +1,58 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * [ADR-0046 §6.7] Every doc this package registers is claimed by its manual,
+ * and gated as the manual is.
+ *
+ * The Studio manual claims its pages by the package's doc namespace
+ * (`include: 'studio_*'`), and nothing else holds the package's docs to that
+ * prefix: `docs/namespace-prefix` runs in `os build`, and this package is built
+ * by tsup. So this pin reads what the plugin really registers, the shipped
+ * constants and nothing copied, and resolves the audiences the docs doors
+ * resolve. A doc named outside the prefix is claimed by no book and falls back
+ * to `org`; the constant put back to `'*'` also claims the control doc bound to
+ * no package. Either turns this red.
+ */
+
+import { describe, expect, it } from 'vitest';
+import { resolveDocAudiences, type AudienceBook, type ResolverDoc } from '@objectstack/spec/system';
+import { createStudioAppPlugin, STUDIO_APP_PACKAGE_ID, STUDIO_MANUAL_BOOK } from './index.js';
+
+interface Registered {
+ id: string;
+ docs: Array<{ name: string; label?: string }>;
+ books: AudienceBook[];
+}
+
+async function registeredManifest(): Promise {
+ const registered: Registered[] = [];
+ const manifest = { register: (m: Registered) => registered.push(m) };
+ await createStudioAppPlugin().start({ getService: (name: string) => (name === 'manifest' ? manifest : undefined) });
+ expect(registered, 'start() registers one manifest').toHaveLength(1);
+ return registered[0]!;
+}
+
+describe('studio_manual claims every doc @objectstack/studio registers', () => {
+ it('registers the manual beside its docs', async () => {
+ const m = await registeredManifest();
+ expect(m.id).toBe(STUDIO_APP_PACKAGE_ID);
+ expect(m.books).toEqual([STUDIO_MANUAL_BOOK]);
+ expect(m.docs.length, 'a package with no docs pins nothing').toBeGreaterThan(0);
+ });
+
+ it('gives every registered doc the manual\'s audience, and leaves a doc bound to no package alone', async () => {
+ const m = await registeredManifest();
+ // The metadata layer stamps each registered item with its package.
+ const books: AudienceBook[] = m.books.map((b) => ({ ...b, packageId: m.id }));
+ const docs: ResolverDoc[] = [
+ ...m.docs.map((d) => ({ name: d.name, label: d.label, packageId: m.id })),
+ // Control: a stored doc bound to no package is in every package scope.
+ { name: 'unbound_page', label: 'Unbound' },
+ ];
+ const audiences = resolveDocAudiences(books, docs);
+ for (const doc of m.docs) {
+ expect(audiences.get(doc.name), `${doc.name} is not claimed by studio_manual`).toEqual([STUDIO_MANUAL_BOOK.audience]);
+ }
+ expect(audiences.get('unbound_page'), 'the manual claims a doc bound to no package').toEqual(['org']);
+ });
+});
diff --git a/packages/apps/studio/tsconfig.json b/packages/apps/studio/tsconfig.json
index b93023e07c8..abe88b93996 100644
--- a/packages/apps/studio/tsconfig.json
+++ b/packages/apps/studio/tsconfig.json
@@ -7,5 +7,5 @@
"declarationMap": true
},
"include": ["src/**/*"],
- "exclude": ["node_modules", "dist", "**/*.test.ts"]
+ "exclude": ["node_modules", "dist"]
}
diff --git a/packages/apps/studio/vitest.config.ts b/packages/apps/studio/vitest.config.ts
new file mode 100644
index 00000000000..27ec77c5fe5
--- /dev/null
+++ b/packages/apps/studio/vitest.config.ts
@@ -0,0 +1,32 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+import { defineConfig } from 'vitest/config';
+import path from 'node:path';
+
+export default defineConfig({
+ test: {
+ // A late console.* must not redden a green suite: vitest's worker forwards
+ // console output over RPC and a write landing after teardown is rejected
+ // into an unhandled error. Mechanism and measured costs:
+ // examples/app-showcase/vitest.config.ts; enforced repo-wide by
+ // scripts/check-console-intercept-disarm.mjs.
+ disableConsoleIntercept: true,
+ },
+ resolve: {
+ // The manual pin (`src/manual-claims-docs.test.ts`) reads this package's
+ // registered docs and book through the spec's own audience resolver, so
+ // both specifiers resolve to SOURCE, never to a `dist/` that may be behind
+ // it (`pnpm check:test-source-alias`). Array form with anchored patterns:
+ // the object form matches by prefix and would swallow sibling subpaths.
+ alias: [
+ {
+ find: /^@objectstack\/platform-objects\/apps$/,
+ replacement: path.resolve(__dirname, '../../platform-objects/src/apps/index.ts'),
+ },
+ {
+ find: /^@objectstack\/spec\/system$/,
+ replacement: path.resolve(__dirname, '../../spec/src/system/index.ts'),
+ },
+ ],
+ },
+});
diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts
index 251a5b950bf..d91276cdd06 100644
--- a/packages/lint/src/authoring-rules.ts
+++ b/packages/lint/src/authoring-rules.ts
@@ -122,6 +122,7 @@ import { validateJsxPages } from './validate-jsx-pages.js';
import { validateReactPages } from './validate-react-pages.js';
import { validatePageSourceStyling } from './validate-page-source-styling.js';
import { validateCapabilityReferences } from './validate-capability-references.js';
+import { validateBookAudienceClaims } from './validate-book-audience-claims.js';
import {
validateFlowApiTriggerSecret,
validateFlowSubflowTargets,
@@ -1639,6 +1640,22 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [
+ 'severity change on a published rule id and belongs in its own PR, not riding a wiring change.',
run: (stack) => validateCapabilityReferences(stack),
},
+ // ADR-0046 §6.7 — a gated book claims its pages by name. `include: '*'` on a
+ // book with a `{ permissionSet }` / `{ systemPermission }` audience also
+ // claims every doc bound to no package (in every package scope) and hides it
+ // from every reader outside the audience. Decidable from the book alone, so it
+ // gates, and it judges the written book at the runtime door too: a Studio,
+ // REST `/meta` or MCP author of a book is the same author.
+ {
+ name: 'validateBookAudienceClaims',
+ tier: 'gating',
+ input: 'parsed',
+ commands: ALL,
+ source: 'packages/lint/src/validate-book-audience-claims.ts',
+ surfaces: CLI_AND_RUNTIME,
+ runtimeTypes: ['book'],
+ run: (stack) => validateBookAudienceClaims(stack),
+ },
// A flow that LOOKS armed and never launches — silently. Reads the pre-parse
// tier so an author sees what they wrote.
//
diff --git a/packages/lint/src/index.ts b/packages/lint/src/index.ts
index d0a3884fa19..988e574abb5 100644
--- a/packages/lint/src/index.ts
+++ b/packages/lint/src/index.ts
@@ -373,6 +373,11 @@ export {
CAPABILITY_REFERENCE_UNKNOWN,
} from './validate-capability-references.js';
export type { CapabilityRefFinding, CapabilityRefSeverity } from './validate-capability-references.js';
+export {
+ validateBookAudienceClaims,
+ BOOK_GATED_CATCH_ALL_INCLUDE,
+} from './validate-book-audience-claims.js';
+export type { BookAudienceClaimFinding } from './validate-book-audience-claims.js';
export {
validateApprovalApprovers,
diff --git a/packages/lint/src/validate-book-audience-claims.test.ts b/packages/lint/src/validate-book-audience-claims.test.ts
new file mode 100644
index 00000000000..7e403561c73
--- /dev/null
+++ b/packages/lint/src/validate-book-audience-claims.test.ts
@@ -0,0 +1,110 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * [ADR-0046 §6.7] `book-gated-catch-all-include`: a book gated by `audience`
+ * never claims docs by `include: '*'`. One positive and one negative pin per
+ * gated form, the passing claims by name, and the two doors the rule runs at
+ * (the CLI registry and the runtime publish gate).
+ */
+
+import { describe, expect, it } from 'vitest';
+import { AUTHORING_RULES, runAuthoringRules } from './authoring-rules.js';
+import { runRuntimeAuthoringRules } from './runtime-gate.js';
+import {
+ BOOK_GATED_CATCH_ALL_INCLUDE,
+ validateBookAudienceClaims,
+} from './validate-book-audience-claims.js';
+
+const book = (audience: unknown, include: unknown, extra: Record = {}) => ({
+ name: 'crm_admin_guide',
+ label: 'Admin Guide',
+ ...(audience === undefined ? {} : { audience }),
+ groups: [{ key: 'all', label: 'All', ...(include === undefined ? {} : { include }), ...extra }],
+});
+
+const rulesOf = (stack: Record) => validateBookAudienceClaims(stack).map((f) => f.rule);
+
+describe('validateBookAudienceClaims — a gated book claims its pages by name', () => {
+ const GATES = [
+ { permissionSet: 'crm_admin' },
+ { systemPermission: 'setup.access' },
+ ];
+
+ for (const gate of GATES) {
+ const form = Object.keys(gate)[0];
+
+ it(`refuses the catch-all on a { ${form} } book`, () => {
+ const findings = validateBookAudienceClaims({ books: [book(gate, '*')] });
+ expect(findings).toHaveLength(1);
+ expect(findings[0]).toMatchObject({
+ severity: 'error',
+ rule: BOOK_GATED_CATCH_ALL_INCLUDE,
+ where: 'book "crm_admin_guide"',
+ path: 'books[0].groups[0].include',
+ });
+ expect(findings[0].message).toContain(`${form}:`);
+ expect(findings[0].message).toContain('group "all"');
+ expect(findings[0].hint).toContain('namespace glob');
+ });
+
+ it(`accepts a { ${form} } book that claims by namespace glob, tag or pinned pages`, () => {
+ expect(rulesOf({ books: [book(gate, 'crm_admin_*')] })).toEqual([]);
+ expect(rulesOf({ books: [book(gate, { tag: 'admin' })] })).toEqual([]);
+ expect(rulesOf({ books: [book(gate, undefined, { pages: ['crm_admin_setup'] })] })).toEqual([]);
+ });
+ }
+
+ it('refuses every all-star spelling and names the group that carries it', () => {
+ const stack = {
+ books: [{
+ name: 'ops_manual',
+ audience: { systemPermission: 'ops.access' },
+ groups: [
+ { key: 'intro', label: 'Intro', include: 'ops_intro_*' },
+ { key: 'rest', label: 'Rest', include: '**' },
+ ],
+ }],
+ };
+ const findings = validateBookAudienceClaims(stack);
+ expect(findings.map((f) => f.path)).toEqual(['books[0].groups[1].include']);
+ expect(findings[0].message).toContain('group "rest"');
+ expect(findings[0].message).toContain("include: '**'");
+ });
+
+ it('leaves a book gated on nothing alone, whatever it claims', () => {
+ for (const audience of [undefined, 'org', 'public']) {
+ expect(rulesOf({ books: [book(audience, '*')] }), String(audience)).toEqual([]);
+ }
+ });
+
+ it('reads a map-shaped books collection as well as an array', () => {
+ const findings = validateBookAudienceClaims({
+ books: { crm_admin_guide: { audience: { permissionSet: 'crm_admin' }, groups: [{ key: 'all', label: 'All', include: '*' }] } },
+ });
+ expect(findings.map((f) => f.where)).toEqual(['book "crm_admin_guide"']);
+ });
+});
+
+describe('book-gated-catch-all-include at the authoring doors', () => {
+ it('is a gating rule on all three commands and on the runtime publish gate for books', () => {
+ const entry = AUTHORING_RULES.find((r) => r.name === 'validateBookAudienceClaims');
+ expect(entry).toBeDefined();
+ expect(entry!.tier).toBe('gating');
+ expect(entry!.surfaces).toContain('runtime-publish');
+ expect(entry!.runtimeTypes).toEqual(['book']);
+ for (const command of ['validate', 'build', 'lint'] as const) {
+ const found = runAuthoringRules(command, { normalized: { books: [book({ permissionSet: 'crm_admin' }, '*')] } });
+ expect(found.map((f) => f.rule), command).toContain(BOOK_GATED_CATCH_ALL_INCLUDE);
+ }
+ });
+
+ it('refuses the write of a catch-all gated book at the runtime door, and passes the named claim', () => {
+ const refused = runRuntimeAuthoringRules({ type: 'book', item: book({ systemPermission: 'setup.access' }, '*') });
+ expect(refused.rulesRun).toContain('validateBookAudienceClaims');
+ expect(refused.errors.map((f) => f.rule)).toContain(BOOK_GATED_CATCH_ALL_INCLUDE);
+
+ const named = runRuntimeAuthoringRules({ type: 'book', item: book({ systemPermission: 'setup.access' }, 'crm_admin_*') });
+ expect(named.rulesRun).toContain('validateBookAudienceClaims');
+ expect(named.errors.map((f) => f.rule)).not.toContain(BOOK_GATED_CATCH_ALL_INCLUDE);
+ });
+});
diff --git a/packages/lint/src/validate-book-audience-claims.ts b/packages/lint/src/validate-book-audience-claims.ts
new file mode 100644
index 00000000000..ea5d463e2bf
--- /dev/null
+++ b/packages/lint/src/validate-book-audience-claims.ts
@@ -0,0 +1,87 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+/**
+ * [ADR-0046 §6.7] A gated book claims its pages by name, never by the catch-all.
+ *
+ * A book whose `audience` names a gate (`{ permissionSet }` or
+ * `{ systemPermission }`) takes every doc it claims away from every reader
+ * outside that gate: a doc's effective audience is the union over the books
+ * that claim it (`resolveDocAudiences`), and a claimed doc no longer falls back
+ * to `org`. So what such a book claims has to be exactly the pages it means.
+ *
+ * `include: '*'` is not that. A group's membership is scoped to a package
+ * (`group.package`, else the book's own), and the scope leaves out only a doc
+ * stamped with ANOTHER package: a stored doc bound to no package (ADR-0070) is
+ * in every scope (`matchesInclude` in `@objectstack/spec/system`). A catch-all
+ * gated book therefore claims every such doc too, and every member outside the
+ * audience loses a page nobody meant to gate. The ADR-0046 §6.7 amendment
+ * states the rule; this is the rule that holds an author to it.
+ *
+ * What counts as the catch-all: a glob made of `*` alone (`'*'`, `'**'`), the
+ * spellings that match every doc name. A namespace glob (`setup_*`), a tag
+ * include and pinned `pages` are claims by name and pass. A book gated on
+ * nothing (`'org'`, `'public'`, no audience) is out of scope: the rule is about
+ * taking a page away, and those audiences take nothing away.
+ *
+ * ERROR, not warning: the defect is decidable from the book alone, and what it
+ * gets wrong is who may read a page.
+ */
+
+import { recordsOf } from './object-graph.js';
+
+export const BOOK_GATED_CATCH_ALL_INCLUDE = 'book-gated-catch-all-include';
+
+export interface BookAudienceClaimFinding {
+ severity: 'error';
+ rule: string;
+ where: string;
+ path: string;
+ message: string;
+ hint: string;
+}
+
+type AnyRec = Record;
+
+/** The gate an audience names, or `undefined` for one that takes nothing away. */
+function gateOf(audience: unknown): string | undefined {
+ if (!audience || typeof audience !== 'object' || Array.isArray(audience)) return undefined;
+ const rec = audience as AnyRec;
+ if (typeof rec.permissionSet === 'string') return `{ permissionSet: '${rec.permissionSet}' }`;
+ if (typeof rec.systemPermission === 'string') return `{ systemPermission: '${rec.systemPermission}' }`;
+ return undefined;
+}
+
+/** A string glob that matches every doc name. */
+function isCatchAll(include: unknown): include is string {
+ return typeof include === 'string' && /^\*+$/.test(include.trim());
+}
+
+export function validateBookAudienceClaims(stack: AnyRec): BookAudienceClaimFinding[] {
+ const findings: BookAudienceClaimFinding[] = [];
+ for (const [i, book] of recordsOf(stack.books).entries()) {
+ const gate = gateOf(book.audience);
+ if (gate === undefined) continue;
+ const bName = typeof book.name === 'string' ? book.name : `(book ${i})`;
+ const groups = Array.isArray(book.groups) ? book.groups : [];
+ for (const [g, group] of groups.entries()) {
+ if (!group || typeof group !== 'object') continue;
+ const include = (group as AnyRec).include;
+ if (!isCatchAll(include)) continue;
+ const key = typeof (group as AnyRec).key === 'string' ? (group as AnyRec).key : `(group ${g})`;
+ findings.push({
+ severity: 'error',
+ rule: BOOK_GATED_CATCH_ALL_INCLUDE,
+ where: `book "${bName}"`,
+ path: `books[${i}].groups[${g}].include`,
+ message:
+ `Book "${bName}" is gated (audience ${gate}) but its group "${key}" claims docs with `
+ + `include: '${include}'. A doc bound to no package is in every package scope, so the catch-all `
+ + 'claims it too and hides it from every reader outside the audience.',
+ hint:
+ 'Claim the book\'s pages by name: a namespace glob such as `include: \'_*\'`, a tag '
+ + 'include `{ tag: \'...\' }`, or pinned `pages`.',
+ });
+ }
+ }
+ return findings;
+}
diff --git a/packages/spec/liveness/book.json b/packages/spec/liveness/book.json
index 51fbef4724d..281d1292251 100644
--- a/packages/spec/liveness/book.json
+++ b/packages/spec/liveness/book.json
@@ -4,7 +4,7 @@
"props": {
"name": {
"status": "live",
- "verifiedAt": "2026-11-26",
+ "verifiedAt": "2026-09-27",
"evidence": "packages/rest/src/meta-item-read-gate.ts#deriveImplicitPackageBook (`bookNamed`: `books.find((b: any) => b && b.name === name) ?? deriveImplicitPackageBook(name, name)` — the tree route's `audience.bookNamed(req.params.name)` matches the book by name and, failing that, synthesizes the implicit per-package book from the same segment — §6.4); packages/spec/src/system/book.zod.ts#resolveBookTree (`return { name: book.name, … }` — the resolved tree carries it back out)",
"note": "tree-route identity; an unknown name is treated as a package id and resolved as the implicit per-package book (§6.4). 2026-08-28: RE-ANCHORED (commit 8cb96ec41) and REPOINTED — `rest-server.ts:3098` had rotted onto `patterns: crud.patterns` in the CRUD-endpoint config, ~1,800 lines from the book route. The `_note`'s file-level range (`:3078-3169`) had rotted with it and is replaced by a symbol too. Re-closed by hand against 93ea19bca."
},
@@ -40,9 +40,9 @@
},
"audience": {
"status": "live",
- "verifiedAt": "2026-09-27",
+ "verifiedAt": "2026-11-27",
"evidence": "packages/spec/src/system/book.zod.ts#audienceAllows (the gate itself: `public` always, `org`/unset any authenticated principal, `{ permissionSet }` only a holder of the set, `{ systemPermission }` only a holder of the capability, unknown shape → false); packages/spec/src/system/book.zod.ts#resolveDocAudiences (`const audience = book.audience ?? 'org'` — every doc's effective audience is the UNION over the books that claim it, unclaimed docs falling back to `org`); packages/rest/src/meta-item-read-gate.ts#audienceAllows (`admitsBook: (book: Book) => audienceAllows(book?.audience, caller)` — the gate the tree route asks as `if (!audience.admitsBook(book))` → 401 anonymous / 403 non-holder, before any tree is built, and the book item read asks on both transports); packages/rest/src/meta-item-read-gate.ts#resolveAudienceCaller (`caller.systemPermissions` — the caller's own capability list, the one `holdsRequiredPermissions` reads for an app, filled only when a `{ systemPermission }` book exists)",
- "note": "ENFORCED access gate (§6.7), fail-closed: gates the whole tree (401 anonymous / 403 non-holder), and every doc's effective audience is the union over the books that claim it (resolveDocAudiences) — applied to both doc lists and tree entries. The one security-shaped property on this type, and it is real. 2026-08-28: RE-ANCHORED (commit 8cb96ec41) and REPOINTED — ALL THREE legs were wrong. `rest-server.ts:3113` lands on the comment `// config to read).` and `:2969` on a docblock sentence about `'v1/beta'` splicing a path segment; `book.zod.ts:351` lands on `entries.push(entryFromDoc(d))` inside `resolveBookTree`'s `...` rest-expansion — tree ASSEMBLY, not the gate, ~83 lines from `audienceAllows`. A security-shaped property whose every pointer had drifted, one of them onto a comment, is the case this whole worklist is justified by: the verdict was right, and nothing cited could have shown it. Re-closed by hand against 93ea19bca. 2026-11-26: the `{ systemPermission }` arm (ADR-0046 §6.7) joins the same gate — a capability the reader holds through any set, so the Setup and Studio manuals open for exactly the callers their apps open for; pinned on every docs door by packages/rest/src/meta-doc-system-permission-audience.test.ts and on the MCP docs door by packages/runtime/src/domains/mcp-package-docs.test.ts."
+ "note": "ENFORCED access gate (§6.7), fail-closed: gates the whole tree (401 anonymous / 403 non-holder), and every doc's effective audience is the union over the books that claim it (resolveDocAudiences) — applied to both doc lists and tree entries. The one security-shaped property on this type, and it is real. 2026-08-28: RE-ANCHORED (commit 8cb96ec41) and REPOINTED — ALL THREE legs were wrong. `rest-server.ts:3113` lands on the comment `// config to read).` and `:2969` on a docblock sentence about `'v1/beta'` splicing a path segment; `book.zod.ts:351` lands on `entries.push(entryFromDoc(d))` inside `resolveBookTree`'s `...` rest-expansion — tree ASSEMBLY, not the gate, ~83 lines from `audienceAllows`. A security-shaped property whose every pointer had drifted, one of them onto a comment, is the case this whole worklist is justified by: the verdict was right, and nothing cited could have shown it. Re-closed by hand against 93ea19bca. 2026-11-26: the `{ systemPermission }` arm (ADR-0046 §6.7) joins the same gate — a capability the reader holds through any set, so the Setup and Studio manuals open for exactly the callers their apps open for; pinned on every docs door by packages/rest/src/meta-doc-system-permission-audience.test.ts and on the MCP docs door by packages/runtime/src/domains/mcp-package-docs.test.ts. 2026-11-27: re-closed against the two-gate refusal — `BookAudienceSchema` refuses an audience naming both `permissionSet` and `systemPermission` at the parse (the set arm used to strip the capability), and `validateBookAudienceClaims` (packages/lint) refuses a gated book claiming by `include: '*'`; this row's date moved here from `name`, whose evidence #37591 did not change."
},
"groups": {
"children": {
diff --git a/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts b/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts
new file mode 100644
index 00000000000..75ccb40bca5
--- /dev/null
+++ b/packages/spec/src/migrations/entries/semantic/19.book-audience-two-gates-and-catch-all-claim-refused.ts
@@ -0,0 +1,34 @@
+// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
+
+import type { SemanticMigration } from '../../types.js';
+
+// Two narrowings of a book's access gate (ADR-0046 §6.7), one upgrade-guide
+// entry: the parse refuses an `audience` naming both `permissionSet` and
+// `systemPermission`, where the set arm used to strip the capability, and the
+// author-time rule `book-gated-catch-all-include` refuses a gated book whose
+// group claims docs with the catch-all. No key is removed and no D2 conversion
+// exists, because each fix is a choice only the author can make (which gate the
+// book means, which pages it claims). No relevance question: the runtime save
+// door judges a book written through Studio, REST `/meta` or MCP too, which no
+// question over one stack can name.
+export const entry: SemanticMigration = {
+ id: 'book-audience-two-gates-and-catch-all-claim-refused',
+ surface:
+ 'A book `audience` object carrying both `permissionSet` and `systemPermission` (refused at the parse, by '
+ + '`defineStack`, `os validate` and the `/meta` save); a book whose `audience` is `{ permissionSet }` or '
+ + '`{ systemPermission }` with a group claiming docs by `include: \'*\'` (`book-gated-catch-all-include`, an error '
+ + 'from `os validate` / `lint` / `build` and from the runtime publish gate)',
+ replacement:
+ 'Keep one gate: `{ systemPermission: \'\' }` for everyone who holds the capability through any '
+ + 'permission set, or `{ permissionSet: \'\' }` for the holders of that one set. Claim a gated book\'s pages '
+ + 'by name: a namespace glob (`include: \'_*\'`), a tag include or pinned `pages`',
+ reason:
+ 'A two-gate audience parsed as the set form with the capability dropped, so the book was gated on the set alone '
+ + 'while its author believed it was gated on the capability. A gated catch-all claims every stored doc bound to no '
+ + 'package as well, because a package scope leaves out only a doc stamped with another package, and hides it from '
+ + 'every reader outside the audience. Stored books are not rewritten or refused at boot; the next save or publish '
+ + 'of such a book is refused with the fix named.',
+ acceptanceCriteria:
+ 'os validate reports no `book-gated-catch-all-include` and accepts every book audience; a save of every book the '
+ + 'package carries succeeds.',
+};
diff --git a/packages/spec/src/system/book.test.ts b/packages/spec/src/system/book.test.ts
index 0be8f2e5974..89e61f38307 100644
--- a/packages/spec/src/system/book.test.ts
+++ b/packages/spec/src/system/book.test.ts
@@ -52,6 +52,31 @@ describe('BookSchema (ADR-0046 §6)', () => {
expect(BookSchema.safeParse({ name: 'b', audience, groups: [] }).success).toBe(false);
}
});
+ it('refuses an audience naming both gates, and says which to keep (ADR-0046 §6.7)', () => {
+ // Before the refusal this parsed as the `{ permissionSet }` arm with the
+ // capability stripped: the book was gated on the set alone.
+ const audience = { permissionSet: 'crm_admin', systemPermission: 'setup.access' };
+ const result = BookSchema.safeParse({ name: 'b', audience, groups: [] });
+ expect(result.success).toBe(false);
+ const text = JSON.stringify(result.error?.issues);
+ expect(text).toContain('names ONE gate');
+ expect(text).toContain('Keep `systemPermission`');
+ expect(text).toContain('keep `permissionSet`');
+ // Either order of the keys is the same refusal.
+ expect(BookSchema.safeParse({
+ name: 'b', audience: { systemPermission: 'setup.access', permissionSet: 'crm_admin' }, groups: [],
+ }).success).toBe(false);
+ });
+ it('keeps accepting every shape it accepted before the two-gate refusal', () => {
+ // The refusal is the second gate key only: the set form still strips any
+ // other stray key, exactly as it did.
+ const parsed = BookSchema.parse({ name: 'b', audience: { permissionSet: 'crm_admin', label: 'Admins' }, groups: [] });
+ expect(parsed.audience).toEqual({ permissionSet: 'crm_admin' });
+ // An explicit `undefined` capability is no second gate.
+ expect(BookSchema.parse({
+ name: 'b', audience: { permissionSet: 'crm_admin', systemPermission: undefined }, groups: [],
+ }).audience).toEqual({ permissionSet: 'crm_admin' });
+ });
it('rejects the removed { profile } audience shape (ADR-0090 D2)', () => {
expect(() => BookSchema.parse({ name: 'b', audience: { profile: 'admin' }, groups: [] })).toThrow();
});
diff --git a/packages/spec/src/system/book.zod.ts b/packages/spec/src/system/book.zod.ts
index df524f997ca..412496d8d8d 100644
--- a/packages/spec/src/system/book.zod.ts
+++ b/packages/spec/src/system/book.zod.ts
@@ -120,6 +120,26 @@ export type BookGroup = {
pages?: BookNode[];
};
+/**
+ * The refusal for an audience that names both gates (ADR-0046 §6.7).
+ *
+ * The two object forms are alternatives, never a conjunction: `audienceAllows`
+ * reads one of them. Before this refusal the older `{ permissionSet }` arm,
+ * a plain object, accepted `{ permissionSet, systemPermission }` and stripped
+ * the capability without a word — the author believed the book was gated on a
+ * capability and it was gated on one set. The refusal is narrow on purpose:
+ * only the second gate key is refused, so no other shape that parsed before is
+ * refused now. Every authoring door meets it at the parse (`defineStack`, the
+ * `/meta` save), which is why it lives here and not in a lint rule: a
+ * `defineStack` config is parsed before any rule runs, so a rule would never
+ * see the key.
+ */
+const BOOK_AUDIENCE_ONE_GATE =
+ 'A book audience names ONE gate, and this one names two: `permissionSet` and `systemPermission`. '
+ + 'Keep `systemPermission` when the readers are everyone who holds a capability through any '
+ + 'permission set (the form for an app\'s manual, matching the app\'s `requiredPermissions`); keep '
+ + '`permissionSet` when the readers are the holders of that one set. Delete the other key.';
+
/**
* Access audience for a book — a reference into the permission model
* (ADR-0046 §6.7, vocabulary per ADR-0090). The gate is a capability
@@ -137,16 +157,33 @@ export type BookGroup = {
* token carries — ADR-0090 D10). This is the form for a
* manual that belongs to an app gated on a capability several sets grant
* (Setup's `setup.access`): a set name would shut out every other holder.
+ *
+ * An audience names one of the two, never both: the pair is refused at the
+ * parse ({@link BOOK_AUDIENCE_ONE_GATE}).
*/
export const BookAudienceSchema = lazySchema(() =>
z.union([
z.literal('org'), // default — inherits the package grant (§3.6)
z.literal('public'), // ≡ the built-in `guest` position (ADR-0090 D9): anonymous, indexable
- z.object({ permissionSet: z.string() }), // capability-gated, e.g. { permissionSet: 'crm_admin' }
- z
- .object({ systemPermission: z.string() })
- .strict()
- .describe("Readers holding this capability through any permission set, e.g. { systemPermission: 'setup.access' }"),
+ z.object({
+ permissionSet: z.string(), // gated on one named set, e.g. { permissionSet: 'crm_admin' }
+ // Declared only to be refused: see BOOK_AUDIENCE_ONE_GATE. Without it this
+ // plain arm accepted `{ permissionSet, systemPermission }` and stripped the
+ // capability, so the book was gated on the set alone.
+ systemPermission: z
+ .never({ error: () => BOOK_AUDIENCE_ONE_GATE })
+ .optional()
+ .describe('Not accepted beside `permissionSet`: an audience names one gate'),
+ }),
+ strictObject(
+ {
+ surface: 'this book audience',
+ history: 'A `{ permissionSet }` audience that also named `systemPermission` used to parse as the '
+ + 'set form with the capability dropped, so the book was gated on the set alone.',
+ guidance: { permissionSet: BOOK_AUDIENCE_ONE_GATE },
+ },
+ { systemPermission: z.string() },
+ ).describe("Readers holding this capability through any permission set, e.g. { systemPermission: 'setup.access' }"),
]),
);
export type BookAudience = 'org' | 'public' | { permissionSet: string } | { systemPermission: string };