@tpsdev-ai/flair 0.62.0 → 0.63.1

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.
Files changed (257) hide show
  1. package/README.md +14 -13
  2. package/SECURITY.md +73 -43
  3. package/config.yaml +11 -11
  4. package/dist/bridges/runtime/execute.js +1 -0
  5. package/dist/bridges/runtime/import-runner.js +4 -0
  6. package/dist/bridges/types.js +1 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli.js +309 -205
  9. package/dist/commands/agent.js +325 -137
  10. package/dist/commands/attention.js +2 -0
  11. package/dist/commands/backup-approval.js +218 -0
  12. package/dist/commands/backup.js +37 -33
  13. package/dist/commands/bootstrap.js +5 -1
  14. package/dist/commands/bridge.js +10 -0
  15. package/dist/commands/deploy.js +37 -7
  16. package/dist/commands/doctor.js +206 -42
  17. package/dist/commands/export.js +144 -15
  18. package/dist/commands/federation.js +653 -68
  19. package/dist/commands/grant.js +5 -6
  20. package/dist/commands/help.js +25 -0
  21. package/dist/commands/idp.js +14 -19
  22. package/dist/commands/import.js +167 -34
  23. package/dist/commands/init.js +380 -164
  24. package/dist/commands/integrity.js +5 -6
  25. package/dist/commands/keys.js +12 -8
  26. package/dist/commands/mcp.js +157 -79
  27. package/dist/commands/memory.js +38 -17
  28. package/dist/commands/migrate-harness-memory.js +9 -3
  29. package/dist/commands/orgevent.js +5 -10
  30. package/dist/commands/principal.js +32 -39
  31. package/dist/commands/quality.js +26 -3
  32. package/dist/commands/reembed.js +468 -111
  33. package/dist/commands/rem.js +484 -65
  34. package/dist/commands/restore.js +352 -44
  35. package/dist/commands/search.js +2 -0
  36. package/dist/commands/service.js +109 -2
  37. package/dist/commands/soul.js +0 -6
  38. package/dist/commands/status.js +165 -124
  39. package/dist/commands/test.js +4 -1
  40. package/dist/commands/upgrade.js +53 -22
  41. package/dist/commands/workspace.js +7 -8
  42. package/dist/deploy.js +59 -3
  43. package/dist/doctor-client.js +9 -25
  44. package/dist/fabric-upgrade.js +12 -2
  45. package/dist/federation/presence-send.js +139 -0
  46. package/dist/federation/scheduler.js +148 -12
  47. package/dist/federation-verify.js +269 -177
  48. package/dist/install/clients.js +171 -35
  49. package/dist/keystore.js +77 -10
  50. package/dist/lib/agent-id-rule.js +44 -2
  51. package/dist/lib/agent-key-file.js +509 -0
  52. package/dist/lib/agent-rotation-lock.js +249 -0
  53. package/dist/lib/atomic-write.js +3 -3
  54. package/dist/lib/auth-resolve.js +1040 -64
  55. package/dist/lib/backup-approval-store.js +612 -0
  56. package/dist/lib/backup-artifact.js +343 -0
  57. package/dist/lib/config-critical-section.js +212 -25
  58. package/dist/lib/connect-phase.js +33 -0
  59. package/dist/lib/daemon-liveness.js +2 -1
  60. package/dist/lib/federation-pair-access.js +4 -0
  61. package/dist/lib/federation-retry-queue.js +283 -0
  62. package/dist/lib/federation-retry-row.js +101 -0
  63. package/dist/lib/instruction-event-contract.js +17 -0
  64. package/dist/lib/instruction-event-doctor.js +102 -0
  65. package/dist/lib/key-dir.js +203 -0
  66. package/dist/lib/launchd-management.js +21 -6
  67. package/dist/lib/local-instance-pair.js +8 -1
  68. package/dist/lib/mcp-enable.js +14 -15
  69. package/dist/lib/memory-attributes.js +2 -0
  70. package/dist/lib/memory-provider-timeout.js +33 -0
  71. package/dist/lib/mqtt-config.js +132 -0
  72. package/dist/lib/mqtt-listener-doctor.js +104 -0
  73. package/dist/lib/node-alias-path.js +50 -2
  74. package/dist/lib/open-live-row.js +20 -0
  75. package/dist/lib/ops-url.js +52 -0
  76. package/dist/lib/promotion-content-hash.js +20 -0
  77. package/dist/lib/remote-admin-pass.js +157 -0
  78. package/dist/lib/restore-archive.js +760 -0
  79. package/dist/lib/restore-verify.js +1 -1
  80. package/dist/lib/scheduler-platform.js +13 -0
  81. package/dist/lib/service-repoint.js +13 -4
  82. package/dist/lib/skill-assignment-preflight.js +159 -0
  83. package/dist/lib/skill-seed.js +125 -10
  84. package/dist/lib/skill-tombstone-doctor.js +133 -0
  85. package/dist/lib/soul-scope-fields.js +26 -0
  86. package/dist/lib/terminal-text.js +32 -0
  87. package/dist/lib/uninstall-purge.js +266 -11
  88. package/dist/lib/upgrade-prior-liveness.js +2 -1
  89. package/dist/mcp-client-assertion.js +7 -14
  90. package/dist/memory-id-checkpoint.js +28 -7
  91. package/dist/mqtt-off-deploy.js +550 -0
  92. package/dist/rem/promote-policy.js +3 -3
  93. package/dist/rem/restore.js +302 -26
  94. package/dist/rem/runner.js +220 -58
  95. package/dist/rem/scheduler.js +21 -4
  96. package/dist/resources/A2AAdapter.js +131 -178
  97. package/dist/resources/AdminMemory.js +2 -0
  98. package/dist/resources/AdminMemoryCandidates.js +116 -0
  99. package/dist/resources/Agent.js +155 -45
  100. package/dist/resources/AgentCard.js +4 -0
  101. package/dist/resources/AgentKeyRegister.js +56 -22
  102. package/dist/resources/AgentReadPosition.js +7 -0
  103. package/dist/resources/AgentSeed.js +232 -107
  104. package/dist/resources/AutoPromoteCandidates.js +413 -84
  105. package/dist/resources/Credential.js +6 -8
  106. package/dist/resources/Federation.js +219 -57
  107. package/dist/resources/FederationRetry.js +4 -4
  108. package/dist/resources/InstructionVersion.js +1 -1
  109. package/dist/resources/MCPClientMetadata.js +6 -3
  110. package/dist/resources/Memory.js +1348 -271
  111. package/dist/resources/MemoryArchive.js +149 -64
  112. package/dist/resources/MemoryBootstrap.js +12 -22
  113. package/dist/resources/MemoryCandidate.js +16 -2
  114. package/dist/resources/MemoryConsolidate.js +2 -2
  115. package/dist/resources/MemoryFeed.js +360 -147
  116. package/dist/resources/MemoryMaintenance.js +290 -72
  117. package/dist/resources/MemoryPurge.js +138 -22
  118. package/dist/resources/MemoryReflect.js +68 -14
  119. package/dist/resources/MemoryReindex.js +91 -13
  120. package/dist/resources/Message.js +11 -2
  121. package/dist/resources/OAuth.js +156 -39
  122. package/dist/resources/OAuthClient.js +1 -1
  123. package/dist/resources/OrgEvent.js +292 -29
  124. package/dist/resources/OrgEventCatchup.js +7 -0
  125. package/dist/resources/OrgEventMaintenance.js +48 -10
  126. package/dist/resources/PairingToken.js +1 -1
  127. package/dist/resources/Presence.js +31 -11
  128. package/dist/resources/PromoteMemoryCandidate.js +8 -2
  129. package/dist/resources/RecordUsage.js +2 -4
  130. package/dist/resources/Soul.js +2 -0
  131. package/dist/resources/SoulFeed.js +2 -1
  132. package/dist/resources/WorkspaceLatest.js +4 -0
  133. package/dist/resources/XAA.js +36 -10
  134. package/dist/resources/a2a-stream.js +313 -0
  135. package/dist/resources/a2a-url.js +4 -5
  136. package/dist/resources/agent-admin.js +10 -1
  137. package/dist/resources/agent-auth.js +98 -68
  138. package/dist/resources/agent-read-position-lib.js +4 -1
  139. package/dist/resources/agent-status-guard.js +9 -7
  140. package/dist/resources/auth-middleware.js +166 -42
  141. package/dist/resources/authority-field-guard.js +9 -11
  142. package/dist/resources/auto-promote-lib.js +8 -5
  143. package/dist/resources/basic-auth-header.js +21 -0
  144. package/dist/resources/bm25-index-service.js +4 -5
  145. package/dist/resources/dedup-cluster.js +6 -1
  146. package/dist/resources/embeddings-provider.js +25 -0
  147. package/dist/resources/federation-classify.js +89 -0
  148. package/dist/resources/federation-retry-lib.js +6 -81
  149. package/dist/resources/health.js +75 -19
  150. package/dist/resources/host-pointer/registry.js +29 -0
  151. package/dist/resources/host-pointer-adapter.js +1 -0
  152. package/dist/resources/in-process-api.js +74 -11
  153. package/dist/resources/in-process.js +24 -22
  154. package/dist/resources/instruction-version-record.js +251 -7
  155. package/dist/resources/internal-authority.js +13 -0
  156. package/dist/resources/mcp-client-metadata-fields.js +4 -0
  157. package/dist/resources/mcp-handler.js +146 -13
  158. package/dist/resources/mcp-oauth-flag.js +12 -14
  159. package/dist/resources/mcp-oauth.js +446 -53
  160. package/dist/resources/mcp-tool-scopes.js +69 -0
  161. package/dist/resources/mcp-tools.js +70 -22
  162. package/dist/resources/memory-declared-attributes.js +1 -0
  163. package/dist/resources/memory-embed-hash.js +56 -0
  164. package/dist/resources/memory-host-source.js +5 -2
  165. package/dist/resources/memory-reflect-lib.js +1 -1
  166. package/dist/resources/memory-write-lock.js +202 -23
  167. package/dist/resources/memory-write-response.js +1 -1
  168. package/dist/resources/memory-write-transaction.js +243 -0
  169. package/dist/resources/migration-boot.js +17 -12
  170. package/dist/resources/migrations/boot-progress.js +25 -0
  171. package/dist/resources/migrations/data-dir.js +16 -3
  172. package/dist/resources/migrations/dir-safety.js +60 -2
  173. package/dist/resources/migrations/embedding-stamp.js +315 -49
  174. package/dist/resources/migrations/graph-heal.js +9 -2
  175. package/dist/resources/migrations/ledger.js +5 -2
  176. package/dist/resources/migrations/lock.js +867 -80
  177. package/dist/resources/migrations/progress.js +71 -10
  178. package/dist/resources/migrations/runner.js +212 -18
  179. package/dist/resources/migrations/state.js +36 -1
  180. package/dist/resources/migrations/status.js +2 -13
  181. package/dist/resources/migrations/synthetic-test-migration.js +78 -12
  182. package/dist/resources/migrations/types.js +26 -1
  183. package/dist/resources/migrations/visibility-backfill.js +111 -70
  184. package/dist/resources/oauth-discovery.js +0 -5
  185. package/dist/resources/object-body-guard.js +12 -5
  186. package/dist/resources/org-event-reserved.js +92 -0
  187. package/dist/resources/org-event-write-fault.js +19 -0
  188. package/dist/resources/owner-field-guard.js +1 -1
  189. package/dist/resources/owner-scoped-write-policy.js +65 -21
  190. package/dist/resources/owner-scoped-writes.js +37 -6
  191. package/dist/resources/path-id-rewrite.js +76 -0
  192. package/dist/resources/presence-internal.js +5 -5
  193. package/dist/resources/promotion-binding.js +43 -0
  194. package/dist/resources/promotion-stamp.js +124 -33
  195. package/dist/resources/protocol-context.js +189 -0
  196. package/dist/resources/record-type-kit.js +2 -4
  197. package/dist/resources/request-target.js +28 -1
  198. package/dist/resources/request-transaction.js +11 -1
  199. package/dist/resources/seed-reservation.js +1 -2
  200. package/dist/resources/semantic-retrieval-core.js +7 -6
  201. package/dist/resources/server-row-validation.js +71 -0
  202. package/dist/resources/skill-manifest.js +4 -3
  203. package/dist/resources/skill-version-write.js +400 -27
  204. package/dist/resources/skill-write-fault.js +6 -3
  205. package/dist/resources/skill-write-policy.js +2 -1
  206. package/dist/resources/soul-write-policy.js +26 -7
  207. package/dist/resources/table-helpers.js +1 -1
  208. package/dist/resources/table-subscription-policy.js +518 -85
  209. package/dist/resources/table-subscriptions.js +20 -7
  210. package/dist/resources/txn-pause-point.js +122 -5
  211. package/dist/resources/usage-recording.js +54 -46
  212. package/dist/resources/write-back.js +176 -11
  213. package/dist/resources/write-journal-context.js +5 -0
  214. package/dist/resources/write-journal.js +289 -0
  215. package/dist/src/keystore.js +77 -10
  216. package/dist/src/lib/agent-id-rule.js +44 -2
  217. package/dist/src/lib/atomic-write.js +3 -3
  218. package/dist/src/lib/federation-retry-row.js +101 -0
  219. package/dist/src/lib/instruction-event-contract.js +17 -0
  220. package/dist/src/lib/key-dir.js +203 -0
  221. package/dist/src/lib/memory-attributes.js +2 -0
  222. package/dist/src/lib/open-live-row.js +20 -0
  223. package/dist/src/lib/scheduler-platform.js +13 -0
  224. package/dist/src/lib/soul-scope-fields.js +26 -0
  225. package/dist/src/rem/promote-policy.js +3 -3
  226. package/dist/src/rem/scheduler.js +21 -4
  227. package/docs/access-control.md +39 -21
  228. package/docs/api-reference.md +161 -52
  229. package/docs/auth.md +69 -38
  230. package/docs/claude-code.md +3 -3
  231. package/docs/deploying-on-fabric.md +118 -2
  232. package/docs/deployment.md +17 -0
  233. package/docs/embedding-in-a-harper-app.md +23 -21
  234. package/docs/entity-vocabulary.md +7 -11
  235. package/docs/federation.md +29 -2
  236. package/docs/hosted-on-fabric.md +1 -1
  237. package/docs/integrations.md +11 -11
  238. package/docs/mcp-clients.md +7 -5
  239. package/docs/notes/mcp-agent-auth-consumer.md +4 -9
  240. package/docs/notes/mcp-oauth-model2.md +6 -6
  241. package/docs/openclaw.md +1 -1
  242. package/docs/quickstart-fabric.md +2 -2
  243. package/docs/quickstart.md +3 -3
  244. package/docs/releasing.md +13 -13
  245. package/docs/rem.md +24 -3
  246. package/docs/secrets-and-keys.md +9 -14
  247. package/docs/standalone-local.md +29 -2
  248. package/docs/supply-chain-policy.md +28 -20
  249. package/docs/the-team.md +2 -2
  250. package/docs/upgrade.md +29 -5
  251. package/package.json +18 -11
  252. package/schemas/agent.graphql +3 -3
  253. package/schemas/federation.graphql +10 -7
  254. package/schemas/memory.graphql +7 -2
  255. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  256. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  257. package/dist/resources/soul-adk-guard.js +0 -68
package/docs/auth.md CHANGED
@@ -14,7 +14,7 @@ Different surfaces authenticate differently. The model in one place:
14
14
  | **OpenClaw / pi / Hermes plugins** | Ed25519 agent keys; Pi can use configured administrator Basic fallback | Ordinary signed agents: own writes; own and org-wide non-private reads | OpenClaw identity comes from host context; Pi requires `FLAIR_AGENT_ID`; Hermes defaults to `hermes`. |
15
15
  | **`n8n-nodes-flair`** | **Ed25519 with Agent Private Key selected**; deprecated administrator Basic | Ordinary signed agents: own writes; own and org-wide non-private reads | The deprecated **Admin Password** authenticates as the Harper administrator (whole instance, including `private`) when Agent Private Key is empty. |
16
16
 
17
- **The default, secure path is Ed25519 per-agent** (see below): each agent holds its own key and signs every request. For ordinary signed agents, this enforces write ownership: they can write only their own records and read their own plus other agents' non-private records. Administrator credentials and administrator agent roles have broader authority, including access to private records. The hard access boundary is the **federation edge** (a separate Flair instance / org), not reads within an instance. See [SECURITY.md](../SECURITY.md) for the full model. Use Ed25519 per-agent everywhere you can regardless — it's still what makes writes and identity trustworthy.
17
+ **The default, secure path is Ed25519 per-agent** (see below): each agent holds its own key and signs every request. For ordinary signed agents, this enforces write ownership: they can write only their own records. Reads follow each resource's policy: Memory uses owner/visibility scope with an additional current-authority check for retained closed skills, while Credential records are owner-only for non-admin callers. Administrator credentials and administrator agent roles have broader authority, including access to private records. The hard access boundary is the **federation edge** (a separate Flair instance / org), not reads within an instance. See [SECURITY.md](../SECURITY.md) for the full model. Use Ed25519 per-agent everywhere you can regardless — it's still what makes writes and identity trustworthy.
18
18
 
19
19
  ### n8n: agent-key signing, with the admin password deprecated
20
20
 
@@ -22,7 +22,7 @@ With **Agent Private Key** selected, `n8n-nodes-flair` signs as the credential's
22
22
 
23
23
  ## Ed25519 Agent Auth (Default)
24
24
 
25
- Every agent has an Ed25519 key pair. Requests are signed with `agentId:timestamp:nonce:METHOD:/path` and verified against the agent's registered public key. 30-second replay window with nonce deduplication.
25
+ Each signing agent has an Ed25519 key pair. Requests are signed with `agentId:timestamp:nonce:METHOD:/path?query` and verified against the agent's registered public key. 30-second replay window with nonce deduplication.
26
26
 
27
27
  ```bash
28
28
  # Register an agent
@@ -43,22 +43,22 @@ never an existence signal. The adapter write-up is
43
43
 
44
44
  Flair has no `mode`/`shape` config setting — the shape you get is emergent from *how you provision principals*, not something you declare:
45
45
 
46
- - **Personal.** `flair init --agent <id>` creates (or reuses) ONE agent identity and wires that same `FLAIR_AGENT_ID` into every MCP client it configures (Claude Code, Codex, Gemini, Cursor). One human driving several AI clients ends up with one canonical principal and one Ed25519 keypair — all clients share ownership of the same memory. This is intentional, not a limitation: all clients see each other's private rows (one human's memory, one view). Writes with fresh IDs create separate records even when the server reports a dedup match; writes that reuse an existing ID update that record. Usage counting treats the shared principal as one contributor.
46
+ - **Personal.** `flair init --agent <id>` creates (or reuses) ONE agent identity and wires that same `FLAIR_AGENT_ID` into every MCP client it configures (Claude Code, Codex, Gemini, Cursor, Antigravity). When pi is selected, it registers the native extension and prints the agent environment to export at launch. One human driving several AI clients ends up with one canonical principal and one Ed25519 keypair — all clients share ownership of the same memory. This is intentional, not a limitation: all clients see each other's private rows (one human's memory, one view). Writes with fresh IDs create separate records even when the server reports a dedup match; writes that reuse an existing ID update that record. Usage counting treats the shared principal as one contributor.
47
47
  - **Org (multiple real agents).** `flair agent add <id>` mints a distinct principal — its own keypair, its own ownership boundary — for each real agent that should be a separate identity. Wire each principal's own `FLAIR_AGENT_ID` into its own client(s).
48
48
 
49
49
  Nothing in flair validates which shape you're in; a personal install that later grows into an org just runs `flair agent add` for the new distinct identities it needs.
50
50
 
51
51
  ### Authorship: which client wrote a row
52
52
 
53
- The personal shape's one shared principal means `agentId` alone can't answer "was this written by Claude Code or Codex?" — every write it receives has the same owner. `flair init`'s per-client wiring closes that gap by setting an additional env var per client: `FLAIR_CLIENT` (`"claude-code"` / `"codex"` / `"gemini"` / `"cursor"`). `flair-client` and `flair-mcp` forward it on memory writes as `claimedClient`, and the server folds it into the write's `provenance` blob as `claimed.client` — self-reported, unverified metadata recording *which tool* authored a row, alongside the existing `claimed.model`.
53
+ The personal shape's one shared principal means `agentId` alone can't answer "was this written by Claude Code or Codex?" — every write it receives has the same owner. `flair init`'s per-client MCP wiring closes that gap by setting an additional env var per client: `FLAIR_CLIENT` (`"claude-code"` / `"codex"` / `"gemini"` / `"cursor"` / `"antigravity"`). `flair-client` and `flair-mcp` forward it on memory writes as `claimedClient`, and the server folds it into the write's `provenance` blob as `claimed.client` — self-reported, unverified metadata recording *which tool* authored a row, alongside the existing `claimed.model`.
54
54
 
55
55
  This is deliberately in `claimed`, never `verified`: it carries **zero authority**. It is never read for access control, read-scope, attribution weighting, or dedup decisions — it exists purely for audit/analysis. Absent on any install that predates this field (no backfill, no migration) and absent whenever a client doesn't set `FLAIR_CLIENT`.
56
56
 
57
- The native `/mcp` OAuth surface (see below) doesn't need any client-side wiring at all: the handler stamps `claimed.client` directly from the OAuth token's verified `client_id` claim — the server-generated `flair_cl_...` machine id assigned at Dynamic Client Registration, **not** the user-supplied `client_name` (which the registering client fully controls and could set to anything). Using `client_id` keeps the stamp a stable, server-verified label even though it still only carries `claimed`-level (unverified-by-content) authority.
57
+ The native `/mcp` handler stamps `claimed.client` from the token's verified `client_id` when present, so the label is tied to the authenticated client rather than its display name; it remains claimed metadata.
58
58
 
59
59
  ## OAuth 2.1
60
60
 
61
- Flair includes a built-in OAuth 2.1 authorization server for client integrations (e.g., Claude connecting to Flair as an MCP server).
61
+ Flair's legacy OAuth endpoints are separate from the native `/mcp` authorization server.
62
62
 
63
63
  The native `/mcp` endpoint is guarded by the `@harperfast/oauth` authorization server instead; who can connect through it, and how to revoke that access, is in [access-control.md](access-control.md).
64
64
 
@@ -133,13 +133,31 @@ rather than registration.
133
133
 
134
134
  ### Authorization Code Flow with PKCE
135
135
 
136
- Standard OAuth 2.1 authorization code flow:
137
-
138
- 1. Client generates PKCE `code_verifier` and `code_challenge`
139
- 2. Client redirects user to `GET /OAuthAuthorize?client_id=...&code_challenge=...&redirect_uri=...`
140
- 3. User approves (or auto-approves for trusted clients)
141
- 4. Flair redirects back with authorization code
142
- 5. Client exchanges code for access token at `POST /OAuthToken`
136
+ Standard OAuth 2.1 authorization code flow. The authorization endpoints and the
137
+ authorization-code exchange require PKCE with the `S256` method only; the
138
+ metadata's `code_challenge_methods_supported` lists `["S256"]` as the supported method:
139
+
140
+ 1. Client generates a PKCE `code_verifier` and its `S256` `code_challenge`
141
+ (`BASE64URL(SHA256(code_verifier))`, RFC 7636)
142
+ 2. Client redirects user to `GET /OAuthAuthorize?response_type=code&client_id=...&redirect_uri=...&code_challenge=...&code_challenge_method=S256`
143
+ 3. User approves with administrator Basic auth or a signed agent request, or denies on the consent page
144
+ 4. Flair redirects to `https://claude.com/api/mcp/auth_callback` with an authorization code on approve, or with `error=access_denied` on deny
145
+ 5. Client exchanges code and `code_verifier` for access token at `POST /OAuthToken`
146
+
147
+ After the earlier request, scope and client checks pass, `GET /OAuthAuthorize`
148
+ (the consent page) and its Approve (`POST /OAuthAuthorize`) answer
149
+ `400 invalid_request` when `code_challenge` is missing, empty or not exactly 43
150
+ base64url characters (43 is the length of an unpadded
151
+ `BASE64URL(SHA256(verifier))`), or when `code_challenge_method` is anything other than
152
+ `S256`. The consent page is not rendered and no authorization code is stored. A
153
+ Deny needs no PKCE fields: after redirect-URI validation passes, it redirects with `access_denied` and issues nothing (an invalid `redirect_uri` is refused with `400 invalid_redirect_uri` first).
154
+
155
+ The authorization-code exchange at `POST /OAuthToken` redeems a code only with a
156
+ `code_verifier` whose S256 hash equals the challenge stored with the code. A code
157
+ stored without an S256 challenge is `400 invalid_grant`. For an otherwise valid,
158
+ unused code carrying an S256 challenge, a missing verifier is
159
+ `400 invalid_request` and a verifier that does not match is `400 invalid_grant`.
160
+ A PKCE refusal does not redeem the code.
143
161
 
144
162
  ### Endpoints
145
163
 
@@ -150,7 +168,7 @@ Standard OAuth 2.1 authorization code flow:
150
168
  | `/OAuthToken` | POST | Token endpoint |
151
169
  | `/.well-known/oauth-authorization-server` | GET | Authorization server metadata (RFC 8414) |
152
170
  | `/.well-known/oauth-protected-resource` | GET | Protected resource metadata (RFC 9728) |
153
- | `/OAuthMetadata` | GET | Alias of `/.well-known/oauth-authorization-server` |
171
+ | `/OAuthMetadata` | GET | Legacy authorization-server metadata; matches the well-known document when OAuth MCP is off |
154
172
 
155
173
  Both well-known documents are public — RFC 8414 §3 and RFC 9728 §3 require them
156
174
  to be retrievable without authentication — and are served with
@@ -219,14 +237,14 @@ localhost. See [deploying-on-fabric.md](deploying-on-fabric.md).
219
237
 
220
238
  ## XAA (Enterprise-Managed Authorization)
221
239
 
222
- For organizations using an Identity Provider (IdP), XAA lets the IdP control who accesses Flair and with what scopes.
240
+ For organizations using an Identity Provider (IdP), XAA maps IdP identities to Flair principals.
223
241
 
224
242
  ### How It Works
225
243
 
226
244
  1. User authenticates with the organization's IdP (Google, Azure AD, Okta)
227
245
  2. IdP issues an ID token (JWT) with user identity and group claims
228
246
  3. Client sends the ID token to Flair's token endpoint using the `jwt-bearer` grant type
229
- 4. Flair validates the JWT signature, checks issuer/domain, maps to a Principal, and issues a scoped access token
247
+ 4. Flair verifies the JWT signature and issuer, applies any configured domain restriction, maps to a Principal, and issues an access token.
230
248
 
231
249
  A `jti` claim, when present, must be a nonempty string, and the assertion must then carry an `exp` no more than 24 hours (plus 30 seconds of clock skew) ahead. Flair records the `jti` before it issues tokens, and refuses the assertion if it is presented to this Harper instance again.
232
250
 
@@ -247,6 +265,8 @@ flair idp add \
247
265
  --name "Google Workspace" \
248
266
  --issuer "https://accounts.google.com" \
249
267
  --jwks-uri "https://www.googleapis.com/oauth2/v3/certs" \
268
+ --client-id "<client-id-at-google>" \
269
+ --admin-pass-file ~/.flair/admin-pass \
250
270
  --required-domain "yourcompany.com"
251
271
  ```
252
272
 
@@ -260,14 +280,21 @@ flair idp add \
260
280
 
261
281
  ### Scopes
262
282
 
263
- | Scope | Description |
264
- |-------|-------------|
265
- | `memory:read` | Read memories and search |
266
- | `memory:write` | Write and delete memories |
267
- | `memory:admin` | Memory maintenance operations |
268
- | `principal:read` | View principal list |
269
- | `principal:admin` | Create/modify/disable principals |
270
- | `connector:admin` | Manage OAuth clients and IdPs |
283
+ Discovery advertises these scope names:
284
+
285
+ | Scope | `/mcp` tools that require it |
286
+ |-------|------------------------------|
287
+ | `memory:read` | `memory_search`, `memory_get`, `skill_search`, `skill_get`, `bootstrap`, `soul_get`, `attention` |
288
+ | `memory:write` | `memory_store`, `memory_update`, `memory_delete`, `memory_basement`, `memory_restore`, `skill_store`, `flair_workspace_set`, `flair_orgevent`, `record_usage` |
289
+ | `memory:admin` | none |
290
+ | `principal:read` | `team_directory` |
291
+ | `principal:admin` | `soul_set`, which then refuses the write (`soul_write_requires_operator`) |
292
+ | `connector:read` | none |
293
+ | `connector:admin` | none |
294
+
295
+ The jwt-bearer grant above issues opaque `flair_at_` tokens, which native `/mcp` does not accept; `/mcp` accepts the access tokens from its own OAuth sign-in. For native `/mcp` tool calls, the access token must grant the tool's scope above. A missing `scope` claim grants no scope. A call missing its tool's scope returns HTTP 403 with a JSON-RPC `insufficient_scope` error naming the required scope and a `WWW-Authenticate: Bearer error="insufficient_scope", scope="…"` challenge, before resolving the principal or running the tool. A permitted call runs with the mapped principal's authority.
296
+
297
+ The `/mcp` 401 challenge names `memory:read memory:write principal:read`. Refresh preserves the scopes from sign-in; existing connectors missing a required scope must sign in again requesting it.
271
298
 
272
299
  ### JIT Provisioning
273
300
 
@@ -281,7 +308,7 @@ flair principal promote <principal-id> <tier>
281
308
 
282
309
  `<tier>` is one of `endorsed`, `corroborated`, or `unverified`. There is no `verified` tier and no `admin` tier. The command writes `defaultTrustTier` and does not write `role` or `admin`, so it cannot grant admin.
283
310
 
284
- Admin authority is `role: admin` on the Agent record. `admin: true` is the mirror the server keeps in step with that role; setting the mirror alone does not grant admin. The CLI that writes both is:
311
+ Admin authority is `role: admin` on the Agent record; the auth gate does not read the `admin` mirror. Administrator POST, PUT and ordinary PATCH writes through the Agent resource reconcile `admin: true` to `role: admin`; guarded `flairPrincipalWriteBack`/`flairStampHome` PATCH writes do not. Non-admin PATCH cannot change admin status. The CLI that writes both is:
285
312
 
286
313
  ```bash
287
314
  flair principal add <principal-id> --admin
@@ -289,6 +316,8 @@ flair principal add <principal-id> --admin
289
316
 
290
317
  `add` upserts the Agent row. If `~/.flair/keys/<principal-id>.key` already exists, that key is reused and is not regenerated. The upsert writes the record this command builds, including `role: admin` and `admin: true` when `--admin` is set. With `--admin` and no `--trust`, the trust tier written is `endorsed`.
291
318
 
319
+ For a request signed with an agent key, the admin decision uses the Agent row the signature is verified against: the caller is an admin when that row has `role: admin`, or when its id is listed in the instance's `FLAIR_ADMIN_AGENTS` (comma-separated). The decision is made on every request and nothing is kept between requests, so a role change, a removed row, or a new row under the same id applies to the next request on every worker thread.
320
+
292
321
  ### CLI Reference
293
322
 
294
323
  | Command | Description |
@@ -300,15 +329,15 @@ flair principal add <principal-id> --admin
300
329
 
301
330
  ## Web Admin
302
331
 
303
- The web admin at `/AdminDashboard` provides a UI for managing:
332
+ The web admin at `/AdminDashboard` provides read-only views:
304
333
 
305
- - **Principals:** view, promote, disable agents and users
306
- - **Connectors:** OAuth clients and active sessions
334
+ - **Principals:** list agents and users
335
+ - **Connectors:** list OAuth clients
307
336
  - **IdP:** enterprise identity provider configuration
308
337
  - **Memory:** browse and search stored memories
309
338
  - **Instance:** federation status, peer connections
310
339
 
311
- Access requires admin-level authentication (Basic auth with the Harper admin password).
340
+ Access goes through the `allowAdmin` gate. It admits an admin agent, and admits the `internal` verdict only for a call whose context carries the marker that `internalContext()` sets and no request headers; a call that reaches the gate with no context is refused.
312
341
 
313
342
  ## Soul authorship
314
343
 
@@ -345,18 +374,20 @@ Federation remains an authenticated instance-to-instance replication path and
345
374
  preserves the originating record; it does not reclassify a runtime request as
346
375
  an operator edit. Raw Harper OPS access remains administrator infrastructure.
347
376
 
348
- An operator write is refused if its value exactly matches stored Memory or
349
- MemoryCandidate text for the target agent, including legacy or untagged records.
377
+ A learned-text refusal reports `soul_value_is_learned_content` for a non-empty
378
+ exact value match with stored Memory or MemoryCandidate text for the target
379
+ agent, including legacy or untagged records.
350
380
  The owner-scoped lookup prevents another agent from blocking edits by copying
351
381
  known Soul text into its own memories. Learned artifacts are not an operator-authored Soul source;
352
382
  claimed or missing provenance does not exempt them. Lookup failure aborts the
353
383
  write. This is an exact-match backstop, not semantic detection of paraphrases.
354
384
  Existing Soul records remain readable without a migration.
355
385
 
356
- The legacy `adk:` body-tag and stored-tag refusal remains a compatibility
357
- bridge until **2026-10-31** (`ADK_SOUL_REFUSE_KILL_DATE` in
358
- `resources/soul-adk-guard.ts`). Runtime denial itself never depends on
359
- connector names — Soul writes are deny-by-default, and Flair stamps
360
- `sourceClass` from the authenticated credential, not from a body field.
361
- Removal of the vendor-string bridge is #1540; do not grow a per-connector
362
- blacklist in Soul.
386
+ Authorized Soul resource POST/PUT with a non-empty `scopeTag` or non-empty
387
+ `tags` array in the request body, and authorized PATCH with those fields in
388
+ the merged row after its stored-row checks, receive
389
+ `soul_scope_fields_not_writable`. Runtime denial
390
+ does not depend on connector names — Soul writes are deny-by-default, and Flair
391
+ stamps `sourceClass` from verified Basic credentials or a deliberate internal
392
+ context, never a body field.
393
+ Do not grow a per-connector blacklist in Soul.
@@ -29,7 +29,7 @@ This generates an Ed25519 key pair at `~/.flair/keys/my-project.key` and registe
29
29
 
30
30
  ### 4. Add to your project's CLAUDE.md
31
31
 
32
- Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`, etc.):
32
+ Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`, etc.): <!-- docs-freshness-allow: names files in the reader's project -->
33
33
 
34
34
  ---
35
35
 
@@ -184,14 +184,14 @@ flair agent add project-beta
184
184
  flair agent add infra-ops
185
185
  ```
186
186
 
187
- Each project's `CLAUDE.md` uses its own agent ID. Writes carry an `agentId` field (tags are optional); reads use owner plus visibility.
187
+ Each project's `CLAUDE.md` uses its own agent ID. <!-- docs-freshness-allow: names a file in the reader's project --> Writes carry an `agentId` field (tags are optional); reads use owner plus visibility.
188
188
 
189
189
  ## Subagents
190
190
 
191
191
  Claude Code subagents (spawned via `/run` or background tasks) can share the parent's memory:
192
192
 
193
193
  ### Subagents
194
- Subagents share memory with the parent session when they use the same agent ID (to share, set `FLAIR_AGENT_ID=my-project`). A subagent with its own agent ID owns what it writes, but this is not isolation: only its private records are hidden from other agents, and it can still read other agents' non-private records. Writes without an explicit visibility default by durability: persistent and permanent are shared, standard and ephemeral are private.
194
+ Subagents share memory with the parent session when they use the same agent ID (to share, set `FLAIR_AGENT_ID=my-project`). A subagent with its own agent ID owns its writes; memory reads use owner/visibility scope, with an additional current-authority check for non-admin by-id and collection reads of retained closed skills. Writes without an explicit visibility default by durability: persistent and permanent are shared, standard and ephemeral are private.
195
195
 
196
196
  When spawning subagents, pass the agent ID so they can access shared context.
197
197
 
@@ -58,8 +58,16 @@ flair init --target https://<cluster>.<org>.harperfabric.com \
58
58
  - `--force` is required — this writes to a live instance.
59
59
  - `--remote` marks it a federation **hub** and creates the `flair_pair_initiator` role;
60
60
  without it, pairing later fails role-not-found.
61
- - Generated admin password lands in `~/.tps/secrets/flair-fabric-hdb` (mode `0600`);
62
- `--flair-admin-pass` to choose your own.
61
+ - Before attempting to set `admin`'s password, init saves the chosen or generated
62
+ password locally in a mode-`0600` file; `--flair-admin-pass` chooses your own. The
63
+ final credential path is `~/.tps/secrets/flair-fabric-hdb`. Init attempts this save
64
+ only when it selects the branch that will try to create or update `admin`; an
65
+ existing `super_user` cluster administrator is reused without writing a password
66
+ file. With no file present the password is written directly and kept even if the
67
+ deployment is refused; with one present, the new value is staged beside it and moved
68
+ into place after the cluster accepts it and the staged copy verifies. If the cluster
69
+ accepts the change but the saved copy cannot be confirmed, init prints the recovery
70
+ step.
63
71
 
64
72
  Run **once**, before serving multi-region traffic — see
65
73
  [Multi-region](#multi-region-replication-vs-federation).
@@ -305,6 +313,114 @@ without this re-flip will appear healthy (`/Health` green) while its MCP tools a
305
313
  dark to every connected client. If you rely on MCP, add the re-flip to your upgrade
306
314
  runbook.
307
315
 
316
+ ### MQTT configuration
317
+
318
+ Flair does not use MQTT. Its local starts run Harper with every MQTT listener
319
+ off: the TCP and TLS listeners (`mqtt.network.port`,
320
+ `mqtt.network.securePort`) and MQTT over WebSocket on the HTTP port
321
+ (`mqtt.webSocket`), set on every start. A component deployment does not go
322
+ through those starts, and a component's `config.yaml` cannot set it (`mqtt`
323
+ belongs to the instance's root configuration). So, by default, `flair deploy`
324
+ and `flair upgrade --target` set those listeners off in the target's
325
+ configuration through its operations API and request the worker restart that
326
+ applies it; they do not confirm the listeners' live state. `--keep-mqtt-config`,
327
+ `--no-restart` and `--no-verify` change these steps (below).
328
+
329
+ **Before deploying**, they send:
330
+
331
+ ```json
332
+ { "operation": "set_configuration", "mqtt_network_port": null, "mqtt_network_securePort": null, "mqtt_webSocket": false, "replicated": true }
333
+ ```
334
+
335
+ `replicated` follows the deploy (`--no-replicated` sends it to the origin
336
+ only; an instance without replication is set on its own). If the target
337
+ refuses it, or its answer names a cluster node that did not take it, nothing
338
+ is deployed, and the error names the node and the request to send to it.
339
+
340
+ **After the deploy's restart**, they read the target's configuration back
341
+ through its operations API. An answer that is not a recognizable root
342
+ configuration (it must carry Harper's `http` and `operationsApi` sections and
343
+ its `rootPath`) is reported as not confirmed, never as off, and the saved
344
+ `mqtt` section must read off (`mqtt.network.port` and `mqtt.network.securePort`
345
+ null, `mqtt.webSocket` false); a mismatch is named by field and category, such
346
+ as `mqtt.webSocket is not false`. Either failure fails the command after the
347
+ deploy, with the request to send.
348
+
349
+ Harper applies the setting when the shared HTTP worker threads, which start
350
+ the MQTT listeners, restart. The deploy's own restart covers them, except for a
351
+ fresh isolated deploy: when the root configuration marks Flair `isolated: true`
352
+ and Harper does not find it already active, Harper restarts only Flair's own
353
+ worker (for an application it finds already active, it restarts every
354
+ worker). For an isolated Flair they therefore also request the shared worker
355
+ threads' restart through the operations API (`restart_service`, `"service":
356
+ "http_workers"`, `"scope": ""`, replicated with the deploy; a standalone
357
+ instance, which refuses the replicated request, gets it on its own) and follow
358
+ Harper's job. The command fails when the restart request fails or is answered
359
+ without a job id, and on these job outcomes: a job read that does not succeed
360
+ (refused before its body is parsed), a job that does not complete, a completion
361
+ message that is not exactly Harper's for that job, a replicated result without
362
+ its node list, or a node the result lists without Harper's completed-job
363
+ message (each named, with the request to send to it). Nodes are judged as the
364
+ job's result lists them: that list is not compared with the nodes the
365
+ configuration answer named. A completed job is not proof that a node's workers
366
+ restarted: Harper sends a node's restart-complete from a `finally` and does
367
+ not carry the worker replacement's outcome.
368
+
369
+ **What they report.** Exactly this, and nothing more:
370
+
371
+ ```
372
+ MQTT listeners configured off on <the target and the nodes the replicated answer named>; shared workers restart requested (job <id>: <each node's outcome>, or: with the deploy's own restart); the saved configuration on <the target's operations host> reads off. Listeners stop when each node's workers restart; flair does not probe them. To confirm on a node, connect an MQTT client to its MQTT ports or WebSocket path.
373
+ ```
374
+
375
+ Flair does not connect to the MQTT listeners. To confirm that a node stopped
376
+ serving MQTT after its workers restarted, connect an MQTT client to that node's
377
+ MQTT ports (1883 and 8883 by default) or to its MQTT-over-WebSocket path on the
378
+ HTTP port.
379
+
380
+ With `--no-verify` (both commands) the post-restart step is skipped (the saved
381
+ configuration is not read back, and no restart is requested for an isolated
382
+ application), and with `--no-restart` the setting takes effect at the next
383
+ restart; both print the restart request to send. With `--keep-mqtt-config`
384
+ neither step runs.
385
+
386
+ **URLs.** The operations API URL is resolved as for every remote command:
387
+ `--ops-target` / `FLAIR_OPS_TARGET`, else derived from the target. The target
388
+ and the operations API URL must be http or https URLs with a host, and nothing
389
+ but scheme, host, port and path: any other scheme (such as `file:` or
390
+ `javascript:`), a URL without a host, a user name, password, query or fragment
391
+ is refused before either command prints or sends anything. The operations API
392
+ calls follow no redirect. Every URL the MQTT-off steps print, and the target
393
+ URL in the commands' own deploy lines (`flair deploy`'s next-steps example
394
+ included), shows scheme, host, port and path only; that includes the
395
+ operations API URL they name for a cluster node, which they build only from a
396
+ node name that is a valid host name or IP address.
397
+
398
+ **Output.** The errors and progress lines of these MQTT-off steps quote a
399
+ remote answer's HTTP status code, a restart job's id (when it is a plain
400
+ token) and state, and cluster node names as its answers give them (when they
401
+ are valid host names or IP addresses); never its body, a job's message, a
402
+ configuration value or a transport error's text. This covers only these
403
+ steps: the Harper deploy between them runs Harper's CLI, whose output is
404
+ streamed as it comes.
405
+
406
+ `flair doctor` (local instances; it takes no `--target`) reports an instance
407
+ whose saved configuration starts an MQTT listener, and names the call that
408
+ sets the listeners off in the configuration. It reads the configuration, not
409
+ the running listeners: worker threads that have not restarted since the
410
+ configuration changed may still serve their previous listener configuration,
411
+ and doctor says so on every path, including when it cannot read the
412
+ configuration. It follows no redirect: a redirected configuration read is NOT
413
+ RUN.
414
+
415
+ **Turning MQTT on deliberately.** Send `set_configuration` with the listeners
416
+ you want (for example `"mqtt_webSocket": true`), then restart the worker threads
417
+ (`restart_service` with `"service": "http_workers"`). Pass `--keep-mqtt-config`
418
+ to later `flair deploy` / `flair upgrade --target` runs so they leave the
419
+ instance's MQTT configuration as it is. Table subscriptions, publishes and
420
+ retained publishes over MQTT then follow the same policy as SSE and WebSocket
421
+ subscriptions: administrators and trusted internal callers only
422
+ ([api-reference.md](api-reference.md)).
423
+
308
424
  ### npm cache on the node
309
425
 
310
426
  `flair deploy` and `flair upgrade --target` pass Harper an `install_command` that runs
@@ -46,6 +46,23 @@ flair init --port 8000
46
46
 
47
47
  Or edit `~/.flair/config.yaml` and restart.
48
48
 
49
+ ### MQTT
50
+
51
+ Flair runs Harper with MQTT off in local installs: no TCP or TLS MQTT listener
52
+ and no MQTT over WebSocket. Every local start re-asserts it, and `flair doctor`
53
+ reports an instance whose saved configuration starts an MQTT listener (it reads
54
+ the configuration, not the running listeners). For a component deployed with
55
+ `flair deploy` or `flair upgrade --target` — which by default set MQTT off in
56
+ the target's configuration, request the shared worker threads' restart that
57
+ applies it for an isolated application, and read the saved configuration back
58
+ after the deploy's restart, without probing the listeners (`--keep-mqtt-config`
59
+ skips all of it, `--no-restart` and `--no-verify` skip the restart request and
60
+ the read-back) — see
61
+ [deploying-on-fabric.md](deploying-on-fabric.md#mqtt-configuration), including how an
62
+ operator turns MQTT on deliberately; table subscriptions, publishes and
63
+ retained publishes over MQTT then follow the same policy as SSE and WebSocket
64
+ subscriptions.
65
+
49
66
  ---
50
67
 
51
68
  ## Linux
@@ -35,8 +35,8 @@ That is the whole API. No deep import, no `server.resources`, no `.Resource`, no
35
35
  **3. Read it back, scoped to that agent.**
36
36
 
37
37
  ```javascript
38
- const hits = await planner.recall("deploy schedule", { limit: 5 });
39
- const record = await planner.memory.get(hits[0].id);
38
+ const hits = await planner.recall("deploy schedule", { limit: 5 }); // an array of hits
39
+ const record = await planner.memory.get(hits[0].id); // the stored row, or null
40
40
  ```
41
41
 
42
42
  **4. Register an agent, no CLI.**
@@ -50,7 +50,7 @@ await flair.admin.registerAgent("planner", { publicKey: "pending" });
50
50
  **5. Verify it worked.**
51
51
 
52
52
  ```javascript
53
- console.log(await planner.memory.search({ limit: 10 }));
53
+ console.log(await planner.memory.search({ limit: 10 })); // an array of at most 10 rows
54
54
  console.log([...server.resources.keys()].sort()); // what Flair registered
55
55
  ```
56
56
 
@@ -80,9 +80,9 @@ planner.agentId; // "planner"
80
80
  | Method | Description |
81
81
  |---|---|
82
82
  | `handle.memory.write(content, opts?)` | Write a memory as this agent. `agentId` is stamped from the handle — the caller never passes it. |
83
- | `handle.memory.get(id)` | Read a memory by id, scoped to this agent. |
84
- | `handle.memory.search(opts?)` | Search memories scoped to this agent. |
85
- | `handle.recall(query, opts?)` | Semantic search scoped to this agent. |
83
+ | `handle.memory.get(id)` | Read a memory by id, scoped to this agent. Resolves to the stored row, or `null` when that id is not readable by this agent. |
84
+ | `handle.memory.search(opts?)` | Search memories scoped to this agent. Resolves to an array of rows, at most `opts.limit` of them when that option is set. |
85
+ | `handle.recall(query, opts?)` | Semantic search scoped to this agent. Resolves to an array of hits. |
86
86
 
87
87
  ### `flair.admin`
88
88
 
@@ -93,7 +93,7 @@ Admin operations — unfiltered reads, cross-agent writes. Every call site is gr
93
93
  | Method | Description |
94
94
  |---|---|
95
95
  | `flair.admin.registerAgent(id, opts?)` | Register an agent through the Agent resource (full Principal shape). |
96
- | `flair.admin.memory.get(id)` | Read any memory by id, unfiltered. |
96
+ | `flair.admin.memory.get(id)` | Read any memory by id, unfiltered. Resolves to the stored row, or `null` when no record has that id. |
97
97
  | `flair.admin.memory.write(asAgentId, content, opts?)` | Write a memory attributed to another agent. |
98
98
 
99
99
  ### `flair.internal`
@@ -135,7 +135,7 @@ Verified against a real instance: that lands `kind: "agent"`, `status: "active"`
135
135
 
136
136
  > **Prefer this to `databases.flair.Agent.put()`.** The raw table applies **no** defaults, so a hand-written literal has to reproduce every field above and then stay in step with Flair as the Principal model grows. Records written that way are missing `kind`/`status`/`defaultTrustTier` and read as under-specified Principals in the admin surfaces.
137
137
 
138
- > **Admin is one meaning with one answer.** `role === "admin"` is the authority; the `admin` boolean is a mirror of it that the server maintains. Write **either** through the `Agent` resource and both are set — you no longer have to know which one is real, and a record cannot be stored saying one thing in one field and the opposite in the other. Nothing reads the mirror to make an authorization decision, and a promotion applied through the resource takes effect on the next request rather than after the 60-second admin-lookup cache expires.
138
+ > **Admin is one meaning with one answer.** On the Agent record, `role === "admin"` is the authority; the `admin` boolean is a mirror of it that the server maintains. An id listed in the instance's `FLAIR_ADMIN_AGENTS` is also an administrator, whatever its record's role. Write **either** through the `Agent` resource and both are set — you no longer have to know which one is real, and a record cannot be stored saying one thing in one field and the opposite in the other. The signed-request admin lookup does not use the `admin` mirror.
139
139
  >
140
140
  > A record written straight to the table (`databases.flair.Agent.put()`, an ops-API insert, a federation merge) skips that reconciliation and can still carry a mismatch. `flair principal show` and the admin dashboard flag such a record rather than silently picking a side; re-issuing the grant repairs it.
141
141
 
@@ -154,7 +154,7 @@ Flair accepts the public key as 64-char hex, or base64 of the raw 32 bytes.
154
154
 
155
155
  Both verified end to end: an agent registered this way, with a key its app minted, then authenticated over HTTP with a real `TPS-Ed25519` signature — and a request signed with the *wrong* key was rejected.
156
156
 
157
- > **Two traps.** `Agent.put()` on the *resource* silently strips `publicKey`, so set the key when you **create** the record; to rotate one later, write `databases.flair.Agent.put({ ...existing, publicKey })` on the raw table (which is what `flair agent rotate-key` does through the admin ops API — there is no dedicated endpoint today). And do **not** call `AgentSeed` in-process: although its `allowCreate()` explicitly permits the trusted `internal` verdict, its `post()` then re-checks for a named admin and returns `403 forbidden: admin only` — confirmed by running it.
157
+ > **Setting the key, and who may call `AgentSeed`.** `Agent.put()` on the *resource* is an administrator operation (a trusted in-process call is admitted; over HTTP an agent that is not an administrator is refused and updates its own record with PATCH). It updates an existing record and keeps its stored `publicKey` (a `publicKey` in the body is ignored), and an admitted PUT to an id with no record is refused with `404 agent_put_requires_existing`, so set the key when you **create** the record; to rotate one later, write `databases.flair.Agent.put({ ...existing, publicKey })` on the raw table (`flair agent rotate-key` does the equivalent through the admin operations API, an `update` of the record's `publicKey` — there is no dedicated endpoint today). `AgentSeed` writes the agent's Soul, so its `post()` admits only a Soul-write source (`authorizeSoulWrite` in `resources/soul-write-policy.ts`): over HTTP, operator Basic (a verified Harper administrator's `Basic` credential; an admin agent's `TPS-Ed25519` key is refused `403 soul_write_requires_operator`), and in-process, a deliberate trusted internal call made with `internalContext()` on the resource `collectionResource()` binds. `collectionResource()` called without a context throws `InProcessContextError` before `post()` runs, and an explicit context that lacks the internal marker is refused `403 soul_write_requires_operator`. An unauthenticated request is refused.
158
158
 
159
159
  ---
160
160
 
@@ -178,7 +178,9 @@ Flair uses the raw table where it *wants* to bypass its own rules — the federa
178
178
  | `{ request: { tpsAnonymous: true } }` | `anonymous` | Denied everywhere |
179
179
  | `{ request: { tpsAgent: "mybot" } }` | `agent` | Scoped to that agent — **use this** |
180
180
  | `{ request: { tpsAgent: "mybot", tpsAgentIsAdmin: true } }` | admin | Unfiltered reads, cross-agent writes |
181
- | **Nothing**, or an empty/missing `tpsAgent` | `internal` | **Trusted. Unfiltered.** See the warning above. |
181
+ | **Nothing** (with no ambient Harper context), or an in-process `{ request: {} }` | `internal` | Unfiltered `Memory` reads. An `allowAdmin` check admits it only when the context carries the marker that `internalContext()` sets and no request headers, and refuses it otherwise. See the warning below. |
182
+
183
+ A context with an anonymous marker or request headers can resolve differently.
182
184
 
183
185
  Build these with `agentContext(id)`, `adminContext(id)` and `internalContext()` rather than by hand — see [below](#the-api-is-built-so-omission-cannot-happen-quietly) for why the hand-written form is a trap.
184
186
 
@@ -198,7 +200,7 @@ There are exactly two ways to lose the model, from opposite ends. Both are pinne
198
200
 
199
201
  | | |
200
202
  |---|---|
201
- | **By omission** | No usable agent id ⇒ `internal` ⇒ admin-equivalent, unfiltered. |
203
+ | **By omission** | No context argument and no ambient Harper context, or an in-process `{ request: {} }` ⇒ `internal` ⇒ unfiltered `Memory` reads. Without the marker that `internalContext()` sets, an `allowAdmin` check refuses it when Harper consults the gate. |
202
204
  | **By assertion** | An attacker-influenced `agentId` is honoured verbatim. |
203
205
 
204
206
  ### The API is built so omission cannot happen quietly
@@ -207,19 +209,19 @@ There are exactly two ways to lose the model, from opposite ends. Both are pinne
207
209
 
208
210
  ```
209
211
  resolveAgentAuth({ request: { tpsAgent: undefined } }) -> { kind: "internal" }
210
- allowAdmin({ request: { tpsAgent: undefined } }) -> true
212
+ allowAdmin({ request: { tpsAgent: undefined } }) -> false
211
213
  ```
212
214
 
213
- That would turn the most ordinary bug there is — `agentContext(session.agentId)` where the field came back undefined — into silent administrator access. So the helpers refuse rather than default:
215
+ That would turn `agentContext(session.agentId)`, where the field came back undefined, into unfiltered `Memory` reads across every agent. The admin-only gate refuses it: `allowAdmin` admits the `internal` verdict only for a call that carries `internalContext()`'s marker and no request headers. So the helpers refuse rather than default:
214
216
 
215
217
  | | |
216
218
  |---|---|
217
219
  | `agentContext(id)` | **Throws** `InProcessContextError` on a missing, empty or blank id. Takes **no options**, so no object spread into it can escalate. |
218
- | `adminContext(id)` | The *only* way to get admin authority. Same id guard. |
219
- | `internalContext()` | The *only* way to get the unfiltered verdict. |
220
+ | `adminContext(id)` | Builds `{ request: { tpsAgent: id, tpsAgentIsAdmin: true } }`. Same id guard. |
221
+ | `internalContext()` | Builds `{ request: {}, __flairInternal: true }`, which resolves to `internal` and carries the marker that `allowAdmin` checks. |
220
222
  | `collectionResource(Cls, context)` | Context is **required**; omitting it throws rather than granting `internal`. |
221
223
 
222
- The privileged paths are now the longest ones to type, and `git grep "adminContext\|internalContext"` enumerates every deliberate escalation in your codebase. These are runtime guards, not type annotations — a plain-JavaScript embedder gets exactly the same protection.
224
+ Elevated calls have named helpers, and `git grep "adminContext\|internalContext"` finds textual references to those helper names in tracked files. These are runtime guards, not type annotations.
223
225
 
224
226
  ### Individual identities, not one app identity
225
227
 
@@ -346,11 +348,11 @@ export async function remember(agentId, content, opts = {}) {
346
348
  >
347
349
  > `collectionResource(Cls, context)` is a two-line wrapper over the supported call — `Cls.getResource({}, context, { isCollection: true })` — and exists so this is written once. **Reads do not need it:** `Cls.get(id, context)` and `Cls.search(query, context)` thread the context themselves.
348
350
  >
349
- > They do still need the **context**. Only the collection binding is unnecessary for a read, never the identity — `Cls.search(query)` with the second argument left off resolves to the trusted `internal` verdict when it runs outside a request scope (a boot hook, a timer, a queue worker, a detached promise) and returns every agent's private records. On that path the resource's `allow*` gate is not consulted at all. Pass the context to every call, read and write.
351
+ > They do still need the **context**. Pass the context to every call, read and write; the warning below covers what omitting it does.
350
352
 
351
- > ### ⚠️ A resource with no context is an administrator
353
+ > ### ⚠️ A `Memory` read with no context can run unfiltered
352
354
  >
353
- > A resource built without a context resolves to Flair's trusted `internal` verdict and runs **unfiltered** — every read unscoped, every write unowned. Silently. No error, no warning, no trace.
355
+ > A resource given no context, when no ambient Harper context is present, resolves to Flair's trusted `internal` verdict. A `Memory` read then runs **unfiltered** across every agent, and the omission raises no error. An `allowAdmin` check refuses the same verdict when Harper consults the gate.
354
356
  >
355
357
  > Measured, not inferred: a context-less `Memory.search()` returns every agent's `private` records, and so does a context-less `SemanticSearch`.
356
358
  >
@@ -383,7 +385,7 @@ export async function registerAgent(id, { publicKey = "pending", admin = false }
383
385
 
384
386
  ### What we measured, so you do not have to
385
387
 
386
- Run end to end on **Harper 5.1.22**, from a second component loaded into the same instance — the exact shape above. `test/integration/in-process-agents.test.ts` in the Flair repo is that run, and `test/fixtures/inproc-app` is the component it drives.
388
+ Run end to end on **Harper 5.1.22**, from a second component loaded into the same instance — the exact shape above. `test/integration-heavy/in-process-agents.test.ts` in the Flair repo is that run, and `test/fixtures/inproc-app` is the component it drives.
387
389
 
388
390
  | Claim | Result |
389
391
  |---|---|
@@ -402,4 +404,4 @@ Handlers return a `Response` for `401`/`403`/`400` rather than throwing — chec
402
404
 
403
405
  ## See also
404
406
 
405
- [Integrations](integrations.md) · [Deployment](deployment.md) · [Federation](federation.md) · [Auth](auth.md) · [Architecture](../DESIGN.md)
407
+ [Integrations](integrations.md) · [Deployment](deployment.md) · [Federation](federation.md) · [Auth](auth.md) · [Architecture](https://github.com/tpsdev-ai/flair/blob/main/DESIGN.md)
@@ -14,10 +14,9 @@ and the new `entities` fields on `WorkspaceState`/`OrgEvent`/`Memory`), plus the
14
14
  query and bootstrap collision surfacing (both shipped in later slices) and any future MCP
15
15
  scope field — retrofitting a divergent vocabulary later is expensive.
16
16
 
17
- > This doc covers the vocabulary and validator only — the foundation slice of the attention
18
- > plane (flair#675). The attention query ("what touches entity E in the last N days") and
19
- > bootstrap collision surfacing are separate, later slices. See `FLAIR-ATTENTION-PLANE.md`
20
- > for the full design.
17
+ > This doc covers the vocabulary and validator, the foundation slice of the attention
18
+ > plane (flair#675). The attention query (flair#677) and bootstrap collision surfacing
19
+ > (flair#681) build on it.
21
20
 
22
21
  ## The form
23
22
 
@@ -54,8 +53,8 @@ Rules that apply across every type:
54
53
 
55
54
  ## The validator
56
55
 
57
- `resources/entity-vocab.ts` is the single source of truth — every write path that persists
58
- an `entities` value validates against it, not a local reimplementation of the grammar.
56
+ `resources/entity-vocab.ts` validates `entities` on Memory and WorkspaceState
57
+ POST/PUT, and on single-record OrgEvent POST/PUT.
59
58
 
60
59
  ```ts
61
60
  import { isValidEntity, validateEntities, invalidEntitiesResponse } from "./entity-vocab.js";
@@ -72,7 +71,7 @@ validateEntities(undefined);
72
71
  ```
73
72
 
74
73
  `invalidEntitiesResponse(entities)` is a thin convenience wrapper for Harper resource write
75
- paths: it returns a ready-to-return `400 { error: "invalid_entities", invalid: [...] }`
74
+ paths: it returns a ready-to-return `400 { error: "invalid_entities", invalid: [...], message: "..." }`
76
75
  `Response` when validation fails, or `null` when the field is absent or every entry is valid.
77
76
  `WorkspaceState.ts`, `OrgEvent.ts`, and `Memory.ts` all call it early in `post()`/`put()`.
78
77
 
@@ -98,8 +97,7 @@ flair memory add --agent flint --entities "repo:tpsdev-ai/flair,issue:tpsdev-ai/
98
97
  ```
99
98
 
100
99
  The CLI validates each value before writing (a malformed value is rejected with the
101
- `type:value` format and the valid type list); the server re-validates on every write path
102
- regardless. The CLI's validator is an inlined copy of this module
100
+ `type:value` format and the valid type list). The CLI's validator is an inlined copy of this module
103
101
  (`src/lib/entity-vocab-cli.ts` — `src/` can't import across the packaging boundary into
104
102
  `resources/`), pinned to it by `test/unit/cli-entities-option.test.ts`; the server-side gate
105
103
  remains this module alone.
@@ -120,5 +118,3 @@ vocabulary; wiring that validation is a follow-up, not part of this foundation s
120
118
  - Automatic entity extraction/tagging on write (producers set `entities` themselves today,
121
119
  where they choose to; there's no NLP-derived auto-population yet).
122
120
  - Validating `Relationship.subject`/`object` against this vocabulary.
123
-
124
- These are tracked as follow-ups in `FLAIR-ATTENTION-PLANE.md`.