@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.
Files changed (188) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/assets/scaffold/core/scripts/hq-session.sh +9 -0
  3. package/contracts/host-canary-release.json +9 -3
  4. package/dist/command-catalog.generated.d.ts +269 -1
  5. package/dist/command-catalog.generated.js +330 -1
  6. package/dist/command-registration-plan.d.ts +6 -0
  7. package/dist/command-registration-plan.js +1 -0
  8. package/dist/commands/bot.js +7 -2
  9. package/dist/commands/ci-intake.d.ts +15 -0
  10. package/dist/commands/ci-intake.js +252 -0
  11. package/dist/commands/ci-metrics.d.ts +8 -0
  12. package/dist/commands/ci-metrics.js +55 -0
  13. package/dist/commands/ci.d.ts +13 -0
  14. package/dist/commands/ci.js +10 -0
  15. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
  16. package/dist/commands/core-hq-session-binding.d.ts +140 -0
  17. package/dist/commands/core-hq-session-binding.js +363 -0
  18. package/dist/commands/core-hq-session-native.d.ts +23 -0
  19. package/dist/commands/core-hq-session-native.js +59 -9
  20. package/dist/commands/core-stop-autosave.js +1 -1
  21. package/dist/commands/core.js +10 -0
  22. package/dist/commands/doctor.d.ts +5 -1
  23. package/dist/commands/doctor.js +42 -5
  24. package/dist/commands/files.d.ts +62 -0
  25. package/dist/commands/files.js +250 -9
  26. package/dist/commands/install-global.js +4 -2
  27. package/dist/commands/logout.js +4 -0
  28. package/dist/commands/ontology-graph.d.ts +2 -0
  29. package/dist/commands/ontology-graph.js +33 -0
  30. package/dist/commands/report.js +35 -2
  31. package/dist/commands/storage-gate.js +1 -1
  32. package/dist/commands/vault-retention-flag.js +2 -1
  33. package/dist/commands/whoami.js +1 -1
  34. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
  35. package/dist/hq-cloud-sync-runner/package.json +1 -1
  36. package/dist/index.js +3 -1
  37. package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
  38. package/dist/lib/agent-kit/mcp/tools.js +48 -0
  39. package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
  40. package/dist/lib/bot/fleet-cron.d.ts +50 -0
  41. package/dist/lib/bot/fleet-cron.js +173 -32
  42. package/dist/lib/bot/fleet-local.d.ts +18 -0
  43. package/dist/lib/bot/fleet-local.js +51 -5
  44. package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
  45. package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
  46. package/dist/lib/bot/signals-engine-flag.js +1 -1
  47. package/dist/lib/cli-invite-nudge.js +1 -1
  48. package/dist/lib/client-version.d.ts +2 -0
  49. package/dist/lib/client-version.js +24 -0
  50. package/dist/lib/company-flag-gate.d.ts +30 -0
  51. package/dist/lib/company-flag-gate.js +104 -0
  52. package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
  53. package/dist/lib/daemon/flag.js +2 -1
  54. package/dist/lib/daemon/legacy-journal-gate.js +3 -1
  55. package/dist/lib/daemon/run.js +4 -3
  56. package/dist/lib/daemon/shared-flag-reads.js +1 -1
  57. package/dist/lib/delivery/migrations.d.ts +32 -1
  58. package/dist/lib/delivery/migrations.js +69 -8
  59. package/dist/lib/doctor/checks/host-core.js +22 -4
  60. package/dist/lib/doctor/checks/jq.d.ts +27 -6
  61. package/dist/lib/doctor/checks/jq.js +46 -8
  62. package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
  63. package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
  64. package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
  65. package/dist/lib/flag-client-gate-headers.d.ts +38 -0
  66. package/dist/lib/flag-client-gate-headers.js +62 -0
  67. package/dist/lib/flag-client-headers.d.ts +15 -0
  68. package/dist/lib/flag-client-headers.js +25 -0
  69. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  70. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  71. package/dist/lib/flag-registry-worker.js +35 -0
  72. package/dist/lib/flag-registry.d.ts +1 -20
  73. package/dist/lib/flag-registry.js +5 -81
  74. package/dist/lib/hook-engine/adapter-core-pin.d.ts +30 -0
  75. package/dist/lib/hook-engine/adapter-core-pin.js +30 -0
  76. package/dist/lib/hook-engine/coverage.d.ts +65 -1
  77. package/dist/lib/hook-engine/coverage.js +173 -8
  78. package/dist/lib/hook-engine/reconcile.js +3 -2
  79. package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
  80. package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
  81. package/dist/lib/hot-channels/signal-changes.js +683 -0
  82. package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
  83. package/dist/lib/hot-channels/signals-pass.js +232 -12
  84. package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
  85. package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
  86. package/dist/lib/lanes/registry-flag.js +2 -1
  87. package/dist/lib/lanes/spawn.js +11 -1
  88. package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
  89. package/dist/lib/mesh/live/binding-intent.js +201 -0
  90. package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
  91. package/dist/lib/mesh/live/binding-receipt.js +365 -0
  92. package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
  93. package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
  94. package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
  95. package/dist/lib/mesh/live/daemon/install.js +2 -1
  96. package/dist/lib/mesh/live/daemon/presence.js +9 -0
  97. package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
  98. package/dist/lib/mesh/live/daemon/run.js +33 -1
  99. package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
  100. package/dist/lib/ontology-graph/lineage/index.js +1027 -0
  101. package/dist/lib/ontology-graph/model/index.d.ts +54 -0
  102. package/dist/lib/ontology-graph/model/index.js +112 -0
  103. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
  104. package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
  105. package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
  106. package/dist/lib/ontology-graph/model/pass.js +9 -2
  107. package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
  108. package/dist/lib/ontology-graph/model/pending-items.js +24 -1
  109. package/dist/lib/ontology-graph/model/step.d.ts +1 -1
  110. package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
  111. package/dist/lib/ontology-graph/model/tasks.js +20 -7
  112. package/dist/lib/ontology-graph/read/brief.js +41 -6
  113. package/dist/lib/ontology-graph/read/index.d.ts +4 -0
  114. package/dist/lib/ontology-graph/read/index.js +173 -29
  115. package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
  116. package/dist/lib/ontology-graph/read/lineage.js +262 -0
  117. package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
  118. package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
  119. package/dist/lib/ontology-graph/replay/engine.js +213 -8
  120. package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
  121. package/dist/lib/ontology-graph/replay/extractors.js +25 -1
  122. package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
  123. package/dist/lib/ontology-graph/replay/index.js +9 -3
  124. package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
  125. package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
  126. package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
  127. package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
  128. package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
  129. package/dist/lib/ontology-graph/schema/index.js +1 -0
  130. package/dist/lib/ontology-graph/setup/index.js +13 -3
  131. package/dist/lib/search-index/index.d.ts +33 -1
  132. package/dist/lib/search-index/index.js +180 -25
  133. package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
  134. package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
  135. package/dist/lib/signals/adapters-catalog.js +1 -1
  136. package/dist/lib/smart-ci/cost.d.ts +72 -0
  137. package/dist/lib/smart-ci/cost.js +120 -0
  138. package/dist/lib/smart-ci/github.d.ts +112 -0
  139. package/dist/lib/smart-ci/github.js +267 -0
  140. package/dist/lib/smart-ci/intake.d.ts +288 -0
  141. package/dist/lib/smart-ci/intake.js +1078 -0
  142. package/dist/lib/smart-ci/ledger.d.ts +218 -0
  143. package/dist/lib/smart-ci/ledger.js +527 -0
  144. package/dist/lib/smart-ci/metrics.d.ts +137 -0
  145. package/dist/lib/smart-ci/metrics.js +249 -0
  146. package/dist/lib/smart-ci/records.d.ts +265 -0
  147. package/dist/lib/smart-ci/records.js +281 -0
  148. package/dist/lib/smart-ci/reducer.d.ts +67 -0
  149. package/dist/lib/smart-ci/reducer.js +261 -0
  150. package/dist/lib/sync-core/engine-holds.d.ts +15 -0
  151. package/dist/lib/sync-core/engine-holds.js +104 -11
  152. package/dist/lib/sync-core/engine-home.d.ts +3 -0
  153. package/dist/lib/sync-core/engine-home.js +41 -1
  154. package/dist/lib/sync-core/flag.js +2 -1
  155. package/dist/lib/sync-core/hand-back.d.ts +1 -0
  156. package/dist/lib/sync-core/hand-back.js +7 -2
  157. package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
  158. package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
  159. package/dist/lib/sync-core/legacy-journal-export.js +120 -55
  160. package/dist/lib/sync-core/reconcile.d.ts +2 -1
  161. package/dist/lib/sync-core/reconcile.js +40 -7
  162. package/dist/lib/sync-invalid-entity-warning.js +2 -1
  163. package/dist/lib/windows/install-followup.d.ts +41 -0
  164. package/dist/lib/windows/install-followup.js +87 -0
  165. package/dist/lib/windows/jq.d.ts +59 -0
  166. package/dist/lib/windows/jq.js +154 -3
  167. package/dist/lib/windows/user-path.d.ts +5 -0
  168. package/dist/lib/windows/user-path.js +1 -1
  169. package/dist/lib/work-context/auto-bind.d.ts +12 -0
  170. package/dist/lib/work-context/auto-bind.js +49 -3
  171. package/dist/lib/work-context/organize.d.ts +4 -2
  172. package/dist/lib/work-context/organize.js +18 -8
  173. package/dist/lib/work-context/reconcile.js +16 -1
  174. package/dist/main.js +12 -1
  175. package/dist/utils/client-health-contract.d.ts +30 -0
  176. package/dist/utils/client-health-contract.js +111 -0
  177. package/dist/utils/client-health.d.ts +5 -2
  178. package/dist/utils/client-health.js +74 -5
  179. package/dist/utils/exclusive-lock.d.ts +5 -1
  180. package/dist/utils/exclusive-lock.js +9 -2
  181. package/dist/utils/host-registration.d.ts +7 -0
  182. package/dist/utils/host-registration.js +10 -1
  183. package/dist/utils/pid.d.ts +31 -0
  184. package/dist/utils/pid.js +65 -0
  185. package/dist/utils/resident-package-preload.js +12 -4
  186. package/dist/utils/sentry-fingerprint.js +3 -0
  187. package/package.json +10 -8
  188. package/scripts/install-hook-engine.mjs +5 -3
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The statuses that say a decision no longer stands.
3
+ *
4
+ * One list, used by the rule that writes decision lineage from signals
5
+ * (replay/signal-changes.ts), by the readers (read/lineage.ts) and by the
6
+ * model pass (model/pass.ts), so the three agree on what "ended" means:
7
+ *
8
+ * - `superseded`, `reversed`, `withdrawn`: what the rule writes;
9
+ * - `replaced`: the word a person or a record may use for the same thing.
10
+ *
11
+ * A person or a record that writes one of these on a decision agrees with a
12
+ * link that says the decision was replaced. Any other status (`decided`,
13
+ * `active`, `accepted`, ...) says the decision stands, and disagrees with it.
14
+ */
15
+ export declare const ENDED_DECISION_STATUSES: ReadonlySet<string>;
16
+ /** True for a status value that says the decision no longer stands. Letter case and outer spaces do not matter. */
17
+ export declare function endsDecision(status: string): boolean;
18
+ //# sourceMappingURL=decision-status.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The statuses that say a decision no longer stands.
3
+ *
4
+ * One list, used by the rule that writes decision lineage from signals
5
+ * (replay/signal-changes.ts), by the readers (read/lineage.ts) and by the
6
+ * model pass (model/pass.ts), so the three agree on what "ended" means:
7
+ *
8
+ * - `superseded`, `reversed`, `withdrawn`: what the rule writes;
9
+ * - `replaced`: the word a person or a record may use for the same thing.
10
+ *
11
+ * A person or a record that writes one of these on a decision agrees with a
12
+ * link that says the decision was replaced. Any other status (`decided`,
13
+ * `active`, `accepted`, ...) says the decision stands, and disagrees with it.
14
+ */
15
+ export const ENDED_DECISION_STATUSES = new Set(["superseded", "reversed", "withdrawn", "replaced"]);
16
+ /** True for a status value that says the decision no longer stands. Letter case and outer spaces do not matter. */
17
+ export function endsDecision(status) {
18
+ return ENDED_DECISION_STATUSES.has(status.trim().toLowerCase());
19
+ }
20
+ //# sourceMappingURL=decision-status.js.map
@@ -9,4 +9,5 @@ export { SchemaError } from "./default-schema.js";
9
9
  export { validateEntityUpsert, validateRow } from "./validate.js";
10
10
  export { GUESS_CONFIDENCE_BELOW, GUESS_EMPLOYER_VERBS, GUESS_FIELDS, GUESS_HIERARCHY_VERBS, GUESS_OWNERSHIP_VERBS, GUESS_VERBS, dropUnverifiedGuesses, effectiveFacts, isUnverifiedGuess, inverseEdge, isOpen, isSingleValued, planSupersession, rowCoversDay, singleValueKey, } from "./authority.js";
11
11
  export type { SupersessionPlan } from "./authority.js";
12
+ export { ENDED_DECISION_STATUSES, endsDecision } from "./decision-status.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,5 @@ export { DEFAULT_SCHEMA, parseSchemaYaml, renderSchemaYaml } from "./default-sch
7
7
  export { SchemaError } from "./default-schema.js";
8
8
  export { validateEntityUpsert, validateRow } from "./validate.js";
9
9
  export { GUESS_CONFIDENCE_BELOW, GUESS_EMPLOYER_VERBS, GUESS_FIELDS, GUESS_HIERARCHY_VERBS, GUESS_OWNERSHIP_VERBS, GUESS_VERBS, dropUnverifiedGuesses, effectiveFacts, isUnverifiedGuess, inverseEdge, isOpen, isSingleValued, planSupersession, rowCoversDay, singleValueKey, } from "./authority.js";
10
+ export { ENDED_DECISION_STATUSES, endsDecision } from "./decision-status.js";
10
11
  //# sourceMappingURL=index.js.map
@@ -20,7 +20,7 @@
20
20
  import * as fs from "node:fs";
21
21
  import * as path from "node:path";
22
22
  import yaml from "js-yaml";
23
- import { MODEL_STATE_PATHS, ONTOLOGY_MODEL_ENV, ONTOLOGY_SETTINGS_FILE, estimateTokens, isOntologyModelName, peekPendingMarkers, readModelSetting, resolveModelStateDir } from "../model/index.js";
23
+ import { MODEL_STATE_PATHS, ONTOLOGY_MODEL_ENV, ONTOLOGY_SETTINGS_FILE, estimateTokens, isOntologyModelName, heldMarkerCounts, modelTasksLine, modelTasksNotes, peekPendingMarkers, readModelSetting, readModelTasks, resolveModelStateDir } from "../model/index.js";
24
24
  import { DEFAULT_ONTOLOGY_MODEL } from "../model/runner.js";
25
25
  import { graphExists } from "../read/graph-index.js";
26
26
  import { READER_SETTING_RELATIVE, parseReaderSetting, readReaderSetting, readerSettingFile } from "../read/reader-setting.js";
@@ -411,7 +411,7 @@ function pendingLook(context, env) {
411
411
  const kind = typeof marker.kind === "string" ? marker.kind : "other";
412
412
  byKind[kind] = (byKind[kind] ?? 0) + 1;
413
413
  }
414
- return { items: markers.length, byKind };
414
+ return { items: markers.length, byKind, held: { ...heldMarkerCounts(markers, readModelTasks(context.companyRoot).tasks) } };
415
415
  }
416
416
  const number = (value) => value.toLocaleString("en-US");
417
417
  /** `hq ontology status`: reader, model, graph, counts, pending model work, last update and brief, on one screen. Reads only. */
@@ -427,6 +427,9 @@ export async function statusCommand(context, options = {}) {
427
427
  const cursor = usable ? readCursorLook(context.graphRoot) : null;
428
428
  const brief = usable ? readBriefLook(context.graphRoot) : null;
429
429
  const pending = usable ? pendingLook(context, env) : null;
430
+ // The effective `model_tasks` setting, read the way a run reads it. It is shown whether or not a run would call a
431
+ // model at all (`--no-model`), so a person can check the file before a run sends anything.
432
+ const tasks = readModelTasks(context.companyRoot);
430
433
  const shownRoot = rel(context.hqRoot, context.graphRoot);
431
434
  const next = [];
432
435
  if (graph.state === "missing") {
@@ -439,7 +442,7 @@ export async function statusCommand(context, options = {}) {
439
442
  else {
440
443
  if (graph.state === "unstamped")
441
444
  next.push(`stamp the folder with a build: hq ontology update --company ${context.company}`);
442
- if (pending && pending.items > 0)
445
+ if (pending && pending.items - Object.values(pending.held).reduce((sum, count) => sum + count, 0) > 0)
443
446
  next.push(`send pending model work: hq ontology update --company ${context.company} --follow-up`);
444
447
  if (brief && !brief.present)
445
448
  next.push(`write the brief: hq ontology brief --company ${context.company}`);
@@ -449,6 +452,9 @@ export async function statusCommand(context, options = {}) {
449
452
  const lines = [`ontology status for ${context.company}`];
450
453
  lines.push(`reader: ${reader}${setting.present ? "" : " (no setting; the default)"}${setting.present && setting.reader === "graph" && setting.company !== context.company ? ` (the setting says graph for ${setting.company === "" ? "no company" : setting.company})` : ""}`);
451
454
  lines.push(`model: ${model.model} (${sourceWords(model, context.company)}; per machine, not synced)`);
455
+ lines.push(`tasks: ${modelTasksLine(tasks.tasks)} (${tasks.source === "default" ? "no model_tasks setting; the default" : tasks.source === "setting" ? `model_tasks in ${ONTOLOGY_SETTINGS_FILE}` : `${ONTOLOGY_SETTINGS_FILE} could not be read as written; the setting fails closed`})`);
456
+ for (const note of modelTasksNotes(tasks))
457
+ lines.push(` ${note}`);
452
458
  lines.push(`graph: ${graph.present ? "present" : "missing"}, ${graph.detail} (${shownRoot})`);
453
459
  if (counts) {
454
460
  const byType = Object.entries(counts.entitiesByType)
@@ -464,6 +470,9 @@ export async function statusCommand(context, options = {}) {
464
470
  .map(([kind, count]) => `${kind} ${number(count)}`)
465
471
  .join(", ");
466
472
  lines.push(`pending: ${pending.items === 0 ? "no model work pending" : `${number(pending.items)} model ${pending.items === 1 ? "item" : "items"} pending (${kinds})`}`);
473
+ for (const [task, count] of Object.entries(pending.held).sort((a, b) => (a[0] < b[0] ? -1 : 1))) {
474
+ lines.push(` ${number(count)} ${count === 1 ? "item" : "items"} pending for ${task} ${count === 1 ? "is" : "are"} held because the task is off`);
475
+ }
467
476
  }
468
477
  if (cursor)
469
478
  lines.push(`updated: ${cursor.updatedAt ? `${cursor.updatedAt}${cursor.lastDay ? `, replayed through ${cursor.lastDay}` : ""}` : "never"}`);
@@ -477,6 +486,7 @@ export async function statusCommand(context, options = {}) {
477
486
  company: context.company,
478
487
  reader: { effective: reader, setting: { ...setting, file: READER_SETTING_RELATIVE } },
479
488
  model: { ...model, perMachine: true },
489
+ modelTasks: { ...tasks.tasks, source: tasks.source, problems: tasks.problems, warnings: tasks.warnings, file: ONTOLOGY_SETTINGS_FILE },
480
490
  graph: { root: shownRoot, present: graph.present, stamp: graph.stamp, state: graph.state },
481
491
  counts,
482
492
  pending,
@@ -93,6 +93,25 @@ export declare class QmdBinaryMissingError extends Error {
93
93
  readonly spawnDiagnostics?: QmdSpawnDiagnostics;
94
94
  constructor(message: string, spawnDiagnostics?: QmdSpawnDiagnostics);
95
95
  }
96
+ /** Bounded reason a qmd usability probe failed. Safe to use as a Sentry tag. */
97
+ export type QmdProbeFailureKind = 'spawn-failed' | 'native-bindings' | 'timed-out' | 'unusable';
98
+ /**
99
+ * Neither the bundled qmd nor the qmd on PATH passed the usability probe, so
100
+ * hq used neither (HQ-CLI-J4, HQ-CLI-HH). The message is the user-facing
101
+ * remedy: what happened and the one step that fixes it, with no raw qmd or
102
+ * cmd.exe output. Both probe reasons are kept as bounded kinds (for Sentry
103
+ * tags) and as redacted, length-bounded detail (for local debugging).
104
+ */
105
+ export declare class QmdUnusableError extends QmdBinaryMissingError {
106
+ readonly bundledBin: string | undefined;
107
+ readonly bundledProbe: QmdProbeFailureKind | 'not-found';
108
+ readonly pathBin: string;
109
+ readonly pathProbe: QmdProbeFailureKind;
110
+ name: string;
111
+ readonly bundledDetail: string;
112
+ readonly pathDetail: string;
113
+ constructor(bundledBin: string | undefined, bundledProbe: QmdProbeFailureKind | 'not-found', bundledDetail: string, pathBin: string, pathProbe: QmdProbeFailureKind, pathDetail: string);
114
+ }
96
115
  /**
97
116
  * qmd could not be SPAWNED because its working directory does not exist:
98
117
  * spawnSync returned ENOENT while chdir-ing into `cwd` (the resolved hq root at
@@ -121,6 +140,10 @@ export declare class QmdExitError extends Error {
121
140
  entryPath?: QmdUpdateEntryPath;
122
141
  /** Present only when the invoked executable is the bundled qmd. */
123
142
  qmdVersion?: string;
143
+ /** `path-fallback` when hq ran the PATH qmd because the bundled copy failed its probe. */
144
+ qmdSource?: 'path-fallback';
145
+ /** Why the bundled qmd was skipped, when {@link qmdSource} is `path-fallback`. */
146
+ bundledProbe?: QmdProbeFailureKind;
124
147
  constructor(message: string, args: string[], status: number | null, stdout: string, stderr: string);
125
148
  }
126
149
  export declare class QmdCollectionMissingError extends QmdExitError {
@@ -490,7 +513,9 @@ export declare function ensureQmdStoreDir(env?: NodeJS.ProcessEnv, options?: Ens
490
513
  export declare function __resetQmdProbeStateForTests(): void;
491
514
  /** Backwards-compatible string form: probe a bare bin path shell-free (or via
492
515
  * the shell plan when it is a Windows `.cmd`/`.bat`). */
493
- export declare function isUsableQmd(bin: string): boolean;
516
+ export declare function isUsableQmd(bin: string, options?: {
517
+ keepHome?: boolean;
518
+ }): boolean;
494
519
  /**
495
520
  * Honest one-line reason a package-local qmd probe failed, for the resolver's
496
521
  * probes note. A spawn-level failure — the binary could not be executed at all
@@ -499,6 +524,13 @@ export declare function isUsableQmd(bin: string): boolean;
499
524
  * the native-bindings story. Only a genuine better-sqlite3 load failure keeps it.
500
525
  */
501
526
  export declare function describeProbeFailure(detail: string): string;
527
+ /** Bounded kind of a probe failure, from the same detail {@link describeProbeFailure} reads. */
528
+ export declare function qmdProbeFailureKind(detail: string): QmdProbeFailureKind;
529
+ /**
530
+ * The bundled qmd's failure kind when `bin` is a PATH copy hq chose because the
531
+ * bundled copy failed its probe; undefined otherwise.
532
+ */
533
+ export declare function qmdPathFallbackReason(bin: string): QmdProbeFailureKind | undefined;
502
534
  /**
503
535
  * Derive the better-sqlite3 PACKAGE directory qmd tried to load, from a bindings
504
536
  * failure. `bindings` lists every path it tried, each ending in
@@ -11,6 +11,7 @@ import { isQmdQueryDocumentError } from '../../utils/qmd-query-document-error.js
11
11
  import { isQmdStoreMissingError } from '../../utils/qmd-store-missing-error.js';
12
12
  import { isQmdStoreUnopenableError } from '../../utils/qmd-store-unopenable-error.js';
13
13
  import { markExpectedUserError } from '../../utils/expected-cli-error.js';
14
+ import { HQ_CLI_NPM_REPAIR_COMMAND } from '../../utils/npm-install-flags.js';
14
15
  import { redactErrorText } from '../../utils/redact-error-text.js';
15
16
  import { planCommandSpawn } from '../../utils/windows-spawn.js';
16
17
  import { resolveQmdConfigPath } from './max-doc-bytes.js';
@@ -46,6 +47,48 @@ export class QmdBinaryMissingError extends Error {
46
47
  this.spawnDiagnostics = spawnDiagnostics;
47
48
  }
48
49
  }
50
+ /** Longest probe detail kept on a QmdUnusableError (after redaction). */
51
+ const PROBE_DETAIL_MAX = 300;
52
+ /**
53
+ * Neither the bundled qmd nor the qmd on PATH passed the usability probe, so
54
+ * hq used neither (HQ-CLI-J4, HQ-CLI-HH). The message is the user-facing
55
+ * remedy: what happened and the one step that fixes it, with no raw qmd or
56
+ * cmd.exe output. Both probe reasons are kept as bounded kinds (for Sentry
57
+ * tags) and as redacted, length-bounded detail (for local debugging).
58
+ */
59
+ export class QmdUnusableError extends QmdBinaryMissingError {
60
+ bundledBin;
61
+ bundledProbe;
62
+ pathBin;
63
+ pathProbe;
64
+ name = 'QmdUnusableError';
65
+ bundledDetail;
66
+ pathDetail;
67
+ constructor(bundledBin, bundledProbe, bundledDetail, pathBin, pathProbe, pathDetail) {
68
+ super(qmdUnusableMessage(bundledBin, bundledProbe, pathBin, pathProbe));
69
+ this.bundledBin = bundledBin;
70
+ this.bundledProbe = bundledProbe;
71
+ this.pathBin = pathBin;
72
+ this.pathProbe = pathProbe;
73
+ this.bundledDetail = redactErrorText(bundledDetail).slice(0, PROBE_DETAIL_MAX);
74
+ this.pathDetail = redactErrorText(pathDetail).slice(0, PROBE_DETAIL_MAX);
75
+ }
76
+ }
77
+ const PROBE_KIND_WORDS = {
78
+ 'spawn-failed': 'it could not be started',
79
+ 'native-bindings': 'its database module was not built',
80
+ 'timed-out': 'it did not answer in time',
81
+ unusable: 'it exited with an error',
82
+ };
83
+ function qmdUnusableMessage(bundledBin, bundledProbe, pathBin, pathProbe) {
84
+ const found = Boolean(bundledBin) && bundledProbe !== 'not-found';
85
+ const bundled = bundledBin && bundledProbe !== 'not-found'
86
+ ? `The qmd search engine bundled with hq failed its startup check (${PROBE_KIND_WORDS[bundledProbe]})`
87
+ : 'The qmd search engine bundled with hq was not found';
88
+ return (`hq search can't start. ${bundled}, and the qmd on your PATH (${pathBin}) ` +
89
+ `failed ${found ? 'the same' : 'its startup'} check (${PROBE_KIND_WORDS[pathProbe]}), so hq used neither. ` +
90
+ `To fix it, reinstall hq with \`${HQ_CLI_NPM_REPAIR_COMMAND}\`, then run the command again.`);
91
+ }
49
92
  /**
50
93
  * qmd could not be SPAWNED because its working directory does not exist:
51
94
  * spawnSync returned ENOENT while chdir-ing into `cwd` (the resolved hq root at
@@ -79,6 +122,10 @@ export class QmdExitError extends Error {
79
122
  entryPath;
80
123
  /** Present only when the invoked executable is the bundled qmd. */
81
124
  qmdVersion;
125
+ /** `path-fallback` when hq ran the PATH qmd because the bundled copy failed its probe. */
126
+ qmdSource;
127
+ /** Why the bundled qmd was skipped, when {@link qmdSource} is `path-fallback`. */
128
+ bundledProbe;
82
129
  constructor(message, args, status, stdout, stderr) {
83
130
  super(message);
84
131
  this.args = args;
@@ -577,6 +624,12 @@ const usableQmdCache = new Map();
577
624
  * and, from the bindings "Tried:" list, WHERE the unbuilt better-sqlite3 lives.
578
625
  */
579
626
  const lastProbeFailure = new Map();
627
+ /**
628
+ * PATH qmd copies chosen because the bundled copy failed its probe, keyed by
629
+ * the PATH bin, with the bundled copy's bounded failure kind. runQmd stamps it
630
+ * onto a later QmdExitError so the bundled reason is not lost (HQ-CLI-J4/HH).
631
+ */
632
+ const pathFallbackReasons = new Map();
580
633
  /** At most one native-binding repair attempt per process (bounded, no retries). */
581
634
  let nativeBindingRepairAttempted = false;
582
635
  const storeEnsureByDir = new Map();
@@ -702,6 +755,7 @@ const REPAIR_LOCK_TTL_MS = 10 * 60_000;
702
755
  export function __resetQmdProbeStateForTests() {
703
756
  usableQmdCache.clear();
704
757
  lastProbeFailure.clear();
758
+ pathFallbackReasons.clear();
705
759
  nativeBindingRepairAttempted = false;
706
760
  storeEnsureByDir.clear();
707
761
  lastQmdStoreEnsure = undefined;
@@ -783,14 +837,23 @@ function probeQmd(invocation, options = {}) {
783
837
  let scratch;
784
838
  try {
785
839
  scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'hq-qmd-probe-'));
786
- const env = {
787
- ...process.env,
788
- HOME: scratch,
789
- QMD_CONFIG_DIR: path.join(scratch, 'config'),
790
- INDEX_PATH: path.join(scratch, 'probe-index.db'),
791
- XDG_CONFIG_HOME: path.join(scratch, 'xdg-config'),
792
- XDG_CACHE_HOME: path.join(scratch, 'xdg-cache'),
793
- };
840
+ // A PATH qmd may be a version-manager shim (mise, asdf) that finds its
841
+ // install through HOME/XDG, so its probe keeps them. qmd's store and config
842
+ // still point at scratch, so neither probe touches the user's real index.
843
+ const env = options.keepHome
844
+ ? {
845
+ ...process.env,
846
+ QMD_CONFIG_DIR: path.join(scratch, 'config'),
847
+ INDEX_PATH: path.join(scratch, 'probe-index.db'),
848
+ }
849
+ : {
850
+ ...process.env,
851
+ HOME: scratch,
852
+ QMD_CONFIG_DIR: path.join(scratch, 'config'),
853
+ INDEX_PATH: path.join(scratch, 'probe-index.db'),
854
+ XDG_CONFIG_HOME: path.join(scratch, 'xdg-config'),
855
+ XDG_CACHE_HOME: path.join(scratch, 'xdg-cache'),
856
+ };
794
857
  const probe = spawnQmd(invocation, ['collection', 'list'], {
795
858
  cwd: scratch,
796
859
  env,
@@ -834,8 +897,8 @@ function isUsableInvocation(invocation, options = {}) {
834
897
  }
835
898
  /** Backwards-compatible string form: probe a bare bin path shell-free (or via
836
899
  * the shell plan when it is a Windows `.cmd`/`.bat`). */
837
- export function isUsableQmd(bin) {
838
- return isUsableInvocation({ command: bin, prefixArgs: [] });
900
+ export function isUsableQmd(bin, options = {}) {
901
+ return isUsableInvocation({ command: bin, prefixArgs: [] }, options);
839
902
  }
840
903
  /**
841
904
  * Honest one-line reason a package-local qmd probe failed, for the resolver's
@@ -845,6 +908,8 @@ export function isUsableQmd(bin) {
845
908
  * the native-bindings story. Only a genuine better-sqlite3 load failure keeps it.
846
909
  */
847
910
  export function describeProbeFailure(detail) {
911
+ if (/\bETIMEDOUT\b/.test(detail))
912
+ return 'present but its check timed out';
848
913
  if (/\b(?:EINVAL|ENOENT|EACCES|ENOEXEC)\b/.test(detail) || /^spawnSync\b/.test(detail)) {
849
914
  return 'present but could not be spawned';
850
915
  }
@@ -852,6 +917,61 @@ export function describeProbeFailure(detail) {
852
917
  return 'present but native bindings unbuilt';
853
918
  return 'present but unusable';
854
919
  }
920
+ /** Bounded kind of a probe failure, from the same detail {@link describeProbeFailure} reads. */
921
+ export function qmdProbeFailureKind(detail) {
922
+ if (/\bETIMEDOUT\b/.test(detail))
923
+ return 'timed-out';
924
+ if (/\b(?:EINVAL|ENOENT|EACCES|ENOEXEC)\b/.test(detail) || /^spawnSync\b/.test(detail))
925
+ return 'spawn-failed';
926
+ if (isQmdNativeBindingError(detail))
927
+ return 'native-bindings';
928
+ return 'unusable';
929
+ }
930
+ /**
931
+ * The bundled qmd's failure kind when `bin` is a PATH copy hq chose because the
932
+ * bundled copy failed its probe; undefined otherwise.
933
+ */
934
+ export function qmdPathFallbackReason(bin) {
935
+ return pathFallbackReasons.get(bin);
936
+ }
937
+ /**
938
+ * Probe the PATH qmd the same way as the bundled copy before it may be used
939
+ * (HQ-CLI-J4, HQ-CLI-HH: an unprobed, corrupt `%APPDATA%\npm\qmd.cmd` was run
940
+ * after the bundled copy failed). Probed only when it is actually needed.
941
+ *
942
+ * A PATH probe that only TIMED OUT is inconclusive (a slow machine; the real
943
+ * run has no probe timeout), so that copy is still used, as it was before the
944
+ * probe existed. Only a definite failure rules it out.
945
+ */
946
+ function choosePathFallback(onPath, executable, usable, bundledFailure) {
947
+ if (!onPath || !executable(onPath))
948
+ return { kind: 'none' };
949
+ const passed = usable(onPath);
950
+ const detail = passed ? '' : lastProbeFailure.get(onPath) ?? '';
951
+ const probe = qmdProbeFailureKind(detail);
952
+ if (passed || probe === 'timed-out') {
953
+ if (bundledFailure)
954
+ pathFallbackReasons.set(onPath, bundledFailure);
955
+ else
956
+ pathFallbackReasons.delete(onPath);
957
+ return { kind: 'use', bin: onPath };
958
+ }
959
+ return { kind: 'failed', bin: onPath, probe, detail };
960
+ }
961
+ /**
962
+ * What to do when the PATH copy definitely failed its probe: throw the remedy
963
+ * error, or return undefined so the caller keeps its classified last resort,
964
+ * the bundled copy. That last resort is kept when the bundled copy is
965
+ * bindings-broken (runQmd then prints the native-binding remedy) or when its
966
+ * probe only timed out (the real run may still succeed).
967
+ */
968
+ function unusableBoth(bundledBin, bundledDetail, path) {
969
+ const bundledProbe = bundledBin && bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : 'not-found';
970
+ if (bundledProbe === 'native-bindings' || bundledProbe === 'timed-out') {
971
+ return undefined;
972
+ }
973
+ return new QmdUnusableError(bundledBin, bundledProbe, bundledDetail ?? '', path.bin, path.probe, path.detail);
974
+ }
855
975
  /** Native-binding self-repair is on unless explicitly disabled. */
856
976
  function repairEnabled(env) {
857
977
  const flag = env.HQ_QMD_NO_REPAIR;
@@ -1040,9 +1160,11 @@ export function resolveQmdBin(options = {}) {
1040
1160
  }
1041
1161
  const installed = (options.packageBin ?? packageLocalBin)();
1042
1162
  const onPath = (options.pathBin ?? pathBin)();
1043
- const fallback = onPath && executable(onPath) ? onPath : undefined;
1044
1163
  const isUsable = options.isUsable ?? isUsableQmd;
1045
- if (installed && executable(installed)) {
1164
+ const installedPresent = Boolean(installed && executable(installed));
1165
+ // Undefined while the bundled copy has not failed (absent or not yet probed).
1166
+ let bundledDetail;
1167
+ if (installed && installedPresent) {
1046
1168
  // Executable is not the same as usable: pnpm 10 skips better-sqlite3's build
1047
1169
  // script for dependency installs, so the bundled qmd can be present yet
1048
1170
  // unable to open its SQLite store. ALWAYS probe — the 5.94.2 short-circuit
@@ -1059,23 +1181,34 @@ export function resolveQmdBin(options = {}) {
1059
1181
  return installed;
1060
1182
  }
1061
1183
  }
1062
- probes.push(`package-local @tobilu/qmd (${installed}, ${describeProbeFailure(lastProbeFailure.get(installed) ?? '')})`);
1184
+ bundledDetail = lastProbeFailure.get(installed) ?? '';
1185
+ probes.push(`package-local @tobilu/qmd (${installed}, ${describeProbeFailure(bundledDetail)})`);
1063
1186
  }
1064
1187
  else {
1065
1188
  probes.push(`package-local @tobilu/qmd (${installed ?? 'not found'})`);
1066
1189
  }
1067
- // A working qmd on PATH is the right answer when the bundled one is broken —
1068
- // the fallback the 5.94.2 fix intended but its short-circuit never reached.
1069
- if (fallback)
1070
- return fallback;
1071
- probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
1190
+ // A qmd on PATH is the right answer when the bundled one is broken, but only
1191
+ // when it passes the same probe (HQ-CLI-J4, HQ-CLI-HH).
1192
+ const pathChoice = choosePathFallback(onPath, executable, options.isUsable ?? ((bin) => isUsableQmd(bin, { keepHome: true })), bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : undefined);
1193
+ if (pathChoice.kind === 'use')
1194
+ return pathChoice.bin;
1195
+ if (pathChoice.kind === 'failed') {
1196
+ // With no bundled copy, a failed PATH copy always throws here.
1197
+ const unusable = unusableBoth(installedPresent ? installed : undefined, bundledDetail, pathChoice);
1198
+ if (unusable)
1199
+ throw unusable;
1200
+ probes.push(`qmd on PATH (${pathChoice.bin}, ${describeProbeFailure(pathChoice.detail)})`);
1201
+ }
1202
+ else {
1203
+ probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
1204
+ }
1072
1205
  // Last resort: no usable qmd anywhere, but the bundled binary IS present. Hand
1073
1206
  // it back rather than throwing an opaque "qmd missing" error — running it
1074
1207
  // yields a QmdExitError whose native-binding signature the top-level handler
1075
1208
  // turns into an actionable remedy (and skips Sentry). This is the "never
1076
1209
  // return an unusable binary SILENTLY" contract: we probed, we tried repair,
1077
1210
  // and the ensuing failure is classified, not swallowed.
1078
- if (installed && executable(installed))
1211
+ if (installed && installedPresent)
1079
1212
  return installed;
1080
1213
  throw new QmdBinaryMissingError(`Unable to resolve qmd. Probed ${probes.join('; ')}. Install @tobilu/qmd or set HQ_QMD_BIN to an executable qmd binary.`);
1081
1214
  }
@@ -1109,7 +1242,8 @@ export function resolveQmdInvocation(options = {}) {
1109
1242
  const nodeEntry = (options.packageNodeEntry ?? packageLocalNodeEntry)();
1110
1243
  const shim = (options.packageBin ?? packageLocalBin)();
1111
1244
  const onPath = (options.pathBin ?? pathBin)();
1112
- const fallback = onPath && executable(onPath) ? onPath : undefined;
1245
+ // Undefined while the bundled copy has not failed (absent or not yet probed).
1246
+ let bundledDetail;
1113
1247
  // The bundled qmd, PREFERRING the shell-free Node launcher over the `.cmd`/`.bat`
1114
1248
  // shim. `bundledBin` keeps the qmd file identity (the launcher, else the shim)
1115
1249
  // for probe-failure keying and repair-tree confinement. The launcher is read by
@@ -1154,15 +1288,29 @@ export function resolveQmdInvocation(options = {}) {
1154
1288
  return bundled;
1155
1289
  }
1156
1290
  }
1157
- probes.push(`package-local @tobilu/qmd (${bundledBin}, ${describeProbeFailure(lastProbeFailure.get(bundledBin) ?? '')})`);
1291
+ bundledDetail = lastProbeFailure.get(bundledBin) ?? '';
1292
+ probes.push(`package-local @tobilu/qmd (${bundledBin}, ${describeProbeFailure(bundledDetail)})`);
1158
1293
  }
1159
1294
  else {
1160
1295
  probes.push(`package-local @tobilu/qmd (${shim ?? nodeEntry ?? 'not found'})`);
1161
1296
  }
1162
- // A working qmd on PATH is the right answer when the bundled one is broken.
1163
- if (fallback)
1164
- return { command: fallback, prefixArgs: [] };
1165
- probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
1297
+ // A qmd on PATH is the right answer when the bundled one is broken, but only
1298
+ // when it passes the same probe (HQ-CLI-J4, HQ-CLI-HH).
1299
+ const pathChoice = choosePathFallback(onPath, executable, (bin) => options.isUsable
1300
+ ? options.isUsable({ command: bin, prefixArgs: [] })
1301
+ : isUsableInvocation({ command: bin, prefixArgs: [] }, { platform, spawn: options.spawn, keepHome: true }), bundledDetail !== undefined ? qmdProbeFailureKind(bundledDetail) : undefined);
1302
+ if (pathChoice.kind === 'use')
1303
+ return { command: pathChoice.bin, prefixArgs: [] };
1304
+ if (pathChoice.kind === 'failed') {
1305
+ // With no bundled copy, a failed PATH copy always throws here.
1306
+ const unusable = unusableBoth(bundled ? bundledBin : undefined, bundledDetail, pathChoice);
1307
+ if (unusable)
1308
+ throw unusable;
1309
+ probes.push(`qmd on PATH (${pathChoice.bin}, ${describeProbeFailure(pathChoice.detail)})`);
1310
+ }
1311
+ else {
1312
+ probes.push(`qmd on PATH (${onPath ?? 'not found'})`);
1313
+ }
1166
1314
  // Last resort: no usable qmd anywhere, but the bundled binary IS present. Hand
1167
1315
  // it back rather than throwing an opaque error — running it yields a classified
1168
1316
  // failure (native-binding remedy + no Sentry) instead of an unactionable crash.
@@ -1487,6 +1635,13 @@ function finishRunQmdWithDiagnostics(result, bin, args, options, attribution) {
1487
1635
  const bundledBins = [packageLocalBin(), packageLocalNodeEntry()].filter((candidate) => Boolean(candidate));
1488
1636
  if (bundledBins.includes(bin))
1489
1637
  error.qmdVersion = resolveQmdVersion();
1638
+ // Keep the bundled copy's failure reason when this exit came from the
1639
+ // PATH copy hq fell back to (HQ-CLI-J4, HQ-CLI-HH).
1640
+ const bundledProbe = pathFallbackReasons.get(bin);
1641
+ if (bundledProbe) {
1642
+ error.qmdSource = 'path-fallback';
1643
+ error.bundledProbe = bundledProbe;
1644
+ }
1490
1645
  }
1491
1646
  throw error;
1492
1647
  }
@@ -2,4 +2,11 @@
2
2
  export declare function qmdExitCaptureContext(err: unknown): {
3
3
  tags: Record<string, string>;
4
4
  } | undefined;
5
+ /**
6
+ * Bounded Sentry tags for a QmdUnusableError (neither qmd copy passed its
7
+ * probe, HQ-CLI-J4/HH). Only the two closed probe kinds; never paths or detail.
8
+ */
9
+ export declare function qmdUnusableCaptureContext(err: unknown): {
10
+ tags: Record<string, string>;
11
+ } | undefined;
5
12
  //# sourceMappingURL=qmd-exit-diagnostics.d.ts.map
@@ -1,4 +1,4 @@
1
- import { QmdExitError } from "./index.js";
1
+ import { QmdExitError, QmdUnusableError } from "./index.js";
2
2
  const QMD_ERROR_CODE_TOKENS = [
3
3
  "SQLITE_BUSY",
4
4
  "SQLITE_CORRUPT",
@@ -35,6 +35,30 @@ export function qmdExitCaptureContext(err) {
35
35
  if (typeof err.entryPath === "string" && QMD_UPDATE_ENTRY_PATHS.has(err.entryPath)) {
36
36
  tags.qmd_entry_path = err.entryPath;
37
37
  }
38
+ // HQ-CLI-J4/HH: this exit came from the PATH qmd hq fell back to; keep why
39
+ // the bundled copy was skipped.
40
+ if (err.qmdSource === "path-fallback") {
41
+ tags.qmd_source = "path-fallback";
42
+ tags.qmd_bundled_probe = probeKindTag(err.bundledProbe);
43
+ }
38
44
  return { tags };
39
45
  }
46
+ const QMD_PROBE_KINDS = new Set(["spawn-failed", "native-bindings", "timed-out", "unusable", "not-found"]);
47
+ function probeKindTag(kind) {
48
+ return typeof kind === "string" && QMD_PROBE_KINDS.has(kind) ? kind : "unknown";
49
+ }
50
+ /**
51
+ * Bounded Sentry tags for a QmdUnusableError (neither qmd copy passed its
52
+ * probe, HQ-CLI-J4/HH). Only the two closed probe kinds; never paths or detail.
53
+ */
54
+ export function qmdUnusableCaptureContext(err) {
55
+ if (!(err instanceof QmdUnusableError))
56
+ return undefined;
57
+ return {
58
+ tags: {
59
+ qmd_bundled_probe: probeKindTag(err.bundledProbe),
60
+ qmd_path_probe: probeKindTag(err.pathProbe),
61
+ },
62
+ };
63
+ }
40
64
  //# sourceMappingURL=qmd-exit-diagnostics.js.map
@@ -101,7 +101,7 @@ export function companyAdapterFlagReader(companyUid, idToken, state) {
101
101
  let hit = memo.get(key);
102
102
  if (!hit) {
103
103
  // Loaded on first read: the registry module embeds its worker source.
104
- hit = import("../flag-registry.js").then(async ({ readCompanyFlag }) => {
104
+ hit = import("../company-flag-gate.js").then(async ({ readCompanyFlag }) => {
105
105
  const read = await readCompanyFlag(companyUid, idToken, flag, { fallback: defaultValue });
106
106
  if (read === null) {
107
107
  if (!defaultValue || !state)
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Cost per merge (smart-ci US-001).
3
+ *
4
+ * Same method as the CI cost study of 2026-11-22
5
+ * (workspace/reports/ship-faster-2026-11-20/corey-ci-cost-2026-11-22.md):
6
+ *
7
+ * cost per merge = (GitHub-hosted spend + AWS runner fleet spend) / merged pull requests
8
+ *
9
+ * over one window. The study took GitHub spend from the org billing usage API
10
+ * and AWS spend from Cost Explorer. The ledger holds neither bill, so each
11
+ * input is one of two things and the output says which:
12
+ *
13
+ * - measured: counted from ledger records (merges, job minutes per pool, idle
14
+ * runner minutes), or a billed amount the caller passed in;
15
+ * - estimated: minutes multiplied by a price from the table below.
16
+ *
17
+ * The prices are list prices written down on 2026-11-24 and are estimates.
18
+ * Pass billed amounts to replace them. Runners on hardware Indigo owns (the Mac
19
+ * pool, the Windows boxes) have no price here, as in the study, and count as $0.
20
+ */
21
+ export interface CostRates {
22
+ /** USD per billed minute on a GitHub-hosted runner, by OS. */
23
+ hostedPerMinute: {
24
+ linux: number;
25
+ windows: number;
26
+ macos: number;
27
+ };
28
+ /** USD per hour for one runner of an AWS pool, by pool label. */
29
+ awsPerHour: Record<string, number>;
30
+ /** USD per hour added to every AWS runner: public IPv4 and root volume. */
31
+ awsOverheadPerHour: number;
32
+ }
33
+ export declare const DEFAULT_RATES: CostRates;
34
+ export type PoolClass = "hosted-linux" | "hosted-windows" | "hosted-macos" | "aws" | "own-hardware";
35
+ /** Which bill a pool's minutes land on. */
36
+ export declare function classifyPool(pool: string, hosted: boolean, labels: readonly string[], rates: CostRates): PoolClass;
37
+ export interface CostInput {
38
+ merges: number;
39
+ /** Per pool: minutes jobs ran, and for hosted pools the minutes GitHub bills (each job rounded up to a whole minute). */
40
+ pools: Array<{
41
+ pool: string;
42
+ poolClass: PoolClass;
43
+ runMinutes: number;
44
+ billedMinutes: number;
45
+ }>;
46
+ /** Idle minutes per pool from runner samples, or null when the window has no samples. */
47
+ idleMinutesByPool: Record<string, number> | null;
48
+ /** Part of the sampled span the runner samples cover, 0 to 1; under 0.95 the idle minutes are an estimate. */
49
+ idleCoverage?: number | null;
50
+ rates: CostRates;
51
+ /** Billed GitHub amount for the same repo and window, when the caller has it. */
52
+ githubBilledUsd?: number;
53
+ /** AWS runner fleet amount for the same window, when the caller has it. */
54
+ awsFleetUsd?: number;
55
+ }
56
+ export interface CostInputNote {
57
+ input: string;
58
+ value: string;
59
+ basis: "measured" | "estimated" | "not counted";
60
+ how: string;
61
+ }
62
+ export interface CostPerMerge {
63
+ /** null when the window has no merges. */
64
+ usdPerMerge: number | null;
65
+ totalUsd: number;
66
+ githubHostedUsd: number;
67
+ awsUsd: number;
68
+ merges: number;
69
+ inputs: CostInputNote[];
70
+ }
71
+ export declare function costPerMerge(input: CostInput): CostPerMerge;
72
+ //# sourceMappingURL=cost.d.ts.map