@tpsdev-ai/flair 0.62.0 → 0.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/README.md +14 -13
  2. package/SECURITY.md +73 -43
  3. package/config.yaml +11 -11
  4. package/dist/bridges/runtime/execute.js +1 -0
  5. package/dist/bridges/runtime/import-runner.js +4 -0
  6. package/dist/bridges/types.js +1 -0
  7. package/dist/build-info.json +3 -3
  8. package/dist/cli.js +309 -205
  9. package/dist/commands/agent.js +325 -137
  10. package/dist/commands/attention.js +2 -0
  11. package/dist/commands/backup-approval.js +218 -0
  12. package/dist/commands/backup.js +37 -33
  13. package/dist/commands/bootstrap.js +5 -1
  14. package/dist/commands/bridge.js +10 -0
  15. package/dist/commands/deploy.js +37 -7
  16. package/dist/commands/doctor.js +206 -42
  17. package/dist/commands/export.js +144 -15
  18. package/dist/commands/federation.js +653 -68
  19. package/dist/commands/grant.js +5 -6
  20. package/dist/commands/help.js +25 -0
  21. package/dist/commands/idp.js +14 -19
  22. package/dist/commands/import.js +167 -34
  23. package/dist/commands/init.js +380 -164
  24. package/dist/commands/integrity.js +5 -6
  25. package/dist/commands/keys.js +12 -8
  26. package/dist/commands/mcp.js +157 -79
  27. package/dist/commands/memory.js +38 -17
  28. package/dist/commands/migrate-harness-memory.js +9 -3
  29. package/dist/commands/orgevent.js +5 -10
  30. package/dist/commands/principal.js +32 -39
  31. package/dist/commands/quality.js +26 -3
  32. package/dist/commands/reembed.js +468 -111
  33. package/dist/commands/rem.js +484 -65
  34. package/dist/commands/restore.js +352 -44
  35. package/dist/commands/search.js +2 -0
  36. package/dist/commands/service.js +109 -2
  37. package/dist/commands/soul.js +0 -6
  38. package/dist/commands/status.js +165 -124
  39. package/dist/commands/test.js +4 -1
  40. package/dist/commands/upgrade.js +53 -22
  41. package/dist/commands/workspace.js +7 -8
  42. package/dist/deploy.js +59 -3
  43. package/dist/doctor-client.js +9 -25
  44. package/dist/fabric-upgrade.js +12 -2
  45. package/dist/federation/presence-send.js +139 -0
  46. package/dist/federation/scheduler.js +148 -12
  47. package/dist/federation-verify.js +269 -177
  48. package/dist/install/clients.js +171 -35
  49. package/dist/keystore.js +77 -10
  50. package/dist/lib/agent-id-rule.js +44 -2
  51. package/dist/lib/agent-key-file.js +509 -0
  52. package/dist/lib/agent-rotation-lock.js +249 -0
  53. package/dist/lib/atomic-write.js +3 -3
  54. package/dist/lib/auth-resolve.js +1040 -64
  55. package/dist/lib/backup-approval-store.js +612 -0
  56. package/dist/lib/backup-artifact.js +343 -0
  57. package/dist/lib/config-critical-section.js +212 -25
  58. package/dist/lib/connect-phase.js +33 -0
  59. package/dist/lib/daemon-liveness.js +2 -1
  60. package/dist/lib/federation-pair-access.js +4 -0
  61. package/dist/lib/federation-retry-queue.js +283 -0
  62. package/dist/lib/federation-retry-row.js +101 -0
  63. package/dist/lib/instruction-event-contract.js +17 -0
  64. package/dist/lib/instruction-event-doctor.js +102 -0
  65. package/dist/lib/key-dir.js +203 -0
  66. package/dist/lib/launchd-management.js +21 -6
  67. package/dist/lib/local-instance-pair.js +8 -1
  68. package/dist/lib/mcp-enable.js +14 -15
  69. package/dist/lib/memory-attributes.js +2 -0
  70. package/dist/lib/memory-provider-timeout.js +33 -0
  71. package/dist/lib/mqtt-config.js +132 -0
  72. package/dist/lib/mqtt-listener-doctor.js +104 -0
  73. package/dist/lib/node-alias-path.js +50 -2
  74. package/dist/lib/open-live-row.js +20 -0
  75. package/dist/lib/ops-url.js +52 -0
  76. package/dist/lib/promotion-content-hash.js +20 -0
  77. package/dist/lib/remote-admin-pass.js +157 -0
  78. package/dist/lib/restore-archive.js +760 -0
  79. package/dist/lib/restore-verify.js +1 -1
  80. package/dist/lib/scheduler-platform.js +13 -0
  81. package/dist/lib/service-repoint.js +13 -4
  82. package/dist/lib/skill-assignment-preflight.js +159 -0
  83. package/dist/lib/skill-seed.js +125 -10
  84. package/dist/lib/skill-tombstone-doctor.js +133 -0
  85. package/dist/lib/soul-scope-fields.js +26 -0
  86. package/dist/lib/terminal-text.js +32 -0
  87. package/dist/lib/uninstall-purge.js +266 -11
  88. package/dist/lib/upgrade-prior-liveness.js +2 -1
  89. package/dist/mcp-client-assertion.js +7 -14
  90. package/dist/memory-id-checkpoint.js +28 -7
  91. package/dist/mqtt-off-deploy.js +550 -0
  92. package/dist/rem/promote-policy.js +3 -3
  93. package/dist/rem/restore.js +302 -26
  94. package/dist/rem/runner.js +220 -58
  95. package/dist/rem/scheduler.js +21 -4
  96. package/dist/resources/A2AAdapter.js +131 -178
  97. package/dist/resources/AdminMemory.js +2 -0
  98. package/dist/resources/AdminMemoryCandidates.js +116 -0
  99. package/dist/resources/Agent.js +155 -45
  100. package/dist/resources/AgentCard.js +4 -0
  101. package/dist/resources/AgentKeyRegister.js +56 -22
  102. package/dist/resources/AgentReadPosition.js +7 -0
  103. package/dist/resources/AgentSeed.js +232 -107
  104. package/dist/resources/AutoPromoteCandidates.js +413 -84
  105. package/dist/resources/Credential.js +6 -8
  106. package/dist/resources/Federation.js +219 -57
  107. package/dist/resources/FederationRetry.js +4 -4
  108. package/dist/resources/InstructionVersion.js +1 -1
  109. package/dist/resources/MCPClientMetadata.js +6 -3
  110. package/dist/resources/Memory.js +1348 -271
  111. package/dist/resources/MemoryArchive.js +149 -64
  112. package/dist/resources/MemoryBootstrap.js +12 -22
  113. package/dist/resources/MemoryCandidate.js +16 -2
  114. package/dist/resources/MemoryConsolidate.js +2 -2
  115. package/dist/resources/MemoryFeed.js +360 -147
  116. package/dist/resources/MemoryMaintenance.js +290 -72
  117. package/dist/resources/MemoryPurge.js +138 -22
  118. package/dist/resources/MemoryReflect.js +68 -14
  119. package/dist/resources/MemoryReindex.js +91 -13
  120. package/dist/resources/Message.js +11 -2
  121. package/dist/resources/OAuth.js +156 -39
  122. package/dist/resources/OAuthClient.js +1 -1
  123. package/dist/resources/OrgEvent.js +292 -29
  124. package/dist/resources/OrgEventCatchup.js +7 -0
  125. package/dist/resources/OrgEventMaintenance.js +48 -10
  126. package/dist/resources/PairingToken.js +1 -1
  127. package/dist/resources/Presence.js +31 -11
  128. package/dist/resources/PromoteMemoryCandidate.js +8 -2
  129. package/dist/resources/RecordUsage.js +2 -4
  130. package/dist/resources/Soul.js +2 -0
  131. package/dist/resources/SoulFeed.js +2 -1
  132. package/dist/resources/WorkspaceLatest.js +4 -0
  133. package/dist/resources/XAA.js +36 -10
  134. package/dist/resources/a2a-stream.js +313 -0
  135. package/dist/resources/a2a-url.js +4 -5
  136. package/dist/resources/agent-admin.js +10 -1
  137. package/dist/resources/agent-auth.js +98 -68
  138. package/dist/resources/agent-read-position-lib.js +4 -1
  139. package/dist/resources/agent-status-guard.js +9 -7
  140. package/dist/resources/auth-middleware.js +166 -42
  141. package/dist/resources/authority-field-guard.js +9 -11
  142. package/dist/resources/auto-promote-lib.js +8 -5
  143. package/dist/resources/basic-auth-header.js +21 -0
  144. package/dist/resources/bm25-index-service.js +4 -5
  145. package/dist/resources/dedup-cluster.js +6 -1
  146. package/dist/resources/embeddings-provider.js +25 -0
  147. package/dist/resources/federation-classify.js +89 -0
  148. package/dist/resources/federation-retry-lib.js +6 -81
  149. package/dist/resources/health.js +75 -19
  150. package/dist/resources/host-pointer/registry.js +29 -0
  151. package/dist/resources/host-pointer-adapter.js +1 -0
  152. package/dist/resources/in-process-api.js +74 -11
  153. package/dist/resources/in-process.js +24 -22
  154. package/dist/resources/instruction-version-record.js +251 -7
  155. package/dist/resources/internal-authority.js +13 -0
  156. package/dist/resources/mcp-client-metadata-fields.js +4 -0
  157. package/dist/resources/mcp-handler.js +146 -13
  158. package/dist/resources/mcp-oauth-flag.js +12 -14
  159. package/dist/resources/mcp-oauth.js +446 -53
  160. package/dist/resources/mcp-tool-scopes.js +69 -0
  161. package/dist/resources/mcp-tools.js +70 -22
  162. package/dist/resources/memory-declared-attributes.js +1 -0
  163. package/dist/resources/memory-embed-hash.js +56 -0
  164. package/dist/resources/memory-host-source.js +5 -2
  165. package/dist/resources/memory-reflect-lib.js +1 -1
  166. package/dist/resources/memory-write-lock.js +202 -23
  167. package/dist/resources/memory-write-response.js +1 -1
  168. package/dist/resources/memory-write-transaction.js +243 -0
  169. package/dist/resources/migration-boot.js +17 -12
  170. package/dist/resources/migrations/boot-progress.js +25 -0
  171. package/dist/resources/migrations/data-dir.js +16 -3
  172. package/dist/resources/migrations/dir-safety.js +60 -2
  173. package/dist/resources/migrations/embedding-stamp.js +315 -49
  174. package/dist/resources/migrations/graph-heal.js +9 -2
  175. package/dist/resources/migrations/ledger.js +5 -2
  176. package/dist/resources/migrations/lock.js +867 -80
  177. package/dist/resources/migrations/progress.js +71 -10
  178. package/dist/resources/migrations/runner.js +212 -18
  179. package/dist/resources/migrations/state.js +36 -1
  180. package/dist/resources/migrations/status.js +2 -13
  181. package/dist/resources/migrations/synthetic-test-migration.js +78 -12
  182. package/dist/resources/migrations/types.js +26 -1
  183. package/dist/resources/migrations/visibility-backfill.js +111 -70
  184. package/dist/resources/oauth-discovery.js +0 -5
  185. package/dist/resources/object-body-guard.js +12 -5
  186. package/dist/resources/org-event-reserved.js +92 -0
  187. package/dist/resources/org-event-write-fault.js +19 -0
  188. package/dist/resources/owner-field-guard.js +1 -1
  189. package/dist/resources/owner-scoped-write-policy.js +65 -21
  190. package/dist/resources/owner-scoped-writes.js +37 -6
  191. package/dist/resources/path-id-rewrite.js +76 -0
  192. package/dist/resources/presence-internal.js +5 -5
  193. package/dist/resources/promotion-binding.js +43 -0
  194. package/dist/resources/promotion-stamp.js +124 -33
  195. package/dist/resources/protocol-context.js +189 -0
  196. package/dist/resources/record-type-kit.js +2 -4
  197. package/dist/resources/request-target.js +28 -1
  198. package/dist/resources/request-transaction.js +11 -1
  199. package/dist/resources/seed-reservation.js +1 -2
  200. package/dist/resources/semantic-retrieval-core.js +7 -6
  201. package/dist/resources/server-row-validation.js +71 -0
  202. package/dist/resources/skill-manifest.js +4 -3
  203. package/dist/resources/skill-version-write.js +400 -27
  204. package/dist/resources/skill-write-fault.js +6 -3
  205. package/dist/resources/skill-write-policy.js +2 -1
  206. package/dist/resources/soul-write-policy.js +26 -7
  207. package/dist/resources/table-helpers.js +1 -1
  208. package/dist/resources/table-subscription-policy.js +518 -85
  209. package/dist/resources/table-subscriptions.js +20 -7
  210. package/dist/resources/txn-pause-point.js +122 -5
  211. package/dist/resources/usage-recording.js +54 -46
  212. package/dist/resources/write-back.js +176 -11
  213. package/dist/resources/write-journal-context.js +5 -0
  214. package/dist/resources/write-journal.js +289 -0
  215. package/dist/src/keystore.js +77 -10
  216. package/dist/src/lib/agent-id-rule.js +44 -2
  217. package/dist/src/lib/atomic-write.js +3 -3
  218. package/dist/src/lib/federation-retry-row.js +101 -0
  219. package/dist/src/lib/instruction-event-contract.js +17 -0
  220. package/dist/src/lib/key-dir.js +203 -0
  221. package/dist/src/lib/memory-attributes.js +2 -0
  222. package/dist/src/lib/open-live-row.js +20 -0
  223. package/dist/src/lib/scheduler-platform.js +13 -0
  224. package/dist/src/lib/soul-scope-fields.js +26 -0
  225. package/dist/src/rem/promote-policy.js +3 -3
  226. package/dist/src/rem/scheduler.js +21 -4
  227. package/docs/access-control.md +39 -21
  228. package/docs/api-reference.md +161 -52
  229. package/docs/auth.md +69 -38
  230. package/docs/claude-code.md +3 -3
  231. package/docs/deploying-on-fabric.md +118 -2
  232. package/docs/deployment.md +17 -0
  233. package/docs/embedding-in-a-harper-app.md +23 -21
  234. package/docs/entity-vocabulary.md +7 -11
  235. package/docs/federation.md +29 -2
  236. package/docs/hosted-on-fabric.md +1 -1
  237. package/docs/integrations.md +11 -11
  238. package/docs/mcp-clients.md +7 -5
  239. package/docs/notes/mcp-agent-auth-consumer.md +4 -9
  240. package/docs/notes/mcp-oauth-model2.md +6 -6
  241. package/docs/openclaw.md +1 -1
  242. package/docs/quickstart-fabric.md +2 -2
  243. package/docs/quickstart.md +3 -3
  244. package/docs/releasing.md +13 -13
  245. package/docs/rem.md +24 -3
  246. package/docs/secrets-and-keys.md +9 -14
  247. package/docs/standalone-local.md +29 -2
  248. package/docs/supply-chain-policy.md +28 -20
  249. package/docs/the-team.md +2 -2
  250. package/docs/upgrade.md +29 -5
  251. package/package.json +18 -11
  252. package/schemas/agent.graphql +3 -3
  253. package/schemas/federation.graphql +10 -7
  254. package/schemas/memory.graphql +7 -2
  255. package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
  256. package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
  257. package/dist/resources/soul-adk-guard.js +0 -68
package/README.md CHANGED
@@ -166,7 +166,7 @@ Embeddings are generated in-process by [nomic-embed-text](https://huggingface.co
166
166
 
167
167
  Requests are signed as `agentId:timestamp:nonce:METHOD:/path` and verified against the agent's registered public key, with a 30-second replay window and nonce deduplication.
168
168
 
169
- See **[DESIGN.md](DESIGN.md)** for the invariants behind the three primitives — why they're shaped the way they are.
169
+ See **[DESIGN.md](https://github.com/tpsdev-ai/flair/blob/main/DESIGN.md)** for the invariants behind the three primitives — why they're shaped the way they are.
170
170
 
171
171
  ## Features
172
172
 
@@ -187,7 +187,7 @@ See **[DESIGN.md](DESIGN.md)** for the invariants behind the three primitives
187
187
  | **OAuth 2.1 server** | PKCE, dynamic client registration, standards-compliant token endpoint. Delegate auth to Flair without a separate IdP. [docs/auth.md](docs/auth.md) |
188
188
  | **XAA** | Bind agent identities to Google Workspace, Azure AD or Okta accounts. |
189
189
  | **Web admin** | Server-rendered UI for principals, connectors, IdPs and instance config. No separate dashboard service. |
190
- | **Benchmarks** | [`flair-bench`](packages/flair-bench/README.md) scores candidate embedding models against the same recall corpus Flair's CI gates on. Runs standalone — no Flair install, no server. |
190
+ | **Benchmarks** | [`flair-bench`](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-bench/README.md) scores candidate embedding models against the same recall corpus Flair's CI gates on. Runs standalone — no Flair install, no server. |
191
191
 
192
192
  Trust-graded recall reaches the authenticated HTTP API and the built-in `/mcp` tools today — the latter being off by default, see [One install, one binary](#one-install-one-binary). CLI, `@tpsdev-ai/flair-client` and `flair-mcp` exposure is a follow-up. REM needs a configured generative backend (Ollama, OpenAI, Anthropic, …) — without one, `flair rem rapid` fails with `Reflection error: No generative backend configured`.
193
193
 
@@ -227,7 +227,7 @@ Flair works with any agent runtime. Pick the path that fits yours — **[full ca
227
227
  }
228
228
  ```
229
229
 
230
- Then add to your `CLAUDE.md`:
230
+ Then add to your `CLAUDE.md`: <!-- docs-freshness-allow: names a file in the reader's project -->
231
231
 
232
232
  At the start of every session, run mcp__flair__bootstrap before responding.
233
233
 
@@ -243,7 +243,7 @@ Per-CLI config snippets (Gemini CLI's `~/.gemini/settings.json`, Codex CLI's `~/
243
243
  openclaw plugins install @tpsdev-ai/openclaw-flair
244
244
  ```
245
245
 
246
- Auto-detects the agent identity, provides `memory_store` / `memory_search` / `memory_get`, and provides bootstrap context from `before_prompt_build` (requires host opt-in). See the [plugin README](packages/openclaw-flair/README.md).
246
+ Auto-detects the agent identity, provides `memory_store` / `memory_search` / `memory_get`, and provides bootstrap context from `before_prompt_build` (requires host opt-in). See the [plugin README](https://github.com/tpsdev-ai/flair/blob/main/packages/openclaw-flair/README.md).
247
247
 
248
248
  ### n8n
249
249
 
@@ -289,7 +289,7 @@ const ctx = await flair.bootstrap({ maxTokens: 4000 })
289
289
  await flair.soul.get('role')
290
290
  ```
291
291
 
292
- No Harper, no embeddings — just HTTP and auth. Full API in the [client README](packages/flair-client/README.md).
292
+ No Harper, no embeddings — just HTTP and auth. Full API in the [client README](https://github.com/tpsdev-ai/flair/blob/main/packages/flair-client/README.md).
293
293
 
294
294
  ### HTTP API (any language)
295
295
 
@@ -311,20 +311,21 @@ Sign `agentId:timestamp:nonce:METHOD:/path` with the agent's private key. Protoc
311
311
 
312
312
  The second front door, and the one to take if your code already runs on Harper.
313
313
 
314
- Flair *is* a Harper component. Deploy it into the instance your application already runs in and call its resources directly — `await h.post({ agentId, content })` is a **method call**, not a network call. No second service to operate, no HTTP round trip, and no key to distribute: a caller in the same process is already inside the trust boundary and names the agent it is acting as, per call.
314
+ Flair *is* a Harper component. Deploy it into the instance your application already runs in and call its facade directly — `await agent.memory.write(...)` is a **method call**, not a network call. No second service to operate, no HTTP round trip, and no key to distribute: a caller in the same process is already inside the trust boundary and names the agent it is acting as, per call.
315
315
 
316
316
  Adding it takes nothing away. The HTTP surface keeps serving MCP clients and remote agents exactly as before.
317
317
 
318
318
  ```javascript
319
319
  import { server } from "harper";
320
- import { agentContext, collectionResource } from "@tpsdev-ai/flair/dist/resources/in-process.js";
320
+ import { Flair } from "@tpsdev-ai/flair";
321
321
 
322
- // The RESOURCE — auth, read-scoping, visibility, embedding.
323
- // Registry keys carry no leading slash: get("Memory"), never get("/Memory").
324
- const Memory = server.resources.get("Memory").Resource;
322
+ const flair = new Flair(server);
323
+ const agent = flair.as("mybot");
325
324
 
326
- const h = await collectionResource(Memory, agentContext("mybot"));
327
- await h.post({ agentId: "mybot", content: "...", durability: "standard" });
325
+ await agent.memory.write("deploy runs at 0200 UTC", { durability: "standard" });
326
+ const hits = await agent.recall("deploy schedule", { limit: 5 }); // an array of hits
327
+ const record = await agent.memory.get(hits[0].id); // the stored row, or null
328
+ const recent = await agent.memory.search({ limit: 10 }); // an array of at most 10 rows
328
329
  ```
329
330
 
330
331
  `databases.flair.Memory` is the **table** (raw storage); the exported `Memory` class is the **resource**, where auth, read-scoping, visibility and embedding live. `new Memory(...)` is not a substitute for `collectionResource` — a create needs a collection-bound instance only Harper can produce. Both helpers refuse a missing agent id rather than defaulting it, because a resource invoked with no context resolves to Flair's trusted `internal` verdict and runs unfiltered across every agent.
@@ -415,7 +416,7 @@ bun run build # compile TypeScript → dist/
415
416
  bun test # unit + integration tests
416
417
  ```
417
418
 
418
- Integration tests spin up a real Harper instance on a random port and tear it down afterwards — no mocks for the database layer. Every commit runs unit tests, integration tests, type check, dependency audit, Semgrep and CodeQL SAST, and a from-scratch Docker validation. See [CONTRIBUTING.md](CONTRIBUTING.md).
419
+ Integration tests spin up a real Harper instance on a random port and tear it down afterwards — no mocks for the database layer. CI for pull requests to main and pushes to main runs unit and integration tests, type checks, dependency audit, Semgrep and CodeQL SAST. See [CONTRIBUTING.md](https://github.com/tpsdev-ai/flair/blob/main/CONTRIBUTING.md).
419
420
 
420
421
  ## Status
421
422
 
package/SECURITY.md CHANGED
@@ -4,8 +4,8 @@
4
4
 
5
5
  Flair uses cryptographic identity (Ed25519) for agent authentication. Within
6
6
  an org, memory reads are open — agents see each other's non-private memories —
7
- while writes are isolated per agent and private memories stay strictly
8
- owner-only. The hard access boundary is the federation edge (cross-instance).
7
+ while writes are isolated per agent and private memories restrict non-admin
8
+ reads to their owner. The hard access boundary is the federation edge (cross-instance).
9
9
 
10
10
  ## Authentication
11
11
 
@@ -17,7 +17,7 @@ Every request includes an `Authorization` header:
17
17
  TPS-Ed25519 <agentId>:<timestamp>:<nonce>:<signature>
18
18
  ```
19
19
 
20
- The signature covers `agentId:timestamp:nonce:METHOD:/path` using the
20
+ The signature covers `agentId:timestamp:nonce:METHOD:/path?query` using the
21
21
  agent's Ed25519 private key. The server verifies against the agent's
22
22
  registered public key.
23
23
 
@@ -49,11 +49,14 @@ requests to it require admin Basic auth: Flair ships with
49
49
  `authorizeLocal: false`, so an unauthenticated loopback request is
50
50
  rejected (`401`) instead of being auto-elevated to super_user. The same
51
51
  API is also reachable over a Unix **domain socket**
52
- (`~/.flair/data/operations-server`, owner-write-only), which Harper
52
+ (`~/.flair/data/operations-server`), which Harper
53
53
  treats as an inherent local-admin channel — a request over the socket is
54
54
  authorized as super_user **without** credentials. This is by design (the
55
- admin-password rotation flow relies on it) and is constrained to the box
56
- owner; see Threats NOT Mitigated below.
55
+ admin-password rotation flow relies on it). CLI `init`, `start`, `restart` and
56
+ launchd repair attempt parent/socket modes `0700`/`0600` (or `0750`/`0660` with
57
+ `FLAIR_SOCKET_GROUP`, changing the socket's group); unattended macOS launchd
58
+ spawns use `Umask 077` (`0700` socket, since Darwin does not retain `0600` on
59
+ Unix sockets) without reapplying the CLI posture.
57
60
 
58
61
  ## Data Scoping
59
62
 
@@ -63,21 +66,19 @@ Reads are open **within an org**; writes are isolated per agent. Enforced at
63
66
  the database layer (Harper resource `search()` override via a single
64
67
  centralized read-scope rule), not application logic:
65
68
 
66
- - `GET /Memory/` — returns the authenticated agent's own memories (any
67
- visibility) plus every **non-private** memory in the org
68
- - `POST /MemorySearch` — same read scope: own memories plus all non-private
69
+ - `GET /Memory/` — applies the owner/visibility base scope and omits retained
70
+ closed skill payloads that fail the non-admin reader's current-authority check
71
+ - `POST /SemanticSearch` — applies the owner/visibility read scope
69
72
  - `POST /Memory` — writes are attributed to the authenticated agent; an
70
73
  agent cannot write as another (write isolation)
71
74
 
72
- **Private memories are strictly owner-only** — a memory written with
73
- `visibility: private` is returned only to its author, never to another agent.
75
+ Non-admin memory reads restrict `visibility: private` to its author.
74
76
 
75
- **A write that does not name a visibility gets one anyway.** The server derives
76
- it from the memory's durability: `permanent`/`persistent` → `shared`,
77
- `standard`/`ephemeral` → `private`. Durability itself defaults to `standard`,
78
- so a write naming neither is stamped `private` and is owner-only. An explicit
79
- `visibility` on the write always overrides the rule, and the response to a
80
- create names the value the record actually landed on.
77
+ On `POST /Memory` and `PUT /Memory` creates, omitted visibility defaults by
78
+ durability: `permanent`/`persistent` → `shared`, `standard`/`ephemeral` → `private`.
79
+ Durability defaults to `standard`. Explicit visibility overrides this default;
80
+ ephemeral memories require `private`, and grant-authorized `supersedes` writes
81
+ keep the predecessor's visibility, including when visibility is omitted.
81
82
 
82
83
  ### Record Ownership on Writes
83
84
 
@@ -92,11 +93,14 @@ OrgEvent, WorkspaceState, Presence):
92
93
  non-empty path segments, no `.` in the decoded id), for which Harper resolves
93
94
  the same record id. Other addressed forms are left to the guard, which uses
94
95
  Harper's resolved id.
95
- - If reached, the guard checks a differing string or number body `id` on POST/PUT/PATCH
96
- first (`403 write_id_not_addressed`), then stored ownership (the same owner
97
- refusal), using Harper's resolved record id. An absent or matching body `id`
98
- passes the body-id check. OrgEvent and Memory bind an addressed POST's
99
- missing body `id` to the addressed id.
96
+ - If reached, the guard checks the body `id` on POST/PUT/PATCH first, then
97
+ stored ownership (the same owner refusal), using Harper's resolved record id.
98
+ An absent, null or matching body `id` passes the body-id check; a differing
99
+ string or number `id` gets `403 write_id_not_addressed`, and a present,
100
+ non-null `id` of any other type that is not the addressed key gets
101
+ `400 id_target_mismatch`. Each
102
+ object element of an array body is checked the same way. OrgEvent and Memory
103
+ bind an addressed POST's missing body `id` to the addressed id.
100
104
  - For a collection PUT, PATCH or DELETE, if reached, the table guard returns
101
105
  `403 forbidden: a non-admin write to <Table> must address one record by its id`;
102
106
  existing DELETE middleware may refuse earlier.
@@ -115,12 +119,17 @@ its own ownership rule.
115
119
  The guard exempts administrator and in-process calls. OrgEvent POST id
116
120
  selection also applies to administrator and in-process calls.
117
121
 
122
+ Credential records are owner-scoped by `principalId`: non-admin callers read and
123
+ modify only their own records, and administrators and trusted internal callers
124
+ are unscoped. Anonymous HTTP access is refused.
125
+
118
126
  ### Cross-Agent Access (within an org)
119
127
 
120
- Within an org, an agent reads every non-private memory directly — no grant
121
- required. This is deliberate: the goal is relevance (surface what's useful to
122
- the org) over secrecy. A writer keeps something private by marking it
123
- `visibility: private`, which keeps it strictly owner-only. The access boundary
128
+ Within an org, non-private memories pass the base read-scope check without a
129
+ grant; non-admin by-id and collection reads of retained closed skills
130
+ additionally require readable current authority. This is deliberate: the goal
131
+ is relevance (surface what's useful to the org) over secrecy. A writer keeps something private by marking it
132
+ `visibility: private`, which restricts non-admin reads to its author. The access boundary
124
133
  that stays hard is the **federation edge** (cross-instance / cross-org), not
125
134
  within-org reads.
126
135
 
@@ -134,9 +143,32 @@ are restricted to admin-only.
134
143
 
135
144
  ### Key Storage
136
145
 
137
- Private keys are stored at `~/.flair/keys/<agentId>.key` with `0600`
138
- permissions (owner read/write only). Legacy path `~/.tps/secrets/flair/`
139
- is supported with deprecation warnings.
146
+ Private keys at `~/.flair/keys/<agentId>.key` are created owner-only
147
+ (`0600`) from the first byte on POSIX by `flair agent add`, `flair init` (local
148
+ and remote agent provisioning), `flair principal add`, `flair import` and
149
+ `flair agent rotate-key` (which stages the replacement before it updates Flair
150
+ and renames it over the current key once Flair holds its public key). On
151
+ POSIX the keys directory is requested with mode `0700` (the umask may make it
152
+ narrower), and an owned directory with group or world bits is tightened to
153
+ `0700`; on the create and reuse paths an existing key with group or world
154
+ bits is refused with `chmod 600 <path>`, while rotation reports it. A successful
155
+ rotation replaces the file; a failed update leaves it. `flair doctor` warns
156
+ about an existing agent key file with group or world bits, and `flair status`
157
+ warns about it for a local target; both name the path, its mode and
158
+ `chmod 600 <path>`, and neither changes the file. The check covers the standard
159
+ `resolveKeyPath` locations: `$FLAIR_KEY_DIR/<agentId>.key` when that variable is
160
+ set, `~/.flair/keys/<agentId>.key`, and the legacy
161
+ `~/.tps/secrets/flair/<agentId>-priv.key`; explicit key paths (such as `--key`)
162
+ are outside this scan. A symlinked agent key is
163
+ reported as not checked. On Windows mode bits
164
+ do not establish owner-only.
165
+
166
+ `flair export --include-key` publishes its output through a `0600` temp file
167
+ renamed over the target, so an existing output file's wider mode does not apply
168
+ to the new contents. The keystore seed file is replaced the same way.
169
+ A generated passphrase is published at `0600` if its path is absent. When used
170
+ (`FLAIR_KEY_PASSPHRASE` unset), an existing generated passphrase file with group
171
+ or world bits is refused unchanged before reading, with `chmod 600 <path>`. On Windows the mode bits do not apply.
140
172
 
141
173
  ### Key Generation
142
174
 
@@ -146,8 +178,11 @@ runtime.
146
178
 
147
179
  ### Key Rotation
148
180
 
149
- `flair agent rotate-key <id>` generates a new key pair, updates the
150
- public key in Flair, and backs up the old key as `<agentId>.key.bak`.
181
+ `flair agent rotate-key <id>` generates a new key pair, stages the new private
182
+ key owner-only (`0600`) from creation on POSIX, updates the public key in
183
+ Flair, reads the row back to confirm the stored key, then renames the staged
184
+ key over the current one. The old key is backed up as a new
185
+ `<agentId>.key.bak.<UTC timestamp>`; an existing backup is left untouched.
151
186
 
152
187
  ## Threat Model
153
188
 
@@ -155,8 +190,8 @@ public key in Flair, and backs up the old key as `<agentId>.key.bak`.
155
190
 
156
191
  - **Agent impersonation:** Ed25519 signatures prevent one agent from
157
192
  acting as another without possessing the private key.
158
- - **Private-memory leakage:** memories marked `visibility: private` are
159
- strictly owner-only and never returned to another agent. Non-private
193
+ - **Private-memory leakage:** non-admin reads of `visibility: private` memories
194
+ are restricted to their author. Non-private
160
195
  memories are intentionally readable within the org (by design, not
161
196
  leakage); the cross-instance boundary is the federation edge.
162
197
  - **Write forgery:** writes are attributed to the authenticated agent —
@@ -164,8 +199,6 @@ public key in Flair, and backs up the old key as `<agentId>.key.bak`.
164
199
  - **Replay attacks:** 30-second window + nonce deduplication.
165
200
  - **Privilege escalation via SQL:** SQL and GraphQL endpoints blocked
166
201
  for non-admin agents.
167
- - **Admin token theft from filesystem:** Admin credentials are only in
168
- process environment, never on disk.
169
202
 
170
203
  ### Threats NOT Mitigated (Runtime Responsibility)
171
204
 
@@ -176,13 +209,10 @@ public key in Flair, and backs up the old key as `<agentId>.key.bak`.
176
209
  process could extract them.
177
210
  - **Network sniffing:** Flair uses HTTP by default. Use HTTPS in
178
211
  production or restrict to localhost.
179
- - **Same-OS-user ops-API socket access:** the operations-API domain
180
- socket (`operations-server`, owner-write-only) is an unauthenticated
181
- super_user channel by Harper design — any process running as the box
182
- owner can perform admin operations through it (the admin-password
183
- rotation flow uses this path). Owner-write permissions keep it
184
- unreachable by other OS users, co-tenants, and the network; isolate
185
- untrusted workloads to separate OS users.
212
+ - **Local ops-API socket access:** the operations-API domain socket
213
+ (`operations-server`) grants local admin access, restricted by the
214
+ directory and socket modes above. Isolate untrusted workloads to separate
215
+ OS users outside any configured `FLAIR_SOCKET_GROUP`.
186
216
 
187
217
  ## Recommendations
188
218
 
@@ -191,4 +221,4 @@ public key in Flair, and backs up the old key as `<agentId>.key.bak`.
191
221
  3. **Rotate keys** periodically with `flair agent rotate-key`
192
222
  4. **Back up** with `flair backup` — backup files contain memory content
193
223
  and should be treated as sensitive
194
- 5. **Monitor** with `flair status` — warns about key permission issues
224
+ 5. **Monitor** with `flair status`
package/config.yaml CHANGED
@@ -30,20 +30,20 @@ authentication:
30
30
  # (flair#1152). Requires @harperfast/oauth >= 2.5.0 (resolved-version
31
31
  # assertion + behavioral gate: test/integration/mcp-oauth-boot-safety.test.ts).
32
32
  #
33
- # ASYMMETRY (load-bearing, measured on oauth 2.5.0): the two readers of
34
- # this flag accept DIFFERENT vocabularies. The component's
35
- # coerceConfigBoolean accepts ONLY "true"/"false" and DELETES any other
36
- # string (unresolved placeholder, "1", "yes", garbage) so its disabled
37
- # default applies. flair's mcpOAuthEnabled() accepts 1/true/yes/on.
33
+ # ASYMMETRY (load-bearing, measured on @harperfast/oauth 2.9.0): the two
34
+ # readers of this flag accept DIFFERENT vocabularies. The component's
35
+ # coerceConfigBoolean trims and lowercases, mapping "true"/"false" to a
36
+ # boolean, and normalizeBooleanField deletes strings it cannot coerce
37
+ # (unresolved placeholder, "1", "yes", garbage), so its disabled default
38
+ # applies (dist/lib/config.js). flair's mcpOAuthEnabled() accepts
39
+ # 1/true/yes/on.
38
40
  #
39
- # Failure modes (oauth 2.5.0):
41
+ # Failure modes (oauth 2.9.0):
40
42
  # unset -> placeholder deleted -> both sides OFF, clean boot
41
- # true -> BOTH sides ON — the one working enable value
42
- # (`flair mcp enable` stages exactly this)
43
+ # true -> both flag readers accept this value
43
44
  # false -> both sides OFF
44
- # 1 / yes / on -> flair /mcp handler ON, component AS OFF ->
45
- # fail-closed broken-on: every /mcp request 401s,
46
- # no AS is advertised. Use "true" instead.
45
+ # 1 / yes / on -> flair's reader is ON, the component deletes the
46
+ # value (AS stays OFF); /mcp is not mounted.
47
47
  # garbage (maybe) -> deleted -> component OFF; flair strict -> OFF.
48
48
  # Inert: no /mcp handler, no data path (flair's own
49
49
  # discovery documents still serve, by design).
@@ -20,6 +20,7 @@ const FLAIR_RESERVED_FIELDS_SET = new Set([
20
20
  "retrievalCount",
21
21
  "lastRetrieved",
22
22
  "promotionStatus",
23
+ "promotionContentHash",
23
24
  "_safetyFlags",
24
25
  "createdBy",
25
26
  "updatedBy",
@@ -17,6 +17,7 @@ import { randomUUID } from "node:crypto";
17
17
  import { BridgeRuntimeError } from "../types.js";
18
18
  import { importFromYaml } from "./execute.js";
19
19
  import { endsWithContentSelectorSuffix } from "../../lib/memory-id-policy.js";
20
+ import { requireAgentId } from "../../lib/key-dir.js";
20
21
  const VALID_DURABILITY = new Set(["ephemeral", "standard", "persistent", "permanent"]);
21
22
  /**
22
23
  * Drive a YAML descriptor's `import` block all the way through to PUTs
@@ -48,6 +49,9 @@ export async function runImport(opts) {
48
49
  hint: `record ${total} has no agentId and no --agent default was provided. Pass --agent <id> on the import command, or have the descriptor map an agentId column.`,
49
50
  });
50
51
  }
52
+ // Refuse an invalid agent id before the caller resolves a key path or reads
53
+ // a key for this record.
54
+ requireAgentId(resolvedAgent);
51
55
  const durability = (m.durability && VALID_DURABILITY.has(m.durability))
52
56
  ? m.durability
53
57
  : "standard";
@@ -16,6 +16,7 @@ export const FLAIR_RESERVED_FIELDS = [
16
16
  "retrievalCount",
17
17
  "lastRetrieved",
18
18
  "promotionStatus",
19
+ "promotionContentHash",
19
20
  "_safetyFlags",
20
21
  "createdBy",
21
22
  "updatedBy",
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.62.0",
3
- "commit": "2461721a17f346ef922f9665a14e940e257415d1",
4
- "builtAt": "2026-10-17T20:48:39.747Z",
2
+ "version": "0.63.1",
3
+ "commit": "d2469c5dec55a9fc31b1a9b8644eb086c86cd40c",
4
+ "builtAt": "2026-11-29T07:21:07.327Z",
5
5
  "builder": "tsc"
6
6
  }