@tpsdev-ai/flair 0.56.0 → 0.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -20
- package/SECURITY.md +4 -1
- package/dist/build-info.json +3 -3
- package/dist/cli.js +1800 -293
- package/dist/commands/agent.js +22 -15
- package/dist/commands/bridge.js +40 -3
- package/dist/commands/doctor.js +214 -4
- package/dist/commands/federation.js +265 -38
- package/dist/commands/hook.js +10 -2
- package/dist/commands/init.js +179 -48
- package/dist/commands/memory.js +24 -2
- package/dist/commands/quality.js +26 -18
- package/dist/commands/service.js +137 -22
- package/dist/commands/status.js +114 -3
- package/dist/commands/upgrade.js +204 -84
- package/dist/doctor-client.js +50 -4
- package/dist/federation/scheduler.js +253 -4
- package/dist/install/clients.js +89 -23
- package/dist/install/global-bin-path.js +26 -6
- package/dist/lib/atomic-write.js +256 -0
- package/dist/lib/auth-resolve.js +46 -0
- package/dist/lib/daemon-liveness.js +61 -0
- package/dist/lib/doctor-run.js +5 -0
- package/dist/lib/embed-gpu-doctor.js +49 -26
- package/dist/lib/federation-memory-attributes.js +15 -0
- package/dist/lib/init-admin-pass.js +4 -2
- package/dist/lib/init-listener-environ.js +38 -0
- package/dist/lib/init-occupied-listener.js +165 -0
- package/dist/lib/instance-identity-row.js +580 -0
- package/dist/lib/launchd-domain-preflight.js +448 -0
- package/dist/lib/launchd-management.js +176 -6
- package/dist/lib/launchd-repair.js +95 -0
- package/dist/lib/memory-attributes.js +77 -0
- package/dist/lib/node-alias-path.js +95 -0
- package/dist/lib/npm-registry.js +119 -6
- package/dist/lib/owned-pins.js +20 -6
- package/dist/lib/redact-token-id.js +197 -0
- package/dist/lib/service-repoint-apply.js +267 -0
- package/dist/lib/service-repoint.js +575 -0
- package/dist/lib/toml-string-array.js +104 -0
- package/dist/lib/tree-divergence.js +716 -0
- package/dist/lib/upgrade-plain-tree.js +18 -8
- package/dist/lib/upgrade-prior-liveness.js +69 -0
- package/dist/lib/upgrade-rollback.js +116 -0
- package/dist/rem/runner.js +11 -0
- package/dist/resources/Agent.js +27 -14
- package/dist/resources/AgentSeed.js +39 -2
- package/dist/resources/Asset.js +3 -11
- package/dist/resources/Credential.js +4 -10
- package/dist/resources/Federation.js +299 -127
- package/dist/resources/Integration.js +8 -32
- package/dist/resources/Memory.js +623 -86
- package/dist/resources/MemoryArchive.js +9 -0
- package/dist/resources/MemoryBootstrap.js +23 -12
- package/dist/resources/MemoryCandidate.js +3 -11
- package/dist/resources/MemoryDedupStats.js +1 -1
- package/dist/resources/MemoryFeed.js +214 -5
- package/dist/resources/MemoryGrant.js +19 -40
- package/dist/resources/MemoryHostSource.js +90 -0
- package/dist/resources/MemoryMaintenance.js +121 -32
- package/dist/resources/MemoryReflect.js +4 -1
- package/dist/resources/MemoryReindex.js +7 -4
- package/dist/resources/MemoryUsage.js +55 -18
- package/dist/resources/Presence.js +18 -10
- package/dist/resources/RecordUsage.js +30 -40
- package/dist/resources/Relationship.js +170 -89
- package/dist/resources/SemanticSearch.js +44 -19
- package/dist/resources/Soul.js +31 -19
- package/dist/resources/XAA.js +7 -3
- package/dist/resources/agent-auth.js +16 -10
- package/dist/resources/auth-middleware.js +164 -50
- package/dist/resources/auto-promote-lib.js +4 -4
- package/dist/resources/bm25-index-service.js +246 -32
- package/dist/resources/bm25-status.js +132 -0
- package/dist/resources/bm25.js +13 -14
- package/dist/resources/ed25519-auth.js +11 -54
- package/dist/resources/embed-gpu.js +262 -47
- package/dist/resources/embeddings-boot.js +52 -17
- package/dist/resources/federation-classify.js +12 -0
- package/dist/resources/federation-cleanup.js +289 -51
- package/dist/resources/federation-crypto.js +65 -19
- package/dist/resources/health.js +105 -22
- package/dist/resources/host-pointer/registry.js +35 -0
- package/dist/resources/host-pointer-adapter.js +15 -0
- package/dist/resources/host-source-visibility.js +167 -0
- package/dist/resources/host-source.js +151 -0
- package/dist/resources/in-process-api.js +2 -1
- package/dist/resources/instance-create-lock.js +363 -0
- package/dist/resources/instance-identity-rows.js +43 -0
- package/dist/resources/instance-identity.js +97 -12
- package/dist/resources/mcp-handler.js +155 -51
- package/dist/resources/mcp-tool-arguments.js +83 -0
- package/dist/resources/mcp-tools.js +28 -25
- package/dist/resources/memory-consolidate-lib.js +3 -1
- package/dist/resources/memory-declared-attributes.js +103 -0
- package/dist/resources/memory-feed-lib.js +5 -1
- package/dist/resources/memory-host-source.js +163 -0
- package/dist/resources/memory-visibility.js +10 -7
- package/dist/resources/migrations/synthetic-test-migration.js +4 -1
- package/dist/resources/migrations/visibility-backfill.js +4 -1
- package/dist/resources/originator-instance.js +235 -0
- package/dist/resources/promotion-stamp.js +2 -0
- package/dist/resources/provenance.js +111 -11
- package/dist/resources/rate-limit.js +6 -4
- package/dist/resources/record-owner-guard.js +19 -0
- package/dist/resources/record-type-kit.js +44 -23
- package/dist/resources/record-types.js +6 -6
- package/dist/resources/relay-ops.js +28 -3
- package/dist/resources/replay-store.js +289 -0
- package/dist/resources/request-transaction.js +78 -0
- package/dist/resources/search-readiness.js +26 -22
- package/dist/resources/semantic-retrieval-core.js +103 -4
- package/dist/resources/table-helpers.js +33 -0
- package/dist/resources/table-patch-policy.js +109 -0
- package/dist/resources/table-patches.js +17 -0
- package/dist/resources/table-post-policy.js +138 -0
- package/dist/resources/table-posts.js +22 -0
- package/dist/resources/table-subscription-policy.js +135 -0
- package/dist/resources/table-subscriptions.js +19 -0
- package/dist/resources/tool-descriptors/index.js +15 -15
- package/dist/resources/trust-block.js +10 -3
- package/dist/resources/usage-recording.js +169 -41
- package/dist/src/lib/instance-identity-row.js +580 -0
- package/dist/src/lib/memory-attributes.js +77 -0
- package/dist/src/lib/redact-token-id.js +197 -0
- package/docs/api-reference.md +80 -16
- package/docs/auth.md +5 -5
- package/docs/claude-code.md +137 -6
- package/docs/deploying-on-fabric.md +6 -3
- package/docs/deployment.md +1 -1
- package/docs/embedding-in-a-harper-app.md +3 -3
- package/docs/federation.md +17 -10
- package/docs/hosted-on-fabric.md +4 -3
- package/docs/integrations.md +28 -19
- package/docs/mcp-clients.md +26 -32
- package/docs/n8n.md +8 -8
- package/docs/notes/mcp-oauth-model2.md +27 -18
- package/docs/openclaw.md +29 -28
- package/docs/quickstart.md +5 -0
- package/docs/releasing.md +134 -2
- package/docs/spoke-bringup.md +14 -11
- package/docs/standalone-local.md +2 -2
- package/docs/supply-chain-policy.md +28 -10
- package/docs/system-requirements.md +1 -1
- package/docs/troubleshooting.md +11 -0
- package/docs/upgrade.md +189 -63
- package/package.json +9 -5
- package/schemas/agent.graphql +9 -6
- package/schemas/federation.graphql +2 -11
- package/schemas/memory.graphql +106 -17
- package/schemas/replay.graphql +18 -0
- package/templates/launchd/start-flair-with-admin-pass.sh +22 -0
- package/dist/resources/federation-nonce-store.js +0 -195
package/dist/commands/agent.js
CHANGED
|
@@ -2,7 +2,7 @@ import nacl from "tweetnacl";
|
|
|
2
2
|
import { existsSync, mkdirSync, writeFileSync, readFileSync, chmodSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import * as render from "../render.js";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveAdminPassFromSources, defaultKeysDir, resolveLocalAdminPass, resolveAdminUser, resolveKeyPath, authFetch, } from "../lib/auth-resolve.js";
|
|
6
6
|
let cli;
|
|
7
7
|
/** Bind shared CLI helpers. cli.ts calls this immediately before register(program). */
|
|
8
8
|
export function bindCli(fns) {
|
|
@@ -46,22 +46,29 @@ export function register(program) {
|
|
|
46
46
|
// `flair import`: explicit --ops-target > derive from --target > localhost.
|
|
47
47
|
const seedOpsTarget = resolveEffectiveOpsUrl({ target: opts.target, opsTarget: opts.opsTarget }) ?? opsPort;
|
|
48
48
|
const isRemoteTarget = typeof seedOpsTarget === "string";
|
|
49
|
-
// flair#1259 — --admin-pass-file
|
|
50
|
-
//
|
|
49
|
+
// flair#1259 / #1910 — --admin-pass-file and --admin-pass resolve through
|
|
50
|
+
// the ONE resolver (resolveAdminPassFromSources), the file read in-process
|
|
51
51
|
// via readAdminPassFileSecure so the secret never appears in ps or shell
|
|
52
|
-
// history.
|
|
53
|
-
//
|
|
54
|
-
// explicit
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
// history. Combining the file and the flag is a usage error (the flag used
|
|
53
|
+
// to silently win). This does NOT weaken the #1085 remote guard below: an
|
|
54
|
+
// explicit flag naming a file IS operator intent toward this target,
|
|
55
|
+
// exactly like an explicit inline --admin-pass — what the guard blocks is
|
|
56
|
+
// the AMBIENT env/local-file fallbacks silently traveling to a third-party
|
|
57
|
+
// host.
|
|
58
|
+
let explicitPass;
|
|
59
|
+
try {
|
|
60
|
+
explicitPass =
|
|
61
|
+
resolveAdminPassFromSources({
|
|
62
|
+
adminPassFile: opts.adminPassFile,
|
|
63
|
+
adminPass: opts.adminPass,
|
|
64
|
+
envPass: undefined,
|
|
65
|
+
}) || undefined;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
console.error(`Error: ${err.message}`);
|
|
69
|
+
process.exit(1);
|
|
64
70
|
}
|
|
71
|
+
opts.adminPass = explicitPass;
|
|
65
72
|
// #590 — local convenience fallback: FLAIR_ADMIN_PASS env, then the secure
|
|
66
73
|
// ~/.flair/admin-pass file `flair init` already writes (mode 0600). Never
|
|
67
74
|
// applied for a remote target — see resolveLocalAdminPass.
|
package/dist/commands/bridge.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import * as render from "../render.js";
|
|
2
2
|
import { resolveKeyPath, buildEd25519Auth } from "../lib/auth-resolve.js";
|
|
3
3
|
let cli;
|
|
4
|
+
/**
|
|
5
|
+
* Percent-encode a Memory id so it addresses exactly that record as ONE path
|
|
6
|
+
* segment (flair#1970). REFUSES an id that is exactly `.` or `..`: percent-
|
|
7
|
+
* encoding leaves those unchanged and URL normalization collapses `/Memory/.`
|
|
8
|
+
* to `/Memory/` and `/Memory/..` to `/`, so the sent path would not be the id
|
|
9
|
+
* (nor the signed path). Such an id cannot address its record.
|
|
10
|
+
*/
|
|
11
|
+
function encodeRecordId(id) {
|
|
12
|
+
if (id === "." || id === "..") {
|
|
13
|
+
throw new Error(`record id ${JSON.stringify(id)} is a URL path dot-segment ("." or ".."); ` +
|
|
14
|
+
`it cannot be addressed as one path segment of /Memory/<id>. Use a different id.`);
|
|
15
|
+
}
|
|
16
|
+
return encodeURIComponent(id);
|
|
17
|
+
}
|
|
4
18
|
/** Bind shared CLI helpers. cli.ts calls this immediately before register(program). */
|
|
5
19
|
export function bindCli(fns) {
|
|
6
20
|
cli = fns;
|
|
@@ -128,6 +142,20 @@ export function register(program) {
|
|
|
128
142
|
process.exit(1);
|
|
129
143
|
}
|
|
130
144
|
const baseUrl = opts.url ?? `http://127.0.0.1:${resolveHttpPort(opts)}`;
|
|
145
|
+
// A Flair base URL is an origin with an optional path; a query string or
|
|
146
|
+
// fragment on the base is refused before anything is imported — including
|
|
147
|
+
// for an empty or dry-run import, and including a bare trailing "?" or "#"
|
|
148
|
+
// (new URL reports those as an empty search/hash, but the join would drop
|
|
149
|
+
// the base's path). The route's own query string is what gets signed. #1970.
|
|
150
|
+
const parsedBase = new URL(baseUrl);
|
|
151
|
+
if (parsedBase.href.includes("?") || parsedBase.href.includes("#")) {
|
|
152
|
+
console.error(`Bridge import failed: refusing base URL "${baseUrl}": a Flair base URL must not carry a query string or fragment.`);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
// Routes join against the PARSED base, which new URL() has normalized (for
|
|
156
|
+
// example surrounding whitespace removed), so the path sent is the path the
|
|
157
|
+
// base names.
|
|
158
|
+
const joinBase = `${parsedBase.href.replace(/\/+$/, "")}/`;
|
|
131
159
|
const ctx = makeContext({ bridge: name });
|
|
132
160
|
// Memory POST: Ed25519-signed when an agent key is available, fall back
|
|
133
161
|
// to the shared `api()` helper otherwise. Mirrors how `flair memory add`
|
|
@@ -135,17 +163,26 @@ export function register(program) {
|
|
|
135
163
|
const putMemory = async (body) => {
|
|
136
164
|
const headers = { "content-type": "application/json" };
|
|
137
165
|
const keyPath = opts.key ?? resolveKeyPath(body.agentId);
|
|
166
|
+
// One percent-encoded path segment, built once. Join the route onto the
|
|
167
|
+
// base URL's OWN path with exactly one slash between them, preserving any
|
|
168
|
+
// path the base carries (a base like http://h/flair still addresses
|
|
169
|
+
// /flair/Memory/<id>). Build the FINAL url once, then sign the path the
|
|
170
|
+
// request actually carries (#1970); ids of ordinary characters address
|
|
171
|
+
// the same record as before.
|
|
172
|
+
const memoryPath = `/Memory/${encodeRecordId(body.id)}`;
|
|
173
|
+
const memoryUrl = new URL(memoryPath.replace(/^\/+/, ""), joinBase);
|
|
174
|
+
const signedPath = `${memoryUrl.pathname}${memoryUrl.search}`;
|
|
138
175
|
if (keyPath) {
|
|
139
|
-
headers["authorization"] = buildEd25519Auth(body.agentId, "PUT",
|
|
176
|
+
headers["authorization"] = buildEd25519Auth(body.agentId, "PUT", signedPath, keyPath);
|
|
140
177
|
}
|
|
141
|
-
const res = await fetch(
|
|
178
|
+
const res = await fetch(memoryUrl, {
|
|
142
179
|
method: "PUT",
|
|
143
180
|
headers,
|
|
144
181
|
body: JSON.stringify(body),
|
|
145
182
|
});
|
|
146
183
|
if (!res.ok) {
|
|
147
184
|
const text = await res.text().catch(() => "");
|
|
148
|
-
throw new Error(`PUT
|
|
185
|
+
throw new Error(`PUT ${signedPath} → ${res.status}: ${text || res.statusText}`);
|
|
149
186
|
}
|
|
150
187
|
};
|
|
151
188
|
let lastReportedAt = Date.now();
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { COMPONENT_ENV_FILENAME, PUBLIC_URL_KEY, describePublicUrlFinding, readEnvValue } from "../component-env.js";
|
|
2
|
-
import { checkClaudeMdBootstrap, checkContinuityCaptureHooks, describeAgentGateFinding, effectiveFlairUrl, embeddingsSkipRemedy, fixClaudeMdBootstrap, fixCommandAgentHint, fixContinuityCaptureHooks, fixSessionStartHook, inspectSessionStartHook, partitionKeyIds, planAgentIterations, readClientMcpBlock, resolveFixAgentId, resolveWireFlairUrl, upgradeSessionStartHookCommand } from "../doctor-client.js";
|
|
2
|
+
import { checkClaudeMdBootstrap, checkContinuityCaptureHooks, continuityWriteBlockers, describeAgentGateFinding, effectiveFlairUrl, embeddingsSkipRemedy, fixClaudeMdBootstrap, fixCommandAgentHint, fixContinuityCaptureHooks, fixSessionStartHook, inspectSessionStartHook, partitionKeyIds, planAgentIterations, readClientMcpBlock, resolveFixAgentId, resolveWireFlairUrl, upgradeSessionStartHookCommand } from "../doctor-client.js";
|
|
3
3
|
import { markStale, sortOldestVersionFirst } from "../fleet-presence.js";
|
|
4
4
|
import { hookSettingsPath, resolveHookAgentId } from "../hook-install.js";
|
|
5
5
|
import { ALL_CLIENTS, decideCodexPinOnly, decideJsonPinOnly, detectClients, wireAntigravity, wireClaudeCode, wireCodex, wireCursor, wireGemini } from "../install/clients.js";
|
|
@@ -12,11 +12,14 @@ import { DOCTOR_CHECK_IDS, catalogIssueDelta, mcpRepinIcon, renderCatalogDoctorL
|
|
|
12
12
|
import { describeEmbedGpuDoctorFinding } from "../lib/embed-gpu-doctor.js";
|
|
13
13
|
import { adminPassDesyncFinding, detectPersistedAdminUser } from "../lib/init-admin-pass.js";
|
|
14
14
|
import { opsApiBindFinding } from "../lib/ops-api-bind.js";
|
|
15
|
+
import { instanceIdentityLines, probeInstanceIdentity, } from "../lib/instance-identity-row.js";
|
|
15
16
|
import { flairCliVersion, unpinnedSpecWarning } from "../lib/mcp-spec.js";
|
|
16
17
|
import { mcpClientPinFindings, refreshOwnedPins, repinSessionStartHookGuarded, sessionStartHookPinFindings } from "../lib/owned-pins.js";
|
|
17
18
|
import * as render from "../render.js";
|
|
18
19
|
import { checkVersion, formatVersionNudge, probeInstanceVersion, FLAIR_PKG_NAME } from "../version-check.js";
|
|
19
20
|
import { resolveRegistryNotice } from "../lib/npm-registry.js";
|
|
21
|
+
import { formatServingTreeLine, formatTreeAssessmentLines } from "../lib/tree-divergence.js";
|
|
22
|
+
import { rewriteFederationSchedulerRuntime } from "../federation/scheduler.js";
|
|
20
23
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
21
24
|
import { dirname, join } from "node:path";
|
|
22
25
|
import { resolveHome } from "../lib/home.js";
|
|
@@ -129,6 +132,133 @@ export function renderEmbedGpuDoctorFinding(embedding, write = (line) => console
|
|
|
129
132
|
write(line);
|
|
130
133
|
return { lines, issueDelta: finding.isIssue ? 1 : 0 };
|
|
131
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* flair#2034 §2 — the "Install tree" doctor section: is the instance served
|
|
137
|
+
* from this CLI's install tree, and does the federation-sync shim run it?
|
|
138
|
+
*
|
|
139
|
+
* Runs in every `flair doctor` (it is not a catalog member, so it cannot be
|
|
140
|
+
* filtered out the way the catalog's launchd check is). Counting rules:
|
|
141
|
+
*
|
|
142
|
+
* - a PROVEN divergence is one issue; a deliberate runtime pin (a different
|
|
143
|
+
* node serving this CLI's own tree), a separately managed tree (a plain
|
|
144
|
+
* tree or checkout) and an unknown serving tree are reported, never counted;
|
|
145
|
+
* - `--fix` counts the divergence FIXED only after the unit was re-pointed,
|
|
146
|
+
* the instance restarted, and the serving tree re-proven to be this CLI's —
|
|
147
|
+
* "nothing to rewrite" or a failed restart is never a fix;
|
|
148
|
+
* - a federation-sync shim running another npm-global tree is one issue,
|
|
149
|
+
* fixed only when re-pointed AND re-read as current.
|
|
150
|
+
*
|
|
151
|
+
* Extracted from the action (like renderEmbedGpuDoctorFinding) so the counting
|
|
152
|
+
* is exercised directly; the action passes the real adapters.
|
|
153
|
+
*/
|
|
154
|
+
export async function runInstallTreeDoctorSection(mode, deps, write = (line) => console.log(line)) {
|
|
155
|
+
let issues = 0;
|
|
156
|
+
let fixed = 0;
|
|
157
|
+
const ok = render.icons.ok;
|
|
158
|
+
const bad = render.icons.error;
|
|
159
|
+
const info = render.icons.info;
|
|
160
|
+
const warn = render.icons.warn;
|
|
161
|
+
let a = null;
|
|
162
|
+
try {
|
|
163
|
+
a = deps.assess();
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
write(` ${warn} install tree: could not check ${render.wrap(render.c.dim, `(${err?.message ?? err})`)}`);
|
|
167
|
+
}
|
|
168
|
+
if (a?.state === "same") {
|
|
169
|
+
write(` ${ok} ${formatServingTreeLine(a)}`);
|
|
170
|
+
if (a.nodePin?.kind === "pinned")
|
|
171
|
+
write(` ${info} ${a.nodePin.message}`);
|
|
172
|
+
}
|
|
173
|
+
else if (a?.state === "unknown") {
|
|
174
|
+
write(` ${info} ${render.wrap(render.c.dim, formatServingTreeLine(a))}`);
|
|
175
|
+
}
|
|
176
|
+
else if (a?.state === "separate") {
|
|
177
|
+
for (const line of formatTreeAssessmentLines(a, { context: "doctor" }))
|
|
178
|
+
write(` ${line}`);
|
|
179
|
+
}
|
|
180
|
+
else if (a?.state === "diverged") {
|
|
181
|
+
issues++;
|
|
182
|
+
write(` ${bad} ${render.wrap(render.c.red, "the instance is served from a different install tree than this CLI")}`);
|
|
183
|
+
for (const line of formatTreeAssessmentLines(a, { context: "doctor" }))
|
|
184
|
+
write(` ${render.wrap(render.c.yellow, line)}`);
|
|
185
|
+
if (mode.autoFix && a.cliOlder) {
|
|
186
|
+
write(` ${bad} not re-pointed: this CLI's tree is older than what the instance runs — update it first (npm i -g @tpsdev-ai/flair), then re-run.`);
|
|
187
|
+
}
|
|
188
|
+
else if (mode.autoFix && mode.dryRun) {
|
|
189
|
+
const r = deps.repoint(true);
|
|
190
|
+
write(` ${info} ${render.wrap(render.c.dim, `[dry-run] ${r.detail}; then restart the instance and re-prove which tree serves it`)}`);
|
|
191
|
+
}
|
|
192
|
+
else if (mode.autoFix) {
|
|
193
|
+
const r = deps.repoint(false);
|
|
194
|
+
if (r.kind === "repointed" || r.kind === "current") {
|
|
195
|
+
if (r.kind === "repointed")
|
|
196
|
+
write(` ${ok} ${r.detail}`);
|
|
197
|
+
try {
|
|
198
|
+
await deps.restart();
|
|
199
|
+
const after = deps.assess();
|
|
200
|
+
if (after.state === "same") {
|
|
201
|
+
fixed++;
|
|
202
|
+
write(` ${ok} ${render.wrap(render.c.green, "restarted; verified")} — ${formatServingTreeLine(after)}`);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
write(` ${bad} restarted, but NOT fixed — ${formatServingTreeLine(after)}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
write(` ${bad} the restart failed (${err?.message ?? err}); the unit is re-pointed — run: flair restart`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
write(` ${bad} not re-pointed — ${r.detail}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
let f = null;
|
|
218
|
+
try {
|
|
219
|
+
f = deps.rewriteFederation(true);
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
write(` ${warn} federation-sync shim: could not check ${render.wrap(render.c.dim, `(${err?.message ?? err})`)}`);
|
|
223
|
+
}
|
|
224
|
+
switch (f?.status) {
|
|
225
|
+
case "current":
|
|
226
|
+
write(` ${ok} federation-sync shim runs this CLI's tree`);
|
|
227
|
+
break;
|
|
228
|
+
case "pinned-node":
|
|
229
|
+
case "separate":
|
|
230
|
+
write(` ${info} federation-sync shim: ${f.detail}`);
|
|
231
|
+
break;
|
|
232
|
+
case "refused":
|
|
233
|
+
write(` ${warn} federation-sync shim: ${f.detail}`);
|
|
234
|
+
break;
|
|
235
|
+
case "would-rewrite": {
|
|
236
|
+
issues++;
|
|
237
|
+
write(` ${bad} the federation-sync shim runs another install tree — ${f.detail}`);
|
|
238
|
+
if (mode.autoFix && mode.dryRun) {
|
|
239
|
+
write(` ${info} ${render.wrap(render.c.dim, "[dry-run] would re-point the shim's exec line (the scheduler unit is not rewritten)")}`);
|
|
240
|
+
}
|
|
241
|
+
else if (mode.autoFix) {
|
|
242
|
+
const r = deps.rewriteFederation(false);
|
|
243
|
+
const verify = r.status === "rewritten" ? deps.rewriteFederation(true) : null;
|
|
244
|
+
if (verify?.status === "current") {
|
|
245
|
+
fixed++;
|
|
246
|
+
write(` ${ok} ${r.detail}`);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
write(` ${bad} federation-sync shim not re-pointed — ${verify ? verify.detail : r.detail}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
write(` ${render.wrap(render.c.dim, "Fix:")} flair doctor --fix ${render.wrap(render.c.dim, "(or flair init)")}`);
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
default:
|
|
258
|
+
break; // not enabled: nothing to say
|
|
259
|
+
}
|
|
260
|
+
return { issues, fixed };
|
|
261
|
+
}
|
|
132
262
|
// ─── flair doctor ─────────────────────────────────────────────────────────────
|
|
133
263
|
export function register(program) {
|
|
134
264
|
const __pkgVersion = cli.__pkgVersion;
|
|
@@ -733,6 +863,57 @@ export function register(program) {
|
|
|
733
863
|
break;
|
|
734
864
|
}
|
|
735
865
|
}
|
|
866
|
+
// 4c. Instance identity (flair#1883). A hub's identity is ONE
|
|
867
|
+
// `flair.Instance` row, and the pairing-cleanup sweep reads its role from
|
|
868
|
+
// that row. More than one row means there is no canonical identity — the
|
|
869
|
+
// state a hub lands in when `GET /FederationInstance` find-or-creates a
|
|
870
|
+
// spoke row and `flair init --remote` inserted a second one (which is why
|
|
871
|
+
// the sweep could find no hub role and never clean up). A
|
|
872
|
+
// `flair_pair_initiator` role on an instance whose identity row is not a
|
|
873
|
+
// hub is the same debris seen from the other side. Both are read from the
|
|
874
|
+
// instance itself, so they need the ops API — same admin credential as the
|
|
875
|
+
// audit check above. A read that does not happen is UNVERIFIED: never a
|
|
876
|
+
// pass, and never a fabricated finding. The two reads are separate, so the
|
|
877
|
+
// states are separate too (flair#1883 round 2): rows read but list_roles
|
|
878
|
+
// unreadable leaves the pairing-role check UNVERIFIED while the row facts
|
|
879
|
+
// are still reported — a green line would claim a check that did not run.
|
|
880
|
+
if (harperResponding) {
|
|
881
|
+
let identityAdminPass;
|
|
882
|
+
let identityCredIssue = null;
|
|
883
|
+
try {
|
|
884
|
+
identityAdminPass = resolveLocalAdminPass(undefined);
|
|
885
|
+
}
|
|
886
|
+
catch (err) {
|
|
887
|
+
identityCredIssue = err instanceof Error ? err.message : String(err);
|
|
888
|
+
}
|
|
889
|
+
if (identityCredIssue) {
|
|
890
|
+
console.log(` ${render.icons.warn} Instance identity: UNVERIFIED (could not probe — ${identityCredIssue})`);
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
const probe = await probeInstanceIdentity({
|
|
894
|
+
opsUrl: `http://127.0.0.1:${resolveOpsPort(opts)}`,
|
|
895
|
+
credentials: { user: resolveAdminUser(undefined), pass: identityAdminPass ?? "" },
|
|
896
|
+
});
|
|
897
|
+
if (probe.rows === null) {
|
|
898
|
+
console.log(` ${render.icons.warn} Instance identity: UNVERIFIED (could not read the Instance table via the ops API)`);
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
// The lines — and therefore the pairing-role state — are built in
|
|
902
|
+
// `instanceIdentityLines`, so "an unread pairing-role check is never
|
|
903
|
+
// silent" is a property of the lines and not of this call site: a row
|
|
904
|
+
// finding and the pairing-role UNVERIFIED status print as two lines
|
|
905
|
+
// from one call (flair#1883 round 5).
|
|
906
|
+
for (const line of instanceIdentityLines({ rows: probe.rows, roleNames: probe.roleNames })) {
|
|
907
|
+
const icon = line.level === "ok" ? render.icons.ok : line.level === "warn" ? render.icons.warn : render.icons.error;
|
|
908
|
+
console.log(` ${icon} ${line.level === "fail" ? line.text : render.wrap(render.c.dim, line.text)}`);
|
|
909
|
+
if (line.fix)
|
|
910
|
+
console.log(` ${render.wrap(render.c.dim, line.fix)}`);
|
|
911
|
+
if (line.level === "fail")
|
|
912
|
+
issues++;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
736
917
|
// 5. Stale PID file (skip if already reported in port check)
|
|
737
918
|
const dataDir = defaultDataDir();
|
|
738
919
|
const pidFile = join(dataDir, "hdb.pid");
|
|
@@ -1250,8 +1431,13 @@ export function register(program) {
|
|
|
1250
1431
|
const continuityDetail = continuity.state === "partial"
|
|
1251
1432
|
? (!continuity.postToolUse.present ? "the PostToolUse entry is missing" : "the Stop entry is missing")
|
|
1252
1433
|
: "an entry is not the current form (unsilenced, hand-altered, or a drifted PostToolUse matcher)";
|
|
1253
|
-
|
|
1254
|
-
|
|
1434
|
+
const pinDetail = [
|
|
1435
|
+
continuity.postToolUse.reason && "PostToolUse " + continuity.postToolUse.reason,
|
|
1436
|
+
continuity.stop.reason && "Stop " + continuity.stop.reason,
|
|
1437
|
+
].filter(Boolean).join("; ");
|
|
1438
|
+
const blockers = continuityWriteBlockers(continuity);
|
|
1439
|
+
console.log(` ${render.icons.warn} Continuity capture hooks: ${continuity.state} — ${continuityDetail}${pinDetail ? "; " + pinDetail : ""}`);
|
|
1440
|
+
if (autoFix && blockers.length === 0) {
|
|
1255
1441
|
if (dryRun) {
|
|
1256
1442
|
console.log(` ${render.wrap(render.c.dim, "Would rewrite the continuity capture hooks in")} ${continuity.path}`);
|
|
1257
1443
|
}
|
|
@@ -1275,7 +1461,15 @@ export function register(program) {
|
|
|
1275
1461
|
}
|
|
1276
1462
|
}
|
|
1277
1463
|
else {
|
|
1278
|
-
|
|
1464
|
+
if (blockers.length > 0) {
|
|
1465
|
+
const advice = pinDetail
|
|
1466
|
+
? "Resolve the listed non-version pin(s) manually; doctor cannot rewrite them."
|
|
1467
|
+
: "Continuity hook rewrite held or refused; resolve the listed reason(s) manually.";
|
|
1468
|
+
console.log(` ${advice} ${blockers.join(" ")}`);
|
|
1469
|
+
}
|
|
1470
|
+
else {
|
|
1471
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} flair doctor --fix ${render.wrap(render.c.dim, "(rewrites both entries to the current form — same agent, same instance)")}`);
|
|
1472
|
+
}
|
|
1279
1473
|
}
|
|
1280
1474
|
issues++;
|
|
1281
1475
|
}
|
|
@@ -1505,6 +1699,22 @@ export function register(program) {
|
|
|
1505
1699
|
// Plist unreadable — the launchd plan above already reports presence.
|
|
1506
1700
|
}
|
|
1507
1701
|
}
|
|
1702
|
+
// 7c. Install tree (flair#2034 §2) — after launchd management, so a repair
|
|
1703
|
+
// above has settled which service owns the instance before this asks.
|
|
1704
|
+
console.log(`\n ${render.wrap(render.c.bold, "Install tree")}`);
|
|
1705
|
+
{
|
|
1706
|
+
const treeSection = await runInstallTreeDoctorSection({ autoFix, dryRun }, {
|
|
1707
|
+
assess: () => cli.assessInstallTree(defaultDataDir(), effectivePort, {
|
|
1708
|
+
local: true,
|
|
1709
|
+
runningVersion: effectivePort === port ? instanceVersion : null,
|
|
1710
|
+
}),
|
|
1711
|
+
repoint: (dry) => cli.repointMainServiceUnit(defaultDataDir(), effectivePort, { dryRun: dry }),
|
|
1712
|
+
restart: () => cli.restartFlair(effectivePort, defaultDataDir()),
|
|
1713
|
+
rewriteFederation: (dry) => rewriteFederationSchedulerRuntime({ dryRun: dry }),
|
|
1714
|
+
});
|
|
1715
|
+
issues += treeSection.issues;
|
|
1716
|
+
fixed += treeSection.fixed;
|
|
1717
|
+
}
|
|
1508
1718
|
// 7a. Resolve which agent identities the two verified-read sections below
|
|
1509
1719
|
// (Fleet presence, Migrations) iterate (flair#722). Previously both
|
|
1510
1720
|
// sections required --agent explicitly; doctor already enumerates every
|