@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
@@ -6,7 +6,7 @@ adopter does not have to read `resources/` or `schemas/` to see what is
6
6
  callable.
7
7
 
8
8
  - **Auth model:** [docs/auth.md](auth.md), [SECURITY.md](../SECURITY.md)
9
- - **Access invariant:** [DESIGN.md](../DESIGN.md) — open within the org, closed
9
+ - **Access invariant:** [DESIGN.md](https://github.com/tpsdev-ai/flair/blob/main/DESIGN.md) — open within the org, closed
10
10
  at the federation edge
11
11
  - **Federation pairing and sync:** [docs/federation.md](federation.md)
12
12
  - **Source of truth for tables:** [`schemas/*.graphql`](../schemas/)
@@ -17,7 +17,7 @@ fails when a GraphQL `@table` type is missing from this file, so a new table
17
17
  cannot land undocumented.
18
18
 
19
19
  Default REST port is `19926` (`DEFAULT_PORT` in `src/cli.ts`). Override with
20
- `--port` / `HTTP_PORT`. Sign remote requests as
20
+ `flair init --port <port>`; CLI commands also read `FLAIR_URL`. Sign remote requests as
21
21
  `agentId:timestamp:nonce:METHOD:/path?query` and send
22
22
  `Authorization: TPS-Ed25519 <agentId>:<ts>:<nonce>:<sig>`. Protocol detail is
23
23
  in [SECURITY.md](../SECURITY.md).
@@ -54,10 +54,11 @@ the schema section so the catalog is complete.
54
54
  | **Admin Basic** | Harper `HDB_ADMIN_PASSWORD` / `FLAIR_ADMIN_PASSWORD` | Whole-instance operator. Bypasses agent scoping, including `private` memory. Used by the web admin and `n8n-nodes-flair`. |
55
55
  | **Operator / internal** | Admin Basic, or a deliberate `internalContext()` call inside the process | Soul mutations, `OrgSkillAssignment` writes and `AgentSeed`. Agent Ed25519 keys — including admin-agent keys — cannot author Soul. |
56
56
  | **Federation body-sig** | Ed25519 over the request body + timestamp/nonce; pairing uses a one-time token | `/FederationPair`, `/FederationSync`. Harper role gate is open; the handler is the auth boundary. |
57
- | **OAuth bearer** | Access token from Flair's AS or `@harperfast/oauth` | `/mcp` only, and only when `FLAIR_MCP_OAUTH=true` plus a public issuer. Off by default (path 404s). |
57
+ | **OAuth bearer** | Access token from `@harperfast/oauth` | Native `/mcp` authentication. Off by default. |
58
58
 
59
- Anonymous HTTP is denied on every agent-facing table (and on `GET /Presence`, which needs a verified reader unless the instance enables the public-roster opt-in). A by-id miss and a
60
- by-id deny both return **404**, never 403, so ids are not an existence oracle.
59
+ Anonymous HTTP is denied on every agent-facing table (and on `GET /Presence`, which needs a verified reader unless the instance enables the public-roster opt-in). By-id refusal
60
+ status is resource-specific: Memory returns **404** for missing or unreadable rows, while Credential
61
+ refuses a non-admin's by-id read of another principal's credential.
61
62
 
62
63
  **PATCH updates existing rows.** On every table, a PATCH from a caller that is
63
64
  not an administrator or a trusted internal call does not create or modify its
@@ -74,7 +75,55 @@ or an admin agent) and trusted internal callers only. A verified non-admin
74
75
  agent is refused with **403** (WebSocket close code 3003), and a caller without
75
76
  a valid credential with **401** (close code 3000). Verified agents receive
76
77
  changes to the memories they can read through `/FeedMemories`, and soul changes
77
- through `/FeedSouls`; neither is a table.
78
+ through `/FeedSouls`; neither is a table. Harper's native MCP
79
+ `resources/subscribe`, available only when an operator configures Harper's MCP
80
+ component, refuses every table subscription, administrators included: flair
81
+ does not yet verify the Harper user of an MCP session as a flair caller. For
82
+ the same reason, that component's application tools (`get_`, `search_`,
83
+ `create_`, `update_`, `delete_`) are resolved, wherever flair resolves a
84
+ caller, as a caller without a valid credential, administrators included.
85
+
86
+ Flair's local installs run Harper with MQTT off. For a component deployment,
87
+ `flair deploy` and `flair upgrade --target` by default set MQTT off in the
88
+ target's configuration, request the shared worker threads' restart that
89
+ applies it for an isolated application, and read the saved configuration back
90
+ after the deploy's restart (`--keep-mqtt-config` skips all of it;
91
+ `--no-restart` and `--no-verify` skip the restart request and the read-back);
92
+ they do not probe the listeners
93
+ ([deploying-on-fabric.md](deploying-on-fabric.md#mqtt-configuration)). When an
94
+ operator turns MQTT on, an exported table's path is also an MQTT topic (`<Table>/#`,
95
+ `<Table>/<id>`) — except a path that a resource other than the table serves
96
+ (`AgentReadPosition`, `OAuthToken`), which follows that resource's own rules.
97
+ On a table topic, these MQTT actions are served to administrators and trusted
98
+ internal callers only: SUBSCRIBE; PUBLISH; a retained PUBLISH (which writes
99
+ the row, or with an empty payload deletes it); and a session's last-will when
100
+ Harper publishes it. UNSUBSCRIBE is not guarded: it only ends a subscription
101
+ the session already holds. CONNECT is Harper's own authentication.
102
+
103
+ Over MQTT 5, a refused SUBSCRIBE gets SUBACK reason code `0x87` (not
104
+ authorized) for a verified non-admin agent and for a caller without a login
105
+ whose session Harper admits (Harper may instead refuse that
106
+ caller at CONNECT). A refused PUBLISH is answered only when it asks for an
107
+ acknowledgment: at QoS 1 (PUBACK) or QoS 2 (PUBREC) it gets the same codes, and
108
+ a verified non-admin agent's also carries the refusal as a reason string unless
109
+ the client turned problem information off or the string would exceed its
110
+ maximum packet size. A refused QoS 0 PUBLISH gets no answer. Over MQTT 3.1.1, a
111
+ refused SUBSCRIBE gets SUBACK `0x80`, and a PUBACK carries no reason code, so a
112
+ PUBACK alone cannot tell a refused PUBLISH from an accepted one. A refused
113
+ publish reaches no subscriber, and a refused retained publish leaves the row as
114
+ it was.
115
+
116
+ A session's last-will message is decided when Harper publishes it: when the
117
+ session drops without DISCONNECT, as that session's own publish; and when
118
+ Harper replays the eligible wills it still holds as its first worker starts,
119
+ as a caller without a valid credential, so a replayed will on a table topic is
120
+ refused, an administrator's included. Harper drops an expired scoped-token
121
+ will before this check, on replay and when a session drops. Over MQTT on
122
+ WebSocket the credential is
123
+ the one on the WebSocket upgrade request, as for SSE and WebSocket. An MQTT
124
+ connection on Harper's TCP or TLS listener carries no HTTP request, so flair
125
+ resolves the caller of each of its actions as one without a valid credential,
126
+ whatever it sent in CONNECT.
78
127
 
79
128
  Every Ed25519-signed request and federation body carries a nonce, recorded
80
129
  once per instance in the `ReplayNonce` table before the request takes effect.
@@ -89,27 +138,28 @@ From `RECORD_TYPES` in `resources/record-types.ts`:
89
138
 
90
139
  | Scope | Meaning | Tables |
91
140
  |-------|---------|--------|
92
- | **open-within-org** | Own rows (any visibility) plus every other agent's non-private rows | Memory |
141
+ | **open-within-org** | Base scope: own rows at any visibility plus other agents' non-private rows; non-admin Memory by-id and collection reads of retained closed skills additionally require readable current authority. | Memory |
93
142
  | **owner-only** | Only the owning agent (plus admin / internal) | Relationship, WorkspaceState, Asset, MemoryCandidate |
94
143
  | **none** | Any verified agent reads every row; no visibility field | Soul, OrgEvent, OrgSkillAssignment |
95
144
 
96
- These three scopes are **not** in `RECORD_TYPES`. Each is hand-implemented on its
97
- own resource:
145
+ The following resources implement their read scopes outside `RECORD_TYPES`.
98
146
 
99
147
  | Scope | Meaning | Table | Enforced in |
100
148
  |-------|---------|-------|-------------|
101
149
  | **party** | Sender or recipient only | Message | `resources/Message.ts` |
102
150
  | **own-ledger** | Non-admin reads: only the contributing agent's rows, about memories it can read. Admin / internal reads: unfiltered | MemoryUsage | `resources/MemoryUsage.ts` |
103
151
  | **owner-or-grantee** | Either party on the grant | MemoryGrant | `resources/MemoryGrant.ts` |
152
+ | **owner-only** | Non-admin reads match `principalId` to the caller; administrator/internal reads are unfiltered | Credential | `resources/Credential.ts` |
104
153
 
105
154
  Writes stamp `agentId` (or `authorId` / `from`) from the authenticated
106
155
  principal. A body that names a different owner is rejected or overwritten
107
156
  per the table's attribution mode — never trusted.
108
157
 
109
158
  Federation sync currently pushes **Memory** (non-`private`), **Soul**,
110
- **Agent**, and **Relationship**. `Message` has a classifier policy for a later
111
- cross-host slice; it is not in today's spoke push list. Everything else is
112
- instance-local.
159
+ **Agent**, and **Relationship**. **Presence** send and receive are opt-in via
160
+ `FLAIR_FEDERATION_PRESENCE_SEND` and `FLAIR_FEDERATION_PRESENCE_RECEIVE`.
161
+ `Message` has a classifier policy for a later cross-host slice; it is not in
162
+ today's spoke push list.
113
163
 
114
164
  ---
115
165
 
@@ -126,30 +176,53 @@ is `GET /Name/<id>` unless noted.
126
176
  | GET | `/HealthDetail` | Ed25519 | Rich stats (counts, agents, migration). `bm25.summary` is this worker's lexical index: `building N/M docs`, `ready · N docs`, or `disabled — reason`. |
127
177
  | GET | `/AgentCard/<agentId>` | Public | A2A agent-card; field-allowlisted. |
128
178
  | GET | `/a2a`, `/A2AAdapter` | Public | A2A discovery. |
129
- | POST | `/a2a`, `/A2AAdapter` | Ed25519 | JSON-RPC actions (writes OrgEvents, reads tasks). GET-only is public; POST is not. |
179
+ | POST | `/a2a`, `/A2AAdapter` | Ed25519 | JSON-RPC actions (writes OrgEvents, streams an agent's OrgEvents, reads tasks). GET-only is public; POST is not. Methods: [A2A JSON-RPC](#a2a-json-rpc-post-a2a). |
180
+
181
+ #### A2A JSON-RPC (`POST /a2a`)
182
+
183
+ `POST /a2a` takes a JSON-RPC 2.0 request and requires a `TPS-Ed25519`
184
+ signature or admin Basic auth. A request with neither is answered with error
185
+ `-32001` `Unauthorized`.
186
+
187
+ **Caller match (`message/send` and `message/stream` only).** For these two
188
+ methods `params.agentId` must be the caller's own agent id when the caller is
189
+ not an admin; any other id is answered with error `-32001` `Forbidden`, whose
190
+ `data.detail` names the method (`caller <a> cannot send as <b>`, `caller <a>
191
+ cannot stream as <b>`). An admin caller may name another agent. `tasks/list`
192
+ does not apply this rule: its `params.agentId` is only an assignee filter.
193
+
194
+ | Method | What it does |
195
+ |--------|--------------|
196
+ | `message/send` | Writes an `a2a.message` OrgEvent authored by `params.agentId`, targeted at `params.toAgentId`, or at `params.agentId` when that is omitted. |
197
+ | `message/stream` | Answers with a `text/event-stream` of OrgEvents for `params.agentId`: the events targeted at that agent or carrying no targets, not expired, created after the stream's opening position, in catch-up position order. The opening position follows every event created in or before the millisecond the stream opened (whatever its id); the stream's opening comment and first read wait until that millisecond has passed. The events are read in process through `OrgEventCatchup` with the requesting caller's own identity. The stream keeps its own cursor, passed to each catch-up read: it never moves the agent's durable catch-up watermark (which a default `GET /OrgEventCatchup/<agentId>` starts from), and the watermark does not decide what the stream delivers. A missing `params.agentId` is error `-32602`. Each event arrives as an `org.event` frame whose `data` is a JSON-RPC result `{ type: "event", event }`. A `task.status` frame follows when the status helper finds a status for the event: from its `detail`, its `status` or `kind`, or words in its `summary` (the helper may infer `failed` from `error` in the summary). The stream ends when the client disconnects, after 5 minutes, at an event for the task named in `params.taskId` whose status is terminal (`completed`, `failed`, `canceled`; later events in that read are not sent), or with one `error` frame (a JSON-RPC error) when a read is refused or fails while the stream is open. A read that settles after the stream has ended sends nothing. A POST whose body is a JSON-RPC request reaches this handler with or without `Accept: text/event-stream`. |
198
+ | `tasks/get` | One task by `params.taskId`, with its OrgEvent history. |
199
+ | `tasks/list` | The instance's Beads task board on the Flair host, from one source: the `.yaml`/`.yml` files in `~/ops/.beads/issues/` when at least one exists, otherwise `~/ops/.beads/issues.jsonl`. The two sources are not combined. An authenticated caller can request the unfiltered board; the board is shared within one instance and not scoped per caller. Optional filters: `params.agentId` matches the issue's assignee (case-insensitive) and `params.status` the mapped A2A status (`working`, `completed`, `input-required`, `canceled`). Tasks are ordered newest `updatedAt` first. An anonymous request is refused (`-32001`). |
130
200
 
131
201
  ### Identity — Agent, Presence, Soul
132
202
 
133
203
  | Method | Path | Auth | Read / write |
134
204
  |--------|------|------|--------------|
135
205
  | GET | `/Agent`, `/Agent/<id>` | Ed25519 | Any verified agent may read principals (discovery). |
136
- | POST | `/Agent` | Admin Basic | Create principal. Also `POST /AgentSeed` (operator/internal only — not an admin-agent key). |
137
- | PUT / PATCH | `/Agent/<id>` | Ed25519 | An agent updates **only its own** record. |
138
- | DELETE | `/Agent/<id>` | Admin Basic | Deprovision. |
139
- | POST | `/AgentKeyRegister` | Basic admin / Ed25519 agent with the admin annotation | Register an agent key. Under Flair's per-agent registration lock, reads a fresh local, non-deactivated row with `publicKey: "pending"` and, at the confirmation read, requires the committed row to equal the fresh-read snapshot and still be `pending` before commit. The lock serializes registrations for that agent within one Harper process; raw operations-API writes and other processes do not take it. A change committed after the confirmation read and before commit is not seen, and a change restored before the confirmation read is not observed; a commit-time pending check is a follow-up. Unsupported schemes that reach the handler receive 401 before Flair's `resolveAgentAuth`, body validation and table reads. Harper handles some Authorization values upstream: a Bearer refresh token receives Harper's 404 before any resource runs. Refuses 409 `agent_key_not_pending` (a non-`pending` row points to key rotation), 403 `agent_not_local` / `agent_inactive`, 404 `agent_not_found`, 400 `registration_request_invalid`, 409 `registration_conflict`, 503 `registration_unavailable`. Writes an `AgentKeyRegistration` audit row and an `agent_key_registered` OrgEvent. The audit `keyFingerprint` and the event `detail` carry the key fingerprint, not the key; the audit `agentId` and the event `refId` carry the target agent's id, which the event `summary` names in text. |
206
+ | POST | `/Agent` | Admin Basic / Ed25519 admin | Create principal. Also `POST /AgentSeed` (operator/internal only — not an admin-agent key). |
207
+ | PUT | `/Agent/<id>` | Ed25519 admin / Admin Basic | An administrator operation. An administrator (an Ed25519 agent whose record has `role: "admin"` or whose id `FLAIR_ADMIN_AGENTS` names, or Admin Basic) may PUT any existing record. For a request that reaches `Agent.put()`, the target id is checked first: an id outside the agent-id rule is refused 400 before the handler's authorization and existence checks. Authentication, routing and Harper's resource admission (for a missing target, `allowCreate()`, administrators only) can refuse earlier. For a valid id, a PUT from any other verified agent is refused 403: `agent_put_admin_only` when the record exists, Harper's create check (`allowCreate()`, administrators only) when it does not; such an agent updates its own record with PATCH. An unauthenticated request is refused. The PUT is a full replacement of an existing record. The server sets these fields whatever the body says: the id is the URL's; `createdAt`, `publicKey`, `originatorInstanceId` and the receiver federation fields (`_originatorInstanceId`, `_syncedFrom`, `_syncedAt`) are kept from the stored record; `updatedAt` is set by the handler; `role` and `admin` are reconciled (an admin role or `admin: true` sets both, otherwise `admin` is false). Every other field comes from the body, so an ordinary field the body omits (`status` and `role` included) is not kept, and an absent `status` reads as active. An administrator's PUT to a valid id with no record is refused 404 `agent_put_requires_existing` (a body `id` that disagrees with the URL's is refused instead). |
208
+ | PATCH | `/Agent/<id>` | Ed25519 / Admin Basic | Merges the body into the stored record. A verified agent that is not an administrator may PATCH only its own record, may not write `status`, and may not change the record's admin status (403); the admin-status decision compares the `role` of the row it reads with the role that row would have once the body is merged and reconciled. An administrator may PATCH any record. An unauthenticated request is refused. |
209
+ | DELETE | `/Agent/<id>` | Admin Basic / Ed25519 admin | Deprovision. |
210
+ | POST | `/AgentKeyRegister` | Basic admin / Ed25519 agent with the admin annotation | Register an agent key. Under Flair's per-agent registration lock, reads a fresh local, non-deactivated row with `publicKey: "pending"` and, at the confirmation read, requires the committed row to equal the fresh-read snapshot and still be `pending` before commit. The lock serializes registrations for that agent within one Harper process; raw operations-API writes and other processes do not take it. The post-commit read-back detects surviving differences in compared fields or identity and reports the registered key only when the committed row still has the registered key's identity and the staged `publicKey` and `updatedAt`, and the `AgentKeyRegistration` row this attempt wrote under its `registrationId` is present; otherwise it refuses 503 `registration_unavailable` with outcome `unconfirmed`. A change restored before the confirmation read is not observed; a commit-time pending check is a follow-up. Unsupported schemes that reach the handler receive 401 before Flair's `resolveAgentAuth`, body validation and table reads. Harper handles some Authorization values upstream: a Bearer refresh token receives Harper's 404 before any resource runs. Refuses 409 `agent_key_not_pending` (a non-`pending` row points to key rotation), 403 `agent_not_local` / `agent_inactive`, 404 `agent_not_found`, 400 `registration_request_invalid`, 409 `registration_conflict`, 503 `registration_unavailable`. Writes an `AgentKeyRegistration` audit row and an `agent_key_registered` OrgEvent. The audit `keyFingerprint` and the event `detail` carry the key fingerprint, not the key; the audit `agentId` and the event `refId` carry the target agent's id, which the event `summary` names in text. |
140
211
  | GET | `/Presence` | Verified reader | Roster. Requires a valid `TPS-Ed25519` agent signature or the admin credential; an anonymous request gets 401. An instance may opt in to a public roster with `PRESENCE_PUBLIC_ROSTER=true`, in which case an unverified reader gets the allowlisted roster with `currentTask`, `flairVersion`, and `harperVersion` as null. Thresholds: [Presence for API consumers](#presence-for-api-consumers). |
141
212
  | POST | `/Presence` | Ed25519 | Heartbeat. Agent writes only its own row (403 cross-agent). Stamps `flairVersion` / `harperVersion` on the row. |
142
213
  | PUT / DELETE | `/Presence/<id>` | Ed25519 | Own row only. Collection PUT is not a public bypass. |
143
214
  | GET | `/Soul`, `/Soul/<id>` | Ed25519 | Any verified agent; unscoped (identity/discovery). |
144
215
  | POST / PUT / PATCH / DELETE | `/Soul` | **Operator / internal** | Not Ed25519. Learned Memory text cannot be copied in as Soul. See [docs/auth.md](auth.md#soul-authorship). |
145
- | POST | `/FeedSouls` | Ed25519 | Soul change feed (verified). |
146
-
147
- `Credential` (GET/POST verified; extra credentials for a principal; through
148
- this resource only an administrator or the server creates a `kind: "idp"`
149
- credential, changes its kind or identity fields, or reactivates it, and its
150
- owner may relabel, revoke or delete it, see
151
- [Who writes a mapping](access-control.md#who-writes-a-mapping)) and
152
- `Integration` (legacy 0.x platform rows; verified, prefer Credential) sit on
216
+ | GET (SSE / WebSocket) | `/FeedSouls` | Ed25519 | Soul subscription. |
217
+
218
+ `Credential` (extra credentials for a principal) requires authenticated HTTP
219
+ access: non-admin by-id reads and writes are limited to the caller's
220
+ `principalId`, while administrators and trusted internal callers may access
221
+ other principals' credentials. Through this resource only an administrator or the server creates a
222
+ `kind: "idp"` credential, changes its kind or identity fields, or reactivates
223
+ it, and its owner may relabel, revoke or delete it (see
224
+ [Who writes a mapping](access-control.md#who-writes-a-mapping)). `Credential`
225
+ and `Integration` (legacy 0.x platform rows; verified, prefer Credential) sit on
153
226
  the same identity plane. `AgentKeyRegistration`
154
227
  (agent-key-registration.graphql) is the admin-read-only audit log of committed
155
228
  registrations; its key field is the fingerprint, not the key.
@@ -158,7 +231,7 @@ registrations; its key field is the fingerprint, not the key.
158
231
 
159
232
  | Method | Path | Auth | Read / write |
160
233
  |--------|------|------|--------------|
161
- | GET | `/Memory`, `/Memory/<id>` | Ed25519 | open-within-org. By-id deny = 404. |
234
+ | GET | `/Memory`, `/Memory/<id>` | Ed25519 | Open-within-org base scope, with the additional current-authority check for non-admin reads of retained closed skills; denied by-id reads return 404 and denied collection rows are omitted. |
162
235
  | POST / PUT / PATCH | `/Memory` | Ed25519 | Own `agentId` only. Auto-embed on write. Visibility defaults from durability (`permanent`/`persistent` → `shared`, `standard`/`ephemeral` → `private`). Identified client older than 0.18.0 → **426** `stale_flair_client` (missing version is served). |
163
236
  | PATCH | `/Memory/<id>`, body `{"embedding": null, "embeddingModel": null}` | Ed25519 | Owner or admin. Re-embeds the stored row, writing `embedding`, `embeddingModel` and `updatedAt`, and answers `{ id, updatedAt }` (what `flair reembed` sends; it reads `embeddingModel` from the stored row afterwards). |
164
237
  | DELETE | `/Memory/<id>` | Ed25519 | Owner or admin. `permanent` owner-delete is allowed. |
@@ -170,14 +243,14 @@ registrations; its key field is the fingerprint, not the key.
170
243
  | GET / write | `/Asset` | Ed25519 | Owner-only blobs linked by `memoryId`. No MCP and no federation in this slice. |
171
244
  | GET / write | `/MemoryCandidate` | Ed25519 | Owner-only REM drafts. Never auto-promoted except the narrow ADK path. |
172
245
  | POST | `/PromoteMemoryCandidate` | Ed25519 | Promote/reject with required rationale. |
173
- | POST | `/AutoPromoteCandidates` | Ed25519 | ADK per-user auto-promote only. |
246
+ | POST | `/AutoPromoteCandidates` | Ed25519 | Auto-promote of eligible per-user ADK and continuity candidates. Answers `promoted` (memory ids), `skipped` (`{ id, reason }`), `incomplete` (`{ memoryId, candidateId, error }`: memory written and stamped, candidate update threw, candidate read back `pending`), `unconfirmed` (the same throw where the read-back did not confirm the promotion on this memory, plus `readBack` with what it found), `count` (`promoted` only) and `considered`. A later sweep can adopt the recorded memory of a candidate still pending, without a second memory, only when the memory's identity is present on the candidate and the memory still passes the sweep's checks. See [docs/rem.md](rem.md#auto-promote-adk-only). |
174
247
  | POST | `/FeedMemories` | Ed25519 | Ingest path; `agentId` stamped from the caller (`stamp-strict`). |
175
- | POST | `/MemoryArchive` | Ed25519 | Basement / restore (`memory_basement` / `memory_restore` on `/mcp`). |
176
- | POST | `/MemoryMaintenance` | Ed25519 or admin | Hygiene: expire ephemeral, archive old standard. Agent-scoped unless admin. |
177
- | POST | `/MemoryReindex` | Admin / verified per handler | Embedding / HNSW rebuild. |
178
- | POST | `/MemoryConsolidate` | Ed25519 | Dedup / consolidate. |
179
- | POST | `/MemoryReflect` | Ed25519 | REM distill → MemoryCandidate. |
180
- | POST | `/MemoryDedupStats` | Admin Basic | Dedup diagnostics. Fleet-wide sweep; `allowCreate` is `allowAdmin`. |
248
+ | POST | `/MemoryArchive` | Ed25519 | Basement / restore. Accepts `{ id, action: "basement" \| "restore" }`; a successful ordinary-memory operation returns HTTP 200 with Memory.put()'s write receipt, including `id`, `written`, `deduplicated` and any returned visibility or redaction fields. Read the memory to inspect its archive state. Read/write refusals retain their HTTP status and body; a persisted-row change detected by the archive's re-read returns `409 memory_changed`. |
249
+ | POST | `/MemoryMaintenance` | Ed25519 or admin | Hygiene: expire ephemeral, archive old standard. An agent's own run is scoped to the caller; an admin run with no `agentId` is fleet-wide, and one that names an `agentId` is scoped to that agent. Fleet-wide maintenance expires and archives eligible rows of every agent. A supplied admin `agentId` that is not a conforming string (the agent-id rule `^[a-zA-Z0-9_-]{1,64}$` included) is refused 400 with the rule and a `remedy`: run that agent's own authenticated non-admin maintenance, which reaches its rows, when the stored id can authenticate (the signed TPS-Ed25519 header cannot carry a colon or whitespace); for an id the header cannot represent, run fleet-wide, which reaches that agent's rows and expires or archives every other agent's eligible rows. |
250
+ | POST | `/MemoryReindex` | Admin Basic / Ed25519 admin | Secondary-index (`agentId`) heal via primary-store re-PUT (no embedding regeneration). |
251
+ | POST | `/ConsolidateMemories` | Ed25519 | Dedup / consolidate. |
252
+ | POST | `/ReflectMemories` | Ed25519 | REM distill → MemoryCandidate. |
253
+ | POST | `/MemoryDedupStats` | Admin Basic / Ed25519 admin | Dedup diagnostics. Fleet-wide sweep; `allowCreate` is `allowAdmin`. |
181
254
  | POST | `/MemoryPurge` | **Operator / internal** | Not Ed25519, admin-agent keys included. Physical removal of Memory rows by id; a skill-tagged row expands to its whole skill lineage. `removedIds` lists the rows a read after the commit finds gone; a target not stored before the delete fails the call (404). A target still stored after the commit keeps its pointer row. Unconfirmed history cleanup returns 500 `memory_purge_history_cleanup_unconfirmed` before pointer-cleanup failure (500 `memory_purge_pointer_cleanup_failed`) or a still-stored target (409 `memory_purge_unconfirmed`). Does not change `DELETE /Memory/<id>`. An accepted DELETE of a non-reserved skill closes its head; the reserved `using-flair` seed is physically deleted. |
182
255
  | POST | `/SkillScan` | Ed25519 | Skill-tag scan on Memory writes. |
183
256
  | GET | `/OrgSkillAssignment`, `/OrgSkillAssignment/<id>` | Ed25519 | Any verified agent. Org-scope skill assignments; see the `skills` paragraph in [docs/mcp-clients.md](mcp-clients.md). Not federated. |
@@ -186,6 +259,21 @@ registrations; its key field is the fingerprint, not the key.
186
259
  Skill-tagged Memory rows embed from `trigger` (the recall signal), not
187
260
  `content`. MCP tools: `skill_store`, `skill_search`, `skill_get`.
188
261
 
262
+ For non-admin Memory by-id and collection reads, a retained closed skill payload must pass both its
263
+ stored owner/visibility check and its subject's current-authority check: a
264
+ readable live skill referenced by a matching create/update head, or a readable
265
+ delete head with `memoryId: null`. Missing, invalid or unreadable authority
266
+ denies the payload even to its owner: by-id reads return 404 and collection
267
+ reads omit it. Administrator and trusted internal reads are not subject to this additional
268
+ check.
269
+
270
+ Superseding a skill closes its predecessor with `validTo`; deleting a
271
+ non-reserved skill closes its live head and appends a delete version while
272
+ retaining the Memory row. Skill writes through Memory POST/PUT and
273
+ `FeedMemories` that supply a non-null `archived` value other than `false` or a
274
+ nonempty `validTo` are refused with `400 skill_state_requires_delete`, so basementing a
275
+ skill is refused.
276
+
189
277
  #### Client version gate (HTTP 426 `stale_flair_client`)
190
278
 
191
279
  `POST` / `PUT` / `PATCH` `/Memory` refuse an **identified**
@@ -225,12 +313,23 @@ The remedy is `flair upgrade` (the adapter), not a server upgrade alone.
225
313
  |--------|------|------|--------------|
226
314
  | GET / POST / PUT | `/Relationship` | Ed25519 / Admin Basic | Owner-only for non-admin agents; administrators can read across owners. POST creates; a create that is otherwise admitted, valid and within the rate limit is 409 when its id already exists. PUT upserts. For a verified non-admin agent both stamp the owner from the caller (a body naming another agent is 403); an administrator keeps the owner it supplies. A write that passes validation gets provenance built server-side. |
227
315
  | GET / POST / PUT | `/WorkspaceState` | Ed25519 | Owner-only. POST stamps `agentId`; PUT rejects a mismatch. |
228
- | GET | `/WorkspaceLatest` | Ed25519 | Latest workspace row for the caller. |
316
+ | GET | `/WorkspaceLatest/<agentId>` | Ed25519 | Latest workspace row for the caller. |
229
317
  | GET / POST / PUT / PATCH | `/OrgEvent` | Ed25519 / Admin Basic | Any verified agent reads every event. `authorId` for a non-admin agent: POST sets it from the caller, whatever the body says; PUT requires the body to name the caller (403 otherwise, including when it is absent); PATCH leaves the stored value unless the body names one, and refuses a change (403). An administrator (an admin agent key or credentialed Basic admin) may supply `authorId` on any verb; POST defaults it to the administrator's own id. The server assigns an OrgEvent's `createdAt` on create. After the earlier checks, a `createdAt` check reads the stored row under each event's id. A stored row's `createdAt` is authoritative whatever its value (an empty string included): an update that omits it keeps it, and one that names a different value is refused with 409 `created_at_immutable`. An event that reaches the check and is not an object, or whose id is not a non-empty string or a non-empty array of strings, is refused with 400 `invalid_event_id` before any write, as is an administrator's PATCH to the collection (for a non-admin's collection PUT, PATCH or DELETE, if reached, the table guard returns the 403 collection refusal; existing DELETE middleware may refuse earlier). Before validation, an addressed POST binds a missing or `null` body id to the addressed id, and a string or number body id when its text matches the address; any other id type is left unchanged by this step. At the root collection, POST generates an id when the body's id is missing, `null` or empty. At POST id validation, at the root collection or an addressed path whose body id was not bound, a remaining id that is not a non-empty string or a non-empty array of strings receives 400 `invalid_event_id`. |
230
- | GET / POST | `/OrgEventCatchup` | Ed25519 | Catch-up feed for the caller. `since` is optional (defaults to the per-agent watermark). GET pages; POST acks `{ position }` (advance-on-ack). |
231
- | GET / POST | `/AgentReadPosition` | Ed25519 | Owner-only watermark (`stream`, default `org-event`). Foundation for light-comms catch-up. |
232
- | POST | `/OrgEventMaintenance` | Ed25519 / admin | Expire / sweep org events. |
318
+ | GET / POST | `/OrgEventCatchup/<agentId>` | Ed25519 | Catch-up feed for the caller. `after` defaults to the per-agent watermark; `since` is an optional ISO `createdAt` floor. GET pages; POST acks `{ position }` (advance-on-ack). |
319
+ | GET / POST | `/AgentReadPosition/<agentId>` | Ed25519 | Owner-only watermark (`stream`, default `org-event`). Foundation for light-comms catch-up. |
320
+ | POST | `/OrgEventMaintenance` | Admin Basic / Ed25519 admin | Expire / sweep org events. |
233
321
  | POST | `/AttentionQuery` | Ed25519 | Cross-table “what touches entity E”. Entity strings: [docs/entity-vocabulary.md](entity-vocabulary.md). |
322
+ | GET | `/TeamDirectory` | Verified active agent | Team directory; filters `id`, `name`, `cursor`, `limit`. |
323
+
324
+ #### Instruction-change events (Soul and skill)
325
+
326
+ Each version appended by Flair's Soul and skill application writers also creates an OrgEvent: kind `soul.changed` or `skill.changed`, id `instruction-change:<version id>`, `refId` the version id, `authorId` `flair:internal`, `createdAt` copied from the version, and `detail` built from these fields only: `subjectType`, `subjectId`, `key` (the Soul key; null for skills), `changeKind`, `actorKind`, `actorId`, `sourceClass`, `valueHash`, `previousVersionHash`, `recordHash`. A private skill's event omits the three hashes, including on the tombstone, whose stored visibility is the closed head's last state. `authorId` is `flair:internal`; `detail.actorKind` disambiguates the actor.
327
+
328
+ Instruction events are readable by any verified agent. Three things a reader should not infer:
329
+
330
+ - The stream begins with the release that ships this event; versions appended earlier have no event, and `InstructionVersion` remains the complete history. A missing event before the cutover does not mean nothing changed.
331
+ - An event does not grant read access to its version record, which keeps stored-and-current authority.
332
+ - Hashes emitted while a skill was shared stay readable in the append-only stream after the skill is tightened to private.
234
333
 
235
334
  ### Federation
236
335
 
@@ -240,6 +339,7 @@ The remedy is `flair upgrade` (the adapter), not a server upgrade alone.
240
339
  | POST | `/FederationPair` | Pairing token + body-sig | Public at the Harper role gate. Handler validates token, signature, anti-replay. Response includes `instance {id, publicKey}` when this hub has an Instance row; `instance` is null if it does not (flair#839). With several rows it answers `409 multiple_instance_rows` before the token is consumed, naming no row (the hub's log names them; flair#1883). The spoke CLI must not store an empty hub key (flair#822). Fabric uses the bootstrap-user triple from `flair federation token`. |
241
340
  | POST | `/FederationSync` | Peer body-sig | Public at the role gate. Merge Memory / Soul / Agent / Relationship (and classifier-ready Message). Originator + per-record signature checks. |
242
341
  | GET | `/FederationPeers` | Admin Basic | Known peers. |
342
+ | GET | `/FederationRetries` | Admin Basic / Ed25519 admin | Pending, terminal, and malformed retry rows. |
243
343
  | GET / write | `/Instance` | Read: Ed25519. Write: admin | Instance row (`flair_…` id, role hub/spoke). |
244
344
  | GET / write | `/Peer` | Admin Basic | Pinned peer keys and sync cursors. |
245
345
  | GET / write | `/PairingToken` | Admin Basic | One-time tokens; default TTL 1 hour. |
@@ -256,7 +356,7 @@ operator audit trail.
256
356
  | GET | `/MessageInbox` | Ed25519 | Inbox for the caller. |
257
357
  | POST | `/MessageAck` | Ed25519 | Consume a delivered message. |
258
358
  | GET | `/MessageDeadLetter` | Ed25519 | Visible failures for the sender (`deadline`, `inbox_full`, …). |
259
- | GET / POST | `/MessageSweep` | Ed25519 / admin | Deadline sweep. Messages never arrive at a silent drop. |
359
+ | POST | `/MessageSweep` | Admin / internal | Deadline sweep. |
260
360
 
261
361
  ### OAuth, MCP, XAA
262
362
 
@@ -265,10 +365,10 @@ operator audit trail.
265
365
  | GET | `/.well-known/oauth-authorization-server`, `/OAuthMetadata` | Public | RFC 8414. CORS `*`. |
266
366
  | GET | `/.well-known/oauth-protected-resource`, `…/mcp` | Public | RFC 9728. |
267
367
  | POST | `/OAuthRegister` | `X-Flair-Initial-Access-Token` | DCR. **Off** unless `FLAIR_OAUTH_DCR_TOKEN` is set (32–508 chars). Rate-limited. |
268
- | GET / POST | `/OAuthAuthorize` | Public (user consent) | Authorization code + PKCE. |
368
+ | GET / POST | `/OAuthAuthorize` | Public consent page; approval requires Basic admin / signed agent | Authorization code + PKCE (`S256` required). |
269
369
  | POST | `/OAuthToken` | Public (client + code/assertion) | Token + `jwt-bearer` (XAA). |
270
370
  | POST | `/OAuthRevoke` | Public (token) | Revocation. |
271
- | GET / POST | `/mcp` | OAuth bearer | Curated tools. **Unmounted** until `FLAIR_MCP_OAUTH=true` and an issuer. |
371
+ | POST | `/mcp` | OAuth bearer | Curated tools. **Unmounted** until `FLAIR_MCP_OAUTH=true` and an issuer. |
272
372
  | GET / write | `/OAuthClient` | Admin Basic | Durable client rows. |
273
373
  | GET / write | `/IdpConfig` | Admin Basic | XAA IdP registration (`flair idp add`). |
274
374
  | GET | `/MCPClientMetadata` | Public / handler-gated | CIMD documents for allowed hosts. |
@@ -285,15 +385,16 @@ OAuth rate limits and env vars: [docs/auth.md](auth.md#rate-limiting).
285
385
 
286
386
  ### Admin UI
287
387
 
288
- All `/Admin*` routes require **Admin Basic**.
388
+ Reads of the `/Admin*` routes below are admin-only: **Admin Basic**, or a `TPS-Ed25519` signature from an admin agent.
289
389
 
290
390
  | Path | Purpose |
291
391
  |------|---------|
292
392
  | `/Admin`, `/AdminDashboard` | Server-rendered console |
293
- | `/AdminPrincipals` | Agents / users: view, promote, disable |
294
- | `/AdminConnectors` | OAuth clients and sessions |
393
+ | `/AdminPrincipals` | List agents / users; management via `flair principal` |
394
+ | `/AdminConnectors` | List OAuth clients |
295
395
  | `/AdminIdp` | IdP configuration |
296
396
  | `/AdminMemory` | Browse / search memory as operator |
397
+ | `/AdminMemoryCandidates/{agentId}` | JSON: one agent's MemoryCandidate ids in id order (`limit`, default 200, max 500; `after=<id>` for the ids after that one), used by `flair rem restore` |
297
398
  | `/AdminInstance` | Federation status, peers, instance |
298
399
 
299
400
  ---
@@ -310,8 +411,8 @@ comes from the token `sub`, never from tool arguments.
310
411
  | `memory_update` | Memory read-modify-write (in-place or `supersedes` version) |
311
412
  | `memory_get` | `GET /Memory/<id>` |
312
413
  | `memory_delete` | `DELETE /Memory/<id>` |
313
- | `memory_basement` | `POST /MemoryArchive` (archive) |
314
- | `memory_restore` | `POST /MemoryArchive` (restore) |
414
+ | `memory_basement` | Memory read-modify-write setting `archived: true` |
415
+ | `memory_restore` | Memory read-modify-write setting `archived: false` and removing `archivedAt` and `archivedBy` |
315
416
  | `skill_store` / `skill_search` / `skill_get` | Skill-tagged Memory |
316
417
  | `bootstrap` | `POST /BootstrapMemories` |
317
418
  | `soul_get` | `GET /Soul` |
@@ -319,6 +420,7 @@ comes from the token `sub`, never from tool arguments.
319
420
  | `flair_workspace_set` | `POST /WorkspaceState` |
320
421
  | `flair_orgevent` | `POST /OrgEvent` |
321
422
  | `attention` | `POST /AttentionQuery` |
423
+ | `team_directory` | `GET /TeamDirectory` |
322
424
  | `record_usage` | `POST /RecordUsage` |
323
425
 
324
426
  The stdio package `@tpsdev-ai/flair-mcp` is a separate HTTP client, not this
@@ -343,6 +445,8 @@ client-writable even if a client sends them. Full comments live in
343
445
  | `activityUpdatedAt` | BigInt | When activity/task were asserted |
344
446
  | `flairVersion` | String | Serving `@tpsdev-ai/flair` version. Null when redacted or never stamped — see below. |
345
447
  | `harperVersion` | String | Serving Harper version. Same redaction. Also null when the server could not resolve Harper's version. |
448
+ | `originatorInstanceId` | String | Local instance id on local create when resolvable, otherwise null; stored value on local update; verified sender on federation receipt. |
449
+ | `receivedAt` | BigInt | Local receipt time in Unix ms; stamped on federation receipt. |
346
450
 
347
451
  ### Presence for API consumers
348
452
 
@@ -377,6 +481,7 @@ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `last
377
481
  | `agentId` | String! | Owner; no-forge |
378
482
  | `content` | String! | Embedded text (non-skill) |
379
483
  | `contentHash` | String | Near-duplicate key |
484
+ | `embeddedContentHash` | String | Stored embedding-text hash; may be absent, null, or retained from an earlier vector. |
380
485
  | `trigger` | String | Skill “when to use”; skill rows embed from this |
381
486
  | `visibility` | String | `shared` \| `private` (durability default if omitted) |
382
487
  | `embedding` | [Float] | HNSW, M:16 |
@@ -384,11 +489,15 @@ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `last
384
489
  | `tags` | [String] | |
385
490
  | `durability` | String | `permanent` \| `persistent` \| `standard` \| `ephemeral` |
386
491
  | `source` | String | |
492
+ | `type` | String | |
493
+ | `instanceToken` | String | Server-stamped row incarnation token. |
494
+ | `writeBackWriteId` | String | |
495
+ | `skillSubjectId` | String | Nullable, server-owned skill subject. |
387
496
  | `createdAt` / `updatedAt` | String | |
388
497
  | `expiresAt` | String | Ephemeral TTL |
389
498
  | `retrievalCount` / `lastRetrieved` | | Search-hit counters (weak signal). Incremented on `MemoryHitStat` and overlaid on Memory reads — search no longer rewrites the Memory row. |
390
499
  | `usageCount` | Int | Verified-use signal; only `RecordUsage` / citations increment |
391
- | `promotionStatus` / `promotedAt` / `promotedBy` | | REM promotion |
500
+ | `promotionStatus` / `promotedAt` / `promotedBy` / `promotionContentHash` | | REM promotion; the hash binds the verdict to the stored text |
392
501
  | `archived` / `archivedAt` / `archivedBy` | | Basement |
393
502
  | `parentId` / `derivedFrom` / `sessionId` / `lastReflected` | | Learning pipeline |
394
503
  | `supersedes` | String | Version chain |
@@ -438,7 +547,7 @@ The **binding** (A1-iv item 1): The named application create paths stamp a local
438
547
 
439
548
  **Direct access** — Direct resource reads permit admin agents and trusted in-process callers; non-admin agents cannot read this table directly. The author reads their own pointer only through the gated join. The table has **NO REST write verbs**: `POST`/`PUT`/`PATCH`/`DELETE` to the resource are refused for EVERY caller, non-admin and admin alike, with nothing written (`r4-http`), so no REST caller can plant a pointer. A superuser Harper operation against the table (an admin `export`, `backup`, `reseed`, or a hygiene/forensics read of orphaned or author-only pointers) is the named operator path and is not gated by the resource (`r4-http` proves only the resource refusal). This admin exception names `MemoryHostSource` explicitly.
440
549
 
441
- **Federation** — `MemoryHostSource` is excluded from the sync's table set by mechanism (it is absent from the federation table policy), and an inbound row carrying a pointer field is refused. The outbound reader projects declared Memory attributes. The inbound merge removes undeclared attributes except the named bookkeeping fields (`f1-out`, `f1-in`). `Memory.delete` and maintenance expiry or age-based archival delete the pointer with their Memory operation. `MemoryArchive` basement/restore retains the pointer row; the join suppresses it while the Memory is archived. `Memory.delete` joins a request transaction when present; maintenance uses an owned transaction per item. An orphan sweep re-checks inside the transaction before deleting; a cleanup failure makes the maintenance run report a failure, not "complete". Orphaned pointers are absent from ordinary Memory joins but remain directly readable by administrators.
550
+ **Federation** — `MemoryHostSource` is excluded from the sync's table set by mechanism (it is absent from the federation table policy), and an inbound row carrying a pointer field is refused. The outbound reader projects declared Memory attributes. The inbound merge removes undeclared attributes except the named bookkeeping fields (`f1-out`, `f1-in`). `Memory.delete` and maintenance expiry or age-based archival delete the pointer with their Memory operation. `MemoryArchive` basement/restore retains the pointer row; the join suppresses it while the Memory is archived. Ordinary `Memory.delete` uses an owned transaction; maintenance uses an owned transaction per item. An orphan sweep re-checks inside the transaction before deleting; a cleanup failure makes the maintenance run report a failure, not "complete". The orphan sweep runs only when the run is not a dry run, and follows the run's scope: a non-admin run, and an admin run that names an agent, considers only pointer rows whose stamped `authorId` is that agent, and a pointer with an empty author is outside such a run; fleet-wide admin maintenance considers every pointer row, so it also removes an empty-author orphan pointer. A pointer whose Memory row is live at the sweep's reads is kept. Harper has no compare-and-delete, so the sweep re-reads the Memory row and the pointer and stages the delete in one owned transaction, whose time Harper takes at its first read; inside that transaction's callback it also reads both rows' committed state through fresh contexts (the confirmation reads) before staging the delete: a pointer replaced before the confirmation read is skipped, and a replacement whose transaction takes its time after that first read is applied after the delete and stays stored. A write whose transaction took its time before that first read and commits after the confirmation read is not covered (per-id serialization is tracked in #2478). A pointer counts as removed only when a read after the commit finds no row for its memoryId. Orphaned pointers are absent from ordinary Memory joins but remain directly readable by administrators.
442
551
 
443
552
  hostSource is the writer's unverified claim about an external source, stored with the writer's authenticated agent id; Flair does not verify it. The Ed25519 request signature covers method and URL, not the body.
444
553
 
@@ -465,7 +574,7 @@ agents.
465
574
  |-------|------|-------|
466
575
  | `id` | ID PK | Agent id |
467
576
  | `name` | String! | |
468
- | `role` / `type` | String | Legacy; `role` reconciles with `admin` |
577
+ | `role` / `type` | String | Role / legacy type; see [admin authority](auth.md#jit-provisioning) |
469
578
  | `kind` | String | `human` \| `agent` |
470
579
  | `displayName` | String | |
471
580
  | `status` | String | `active` \| `deactivated` |
@@ -487,7 +596,7 @@ ed25519 / idp) and **Integration** (legacy platform connection).
487
596
  | **Instance** | yes | One row per Flair instance (`id`, `publicKey`, `role` hub/spoke, `fabricEndpoint`, `status`) |
488
597
  | **PairingToken** | yes | One-time token (`expiresAt`, `consumedBy`) |
489
598
  | **Peer** | yes | Pinned peer (`publicKey`, `endpoint`, `status`, `lastSyncAt` / `lastMergeAt`, `lastSyncCursor`, `relayOnly`) |
490
- | **FederationRetry** | yes | Sender-owned federation retry bookkeeping, shaped for one row per (peer, table, record) refused for a reason a later re-offer could clear (`state`, `attempts`, `firstRefusedAt`, `lastReason`, `resolution`, `bound`). No production sender path creates rows yet; admin-written rows are readable. `@sealed`: a write naming an undeclared field is refused. Admin-only on every operation; excluded from federation policy and the receive mapping. |
599
+ | **FederationRetry** | yes | Sender-owned federation retry bookkeeping, shaped for one row per (peer, table, record) refused for a reason a later re-offer could clear (`state`, `attempts`, `firstRefusedAt`, `lastReason`, `resolution`, `bound`). The sync sender writes and confirms retry rows. `@sealed`: a write naming an undeclared field is refused. Admin-only on every operation; excluded from federation policy and the receive mapping. |
491
600
  | **ReplayNonce** | no | `schemas/replay.graphql`. Anti-replay record shared by agent auth (`a:<agentId>:<nonce>`) and federation body signatures (`f:<nonce>`). Local to the instance (`replicate: false`); rows expire after 120 s |
492
601
  | **SyncLog** | no | Per-sync audit (`peerId`, `direction`, counts, `skippedReasons`, `status`) |
493
602
 
@@ -504,10 +613,10 @@ ed25519 / idp) and **Integration** (legacy platform connection).
504
613
  | **OrgSkillAssignment** | memory.graphql | yes | Org-scope skill assignment (`skillName`, `skillRef`, `priority`, server-stamped `writer` / `sourceClass`) |
505
614
  | **OrgSkillAssignmentHistory** | memory.graphql | no | One row per accepted OrgSkillAssignment resource write (`assignmentId`, `op`, `actor`, `sourceClass`, `previousHash`) |
506
615
  | **MemoryDeletionHistory** | memory.graphql | no | History of confirmed physical deletions of permanent/persistent Memory rows through `Memory.delete` (including CLI hygiene and agent remove), appended in the delete transaction. Non-durable deletes, including maintenance expiry, append no history (`memoryId`, `memoryInstanceToken`, `durability`, `actor`, `sourceClass`, `at`); read by `flair integrity check` for history-backed attributions. `replicate: true` is declared explicitly to state the database default (a table replicates unless it opts out) |
507
- | **InstructionVersion** | memory.graphql | yes (read only) | Append-only history for single-row Soul resource writes and skill writes through Memory post/put/delete and FeedMemories (excluding `_reindex` and reserved-seed deletes). Soul collection deletes and InstructionVersion REST writes are refused. The operator's reserved seed row keeps its fixed id and is versioned in place. Skill writers share a subject-type lock, select rows where `archived !== true` and `validTo` is not a nonempty string, and refuse stale create/update targets or predecessors and ambiguous heads. Reads authorize `soul` subjects under Soul's verified-agent rule. Ordinary skill readers require readable stored visibility and current authority: matching subjects, a live skill Memory row owned by the head's owner, or a delete head with null `memoryId`; authority references require nonempty owners and explicit private/shared visibility. Admin/internal keep unfiltered skill reads; unknown subject types deny. `Memory.skillSubjectId` is nullable and server-owned. |
616
+ | **InstructionVersion** | memory.graphql | yes (read only) | History for single-row Soul resource writes and skill writes through Memory post/put/delete and FeedMemories (excluding `_reindex` and reserved-seed deletes). InstructionVersion resource REST clients cannot write or delete version records; the server appends them, and when a request's close fails it attempts to remove the version that request appended only while that version is still the head, reporting a compensation failure when the removal cannot be confirmed. Soul collection deletes and InstructionVersion REST writes are refused. The administrator operations API (`upsert` / `delete` under admin auth) is the separate raw-table exception described below. The operator's reserved seed row keeps its fixed id and is versioned in place. Skill writers share a subject-type lock, select rows where `archived !== true`, `validTo` is not a nonempty string, and `expiresAt` is absent or a valid future timestamp, and refuse stale create/update targets or predecessors and ambiguous heads. Reads authorize `soul` subjects under Soul's verified-agent rule. Ordinary skill readers require readable stored visibility and current authority: matching subjects, a live skill Memory row owned by the head's owner, or a delete head with null `memoryId`; authority references require nonempty owners and explicit private/shared visibility. Admin/internal keep unfiltered skill reads; unknown subject types deny. `Memory.skillSubjectId` is nullable and server-owned. |
508
617
  | **WorkspaceState** | workspace.graphql | yes | Current work (`ref`, `provider`, `phase`, `entities`) |
509
618
  | **OrgEvent** | event.graphql | yes | Org-visible event (`authorId`, `kind`, `summary`, `entities`) |
510
- | **AgentReadPosition** | agent.graphql | no | Per-agent watermark (`agentId`, `stream`, `position`). HTTP via `/AgentReadPosition`, not raw-table REST. |
619
+ | **AgentReadPosition** | agent.graphql | no | Per-agent watermark (`agentId`, `stream`, `position`). HTTP via `/AgentReadPosition/<agentId>`, not raw-table REST. |
511
620
  | **AgentKeyRegistration** | agent-key-registration.graphql | yes (admin read only) | Audit log of committed `POST /AgentKeyRegister` calls (`actorId`, `operator`, `agentId`, `instanceId`, `keyFingerprint`, `createdAt`). The Flair resource route refuses every write; the registration operation is its only application writer. The operations API is a separate raw-table trust root. `replicate: true` is declared explicitly to state the database default (a table replicates unless it opts out). |
512
621
  | **Message** | message.graphql | yes | Signed envelope (`from`, `to`, `threadId`, `seq`, `state`, `signature`) |
513
622
  | **OAuthClient** | oauth.graphql | yes | Registered OAuth clients |
@@ -534,4 +643,4 @@ Raw operations-API Memory deletes create no deletion history. A scan alerts when
534
643
  - [docs/rem.md](rem.md) — MemoryCandidate promote/reject
535
644
  - [docs/entity-vocabulary.md](entity-vocabulary.md) — `entities` grammar
536
645
  - [docs/embedding-in-a-harper-app.md](embedding-in-a-harper-app.md) — in-process API
537
- - [`packages/flair-client/README.md`](../packages/flair-client/README.md) — typed HTTP client
646
+ - [`packages/flair-client/README.md`](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-client/README.md) — typed HTTP client