@tpsdev-ai/flair 0.55.1 → 0.56.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 (76) hide show
  1. package/README.md +3 -3
  2. package/dist/bridges/builtins/markdown.js +2 -2
  3. package/dist/bridges/discover.js +2 -2
  4. package/dist/bridges/runtime/allow-list.js +2 -2
  5. package/dist/build-info.json +3 -3
  6. package/dist/cli.js +201 -95
  7. package/dist/commands/attention.js +2 -2
  8. package/dist/commands/backup.js +2 -2
  9. package/dist/commands/doctor.js +168 -37
  10. package/dist/commands/export.js +2 -2
  11. package/dist/commands/federation.js +229 -95
  12. package/dist/commands/hook.js +4 -4
  13. package/dist/commands/init.js +94 -70
  14. package/dist/commands/mcp.js +2 -2
  15. package/dist/commands/migrate-harness-memory.js +8 -8
  16. package/dist/commands/rem.js +31 -4
  17. package/dist/commands/service.js +25 -1
  18. package/dist/commands/session.js +2 -2
  19. package/dist/commands/uninstall.js +2 -2
  20. package/dist/commands/upgrade.js +88 -69
  21. package/dist/doctor-client.js +341 -161
  22. package/dist/engine-version.js +2 -2
  23. package/dist/federation/scheduler.js +5 -5
  24. package/dist/hook-install.js +359 -176
  25. package/dist/install/clients.js +908 -214
  26. package/dist/keystore.js +10 -2
  27. package/dist/lib/auth-resolve.js +5 -5
  28. package/dist/lib/config-critical-section.js +557 -0
  29. package/dist/lib/doctor-config-path.js +2 -2
  30. package/dist/lib/doctor-run.js +107 -27
  31. package/dist/lib/flair-paths.js +29 -0
  32. package/dist/lib/home.js +60 -0
  33. package/dist/lib/launchd-repair.js +109 -0
  34. package/dist/lib/mcp-enable.js +4 -4
  35. package/dist/lib/owned-pins.js +256 -94
  36. package/dist/lib/pin-write-guard.js +87 -0
  37. package/dist/lib/settings-bytes.js +85 -0
  38. package/dist/lib/socket-path-limit.js +120 -0
  39. package/dist/lib/uninstall-purge.js +2 -18
  40. package/dist/lib/upgrade-plain-tree.js +2 -2
  41. package/dist/lib/upgrade-status.js +164 -0
  42. package/dist/lib/wiring-spec.js +238 -0
  43. package/dist/mcp-client-assertion.js +3 -3
  44. package/dist/rem/promote-policy.js +102 -0
  45. package/dist/rem/runner.js +3 -3
  46. package/dist/rem/scheduler.js +5 -5
  47. package/dist/rem/snapshot.js +2 -2
  48. package/dist/resources/MemoryReflect.js +10 -0
  49. package/dist/resources/OAuth.js +62 -11
  50. package/dist/resources/Presence.js +135 -47
  51. package/dist/resources/admin-layout.js +7 -2
  52. package/dist/resources/auto-promote-lib.js +56 -0
  53. package/dist/resources/health.js +26 -0
  54. package/dist/resources/memory-reflect-lib.js +215 -6
  55. package/dist/resources/migrations/progress.js +17 -0
  56. package/dist/resources/migrations/runner.js +46 -27
  57. package/dist/resources/migrations/status.js +2 -1
  58. package/dist/src/keystore.js +10 -2
  59. package/dist/src/lib/home.js +60 -0
  60. package/dist/src/rem/promote-policy.js +102 -0
  61. package/dist/src/rem/scheduler.js +5 -5
  62. package/dist/version-check.js +2 -2
  63. package/dist/version-handshake.js +2 -2
  64. package/docs/api-reference.md +31 -6
  65. package/docs/auth.md +14 -2
  66. package/docs/deploying-on-fabric.md +5 -4
  67. package/docs/deployment.md +26 -37
  68. package/docs/embedding-in-a-harper-app.md +4 -2
  69. package/docs/entity-vocabulary.md +5 -5
  70. package/docs/federation.md +58 -19
  71. package/docs/hosted-on-fabric.md +7 -5
  72. package/docs/mcp-clients.md +29 -12
  73. package/docs/releasing.md +66 -22
  74. package/docs/spoke-bringup.md +41 -22
  75. package/docs/standalone-local.md +12 -16
  76. package/package.json +3 -1
@@ -202,3 +202,105 @@ export function validateHumanReviewerId(reviewerId) {
202
202
  }
203
203
  return null;
204
204
  }
205
+ // ─── Structural-truncation signal (flair#1756 slice 2, #1776 slice 3) ────────
206
+ // The SINGLE definition of the structural-truncation signal. The GATE for it
207
+ // lives server-side in resources/auto-promote-lib.ts (decideAutoPromote — the
208
+ // UNATTENDED path), which IMPORTS these from here. The direction is deliberate
209
+ // and established in this repo: a server file may import a PURE helper from src/
210
+ // (resources/PromoteMemoryCandidate.ts and resources/soul-adk-guard.ts already
211
+ // import this very module); it is a CLI file importing FROM resources/ that does
212
+ // not survive npm packaging. Defining it here lets the CLI side
213
+ // (src/commands/rem.ts, `flair rem candidates`) and the server gate share ONE
214
+ // implementation rather than a hand-kept pair.
215
+ //
216
+ // Detects STRUCTURAL imbalance (unclosed/unmatched backtick, bracket, paren,
217
+ // brace) — NOT semantic completeness. A balanced claim can still be a fragment.
218
+ //
219
+ // The delimiter set is an ENUMERATED table (STRUCTURAL_PAIRS, below): the ASCII
220
+ // pairs `( )`, `[ ]`, `{ }` AND the full-width/CJK pairs
221
+ // `()[]{}【】〔〕〖〗「」『』《》〈〉〘〙〚〛`. Both the opener set and the closer
222
+ // map are DERIVED from that one list, so a pair cannot be added to one side and
223
+ // missed on the other. The table IS the boundary: mathematical and ornamental
224
+ // brackets (`⟨⟩ ⟦⟧ ⌈⌉ ⌊⌋ ⁅⁆ ⦅⦆ ❨❩ ༺༻`) are deliberately EXCLUDED — they are used
225
+ // standalone in real text, so counting them by category would over-refuse. The
226
+ // set is deliberately NOT derived from Unicode general categories
227
+ // (`\p{Ps}` / `\p{Pe}`) and is NOT described as "Unicode-aware": category
228
+ // membership does not establish paired usage (Ogham `᚛` and bare `༺`/`༻`,
229
+ // `⸢`/`⸣`, `⌈`/`⌉` are permitted standalone by the core spec), and a category
230
+ // counter refuses ordinary COMPLETE prose — see the quotation-mark note
231
+ // immediately below. There is no vendored Unicode data and no codegen here.
232
+ //
233
+ // QUOTATION MARKS OF EVERY SCRIPT ARE OUT OF SCOPE. `“ ” ‘ ’ „ “ ‚ ‘ « »` are
234
+ // NOT counted, so a claim truncated mid-quotation is judged balanced. The reason
235
+ // is concrete, not a preference: U+201E `„` (and U+201A `‚`) is category Ps
236
+ // while its closing mark U+201C (U+2018) is Pi, so ANY category-based counter
237
+ // reports positive depth on the ordinary COMPLETE German quotation `„Fertig.“`
238
+ // and refuses it; and U+2019 `’` is the standard English apostrophe (category
239
+ // Pf), so a quote-counting leg refuses every English contraction (e.g. `isn’t`).
240
+ // Enumerating matched bracket pairs avoids both false positives. That is why
241
+ // categories were rejected in favour of this table.
242
+ //
243
+ // The check counts delimiters without interpreting context, so a complete claim
244
+ // that merely DISCUSSES an unmatched delimiter is also flagged/refused
245
+ // (fail-closed; nothing is lost — the candidate stays pending for the human
246
+ // `rem promote` path).
247
+ //
248
+ // Runtimes this signal was exercised against (2026-09-21): Node v22.22.1
249
+ // (process.versions.unicode = 17.0) and Bun 1.3.10 (process.versions.unicode =
250
+ // 15.1). Passing the check means NO DETECTED IMBALANCE for the enumerated
251
+ // pairs — never completeness, and never coverage of an unenumerated script.
252
+ // The one source of truth: [opener, closer]. The two lookups below are DERIVED,
253
+ // so there is no second hand-kept list that can drift out of step. All three are
254
+ // exported so the pair-table invariant can be pinned by a test without
255
+ // duplicating the list here.
256
+ export const STRUCTURAL_PAIRS = [
257
+ ["(", ")"], ["[", "]"], ["{", "}"],
258
+ ["(", ")"], ["[", "]"], ["{", "}"],
259
+ ["【", "】"], ["〔", "〕"], ["〖", "〗"],
260
+ ["「", "」"], ["『", "』"],
261
+ ["《", "》"], ["〈", "〉"], ["〘", "〙"], ["〚", "〛"],
262
+ ];
263
+ export const STRUCTURAL_OPENERS = new Map(STRUCTURAL_PAIRS);
264
+ export const STRUCTURAL_CLOSERS = new Map(STRUCTURAL_PAIRS.map(([opener, closer]) => [closer, opener]));
265
+ /**
266
+ * Return a description of the STRUCTURAL imbalance in `claim` (an unmatched or
267
+ * closing-first bracket, an unclosed opener, or an odd number of backticks), or
268
+ * null if it is balanced. The delimiter set is the ENUMERATED table above
269
+ * (ASCII + full-width/CJK pairs); a delimiter outside that set — in particular a
270
+ * quotation mark of any script — is not examined and does not make this
271
+ * non-null. Pure. The description is for diagnostics only — it is NOT surfaced
272
+ * as a claim about completeness.
273
+ */
274
+ export function structuralImbalance(claim) {
275
+ const stack = [];
276
+ for (const ch of claim) {
277
+ if (STRUCTURAL_OPENERS.has(ch)) {
278
+ stack.push(ch);
279
+ }
280
+ else {
281
+ const opener = STRUCTURAL_CLOSERS.get(ch);
282
+ if (opener !== undefined && stack.pop() !== opener)
283
+ return `unmatched '${ch}'`;
284
+ }
285
+ }
286
+ if (stack.length > 0)
287
+ return `unclosed '${stack[stack.length - 1]}'`;
288
+ if (((claim.match(/`/g) ?? []).length) % 2 !== 0)
289
+ return "unbalanced backtick";
290
+ return null;
291
+ }
292
+ /**
293
+ * True iff `claim` ends with terminal punctuation (optionally followed by a
294
+ * closing quote/bracket). This is a FLAG INPUT ONLY, never a refusal: plenty of
295
+ * legitimate claims end without a full stop, and on the UNATTENDED path a false
296
+ * refusal is silent. `flair rem candidates` surfaces it for the human reviewer.
297
+ *
298
+ * Terminators: ASCII `.` `!` `?` plus the full-width/CJK `。` (U+3002), `!`
299
+ * (U+FF01), `?` (U+FF1F). The trailing-suffix class accepts the quote/bracket
300
+ * closers it always did plus the enumerated bracket closers
301
+ * `」』)]}】〕〗》〉〙〛`. The single-dot leaders `…` `‥` `․` are deliberately NOT
302
+ * terminators — they are not interchangeable with a full stop.
303
+ */
304
+ export function hasTerminalPunctuation(claim) {
305
+ return /[.!?。!?]["')\]}»”’」』)]}】〕〗》〉〙〛]*$/.test(claim.trimEnd());
306
+ }
@@ -15,25 +15,25 @@
15
15
  */
16
16
  import { existsSync, mkdirSync, chmodSync, rmSync } from "node:fs";
17
17
  import { resolve, dirname } from "node:path";
18
- import { homedir } from "node:os";
19
18
  import { spawn } from "node:child_process";
20
19
  import { fileURLToPath } from "node:url";
21
20
  import { escapeXml } from "../lib/xml-escape.js";
22
21
  import { detectPlatform as detectPlatformFor, spawnReport, readTemplate as readTemplateFrom, renderTemplateWith, writeFileWithDir, interpretActiveResult, describeLoadFailure as describeLoadFailureFor, describeExitCode, resolveNodeBin, resolveFlairBin, formatFlairBinWarning, verifyFirstRun, probeUserLingerEnabled, STATUS_CHECK_TIMEOUT_MS, } from "../lib/scheduler-platform.js";
22
+ import { resolveHome } from "../lib/home.js";
23
23
  // Re-exported so this module's public surface is unchanged by the extraction
24
24
  // into src/lib/scheduler-platform.ts (a second scheduler — `flair federation
25
25
  // sync enable` — needs the identical launchctl/systemctl interpretation, and
26
26
  // flair#850's lesson must have exactly one implementation).
27
27
  export { interpretActiveResult };
28
- export const SHIM_PATH_DEFAULT = resolve(homedir(), ".flair", "bin", "flair-rem-nightly");
28
+ export const SHIM_PATH_DEFAULT = resolve(resolveHome(), ".flair", "bin", "flair-rem-nightly");
29
29
  // Unit names, exported (flair#1278) so `flair doctor`'s scheduled-drivers
30
30
  // section addresses the same job this module installs — same single-source
31
31
  // rule as the federation scheduler's LAUNCHD_LABEL/SYSTEMD_*_UNIT constants.
32
32
  export const LAUNCHD_LABEL = "dev.flair.rem.nightly";
33
33
  export const SYSTEMD_TIMER_UNIT = "flair-rem-nightly.timer";
34
34
  export const SYSTEMD_SERVICE_UNIT = "flair-rem-nightly.service";
35
- export const LAUNCHD_PLIST_PATH = resolve(homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
36
- export const SYSTEMD_USER_DIR = resolve(homedir(), ".config", "systemd", "user");
35
+ export const LAUNCHD_PLIST_PATH = resolve(resolveHome(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
36
+ export const SYSTEMD_USER_DIR = resolve(resolveHome(), ".config", "systemd", "user");
37
37
  export const SYSTEMD_TIMER_PATH = resolve(SYSTEMD_USER_DIR, SYSTEMD_TIMER_UNIT);
38
38
  export const SYSTEMD_SERVICE_PATH = resolve(SYSTEMD_USER_DIR, SYSTEMD_SERVICE_UNIT);
39
39
  function detectPlatform(override) {
@@ -102,7 +102,7 @@ function buildSubstitutions(opts, shimPath, flairBin, nodeBin) {
102
102
  FLAIR_BIN: flairBin,
103
103
  NODE_BIN: nodeBin,
104
104
  SHIM_PATH: shimPath,
105
- HOME: opts.homeOverride ?? homedir(),
105
+ HOME: opts.homeOverride ?? resolveHome(),
106
106
  AGENT_ID: opts.agentId,
107
107
  FLAIR_URL: opts.flairUrl,
108
108
  HOUR: String(opts.hour),
@@ -29,12 +29,12 @@
29
29
  * current fact.
30
30
  */
31
31
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
32
- import { homedir } from "node:os";
33
32
  import { dirname, join } from "node:path";
34
33
  import { parseSemverCore } from "./fabric-upgrade.js";
35
34
  import { fetchLatestVersion } from "./lib/npm-registry.js";
35
+ import { resolveHome } from "./lib/home.js";
36
36
  export const FLAIR_PKG_NAME = "@tpsdev-ai/flair";
37
- export const DEFAULT_CACHE_PATH = join(homedir(), ".flair", ".version-check-cache.json");
37
+ export const DEFAULT_CACHE_PATH = join(resolveHome(), ".flair", ".version-check-cache.json");
38
38
  /** How long a cached "latest" answer is trusted before we re-hit the registry. */
39
39
  export const DEFAULT_TTL_MS = 12 * 60 * 60 * 1000; // 12h
40
40
  /** Registry fetch timeout — this runs on every status/doctor call, so it must stay short. */
@@ -17,10 +17,10 @@
17
17
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
18
18
  import { createHash } from "node:crypto";
19
19
  import { dirname, join } from "node:path";
20
- import { homedir } from "node:os";
20
+ import { resolveHome } from "./lib/home.js";
21
21
  export const DEFAULT_HANDSHAKE_TTL_MS = 60_000;
22
22
  export const DEFAULT_HANDSHAKE_TIMEOUT_MS = 1500; // within the spec's 1-2s budget
23
- export const DEFAULT_HANDSHAKE_CACHE_DIR = join(homedir(), ".flair", ".version-handshake-cache");
23
+ export const DEFAULT_HANDSHAKE_CACHE_DIR = join(resolveHome(), ".flair", ".version-handshake-cache");
24
24
  export function defaultHandshakeDeps() {
25
25
  return {
26
26
  fetchImpl: fetch,
@@ -44,14 +44,14 @@ the schema section so the catalog is complete.
44
44
 
45
45
  | Class | Credential | Typical grant |
46
46
  |-------|------------|---------------|
47
- | **Public** | none | Discovery, health, OAuth well-known, Presence roster (field-allowlisted) |
47
+ | **Public** | none | Discovery, health, OAuth well-known. `GET /Presence` is public only when the instance opts in to a public roster (`PRESENCE_PUBLIC_ROSTER=true`) — by default it needs a verified reader. See [Presence for API consumers](#presence-for-api-consumers). |
48
48
  | **Ed25519 agent** | `TPS-Ed25519` header | Default agent path. Writes as self only. Reads follow the resource's read-scope (below). |
49
49
  | **Admin Basic** | Harper `HDB_ADMIN_PASSWORD` / `FLAIR_ADMIN_PASSWORD` | Whole-instance operator. Bypasses agent scoping, including `private` memory. Used by the web admin and `n8n-nodes-flair`. |
50
50
  | **Operator / internal** | Admin Basic, or a deliberate `internalContext()` call inside the process | Soul mutations and `AgentSeed`. Agent Ed25519 keys — including admin-agent keys — cannot author Soul. |
51
51
  | **Federation body-sig** | Ed25519 over the request body + timestamp/nonce; pairing uses a one-time token | `/FederationPair`, `/FederationSync`. Harper role gate is open; the handler is the auth boundary. |
52
52
  | **OAuth bearer** | Access token from Flair's AS or `@harperfast/oauth` | `/mcp` only, and only when `FLAIR_MCP_OAUTH=true` plus a public issuer. Off by default (path 404s). |
53
53
 
54
- Anonymous HTTP is denied on every agent-facing table. A by-id miss and a
54
+ Anonymous HTTP is denied on every agent-facing table (and on `GET /Presence`, which needs a verified reader unless the instance enables the public-roster opt-in). A by-id miss and a
55
55
  by-id deny both return **404**, never 403, so ids are not an existence oracle.
56
56
 
57
57
  ### Read-scope vocabulary
@@ -107,8 +107,8 @@ is `GET /Name/<id>` unless noted.
107
107
  | POST | `/Agent` | Admin Basic | Create principal. Also `POST /AgentSeed` (operator/internal only — not an admin-agent key). |
108
108
  | PUT / PATCH | `/Agent/<id>` | Ed25519 | An agent updates **only its own** record. |
109
109
  | DELETE | `/Agent/<id>` | Admin Basic | Deprovision. |
110
- | GET | `/Presence` | Public | Roster, field-allowlisted. `currentTask` is null for anonymous callers; verified agents see the text. |
111
- | POST | `/Presence` | Ed25519 | Heartbeat. Agent writes only its own row (403 cross-agent). Stamps `flairVersion` / `harperVersion`. |
110
+ | GET | `/Presence` | Verified reader | Roster. Requires a valid `TPS-Ed25519` agent signature or the admin credential; an anonymous request gets 401. An instance may opt in to a public roster with `PRESENCE_PUBLIC_ROSTER=true`, in which case an unverified reader gets the allowlisted roster with `currentTask`, `flairVersion`, and `harperVersion` as null. Thresholds: [Presence for API consumers](#presence-for-api-consumers). |
111
+ | POST | `/Presence` | Ed25519 | Heartbeat. Agent writes only its own row (403 cross-agent). Stamps `flairVersion` / `harperVersion` on the row. |
112
112
  | PUT / DELETE | `/Presence/<id>` | Ed25519 | Own row only. Collection PUT is not a public bypass. |
113
113
  | GET | `/Soul`, `/Soul/<id>` | Ed25519 | Any verified agent; unscoped (identity/discovery). |
114
114
  | POST / PUT / PATCH / DELETE | `/Soul` | **Operator / internal** | Not Ed25519. Learned Memory text cannot be copied in as Soul. See [docs/auth.md](auth.md#soul-authorship). |
@@ -295,8 +295,33 @@ client-writable even if a client sends them. Full comments live in
295
295
  | `currentTask` | String | Free text; verified-agent read only |
296
296
  | `activity` | String | `coding` \| `reviewing` \| `planning` \| `debugging` \| `idle` |
297
297
  | `activityUpdatedAt` | BigInt | When activity/task were asserted |
298
- | `flairVersion` | String | Serving `@tpsdev-ai/flair` version |
299
- | `harperVersion` | String | Serving Harper version |
298
+ | `flairVersion` | String | Serving `@tpsdev-ai/flair` version. Null when redacted or never stamped — see below. |
299
+ | `harperVersion` | String | Serving Harper version. Same redaction. Also null when the server could not resolve Harper's version. |
300
+
301
+ ### Presence for API consumers
302
+
303
+ `GET /Presence` requires a **verified reader** by default. A verified reader is a request carrying a valid `TPS-Ed25519` agent signature from an agent registered on this instance, or the admin credential. An anonymous — or otherwise unverified — request gets **401**, not a redacted roster. The roster is org-visible data (who is working, on what class of activity, and how recently) and is not published by default.
304
+
305
+ An instance that runs a public status page opts back in with the presence config key `PRESENCE_PUBLIC_ROSTER=true` (the same env-var channel as the thresholds below); it is **off by default** and is documented as *publishes your roster to the internet*. With it on the behaviour is exactly as it was before: an anonymous caller gets the field-allowlisted roster (id, display name, role, runtime, activity fields, `presenceStatus`, `lastHeartbeatAt`), and three fields are redacted to `null` unless the request carries a valid `TPS-Ed25519` agent signature: `currentTask`, `flairVersion`, and `harperVersion`. Anonymous callers, unsigned loopback, Basic admin, and in-process calls without that signature are unverified readers of the content gate. The nulls are intentional. Version strings are withheld so a public roster cannot fingerprint the instance (the same split as public `/Health` versus Ed25519 `/HealthDetail`). A null `flairVersion` on an unverified read does not mean the peer lacks a version, and it does not mean the peer cannot accept a directed handoff.
306
+
307
+ A verified reader still sees `null` for a version the row never stored. Heartbeats stamp the running server's versions; a row written before that stamp, and not heartbeated since, has no value to return. `harperVersion` is also null when this process could not resolve Harper's package version. That null means unknown, not redacted.
308
+
309
+ `presenceStatus` is liveness of `lastHeartbeatAt`. The idle threshold defaults to 90 seconds and the offline threshold defaults to 10 minutes. A tuned instance overrides those numbers with `PRESENCE_IDLE_THRESHOLD_MS` and `PRESENCE_OFFLINE_THRESHOLD_MS` (milliseconds). Read the live values from those variables; the 90s and 10m figures below are only what an unset process uses. An unset, empty, zero, or non-numeric value falls back to that default:
310
+
311
+ | Age of `lastHeartbeatAt` | `presenceStatus` |
312
+ |---|---|
313
+ | Missing, or not a finite number | `offline` |
314
+ | Negative (stamp ahead of the server clock) | `active` |
315
+ | Younger than the idle threshold (`PRESENCE_IDLE_THRESHOLD_MS`, default 90s) | `active` |
316
+ | Younger than the offline threshold (`PRESENCE_OFFLINE_THRESHOLD_MS`, default 10 min) | `idle` |
317
+ | At or beyond the offline threshold, when the idle threshold is at or below it | `offline` |
318
+ | At or beyond the idle threshold, when the idle threshold is above the offline threshold (the idle status never occurs then) | `offline` |
319
+
320
+ The rows are checked in that order and the first match wins. `derivePresenceStatus` (`resources/Presence.ts`) returns `active` while the age is strictly below `PRESENCE_IDLE_THRESHOLD_MS`, even when that age is already at or past `PRESENCE_OFFLINE_THRESHOLD_MS`. The ordering these rows describe is an idle threshold strictly below the offline threshold. An age equal to the offline threshold is `offline` only when the idle threshold is at or below the offline threshold; when the idle threshold is above it, the `active` row matches first and the status is `active`.
321
+
322
+ `activityFresh` uses a different stamp: `activityUpdatedAt` when that is a finite number, otherwise `lastHeartbeatAt`. It is true while that stamp is younger than the **offline** threshold (`PRESENCE_OFFLINE_THRESHOLD_MS`, default 10 minutes), including when the stamp is in the future. While it is true, `activity` is the stored label (`coding`, `reviewing`, `planning`, `debugging`, or `idle`). When it is false, `activity` is reported as `idle`, `lastActivity` keeps the stored label, and `currentTask` is null even for a verified reader. `activityAgeMs` is how old that stamp is.
323
+
324
+ A peer can therefore show `presenceStatus: "offline"`, `activity: "idle"`, `lastActivity: "coding"`, and `activityFresh: false` at once: the heartbeat is past the offline threshold, and the live activity label has lapsed. Gate "is this agent doing this now" on `activityFresh` (and `activityAgeMs`). Read `presenceStatus` for heartbeat liveness. Read `lastActivity` as what they were doing, not what they are doing.
300
325
 
301
326
  ### Memory (`schemas/memory.graphql`)
302
327
 
package/docs/auth.md CHANGED
@@ -273,12 +273,24 @@ flair idp add \
273
273
 
274
274
  ### JIT Provisioning
275
275
 
276
- First-time IdP users are automatically created as `unverified` principals. An admin can promote them to `verified` or `admin` via:
276
+ First-time IdP users are automatically created as `unverified` principals.
277
+
278
+ Trust tier and admin are different fields. `flair principal promote` changes only `defaultTrustTier`. It takes the principal id and a tier:
277
279
 
278
280
  ```bash
279
- flair principal promote <principal-id>
281
+ flair principal promote <principal-id> <tier>
280
282
  ```
281
283
 
284
+ `<tier>` is one of `endorsed`, `corroborated`, or `unverified`. There is no `verified` tier and no `admin` tier. The command writes `defaultTrustTier` and does not write `role` or `admin`, so it cannot grant admin.
285
+
286
+ Admin authority is `role: admin` on the Agent record. `admin: true` is the mirror the server keeps in step with that role; setting the mirror alone does not grant admin. The CLI that writes both is:
287
+
288
+ ```bash
289
+ flair principal add <principal-id> --admin
290
+ ```
291
+
292
+ `add` upserts the Agent row. If `~/.flair/keys/<principal-id>.key` already exists, that key is reused and is not regenerated. The upsert writes the record this command builds, including `role: admin` and `admin: true` when `--admin` is set. With `--admin` and no `--trust`, the trust tier written is `endorsed`.
293
+
282
294
  ### CLI Reference
283
295
 
284
296
  | Command | Description |
@@ -164,17 +164,18 @@ No shell on the hub, so mint the token remotely rather than over `ssh`:
164
164
 
165
165
  ```bash
166
166
  # On any machine — note --ops-target, this hits the ops API
167
- FLAIR_ADMIN_PASS=<hub-admin-password> flair federation token \
167
+ (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
168
168
  --target https://<cluster>.<org>.harperfabric.com \
169
- --ops-target <ops-url> > ./pair-triple.json
169
+ --ops-target <ops-url> > ./pair-triple.json)
170
170
 
171
171
  # On the spoke
172
- flair federation pair https://<cluster>.<org>.harperfabric.com \
172
+ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<cluster>.<org>.harperfabric.com \
173
173
  --token-from ./pair-triple.json
174
174
  ```
175
175
 
176
176
  `federation token` takes `--admin-pass`, **not** `--admin-pass-file`. The triple holds a
177
- one-time credential — delete it after pairing (60-min TTL, `--ttl`).
177
+ one-time credential — delete it after pairing (60-min TTL, `--ttl`). `set -C` refuses to
178
+ overwrite an existing `pair-triple.json`, so remove an old one first.
178
179
 
179
180
  ### Federation is push-only
180
181
 
@@ -136,43 +136,33 @@ Then set `FLAIR_URL=http://localhost:19926` on the client.
136
136
 
137
137
  ### Direct network access
138
138
 
139
- Flair reads the HTTP bind host from three places — the first one set wins:
139
+ On `flair start`, `flair restart`, and `flair upgrade` the HTTP bind host is resolved in this order. The first one set wins. None of those commands take an `--http-bind` flag:
140
140
 
141
- 1. `flair init --http-bind <host>`
142
- 2. `FLAIR_HTTP_BIND` in the Flair process environment
143
- 3. a **top-level** `httpBind:` key in `~/.flair/config.yaml`
141
+ 1. `FLAIR_HTTP_BIND` in the Flair process environment
142
+ 2. a **top-level** `httpBind:` key in `~/.flair/config.yaml`
143
+ 3. `127.0.0.1`
144
144
 
145
- `127.0.0.1` is the default when none is set. **Only hosts that include IPv4
146
- loopback are accepted** — `127.0.0.1` itself, or a wildcard (`0.0.0.0` / `::`).
147
- Every credentialed self-call Flair makes hardcodes `127.0.0.1`, so a bind that
148
- excludes it is refused: it would leave those calls pointing at a dead port
149
- while every bind check still passed.
145
+ `flair init --http-bind <host>` is how that `httpBind` key gets written. During `init` the flag wins over `FLAIR_HTTP_BIND`, and the host that won is persisted. On Linux the CLI starts Harper directly and resolves the bind on every start, so a later start follows the list above and an env var in the service's environment overrides the file. On macOS the resolved bind is stored in the launchd job instead of being re-read on the launchd reload path: any restart that goes through it — `flair restart` included, and a restart launchd starts itself (a reboot, a crash, KeepAlive) — reuses that stored value and does not re-read `FLAIR_HTTP_BIND` or `config.yaml`; only `flair init` writes it.
150
146
 
151
- To widen deliberately, pass the flag — or record it in config so the choice
152
- survives `flair restart` / `flair upgrade`, neither of which takes the flag:
147
+ **Only hosts that include IPv4 loopback are accepted** — `127.0.0.1` itself, or a wildcard (`0.0.0.0` / `::`). Every credentialed self-call Flair makes hardcodes `127.0.0.1`. A bind that excludes that address is refused: those calls would point at a dead port while every bind check still passed. A specific LAN address is not accepted. Loopback is the default so a single-host install does not expose the HTTP surface, including unauthenticated `/Health`, on every interface.
148
+
149
+ To widen deliberately, record a wildcard so the choice survives restart and upgrade:
153
150
 
154
151
  ```bash
155
152
  flair init --http-bind 0.0.0.0
156
153
  ```
157
154
 
158
155
  ```yaml
159
- # ~/.flair/config.yaml — top-level, NOT nested under `http:`
156
+ # ~/.flair/config.yaml — top-level key. There is no nested `http:` block.
160
157
  httpBind: 0.0.0.0
161
158
  ```
162
159
 
163
- > **`http.host` is not read.** Earlier versions of this page told you to widen
164
- > the bind with a nested `http.host:` key. **Flair never read that key**, and
165
- > from 0.55.0 it is ignored outright: an install that was only ever wide
166
- > because the old default bound every interface will narrow to `127.0.0.1` on
167
- > the next `flair restart` or `flair upgrade`. The block below is kept so this
168
- > section stays findable from a snippet you may already have — **do not copy
169
- > it**; use `httpBind:` (or `--http-bind` / `FLAIR_HTTP_BIND`) instead.
160
+ A nested `http.host` (or `http.port`) is not read. An install that was only wide because an older default bound every interface narrows to `127.0.0.1` on the next `flair restart` or `flair upgrade` unless `FLAIR_HTTP_BIND` or `httpBind` names a wildcard.
170
161
 
171
- ```yaml
172
- # OLD — ignored by Flair. Replace with `httpBind:` as above.
173
- http:
174
- port: 19926
175
- host: 0.0.0.0 # listen on all interfaces
162
+ **Confirm the bind.** `flair status` prints the URL the CLI dials. That URL stays on loopback even when the listener is widened, so it is not the bind. After a Flair-managed start, Harper records the listener it was given as `http.port` in the instance data directory (default `~/.flair/data/harper-config.yaml`, legacy name `harperdb-config.yaml`). The value is host-qualified, for example `127.0.0.1:19926`, `0.0.0.0:19926`, or `[::]:19926`. The live socket shows the same address:
163
+
164
+ ```bash
165
+ lsof -nP -iTCP:19926 -sTCP:LISTEN
176
166
  ```
177
167
 
178
168
  **Security:** Flair uses Ed25519 authentication. Agents must present a valid signature to read or write. However, the `/Health` endpoint is unauthenticated. For internet-facing deployments, put Flair behind a reverse proxy with TLS.
@@ -185,26 +175,25 @@ All configuration lives in `~/.flair/`:
185
175
 
186
176
  ```
187
177
  ~/.flair/
188
- ├── config.yaml # port, bind host, embedding model
189
- ├── data/ # Harper database
178
+ ├── config.yaml # port, opsPort, opsBind, httpBind
179
+ ├── data/ # Harper database (harper-config.yaml lives here)
190
180
  ├── keys/ # Ed25519 keypairs per agent
191
181
  └── backups/ # flair backup output
192
182
  ```
193
183
 
194
184
  ### Key config options (`~/.flair/config.yaml`)
195
185
 
196
- ```yaml
197
- # Top-level keys — Flair's config has no nested `http:` block, and no
198
- # `http.host`.
199
- port: 19926 # API port (ops port = this - 1)
200
- httpBind: 127.0.0.1 # HTTP bind host (see "Direct network access" above)
186
+ Flair reads four top-level keys from this file: `port`, `opsPort`, `opsBind`, and `httpBind`. `flair init` rewrites the file with those keys and drops anything else, including a `clustering:` or `logging:` block and any embedding-model key. Embedding threads, GPU layers, and the model directory are environment variables in the table below, not keys in this file.
201
187
 
202
- clustering:
203
- nodeName: flair
188
+ `clustering` and `logging` are not read from `~/.flair/config.yaml` or from `<dataDir>/harper-config.yaml` by anything in this repository, so they are not given a home here. Harper itself does read its own clustering and logging settings — from its `harperdb-config.yaml` — so configure those there, not here. Harper's generative `models:` block, when REM needs one, does belong in `<dataDir>/harper-config.yaml`. See [rem.md](rem.md).
204
189
 
205
- logging:
206
- level: warn
207
- stdStreams: true
190
+ ```yaml
191
+ # ~/.flair/config.yaml — only these keys are read. A later `flair init`
192
+ # rewrites the file and drops every other key.
193
+ port: 19926
194
+ opsPort: 19925 # Harper operations API port
195
+ opsBind: 127.0.0.1 # operations API bind host
196
+ httpBind: 127.0.0.1 # HTTP bind host (see "Direct network access" above)
208
197
  ```
209
198
 
210
199
  ### Environment variables
@@ -217,7 +206,7 @@ Set these in the Flair process environment (`~/Library/LaunchAgents/ai.tpsdev.fl
217
206
  | `HDB_ADMIN_PASSWORD` | Bootstrap password for the embedded Harper. After first start, the persisted user record is the source of truth; rotate via the Harper ops API, not by changing this env var. | Set at install time. See [secrets-and-keys.md](secrets-and-keys.md) for rotation. |
218
207
  | `FLAIR_KEY_PASSPHRASE` | Passphrase used to derive the AES-256-GCM key that wraps federation private-key seeds at rest. Auto-generated to `~/.flair/keys/.passphrase` if unset. | Set explicitly for production federation deployments so the passphrase isn't auto-generated and lost on disk wipe. |
219
208
  | `HTTP_PORT` | Override the Harper HTTP port. Useful for sandboxes; production deployments should configure the port in `config.yaml` instead. | Rare. |
220
- | `FLAIR_HTTP_BIND` | Bind address for the Harper **HTTP API**. Resolution order: `flair init --http-bind` > this variable > the top-level `httpBind` key `flair init` persists in `~/.flair/config.yaml` > `127.0.0.1`. Only `127.0.0.1` or a wildcard (`0.0.0.0` / `::`) is accepted — the listener must include IPv4 loopback for Flair's own `127.0.0.1` self-calls. Every Flair-managed Harper start re-asserts the resolved value, so the persisted key is what survives `flair restart` / `flair upgrade`. | Only for deployments that need the HTTP API reachable off-host — set it to `0.0.0.0`, or record it once with `flair init --http-bind 0.0.0.0`. Single-host installs want the loopback default. |
209
+ | `FLAIR_HTTP_BIND` | Bind address for the Harper **HTTP API**. On start, restart, and upgrade the order is this variable, then the top-level `httpBind` key in `~/.flair/config.yaml`, then `127.0.0.1`. `flair init --http-bind` writes that key (the flag wins over this variable during init). Only `127.0.0.1` or a wildcard (`0.0.0.0` / `::`) is accepted — the listener must include IPv4 loopback for Flair's own `127.0.0.1` self-calls. See [Direct network access](#direct-network-access). | Only for deployments that need the HTTP API reachable off-host — set it to `0.0.0.0`, or record it once with `flair init --http-bind 0.0.0.0`. Single-host installs want the loopback default. |
221
210
  | `FLAIR_OPS_BIND` | Bind address for the Harper **ops API**. Resolution order: `flair init --ops-bind` > this variable > the `opsBind` key `flair init` persists in `~/.flair/config.yaml` > `127.0.0.1`. Every Flair-managed Harper start re-asserts the resolved value, so the persisted key is what makes a choice survive `flair restart` / `flair upgrade`. | Only for deployments that genuinely need remote ops admin (multi-host / Fabric) — set it to `0.0.0.0`, or record it once with `flair init --ops-bind 0.0.0.0`. Single-host installs want the loopback default. |
222
211
 
223
212
  ### Performance-related environment variables
@@ -272,12 +272,14 @@ flair memory search "deploy schedule" --agent mybot
272
272
  Federation, which has no in-process equivalent:
273
273
 
274
274
  ```bash
275
- flair federation token --admin-pass <hub-admin-pass> > triple.json
276
- flair federation pair <hub-url> --token-from ./triple.json
275
+ (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token > triple.json)
276
+ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from ./triple.json
277
277
  flair federation sync enable --interval 300
278
278
  flair federation status
279
279
  ```
280
280
 
281
+ `set -C` makes the redirect refuse an existing `triple.json` (and `umask 077` only modes a file it creates); remove an old one first (`rm triple.json`). `--admin-pass` is also accepted but puts the password in shell history and process listings; prefer the environment form above (or a secret manager).
282
+
281
283
  `sync enable` landed **after 0.30.0**; on an older install, schedule the one-shot yourself.
282
284
 
283
285
  A `SyncLog` row reads `direction: "pull"` — the receiver's label for a push it accepted. `"push"` is never written. Not a pull path.
@@ -10,9 +10,9 @@ matching across free-text fields.
10
10
  This document is that convention. It's written down and enforced by a small validator
11
11
  (`resources/entity-vocab.ts`) **before** anything is built on top of it, because three
12
12
  surfaces already consume entity strings today (the `Relationship` graph's `subject`/`object`,
13
- and the new `entities` fields on `WorkspaceState`/`OrgEvent`/`Memory`), plus a future
14
- attention query and any future MCP scope field — retrofitting a divergent vocabulary later
15
- is expensive.
13
+ and the new `entities` fields on `WorkspaceState`/`OrgEvent`/`Memory`), plus the attention
14
+ query and bootstrap collision surfacing (both shipped in later slices) and any future MCP
15
+ scope field — retrofitting a divergent vocabulary later is expensive.
16
16
 
17
17
  > This doc covers the vocabulary and validator only — the foundation slice of the attention
18
18
  > plane (flair#675). The attention query ("what touches entity E in the last N days") and
@@ -84,7 +84,7 @@ Per the attention-plane spec's K&S-approved refinements, `entities: [String] @in
84
84
  - `WorkspaceState` (`schemas/workspace.graphql`)
85
85
  - `OrgEvent` (`schemas/event.graphql`)
86
86
  - `Memory` (`schemas/memory.graphql`) — added in v1 (not deferred to v2) for index-pushdown
87
- uniformity across all three sources the future attention query joins.
87
+ uniformity across all three sources the attention query (shipped in a later slice) joins.
88
88
 
89
89
  Existing rows on all three tables simply carry no `entities` — readers must tolerate absence,
90
90
  the same pattern already used for `Presence.activityUpdatedAt`. No migration, no backfill.
@@ -111,7 +111,7 @@ vocabulary; wiring that validation is a follow-up, not part of this foundation s
111
111
 
112
112
  ## What's explicitly NOT in this slice
113
113
 
114
- - The attention query (`AttentionQuery` / `flair attention <entity>`) that joins Memory,
114
+ - The attention query (`AttentionQuery` / `flair attention <type:value>`) that joins Memory,
115
115
  Relationship, WorkspaceState, Presence, and OrgEvent by entity — shipped in flair#678
116
116
  (`resources/AttentionQuery.ts`), a later slice.
117
117
  - Bootstrap collision surfacing ("others in the room") — shipped in flair#681
@@ -4,7 +4,7 @@ Hub-and-spoke sync between Flair instances. A hub instance coordinates sync for
4
4
 
5
5
  ## Overview
6
6
 
7
- Federation lets multiple Flair instances share memories, relationships, and agent records **in one direction per call**. Each instance maintains its own Ed25519 identity. Sync requests are signed and verified against pinned peer public keys.
7
+ Federation lets multiple Flair instances share memories, relationships, and agent records **in one direction per call**. Each instance maintains its own Ed25519 identity. Sync requests are signed and verified against pinned peer public keys. A push omits private memories — see [What a push sends](#what-a-push-sends).
8
8
 
9
9
  ```
10
10
  Spoke A ──[POST /FederationSync]──▶ Hub
@@ -35,7 +35,7 @@ Pairing connects a spoke to a hub with mutual key pinning and an auth-aware hand
35
35
  On the hub machine, the admin runs `flair federation token`. The command emits a JSON triple containing a one-time bootstrap credential:
36
36
 
37
37
  ```bash
38
- flair federation token --admin-pass <hub-admin-password>
38
+ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation token
39
39
  ```
40
40
 
41
41
  Output (a single JSON object):
@@ -56,10 +56,10 @@ On the spoke machine:
56
56
 
57
57
  ```bash
58
58
  # From a file
59
- flair federation pair <hub-url> --token-from /path/to/triple.json
59
+ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from /path/to/triple.json
60
60
 
61
61
  # From stdin
62
- cat triple.json | flair federation pair <hub-url> --token-from -
62
+ cat triple.json | FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair <hub-url> --token-from -
63
63
  ```
64
64
 
65
65
  **4. Behind the scenes**
@@ -76,21 +76,24 @@ Earlier designs relied on `allowCreate=true` combined with body-only authenticat
76
76
 
77
77
  ## Fabric Pairing Example
78
78
 
79
- When the hub runs on Harper Fabric, adapt the hub URL to the Fabric pattern:
79
+ A managed Harper Fabric hub has no shell. Mint the triple from any machine that can reach it, then pair from the spoke. `FLAIR_ADMIN_PASS` on that mint is the **hub/cluster** admin (the admin file on the hub host, or a secret manager), not the spoke's `~/.flair/admin-pass`. `--admin-pass` is also accepted but puts the password in shell history and process listings; prefer the environment form below. The full bring-up, including why `--ops-target` names port 9925, is [spoke-bringup.md §5a](spoke-bringup.md#harper-fabric-hub-no-shell). <!-- docs-freshness-allow: Fabric ops API port, not legacy data port -->
80
80
 
81
81
  ```bash
82
- # 1. Hub admin generates the triple (on the Fabric host)
83
- ssh hub-host
84
- flair federation token --admin-pass <hub-admin-password> > /tmp/pair-triple.json
85
-
86
- # 2. Transfer the triple to the spoke admin (out-of-band)
87
- scp hub-host:/tmp/pair-triple.json ./pair-triple.json
88
-
89
- # 3. Spoke admin pairs using the Fabric URL
90
- flair federation pair https://<fabric-node>:19926/<instance-name> --token-from ./pair-triple.json
82
+ # 1. On any machine (the spoke itself is fine) — no ssh, no scp.
83
+ # umask 077 sets the mode of a file the redirect CREATES; set -C makes the redirect
84
+ # refuse to overwrite an existing one, so a retry cannot truncate-and-reuse a looser file.
85
+ # /path/to/hub-admin-pass is a 0600 file holding the HUB admin password, not ~/.flair/admin-pass on this machine; a literal here would land in shell history.
86
+ (umask 077; set -C; FLAIR_ADMIN_PASS="$(cat /path/to/hub-admin-pass)" flair federation token \
87
+ --target https://<hub>.<org>.harperfabric.com \
88
+ --ttl 60 \
89
+ --ops-target https://<hub>.<org>.harperfabric.com:9925 > ./pair-triple.json) # docs-freshness-allow: Fabric ops API port, not legacy data port
90
+
91
+ # 2. On the spoke — the SPOKE admin password (its own ~/.flair/admin-pass) writes the local Peer row; the mint above used the hub admin
92
+ FLAIR_ADMIN_PASS="$(cat ~/.flair/admin-pass)" flair federation pair https://<hub>.<org>.harperfabric.com \
93
+ --token-from ./pair-triple.json
91
94
  ```
92
95
 
93
- Replace `<fabric-node>`, `<instance-name>`, and `<hub-admin-password>` with your actual values.
96
+ Replace `<hub>` and `<org>` with your actual values, and point `/path/to/hub-admin-pass` at a 0600 file holding the hub admin password on the minting machine. The pair step's admin password is the spoke's, used to write the local Peer row.
94
97
 
95
98
  Running the hub on Fabric has its own considerations — port derivation against a managed
96
99
  `443` endpoint, why the sync driver can only be installed on a machine you control, and
@@ -106,6 +109,20 @@ flair federation sync --admin-pass <password>
106
109
  # Output: ✅ Synced 12 records (0 skipped) in 145ms
107
110
  ```
108
111
 
112
+ ### What a push sends
113
+
114
+ Each sync pushes rows changed since the cursor from four tables: `Memory`, `Soul`, `Agent`, and `Relationship`. `Presence` is not in that set.
115
+
116
+ **Memory rows with `visibility` exactly `"private"` are left behind.** Durability is not the filter. `"shared"` and any other present value are included. Soul, Agent, and Relationship have no `visibility` field, so this rule does not apply to them.
117
+
118
+ A Memory row with **no `visibility` field still syncs, on purpose.** Those rows were written before the field existed. The push uses the same predicate as cross-agent read (`resolveReadScope` in `resources/memory-read-scope.ts`): only the literal string `"private"` is private. Missing, `null`, and anything else stay non-private so pre-field rows keep replicating exactly as they did. That is the migration rule, not a hole in the filter.
119
+
120
+ Private means owner-only on this instance. A peer that received the row would hold a copy other agents on that instance could read. Holding the row back is the point of `private`.
121
+
122
+ Durability still explains a count gap that is entirely `standard` rows. When a write omits `visibility`, the server defaults it from durability: `permanent` and `persistent` become `shared`; `standard`, `ephemeral`, and an omitted durability become `private`. A standard memory therefore stays on the spoke unless the writer set `visibility` to `shared`. Ephemeral memories are private-only at write time, so they never federate. That is the default and the ephemeral constraint, not a second filter and not loss of memories that were stored as shared.
123
+
124
+ `flair federation verify` writes its canary as `durability: "standard"` and `visibility: "shared"` for this reason. When every changed Memory row was withheld, sync says they were held back for private visibility instead of reporting that nothing changed.
125
+
109
126
  ### Keeping it synced
110
127
 
111
128
  `flair federation sync` is one-shot and `flair federation watch` only runs
@@ -173,6 +190,25 @@ The check is local to the machine running the CLI, so it is omitted when
173
190
 
174
191
  Driver logs: `~/.flair/logs/federation-sync.{stdout,stderr}.log`.
175
192
 
193
+ ### What `connected` means
194
+
195
+ `federation.peers.connected` counts **recent contact** — a peer whose
196
+ `lastSyncAt` sits inside the staleness window. `lastSyncAt` is the spoke's
197
+ outbound sync cursor: it is stamped after a successful sync batch or a
198
+ successful no-change liveness ping, and `federation sync` re-sends from it, so a
199
+ frozen cursor re-sends from the frozen point on every poll.
200
+
201
+ `connected` is **not** a verified hub identity and **not** pull readiness.
202
+ Inbound federation separately verifies each request against the peer's pinned
203
+ public key, so a peer row whose stored key is missing still reads `connected`
204
+ when it has synced recently — that is correct under this definition. A missing
205
+ key is a `connected`-but-unauthenticated state, repaired by re-pairing, never
206
+ silently trusted.
207
+
208
+ The cursor stamp is written as a field-only update of the peer row (only
209
+ `lastSyncAt` and `updatedAt`), so it cannot revert a concurrent key repair or
210
+ revocation, and it never inserts a row that is not there.
211
+
176
212
  ## Security
177
213
 
178
214
  ### Signed requests
@@ -236,13 +272,16 @@ Federation uses record-level last-write-wins (LWW) with ISO timestamp comparison
236
272
 
237
273
  ## Troubleshooting
238
274
 
239
- ### config.yaml port drift
275
+ ### Listen port drift
276
+
277
+ There is no `federation.port` key. Federation uses the hub's HTTP listen port. The spoke's pair URL has to use that port.
240
278
 
241
- If the hub's configured port in `config.yaml` differs from the port the spoke is targeting, federation requests fail with a connection error. Verify the port matches between the spoke's pair URL and the hub's `config.yaml` (`federation.port` or the instance's listen port).
279
+ On the hub, the listen port Harper last bound is `http.port` in the instance data directory (default `~/.flair/data/harper-config.yaml`). A default install also records a top-level `port:` in `~/.flair/config.yaml`. That file's port keys are `port` and `opsPort` only.
242
280
 
243
281
  ```bash
244
- # On the hub, confirm the listening port
245
- grep -E 'port|federation' ~/.flair/config.yaml
282
+ # On the hub. `http.port` is host-qualified, for example 127.0.0.1:19926.
283
+ grep -A2 '^http:' ~/.flair/data/harper-config.yaml
284
+ grep -E '^(port|opsPort):' ~/.flair/config.yaml
246
285
  ```
247
286
 
248
287
  ### Local FederationInstance fetch needs auth