@indigoai-us/hq-cli 5.345.219 → 5.345.221
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 +170 -0
- package/dist/command-catalog.generated.d.ts +169 -3
- package/dist/command-catalog.generated.js +206 -3
- package/dist/commands/auth.js +4 -1
- package/dist/commands/bot-runtime.d.ts +18 -5
- package/dist/commands/bot-runtime.js +29 -12
- package/dist/commands/bot.d.ts +85 -0
- package/dist/commands/bot.js +245 -16
- package/dist/commands/cloud.d.ts +16 -0
- package/dist/commands/cloud.js +112 -102
- package/dist/commands/core-checkpoint-native.d.ts +13 -0
- package/dist/commands/core-checkpoint-native.js +167 -52
- package/dist/commands/core-hook-registration-plan.js +5 -4
- package/dist/commands/core-stop-autosave.d.ts +21 -0
- package/dist/commands/core-stop-autosave.js +300 -0
- package/dist/commands/core.js +2 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.js +52 -9
- package/dist/commands/doctor-usage.d.ts +5 -0
- package/dist/commands/doctor-usage.js +25 -0
- package/dist/commands/env.d.ts +49 -4
- package/dist/commands/env.js +355 -5
- package/dist/commands/integrations.js +84 -3
- package/dist/commands/lanes-shared.d.ts +3 -0
- package/dist/commands/lanes.d.ts +3 -0
- package/dist/commands/lanes.js +87 -3
- package/dist/commands/packs.js +23 -0
- package/dist/commands/pkg-update.d.ts +6 -0
- package/dist/commands/pkg-update.js +15 -7
- package/dist/commands/run.js +55 -45
- package/dist/commands/sources.js +4 -3
- package/dist/commands/sync-core.d.ts +1 -0
- package/dist/commands/sync-core.js +77 -3
- package/dist/commands/whoami.js +96 -80
- package/dist/lib/bot/config.d.ts +17 -0
- package/dist/lib/bot/config.js +13 -0
- package/dist/lib/bot/fleet-cron.js +29 -4
- package/dist/lib/bot/fleet-local.d.ts +30 -2
- package/dist/lib/bot/fleet-local.js +60 -1
- package/dist/lib/bot/grok-login-scope.d.ts +36 -0
- package/dist/lib/bot/grok-login-scope.js +93 -0
- package/dist/lib/bot/inflight.d.ts +9 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +51 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +90 -9
- package/dist/lib/bot/legacy-provider-login.d.ts +32 -9
- package/dist/lib/bot/legacy-provider-login.js +28 -22
- package/dist/lib/bot/run.d.ts +29 -5
- package/dist/lib/bot/run.js +203 -1
- package/dist/lib/bot/runtime-sign-in-check.js +6 -1
- package/dist/lib/bot/runtime-sign-in.d.ts +2 -0
- package/dist/lib/bot/signals-try-now.d.ts +76 -0
- package/dist/lib/bot/signals-try-now.js +111 -0
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +22 -3
- package/dist/lib/capacity/collectors/claude-oauth.js +78 -22
- package/dist/lib/capacity/scheduler.d.ts +8 -0
- package/dist/lib/capacity/scheduler.js +5 -2
- package/dist/lib/core-utils/sentry-report.js +2 -0
- package/dist/lib/daemon/machine-checks.d.ts +22 -1
- package/dist/lib/daemon/machine-checks.js +54 -12
- package/dist/lib/daemon/run.js +71 -8
- package/dist/lib/daemon/runtime-notifications.d.ts +7 -0
- package/dist/lib/daemon/runtime-notifications.js +50 -0
- package/dist/lib/daemon/stop-autosave-lock.d.ts +19 -0
- package/dist/lib/daemon/stop-autosave-lock.js +166 -0
- package/dist/lib/daemon/stop-autosave.d.ts +28 -0
- package/dist/lib/daemon/stop-autosave.js +111 -0
- package/dist/lib/daemon/stop-diagnostics.d.ts +11 -0
- package/dist/lib/daemon/stop-diagnostics.js +136 -0
- package/dist/lib/daemon/stop-job-executor.d.ts +19 -0
- package/dist/lib/daemon/stop-job-executor.js +126 -0
- package/dist/lib/daemon/stop-jobs.d.ts +93 -0
- package/dist/lib/daemon/stop-jobs.js +599 -0
- package/dist/lib/doctor/checks/fleet-hook-core.d.ts +9 -1
- package/dist/lib/doctor/checks/fleet-hook-core.js +39 -15
- package/dist/lib/doctor/checks/host-core.js +1 -1
- package/dist/lib/environment/access-probes.d.ts +234 -0
- package/dist/lib/environment/access-probes.js +918 -0
- package/dist/lib/environment/profile.d.ts +15 -2
- package/dist/lib/environment/profile.js +55 -20
- package/dist/lib/environment/rfc3339.d.ts +8 -0
- package/dist/lib/environment/rfc3339.js +26 -0
- package/dist/lib/environment/work-requirements.d.ts +169 -0
- package/dist/lib/environment/work-requirements.js +389 -0
- package/dist/lib/hook-engine/coverage.d.ts +137 -7
- package/dist/lib/hook-engine/coverage.js +1424 -4
- package/dist/lib/hook-engine/fleet-registration.d.ts +17 -5
- package/dist/lib/hook-engine/fleet-registration.js +53 -17
- package/dist/lib/hook-engine/git-stop-config.json +513 -0
- package/dist/lib/hook-engine/native-stop-compatibility.json +311 -0
- package/dist/lib/hook-engine/reconcile.js +2 -2
- package/dist/lib/hot-channels/alert.d.ts +10 -1
- package/dist/lib/hot-channels/alert.js +38 -8
- package/dist/lib/hot-channels/signals-claude-login.d.ts +53 -0
- package/dist/lib/hot-channels/signals-claude-login.js +96 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +143 -17
- package/dist/lib/hot-channels/signals-pass.js +324 -17
- package/dist/lib/hot-channels/signals-runtime.d.ts +30 -0
- package/dist/lib/hot-channels/signals-runtime.js +82 -0
- package/dist/lib/install/hook-target.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +26 -2
- package/dist/lib/lanes/host-capacity.js +17 -2
- package/dist/lib/lanes/host-compute.d.ts +90 -0
- package/dist/lib/lanes/host-compute.js +185 -0
- package/dist/lib/lanes/index.d.ts +2 -0
- package/dist/lib/lanes/index.js +1 -0
- package/dist/lib/lanes/reconcile.js +22 -1
- package/dist/lib/lanes/resource-usage.d.ts +155 -0
- package/dist/lib/lanes/resource-usage.js +589 -0
- package/dist/lib/lanes/run-size.d.ts +46 -0
- package/dist/lib/lanes/run-size.js +197 -0
- package/dist/lib/lanes/store.js +27 -0
- package/dist/lib/lanes/throttle.d.ts +36 -1
- package/dist/lib/lanes/throttle.js +47 -10
- package/dist/lib/lanes/types.d.ts +40 -0
- package/dist/lib/lanes/types.js +2 -2
- package/dist/lib/lanes/watcher.js +13 -4
- package/dist/lib/lanes/worker-process.d.ts +25 -2
- package/dist/lib/lanes/worker-process.js +71 -19
- package/dist/lib/placement/match.d.ts +192 -0
- package/dist/lib/placement/match.js +667 -0
- package/dist/lib/safe-store.d.ts +14 -0
- package/dist/lib/safe-store.js +77 -4
- package/dist/lib/search-index/index.d.ts +88 -4
- package/dist/lib/search-index/index.js +299 -25
- package/dist/lib/search-index/max-doc-bytes.d.ts +17 -6
- package/dist/lib/search-index/max-doc-bytes.js +48 -23
- package/dist/lib/signals/codex-lockdown.d.ts +79 -0
- package/dist/lib/signals/codex-lockdown.js +271 -0
- package/dist/lib/signals/codex-login.d.ts +37 -0
- package/dist/lib/signals/codex-login.js +83 -0
- package/dist/lib/signals/engine.d.ts +28 -0
- package/dist/lib/signals/engine.js +77 -0
- package/dist/lib/signals/reply.d.ts +48 -0
- package/dist/lib/signals/reply.js +94 -12
- package/dist/lib/signals/run-record.js +6 -1
- package/dist/lib/signals/settings.d.ts +5 -0
- package/dist/lib/signals/settings.js +2 -0
- package/dist/lib/signals/steps/adapters.js +6 -0
- package/dist/lib/signals/steps/extract.d.ts +135 -12
- package/dist/lib/signals/steps/extract.js +416 -84
- package/dist/lib/signals/steps/types.d.ts +21 -0
- package/dist/lib/sync-core/engine-home.d.ts +41 -2
- package/dist/lib/sync-core/engine-home.js +132 -19
- package/dist/lib/sync-core/reconcile.js +1 -1
- package/dist/lib/sync-core/release-compare.d.ts +7 -0
- package/dist/lib/sync-core/release-compare.js +16 -0
- package/dist/lib/sync-core/release.d.ts +2 -1
- package/dist/lib/sync-core/release.js +2 -10
- package/dist/lib/sync-core/rollout-state.d.ts +2 -1
- package/dist/lib/sync-core/rollout-state.js +5 -2
- package/dist/lib/sync-core/vault-uid.d.ts +2 -0
- package/dist/lib/sync-core/vault-uid.js +4 -0
- package/dist/run/schema-env-overrides.d.ts +24 -0
- package/dist/run/schema-env-overrides.js +72 -0
- package/dist/schemas/hq-work-requirements.v1.schema.json +145 -0
- package/dist/utils/auth-session-check.d.ts +16 -0
- package/dist/utils/auth-session-check.js +16 -0
- package/dist/utils/client-health-contract.d.ts +6 -0
- package/dist/utils/client-health-contract.js +13 -0
- package/dist/utils/client-health.d.ts +7 -0
- package/dist/utils/client-health.js +22 -1
- package/dist/utils/command-usage.d.ts +40 -0
- package/dist/utils/command-usage.js +61 -0
- package/dist/utils/duplicate-command-usage.d.ts +72 -0
- package/dist/utils/duplicate-command-usage.js +125 -0
- package/dist/utils/host-registration.d.ts +1 -1
- package/dist/utils/host-registration.js +6 -1
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/sentry-fingerprint.js +9 -0
- package/dist/utils/windows-bash.d.ts +2 -0
- package/dist/utils/windows-bash.js +2 -1
- package/package.json +15 -10
- package/scripts/bench-core-compare.mjs +313 -0
- package/scripts/bench-core.mjs +399 -12
- package/scripts/check-function-manifest.mjs +121 -7
- package/dist/commands/__fixtures__/access-vault.d.ts +0 -95
- package/dist/commands/__fixtures__/access-vault.js +0 -166
- package/dist/commands/__fixtures__/make-tar.d.ts +0 -38
- package/dist/commands/__fixtures__/make-tar.js +0 -102
- package/dist/commands/secrets-public-types.test-d.d.ts +0 -2
- package/dist/commands/secrets-public-types.test-d.js +0 -18
- package/dist/lib/decisions/fixtures/us001.d.ts +0 -137
- package/dist/lib/decisions/fixtures/us001.js +0 -21
- package/dist/lib/doctor/__testing__/fake-hq-tree.d.ts +0 -226
- package/dist/lib/doctor/__testing__/fake-hq-tree.js +0 -408
- package/dist/lib/doctor/__testing__/run-doctor.d.ts +0 -8
- package/dist/lib/doctor/__testing__/run-doctor.js +0 -69
- package/dist/lib/fingerprint/fixtures.d.ts +0 -19
- package/dist/lib/fingerprint/fixtures.js +0 -61
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.d.ts +0 -33
- package/dist/lib/hot-channels/adapters/__fixtures__/dummy.js +0 -53
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.d.ts +0 -38
- package/dist/lib/hot-channels/adapters/__fixtures__/meeting-providers.js +0 -64
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.d.ts +0 -2
- package/dist/lib/mesh/live/daemon/mqtt-events.test-d.js +0 -10
- package/dist/lib/test-utils/isolated-flag-company-context.d.ts +0 -3
- package/dist/lib/test-utils/isolated-flag-company-context.js +0 -18
- package/scripts/hook-engine-manifest.mjs +0 -22
- package/scripts/mesh-daemon-if-stale.mjs +0 -20
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which bot the hot-channel signals pass takes its runtime from, and which
|
|
3
|
+
* Codex login it uses.
|
|
4
|
+
*
|
|
5
|
+
* The pass runs on Claude Code unless the Executive bot is a Codex bot whose
|
|
6
|
+
* bot.json has `signalsRuntime: "bot"` (signalsPassRuntime in bot/config.ts).
|
|
7
|
+
* Both `hq bot run` (the hot-signal-sync job) and `hq sources sync` use the
|
|
8
|
+
* Executive bot, the bot whose runtime the pass already read for its wording
|
|
9
|
+
* (defaultResolveBotRuntime) and the one the signals engine's extract step
|
|
10
|
+
* reads, so a Claude bot behaves exactly as before. bot.json is read when the
|
|
11
|
+
* pass asks, so `hq bot set <name> --signals-runtime ...` applies from the
|
|
12
|
+
* next pass without a restart.
|
|
13
|
+
*/
|
|
14
|
+
import { signalsCodexLogin, type SignalsCodexLogin } from "../signals/codex-login.js";
|
|
15
|
+
import type { ClaudeSignalsPassOptions } from "./signals-pass.js";
|
|
16
|
+
export { signalsCodexLogin, type SignalsCodexLogin } from "../signals/codex-login.js";
|
|
17
|
+
export type SignalsRuntimeOptions = Required<Pick<ClaudeSignalsPassOptions, "botRuntime" | "useBotRuntime" | "botRuntimeEnv">>;
|
|
18
|
+
/**
|
|
19
|
+
* signalsCodexLogin, plus the extract step's refusal of a login folder that
|
|
20
|
+
* holds files Codex would load as instructions (AGENTS.md,
|
|
21
|
+
* AGENTS.override.md, user skills). The one gate the pass, `hq bot status`
|
|
22
|
+
* and `hq bot set --signals-runtime` all read, including the HQ Fleet
|
|
23
|
+
* Runtime refusal.
|
|
24
|
+
*/
|
|
25
|
+
export declare function signalsPassCodexLogin(dir: string, config: Parameters<typeof signalsCodexLogin>[1], base?: NodeJS.ProcessEnv): SignalsCodexLogin;
|
|
26
|
+
/** The options for a pass that runs on the bot in `dir`. */
|
|
27
|
+
export declare function botSignalsRuntimeOptions(dir: string, base?: NodeJS.ProcessEnv): SignalsRuntimeOptions;
|
|
28
|
+
/** The options for a pass run outside a bot (`hq sources sync`): the Executive bot's. */
|
|
29
|
+
export declare function executiveSignalsRuntimeOptions(root?: string, base?: NodeJS.ProcessEnv): SignalsRuntimeOptions;
|
|
30
|
+
//# sourceMappingURL=signals-runtime.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which bot the hot-channel signals pass takes its runtime from, and which
|
|
3
|
+
* Codex login it uses.
|
|
4
|
+
*
|
|
5
|
+
* The pass runs on Claude Code unless the Executive bot is a Codex bot whose
|
|
6
|
+
* bot.json has `signalsRuntime: "bot"` (signalsPassRuntime in bot/config.ts).
|
|
7
|
+
* Both `hq bot run` (the hot-signal-sync job) and `hq sources sync` use the
|
|
8
|
+
* Executive bot, the bot whose runtime the pass already read for its wording
|
|
9
|
+
* (defaultResolveBotRuntime) and the one the signals engine's extract step
|
|
10
|
+
* reads, so a Claude bot behaves exactly as before. bot.json is read when the
|
|
11
|
+
* pass asks, so `hq bot set <name> --signals-runtime ...` applies from the
|
|
12
|
+
* next pass without a restart.
|
|
13
|
+
*/
|
|
14
|
+
import { readBotConfig, signalsPassRuntime, isBotRuntimeId } from "../bot/config.js";
|
|
15
|
+
import { resolveExecutiveBot } from "../bot/executive.js";
|
|
16
|
+
import { botsRoot } from "../bot/paths.js";
|
|
17
|
+
import { signalsCodexLogin } from "../signals/codex-login.js";
|
|
18
|
+
import { codexHomeInstructions } from "../signals/steps/extract.js";
|
|
19
|
+
// The shared login rule lives in signals/codex-login.ts; re-exported for callers here.
|
|
20
|
+
export { signalsCodexLogin } from "../signals/codex-login.js";
|
|
21
|
+
/**
|
|
22
|
+
* signalsCodexLogin, plus the extract step's refusal of a login folder that
|
|
23
|
+
* holds files Codex would load as instructions (AGENTS.md,
|
|
24
|
+
* AGENTS.override.md, user skills). The one gate the pass, `hq bot status`
|
|
25
|
+
* and `hq bot set --signals-runtime` all read, including the HQ Fleet
|
|
26
|
+
* Runtime refusal.
|
|
27
|
+
*/
|
|
28
|
+
export function signalsPassCodexLogin(dir, config, base = process.env) {
|
|
29
|
+
const login = signalsCodexLogin(dir, config, base);
|
|
30
|
+
if (!login.ok)
|
|
31
|
+
return login;
|
|
32
|
+
const instructions = codexHomeInstructions(login.codexHome);
|
|
33
|
+
if (instructions.length > 0) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
reason: `${config.name}'s Codex login folder holds ${instructions.join(", ")}, which Codex would load as instructions. Remove ${instructions.length === 1 ? "it" : "them"} from ${login.codexHome}`,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return login;
|
|
40
|
+
}
|
|
41
|
+
/** The options for a pass that runs on the bot in `dir`. */
|
|
42
|
+
export function botSignalsRuntimeOptions(dir, base = process.env) {
|
|
43
|
+
return {
|
|
44
|
+
botRuntime: () => {
|
|
45
|
+
const config = readBotConfig(dir);
|
|
46
|
+
return config && isBotRuntimeId(config.runtime) ? config.runtime : null;
|
|
47
|
+
},
|
|
48
|
+
useBotRuntime: () => signalsPassRuntime(readBotConfig(dir)) === "codex",
|
|
49
|
+
// signalsCodexLogin: the bot's own Codex login, or a throw, which fails
|
|
50
|
+
// the pass signed out instead of using another login.
|
|
51
|
+
botRuntimeEnv: () => {
|
|
52
|
+
const config = readBotConfig(dir);
|
|
53
|
+
if (!config)
|
|
54
|
+
throw new Error("the bot's config is not readable");
|
|
55
|
+
const login = signalsPassCodexLogin(dir, config, base);
|
|
56
|
+
if (!login.ok)
|
|
57
|
+
throw new Error(login.reason);
|
|
58
|
+
// Only the ok variant is a login dir this pass can point CODEX_HOME at.
|
|
59
|
+
if (!("codexHome" in login))
|
|
60
|
+
throw new Error(`${config.name}'s Codex login cannot be lent to a signals turn`);
|
|
61
|
+
return login.env;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The options for a pass run outside a bot (`hq sources sync`): the Executive bot's. */
|
|
66
|
+
export function executiveSignalsRuntimeOptions(root = botsRoot(), base = process.env) {
|
|
67
|
+
const executive = () => {
|
|
68
|
+
const bot = resolveExecutiveBot({ root });
|
|
69
|
+
return bot ? botSignalsRuntimeOptions(bot.dir, base) : null;
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
botRuntime: () => executive()?.botRuntime() ?? null,
|
|
73
|
+
useBotRuntime: () => executive()?.useBotRuntime() ?? false,
|
|
74
|
+
botRuntimeEnv: () => {
|
|
75
|
+
const options = executive();
|
|
76
|
+
if (!options)
|
|
77
|
+
throw new Error("there is no Executive bot on this computer");
|
|
78
|
+
return options.botRuntimeEnv();
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=signals-runtime.js.map
|
|
@@ -40,7 +40,7 @@ export function hookTargetFor(hqRoot, home, daemonInstalled, env = process.env,
|
|
|
40
40
|
// other event keeps the flag-off target. A failure to set up the new core
|
|
41
41
|
// is one warning, and install goes on with the flag-off target for every
|
|
42
42
|
// event.
|
|
43
|
-
const coreNext = forHost(coreNextTargetOrWarn(home, env), hqRoot, host);
|
|
43
|
+
const coreNext = forHost(coreNextTargetOrWarn(home, env), hqRoot, host, env);
|
|
44
44
|
const fallback = legacyHookTarget(hqRoot, home, daemonInstalled, env);
|
|
45
45
|
return coreNext ? { ...coreNext, fallback } : fallback;
|
|
46
46
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AuthState } from "./accounts.js";
|
|
2
2
|
import type { ClaudeCredentialReader } from "./claude-credential.js";
|
|
3
|
+
import { type HostComputeReading } from "./host-compute.js";
|
|
3
4
|
import type { LocalHostMatch } from "./local-host-identity.js";
|
|
4
5
|
import { type QuotaState } from "./quota.js";
|
|
5
6
|
import type { LaneHost, LaneProvider, LaneRecord, LanesConfig } from "./types.js";
|
|
@@ -51,6 +52,20 @@ export interface HostCapacitySnapshot {
|
|
|
51
52
|
host_aliases?: string[];
|
|
52
53
|
sampled_at: string;
|
|
53
54
|
providers: Record<LaneProvider, HostCapacityProvider>;
|
|
55
|
+
/**
|
|
56
|
+
* CPU, memory and disk on this host (PS-004), in the shape of
|
|
57
|
+
* hq-environment-profile.v1 `readings.compute`. Absent when the producer did
|
|
58
|
+
* not sample it (older CLIs, snapshots built for placement only) or a
|
|
59
|
+
* required value could not be read. Informational: placement does not use
|
|
60
|
+
* it yet, and a stale reading is never room (see `computeHeadroom`).
|
|
61
|
+
*/
|
|
62
|
+
compute?: HostComputeReading;
|
|
63
|
+
/**
|
|
64
|
+
* Present with `compute`. true when the reading is past its ttl_seconds:
|
|
65
|
+
* false where it was sampled, re-checked against the reader's clock when a
|
|
66
|
+
* snapshot from another host is parsed.
|
|
67
|
+
*/
|
|
68
|
+
compute_stale?: boolean;
|
|
54
69
|
}
|
|
55
70
|
/** The printed form: `hq runners capacity --json` and the remote capacity probe. */
|
|
56
71
|
export type HostCapacitySnapshotWire = Omit<HostCapacitySnapshot, "host" | "host_aliases"> & {
|
|
@@ -95,9 +110,18 @@ export declare function buildHostCapacitySnapshot(input: {
|
|
|
95
110
|
now: Date;
|
|
96
111
|
quotaState?: QuotaState;
|
|
97
112
|
readClaudeCredential?: ClaudeCredentialReader;
|
|
113
|
+
/** This host's compute reading, from `readHostCompute`. */
|
|
114
|
+
compute?: HostComputeReading | null;
|
|
98
115
|
}): HostCapacitySnapshot;
|
|
99
|
-
/**
|
|
100
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Reject malformed remote snapshots before they can influence host selection.
|
|
118
|
+
*
|
|
119
|
+
* A compute block that breaks the schema's rules is dropped rather than
|
|
120
|
+
* failing the snapshot: placement does not read it, so it must not make a host
|
|
121
|
+
* unavailable. A kept block is marked stale when the producer said so or when
|
|
122
|
+
* it is past its ttl at `now`.
|
|
123
|
+
*/
|
|
124
|
+
export declare function parseHostCapacitySnapshot(raw: unknown, now?: Date): HostCapacitySnapshot;
|
|
101
125
|
/**
|
|
102
126
|
* Choose the least-loaded eligible host/account from advisory snapshots. The
|
|
103
127
|
* selected host still runs the shared admission check under its own lock.
|
|
@@ -2,6 +2,7 @@ import { accountStatus } from "./accounts.js";
|
|
|
2
2
|
import { accountMaxRunning } from "./config.js";
|
|
3
3
|
import { laneOccupiesRunningSlot, laneRunsOnHost, } from "./admission.js";
|
|
4
4
|
import { HOST_ALIAS_LIMIT } from "./canonical-host.js";
|
|
5
|
+
import { computeReadingIsStale, parseHostComputeReading, } from "./host-compute.js";
|
|
5
6
|
import { LanesError } from "./errors.js";
|
|
6
7
|
import { quotaBlockFor, quotaHitInfo } from "./quota.js";
|
|
7
8
|
function admissionHost(host) {
|
|
@@ -91,6 +92,9 @@ export function buildHostCapacitySnapshot(input) {
|
|
|
91
92
|
...(input.aliases !== undefined ? { host_aliases: [...input.aliases] } : {}),
|
|
92
93
|
sampled_at: input.now.toISOString(),
|
|
93
94
|
providers,
|
|
95
|
+
...(input.compute
|
|
96
|
+
? { compute: input.compute, compute_stale: computeReadingIsStale(input.compute, input.now) }
|
|
97
|
+
: {}),
|
|
94
98
|
};
|
|
95
99
|
}
|
|
96
100
|
function objectValue(value) {
|
|
@@ -109,8 +113,15 @@ function requireCount(value, field, positive = false) {
|
|
|
109
113
|
}
|
|
110
114
|
return value;
|
|
111
115
|
}
|
|
112
|
-
/**
|
|
113
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Reject malformed remote snapshots before they can influence host selection.
|
|
118
|
+
*
|
|
119
|
+
* A compute block that breaks the schema's rules is dropped rather than
|
|
120
|
+
* failing the snapshot: placement does not read it, so it must not make a host
|
|
121
|
+
* unavailable. A kept block is marked stale when the producer said so or when
|
|
122
|
+
* it is past its ttl at `now`.
|
|
123
|
+
*/
|
|
124
|
+
export function parseHostCapacitySnapshot(raw, now = new Date()) {
|
|
114
125
|
const root = objectValue(raw);
|
|
115
126
|
const hostRaw = objectValue(root?.host);
|
|
116
127
|
const providersRaw = objectValue(root?.providers);
|
|
@@ -193,12 +204,16 @@ export function parseHostCapacitySnapshot(raw) {
|
|
|
193
204
|
accounts,
|
|
194
205
|
};
|
|
195
206
|
}
|
|
207
|
+
const compute = root.compute === undefined ? null : parseHostComputeReading(root.compute);
|
|
196
208
|
return {
|
|
197
209
|
schema_version: "hq-lanes-host-capacity.v1",
|
|
198
210
|
host: { kind: hostRaw.kind, id: hostRaw.id },
|
|
199
211
|
...(hostAliases !== undefined ? { host_aliases: hostAliases } : {}),
|
|
200
212
|
sampled_at: root.sampled_at,
|
|
201
213
|
providers,
|
|
214
|
+
...(compute !== null
|
|
215
|
+
? { compute, compute_stale: root.compute_stale === true || computeReadingIsStale(compute, now) }
|
|
216
|
+
: {}),
|
|
202
217
|
};
|
|
203
218
|
}
|
|
204
219
|
function parseLaneCounts(value, field) {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compute reading in a host capacity snapshot (PS-004): vCPU count, load
|
|
3
|
+
* per vCPU, memory total and available, and disk total and free on the HQ
|
|
4
|
+
* root's filesystem, with observed_at and ttl_seconds.
|
|
5
|
+
*
|
|
6
|
+
* The fields are those of `readings.compute` in hq-environment-profile.v1
|
|
7
|
+
* (src/schemas/hq-environment-profile.v1.schema.json), so a block printed by
|
|
8
|
+
* `hq runners capacity --json` can be copied into a profile unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Every value comes from a sampler lane admission already uses: os.cpus()
|
|
11
|
+
* through ThrottleDeps for the vCPU count, readMemorySignal for available
|
|
12
|
+
* memory (MemAvailable on Linux; on darwin vm_stat free + inactive +
|
|
13
|
+
* speculative pages, the figure the PS-001 profile records, then the
|
|
14
|
+
* memory_pressure sysctls only if vm_stat fails), and measureDiskSpace
|
|
15
|
+
* (statfs) for the disk. This module adds no sampler of its own. Lane
|
|
16
|
+
* admission's memory gate is unchanged and still reads memory_pressure first
|
|
17
|
+
* on darwin.
|
|
18
|
+
*
|
|
19
|
+
* A reading older than its ttl_seconds is stale. A stale reading is still
|
|
20
|
+
* printed, marked stale, and `computeHeadroom` returns null for it, so it is
|
|
21
|
+
* never counted as room on a host.
|
|
22
|
+
*/
|
|
23
|
+
import { type StatFs } from "./disk-guard.js";
|
|
24
|
+
import { type ThrottleDeps } from "./throttle.js";
|
|
25
|
+
/** How long a compute reading counts as current. */
|
|
26
|
+
export declare const HOST_COMPUTE_TTL_SECONDS = 60;
|
|
27
|
+
/**
|
|
28
|
+
* The compute block. Field names and types follow `$defs/compute` in the
|
|
29
|
+
* PS-001 schema; that definition allows no other properties, so staleness is
|
|
30
|
+
* carried beside the block (`compute_stale`), not inside it.
|
|
31
|
+
*
|
|
32
|
+
* Units: memory in MiB, disk in GiB (what `df -h` prints as G).
|
|
33
|
+
*/
|
|
34
|
+
export interface HostComputeReading {
|
|
35
|
+
observed_at: string;
|
|
36
|
+
ttl_seconds: number;
|
|
37
|
+
source: string;
|
|
38
|
+
vcpu_online: number;
|
|
39
|
+
load_1m: number | null;
|
|
40
|
+
load_per_vcpu: number | null;
|
|
41
|
+
mem_total_mb?: number;
|
|
42
|
+
mem_available_mb: number;
|
|
43
|
+
/** Absent only on a block from another host that left it out. */
|
|
44
|
+
disk_total_gb?: number;
|
|
45
|
+
disk_free_gb: number;
|
|
46
|
+
}
|
|
47
|
+
export type HostComputeDeps = Pick<ThrottleDeps, "cpus" | "readFileSync" | "freemem" | "platform" | "execFileSync" | "loadavg" | "totalmem">;
|
|
48
|
+
/**
|
|
49
|
+
* Read this host's compute block, or null when the vCPU count, available
|
|
50
|
+
* memory or disk cannot be read. Those three are required by the schema; a
|
|
51
|
+
* block without them is not printed at all.
|
|
52
|
+
*/
|
|
53
|
+
export declare function readHostCompute(input: {
|
|
54
|
+
deps: HostComputeDeps;
|
|
55
|
+
/** The filesystem to measure: the HQ root, where lane worktrees live. */
|
|
56
|
+
diskPath: string;
|
|
57
|
+
statfs?: StatFs;
|
|
58
|
+
now: Date;
|
|
59
|
+
ttlSeconds?: number;
|
|
60
|
+
}): HostComputeReading | null;
|
|
61
|
+
/**
|
|
62
|
+
* Whether a reading is past its ttl at `now`. A reading whose observed_at
|
|
63
|
+
* cannot be parsed, or lies further in the future than its ttl (a skewed
|
|
64
|
+
* clock), is stale too.
|
|
65
|
+
*/
|
|
66
|
+
export declare function computeReadingIsStale(reading: Pick<HostComputeReading, "observed_at" | "ttl_seconds">, now: Date): boolean;
|
|
67
|
+
/** What a current compute reading says is free on a host. */
|
|
68
|
+
export interface HostComputeHeadroom {
|
|
69
|
+
vcpu_online: number;
|
|
70
|
+
load_per_vcpu: number | null;
|
|
71
|
+
mem_available_mb: number;
|
|
72
|
+
disk_free_gb: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The room a compute reading reports, or null when there is no reading, the
|
|
76
|
+
* snapshot marked it stale, or it is past its ttl at `now`. A stale reading is
|
|
77
|
+
* never room.
|
|
78
|
+
*/
|
|
79
|
+
export declare function computeHeadroom(snapshot: {
|
|
80
|
+
compute?: HostComputeReading;
|
|
81
|
+
compute_stale?: boolean;
|
|
82
|
+
}, now: Date): HostComputeHeadroom | null;
|
|
83
|
+
/**
|
|
84
|
+
* Check a compute block from another host against the rules of the schema's
|
|
85
|
+
* `$defs/compute`, without loading the schema validator on the placement path.
|
|
86
|
+
* `host-compute.test.ts` checks this function and the schema agree. Returns
|
|
87
|
+
* null for a block either would reject.
|
|
88
|
+
*/
|
|
89
|
+
export declare function parseHostComputeReading(raw: unknown): HostComputeReading | null;
|
|
90
|
+
//# sourceMappingURL=host-compute.d.ts.map
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The compute reading in a host capacity snapshot (PS-004): vCPU count, load
|
|
3
|
+
* per vCPU, memory total and available, and disk total and free on the HQ
|
|
4
|
+
* root's filesystem, with observed_at and ttl_seconds.
|
|
5
|
+
*
|
|
6
|
+
* The fields are those of `readings.compute` in hq-environment-profile.v1
|
|
7
|
+
* (src/schemas/hq-environment-profile.v1.schema.json), so a block printed by
|
|
8
|
+
* `hq runners capacity --json` can be copied into a profile unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Every value comes from a sampler lane admission already uses: os.cpus()
|
|
11
|
+
* through ThrottleDeps for the vCPU count, readMemorySignal for available
|
|
12
|
+
* memory (MemAvailable on Linux; on darwin vm_stat free + inactive +
|
|
13
|
+
* speculative pages, the figure the PS-001 profile records, then the
|
|
14
|
+
* memory_pressure sysctls only if vm_stat fails), and measureDiskSpace
|
|
15
|
+
* (statfs) for the disk. This module adds no sampler of its own. Lane
|
|
16
|
+
* admission's memory gate is unchanged and still reads memory_pressure first
|
|
17
|
+
* on darwin.
|
|
18
|
+
*
|
|
19
|
+
* A reading older than its ttl_seconds is stale. A stale reading is still
|
|
20
|
+
* printed, marked stale, and `computeHeadroom` returns null for it, so it is
|
|
21
|
+
* never counted as room on a host.
|
|
22
|
+
*/
|
|
23
|
+
import * as os from "node:os";
|
|
24
|
+
import { measureDiskSpace } from "./disk-guard.js";
|
|
25
|
+
import { isRfc3339DateTime } from "../environment/rfc3339.js";
|
|
26
|
+
import { readMemorySignal, readMemoryTotal } from "./throttle.js";
|
|
27
|
+
/** How long a compute reading counts as current. */
|
|
28
|
+
export const HOST_COMPUTE_TTL_SECONDS = 60;
|
|
29
|
+
const GIB = 1024 ** 3;
|
|
30
|
+
function round(value, places) {
|
|
31
|
+
const factor = 10 ** places;
|
|
32
|
+
return Math.round(value * factor) / factor;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Read this host's compute block, or null when the vCPU count, available
|
|
36
|
+
* memory or disk cannot be read. Those three are required by the schema; a
|
|
37
|
+
* block without them is not printed at all.
|
|
38
|
+
*/
|
|
39
|
+
export function readHostCompute(input) {
|
|
40
|
+
const { deps } = input;
|
|
41
|
+
let vcpu;
|
|
42
|
+
try {
|
|
43
|
+
vcpu = deps.cpus().length;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isInteger(vcpu) || vcpu < 1)
|
|
49
|
+
return null;
|
|
50
|
+
const memory = readMemorySignal(deps, { darwinPrimary: "vm_stat" });
|
|
51
|
+
if (memory === null || !Number.isFinite(memory.available_mb) || memory.available_mb < 0)
|
|
52
|
+
return null;
|
|
53
|
+
const total = readMemoryTotal(deps);
|
|
54
|
+
let disk;
|
|
55
|
+
try {
|
|
56
|
+
disk = input.statfs
|
|
57
|
+
? measureDiskSpace(input.diskPath, input.statfs)
|
|
58
|
+
: measureDiskSpace(input.diskPath);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
// os.loadavg() is always [0, 0, 0] on Windows, which is not a reading.
|
|
64
|
+
let load1m = null;
|
|
65
|
+
if (deps.platform() !== "win32") {
|
|
66
|
+
try {
|
|
67
|
+
const value = (deps.loadavg ?? os.loadavg)()[0];
|
|
68
|
+
load1m = typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : null;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
load1m = null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const sources = [
|
|
75
|
+
"os.cpus",
|
|
76
|
+
...(load1m !== null ? ["os.loadavg"] : []),
|
|
77
|
+
`memory available: ${memory.source}`,
|
|
78
|
+
...(total !== null ? [`memory total: ${total.source}`] : []),
|
|
79
|
+
"disk: statfs(hq root)",
|
|
80
|
+
];
|
|
81
|
+
return {
|
|
82
|
+
observed_at: input.now.toISOString(),
|
|
83
|
+
ttl_seconds: input.ttlSeconds ?? HOST_COMPUTE_TTL_SECONDS,
|
|
84
|
+
source: sources.join("; "),
|
|
85
|
+
vcpu_online: vcpu,
|
|
86
|
+
load_1m: load1m === null ? null : round(load1m, 2),
|
|
87
|
+
load_per_vcpu: load1m === null ? null : round(load1m / vcpu, 3),
|
|
88
|
+
...(total !== null ? { mem_total_mb: Math.round(total.total_mb) } : {}),
|
|
89
|
+
mem_available_mb: Math.floor(memory.available_mb),
|
|
90
|
+
disk_total_gb: round(disk.total_bytes / GIB, 1),
|
|
91
|
+
disk_free_gb: round(disk.free_bytes / GIB, 1),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Whether a reading is past its ttl at `now`. A reading whose observed_at
|
|
96
|
+
* cannot be parsed, or lies further in the future than its ttl (a skewed
|
|
97
|
+
* clock), is stale too.
|
|
98
|
+
*/
|
|
99
|
+
export function computeReadingIsStale(reading, now) {
|
|
100
|
+
const observed = Date.parse(reading.observed_at);
|
|
101
|
+
if (!Number.isFinite(observed) || !Number.isInteger(reading.ttl_seconds) || reading.ttl_seconds < 0)
|
|
102
|
+
return true;
|
|
103
|
+
const ttlMs = reading.ttl_seconds * 1000;
|
|
104
|
+
const age = now.getTime() - observed;
|
|
105
|
+
return age > ttlMs || age < -ttlMs;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The room a compute reading reports, or null when there is no reading, the
|
|
109
|
+
* snapshot marked it stale, or it is past its ttl at `now`. A stale reading is
|
|
110
|
+
* never room.
|
|
111
|
+
*/
|
|
112
|
+
export function computeHeadroom(snapshot, now) {
|
|
113
|
+
const reading = snapshot.compute;
|
|
114
|
+
if (reading === undefined || snapshot.compute_stale === true || computeReadingIsStale(reading, now))
|
|
115
|
+
return null;
|
|
116
|
+
return {
|
|
117
|
+
vcpu_online: reading.vcpu_online,
|
|
118
|
+
load_per_vcpu: reading.load_per_vcpu,
|
|
119
|
+
mem_available_mb: reading.mem_available_mb,
|
|
120
|
+
disk_free_gb: reading.disk_free_gb,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const COMPUTE_FIELDS = new Set([
|
|
124
|
+
"observed_at",
|
|
125
|
+
"ttl_seconds",
|
|
126
|
+
"source",
|
|
127
|
+
"vcpu_online",
|
|
128
|
+
"load_1m",
|
|
129
|
+
"load_per_vcpu",
|
|
130
|
+
"mem_total_mb",
|
|
131
|
+
"mem_available_mb",
|
|
132
|
+
"disk_total_gb",
|
|
133
|
+
"disk_free_gb",
|
|
134
|
+
]);
|
|
135
|
+
function nonNegativeInteger(value) {
|
|
136
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
137
|
+
}
|
|
138
|
+
function nonNegativeNumber(value) {
|
|
139
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
140
|
+
}
|
|
141
|
+
function nullableNonNegativeNumber(value) {
|
|
142
|
+
return value === null || nonNegativeNumber(value);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check a compute block from another host against the rules of the schema's
|
|
146
|
+
* `$defs/compute`, without loading the schema validator on the placement path.
|
|
147
|
+
* `host-compute.test.ts` checks this function and the schema agree. Returns
|
|
148
|
+
* null for a block either would reject.
|
|
149
|
+
*/
|
|
150
|
+
export function parseHostComputeReading(raw) {
|
|
151
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
152
|
+
return null;
|
|
153
|
+
const value = raw;
|
|
154
|
+
if (Object.keys(value).some((key) => !COMPUTE_FIELDS.has(key)))
|
|
155
|
+
return null;
|
|
156
|
+
if (
|
|
157
|
+
// The schema's date-time rule, so a real calendar date is required. A leap
|
|
158
|
+
// second (:60) passes it but not Date.parse, so computeReadingIsStale
|
|
159
|
+
// reports such a reading stale.
|
|
160
|
+
typeof value.observed_at !== "string" || !isRfc3339DateTime(value.observed_at) ||
|
|
161
|
+
!nonNegativeInteger(value.ttl_seconds) ||
|
|
162
|
+
typeof value.source !== "string" || value.source === "" ||
|
|
163
|
+
!nonNegativeInteger(value.vcpu_online) || value.vcpu_online < 1 ||
|
|
164
|
+
!nonNegativeInteger(value.mem_available_mb) ||
|
|
165
|
+
!nonNegativeNumber(value.disk_free_gb) ||
|
|
166
|
+
(value.load_1m !== undefined && !nullableNonNegativeNumber(value.load_1m)) ||
|
|
167
|
+
(value.load_per_vcpu !== undefined && !nullableNonNegativeNumber(value.load_per_vcpu)) ||
|
|
168
|
+
(value.mem_total_mb !== undefined && !nonNegativeInteger(value.mem_total_mb)) ||
|
|
169
|
+
(value.disk_total_gb !== undefined && !nonNegativeNumber(value.disk_total_gb))) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
observed_at: value.observed_at,
|
|
174
|
+
ttl_seconds: value.ttl_seconds,
|
|
175
|
+
source: value.source,
|
|
176
|
+
vcpu_online: value.vcpu_online,
|
|
177
|
+
load_1m: value.load_1m ?? null,
|
|
178
|
+
load_per_vcpu: value.load_per_vcpu ?? null,
|
|
179
|
+
...(value.mem_total_mb !== undefined ? { mem_total_mb: value.mem_total_mb } : {}),
|
|
180
|
+
mem_available_mb: value.mem_available_mb,
|
|
181
|
+
...(value.disk_total_gb !== undefined ? { disk_total_gb: value.disk_total_gb } : {}),
|
|
182
|
+
disk_free_gb: value.disk_free_gb,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=host-compute.js.map
|
|
@@ -9,6 +9,8 @@ export { compareLaneQueueOrder, hasActiveAdmissionReservation, hasActivePendingR
|
|
|
9
9
|
export type { AdmissionCapReason, AdmissionHost } from "./admission.js";
|
|
10
10
|
export { buildHostCapacitySnapshot, chooseHostForLane, parseHostCapacitySnapshot, } from "./host-capacity.js";
|
|
11
11
|
export type { HostCapacityAccount, HostCapacityProvider, HostCapacitySnapshot, HostPlacementChoice, } from "./host-capacity.js";
|
|
12
|
+
export { computeHeadroom, computeReadingIsStale, HOST_COMPUTE_TTL_SECONDS, parseHostComputeReading, readHostCompute, } from "./host-compute.js";
|
|
13
|
+
export type { HostComputeHeadroom, HostComputeReading } from "./host-compute.js";
|
|
12
14
|
export { CONFIG_SCHEMA_VERSION, ENVELOPE_DECISIONS, ENVELOPE_SCHEMA_VERSION, HISTORY_CAP, HOST_KINDS, LANE_PROVIDERS, LANE_SCHEMA_VERSION, LANE_STORY_STATUSES, LANE_STATES, LIVENESS_STATES, QUESTION_BODY_STORES, QUESTION_SCHEMA_VERSION, QUESTION_STATUSES, QUEUED_REASONS, RAISED_VIA, ROUTING_REASONS, SENIOR_KINDS, STORY_STATUSES, TERMINAL_LANE_STATES, isEnvelopeDecision, isHostKind, isLaneProvider, isLaneState, isLivenessState, isQuestionStatus, isSeniorKind, isTerminalLaneState, parseLaneEnvelope, parseLaneProvider, parseLaneState, parseLivenessState, parseMajorSchema, parseQuestionStatus, parseSeniorKind, } from "./types.js";
|
|
13
15
|
export type { AccountConfig, AttributionHistoryEntry, EnvelopeDecision, EnvelopeQuestion, HostKind, LaneCompanyRef, LaneAccountSelection, LaneAccountSelectionConsidered, LaneAccountSelectionHostCount, LaneEnvelope, LaneHost, LaneProvider, LanePlacementPolicy, LaneRecord, LaneStory, LaneStoryStatus, PendingResume, AccountHistoryEntry, LaneState, LanesConfig, LastEnvelopeRef, LivenessState, LivenessWindows, ProviderConfig, QuestionAnswer, QuestionBodyRef, QuestionPriority, QuestionRecord, QuestionStatus, QueuedReason, RaisedVia, RoutingHistoryEntry, RoutingReason, SeniorHistoryEntry, SeniorKind, SeniorRef, WorkerProfileRepinHistoryEntry, LaneSettingsHistoryEntry, StoryStatus, TerminalLaneState, ThrottleConfig, } from "./types.js";
|
|
14
16
|
export { ACTIVE_LANE_STORY_STATUSES, activeLaneStories, laneStories, laneStory, storyKey, storyStatusForEnvelope, storyWarning, withCurrentStory, withLaneStories, } from "./stories.js";
|
package/dist/lib/lanes/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { MAX_LANE_DEPTH } from "./constants.js";
|
|
|
6
6
|
export { assignedChildHireGrants, childrenHoldingHireGrantCarve, isFinishedResumableHireChild, laneHoldsHireGrantCarve, hireGrantCapacityError, planHireGrantBackfill, terminalChildResumeHireGrantError, withHireGrantAdmission, } from "./grants.js";
|
|
7
7
|
export { compareLaneQueueOrder, hasActiveAdmissionReservation, hasActivePendingResume, hasEarlierEligibleQueuedLane, laneOccupiesRunningSlot, laneAdmissionCapReason, laneRunsOnHost, withAllLaneAdmissionLocks, withLaneAdmissionLock, } from "./admission.js";
|
|
8
8
|
export { buildHostCapacitySnapshot, chooseHostForLane, parseHostCapacitySnapshot, } from "./host-capacity.js";
|
|
9
|
+
export { computeHeadroom, computeReadingIsStale, HOST_COMPUTE_TTL_SECONDS, parseHostComputeReading, readHostCompute, } from "./host-compute.js";
|
|
9
10
|
export { CONFIG_SCHEMA_VERSION, ENVELOPE_DECISIONS, ENVELOPE_SCHEMA_VERSION, HISTORY_CAP, HOST_KINDS, LANE_PROVIDERS, LANE_SCHEMA_VERSION, LANE_STORY_STATUSES, LANE_STATES, LIVENESS_STATES, QUESTION_BODY_STORES, QUESTION_SCHEMA_VERSION, QUESTION_STATUSES, QUEUED_REASONS, RAISED_VIA, ROUTING_REASONS, SENIOR_KINDS, STORY_STATUSES, TERMINAL_LANE_STATES, isEnvelopeDecision, isHostKind, isLaneProvider, isLaneState, isLivenessState, isQuestionStatus, isSeniorKind, isTerminalLaneState, parseLaneEnvelope, parseLaneProvider, parseLaneState, parseLivenessState, parseMajorSchema, parseQuestionStatus, parseSeniorKind, } from "./types.js";
|
|
10
11
|
export { ACTIVE_LANE_STORY_STATUSES, activeLaneStories, laneStories, laneStory, storyKey, storyStatusForEnvelope, storyWarning, withCurrentStory, withLaneStories, } from "./stories.js";
|
|
11
12
|
export { DEFAULT_ACCOUNT_HOMES, DEFAULT_AUTO_COMPACT_TOKENS, DEFAULT_COMPACT_AFTER_MS, DEFAULT_LIVE_WITHIN_MS, DEFAULT_LIVENESS_WINDOWS, DEFAULT_MAX_QUEUED, DEFAULT_PROVIDER_MAX_RUNNING, DEFAULT_SILENT_LOST_MS, DEFAULT_TURN_START_LOST_MS, LANES_CONFIG_REL, accountMaxRunning, canonicalizeHome, documentedDefaultConfig, expandHome, lanesConfigPath, loadLanesConfig, parseLanesConfig, providerCompactAfterMs, providerAutoCompactTokens, providerQuotaDefaultHoldMs, DEFAULT_QUOTA_HOLD_MS, writeLanesConfig, } from "./config.js";
|
|
@@ -16,6 +16,7 @@ import { enforceRegistryApprovalGate } from "./approval-gate.js";
|
|
|
16
16
|
import { inspectLoopRecovery, loopControllerIsAlive, loopLaneIsIdle, loopStatus } from "./loop.js";
|
|
17
17
|
import { loadLanesConfig, providerQuotaDefaultHoldMs } from "./config.js";
|
|
18
18
|
import { MAX_LANE_DEPTH } from "./constants.js";
|
|
19
|
+
import { runSizeFields } from "./run-size.js";
|
|
19
20
|
import { laneDepthCap } from "./depth-cap.js";
|
|
20
21
|
import { AccountResolutionError, LanesError, isLaneVersionConflict } from "./errors.js";
|
|
21
22
|
import { isQuestionImported } from "./imported-question.js";
|
|
@@ -1814,7 +1815,25 @@ async function heartbeatAndDeadHosts(hqRoot, lanes, summary, deps, now) {
|
|
|
1814
1815
|
accountRetryReason &&
|
|
1815
1816
|
classified.account) {
|
|
1816
1817
|
try {
|
|
1817
|
-
|
|
1818
|
+
// PS-011: the respawn below deletes worker-exit.json, so this
|
|
1819
|
+
// run's size is recorded first. A run already added is skipped.
|
|
1820
|
+
// A failed measurement write is logged and never stops the failover.
|
|
1821
|
+
let retryLane = classified;
|
|
1822
|
+
try {
|
|
1823
|
+
if (runSizeFields(laneRunDir(hqRoot, classified.lane_id), classified, nowIso).run_size) {
|
|
1824
|
+
retryLane = retryUpdateLane(hqRoot, classified.lane_id, "reconcile", (current) => {
|
|
1825
|
+
const size = runSizeFields(laneRunDir(hqRoot, current.lane_id), current, nowIso);
|
|
1826
|
+
return size.run_size ? { ...current, ...size } : current;
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
catch (sizeErr) {
|
|
1831
|
+
const sizeMessage = sizeErr instanceof Error ? sizeErr.message : String(sizeErr);
|
|
1832
|
+
process.stderr.write(`hq lanes reconcile: run size not recorded before account failover for ${lane.lane_id}: ${sizeMessage}\n`);
|
|
1833
|
+
// The write did not land, so the classified record is still current.
|
|
1834
|
+
retryLane = classified;
|
|
1835
|
+
}
|
|
1836
|
+
const recovered = await retryLaneOnAlternateAccount(hqRoot, retryLane, accountRetryReason, "reconcile", {
|
|
1818
1837
|
...spawnDepsForHost(deps),
|
|
1819
1838
|
});
|
|
1820
1839
|
summary.dead_host.push({
|
|
@@ -1867,6 +1886,8 @@ async function heartbeatAndDeadHosts(hqRoot, lanes, summary, deps, now) {
|
|
|
1867
1886
|
: repairedClassification;
|
|
1868
1887
|
const next = {
|
|
1869
1888
|
...current,
|
|
1889
|
+
// PS-011: the worker's exit record is read before a later spawn deletes it.
|
|
1890
|
+
...runSizeFields(laneRunDir(hqRoot, current.lane_id), current, nowIso),
|
|
1870
1891
|
state: terminalClassification.state,
|
|
1871
1892
|
queued_reason: undefined,
|
|
1872
1893
|
queued_details: undefined,
|