@indigoai-us/hq-cli 5.345.251 → 5.345.253
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/CHANGELOG.md +153 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +269 -1
- package/dist/command-catalog.generated.js +330 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/bot.js +7 -2
- package/dist/commands/ci-intake.d.ts +15 -0
- package/dist/commands/ci-intake.js +252 -0
- package/dist/commands/ci-metrics.d.ts +8 -0
- package/dist/commands/ci-metrics.js +55 -0
- package/dist/commands/ci.d.ts +13 -0
- package/dist/commands/ci.js +10 -0
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.d.ts +62 -0
- package/dist/commands/files.js +250 -9
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +2 -0
- package/dist/commands/ontology-graph.js +33 -0
- package/dist/commands/report.js +35 -2
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +50 -0
- package/dist/lib/bot/fleet-cron.js +173 -32
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/run.js +4 -3
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/delivery/migrations.d.ts +32 -1
- package/dist/lib/delivery/migrations.js +69 -8
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +30 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +30 -0
- package/dist/lib/hook-engine/coverage.d.ts +65 -1
- package/dist/lib/hook-engine/coverage.js +173 -8
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +232 -12
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/index.d.ts +54 -0
- package/dist/lib/ontology-graph/model/index.js +112 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
- package/dist/lib/ontology-graph/model/pass.js +9 -2
- package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
- package/dist/lib/ontology-graph/model/pending-items.js +24 -1
- package/dist/lib/ontology-graph/model/step.d.ts +1 -1
- package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
- package/dist/lib/ontology-graph/model/tasks.js +20 -7
- package/dist/lib/ontology-graph/read/brief.js +41 -6
- package/dist/lib/ontology-graph/read/index.d.ts +4 -0
- package/dist/lib/ontology-graph/read/index.js +173 -29
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +9 -3
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
- package/dist/lib/ontology-graph/schema/index.js +1 -0
- package/dist/lib/ontology-graph/setup/index.js +13 -3
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/smart-ci/cost.d.ts +72 -0
- package/dist/lib/smart-ci/cost.js +120 -0
- package/dist/lib/smart-ci/github.d.ts +112 -0
- package/dist/lib/smart-ci/github.js +267 -0
- package/dist/lib/smart-ci/intake.d.ts +288 -0
- package/dist/lib/smart-ci/intake.js +1078 -0
- package/dist/lib/smart-ci/ledger.d.ts +218 -0
- package/dist/lib/smart-ci/ledger.js +527 -0
- package/dist/lib/smart-ci/metrics.d.ts +137 -0
- package/dist/lib/smart-ci/metrics.js +249 -0
- package/dist/lib/smart-ci/records.d.ts +265 -0
- package/dist/lib/smart-ci/records.js +281 -0
- package/dist/lib/smart-ci/reducer.d.ts +67 -0
- package/dist/lib/smart-ci/reducer.js +261 -0
- package/dist/lib/sync-core/engine-holds.d.ts +15 -0
- package/dist/lib/sync-core/engine-holds.js +104 -11
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/hand-back.d.ts +1 -0
- package/dist/lib/sync-core/hand-back.js +7 -2
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +40 -7
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +10 -8
- package/scripts/install-hook-engine.mjs +5 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI version sent as `x-hq-client-version` on flag resolve requests.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `cli-version.ts`, this never throws. It reads package.json relative to
|
|
5
|
+
* this file, and code that bundles it elsewhere (a test bundle in
|
|
6
|
+
* node_modules/.cache, an eval'd worker with no module URL) cannot find it.
|
|
7
|
+
* The read then returns undefined and the request goes out without the
|
|
8
|
+
* version header; hq-pro stores null and only gated rows deny on that.
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
let cached;
|
|
12
|
+
export function readClientVersion() {
|
|
13
|
+
if (cached === undefined) {
|
|
14
|
+
try {
|
|
15
|
+
const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
|
|
16
|
+
cached = typeof pkg.version === "string" && pkg.version.length > 0 ? pkg.version : null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
cached = null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return cached ?? undefined;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client-version.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-shot company-scoped flag resolution helpers.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from `flag-registry.ts` so non-network fast routes (such as
|
|
5
|
+
* `timeout-guard`, `handoff`, and `delegate`) that import the worker-backed
|
|
6
|
+
* process snapshot reader do not pull `createHqFlagClient` / `globalThis.fetch`
|
|
7
|
+
* into their static import closure.
|
|
8
|
+
*/
|
|
9
|
+
import { type FlagLookupOptions, type FlagResolution } from "@indigoai-us/hq-flags-client";
|
|
10
|
+
import { createHqFlagClient } from "./flag-client-headers.js";
|
|
11
|
+
export interface CompanyFlagGateDependencies {
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
requestTimeoutMs?: number;
|
|
14
|
+
createClient?: typeof createHqFlagClient;
|
|
15
|
+
}
|
|
16
|
+
/** Resolve one explicit company's flag without relying on process-wide binding. */
|
|
17
|
+
export declare function resolveCompanyFlagGate(companyUid: string, idToken: string, flagKey: string, lookup: FlagLookupOptions, legacyFallback: () => boolean, dependencies?: CompanyFlagGateDependencies): Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Read one explicit company's flag and say whether the registry answered.
|
|
20
|
+
*
|
|
21
|
+
* Returns the evaluator's resolution when the registry snapshot loaded (an
|
|
22
|
+
* absent row resolves to `lookup.fallback`, source "fallback"), a
|
|
23
|
+
* "local-override" resolution when the process sets one, and null when the
|
|
24
|
+
* registry could not be read: no company uid or token, a client error, a
|
|
25
|
+
* timeout, or a failed load. Callers that keep a last-known value (ingest
|
|
26
|
+
* kill switches) use the null to tell an unreadable registry from an answer.
|
|
27
|
+
* Bounded by the client's request timeout, like `resolveCompanyFlagGate`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readCompanyFlag(companyUid: string, idToken: string, flagKey: string, lookup: FlagLookupOptions, dependencies?: CompanyFlagGateDependencies): Promise<FlagResolution | null>;
|
|
30
|
+
//# sourceMappingURL=company-flag-gate.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-shot company-scoped flag resolution helpers.
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from `flag-registry.ts` so non-network fast routes (such as
|
|
5
|
+
* `timeout-guard`, `handoff`, and `delegate`) that import the worker-backed
|
|
6
|
+
* process snapshot reader do not pull `createHqFlagClient` / `globalThis.fetch`
|
|
7
|
+
* into their static import closure.
|
|
8
|
+
*/
|
|
9
|
+
import { readLocalOverride, } from "@indigoai-us/hq-flags-client";
|
|
10
|
+
import { createHqFlagClient } from "./flag-client-headers.js";
|
|
11
|
+
import { resolveFlagRegistryEndpoint } from "./flag-registry-endpoint.js";
|
|
12
|
+
import { resolveFlagGate } from "./flag-registry.js";
|
|
13
|
+
const COMPANY_UID_RE = /^cmp_[A-Za-z0-9]{3,128}$/;
|
|
14
|
+
function normalizedCompanyUid(value) {
|
|
15
|
+
const candidate = value?.trim() ?? "";
|
|
16
|
+
return COMPANY_UID_RE.test(candidate) ? candidate : undefined;
|
|
17
|
+
}
|
|
18
|
+
function processLocalOverride(flagKey, env = process.env) {
|
|
19
|
+
return readLocalOverride(flagKey, env);
|
|
20
|
+
}
|
|
21
|
+
function localOverrideOrFallback(flagKey, legacyFallback, env = process.env) {
|
|
22
|
+
return processLocalOverride(flagKey, env) ?? legacyFallback();
|
|
23
|
+
}
|
|
24
|
+
/** Resolve one explicit company's flag without relying on process-wide binding. */
|
|
25
|
+
export async function resolveCompanyFlagGate(companyUid, idToken, flagKey, lookup, legacyFallback, dependencies = {}) {
|
|
26
|
+
const localOverride = processLocalOverride(flagKey);
|
|
27
|
+
if (localOverride !== null)
|
|
28
|
+
return localOverride;
|
|
29
|
+
const targetCompanyUid = normalizedCompanyUid(companyUid);
|
|
30
|
+
if (!targetCompanyUid || idToken.trim() === "") {
|
|
31
|
+
return localOverrideOrFallback(flagKey, legacyFallback);
|
|
32
|
+
}
|
|
33
|
+
let client;
|
|
34
|
+
try {
|
|
35
|
+
client = (dependencies.createClient ?? createHqFlagClient)({
|
|
36
|
+
endpoint: resolveFlagRegistryEndpoint(dependencies.endpoint, process.env),
|
|
37
|
+
getToken: () => idToken,
|
|
38
|
+
companyUid: targetCompanyUid,
|
|
39
|
+
refreshIntervalMs: 0,
|
|
40
|
+
requestTimeoutMs: dependencies.requestTimeoutMs ?? 1_200,
|
|
41
|
+
onError: (error) => {
|
|
42
|
+
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
43
|
+
console.error(`hq: Could not resolve a company flag (${errorClass}); using its fallback.`);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
await client.ready();
|
|
47
|
+
return resolveFlagGate(client, flagKey, lookup, legacyFallback);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
51
|
+
console.error(`hq: Could not resolve a company flag (${errorClass}); using its fallback.`);
|
|
52
|
+
return localOverrideOrFallback(flagKey, legacyFallback);
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
client?.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read one explicit company's flag and say whether the registry answered.
|
|
60
|
+
*
|
|
61
|
+
* Returns the evaluator's resolution when the registry snapshot loaded (an
|
|
62
|
+
* absent row resolves to `lookup.fallback`, source "fallback"), a
|
|
63
|
+
* "local-override" resolution when the process sets one, and null when the
|
|
64
|
+
* registry could not be read: no company uid or token, a client error, a
|
|
65
|
+
* timeout, or a failed load. Callers that keep a last-known value (ingest
|
|
66
|
+
* kill switches) use the null to tell an unreadable registry from an answer.
|
|
67
|
+
* Bounded by the client's request timeout, like `resolveCompanyFlagGate`.
|
|
68
|
+
*/
|
|
69
|
+
export async function readCompanyFlag(companyUid, idToken, flagKey, lookup, dependencies = {}) {
|
|
70
|
+
const localOverride = processLocalOverride(flagKey);
|
|
71
|
+
if (localOverride !== null)
|
|
72
|
+
return { value: localOverride, source: "local-override" };
|
|
73
|
+
const targetCompanyUid = normalizedCompanyUid(companyUid);
|
|
74
|
+
if (!targetCompanyUid || idToken.trim() === "")
|
|
75
|
+
return null;
|
|
76
|
+
let client;
|
|
77
|
+
try {
|
|
78
|
+
client = (dependencies.createClient ?? createHqFlagClient)({
|
|
79
|
+
endpoint: resolveFlagRegistryEndpoint(dependencies.endpoint, process.env),
|
|
80
|
+
getToken: () => idToken,
|
|
81
|
+
companyUid: targetCompanyUid,
|
|
82
|
+
refreshIntervalMs: 0,
|
|
83
|
+
requestTimeoutMs: dependencies.requestTimeoutMs ?? 1_200,
|
|
84
|
+
onError: (error) => {
|
|
85
|
+
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
86
|
+
console.error(`hq: Could not read a company flag (${errorClass}).`);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
await client.ready();
|
|
90
|
+
// ready() resolves after a failed load too; no snapshot means no answer.
|
|
91
|
+
if (client.snapshot() === null)
|
|
92
|
+
return null;
|
|
93
|
+
return client.explain(flagKey, lookup);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
const errorClass = error instanceof Error ? error.name : "unknown";
|
|
97
|
+
console.error(`hq: Could not read a company flag (${errorClass}).`);
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
client?.close();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=company-flag-gate.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { loadCachedTokens } from "@indigoai-us/hq-cloud";
|
|
2
|
-
import { createFlagClient
|
|
2
|
+
import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
|
|
3
3
|
import { resolveProcessFlagCompanyContext } from "../flag-registry.js";
|
|
4
4
|
import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
|
|
5
5
|
export const HOOK_TIMEOUT_DEBUG_CONTEXT_FLAG = "hook-timeout-debug-context";
|
package/dist/lib/daemon/flag.js
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* instead of one request per flag.
|
|
9
9
|
*/
|
|
10
10
|
import { performance } from "node:perf_hooks";
|
|
11
|
-
import {
|
|
11
|
+
import { readLocalOverride, } from "@indigoai-us/hq-flags-client";
|
|
12
|
+
import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
|
|
12
13
|
import { ensureCognitoIdToken } from "../../utils/cognito-session.js";
|
|
13
14
|
import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
|
|
14
15
|
import { resolveProcessFlagCompanyContext } from "../flag-registry.js";
|
|
@@ -40,7 +40,9 @@ export function createLegacyJournalGate(deps) {
|
|
|
40
40
|
let needed;
|
|
41
41
|
try {
|
|
42
42
|
const state = legacyJournalExportState(deps.home, vault, deps.now());
|
|
43
|
-
needed = (state === "missing" || state === "unusable")
|
|
43
|
+
needed = (state === "missing" || state === "unusable")
|
|
44
|
+
&& Number.isFinite(Date.parse(vault.legacyOffSince ?? ""))
|
|
45
|
+
&& legacyJournalDirs(deps.home, deps.env, slug).length > 0;
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
46
48
|
deps.log("warn", `${vault.uid}: could not check for the current sync's record of ${slug}: ${error instanceof Error ? error.message : String(error)}; starting the new sync engine without it`);
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -34,7 +34,7 @@ import { serveQmdWorker } from "../search-index/worker-process.js";
|
|
|
34
34
|
import { inspectEngineHome, syncCoreUnitId } from "../sync-core/engine-home.js";
|
|
35
35
|
import { fullModeHold } from "../sync-core/reconcile.js";
|
|
36
36
|
import { engineVaultCount, readSyncCoreRolloutState } from "../sync-core/rollout-state.js";
|
|
37
|
-
import { engineOwnsVault, finishLegacyHandBack } from "../sync-core/hand-back.js";
|
|
37
|
+
import { engineHoldBlocksHandBack, engineOwnsVault, finishLegacyHandBack } from "../sync-core/hand-back.js";
|
|
38
38
|
import { effectiveEngineSettings, readSyncCoreVaultSettings } from "../sync-core/vault-settings.js";
|
|
39
39
|
import { assertPersonalServiceSessionCapability, readRemoteControlPoolsConfig, remoteControlPoolSecretsEnv, } from "./remote-control-pools.js";
|
|
40
40
|
import { loadLanesConfig } from "../lanes/config.js";
|
|
@@ -147,8 +147,9 @@ export function planUnitsWithSyncCoreInterlock(services, context, supervisor, re
|
|
|
147
147
|
let personalOff = context.vaultSync.personalOff;
|
|
148
148
|
const offCompanies = new Set(context.vaultSync.offCompanies);
|
|
149
149
|
const engineStopped = (uid) => !!supervisor && supervisor.runningPlanKey(syncCoreUnitId(uid)) === undefined;
|
|
150
|
-
const held = (context.syncCoreVaults ?? []).filter((vault) => vault.phase === "full" && engineStopped(vault.uid) && fullModeHold(vault, vault.release, context.platform)
|
|
151
|
-
|
|
150
|
+
const held = (context.syncCoreVaults ?? []).filter((vault) => vault.phase === "full" && engineStopped(vault.uid) && fullModeHold(vault, vault.release, context.platform)
|
|
151
|
+
&& !engineHoldBlocksHandBack(context.home, vault.uid));
|
|
152
|
+
const handingBack = (context.syncCoreHandingBack ?? []).filter((vault) => engineStopped(vault.uid) && engineOwnsVault(context.home, vault.uid) && !engineHoldBlocksHandBack(context.home, vault.uid));
|
|
152
153
|
const handBack = [...held, ...handingBack];
|
|
153
154
|
const restore = legacySwitchRestorePatch(handBack, context.vaultSync);
|
|
154
155
|
if (restore.personal)
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* so the snapshot keeps the last answer the registry gave, exactly as it did
|
|
26
26
|
* when the worker's refresh failed.
|
|
27
27
|
*/
|
|
28
|
-
import { createFlagClient } from "
|
|
28
|
+
import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
|
|
29
29
|
import { anywhereRuntimeEnabledFromSnapshot } from "../anywhere-runtime-fast-flag.js";
|
|
30
30
|
import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
|
|
31
31
|
import { flagSnapshotWriteFailureTags, writeFlagSnapshotFile, writePersonFlagSnapshotFile, } from "../flag-snapshot-file.js";
|
|
@@ -12,8 +12,10 @@ export declare const STORE_SCHEMA_V5 = "hq-delivery.store.v5";
|
|
|
12
12
|
export declare const STORE_SCHEMA_V6 = "hq-delivery.store.v6";
|
|
13
13
|
/** v7 (US-011 slice 4) adds a claim lease to every attempt (leaseExpiresAt). */
|
|
14
14
|
export declare const STORE_SCHEMA_V7 = "hq-delivery.store.v7";
|
|
15
|
+
/** v8 (smart-ci US-001) adds the smart-ci namespace: keyed records and stream cursors. */
|
|
16
|
+
export declare const STORE_SCHEMA_V8 = "hq-delivery.store.v8";
|
|
15
17
|
/** The store schema version this code writes. */
|
|
16
|
-
export declare const STORE_SCHEMA_VERSION = "hq-delivery.store.
|
|
18
|
+
export declare const STORE_SCHEMA_VERSION = "hq-delivery.store.v8";
|
|
17
19
|
/** Every version this code can open, oldest first. Older ones migrate forward on open. */
|
|
18
20
|
export declare const KNOWN_STORE_SCHEMA_VERSIONS: readonly string[];
|
|
19
21
|
export type DeliveryStoreErrorCode = "STORE_CORRUPT" | "STORE_SCHEMA_NEWER" | "STORE_SCHEMA_UNKNOWN" | "STORE_INVALID_RECORD" | "CONTROLLER_OWNED" | "CONTROLLER_AMBIGUOUS" | "FENCED" | "STORE_CLOSED" | "STORE_IO" | "INVALID_RECORD" | "DUPLICATE_CONFLICT" | "UNKNOWN_RUN" | "UNKNOWN_JOB" | "UNKNOWN_DEPENDENCY" | "DEPENDENCY_CYCLE" | "NOT_CLAIMABLE" | "UNKNOWN_ATTEMPT" | "ATTEMPT_CONFLICT" | "ATTEMPT_ABANDONED" | "ACCESS_DENIED" | "WORKER_REVOKED" | "PRIVILEGE_REJECTED" | "CREDENTIAL_UNAVAILABLE" | "NOTIFICATION_UNVERIFIED" | "ARTIFACT_UNKNOWN" | "ARTIFACT_TAMPERED" | "ARTIFACT_NOT_PROMOTABLE" | "SIGNING_KEY_UNCONFIGURED" | "BACKUP_INVALID" | "RESTORE_PENDING" | "STORE_RETIRED" | "DEPLOY_BLOCKED" | "ENV_BUSY" | "DEPLOY_OUTCOME_UNKNOWN" | "STALE_PUBLICATION" | "UNKNOWN_DEPLOYMENT" | "TARGET_UNREACHABLE" | "RPC_TIMEOUT" | "RPC_CLOSED" | "RPC_UNREACHABLE" | "RPC_BAD_REQUEST" | "RPC_UNKNOWN_METHOD" | "RPC_TOO_LARGE" | "RPC_BAD_ANSWER" | "RPC_SERVER_ERROR" | "RPC_NOT_LOOPBACK" | "RPC_BUSY" | "LEASE_UNCONFIRMED";
|
|
@@ -129,6 +131,35 @@ export interface StoreState {
|
|
|
129
131
|
deployments: StoredDeployment[];
|
|
130
132
|
/** US-009: one admin-set, signed deploy policy per company. Workers never write it. */
|
|
131
133
|
deployPolicies: StoredDeployPolicy[];
|
|
134
|
+
/** v8: the smart-ci namespace. Smart CI records and cursors live here and nowhere else. */
|
|
135
|
+
smartCi: SmartCiNamespace;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* One smart-ci record (v8). `kind` and `id` together are unique, so writing
|
|
139
|
+
* the same observation again replaces the record and never adds a second one.
|
|
140
|
+
* The store checks this envelope only; src/lib/smart-ci owns each kind's body.
|
|
141
|
+
*/
|
|
142
|
+
export interface StoredSmartCiRecord {
|
|
143
|
+
kind: string;
|
|
144
|
+
id: string;
|
|
145
|
+
/** When the record was first written, on the controller's clock. */
|
|
146
|
+
recordedAt: string;
|
|
147
|
+
recordedEpoch: number;
|
|
148
|
+
/** When the body last changed, on the controller's clock. */
|
|
149
|
+
updatedAt: string;
|
|
150
|
+
updatedEpoch: number;
|
|
151
|
+
body: Record<string, unknown>;
|
|
152
|
+
}
|
|
153
|
+
/** How far one smart-ci input stream has been read (v8). One entry per stream. */
|
|
154
|
+
export interface StoredSmartCiCursor {
|
|
155
|
+
stream: string;
|
|
156
|
+
position: string;
|
|
157
|
+
updatedAt: string;
|
|
158
|
+
updatedEpoch: number;
|
|
159
|
+
}
|
|
160
|
+
export interface SmartCiNamespace {
|
|
161
|
+
records: StoredSmartCiRecord[];
|
|
162
|
+
cursors: StoredSmartCiCursor[];
|
|
132
163
|
}
|
|
133
164
|
/**
|
|
134
165
|
* blocked: refused by admission; carries a decision, no fence, no effect.
|
|
@@ -28,12 +28,14 @@ export const STORE_SCHEMA_V5 = "hq-delivery.store.v5";
|
|
|
28
28
|
export const STORE_SCHEMA_V6 = "hq-delivery.store.v6";
|
|
29
29
|
/** v7 (US-011 slice 4) adds a claim lease to every attempt (leaseExpiresAt). */
|
|
30
30
|
export const STORE_SCHEMA_V7 = "hq-delivery.store.v7";
|
|
31
|
+
/** v8 (smart-ci US-001) adds the smart-ci namespace: keyed records and stream cursors. */
|
|
32
|
+
export const STORE_SCHEMA_V8 = "hq-delivery.store.v8";
|
|
31
33
|
/** The store schema version this code writes. */
|
|
32
|
-
export const STORE_SCHEMA_VERSION =
|
|
34
|
+
export const STORE_SCHEMA_VERSION = STORE_SCHEMA_V8;
|
|
33
35
|
/** Every version this code can open, oldest first. Older ones migrate forward on open. */
|
|
34
|
-
export const KNOWN_STORE_SCHEMA_VERSIONS = [STORE_SCHEMA_V1, STORE_SCHEMA_V2, STORE_SCHEMA_V3, STORE_SCHEMA_V4, STORE_SCHEMA_V5, STORE_SCHEMA_V6, STORE_SCHEMA_V7];
|
|
36
|
+
export const KNOWN_STORE_SCHEMA_VERSIONS = [STORE_SCHEMA_V1, STORE_SCHEMA_V2, STORE_SCHEMA_V3, STORE_SCHEMA_V4, STORE_SCHEMA_V5, STORE_SCHEMA_V6, STORE_SCHEMA_V7, STORE_SCHEMA_V8];
|
|
35
37
|
const VERSION_PATTERN = /^hq-delivery\.store\.v(\d+)$/;
|
|
36
|
-
const CURRENT_VERSION_NUMBER =
|
|
38
|
+
const CURRENT_VERSION_NUMBER = 8;
|
|
37
39
|
/** Every refusal from the delivery store. The message reads "CODE: found ...; expected .... action". */
|
|
38
40
|
export class DeliveryStoreError extends Error {
|
|
39
41
|
code;
|
|
@@ -69,7 +71,7 @@ export const DECISION_CODES = [
|
|
|
69
71
|
];
|
|
70
72
|
export const OBSERVATION_SOURCES = ["apply-response", "apply-rejected", "transport-error", "stale-publication", "lease-lost", "target-query"];
|
|
71
73
|
export function emptyState() {
|
|
72
|
-
return { epoch: 0, controllers: [], runs: [], jobs: [], attempts: [], workers: [], artifacts: [], cache: [], deployments: [], deployPolicies: [] };
|
|
74
|
+
return { epoch: 0, controllers: [], runs: [], jobs: [], attempts: [], workers: [], artifacts: [], cache: [], deployments: [], deployPolicies: [], smartCi: { records: [], cursors: [] } };
|
|
73
75
|
}
|
|
74
76
|
export function stateChecksum(state) {
|
|
75
77
|
return createHash("sha256").update(JSON.stringify(state)).digest("hex");
|
|
@@ -123,8 +125,8 @@ export function parseStoreText(text, source) {
|
|
|
123
125
|
});
|
|
124
126
|
}
|
|
125
127
|
const envelope = () => readEnvelope(parsed, source);
|
|
126
|
-
const
|
|
127
|
-
?
|
|
128
|
+
const v7 = () => version === STORE_SCHEMA_V7
|
|
129
|
+
? envelope()
|
|
128
130
|
: version === STORE_SCHEMA_V6
|
|
129
131
|
? migrateV6(envelope(), source)
|
|
130
132
|
: version === STORE_SCHEMA_V5
|
|
@@ -136,6 +138,7 @@ export function parseStoreText(text, source) {
|
|
|
136
138
|
: version === STORE_SCHEMA_V2
|
|
137
139
|
? migrateV6(migrateV5(migrateV4(migrateV3(migrateV2(envelope(), source), source), source), source), source)
|
|
138
140
|
: migrateV6(migrateV5(migrateV4(migrateV1(parsed, source), source), source), source);
|
|
141
|
+
const state = version === STORE_SCHEMA_V8 ? readEnvelope(parsed, source) : migrateV7(v7(), source);
|
|
139
142
|
const errors = validateState(state);
|
|
140
143
|
if (errors.length > 0)
|
|
141
144
|
throw invalidStore(source, errors);
|
|
@@ -187,7 +190,16 @@ function migrateV6(state, source) {
|
|
|
187
190
|
});
|
|
188
191
|
return { ...state, attempts };
|
|
189
192
|
}
|
|
190
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* v7 → v8. v8 adds the smart-ci namespace, which starts empty. Nothing else
|
|
195
|
+
* changes. The v7 checksum is checked first, by readEnvelope.
|
|
196
|
+
*/
|
|
197
|
+
function migrateV7(state, source) {
|
|
198
|
+
if ("smartCi" in state)
|
|
199
|
+
throw invalidStore(source, ["v7 state has a smartCi field; v7 has none"]);
|
|
200
|
+
return { ...state, smartCi: { records: [], cursors: [] } };
|
|
201
|
+
}
|
|
202
|
+
/** The v2 to v8 file envelope: exactly storeSchemaVersion, sha256 and state, with a matching checksum. */
|
|
191
203
|
function readEnvelope(parsed, source) {
|
|
192
204
|
const keys = Object.keys(parsed).sort().join(",");
|
|
193
205
|
if (keys !== "sha256,state,storeSchemaVersion" || typeof parsed.sha256 !== "string" || !isObject(parsed.state)) {
|
|
@@ -348,7 +360,7 @@ function checkRecord(kind, input, where, errors) {
|
|
|
348
360
|
/** All problems with a store state, or [] when it is valid. Never throws. */
|
|
349
361
|
export function validateState(input) {
|
|
350
362
|
const errors = [];
|
|
351
|
-
if (!hasExactKeys(input, ["epoch", "controllers", "runs", "jobs", "attempts", "workers", "artifacts", "cache", "deployments", "deployPolicies"], "state", errors))
|
|
363
|
+
if (!hasExactKeys(input, ["epoch", "controllers", "runs", "jobs", "attempts", "workers", "artifacts", "cache", "deployments", "deployPolicies", "smartCi"], "state", errors))
|
|
352
364
|
return errors;
|
|
353
365
|
const epoch = isCount(input.epoch) ? input.epoch : null;
|
|
354
366
|
if (epoch === null)
|
|
@@ -556,8 +568,57 @@ export function validateState(input) {
|
|
|
556
568
|
validateArtifacts(input, attemptsById, checkEpoch, errors);
|
|
557
569
|
validateDeployments(input, attemptsById, checkEpoch, errors);
|
|
558
570
|
validateDeployPolicies(input, checkEpoch, errors);
|
|
571
|
+
validateSmartCi(input, checkEpoch, errors);
|
|
559
572
|
return errors;
|
|
560
573
|
}
|
|
574
|
+
/** v8 smart-ci namespace: the record and cursor envelopes. Bodies are checked by src/lib/smart-ci. */
|
|
575
|
+
function validateSmartCi(input, checkEpoch, errors) {
|
|
576
|
+
const ns = input.smartCi;
|
|
577
|
+
if (!hasExactKeys(ns, ["records", "cursors"], "state.smartCi", errors))
|
|
578
|
+
return;
|
|
579
|
+
const isTime = (v) => v !== null && isTimeOrNull(v);
|
|
580
|
+
const seen = new Set();
|
|
581
|
+
(Array.isArray(ns.records) ? ns.records : (errors.push("state.smartCi.records: not an array"), [])).forEach((r, i) => {
|
|
582
|
+
const where = `smartCi.records[${i}]`;
|
|
583
|
+
if (!hasExactKeys(r, ["kind", "id", "recordedAt", "recordedEpoch", "updatedAt", "updatedEpoch", "body"], where, errors))
|
|
584
|
+
return;
|
|
585
|
+
if (!isText(r.kind))
|
|
586
|
+
errors.push(`${where}.kind: not a non-empty string`);
|
|
587
|
+
if (!isText(r.id))
|
|
588
|
+
errors.push(`${where}.id: not a non-empty string`);
|
|
589
|
+
if (isText(r.kind) && isText(r.id)) {
|
|
590
|
+
const key = JSON.stringify([r.kind, r.id]);
|
|
591
|
+
if (seen.has(key))
|
|
592
|
+
errors.push(`${where}: duplicate ${r.kind} record ${r.id}`);
|
|
593
|
+
seen.add(key);
|
|
594
|
+
}
|
|
595
|
+
if (!isTime(r.recordedAt))
|
|
596
|
+
errors.push(`${where}.recordedAt: not a timestamp`);
|
|
597
|
+
if (!isTime(r.updatedAt))
|
|
598
|
+
errors.push(`${where}.updatedAt: not a timestamp`);
|
|
599
|
+
checkEpoch(r.recordedEpoch, `${where}.recordedEpoch`);
|
|
600
|
+
checkEpoch(r.updatedEpoch, `${where}.updatedEpoch`);
|
|
601
|
+
if (!isObject(r.body))
|
|
602
|
+
errors.push(`${where}.body: not an object`);
|
|
603
|
+
});
|
|
604
|
+
const streams = new Set();
|
|
605
|
+
(Array.isArray(ns.cursors) ? ns.cursors : (errors.push("state.smartCi.cursors: not an array"), [])).forEach((c, i) => {
|
|
606
|
+
const where = `smartCi.cursors[${i}]`;
|
|
607
|
+
if (!hasExactKeys(c, ["stream", "position", "updatedAt", "updatedEpoch"], where, errors))
|
|
608
|
+
return;
|
|
609
|
+
if (!isText(c.stream))
|
|
610
|
+
errors.push(`${where}.stream: not a non-empty string`);
|
|
611
|
+
else if (streams.has(c.stream))
|
|
612
|
+
errors.push(`${where}: duplicate cursor for stream ${c.stream}`);
|
|
613
|
+
else
|
|
614
|
+
streams.add(c.stream);
|
|
615
|
+
if (typeof c.position !== "string")
|
|
616
|
+
errors.push(`${where}.position: not a string`);
|
|
617
|
+
if (!isTime(c.updatedAt))
|
|
618
|
+
errors.push(`${where}.updatedAt: not a timestamp`);
|
|
619
|
+
checkEpoch(c.updatedEpoch, `${where}.updatedEpoch`);
|
|
620
|
+
});
|
|
621
|
+
}
|
|
561
622
|
const isHex64 = (v) => typeof v === "string" && SHA256_HEX.test(v);
|
|
562
623
|
const isText = (v) => typeof v === "string" && v !== "";
|
|
563
624
|
/** US-008 artifact provenance and cache entries. Signatures are checked by artifacts.ts, which holds the key. */
|
|
@@ -13,9 +13,9 @@ import * as path from 'node:path';
|
|
|
13
13
|
import { jsonFormat } from '../../../commands/mcp-registration.js';
|
|
14
14
|
import { CORE_NEXT_LINK, isCoreNextEntry, isNativeEntry } from '../../hook-engine/registration.js';
|
|
15
15
|
import { isAdapterEntry } from '../../install/codex-targets.js';
|
|
16
|
-
import { uncoveredHooks } from '../../hook-engine/coverage.js';
|
|
16
|
+
import { claudeProjectAdapterHold, uncoveredHooks } from '../../hook-engine/coverage.js';
|
|
17
17
|
import { masterHookPath, shimPath } from '../../install/claude-targets.js';
|
|
18
|
-
import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
|
|
18
|
+
import { CORE_NEXT_FLAG, CORE_NEXT_KILL_ENV, CORE_NEXT_KILL_FILE, ENGINE_KILL_ENV, ENGINE_KILL_FILE, REQUIRED_EVALUATORS, STABLE_LINK_NAME, coreNextEnabled, coreNextKillReason, coreNextTargetFor, missingEvaluators, probeEngine, } from '../../../utils/host-registration.js';
|
|
19
19
|
import { fleetHookCoreResults } from './fleet-hook-core.js';
|
|
20
20
|
import { HOOKS_FAMILY_ID } from '../registry.js';
|
|
21
21
|
export const HOST_CORE_FAMILY_ID = 'host-core';
|
|
@@ -141,7 +141,17 @@ export function hostCoreResults(root, options = {}) {
|
|
|
141
141
|
/** Old-dispatcher hooks for `event` on `host` that the engine's report does not cover. */
|
|
142
142
|
const uncovered = (caps, host, event) => uncoveredHooks(root, host, event, caps.covers, env);
|
|
143
143
|
const listed = (hooks) => (hooks.length > 6 ? `${hooks.slice(0, 6).join(', ')} and ${hooks.length - 6} more` : hooks.join(', '));
|
|
144
|
-
|
|
144
|
+
/**
|
|
145
|
+
* Why an event of `<root>/.claude/settings.json` stays on master-hook.sh for
|
|
146
|
+
* the Codex and Grok Build shell adapters, or null: the answer `hq reindex`
|
|
147
|
+
* acts on (coverage.ts `claudeProjectAdapterHold`), asked of the same target
|
|
148
|
+
* reindex builds for an engine with `caps`, without installing anything.
|
|
149
|
+
*/
|
|
150
|
+
const adapterHold = (caps, event) => {
|
|
151
|
+
const target = coreNextTargetFor(home, env, defaultStableEngine(home, platform), caps, platform, () => { });
|
|
152
|
+
return claudeProjectAdapterHold(root, event, target, env);
|
|
153
|
+
};
|
|
154
|
+
const oldCore = (event, host, scope) => {
|
|
145
155
|
if (!flagOn)
|
|
146
156
|
return { status: 'PASS', reason: `flag ${CORE_NEXT_FLAG} is off` };
|
|
147
157
|
if (killedBy)
|
|
@@ -159,6 +169,11 @@ export function hostCoreResults(root, options = {}) {
|
|
|
159
169
|
const left = uncovered(caps, host, event);
|
|
160
170
|
if (left.length > 0)
|
|
161
171
|
return { status: 'PASS', reason: `the new core does not cover ${listed(left)}` };
|
|
172
|
+
if (host === 'claude' && scope === 'project') {
|
|
173
|
+
const held = adapterHold(caps, event);
|
|
174
|
+
if (held)
|
|
175
|
+
return { status: 'PASS', reason: `held on the old dispatcher while ${held}` };
|
|
176
|
+
}
|
|
162
177
|
return { status: 'WARN', reason: 'the new core can take this event; run hq reindex to switch it' };
|
|
163
178
|
};
|
|
164
179
|
const results = [];
|
|
@@ -233,6 +248,9 @@ export function hostCoreResults(root, options = {}) {
|
|
|
233
248
|
const left = caps && !(caps instanceof Error) ? uncovered(caps, target.host, event) : [];
|
|
234
249
|
if (left.length > 0)
|
|
235
250
|
verdict = { status: 'FAIL', reason: `the new core does not cover ${listed(left)}, so they do not run; run hq reindex to put this event back on the old dispatcher` };
|
|
251
|
+
const held = verdict.status === 'PASS' && caps && !(caps instanceof Error) && target.host === 'claude' && target.scope === 'project' ? adapterHold(caps, event) : null;
|
|
252
|
+
if (held)
|
|
253
|
+
verdict = { status: 'FAIL', reason: `registered to the new core while ${held}, so that adapter finds no master record for it; run hq reindex to put this event back on master-hook.sh` };
|
|
236
254
|
}
|
|
237
255
|
if (verdict.status === 'WARN')
|
|
238
256
|
mixed.push(event);
|
|
@@ -245,7 +263,7 @@ export function hostCoreResults(root, options = {}) {
|
|
|
245
263
|
continue;
|
|
246
264
|
}
|
|
247
265
|
const core = kinds[0];
|
|
248
|
-
events.push({ event, core, ...oldCore(event, target.host) });
|
|
266
|
+
events.push({ event, core, ...oldCore(event, target.host, target.scope) });
|
|
249
267
|
}
|
|
250
268
|
if (events.length === 0) {
|
|
251
269
|
results.push({ status: 'NA', checkId, target: target.file, message: `${target.host} (${target.scope}): no HQ hook registered` });
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import type { PowerShellRun } from "../../windows/user-path.js";
|
|
1
2
|
import type { CheckContext, CheckFamily, CheckResult } from "../types.js";
|
|
2
3
|
export declare const JQ_FAMILY_ID = "jq";
|
|
3
4
|
export declare const JQ_CHECK_ID = "jq.on-path";
|
|
4
5
|
/**
|
|
5
|
-
* Windows
|
|
6
|
-
* master-hook block every tool call without jq.
|
|
7
|
-
* (
|
|
6
|
+
* Windows repair hint for a missing jq. hq-core-staging PR 1882 makes
|
|
7
|
+
* master-hook block every tool call without jq. HQ's own repair comes first
|
|
8
|
+
* and no package manager is named (hq-cli #3716): the repair installs a
|
|
9
|
+
* checksum-verified jq and puts its folder on the user PATH.
|
|
8
10
|
*/
|
|
9
|
-
export declare const JQ_WINDOWS_INSTALL_HINT = "
|
|
11
|
+
export declare const JQ_WINDOWS_INSTALL_HINT = "Run `hq doctor --fix-jq` (it installs the verified jq and adds it to your PATH), then open a new terminal and restart Claude Code; HQ hooks block tool calls until jq is on PATH.";
|
|
12
|
+
/** What to do when jq is on the stored PATH but this process started before it was added. */
|
|
13
|
+
export declare const JQ_RESTART_HINT = "Open a new terminal and restart Claude Code. A session that was already open keeps its old PATH, and its hooks may keep blocking tool calls until it restarts.";
|
|
10
14
|
/** Per-platform install guidance for a missing jq. */
|
|
11
15
|
export declare function jqInstallHint(platform: NodeJS.Platform): string;
|
|
12
16
|
export interface JqCheckDeps {
|
|
@@ -15,11 +19,28 @@ export interface JqCheckDeps {
|
|
|
15
19
|
findJq: () => string | undefined;
|
|
16
20
|
/** `jq --version` output for the binary at `file`; throws when it cannot run. */
|
|
17
21
|
readVersion: (file: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Windows only: the jq on the stored machine and user Path, which is what a
|
|
24
|
+
* new terminal gets. Asked only when `findJq` finds nothing.
|
|
25
|
+
*/
|
|
26
|
+
findPersistedJq?: () => string | undefined;
|
|
18
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The closing check of `hq doctor --fix-jq`: the jq.on-path check, asked about
|
|
30
|
+
* the stored Windows PATH instead of this process's PATH. The stored value is
|
|
31
|
+
* what the next terminal and the next Claude Code session start with, and the
|
|
32
|
+
* terminal running the repair may be the one that still has the old PATH.
|
|
33
|
+
*/
|
|
34
|
+
export declare function verifyJqForNewSessions(options?: {
|
|
35
|
+
powerShell?: PowerShellRun;
|
|
36
|
+
env?: NodeJS.ProcessEnv;
|
|
37
|
+
readVersion?: JqCheckDeps["readVersion"];
|
|
38
|
+
}): CheckResult[];
|
|
19
39
|
/**
|
|
20
40
|
* HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
|
|
21
|
-
* PR 1882 it blocks every PreToolUse call when jq is missing
|
|
22
|
-
*
|
|
41
|
+
* PR 1882 it blocks every PreToolUse call when jq is missing. On Windows the
|
|
42
|
+
* CLI installs jq itself (ensureWindowsJq). This check only reads: it never
|
|
43
|
+
* installs jq.
|
|
23
44
|
*/
|
|
24
45
|
export declare function createJqFamily(deps?: JqCheckDeps): CheckFamily;
|
|
25
46
|
export declare const jqFamily: CheckFamily;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { findExecutableOnPath } from "../../../utils/resolve-executable.js";
|
|
3
3
|
import { JQ_VERSION_RE } from "../../daemon/verified-jq.js";
|
|
4
|
+
import { WINDOWS_JQ_REPAIR, findJqOnPersistedPath } from "../../windows/jq.js";
|
|
4
5
|
export const JQ_FAMILY_ID = "jq";
|
|
5
6
|
export const JQ_CHECK_ID = "jq.on-path";
|
|
6
7
|
/**
|
|
7
|
-
* Windows
|
|
8
|
-
* master-hook block every tool call without jq.
|
|
9
|
-
* (
|
|
8
|
+
* Windows repair hint for a missing jq. hq-core-staging PR 1882 makes
|
|
9
|
+
* master-hook block every tool call without jq. HQ's own repair comes first
|
|
10
|
+
* and no package manager is named (hq-cli #3716): the repair installs a
|
|
11
|
+
* checksum-verified jq and puts its folder on the user PATH.
|
|
10
12
|
*/
|
|
11
|
-
export const JQ_WINDOWS_INSTALL_HINT =
|
|
13
|
+
export const JQ_WINDOWS_INSTALL_HINT = `Run \`${WINDOWS_JQ_REPAIR}\` (it installs the verified jq and adds it to your PATH), then open a new terminal and restart Claude Code; HQ hooks block tool calls until jq is on PATH.`;
|
|
14
|
+
/** What to do when jq is on the stored PATH but this process started before it was added. */
|
|
15
|
+
export const JQ_RESTART_HINT = "Open a new terminal and restart Claude Code. A session that was already open keeps its old PATH, and its hooks may keep blocking tool calls until it restarts.";
|
|
12
16
|
/** Per-platform install guidance for a missing jq. */
|
|
13
17
|
export function jqInstallHint(platform) {
|
|
14
18
|
if (platform === "win32")
|
|
@@ -28,11 +32,26 @@ const defaultDeps = {
|
|
|
28
32
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29
33
|
windowsHide: true,
|
|
30
34
|
}),
|
|
35
|
+
findPersistedJq: () => findJqOnPersistedPath(),
|
|
31
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* The closing check of `hq doctor --fix-jq`: the jq.on-path check, asked about
|
|
39
|
+
* the stored Windows PATH instead of this process's PATH. The stored value is
|
|
40
|
+
* what the next terminal and the next Claude Code session start with, and the
|
|
41
|
+
* terminal running the repair may be the one that still has the old PATH.
|
|
42
|
+
*/
|
|
43
|
+
export function verifyJqForNewSessions(options = {}) {
|
|
44
|
+
return checkJq({ hqRoot: "" }, {
|
|
45
|
+
platform: "win32",
|
|
46
|
+
findJq: () => findJqOnPersistedPath(options.powerShell, options.env),
|
|
47
|
+
readVersion: options.readVersion ?? defaultDeps.readVersion,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
32
50
|
/**
|
|
33
51
|
* HQ's master-hook needs jq to parse every hook payload. Since hq-core-staging
|
|
34
|
-
* PR 1882 it blocks every PreToolUse call when jq is missing
|
|
35
|
-
*
|
|
52
|
+
* PR 1882 it blocks every PreToolUse call when jq is missing. On Windows the
|
|
53
|
+
* CLI installs jq itself (ensureWindowsJq). This check only reads: it never
|
|
54
|
+
* installs jq.
|
|
36
55
|
*/
|
|
37
56
|
export function createJqFamily(deps = defaultDeps) {
|
|
38
57
|
return {
|
|
@@ -44,7 +63,12 @@ export function createJqFamily(deps = defaultDeps) {
|
|
|
44
63
|
export const jqFamily = createJqFamily();
|
|
45
64
|
export function checkJq(_context, deps = defaultDeps) {
|
|
46
65
|
const hint = jqInstallHint(deps.platform);
|
|
47
|
-
|
|
66
|
+
let file = deps.findJq();
|
|
67
|
+
let storedPathOnly = false;
|
|
68
|
+
if (!file && deps.platform === "win32" && deps.findPersistedJq) {
|
|
69
|
+
file = deps.findPersistedJq();
|
|
70
|
+
storedPathOnly = file !== undefined;
|
|
71
|
+
}
|
|
48
72
|
if (!file) {
|
|
49
73
|
return [
|
|
50
74
|
{
|
|
@@ -81,7 +105,21 @@ export function checkJq(_context, deps = defaultDeps) {
|
|
|
81
105
|
checkId: JQ_CHECK_ID,
|
|
82
106
|
target: file,
|
|
83
107
|
message: `The jq on PATH at ${file} is not jq: \`jq --version\` printed "${shown}" instead of jq-1.x. HQ hooks cannot read tool calls with it.`,
|
|
84
|
-
remediation:
|
|
108
|
+
remediation: deps.platform === "win32"
|
|
109
|
+
? `Remove or rename ${file}, then run \`${WINDOWS_JQ_REPAIR}\`. The HQ desktop app replaces a jq that is not jq when it next checks its tools.`
|
|
110
|
+
: `${hint} The HQ desktop app replaces a jq that is not jq when it next checks its tools.`,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
if (storedPathOnly) {
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
status: "WARN",
|
|
118
|
+
checkId: JQ_CHECK_ID,
|
|
119
|
+
target: file,
|
|
120
|
+
message: `${version || "jq"} is on your Windows PATH at ${file}, but this terminal started before it was added.`,
|
|
121
|
+
remediation: JQ_RESTART_HINT,
|
|
122
|
+
details: { version },
|
|
85
123
|
},
|
|
86
124
|
];
|
|
87
125
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFlagClient
|
|
1
|
+
import { createHqFlagClient as createFlagClient } from "../flag-client-headers.js";
|
|
2
2
|
import { resolveFlagRegistryEndpoint } from "../flag-registry-endpoint.js";
|
|
3
3
|
import { getClientHealthFlagToken } from "./client-health-flag-token.js";
|
|
4
4
|
export const CLIENT_HEALTH_REASON_CODES_FLAG = "client-health-sync-reason-codes";
|