@tpsdev-ai/flair 0.59.0 → 0.63.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.
- package/README.md +10 -10
- package/SECURITY.md +49 -5
- package/config.yaml +23 -12
- package/dist/bridges/builtins/mem0.js +63 -28
- package/dist/bridges/runtime/execute.js +1 -0
- package/dist/bridges/runtime/import-runner.js +12 -0
- package/dist/bridges/runtime/load-plugin.js +42 -13
- package/dist/bridges/runtime/yaml-loader.js +4 -2
- package/dist/bridges/types.js +1 -0
- package/dist/build-info.json +3 -3
- package/dist/cli.js +1054 -367
- package/dist/commands/agent.js +233 -90
- package/dist/commands/attention.js +4 -3
- package/dist/commands/backup-approval.js +218 -0
- package/dist/commands/backup.js +211 -39
- package/dist/commands/bootstrap.js +3 -1
- package/dist/commands/bridge.js +172 -119
- package/dist/commands/deploy.js +71 -8
- package/dist/commands/doctor.js +711 -146
- package/dist/commands/export.js +57 -23
- package/dist/commands/federation.js +787 -82
- package/dist/commands/grant.js +5 -6
- package/dist/commands/help.js +25 -0
- package/dist/commands/hook.js +155 -2
- package/dist/commands/idp.js +27 -19
- package/dist/commands/import.js +136 -20
- package/dist/commands/init.js +469 -200
- package/dist/commands/integrity.js +387 -0
- package/dist/commands/keys.js +247 -58
- package/dist/commands/mcp.js +108 -52
- package/dist/commands/memory.js +203 -35
- package/dist/commands/migrate-harness-memory.js +3 -2
- package/dist/commands/orgevent.js +51 -47
- package/dist/commands/presence.js +4 -3
- package/dist/commands/principal.js +428 -62
- package/dist/commands/quality.js +13 -1
- package/dist/commands/reembed.js +141 -17
- package/dist/commands/relationship.js +2 -1
- package/dist/commands/rem.js +537 -80
- package/dist/commands/restore.js +413 -65
- package/dist/commands/search.js +6 -4
- package/dist/commands/service.js +235 -40
- package/dist/commands/soul.js +4 -9
- package/dist/commands/status.js +94 -38
- package/dist/commands/test.js +7 -3
- package/dist/commands/upgrade.js +77 -23
- package/dist/commands/workspace.js +13 -11
- package/dist/component-env.js +31 -41
- package/dist/deploy.js +136 -4
- package/dist/doctor-client.js +534 -92
- package/dist/engine-version-contract.js +1 -0
- package/dist/engine-version.js +23 -3
- package/dist/fabric-upgrade.js +12 -2
- package/dist/federation/presence-send.js +139 -0
- package/dist/federation-verify.js +273 -180
- package/dist/hook-install.js +670 -6
- package/dist/install/clients.js +171 -35
- package/dist/keystore.js +72 -0
- package/dist/lib/action-recall-runtime.js +328 -0
- package/dist/lib/agent-home-fields.js +132 -0
- package/dist/lib/agent-home.js +427 -0
- package/dist/lib/agent-id-rule.js +88 -0
- package/dist/lib/agent-roster.js +33 -0
- package/dist/lib/atomic-write.js +1 -1
- package/dist/lib/auth-resolve.js +1069 -60
- package/dist/lib/backup-approval-store.js +612 -0
- package/dist/lib/backup-artifact.js +343 -0
- package/dist/lib/capture-runtime.js +124 -0
- package/dist/lib/config-critical-section.js +212 -25
- package/dist/lib/connect-phase.js +33 -0
- package/dist/lib/credential-status-rule.js +78 -0
- package/dist/lib/daemon-liveness.js +43 -11
- package/dist/lib/doctor-run.js +75 -37
- package/dist/lib/durability-copy.js +10 -0
- package/dist/lib/embedding-space-doctor.js +75 -0
- package/dist/lib/federation-pair-access.js +4 -0
- package/dist/lib/federation-retry-queue.js +283 -0
- package/dist/lib/federation-retry-row.js +101 -0
- package/dist/lib/flair-agent-role.js +4 -0
- package/dist/lib/hub-url.js +12 -0
- package/dist/lib/init-admin-pass.js +88 -12
- package/dist/lib/init-listener-environ.js +1 -2
- package/dist/lib/init-occupied-listener.js +15 -111
- package/dist/lib/init-spawn-attribution.js +73 -0
- package/dist/lib/init-tcp-probe.js +33 -0
- package/dist/lib/instance-identity-row.js +20 -0
- package/dist/lib/instruction-event-contract.js +17 -0
- package/dist/lib/instruction-event-doctor.js +102 -0
- package/dist/lib/launchd-management.js +38 -3
- package/dist/lib/listener-table.js +268 -0
- package/dist/lib/local-delete-instance.js +27 -0
- package/dist/lib/local-instance-pair.js +256 -0
- package/dist/lib/mcp-enable.js +1182 -341
- package/dist/lib/mcp-oauth-env-core.js +133 -0
- package/dist/lib/mcp-oauth-env.js +125 -0
- package/dist/lib/mcp-spec.js +17 -1
- package/dist/lib/memory-attributes.js +4 -0
- package/dist/lib/memory-id-policy.js +46 -0
- package/dist/lib/memory-integrity.js +309 -0
- package/dist/lib/memory-provider-timeout.js +33 -0
- package/dist/lib/memory-purge-response.js +20 -0
- package/dist/lib/mqtt-config.js +132 -0
- package/dist/lib/mqtt-listener-doctor.js +104 -0
- package/dist/lib/open-live-row.js +20 -0
- package/dist/lib/ops-table-count.js +25 -0
- package/dist/lib/ops-url.js +52 -0
- package/dist/lib/owned-pins.js +67 -10
- package/dist/lib/peer-status.js +27 -0
- package/dist/lib/principal-status.js +29 -0
- package/dist/lib/process-start-time.js +76 -12
- package/dist/lib/promotion-content-hash.js +20 -0
- package/dist/lib/proto-safe-record.js +42 -0
- package/dist/lib/record-id-path.js +25 -0
- package/dist/lib/reembed-server-support.js +66 -0
- package/dist/lib/restore-archive.js +760 -0
- package/dist/lib/restore-verify.js +104 -0
- package/dist/lib/scheduler-platform.js +10 -6
- package/dist/lib/secret-keys.js +25 -0
- package/dist/lib/secrets-push.js +50 -22
- package/dist/lib/skill-assignment-preflight.js +159 -0
- package/dist/lib/skill-seed-pending.js +24 -0
- package/dist/lib/skill-seed.js +448 -0
- package/dist/lib/skill-tombstone-doctor.js +133 -0
- package/dist/lib/soul-scope-fields.js +26 -0
- package/dist/lib/stop-start-recovery.js +54 -0
- package/dist/lib/uninstall-purge.js +266 -11
- package/dist/lib/upgrade-prior-liveness.js +2 -1
- package/dist/lib/using-flair-skill.js +87 -0
- package/dist/mcp-client-assertion.js +114 -14
- package/dist/memory-id-checkpoint.js +347 -0
- package/dist/memory-node-compare.js +207 -0
- package/dist/mqtt-off-deploy.js +550 -0
- package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
- package/dist/rem/promote-policy.js +3 -3
- package/dist/rem/restore.js +303 -26
- package/dist/rem/runner.js +317 -96
- package/dist/rem/scheduler.js +21 -4
- package/dist/resources/A2AAdapter.js +131 -178
- package/dist/resources/AdminMemory.js +2 -0
- package/dist/resources/AdminMemoryCandidates.js +116 -0
- package/dist/resources/Agent.js +463 -33
- package/dist/resources/AgentCard.js +4 -0
- package/dist/resources/AgentKeyRegister.js +248 -0
- package/dist/resources/AgentKeyRegistration.js +28 -0
- package/dist/resources/AgentReadPosition.js +7 -0
- package/dist/resources/AgentSeed.js +238 -107
- package/dist/resources/AutoPromoteCandidates.js +413 -78
- package/dist/resources/Credential.js +183 -10
- package/dist/resources/Federation.js +915 -145
- package/dist/resources/FederationRetry.js +140 -0
- package/dist/resources/InstructionVersion.js +220 -0
- package/dist/resources/Integration.js +300 -25
- package/dist/resources/MCPClientMetadata.js +6 -3
- package/dist/resources/Memory.js +3300 -758
- package/dist/resources/MemoryArchive.js +171 -53
- package/dist/resources/MemoryBootstrap.js +122 -61
- package/dist/resources/MemoryCandidate.js +37 -3
- package/dist/resources/MemoryConsolidate.js +2 -2
- package/dist/resources/MemoryDedupStats.js +30 -1
- package/dist/resources/MemoryFeed.js +545 -50
- package/dist/resources/MemoryGrant.js +21 -1
- package/dist/resources/MemoryMaintenance.js +368 -46
- package/dist/resources/MemoryPurge.js +348 -0
- package/dist/resources/MemoryReflect.js +71 -12
- package/dist/resources/MemoryReindex.js +111 -17
- package/dist/resources/Message.js +16 -5
- package/dist/resources/OAuth.js +342 -48
- package/dist/resources/OAuthClient.js +1 -1
- package/dist/resources/OrgEvent.js +405 -19
- package/dist/resources/OrgEventCatchup.js +7 -0
- package/dist/resources/OrgEventMaintenance.js +48 -10
- package/dist/resources/PairingToken.js +1 -1
- package/dist/resources/Presence.js +166 -51
- package/dist/resources/PromoteMemoryCandidate.js +24 -7
- package/dist/resources/RecordUsage.js +2 -4
- package/dist/resources/Relationship.js +23 -0
- package/dist/resources/SemanticSearch.js +63 -32
- package/dist/resources/Soul.js +191 -76
- package/dist/resources/SoulFeed.js +2 -1
- package/dist/resources/TeamDirectory.js +35 -0
- package/dist/resources/WorkspaceLatest.js +4 -0
- package/dist/resources/WorkspaceState.js +21 -1
- package/dist/resources/XAA.js +207 -63
- package/dist/resources/a2a-stream.js +313 -0
- package/dist/resources/a2a-url.js +4 -5
- package/dist/resources/agent-admin.js +10 -1
- package/dist/resources/agent-auth.js +138 -83
- package/dist/resources/agent-read-position-lib.js +4 -1
- package/dist/resources/agent-status-guard.js +9 -7
- package/dist/resources/auth-middleware.js +534 -171
- package/dist/resources/authority-field-guard.js +9 -11
- package/dist/resources/auto-promote-lib.js +8 -5
- package/dist/resources/basic-auth-header.js +21 -0
- package/dist/resources/bm25-index-service.js +4 -5
- package/dist/resources/dedup-cluster.js +6 -1
- package/dist/resources/ed25519-auth.js +1 -1
- package/dist/resources/embedding-space-guard.js +366 -72
- package/dist/resources/embeddings-provider.js +25 -0
- package/dist/resources/engine-version-stamp-boot.js +53 -0
- package/dist/resources/federation-classify.js +161 -0
- package/dist/resources/federation-crypto.js +5 -5
- package/dist/resources/federation-retry-lib.js +60 -0
- package/dist/resources/grant-visibility.js +135 -0
- package/dist/resources/harper-routing.js +83 -0
- package/dist/resources/health.js +163 -22
- package/dist/resources/host-pointer/registry.js +29 -0
- package/dist/resources/host-pointer-adapter.js +1 -0
- package/dist/resources/host-source-citation.js +49 -0
- package/dist/resources/host-source-visibility.js +7 -6
- package/dist/resources/in-process.js +24 -22
- package/dist/resources/instance-create-lock.js +17 -0
- package/dist/resources/instance-identity.js +23 -0
- package/dist/resources/instruction-version-record.js +587 -0
- package/dist/resources/internal-authority.js +13 -0
- package/dist/resources/key-lock.js +3 -3
- package/dist/resources/mcp-handler.js +141 -19
- package/dist/resources/mcp-oauth-env-guard.js +36 -0
- package/dist/resources/mcp-oauth-flag.js +12 -14
- package/dist/resources/mcp-oauth.js +450 -56
- package/dist/resources/mcp-tool-arguments.js +4 -6
- package/dist/resources/mcp-tools.js +187 -40
- package/dist/resources/memory-bootstrap-lib.js +5 -15
- package/dist/resources/memory-declared-attributes.js +4 -1
- package/dist/resources/memory-deletion-history.js +55 -0
- package/dist/resources/memory-durability.js +54 -0
- package/dist/resources/memory-embed-hash.js +144 -0
- package/dist/resources/memory-embedding-value.js +8 -0
- package/dist/resources/memory-host-source.js +32 -7
- package/dist/resources/memory-id-guard.js +75 -0
- package/dist/resources/memory-redaction.js +236 -0
- package/dist/resources/memory-reflect-lib.js +1 -1
- package/dist/resources/memory-supplied-vector.js +72 -0
- package/dist/resources/memory-write-lock.js +489 -0
- package/dist/resources/memory-write-response.js +139 -0
- package/dist/resources/memory-write-transaction.js +243 -0
- package/dist/resources/migration-boot.js +17 -12
- package/dist/resources/migrations/boot-progress.js +25 -0
- package/dist/resources/migrations/data-dir.js +90 -19
- package/dist/resources/migrations/dir-safety.js +61 -3
- package/dist/resources/migrations/embedding-stamp.js +462 -82
- package/dist/resources/migrations/export.js +1 -0
- package/dist/resources/migrations/graph-heal.js +27 -27
- package/dist/resources/migrations/ledger.js +5 -2
- package/dist/resources/migrations/lock.js +870 -77
- package/dist/resources/migrations/progress.js +71 -10
- package/dist/resources/migrations/runner.js +212 -18
- package/dist/resources/migrations/snapshot.js +1 -0
- package/dist/resources/migrations/source-fields.js +5 -5
- package/dist/resources/migrations/state.js +36 -1
- package/dist/resources/migrations/status.js +2 -13
- package/dist/resources/migrations/synthetic-test-migration.js +81 -12
- package/dist/resources/migrations/types.js +26 -1
- package/dist/resources/migrations/visibility-backfill.js +113 -72
- package/dist/resources/oauth-discovery.js +0 -5
- package/dist/resources/object-body-guard.js +40 -0
- package/dist/resources/org-event-created-at.js +133 -0
- package/dist/resources/org-event-reserved.js +92 -0
- package/dist/resources/org-event-write-fault.js +19 -0
- package/dist/resources/originator-instance.js +39 -7
- package/dist/resources/owner-delete-recheck.js +78 -0
- package/dist/resources/owner-field-guard.js +39 -5
- package/dist/resources/owner-scoped-write-policy.js +256 -0
- package/dist/resources/owner-scoped-writes.js +89 -0
- package/dist/resources/path-id-rewrite.js +76 -0
- package/dist/resources/presence-internal.js +5 -5
- package/dist/resources/presence-receipt.js +236 -0
- package/dist/resources/promotion-binding.js +43 -0
- package/dist/resources/promotion-stamp.js +143 -17
- package/dist/resources/protocol-context.js +189 -0
- package/dist/resources/record-owner-guard.js +74 -26
- package/dist/resources/record-type-kit.js +2 -4
- package/dist/resources/record-types.js +1 -1
- package/dist/resources/relay-ops.js +78 -6
- package/dist/resources/replay-store.js +96 -19
- package/dist/resources/request-target.js +163 -0
- package/dist/resources/request-transaction.js +46 -1
- package/dist/resources/search-readiness.js +4 -1
- package/dist/resources/seed-ids.js +9 -0
- package/dist/resources/seed-reservation.js +116 -0
- package/dist/resources/semantic-retrieval-core.js +27 -15
- package/dist/resources/server-row-validation.js +71 -0
- package/dist/resources/skill-manifest.js +24 -14
- package/dist/resources/skill-subject.js +53 -0
- package/dist/resources/skill-version-write.js +789 -0
- package/dist/resources/skill-write-fault.js +20 -0
- package/dist/resources/skill-write-policy.js +68 -0
- package/dist/resources/skill-write.js +67 -7
- package/dist/resources/soul-write-policy.js +26 -7
- package/dist/resources/table-helpers.js +10 -7
- package/dist/resources/table-subscription-policy.js +518 -85
- package/dist/resources/table-subscriptions.js +20 -7
- package/dist/resources/team-directory.js +248 -0
- package/dist/resources/tool-descriptors/index.js +69 -8
- package/dist/resources/txn-pause-point.js +235 -0
- package/dist/resources/usage-recording.js +186 -70
- package/dist/resources/write-back.js +383 -0
- package/dist/resources/write-journal-context.js +5 -0
- package/dist/resources/write-journal.js +289 -0
- package/dist/src/engine-version-contract.js +1 -0
- package/dist/src/keystore.js +72 -0
- package/dist/src/lib/agent-home-fields.js +132 -0
- package/dist/src/lib/agent-id-rule.js +88 -0
- package/dist/src/lib/agent-key-register.js +80 -0
- package/dist/src/lib/atomic-write.js +256 -0
- package/dist/src/lib/credential-status-rule.js +78 -0
- package/dist/src/lib/expired-by-agent.js +37 -0
- package/dist/src/lib/federation-retry-row.js +101 -0
- package/dist/src/lib/flair-agent-role.js +4 -0
- package/dist/src/lib/idp-mapping-rule.js +81 -0
- package/dist/src/lib/instance-identity-row.js +20 -0
- package/dist/src/lib/instruction-event-contract.js +17 -0
- package/dist/src/lib/mcp-oauth-env-core.js +133 -0
- package/dist/src/lib/memory-attributes.js +4 -0
- package/dist/src/lib/memory-id-policy.js +46 -0
- package/dist/src/lib/open-live-row.js +20 -0
- package/dist/src/lib/principal-status.js +29 -0
- package/dist/src/lib/proto-safe-record.js +42 -0
- package/dist/src/lib/reembed-server-support.js +66 -0
- package/dist/src/lib/scheduler-platform.js +10 -6
- package/dist/src/lib/soul-scope-fields.js +26 -0
- package/dist/src/lib/systemd-agent-id.js +38 -0
- package/dist/src/rem/promote-policy.js +3 -3
- package/dist/src/rem/scheduler.js +21 -4
- package/docs/access-control.md +164 -54
- package/docs/api-reference.md +165 -32
- package/docs/auth.md +46 -30
- package/docs/bridges.md +11 -0
- package/docs/claude-code.md +37 -7
- package/docs/deploying-on-fabric.md +178 -0
- package/docs/deployment.md +19 -0
- package/docs/embedding-in-a-harper-app.md +17 -15
- package/docs/entity-vocabulary.md +3 -6
- package/docs/federation.md +61 -3
- package/docs/hosted-on-fabric.md +43 -36
- package/docs/integrations.md +14 -14
- package/docs/mcp-clients.md +12 -7
- package/docs/n8n.md +17 -11
- package/docs/notes/mcp-agent-auth-consumer.md +16 -13
- package/docs/notes/mcp-oauth-model2.md +40 -11
- package/docs/openclaw.md +1 -1
- package/docs/quickstart-fabric.md +4 -4
- package/docs/quickstart.md +12 -4
- package/docs/releasing.md +25 -19
- package/docs/rem.md +32 -3
- package/docs/secrets-and-keys.md +21 -4
- package/docs/standalone-local.md +30 -2
- package/docs/supply-chain-policy.md +34 -16
- package/docs/the-team.md +2 -2
- package/docs/upgrade.md +46 -6
- package/package.json +24 -12
- package/schemas/agent-key-registration.graphql +22 -0
- package/schemas/agent.graphql +6 -3
- package/schemas/federation.graphql +41 -1
- package/schemas/memory.graphql +91 -7
- package/schemas/oauth.graphql +19 -0
- package/schemas/schema.graphql +2 -0
- package/templates/bin/flair-rem-nightly.sh.tmpl +7 -1
- package/templates/launchd/start-flair-with-admin-pass.sh +188 -10
- package/dist/resources/soul-adk-guard.js +0 -68
package/docs/bridges.md
CHANGED
|
@@ -47,6 +47,12 @@ interface BridgeMemory {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
- permanent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it); it never decays; bootstrap considers the bootstrapping agent's own permanent memories before recent rows, subject to scope, expiry/closure and the token budget.
|
|
51
|
+
- persistent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it).
|
|
52
|
+
- standard — routine maintenance archives it once its validTo passes or, as a session note, after 30 days.
|
|
53
|
+
- ephemeral — routine maintenance reaps it once its TTL (24h by default) passes.
|
|
54
|
+
- No tier adds a flush, fsync, backup or replica acknowledgement: an explicit delete (owner or admin) or a store failure can end any of them.
|
|
55
|
+
|
|
50
56
|
**Required on import:** `content` and (`agentId` or the `--agent` flag).
|
|
51
57
|
|
|
52
58
|
**Flair-owned, never set by a bridge:** `contentHash`, `embedding`, `embeddingModel`, `retrievalCount`, `lastRetrieved`, `promotionStatus`, `_safetyFlags`, any `*By` audit field. These are computed on ingest; if a bridge emits them they're ignored.
|
|
@@ -73,6 +79,9 @@ Common runtime options for `import`:
|
|
|
73
79
|
| `--port <port>` | Harper HTTP port |
|
|
74
80
|
| `--url <url>` | Flair base URL (overrides `--port`) |
|
|
75
81
|
| `--key <path>` | Ed25519 private key path (default: resolved from agent) |
|
|
82
|
+
| `--user <id>` | Foreign-system user id for bridges that import one user (e.g. mem0); YAML imports do not use it |
|
|
83
|
+
| `--base-url <url>` | HTTP(S) base URL of the foreign API for API bridges (e.g. a self-hosted mem0); an explicit empty or invalid mem0 URL is refused |
|
|
84
|
+
| `--api-key-file <path>` | For API bridges that declare an `apiKey` option, read the key from a file with no group/world permissions (`chmod 600` recommended). YAML imports refuse this flag. For mem0, `MEM0_API_KEY` is the alternative; the key is never a flag value. |
|
|
76
85
|
|
|
77
86
|
## Your first import (worked example: agentic-stack)
|
|
78
87
|
|
|
@@ -198,6 +207,8 @@ export const bridge: MemoryBridge = {
|
|
|
198
207
|
};
|
|
199
208
|
```
|
|
200
209
|
|
|
210
|
+
**`opts`** contains the option values passed to the plugin as own properties. For `import` it is a null-prototype record, so inherited methods such as `opts.hasOwnProperty` are not available: test for a key with `Object.hasOwn(opts, key)`, which works for `export` too.
|
|
211
|
+
|
|
201
212
|
**`BridgeContext`** gives you:
|
|
202
213
|
|
|
203
214
|
- `ctx.fetch` — instrumented, rate-limited HTTP. **Always use this instead of the global `fetch`** — it's how the runtime applies per-bridge throttling and audit logging.
|
package/docs/claude-code.md
CHANGED
|
@@ -29,7 +29,7 @@ This generates an Ed25519 key pair at `~/.flair/keys/my-project.key` and registe
|
|
|
29
29
|
|
|
30
30
|
### 4. Add to your project's CLAUDE.md
|
|
31
31
|
|
|
32
|
-
Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`, etc.):
|
|
32
|
+
Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`, etc.): <!-- docs-freshness-allow: names files in the reader's project -->
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
@@ -74,9 +74,11 @@ Copy this into your project's `CLAUDE.md` (or `.claude/settings.md`, `AGENTS.md`
|
|
|
74
74
|
|
|
75
75
|
### Durability levels
|
|
76
76
|
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
77
|
+
- permanent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it); it never decays; bootstrap considers the bootstrapping agent's own permanent memories before recent rows, subject to scope, expiry/closure and the token budget.
|
|
78
|
+
- persistent — routine maintenance never reaps or age-archives it (an expired validTo archives an eligible row; an acquired expiresAt never reaps it).
|
|
79
|
+
- standard — routine maintenance archives it once its validTo passes or, as a session note, after 30 days.
|
|
80
|
+
- ephemeral — routine maintenance reaps it once its TTL (24h by default) passes.
|
|
81
|
+
- No tier adds a flush, fsync, backup or replica acknowledgement: an explicit delete (owner or admin) or a store failure can end any of them.
|
|
80
82
|
|
|
81
83
|
> **End of CLAUDE.md snippet.**
|
|
82
84
|
|
|
@@ -86,13 +88,15 @@ This is a prompt-driven CLI setup: Claude must choose to run these commands. For
|
|
|
86
88
|
|
|
87
89
|
## Hooks
|
|
88
90
|
|
|
89
|
-
`@tpsdev-ai/flair-mcp` ships
|
|
91
|
+
`@tpsdev-ai/flair-mcp` ships six 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
92
|
|
|
91
93
|
| Hook | Claude Code event | What it does | Install |
|
|
92
94
|
|---|---|---|---|
|
|
93
95
|
| `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
96
|
| `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
97
|
| `flair-prompt-recall` | `UserPromptSubmit` | Searches memory with each prompt and adds the relevant memories as context before the model answers. | By hand, below |
|
|
98
|
+
| `flair-action-recall` | `PreToolUse` | Matches the pending Bash command against the agent's own triggered lessons and adds the matching ones as context on the next model request. | `flair hook install --action-recall` |
|
|
99
|
+
| `flair-capture` | `PostToolUseFailure`, `PostToolUse` and `Stop` | Stages candidates locally; a background flush attempts writes. | `flair hook install --capture` |
|
|
96
100
|
| `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
101
|
|
|
98
102
|
### Per-prompt recall (`flair-prompt-recall`)
|
|
@@ -144,6 +148,32 @@ The same `npx -y -p @tpsdev-ai/flair-mcp@<version> flair-prompt-recall` invocati
|
|
|
144
148
|
|
|
145
149
|
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
150
|
|
|
151
|
+
### Action recall (`flair-action-recall`)
|
|
152
|
+
|
|
153
|
+
`flair hook install --action-recall` copies the version-matched hook and its runtime modules to `~/.flair/hooks/action-recall/<version>-<content hash>/` and probes that installed command. This Flair-owned directory survives npm cache eviction; uninstall removes it. Status probes a detected entry; absence is informational. If absent, run `npx -y -p @tpsdev-ai/flair-mcp@<CLI version> node --version` first, then `flair hook install --action-recall`. An incompatible SessionStart entry or held pin refuses installation.
|
|
154
|
+
|
|
155
|
+
**How it decides.** A lesson opts in through its JSON `metadata` field:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{ "flairActionRecall": { "v": 1, "triggers": [ { "verb": "git", "subcommands": ["push"], "flags": ["--force"], "paths": [] } ] } }
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Write a new lesson with `client.memory.write(content, { type: "lesson", metadata: { flairActionRecall: { v: 1, triggers } } })`. For an existing lesson, `client.memory.update(id, content, { metadata: { flairActionRecall: { v: 1, triggers } } })` preserves other metadata keys.
|
|
162
|
+
|
|
163
|
+
`verb` is a literal executable basename; `subcommands` are an exact contiguous argv prefix after it; `flags` are required members; `paths` are optional operand-glob alternatives matched against the command's operands, normalized against the payload `cwd`. A trigger with none of the three is rejected. At most 4 triggers per lesson, 3 subcommands, 8 flags and 2 path globs per trigger, each string at most 128 bytes. Set `triggers: []` through `client.memory.update` to disable recall at the next refresh.
|
|
164
|
+
|
|
165
|
+
The hot path reads a per-session cache of the agent's own lessons under `~/.flair/action-recall/`, refreshed at session start through a signed, non-admin read. The cache expires five minutes after refresh starts, shortened by each lesson's valid expiry or end-of-validity timestamp. Between refreshes, a deletion, edit or supersession can stay visible until expiry.
|
|
166
|
+
|
|
167
|
+
**What it never does.** It emits only `hookSpecificOutput.additionalContext` — never a permission decision, a question, replacement input or blocking output. It never executes or echoes the submitted command. Caught read and input errors produce no context. Missing, corrupt, wrong-mode, oversized or stale caches do not match. The reader checks path components for symlinks before opening and uses `O_NOFOLLOW` on the final component. A command it cannot read as one simple argv command (expansions, substitutions, assignments, redirects, comments, pipelines, lists, heredocs, compound commands) is silently not matched. At most three lessons are shown, each quoted line bounded, the whole output at most 4 KiB; excerpts are redacted before they are cached and quoted when shown. The hook does not read or use credentials, signs nothing and makes no network call.
|
|
168
|
+
|
|
169
|
+
### Learning capture (`flair-capture`)
|
|
170
|
+
|
|
171
|
+
`flair hook install --capture` copies the version-matched hook and its runtime modules to `~/.flair/hooks/capture/<version>-<content hash>/` and probes that installed command. It wires three Claude Code events: `PostToolUseFailure` (matching `Bash`), `PostToolUse` (matching `Write|Edit|NotebookEdit|Bash`) and `Stop`.
|
|
172
|
+
|
|
173
|
+
The hook may stage a possible matching follow-up to a failed `Bash` call, or a cue-matching sentence from the turn's final text, in a bounded local spool under `~/.flair/capture/`. Network writes run in a detached flush. The foreground stdin deadline is 2 seconds; the default append-lock wait for Stop, PostToolUse and flush snapshot/rewrite operations is 200 ms. A failed-tool append waits up to 2 seconds for the lock and refuses if it remains busy. The installed command suppresses stdout, keeps stderr for lock-contention and pending-write warnings, and exits 0. The flush bounds its asynchronous setup and each write with one deadline; the 10 ms p95 hot-path budget in `scripts/capture-latency.mjs` is a manual measurement, not a CI gate.
|
|
174
|
+
|
|
175
|
+
Install probes the copied command; status probes artifact paths named in settings, without a directory restriction, and reports `partial` when only some of the three events are wired. Absence is informational: installing the hooks is the opt-in. If absent, run `npx -y -p @tpsdev-ai/flair-mcp@<CLI version> node --version` first, then `flair hook install --capture`.
|
|
176
|
+
|
|
147
177
|
## Multiple Projects
|
|
148
178
|
|
|
149
179
|
Create a separate agent per project:
|
|
@@ -154,14 +184,14 @@ flair agent add project-beta
|
|
|
154
184
|
flair agent add infra-ops
|
|
155
185
|
```
|
|
156
186
|
|
|
157
|
-
Each project's `CLAUDE.md` uses its own agent ID. Writes carry an `agentId` field (tags are optional); reads use owner plus visibility.
|
|
187
|
+
Each project's `CLAUDE.md` uses its own agent ID. <!-- docs-freshness-allow: names a file in the reader's project --> Writes carry an `agentId` field (tags are optional); reads use owner plus visibility.
|
|
158
188
|
|
|
159
189
|
## Subagents
|
|
160
190
|
|
|
161
191
|
Claude Code subagents (spawned via `/run` or background tasks) can share the parent's memory:
|
|
162
192
|
|
|
163
193
|
### Subagents
|
|
164
|
-
Subagents share memory with the parent session when they use the same agent ID (to share, set `FLAIR_AGENT_ID=my-project`). A subagent with its own agent ID owns
|
|
194
|
+
Subagents share memory with the parent session when they use the same agent ID (to share, set `FLAIR_AGENT_ID=my-project`). A subagent with its own agent ID owns its writes; memory reads use owner/visibility scope, with an additional current-authority check for non-admin by-id and collection reads of retained closed skills. Writes without an explicit visibility default by durability: persistent and permanent are shared, standard and ephemeral are private.
|
|
165
195
|
|
|
166
196
|
When spawning subagents, pass the agent ID so they can access shared context.
|
|
167
197
|
|
|
@@ -305,6 +305,114 @@ without this re-flip will appear healthy (`/Health` green) while its MCP tools a
|
|
|
305
305
|
dark to every connected client. If you rely on MCP, add the re-flip to your upgrade
|
|
306
306
|
runbook.
|
|
307
307
|
|
|
308
|
+
### MQTT configuration
|
|
309
|
+
|
|
310
|
+
Flair does not use MQTT. Its local starts run Harper with every MQTT listener
|
|
311
|
+
off: the TCP and TLS listeners (`mqtt.network.port`,
|
|
312
|
+
`mqtt.network.securePort`) and MQTT over WebSocket on the HTTP port
|
|
313
|
+
(`mqtt.webSocket`), set on every start. A component deployment does not go
|
|
314
|
+
through those starts, and a component's `config.yaml` cannot set it (`mqtt`
|
|
315
|
+
belongs to the instance's root configuration). So, by default, `flair deploy`
|
|
316
|
+
and `flair upgrade --target` set those listeners off in the target's
|
|
317
|
+
configuration through its operations API and request the worker restart that
|
|
318
|
+
applies it; they do not confirm the listeners' live state. `--keep-mqtt-config`,
|
|
319
|
+
`--no-restart` and `--no-verify` change these steps (below).
|
|
320
|
+
|
|
321
|
+
**Before deploying**, they send:
|
|
322
|
+
|
|
323
|
+
```json
|
|
324
|
+
{ "operation": "set_configuration", "mqtt_network_port": null, "mqtt_network_securePort": null, "mqtt_webSocket": false, "replicated": true }
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
`replicated` follows the deploy (`--no-replicated` sends it to the origin
|
|
328
|
+
only; an instance without replication is set on its own). If the target
|
|
329
|
+
refuses it, or its answer names a cluster node that did not take it, nothing
|
|
330
|
+
is deployed, and the error names the node and the request to send to it.
|
|
331
|
+
|
|
332
|
+
**After the deploy's restart**, they read the target's configuration back
|
|
333
|
+
through its operations API. An answer that is not a recognizable root
|
|
334
|
+
configuration (it must carry Harper's `http` and `operationsApi` sections and
|
|
335
|
+
its `rootPath`) is reported as not confirmed, never as off, and the saved
|
|
336
|
+
`mqtt` section must read off (`mqtt.network.port` and `mqtt.network.securePort`
|
|
337
|
+
null, `mqtt.webSocket` false); a mismatch is named by field and category, such
|
|
338
|
+
as `mqtt.webSocket is not false`. Either failure fails the command after the
|
|
339
|
+
deploy, with the request to send.
|
|
340
|
+
|
|
341
|
+
Harper applies the setting when the shared HTTP worker threads, which start
|
|
342
|
+
the MQTT listeners, restart. The deploy's own restart covers them, except for a
|
|
343
|
+
fresh isolated deploy: when the root configuration marks Flair `isolated: true`
|
|
344
|
+
and Harper does not find it already active, Harper restarts only Flair's own
|
|
345
|
+
worker (for an application it finds already active, it restarts every
|
|
346
|
+
worker). For an isolated Flair they therefore also request the shared worker
|
|
347
|
+
threads' restart through the operations API (`restart_service`, `"service":
|
|
348
|
+
"http_workers"`, `"scope": ""`, replicated with the deploy; a standalone
|
|
349
|
+
instance, which refuses the replicated request, gets it on its own) and follow
|
|
350
|
+
Harper's job. The command fails when the restart request fails or is answered
|
|
351
|
+
without a job id, and on these job outcomes: a job read that does not succeed
|
|
352
|
+
(refused before its body is parsed), a job that does not complete, a completion
|
|
353
|
+
message that is not exactly Harper's for that job, a replicated result without
|
|
354
|
+
its node list, or a node the result lists without Harper's completed-job
|
|
355
|
+
message (each named, with the request to send to it). Nodes are judged as the
|
|
356
|
+
job's result lists them: that list is not compared with the nodes the
|
|
357
|
+
configuration answer named. A completed job is not proof that a node's workers
|
|
358
|
+
restarted: Harper sends a node's restart-complete from a `finally` and does
|
|
359
|
+
not carry the worker replacement's outcome.
|
|
360
|
+
|
|
361
|
+
**What they report.** Exactly this, and nothing more:
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
MQTT listeners configured off on <the target and the nodes the replicated answer named>; shared workers restart requested (job <id>: <each node's outcome>, or: with the deploy's own restart); the saved configuration on <the target's operations host> reads off. Listeners stop when each node's workers restart; flair does not probe them. To confirm on a node, connect an MQTT client to its MQTT ports or WebSocket path.
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
Flair does not connect to the MQTT listeners. To confirm that a node stopped
|
|
368
|
+
serving MQTT after its workers restarted, connect an MQTT client to that node's
|
|
369
|
+
MQTT ports (1883 and 8883 by default) or to its MQTT-over-WebSocket path on the
|
|
370
|
+
HTTP port.
|
|
371
|
+
|
|
372
|
+
With `--no-verify` (both commands) the post-restart step is skipped (the saved
|
|
373
|
+
configuration is not read back, and no restart is requested for an isolated
|
|
374
|
+
application), and with `--no-restart` the setting takes effect at the next
|
|
375
|
+
restart; both print the restart request to send. With `--keep-mqtt-config`
|
|
376
|
+
neither step runs.
|
|
377
|
+
|
|
378
|
+
**URLs.** The operations API URL is resolved as for every remote command:
|
|
379
|
+
`--ops-target` / `FLAIR_OPS_TARGET`, else derived from the target. The target
|
|
380
|
+
and the operations API URL must be http or https URLs with a host, and nothing
|
|
381
|
+
but scheme, host, port and path: any other scheme (such as `file:` or
|
|
382
|
+
`javascript:`), a URL without a host, a user name, password, query or fragment
|
|
383
|
+
is refused before either command prints or sends anything. The operations API
|
|
384
|
+
calls follow no redirect. Every URL the MQTT-off steps print, and the target
|
|
385
|
+
URL in the commands' own deploy lines (`flair deploy`'s next-steps example
|
|
386
|
+
included), shows scheme, host, port and path only; that includes the
|
|
387
|
+
operations API URL they name for a cluster node, which they build only from a
|
|
388
|
+
node name that is a valid host name or IP address.
|
|
389
|
+
|
|
390
|
+
**Output.** The errors and progress lines of these MQTT-off steps quote a
|
|
391
|
+
remote answer's HTTP status code, a restart job's id (when it is a plain
|
|
392
|
+
token) and state, and cluster node names as its answers give them (when they
|
|
393
|
+
are valid host names or IP addresses); never its body, a job's message, a
|
|
394
|
+
configuration value or a transport error's text. This covers only these
|
|
395
|
+
steps: the Harper deploy between them runs Harper's CLI, whose output is
|
|
396
|
+
streamed as it comes.
|
|
397
|
+
|
|
398
|
+
`flair doctor` (local instances; it takes no `--target`) reports an instance
|
|
399
|
+
whose saved configuration starts an MQTT listener, and names the call that
|
|
400
|
+
sets the listeners off in the configuration. It reads the configuration, not
|
|
401
|
+
the running listeners: worker threads that have not restarted since the
|
|
402
|
+
configuration changed may still serve their previous listener configuration,
|
|
403
|
+
and doctor says so on every path, including when it cannot read the
|
|
404
|
+
configuration. It follows no redirect: a redirected configuration read is NOT
|
|
405
|
+
RUN.
|
|
406
|
+
|
|
407
|
+
**Turning MQTT on deliberately.** Send `set_configuration` with the listeners
|
|
408
|
+
you want (for example `"mqtt_webSocket": true`), then restart the worker threads
|
|
409
|
+
(`restart_service` with `"service": "http_workers"`). Pass `--keep-mqtt-config`
|
|
410
|
+
to later `flair deploy` / `flair upgrade --target` runs so they leave the
|
|
411
|
+
instance's MQTT configuration as it is. Table subscriptions, publishes and
|
|
412
|
+
retained publishes over MQTT then follow the same policy as SSE and WebSocket
|
|
413
|
+
subscriptions: administrators and trusted internal callers only
|
|
414
|
+
([api-reference.md](api-reference.md)).
|
|
415
|
+
|
|
308
416
|
### npm cache on the node
|
|
309
417
|
|
|
310
418
|
`flair deploy` and `flair upgrade --target` pass Harper an `install_command` that runs
|
|
@@ -331,6 +439,76 @@ flair upgrade --target https://<cluster>.<org>.harperfabric.com --check
|
|
|
331
439
|
|
|
332
440
|
Full path: [upgrade.md](upgrade.md#upgrading-a-fabric-deployed-instance).
|
|
333
441
|
|
|
442
|
+
### Memory ids: operator-run checkpoint and post-operation check
|
|
443
|
+
|
|
444
|
+
`flair fleet verify` probes health and version. Deploy's replication-error check compares
|
|
445
|
+
component-tree metadata. Neither checks Memory rows. Checkpoint the instance's Memory ids
|
|
446
|
+
before the operation, then verify after:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
flair memory checkpoint --target https://<cluster>.<org>.harperfabric.com \
|
|
450
|
+
--fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
|
|
451
|
+
|
|
452
|
+
# ... the planned cluster operation ...
|
|
453
|
+
|
|
454
|
+
flair memory verify --target https://<cluster>.<org>.harperfabric.com \
|
|
455
|
+
--fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
The checkpoint command reads Memory ids and durability tiers through the admin operations
|
|
459
|
+
API (primary-key pages, never through recall) and writes IDs and aggregate tier counts to
|
|
460
|
+
`~/.flair/memory-id-checkpoint.json` (mode `0600`); it reads no Memory content.
|
|
461
|
+
`--checkpoint <path>` picks another file.
|
|
462
|
+
|
|
463
|
+
The verify command re-reads the same operations origin and compares:
|
|
464
|
+
|
|
465
|
+
- **verified** (exit 0) — checkpointed ids present and no tier-count drop; new ids are fine;
|
|
466
|
+
- **integrity failure** (exit 2) — a checkpointed id is gone, or a durability tier count
|
|
467
|
+
dropped; the report names the count of missing ids and up to ten ids;
|
|
468
|
+
- **unknown** (exit 3) — the comparison could not be completed: for example, an unreadable
|
|
469
|
+
checkpoint, a different operations origin, a failed read, or a count change.
|
|
470
|
+
|
|
471
|
+
An absent checkpoint exits 1 without a verification outcome.
|
|
472
|
+
|
|
473
|
+
`flair deploy` also takes `--memory-checkpoint <path>`: after the deploy it runs the same
|
|
474
|
+
verify and adds a `Memory id/tier check:` line to the report; an integrity failure does not
|
|
475
|
+
fail the deploy. Without the flag it says `not checked`.
|
|
476
|
+
|
|
477
|
+
### Memory ids: comparing nodes
|
|
478
|
+
|
|
479
|
+
`flair memory checkpoint` writes one instance's observed Memory ids and per-tier counts to a file; `flair memory verify` compares a later read of those ids and counts with that file. To see whether two or more
|
|
480
|
+
physical nodes have the same observed Memory ids, name each node's operations API origin explicitly:
|
|
481
|
+
|
|
482
|
+
```bash
|
|
483
|
+
flair memory compare-nodes \
|
|
484
|
+
--node <node-a-ops-origin> --node <node-b-ops-origin> \
|
|
485
|
+
--fabric-user admin --fabric-password-file ~/.tps/secrets/flair-fabric-hdb
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
Each `--node` is the address that node's operations API is read at (the address `flair memory
|
|
489
|
+
checkpoint` reaches through `--ops-target`). Physical peers are never inferred from Flair's
|
|
490
|
+
federation peers: a node is compared only when `--node` names it. Each node is read with the same
|
|
491
|
+
paged operations-API read the checkpoint uses, plus stored timestamps. Count checks cannot detect
|
|
492
|
+
equal-count concurrent updates or replacements; an id absent on every named node is invisible
|
|
493
|
+
without a reference set. Timestamps use parseable `updatedAt`, else `createdAt`, which can be
|
|
494
|
+
caller-supplied. Node clocks can differ; timestamp comparisons do not establish actual write order.
|
|
495
|
+
A missing id uses the maximum timestamp among usable peers holding it. Per node the report gives:
|
|
496
|
+
|
|
497
|
+
- **in-sync** — observed ids equal the union of the other usable readings;
|
|
498
|
+
- **lagging** — missing ids only, each timestamp greater than this node's maximum timestamp;
|
|
499
|
+
- **divergent** — an extra id, or a missing id timestamp at or below this node's maximum;
|
|
500
|
+
- **unknown** — failed read, unusable timestamp, no usable peer, or no local timestamp for missing ids.
|
|
501
|
+
|
|
502
|
+
The overall result is healthy only when every node is in-sync. A lagging node is reported as such
|
|
503
|
+
and is never healthy; any unknown makes the overall result unknown. The report lists the missing
|
|
504
|
+
and extra ids against other usable readings (a count, then the ids up to ten). Failed reads report
|
|
505
|
+
counts, ids and timestamps as `UNAVAILABLE`; differences without a usable peer are `UNAVAILABLE`.
|
|
506
|
+
`--json` prints the same result as JSON.
|
|
507
|
+
|
|
508
|
+
Exit codes: `0` healthy, `2` divergent, `3` unknown, `4` lagging. Fewer than two `--node` values, a
|
|
509
|
+
repeated node, or an invalid HTTP(S) URL exits `1`. Paths, queries and fragments are removed from
|
|
510
|
+
node URLs before comparison.
|
|
511
|
+
|
|
334
512
|
---
|
|
335
513
|
|
|
336
514
|
## See also
|
package/docs/deployment.md
CHANGED
|
@@ -46,6 +46,23 @@ flair init --port 8000
|
|
|
46
46
|
|
|
47
47
|
Or edit `~/.flair/config.yaml` and restart.
|
|
48
48
|
|
|
49
|
+
### MQTT
|
|
50
|
+
|
|
51
|
+
Flair runs Harper with MQTT off in local installs: no TCP or TLS MQTT listener
|
|
52
|
+
and no MQTT over WebSocket. Every local start re-asserts it, and `flair doctor`
|
|
53
|
+
reports an instance whose saved configuration starts an MQTT listener (it reads
|
|
54
|
+
the configuration, not the running listeners). For a component deployed with
|
|
55
|
+
`flair deploy` or `flair upgrade --target` — which by default set MQTT off in
|
|
56
|
+
the target's configuration, request the shared worker threads' restart that
|
|
57
|
+
applies it for an isolated application, and read the saved configuration back
|
|
58
|
+
after the deploy's restart, without probing the listeners (`--keep-mqtt-config`
|
|
59
|
+
skips all of it, `--no-restart` and `--no-verify` skip the restart request and
|
|
60
|
+
the read-back) — see
|
|
61
|
+
[deploying-on-fabric.md](deploying-on-fabric.md#mqtt-configuration), including how an
|
|
62
|
+
operator turns MQTT on deliberately; table subscriptions, publishes and
|
|
63
|
+
retained publishes over MQTT then follow the same policy as SSE and WebSocket
|
|
64
|
+
subscriptions.
|
|
65
|
+
|
|
49
66
|
---
|
|
50
67
|
|
|
51
68
|
## Linux
|
|
@@ -234,6 +251,8 @@ flair restore ~/flair-backup-20260405.json
|
|
|
234
251
|
|
|
235
252
|
Always backup before upgrades.
|
|
236
253
|
|
|
254
|
+
Concurrent deletes can cause `flair backup` to refuse publication on a count mismatch; pause writers and maintenance, then retry.
|
|
255
|
+
|
|
237
256
|
---
|
|
238
257
|
|
|
239
258
|
## Uninstall
|
|
@@ -135,7 +135,7 @@ Verified against a real instance: that lands `kind: "agent"`, `status: "active"`
|
|
|
135
135
|
|
|
136
136
|
> **Prefer this to `databases.flair.Agent.put()`.** The raw table applies **no** defaults, so a hand-written literal has to reproduce every field above and then stay in step with Flair as the Principal model grows. Records written that way are missing `kind`/`status`/`defaultTrustTier` and read as under-specified Principals in the admin surfaces.
|
|
137
137
|
|
|
138
|
-
> **Admin is one meaning with one answer.** `role === "admin"` is the authority; the `admin` boolean is a mirror of it that the server maintains. Write **either** through the `Agent` resource and both are set — you no longer have to know which one is real, and a record cannot be stored saying one thing in one field and the opposite in the other.
|
|
138
|
+
> **Admin is one meaning with one answer.** On the Agent record, `role === "admin"` is the authority; the `admin` boolean is a mirror of it that the server maintains. An id listed in the instance's `FLAIR_ADMIN_AGENTS` is also an administrator, whatever its record's role. Write **either** through the `Agent` resource and both are set — you no longer have to know which one is real, and a record cannot be stored saying one thing in one field and the opposite in the other. The signed-request admin lookup does not use the `admin` mirror.
|
|
139
139
|
>
|
|
140
140
|
> A record written straight to the table (`databases.flair.Agent.put()`, an ops-API insert, a federation merge) skips that reconciliation and can still carry a mismatch. `flair principal show` and the admin dashboard flag such a record rather than silently picking a side; re-issuing the grant repairs it.
|
|
141
141
|
|
|
@@ -154,7 +154,7 @@ Flair accepts the public key as 64-char hex, or base64 of the raw 32 bytes.
|
|
|
154
154
|
|
|
155
155
|
Both verified end to end: an agent registered this way, with a key its app minted, then authenticated over HTTP with a real `TPS-Ed25519` signature — and a request signed with the *wrong* key was rejected.
|
|
156
156
|
|
|
157
|
-
> **
|
|
157
|
+
> **Setting the key, and who may call `AgentSeed`.** `Agent.put()` on the *resource* is an administrator operation (a trusted in-process call is admitted; over HTTP an agent that is not an administrator is refused and updates its own record with PATCH). It updates an existing record and keeps its stored `publicKey` (a `publicKey` in the body is ignored), and an admitted PUT to an id with no record is refused with `404 agent_put_requires_existing`, so set the key when you **create** the record; to rotate one later, write `databases.flair.Agent.put({ ...existing, publicKey })` on the raw table (`flair agent rotate-key` does the equivalent through the admin operations API, an `update` of the record's `publicKey` — there is no dedicated endpoint today). `AgentSeed` writes the agent's Soul, so its `post()` admits only a Soul-write source (`authorizeSoulWrite` in `resources/soul-write-policy.ts`): over HTTP, operator Basic (a verified Harper administrator's `Basic` credential; an admin agent's `TPS-Ed25519` key is refused `403 soul_write_requires_operator`), and in-process, a deliberate trusted internal call made with `internalContext()` on the resource `collectionResource()` binds. `collectionResource()` called without a context throws `InProcessContextError` before `post()` runs, and an explicit context that lacks the internal marker is refused `403 soul_write_requires_operator`. An unauthenticated request is refused.
|
|
158
158
|
|
|
159
159
|
---
|
|
160
160
|
|
|
@@ -178,7 +178,9 @@ Flair uses the raw table where it *wants* to bypass its own rules — the federa
|
|
|
178
178
|
| `{ request: { tpsAnonymous: true } }` | `anonymous` | Denied everywhere |
|
|
179
179
|
| `{ request: { tpsAgent: "mybot" } }` | `agent` | Scoped to that agent — **use this** |
|
|
180
180
|
| `{ request: { tpsAgent: "mybot", tpsAgentIsAdmin: true } }` | admin | Unfiltered reads, cross-agent writes |
|
|
181
|
-
| **Nothing
|
|
181
|
+
| **Nothing** (with no ambient Harper context), or an in-process `{ request: {} }` | `internal` | Unfiltered `Memory` reads. An `allowAdmin` check admits it only when the context carries the marker that `internalContext()` sets and no request headers, and refuses it otherwise. See the warning below. |
|
|
182
|
+
|
|
183
|
+
A context with an anonymous marker or request headers can resolve differently.
|
|
182
184
|
|
|
183
185
|
Build these with `agentContext(id)`, `adminContext(id)` and `internalContext()` rather than by hand — see [below](#the-api-is-built-so-omission-cannot-happen-quietly) for why the hand-written form is a trap.
|
|
184
186
|
|
|
@@ -198,7 +200,7 @@ There are exactly two ways to lose the model, from opposite ends. Both are pinne
|
|
|
198
200
|
|
|
199
201
|
| | |
|
|
200
202
|
|---|---|
|
|
201
|
-
| **By omission** | No
|
|
203
|
+
| **By omission** | No context argument and no ambient Harper context, or an in-process `{ request: {} }` ⇒ `internal` ⇒ unfiltered `Memory` reads. Without the marker that `internalContext()` sets, an `allowAdmin` check refuses it when Harper consults the gate. |
|
|
202
204
|
| **By assertion** | An attacker-influenced `agentId` is honoured verbatim. |
|
|
203
205
|
|
|
204
206
|
### The API is built so omission cannot happen quietly
|
|
@@ -207,19 +209,19 @@ There are exactly two ways to lose the model, from opposite ends. Both are pinne
|
|
|
207
209
|
|
|
208
210
|
```
|
|
209
211
|
resolveAgentAuth({ request: { tpsAgent: undefined } }) -> { kind: "internal" }
|
|
210
|
-
allowAdmin({ request: { tpsAgent: undefined } }) ->
|
|
212
|
+
allowAdmin({ request: { tpsAgent: undefined } }) -> false
|
|
211
213
|
```
|
|
212
214
|
|
|
213
|
-
That would turn
|
|
215
|
+
That would turn `agentContext(session.agentId)`, where the field came back undefined, into unfiltered `Memory` reads across every agent. The admin-only gate refuses it: `allowAdmin` admits the `internal` verdict only for a call that carries `internalContext()`'s marker and no request headers. So the helpers refuse rather than default:
|
|
214
216
|
|
|
215
217
|
| | |
|
|
216
218
|
|---|---|
|
|
217
219
|
| `agentContext(id)` | **Throws** `InProcessContextError` on a missing, empty or blank id. Takes **no options**, so no object spread into it can escalate. |
|
|
218
|
-
| `adminContext(id)` |
|
|
219
|
-
| `internalContext()` |
|
|
220
|
+
| `adminContext(id)` | Builds `{ request: { tpsAgent: id, tpsAgentIsAdmin: true } }`. Same id guard. |
|
|
221
|
+
| `internalContext()` | Builds `{ request: {}, __flairInternal: true }`, which resolves to `internal` and carries the marker that `allowAdmin` checks. |
|
|
220
222
|
| `collectionResource(Cls, context)` | Context is **required**; omitting it throws rather than granting `internal`. |
|
|
221
223
|
|
|
222
|
-
|
|
224
|
+
Elevated calls have named helpers, and `git grep "adminContext\|internalContext"` finds textual references to those helper names in tracked files. These are runtime guards, not type annotations.
|
|
223
225
|
|
|
224
226
|
### Individual identities, not one app identity
|
|
225
227
|
|
|
@@ -227,7 +229,7 @@ Give every agent its own. A per-agent context costs nothing — no client to con
|
|
|
227
229
|
|
|
228
230
|
### In a cluster
|
|
229
231
|
|
|
230
|
-
Harper replicates
|
|
232
|
+
Harper replicates tables in a replicated database unless a table opts out with `@table(replicate: false)`. Flair's replay stores are instance-wide across workers: `ReplayNonce` records agent-auth and federation nonces and opts out of replication, while `IdJagReplay` records used XAA assertion `jti` values and `OAuthSingleUse` records claims to redeem authorization codes or rotate refresh tokens. A single-use row records that a redemption was claimed. The handler attempts the later `used` or revocation write before issuing tokens. If that write fails, no token pair is issued; the claim remains, so the code or token cannot be redeemed again. `IdJagReplay` and `OAuthSingleUse` have no replication opt-out, so they replicate when the `flair` database does. Other Flair tables without a replication opt-out do too. So:
|
|
231
233
|
|
|
232
234
|
- **The registry replicates.** An agent registered on node A is visible on node B with no coordination. (Replication comes from the *database* being replicated — not from `@export`, which only controls REST exposure. `Memory` carries no `@export` and still replicates.)
|
|
233
235
|
- **Authority is local.** The context is constructed per call, in whichever process handles it. No node asks another who a caller is.
|
|
@@ -346,11 +348,11 @@ export async function remember(agentId, content, opts = {}) {
|
|
|
346
348
|
>
|
|
347
349
|
> `collectionResource(Cls, context)` is a two-line wrapper over the supported call — `Cls.getResource({}, context, { isCollection: true })` — and exists so this is written once. **Reads do not need it:** `Cls.get(id, context)` and `Cls.search(query, context)` thread the context themselves.
|
|
348
350
|
>
|
|
349
|
-
> They do still need the **context**.
|
|
351
|
+
> They do still need the **context**. Pass the context to every call, read and write; the warning below covers what omitting it does.
|
|
350
352
|
|
|
351
|
-
> ### ⚠️ A
|
|
353
|
+
> ### ⚠️ A `Memory` read with no context can run unfiltered
|
|
352
354
|
>
|
|
353
|
-
> A resource
|
|
355
|
+
> A resource given no context, when no ambient Harper context is present, resolves to Flair's trusted `internal` verdict. A `Memory` read then runs **unfiltered** across every agent, and the omission raises no error. An `allowAdmin` check refuses the same verdict when Harper consults the gate.
|
|
354
356
|
>
|
|
355
357
|
> Measured, not inferred: a context-less `Memory.search()` returns every agent's `private` records, and so does a context-less `SemanticSearch`.
|
|
356
358
|
>
|
|
@@ -383,7 +385,7 @@ export async function registerAgent(id, { publicKey = "pending", admin = false }
|
|
|
383
385
|
|
|
384
386
|
### What we measured, so you do not have to
|
|
385
387
|
|
|
386
|
-
Run end to end on **Harper 5.1.22**, from a second component loaded into the same instance — the exact shape above. `test/integration/in-process-agents.test.ts` in the Flair repo is that run, and `test/fixtures/inproc-app` is the component it drives.
|
|
388
|
+
Run end to end on **Harper 5.1.22**, from a second component loaded into the same instance — the exact shape above. `test/integration-heavy/in-process-agents.test.ts` in the Flair repo is that run, and `test/fixtures/inproc-app` is the component it drives.
|
|
387
389
|
|
|
388
390
|
| Claim | Result |
|
|
389
391
|
|---|---|
|
|
@@ -402,4 +404,4 @@ Handlers return a `Response` for `401`/`403`/`400` rather than throwing — chec
|
|
|
402
404
|
|
|
403
405
|
## See also
|
|
404
406
|
|
|
405
|
-
[Integrations](integrations.md) · [Deployment](deployment.md) · [Federation](federation.md) · [Auth](auth.md) · [Architecture](
|
|
407
|
+
[Integrations](integrations.md) · [Deployment](deployment.md) · [Federation](federation.md) · [Auth](auth.md) · [Architecture](https://github.com/tpsdev-ai/flair/blob/main/DESIGN.md)
|
|
@@ -14,10 +14,9 @@ and the new `entities` fields on `WorkspaceState`/`OrgEvent`/`Memory`), plus the
|
|
|
14
14
|
query and bootstrap collision surfacing (both shipped in later slices) and any future MCP
|
|
15
15
|
scope field — retrofitting a divergent vocabulary later is expensive.
|
|
16
16
|
|
|
17
|
-
> This doc covers the vocabulary and validator
|
|
18
|
-
> plane (flair#675). The attention query (
|
|
19
|
-
>
|
|
20
|
-
> for the full design.
|
|
17
|
+
> This doc covers the vocabulary and validator, the foundation slice of the attention
|
|
18
|
+
> plane (flair#675). The attention query (flair#677) and bootstrap collision surfacing
|
|
19
|
+
> (flair#681) build on it.
|
|
21
20
|
|
|
22
21
|
## The form
|
|
23
22
|
|
|
@@ -120,5 +119,3 @@ vocabulary; wiring that validation is a follow-up, not part of this foundation s
|
|
|
120
119
|
- Automatic entity extraction/tagging on write (producers set `entities` themselves today,
|
|
121
120
|
where they choose to; there's no NLP-derived auto-population yet).
|
|
122
121
|
- Validating `Relationship.subject`/`object` against this vocabulary.
|
|
123
|
-
|
|
124
|
-
These are tracked as follow-ups in `FLAIR-ATTENTION-PLANE.md`.
|
package/docs/federation.md
CHANGED
|
@@ -118,7 +118,7 @@ lands in shell history and the process list.
|
|
|
118
118
|
|
|
119
119
|
### What a push sends
|
|
120
120
|
|
|
121
|
-
Each sync
|
|
121
|
+
Each sync considers rows changed since the cursor from four tables: `Memory`, `Soul`, `Agent`, and `Relationship`. With `FLAIR_FEDERATION_PRESENCE_SEND` enabled (default off), `Presence` is scanned after those tables. Only Presence rows whose `originatorInstanceId` is this instance are eligible. Selection uses the later of `lastHeartbeatAt` and `activityUpdatedAt` against a separate watermark, clamped to scan time, with a 30 s overlap. A hub requires `FLAIR_FEDERATION_PRESENCE_RECEIVE` (default off) to store pushed Presence.
|
|
122
122
|
|
|
123
123
|
**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.
|
|
124
124
|
|
|
@@ -235,9 +235,15 @@ If neither the env var nor the passphrase file can be accessed, federation ident
|
|
|
235
235
|
|
|
236
236
|
### Pairing tokens
|
|
237
237
|
|
|
238
|
-
New peers must present a valid, unexpired, unused pairing token. This prevents unauthorized instances from joining the federation. Tokens are generated by the hub admin and are single-use.
|
|
238
|
+
New peers must present a valid, unexpired, unused pairing token. This prevents unauthorized instances from joining the federation. Tokens are generated by the hub admin and are single-use on one node.
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
An otherwise valid re-pair of a non-revoked peer (same instance ID, signed with the peer's pinned public key) requires no token; a supplied token must pass validation before the transactional Peer re-read. Before writing, the re-pair rechecks the pinned key and revoke status inside its owned transaction: a different key is refused (409); otherwise a revoked peer is refused (403 `peer_revoked`), with no peer row written and no token consumed. A peer row absent at that re-read is paired as a first-time pair with a valid token; without a token the request is refused (401). On the token path, the re-read covers changes committed before the transaction's first read (its token read), not changes committed after it. Both first-pair routes (initially absent Peer or deleted Peer on a token re-pair) stage their peer row in the owned transaction that consumes its token, then confirm its absence in committed state before that transaction commits. If that confirm read finds a row for the instance in committed state although the earlier read returned none, the pair is refused (409 `peer_row_appeared`): the request writes no peer row and the token stays unconsumed. After the commit, each route confirms its write from a fresh committed read, and a request whose confirmation fails is never reported as `paired`:
|
|
241
|
+
|
|
242
|
+
- **First-time pair** (an initially absent Peer, or a token re-pair whose Peer was deleted): the committed Peer row must show this attempt's marker and every staged field at its staged value, and the committed `PairingToken` row must match the staged marker, `consumedBy`, and `consumedAt`. A mismatch is refused 409 `peer_pair_unconfirmed`; a failed read is refused 503 `peer_read_back_unconfirmed`.
|
|
243
|
+
- **Token re-pair of an existing Peer:** the same comparison, except that its staged Peer row is a copy of the re-read row, so Harper's `__createdtime__` and `__updatedtime__` are left out. A mismatch or a failed read is refused 409 `peer_pair_unconfirmed`.
|
|
244
|
+
- **Re-pair without a token:** the committed Peer row must show this attempt's marker and its staged fields, again without Harper's timestamps. A mismatch or a failed read answers 503 `write_outcome_unknown` with outcome `unconfirmed`; no token was spent, so the request may be sent again.
|
|
245
|
+
|
|
246
|
+
On both re-pair routes, `pairAttemptWriteId` is written by a pairing attempt as the id of its write. A field-level competing update that leaves this field alone merges around it, so a refused attempt's id can remain on the committed row next to the competing update's fields. The post-commit comparison uses it as the id of the staged write; it is not a confirmation of the attempt.
|
|
241
247
|
|
|
242
248
|
### Originator enforcement
|
|
243
249
|
|
|
@@ -277,6 +283,58 @@ Records with `updatedAt` more than 5 minutes in the future are rejected. This pr
|
|
|
277
283
|
|
|
278
284
|
Federation uses record-level last-write-wins (LWW) with ISO timestamp comparison. When two instances modify the same record, the one with the later `updatedAt` wins. Field-level LWW is planned for a future version.
|
|
279
285
|
|
|
286
|
+
### A pending agent key is never completed by federation
|
|
287
|
+
|
|
288
|
+
`POST /AgentKeyRegister` checks a fresh row is non-deactivated, local and `pending` and
|
|
289
|
+
confirms it before commit (see [registration limits](api-reference.md#identity--agent-presence-soul)); the administrator
|
|
290
|
+
operations API can also write the column directly (the documented admin
|
|
291
|
+
trust-root path). Federation cannot complete it. A record that reaches the merge
|
|
292
|
+
plan with `publicKey` different from stored `pending` is skipped whole as
|
|
293
|
+
`agent_pending_key_not_federated`, unless the status rule refused it first as
|
|
294
|
+
`agent_status_not_federated`. Earlier validation keeps its own reason, such as
|
|
295
|
+
`future_timestamp` (see [docs/api-reference.md](api-reference.md#federation)).
|
|
296
|
+
|
|
297
|
+
Peer non-convergence is the consequence for a copy B already holds. Registration
|
|
298
|
+
writes only A's local tables; when B already holds a pending copy and A's
|
|
299
|
+
registered-key row later reaches B through a sync, the skip rule leaves that copy
|
|
300
|
+
exactly `pending`. Sync alone therefore does not converge that copy. Whether B's
|
|
301
|
+
own `POST /AgentKeyRegister` can complete it depends on how B's copy was created:
|
|
302
|
+
B stamps sync provenance on a row it receives through a sync, and a copy that
|
|
303
|
+
carries sync provenance (or whose `originatorInstanceId` names another instance)
|
|
304
|
+
is refused there as `agent_not_local`. A pending copy created locally on B, with
|
|
305
|
+
neither marker, is a local agent: B's own registration can complete it. For a
|
|
306
|
+
sync-originated or foreign-home copy, the two instances do not converge on one
|
|
307
|
+
key: syncing A's registered-key row cannot complete B's pending copy, and that
|
|
308
|
+
key needs direct action on B. The remedy is on B, for
|
|
309
|
+
a sync-originated or foreign-home copy: B's administrator writes the agent's
|
|
310
|
+
public key (the one registered on A) onto B's copy through B's operations API,
|
|
311
|
+
an `update` of `flair.Agent` with `{id, publicKey, updatedAt}`. That is the raw
|
|
312
|
+
write `flair agent rotate-key` makes, but `rotate-key` generates a new keypair,
|
|
313
|
+
so B's copy would then hold a different key from A's. A B row that is absent
|
|
314
|
+
can receive A's registered-key row: the pending-key guard applies only to a row B
|
|
315
|
+
already holds with `publicKey: "pending"`.
|
|
316
|
+
|
|
317
|
+
### An agent's key, home and admin fields in a sync
|
|
318
|
+
|
|
319
|
+
An existing Agent row's `publicKey` and home (`originatorInstanceId`) change
|
|
320
|
+
through a sync only when the batch's signing sender is the row's stored home. A
|
|
321
|
+
record from another peer that would change either is skipped whole as
|
|
322
|
+
`agent_identity_not_from_home`. A missing, null or empty stored home counts as
|
|
323
|
+
no home: such a row takes no key change from a peer and cannot acquire a
|
|
324
|
+
non-empty home through a sync.
|
|
325
|
+
|
|
326
|
+
A sync does not set or change `role: "admin"` or `admin: true`: a new row is
|
|
327
|
+
stored without them, and an existing row keeps its stored admin state (whether
|
|
328
|
+
`role` is `"admin"` and whether `admin` is `true`) when the record's would change
|
|
329
|
+
it. A `role` label follows the merge when the stored and incoming roles are both
|
|
330
|
+
non-admin. A record that would
|
|
331
|
+
create a row whose id the receiving instance's `FLAIR_ADMIN_AGENTS` names is
|
|
332
|
+
skipped as `agent_admin_id_not_federated`.
|
|
333
|
+
|
|
334
|
+
Earlier checks, including the status and pending-key rules, keep their own
|
|
335
|
+
reasons. The receiving instance's administrator can write these fields, or
|
|
336
|
+
create the row, through its operations API.
|
|
337
|
+
|
|
280
338
|
## Troubleshooting
|
|
281
339
|
|
|
282
340
|
### Listen port drift
|