@tpsdev-ai/flair 0.59.0 → 0.62.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 +4 -4
- package/SECURITY.md +36 -0
- package/config.yaml +12 -1
- package/dist/bridges/builtins/mem0.js +63 -28
- 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/build-info.json +3 -3
- package/dist/cli.js +991 -248
- package/dist/commands/agent.js +224 -43
- package/dist/commands/attention.js +4 -3
- package/dist/commands/backup.js +202 -34
- package/dist/commands/bridge.js +172 -119
- package/dist/commands/deploy.js +37 -4
- package/dist/commands/doctor.js +592 -146
- package/dist/commands/export.js +54 -19
- package/dist/commands/federation.js +141 -21
- package/dist/commands/hook.js +155 -2
- package/dist/commands/idp.js +14 -1
- package/dist/commands/import.js +7 -3
- package/dist/commands/init.js +462 -193
- package/dist/commands/integrity.js +388 -0
- package/dist/commands/keys.js +247 -58
- package/dist/commands/mcp.js +97 -35
- package/dist/commands/memory.js +171 -21
- package/dist/commands/migrate-harness-memory.js +3 -2
- package/dist/commands/orgevent.js +46 -37
- package/dist/commands/presence.js +4 -3
- package/dist/commands/principal.js +426 -48
- package/dist/commands/quality.js +10 -1
- package/dist/commands/reembed.js +141 -17
- package/dist/commands/relationship.js +2 -1
- package/dist/commands/rem.js +56 -18
- package/dist/commands/restore.js +101 -61
- package/dist/commands/search.js +6 -4
- package/dist/commands/service.js +151 -38
- package/dist/commands/soul.js +4 -3
- package/dist/commands/status.js +43 -5
- package/dist/commands/test.js +3 -2
- package/dist/commands/upgrade.js +24 -1
- package/dist/commands/workspace.js +6 -3
- package/dist/component-env.js +31 -41
- package/dist/deploy.js +77 -1
- package/dist/doctor-client.js +529 -92
- package/dist/engine-version-contract.js +1 -0
- package/dist/engine-version.js +23 -3
- package/dist/federation-verify.js +4 -3
- package/dist/hook-install.js +670 -6
- 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 +46 -0
- package/dist/lib/agent-roster.js +33 -0
- package/dist/lib/auth-resolve.js +49 -16
- package/dist/lib/capture-runtime.js +124 -0
- package/dist/lib/credential-status-rule.js +78 -0
- package/dist/lib/daemon-liveness.js +41 -10
- 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/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/launchd-management.js +24 -0
- 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 +1168 -326
- 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 +2 -0
- package/dist/lib/memory-id-policy.js +46 -0
- package/dist/lib/memory-integrity.js +309 -0
- package/dist/lib/memory-purge-response.js +20 -0
- package/dist/lib/ops-table-count.js +25 -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/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-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-seed-pending.js +24 -0
- package/dist/lib/skill-seed.js +365 -0
- package/dist/lib/stop-start-recovery.js +54 -0
- package/dist/lib/using-flair-skill.js +87 -0
- package/dist/mcp-client-assertion.js +112 -4
- package/dist/memory-id-checkpoint.js +326 -0
- package/dist/memory-node-compare.js +207 -0
- package/dist/packages/flair-mcp/src/secret-redaction.js +113 -0
- package/dist/rem/restore.js +6 -5
- package/dist/rem/runner.js +103 -44
- package/dist/resources/Agent.js +321 -1
- package/dist/resources/AgentKeyRegister.js +214 -0
- package/dist/resources/AgentKeyRegistration.js +28 -0
- package/dist/resources/AgentSeed.js +10 -4
- package/dist/resources/AutoPromoteCandidates.js +7 -1
- package/dist/resources/Credential.js +177 -2
- package/dist/resources/Federation.js +751 -143
- package/dist/resources/FederationRetry.js +140 -0
- package/dist/resources/InstructionVersion.js +220 -0
- package/dist/resources/Integration.js +300 -25
- package/dist/resources/Memory.js +2113 -604
- package/dist/resources/MemoryArchive.js +75 -42
- package/dist/resources/MemoryBootstrap.js +110 -39
- package/dist/resources/MemoryCandidate.js +21 -1
- package/dist/resources/MemoryDedupStats.js +30 -1
- package/dist/resources/MemoryFeed.js +327 -45
- package/dist/resources/MemoryGrant.js +21 -1
- package/dist/resources/MemoryMaintenance.js +129 -25
- package/dist/resources/MemoryPurge.js +232 -0
- package/dist/resources/MemoryReflect.js +7 -2
- package/dist/resources/MemoryReindex.js +24 -8
- package/dist/resources/Message.js +5 -3
- package/dist/resources/OAuth.js +186 -9
- package/dist/resources/OrgEvent.js +126 -3
- package/dist/resources/Presence.js +144 -49
- package/dist/resources/PromoteMemoryCandidate.js +18 -7
- package/dist/resources/Relationship.js +23 -0
- package/dist/resources/SemanticSearch.js +63 -32
- package/dist/resources/Soul.js +189 -76
- package/dist/resources/TeamDirectory.js +35 -0
- package/dist/resources/WorkspaceState.js +21 -1
- package/dist/resources/XAA.js +181 -63
- package/dist/resources/agent-auth.js +40 -15
- package/dist/resources/auth-middleware.js +400 -161
- package/dist/resources/ed25519-auth.js +1 -1
- package/dist/resources/embedding-space-guard.js +366 -72
- package/dist/resources/engine-version-stamp-boot.js +53 -0
- package/dist/resources/federation-classify.js +72 -0
- package/dist/resources/federation-crypto.js +5 -5
- package/dist/resources/federation-retry-lib.js +135 -0
- package/dist/resources/grant-visibility.js +135 -0
- package/dist/resources/harper-routing.js +83 -0
- package/dist/resources/health.js +120 -18
- package/dist/resources/host-source-citation.js +49 -0
- package/dist/resources/host-source-visibility.js +7 -6
- package/dist/resources/instance-create-lock.js +17 -0
- package/dist/resources/instance-identity.js +23 -0
- package/dist/resources/instruction-version-record.js +343 -0
- package/dist/resources/key-lock.js +3 -3
- package/dist/resources/mcp-handler.js +36 -8
- package/dist/resources/mcp-oauth-env-guard.js +36 -0
- package/dist/resources/mcp-oauth.js +23 -6
- package/dist/resources/mcp-tool-arguments.js +4 -6
- package/dist/resources/mcp-tools.js +128 -19
- package/dist/resources/memory-bootstrap-lib.js +5 -15
- package/dist/resources/memory-declared-attributes.js +3 -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 +88 -0
- package/dist/resources/memory-embedding-value.js +8 -0
- package/dist/resources/memory-host-source.js +27 -5
- package/dist/resources/memory-id-guard.js +75 -0
- package/dist/resources/memory-redaction.js +236 -0
- package/dist/resources/memory-supplied-vector.js +72 -0
- package/dist/resources/memory-write-lock.js +310 -0
- package/dist/resources/memory-write-response.js +139 -0
- package/dist/resources/migrations/data-dir.js +74 -16
- package/dist/resources/migrations/dir-safety.js +1 -1
- package/dist/resources/migrations/embedding-stamp.js +193 -79
- package/dist/resources/migrations/export.js +1 -0
- package/dist/resources/migrations/graph-heal.js +18 -25
- package/dist/resources/migrations/lock.js +7 -1
- package/dist/resources/migrations/snapshot.js +1 -0
- package/dist/resources/migrations/source-fields.js +5 -5
- package/dist/resources/migrations/synthetic-test-migration.js +14 -11
- package/dist/resources/migrations/visibility-backfill.js +29 -29
- package/dist/resources/object-body-guard.js +33 -0
- package/dist/resources/org-event-created-at.js +133 -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 +212 -0
- package/dist/resources/owner-scoped-writes.js +58 -0
- package/dist/resources/presence-receipt.js +236 -0
- package/dist/resources/promotion-stamp.js +47 -12
- package/dist/resources/record-owner-guard.js +74 -26
- 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 +136 -0
- package/dist/resources/request-transaction.js +35 -0
- package/dist/resources/search-readiness.js +4 -1
- package/dist/resources/seed-ids.js +9 -0
- package/dist/resources/seed-reservation.js +117 -0
- package/dist/resources/semantic-retrieval-core.js +20 -9
- package/dist/resources/skill-manifest.js +20 -11
- package/dist/resources/skill-subject.js +53 -0
- package/dist/resources/skill-version-write.js +432 -0
- package/dist/resources/skill-write-fault.js +17 -0
- package/dist/resources/skill-write-policy.js +67 -0
- package/dist/resources/skill-write.js +67 -7
- package/dist/resources/table-helpers.js +10 -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 +118 -0
- package/dist/resources/usage-recording.js +171 -63
- package/dist/resources/write-back.js +218 -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 +46 -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/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/mcp-oauth-env-core.js +133 -0
- package/dist/src/lib/memory-attributes.js +2 -0
- package/dist/src/lib/memory-id-policy.js +46 -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/systemd-agent-id.js +38 -0
- package/docs/access-control.md +146 -45
- package/docs/api-reference.md +46 -11
- package/docs/auth.md +6 -12
- package/docs/bridges.md +11 -0
- package/docs/claude-code.md +34 -4
- package/docs/deploying-on-fabric.md +70 -0
- package/docs/deployment.md +2 -0
- package/docs/embedding-in-a-harper-app.md +1 -1
- package/docs/federation.md +33 -2
- package/docs/hosted-on-fabric.md +43 -36
- package/docs/integrations.md +5 -5
- package/docs/mcp-clients.md +5 -2
- package/docs/n8n.md +17 -11
- package/docs/notes/mcp-agent-auth-consumer.md +12 -4
- package/docs/notes/mcp-oauth-model2.md +34 -5
- package/docs/quickstart-fabric.md +2 -2
- package/docs/quickstart.md +9 -1
- package/docs/releasing.md +12 -6
- package/docs/rem.md +8 -0
- package/docs/secrets-and-keys.md +19 -2
- package/docs/standalone-local.md +1 -0
- package/docs/supply-chain-policy.md +13 -3
- package/docs/upgrade.md +32 -6
- package/package.json +10 -5
- package/schemas/agent-key-registration.graphql +22 -0
- package/schemas/agent.graphql +3 -0
- package/schemas/federation.graphql +38 -1
- package/schemas/memory.graphql +84 -5
- package/schemas/oauth.graphql +19 -0
- package/schemas/schema.graphql +2 -0
package/dist/commands/doctor.js
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { makeReadInstanceIds } from "./keys.js";
|
|
2
|
+
import { COMPONENT_ENV_FILENAME, MCP_ISSUER_KEY, PUBLIC_URL_KEY, describePublicUrlFinding, readEnvValue } from "../component-env.js";
|
|
3
|
+
import { readTargetMcpRedirectFinding, mcpOAuthEnabledFromComponentEnv } from "../lib/mcp-oauth-env.js";
|
|
4
|
+
import { checkClaudeMdBootstrap, checkContinuityCaptureHooks, continuityWriteBlockers, describeAgentGateFinding, describeAgentHomeFinding, describeAgentIdRuleFinding, effectiveFlairUrl, embeddingsSkipRemedy, fixClaudeMdBootstrap, fixCommandAgentHint, fixContinuityCaptureHooks, fixSessionStartHook, inspectSessionStartHook, orphanInstanceSeedAdvisory, partitionKeyIds, planAgentIterations, readClientMcpBlock, resolveFixAgentId, resolveWireFlairUrl, upgradeSessionStartHookCommand } from "../doctor-client.js";
|
|
3
5
|
import { markStale, sortOldestVersionFirst } from "../fleet-presence.js";
|
|
4
6
|
import { hookSettingsPath, resolveHookAgentId } from "../hook-install.js";
|
|
5
7
|
import { ALL_CLIENTS, decideCodexPinOnly, decideJsonPinOnly, detectClients, wireAntigravity, wireClaudeCode, wireCodex, wireCursor, wireGemini } from "../install/clients.js";
|
|
6
8
|
import { checkGlobalBinOnPath, resolveNpmGlobalPrefix } from "../install/global-bin-path.js";
|
|
7
|
-
import { buildEd25519Auth, defaultAdminPassPath, defaultKeysDir, resolveAdminUser, resolveKeyPath, resolveLocalAdminPass } from "../lib/auth-resolve.js";
|
|
9
|
+
import { buildEd25519Auth, defaultAdminPassPath, defaultKeysDir, requestTarget, requestUrl, resolveAdminUser, resolveKeyPath, resolveLocalAdminPass } from "../lib/auth-resolve.js";
|
|
10
|
+
import { proveLocalHarperListener } from "../lib/local-instance-pair.js";
|
|
11
|
+
import { AGENT_ID_RULE } from "../lib/agent-id-rule.js";
|
|
12
|
+
import { agentHomeEndpoint, readAgentHomeRows, resolveTargetInstanceIdentity } from "../lib/agent-home.js";
|
|
13
|
+
import { readAgentRoster } from "../lib/agent-roster.js";
|
|
8
14
|
import { flairConfigYamlCandidates, readPortFromYamlFile, resolveFlairConfigYaml } from "../lib/doctor-config-path.js";
|
|
9
15
|
import { collectFederationEnv, describeFederationDriverFinding, federationPeersConfigured, loadYamlDoc } from "../lib/doctor-federation-driver.js";
|
|
10
16
|
import { plistCarriesInlineAdminPassword } from "../lib/launchd-management.js";
|
|
11
17
|
import { DOCTOR_CHECK_IDS, catalogIssueDelta, mcpRepinIcon, probeFlairHealth, renderCatalogDoctorLines, runDoctorChecks } from "../lib/doctor-run.js";
|
|
12
18
|
import { describeEmbedGpuDoctorFinding } from "../lib/embed-gpu-doctor.js";
|
|
19
|
+
import { describeEmbeddingSpaceDoctorFinding } from "../lib/embedding-space-doctor.js";
|
|
13
20
|
import { adminPassDesyncFinding, detectPersistedAdminUser } from "../lib/init-admin-pass.js";
|
|
14
21
|
import { opsApiBindFinding } from "../lib/ops-api-bind.js";
|
|
15
22
|
import { instanceIdentityLines, probeInstanceIdentity, } from "../lib/instance-identity-row.js";
|
|
16
23
|
import { flairCliVersion, unpinnedSpecWarning } from "../lib/mcp-spec.js";
|
|
24
|
+
import { discriminateMcpOAuthDiscovery, reportMcpOAuthDiscovery } from "../lib/mcp-enable.js";
|
|
17
25
|
import { mcpClientPinFindings, refreshOwnedPins, repinSessionStartHookGuarded, sessionStartHookPinFindings } from "../lib/owned-pins.js";
|
|
18
26
|
import * as render from "../render.js";
|
|
19
27
|
import { checkVersion, formatVersionNudge, probeInstanceVersion, FLAIR_PKG_NAME } from "../version-check.js";
|
|
@@ -23,12 +31,89 @@ import { rewriteFederationSchedulerRuntime } from "../federation/scheduler.js";
|
|
|
23
31
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
24
32
|
import { dirname, join } from "node:path";
|
|
25
33
|
import { resolveHome } from "../lib/home.js";
|
|
34
|
+
export async function fetchAndRenderMigrations(healthDetailUrl, headers, indent) {
|
|
35
|
+
let issues = 0;
|
|
36
|
+
try {
|
|
37
|
+
const migRes = await fetch(healthDetailUrl, { headers, signal: AbortSignal.timeout(5000) });
|
|
38
|
+
if (!migRes.ok) {
|
|
39
|
+
console.log(`${indent}${render.icons.warn} Could not fetch migration state (HTTP ${migRes.status})`);
|
|
40
|
+
return issues;
|
|
41
|
+
}
|
|
42
|
+
const detail = (await migRes.json());
|
|
43
|
+
const migBlock = detail?.migrations;
|
|
44
|
+
if (!migBlock || !Array.isArray(migBlock.migrations) || migBlock.migrations.length === 0) {
|
|
45
|
+
console.log(`${indent}${render.icons.info} No migrations registered on this instance`);
|
|
46
|
+
return issues;
|
|
47
|
+
}
|
|
48
|
+
if (migBlock.cyclePhase === "pre-hash") {
|
|
49
|
+
console.log(`${indent}${render.icons.info} Pre-flight integrity check in progress — migrations deferred until it completes`);
|
|
50
|
+
}
|
|
51
|
+
// flair#812: the boot trigger sets `scheduled` synchronously at
|
|
52
|
+
// module load, so `idle` means resources/migration-boot.js never
|
|
53
|
+
// loaded in the serving process — NO migration will ever run on
|
|
54
|
+
// this instance, which is precisely the failure that went unnoticed
|
|
55
|
+
// because a skipped cycle looked identical to a clean one.
|
|
56
|
+
if (migBlock.cyclePhase === "idle") {
|
|
57
|
+
console.log(`${indent}${render.icons.error} Migration boot cycle never fired on this instance — no migration will run until this is resolved. Check the instance log for [flair-migrations] and confirm the running build ships dist/resources/migration-boot.js.`);
|
|
58
|
+
issues++;
|
|
59
|
+
}
|
|
60
|
+
if (migBlock.lastCycleError) {
|
|
61
|
+
console.log(`${indent}${render.icons.error} Last migration cycle did not complete: ${migBlock.lastCycleError}`);
|
|
62
|
+
issues++;
|
|
63
|
+
}
|
|
64
|
+
for (const m of migBlock.migrations) {
|
|
65
|
+
if (m.state === "completed") {
|
|
66
|
+
// Print the state-file short-circuit qualification (flair#812).
|
|
67
|
+
const note = m.reason ? ` ${render.wrap(render.c.dim, `(${m.reason})`)}` : "";
|
|
68
|
+
console.log(`${indent}${render.icons.ok} ${m.id}: completed${note}`);
|
|
69
|
+
}
|
|
70
|
+
else if (m.state === "halted" || m.state === "failed") {
|
|
71
|
+
console.log(`${indent}${render.icons.error} ${m.id}: ${m.state}${m.reason ? ` — ${m.reason}` : ""}`);
|
|
72
|
+
issues++;
|
|
73
|
+
}
|
|
74
|
+
else if (m.state === "running") {
|
|
75
|
+
console.log(`${indent}${render.icons.info} ${m.id}: in progress (${m.rowsDone} done, ${m.rowsRemaining} remaining)`);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.log(`${indent}${render.icons.info} ${m.id}: ${m.state}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
console.log(`${indent}${render.icons.warn} Migration state check failed: ${err?.message ?? err}`);
|
|
84
|
+
}
|
|
85
|
+
return issues;
|
|
86
|
+
}
|
|
87
|
+
export async function readNodeSeedAdvisory(input) {
|
|
88
|
+
if (input.nodeKeyIds.length === 0)
|
|
89
|
+
return null;
|
|
90
|
+
const read = await makeReadInstanceIds(input)();
|
|
91
|
+
return orphanInstanceSeedAdvisory({
|
|
92
|
+
...input,
|
|
93
|
+
instanceIds: read.state === "read" ? read.ids : null,
|
|
94
|
+
agentIds: read.state === "read" ? read.agentIds : null,
|
|
95
|
+
unreadableReason: read.state === "read" ? read.agentReadReason : read.reason,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
26
98
|
let cli;
|
|
27
99
|
/** Bind the cli-locals this module depends on. */
|
|
28
100
|
export function bindCli(fns) {
|
|
29
101
|
cli = fns;
|
|
30
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* flair#2526: true while doctor's HTTP-port gate is `http-only` (the probed
|
|
105
|
+
* port's listener is proven but the HTTP/ops pair is not). Every `api()` call
|
|
106
|
+
* doctor makes then runs with the shared resolver's `signedOnly` transport:
|
|
107
|
+
* no Authorization header or an Ed25519 signature; never a Basic or Bearer
|
|
108
|
+
* header, from any source. Set by the doctor action each time it decides the
|
|
109
|
+
* gate.
|
|
110
|
+
*/
|
|
111
|
+
let signedOnlyTransport = false;
|
|
31
112
|
function api(...args) {
|
|
113
|
+
if (signedOnlyTransport) {
|
|
114
|
+
const options = args[3] && typeof args[3] === "object" ? args[3] : {};
|
|
115
|
+
args[3] = { ...options, signedOnly: true };
|
|
116
|
+
}
|
|
32
117
|
return cli.api(...args);
|
|
33
118
|
}
|
|
34
119
|
function checkAgentRegistered(...args) {
|
|
@@ -73,6 +158,67 @@ function repairLaunchdManagement(...args) {
|
|
|
73
158
|
function resolveHttpPort(...args) {
|
|
74
159
|
return cli.resolveHttpPort(...args);
|
|
75
160
|
}
|
|
161
|
+
function verifyDoctorRosterInstance(...args) {
|
|
162
|
+
return cli.verifyDoctorRosterInstance(...args);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Whether `url` uses `httpPort`, the port the pair check proves, on ANY host,
|
|
166
|
+
* so a credentialed request to it waits for that check. The host is not
|
|
167
|
+
* compared: alternate host spellings and the wildcard address (`0.0.0.0`,
|
|
168
|
+
* `localhost.`, an IPv4-mapped address) can reach the probed listener under
|
|
169
|
+
* names no list can enumerate, so the gate conservatively holds any URL on
|
|
170
|
+
* the probed port, whatever its host, without claiming that every spelling
|
|
171
|
+
* reaches the listener. An unparseable URL is held too.
|
|
172
|
+
*/
|
|
173
|
+
export function targetsProbedHttpPort(url, httpPort) {
|
|
174
|
+
let parsed;
|
|
175
|
+
try {
|
|
176
|
+
parsed = new URL(url);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
const port = parsed.port === "" ? (parsed.protocol === "https:" ? 443 : 80) : Number(parsed.port);
|
|
182
|
+
return port === httpPort;
|
|
183
|
+
}
|
|
184
|
+
/** What doctor prints when it has no admin credential to run the pair check with. */
|
|
185
|
+
const DOCTOR_PAIR_NO_CREDENTIAL_REMEDY = "Set FLAIR_ADMIN_PASS, or restore ~/.flair/admin-pass (`flair init` writes it), so doctor can read the ops "
|
|
186
|
+
+ "endpoint's configuration, then re-run flair doctor.";
|
|
187
|
+
/**
|
|
188
|
+
* Derive the HTTP-port gate (flair#2526) from the probed target flair#2520
|
|
189
|
+
* resolves (the admin credential and `verifyDoctorRosterInstance`'s answer for
|
|
190
|
+
* it, which includes the live-process pair proof). A proven pair runs; a pair
|
|
191
|
+
* check that ran and refused holds every credentialed request. When the pair
|
|
192
|
+
* could not be checked for want of a usable admin credential, the probed
|
|
193
|
+
* port's own listener is proven without any credential instead.
|
|
194
|
+
*/
|
|
195
|
+
function decideDoctorPairGate(probed, probedHttpPort, proveListener = proveLocalHarperListener) {
|
|
196
|
+
const read = probed.read;
|
|
197
|
+
if (read?.kind === "run")
|
|
198
|
+
return read;
|
|
199
|
+
if (read?.kind === "not-run" && read.credentialRefused !== true) {
|
|
200
|
+
return { kind: "not-run", reason: read.reason, remedy: read.remedy };
|
|
201
|
+
}
|
|
202
|
+
const unchecked = read !== null
|
|
203
|
+
? { reason: read.reason, remedy: read.remedy }
|
|
204
|
+
: probed.credIssue !== null
|
|
205
|
+
? {
|
|
206
|
+
reason: `the admin credential could not be resolved (${probed.credIssue}), so the HTTP/ops pair check could not run`,
|
|
207
|
+
remedy: DOCTOR_PAIR_NO_CREDENTIAL_REMEDY,
|
|
208
|
+
}
|
|
209
|
+
: {
|
|
210
|
+
reason: "no admin credential to read the ops endpoint's configuration with, so the HTTP/ops pair check could not run",
|
|
211
|
+
remedy: DOCTOR_PAIR_NO_CREDENTIAL_REMEDY,
|
|
212
|
+
};
|
|
213
|
+
const listener = proveListener(probedHttpPort);
|
|
214
|
+
if (listener.kind === "proven")
|
|
215
|
+
return { kind: "http-only", ...unchecked };
|
|
216
|
+
return {
|
|
217
|
+
kind: "not-run",
|
|
218
|
+
reason: `${unchecked.reason}; nor is the HTTP port's own listener proven (${listener.detail})`,
|
|
219
|
+
remedy: listener.remedy ?? unchecked.remedy,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
76
222
|
function resolveOpsPort(...args) {
|
|
77
223
|
return cli.resolveOpsPort(...args);
|
|
78
224
|
}
|
|
@@ -132,6 +278,25 @@ export function renderEmbedGpuDoctorFinding(embedding, write = (line) => console
|
|
|
132
278
|
write(line);
|
|
133
279
|
return { lines, issueDelta: finding.isIssue ? 1 : 0 };
|
|
134
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* flair#2530 — the single place a /Health embedding-space verdict becomes doctor
|
|
283
|
+
* output and exit-code weight, extracted like renderEmbedGpuDoctorFinding so the
|
|
284
|
+
* four states are exercised on the real counting path. Only the `mixed` state is
|
|
285
|
+
* a blocking finding; `uniform` prints an OK line and the two unverified states
|
|
286
|
+
* print advisories.
|
|
287
|
+
*/
|
|
288
|
+
export function renderEmbeddingSpaceDoctorFinding(embeddingSpace, write = (line) => console.log(line)) {
|
|
289
|
+
const finding = describeEmbeddingSpaceDoctorFinding(embeddingSpace);
|
|
290
|
+
if (!finding)
|
|
291
|
+
return { lines: [], issueDelta: 0 };
|
|
292
|
+
const icon = finding.icon === "ok" ? render.icons.ok : finding.icon === "warn" ? render.icons.warn : render.icons.error;
|
|
293
|
+
const lines = [` ${icon} ${finding.message}`];
|
|
294
|
+
if (finding.fixHint)
|
|
295
|
+
lines.push(` ${render.wrap(render.c.dim, "Fix:")} ${finding.fixHint}`);
|
|
296
|
+
for (const line of lines)
|
|
297
|
+
write(line);
|
|
298
|
+
return { lines, issueDelta: finding.isIssue ? 1 : 0 };
|
|
299
|
+
}
|
|
135
300
|
/**
|
|
136
301
|
* flair#2034 §2 — the "Install tree" doctor section: is the instance served
|
|
137
302
|
* from this CLI's install tree, and does the federation-sync shim run it?
|
|
@@ -287,6 +452,7 @@ export function register(program) {
|
|
|
287
452
|
.option("--fix", "Automatically fix issues where possible")
|
|
288
453
|
.option("--dry-run", "Show what --fix would do without making changes")
|
|
289
454
|
.action(async (opts) => {
|
|
455
|
+
signedOnlyTransport = false; // flair#2526: decided per run, below
|
|
290
456
|
const port = resolveHttpPort(opts);
|
|
291
457
|
const autoFix = opts.fix ?? false;
|
|
292
458
|
const dryRun = opts.dryRun ?? false;
|
|
@@ -432,7 +598,24 @@ export function register(program) {
|
|
|
432
598
|
console.log(` ${render.icons.warn} PID file contains non-numeric value: ${render.wrap(render.c.dim, pidFile0)} — skipping`);
|
|
433
599
|
}
|
|
434
600
|
}
|
|
435
|
-
|
|
601
|
+
// flair#2530: a readiness 503 whose body has Flair's /Health fields (see
|
|
602
|
+
// readFlairHealthBody) is reported as Flair answering without serving
|
|
603
|
+
// search. It is an issue, never "responding", so the checks that need a
|
|
604
|
+
// serving instance stay skipped; its body still carries the version and the
|
|
605
|
+
// embedding-space guard state, read in 1a below. It is checked BEFORE
|
|
606
|
+
// `reaching`: a 503 can carry a multi-worker refusal too, which makes the
|
|
607
|
+
// probe `reaching`, but search is still not served. The worker-thread
|
|
608
|
+
// finding is reported separately by the catalog check.
|
|
609
|
+
let flairNotReady = false;
|
|
610
|
+
const configuredProbe = await probeFlairHealth(`http://127.0.0.1:${port}/Health`);
|
|
611
|
+
if (configuredProbe.notReady) {
|
|
612
|
+
const why = configuredProbe.notReadyReason ? ` (${configuredProbe.notReadyReason})` : "";
|
|
613
|
+
console.log(` ${render.icons.error} Flair is answering on port ${render.wrap(render.c.bold, String(port))} but not serving search${why}`);
|
|
614
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} wait for startup to finish; if it persists, flair restart`);
|
|
615
|
+
flairNotReady = true;
|
|
616
|
+
issues++;
|
|
617
|
+
}
|
|
618
|
+
else if (configuredProbe.reaching) {
|
|
436
619
|
console.log(` ${render.icons.ok} Harper responding on port ${render.wrap(render.c.bold, String(port))}`);
|
|
437
620
|
harperResponding = true;
|
|
438
621
|
}
|
|
@@ -527,17 +710,21 @@ export function register(program) {
|
|
|
527
710
|
// picture here instead of a one-liner and `--fix` offers the restart.
|
|
528
711
|
let runningVersion = null;
|
|
529
712
|
let embedGpuFromHealth;
|
|
713
|
+
let embeddingSpaceFromHealth;
|
|
530
714
|
let workerThreads;
|
|
531
|
-
if (harperResponding) {
|
|
715
|
+
if (harperResponding || flairNotReady) {
|
|
532
716
|
try {
|
|
533
717
|
const probe = await probeFlairHealth(`${baseUrl}/Health`);
|
|
534
|
-
if (probe.reaching)
|
|
718
|
+
if (probe.reaching)
|
|
535
719
|
workerThreads = probe.observation ?? undefined;
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
720
|
+
// A 2xx body, or a 503 body with Flair's /Health fields (flair#2530).
|
|
721
|
+
// Reading a 503 body does not make it healthy; the port check or the
|
|
722
|
+
// worker-threads check counts it.
|
|
723
|
+
if (probe.healthBody) {
|
|
724
|
+
const healthBody = probe.healthBody;
|
|
725
|
+
runningVersion = typeof healthBody.version === "string" ? healthBody.version : null;
|
|
726
|
+
embedGpuFromHealth = healthBody.embedding;
|
|
727
|
+
embeddingSpaceFromHealth = healthBody.embeddingSpace;
|
|
541
728
|
}
|
|
542
729
|
}
|
|
543
730
|
catch { /* leave runningVersion null — reported below as "unknown" */ }
|
|
@@ -576,6 +763,89 @@ export function register(program) {
|
|
|
576
763
|
// does NOT fail the run, while an explicit request or an unrecognized
|
|
577
764
|
// source still fails closed. A stated CPU default is silent here.
|
|
578
765
|
issues += renderEmbedGpuDoctorFinding(embedGpuFromHealth).issueDelta;
|
|
766
|
+
// flair#2530 — the embedding-space guard's verdict, from /Health. The
|
|
767
|
+
// `mixed` state is a blocking finding; the two unverified states are advisories.
|
|
768
|
+
issues += renderEmbeddingSpaceDoctorFinding(embeddingSpaceFromHealth).issueDelta;
|
|
769
|
+
}
|
|
770
|
+
// flair#2520: the audit-log, instance-identity, Agent-roster and Agent-homes
|
|
771
|
+
// reads go through an ops endpoint, which must belong to the instance doctor
|
|
772
|
+
// probed. Resolve the admin credential and verify that target with it here,
|
|
773
|
+
// using the pair check flair#2483 applies (with flair#2526's live-process
|
|
774
|
+
// proof). The order is: pair proof, then (only when the pair is proven)
|
|
775
|
+
// the Basic `/Instance/` identity read on the probed HTTP port, then the
|
|
776
|
+
// gate below for the later diagnostic requests. Diagnostic reads that run use
|
|
777
|
+
// the verified target; pairing refusals report NOT RUN with the shared
|
|
778
|
+
// reason and remedy, and existing UNVERIFIED/skipped outcomes remain. With
|
|
779
|
+
// no resolvable admin password there is no target (`read` null) and no ops
|
|
780
|
+
// endpoint is read. A resolved password that the ops endpoint rejects
|
|
781
|
+
// (HTTP 401/403) has been sent there, and the answer is `not-run`. `effectivePort` is final: PID discovery (step 1) and any
|
|
782
|
+
// --fix re-record have already run. This answer describes the credential
|
|
783
|
+
// and the process serving the probed port at this point, so it is shared
|
|
784
|
+
// only until a --fix step may change either: the launchd repair (7b, which
|
|
785
|
+
// can also write the admin-pass file from HDB_ADMIN_PASSWORD) and the
|
|
786
|
+
// install-tree restart (7c), both below. Those steps set
|
|
787
|
+
// `servingProcessMayHaveChanged`; the credential is then resolved again
|
|
788
|
+
// and, when one is available, the target verified with it, once, right
|
|
789
|
+
// after those steps (7a), and the Agent-roster and Agent-homes checks and
|
|
790
|
+
// the later credentialed HTTP reads use only that answer.
|
|
791
|
+
async function resolveProbedTarget() {
|
|
792
|
+
let adminPass;
|
|
793
|
+
let credIssue = null;
|
|
794
|
+
try {
|
|
795
|
+
adminPass = resolveLocalAdminPass(undefined);
|
|
796
|
+
}
|
|
797
|
+
catch (err) {
|
|
798
|
+
credIssue = err instanceof Error ? err.message : String(err);
|
|
799
|
+
}
|
|
800
|
+
const read = adminPass
|
|
801
|
+
? await verifyDoctorRosterInstance(opts, effectivePort, adminPass)
|
|
802
|
+
: null;
|
|
803
|
+
return { adminPass, credIssue, read };
|
|
804
|
+
}
|
|
805
|
+
const probed = harperResponding
|
|
806
|
+
? await resolveProbedTarget()
|
|
807
|
+
: { adminPass: undefined, credIssue: null, read: null };
|
|
808
|
+
const { adminPass: probedAdminPass, credIssue: probedCredIssue, read: probedRead } = probed;
|
|
809
|
+
let servingProcessMayHaveChanged = false;
|
|
810
|
+
// flair#2526: doctor sends a credential to the probed HTTP port only after
|
|
811
|
+
// that port is proven. The pair proof above runs before any credentialed
|
|
812
|
+
// HTTP request (its own Basic `/Instance/` identity read follows only a
|
|
813
|
+
// proven pair). The gate is derived from that answer (decideDoctorPairGate)
|
|
814
|
+
// for the later diagnostic requests. Unauthenticated reads
|
|
815
|
+
// (/Health, /OAuthMetadata, OAuth discovery, an unsigned /Presence) do not
|
|
816
|
+
// wait for it.
|
|
817
|
+
// - `run` (the HTTP/ops pair is proven): the gate permits every section;
|
|
818
|
+
// each section's own prerequisites still apply.
|
|
819
|
+
// - `http-only` (no usable admin credential to check the pair with, but
|
|
820
|
+
// the probed port's listener passes the listener-only check): requests
|
|
821
|
+
// to the HTTP port are permitted with no Authorization header or an
|
|
822
|
+
// Ed25519 signature; never Basic or Bearer. Every
|
|
823
|
+
// api() call runs signedOnly, so no Basic or Bearer header goes out from
|
|
824
|
+
// any source (FLAIR_TOKEN, FLAIR_ADMIN_PASS, HDB_ADMIN_PASSWORD, the
|
|
825
|
+
// admin-pass file). flair#2270: `doctor --agent` with an unusable
|
|
826
|
+
// ambient credential still reads the redirect state. Sections that join
|
|
827
|
+
// the HTTP port with the ops endpoint are not permitted.
|
|
828
|
+
// - `not-run`: later credentialed HTTP requests are held. Fully held
|
|
829
|
+
// diagnostic sections report NOT RUN; Scheduled drivers skips the live
|
|
830
|
+
// `/FederationPeers` read and continues using configured peers.
|
|
831
|
+
// After a --fix step that may change the serving process, the gate is
|
|
832
|
+
// derived again from the re-resolved target (7a below).
|
|
833
|
+
let pairGate = harperResponding ? decideDoctorPairGate(probed, effectivePort) : null;
|
|
834
|
+
/** Why the HTTP/ops pair is unproven (`http-only` or `not-run`), else null. */
|
|
835
|
+
let pairNotRun = pairGate !== null && pairGate.kind !== "run" ? pairGate : null;
|
|
836
|
+
/** Whether requests to the probed HTTP port are held. */
|
|
837
|
+
let httpHeld = pairGate?.kind === "not-run";
|
|
838
|
+
signedOnlyTransport = pairGate?.kind === "http-only";
|
|
839
|
+
let pairRemedyShown = false;
|
|
840
|
+
/** Print `<label>: NOT RUN — <reason>`, with the remedy the first time. */
|
|
841
|
+
function reportPairNotRun(label, indent = " ") {
|
|
842
|
+
if (!pairNotRun)
|
|
843
|
+
return;
|
|
844
|
+
console.log(`${indent}${render.icons.warn} ${label}: NOT RUN — ${pairNotRun.reason}`);
|
|
845
|
+
if (!pairRemedyShown) {
|
|
846
|
+
console.log(`${indent} ${render.wrap(render.c.dim, "Fix:")} ${pairNotRun.remedy}`);
|
|
847
|
+
pairRemedyShown = true;
|
|
848
|
+
}
|
|
579
849
|
}
|
|
580
850
|
// 2. Keys directory
|
|
581
851
|
const keysDir = defaultKeysDir();
|
|
@@ -609,6 +879,18 @@ export function register(program) {
|
|
|
609
879
|
console.log(` ${render.wrap(render.c.dim, "Fix:")} flair init --agent-id <your-agent>`);
|
|
610
880
|
issues++;
|
|
611
881
|
}
|
|
882
|
+
if (nodeKeyIds.length > 0 && harperResponding) {
|
|
883
|
+
if (pairNotRun) {
|
|
884
|
+
reportPairNotRun("Node key instance check");
|
|
885
|
+
}
|
|
886
|
+
else {
|
|
887
|
+
const advisory = await readNodeSeedAdvisory({
|
|
888
|
+
nodeKeyIds, keysDir, baseUrl, port: opts.port, resolveHttpPort, resolveOpsPort,
|
|
889
|
+
});
|
|
890
|
+
if (advisory)
|
|
891
|
+
console.log(` ${render.icons.info} ${advisory}`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
612
894
|
}
|
|
613
895
|
else {
|
|
614
896
|
console.log(` ${render.icons.error} Keys directory missing: ${render.wrap(render.c.dim, keysDir)}`);
|
|
@@ -661,16 +943,29 @@ export function register(program) {
|
|
|
661
943
|
// The remedy names the two exits: `--admin-pass-file` / `--reset-admin-pass`.
|
|
662
944
|
try {
|
|
663
945
|
const dataDir = defaultDataDir();
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
persistedAdminUser
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
console.log(` ${render.wrap(render.c.dim, finding.remedy)}`);
|
|
946
|
+
let persistedAdminUser;
|
|
947
|
+
try {
|
|
948
|
+
persistedAdminUser = detectPersistedAdminUser(dataDir);
|
|
949
|
+
}
|
|
950
|
+
catch {
|
|
951
|
+
persistedAdminUser = null;
|
|
952
|
+
}
|
|
953
|
+
if (persistedAdminUser === null) {
|
|
673
954
|
issues++;
|
|
955
|
+
console.log(` ${render.icons.warn} ${render.wrap(render.c.yellow, `could not read the Harper system database under ${dataDir} to tell whether an admin user is persisted — not assessing the admin-pass desync`)}`);
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
const finding = adminPassDesyncFinding({
|
|
959
|
+
adminPassFileExists: existsSync(defaultAdminPassPath()),
|
|
960
|
+
persistedAdminUser,
|
|
961
|
+
dataDir,
|
|
962
|
+
adminPassPath: defaultAdminPassPath(),
|
|
963
|
+
});
|
|
964
|
+
if (finding?.flagged) {
|
|
965
|
+
console.log(` ${render.icons.error} ${finding.message}`);
|
|
966
|
+
console.log(` ${render.wrap(render.c.dim, finding.remedy)}`);
|
|
967
|
+
issues++;
|
|
968
|
+
}
|
|
674
969
|
}
|
|
675
970
|
}
|
|
676
971
|
catch { /* best-effort — a missing data dir is not a doctor crash */ }
|
|
@@ -720,13 +1015,14 @@ export function register(program) {
|
|
|
720
1015
|
// READs it for drift detection, but describePublicUrlFinding never names
|
|
721
1016
|
// it as the fix (flair#1313 — wiped on every upgrade).
|
|
722
1017
|
const componentEnvPath = join(flairPackageDir(), COMPONENT_ENV_FILENAME);
|
|
723
|
-
let
|
|
1018
|
+
let componentEnvText = null;
|
|
724
1019
|
try {
|
|
725
|
-
if (existsSync(componentEnvPath))
|
|
726
|
-
|
|
727
|
-
}
|
|
1020
|
+
if (existsSync(componentEnvPath))
|
|
1021
|
+
componentEnvText = readFileSync(componentEnvPath, "utf-8");
|
|
728
1022
|
}
|
|
729
1023
|
catch { /* unreadable → treat as absent */ }
|
|
1024
|
+
const componentEnvValue = readEnvValue(componentEnvText, PUBLIC_URL_KEY);
|
|
1025
|
+
const componentMcpIssuer = readEnvValue(componentEnvText, MCP_ISSUER_KEY);
|
|
730
1026
|
const finding = describePublicUrlFinding({
|
|
731
1027
|
advertisedIssuer,
|
|
732
1028
|
componentEnvValue,
|
|
@@ -743,6 +1039,41 @@ export function register(program) {
|
|
|
743
1039
|
if (finding.isIssue)
|
|
744
1040
|
issues++;
|
|
745
1041
|
}
|
|
1042
|
+
const mcpRedirectFinding = httpHeld
|
|
1043
|
+
? null
|
|
1044
|
+
: await readTargetMcpRedirectFinding(() => api("GET", "/HealthDetail", undefined, {
|
|
1045
|
+
baseUrl,
|
|
1046
|
+
keysDir: defaultKeysDir(),
|
|
1047
|
+
...(opts.agent ? { agentId: opts.agent, agentIdSource: "flag" } : {}),
|
|
1048
|
+
}));
|
|
1049
|
+
if (httpHeld)
|
|
1050
|
+
reportPairNotRun("MCP OAuth redirect");
|
|
1051
|
+
if (mcpRedirectFinding) {
|
|
1052
|
+
console.log(` ${mcpRedirectFinding.isIssue ? render.icons.error : render.icons.warn} ${mcpRedirectFinding.message}`);
|
|
1053
|
+
if (mcpRedirectFinding.fixHint)
|
|
1054
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${mcpRedirectFinding.fixHint}`);
|
|
1055
|
+
if (mcpRedirectFinding.isIssue)
|
|
1056
|
+
issues++;
|
|
1057
|
+
}
|
|
1058
|
+
// flair#2283: share enable's discovery discriminator and infer report severity locally.
|
|
1059
|
+
const discovery = await discriminateMcpOAuthDiscovery(baseUrl, {
|
|
1060
|
+
expectedIssuers: [componentMcpIssuer, componentEnvValue, process.env.FLAIR_MCP_ISSUER, process.env.FLAIR_PUBLIC_URL].filter((issuer) => typeof issuer === "string" && issuer.trim() !== ""),
|
|
1061
|
+
});
|
|
1062
|
+
const discoveryReport = reportMcpOAuthDiscovery(discovery, mcpOAuthEnabledFromComponentEnv(componentEnvText, process.env));
|
|
1063
|
+
const discoveryIcons = {
|
|
1064
|
+
ok: render.icons.ok,
|
|
1065
|
+
info: render.icons.info,
|
|
1066
|
+
warn: render.icons.warn,
|
|
1067
|
+
error: render.icons.error,
|
|
1068
|
+
};
|
|
1069
|
+
discoveryReport.lines.forEach((line, index) => {
|
|
1070
|
+
console.log(index === 0 ? ` ${discoveryIcons[discoveryReport.severity]} ${line}` : ` ${line}`);
|
|
1071
|
+
});
|
|
1072
|
+
if (discoveryReport.severity === "error")
|
|
1073
|
+
issues++;
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
console.log(` ${render.icons.warn} MCP OAuth redirect: cannot verify target configuration`);
|
|
746
1077
|
}
|
|
747
1078
|
// 4. Embeddings check — REAL semantic round-trip (only if Harper is responding).
|
|
748
1079
|
//
|
|
@@ -754,7 +1085,10 @@ export function register(program) {
|
|
|
754
1085
|
// "no issues found". This now stores a memory with a distinctive phrase and
|
|
755
1086
|
// searches for a PARAPHRASE (no shared keywords). If the top result isn't
|
|
756
1087
|
// recovered by MEANING, recall-by-meaning is broken and doctor FAILS LOUDLY.
|
|
757
|
-
if (harperResponding) {
|
|
1088
|
+
if (harperResponding && httpHeld) {
|
|
1089
|
+
reportPairNotRun("Embeddings");
|
|
1090
|
+
}
|
|
1091
|
+
else if (harperResponding) {
|
|
758
1092
|
const semanticStatus = await verifySemanticSearch(baseUrl, opts.agent, defaultKeysDir());
|
|
759
1093
|
switch (semanticStatus.state) {
|
|
760
1094
|
case "ok":
|
|
@@ -807,51 +1141,63 @@ export function register(program) {
|
|
|
807
1141
|
// agent's Ed25519 header cannot authenticate — resolve the local admin
|
|
808
1142
|
// credential (env or ~/.flair/admin-pass; never prompts). A file with
|
|
809
1143
|
// unsafe permissions throws — that is "could not probe", not "broken".
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
try {
|
|
813
|
-
auditAdminPass = resolveLocalAdminPass(undefined);
|
|
1144
|
+
if (probedCredIssue) {
|
|
1145
|
+
console.log(` ${render.icons.warn} Audit log: UNVERIFIED (could not probe — ${probedCredIssue})`);
|
|
814
1146
|
}
|
|
815
|
-
|
|
816
|
-
|
|
1147
|
+
else if (probedRead?.kind === "not-run") {
|
|
1148
|
+
// flair#2520: the pair-refused target the instance-identity section
|
|
1149
|
+
// also uses (and the roster and home sections, unless a --fix step
|
|
1150
|
+
// makes them verify again); name why and the remedy, and count it. This
|
|
1151
|
+
// section's diagnostic read does not run.
|
|
1152
|
+
issues++;
|
|
1153
|
+
console.log(` ${render.icons.warn} Audit log: NOT RUN — ${probedRead.reason}`);
|
|
1154
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${probedRead.remedy}`);
|
|
817
1155
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1156
|
+
else if (httpHeld) {
|
|
1157
|
+
// flair#2526: the probe writes through the HTTP port, which is not
|
|
1158
|
+
// proven, so nothing credentialed goes to it.
|
|
1159
|
+
reportPairNotRun("Audit log");
|
|
1160
|
+
}
|
|
1161
|
+
else {
|
|
1162
|
+
// A verified target, or null with no admin credential. With none,
|
|
1163
|
+
// verifyAuditLog answers its no-credential/no-agent skip before it would
|
|
1164
|
+
// address the ops URL, so the empty URL is never fetched.
|
|
1165
|
+
const auditStatus = await verifyAuditLog(baseUrl, opts.agent, defaultKeysDir(), probedRead ? `http://127.0.0.1:${probedRead.opsPort}` : "", resolveAdminUser(undefined), probedAdminPass);
|
|
1166
|
+
switch (auditStatus.state) {
|
|
1167
|
+
case "ok":
|
|
1168
|
+
// Present-tense claim ONLY (see AuditVerifyResult): the probe
|
|
1169
|
+
// proves the log records writes NOW — never that history is
|
|
1170
|
+
// complete. Overclaiming here would rebuild the false trust
|
|
1171
|
+
// anchor this check exists to kill, one layer up.
|
|
1172
|
+
console.log(` ${render.icons.ok} Audit log: recording (verified now) ${render.wrap(render.c.dim, "(verifies current recording, not history — a resynced node's audit has a hard start boundary at its copy time)")}`);
|
|
1173
|
+
break;
|
|
1174
|
+
case "degraded":
|
|
1175
|
+
if (auditStatus.cause === "disabled") {
|
|
1176
|
+
console.log(` ${render.icons.error} Audit log DISABLED ${render.wrap(render.c.dim, `— ${auditStatus.detail}`)}`);
|
|
1177
|
+
console.log(` ${render.wrap(render.c.dim, "Fix: enable logging.auditLog in the ROOT harperdb-config.yaml (the Harper instance config, NOT flair's component config.yaml), then restart Harper.")}`);
|
|
1178
|
+
}
|
|
1179
|
+
else {
|
|
1180
|
+
console.log(` ${render.icons.error} Audit log NOT RECORDING ${render.wrap(render.c.dim, `— ${auditStatus.detail}`)}`);
|
|
1181
|
+
console.log(` ${render.wrap(render.c.red, "Audit reports as enabled, but fresh writes produced no audit entries — do not treat the audit log as a record of what happened.")}`);
|
|
1182
|
+
console.log(` ${render.wrap(render.c.dim, "On a node that joined or resynced via cluster base copy, audit history has a hard start boundary at copy time (harper#2212) — \"no history\" does not mean \"nothing happened\".")}`);
|
|
1183
|
+
console.log(` ${render.wrap(render.c.dim, "Check logging.auditLog in the ROOT harperdb-config.yaml (not flair's component config.yaml), then restart Harper.")}`);
|
|
1184
|
+
}
|
|
1185
|
+
issues++;
|
|
1186
|
+
break;
|
|
1187
|
+
case "failed":
|
|
1188
|
+
// Same loud discipline as the embeddings probe above (flair#1501).
|
|
1189
|
+
console.log(` ${render.icons.error} Audit log: probe rejected ${render.wrap(render.c.dim, `— ${auditStatus.detail}`)}`);
|
|
1190
|
+
console.log(` ${render.wrap(render.c.dim, "Fix: register this key on the instance (`flair agent add <id>`) or pass --agent <a registered agent id>.")}`);
|
|
1191
|
+
issues++;
|
|
1192
|
+
break;
|
|
1193
|
+
case "skipped":
|
|
1194
|
+
// An unrun check must not look like a pass — UNVERIFIED, visually
|
|
1195
|
+
// distinct from ok, but not a hard issue (mirrors the embeddings
|
|
1196
|
+
// skip: the operator may simply have no agent or no local admin
|
|
1197
|
+
// credential on this box).
|
|
1198
|
+
console.log(` ${render.icons.warn} Audit log: UNVERIFIED (could not probe — ${auditStatus.detail})`);
|
|
1199
|
+
break;
|
|
1200
|
+
}
|
|
855
1201
|
}
|
|
856
1202
|
}
|
|
857
1203
|
// 4c. Instance identity (flair#1883). A hub's identity is ONE
|
|
@@ -869,21 +1215,28 @@ export function register(program) {
|
|
|
869
1215
|
// unreadable leaves the pairing-role check UNVERIFIED while the row facts
|
|
870
1216
|
// are still reported — a green line would claim a check that did not run.
|
|
871
1217
|
if (harperResponding) {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
try {
|
|
875
|
-
identityAdminPass = resolveLocalAdminPass(undefined);
|
|
1218
|
+
if (probedCredIssue) {
|
|
1219
|
+
console.log(` ${render.icons.warn} Instance identity: UNVERIFIED (could not probe — ${probedCredIssue})`);
|
|
876
1220
|
}
|
|
877
|
-
|
|
878
|
-
|
|
1221
|
+
else if (probedRead?.kind === "not-run") {
|
|
1222
|
+
// flair#2520: the pair-refused target the audit-log section also uses
|
|
1223
|
+
// (and the roster and home sections, unless a --fix step makes them
|
|
1224
|
+
// verify again); name why and the remedy, and count it. This section's
|
|
1225
|
+
// diagnostic read does not run.
|
|
1226
|
+
issues++;
|
|
1227
|
+
console.log(` ${render.icons.warn} Instance identity: NOT RUN — ${probedRead.reason}`);
|
|
1228
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${probedRead.remedy}`);
|
|
879
1229
|
}
|
|
880
|
-
if (
|
|
881
|
-
|
|
1230
|
+
else if (probedRead === null) {
|
|
1231
|
+
// No admin credential: the Instance table cannot be read, and no ops
|
|
1232
|
+
// endpoint is addressed. Same UNVERIFIED state as before the target was
|
|
1233
|
+
// shared.
|
|
1234
|
+
console.log(` ${render.icons.warn} Instance identity: UNVERIFIED (could not read the Instance table via the ops API)`);
|
|
882
1235
|
}
|
|
883
1236
|
else {
|
|
884
1237
|
const probe = await probeInstanceIdentity({
|
|
885
|
-
opsUrl: `http://127.0.0.1:${
|
|
886
|
-
credentials: { user: resolveAdminUser(undefined), pass:
|
|
1238
|
+
opsUrl: `http://127.0.0.1:${probedRead.opsPort}`,
|
|
1239
|
+
credentials: { user: resolveAdminUser(undefined), pass: probedAdminPass ?? "" },
|
|
887
1240
|
});
|
|
888
1241
|
if (probe.rows === null) {
|
|
889
1242
|
console.log(` ${render.icons.warn} Instance identity: UNVERIFIED (could not read the Instance table via the ops API)`);
|
|
@@ -1125,6 +1478,10 @@ export function register(program) {
|
|
|
1125
1478
|
continue;
|
|
1126
1479
|
}
|
|
1127
1480
|
console.log(` ${render.icons.ok} FLAIR_URL ${render.wrap(render.c.dim, urlLabel)} reachable`);
|
|
1481
|
+
if (httpHeld && targetsProbedHttpPort(eff.url, effectivePort)) {
|
|
1482
|
+
reportPairNotRun(`agent '${block.agentId}' registration`, " ");
|
|
1483
|
+
continue;
|
|
1484
|
+
}
|
|
1128
1485
|
const reg = await checkAgentRegistered(eff.url, block.agentId, defaultKeysDir());
|
|
1129
1486
|
if (reg.state === "registered") {
|
|
1130
1487
|
console.log(` ${render.icons.ok} agent '${block.agentId}' registered`);
|
|
@@ -1274,7 +1631,11 @@ export function register(program) {
|
|
|
1274
1631
|
// ✓ "still runs". Check freshness first so a stale pin cannot
|
|
1275
1632
|
// hide behind the execution probe. Catalog owns the issue count.
|
|
1276
1633
|
const claudeStale = sessionStartHookPinFindings(resolveHome()).find((f) => f.reading.target.id === "claude-code");
|
|
1277
|
-
if (claudeStale
|
|
1634
|
+
if (claudeStale?.reading.held) {
|
|
1635
|
+
// flair#2291: a held hook shape (see readOwnedPin).
|
|
1636
|
+
console.log(` ${render.icons.warn} SessionStart hook: ${claudeStale.reading.held}`);
|
|
1637
|
+
}
|
|
1638
|
+
else if (claudeStale && claudeStale.direction === "unknown") {
|
|
1278
1639
|
// flair#1778: a pin we cannot compare is its OWN finding — a warn,
|
|
1279
1640
|
// never the stale "old adapter" error, and NOT re-pinned (the
|
|
1280
1641
|
// refresh holds an unreadable pin). Needs no --fix.
|
|
@@ -1483,7 +1844,11 @@ export function register(program) {
|
|
|
1483
1844
|
const hook = codexHook;
|
|
1484
1845
|
if (hook.present) {
|
|
1485
1846
|
const codexStale = sessionStartHookPinFindings(resolveHome()).find((f) => f.reading.target.id === "codex");
|
|
1486
|
-
if (codexStale
|
|
1847
|
+
if (codexStale?.reading.held) {
|
|
1848
|
+
// flair#2291: same held rule as Claude Code above.
|
|
1849
|
+
console.log(` ${render.icons.warn} SessionStart hook (codex): ${codexStale.reading.held}`);
|
|
1850
|
+
}
|
|
1851
|
+
else if (codexStale && codexStale.direction === "unknown") {
|
|
1487
1852
|
// flair#1778: same direction rule as Claude Code above.
|
|
1488
1853
|
console.log(` ${render.icons.warn} SessionStart hook (codex): pin is not a version I can compare: ${codexStale.reading.pin} — not re-pinned; re-run flair init or edit the hook if this is unintended`);
|
|
1489
1854
|
}
|
|
@@ -1616,6 +1981,16 @@ export function register(program) {
|
|
|
1616
1981
|
// Execute the repair directly; it re-derives the plan internally and
|
|
1617
1982
|
// verifies via assessLaunchdManagement (fail-loud, never a silent pass).
|
|
1618
1983
|
const repairResult = await repairLaunchdManagement(defaultDataDir(), effectivePort);
|
|
1984
|
+
// flair#2520: only a no-op is certain to leave the instance and the admin
|
|
1985
|
+
// credential as they were. A repair or a failure may have clean-stopped
|
|
1986
|
+
// the direct process and loaded a launchd job, and any outcome but a
|
|
1987
|
+
// no-op may come after the repair wrote the 0600 admin-pass file from
|
|
1988
|
+
// HDB_ADMIN_PASSWORD (flair#1685; a later refusal leaves the file in
|
|
1989
|
+
// place). So the credential and target resolved before the repair no
|
|
1990
|
+
// longer hold: the Agent-roster and Agent-homes checks resolve the
|
|
1991
|
+
// credential again and, when one is available, verify the target again.
|
|
1992
|
+
if (repairResult.kind !== "no-op")
|
|
1993
|
+
servingProcessMayHaveChanged = true;
|
|
1619
1994
|
switch (repairResult.kind) {
|
|
1620
1995
|
case "no-op":
|
|
1621
1996
|
console.log(` ${render.icons.ok} ${repairResult.detail}`);
|
|
@@ -1701,7 +2076,13 @@ export function register(program) {
|
|
|
1701
2076
|
runningVersion: effectivePort === port ? instanceVersion : null,
|
|
1702
2077
|
}),
|
|
1703
2078
|
repoint: (dry) => cli.repointMainServiceUnit(defaultDataDir(), effectivePort, { dryRun: dry }),
|
|
1704
|
-
|
|
2079
|
+
// flair#2520: set before the restart runs, so a restart that fails
|
|
2080
|
+
// part-way still makes the later checks resolve the credential again
|
|
2081
|
+
// and, when one is available, verify the target again.
|
|
2082
|
+
restart: () => {
|
|
2083
|
+
servingProcessMayHaveChanged = true;
|
|
2084
|
+
return cli.restartFlair(effectivePort, defaultDataDir());
|
|
2085
|
+
},
|
|
1705
2086
|
rewriteFederation: (dry) => rewriteFederationSchedulerRuntime({ dryRun: dry }),
|
|
1706
2087
|
});
|
|
1707
2088
|
issues += treeSection.issues;
|
|
@@ -1728,11 +2109,26 @@ export function register(program) {
|
|
|
1728
2109
|
// never aborts the others — that's the failure isolation flair#722 asks
|
|
1729
2110
|
// for; describeAgentGateFinding (src/doctor-client.ts) is pure decision
|
|
1730
2111
|
// logic so it's unit-tested without a real Harper.
|
|
2112
|
+
// flair#2520/#2526: a --fix step above (7b, 7c) may have changed the serving
|
|
2113
|
+
// process or written the admin-pass file. Resolve the credential and the
|
|
2114
|
+
// target again, once, here, and derive the HTTP-port gate from that answer
|
|
2115
|
+
// for every credentialed read below; the Agent-roster and Agent-homes
|
|
2116
|
+
// checks use the same answer.
|
|
2117
|
+
const lateProbe = servingProcessMayHaveChanged ? await resolveProbedTarget() : probed;
|
|
2118
|
+
if (lateProbe !== probed) {
|
|
2119
|
+
pairGate = harperResponding ? decideDoctorPairGate(lateProbe, effectivePort) : null;
|
|
2120
|
+
pairNotRun = pairGate !== null && pairGate.kind !== "run" ? pairGate : null;
|
|
2121
|
+
httpHeld = pairGate?.kind === "not-run";
|
|
2122
|
+
signedOnlyTransport = pairGate?.kind === "http-only";
|
|
2123
|
+
pairRemedyShown = false;
|
|
2124
|
+
}
|
|
1731
2125
|
const verifiedReadAgentIds = harperResponding
|
|
1732
2126
|
? planAgentIterations(keyAgentIds, opts.agent || process.env.FLAIR_AGENT_ID)
|
|
1733
2127
|
: [];
|
|
2128
|
+
// flair#2526: these reads are agent-signed, held when the pair check refused.
|
|
2129
|
+
const signedReadsNotRun = httpHeld && verifiedReadAgentIds.length > 0;
|
|
1734
2130
|
const agentGates = [];
|
|
1735
|
-
for (const id of verifiedReadAgentIds) {
|
|
2131
|
+
for (const id of signedReadsNotRun ? [] : verifiedReadAgentIds) {
|
|
1736
2132
|
const reg = await checkAgentRegistered(baseUrl, id, defaultKeysDir());
|
|
1737
2133
|
agentGates.push({ id, state: reg.state, detail: reg.detail });
|
|
1738
2134
|
// harperResponding is necessarily true here (verifiedReadAgentIds is
|
|
@@ -1788,9 +2184,10 @@ export function register(program) {
|
|
|
1788
2184
|
// pre-#722 single unauthenticated read (hidden versions, "Pass --agent"
|
|
1789
2185
|
// hint) — there's no agent to sign as, but remote agents may still have
|
|
1790
2186
|
// heartbeated onto this instance and identities are worth showing.
|
|
2187
|
+
const presenceUrl = requestUrl(baseUrl, "/Presence");
|
|
1791
2188
|
async function fetchAndRenderFleetPresence(headers, canSign, indent) {
|
|
1792
2189
|
try {
|
|
1793
|
-
const presRes = await fetch(
|
|
2190
|
+
const presRes = await fetch(presenceUrl, { headers, signal: AbortSignal.timeout(5000) });
|
|
1794
2191
|
if (!presRes.ok) {
|
|
1795
2192
|
// flair#1880: GET /Presence requires a verified reader by default, so
|
|
1796
2193
|
// a keyless (unsigned) read now gets 401. Say so plainly instead of a
|
|
@@ -1853,7 +2250,10 @@ export function register(program) {
|
|
|
1853
2250
|
}
|
|
1854
2251
|
if (harperResponding) {
|
|
1855
2252
|
console.log(`\n ${render.wrap(render.c.bold, "Fleet presence")}`);
|
|
1856
|
-
if (
|
|
2253
|
+
if (signedReadsNotRun) {
|
|
2254
|
+
reportPairNotRun("Fleet presence");
|
|
2255
|
+
}
|
|
2256
|
+
else if (agentGates.length === 0) {
|
|
1857
2257
|
await fetchAndRenderFleetPresence({}, false, " ");
|
|
1858
2258
|
}
|
|
1859
2259
|
else {
|
|
@@ -1862,11 +2262,107 @@ export function register(program) {
|
|
|
1862
2262
|
if (!registered)
|
|
1863
2263
|
continue;
|
|
1864
2264
|
const keyPath = resolveKeyPath(gate.id) ?? join(defaultKeysDir(), `${gate.id}.key`);
|
|
1865
|
-
const headers = { Authorization: buildEd25519Auth(gate.id, "GET",
|
|
2265
|
+
const headers = { Authorization: buildEd25519Auth(gate.id, "GET", requestTarget(presenceUrl), keyPath) };
|
|
1866
2266
|
await fetchAndRenderFleetPresence(headers, true, " ");
|
|
1867
2267
|
}
|
|
1868
2268
|
}
|
|
1869
2269
|
}
|
|
2270
|
+
// 8b. Agent ID rule (flair#2359) — report a stored Agent id outside
|
|
2271
|
+
// the shared agent-ID rule. Read-only: nothing is rewritten.
|
|
2272
|
+
if (harperResponding) {
|
|
2273
|
+
console.log(`\n ${render.wrap(render.c.bold, "Agent IDs")}`);
|
|
2274
|
+
let roster = null;
|
|
2275
|
+
let rosterReadAttempted = false;
|
|
2276
|
+
// flair#2483/#2520: read from the verified instance target. That is the
|
|
2277
|
+
// answer resolved above, unless a --fix step since then may have changed
|
|
2278
|
+
// the serving process or written the admin-pass file
|
|
2279
|
+
// (servingProcessMayHaveChanged): the credential is then resolved and the
|
|
2280
|
+
// target verified with it again, once, right after those steps (7a,
|
|
2281
|
+
// `lateProbe`), and only that answer is used. The roster read addresses the verified ops port,
|
|
2282
|
+
// or both the roster and home checks report NOT RUN (counted as an issue)
|
|
2283
|
+
// and no Agent row is read. No admin credential leaves the target null;
|
|
2284
|
+
// the roster read is skipped and named below.
|
|
2285
|
+
const rosterProbe = lateProbe;
|
|
2286
|
+
const rosterAdminPass = rosterProbe.adminPass;
|
|
2287
|
+
const rosterNotRun = rosterProbe.read?.kind === "not-run" ? rosterProbe.read : null;
|
|
2288
|
+
const rosterOpsPort = rosterProbe.read?.kind === "run" ? rosterProbe.read.opsPort : null;
|
|
2289
|
+
if (rosterAdminPass && rosterOpsPort !== null) {
|
|
2290
|
+
rosterReadAttempted = true;
|
|
2291
|
+
const auth = Buffer.from(`${resolveAdminUser()}:${rosterAdminPass}`).toString("base64");
|
|
2292
|
+
roster = await readAgentRoster({
|
|
2293
|
+
opsUrl: `http://127.0.0.1:${rosterOpsPort}/`,
|
|
2294
|
+
authHeader: `Basic ${auth}`,
|
|
2295
|
+
timeoutMs: 5000,
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
if (rosterNotRun) {
|
|
2299
|
+
// A pair-refused check is not a clean result and not a finding about
|
|
2300
|
+
// another instance: count it, and name why and the remedy. (The Agent
|
|
2301
|
+
// homes no-credential skip below is different: it reads nothing and
|
|
2302
|
+
// counts nothing.)
|
|
2303
|
+
issues++;
|
|
2304
|
+
console.log(` ${render.icons.warn} Agent IDs: NOT RUN — ${rosterNotRun.reason}`);
|
|
2305
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${rosterNotRun.remedy}`);
|
|
2306
|
+
}
|
|
2307
|
+
else if (roster === null) {
|
|
2308
|
+
// A check that could not run is not a clean result: it counts as an
|
|
2309
|
+
// issue, so the summary and exit status never report "No issues found"
|
|
2310
|
+
// for an Agent-ID check that did not happen.
|
|
2311
|
+
issues++;
|
|
2312
|
+
console.log(rosterProbe.credIssue
|
|
2313
|
+
? ` ${render.icons.warn} Skipped: the admin credential could not be resolved (${rosterProbe.credIssue}), so the agent-id check did not run.`
|
|
2314
|
+
: rosterReadAttempted
|
|
2315
|
+
? ` ${render.icons.warn} Could not read the stored Agent roster, so the agent-id check did not run.`
|
|
2316
|
+
: ` ${render.icons.warn} Skipped: no admin credentials to read the stored Agent roster, so the agent-id check did not run.`);
|
|
2317
|
+
}
|
|
2318
|
+
else {
|
|
2319
|
+
const finding = describeAgentIdRuleFinding(roster);
|
|
2320
|
+
if (!finding) {
|
|
2321
|
+
console.log(` ${render.icons.ok} No stored agent id is outside ${AGENT_ID_RULE}.`);
|
|
2322
|
+
}
|
|
2323
|
+
else {
|
|
2324
|
+
issues++;
|
|
2325
|
+
console.log(` ${render.icons.warn} ${finding.message}`);
|
|
2326
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${finding.fixHint}`);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
// 8c. Agent homes (flair#2433) — report every stored Agent row with no
|
|
2330
|
+
// home instance (`originatorInstanceId`) and name the remedy that
|
|
2331
|
+
// back-fills it. Read-only: nothing is rewritten here.
|
|
2332
|
+
console.log(`\n ${render.wrap(render.c.bold, "Agent homes")}`);
|
|
2333
|
+
if (rosterNotRun) {
|
|
2334
|
+
issues++;
|
|
2335
|
+
console.log(` ${render.icons.warn} Agent homes: NOT RUN — ${rosterNotRun.reason}`);
|
|
2336
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${rosterNotRun.remedy}`);
|
|
2337
|
+
}
|
|
2338
|
+
else if (!rosterAdminPass) {
|
|
2339
|
+
console.log(` ${render.icons.info} Agent homes check skipped (no admin credential).`);
|
|
2340
|
+
}
|
|
2341
|
+
else {
|
|
2342
|
+
const homeOpsUrl = `http://127.0.0.1:${rosterOpsPort}/`;
|
|
2343
|
+
const homeEndpoint = agentHomeEndpoint(homeOpsUrl, resolveAdminUser(), rosterAdminPass);
|
|
2344
|
+
const homeAuth = `Basic ${Buffer.from(`${resolveAdminUser()}:${rosterAdminPass}`).toString("base64")}`;
|
|
2345
|
+
const homeRows = await readAgentHomeRows({ opsUrl: homeOpsUrl, authHeader: homeAuth, timeoutMs: 5000 });
|
|
2346
|
+
if (homeRows === null) {
|
|
2347
|
+
issues++;
|
|
2348
|
+
console.log(` ${render.icons.warn} Could not read the stored Agent roster, so the home-instance check did not run.`);
|
|
2349
|
+
}
|
|
2350
|
+
else {
|
|
2351
|
+
const homeIdentity = await resolveTargetInstanceIdentity(homeEndpoint);
|
|
2352
|
+
const homeFinding = describeAgentHomeFinding(homeRows, homeIdentity);
|
|
2353
|
+
if (!homeFinding) {
|
|
2354
|
+
console.log(` ${render.icons.ok} Every stored agent row names a home instance.`);
|
|
2355
|
+
}
|
|
2356
|
+
else {
|
|
2357
|
+
console.log(` ${homeFinding.severity === "info" ? render.icons.info : render.icons.warn} ${homeFinding.message}`);
|
|
2358
|
+
if (homeFinding.fixHint)
|
|
2359
|
+
console.log(` ${render.wrap(render.c.dim, "Fix:")} ${homeFinding.fixHint}`);
|
|
2360
|
+
if (homeFinding.isIssue)
|
|
2361
|
+
issues++;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
1870
2366
|
// 9. Migration state (flair#695) — pending/in-progress/blocked + last
|
|
1871
2367
|
// ledger-derived outcome per registered migration, read off the same
|
|
1872
2368
|
// authenticated /HealthDetail the "Fleet presence" section above
|
|
@@ -1885,66 +2381,13 @@ export function register(program) {
|
|
|
1885
2381
|
// iterates only the gate-passed agents and rolls the rest into one
|
|
1886
2382
|
// aggregate skip line. The issue COUNT is unaffected either way — gate
|
|
1887
2383
|
// findings are counted exactly once, at gate-resolution time (step 7a).
|
|
1888
|
-
|
|
1889
|
-
try {
|
|
1890
|
-
const migRes = await fetch(`${baseUrl}/HealthDetail`, { headers, signal: AbortSignal.timeout(5000) });
|
|
1891
|
-
if (!migRes.ok) {
|
|
1892
|
-
console.log(`${indent}${render.icons.warn} Could not fetch migration state (HTTP ${migRes.status})`);
|
|
1893
|
-
return;
|
|
1894
|
-
}
|
|
1895
|
-
const detail = (await migRes.json());
|
|
1896
|
-
const migBlock = detail?.migrations;
|
|
1897
|
-
if (!migBlock || !Array.isArray(migBlock.migrations) || migBlock.migrations.length === 0) {
|
|
1898
|
-
console.log(`${indent}${render.icons.info} No migrations registered on this instance`);
|
|
1899
|
-
return;
|
|
1900
|
-
}
|
|
1901
|
-
if (migBlock.cyclePhase === "pre-hash") {
|
|
1902
|
-
console.log(`${indent}${render.icons.info} Pre-flight integrity check in progress — migrations deferred until it completes`);
|
|
1903
|
-
}
|
|
1904
|
-
// flair#812: the boot trigger sets `scheduled` synchronously at
|
|
1905
|
-
// module load, so `idle` means resources/migration-boot.js never
|
|
1906
|
-
// loaded in the serving process — NO migration will ever run on
|
|
1907
|
-
// this instance, which is precisely the failure that went unnoticed
|
|
1908
|
-
// because a skipped cycle looked identical to a clean one.
|
|
1909
|
-
if (migBlock.cyclePhase === "idle") {
|
|
1910
|
-
console.log(`${indent}${render.icons.error} Migration boot cycle never fired on this instance — no migration will run until this is resolved. Check the instance log for [flair-migrations] and confirm the running build ships dist/resources/migration-boot.js.`);
|
|
1911
|
-
issues++;
|
|
1912
|
-
}
|
|
1913
|
-
// A cycle that reached a terminal phase carrying an error explains
|
|
1914
|
-
// itself here rather than only in the process log — the reason
|
|
1915
|
-
// string names the paths tried and the remedy.
|
|
1916
|
-
if (migBlock.lastCycleError) {
|
|
1917
|
-
console.log(`${indent}${render.icons.error} Last migration cycle did not complete: ${migBlock.lastCycleError}`);
|
|
1918
|
-
issues++;
|
|
1919
|
-
}
|
|
1920
|
-
for (const m of migBlock.migrations) {
|
|
1921
|
-
if (m.state === "completed") {
|
|
1922
|
-
// flair#812: a `reason` on a COMPLETED migration means the
|
|
1923
|
-
// runner short-circuited it from the (hand-editable) state file
|
|
1924
|
-
// rather than verifying the corpus this boot. Print it, so an
|
|
1925
|
-
// unverified claim is never rendered as a verified one.
|
|
1926
|
-
const note = m.reason ? ` ${render.wrap(render.c.dim, `(${m.reason})`)}` : "";
|
|
1927
|
-
console.log(`${indent}${render.icons.ok} ${m.id}: completed${note}`);
|
|
1928
|
-
}
|
|
1929
|
-
else if (m.state === "halted" || m.state === "failed") {
|
|
1930
|
-
console.log(`${indent}${render.icons.error} ${m.id}: ${m.state}${m.reason ? ` — ${m.reason}` : ""}`);
|
|
1931
|
-
issues++;
|
|
1932
|
-
}
|
|
1933
|
-
else if (m.state === "running") {
|
|
1934
|
-
console.log(`${indent}${render.icons.info} ${m.id}: in progress (${m.rowsDone} done, ${m.rowsRemaining} remaining)`);
|
|
1935
|
-
}
|
|
1936
|
-
else {
|
|
1937
|
-
console.log(`${indent}${render.icons.info} ${m.id}: ${m.state}`);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
catch (err) {
|
|
1942
|
-
console.log(`${indent}${render.icons.warn} Migration state check failed: ${err?.message ?? err}`);
|
|
1943
|
-
}
|
|
1944
|
-
}
|
|
2384
|
+
const healthDetailUrl = requestUrl(baseUrl, "/HealthDetail");
|
|
1945
2385
|
if (harperResponding) {
|
|
1946
2386
|
console.log(`\n ${render.wrap(render.c.bold, "Migrations")}`);
|
|
1947
|
-
if (
|
|
2387
|
+
if (signedReadsNotRun) {
|
|
2388
|
+
reportPairNotRun("Migrations");
|
|
2389
|
+
}
|
|
2390
|
+
else if (agentGates.length === 0) {
|
|
1948
2391
|
console.log(` ${render.icons.info} Pass --agent <id> (with a matching key in ~/.flair/keys) to see migration state — requires a verified read, same as Fleet presence above.`);
|
|
1949
2392
|
}
|
|
1950
2393
|
else {
|
|
@@ -1952,8 +2395,8 @@ export function register(program) {
|
|
|
1952
2395
|
for (const gate of passedGates) {
|
|
1953
2396
|
renderAgentGateHeader(gate);
|
|
1954
2397
|
const keyPath = resolveKeyPath(gate.id) ?? join(defaultKeysDir(), `${gate.id}.key`);
|
|
1955
|
-
const headers = { Authorization: buildEd25519Auth(gate.id, "GET",
|
|
1956
|
-
await fetchAndRenderMigrations(headers, " ");
|
|
2398
|
+
const headers = { Authorization: buildEd25519Auth(gate.id, "GET", requestTarget(healthDetailUrl), keyPath) };
|
|
2399
|
+
issues += await fetchAndRenderMigrations(healthDetailUrl, headers, " ");
|
|
1957
2400
|
}
|
|
1958
2401
|
const skipped = agentGates.length - passedGates.length;
|
|
1959
2402
|
if (skipped > 0) {
|
|
@@ -1988,7 +2431,10 @@ export function register(program) {
|
|
|
1988
2431
|
const remSched = await import("../rem/scheduler.js");
|
|
1989
2432
|
const guiDomain = `gui/${process.getuid?.() ?? ""}`;
|
|
1990
2433
|
let livePeerCount = null;
|
|
1991
|
-
|
|
2434
|
+
// flair#2526: a credentialed read, held while the gate is `not-run`; in
|
|
2435
|
+
// `http-only` it runs signed-only (no Basic or Bearer header). An unread
|
|
2436
|
+
// count falls back to the configured peers below.
|
|
2437
|
+
if (harperResponding && !httpHeld) {
|
|
1992
2438
|
try {
|
|
1993
2439
|
const r = await api("GET", "/FederationPeers", undefined, { baseUrl });
|
|
1994
2440
|
const peers = Array.isArray(r?.peers) ? r.peers : [];
|