@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
package/docs/rem.md CHANGED
@@ -94,4 +94,12 @@ Anything ineligible (no scope tag, flagged content, already decided) is left pen
94
94
 
95
95
  Durability is owner-controlled, including `permanent`: owners may create, change, archive and delete their own memories at every tier. Administrators may delete any owner’s memory. The permanent tier controls retention and bootstrap priority; it does not prevent an explicit owner deletion.
96
96
 
97
+ What each tier actually guarantees:
98
+
99
+ - 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.
100
+ - persistent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it).
101
+ - standard — routine maintenance archives it once its validTo passes or, as a session note, after 30 days.
102
+ - ephemeral — routine maintenance reaps it once its TTL (24h by default) passes.
103
+ - 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.
104
+
97
105
  Soul is operator-authored identity, not a promotion target for learned candidates. `flair rem promote --to soul` is refused for stored candidate text even with operator credentials; promote learned claims to Memory instead.
@@ -14,11 +14,11 @@ Agents sign every request to Flair with this key. Flair refuses unsigned request
14
14
  **This is the only secret material Flair manages.** Lose the key file and the agent is locked out (`flair agent rotate-key <id>` to issue a new pair).
15
15
 
16
16
  ## Flair admin password (Harper instance)
17
- - If not provided via `--admin-pass`, `--admin-pass-file`, `FLAIR_ADMIN_PASS`, or `HDB_ADMIN_PASSWORD`, a random password is generated and written to `~/.flair/admin-pass` (mode `0o600`). The password is **not** printed to the console.
17
+ - Fresh local `flair init` writes the supplied or generated admin password to `~/.flair/admin-pass` (mode `0o600`).
18
18
  - The `--admin-pass-file <path>` option allows reading the password from a file (for pre-staged secrets).
19
19
  - The `--admin-pass <pass>` option is deprecated due to shell history exposure; use `--admin-pass-file` or environment variables instead. A warning is printed when this option is used.
20
20
  - Environment variables `FLAIR_ADMIN_PASS` and `HDB_ADMIN_PASSWORD` are also supported.
21
- - After the first start, Harper's persisted user hash is the source of truth. `HDB_ADMIN_PASSWORD` will not rotate it. If `~/.flair/admin-pass` is missing and the data dir already has a user, `flair init` refuses rather than writing a file that 401s. Recovery is exact: `flair init --admin-pass-file <path>` if you have the original, or `flair init --reset-admin-pass` to rotate through the operations socket and rewrite the file.
21
+ - After the first start, Harper's persisted user hash is the source of truth. `HDB_ADMIN_PASSWORD` will not rotate it. Without `--reset-admin-pass`, supplied credentials are refused when no instance is running and an admin-pass file or persisted admin user exists, except that `--skip-start` can reuse an identical securely read credential.
22
22
  ## What Flair does *not* own: API keys, tokens, third-party credentials
23
23
 
24
24
  Things that are NOT Flair's job:
@@ -144,6 +144,23 @@ Hermes uses `~/.hermes/.env` for provider API keys (managed by `hermes auth`). T
144
144
  - **Don't check it into git.** `.gitignore` should already exclude `~/.flair/keys/`; if you're ever tempted to share keys for "convenience," rotate first (`flair agent rotate-key <id>`).
145
145
  - **Backup separately**, encrypted. The `flair backup` command excludes private keys by default. Roll your own backup of `~/.flair/keys/` via age-encrypted archive if you want offsite recovery.
146
146
 
147
+ ## Key cleanup
148
+
149
+ `flair keys prune` classifies every `.key` file in the key directory and, with
150
+ `--apply`, moves prunable keys into `<keysDir>/.pruned/<date>/`; keys with
151
+ refused sidecars stay in place.
152
+ It never deletes a file itself. A move can still replace an entry that a
153
+ concurrent writer creates at the destination before the move lands: the selected
154
+ archive name, or, when a failed key move rolls its sidecar back, the sidecar's
155
+ original path.
156
+
157
+ - Agent signing keys whose seed parses are prunable when the agent is not
158
+ registered on the targeted instance, except node-shaped files without `.pub`.
159
+ - Node-shaped files (`flair_<hex8>.key` without `.pub`) stay report-only.
160
+ Minting attempts to record a sidecar; sidecar-write failure leaves them report-only.
161
+
162
+ Unreadable reference rows leave node-shaped files unidentified.
163
+
147
164
  ## What about a `flair secret` CLI?
148
165
 
149
166
  Considered, deferred. Flair could ship a thin wrapper around the OS keyring (`flair secret get/set/list`) — but the OS primitives already work and are universally trusted. Adding a Flair-shaped wrapper would mean we own the bug surface for marginal ergonomic gain. Better path: document the OS primitives well (this page) and stay focused on identity + memory.
@@ -45,6 +45,7 @@ flair init --agent mybot # name the agent (--agent-id also works)
45
45
  flair init --client claude-code # wire one specific MCP client
46
46
  flair init --no-mcp # instance + agent only, skip MCP wiring
47
47
  flair init --skip-smoke # skip the MCP smoke test
48
+ flair init --skip-start # do not start Harper; with --agent, defer registration
48
49
  flair init --port 8000 # use a non-default port
49
50
  ```
50
51
 
@@ -36,9 +36,19 @@ Document any addition here, in this section, alongside the package name. The doc
36
36
 
37
37
  Override per-run via `FLAIR_DEP_KEEP_CURRENT="pkg1,pkg2,@scope/pkg3"` env (additive — adds to the default allow-list, doesn't replace it).
38
38
 
39
+ #### 1b. Dated exemptions for security pins
40
+
41
+ A security patch can be newer than the bake window, and pinning it is the right move. The gate accepts an explicit, dated exemption in `.github/dep-age-allowlist.json`: one entry per checked exact-pinned `package` and `version` (in `dependencies`, `optionalDependencies` or `overrides`), with a GHSA-formatted id (`ghsa`), `added`, `expires` and a `reason`. Review verifies that the version fixes the advisory.
42
+
43
+ - An entry exempts an otherwise checked pin only while unexpired; `expires` is the first day it no longer applies.
44
+ - An **expired** entry fails the gate before any registry request; removing it lets an otherwise checked pin be age-checked. Re-read the `reason` before re-dating; removing the entry once the version has aged past the window is the normal outcome.
45
+ - A fresh checked pin with no matching entry fails; keep-current pins are skipped. A malformed entry also fails.
46
+
47
+ `FLAIR_DEP_MIN_AGE_DAYS` remains a threshold control: it moves the bar for every checked pin at once and leaves no record. A per-pin exemption belongs in this allowlist.
48
+
39
49
  ### 2. Exact-version pinning for production deps
40
50
 
41
- Some `dependencies` entries are exact-pinned (`harper@5.2.8`, `commander@14.0.3`, `jose@6.2.2`, `tweetnacl@1.0.3`), but others are range-spec'd (`harper-fabric-embeddings@^0.5.0`, `js-yaml@^4.3.2`, `semver@^7.8.5`, `tar@^7.5.22`). Most overrides use ranges (`^`/`~`), with one exact alias (`npm:empty-npm-package@1.0.0` for `react-native-fs`). The age gate (`scripts/check-dep-ages.mjs`, with the collection rule in `collectDeps` in `scripts/lib/check-dep-ages-collect.mjs`) checks npm publish age for external entries in both `dependencies` and `optionalDependencies` whose declared version starts with a digit (`/^\d/.test(version)`), excluding workspace-internal dependencies and the keep-current list (`harper`, `harper-fabric-embeddings`, `@harperfast/oauth`); its default threshold is seven days.
51
+ Some `dependencies` entries are exact-pinned (`harper@5.3.1`, `commander@14.0.3`, `jose@6.2.2`, `tweetnacl@1.0.3`), but others are range-spec'd (`harper-fabric-embeddings@^0.5.0`, `js-yaml@^4.3.2`, `semver@^7.8.5`, `tar@^7.5.22`). Overrides are mostly ranges (`^`/`~`). The age gate (`scripts/check-dep-ages.mjs`, with the collection rule in `collectDeps` in `scripts/lib/check-dep-ages-collect.mjs`) checks npm publish age for non-exempt external exact pins in `dependencies`, `optionalDependencies` and `overrides` — root and every workspace package.json. In `dependencies` and `optionalDependencies` a specifier is classified by the same version classifier the override grammar uses: an exact version is age-checked, a range such as `1.x` or `^1` is not; in `overrides`, nested rules included, it is an exact declaration, and an `npm:` alias is checked against its target. Workspace-internal dependencies, the keep-current list (`harper`, `harper-fabric-embeddings`, `@harperfast/oauth`) and exact pins with a matching unexpired exemption in `.github/dep-age-allowlist.json` (§1b) are exempt; the default threshold is seven days. The gate reads manifests, not the lockfile: an exact version is age-checked, a range is printed as not age-checked, and a refused dependency or override form fails the gate.
42
52
 
43
53
  - `peerDependencies` may use ranges: they state what the host project must provide. They are still installed, but an exact-pin check of our declaration does not describe what actually gets installed — the consumer resolves them from a range. This is the reason we do not include peers in the bake-time gate (not "never bundled into tarballs"): the gate checks versions we actually pull, and we don't pull a peer declaration at face value. Our workspace install records the required peers of `langgraph-flair`, `n8n-nodes-flair` and `openclaw-flair` in `bun.lock` like any other dependency (the frozen-lockfile install does not check a recorded peer against its declared range; flair#1936). Most `devDependencies` are exact-pinned for build reproducibility; a few are ranged (`@types/semver@^7.8.0`). They don't ship in our published tarballs.
44
54
  - **Flair declares no optional peers today**, and no `optionalDependencies` at the root; `packages/flair-bench/package.json` (line 38) declares some. If either is ever proposed as an install-weight fix, the mechanism has now been measured twice (`@harperfast/oauth` flair#750, `node-llama-cpp` flair#887) and the result is counter-intuitive enough to be worth stating: **only `peerDependencies` + `peerDependenciesMeta.optional` is skipped by a default install** (npm and bun alike). A plain `optionalDependencies` entry *is* still installed by default — "optional" there means "a failed install is non-fatal", not "skipped" — so it buys no install-weight reduction whatsoever. Exact-pinning an optional peer (rather than ranging it) is also legitimate where the consuming code path is version-sensitive, so that an operator who installs a different version gets told the version they have is not the version that was tested.
@@ -121,7 +131,7 @@ Fails any PR where a workspace package declares an internal `@tpsdev-ai/*` dep a
121
131
 
122
132
  ### `scripts/check-dep-ages.mjs` (this PR)
123
133
 
124
- Fails any PR with an external pinned production dep version published less than `FLAIR_DEP_MIN_AGE_DAYS` ago (default 7). Queries the npm registry's `time` map. Checks both `dependencies` and `optionalDependencies` — npm and bun install optionalDependencies by default. Workspace-internal deps exempt. Wired into the `test-unit` job. Its limits, stated: it does not check `peerDependencies` (resolved from a range by the consumer's install) nor `devDependencies` (don't ship in our tarballs) — it reads the same registry publish timestamp Renovate does, so it is a second line against the cooldown being removed from the config — not against a release whose publish date lies.
134
+ Fails when a checked external exact-pinned production dep version was published less than `FLAIR_DEP_MIN_AGE_DAYS` ago (default 7) without a matching unexpired exemption; keep-current pins are skipped. Queries the npm registry's `time` map. Checks `dependencies`, `optionalDependencies` and `overrides` (root and every workspace package.json) — npm and bun install optionalDependencies by default; the gate checks exact override declarations, including conditional rules, not installed versions. Workspace-internal deps and exact pins with a matching unexpired exemption in `.github/dep-age-allowlist.json` (§1b) are exempt; a range is printed, not age-checked, and a refused dependency or override form fails the gate. Wired into the `test-unit` job. Its limits, stated: it does not check `peerDependencies` (resolved from a range by the consumer's install) nor `devDependencies` (don't ship in our tarballs) — it reads the same registry publish timestamp Renovate does, so it is a second line against the cooldown being removed from the config — not against a release whose publish date lies.
125
135
 
126
136
  Configurable:
127
137
 
@@ -195,7 +205,7 @@ Add `packageRules` only for your own exceptions. The preset carries no `@tpsdev-
195
205
 
196
206
  ## Exceptions and incident response
197
207
 
198
- - **Bypass for known-good fresh dep:** set `FLAIR_DEP_MIN_AGE_DAYS=0` for the affected CI run AND open a PR to add a comment-row in this doc explaining the exception. Don't bypass silently.
208
+ - **Exempt an otherwise checked fresh security pin:** add a dated entry to `.github/dep-age-allowlist.json` naming the advisory (§1b). It is reviewed on the PR and expires on its own. Don't bypass silently.
199
209
  - **Confirmed upstream compromise affecting Flair:** rotate any affected credential, revert the offending dep version, ship a patch release, file a public advisory at `github.com/tpsdev-ai/flair/security/advisories`. Notify Nathan immediately; don't act unilaterally.
200
210
  - **Suspected (not confirmed) compromise:** open an issue with the evidence; treat it as P0 in our backlog until disproven.
201
211
 
package/docs/upgrade.md CHANGED
@@ -111,6 +111,22 @@ flair upgrade --tree /opt/flair --flair-version 0.50.0
111
111
  without touching the tree. A git checkout or a path that *is* the npm-global
112
112
  install is refused rather than overwritten.
113
113
 
114
+ ### A symlinked data directory is refused at boot
115
+
116
+ The migration probe refuses a symlinked data directory or `.migrations` child.
117
+ When no candidate is usable, the boot log and `/HealthDetail` report the failure;
118
+ `flair doctor` does so with a verified agent and a reachable instance. Full paths
119
+ appear in the operator log, admin `/HealthDetail` responses and admin `flair doctor` output.
120
+
121
+ > **Heads-up:** for a link to a directory, only after verifying that the target is
122
+ > dedicated to this Flair instance and safe to relocate, stop Flair, remove the
123
+ > link, move its target to the configured path and start Flair. If ownership is
124
+ > uncertain, leave the target in place: for a linked **data directory**, set
125
+ > `FLAIR_MIGRATION_DATA_DIR` to the real directory path instead of the link and
126
+ > restart; for a linked `.migrations` child, configure a different data directory
127
+ > with an unlinked `.migrations` child. For a dangling link or a link to a file,
128
+ > replace the link with a writable directory.
129
+
114
130
  ### After a Node bump: the CLI and the instance in different install trees
115
131
 
116
132
  A service unit bakes the node binary and install tree of the runtime it was
@@ -685,10 +701,10 @@ the destructive replace unless you pass `--yes`); the equivalent by hand is `fla
685
701
  stop && rm -rf ~/.flair/data && mkdir -p ~/.flair/data && tar -xzf
686
702
  <snapshot> -C ~/.flair/data && flair start`, in case you'd rather not use the command.
687
703
 
688
- If you don't have a snapshot (upgraded without `--snapshot`, or on a version from
689
- before flair#637 shipped it), there is no tested way back short of restoring from a
690
- `flair backup` JSON export on the older version — do not assume an untested downgrade
691
- boot will work.
704
+ The only full rollback is restoring the pre-upgrade physical data-directory snapshot.
705
+ `flair backup`/`restore` logically exports/imports only Agent, Memory and Soul rows
706
+ through a running server into a fresh compatible instance; it does not restore the
707
+ physical store or other tables.
692
708
 
693
709
  ### Does the previous version actually boot against newer data? (tested, not assumed)
694
710
 
@@ -696,8 +712,11 @@ This used to be aspirational — nobody had actually checked. `test/compat/downg
696
712
  now checks it for real, nightly, alongside the mixed-version federation suite (both run
697
713
  from `.github/workflows/federation-compat.yml`'s `bun test test/compat/`): it boots the
698
714
  current build, writes a memory and a presence row, stops it *without* wiping the data
699
- directory, then boots the last **npm-published** `@tpsdev-ai/flair` against that exact
700
- same directory and confirms it comes up healthy and can read both rows back.
715
+ directory, then starts a pinned earlier Flair release that uses the previous storage engine (`@tpsdev-ai/flair` 0.59.0) against that
716
+ same directory through its own CLI in npm's nested layout. The test requires the two Harper engines to
717
+ differ, and confirms the older CLI's backwards-engine guard refuses the store *before*
718
+ Harper is spawned, naming the engine change, with regular-file paths and contents in the
719
+ data directory unchanged.
701
720
 
702
721
  **The guarantee is now restated (flair#1050):** there is never a silent bad outcome.
703
722
  Either the old binary boots and serves the corpus correctly, **or** it refuses to start
@@ -721,6 +740,13 @@ recovery as the 5.1 → 5.2 break: `flair snapshot restore <path>`. The
721
740
  the flair#1050 invariant (it boots Harper via `startHarper`, so the CLI stamp
722
741
  phrasing is not on that path).
723
742
 
743
+ **Engine-version break: Harper 5.2 → 5.3.** This release attempts to write an `engine-version.txt` stamp into
744
+ `ROOTPATH` (or `~/.flair/data` when unset) at boot; the write is best effort. With a readable, nonempty stamp and a known installed Harper version, an older guarded Flair refuses before Harper opens the store if the stamp is newer or the versions cannot be compared. A failed write can leave a stale stamp.
745
+ The only full rollback is restoring the pre-upgrade physical data-directory snapshot
746
+ (`flair snapshot restore <path>`). `flair backup`/`restore` logically exports/imports
747
+ only Agent, Memory and Soul rows through a running server into a fresh compatible
748
+ instance; it does not restore the physical store or other tables.
749
+
724
750
  **As observed when this suite was added (2026-07-08):** the npm-published baseline
725
751
  (0.21.0) boots cleanly against data written by a HEAD build roughly 14 commits ahead of
726
752
  it (several security-hardening and CLI-behavior changes, no Flair schema migration, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair",
3
- "version": "0.59.0",
3
+ "version": "0.62.0",
4
4
  "packageManager": "bun@1.3.10",
5
5
  "description": "Identity, memory, and soul for AI agents. Cryptographic identity (Ed25519), semantic memory with local embeddings, and persistent personality — all in a single process.",
6
6
  "type": "module",
@@ -63,10 +63,10 @@
63
63
  "node": "^22.18.0 || >=24.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "@harperfast/oauth": "2.5.0",
66
+ "@harperfast/oauth": "2.9.0",
67
67
  "@types/js-yaml": "4.0.9",
68
68
  "commander": "14.0.3",
69
- "harper": "5.2.8",
69
+ "harper": "5.3.1",
70
70
  "harper-fabric-embeddings": "^0.5.0",
71
71
  "jose": "6.2.2",
72
72
  "js-yaml": "^4.3.2",
@@ -76,6 +76,7 @@
76
76
  },
77
77
  "overrides": {
78
78
  "react-native-fs": "npm:empty-npm-package@1.0.0",
79
+ "@harperfast/fulltext": "npm:empty-npm-package@1.0.0",
79
80
  "brace-expansion": "^5.0.12",
80
81
  "undici": "~8.10.2",
81
82
  "fast-uri": "^4.1.5",
@@ -88,14 +89,18 @@
88
89
  "@tootallnate/once": "^2.0.1",
89
90
  "form-data": "^4.0.6",
90
91
  "mysql2": "^3.22.0",
91
- "mariadb": "~3.4.7",
92
+ "mariadb": "3.5.4",
92
93
  "qs": "^6.16.0",
93
94
  "fastify": "^5.12.5",
94
95
  "lodash": "^4.18.0",
95
96
  "ip-address": "^10.5.1",
96
97
  "joi": "^17.13.7",
97
98
  "moment": "^2.31.0",
98
- "@grpc/grpc-js": "^1.14.5"
99
+ "@grpc/grpc-js": "^1.14.5",
100
+ "http-cache-semantics": "^4.3.0",
101
+ "proxy-addr": "^2.0.8",
102
+ "@modelcontextprotocol/sdk": "1.31.0",
103
+ "handlebars": "4.7.10"
99
104
  },
100
105
  "devDependencies": {
101
106
  "@playwright/test": "1.59.1",
@@ -0,0 +1,22 @@
1
+ # AgentKeyRegistration — the private audit record for one committed key
2
+ # registration (POST /AgentKeyRegister, resources/AgentKeyRegister.ts).
3
+ #
4
+ # One row per committed registration. It carries NO secret: the actor, the
5
+ # operator, the target agent's id, this instance's id, the key's FINGERPRINT in
6
+ # place of the key, and the time. Because it holds no secret it is `replicate: true` —
7
+ # a deliberate choice, in contrast to the token-enrollment table the design
8
+ # thread records for a later slice, which must be `replicate: false`.
9
+ #
10
+ # On the Flair resource route (resources/AgentKeyRegistration.ts) reads are
11
+ # admin-only and every write is refused; the registration operation is its only
12
+ # application writer, through the raw table handle. The Harper operations API is
13
+ # a separate raw-table trust root that this does not govern.
14
+ type AgentKeyRegistration @table(database: "flair", replicate: true) {
15
+ id: ID @primaryKey # server-generated registrationId
16
+ actorId: String! @indexed # the admin that registered the key: an admin agent id (TPS-Ed25519) or a Harper username (Basic)
17
+ operator: String # the Harper username on the request, if any (an audit label only)
18
+ agentId: String! @indexed # the agent row whose key was registered
19
+ instanceId: String @indexed # the local instance id that performed the registration
20
+ keyFingerprint: String! # sha256 (hex) of the registered key's canonical base64url string, stored in place of the key
21
+ createdAt: String!
22
+ }
@@ -76,6 +76,9 @@ type Integration @table(database: "flair") @export {
76
76
  email: String
77
77
  encryptedCredential: String
78
78
  metadata: String
79
+ # Null or absent means unpublished. Integration resource publication writes
80
+ # stamp an ISO time for a tps-mail binding.
81
+ directoryPublishedAt: String
79
82
  createdAt: String!
80
83
  updatedAt: String
81
84
  }
@@ -39,6 +39,43 @@ type Peer @table(database: "flair") @export {
39
39
  updatedAt: String
40
40
  }
41
41
 
42
+ # Sender-owned federation retry bookkeeping (flair#2455). The table is shaped
43
+ # for one row per (peer, table, record) the receiver refused for a reason a
44
+ # later re-offer could clear, plus locally observed unconfirmed sends. No
45
+ # production sender path creates rows yet (a later slice activates the sender);
46
+ # rows an admin writes are readable now. Local bookkeeping, EXCLUDED from
47
+ # federation policy and the receive mapping, so no inbound sync record can write
48
+ # it (a pushed record naming it that passes the receiver's payload-id check
49
+ # skips as `unknown_table`). Admin-only on every
50
+ # operation; see resources/FederationRetry.ts.
51
+ #
52
+ # ENFORCED: @sealed makes Harper refuse a write that names a field not declared
53
+ # below. CONVENTIONS, not enforced by this schema: `id` is retryEntryKey(peerId,
54
+ # table, recordId) (resources/federation-retry-lib.ts), and the commented
55
+ # values of state, lastReason, resolution and bound. The reader and the
56
+ # transition check these (retryRowProblem) and treat a row that breaks one as
57
+ # malformed.
58
+ type FederationRetry @table(database: "flair") @sealed @export {
59
+ id: ID @primaryKey # by convention retryEntryKey(peerId, table, recordId)
60
+ peerId: String! @indexed # the peer that refused (or never answered)
61
+ table: String! # the source table name
62
+ recordId: String! # the source row id
63
+ state: String! @indexed # "pending" | "terminal"
64
+ firstRefusedAt: String! @indexed # age is measured from here (the T bound)
65
+ attempts: Int! @indexed # reserved and persisted before each send (the N bound)
66
+ episodeId: String # RESERVED for sender activation (flair#2455 slice 3): the obligation's generation, for rejecting stale completions; nothing sets or checks it yet
67
+ recordFingerprint: String # content fingerprint, for exhausted-row suppression
68
+ lastReason: String # the closed SkipReason, or a local reason
69
+ lastAttemptSyncId: String # the sync that last reserved an attempt
70
+ lastAttemptAt: String
71
+ completedAt: String # when the row became terminal
72
+ resolution: String # which terminal outcome ended it
73
+ bound: String # "attempts" | "age" | "both" for retry_exhausted; null otherwise
74
+ createdAt: String!
75
+ updatedAt: String
76
+ }
77
+
78
+
42
79
  # Federation body-signature nonces are recorded in `ReplayNonce`
43
80
  # (schemas/replay.graphql), shared with agent auth (flair#2061).
44
81
 
@@ -49,7 +86,7 @@ type SyncLog @table(database: "flair") {
49
86
  direction: String! @indexed # "push" | "pull"
50
87
  recordCount: Int # how many records merged in this batch
51
88
  skippedCount: Int # how many records skipped (sum of skippedReasons)
52
- skippedReasons: String # JSON: { unknown_table: N, non_originator: N, future_timestamp: N, no_op_same_hash: N, merge_error: N, unknown_originator_key: N, invalid_signature: N, missing_signature: N, principal_mismatch: N }
89
+ skippedReasons: String # JSON counts by SkipReason, for example { unknown_table: N, non_originator: N, merge_error: N }; the full vocabulary is SKIP_REASON_CLASS in resources/federation-classify.ts
53
90
  status: String @indexed # "success" | "partial" | "failed"
54
91
  error: String # human-readable summary if partial/failed (includes per-record error messages, capped)
55
92
  durationMs: Int # how long the sync took
@@ -33,12 +33,38 @@ type Memory @table(database: "flair") {
33
33
  # write) but never DECLARED in this schema, so it was storable but not
34
34
  # queryable — Harper's Table.search({conditions}) rejects a condition on
35
35
  # an undeclared attribute ("X is not a defined attribute"), which the
36
- # zero-touch migration runner's bounded detect()/countPending()/run()
37
- # queries (resources/migrations/embedding-stamp.ts: `embeddingModel
38
- # not_equal <current>`) need in order to stay O(1)-bounded rather than a
39
- # full-corpus scan on every boot. Purely additive — existing rows already
36
+ # zero-touch migration runner's `embeddingModel not_equals <current>` query
37
+ # (resources/migrations/embedding-stamp.ts) needs. Since flair#2465 only
38
+ # detect() runs that query (first, before a scan); countPending() and run()
39
+ # scan the whole table directly. Purely additive — existing rows already
40
40
  # carry this value on disk; declaring it queryable changes nothing about
41
41
  # what's written or how embeddings/prefixes behave (#689's gate untouched).
42
+ embeddedContentHash: String @indexed # flair#2465: a stored text hash —
43
+ # `computeContentHash(agentId, skillEmbedText(row))`, the function that
44
+ # defines `contentHash`, applied to the field the row embeds from
45
+ # (`trigger` for a skill-tagged row with a non-empty trigger, else
46
+ # `content`). NEWLY COMPUTED over the text embedded when the server
47
+ # computes a vector on a guarded path (Memory POST/PUT/PATCH embed,
48
+ # re-embed PATCH, stamp migration fallback, auto-embed backfill) for a row
49
+ # with a non-empty owner; null for an empty owner. RETAINED, not
50
+ # recomputed, by a PUT/PATCH that carries a vector or stores one accepted
51
+ # from the caller and by a skill successor that carries the stored
52
+ # vector: a preserved value that may describe an earlier server-computed
53
+ # vector. A POST or PUT create that stores a vector accepted from the
54
+ # caller stores null; when redaction changes the text, the supplied
55
+ # vector is discarded and the redacted text is embedded afresh, with a
56
+ # new hash when that yields a vector.
57
+ # An admin PATCH create drops a submitted value and can leave the field
58
+ # absent; a `_reindex` PUT keeps the stored value and refuses a differing
59
+ # one; a value received through federation is an unverified peer
60
+ # assertion. The stamp migration treats a row as current when
61
+ # `embeddingModel` is current-space AND this value is absent or equals the
62
+ # EXPECTED hash of the row's current text; it re-queues a row whose value
63
+ # differs (a live per-row scan). Nullable/additive: an absent value
64
+ # bypasses only the hash comparison, as a matching one passes it; either
65
+ # way the row still needs a current-space model. Distinct from
66
+ # `contentHash`, which the feed stamps over `content` and an ordinary
67
+ # Memory write does not maintain.
42
68
  tags: [String] @indexed
43
69
  durability: String @indexed
44
70
  source: String
@@ -140,6 +166,7 @@ type Memory @table(database: "flair") {
140
166
  # that producer is a follow-up); additive/nullable, existing rows carry no
141
167
  # entities, readers tolerate absent (same pattern as Presence.activityUpdatedAt).
142
168
  # See docs/entity-vocabulary.md.
169
+ skillSubjectId: String @indexed # Nullable, server-owned skill subject.
143
170
  }
144
171
 
145
172
  # Explicit entity-to-entity relationships with temporal validity.
@@ -284,7 +311,9 @@ type MemoryHitStat @table(database: "flair") {
284
311
  # undeclared attributes except the named bookkeeping fields (f1-out/f1-in).
285
312
  #
286
313
  # Cascade (A1' item 6 / A1'' item 2): `Memory.delete` and maintenance expiry or
287
- # age-based archival delete the pointer with their Memory operation. `MemoryArchive`
314
+ # age-based archival delete the pointer with their Memory operation. POST
315
+ # /MemoryPurge deletes a pointer only after a read after its row delete's commit
316
+ # finds the row gone, so a row still stored keeps its pointer. `MemoryArchive`
288
317
  # basement/restore retains the pointer row; the join suppresses it while the Memory
289
318
  # is archived. `Memory.delete` joins a request transaction when present; maintenance
290
319
  # uses an owned transaction per item (c3). An orphan sweep re-checks inside the
@@ -402,6 +431,30 @@ type OrgSkillAssignment @table(database: "flair") {
402
431
  sourceClass: String! # operator | internal
403
432
  }
404
433
 
434
+ # Deletion history for physical deletions of permanent/persistent Memory rows,
435
+ # appended in the delete's transaction by Memory.delete and by POST /MemoryPurge
436
+ # (the path CLI hygiene and agent remove use). For a row still stored after the
437
+ # commit, MemoryPurge attempts history cleanup and checks for absence after its
438
+ # commit; unconfirmed cleanup returns 500 memory_purge_history_cleanup_unconfirmed.
439
+ # Non-durable deletes, including maintenance expiry, append no history.
440
+ # No @export and no resource class: there is no direct route.
441
+ #
442
+ # `replicate: true` is declared explicitly to state the current setting:
443
+ # a table in a replicated database replicates unless it opts out with
444
+ # `replicate: false`, so an undeclared table already replicates. Declaring it
445
+ # changes nothing about what replicates (measured on the installed Harper: a
446
+ # `describe_table` of an undeclared table reports no `replicate` key, and the
447
+ # replication decision is `Table.replicate !== false`).
448
+ type MemoryDeletionHistory @table(database: "flair", replicate: true) {
449
+ id: ID @primaryKey # unique per deletion record (a memory id can be deleted and re-created)
450
+ memoryId: String! @indexed
451
+ memoryInstanceToken: String
452
+ durability: String # the deleted row's durability at deletion, when known
453
+ actor: String # the deleting principal; null when no actor is supplied
454
+ sourceClass: String! # agent | admin | internal
455
+ at: String! @indexed # ISO timestamp of the delete
456
+ }
457
+
405
458
  # OrgSkillAssignmentHistory — one row per accepted write through
406
459
  # resources/OrgSkillAssignment.ts, appended in the write's transaction.
407
460
  # No @export and no resource class: there is no direct /OrgSkillAssignmentHistory route.
@@ -414,3 +467,29 @@ type OrgSkillAssignmentHistory @table(database: "flair") {
414
467
  previousHash: String # sha256 of the stored row before the write; null on create
415
468
  at: String!
416
469
  }
470
+
471
+ # InstructionVersion — single-row Soul and skill write history; Soul collection deletes are refused.
472
+ # REST mutation verbs are refused; reads authorize soul and skill subjects.
473
+ # The administrator operations API is an unaudited exception.
474
+ type InstructionVersion @table(database: "flair") @export {
475
+ id: ID @primaryKey # encodes subjectType + subjectId + version
476
+ subjectType: String! @indexed # soul | skill
477
+ subjectId: String! @indexed # Soul: agentId:key or colon-prefixed JSON pair
478
+ agentId: String! @indexed # owner
479
+ key: String # Soul key
480
+ version: BigInt! # positive per-subject sequence
481
+ kind: String! # create | update | delete
482
+ rowId: ID! # affected physical row
483
+ valueHash: String # sha256 of the value bytes; null on delete
484
+ previousVersionHash: String # preceding record digest; null on the first record
485
+ recordHash: String! # record digest over every other field
486
+ soulSnapshot: String # serialized Soul state including its value
487
+ memoryId: ID # skill-version Memory reference
488
+ visibility: String # retained skill read-scope metadata
489
+ actorKind: String! # operator | agent | internal | instance
490
+ actorId: String # verified identity; null for unattributed internal calls
491
+ sourceClass: String! # operator | internal | agent | federation | seed
492
+ createdAt: String! # server ISO timestamp
493
+ guarded: Boolean! # whether expectedVersion was compared
494
+ expectedVersion: ID # the compared head; null on an unguarded write
495
+ }
@@ -59,6 +59,25 @@ type IdJagReplay @table(database: "flair", expiration: 90000) {
59
59
  seenAt: Long! # ms-epoch when recorded
60
60
  }
61
61
 
62
+ # One row per claim to redeem an OAuth authorization code or rotate a refresh token,
63
+ # written once per instance under a per-key lock by resources/replay-store.ts
64
+ # (claimOAuthSingleUse).
65
+ # c:<sha256(code)> a code presented for redemption
66
+ # r:<sha256(token)> a refresh token presented for rotation
67
+ # A single-use row records that a redemption was claimed. If the later `used`
68
+ # or revocation write fails, no token pair is issued; the claim remains, so
69
+ # the code or token cannot be redeemed again.
70
+ # expiration: 691200 — seconds before Harper's scan may remove a row. It MUST equal
71
+ # OAUTH_SINGLE_USE_RETENTION_S in resources/OAuth.ts, which says why it
72
+ # outlives the longest a code or refresh token can be presented;
73
+ # test/unit-isolated/oauth-single-use-2145.test.ts pins both.
74
+ # Internal bookkeeping only: no @export, never served. The key is a hash, so a
75
+ # row holds no redeemable secret.
76
+ type OAuthSingleUse @table(database: "flair", expiration: 691200) {
77
+ id: ID @primaryKey # `c:<sha256(code)>` or `r:<sha256(refresh token)>`
78
+ seenAt: Long! # ms-epoch when recorded
79
+ }
80
+
62
81
  # Access + refresh tokens.
63
82
  type OAuthToken @table(database: "flair") {
64
83
  id: ID @primaryKey # token ID (internal reference)
@@ -9,4 +9,6 @@ type Presence @table(database: "flair") @export {
9
9
  activityUpdatedAt: BigInt # unix ms — when activity/currentTask were last ASSERTED (natural-presence); nullable/additive, absent on records written before this feature (readers fall back to lastHeartbeatAt)
10
10
  flairVersion: String # @tpsdev-ai/flair version serving this heartbeat (flair#639); absent on pre-#639 records
11
11
  harperVersion: String # @harperfast/harper version serving this heartbeat (flair#639); absent on pre-#639 records
12
+ originatorInstanceId: String # local creates stamp this instance's id read fresh from the Instance table (null otherwise); updates preserve the stored value. Receipt stores the batch-verified sender. Nullable/additive.
13
+ receivedAt: BigInt # unix ms — when THIS instance received a replicated row. Stamped only by the federation receive path; a local write (POST/PUT/PATCH) never sets it. Nullable/additive.
12
14
  }