@tpsdev-ai/flair 0.54.2 → 0.55.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/build-info.json +3 -3
  2. package/dist/cli.js +774 -176
  3. package/dist/commands/doctor.js +86 -1
  4. package/dist/commands/federation.js +131 -36
  5. package/dist/commands/hook.js +20 -10
  6. package/dist/commands/init.js +193 -67
  7. package/dist/commands/service.js +16 -12
  8. package/dist/commands/soul.js +10 -5
  9. package/dist/commands/status.js +62 -7
  10. package/dist/commands/upgrade.js +6 -0
  11. package/dist/doctor-client.js +118 -32
  12. package/dist/hook-install.js +170 -16
  13. package/dist/lib/doctor-run.js +49 -3
  14. package/dist/lib/embed-gpu-doctor.js +63 -0
  15. package/dist/lib/federation-pair-access.js +118 -0
  16. package/dist/lib/harper-port-value.js +43 -0
  17. package/dist/lib/http-bind.js +227 -0
  18. package/dist/lib/init-admin-pass.js +316 -0
  19. package/dist/lib/launchd-management.js +16 -0
  20. package/dist/lib/launchd-repair.js +122 -1
  21. package/dist/lib/owned-pins.js +54 -1
  22. package/dist/lib/process-start-time.js +82 -0
  23. package/dist/lib/scratch-owner.js +124 -10
  24. package/dist/lib/stale-client-pin.js +26 -0
  25. package/dist/lib/upgrade-plain-tree.js +293 -48
  26. package/dist/rem/runner.js +10 -1
  27. package/dist/resources/AdminInstance.js +8 -2
  28. package/dist/resources/Memory.js +36 -1
  29. package/dist/resources/MemoryBootstrap.js +23 -32
  30. package/dist/resources/MemoryFeed.js +4 -1
  31. package/dist/resources/MemoryReflect.js +121 -93
  32. package/dist/resources/SkillScan.js +13 -11
  33. package/dist/resources/Soul.js +15 -1
  34. package/dist/resources/XAA.js +16 -1
  35. package/dist/resources/a2a-url.js +5 -2
  36. package/dist/resources/client-version-gate.js +144 -0
  37. package/dist/resources/embed-gpu.js +241 -0
  38. package/dist/resources/embeddings-boot.js +34 -42
  39. package/dist/resources/federation-peer-liveness.js +7 -1
  40. package/dist/resources/health.js +12 -3
  41. package/dist/resources/memory-reflect-lib.js +66 -0
  42. package/dist/resources/memory-reflect-models.js +9 -0
  43. package/dist/resources/migrations/embedding-stamp.js +32 -4
  44. package/dist/resources/oauth-discovery.js +3 -1
  45. package/dist/resources/record-type-kit.js +59 -0
  46. package/dist/resources/scan/skill-markdown.js +166 -0
  47. package/dist/resources/scan/skill-scanner.js +89 -68
  48. package/dist/resources/skill-provenance.js +273 -0
  49. package/dist/resources/skill-write.js +26 -7
  50. package/dist/src/lib/harper-port-value.js +43 -0
  51. package/docs/api-reference.md +35 -2
  52. package/docs/deployment.md +39 -6
  53. package/docs/federation.md +18 -7
  54. package/docs/mcp-clients.md +19 -6
  55. package/docs/releasing.md +79 -13
  56. package/docs/rem.md +1 -1
  57. package/docs/secrets-and-keys.md +1 -0
  58. package/docs/standalone-local.md +8 -5
  59. package/docs/troubleshooting.md +17 -0
  60. package/package.json +1 -1
package/docs/releasing.md CHANGED
@@ -2,8 +2,17 @@
2
2
 
3
3
  Flair publishes nine workspace packages to npm under `@tpsdev-ai/*`. Releases are
4
4
  **tokenless** and **staged**: CI authenticates to npm with a short-lived OIDC token
5
- (no `NPM_TOKEN` lives anywhere) and submits each package to npm's **staging** area.
6
- A maintainer then approves the staged tarballs on npmjs.com with 2FA to make them live.
5
+ (no `NPM_TOKEN` lives anywhere) and submits each package to npm's **staging** area
6
+ **under the `staged` tag** (never straight to `latest`). A maintainer then approves
7
+ the staged tarballs on npmjs.com with 2FA. Approval makes the version public, but
8
+ **not `latest`** — a credential-less post-publish canary installs that exact version
9
+ from the registry and boots it on Linux and macOS. Only a canary PASS prints the
10
+ sha256-bound promote command that moves `latest`; the canary runs on the same
11
+ definition of "it boots" the rockit ritual uses (`scripts/ci/check-instance-boot.sh`).
12
+
13
+ The staging tag is an **immutable property of the staged package** (`npm help stage`):
14
+ re-staging the same version under a different tag requires `npm stage reject` first.
15
+ There is no "fix the stage in place" — you reject it and re-cut the next patch.
7
16
 
8
17
  > `flair-bench` is version-bumped and tagged in lockstep with the other 7, and stages in
9
18
  > its own step in CI for [historical reasons](#flair-bench-bootstrap-one-time-done). That
@@ -11,11 +20,18 @@ A maintainer then approves the staged tarballs on npmjs.com with 2FA to make the
11
20
  > for a release to pass.
12
21
 
13
22
  ```
14
- merge release PR ──▶ push tag v0.11.0 ──▶ CI stages all packages ──▶ npm staging
23
+ merge release PR ──▶ push tag v0.11.0 ──▶ CI stages all packages (tag: staged)
15
24
  │
16
25
  maintainer reviews + approves (2FA)
17
26
  ▼
18
- live on npm
27
+ public on npm, NOT latest ──▶ post-publish canary
28
+ │ installs the exact
29
+ │ version + boots it
30
+ canary PASS ───────┘
31
+ │
32
+ paste the emitted promote line
33
+ ▼
34
+ latest moves
19
35
  ```
20
36
 
21
37
  Pushing a `vX.Y.Z` tag triggers the release. This replaces the old "run
@@ -111,18 +127,67 @@ review each staged tarball, and approve with 2FA. Or from a machine logged into
111
127
  ```bash
112
128
  npm stage list # show staged packages + their stage-ids
113
129
  npm stage view <stage-id> # inspect one
114
- npm stage approve <stage-id> # 2FA prompt; package goes live
130
+ npm stage approve <stage-id> # 2FA prompt; package is made public under `staged`
115
131
  ```
116
132
 
117
133
  There are eight lockstep-staged packages, so eight approvals (the web UI lists them on
118
134
  one page). Approve in dependency order if installing immediately — flair-client before
119
135
  its dependents — though staging does not itself resolve dependencies.
120
136
 
121
- Verify when done:
122
-
123
- ```bash
124
- npm view @tpsdev-ai/flair version # should report the new version
125
- ```
137
+ Approval makes each version **public but not `latest`**: a user who runs the bare
138
+ `npm install -g @tpsdev-ai/flair` still gets the previous `latest` until the promote
139
+ step below. That window is what the canary uses.
140
+
141
+ The staging tag is immutable — if a staged package is wrong, **reject** it
142
+ (`npm stage reject <stage-id>` on npmjs.com) and cut the next patch. The same version
143
+ cannot be re-staged under a different tag.
144
+
145
+ ### Phase 4 — run the post-publish canary
146
+
147
+ The moment the staged packages are approved, dispatch the
148
+ [`post-publish canary`](../.github/workflows/canary.yml) (Actions → "Post-publish canary
149
+ — install + boot a published version") with two inputs:
150
+
151
+ | Input | Value |
152
+ | ----- | ----- |
153
+ | `version` | the version just approved, exact (e.g. `vX.Y.Z` without the `v`) |
154
+ | `expected_sha256` | the published tarball's sha256 (64 hex). The canary computes it from the registry with `node scripts/ci/registry-tarball-sha256.mjs <ver>`. |
155
+
156
+ The canary runs on clean `ubuntu-latest` and `macos-latest` runners and is
157
+ **credential-less**: it installs `@tpsdev-ai/flair@<ver>` by exact version from the
158
+ public registry, downloads the published tarball and verifies its sha256 equals
159
+ `expected_sha256` (npm exposes no sha256 directly — `dist.shasum` is a SHA-1), runs
160
+ the four install-tree assertions (`scripts/check-global-install-lockfile.mjs
161
+ --registry-version`), and boots the installed instance
162
+ (`scripts/ci/check-instance-boot.sh`: init with a 0600 pass file → adopt → `/Health`
163
+ from the supervised process → `flair doctor` → descriptors → clean stop).
164
+
165
+ It then installs the published `@tpsdev-ai/flair-mcp@<ver>` and
166
+ `@tpsdev-ai/flair-client@<ver>` (exact version, never a dist-tag) into a throwaway
167
+ prefix, writes the documented host config (`npx -y @tpsdev-ai/flair-mcp@<ver>`),
168
+ and drives a real `memory_store` → `memory_get` tool-call against the canary-booted
169
+ instance (`scripts/ci/check-plugin-canary.mjs`). That is the path a host actually
170
+ runs — not an in-process import of this checkout. A missing registry package, a
171
+ host that never comes up, or any other unmeasurable result is a FAIL, not a skip.
172
+
173
+ Nothing about the canary is optional. There is no `continue-on-error`, and an
174
+ unmeasurable run (registry lag, runner outage) is a FAIL, not a skip — a check that did
175
+ not run must not read as a pass.
176
+
177
+ ### Phase 5 — promote `latest` (or deprecate)
178
+
179
+ - **On PASS**, the canary emits the complete, sha256-bound promote command. Run it
180
+ from a repo checkout on a machine logged into npm:
181
+
182
+ ```bash
183
+ test "$(node scripts/ci/registry-tarball-sha256.mjs <ver>)" = "<sha256>" && npm dist-tag add @tpsdev-ai/flair@<ver> latest
184
+ ```
185
+
186
+ The `test` is the integrity guard: a stale PASS, a re-cut version, or a paste from a
187
+ failed run aborts before `latest` moves.
188
+ - **On FAIL**, the version stays public but unpromoted. The canary emits the
189
+ `npm deprecate` command; run it, then re-cut the next patch. A version is never
190
+ refreshed in place.
126
191
 
127
192
  ## One-time setup
128
193
 
@@ -210,9 +275,10 @@ The maintainer who approves staged packages must have 2FA enabled on their npm a
210
275
 
211
276
  - **A staged package looks wrong** — reject it on npmjs.com instead of approving; it
212
277
  never goes live. Fix forward on `main` and cut a new patch version.
213
- - **Re-run the stage for the same version** — delete and re-push the tag
214
- (`git push origin :v0.11.0` then `git tag -f v0.11.0 && git push origin v0.11.0`).
215
- The tag push re-triggers the workflow.
278
+ - **Re-run the stage for the same version** — you cannot. The `staged` tag is an
279
+ immutable property of the staged package, so re-stage requires reject first. Reject
280
+ the staged package(s) on npmjs.com, then cut and tag the next patch version; a
281
+ re-pushed tag re-triggers the workflow for that new version.
216
282
  - **Break-glass (CI down):** `./scripts/release.sh X.Y.Z --publish` still works from a
217
283
  machine logged into npm. Prefer the staged flow; this bypasses the staging gate.
218
284
 
package/docs/rem.md CHANGED
@@ -56,7 +56,7 @@ Snapshot locality follows from this: a nightly cycle's pre-run snapshot (`~/.fla
56
56
 
57
57
  ## Interactive vs nightly
58
58
 
59
- - **Interactive (`flair rem rapid`):** one bounded, synchronous distillation call — gather cap 50 memories, bounded output tokens, seconds not minutes. Executes by default, staging candidates and printing a summary; `--prompt-only` returns the reflection prompt instead, for the bring-your-own-model handoff.
59
+ - **Interactive (`flair rem rapid`):** one bounded, synchronous distillation call — gather cap 50 memories, bounded output tokens, seconds not minutes. Executes by default, staging candidates and printing a summary; `--prompt-only` returns the reflection prompt instead, for the bring-your-own-model handoff. A cold generative backend (first Ollama model load) is warmed outside Harper's request transaction so execute fails as the documented 502/503, not HTTP 422 from the 30s open-transaction ceiling.
60
60
  - **Nightly (`flair rem nightly enable` / `run-once`):** fully detached — the scheduler runs the full cycle (snapshot → maintenance → distillation), candidates land as pending rows, and an audit row lands in `~/.flair/logs/rem-nightly.jsonl`. The operator reviews in the morning via `flair rem candidates`.
61
61
 
62
62
  ### Safety bounds (a large backlog must not take the instance down)
@@ -18,6 +18,7 @@ Agents sign every request to Flair with this key. Flair refuses unsigned request
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
22
  ## What Flair does *not* own: API keys, tokens, third-party credentials
22
23
 
23
24
  Things that are NOT Flair's job:
@@ -79,7 +79,7 @@ All configuration lives in `~/.flair/`:
79
79
 
80
80
  ```
81
81
  ~/.flair/
82
- ├── config.yaml # port, host, embedding model
82
+ ├── config.yaml # port, bind host, embedding model
83
83
  ├── data/ # Harper database (RocksDB)
84
84
  ├── keys/ # Ed25519 keypairs per agent (mode 0600)
85
85
  └── backups/ # flair backup output
@@ -87,10 +87,12 @@ All configuration lives in `~/.flair/`:
87
87
 
88
88
  ### Key config options (`~/.flair/config.yaml`)
89
89
 
90
+ Flair's own config file uses **top-level** keys — there is no nested `http:`
91
+ block, and no `http.host` (see [`deployment.md` — Direct network access](deployment.md#direct-network-access) for widening):
92
+
90
93
  ```yaml
91
- http:
92
- port: 19926 # API port (ops port = this - 1)
93
- host: 127.0.0.1 # bind address (0.0.0.0 for remote access)
94
+ port: 19926 # API port (ops port = this - 1)
95
+ httpBind: 127.0.0.1 # HTTP bind host; 0.0.0.0 widens (must include IPv4 loopback)
94
96
 
95
97
  clustering:
96
98
  nodeName: flair
@@ -108,8 +110,9 @@ logging:
108
110
  | `HDB_ADMIN_PASSWORD` | Bootstrap password for the embedded Harper. After first start, the persisted user record is the source of truth. | Set at install time. See [secrets-and-keys.md](secrets-and-keys.md) for rotation. |
109
111
  | `FLAIR_KEY_PASSPHRASE` | Passphrase for AES-256-GCM encryption of federation private-key seeds. | Set explicitly for production federation deployments. |
110
112
  | `FLAIR_URL` | Override the Flair base URL for CLI commands (points to a remote instance). | When connecting from a different machine. |
113
+ | `FLAIR_HTTP_BIND` | HTTP API bind host. Resolution order: `flair init --http-bind` > this variable > top-level `httpBind` in `~/.flair/config.yaml` > `127.0.0.1`. Only `127.0.0.1` or a wildcard (`0.0.0.0` / `::`) is accepted. | When the HTTP API must be reachable off-host; prefer recording it once with `flair init --http-bind 0.0.0.0`. See [deployment.md](deployment.md#direct-network-access). |
111
114
  | `FLAIR_EMBED_THREADS` | CPU threads for in-process embedding. Default is `max(1, availableParallelism() − 1)` — host-aware, one core left for Harper. | Pin a positive integer on a dedicated ingest host, or when the default leaves cores idle / oversubscribed. See [deployment.md](deployment.md#performance-related-environment-variables). |
112
- | `FLAIR_EMBED_GPU_LAYERS` | GPU layers to offload. Unset leaves HFE's default of 0 (CPU only) — this is a pin, not a new default. | Only to measure Metal offload (`99`) or pin CPU (`0`). See [deployment.md](deployment.md#performance-related-environment-variables) and #1437. |
115
+ | `FLAIR_EMBED_GPU_LAYERS` | GPU layers to offload. Unset derives Metal (`99`) on Apple Silicon with a usable Metal prebuilt, else CPU (`0`). Stated on `/Health`. | Pin CPU with `0` on a Metal Mac, or force a layer count. See [deployment.md](deployment.md#performance-related-environment-variables). |
113
116
  | `FLAIR_HYBRID_RETRIEVAL` | Hybrid BM25 + vector retrieval (default on). | Set `false` to revert to HNSW-only. |
114
117
  | `FLAIR_MODELS_DIR` | Directory the embedding GGUF is loaded from. | When the model lives outside `<data-dir>/models`. |
115
118
 
@@ -8,6 +8,23 @@ flair doctor
8
8
 
9
9
  ## Common Issues
10
10
 
11
+ ### Pre-0.18.0 flair-client / flair-mcp silently drops writes
12
+
13
+ **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.
14
+
15
+ **This is not fixed by upgrading the server.** An `@tpsdev-ai/flair-client` older than 0.18.0 (shipped inside `@tpsdev-ai/flair-mcp` ≤ 0.17, and still live in stale adapter pins) runs a cosine-only preflight and returns the existing record **without ever issuing the PUT**. The server cannot run its cosine-AND-Jaccard gate on a request that never arrives.
16
+
17
+ **Fix — upgrade the adapter:**
18
+
19
+ ```bash
20
+ flair upgrade
21
+ # or pin the MCP server / client library yourself
22
+ # @tpsdev-ai/flair-mcp@<current> (must be >= 0.18.0)
23
+ # @tpsdev-ai/flair-client@<current>
24
+ ```
25
+
26
+ Then restart the MCP host so it respawns `flair-mcp`. A current server that *sees* a client older than 0.18.0 on a Memory write (`X-Flair-Client: flair-client/0.17.0`) refuses it with HTTP 426 `stale_flair_client` instead of serving silent loss.
27
+
11
28
  ### "Harper is not running"
12
29
 
13
30
  **Symptoms:** `flair status` shows not running, bootstrap fails.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tpsdev-ai/flair",
3
- "version": "0.54.2",
3
+ "version": "0.55.1",
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",