@tpsdev-ai/flair 0.56.0 → 0.58.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 (153) hide show
  1. package/README.md +19 -20
  2. package/SECURITY.md +4 -1
  3. package/dist/build-info.json +3 -3
  4. package/dist/cli.js +1800 -293
  5. package/dist/commands/agent.js +22 -15
  6. package/dist/commands/bridge.js +40 -3
  7. package/dist/commands/doctor.js +214 -4
  8. package/dist/commands/federation.js +265 -38
  9. package/dist/commands/hook.js +10 -2
  10. package/dist/commands/init.js +179 -48
  11. package/dist/commands/memory.js +24 -2
  12. package/dist/commands/quality.js +26 -18
  13. package/dist/commands/service.js +137 -22
  14. package/dist/commands/status.js +114 -3
  15. package/dist/commands/upgrade.js +204 -84
  16. package/dist/doctor-client.js +50 -4
  17. package/dist/federation/scheduler.js +253 -4
  18. package/dist/install/clients.js +89 -23
  19. package/dist/install/global-bin-path.js +26 -6
  20. package/dist/lib/atomic-write.js +256 -0
  21. package/dist/lib/auth-resolve.js +46 -0
  22. package/dist/lib/daemon-liveness.js +61 -0
  23. package/dist/lib/doctor-run.js +5 -0
  24. package/dist/lib/embed-gpu-doctor.js +49 -26
  25. package/dist/lib/federation-memory-attributes.js +15 -0
  26. package/dist/lib/init-admin-pass.js +4 -2
  27. package/dist/lib/init-listener-environ.js +38 -0
  28. package/dist/lib/init-occupied-listener.js +165 -0
  29. package/dist/lib/instance-identity-row.js +580 -0
  30. package/dist/lib/launchd-domain-preflight.js +448 -0
  31. package/dist/lib/launchd-management.js +176 -6
  32. package/dist/lib/launchd-repair.js +95 -0
  33. package/dist/lib/memory-attributes.js +77 -0
  34. package/dist/lib/node-alias-path.js +95 -0
  35. package/dist/lib/npm-registry.js +119 -6
  36. package/dist/lib/owned-pins.js +20 -6
  37. package/dist/lib/redact-token-id.js +197 -0
  38. package/dist/lib/service-repoint-apply.js +267 -0
  39. package/dist/lib/service-repoint.js +575 -0
  40. package/dist/lib/toml-string-array.js +104 -0
  41. package/dist/lib/tree-divergence.js +716 -0
  42. package/dist/lib/upgrade-plain-tree.js +18 -8
  43. package/dist/lib/upgrade-prior-liveness.js +69 -0
  44. package/dist/lib/upgrade-rollback.js +116 -0
  45. package/dist/rem/runner.js +11 -0
  46. package/dist/resources/Agent.js +27 -14
  47. package/dist/resources/AgentSeed.js +39 -2
  48. package/dist/resources/Asset.js +3 -11
  49. package/dist/resources/Credential.js +4 -10
  50. package/dist/resources/Federation.js +299 -127
  51. package/dist/resources/Integration.js +8 -32
  52. package/dist/resources/Memory.js +623 -86
  53. package/dist/resources/MemoryArchive.js +9 -0
  54. package/dist/resources/MemoryBootstrap.js +23 -12
  55. package/dist/resources/MemoryCandidate.js +3 -11
  56. package/dist/resources/MemoryDedupStats.js +1 -1
  57. package/dist/resources/MemoryFeed.js +214 -5
  58. package/dist/resources/MemoryGrant.js +19 -40
  59. package/dist/resources/MemoryHostSource.js +90 -0
  60. package/dist/resources/MemoryMaintenance.js +121 -32
  61. package/dist/resources/MemoryReflect.js +4 -1
  62. package/dist/resources/MemoryReindex.js +7 -4
  63. package/dist/resources/MemoryUsage.js +55 -18
  64. package/dist/resources/Presence.js +18 -10
  65. package/dist/resources/RecordUsage.js +30 -40
  66. package/dist/resources/Relationship.js +170 -89
  67. package/dist/resources/SemanticSearch.js +44 -19
  68. package/dist/resources/Soul.js +31 -19
  69. package/dist/resources/XAA.js +7 -3
  70. package/dist/resources/agent-auth.js +16 -10
  71. package/dist/resources/auth-middleware.js +164 -50
  72. package/dist/resources/auto-promote-lib.js +4 -4
  73. package/dist/resources/bm25-index-service.js +246 -32
  74. package/dist/resources/bm25-status.js +132 -0
  75. package/dist/resources/bm25.js +13 -14
  76. package/dist/resources/ed25519-auth.js +11 -54
  77. package/dist/resources/embed-gpu.js +262 -47
  78. package/dist/resources/embeddings-boot.js +52 -17
  79. package/dist/resources/federation-classify.js +12 -0
  80. package/dist/resources/federation-cleanup.js +289 -51
  81. package/dist/resources/federation-crypto.js +65 -19
  82. package/dist/resources/health.js +105 -22
  83. package/dist/resources/host-pointer/registry.js +35 -0
  84. package/dist/resources/host-pointer-adapter.js +15 -0
  85. package/dist/resources/host-source-visibility.js +167 -0
  86. package/dist/resources/host-source.js +151 -0
  87. package/dist/resources/in-process-api.js +2 -1
  88. package/dist/resources/instance-create-lock.js +363 -0
  89. package/dist/resources/instance-identity-rows.js +43 -0
  90. package/dist/resources/instance-identity.js +97 -12
  91. package/dist/resources/mcp-handler.js +155 -51
  92. package/dist/resources/mcp-tool-arguments.js +83 -0
  93. package/dist/resources/mcp-tools.js +28 -25
  94. package/dist/resources/memory-consolidate-lib.js +3 -1
  95. package/dist/resources/memory-declared-attributes.js +103 -0
  96. package/dist/resources/memory-feed-lib.js +5 -1
  97. package/dist/resources/memory-host-source.js +163 -0
  98. package/dist/resources/memory-visibility.js +10 -7
  99. package/dist/resources/migrations/synthetic-test-migration.js +4 -1
  100. package/dist/resources/migrations/visibility-backfill.js +4 -1
  101. package/dist/resources/originator-instance.js +235 -0
  102. package/dist/resources/promotion-stamp.js +2 -0
  103. package/dist/resources/provenance.js +111 -11
  104. package/dist/resources/rate-limit.js +6 -4
  105. package/dist/resources/record-owner-guard.js +19 -0
  106. package/dist/resources/record-type-kit.js +44 -23
  107. package/dist/resources/record-types.js +6 -6
  108. package/dist/resources/relay-ops.js +28 -3
  109. package/dist/resources/replay-store.js +289 -0
  110. package/dist/resources/request-transaction.js +78 -0
  111. package/dist/resources/search-readiness.js +26 -22
  112. package/dist/resources/semantic-retrieval-core.js +103 -4
  113. package/dist/resources/table-helpers.js +33 -0
  114. package/dist/resources/table-patch-policy.js +109 -0
  115. package/dist/resources/table-patches.js +17 -0
  116. package/dist/resources/table-post-policy.js +138 -0
  117. package/dist/resources/table-posts.js +22 -0
  118. package/dist/resources/table-subscription-policy.js +135 -0
  119. package/dist/resources/table-subscriptions.js +19 -0
  120. package/dist/resources/tool-descriptors/index.js +15 -15
  121. package/dist/resources/trust-block.js +10 -3
  122. package/dist/resources/usage-recording.js +169 -41
  123. package/dist/src/lib/instance-identity-row.js +580 -0
  124. package/dist/src/lib/memory-attributes.js +77 -0
  125. package/dist/src/lib/redact-token-id.js +197 -0
  126. package/docs/api-reference.md +80 -16
  127. package/docs/auth.md +5 -5
  128. package/docs/claude-code.md +137 -6
  129. package/docs/deploying-on-fabric.md +6 -3
  130. package/docs/deployment.md +1 -1
  131. package/docs/embedding-in-a-harper-app.md +3 -3
  132. package/docs/federation.md +17 -10
  133. package/docs/hosted-on-fabric.md +4 -3
  134. package/docs/integrations.md +28 -19
  135. package/docs/mcp-clients.md +26 -32
  136. package/docs/n8n.md +8 -8
  137. package/docs/notes/mcp-oauth-model2.md +27 -18
  138. package/docs/openclaw.md +29 -28
  139. package/docs/quickstart.md +5 -0
  140. package/docs/releasing.md +134 -2
  141. package/docs/spoke-bringup.md +14 -11
  142. package/docs/standalone-local.md +2 -2
  143. package/docs/supply-chain-policy.md +28 -10
  144. package/docs/system-requirements.md +1 -1
  145. package/docs/troubleshooting.md +11 -0
  146. package/docs/upgrade.md +189 -63
  147. package/package.json +9 -5
  148. package/schemas/agent.graphql +9 -6
  149. package/schemas/federation.graphql +2 -11
  150. package/schemas/memory.graphql +106 -17
  151. package/schemas/replay.graphql +18 -0
  152. package/templates/launchd/start-flair-with-admin-pass.sh +22 -0
  153. package/dist/resources/federation-nonce-store.js +0 -195
@@ -115,7 +115,7 @@ The command prints one JSON object. Tokens expire after **60 minutes** by defaul
115
115
  On the **hub host**, an admin runs:
116
116
 
117
117
  ```bash
118
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token > pair-triple.json)
118
+ (umask 077; set -C; flair federation token --admin-pass-file ~/.flair/admin-pass > pair-triple.json)
119
119
  ```
120
120
 
121
121
  `umask 077` sets the mode of a file the redirect CREATES; an existing file keeps its mode, so `set -C` (noclobber) makes the redirect refuse to overwrite it. Remove an old `pair-triple.json` first (`rm pair-triple.json`).
@@ -125,13 +125,13 @@ On the **hub host**, an admin runs:
125
125
  A Fabric-deployed hub is a Harper component on a managed cluster. There is no host to shell into. Mint the triple from any machine that can reach the hub — for a personal spoke, that machine is the spoke — and name both the data URL and the ops URL:
126
126
 
127
127
  ```bash
128
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
128
+ (umask 077; set -C; flair federation token --admin-pass-file /path/to/hub-admin-pass \
129
129
  --target https://<hub>.<org>.harperfabric.com \
130
130
  --ttl 60 \
131
131
  --ops-target https://<hub>.<org>.harperfabric.com:9925 > pair-triple.json) # docs-freshness-allow: Fabric ops API port, not legacy data port
132
132
  ```
133
133
 
134
- `/path/to/hub-admin-pass` is a 0600 file holding the **HUB** admin password on the minting machine, not the spoke's `~/.flair/admin-pass`, which authenticates only the spoke. A literal on the command line would land in shell history, so read it from the file (or a secret manager). `--ops-target` is the Harper operations API on the same hostname at port 9925. <!-- docs-freshness-allow: Fabric ops API port, not legacy data port --> A portless `https://` `--target` derives that same port. Pass `--ops-target` so the URL is the one you chose. An explicit port other than 443 still derives as REST port minus one, which is not this ops port. `federation token` reads the admin password from `FLAIR_ADMIN_PASS` (or from `--admin-pass`). `--admin-pass` is also accepted but puts the password in shell history and process listings; prefer the file form above (or a secret manager).
134
+ `/path/to/hub-admin-pass` is a 0600 file holding the **HUB** admin password on the minting machine, not the spoke's `~/.flair/admin-pass`, which authenticates only the spoke. `--admin-pass-file` reads it in-process (mode 0600 enforced), so it stays out of shell history and the process list; a literal on the command line would land in both. `--ops-target` is the Harper operations API on the same hostname at port 9925. <!-- docs-freshness-allow: Fabric ops API port, not legacy data port --> A portless `https://` `--target` derives that same port. Pass `--ops-target` so the URL is the one you chose. An explicit port other than 443 still derives as REST port minus one, which is not this ops port. `federation token` also accepts `--admin-pass` (kept for compatibility, but it lands in shell history and the process list) or `FLAIR_ADMIN_PASS` (suits CI).
135
135
 
136
136
  ### 5b. Transfer the triple to the spoke
137
137
 
@@ -146,11 +146,12 @@ When it was minted with `--target` against a Fabric hub, the file is already on
146
146
  ### 5c. Pair from the spoke
147
147
 
148
148
  ```bash
149
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<hub-url> \
149
+ flair federation pair https://<hub-url> \
150
+ --admin-pass-file ~/.flair/admin-pass \
150
151
  --token-from ./pair-triple.json
151
152
  ```
152
153
 
153
- The spoke admin credential (`FLAIR_ADMIN_PASS` as above, or `--admin-pass`) is required so the CLI can write the hub as a local `Peer` record. Without it, pairing succeeds on the hub side but the spoke never records its peer, and `flair federation sync` reports "No hub peer configured."
154
+ The spoke admin credential (`--admin-pass-file ~/.flair/admin-pass`, or `FLAIR_ADMIN_PASS`/`--admin-pass`) is required so the CLI can write the hub as a local `Peer` record. Without it, pairing succeeds on the hub side but the spoke never records its peer, and `flair federation sync` reports "No hub peer configured."
154
155
 
155
156
  ### 5d. What pairing does
156
157
 
@@ -164,7 +165,7 @@ The spoke admin credential (`FLAIR_ADMIN_PASS` as above, or `--admin-pass`) is r
164
165
  ## 6. Sync for the First Time
165
166
 
166
167
  ```bash
167
- flair federation sync --admin-pass "$FLAIR_ADMIN_PASS"
168
+ flair federation sync --admin-pass-file ~/.flair/admin-pass
168
169
  ```
169
170
 
170
171
  Expected:
@@ -178,7 +179,7 @@ Then verify the pairing. `federation verify` pushes the canary itself — you
178
179
  do not need the systemd timer from §7 first:
179
180
 
180
181
  ```bash
181
- flair federation verify --admin-pass "$FLAIR_ADMIN_PASS"
182
+ flair federation verify --admin-pass-file ~/.flair/admin-pass
182
183
  flair federation reachability
183
184
  ```
184
185
 
@@ -290,14 +291,16 @@ export FLAIR_URL=http://127.0.0.1:9926
290
291
  A managed Harper Fabric hub (`https://<hub>.<org>.harperfabric.com`, HTTPS on 443) serves the operations API on port 9925 of the same hostname. <!-- docs-freshness-allow: Fabric ops API port, not legacy data port --> Mint the pairing token with `--target` and `--ops-target` as in [§5a](#harper-fabric-hub-no-shell). Pairing from the spoke still uses the public hub URL:
291
292
 
292
293
  ```bash
293
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<hub>.<org>.harperfabric.com \
294
+ flair federation pair https://<hub>.<org>.harperfabric.com \
295
+ --admin-pass-file ~/.flair/admin-pass \
294
296
  --token-from ./pair-triple.json
295
297
  ```
296
298
 
297
299
  A self-hosted instance that publishes an explicit REST port still uses ops = REST − 1 (a fresh local install is 19926 → 19925). Pass that ops URL with `--ops-target` when you are not on the box:
298
300
 
299
301
  ```bash
300
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://fabric-node.example.com:19926/<instance> \
302
+ flair federation pair https://fabric-node.example.com:19926/<instance> \
303
+ --admin-pass-file ~/.flair/admin-pass \
301
304
  --token-from triple.json \
302
305
  --ops-target https://fabric-node.example.com:19925
303
306
  ```
@@ -311,8 +314,8 @@ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://fabr
311
314
  | Install | `npm install -g @tpsdev-ai/flair` |
312
315
  | Init spoke | `flair init --agent-id <id> --data-dir /data/flair --skip-soul` |
313
316
  | Check status | `flair status` / `flair federation status` |
314
- | Hub: mint token | On the hub host: `(umask 077; set -C; FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token > triple.json)`. Harper Fabric hub (no shell): §5a `--target` + `--ops-target` |
315
- | Spoke: pair | `FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from ./triple.json` |
317
+ | Hub: mint token | On the hub host: `(umask 077; set -C; flair federation token --admin-pass-file ~/.flair/admin-pass > triple.json)`. Harper Fabric hub (no shell): §5a `--target` + `--ops-target` |
318
+ | Spoke: pair | `flair federation pair <hub-url> --admin-pass-file ~/.flair/admin-pass --token-from ./triple.json` |
316
319
  | Spoke: sync | `FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation sync` |
317
320
  | Spoke: verify | `FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation verify` then `flair federation reachability` |
318
321
  | Watch loop | `flair federation watch --interval 30` |
@@ -221,10 +221,10 @@ Available. Pair a local instance as a hub or spoke with another Flair instance:
221
221
 
222
222
  ```bash
223
223
  # On the hub — generate a one-time pairing token triple
224
- (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token > triple.json)
224
+ (umask 077; set -C; flair federation token --admin-pass-file ~/.flair/admin-pass > triple.json)
225
225
 
226
226
  # On the spoke — its own admin password writes the local Peer row
227
- FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from ./triple.json
227
+ flair federation pair <hub-url> --admin-pass-file ~/.flair/admin-pass --token-from ./triple.json
228
228
 
229
229
  # Sync (one-shot)
230
230
  flair federation sync --admin-pass-file ~/.flair/admin-pass
@@ -38,14 +38,14 @@ Override per-run via `FLAIR_DEP_KEEP_CURRENT="pkg1,pkg2,@scope/pkg3"` env (addit
38
38
 
39
39
  ### 2. Exact-version pinning for production deps
40
40
 
41
- Every `dependencies` entry in any `package.json` must be a single concrete version (`"5.0.9"`), not a range (`"^5.0"`, `"~5.0.9"`, `">=5"`). Range specifiers expose us to silent supply-chain swaps every install — exactly the surface attackers exploit.
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.
42
42
 
43
- - `peerDependencies` may use ranges (host-provided; never installed by us). `devDependencies` are also exact-pinned for build reproducibility, though they don't ship in our published tarballs.
44
- - **Flair declares no optional peers today**, and no `optionalDependencies` at all. 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.
43
+ - `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
+ - **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.
45
45
 
46
46
  Note the corollary, measured during flair#893: an optional peer that is simply *absent* installs silently — npm prints no warning at all — so it cannot be relied on to prompt anyone to install it. Anything a user must install for a feature to work needs to be documented, or detected and reported at runtime.
47
- - `bun.lock` is committed and frozen-lockfile installed in CI. Any unintended dep drift fails the workspace-deps consistency gate.
48
- - Pin updates happen via deliberate, test-gated PRs — never auto-merged. **Renovate is enabled** (`.github/renovate.json`) to *propose* these updates on a schedule, but it respects the bake-time cooldown (`minimumReleaseAge: "7 days"`, matching `FLAIR_DEP_MIN_AGE_DAYS`) and opens PRs only — `automerge` is off, so every bump flows through the full test suite + K&S review. Renovate uses `rangeStrategy: "pin"` so it proposes exact-version bumps (never re-widens to ranges) and shares the keep-current allow-list with `check-dep-ages.mjs`. Vulnerability alerts bypass the cooldown so security fixes aren't delayed.
47
+ - `bun.lock` is committed and `bun install --frozen-lockfile` is run in CI (`.github/workflows/test.yml`, ~121). That lockfile gate fails when package.json and bun.lock disagree; `scripts/check-workspace-deps.mjs` compares each recognized internal `@tpsdev-ai/*` dependency's literal declared version to the version the target package ships, and accepts `workspace:` declarations (e.g. `workspace:*` at `packages/cursor-wake-runner/package.json`, line 22; skip at `scripts/check-workspace-deps.mjs`, line 59).
48
+ - Pin updates happen via deliberate, test-gated PRs — never auto-merged. **Renovate is enabled** (the shared org preset at `.github/renovate-preset.json`, with `.github/renovate.json` holding only flair-specific exceptions) to *propose* these updates on a schedule, but it respects the bake-time cooldown (`minimumReleaseAge: "7 days"`, matching `FLAIR_DEP_MIN_AGE_DAYS`) and opens PRs only — `automerge` is off, so every bump flows through the full test suite + K&S review. Renovate uses `rangeStrategy: "pin"` so it proposes exact-version bumps (never re-widens to ranges) and shares the keep-current allow-list with `check-dep-ages.mjs`. Vulnerability alerts bypass the Renovate cooldown, so Renovate can propose an advisory fix immediately; the CI age gate can still hold a fresh pinned npm production dependency.
49
49
 
50
50
  ### 3. Internal dep version lockstep
51
51
 
@@ -109,9 +109,11 @@ Run it locally with `node scripts/audit-gate.mjs --explain`.
109
109
 
110
110
  ## Automation
111
111
 
112
- ### `.github/renovate.json` — deliberate, cooldown-gated update proposals
112
+ ### The shared org preset — `.github/renovate-preset.json` (`.github/renovate.json` holds only flair-specific exceptions)
113
113
 
114
- Renovate opens PRs to propose dependency updates so we don't drift behind upstream indefinitely — but on our terms, not the registry's. It is configured to never auto-merge (`automerge: false`), to pin (`rangeStrategy: "pin"`, consistent with §2), and to respect the bake-time cooldown (`minimumReleaseAge: "7 days"`, matching `FLAIR_DEP_MIN_AGE_DAYS` in `check-dep-ages.mjs`) so it only proposes versions that have already cleared the detection window. Non-major updates are grouped; majors land as isolated PRs. The keep-current allow-list (`harper`, `harper-fabric-embeddings`, `@harperfast/oauth`) mirrors the script's `DEFAULT_KEEP_CURRENT` — keep the two in lockstep when either changes. Vulnerability alerts bypass the cooldown. Every Renovate PR still runs the full CI suite (including the bake-time and workspace-deps gates) and is K&S-reviewed before merge.
114
+ Renovate opens PRs to propose dependency updates so we don't drift behind upstream indefinitely — but on our terms, not the registry's. The org preset (`.github/renovate-preset.json`) is common to all tpsdev-ai repos; `.github/renovate.json` holds only flair-specific overrides (workspace-internal dep exclusions, keep-current allow-list)
115
+
116
+ Renovate is configured to never auto-merge (`automerge: false`), to pin (`rangeStrategy: "pin"`, consistent with §2), and to respect the bake-time cooldown (`minimumReleaseAge: "7 days"` by default, matching `FLAIR_DEP_MIN_AGE_DAYS` in `check-dep-ages.mjs`), so by default it proposes only versions that have cleared the detection window — the two named exceptions are vulnerability fixes and the keep-current list below. Non-major updates are grouped per ecosystem (npm/Bun, Python, GitHub Actions, Docker); a manager outside those four gets no ecosystem-wide group from the four explicit rules (groups inherited from config:recommended may still apply); majors land as isolated PRs. The keep-current allow-list (`harper`, `harper-fabric-embeddings`, `@harperfast/oauth`) mirrors the script's `DEFAULT_KEEP_CURRENT` — keep the two in lockstep when either changes. Vulnerability alerts bypass the cooldown: Renovate can propose an advisory fix immediately. Flair's CI age gate (`check-dep-ages.mjs`) can still block a fresh pinned npm production dependency; other fresh versions follow the 7-day cooldown unless an explicit exception, such as the keep-current list, applies. The control for the fast-track is not the cooldown: it is `automerge: false` plus the full CI suite (including the bake-time and workspace-deps gates) and a K&S review on every Renovate PR. Docker image digests in Dockerfiles and compose files land in the docker group; images in workflow `container:`/`services:` are proposed by the github-actions manager and land in the github-actions group. The preset is in the CODEOWNERS trust root (`@heskew`): Renovate reads it from the default branch for every repo that extends it, so a change to it takes the same human as a change to the release tagger.
115
117
 
116
118
  ### `scripts/check-workspace-deps.mjs` (already shipped, PR #368)
117
119
 
@@ -119,7 +121,7 @@ Fails any PR where a workspace package declares an internal `@tpsdev-ai/*` dep a
119
121
 
120
122
  ### `scripts/check-dep-ages.mjs` (this PR)
121
123
 
122
- 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. Workspace-internal deps exempt. Wired into the `test-unit` job.
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.
123
125
 
124
126
  Configurable:
125
127
 
@@ -161,17 +163,33 @@ Each check matches a CI gate exactly so the local and remote outcomes can't drif
161
163
 
162
164
  If you're building on top of `@tpsdev-ai/flair-client` and want the same posture:
163
165
 
166
+ The guard is two files: `scripts/check-dep-ages.mjs` imports `./lib/check-dep-ages-collect.mjs` relative to itself, so copy both and keep `lib/` beside the script.
167
+
164
168
  ```bash
165
- # Copy the dep-age guard into your repo
169
+ # Copy the dep-age guard into your repo (both files, same relative layout)
170
+ mkdir -p scripts/lib
166
171
  curl -fsSL https://raw.githubusercontent.com/tpsdev-ai/flair/main/scripts/check-dep-ages.mjs \
167
172
  -o scripts/check-dep-ages.mjs
173
+ curl -fsSL https://raw.githubusercontent.com/tpsdev-ai/flair/main/scripts/lib/check-dep-ages-collect.mjs \
174
+ -o scripts/lib/check-dep-ages-collect.mjs
168
175
  chmod +x scripts/check-dep-ages.mjs
169
176
 
170
177
  # Wire it into your CI as a fast pre-test step
171
178
  - run: node scripts/check-dep-ages.mjs
172
179
  ```
173
180
 
174
- The script has no external dependencies — node 18+ is enough.
181
+ The two files have no external dependencies — node 18+ is enough.
182
+
183
+ To adopt the same Renovate preset in your repo, make your `.github/renovate.json`:
184
+
185
+ ```json
186
+ {
187
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
188
+ "extends": ["github>tpsdev-ai/flair//.github/renovate-preset"]
189
+ }
190
+ ```
191
+
192
+ Add `packageRules` only for your own exceptions. The preset carries no `@tpsdev-ai/**` exclusion: a repo whose own release process bumps tpsdev-ai workspace packages adds the same `{ "matchPackageNames": ["@tpsdev-ai/**"], "enabled": false }` rule flair keeps in `.github/renovate.json`, otherwise their non-major updates join the non-major npm group (major updates stay isolated, like every other major).
175
193
 
176
194
  ---
177
195
 
@@ -24,7 +24,7 @@ Flair runs Harper v5 (a Node.js HTTP+storage runtime) plus a small CLI/MCP layer
24
24
  - **Embedding cache.** First semantic search per cold daemon loads `nomic-embed-text-v1.5` into memory (~270 MB). Subsequent searches reuse it. If you disable embeddings (text-only search), strip ~270 MB.
25
25
  - **HNSW index.** In-memory vector index over the agent's memories. Grows linearly with memory count; expect ~1 KB per memory plus the 768-dim vector (~1.5 KB).
26
26
  - **Harper transaction log.** Bounded by retention window; grows during writes, compacts on idle.
27
- - **MCP clients.** Each `flair-mcp` subprocess holds ~40–50 MB. Long-lived MCP host (Claude Code) restarts spawn fresh ones; orphaned ones from the host crashing should be cleaned up by the parent-exit watcher (PR pending).
27
+ - **MCP clients.** Each `flair-mcp` subprocess holds ~40–50 MB. Long-lived MCP host (Claude Code) restarts spawn fresh ones; a lost subprocess exits on reparenting to PID 1 or stdin close/end.
28
28
 
29
29
  ## Scaling expectations
30
30
 
@@ -8,6 +8,17 @@ flair doctor
8
8
 
9
9
  ## Common Issues
10
10
 
11
+ ### BM25 index status
12
+
13
+ `flair status` prints the lexical index for the Harper worker that answered:
14
+
15
+ - `building 312/817 docs (38%) · started 4s ago` — the background build (started after embeddings boot) is in progress. A text search waits for that build.
16
+ - `ready · 817 docs · built in 1.2s · 3m ago` — the index is serving.
17
+ - `disabled — <reason>` — the index is not serving. After a feed error or a failed build, search uses a per-query scan and `flair status` also lists it as a warning. `FLAIR_BM25_INDEX is off` (the kill switch) and `retrieval mode is vector-only` are settings: the index is not built and they are not warnings.
18
+ - `not built yet — builds in the background after startup, or on the first text search` — the warm has not started. A text search builds it too.
19
+
20
+ With `THREADS_COUNT` greater than 1 the line names the worker it describes (`worker 3 of 4`). Each worker has its own index; the line is not a cluster total.
21
+
11
22
  ### Pre-0.18.0 flair-client / flair-mcp silently drops writes
12
23
 
13
24
  **Symptoms:** `memory_store` comes back as if it stored something (`written: false`, a `mergedWith` id, or a "deduplicated" record you did not write) and **zero rows** appear for the writing agent. The match it folded into can be **another agent's `shared` memory**. `flair doctor` after this server version names the pin.
package/docs/upgrade.md CHANGED
@@ -27,8 +27,12 @@ flair backup \
27
27
  # 2. Check what's outdated (doesn't install anything)
28
28
  flair upgrade --check
29
29
 
30
- # 3. Upgrade — installs, restarts, and verifies the new version is actually
31
- # serving, all in one step (see "Upgrade is a transaction" below)
30
+ # 3. Upgrade — installs, then restarts and verifies that the new version is
31
+ # serving (--no-restart skips both, --no-verify skips the verification).
32
+ # A failure does not always roll back: when a new flair package was
33
+ # installed and the pre-install /Health check was refused, a failed restart
34
+ # keeps the new package and exits successfully, printing the start error
35
+ # and `flair start`. See "Restart, verification and rollback" below
32
36
  flair upgrade
33
37
 
34
38
  # 4. Verify
@@ -36,6 +40,15 @@ flair status
36
40
  flair doctor
37
41
  ```
38
42
 
43
+ After a restart, `flair status` shows the BM25 index building in the
44
+ background (`building 312/817 docs (38%) · started 4s ago`) and then
45
+ `ready · 817 docs · built in 1.2s · 3m ago`. A text search issued while it
46
+ is building waits for that build. `disabled — <reason>` means the index is
47
+ not serving; the reason says why (after a failure, search is on the
48
+ per-query scan). With `FLAIR_BM25_INDEX=false` or vector-only retrieval the
49
+ index is not built at all. With `THREADS_COUNT` greater than 1 the line
50
+ names the worker it describes.
51
+
39
52
  `flair upgrade` checks and upgrades the npm-global packages (`@tpsdev-ai/flair`,
40
53
  `@tpsdev-ai/flair-mcp`) and, if present, the `openclaw-flair` plugin (via
41
54
  `openclaw plugins install --force --pin`, not `npm install -g` — it needs OpenClaw's
@@ -45,8 +58,8 @@ for each already-wired client (`~/.claude.json`, `~/.claude/settings.json`,
45
58
  `~/.codex/config.toml`, `~/.codex/hooks.json`, and the other auto-wired clients).
46
59
  Pass `--all` to also see `flair-client` (normally hidden as a
47
60
  transitive dependency). **Other integrations upgrade in their own ecosystem, not via
48
- `flair upgrade`:** `pi-flair` (pi's plugin manager), `langgraph-flair` / `hermes-flair`
49
- (pip / your Python package manager), `n8n-nodes-flair` (n8n's Community Nodes UI).
61
+ `flair upgrade`:** `pi-flair` (pi's plugin manager), `langgraph-flair` (an npm module), `hermes-flair`
62
+ (reinstall the plugin from a flair checkout: `hermes plugins install path:<flair>/packages/hermes-flair`), `n8n-nodes-flair` (n8n's Community Nodes UI).
50
63
 
51
64
  If the running instance's exec path is a **plain extracted tree** (npm pack +
52
65
  `npm install --omit=dev`, typically under systemd — no git checkout, not the
@@ -77,8 +90,16 @@ and:
77
90
  5. Restarts the systemd unit whose `WorkingDirectory` / `ExecStart` names the
78
91
  tree (`FLAIR_SYSTEMD_UNIT=flair.service` adds an explicit unit). If no unit
79
92
  is found, it falls back to `flair restart`
80
- 6. Verifies, then removes `.upgrade-prev`. On a failed restart or verify the
81
- previous tree is swapped back
93
+ 6. Verifies, then removes `.upgrade-prev` on success. A thrown restart error
94
+ keeps a swapped Flair package when the prior `/Health` connection was
95
+ refused (`keep`, successful exit). With a swap and a running or indeterminate
96
+ prior probe, a nonempty previous version selects rollback. No swap, or no
97
+ previous version after a running or indeterminate probe, selects `no-target`
98
+ (failure). Verification keeps an `ok` or `healthy-unverified` result;
99
+ other results select rollback with a
100
+ nonempty previous version, or `cannot-rollback` without one. A reported
101
+ deprecation blocks rollback, and a missing saved tree skips tree restoration.
102
+ See [Restart, verification and rollback](#restart-verification-and-rollback).
82
103
 
83
104
  ```bash
84
105
  flair upgrade --check --tree /opt/flair
@@ -90,48 +111,143 @@ flair upgrade --tree /opt/flair --flair-version 0.50.0
90
111
  without touching the tree. A git checkout or a path that *is* the npm-global
91
112
  install is refused rather than overwritten.
92
113
 
93
- ### Upgrade is a transaction
94
-
95
- As of flair#635, `flair upgrade` is install → restart → verify →
96
- rollback-on-failure, in one step — installing new code without restarting used
97
- to leave the OLD process serving while the version on disk lied about what was
98
- actually running:
99
-
100
- - **Restart happens automatically** after install. Pass `--no-restart` to
101
- stage the new packages without bouncing the process yet (the old
102
- opt-in `--restart` flag still parses but is now a no-op — restart is the
103
- default).
104
- - **The restart runs through the newly installed CLI** (flair#905), not the
105
- process that did the installing. Only version N's own code knows how version
106
- N starts — spawn arguments, required environment, config templates and the
107
- Harper dependency's own package name are all things a release may change, and
108
- the pre-swap process would get every one of them wrong the same silent way.
109
- The output names the CLI it handed the restart to. If that CLI can't be found
110
- or its version can't be confirmed, the upgrade says so and restarts in-process
111
- rather than refusing to start anything.
112
- - **Post-restart verification** (skip with `--no-verify`) confirms the
113
- restarted instance answers `/Health`, that an authenticated request
114
- round-trips, and that the reported running version matches what was just
115
- installed. It then runs the same enumerable doctor install-health checks
116
- (`flair doctor`'s client-integration catalog, plus launchd management)
117
- and prints `✅ verified: healthy` only when every check ran and none
118
- failed. A missing Codex SessionStart hook — which `flair init` before
119
- 0.50.0 never wrote — is one of those checks. Installing the hook is
120
- consent-bearing (it executes at every session start): an interactive
121
- upgrade prompts; a non-interactive upgrade states the gap and withholds
122
- ✅. Pass `--install-hooks` to consent without a prompt, then `flair
123
- doctor` exits 0.
124
- - **On a failed restart OR a failed verification**, `flair upgrade`
125
- automatically reinstalls the previously-running `@tpsdev-ai/flair` version,
126
- restarts again, and re-verifies — then exits nonzero with a clear report of
127
- what failed. Until flair#905 the rollback was wired to the *verification* leg
128
- only: an upgrade that installed new packages and then failed to start them
129
- exited 1 and left the operator on the new version with nothing running, which
130
- is the single outcome this transaction exists to prevent. If the
131
- rollback itself fails verification, it says so loudly and points at the
132
- concrete pre-upgrade snapshot path (see "Pre-upgrade snapshot" below)
133
- instead of retrying in a loop — see [Downgrade](#downgrade) for the
134
- restore procedure.
114
+ ### After a Node bump: the CLI and the instance in different install trees
115
+
116
+ A service unit bakes the node binary and install tree of the runtime it was
117
+ written under. After a Node version bump, `flair` on your PATH can come from the
118
+ new runtime's global tree while the instance keeps serving the old one.
119
+ `flair status`, `flair upgrade`, `flair doctor` and `flair restart` name this —
120
+ both trees, both versions, the unit — but only when it is **proven**: the
121
+ service manager must own the process that answered — the one process listening
122
+ on the instance's port, which must also be the PID the instance reported about
123
+ itself when it reported one. Two listeners, none, or a PID file that names
124
+ another process make the answer unknown; only when the port's listeners cannot
125
+ be read at all (`lsof` missing or failing) does a reported PID stand on its own.
126
+ On Linux, the unit is found from that process — its cgroup (`/proc/<pid>/cgroup`,
127
+ cgroup v2) names the systemd user unit it runs in — and systemd must report that
128
+ process as the unit's MainPID and the unit's file in `~/.config/systemd/user` as
129
+ its `FragmentPath`. Because the unit comes from the process, not from a tree path
130
+ in a unit file, it is still found after `flair init` re-pointed the file: the
131
+ state is then diverged with `flair restart` as the remedy. Otherwise the serving
132
+ tree is reported as unknown and nothing is advised from it.
133
+
134
+ The remedy is `flair init && flair restart`. `flair init` re-points the
135
+ instance's own unit — **only** its launcher, node, Harper entry and working
136
+ directory — and writes nothing unless the unit is provably this instance's and
137
+ exactly a shape flair supports:
138
+
139
+ | | Written only when | Refused (nothing written) |
140
+ |---|---|---|
141
+ | macOS plist (`~/Library/LaunchAgents/ai.tpsdev.flair.<hash>.plist`), read as XML structure | one Label (this data directory's) at the top level, ROOTPATH (this data directory) and HOME (yours) in `EnvironmentVariables`, no `Program` key, ProgramArguments = the launcher in its WorkingDirectory tree, this instance's admin-pass file, a `node`, a Harper entry in that tree | a plist that is not this instance's or not in that shape — another HOME, label or pass file, an extra argument, a key in the wrong dict — and an XML declaration naming an encoding other than UTF-8, an XML comment, CDATA, a character reference, a duplicate key, or an unsupported XML element |
142
+ | Linux systemd user unit (the one proven above) | one `WorkingDirectory=` (the served tree) and one `ExecStart=` of `<node> <harper.js> run .` or `<launcher> <admin-pass file> <node> <harper.js>`, optional `-` prefix | drop-ins (any location systemd reports, or `<unit>.d` beside the file), any other argument (operator arguments are never rewritten), quoting, `%` specifiers, `$` variables, line continuations, other `ExecStart=` prefixes, and a new path that would need quoting |
143
+ | Both, when moving to a different installed tree | the old tree is an npm-global install; its flair version and this CLI's are strict semver and this CLI's is not older (prereleases count: `0.57.0-beta.1` is older than `0.57.0`) | a plain tree or checkout (separately managed), an unreadable, non-semver or newer version (a downgrade cannot be ruled out) |
144
+
145
+ A unit that serves this CLI's tree with a different, existing node is treated
146
+ as a deliberate pin: `flair init` leaves it, and init and `flair doctor` report it
147
+ with the hand edit that would move it. A plist that already serves this CLI's
148
+ tree has a missing runtime path replaced without the version check in the table,
149
+ which applies only to a move between trees. The write is atomic and
150
+ lands only over the bytes it was planned from — the file is read as a regular
151
+ file (a symlink is refused, not followed) whose bytes are valid UTF-8 (anything
152
+ else is refused before planning), and its bytes are re-checked immediately
153
+ before the rename, so an edit saved in between refuses the write. On Linux,
154
+ `flair init` first records what systemd holds for the unit (it writes nothing
155
+ if it cannot, or if systemd no longer reports the serving process as the
156
+ unit's MainPID), then runs `systemctl --user daemon-reload` (which also loads any
157
+ other pending edits to your user units) and checks what systemd loaded. If the
158
+ reload fails or systemd does not hold the re-pointed unit, the previous bytes
159
+ are restored, systemd is reloaded and asked again. That check covers three
160
+ fields: when systemd's FragmentPath, drop-ins and WorkingDirectory are back at
161
+ the values recorded before the write, flair says exactly that and still calls
162
+ full agreement between the restored file and systemd unverified; otherwise it
163
+ reports systemd's state as unverified. Every refusal names the file, what did not match, and the
164
+ remedy — the paths to set by hand, an update of this CLI's tree, or a
165
+ reinstall; after a hand edit, `flair restart` brings the instance up under
166
+ the edited unit (macOS reloads the plist; on Linux, when the unit is proven to
167
+ run the instance, it reloads systemd, restarts through the unit and checks that
168
+ the unit's new main process runs from its WorkingDirectory). On Linux,
169
+ `flair restart` never stops a process that a systemd unit supervises — one
170
+ systemd reports as that unit's MainPID — and starts it again outside the unit:
171
+ when it is not the proven unit, it refuses and names the `systemctl` command to
172
+ use. It also refuses when flair cannot learn the MainPID of the unit the
173
+ process's cgroup names (systemd cannot be asked, or reports no main process),
174
+ naming the same command, and when the process's cgroup cannot be read at all
175
+ or contradicts itself (for example, a user slice and a user manager that name
176
+ different users, or one unit's cgroup nested in another's) — then no manager is
177
+ asked.
178
+ A process that only runs inside some service's cgroup without being its main
179
+ process (a child of a CI runner agent, a terminal multiplexer or an ssh session
180
+ service) was started directly, and `flair restart` restarts it directly.
181
+
182
+ The federation-sync shim (`~/.flair/bin/flair-federation-sync`) is re-pointed
183
+ the same way: only its exec line changes, the scheduler unit is never
184
+ rewritten, and the shim is refused when it is a symlink or not valid UTF-8,
185
+ changes between the read and the rename, runs any command other than what
186
+ `flair federation sync enable` writes (comment lines are not compared), or —
187
+ when it is moved to a different installed tree — when that tree's version (or
188
+ this CLI's) is not strict semver or is newer.
189
+ `flair federation sync enable` regenerates it.
190
+
191
+ ### Restart, verification and rollback
192
+
193
+ In the local upgrade path, `--no-restart` skips restart and post-restart
194
+ verification. With restart enabled, the pre-install `/Health` probe runs, also
195
+ under `--no-verify`. With `--no-restart`, it runs only when a pre-upgrade
196
+ snapshot is needed, to decide whether that snapshot restarts the old instance.
197
+
198
+ The probe labels a successful HTTP response `running`. A caught error is
199
+ `stopped` when every failure in it, including each `cause` and aggregated
200
+ error, is a connection refusal: a string code must be `ECONNREFUSED` or
201
+ `ConnectionRefused`, and an uncoded failure with no nested failures must
202
+ contain one of them in its text. Other responses and caught errors are
203
+ `indeterminate`.
204
+ The `stopped` label does not establish whether a process exists.
205
+
206
+ After a thrown restart error, `decideAfterRestartFailure` selects:
207
+
208
+ | Flair itself was swapped | Prior probe | Previous version | Decision |
209
+ | --- | --- | --- | --- |
210
+ | No | Any | Any | `no-target` |
211
+ | Yes | `stopped` | Any | `keep` |
212
+ | Yes | `running` or `indeterminate` | Nonempty | `rollback` |
213
+ | Yes | `running` or `indeterminate` | Missing or empty | `no-target` |
214
+
215
+ `keep` leaves the new package installed, prints the start error and
216
+ `flair start`, and exits successfully. `no-target` exits with failure.
217
+ `rollback` enters the shared rollback path below.
218
+
219
+ When post-restart verification runs, `decideAfterVerify` returns `ok` for
220
+ a successful probe; otherwise it returns `healthy-unverified` when the probe
221
+ reports healthy with a credentials failure. Other results select `rollback`
222
+ for a nonempty previous version and `cannot-rollback` otherwise; the latter exits
223
+ with failure. Prior liveness and the swap flag are not inputs to this decision.
224
+
225
+ The shared rollback path refuses a target reported deprecated by the registry
226
+ lookup and exits with failure. Failed or unusable lookups, including a null
227
+ `deprecated` field, allow the attempt. npm-global attempts to reinstall the
228
+ previous package version; plain-tree attempts to restore the saved tree when
229
+ it exists and skips restoration when it is absent. The tree restore first
230
+ attempts to move the live path to `.upgrade-failed` when it exists.
231
+
232
+ After that stage, an engine change requires a snapshot path and successful
233
+ snapshot restoration before restart. Before restoring, rollback stops the
234
+ instance and requires fresh daemon evidence that it is stopped. It then moves
235
+ the current data directory to a unique, timestamped sibling named
236
+ `<data-dir>.pre-rollback-<timestamp>-<suffix>` and prints that retained path.
237
+ Rollback never deletes this retained directory. If stopping, confirming the
238
+ stop, validating the snapshot, or moving the data aside fails, restoration is
239
+ refused without replacing the current data. To recover writes made after the
240
+ snapshot, stop Flair, set aside the restored data directory, move the retained
241
+ directory back, and start with the Harper engine version that wrote it.
242
+ Rollback then attempts restart and, if restart returns, verification; its
243
+ reported outcomes exit with failure.
244
+
245
+ If that restart throws, the npm-global and restored-tree diagnostics label
246
+ the rollback target known-broken for this attempt. The missing-tree diagnostic
247
+ uses a neutral headline. Plain-tree recovery text reports whether the previous
248
+ tree was restored and whether a live tree was set aside. Both lanes report
249
+ whether a data snapshot was restored. An npm version candidate printed by
250
+ this message is not guaranteed non-deprecated.
135
251
 
136
252
  ### Pre-upgrade snapshot (opt-in for same-engine, unconditional on engine change)
137
253
 
@@ -177,23 +293,23 @@ To capture one first: `flair snapshot create` (physical) or `flair backup` (logi
177
293
  - **Retention:** keeps the newest 3 snapshots, prunes older ones automatically after
178
294
  each successful snapshot — whether taken via `--snapshot` or `flair snapshot create`
179
295
  (below); both draw from the same `~/.flair/upgrade-snapshots/` pool.
180
- - **Consistency:** when a snapshot is taken (`--snapshot`, or `flair snapshot create`),
181
- Flair is briefly stopped, snapshotted, and immediately restarted on the same version
182
- before anything else happens — a plain file copy of a *running* Harper's data
183
- directory isn't guaranteed point-in-time consistent (Harper 5.x stores tables in
184
- RocksDB — an LSM engine whose WAL, MANIFEST, and SST files can be
185
- mid-write/mid-compaction), so the snapshot always happens against a quiesced
186
- directory. During an upgrade this means a short stop/start blip even with
187
- `--no-restart` — the snapshot's correctness doesn't depend on whether you want a
188
- restart *after* the upgrade, those are separate questions. (A native Harper backup
189
- operation, `get_backup`, was evaluated and rejected here — see the code comment
296
+ - **Consistency:** a snapshot uses a stopped, quiesced data directory — a plain
297
+ file copy of a *running* Harper's data directory isn't guaranteed point-in-time
298
+ consistent (Harper 5.x stores tables in RocksDB, whose WAL, MANIFEST, and SST
299
+ files can be mid-write/mid-compaction). `flair snapshot create` restarts Flair
300
+ afterward. During an upgrade, the old version is restarted after the snapshot
301
+ only if the pre-install `/Health` probe did not refuse the connection. A refused
302
+ connection leaves it stopped through the package swap. An instance that answered
303
+ or had indeterminate liveness has a short stop/start blip even with
304
+ `--no-restart`; that flag controls the restart *after* the upgrade. (A native
305
+ Harper backup operation, `get_backup`, was evaluated and rejected here — see the code comment
190
306
  above `createDataSnapshot` in `src/cli.ts` for why: it backs up one table/schema at a
191
307
  time over the running HTTP API, not the whole data directory, and would be strictly
192
308
  less complete than a plain file copy.)
193
309
  - **Failure is a hard stop when requested:** if you passed `--snapshot` and the
194
310
  snapshot itself fails (disk full, permissions, etc.), the upgrade aborts before any
195
- package changes — no packages are swapped, Flair is restarted on the version it was
196
- already running.
311
+ package changes. Flair is restarted on the old version only if the pre-install
312
+ `/Health` probe did not refuse the connection.
197
313
 
198
314
  #### `flair snapshot` — the standalone command
199
315
 
@@ -443,9 +559,19 @@ flair restart
443
559
  flair restore ~/flair-backup-<date>.json
444
560
  ```
445
561
 
446
- `flair upgrade` does this automatically on a failed post-restart verification — see
447
- "Upgrade is a transaction" above. This section is for doing it by hand, e.g. after
448
- `--no-verify`, or after problems surface later than the automatic check catches.
562
+ `flair upgrade` selects automatic rollback after post-restart verification only
563
+ when the result is neither `ok` nor `healthy-unverified` and a nonempty previous
564
+ version is available; otherwise a failed result is `cannot-rollback`. A thrown
565
+ restart error instead keeps a swapped Flair package after a refused pre-upgrade
566
+ `/Health` connection (`keep`, successful exit). No swap, or no previous version
567
+ after a running or indeterminate probe, selects `no-target`; a swap with that
568
+ probe and a nonempty previous version selects rollback. Reported deprecation
569
+ blocks rollback; a missing saved plain-tree directory skips tree restoration.
570
+ Engine-change data restoration requires a confirmed stop and retention of the
571
+ current directory. See [Restart, verification and rollback](#restart-verification-and-rollback)
572
+ for the decisions and retained-data recovery instructions. This section is for
573
+ manual recovery, e.g. after `--no-verify`, or after problems surface later than
574
+ the automatic check catches.
449
575
 
450
576
  ### Known issue — upgrading *from* an older version can still report a false rollback
451
577
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair",
3
- "version": "0.56.0",
3
+ "version": "0.58.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",
@@ -76,9 +76,9 @@
76
76
  },
77
77
  "overrides": {
78
78
  "react-native-fs": "npm:empty-npm-package@1.0.0",
79
- "brace-expansion": "^5.0.9",
80
- "undici": "^8.9.0",
81
- "fast-uri": "^4.1.3",
79
+ "brace-expansion": "^5.0.12",
80
+ "undici": "~8.10.2",
81
+ "fast-uri": "^4.1.5",
82
82
  "hono": "^4.13.5",
83
83
  "js-yaml": "^4.3.2",
84
84
  "adm-zip": "^0.6.1",
@@ -90,7 +90,11 @@
90
90
  "mysql2": "^3.22.0",
91
91
  "mariadb": "~3.4.7",
92
92
  "qs": "^6.16.0",
93
- "fastify": "^5.12.1"
93
+ "fastify": "^5.12.1",
94
+ "lodash": "^4.18.0",
95
+ "ip-address": "^10.5.1",
96
+ "joi": "^17.13.7",
97
+ "moment": "^2.31.0"
94
98
  },
95
99
  "devDependencies": {
96
100
  "@playwright/test": "1.59.1",
@@ -23,12 +23,15 @@ type Agent @table(database: "flair") @export {
23
23
  createdAt: String!
24
24
  updatedAt: String
25
25
  originatorInstanceId: String @indexed # federation-edge-hardening slice 1 — write-time instance identity,
26
- # stamped server-side in resources/Agent.ts's post()/put() from
27
- # resources/instance-identity.ts's localInstanceId(). Nullable (existing rows
28
- # read null = clean upgrade); preserved (never re-stamped) as the record flows
29
- # through federation sync merges. See schemas/memory.graphql's Memory.
30
- # originatorInstanceId for the full contract — same field, same idiom, this is
31
- # one of the 4 synced tables (Memory/Soul/Agent/Relationship).
26
+ # stamped server-side in resources/Agent.ts's post()/put() via
27
+ # resources/originator-instance.ts from resources/instance-identity.ts's
28
+ # localInstanceId(). On CREATE the local id is stamped (a request-body value is
29
+ # ignored); on UPDATE the STORED value stands (a body value neither replaces nor
30
+ # clears it). Nullable (existing rows read null = clean upgrade); preserved
31
+ # (never re-stamped) as the record flows through federation sync merges. See
32
+ # schemas/memory.graphql's Memory.originatorInstanceId for the full contract —
33
+ # same field, same idiom, this is one of the 4 synced tables
34
+ # (Memory/Soul/Agent/Relationship).
32
35
  }
33
36
 
34
37
  # Credential table — auth surfaces for Principals.