@tpsdev-ai/flair 0.59.0 → 0.62.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 (259) hide show
  1. package/README.md +4 -4
  2. package/SECURITY.md +36 -0
  3. package/config.yaml +12 -1
  4. package/dist/bridges/builtins/mem0.js +63 -28
  5. package/dist/bridges/runtime/import-runner.js +12 -0
  6. package/dist/bridges/runtime/load-plugin.js +42 -13
  7. package/dist/bridges/runtime/yaml-loader.js +4 -2
  8. package/dist/build-info.json +3 -3
  9. package/dist/cli.js +991 -248
  10. package/dist/commands/agent.js +224 -43
  11. package/dist/commands/attention.js +4 -3
  12. package/dist/commands/backup.js +202 -34
  13. package/dist/commands/bridge.js +172 -119
  14. package/dist/commands/deploy.js +37 -4
  15. package/dist/commands/doctor.js +592 -146
  16. package/dist/commands/export.js +54 -19
  17. package/dist/commands/federation.js +141 -21
  18. package/dist/commands/hook.js +155 -2
  19. package/dist/commands/idp.js +14 -1
  20. package/dist/commands/import.js +7 -3
  21. package/dist/commands/init.js +462 -193
  22. package/dist/commands/integrity.js +388 -0
  23. package/dist/commands/keys.js +247 -58
  24. package/dist/commands/mcp.js +97 -35
  25. package/dist/commands/memory.js +171 -21
  26. package/dist/commands/migrate-harness-memory.js +3 -2
  27. package/dist/commands/orgevent.js +46 -37
  28. package/dist/commands/presence.js +4 -3
  29. package/dist/commands/principal.js +426 -48
  30. package/dist/commands/quality.js +10 -1
  31. package/dist/commands/reembed.js +141 -17
  32. package/dist/commands/relationship.js +2 -1
  33. package/dist/commands/rem.js +56 -18
  34. package/dist/commands/restore.js +101 -61
  35. package/dist/commands/search.js +6 -4
  36. package/dist/commands/service.js +151 -38
  37. package/dist/commands/soul.js +4 -3
  38. package/dist/commands/status.js +43 -5
  39. package/dist/commands/test.js +3 -2
  40. package/dist/commands/upgrade.js +24 -1
  41. package/dist/commands/workspace.js +6 -3
  42. package/dist/component-env.js +31 -41
  43. package/dist/deploy.js +77 -1
  44. package/dist/doctor-client.js +529 -92
  45. package/dist/engine-version-contract.js +1 -0
  46. package/dist/engine-version.js +23 -3
  47. package/dist/federation-verify.js +4 -3
  48. package/dist/hook-install.js +670 -6
  49. package/dist/keystore.js +72 -0
  50. package/dist/lib/action-recall-runtime.js +328 -0
  51. package/dist/lib/agent-home-fields.js +132 -0
  52. package/dist/lib/agent-home.js +427 -0
  53. package/dist/lib/agent-id-rule.js +46 -0
  54. package/dist/lib/agent-roster.js +33 -0
  55. package/dist/lib/auth-resolve.js +49 -16
  56. package/dist/lib/capture-runtime.js +124 -0
  57. package/dist/lib/credential-status-rule.js +78 -0
  58. package/dist/lib/daemon-liveness.js +41 -10
  59. package/dist/lib/doctor-run.js +75 -37
  60. package/dist/lib/durability-copy.js +10 -0
  61. package/dist/lib/embedding-space-doctor.js +75 -0
  62. package/dist/lib/flair-agent-role.js +4 -0
  63. package/dist/lib/hub-url.js +12 -0
  64. package/dist/lib/init-admin-pass.js +88 -12
  65. package/dist/lib/init-listener-environ.js +1 -2
  66. package/dist/lib/init-occupied-listener.js +15 -111
  67. package/dist/lib/init-spawn-attribution.js +73 -0
  68. package/dist/lib/init-tcp-probe.js +33 -0
  69. package/dist/lib/instance-identity-row.js +20 -0
  70. package/dist/lib/launchd-management.js +24 -0
  71. package/dist/lib/listener-table.js +268 -0
  72. package/dist/lib/local-delete-instance.js +27 -0
  73. package/dist/lib/local-instance-pair.js +256 -0
  74. package/dist/lib/mcp-enable.js +1168 -326
  75. package/dist/lib/mcp-oauth-env-core.js +133 -0
  76. package/dist/lib/mcp-oauth-env.js +125 -0
  77. package/dist/lib/mcp-spec.js +17 -1
  78. package/dist/lib/memory-attributes.js +2 -0
  79. package/dist/lib/memory-id-policy.js +46 -0
  80. package/dist/lib/memory-integrity.js +309 -0
  81. package/dist/lib/memory-purge-response.js +20 -0
  82. package/dist/lib/ops-table-count.js +25 -0
  83. package/dist/lib/owned-pins.js +67 -10
  84. package/dist/lib/peer-status.js +27 -0
  85. package/dist/lib/principal-status.js +29 -0
  86. package/dist/lib/process-start-time.js +76 -12
  87. package/dist/lib/proto-safe-record.js +42 -0
  88. package/dist/lib/record-id-path.js +25 -0
  89. package/dist/lib/reembed-server-support.js +66 -0
  90. package/dist/lib/restore-verify.js +104 -0
  91. package/dist/lib/scheduler-platform.js +10 -6
  92. package/dist/lib/secret-keys.js +25 -0
  93. package/dist/lib/secrets-push.js +50 -22
  94. package/dist/lib/skill-seed-pending.js +24 -0
  95. package/dist/lib/skill-seed.js +365 -0
  96. package/dist/lib/stop-start-recovery.js +54 -0
  97. package/dist/lib/using-flair-skill.js +87 -0
  98. package/dist/mcp-client-assertion.js +112 -4
  99. package/dist/memory-id-checkpoint.js +326 -0
  100. package/dist/memory-node-compare.js +207 -0
  101. package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
  102. package/dist/rem/restore.js +6 -5
  103. package/dist/rem/runner.js +103 -44
  104. package/dist/resources/Agent.js +321 -1
  105. package/dist/resources/AgentKeyRegister.js +214 -0
  106. package/dist/resources/AgentKeyRegistration.js +28 -0
  107. package/dist/resources/AgentSeed.js +10 -4
  108. package/dist/resources/AutoPromoteCandidates.js +7 -1
  109. package/dist/resources/Credential.js +177 -2
  110. package/dist/resources/Federation.js +751 -143
  111. package/dist/resources/FederationRetry.js +140 -0
  112. package/dist/resources/InstructionVersion.js +220 -0
  113. package/dist/resources/Integration.js +300 -25
  114. package/dist/resources/Memory.js +2113 -604
  115. package/dist/resources/MemoryArchive.js +75 -42
  116. package/dist/resources/MemoryBootstrap.js +110 -39
  117. package/dist/resources/MemoryCandidate.js +21 -1
  118. package/dist/resources/MemoryDedupStats.js +30 -1
  119. package/dist/resources/MemoryFeed.js +327 -45
  120. package/dist/resources/MemoryGrant.js +21 -1
  121. package/dist/resources/MemoryMaintenance.js +129 -25
  122. package/dist/resources/MemoryPurge.js +232 -0
  123. package/dist/resources/MemoryReflect.js +7 -2
  124. package/dist/resources/MemoryReindex.js +24 -8
  125. package/dist/resources/Message.js +5 -3
  126. package/dist/resources/OAuth.js +186 -9
  127. package/dist/resources/OrgEvent.js +126 -3
  128. package/dist/resources/Presence.js +144 -49
  129. package/dist/resources/PromoteMemoryCandidate.js +18 -7
  130. package/dist/resources/Relationship.js +23 -0
  131. package/dist/resources/SemanticSearch.js +63 -32
  132. package/dist/resources/Soul.js +189 -76
  133. package/dist/resources/TeamDirectory.js +35 -0
  134. package/dist/resources/WorkspaceState.js +21 -1
  135. package/dist/resources/XAA.js +181 -63
  136. package/dist/resources/agent-auth.js +40 -15
  137. package/dist/resources/auth-middleware.js +400 -161
  138. package/dist/resources/ed25519-auth.js +1 -1
  139. package/dist/resources/embedding-space-guard.js +366 -72
  140. package/dist/resources/engine-version-stamp-boot.js +53 -0
  141. package/dist/resources/federation-classify.js +72 -0
  142. package/dist/resources/federation-crypto.js +5 -5
  143. package/dist/resources/federation-retry-lib.js +135 -0
  144. package/dist/resources/grant-visibility.js +135 -0
  145. package/dist/resources/harper-routing.js +83 -0
  146. package/dist/resources/health.js +120 -18
  147. package/dist/resources/host-source-citation.js +49 -0
  148. package/dist/resources/host-source-visibility.js +7 -6
  149. package/dist/resources/instance-create-lock.js +17 -0
  150. package/dist/resources/instance-identity.js +23 -0
  151. package/dist/resources/instruction-version-record.js +343 -0
  152. package/dist/resources/key-lock.js +3 -3
  153. package/dist/resources/mcp-handler.js +36 -8
  154. package/dist/resources/mcp-oauth-env-guard.js +36 -0
  155. package/dist/resources/mcp-oauth.js +23 -6
  156. package/dist/resources/mcp-tool-arguments.js +4 -6
  157. package/dist/resources/mcp-tools.js +128 -19
  158. package/dist/resources/memory-bootstrap-lib.js +5 -15
  159. package/dist/resources/memory-declared-attributes.js +3 -1
  160. package/dist/resources/memory-deletion-history.js +55 -0
  161. package/dist/resources/memory-durability.js +54 -0
  162. package/dist/resources/memory-embed-hash.js +88 -0
  163. package/dist/resources/memory-embedding-value.js +8 -0
  164. package/dist/resources/memory-host-source.js +27 -5
  165. package/dist/resources/memory-id-guard.js +75 -0
  166. package/dist/resources/memory-redaction.js +236 -0
  167. package/dist/resources/memory-supplied-vector.js +72 -0
  168. package/dist/resources/memory-write-lock.js +310 -0
  169. package/dist/resources/memory-write-response.js +139 -0
  170. package/dist/resources/migrations/data-dir.js +74 -16
  171. package/dist/resources/migrations/dir-safety.js +1 -1
  172. package/dist/resources/migrations/embedding-stamp.js +193 -79
  173. package/dist/resources/migrations/export.js +1 -0
  174. package/dist/resources/migrations/graph-heal.js +18 -25
  175. package/dist/resources/migrations/lock.js +7 -1
  176. package/dist/resources/migrations/snapshot.js +1 -0
  177. package/dist/resources/migrations/source-fields.js +5 -5
  178. package/dist/resources/migrations/synthetic-test-migration.js +14 -11
  179. package/dist/resources/migrations/visibility-backfill.js +29 -29
  180. package/dist/resources/object-body-guard.js +33 -0
  181. package/dist/resources/org-event-created-at.js +133 -0
  182. package/dist/resources/originator-instance.js +39 -7
  183. package/dist/resources/owner-delete-recheck.js +78 -0
  184. package/dist/resources/owner-field-guard.js +39 -5
  185. package/dist/resources/owner-scoped-write-policy.js +212 -0
  186. package/dist/resources/owner-scoped-writes.js +58 -0
  187. package/dist/resources/presence-receipt.js +236 -0
  188. package/dist/resources/promotion-stamp.js +47 -12
  189. package/dist/resources/record-owner-guard.js +74 -26
  190. package/dist/resources/record-types.js +1 -1
  191. package/dist/resources/relay-ops.js +78 -6
  192. package/dist/resources/replay-store.js +96 -19
  193. package/dist/resources/request-target.js +136 -0
  194. package/dist/resources/request-transaction.js +35 -0
  195. package/dist/resources/search-readiness.js +4 -1
  196. package/dist/resources/seed-ids.js +9 -0
  197. package/dist/resources/seed-reservation.js +117 -0
  198. package/dist/resources/semantic-retrieval-core.js +20 -9
  199. package/dist/resources/skill-manifest.js +20 -11
  200. package/dist/resources/skill-subject.js +53 -0
  201. package/dist/resources/skill-version-write.js +432 -0
  202. package/dist/resources/skill-write-fault.js +17 -0
  203. package/dist/resources/skill-write-policy.js +67 -0
  204. package/dist/resources/skill-write.js +67 -7
  205. package/dist/resources/table-helpers.js +10 -7
  206. package/dist/resources/team-directory.js +248 -0
  207. package/dist/resources/tool-descriptors/index.js +69 -8
  208. package/dist/resources/txn-pause-point.js +118 -0
  209. package/dist/resources/usage-recording.js +171 -63
  210. package/dist/resources/write-back.js +218 -0
  211. package/dist/src/engine-version-contract.js +1 -0
  212. package/dist/src/keystore.js +72 -0
  213. package/dist/src/lib/agent-home-fields.js +132 -0
  214. package/dist/src/lib/agent-id-rule.js +46 -0
  215. package/dist/src/lib/agent-key-register.js +80 -0
  216. package/dist/src/lib/atomic-write.js +256 -0
  217. package/dist/src/lib/credential-status-rule.js +78 -0
  218. package/dist/src/lib/expired-by-agent.js +37 -0
  219. package/dist/src/lib/flair-agent-role.js +4 -0
  220. package/dist/src/lib/idp-mapping-rule.js +81 -0
  221. package/dist/src/lib/instance-identity-row.js +20 -0
  222. package/dist/src/lib/mcp-oauth-env-core.js +133 -0
  223. package/dist/src/lib/memory-attributes.js +2 -0
  224. package/dist/src/lib/memory-id-policy.js +46 -0
  225. package/dist/src/lib/principal-status.js +29 -0
  226. package/dist/src/lib/proto-safe-record.js +42 -0
  227. package/dist/src/lib/reembed-server-support.js +66 -0
  228. package/dist/src/lib/scheduler-platform.js +10 -6
  229. package/dist/src/lib/systemd-agent-id.js +38 -0
  230. package/docs/access-control.md +146 -45
  231. package/docs/api-reference.md +46 -11
  232. package/docs/auth.md +6 -12
  233. package/docs/bridges.md +11 -0
  234. package/docs/claude-code.md +34 -4
  235. package/docs/deploying-on-fabric.md +70 -0
  236. package/docs/deployment.md +2 -0
  237. package/docs/embedding-in-a-harper-app.md +1 -1
  238. package/docs/federation.md +33 -2
  239. package/docs/hosted-on-fabric.md +43 -36
  240. package/docs/integrations.md +5 -5
  241. package/docs/mcp-clients.md +5 -2
  242. package/docs/n8n.md +17 -11
  243. package/docs/notes/mcp-agent-auth-consumer.md +12 -4
  244. package/docs/notes/mcp-oauth-model2.md +34 -5
  245. package/docs/quickstart-fabric.md +2 -2
  246. package/docs/quickstart.md +9 -1
  247. package/docs/releasing.md +12 -6
  248. package/docs/rem.md +8 -0
  249. package/docs/secrets-and-keys.md +19 -2
  250. package/docs/standalone-local.md +1 -0
  251. package/docs/supply-chain-policy.md +13 -3
  252. package/docs/upgrade.md +32 -6
  253. package/package.json +10 -5
  254. package/schemas/agent-key-registration.graphql +22 -0
  255. package/schemas/agent.graphql +3 -0
  256. package/schemas/federation.graphql +38 -1
  257. package/schemas/memory.graphql +84 -5
  258. package/schemas/oauth.graphql +19 -0
  259. package/schemas/schema.graphql +2 -0
@@ -331,6 +331,76 @@ flair upgrade --target https://<cluster>.<org>.harperfabric.com --check
331
331
 
332
332
  Full path: [upgrade.md](upgrade.md#upgrading-a-fabric-deployed-instance).
333
333
 
334
+ ### Memory ids: operator-run checkpoint and post-operation check
335
+
336
+ `flair fleet verify` probes health and version. Deploy's replication-error check compares
337
+ component-tree metadata. Neither checks Memory rows. Checkpoint the instance's Memory ids
338
+ before the operation, then verify after:
339
+
340
+ ```bash
341
+ flair memory checkpoint --target https://<cluster>.<org>.harperfabric.com \
342
+ --fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
343
+
344
+ # ... the planned cluster operation ...
345
+
346
+ flair memory verify --target https://<cluster>.<org>.harperfabric.com \
347
+ --fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
348
+ ```
349
+
350
+ The checkpoint command reads Memory ids and durability tiers through the admin operations
351
+ API (primary-key pages, never through recall) and writes IDs and aggregate tier counts to
352
+ `~/.flair/memory-id-checkpoint.json` (mode `0600`); it reads no Memory content.
353
+ `--checkpoint <path>` picks another file.
354
+
355
+ The verify command re-reads the same operations origin and compares:
356
+
357
+ - **verified** (exit 0) — checkpointed ids present and no tier-count drop; new ids are fine;
358
+ - **integrity failure** (exit 2) — a checkpointed id is gone, or a durability tier count
359
+ dropped; the report names the count of missing ids and up to ten ids;
360
+ - **unknown** (exit 3) — the comparison could not be completed: for example, an unreadable
361
+ checkpoint, a different operations origin, a failed read, or a count change.
362
+
363
+ An absent checkpoint exits 1 without a verification outcome.
364
+
365
+ `flair deploy` also takes `--memory-checkpoint <path>`: after the deploy it runs the same
366
+ verify and adds a `Memory id/tier check:` line to the report; an integrity failure does not
367
+ fail the deploy. Without the flag it says `not checked`.
368
+
369
+ ### Memory ids: comparing nodes
370
+
371
+ `flair memory checkpoint` writes one instance's observed Memory ids and per-tier counts to a file; `flair memory verify` compares a later read of those ids and counts with that file. To see whether two or more
372
+ physical nodes have the same observed Memory ids, name each node's operations API origin explicitly:
373
+
374
+ ```bash
375
+ flair memory compare-nodes \
376
+ --node <node-a-ops-origin> --node <node-b-ops-origin> \
377
+ --fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
378
+ ```
379
+
380
+ Each `--node` is the address that node's operations API is read at (the address `flair memory
381
+ checkpoint` reaches through `--ops-target`). Physical peers are never inferred from Flair's
382
+ federation peers: a node is compared only when `--node` names it. Each node is read with the same
383
+ paged operations-API read the checkpoint uses, plus stored timestamps. Count checks cannot detect
384
+ equal-count concurrent updates or replacements; an id absent on every named node is invisible
385
+ without a reference set. Timestamps use parseable `updatedAt`, else `createdAt`, which can be
386
+ caller-supplied. Node clocks can differ; timestamp comparisons do not establish actual write order.
387
+ A missing id uses the maximum timestamp among usable peers holding it. Per node the report gives:
388
+
389
+ - **in-sync** — observed ids equal the union of the other usable readings;
390
+ - **lagging** — missing ids only, each timestamp greater than this node's maximum timestamp;
391
+ - **divergent** — an extra id, or a missing id timestamp at or below this node's maximum;
392
+ - **unknown** — failed read, unusable timestamp, no usable peer, or no local timestamp for missing ids.
393
+
394
+ The overall result is healthy only when every node is in-sync. A lagging node is reported as such
395
+ and is never healthy; any unknown makes the overall result unknown. The report lists the missing
396
+ and extra ids against other usable readings (a count, then the ids up to ten). Failed reads report
397
+ counts, ids and timestamps as `UNAVAILABLE`; differences without a usable peer are `UNAVAILABLE`.
398
+ `--json` prints the same result as JSON.
399
+
400
+ Exit codes: `0` healthy, `2` divergent, `3` unknown, `4` lagging. Fewer than two `--node` values, a
401
+ repeated node, or an invalid HTTP(S) URL exits `1`. Paths, queries and fragments are removed from
402
+ node URLs before comparison.
403
+
334
404
  ---
335
405
 
336
406
  ## See also
@@ -234,6 +234,8 @@ flair restore ~/flair-backup-20260405.json
234
234
 
235
235
  Always backup before upgrades.
236
236
 
237
+ Concurrent deletes can cause `flair backup` to refuse publication on a count mismatch; pause writers and maintenance, then retry.
238
+
237
239
  ---
238
240
 
239
241
  ## Uninstall
@@ -227,7 +227,7 @@ Give every agent its own. A per-agent context costs nothing — no client to con
227
227
 
228
228
  ### In a cluster
229
229
 
230
- Harper replicates every table in a replicated database unless the table opts out with `@table(replicate: false)`. None of Flair's do. So:
230
+ Harper replicates tables in a replicated database unless a table opts out with `@table(replicate: false)`. Flair's replay stores are instance-wide across workers: `ReplayNonce` records agent-auth and federation nonces and opts out of replication, while `IdJagReplay` records used XAA assertion `jti` values and `OAuthSingleUse` records claims to redeem authorization codes or rotate refresh tokens. A single-use row records that a redemption was claimed. The handler attempts the later `used` or revocation write before issuing tokens. If that write fails, no token pair is issued; the claim remains, so the code or token cannot be redeemed again. `IdJagReplay` and `OAuthSingleUse` have no replication opt-out, so they replicate when the `flair` database does. Other Flair tables without a replication opt-out do too. So:
231
231
 
232
232
  - **The registry replicates.** An agent registered on node A is visible on node B with no coordination. (Replication comes from the *database* being replicated — not from `@export`, which only controls REST exposure. `Memory` carries no `@export` and still replicates.)
233
233
  - **Authority is local.** The context is constructed per call, in whichever process handles it. No node asks another who a caller is.
@@ -235,9 +235,9 @@ If neither the env var nor the passphrase file can be accessed, federation ident
235
235
 
236
236
  ### Pairing tokens
237
237
 
238
- New peers must present a valid, unexpired, unused pairing token. This prevents unauthorized instances from joining the federation. Tokens are generated by the hub admin and are single-use.
238
+ New peers must present a valid, unexpired, unused pairing token. This prevents unauthorized instances from joining the federation. Tokens are generated by the hub admin and are single-use on one node.
239
239
 
240
- Re-pairing an existing peer (same instance ID, same public key) does not require a token.
240
+ An otherwise valid re-pair of a non-revoked peer (same instance ID, signed with the peer's pinned public key) requires no token; a supplied token must pass validation before the transactional Peer re-read and is consumed only if the pairing commits. Before writing, the re-pair rechecks the pinned key and revoke status inside its owned transaction: a different key is refused (409); otherwise a revoked peer is refused (403 `peer_revoked`), with no peer row written and no token consumed. A peer row absent at that re-read is paired as a first-time pair with a valid token; without a token the request is refused (401). On the token path, the re-read covers changes committed before the transaction's first read (its token read), not changes committed after it. A pair request whose first read finds no peer row (a first-time pair) stages its peer row in the owned transaction that consumes its token, then re-reads the committed peer row before that transaction commits. If that confirm read finds a row for the instance in committed state although the first read returned none, the pair is refused (409 `peer_row_appeared`): the request writes no peer row and the token stays unconsumed. The confirm reports a row present when it runs, not when that row was committed; it also detects a row committed after the token read, if that row is still present. A row committed after the confirm read and before the commit is not seen by it.
241
241
 
242
242
  ### Originator enforcement
243
243
 
@@ -277,6 +277,37 @@ Records with `updatedAt` more than 5 minutes in the future are rejected. This pr
277
277
 
278
278
  Federation uses record-level last-write-wins (LWW) with ISO timestamp comparison. When two instances modify the same record, the one with the later `updatedAt` wins. Field-level LWW is planned for a future version.
279
279
 
280
+ ### A pending agent key is never completed by federation
281
+
282
+ `POST /AgentKeyRegister` checks a fresh row is non-deactivated, local and `pending` and
283
+ confirms it before commit (see [registration limits](api-reference.md#identity--agent-presence-soul)); the administrator
284
+ operations API can also write the column directly (the documented admin
285
+ trust-root path). Federation cannot complete it. A record that reaches the merge
286
+ plan with `publicKey` different from stored `pending` is skipped whole as
287
+ `agent_pending_key_not_federated`, unless the status rule refused it first as
288
+ `agent_status_not_federated`. Earlier validation keeps its own reason, such as
289
+ `future_timestamp` (see [docs/api-reference.md](api-reference.md#federation)).
290
+
291
+ Peer non-convergence is the consequence for a copy B already holds. Registration
292
+ writes only A's local tables; when B already holds a pending copy and A's
293
+ registered-key row later reaches B through a sync, the skip rule leaves that copy
294
+ exactly `pending`. Sync alone therefore does not converge that copy. Whether B's
295
+ own `POST /AgentKeyRegister` can complete it depends on how B's copy was created:
296
+ B stamps sync provenance on a row it receives through a sync, and a copy that
297
+ carries sync provenance (or whose `originatorInstanceId` names another instance)
298
+ is refused there as `agent_not_local`. A pending copy created locally on B, with
299
+ neither marker, is a local agent: B's own registration can complete it. For a
300
+ sync-originated or foreign-home copy, the two instances do not converge on one
301
+ key: syncing A's registered-key row cannot complete B's pending copy, and that
302
+ key needs direct action on B. The remedy is on B, for
303
+ a sync-originated or foreign-home copy: B's administrator writes the agent's
304
+ public key (the one registered on A) onto B's copy through B's operations API,
305
+ an `update` of `flair.Agent` with `{id, publicKey, updatedAt}`. That is the raw
306
+ write `flair agent rotate-key` makes, but `rotate-key` generates a new keypair,
307
+ so B's copy would then hold a different key from A's. A B row that is absent
308
+ can receive A's registered-key row: the pending-key guard applies only to a row B
309
+ already holds with `publicKey: "pending"`.
310
+
280
311
  ## Troubleshooting
281
312
 
282
313
  ### Listen port drift
@@ -41,11 +41,11 @@ flair init --target https://<cluster>.<org>.harperfabric.com \
41
41
  - `--remote` marks it a federation **hub** and creates the `flair_pair_initiator` role; without it, pairing later fails role-not-found.
42
42
  - Generated admin password lands in `~/.tps/secrets/flair-fabric-hdb` (mode `0600`); `--flair-admin-pass` to choose your own.
43
43
 
44
- ### Port derivation trap
44
+ ### Operations endpoint
45
45
 
46
- Locally, Flair serves data on `19926` and the ops API on `19925`. The CLI derives **ops = data − 1** everywhere. A managed endpoint is HTTPS on 443 with no port, so derivation produces `:442` — where nothing answers.
46
+ Portless HTTPS targets derive the ops endpoint at `:9925`. <!-- docs-freshness-allow: Fabric ops API port (FABRIC_OPS_PORT), not legacy data port -->
47
47
 
48
- **Pass `--ops-target <url>` explicitly** (or set `FLAIR_OPS_TARGET`) on any command that touches the ops API: `init --target`, `agent add --target`, `federation token --target`.
48
+ Set `FLAIR_OPS_TARGET` to override the derived endpoint, including for `flair backup`.
49
49
 
50
50
  ---
51
51
 
@@ -59,56 +59,63 @@ On Fabric, configuration goes through the component's environment, not a local `
59
59
  | `HDB_ADMIN_PASSWORD` | Bootstrap password for the embedded Harper. | Set at install time. |
60
60
  | `FLAIR_KEY_PASSPHRASE` | Passphrase for federation key encryption. | Set for production federation deployments. |
61
61
 
62
- On Fabric / managed deploys, environment variables are provisioned through Harper's Fabric secrets mechanism (encrypted at rest with `enc:v1:` storage format).
62
+ On Fabric / managed deploys, Harper's secrets mechanism can provision environment variables (encrypted at rest with `enc:v1:` storage format). `flair mcp enable` uses a staged-file fallback when the push is unavailable or fails.
63
63
 
64
64
  ### How `flair mcp enable` delivers its secrets
65
65
 
66
- `flair mcp enable` needs five variables live in the target's process before it restarts — including `FLAIR_MCP_OAUTH` and the RS256 signing key, both read from `process.env` only and therefore impossible to deliver via `set_configuration`.
66
+ `flair mcp enable` provisions five variables for the target's process, including `FLAIR_MCP_OAUTH`, which is read from `process.env` only, so `set_configuration` cannot deliver it.
67
+
68
+ Use `--fabric` for a non-loopback custom-domain Fabric target.
67
69
 
68
70
  It asks the target what it can do, rather than assuming from the hostname or the version:
69
71
 
70
72
  | The target… | What happens |
71
73
  |-------------|--------------|
72
- | supports Harper's env-secrets operations | the five vars are **sealed locally** and pushed over the ops API. No manual step, no re-run. |
73
- | does not have them (Harper older than 5.2) | the vars are staged to a `0600` file and you apply them yourself, then re-run with `--confirm-secrets-applied` |
74
+ | returns a usable env-secrets public key | `enable` attempts a sealed push over the ops API. If the push fails, it reports a staged-file fallback. After confirmation, an already active surface can pass without a restart or re-run; restart if this run changed a secret value. If the surface is inactive, restart the Fabric target after a successful push, or apply the staged values and restart, then re-run with `--confirm-secrets-applied`. |
75
+ | reports no env-secrets public-key operation | the vars are staged to a `0600` file and you apply them yourself, then re-run with `--confirm-secrets-applied` |
74
76
  | is unreachable, refuses the probe, or answers unusably | same staged-file fallback, and the output says **which** of those happened |
75
77
 
76
- Values are encrypted **before leaving your machine** — AES-256-GCM on the value, RSA-OAEP(SHA-256) wrapping the key, addressed to a public key fetched from the target. Plaintext never appears in a request body, and the command's output carries variable *names* only.
78
+ For an automated push, values are encrypted **before leaving your machine** — AES-256-GCM on the value, RSA-OAEP(SHA-256) wrapping the key, addressed to a public key fetched from the target. Plaintext does not appear in the push request body, and the command's output names variables without showing their values.
77
79
 
78
- The staging file is written in every case, so a fallback never strands you mid-run. When the push succeeds it simply goes unused.
80
+ At secrets provisioning, `enable` stages the file before any probe or push; dry runs stop earlier. A successful push leaves it unused.
79
81
 
80
- > **What the probe does not promise.** It establishes that the target accepts secrets, not that it will *decrypt* them — no read-only call can, since a secret only proves it was decrypted by being present in the process. The **self-verify** step at the end is what proves that. Note the endpoint does *not* go quiet when the flag is off — flair serves its own OAuth 2.1 discovery document instead, and self-verify tells them apart by the advertised `token_endpoint` (`/OAuthToken` is flair's own; the MCP one is `/oauth/mcp/token`). So a secret that is stored and never decrypted fails at self-verify with a message naming `FLAIR_MCP_OAUTH`, rather than reporting success.
82
+ > **What the probe does not promise.** When successful, it returns a public key for a possible push; it does not prove the push succeeds or that the target process loads the values. `enable` checks the target's MCP token endpoint and public metadata before reporting success. Flair also serves OAuth metadata when the MCP flag is off: the target check distinguishes Flair's `/OAuthToken` from the MCP `/oauth/mcp/token`. An already active surface can pass these checks before newly pushed values are loaded; restart if this run changed a secret value.
81
83
 
82
84
  `--secrets-mechanism <fabric-env-secrets|env-file>` remains an explicit override and skips the probe entirely.
83
85
 
84
86
  ### The `mcp.enabled` operator step (Fabric)
85
87
 
86
- MCP is **off by default**. The shipped component `config.yaml` contains
87
- `@harperfast/oauth` → `mcp` → `enabled: false`. Until [flair#1152](https://github.com/tpsdev-ai/flair/issues/1152)
88
- lands (interpolate from env — *ON HOLD*), you must flip this manually:
89
-
90
- 1. In your deployed component's `config.yaml`, change:
91
- ```yaml
92
- '@harperfast/oauth':
93
- mcp:
94
- enabled: true # was: false
95
- ```
96
- 2. Re-deploy the component so Harper picks up the new value.
97
- 3. **Verify the `/mcp` surface is actually serving** (the flag alone does not
98
- guarantee it — a secret that is stored but never decrypted fails at self-verify):
99
- ```bash
100
- # Check /mcp is reachable and returning MCP protocol (not a loopback proxy or 404)
101
- curl -sf https://<cluster>.<org>.harperfabric.com/mcp
102
- # Should return MCP JSON-RPC content; if you get HTML redirect or 404 the flag
103
- # is not effective
104
- ```
105
-
106
- **⚠ SECURITY CAVEAT — the upgrade-reverts trap.** Any package update or fleet component
107
- update re-ships the literal `enabled: false` and silently darkens a live `/mcp` surface.
108
- You must **re-flip to `true` after every upgrade** and re-deploy. An updated component
109
- without this re-flip will appear healthy (`/Health` green) while its MCP tools are
110
- dark to every connected client. If you rely on MCP, add the re-flip to your upgrade
111
- runbook.
88
+ MCP is **off by default**. The shipped component `config.yaml` contains the `@harperfast/oauth` block
89
+ uncommented with `mcp.enabled: ${FLAIR_MCP_OAUTH}`, a whole-token environment reference
90
+ ([flair#1152](https://github.com/tpsdev-ai/flair/issues/1152)), so the on/off choice lives in the
91
+ instance's environment and a re-packed deploy cannot revert it. There is no `config.yaml` edit and no
92
+ re-deploy to make.
93
+
94
+ For **`*.harperfabric.com` targets** or non-loopback custom-domain targets selected with `--fabric`, `flair mcp enable` does not restart the instance. It provisions the secrets, then checks the MCP
95
+ surface in this order:
96
+
97
+ 1. **Target/issuer binding.** The target's *own* metadata at
98
+ `<instance-url>/.well-known/oauth-authorization-server` must name the verified issuer and advertise
99
+ the MCP token endpoint `/oauth/mcp/token`. A mismatch refuses the run.
100
+ 2. **Public-origin self-verify.** Metadata at the same path is fetched from the public issuer. The check
101
+ requires a matching issuer, the issuer's `/oauth/mcp/token` endpoint, and advertised
102
+ CIMD support. `flair mcp status`
103
+ uses this check.
104
+
105
+ Then one of:
106
+
107
+ - **Self-verify passes.** The run prints the paste block. If this run changed a secret value, restart the
108
+ instance so its process picks the new value up.
109
+ - **It answers but does not pass** (HTTP 404, flair's own authorization server, or CIMD not advertised).
110
+ The step fails, reports the metadata problem, and gives generic apply-or-restart advice. Re-run
111
+ `flair mcp enable` with the same options plus `--confirm-secrets-applied`.
112
+ - **The request fails** (DNS, connection, TLS, timeout). The step fails and says the public issuer could
113
+ not be reached, quoting the URL and the error. It gives no activation instruction; it asks you to check
114
+ that the host resolves, that this machine can reach it over HTTPS, and that the instance is running in
115
+ Fabric — then re-run with `--confirm-secrets-applied`.
116
+
117
+ After applying the secrets and restarting, re-run with `--confirm-secrets-applied`. The run passes only if
118
+ the target's issuer and MCP token endpoint match, and the public metadata and CIMD checks pass.
112
119
 
113
120
  ---
114
121
 
@@ -1,8 +1,8 @@
1
1
  # Flair integrations
2
2
 
3
- Where Flair already runs. Each integration can reach one shared Flair memory store; signed requests identify an agent, while other verified agents may read its non-private records, and n8n uses admin Basic auth.
3
+ Where Flair already runs. Each integration can reach one shared Flair memory store; signed requests identify an agent, while other verified agents may read its non-private records.
4
4
 
5
- > **The point.** Memory can follow an agent across orchestrators. Integrations using an ordinary Ed25519 agent key can write under that identity and read their own plus other agents' non-private records. Administrator agent roles have broader authority. n8n uses Harper administrator Basic auth; stdio MCP, Pi, LangGraph, and the wake runner can also use it when no signing key resolves. Administrator Basic auth can read private records and write under any agent ID. Choose an integration with its authentication and recall behavior in mind.
5
+ > **The point.** Memory can follow an agent across orchestrators. Integrations using an ordinary Ed25519 agent key can write under that identity and read their own plus other agents' non-private records. Administrator agent roles have broader authority. n8n signs with Agent Private Key selected; its deprecated Admin Password path uses administrator Basic only with an empty key. stdio MCP, Pi, LangGraph, and the wake runner can use administrator Basic auth when no signing key resolves. Administrator Basic auth can read private records and write under any agent ID. Choose an integration with its authentication and recall behavior in mind.
6
6
 
7
7
  ---
8
8
 
@@ -20,7 +20,7 @@ Where Flair already runs. Each integration can reach one shared Flair memory sto
20
20
  | **DeepSeek Harness** (`dsh`) | [`flair-mcp`](deepseek-harness.md) | Cordis overlay | First-party MCP bridge; tools-only, reactive recall — [dedicated page](deepseek-harness.md) |
21
21
  | **LangGraph (TS)** | [`langgraph-flair`](#langgraph-typescript) | FlairClient | FlairStore provides get, put, delete, search, and batch (limitations apply) |
22
22
  | **OpenClaw** | [`openclaw-flair`](#openclaw) | Ed25519 | Native plugin (context-engine slot left intact) |
23
- | **n8n** | [`n8n-nodes-flair`](#n8n) | FlairApi credential | Three nodes (chat memory, search, store) |
23
+ | **n8n** | [`n8n-nodes-flair`](#n8n) | Ed25519 with Agent Private Key selected; deprecated administrator Basic | Three nodes (chat memory, search, store) |
24
24
  | **Hermes Agent** | [`hermes-flair`](#hermes-agent) | Ed25519 | Python `MemoryProvider` |
25
25
  | **Pi agent** | [`pi-flair`](#pi-agent) | Ed25519 | Native pi extension (pi has no MCP support); with `--agent <id>` and wiring enabled, `flair init` attempts Pi wiring for `--client pi`, for detected Pi under `--client all`, or for detected Pi when `--client` is omitted; `--client none` and `--no-mcp` skip it. |
26
26
  | **Google ADK** (Python) | [`adk-flair`](../packages/adk-flair/README.md) | Ed25519 | `BaseMemoryService`; see [hosted auth](#hosted-flair-auth--your-agent-got-a-404) if you just got a 404 |
@@ -83,7 +83,7 @@ A verified agent that is not allowed the row gets 404, never 403. Anonymous by-i
83
83
  | **Pi** | `FLAIR_URL` | `FLAIR_AGENT_ID` | `FLAIR_KEY_PATH` or Pi client `keyPath` | Same Ed25519 model |
84
84
  | **LangGraph** | `FLAIR_URL` | `config.agentId` (required) | Signed requests use `config.privateKey`, `config.keyPath`, or automatic key candidates (`FLAIR_KEY_DIR`, then standard paths); it does not read `FLAIR_KEY_PATH`. | Admin credentials provide a Basic-auth fallback when no key is available. |
85
85
 
86
- n8n still uses Harper admin Basic auth — it is not this path. See [n8n.md](n8n.md#security).
86
+ n8n signs as its credential's Agent ID with Agent Private Key selected. See [n8n.md](n8n.md#3-create-the-credential).
87
87
 
88
88
  ---
89
89
 
@@ -201,7 +201,7 @@ Configuration via OpenClaw's standard plugin surface. See [`docs/openclaw.md`](o
201
201
 
202
202
  The FlairApi credential provides authentication.
203
203
 
204
- **FlairApi credential** — Harper administrator password for Basic authentication; Agent ID selects memory ownership and does not restrict the credential's instance-wide authority.
204
+ **FlairApi credential** — with Agent Private Key selected, requests sign as Agent ID. Ordinary agents read their own and other agents' non-private memories. The deprecated Admin Password path uses Harper administrator Basic authentication only with an empty Agent Private Key, and warns on each node execution.
205
205
 
206
206
  Install via the standard n8n community-node UI (Settings → Community nodes → `@tpsdev-ai/n8n-nodes-flair`) or:
207
207
 
@@ -33,7 +33,7 @@ The snippets below are the **local** path. Flair also has a native `/mcp` endpoi
33
33
  | MCP client on this machine (Claude Code, Cursor, Codex, Gemini, and the snippets below) | `npx -y @tpsdev-ai/flair-mcp@<version>` stdio adapter | Ed25519 over HTTP to the instance |
34
34
  | Remote MCP client that must dial a public HTTPS origin | Native `/mcp` on the instance | OAuth bearer. Unmounted until `FLAIR_MCP_OAUTH=true` and a public issuer are set (otherwise the path 404s). |
35
35
 
36
- Native `/mcp` is remote-only by design. The OAuth authorization server fetches client metadata over HTTPS and refuses private, loopback, and link-local hosts. `flair mcp enable` refuses localhost, loopback, RFC1918, IPv4 link-local, and `.local`. Set `FLAIR_MCP_OAUTH=true` — that is the one value that enables both Flair's `/mcp` route and the OAuth component. A loopback Flair cannot be the origin those clients dial. The stdio adapter is the local path because it speaks the instance's Ed25519 HTTP API and does not need that public origin.
36
+ Native `/mcp` is remote-only by design. The OAuth authorization server fetches client metadata over HTTPS and refuses private, loopback, and link-local hosts. `flair mcp enable` accepts loopback or unspecified targets for the local restart but refuses local issuers. Set `FLAIR_MCP_OAUTH=true` — that is the one value that enables both Flair's `/mcp` route and the OAuth component. A loopback Flair cannot be the origin those clients dial. The stdio adapter is the local path because it speaks the instance's Ed25519 HTTP API and does not need that public origin.
37
37
 
38
38
  `flair init --agent <id>` attempts to wire detected local clients unless MCP wiring is disabled; bare `flair init` only initializes the instance. Turning on native `/mcp` is a separate operator step for a publicly reachable instance, documented from the API side in [api-reference.md](api-reference.md#mcp-tools). Who can connect through native `/mcp`, and how to revoke access, is in [access-control.md](access-control.md).
39
39
 
@@ -291,7 +291,7 @@ If you see (a) the agent calling the `bootstrap` tool returning soul + recent me
291
291
 
292
292
  ## What the MCP server exposes
293
293
 
294
- Clients on this page talk to the stdio server `@tpsdev-ai/flair-mcp`. Its `tools/list` advertises these sixteen tools, in this order. The embedded HTTP `/mcp` handler is a different set: it also advertises `memory_basement`, `memory_restore`, and `attention`, and it does not advertise `relationship_store` or `flair_catchup`.
294
+ Clients on this page talk to the stdio server `@tpsdev-ai/flair-mcp`. Its `tools/list` advertises these seventeen tools, in this order. The embedded HTTP `/mcp` handler is a different set: it also advertises `memory_basement`, `memory_restore`, and `attention`, and it does not advertise `relationship_store` or `flair_catchup`.
295
295
 
296
296
  | Tool | What it does |
297
297
  |---|---|
@@ -310,6 +310,7 @@ Clients on this page talk to the stdio server `@tpsdev-ai/flair-mcp`. Its `tools
310
310
  | `flair_workspace_set` | Set this agent's workspace state (ref, label, provider, task, phase, summary) in the Office Space |
311
311
  | `flair_orgevent` | Publish an org-wide coordination event (claim, release, or status), attributed to the caller |
312
312
  | `flair_catchup` | Drain this agent's own org-event catch-up feed. Page with `after`; advance the watermark with `ack` |
313
+ | `team_directory` | List active agents with published tps-mail contacts. Filter by `id` or `name`; page with `cursor`/`limit` |
313
314
  | `record_usage` | Report that recalled memories were actually used (`memoryId` or `memoryIds`, plus optional `attribution`). Drives `usageCount` / `usageBoost` |
314
315
 
315
316
  For ordinary signed agents, Flair enforces write ownership server-side: they can write only under their authenticated agent ID. Administrator credentials and administrator agent roles have broader authority. Reads are more open by design: any agent on the same Flair instance can read any other agent's **non-private** memories, with no grant to set up (open-within-org read; see [SECURITY.md](../SECURITY.md)).
@@ -322,6 +323,8 @@ The following structured-payload details describe the HTTP bootstrap response an
322
323
 
323
324
  `bootstrap` returns the canonical structured containers — `soul`, `memories`, `predicted`, `teammateFindings`, `events` — plus counts and a `tokenEstimate`. The containers are **always present** (empty `[]`/`{}` when there's nothing), so an empty container is distinguishable from an unsupported one.
324
325
 
326
+ **The structured containers carry no host-source pointer (flair#2448).** A `memories` or `predicted` entry omits `hostSource`. A visible, bound pointer appears in the bootstrap PROSE only when `includeContext` is true, for an authenticated non-admin caller; the admin bootstrap prose is uncited. A non-admin structured consumer that needs the pointer reads the memory back through the gated Memory read — `memory_get` by id — which renders the pointer that caller may see. An admin `memory_get` takes no pointer join, so it does not render the pointer either.
327
+
325
328
  **Skill assignments are reported in `skills` and `skillDiagnostics` (flair#2141).** A `skills` entry is `{ name, skillId, scope, priority, source }` for an assigned skill that won priority resolution; a `skillDiagnostics` entry is a refused, superseded, unresolved or ambiguous assignment with its `decision` and `reason`. Both arrays are present whatever `includeSoul` and `includeContext` say, and hold the entries admitted within the remaining token budget; `skillsTruncated` and `skillDiagnosticsTruncated` count the entries that did not fit. An entry names the skill and does not carry its procedure: fetch that with `skill_get` and the `skillId`, or over REST with a signed `GET /Memory/<skillId>`, which applies the same by-id read gate as `skill_get`. A name-only assignment that wins priority resolution resolves when the agent has exactly one live skill row of its own with that name (not archived, past `validTo` or past `expiresAt`); with none it is `unresolved`, with more than one `ambiguous`. An `OrgSkillAssignment` row is also a candidate when the target's Agent record has `kind` agent and `status` active (absent counts as agent and active); humans, deactivated principals and targets with no Agent record get no org candidates. A Soul `skill-assignment` row with `metadata.optOut: true` removes the org candidates with that name for that agent before priority resolution, when this instance's id can be read and the row's `originatorInstanceId` equals it. An org `skills` entry has `scope: "org"` and its `skillId` is the row's `skillRef`; an org assignment that wins priority resolution with a `skillRef` that is not a live skill row the agent can read is `unresolved`. The `name` and `source` strings come from Soul `skill-assignment` rows, and an org entry's `name` from its `OrgSkillAssignment` row; they reach the agent without SkillScan; that is safe only because no agent key can write those rows (admin agent keys included); only operator credentials and Flair's own internal paths can, so widening who may write them changes what reaches the agent's context.
326
329
 
327
330
  **The token ledger reconciles `tokenEstimate` from the payload alone (flair#1270).** Every token-charged content class carries a counter — `soulTokens`, `memoryTokens`, `trustTokens`, `eventsTokens`, `skillsTokens`, `skillDiagnosticsTokens` — plus a measured `scaffoldTokens` for the fixed JSON frame, and `tokenEstimate ≈ scaffoldTokens + soulTokens + memoryTokens + trustTokens + eventsTokens + skillsTokens + skillDiagnosticsTokens`. At the `/mcp` default (`includeContext: false`) the remaining ≈ gap is the bounded per-item difference between the prose lines the memory counters measure and the heavier structured objects the containers ship; with `includeContext: true` the prose `context` mirror widens it and no upper bound applies. A payload whose estimate an agent can't decompose from the reported figures is a bug, not an accounting convention.
package/docs/n8n.md CHANGED
@@ -13,7 +13,7 @@ Flair is the right pick when you want:
13
13
  | **Shape** | Tagged + typed memories with semantic search, plus chat-buffer compatibility | Conversation-buffer only (LangChain `BaseMessage` records) |
14
14
  | **Cross-orchestrator** | Same memory readable from Claude Code, OpenClaw, n8n | n8n-internal schema; nothing else reads it |
15
15
  | **Cross-instance** | Hub-spoke federation built-in (local ↔ Fabric, etc.) | Single-instance unless you self-build replication |
16
- | **Identity** | Ed25519 per-agent (planned) or admin-token (v1) | n8n credential per workflow |
16
+ | **Identity** | Ed25519 with Agent Private Key selected; the v1 admin password is still accepted, deprecated | n8n credential per workflow |
17
17
 
18
18
  If your AI Agent only needs to remember the last N turns of a single chat in a single n8n instance, Postgres-as-memory is fine. If you want the same memory to inform a Claude Code conversation tomorrow, or to persist across n8n redeploys via federated Flair, this package is the path.
19
19
 
@@ -39,10 +39,20 @@ In n8n: **Credentials → New → Flair API**. Fill in:
39
39
  | Field | Value |
40
40
  |---|---|
41
41
  | **Base URL** | `http://localhost:19926` (or your team's Flair URL) |
42
- | **Agent ID** | Logical identity that will own memories from this n8n workspace. Workflows that share an Agent ID share memory ownership. Use distinct Agent IDs to organize ownership; the shared admin credential can access the whole instance. |
43
- | **Admin Password** | Your Flair admin password (in `~/.flair/admin-pass` for local installs). **Sensitive** — see [Security](#security). |
42
+ | **Agent ID** | The memory owner and, with Agent Private Key selected, signing identity, e.g. `n8n-support`. Workflows that share an Agent ID share memory ownership. |
43
+ | **Agent Private Key** | That agent's Ed25519 private key. |
44
44
 
45
- Click **Test** — if the test request to `/Memory` returns 200, the credential is good.
45
+ Register a new agent with `flair agent add n8n-support`, or use an existing agent's matching key:
46
+
47
+ ```bash
48
+ base64 < ~/.flair/keys/n8n-support.key
49
+ ```
50
+
51
+ Paste the base64 output into **Agent Private Key**.
52
+
53
+ Click **Test** — it reads `/Memory` using the selected auth mode and reports that mode on success.
54
+
55
+ **Admin Password (deprecated)** — used only with Agent Private Key empty. Requests use Harper administrator Basic authentication, including access to other agents' private memories, and each node execution warns.
46
56
 
47
57
  ### 4. Wire the nodes
48
58
 
@@ -81,15 +91,11 @@ Patterns:
81
91
 
82
92
  ## Security
83
93
 
84
- > **The admin password gives every workflow with this credential read/write access to the entire Flair instance**, not just the configured Agent ID. The blast radius is the whole memory store. Treat the credential as highly sensitive: n8n encrypts credentials at rest, but any n8n admin or backup restore can extract it.
85
-
86
- For production deployments where untrusted workflow inputs reach Flair, wait for **Ed25519 per-agent authentication** (planned). v1 (admin password) is appropriate when:
94
+ With Agent Private Key selected, requests sign as the credential's Agent ID. Ordinary agents write their own memories and read their own plus other agents' non-private memories; administrator-role agents have broader authority.
87
95
 
88
- - The n8n instance is single-tenant and operator-controlled
89
- - Workflow inputs are trusted (your own CRM, your own webhook source)
90
- - Memory leakage between agents is acceptable for the use case
96
+ The deprecated **Admin Password** path uses Harper administrator Basic authentication, with access to other agents' private memories. It is used only while Agent Private Key is empty, and every execution that uses it logs a warning. To migrate, set Agent Private Key (step 3).
91
97
 
92
- If any of those don't hold, use Flair's CLI / SDK clients (which support per-agent Ed25519 today) and wait for the n8n credential update.
98
+ Treat the key as a secret.
93
99
 
94
100
  ## Get By Tag
95
101
 
@@ -37,11 +37,19 @@ header `{alg: "EdDSA", typ: "JWT"}`; claims `iss = sub = client_id`, `aud =
37
37
  token endpoint`, `exp - iat ≤ 60s` (hard-capped, not just defaulted), `iat`,
38
38
  random `jti`. Signed with `node:crypto` alone (no new dependency, matching
39
39
  the plugin's own approach and this repo's existing `flair-client.mjs` /
40
- `buildEd25519Auth` signing style). The claim shape is pinned to what PR #165
40
+ `buildEd25519Auth` signing style). The default claim shape is pinned to what PR #165
41
41
  (`src/lib/mcp/clientAssertion.ts`) verifies, and
42
- `test/unit/mcp-client-credentials-live-package.test.ts` proves assertions
43
- this module signs pass the plugin's **real** `verifyClientAssertion` —
44
- including negative cases (wrong signing key, tampered payload).
42
+ `test/unit/mcp-client-credentials-live-package.test.ts` proves default-form
43
+ assertions this module signs pass the pinned plugin's **real**
44
+ `verifyClientAssertion`; it also checks refusals for the issuer form, wrong
45
+ signing keys, and tampered payloads.
46
+
47
+ The audience form is a transition switch (`FLAIR_MCP_CLIENT_ASSERTION_AUDIENCE`,
48
+ or `flair mcp token --assertion-audience`): the default is the shape above, and
49
+ `issuer` signs `aud` = the authorization server metadata document's `issuer`
50
+ with `typ: "client-authentication+jwt"` — the RFC 7523bis form, for the
51
+ verifier release that accepts it (HarperFast/oauth #245, merged upstream but
52
+ not released).
45
53
 
46
54
  Key loading (`resolveAgentKeyPath` / `loadEd25519PrivateKeyFromFile`) mirrors
47
55
  `src/cli.ts`'s existing `resolveKeyPath` / `buildEd25519Auth` (used by the
@@ -6,7 +6,7 @@
6
6
  > Do NOT enable in production until Sherlock signs off on live enablement.
7
7
 
8
8
  This is the **Model 2** native-MCP path: a custom in-process `/mcp` JSON-RPC
9
- handler guarded by `@harperfast/oauth`'s `withMCPAuth`, serving the 17 tools in `resources/mcp-tools.ts`
9
+ handler guarded by `@harperfast/oauth`'s `withMCPAuth`, serving the 18 tools in `resources/mcp-tools.ts`
10
10
  with a per-agent OAuth identity. It is distinct from the
11
11
  native-application-MCP surface (design A / `FLAIR_MCP_ENABLED`); Model 2 does not
12
12
  use Harper's native MCP transport, so it is not blocked by the Harper native-MCP
@@ -18,10 +18,9 @@ gating gaps.
18
18
  Streamable HTTP: `initialize` / `tools/list` / `tools/call` / `ping`. On
19
19
  `tools/call` it resolves the verified token `sub` → a flair `Agent`, then
20
20
  dispatches to the curated tool.
21
- - `resources/mcp-tools.ts` — the 17 tools in `resources/mcp-tools.ts`, each a thin wrapper over the existing resource handler
21
+ - `resources/mcp-tools.ts` — the 18 tools in `resources/mcp-tools.ts`, delegating to resource handlers or the team-directory resolver
22
22
  (Memory / SemanticSearch / BootstrapMemories / Soul / WorkspaceState /
23
- OrgEvent / AttentionQuery / RecordUsage). No raw CRUD surface — the only path to the datastore through `/mcp`
24
- is one of the 17 tools in `resources/mcp-tools.ts`. Curated **by construction**.
23
+ OrgEvent / AttentionQuery / RecordUsage / the team-directory resolver).
25
24
  - `resources/mcp-oauth.ts` — registers `server.http(withMCPAuth(mcpHandler),
26
25
  { urlPath: '/mcp' })` **only when `FLAIR_MCP_OAUTH` is on.** `/mcp` runs on its
27
26
  own dispatch chain; flair's default auth-middleware does not run for it.
@@ -130,6 +129,7 @@ registered identities.
130
129
  github:
131
130
  clientId: ${OAUTH_GITHUB_CLIENT_ID}
132
131
  clientSecret: ${OAUTH_GITHUB_CLIENT_SECRET}
132
+ redirectUri: ${OAUTH_GITHUB_REDIRECT_URI} # this instance's public origin + /oauth; the plugin appends '/github/callback'. Since @harperfast/oauth 2.7.0 a CONFIGURED provider needs it (2.8.1 skips an unconfigured one first — HarperFast/oauth#259)
133
133
  mcp:
134
134
  enabled: ${FLAIR_MCP_OAUTH} # whole-token env reference (flair#1152) — the choice lives in the ENVIRONMENT, so a re-packed deploy can't revert it
135
135
  issuer: ${FLAIR_MCP_ISSUER} # pin to your public origin — REQUIRED
@@ -144,7 +144,8 @@ registered identities.
144
144
  allowedHosts: # CIMD is the only supported client-registration path
145
145
  - claude.ai
146
146
  - claude.com
147
- signingKeyPem: ${FLAIR_MCP_SIGNING_KEY_PEM} # pin in clusters
147
+ # signingKeyPem: ${FLAIR_MCP_SIGNING_KEY_PEM} # Optional pin; add this line and stage the variable.
148
+ # Without a pin, minting reuses a persisted key or generates and persists one if the key table is empty.
148
149
  ```
149
150
 
150
151
  **DCR is not supported; clients connect via CIMD (Client ID Metadata
@@ -162,11 +163,39 @@ registered identities.
162
163
  same var accepts only "true"/"false" and deletes anything else, so `1`
163
164
  gives you a guarded `/mcp` with no authorization server behind it).
164
165
  - `FLAIR_MCP_ISSUER=https://your-public-origin` (or `FLAIR_PUBLIC_URL`).
166
+ - `OAUTH_GITHUB_CLIENT_ID`, `OAUTH_GITHUB_CLIENT_SECRET` and
167
+ `OAUTH_GITHUB_REDIRECT_URI=https://your-public-origin/oauth` — staged by
168
+ `flair mcp enable` using `--issuer` (default: `--instance`).
165
169
  - `FLAIR_MCP_JIT_PROVISION=1` — ONLY if you want unknown subjects
166
170
  auto-provisioned (default OFF; pre-provision Agent+Credential otherwise).
167
171
 
168
172
  3. **Restart flair.** `/mcp` mounts, OAuth-guarded.
169
173
 
174
+ 4. **Upgrading an instance that still holds the old staged value.** When the
175
+ component loads `FLAIR_MCP_OAUTH=1`, its MCP AS is disabled. Correct the value without re-running IdP intake
176
+ or changing the identity mapping:
177
+
178
+ `--admin-pass <target-admin-password>` is required.
179
+
180
+ ```bash
181
+ flair mcp enable --instance https://your-public-origin --refresh-flag --admin-pass <target-admin-password>
182
+ ```
183
+
184
+ It ATTEMPTS an encrypted
185
+ `FLAIR_MCP_OAUTH=true` push: it probes for a usable public key, attempts the update,
186
+ and checks the secret row's `processEnv` marker before restart and discovery
187
+ checks: the target's own discovery document must advertise that issuer with
188
+ the MCP token endpoint, and
189
+ the public document read at that issuer must match the same normalized issuer and its token
190
+ endpoint. When the update could not be pushed or confirmed — a failed capability
191
+ probe, a local encryption failure, a refused or unconfirmed push, or
192
+ a push whose read-back could not confirm storage with `processEnv=true` — it attempts a 0600
193
+ one-var fallback file. Refresh uses a separate default filename; an explicit
194
+ `--secrets-path` can select `mcp enable`'s path. An occupied explicit path
195
+ is refused before probing; an occupied default path is refused when the fallback is
196
+ needed — in both cases by name rather than truncated (the writer opens
197
+ exclusively). These fallback outcomes exit non-zero.
198
+
170
199
  ## Sherlock's 4 requirements — how they are met
171
200
 
172
201
  1. **Token lifetime.** `mcp.accessTokenTtl: 900` (5–15 min) in the AS config +
@@ -56,7 +56,7 @@ Then set an admin password in Fabric Studio (Cluster Settings → Admin). `flair
56
56
 
57
57
  `flair agent add` takes a positional id and `--target`. There is no `--remote` flag on this command (`--remote` belongs to `flair init`).
58
58
 
59
- On Fabric, ops lives on the **same hostname at port 9925**, not the CLI's default "data port − 1" derivation (that would be `:442`, where nothing answers). Pass `--ops-target` explicitly: <!-- docs-freshness-allow: Fabric ops API port, not legacy data port -->
59
+ For portless HTTPS, the CLI derives the ops endpoint at `:9925`; `--ops-target` overrides it. <!-- docs-freshness-allow: Fabric ops API port -->
60
60
 
61
61
  ```bash
62
62
  export FLAIR_URL=https://<cluster>.<org>.harperfabric.com
@@ -64,7 +64,7 @@ export FLAIR_URL=https://<cluster>.<org>.harperfabric.com
64
64
  # Keep the Fabric admin password in an owner-only file; the CLI reads it in-process.
65
65
  printf '%s\n' '<fabric-admin-password>' > ~/.flair/fabric-admin-pass && chmod 600 ~/.flair/fabric-admin-pass
66
66
 
67
- # Fabric ops is :9925 on the same host, not derived :442. docs-freshness-allow: Fabric ops API
67
+ # Operations endpoint override. docs-freshness-allow: Fabric ops API
68
68
  flair agent add mybot --target "$FLAIR_URL" --ops-target https://<cluster>.<org>.harperfabric.com:9925 --admin-pass-file ~/.flair/fabric-admin-pass
69
69
  ```
70
70
 
@@ -49,7 +49,7 @@ First run does six things:
49
49
  5. Wires every MCP client it detects — Claude Code, Cursor, Codex CLI, Gemini CLI — to `npx -y @tpsdev-ai/flair-mcp`, then smoke-tests it. `--no-mcp` skips this.
50
50
  6. Opens a short **soul wizard** so your agent knows who it is.
51
51
 
52
- It also generates a Harper admin password and writes it to `~/.flair/admin-pass` (mode 0600). The CLI prints that **path**, never the value — read the file when a command needs the password, and prefer `--admin-pass-file ~/.flair/admin-pass` over pasting it into a command line.
52
+ It also saves the supplied or generated Harper admin password to `~/.flair/admin-pass` (mode 0600). Read the file when a command needs the password, and prefer `--admin-pass-file ~/.flair/admin-pass` over pasting it into a command line.
53
53
 
54
54
  The soul wizard offers a few shapes:
55
55
 
@@ -137,6 +137,14 @@ You didn't ask for that, and it isn't a setting you have to remember. Flair deri
137
137
  | `permanent`, `persistent` | `shared` — a fact or decision worth keeping is worth the team being able to find |
138
138
  | `standard`, `ephemeral` — including a bare write with no `--durability` | `private` — working context and scratch state belong to the agent that produced them |
139
139
 
140
+ Retention, decay and bootstrap ordering by tier:
141
+
142
+ - permanent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it); it never decays; bootstrap considers the bootstrapping agent's own permanent memories before recent rows, subject to scope, expiry/closure and the token budget.
143
+ - persistent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it).
144
+ - standard — routine maintenance archives it once its validTo passes or, as a session note, after 30 days.
145
+ - ephemeral — routine maintenance reaps it once its TTL (24h by default) passes.
146
+ - No tier adds a flush, fsync, backup or replica acknowledgement: an explicit delete (owner or admin) or a store failure can end any of them.
147
+
140
148
  So sharing is a deliberate act, and it takes one flag:
141
149
 
142
150
  ```bash
package/docs/releasing.md CHANGED
@@ -30,10 +30,10 @@ There is no "fix the stage in place" — you reject it and re-cut the next patch
30
30
  latest moves
31
31
  ```
32
32
 
33
- The `vX.Y.Z` tag triggers the release. This replaces the old "run
34
- `release.sh --publish` from a laptop logged into npm" flow. Nothing publishes without
35
- a human 2FA approval, and every package ships with a provenance attestation (public
36
- repo → verifiable build origin).
33
+ One `vX.Y.Z` tag starts npm staging and the `adk-flair` PyPI workflow.
34
+ PyPI requires the matching `packages/adk-flair/pyproject.toml` version and approval
35
+ in the `adk-flair-publish` environment. `adk-flair-vX.Y.Z` remains available for
36
+ Python-only releases; `workflow_dispatch` remains the manual fallback.
37
37
 
38
38
  ## Cutting a release
39
39
 
@@ -100,8 +100,8 @@ git tag v0.11.0 && git push origin v0.11.0
100
100
  > When the release commit's tree carries
101
101
  > `packages/adk-flair/pyproject.toml` whose `[project].version` equals the version
102
102
  > being tagged, the auto-tagger ALSO creates `adk-flair-v<version>` from the same
103
- > commit — so the PyPI publish run then needs only the environment gate its owner
104
- > keeps or drops (no hand-pushed `adk-flair-v` tag).
103
+ > commit. PyPI runs serialize per version, upload missing artifacts after the guards pass,
104
+ > and verify both filenames and SHA256 digests; lookup errors fail the run.
105
105
  >
106
106
  > The project version is read with Python's `tomllib` — the SAME reader
107
107
  > `.github/workflows/adk-flair-publish.yml` decides with — by handing the file to
@@ -386,6 +386,12 @@ review. Because the release is triggered by a tag push, its deployment policy mu
386
386
  **`v*` tags** (Settings → Environments → `release` → Deployment branches and tags →
387
387
  Selected branches and tags → add tag rule `v*`).
388
388
 
389
+ ### GitHub `adk-flair-publish` environment
390
+
391
+ Repository admin: add the tag rule `v*` under Settings → Environments →
392
+ `adk-flair-publish` → Deployment branches and tags → Selected branches and tags.
393
+ Keep `adk-flair-v*` and the required reviewer. No tag-creation ruleset change is needed.
394
+
389
395
  ### Required status checks (ruleset)
390
396
 
391
397
  Add **`First-publish preflight`** to the main branch ruleset's required status