@tpsdev-ai/flair 0.57.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 (122) hide show
  1. package/README.md +4 -4
  2. package/SECURITY.md +4 -1
  3. package/dist/build-info.json +3 -3
  4. package/dist/cli.js +1685 -279
  5. package/dist/commands/doctor.js +162 -4
  6. package/dist/commands/federation.js +2 -1
  7. package/dist/commands/hook.js +10 -2
  8. package/dist/commands/init.js +150 -44
  9. package/dist/commands/memory.js +24 -2
  10. package/dist/commands/quality.js +26 -18
  11. package/dist/commands/service.js +137 -22
  12. package/dist/commands/status.js +114 -3
  13. package/dist/commands/upgrade.js +204 -84
  14. package/dist/doctor-client.js +50 -4
  15. package/dist/federation/scheduler.js +253 -4
  16. package/dist/install/clients.js +89 -23
  17. package/dist/install/global-bin-path.js +26 -6
  18. package/dist/lib/atomic-write.js +256 -0
  19. package/dist/lib/daemon-liveness.js +61 -0
  20. package/dist/lib/doctor-run.js +5 -0
  21. package/dist/lib/embed-gpu-doctor.js +49 -26
  22. package/dist/lib/federation-memory-attributes.js +15 -0
  23. package/dist/lib/init-admin-pass.js +4 -2
  24. package/dist/lib/init-listener-environ.js +38 -0
  25. package/dist/lib/init-occupied-listener.js +165 -0
  26. package/dist/lib/launchd-domain-preflight.js +448 -0
  27. package/dist/lib/launchd-management.js +176 -6
  28. package/dist/lib/launchd-repair.js +95 -0
  29. package/dist/lib/memory-attributes.js +77 -0
  30. package/dist/lib/node-alias-path.js +95 -0
  31. package/dist/lib/npm-registry.js +119 -6
  32. package/dist/lib/owned-pins.js +20 -6
  33. package/dist/lib/service-repoint-apply.js +267 -0
  34. package/dist/lib/service-repoint.js +575 -0
  35. package/dist/lib/toml-string-array.js +104 -0
  36. package/dist/lib/tree-divergence.js +716 -0
  37. package/dist/lib/upgrade-plain-tree.js +18 -8
  38. package/dist/lib/upgrade-prior-liveness.js +69 -0
  39. package/dist/lib/upgrade-rollback.js +116 -0
  40. package/dist/rem/runner.js +11 -0
  41. package/dist/resources/Agent.js +27 -14
  42. package/dist/resources/AgentSeed.js +35 -1
  43. package/dist/resources/Federation.js +70 -52
  44. package/dist/resources/Memory.js +567 -72
  45. package/dist/resources/MemoryArchive.js +9 -0
  46. package/dist/resources/MemoryBootstrap.js +4 -0
  47. package/dist/resources/MemoryFeed.js +204 -3
  48. package/dist/resources/MemoryHostSource.js +90 -0
  49. package/dist/resources/MemoryMaintenance.js +121 -32
  50. package/dist/resources/MemoryReflect.js +4 -1
  51. package/dist/resources/MemoryReindex.js +7 -4
  52. package/dist/resources/MemoryUsage.js +53 -3
  53. package/dist/resources/Presence.js +18 -10
  54. package/dist/resources/RecordUsage.js +30 -40
  55. package/dist/resources/Relationship.js +167 -78
  56. package/dist/resources/SemanticSearch.js +19 -6
  57. package/dist/resources/Soul.js +31 -19
  58. package/dist/resources/XAA.js +7 -3
  59. package/dist/resources/agent-auth.js +16 -10
  60. package/dist/resources/auth-middleware.js +135 -48
  61. package/dist/resources/auto-promote-lib.js +4 -4
  62. package/dist/resources/bm25-index-service.js +246 -32
  63. package/dist/resources/bm25-status.js +132 -0
  64. package/dist/resources/ed25519-auth.js +11 -54
  65. package/dist/resources/embed-gpu.js +262 -47
  66. package/dist/resources/embeddings-boot.js +52 -17
  67. package/dist/resources/federation-classify.js +12 -0
  68. package/dist/resources/federation-crypto.js +65 -19
  69. package/dist/resources/health.js +57 -14
  70. package/dist/resources/host-pointer/registry.js +35 -0
  71. package/dist/resources/host-pointer-adapter.js +15 -0
  72. package/dist/resources/host-source-visibility.js +167 -0
  73. package/dist/resources/host-source.js +151 -0
  74. package/dist/resources/instance-identity.js +3 -2
  75. package/dist/resources/mcp-handler.js +147 -51
  76. package/dist/resources/mcp-tools.js +25 -21
  77. package/dist/resources/memory-consolidate-lib.js +3 -1
  78. package/dist/resources/memory-declared-attributes.js +103 -0
  79. package/dist/resources/memory-feed-lib.js +5 -1
  80. package/dist/resources/memory-host-source.js +163 -0
  81. package/dist/resources/migrations/synthetic-test-migration.js +4 -1
  82. package/dist/resources/migrations/visibility-backfill.js +4 -1
  83. package/dist/resources/originator-instance.js +235 -0
  84. package/dist/resources/promotion-stamp.js +2 -0
  85. package/dist/resources/provenance.js +111 -11
  86. package/dist/resources/record-owner-guard.js +19 -0
  87. package/dist/resources/record-type-kit.js +9 -12
  88. package/dist/resources/record-types.js +6 -6
  89. package/dist/resources/relay-ops.js +28 -3
  90. package/dist/resources/replay-store.js +289 -0
  91. package/dist/resources/request-transaction.js +78 -0
  92. package/dist/resources/search-readiness.js +19 -21
  93. package/dist/resources/semantic-retrieval-core.js +5 -1
  94. package/dist/resources/table-patch-policy.js +109 -0
  95. package/dist/resources/table-patches.js +17 -0
  96. package/dist/resources/table-post-policy.js +138 -0
  97. package/dist/resources/table-posts.js +22 -0
  98. package/dist/resources/table-subscription-policy.js +135 -0
  99. package/dist/resources/table-subscriptions.js +19 -0
  100. package/dist/resources/tool-descriptors/index.js +15 -15
  101. package/dist/resources/trust-block.js +10 -3
  102. package/dist/resources/usage-recording.js +169 -41
  103. package/dist/src/lib/memory-attributes.js +77 -0
  104. package/docs/api-reference.md +79 -15
  105. package/docs/claude-code.md +132 -0
  106. package/docs/deployment.md +1 -1
  107. package/docs/federation.md +1 -1
  108. package/docs/integrations.md +5 -5
  109. package/docs/mcp-clients.md +11 -21
  110. package/docs/notes/mcp-oauth-model2.md +15 -1
  111. package/docs/quickstart.md +5 -0
  112. package/docs/releasing.md +134 -2
  113. package/docs/supply-chain-policy.md +10 -5
  114. package/docs/troubleshooting.md +11 -0
  115. package/docs/upgrade.md +187 -61
  116. package/package.json +9 -5
  117. package/schemas/agent.graphql +9 -6
  118. package/schemas/federation.graphql +2 -11
  119. package/schemas/memory.graphql +106 -17
  120. package/schemas/replay.graphql +18 -0
  121. package/templates/launchd/start-flair-with-admin-pass.sh +22 -0
  122. package/dist/resources/federation-nonce-store.js +0 -195
@@ -84,6 +84,66 @@ Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`
84
84
 
85
85
  This is a prompt-driven CLI setup: Claude must choose to run these commands. For MCP tools and automatic startup recall, run `flair init --agent my-project --client claude-code`, restart Claude Code, and verify the hook with `flair hook status --harness claude-code`; these prompt instructions do not guarantee automatic capture.
86
86
 
87
+ ## Hooks
88
+
89
+ `@tpsdev-ai/flair-mcp` ships four Claude Code hooks. Each is a separate binary and each is optional. Each exits 0 on every failure it handles, but a hook can still delay the session start, the prompt or the compaction it runs for; the time budgets and limits of prompt recall and of the PreCompact hook are described below.
90
+
91
+ | Hook | Claude Code event | What it does | Install |
92
+ |---|---|---|---|
93
+ | `flair-session-start` | `SessionStart` | Loads bootstrap context (soul plus relevant memories) when a session opens. | `flair hook install` ([details](mcp-clients.md#auto-recall-on-session-start-optional-hook)) |
94
+ | `flair-continuity-capture` | `PostToolUse` and `Stop` | Journals the agent's working state into the ephemeral memory tier, so the next session start can point at it with a one-line resume hint. | `flair hook install --continuity` |
95
+ | `flair-prompt-recall` | `UserPromptSubmit` | Searches memory with each prompt and adds the relevant memories as context before the model answers. | By hand, below |
96
+ | `flair-precompact` | `PreCompact` | Saves a bounded continuity record just before a compaction, for `flair-session-start` to show first afterwards. | By hand, [below](#continuity-across-compaction-flair-precompact-optional) |
97
+
98
+ ### Per-prompt recall (`flair-prompt-recall`)
99
+
100
+ Session-start recall runs once. Later in the session a prompt can bring up something the agent's memory already covers, such as a user's direction on a named technique or an earlier decision, and unless something searches at that moment the agent answers without it. `flair-prompt-recall` searches on every prompt:
101
+
102
+ 1. It builds a search query from the prompt, with markup, URLs and noise such as long ids stripped, bounded to 500 characters.
103
+ 2. It runs the same hybrid search as the MCP `memory_search` tool, signed with the agent's own Ed25519 key, so the results are limited to what that agent may read.
104
+ 3. It adds the hits whose score meets a relevance threshold (at most 4 by default), each with its id, date, score and a snippet, under a header that frames them as a signal, not an instruction, and tells the model to read the full memory before acting on it. The whole block is at most 2,000 characters. A memory that Flair's content scan flagged as possible prompt injection is shown with a fixed warning line ahead of its quoted text; cutting the text to fit never cuts the warning, so such a memory appears with its whole warning or not at all.
105
+
106
+ It can delay a prompt until its time budget runs out, and a response that has fully arrived within the budget can take longer to process (see below). It skips two kinds of prompt: background task notifications, and prompts too short to search once cleaned ("ok, thanks"). Every other prompt is searched, question or not. It exits 0 on every failure it handles. When Flair is unreachable, slow or refuses the request, it adds no memories, only one line saying recall was unavailable for that prompt.
107
+
108
+ The time budget (3 seconds by default) runs from the moment the hook process starts: reading the prompt, reading the config file and the search all count against it. When it runs out during asynchronous work (waiting for the prompt on stdin, reading the config file, connecting to Flair or downloading its response), the hook prints the one "unavailable" line and exits 0 at once. The prompt payload is read up to 1 MiB (a larger one is not searched), and the config file is read only if it is a regular file of at most 256 KiB. Once a response has arrived in full, the Flair client parses it and converts every result in it before returning, synchronously; the deadline cannot interrupt that work, and there is no cap on the size of a response that arrives within the budget. After the client returns, the hook's own processing looks at no more than the requested number of results and the first 4,096 characters of each memory. What happens before the process starts is outside the budget: the launcher and node's own start-up.
109
+
110
+ `flair hook install` does not write this hook, so wire it by hand. The hook runs on every prompt, so its launcher's start-up is added to every turn. Install the pinned package once into a directory of its own, and point the hook at its binary:
111
+
112
+ ```bash
113
+ npm install --prefix ~/.flair-hooks @tpsdev-ai/flair-mcp@<version>
114
+ ```
115
+
116
+ Then add the hook to `~/.claude/settings.json`:
117
+
118
+ ```json
119
+ {
120
+ "hooks": {
121
+ "UserPromptSubmit": [
122
+ {
123
+ "hooks": [
124
+ {
125
+ "type": "command",
126
+ "command": "sh -c 'out=$(FLAIR_AGENT_ID=my-project \"$HOME/.flair-hooks/node_modules/.bin/flair-prompt-recall\" 2>/dev/null) && printf %s \"$out\" || true'"
127
+ }
128
+ ]
129
+ }
130
+ ]
131
+ }
132
+ }
133
+ ```
134
+
135
+ Swap `my-project` for your agent ID and `<version>` for `flair --version`. The binary runs with the `node` found on the hook's `PATH`, which must be Node 22 or later. The `sh -c ... || true` wrapper is the same one the SessionStart hook uses: if the command cannot run at all, the prompt goes through with no output. Nothing in the CLI rewrites this entry or that directory, so re-run the `npm install` with the new version after an upgrade.
136
+
137
+ The same `npx -y -p @tpsdev-ai/flair-mcp@<version> flair-prompt-recall` invocation the SessionStart hook uses also works in place of the binary path, at a cost: npx resolves the package before the hook process starts, on every prompt, outside the hook's budget. That adds npm's own start-up to every turn even when the package is cached, and a download when the pinned version is not in npx's cache.
138
+
139
+ | Setting | Environment variable | `~/.flair/config.yaml` key | Default |
140
+ |---|---|---|---|
141
+ | Relevance threshold, 0 to 1, on the search's absolute score | `FLAIR_PROMPT_RECALL_MIN_SCORE` | `promptRecallMinScore` | `0.62` |
142
+ | Most memories added per prompt, 1 to 10 | `FLAIR_PROMPT_RECALL_MAX_HITS` | `promptRecallMaxHits` | `4` |
143
+ | Time budget in milliseconds, from the hook's start, 250 to 15000 | `FLAIR_PROMPT_RECALL_TIMEOUT_MS` | `promptRecallTimeoutMs` | `3000` |
144
+
145
+ The environment wins over the config file, where the keys are top-level entries; a value that is missing or out of range falls through to the next source. Until the config file has been read, the hook's deadline uses the environment's budget or the default; a budget set in the config file applies from then on, still measured from the start. The hook reads `FLAIR_AGENT_ID`, `FLAIR_URL` and `FLAIR_KEY_PATH` like the other hooks. It never uses `FLAIR_ADMIN_USER` or `FLAIR_ADMIN_PASSWORD`: without an agent key the request goes out unsigned, Flair refuses it, and the prompt gets the one "unavailable" line.
146
+
87
147
  ## Multiple Projects
88
148
 
89
149
  Create a separate agent per project:
@@ -131,6 +191,78 @@ Then the CLAUDE.md simplifies to:
131
191
 
132
192
  Use `flair bootstrap` when MCP is not wired.
133
193
 
194
+ ## Continuity across compaction (`flair-precompact`, optional)
195
+
196
+ When Claude Code compacts a conversation, it replaces the history with a summary, and whatever the summary leaves out is gone from the agent's context: a rule the user gave an hour ago, the open task list, the work in flight. `flair-precompact` is a `PreCompact` hook that saves one bounded record just before that happens (when the end of the transcript holds something to record and the write succeeds), and `flair-session-start` can show the saved record the local marker file names first, when Flair returns it as an eligible live row: when the session continues after the compaction, or when the next session starts after a restart and the marker still names the previous session (see the limits below).
197
+
198
+ It needs `flair-session-start` installed (`flair hook install`): that hook creates the per-session continuity state the record belongs to, and it is the one that shows the record, when the marker matches and Flair returns an eligible live row. `flair hook install` does not write the PreCompact entry, so add it to `~/.claude/settings.json` by hand:
199
+
200
+ ```json
201
+ {
202
+ "hooks": {
203
+ "PreCompact": [
204
+ {
205
+ "hooks": [
206
+ {
207
+ "type": "command",
208
+ "command": "sh -c 'out=$(FLAIR_AGENT_ID=my-project npx -y -p @tpsdev-ai/flair-mcp@<version> flair-precompact 2>/dev/null) && printf %s \"$out\" || true'",
209
+ "timeout": 30
210
+ }
211
+ ]
212
+ }
213
+ ]
214
+ }
215
+ }
216
+ ```
217
+
218
+ Swap `my-project` for your agent ID and `<version>` for `flair --version`. With no `matcher`, the hook runs for both `/compact` (`manual`) and automatic (`auto`) compaction. A PreCompact hook that exits 2 blocks compaction; this command exits 0 whenever it runs to completion (the `|| true` covers a launcher that fails before the hook runs), and `timeout` bounds the launcher, whose start-up happens before the hook's own budget begins.
219
+
220
+ What the record holds: text copied from the end of the transcript (no model call, no summary), under fixed section headings, with a status label on each task (taken from the transcript only when it looks like one, at most 20 lowercase letters and underscores, and is not credential-shaped; else `open`) and a tool label (`bash:`, `write:`, `edit:` or `notebook-edit:`) on each in-flight line:
221
+
222
+ - **Standing instructions**: sentences from the turns the transcript labels as user turns (once the harness markup described below is removed) that start with a rule-giving phrase (don't, do not, never, always, stop, avoid, make sure, remember to, from now on, going forward) or contain always, never, from now on, going forward or in (the) future. Extracted sentences that end in `?` are skipped. At most 6, the newest, 200 characters each.
223
+ - **Open tasks**: the task tools' list (`TaskCreate`/`TaskUpdate`, and `TodoWrite` when a session has it enabled), minus completed and deleted tasks. At most 8.
224
+ - **In-flight work**: the last 5 file edits and shell commands, one line each (a repeated one included), recorded the way `flair-continuity-capture` records them: a file's path, a shell command's description, never the command itself.
225
+ - **The last assistant message**: its text blocks joined in order, cut to 300 characters.
226
+
227
+ A section with nothing in it is left out, and when nothing at all was found no record is written. The whole record is at most 2,000 characters. The hook reads at most the last 1 MiB of the transcript and keeps up to the last 2,000 nonblank lines of it. From tool results it reads only two identifiers, to keep the task list straight: the id `TaskCreate` assigned, and which tool call a result answers. It never copies result content, thinking or subagent turns into the record. Of the messages the harness writes into the transcript, it skips user turns that carry a marker it recognizes (`<task-notification>`; a slash command's `<command-name>`, `<command-message>` or `<command-args>`; `<local-command-…>` output), meta entries and compaction summaries, and it drops system-reminder blocks, all before it redacts the text that is left; a harness message with none of these markers is treated as a user turn, since the hook cannot tell it from your own words.
228
+
229
+ Before the record's content is stored, strings in it that match these patterns are replaced with `[redacted]` (a task status label that redaction would change is shown as `open` instead): private key blocks, `user:password@` in URLs, Authorization-style values (everything after an `Authorization:` or `Proxy-Authorization:` label in any case, or after the word `Bearer` in any case or `Basic` capitalized or in capitals, through the end of that line, whatever its characters, where a line ends at a line feed, carriage return, vertical tab, form feed, U+0085, U+2028 or U+2029, the same breaks the displayed record is split on, so the line after the value is kept; this also cuts short a line of prose such as "use Bearer tokens here", while the lower-case word "basic" is left alone), `name=value` and `name: value` pairs whose name contains password, secret, token, credential, or api, access or private key, and the prefixed tokens in the table below. This is pattern matching and best effort: a secret with no recognizable shape, such as a bare password in a sentence, is stored as written. The record lives in the ephemeral tier (it expires after 24 hours by default; the Flair server's `FLAIR_EPHEMERAL_TTL_HOURS` sets it), is private to the agent, and is written with the agent's own key through the same signed request as the continuity journal; the hook never uses `FLAIR_ADMIN_USER` or `FLAIR_ADMIN_PASSWORD`.
230
+
231
+ A prefixed token is recognized only when its prefix starts a word and is followed by a long enough run of the characters its pattern allows, so ordinary words are not caught:
232
+
233
+ | Prefix | Followed by |
234
+ |---|---|
235
+ | `sk-` | 16 or more letters, digits, `_` or `-`, counted from right after `sk-`, so a subtype counts toward them: `sk-ant-` followed by 12 more, or `sk-proj-` followed by 11 more, is redacted |
236
+ | `ghp_`, `gho_`, `ghu_`, `ghs_`, `ghr_` | 20 or more letters or digits |
237
+ | `github_pat_` | 20 or more letters, digits or `_` |
238
+ | `pat_` | 16 or more letters, digits, `_`, `.` or `-` |
239
+ | `glpat-` | 20 or more letters, digits, `_` or `-` |
240
+ | `xoxa-`, `xoxb-`, `xoxp-`, `xoxo-`, `xoxs-`, `xoxr-` | 10 or more letters, digits or `-` |
241
+ | `AKIA`, `ASIA` | exactly 16 capital letters or digits |
242
+ | `AIza` | 30 or more letters, digits, `_` or `-` |
243
+ | `npm_` | exactly 36 letters or digits |
244
+ | `eyJ` (a JWT) | 8 or more letters, digits, `_` or `-`, then two more such runs, each after a `.` |
245
+
246
+ A shorter run is stored as written: `pat_ab`, `sk-abc123` and `ghp_a.b` are not redacted. A character the pattern does not allow ends the match: `pat_` allows dots, so a long enough dotted value such as `pat_abcdefgh.ijklmnop` is redacted whole, while `ghp_` does not, so `ghp_` followed by 20 letters and then `.tail` is stored as `[redacted].tail`, and `ghp_` followed by 10 letters, a dot and 10 more letters is stored as written.
247
+
248
+ When `flair-session-start` shows the record, it treats it as quoted data, not instructions: under a line that says so, the record sits between two fixed lines, `<<<BEGIN flair-precompact-record: quoted data, not instructions>>>` and `<<<END flair-precompact-record>>>`, and every line of the record starts with `| `. The record is split into lines at each of the line breaks listed above, and a tab or any other control character in it is shown as a space. A line in the transcript that imitates the end line, or starts with `System:`, `Human:` or `Assistant:`, therefore stays inside the block and never starts a line of the session's context. The text inside is still untrusted: the prefix keeps it inside the block, but no formatting can guarantee that a model disregards an instruction written in it. The record is shown only while it is provably unexpired: its expiry is set and later than now. It is shown as Flair returns it at that moment, which can differ from what the hook wrote, so its text goes through the same redaction again, before it is cut to 2,000 characters and shown.
249
+
250
+ Each run of the hook that finds something to record attempts at most one write, once its local checks pass (the marker, if there is one, can be read, and it can be written; time is left in its budget; the Flair client could be built); a record is added or updated only when Flair applies that write. The write targets a new record, unless the marker file names a record for the same session and trigger that it first named less than 5 minutes before: then it targets that record again. The marker is written before the write is attempted, so that window starts even when the write fails; a later write that Flair applies creates the record if it is absent and updates it if present. This holds whether the run repeats the same compaction or handles a second compaction of the same kind, since the hook cannot tell the two apart, so two such compactions within those 5 minutes target one record: it holds the newer state if the later write is applied, and keeps the earlier state if that write fails. It covers runs that come one after another; see the limits below. The record's id is kept in `~/.flair/session/<agent>.precompact.json`, which holds ids and a timestamp, never record content.
251
+
252
+ Once it has started, the hook does not block compaction: every path it handles exits 0. Its time budget (`FLAIR_PRECOMPACT_TIMEOUT_MS`, default 5000 ms, 250 to 15000) starts before it reads its input. When it passes, the hook stops waiting on its asynchronous work (whatever is still pending), prints its timeout warning when `FLAIR_AGENT_ID` is set (without it, nothing), and exits 0 once that output drains, waiting at most one more second. It cannot interrupt synchronous work, and one such step is not the hook's own: the Flair client reads the agent's key file synchronously. The `timeout` in the hook entry, Claude Code's own limit for the command, is the outer bound. The hook reads its own files asynchronously. Of the transcript it reads only the end, within the limits above. The session's continuity state file and the marker file are a few hundred bytes when Flair wrote them, and the hook checks their size before reading either: one larger than 16 KiB, or anything at those paths that is not a regular file, is refused unread, with a warning naming it, and one that grows past 16 KiB while it is read is refused after at most 16 KiB and 1 byte. When Flair is unreachable, slow or refuses the write, or the transcript or the hook's own files cannot be read, Claude Code shows one short warning naming the reason, and compaction goes ahead either way. When a write is not confirmed, the warning says the save did not finish in time (after a timeout) or could not be confirmed (after any other error), and that the record may be missing: Flair can still finish a write the hook stopped waiting for, or may already have applied one whose answer could not be read. A warning that names the state file or the marker shows its path with these changes, each only where it applies: a path inside your home directory (`HOME`, else the system's) starts with `~` (a home directory of `/` collapses nothing), each control character is shown as `?`, strings that match the credential patterns are redacted, and a path longer than 200 characters is cut. A path outside your home directory that none of these touch is shown as it is.
253
+
254
+ Limits worth knowing:
255
+
256
+ - The instruction heuristic is simple. It misses a rule phrased any other way ("I'd rather you ask first", other languages), and it can pick up a sentence that only mentions the words ("I never said that").
257
+ - Claude Code writes the transcript asynchronously, so the newest messages may not be in it yet when the hook runs.
258
+ - Only the end of the transcript is read: a task created before that part has no name there and is left out, and an instruction given before it is not seen.
259
+ - The transcript's format is Claude Code's own, not a documented interface; a field the hook does not recognize is skipped, never guessed.
260
+ - After a restart, a record is shown only when the marker file still names the previous session, and the record shown is the saved record the marker still names, which can predate a later compaction of that session whose record was not saved, and can be older than that session's final state. The block shows the row's `createdAt`, which the hook sets to the time of the run that wrote it (a row changed since can carry another value); treat it as a signal to check, not an instruction.
261
+ - The marker file remembers only the newest record per agent ID. When two sessions share one agent ID and both compact, the session that compacted first no longer finds its record through the marker.
262
+ - Two runs of the hook at the same moment for one agent ID can both find no marker and each write a record: nothing locks the marker across processes.
263
+ - In-flight lines are not merged: five edits of one file fill that section with five identical lines.
264
+ - A Flair server older than 0.47.0 stamps no expiry on the write, so a record saved there is not shown unless a later write gives it an expiry.
265
+
134
266
  ## Soul (Personality / Context)
135
267
 
136
268
  Want Claude Code to have consistent personality or project context? Set soul entries:
@@ -216,7 +216,7 @@ These are read by the Harper process at boot (same places as the table above: la
216
216
  | Variable | Default | What it does |
217
217
  |----------|---------|--------------|
218
218
  | `FLAIR_EMBED_THREADS` | `max(1, availableParallelism() − 1)` | CPU threads for in-process embedding (harper-fabric-embeddings / llama.cpp). Host-aware so a 4-core box does not inherit HFE's fixed 6, and an 8-vCPU ingest host is not stuck at 6 idle cores. One core is left for Harper's event loop and the OS. `availableParallelism()` respects a container CPU quota. Set a positive integer to pin. Invalid values fall back to the default. |
219
- | `FLAIR_EMBED_GPU_LAYERS` | derived: `99` when a usable Metal backend is present (darwin-arm64 + resolvable `@node-llama-cpp/mac-arm64-metal`), else `0` | Layers to offload to the GPU. Unset **derives** the default and states it on the boot log and `/Health` (`embedding.backend` / `gpuLayers` / `source`). `0` = pin CPU; `99` = full offload. Invalid values fall through to the derived default. If offload is requested and Metal does not engage, Health and the log state the CPU fallback — they never claim GPU for a CPU run. |
219
+ | `FLAIR_EMBED_GPU_LAYERS` | derived: `99` when a usable Metal backend is present (darwin-arm64 + resolvable `@node-llama-cpp/mac-arm64-metal`), else `0` | Layers to offload to the GPU. Unset **derives** the default and states it on the boot log and `/Health` (`embedding.backend` / `gpuLayers` / `source`). `0` = pin CPU; `99` = full offload. Invalid values fall through to the derived default. `0` reports `cpu` / `gpuLayers: 0` without a readback. For an offload request, Health reports after warmup the GPU type from the native binding that warmup already opened (not a second addon): `metal` with the requested layer count when that binding says Metal, `cpu` / `gpuLayers: 0` only when that binding says no GPU, and `unconfirmed` / `gpuLayers: null` when it exposes no readback. While warmup is running, Health reports the unconfirmed preview with `pending: true`; HealthDetail calls it "pending (warmup in progress)", and `flair doctor` treats it as advisory even when `source=env`. The pending field disappears when warmup finishes. Health does not infer CPU from an empty log capture or from a different binary, and it does not claim GPU for a run the engine says is on CPU. A finished `source=detected` miss stays advisory in `flair doctor`; a finished `source=env` miss stays blocking. |
220
220
  | `FLAIR_HYBRID_RETRIEVAL` | `true` | Hybrid BM25 + vector retrieval. Set `false` / `0` / `off` to revert to the legacy HNSW + keyword-bump path. |
221
221
  | `FLAIR_MODELS_DIR` | `<data-dir>/models` | Directory the embedding GGUF is loaded from (and downloaded into on first boot). Point this at a pre-seeded directory to skip the HuggingFace download; see [troubleshooting.md](troubleshooting.md). |
222
222
 
@@ -316,7 +316,7 @@ flair federation unpin <instanceId>
316
316
  ```
317
317
 
318
318
  HTTP paths (`/FederationPair`, `/FederationSync`, `/FederationInstance`,
319
- `/FederationPeers`) and the Instance / Peer / PairingToken / Nonce / SyncLog
319
+ `/FederationPeers`) and the Instance / Peer / PairingToken / SyncLog / ReplayNonce
320
320
  schemas: **[docs/api-reference.md](api-reference.md#federation)**.
321
321
 
322
322
  ## Limitations (1.0)
@@ -26,7 +26,7 @@ Where Flair already runs. Each integration can reach one shared Flair memory sto
26
26
  | **Google ADK** (Python) | [`adk-flair`](../packages/adk-flair/README.md) | Ed25519 | `BaseMemoryService`; see [hosted auth](#hosted-flair-auth--your-agent-got-a-404) if you just got a 404 |
27
27
  | **Google ADK** (JS/TS) | [`@tpsdev-ai/adk-flair`](../packages/adk-flair-js/README.md) | Ed25519 | Same identity model as the Python package |
28
28
 
29
- Don't see your harness? If it speaks **MCP** — Flair already works with `flair-mcp`. If it has a **custom memory protocol** like LangGraph's `BaseStore` or CrewAI's `RAGStorage`, an adapter is a ~200-line package; [open an issue](https://github.com/tpsdev-ai/flair/issues) or [send a PR](https://github.com/tpsdev-ai/flair).
29
+ Don't see your harness? If it speaks **MCP** — Flair already works with `flair-mcp`. For a custom memory protocol such as LangGraph's `BaseStore` or CrewAI's `RAGStorage`, an adapter must translate that protocol's operations to Flair; [open an issue](https://github.com/tpsdev-ai/flair/issues) or [send a PR](https://github.com/tpsdev-ai/flair).
30
30
 
31
31
  **Already running on Harper?** Every surface above reaches Flair over HTTP. If your application is itself a Harper app, you can skip the network entirely — load Flair as a component of the same instance and call its resources in-process. See [embedding-in-a-harper-app.md](embedding-in-a-harper-app.md), which also covers the table-vs-resource distinction that decides whether your memories are scoped.
32
32
 
@@ -159,7 +159,7 @@ Full per-tool walkthrough including troubleshooting: [`docs/mcp-clients.md`](mcp
159
159
 
160
160
  ## LangGraph (TypeScript)
161
161
 
162
- [`@tpsdev-ai/langgraph-flair`](https://www.npmjs.com/package/@tpsdev-ai/langgraph-flair) implements LangGraph's `BaseStore`. FlairStore provides get, put, delete, search, and batch, with the limitations below.
162
+ [`@tpsdev-ai/langgraph-flair`](https://www.npmjs.com/package/@tpsdev-ai/langgraph-flair) implements LangGraph's `BaseStore` interface. FlairStore provides get, put, delete, search, batch, listNamespaces, start, and stop; see the package README for its API and retrieval limitations.
163
163
 
164
164
  ```bash
165
165
  npm install @tpsdev-ai/langgraph-flair
@@ -173,9 +173,9 @@ const store = new FlairStore({ agentId: "my-langgraph-agent" });
173
173
  const agent = createReactAgent({ llm, tools, store });
174
174
  ```
175
175
 
176
- Maps LangGraph namespaces to Flair tags, keys to ids, values to JSON content. Search delegates to Flair's HNSW. Filter operators applied client-side. Full mapping table: [`packages/langgraph-flair/README.md`](../packages/langgraph-flair/README.md).
176
+ Maps LangGraph namespaces to Flair tags, keys to ids, values to JSON content. Non-empty search queries call Flair's `/SemanticSearch` endpoint. The server selects hybrid (BM25 plus vector), vector-only, or BM25-only retrieval; embedding availability affects whether the vector leg can run. Filter operators applied client-side. Full mapping table: [`packages/langgraph-flair/README.md`](../packages/langgraph-flair/README.md).
177
177
 
178
- LangGraph **Python** support is on the roadmap (same `BaseStore` shape, Python adapter).
178
+ This package contains the TypeScript adapter; it does not include a Python implementation.
179
179
 
180
180
  ---
181
181
 
@@ -264,7 +264,7 @@ Full details (tools, env reference, auto-recall/auto-capture flags, security not
264
264
 
265
265
  If it speaks MCP, you're already covered — every MCP client works through `flair-mcp` (the section above lists 6 we've explicitly tested).
266
266
 
267
- If it has a custom memory protocol, the adapter pattern is small (~200 lines). LangGraph and Hermes are the reference implementations. **Adapters we'd love to see:**
267
+ If it has a custom memory protocol, an adapter must translate its operations, identity, and retrieval semantics to Flair. LangGraph and Hermes are the reference implementations. **Adapters we'd love to see:**
268
268
 
269
269
  - LangGraph Python (mirror of our TS adapter)
270
270
  - CrewAI (Python `BaseRAGStorage` protocol)
@@ -14,21 +14,11 @@ If you've never set up Flair before, do step 1 first. If Flair is already runnin
14
14
 
15
15
  ## Step 1 — Install Flair (do once)
16
16
 
17
- ```bash
18
- # Install Flair globally
19
- npm install -g @tpsdev-ai/flair
20
-
21
- # Initialize the local Harper-backed server
22
- flair init
23
-
24
- # Provision an agent identity. Pick a name — typically per-project, per-purpose,
25
- # or "me" if you want one durable identity across everything.
26
- flair agent add my-project
27
- # → writes ~/.flair/keys/my-project.key (a raw 32-byte Ed25519 seed) and registers the agent
28
-
29
- # Sanity check
30
- flair status
31
- ```
17
+ Follow [the laptop quickstart](quickstart.md) through agent setup and
18
+ verification. Its `flair init --agent local` path creates the agent identity
19
+ and attempts to wire detected clients when wiring is enabled.
20
+ For the manual snippets below, replace `my-project` with the agent ID you
21
+ created (`local` if you followed the quickstart unchanged).
32
22
 
33
23
  > **`flair: command not found` right after installing?** Your npm global prefix's bin dir isn't on PATH (common with a user prefix like `~/.npm-global`) — run `export PATH="$(npm prefix -g)/bin:$PATH"`, persist that line in your shell profile, and `flair doctor` will print the exact line for your shell any time.
34
24
 
@@ -306,25 +296,25 @@ Clients on this page talk to the stdio server `@tpsdev-ai/flair-mcp`. Its `tools
306
296
  | Tool | What it does |
307
297
  |---|---|
308
298
  | `memory_search` | Semantic search across the caller's own and other agents' non-private memories |
309
- | `memory_store` | Save a memory (type, durability, tags, visibility), attributed to the authenticated agent. Optional `usedMemoryIds` cites memories that informed the write |
299
+ | `memory_store` | Save a memory (type, durability, tags, visibility), under the configured agent ID, subject to server authorization. Optional `usedMemoryIds` cites memories that informed the write |
310
300
  | `skill_store` | Write a skill-tagged memory. `trigger` is the recall text; `content` is the procedure. Durability is forced to persistent, and SkillScan rejects a dangerous payload before embed |
311
301
  | `skill_search` | Rank skills by their trigger against a task. Returns a catalog (id, name, trigger, description, tags, agentId), not the procedure |
312
- | `skill_get` | Fetch one skill's full procedure by id. Own skills and shared skills only; a private skill owned by someone else is not returned |
302
+ | `skill_get` | Fetch one skill's full procedure by id. Non-admin callers can retrieve their own and other agents' non-private skills; administrators can also retrieve private skills |
313
303
  | `memory_update` | Update a memory by id. Overwrites in place, or pass `preserveHistory` to write a superseding version. Optional `usedMemoryIds` |
314
304
  | `memory_get` | Fetch a specific memory by ID |
315
- | `memory_delete` | Delete one of your own memories |
305
+ | `memory_delete` | Delete a memory by ID. Non-admin callers can delete only their own memories; administrators can also delete other agents' memories |
316
306
  | `relationship_store` | Assert a subject-predicate-object triple (for example "nathan manages flair"). Asserting the same triple again updates that row |
317
307
  | `bootstrap` | Session-start context: soul, memories, and predicted context. Pass `subjects` for predictive loading |
318
- | `soul_set` | Advertised as setting a soul entry. The server refuses runtime Soul writes, including this tool's Ed25519 call; operators use `flair soul set` |
308
+ | `soul_set` | Advertised as setting a soul entry. Verified administrator Basic credentials are accepted; Ed25519 agent calls, including this tool's, are refused. Operators use `flair soul set` |
319
309
  | `soul_get` | Get a soul entry |
320
310
  | `flair_workspace_set` | Set this agent's workspace state (ref, label, provider, task, phase, summary) in the Office Space |
321
311
  | `flair_orgevent` | Publish an org-wide coordination event (claim, release, or status), attributed to the caller |
322
312
  | `flair_catchup` | Drain this agent's own org-event catch-up feed. Page with `after`; advance the watermark with `ack` |
323
313
  | `record_usage` | Report that recalled memories were actually used (`memoryId` or `memoryIds`, plus optional `attribution`). Drives `usageCount` / `usageBoost` |
324
314
 
325
- Writes are scoped per-agent (your `FLAIR_AGENT_ID`) and enforced by Flair's server, not by client convention — you can't write as another agent. Reads are more open by design: any agent on the same Flair instance can read any other agent's **non-private** memories, with no grant to set up (open-within-org read; see [SECURITY.md](../SECURITY.md)).
315
+ For ordinary signed agents, Flair enforces write ownership server-side: they can write only under their authenticated agent ID. Administrator credentials and administrator agent roles have broader authority. Reads are more open by design: any agent on the same Flair instance can read any other agent's **non-private** memories, with no grant to set up (open-within-org read; see [SECURITY.md](../SECURITY.md)).
326
316
 
327
- Which memories are non-private is decided at write time, and the default is not "shared". `memory_store` defaults `durability` to `standard`, and the server derives visibility from durability — `permanent`/`persistent` → `shared`, `standard`/`ephemeral` → `private` — so **a bare `memory_store` call writes an owner-only memory that no other agent can read.** Pass `visibility: "shared"` (or `"private"`, to be explicit) to say what you mean; the tool reports the visibility the write actually landed on so an agent can confirm it rather than assume.
317
+ Which memories are non-private is decided at write time, and the default is not "shared". `memory_store` defaults `durability` to `standard`, and the server derives visibility from durability — `permanent`/`persistent` → `shared`, `standard`/`ephemeral` → `private` — so **a bare `memory_store` call creates a private memory: ordinary agents other than its owner cannot read it; administrators retain access.** Pass `visibility: "shared"` (or `"private"`, to be explicit) to say what you mean; the tool reports the visibility the write actually landed on so an agent can confirm it rather than assume.
328
318
 
329
319
  ### Reading the `bootstrap` payload
330
320
 
@@ -34,11 +34,25 @@ aud, scope }`. The handler maps `sub` → a flair `Agent` id:
34
34
 
35
35
  1. Look up `Credential` where `kind === "idp"` AND `idpSubject === sub` → its
36
36
  `principalId` is the Agent id. (Same credential surface XAA's ID-JAG path
37
- uses — one identity model.)
37
+ uses — one identity model.) That Agent must exist and be active on **every**
38
+ tool call dispatched through the mapping — the rule the Ed25519 path applies
39
+ (`isPrincipalDeactivated`; a record with no `status` field counts as
40
+ active). A deactivated or missing principal is refused with a JSON-RPC error
41
+ that names the principal and the operator's remedy, so a token minted while
42
+ the principal was active stops working once it is deactivated and, while the
43
+ token remains valid, works again once it is reactivated. The credential's
44
+ `lastUsedAt` is updated, best effort, after a tool has run; the update
45
+ writes that field alone.
38
46
  2. If no mapping and `FLAIR_MCP_JIT_PROVISION` is on, JIT-provision a
39
47
  non-admin `Agent` + `Credential(kind:"idp")` from the sub.
40
48
  3. Otherwise **deny** — an unresolvable sub never runs as anonymous or admin.
41
49
 
50
+ A failed credential lookup or principal read during identity resolution
51
+ refuses the call. It is never read as "allowed", and never as "no mapping", so
52
+ step 2 runs only for a subject the credential lookup answered for. A failed
53
+ read of the credential before the post-tool `lastUsedAt` update leaves the
54
+ served answer unchanged.
55
+
42
56
  The resolved agent is set as `request.tpsAgent` on a flair-shaped delegation
43
57
  context, so the wrapped handler scopes to the verified agent exactly as an
44
58
  Ed25519-signed REST call would. Identity always comes from the resolved agent,
@@ -121,6 +121,11 @@ flair memory add --agent local "Harper v5 sandbox blocks node:module but process
121
121
 
122
122
  Flair embedded the text locally on write. No network calls.
123
123
 
124
+ ### Task summaries
125
+ Use `flair memory write-task-summary --agent local --outcome merged --summary "Finished the task"` to save a persistent task summary and print its memory id.
126
+ The optional `--ref <ref>` accepts a task, issue, or PR reference; omitted references use `unreferenced`. Outcomes are `merged`, `rejected`, or `abandoned`.
127
+ Existing `--beads` callers remain supported as a deprecated alias; `--ref` takes precedence.
128
+
124
129
  ### Who can read it
125
130
 
126
131
  `visibility: private` means **only `local` can read this memory** — no other agent on the instance can search it, fetch it by id, or receive it in a bootstrap.
package/docs/releasing.md CHANGED
@@ -83,13 +83,94 @@ fragment directory is empty (nothing to release) or when someone hand-wrote an e
83
83
 
84
84
  ### Phase 2 — tag the release
85
85
 
86
- After the release PR is merged to `main`, push the version tag:
86
+ After a release PR merges to `main`, [Release auto-tag](../.github/workflows/release-auto-tag.yml)
87
+ normally creates its tag after a successful push CI run, subject to the release checks.
88
+ If an allowlisted advisory job fails that CI run, the immediate path is skipped and
89
+ nightly recovery makes the tag instead. It runs at **04:23 UTC daily**, so expect up
90
+ to **24 hours plus run time**. It uses completed CI runs regardless of their overall
91
+ conclusion and tolerates only exact names in [the advisory allowlist](../.github/release-auto-tag-advisories.json).
92
+ All other release conditions must pass, and it targets the version still declared
93
+ on `main`, so a newer version supersedes a missed release.
94
+
95
+ To tag by hand, push the version tag:
87
96
 
88
97
  ```bash
89
98
  git checkout main && git pull
90
99
  git tag v0.11.0 && git push origin v0.11.0
91
100
  ```
92
101
 
102
+ > The [`release-auto-tag`](../.github/workflows/release-auto-tag.yml) workflow
103
+ > normally pushes this tag for you once a release PR merges green (see
104
+ > [#1928](https://github.com/tpsdev-ai/flair/issues/1928)); the hand-push above is
105
+ > the manual fallback. When the release commit's tree carries
106
+ > `packages/adk-flair/pyproject.toml` whose `[project].version` equals the version
107
+ > being tagged, the auto-tagger ALSO creates `adk-flair-v<version>` from the same
108
+ > commit — so the PyPI publish run then needs only the environment gate its owner
109
+ > keeps or drops (no hand-pushed `adk-flair-v` tag).
110
+ >
111
+ > The project version is read with Python's `tomllib` — the SAME reader
112
+ > `.github/workflows/adk-flair-publish.yml` decides with — by handing the file to
113
+ > `python3` on stdin, in isolated mode (`-I`: no working-directory module can
114
+ > shadow the standard library) with an environment of `PATH` only, so no token
115
+ > reaches the interpreter ((r9e)). It fails CLOSED: a TOML parse error, a `python3` without
116
+ > `tomllib` (older than 3.11), or a `[project]` that is not a table is
117
+ > `unsupported`, and the tagger refuses `adk-pyproject-unsupported` naming the
118
+ > reason ((s), (v)); a `dynamic = [ … "version" … ]` or a missing
119
+ > `[project].version` is NONE and refuses `adk-version-mismatch` ((t)); a
120
+ > `[project].version` that differs from the version being tagged refuses
121
+ > `adk-version-mismatch` BEFORE either tag is written ((p), (q), (g)) — a
122
+ > `version =` line inside a multi-line string or array is never read as the
123
+ > project version. With NO `packages/adk-flair/pyproject.toml` the
124
+ > tagger's adk step is skipped ((b)), but `scripts/check-version-sync.mjs` lists the
125
+ > pyproject as a source file and refuses when it is missing, so today such a release
126
+ > refuses at `version-sync`. Removing the Python package from the repo means removing
127
+ > it, in the same change, from the checker's source list and from the paths
128
+ > `scripts/release.sh` stages for the release commit; a release is then tagged `v`
129
+ > alone. An
130
+ > `adk-flair-v<version>` already at another commit refuses
131
+ > `adk-tag-exists-elsewhere` before the `v` tag is written ((d)); a second POST
132
+ > rejected for lack of permission refuses `adk-ref-write-rejected`, and the text
133
+ > reports what THIS run read back for BOTH refs and the next step ((e)): for a 403
134
+ > the text names the App's bypass-actor setting on the `adk-flair-v*` ruleset as the
135
+ > first thing to check (the usual cause; the code sees only the status), then a
136
+ > re-run; for any other status, a re-run ((r9a)). A read of the adk ref that FAILS
137
+ > (the API answers neither found nor not found) refuses `adk-ref-unreadable` instead
138
+ > of throwing: before any tag is written at the pre-check and on a same-commit re-run
139
+ > ((r9b), (r9f), (r9g)), and with the `v` tag in place at the re-read and the
140
+ > read-back ((r9c), (r9d)). After a REJECTED adk POST the refusal stays
141
+ > `adk-ref-write-rejected`, and the text reports the adk read-back as
142
+ > `not read: <reason>`; when the adk read-back cannot be resolved, the text reports its raw
143
+ > ref type and SHA (or `not found`), so it names BOTH refs' read-back values on every
144
+ > branch. The post-POST read-back has THREE refusals, each reporting only
145
+ > what this run observed: the adk ref did not read back at all (MISSING, (i2)); it
146
+ > read back but could not be resolved to a commit (UNRESOLVED, (i3)); or it
147
+ > resolves elsewhere (ELSEWHERE, (i)). None states what a future run will do. The
148
+ > membership+read of the pyproject is ONE function (`readAdkPyproject`): a
149
+ > `git ls-tree` that does not answer exactly "absent" or "the path" (non-zero exit,
150
+ > spawn error, timeout, unexpected output) or a failed `git show` refuses
151
+ > `adk-pyproject-unreadable` — before any POST, on BOTH the decide and write paths
152
+ > ((r1)-(r4)); no stderr substring decides anything.
153
+ >
154
+ > The writer (`scripts/check-version-sync.mjs --write`) precomputes the two
155
+ > `SOURCE_VERSION_FILES` edits — `packages/flair-bench/src/version.ts` and
156
+ > `packages/adk-flair/pyproject.toml` — verifies the pyproject edit with `tomllib`
157
+ > (refused unless only `project.version` changed) and the flair-bench edit with its
158
+ > own declaration check (exactly one `TOOL_VERSION = "…"` match), writes NOTHING if
159
+ > either fails, and leaves the `package.json` bumps to `release.sh` ((w), (x2), (m),
160
+ > (h), all-or-nothing).
161
+ >
162
+ > Re-run states (`decide`): with the `v` tag already at `<sha>` and the adk tag
163
+ > absent, the run is a TAG with the `v` step marked SKIP ((n)); with BOTH tags at
164
+ > `<sha>` it is a SKIP, so no write job starts on later runs ((o)). Once `v` is
165
+ > known to sit at the sha, EVERY later refusal carries `v_verdict=SKIP`, so the
166
+ > refusal issue never prints `v: REFUSE` for an existing ref — fed from `decide`'s
167
+ > outputs when `write` was skipped — and that is asserted on the RENDERED issue
168
+ > line, not the wiring (`test/unit/release-auto-tag-workflow.test.ts`). The App
169
+ > must be listed as a bypass actor on the `adk-flair-v*` tag ruleset (id 24044018)
170
+ > for that second POST to be allowed. Each guarantee names its test:
171
+ > `test/unit/release-auto-tag.test.ts` and
172
+ > `test/unit/release-auto-tag-workflow.test.ts`.
173
+
93
174
  The tag push triggers the [`release-publish`](../.github/workflows/release-publish.yml)
94
175
  workflow, which:
95
176
 
@@ -149,12 +230,15 @@ cannot be re-staged under a different tag.
149
230
 
150
231
  The moment the staged packages are approved, dispatch the
151
232
  [`post-publish canary`](../.github/workflows/canary.yml) (Actions → "Post-publish canary
152
- — install + boot a published version") with two inputs:
233
+ — install + boot a published version") with three inputs:
153
234
 
154
235
  | Input | Value |
155
236
  | ----- | ----- |
156
237
  | `version` | the version just approved, exact (e.g. `vX.Y.Z` without the `v`) |
157
238
  | `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>`. |
239
+ | `package_set_digest` | the certified package-set digest (64 lowercase hex), printed as `package-set-digest=<digest>` in the log of the release run's "Pack publishable packages and write the release manifest" step. It can also be recomputed from that step's lines (`<name>@<version> <sha256> <basename>`) by feeding `<name>=<sha256>` lines to `node scripts/ci/package-set-digest.mjs --version <ver>`. The canary re-derives the digest from the tarballs it verified and refuses a mismatch before any verdict. |
240
+
241
+ For example, after all staged packages are public: `gh workflow run canary.yml --ref main -f 'version=<ver>' -f 'expected_sha256=<flair-tarball-sha256>' -f 'package_set_digest=<package-set-digest>'`.
158
242
 
159
243
  The canary runs on clean `ubuntu-latest` and `macos-latest` runners and is
160
244
  **credential-less**: it installs `@tpsdev-ai/flair@<ver>` by exact version from the
@@ -332,3 +416,51 @@ The maintainer who approves staged packages must have 2FA enabled on their npm a
332
416
  npm itself; local approvers need a recent npm.
333
417
  - Node **≥ 22.14**.
334
418
  - Trusted publishing runs on GitHub-hosted runners only (no self-hosted support yet).
419
+
420
+ ## Automated promote — slice 1 (flair#1928)
421
+
422
+ After the npm approval, a maintainer today pastes the promote block from a
423
+ checkout. Slice 1 lands the four pieces the privileged promote job (slice 2) will
424
+ stand on; it holds no npm credential (the poll runs on the automatic
425
+ `GITHUB_TOKEN` with `actions: write`, `contents: read` and `deployments: read`).
426
+
427
+ - **The certified digest travels with the release attempt.** The `release-attempt`
428
+ deployment marker carries a `payload` of `package_set_digest`, `manifest_sha256`
429
+ and `version`, taken from the values `stage-publish` re-derived from the artifact
430
+ it staged. It is written BEFORE anything is staged, so a missing or mismatched
431
+ digest refuses the stage (nothing staged).
432
+ - **A machine surface for the promote block.** `scripts/ci/canary-verdict.sh
433
+ --emit bash` prints ONLY the executable promote block — byte-identical to the
434
+ text between the fences a human sees (one definition). A FAIL or a non-release
435
+ version has no promote block: `--emit bash` exits 3 with one stderr line.
436
+ - **The unprivileged poll.** `release-promote-poll.yml` runs every 10 minutes
437
+ (`schedule` only — there is no manual trigger, because `gh workflow run --ref <branch>` runs that branch's copy of the workflow, and a guard inside the file cannot bind it to main) and holds NO npm credential: no `environment`,
438
+ no repo secret — it runs on the automatic `GITHUB_TOKEN` with `actions: write`,
439
+ `contents: read` and `deployments: read`. It checks out ONLY the default branch
440
+ at the run's own sha (never a tag's tree), and brings exactly what the package
441
+ derivation reads (`scripts/ci`, the root `package.json` and
442
+ `packages/*/package.json`); that derivation FAILS CLOSED — a non-zero exit or an
443
+ empty list is an error exit that names the cause, never a silent "ready". It
444
+ reads every `release-attempt` / `promoted` marker across ALL pages
445
+ (`--paginate`, flattened), and for each pending marker takes the version from the
446
+ MARKER PAYLOAD (never main's `package.json`, which moves on after a release;
447
+ never the ref alone — the ref must equal `v<payload.version>` or the marker is
448
+ refused). It requires EVERY lockstep package `<name>@<version>` to be public and
449
+ to re-derive the certified package-set digest (ALL-form: one missing/odd package
450
+ is NOT READY, exit 0, the package named), and on READY dispatches
451
+ `release-promote.yml --ref v<version>`, gated behind that workflow existing
452
+ (slice 2). Every run is a schedule run of the default branch's copy of the file, so
453
+ `github.sha` is always a main sha. **The poll's outputs are
454
+ never an input to what gets promoted** — the privileged job re-derives everything
455
+ it acts on. (`test/unit/release-promote-poll-workflow.test.ts`.)
456
+ - **Trust-root ownership.** `.github/CODEOWNERS` puts `/scripts/ci/canary-verdict.sh`,
457
+ `/scripts/ci/package-set-digest.mjs`, `/scripts/ci/registry-tarball-sha256.mjs`,
458
+ `/scripts/ci/registry-latest-skew.mjs`, `/scripts/ci/lockstep-packages.mjs`,
459
+ `/.github/workflows/canary.yml` and `/.github/workflows/release-promote*.yml`
460
+ under the trust root (`@heskew`); the test resolves EFFECTIVE ownership (last
461
+ matching rule wins) for each protected path.
462
+ (`test/unit/release-auto-tag-workflow.test.ts`.)
463
+
464
+ Not in this slice: the privileged `release-promote.yml`, the `release-promote`
465
+ environment, `NPM_TOKEN`, the machinery-recency guard, and the refusal issue with
466
+ restore lines — all slice 2.
@@ -38,9 +38,9 @@ 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
- 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`, line 130) checks npm publish age for external entries in the `dependencies` field 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.
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: they state what the host project must provide, and they are never bundled into our published tarballs. They are still installed, because npm and Bun install non-optional peers by default: a consumer's install resolves them, and our own 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.
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
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.
@@ -121,7 +121,7 @@ Fails any PR where a workspace package declares an internal `@tpsdev-ai/*` dep a
121
121
 
122
122
  ### `scripts/check-dep-ages.mjs` (this PR)
123
123
 
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. Workspace-internal deps exempt. Wired into the `test-unit` job. Its limits, stated: it covers npm production dependencies only (not the Python, Docker or GitHub Actions updates the Renovate preset proposes), and 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.
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.
125
125
 
126
126
  Configurable:
127
127
 
@@ -163,17 +163,22 @@ Each check matches a CI gate exactly so the local and remote outcomes can't drif
163
163
 
164
164
  If you're building on top of `@tpsdev-ai/flair-client` and want the same posture:
165
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
+
166
168
  ```bash
167
- # 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
168
171
  curl -fsSL https://raw.githubusercontent.com/tpsdev-ai/flair/main/scripts/check-dep-ages.mjs \
169
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
170
175
  chmod +x scripts/check-dep-ages.mjs
171
176
 
172
177
  # Wire it into your CI as a fast pre-test step
173
178
  - run: node scripts/check-dep-ages.mjs
174
179
  ```
175
180
 
176
- The script has no external dependencies — node 18+ is enough.
181
+ The two files have no external dependencies — node 18+ is enough.
177
182
 
178
183
  To adopt the same Renovate preset in your repo, make your `.github/renovate.json`:
179
184
 
@@ -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.