@tpsdev-ai/flair 0.62.0 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +6 -6
  2. package/SECURITY.md +18 -10
  3. package/config.yaml +11 -11
  4. package/dist/bridges/runtime/execute.js +1 -0
  5. package/dist/bridges/types.js +1 -0
  6. package/dist/build-info.json +3 -3
  7. package/dist/cli.js +66 -122
  8. package/dist/commands/agent.js +27 -65
  9. package/dist/commands/backup-approval.js +218 -0
  10. package/dist/commands/backup.js +37 -33
  11. package/dist/commands/bootstrap.js +3 -1
  12. package/dist/commands/deploy.js +37 -7
  13. package/dist/commands/doctor.js +119 -0
  14. package/dist/commands/export.js +3 -4
  15. package/dist/commands/federation.js +653 -68
  16. package/dist/commands/grant.js +5 -6
  17. package/dist/commands/help.js +25 -0
  18. package/dist/commands/idp.js +14 -19
  19. package/dist/commands/import.js +131 -19
  20. package/dist/commands/init.js +7 -7
  21. package/dist/commands/integrity.js +5 -6
  22. package/dist/commands/mcp.js +11 -17
  23. package/dist/commands/memory.js +33 -15
  24. package/dist/commands/orgevent.js +5 -10
  25. package/dist/commands/principal.js +13 -25
  26. package/dist/commands/quality.js +3 -0
  27. package/dist/commands/rem.js +484 -65
  28. package/dist/commands/restore.js +352 -44
  29. package/dist/commands/service.js +84 -2
  30. package/dist/commands/soul.js +0 -6
  31. package/dist/commands/status.js +51 -33
  32. package/dist/commands/test.js +4 -1
  33. package/dist/commands/upgrade.js +53 -22
  34. package/dist/commands/workspace.js +7 -8
  35. package/dist/deploy.js +59 -3
  36. package/dist/doctor-client.js +7 -2
  37. package/dist/fabric-upgrade.js +12 -2
  38. package/dist/federation/presence-send.js +139 -0
  39. package/dist/federation-verify.js +269 -177
  40. package/dist/install/clients.js +171 -35
  41. package/dist/lib/agent-id-rule.js +44 -2
  42. package/dist/lib/atomic-write.js +1 -1
  43. package/dist/lib/auth-resolve.js +1028 -52
  44. package/dist/lib/backup-approval-store.js +612 -0
  45. package/dist/lib/backup-artifact.js +343 -0
  46. package/dist/lib/config-critical-section.js +212 -25
  47. package/dist/lib/connect-phase.js +33 -0
  48. package/dist/lib/daemon-liveness.js +2 -1
  49. package/dist/lib/federation-pair-access.js +4 -0
  50. package/dist/lib/federation-retry-queue.js +283 -0
  51. package/dist/lib/federation-retry-row.js +101 -0
  52. package/dist/lib/instruction-event-contract.js +17 -0
  53. package/dist/lib/instruction-event-doctor.js +102 -0
  54. package/dist/lib/launchd-management.js +14 -3
  55. package/dist/lib/mcp-enable.js +14 -15
  56. package/dist/lib/memory-attributes.js +2 -0
  57. package/dist/lib/memory-provider-timeout.js +33 -0
  58. package/dist/lib/mqtt-config.js +132 -0
  59. package/dist/lib/mqtt-listener-doctor.js +104 -0
  60. package/dist/lib/open-live-row.js +20 -0
  61. package/dist/lib/ops-url.js +52 -0
  62. package/dist/lib/promotion-content-hash.js +20 -0
  63. package/dist/lib/restore-archive.js +760 -0
  64. package/dist/lib/restore-verify.js +1 -1
  65. package/dist/lib/skill-assignment-preflight.js +159 -0
  66. package/dist/lib/skill-seed.js +91 -8
  67. package/dist/lib/skill-tombstone-doctor.js +133 -0
  68. package/dist/lib/soul-scope-fields.js +26 -0
  69. package/dist/lib/uninstall-purge.js +266 -11
  70. package/dist/lib/upgrade-prior-liveness.js +2 -1
  71. package/dist/mcp-client-assertion.js +2 -10
  72. package/dist/memory-id-checkpoint.js +28 -7
  73. package/dist/mqtt-off-deploy.js +550 -0
  74. package/dist/rem/promote-policy.js +3 -3
  75. package/dist/rem/restore.js +302 -26
  76. package/dist/rem/runner.js +220 -58
  77. package/dist/rem/scheduler.js +21 -4
  78. package/dist/resources/A2AAdapter.js +131 -178
  79. package/dist/resources/AdminMemory.js +2 -0
  80. package/dist/resources/AdminMemoryCandidates.js +116 -0
  81. package/dist/resources/Agent.js +155 -45
  82. package/dist/resources/AgentCard.js +4 -0
  83. package/dist/resources/AgentKeyRegister.js +56 -22
  84. package/dist/resources/AgentReadPosition.js +7 -0
  85. package/dist/resources/AgentSeed.js +232 -107
  86. package/dist/resources/AutoPromoteCandidates.js +413 -84
  87. package/dist/resources/Credential.js +6 -8
  88. package/dist/resources/Federation.js +219 -57
  89. package/dist/resources/FederationRetry.js +4 -4
  90. package/dist/resources/InstructionVersion.js +1 -1
  91. package/dist/resources/MCPClientMetadata.js +6 -3
  92. package/dist/resources/Memory.js +1303 -270
  93. package/dist/resources/MemoryArchive.js +149 -64
  94. package/dist/resources/MemoryBootstrap.js +12 -22
  95. package/dist/resources/MemoryCandidate.js +16 -2
  96. package/dist/resources/MemoryConsolidate.js +2 -2
  97. package/dist/resources/MemoryFeed.js +360 -147
  98. package/dist/resources/MemoryMaintenance.js +290 -72
  99. package/dist/resources/MemoryPurge.js +138 -22
  100. package/dist/resources/MemoryReflect.js +68 -14
  101. package/dist/resources/MemoryReindex.js +91 -13
  102. package/dist/resources/Message.js +11 -2
  103. package/dist/resources/OAuth.js +156 -39
  104. package/dist/resources/OAuthClient.js +1 -1
  105. package/dist/resources/OrgEvent.js +292 -29
  106. package/dist/resources/OrgEventCatchup.js +7 -0
  107. package/dist/resources/OrgEventMaintenance.js +48 -10
  108. package/dist/resources/PairingToken.js +1 -1
  109. package/dist/resources/Presence.js +31 -11
  110. package/dist/resources/PromoteMemoryCandidate.js +8 -2
  111. package/dist/resources/RecordUsage.js +2 -4
  112. package/dist/resources/Soul.js +2 -0
  113. package/dist/resources/SoulFeed.js +2 -1
  114. package/dist/resources/WorkspaceLatest.js +4 -0
  115. package/dist/resources/XAA.js +36 -10
  116. package/dist/resources/a2a-stream.js +313 -0
  117. package/dist/resources/a2a-url.js +4 -5
  118. package/dist/resources/agent-admin.js +10 -1
  119. package/dist/resources/agent-auth.js +98 -68
  120. package/dist/resources/agent-read-position-lib.js +4 -1
  121. package/dist/resources/agent-status-guard.js +9 -7
  122. package/dist/resources/auth-middleware.js +166 -42
  123. package/dist/resources/authority-field-guard.js +9 -11
  124. package/dist/resources/auto-promote-lib.js +8 -5
  125. package/dist/resources/basic-auth-header.js +21 -0
  126. package/dist/resources/bm25-index-service.js +4 -5
  127. package/dist/resources/dedup-cluster.js +6 -1
  128. package/dist/resources/embeddings-provider.js +25 -0
  129. package/dist/resources/federation-classify.js +89 -0
  130. package/dist/resources/federation-retry-lib.js +6 -81
  131. package/dist/resources/health.js +43 -4
  132. package/dist/resources/host-pointer/registry.js +29 -0
  133. package/dist/resources/host-pointer-adapter.js +1 -0
  134. package/dist/resources/in-process.js +24 -22
  135. package/dist/resources/instruction-version-record.js +251 -7
  136. package/dist/resources/internal-authority.js +13 -0
  137. package/dist/resources/mcp-handler.js +106 -12
  138. package/dist/resources/mcp-oauth-flag.js +12 -14
  139. package/dist/resources/mcp-oauth.js +430 -53
  140. package/dist/resources/mcp-tools.js +60 -22
  141. package/dist/resources/memory-declared-attributes.js +1 -0
  142. package/dist/resources/memory-embed-hash.js +56 -0
  143. package/dist/resources/memory-host-source.js +5 -2
  144. package/dist/resources/memory-reflect-lib.js +1 -1
  145. package/dist/resources/memory-write-lock.js +202 -23
  146. package/dist/resources/memory-write-response.js +1 -1
  147. package/dist/resources/memory-write-transaction.js +243 -0
  148. package/dist/resources/migration-boot.js +17 -12
  149. package/dist/resources/migrations/boot-progress.js +25 -0
  150. package/dist/resources/migrations/data-dir.js +16 -3
  151. package/dist/resources/migrations/dir-safety.js +60 -2
  152. package/dist/resources/migrations/embedding-stamp.js +315 -49
  153. package/dist/resources/migrations/graph-heal.js +9 -2
  154. package/dist/resources/migrations/ledger.js +5 -2
  155. package/dist/resources/migrations/lock.js +867 -80
  156. package/dist/resources/migrations/progress.js +71 -10
  157. package/dist/resources/migrations/runner.js +212 -18
  158. package/dist/resources/migrations/state.js +36 -1
  159. package/dist/resources/migrations/status.js +2 -13
  160. package/dist/resources/migrations/synthetic-test-migration.js +78 -12
  161. package/dist/resources/migrations/types.js +26 -1
  162. package/dist/resources/migrations/visibility-backfill.js +111 -70
  163. package/dist/resources/oauth-discovery.js +0 -5
  164. package/dist/resources/object-body-guard.js +12 -5
  165. package/dist/resources/org-event-reserved.js +92 -0
  166. package/dist/resources/org-event-write-fault.js +19 -0
  167. package/dist/resources/owner-field-guard.js +1 -1
  168. package/dist/resources/owner-scoped-write-policy.js +65 -21
  169. package/dist/resources/owner-scoped-writes.js +37 -6
  170. package/dist/resources/path-id-rewrite.js +76 -0
  171. package/dist/resources/presence-internal.js +5 -5
  172. package/dist/resources/promotion-binding.js +43 -0
  173. package/dist/resources/promotion-stamp.js +124 -33
  174. package/dist/resources/protocol-context.js +189 -0
  175. package/dist/resources/record-type-kit.js +2 -4
  176. package/dist/resources/request-target.js +28 -1
  177. package/dist/resources/request-transaction.js +11 -1
  178. package/dist/resources/seed-reservation.js +1 -2
  179. package/dist/resources/semantic-retrieval-core.js +7 -6
  180. package/dist/resources/server-row-validation.js +71 -0
  181. package/dist/resources/skill-manifest.js +4 -3
  182. package/dist/resources/skill-version-write.js +384 -27
  183. package/dist/resources/skill-write-fault.js +6 -3
  184. package/dist/resources/skill-write-policy.js +2 -1
  185. package/dist/resources/soul-write-policy.js +26 -7
  186. package/dist/resources/table-helpers.js +1 -1
  187. package/dist/resources/table-subscription-policy.js +518 -85
  188. package/dist/resources/table-subscriptions.js +20 -7
  189. package/dist/resources/txn-pause-point.js +122 -5
  190. package/dist/resources/usage-recording.js +54 -46
  191. package/dist/resources/write-back.js +176 -11
  192. package/dist/resources/write-journal-context.js +5 -0
  193. package/dist/resources/write-journal.js +289 -0
  194. package/dist/src/lib/agent-id-rule.js +44 -2
  195. package/dist/src/lib/atomic-write.js +1 -1
  196. package/dist/src/lib/federation-retry-row.js +101 -0
  197. package/dist/src/lib/instruction-event-contract.js +17 -0
  198. package/dist/src/lib/memory-attributes.js +2 -0
  199. package/dist/src/lib/open-live-row.js +20 -0
  200. package/dist/src/lib/soul-scope-fields.js +26 -0
  201. package/dist/src/rem/promote-policy.js +3 -3
  202. package/dist/src/rem/scheduler.js +21 -4
  203. package/docs/access-control.md +18 -9
  204. package/docs/api-reference.md +126 -28
  205. package/docs/auth.md +40 -18
  206. package/docs/claude-code.md +3 -3
  207. package/docs/deploying-on-fabric.md +108 -0
  208. package/docs/deployment.md +17 -0
  209. package/docs/embedding-in-a-harper-app.md +16 -14
  210. package/docs/entity-vocabulary.md +3 -6
  211. package/docs/federation.md +29 -2
  212. package/docs/integrations.md +11 -11
  213. package/docs/mcp-clients.md +7 -5
  214. package/docs/notes/mcp-agent-auth-consumer.md +4 -9
  215. package/docs/notes/mcp-oauth-model2.md +6 -6
  216. package/docs/openclaw.md +1 -1
  217. package/docs/quickstart-fabric.md +2 -2
  218. package/docs/quickstart.md +3 -3
  219. package/docs/releasing.md +13 -13
  220. package/docs/rem.md +24 -3
  221. package/docs/secrets-and-keys.md +2 -2
  222. package/docs/standalone-local.md +29 -2
  223. package/docs/supply-chain-policy.md +28 -20
  224. package/docs/the-team.md +2 -2
  225. package/docs/upgrade.md +14 -0
  226. package/package.json +18 -11
  227. package/schemas/agent.graphql +3 -3
  228. package/schemas/federation.graphql +10 -7
  229. package/schemas/memory.graphql +7 -2
  230. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  231. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  232. package/dist/resources/soul-adk-guard.js +0 -68
@@ -27,12 +27,12 @@ server, which has them sign in at the identity provider configured under
27
27
  configures GitHub. The access token the app receives carries the login as its
28
28
  subject; for GitHub, that is the account's username.
29
29
 
30
- `/mcp` answers `initialize`, `ping` and `tools/list` for any valid token, and
31
- refuses a `tools/call` for an unknown tool name, before it looks at the mapping.
30
+ `/mcp` answers `initialize` and `ping` for any valid token, and refuses a
31
+ `tools/call` for an unknown tool name, before it looks at the mapping.
32
32
  On a `tools/call` for a known tool, Flair looks for a `Credential` of kind `idp`
33
33
  whose `idpSubject` is that login, that names a principal, and whose status is
34
- not `revoked`, and acts as that principal. There is no fallback to an anonymous
35
- or admin identity:
34
+ exactly `active`, and acts as that principal. There is no fallback to an
35
+ anonymous or admin identity:
36
36
 
37
37
  - **No mapping:** the call is refused. `/mcp` answers HTTP 200 with a JSON-RPC
38
38
  error:
@@ -41,6 +41,10 @@ or admin identity:
41
41
  {"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"forbidden: token subject is not a provisioned flair agent"}}
42
42
  ```
43
43
 
44
+ - **The login's credentials are not `active` or name no principal:** refused
45
+ with code `-32001`. The message names one of those credentials and its stored
46
+ status (`revoked`, any other value, or no status), and says an operator must
47
+ re-link it.
44
48
  - **Mapped to a principal that does not exist:** refused with code `-32001` and
45
49
  a message naming the principal.
46
50
  - **Mapped to a deactivated principal:** refused; see
@@ -48,6 +52,10 @@ or admin identity:
48
52
  - **The credential or the principal could not be read:** refused with code
49
53
  `-32000` and a message starting `unavailable:`.
50
54
 
55
+ A `tools/list` reads the mapping the same way and answers each case above
56
+ except **No mapping** with the same error; with no mapping it returns a tool
57
+ list.
58
+
51
59
  ### Map a person to a principal
52
60
 
53
61
  `flair mcp enable` writes the mapping in its `identity-mapping` step:
@@ -123,8 +131,8 @@ both take the same `--instance` and `--admin-pass`.
123
131
 
124
132
  ### One mapping per login
125
133
 
126
- `flair mcp enable` and the resolver both count a login's `idp` credential unless
127
- its status is `revoked` (the resolver also skips one that names no principal).
134
+ `flair mcp enable` and the resolver both treat a login's `idp` credential as a
135
+ mapping only when its status is exactly `active` and it names a principal.
128
136
  `flair mcp enable` keeps one such credential per login, whatever the provider
129
137
  name:
130
138
 
@@ -133,9 +141,10 @@ name:
133
141
  says `re-pointed`. Calls from that login then act as the principal the
134
142
  credential names. Memories are not moved or merged; each principal keeps its
135
143
  own.
136
- - If the login has a credential that is not `revoked` under a different
137
- provider name, the run revokes it (the row stays, with status `revoked`) and
138
- prints its id after `SUPERSEDED:`.
144
+ - If the login has a credential under a different provider name whose status
145
+ is `active` and that names a principal, the run revokes it (the row stays,
146
+ with status `revoked`) and prints its id after `SUPERSEDED:`. A credential
147
+ whose status is anything else is not changed.
139
148
  - After writing, it requires exactly one resolvable (principal-bearing) active
140
149
  credential matching the written id and principal.
141
150
  Principal-less legacy rows are skipped and may remain active.
@@ -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/)
@@ -56,8 +56,9 @@ the schema section so the catalog is complete.
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
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). |
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,18 +138,18 @@ 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
@@ -126,7 +175,27 @@ is `GET /Name/<id>` unless noted.
126
175
  | 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
176
  | GET | `/AgentCard/<agentId>` | Public | A2A agent-card; field-allowlisted. |
128
177
  | 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. |
178
+ | 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). |
179
+
180
+ #### A2A JSON-RPC (`POST /a2a`)
181
+
182
+ `POST /a2a` takes a JSON-RPC 2.0 request and requires a `TPS-Ed25519`
183
+ signature or admin Basic auth. A request with neither is answered with error
184
+ `-32001` `Unauthorized`.
185
+
186
+ **Caller match (`message/send` and `message/stream` only).** For these two
187
+ methods `params.agentId` must be the caller's own agent id when the caller is
188
+ not an admin; any other id is answered with error `-32001` `Forbidden`, whose
189
+ `data.detail` names the method (`caller <a> cannot send as <b>`, `caller <a>
190
+ cannot stream as <b>`). An admin caller may name another agent. `tasks/list`
191
+ does not apply this rule: its `params.agentId` is only an assignee filter.
192
+
193
+ | Method | What it does |
194
+ |--------|--------------|
195
+ | `message/send` | Writes an `a2a.message` OrgEvent authored by `params.agentId`, targeted at `params.toAgentId`, or at `params.agentId` when that is omitted. |
196
+ | `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`. |
197
+ | `tasks/get` | One task by `params.taskId`, with its OrgEvent history. |
198
+ | `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
199
 
131
200
  ### Identity — Agent, Presence, Soul
132
201
 
@@ -134,9 +203,10 @@ is `GET /Name/<id>` unless noted.
134
203
  |--------|------|------|--------------|
135
204
  | GET | `/Agent`, `/Agent/<id>` | Ed25519 | Any verified agent may read principals (discovery). |
136
205
  | 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. |
206
+ | 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). |
207
+ | 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. |
138
208
  | 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. |
209
+ | 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
210
  | 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
211
  | POST | `/Presence` | Ed25519 | Heartbeat. Agent writes only its own row (403 cross-agent). Stamps `flairVersion` / `harperVersion` on the row. |
142
212
  | PUT / DELETE | `/Presence/<id>` | Ed25519 | Own row only. Collection PUT is not a public bypass. |
@@ -144,12 +214,14 @@ is `GET /Name/<id>` unless noted.
144
214
  | 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
215
  | POST | `/FeedSouls` | Ed25519 | Soul change feed (verified). |
146
216
 
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
217
+ `Credential` (extra credentials for a principal) requires authenticated HTTP
218
+ access: non-admin by-id reads and writes are limited to the caller's
219
+ `principalId`, while administrators and trusted internal callers may access
220
+ other principals' credentials. Through this resource only an administrator or the server creates a
221
+ `kind: "idp"` credential, changes its kind or identity fields, or reactivates
222
+ it, and its owner may relabel, revoke or delete it (see
223
+ [Who writes a mapping](access-control.md#who-writes-a-mapping)). `Credential`
224
+ and `Integration` (legacy 0.x platform rows; verified, prefer Credential) sit on
153
225
  the same identity plane. `AgentKeyRegistration`
154
226
  (agent-key-registration.graphql) is the admin-read-only audit log of committed
155
227
  registrations; its key field is the fingerprint, not the key.
@@ -158,7 +230,7 @@ registrations; its key field is the fingerprint, not the key.
158
230
 
159
231
  | Method | Path | Auth | Read / write |
160
232
  |--------|------|------|--------------|
161
- | GET | `/Memory`, `/Memory/<id>` | Ed25519 | open-within-org. By-id deny = 404. |
233
+ | 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
234
  | 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
235
  | 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
236
  | DELETE | `/Memory/<id>` | Ed25519 | Owner or admin. `permanent` owner-delete is allowed. |
@@ -170,10 +242,10 @@ registrations; its key field is the fingerprint, not the key.
170
242
  | GET / write | `/Asset` | Ed25519 | Owner-only blobs linked by `memoryId`. No MCP and no federation in this slice. |
171
243
  | GET / write | `/MemoryCandidate` | Ed25519 | Owner-only REM drafts. Never auto-promoted except the narrow ADK path. |
172
244
  | POST | `/PromoteMemoryCandidate` | Ed25519 | Promote/reject with required rationale. |
173
- | POST | `/AutoPromoteCandidates` | Ed25519 | ADK per-user auto-promote only. |
245
+ | 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
246
  | 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. |
247
+ | 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`. |
248
+ | 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. |
177
249
  | POST | `/MemoryReindex` | Admin / verified per handler | Embedding / HNSW rebuild. |
178
250
  | POST | `/MemoryConsolidate` | Ed25519 | Dedup / consolidate. |
179
251
  | POST | `/MemoryReflect` | Ed25519 | REM distill → MemoryCandidate. |
@@ -186,6 +258,21 @@ registrations; its key field is the fingerprint, not the key.
186
258
  Skill-tagged Memory rows embed from `trigger` (the recall signal), not
187
259
  `content`. MCP tools: `skill_store`, `skill_search`, `skill_get`.
188
260
 
261
+ For non-admin Memory by-id and collection reads, a retained closed skill payload must pass both its
262
+ stored owner/visibility check and its subject's current-authority check: a
263
+ readable live skill referenced by a matching create/update head, or a readable
264
+ delete head with `memoryId: null`. Missing, invalid or unreadable authority
265
+ denies the payload even to its owner: by-id reads return 404 and collection
266
+ reads omit it. Administrator and trusted internal reads are not subject to this additional
267
+ check.
268
+
269
+ Superseding a skill closes its predecessor with `validTo`; deleting a
270
+ non-reserved skill closes its live head and appends a delete version while
271
+ retaining the Memory row. Skill writes through Memory POST/PUT and
272
+ `FeedMemories` that supply a non-null `archived` value other than `false` or a
273
+ nonempty `validTo` are refused with `400 skill_state_requires_delete`, so basementing a
274
+ skill is refused.
275
+
189
276
  #### Client version gate (HTTP 426 `stale_flair_client`)
190
277
 
191
278
  `POST` / `PUT` / `PATCH` `/Memory` refuse an **identified**
@@ -232,6 +319,16 @@ The remedy is `flair upgrade` (the adapter), not a server upgrade alone.
232
319
  | POST | `/OrgEventMaintenance` | Ed25519 / admin | Expire / sweep org events. |
233
320
  | POST | `/AttentionQuery` | Ed25519 | Cross-table “what touches entity E”. Entity strings: [docs/entity-vocabulary.md](entity-vocabulary.md). |
234
321
 
322
+ #### Instruction-change events (Soul and skill)
323
+
324
+ 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.
325
+
326
+ Instruction events are readable by any verified agent. Three things a reader should not infer:
327
+
328
+ - 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.
329
+ - An event does not grant read access to its version record, which keeps stored-and-current authority.
330
+ - Hashes emitted while a skill was shared stay readable in the append-only stream after the skill is tightened to private.
331
+
235
332
  ### Federation
236
333
 
237
334
  | Method | Path | Auth | Notes |
@@ -265,7 +362,7 @@ operator audit trail.
265
362
  | GET | `/.well-known/oauth-authorization-server`, `/OAuthMetadata` | Public | RFC 8414. CORS `*`. |
266
363
  | GET | `/.well-known/oauth-protected-resource`, `…/mcp` | Public | RFC 9728. |
267
364
  | 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. |
365
+ | GET / POST | `/OAuthAuthorize` | Public (user consent) | Authorization code + PKCE (`S256` required). |
269
366
  | POST | `/OAuthToken` | Public (client + code/assertion) | Token + `jwt-bearer` (XAA). |
270
367
  | POST | `/OAuthRevoke` | Public (token) | Revocation. |
271
368
  | GET / POST | `/mcp` | OAuth bearer | Curated tools. **Unmounted** until `FLAIR_MCP_OAUTH=true` and an issuer. |
@@ -285,7 +382,7 @@ OAuth rate limits and env vars: [docs/auth.md](auth.md#rate-limiting).
285
382
 
286
383
  ### Admin UI
287
384
 
288
- All `/Admin*` routes require **Admin Basic**.
385
+ Reads of the `/Admin*` routes below are admin-only: **Admin Basic**, or a `TPS-Ed25519` signature from an admin agent.
289
386
 
290
387
  | Path | Purpose |
291
388
  |------|---------|
@@ -294,6 +391,7 @@ All `/Admin*` routes require **Admin Basic**.
294
391
  | `/AdminConnectors` | OAuth clients and sessions |
295
392
  | `/AdminIdp` | IdP configuration |
296
393
  | `/AdminMemory` | Browse / search memory as operator |
394
+ | `/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
395
  | `/AdminInstance` | Federation status, peers, instance |
298
396
 
299
397
  ---
@@ -310,8 +408,8 @@ comes from the token `sub`, never from tool arguments.
310
408
  | `memory_update` | Memory read-modify-write (in-place or `supersedes` version) |
311
409
  | `memory_get` | `GET /Memory/<id>` |
312
410
  | `memory_delete` | `DELETE /Memory/<id>` |
313
- | `memory_basement` | `POST /MemoryArchive` (archive) |
314
- | `memory_restore` | `POST /MemoryArchive` (restore) |
411
+ | `memory_basement` | Memory read-modify-write setting `archived: true` |
412
+ | `memory_restore` | Memory read-modify-write setting `archived: false` and removing `archivedAt` and `archivedBy` |
315
413
  | `skill_store` / `skill_search` / `skill_get` | Skill-tagged Memory |
316
414
  | `bootstrap` | `POST /BootstrapMemories` |
317
415
  | `soul_get` | `GET /Soul` |
@@ -388,7 +486,7 @@ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `last
388
486
  | `expiresAt` | String | Ephemeral TTL |
389
487
  | `retrievalCount` / `lastRetrieved` | | Search-hit counters (weak signal). Incremented on `MemoryHitStat` and overlaid on Memory reads — search no longer rewrites the Memory row. |
390
488
  | `usageCount` | Int | Verified-use signal; only `RecordUsage` / citations increment |
391
- | `promotionStatus` / `promotedAt` / `promotedBy` | | REM promotion |
489
+ | `promotionStatus` / `promotedAt` / `promotedBy` / `promotionContentHash` | | REM promotion; the hash binds the verdict to the stored text |
392
490
  | `archived` / `archivedAt` / `archivedBy` | | Basement |
393
491
  | `parentId` / `derivedFrom` / `sessionId` / `lastReflected` | | Learning pipeline |
394
492
  | `supersedes` | String | Version chain |
@@ -438,7 +536,7 @@ The **binding** (A1-iv item 1): The named application create paths stamp a local
438
536
 
439
537
  **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
538
 
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.
539
+ **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
540
 
443
541
  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
542
 
@@ -504,7 +602,7 @@ ed25519 / idp) and **Integration** (legacy platform connection).
504
602
  | **OrgSkillAssignment** | memory.graphql | yes | Org-scope skill assignment (`skillName`, `skillRef`, `priority`, server-stamped `writer` / `sourceClass`) |
505
603
  | **OrgSkillAssignmentHistory** | memory.graphql | no | One row per accepted OrgSkillAssignment resource write (`assignmentId`, `op`, `actor`, `sourceClass`, `previousHash`) |
506
604
  | **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. |
605
+ | **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
606
  | **WorkspaceState** | workspace.graphql | yes | Current work (`ref`, `provider`, `phase`, `entities`) |
509
607
  | **OrgEvent** | event.graphql | yes | Org-visible event (`authorId`, `kind`, `summary`, `entities`) |
510
608
  | **AgentReadPosition** | agent.graphql | no | Per-agent watermark (`agentId`, `stream`, `position`). HTTP via `/AgentReadPosition`, not raw-table REST. |
@@ -534,4 +632,4 @@ Raw operations-API Memory deletes create no deletion history. A scan alerts when
534
632
  - [docs/rem.md](rem.md) — MemoryCandidate promote/reject
535
633
  - [docs/entity-vocabulary.md](entity-vocabulary.md) — `entities` grammar
536
634
  - [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
635
+ - [`packages/flair-client/README.md`](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-client/README.md) — typed HTTP client
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
 
@@ -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 or denies on the consent page
144
+ 4. Flair redirects back 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
 
@@ -289,6 +307,8 @@ flair principal add <principal-id> --admin
289
307
 
290
308
  `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
309
 
310
+ 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.
311
+
292
312
  ### CLI Reference
293
313
 
294
314
  | Command | Description |
@@ -308,7 +328,7 @@ The web admin at `/AdminDashboard` provides a UI for managing:
308
328
  - **Memory:** browse and search stored memories
309
329
  - **Instance:** federation status, peer connections
310
330
 
311
- Access requires admin-level authentication (Basic auth with the Harper admin password).
331
+ 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
332
 
313
333
  ## Soul authorship
314
334
 
@@ -345,18 +365,20 @@ Federation remains an authenticated instance-to-instance replication path and
345
365
  preserves the originating record; it does not reclassify a runtime request as
346
366
  an operator edit. Raw Harper OPS access remains administrator infrastructure.
347
367
 
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.
368
+ A learned-text refusal reports `soul_value_is_learned_content` for a non-empty
369
+ exact value match with stored Memory or MemoryCandidate text for the target
370
+ agent, including legacy or untagged records.
350
371
  The owner-scoped lookup prevents another agent from blocking edits by copying
351
372
  known Soul text into its own memories. Learned artifacts are not an operator-authored Soul source;
352
373
  claimed or missing provenance does not exempt them. Lookup failure aborts the
353
374
  write. This is an exact-match backstop, not semantic detection of paraphrases.
354
375
  Existing Soul records remain readable without a migration.
355
376
 
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.
377
+ Authorized Soul resource POST/PUT with a non-empty `scopeTag` or non-empty
378
+ `tags` array in the request body, and authorized PATCH with those fields in
379
+ the merged row after its stored-row checks, receive
380
+ `soul_scope_fields_not_writable`. Runtime denial
381
+ does not depend on connector names — Soul writes are deny-by-default, and Flair
382
+ stamps `sourceClass` from verified Basic credentials or a deliberate internal
383
+ context, never a body field.
384
+ 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