@indigoai-us/hq-cli 5.345.248 → 5.345.251

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 (114) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/contracts/host-canary-release.json +3 -3
  3. package/dist/command-catalog.generated.d.ts +288 -9
  4. package/dist/command-catalog.generated.js +355 -9
  5. package/dist/commands/bot.js +5 -1
  6. package/dist/commands/core-job-run-native.js +4 -0
  7. package/dist/commands/core-knowledge-prefs.d.ts +1 -1
  8. package/dist/commands/core-knowledge-prefs.js +1 -16
  9. package/dist/commands/core.js +0 -2
  10. package/dist/commands/daemon.js +21 -0
  11. package/dist/commands/lanes.d.ts +2 -0
  12. package/dist/commands/lanes.js +9 -4
  13. package/dist/commands/ontology-graph.d.ts +11 -3
  14. package/dist/commands/ontology-graph.js +138 -14
  15. package/dist/commands/sources.js +26 -8
  16. package/dist/commands/sync-core.js +6 -0
  17. package/dist/fast-scaffold.js +1 -3
  18. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +281 -256
  19. package/dist/hq-cloud-sync-runner/package.json +1 -1
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +47 -0
  22. package/dist/lib/bot/fleet-cron.d.ts +2 -0
  23. package/dist/lib/bot/fleet-cron.js +5 -0
  24. package/dist/lib/daemon/installed-cli-restart.d.ts +57 -0
  25. package/dist/lib/daemon/installed-cli-restart.js +114 -0
  26. package/dist/lib/daemon/legacy-journal-gate.d.ts +32 -0
  27. package/dist/lib/daemon/legacy-journal-gate.js +102 -0
  28. package/dist/lib/daemon/machine-checks.d.ts +7 -0
  29. package/dist/lib/daemon/machine-checks.js +10 -0
  30. package/dist/lib/daemon/run.d.ts +3 -1
  31. package/dist/lib/daemon/run.js +48 -5
  32. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  33. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  34. package/dist/lib/hook-engine/coverage.d.ts +99 -19
  35. package/dist/lib/hook-engine/coverage.js +269 -35
  36. package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
  37. package/dist/lib/hook-engine/registration-identity.d.ts +5 -0
  38. package/dist/lib/hook-engine/registration-identity.js +1 -1
  39. package/dist/lib/hook-engine/resolve.d.ts +23 -0
  40. package/dist/lib/hook-engine/resolve.js +48 -1
  41. package/dist/lib/hook-engine/stable-heal.d.ts +87 -0
  42. package/dist/lib/hook-engine/stable-heal.js +214 -0
  43. package/dist/lib/hot-channels/graph-context.d.ts +26 -1
  44. package/dist/lib/hot-channels/graph-context.js +80 -10
  45. package/dist/lib/hot-channels/run.d.ts +1 -0
  46. package/dist/lib/hot-channels/signals-pass.js +9 -4
  47. package/dist/lib/ontology-graph/model/files.d.ts +4 -0
  48. package/dist/lib/ontology-graph/model/files.js +23 -0
  49. package/dist/lib/ontology-graph/model/index.d.ts +11 -1
  50. package/dist/lib/ontology-graph/model/index.js +42 -18
  51. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +9 -1
  52. package/dist/lib/ontology-graph/model/pass-tasks.js +7 -4
  53. package/dist/lib/ontology-graph/model/pass.d.ts +5 -0
  54. package/dist/lib/ontology-graph/model/pass.js +8 -8
  55. package/dist/lib/ontology-graph/model/pending-items.d.ts +31 -0
  56. package/dist/lib/ontology-graph/model/pending-items.js +113 -0
  57. package/dist/lib/ontology-graph/model/step.d.ts +48 -1
  58. package/dist/lib/ontology-graph/model/step.js +205 -36
  59. package/dist/lib/ontology-graph/model/tasks.d.ts +17 -1
  60. package/dist/lib/ontology-graph/model/tasks.js +28 -8
  61. package/dist/lib/ontology-graph/org/derive.d.ts +2 -0
  62. package/dist/lib/ontology-graph/org/derive.js +9 -2
  63. package/dist/lib/ontology-graph/org/index.d.ts +35 -6
  64. package/dist/lib/ontology-graph/org/index.js +136 -19
  65. package/dist/lib/ontology-graph/org/text.d.ts +2 -0
  66. package/dist/lib/ontology-graph/org/text.js +6 -0
  67. package/dist/lib/ontology-graph/org/types.d.ts +5 -0
  68. package/dist/lib/ontology-graph/pages/render.d.ts +2 -0
  69. package/dist/lib/ontology-graph/pages/render.js +11 -4
  70. package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
  71. package/dist/lib/ontology-graph/read/brief.js +312 -62
  72. package/dist/lib/ontology-graph/read/index.d.ts +1 -1
  73. package/dist/lib/ontology-graph/read/index.js +14 -3
  74. package/dist/lib/ontology-graph/read/names.d.ts +6 -1
  75. package/dist/lib/ontology-graph/read/names.js +8 -3
  76. package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
  77. package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
  78. package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
  79. package/dist/lib/ontology-graph/remodel/index.js +450 -0
  80. package/dist/lib/ontology-graph/replay/engine.d.ts +47 -1
  81. package/dist/lib/ontology-graph/replay/engine.js +68 -2
  82. package/dist/lib/ontology-graph/replay/index.d.ts +2 -1
  83. package/dist/lib/ontology-graph/replay/index.js +114 -8
  84. package/dist/lib/ontology-graph/schema/authority.d.ts +43 -0
  85. package/dist/lib/ontology-graph/schema/authority.js +39 -0
  86. package/dist/lib/ontology-graph/schema/index.d.ts +1 -1
  87. package/dist/lib/ontology-graph/schema/index.js +1 -1
  88. package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
  89. package/dist/lib/ontology-graph/setup/index.js +489 -0
  90. package/dist/lib/ontology-graph/types.d.ts +28 -0
  91. package/dist/lib/ontology-graph/types.js +5 -0
  92. package/dist/lib/signals/failure-alert.js +4 -5
  93. package/dist/lib/signals/steps/adapters.js +3 -0
  94. package/dist/lib/sync-core/engine-holds.d.ts +1 -1
  95. package/dist/lib/sync-core/engine-holds.js +12 -2
  96. package/dist/lib/sync-core/hand-back.d.ts +2 -1
  97. package/dist/lib/sync-core/hand-back.js +16 -2
  98. package/dist/lib/sync-core/legacy-journal-export-child.d.ts +2 -0
  99. package/dist/lib/sync-core/legacy-journal-export-child.js +24 -0
  100. package/dist/lib/sync-core/legacy-journal-export.d.ts +39 -0
  101. package/dist/lib/sync-core/legacy-journal-export.js +241 -0
  102. package/dist/lib/sync-core/legacy-journal-reader.d.ts +15 -0
  103. package/dist/lib/sync-core/legacy-journal-reader.js +56 -0
  104. package/dist/lib/sync-core/reconcile.d.ts +3 -0
  105. package/dist/lib/sync-core/reconcile.js +43 -3
  106. package/dist/utils/cli-telemetry.d.ts +1 -0
  107. package/dist/utils/cli-telemetry.js +6 -3
  108. package/dist/utils/hook-engine-rollup.d.ts +96 -0
  109. package/dist/utils/hook-engine-rollup.js +725 -0
  110. package/dist/utils/sync-person.d.ts +15 -0
  111. package/dist/utils/sync-person.js +74 -0
  112. package/package.json +8 -8
  113. package/scripts/install-hook-engine.mjs +4 -0
  114. package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
@@ -169,14 +169,15 @@ export declare function coveredOn(covers: Readonly<Record<string, readonly strin
169
169
  /** The old dispatcher's hooks for `event` on `host` that the engine does not cover. */
170
170
  export declare function uncoveredHooks(root: string, host: CoreNextHost, event: string, covers: Readonly<Record<string, readonly string[]>> | undefined, env?: NodeJS.ProcessEnv): string[];
171
171
  /**
172
- * The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
172
+ * The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
173
+ * and the hq-core-staging fd709b39a shim and hq-session.sh):
173
174
  * `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
174
175
  * `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
175
176
  * `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
176
177
  * refuses a SessionStart that reaches any other revision, and Claude Code drops a SessionStart
177
178
  * refusal, so the session would start with no SessionStart hook at all.
178
179
  */
179
- export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, string]>;
180
+ export declare const SESSION_START_PINS: ReadonlyArray<readonly [string, readonly string[]]>;
180
181
  /**
181
182
  * Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
182
183
  * missing, cannot be read, or is not the pinned revision. A registration-time hold, as for Codex
@@ -226,12 +227,20 @@ export declare function pinnedFilesHold(root: string, event: string, files: read
226
227
  * order it reads them. Each is skipped there when it is not a file.
227
228
  */
228
229
  export declare const GROK_STOP_OBSERVE_PINS: readonly PinnedFile[];
230
+ /** The turn-end leaf revision (b373b582, hq-core v16.0.48 to v16.0.50) that sources `session-id.sh`. */
231
+ export declare const GROK_STOP_OBSERVE_SESSION_ID_LEAF = "b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70";
232
+ /**
233
+ * The session library the b373b582 leaf sources (grok_stop_observe.rs `SESSION_ID_LIB_SHA256`).
234
+ * The native member reads it only beside that leaf, and only when no variable names the session;
235
+ * the hold checks it whenever the leaf is b373b582, which can only keep more roots on the shell.
236
+ */
237
+ export declare const GROK_STOP_OBSERVE_SESSION_ID_PIN: PinnedFile;
229
238
  /**
230
239
  * Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
231
- * turn-end leaf or one of its two libraries is a revision the native member refuses
232
- * (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
233
- * `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
234
- * when the member accepts the root's files.
240
+ * turn-end leaf or one of its two libraries is a revision the native member refuses, or the leaf is
241
+ * b373b582 and `core/scripts/lib/session-id.sh` is (grok_stop_observe.rs `plan`). As there, nothing
242
+ * is read in a root with no `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and
243
+ * refuses no file. Null when the member accepts the root's files.
235
244
  */
236
245
  export declare function grokStopObserveHold(root: string, event: string): string | null;
237
246
  /**
@@ -244,23 +253,94 @@ export declare function grokStopObserveHold(root: string, event: string): string
244
253
  * for, so a missing file is not held; every hq-core release ships both.
245
254
  */
246
255
  export declare const GROK_PRE_TOOL_USE_ADAPTER_PINS: readonly PinnedFile[];
247
- /**
248
- * The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
249
- * (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
250
- * released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
251
- * sha256). A root without them runs no shadow row, so a missing file is not held.
252
- */
253
- export declare const GROK_SHADOW_GUARD_PINS: readonly PinnedFile[];
254
256
  /**
255
257
  * Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
256
258
  * pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
257
- * merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
258
- * models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
259
- * native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
260
- * not held: the hold guards against another revision. The merge-hold shim is not pinned:
261
- * the claimed merge-gates-ready member reads hold records, never the shim.
259
+ * merged-write-guard-shadow row) the shadow companions are not a set the native member accepts
260
+ * (`mergedWriteGuardHold`). For the adapter there is no run-time refusal to mirror: on another
261
+ * adapter the native side would answer with the v16.0.50 model, so the hold is the only guard, and a
262
+ * missing adapter file is not held. The merge-hold shim is not pinned: the claimed
263
+ * merge-gates-ready member reads hold records, never the shim.
262
264
  */
263
265
  export declare function grokPreToolUseHold(root: string, shadow: boolean): string | null;
266
+ /**
267
+ * The dispatcher files the native PreToolUse master model reproduces, in its check order:
268
+ * crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
269
+ * v16.0.50 (774bca73) or v16.0.49 (d5049d5f); hqd-hook-shim.sh is the released ab289ac0 or the
270
+ * hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
271
+ * d6a04155; every other file is one revision.
272
+ */
273
+ export declare const PRE_TOOL_USE_DISPATCHER_PINS: readonly PinnedFile[];
274
+ /** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
275
+ export declare const PRE_TOOL_USE_CODEX_ADAPTER_PIN: PinnedFile;
276
+ /**
277
+ * The claimed vault-write guard's script and the companions it reads (crates/hq-hook/src/ports.rs
278
+ * `HOOK_SCRIPT_SHA256` and `HOOK_COMPANION_SHA256` for enforce-vault-write-access). Its arithmetic
279
+ * library is left out, as in `CLAIMED_MEMBER_IGNORES`: the claimed member does not read it. The
280
+ * credential guard holds that file.
281
+ */
282
+ export declare const PRE_TOOL_USE_VAULT_GUARD_PINS: readonly PinnedFile[];
283
+ /**
284
+ * The credential guard's script revisions, each with the arithmetic library its port follows
285
+ * (ports.rs `HOOK_SCRIPT_SHA256`, `HOOK_COMPANION_SHA256` and `COMPANION_SCRIPT_BINDINGS`): the
286
+ * 16.0.48 script 6512581d and its 16.0.51-beta.44 successor 5064061f only with e90d160f, every
287
+ * other revision only with 0566180c.
288
+ */
289
+ export declare const PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS: ReadonlyArray<readonly [string, string]>;
290
+ /**
291
+ * The native policy-frontmatter check's evaluator scripts, in the order it reads them
292
+ * (crates/hq-hook/src/policy_frontmatter.rs `EVAL_TRIGGER_SHA256`, `FORWARDER_LIB_SHA256`,
293
+ * `FLOOR_LIB_SHA256`). Each is read only once the one before it is on its pin; a missing file
294
+ * gives the same evaluator-unavailable answer bash gave (or skips the floor check), so it is not
295
+ * held.
296
+ */
297
+ export declare const PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS: readonly PinnedFile[];
298
+ /** The native image rule's script (ports.rs `HOOK_SCRIPT_SHA256` image-context-guard) and the hook-lib.sh revisions it accepts. */
299
+ export declare const PRE_TOOL_USE_IMAGE_GUARD_PINS: readonly PinnedFile[];
300
+ /**
301
+ * The companion sets of the native merged-write-guard-shadow member
302
+ * (crates/hq-hook/src/merged_write_guard.rs and merged_write_guard/release_1649.rs). The wrapper's
303
+ * sha256 picks the set and never refuses by itself: the v16.0.49 wrapper (742870a2) picks
304
+ * `released`, any other wrapper `legacy`. In a set the helper .cjs, when listed, must match; each
305
+ * guard may be missing (bash exits 127) but not another revision; hook-lib.sh is read only once a
306
+ * guard is on its pin, and must then be the set's library.
307
+ */
308
+ export declare const MERGED_WRITE_GUARD_SETS: {
309
+ readonly releasedWrapper: "742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206";
310
+ readonly released: {
311
+ readonly helper: "6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30";
312
+ readonly guards: ReadonlyArray<readonly [string, string]>;
313
+ readonly hookLib: "9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f";
314
+ };
315
+ readonly legacy: {
316
+ readonly helper: null;
317
+ readonly guards: ReadonlyArray<readonly [string, string]>;
318
+ readonly hookLib: "df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8";
319
+ };
320
+ };
321
+ /**
322
+ * Why the native merged-write-guard-shadow member would refuse a call in `root` (reported for
323
+ * `event`), or null: see [`MERGED_WRITE_GUARD_SETS`]. A root with no wrapper runs no row. The member
324
+ * reads these files only for a session whose shadow marker is on, which `hq reindex` cannot know,
325
+ * so the hold assumes it is.
326
+ */
327
+ export declare function mergedWriteGuardHold(root: string, event: string): string | null;
328
+ /**
329
+ * Why PreToolUse must stay on the old dispatcher in `root` on `host` once `master-hook:PreToolUse`
330
+ * is claimed there (`hooks`: the old dispatcher's PreToolUse hooks there). Each part mirrors a
331
+ * run-time refusal of the native PreToolUse:
332
+ * - the files it reproduces at pinned revisions (pre_tool_use_master.rs `hold_pins`,
333
+ * `changed_files_on`, checked by `guard_refusal_in` before any member): missing, not a regular
334
+ * file or another revision, or the credential guard's script and library not a bound pair. The
335
+ * Codex adapter is read on Codex only;
336
+ * - the policy enforcement gate beside the hook-lib.sh its revision accepts (the injector runs it
337
+ * on Bash calls whatever the registry lists), as for PostToolUse;
338
+ * - the policy-frontmatter evaluator scripts;
339
+ * - the merged-write-guard-shadow companions, where the registry lists that row;
340
+ * - on Claude Code, the image rule's script.
341
+ * Null when the native PreToolUse accepts every file.
342
+ */
343
+ export declare function preToolUseHold(root: string, host: CoreNextHost, hooks?: readonly string[]): string | null;
264
344
  /**
265
345
  * The scripts the native first-prompt company bind rebuilds, each at one revision:
266
346
  * `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
@@ -295,7 +375,7 @@ export declare const POLICY_GATE_REVISIONS: ReadonlyArray<{
295
375
  * a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
296
376
  * script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
297
377
  */
298
- export declare function policyGateHold(root: string): string | null;
378
+ export declare function policyGateHold(root: string, event?: string): string | null;
299
379
  /** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
300
380
  export declare const CODEX_POST_TOOL_USE_GENERATIONS: ReadonlyArray<readonly [string, string]>;
301
381
  /** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
@@ -1716,6 +1716,12 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
1716
1716
  if (hold)
1717
1717
  missing.push(`(native PreToolUse compatibility: ${hold})`);
1718
1718
  }
1719
+ if (event === 'PreToolUse' && covered.includes('master-hook:PreToolUse')) {
1720
+ const hold = preToolUseHold(root, host, hooks);
1721
+ const reason = hold ? `(native PreToolUse compatibility: ${hold})` : null;
1722
+ if (reason && !missing.includes(reason))
1723
+ missing.push(reason);
1724
+ }
1719
1725
  // The native natural-language-router runs where the registry lists it; its claim and master-hook's switch the event.
1720
1726
  if (event === 'UserPromptSubmit' && covered.includes('master-hook:UserPromptSubmit') && covered.includes('natural-language-router') && hooks.includes('natural-language-router')) {
1721
1727
  const hold = promptCompanyBindHold(root);
@@ -1736,10 +1742,16 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
1736
1742
  if (hold)
1737
1743
  missing.push(`(native ${event} compatibility: ${hold})`);
1738
1744
  }
1745
+ if (host === 'agents-v2' && event === 'PreToolUse' && covered.includes('agents-v2-adapter:PreToolUse')) {
1746
+ const hold = sessionStartHold(root);
1747
+ if (hold)
1748
+ missing.push(`(native PreToolUse compatibility: ${hold})`);
1749
+ }
1739
1750
  return missing;
1740
1751
  }
1741
1752
  /**
1742
- * The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50):
1753
+ * The script revisions the native SessionStart master rebuilds (hq-core v16.0.48 through v16.0.50,
1754
+ * and the hq-core-staging fd709b39a shim and hq-session.sh):
1743
1755
  * `hqd_open.rs` (the daemon shim and its flag-cache library), `session_set/mod.rs` `SCRIPTS`,
1744
1756
  * `ID_LIBS` and `CAPABILITY_LIBS` (hq-session.sh and the two libraries it sources) and
1745
1757
  * `foreign_bind.rs` `RESOLVE_REVISIONS` (resolve-company.sh). The native port
@@ -1747,12 +1759,12 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
1747
1759
  * refusal, so the session would start with no SessionStart hook at all.
1748
1760
  */
1749
1761
  export const SESSION_START_PINS = [
1750
- ['core/scripts/hqd-hook-shim.sh', 'ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed'],
1751
- ['core/scripts/hqd-hook-flag-cache-lib.sh', '061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'],
1752
- ['core/scripts/hq-session.sh', 'db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'],
1753
- ['core/scripts/lib/session-id.sh', '2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'],
1754
- ['core/scripts/lib/session-scope-capability.sh', '388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'],
1755
- ['core/scripts/resolve-company.sh', '00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7'],
1762
+ ['core/scripts/hqd-hook-shim.sh', ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0']],
1763
+ ['core/scripts/hqd-hook-flag-cache-lib.sh', ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a']],
1764
+ ['core/scripts/hq-session.sh', ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded']],
1765
+ ['core/scripts/lib/session-id.sh', ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d']],
1766
+ ['core/scripts/lib/session-scope-capability.sh', ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead']],
1767
+ ['core/scripts/resolve-company.sh', ['00d6fa069f574a86087c77daa44887a2617446d4300d5daebecc9bfb5d81abe7']],
1756
1768
  ];
1757
1769
  /**
1758
1770
  * Why SessionStart must stay on the shell registration in `root`: one of [`SESSION_START_PINS`] is
@@ -1761,7 +1773,7 @@ export const SESSION_START_PINS = [
1761
1773
  * any revision it does not rebuild. Null when every file matches.
1762
1774
  */
1763
1775
  export function sessionStartHold(root) {
1764
- for (const [relative, sha] of SESSION_START_PINS) {
1776
+ for (const [relative, accepted] of SESSION_START_PINS) {
1765
1777
  let bytes;
1766
1778
  try {
1767
1779
  const file = path.join(root, relative);
@@ -1772,7 +1784,7 @@ export function sessionStartHold(root) {
1772
1784
  catch {
1773
1785
  return `unreadable SessionStart file ${relative}`;
1774
1786
  }
1775
- if (createHash('sha256').update(bytes).digest('hex') !== sha)
1787
+ if (!accepted.includes(createHash('sha256').update(bytes).digest('hex')))
1776
1788
  return `unmodeled SessionStart file ${relative}`;
1777
1789
  }
1778
1790
  return null;
@@ -1864,23 +1876,53 @@ export function pinnedFilesHold(root, event, files, generations = []) {
1864
1876
  * order it reads them. Each is skipped there when it is not a file.
1865
1877
  */
1866
1878
  export const GROK_STOP_OBSERVE_PINS = [
1867
- { relative: 'core/hooks/Stop/70-work-mesh-turn-end.sh', accepted: ['1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db'], missing: 'allowed' },
1879
+ {
1880
+ relative: 'core/hooks/Stop/70-work-mesh-turn-end.sh',
1881
+ // hq-core v16.0.47 (`LEAF_16_0_47`), and v16.0.48 to v16.0.50 (`LEAF_16_0_48`).
1882
+ accepted: ['1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db', 'b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70'],
1883
+ missing: 'allowed',
1884
+ },
1868
1885
  { relative: 'core/scripts/lib/hook-stop-async.sh', accepted: ['730b008b81b360923f82785467f3a3b6592be6610ee3b909e446b242543ab3bc', 'fe89218c3f92413cff36e82a937eed5e548e712644d8228b34d59c7f459917ad'], missing: 'allowed' },
1869
1886
  { relative: 'core/scripts/lib/work-mesh-enqueue.sh', accepted: ['db440318b8933b7c436c7b7172adffc9e8fd00c92f0e1745ed5da76871accbe7', 'ac44fc8f68dbe7311811e0e97bba2b1e53b3aa856856db566635a135c6319451'], missing: 'allowed' },
1870
1887
  ];
1888
+ /** The turn-end leaf revision (b373b582, hq-core v16.0.48 to v16.0.50) that sources `session-id.sh`. */
1889
+ export const GROK_STOP_OBSERVE_SESSION_ID_LEAF = 'b373b582a906b0993a3ce56aa43c1ef0aec6668a6b7e150d59ef3214b7d65b70';
1890
+ /**
1891
+ * The session library the b373b582 leaf sources (grok_stop_observe.rs `SESSION_ID_LIB_SHA256`).
1892
+ * The native member reads it only beside that leaf, and only when no variable names the session;
1893
+ * the hold checks it whenever the leaf is b373b582, which can only keep more roots on the shell.
1894
+ */
1895
+ export const GROK_STOP_OBSERVE_SESSION_ID_PIN = {
1896
+ relative: 'core/scripts/lib/session-id.sh',
1897
+ accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'],
1898
+ missing: 'allowed',
1899
+ };
1871
1900
  /**
1872
1901
  * Why a Grok StopCancelled or StopFailure (`event`) must stay on the shell adapter in `root`: the
1873
- * turn-end leaf or one of its two libraries is a revision the native member refuses
1874
- * (grok_stop_observe.rs `plan`). As there, nothing is read in a root with no
1875
- * `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and refuses no file. Null
1876
- * when the member accepts the root's files.
1902
+ * turn-end leaf or one of its two libraries is a revision the native member refuses, or the leaf is
1903
+ * b373b582 and `core/scripts/lib/session-id.sh` is (grok_stop_observe.rs `plan`). As there, nothing
1904
+ * is read in a root with no `.claude/hooks/hook-gate.sh` or no leaf: the member writes nothing and
1905
+ * refuses no file. Null when the member accepts the root's files.
1877
1906
  */
1878
1907
  export function grokStopObserveHold(root, event) {
1879
1908
  if (!regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh')))
1880
1909
  return null;
1881
- if (!regularFile(path.join(root, GROK_STOP_OBSERVE_PINS[0].relative)))
1910
+ const leaf = path.join(root, GROK_STOP_OBSERVE_PINS[0].relative);
1911
+ if (!regularFile(leaf))
1882
1912
  return null;
1883
- return pinnedFilesHold(root, event, GROK_STOP_OBSERVE_PINS);
1913
+ const held = pinnedFilesHold(root, event, GROK_STOP_OBSERVE_PINS);
1914
+ if (held)
1915
+ return held;
1916
+ let bytes;
1917
+ try {
1918
+ bytes = fs.readFileSync(leaf);
1919
+ }
1920
+ catch {
1921
+ return `unreadable ${event} file ${GROK_STOP_OBSERVE_PINS[0].relative}`;
1922
+ }
1923
+ if (createHash('sha256').update(bytes).digest('hex') !== GROK_STOP_OBSERVE_SESSION_ID_LEAF)
1924
+ return null;
1925
+ return pinnedFilesHold(root, event, [GROK_STOP_OBSERVE_SESSION_ID_PIN]);
1884
1926
  }
1885
1927
  /**
1886
1928
  * The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
@@ -1895,28 +1937,220 @@ export const GROK_PRE_TOOL_USE_ADAPTER_PINS = [
1895
1937
  { relative: '.grok/hooks/hq-grok-hook-adapter.sh', accepted: ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf'], missing: 'allowed' },
1896
1938
  { relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'], missing: 'allowed' },
1897
1939
  ];
1898
- /**
1899
- * The merged-write-guard-shadow wrapper and its .cjs the native Grok member models
1900
- * (crates/hq-hook/src/merged_write_guard.rs `SCRIPT_SHA256` 63ddff4a and `CJS_SHA256` 225e5c89; the
1901
- * released 742870a2 and 6f65f2b9, which pretool_merged_write_guard.rs models by the wrapper's
1902
- * sha256). A root without them runs no shadow row, so a missing file is not held.
1903
- */
1904
- export const GROK_SHADOW_GUARD_PINS = [
1905
- { relative: '.claude/hooks/merged-write-guard-shadow.sh', accepted: ['63ddff4a40e861d8d922b0701863259a3cedbffaf6d44a94d837865e62cca6ac', '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206'], missing: 'allowed' },
1906
- { relative: '.claude/hooks/merged-write-guard-shadow.cjs', accepted: ['225e5c89501ab87965db46e6520c0fd8d08ec5e9745068a2e7324e64f7360884', '6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30'], missing: 'allowed' },
1907
- ];
1908
1940
  /**
1909
1941
  * Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
1910
1942
  * pair the native work is modelled on, or (when `shadow`, the registry lists the claimed
1911
- * merged-write-guard-shadow row) the wrapper or its .cjs is not a revision the native member
1912
- * models. Unlike the other holds there is no run-time refusal to mirror: on another adapter the
1913
- * native side would answer with the v16.0.50 model, so the hold is the only guard. A missing file is
1914
- * not held: the hold guards against another revision. The merge-hold shim is not pinned:
1915
- * the claimed merge-gates-ready member reads hold records, never the shim.
1943
+ * merged-write-guard-shadow row) the shadow companions are not a set the native member accepts
1944
+ * (`mergedWriteGuardHold`). For the adapter there is no run-time refusal to mirror: on another
1945
+ * adapter the native side would answer with the v16.0.50 model, so the hold is the only guard, and a
1946
+ * missing adapter file is not held. The merge-hold shim is not pinned: the claimed
1947
+ * merge-gates-ready member reads hold records, never the shim.
1916
1948
  */
1917
1949
  export function grokPreToolUseHold(root, shadow) {
1918
1950
  return pinnedFilesHold(root, 'PreToolUse', GROK_PRE_TOOL_USE_ADAPTER_PINS)
1919
- ?? (shadow ? pinnedFilesHold(root, 'PreToolUse', GROK_SHADOW_GUARD_PINS) : null);
1951
+ ?? (shadow ? mergedWriteGuardHold(root, 'PreToolUse') : null);
1952
+ }
1953
+ /**
1954
+ * The dispatcher files the native PreToolUse master model reproduces, in its check order:
1955
+ * crates/hq-hook/src/pre_tool_use_master.rs `DISPATCHER_PINS`. master-hook.sh is v16.0.48 (1a2439ae),
1956
+ * v16.0.50 (774bca73) or v16.0.49 (d5049d5f); hqd-hook-shim.sh is the released ab289ac0 or the
1957
+ * hq-core-staging fd709b39a ee5e9fe7, and session-id.sh the released 2ebbc508 or the fd709b39a
1958
+ * d6a04155; every other file is one revision.
1959
+ */
1960
+ export const PRE_TOOL_USE_DISPATCHER_PINS = [
1961
+ { relative: '.claude/hooks/hook-gate.sh', accepted: ['a443b481d895e74b46743548d049644ab011b1e5cb8ae3fcb8da1a6a169cd364'] },
1962
+ { relative: '.claude/hooks/hook-timeout-probe.sh', accepted: ['ae5c40212c088044205e246a5715a53f52c28f4021e798bd7a74df6ba570113b'] },
1963
+ { relative: '.claude/hooks/hook-timeout-watchdog.sh', accepted: ['3017517bbcd618be5162c621105c229aeba66fea1c39f6dd744416029f0448b5'] },
1964
+ { relative: '.claude/hooks/machine-check-owner.sh', accepted: ['04ee93b3669470930732a2f6f7d9f0011fe7221d3ee0fe706b8f468cd30da16d'] },
1965
+ {
1966
+ relative: '.claude/hooks/master-hook.sh',
1967
+ accepted: [
1968
+ '1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29',
1969
+ '774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16',
1970
+ 'd5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab',
1971
+ ],
1972
+ },
1973
+ { relative: '.claude/hooks/turn-timing.sh', accepted: ['97c70a3251225ba9e469e41fd3fe2341cfe2936490f54571d2ca16de8e766443'] },
1974
+ { relative: 'core/scripts/hook-lib.sh', accepted: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
1975
+ { relative: 'core/scripts/hq-anywhere-runtime-flag.cjs', accepted: ['8a484cef83d383b440462798ac13e26d132e10bbe509b47e0eb1a3d0db76b2b4'] },
1976
+ { relative: 'core/scripts/hqd-hook-flag-cache-lib.sh', accepted: ['061d264460408e9eaf43fdf0fdde662c906a9a7dacb4e7a591e684bca28c138a'] },
1977
+ { relative: 'core/scripts/hqd-hook-shim.sh', accepted: ['ab289ac0af680fe3bcacb110302ca8b998bdc33c6f94321d42bd04a344163eed', 'ee5e9fe729eb7e51f87b5f90cdc020be865f5b6b35ac0b5758587546b35715c0'] },
1978
+ { relative: 'core/scripts/lib/advisory-cap.sh', accepted: ['ab80b2a3f63a5955db392eaff4e54fed88d20130e96ca5c2a0945a3ea146d39b'] },
1979
+ { relative: 'core/scripts/lib/epochrealtime.sh', accepted: ['4c9205520dba31533c95eea145f6068ba626885c342c2aa1f232a7237d046cdf'] },
1980
+ { relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'] },
1981
+ { relative: 'core/scripts/lib/perl-child-locale.sh', accepted: ['18e6b9d0e22874eea00ecc868b4dcfebbc3bb42434d8d0c81b20baec1194df2e'] },
1982
+ { relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d', 'd6a04155571ec53edd853878cebaba5a5bab93801a73e356499440c1cd009c71'] },
1983
+ { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
1984
+ { relative: 'core/scripts/resolve-hq-root.sh', accepted: ['188e99c7c60bc9909290a666d6f3b93387ae6cf68f2eeb41fd24c2dea62a5240'] },
1985
+ ];
1986
+ /** The Codex adapter the model reproduces on Codex only (pre_tool_use_master.rs `CODEX_ADAPTER_PIN`). */
1987
+ export const PRE_TOOL_USE_CODEX_ADAPTER_PIN = {
1988
+ relative: '.codex/hooks/hq-codex-hook-adapter.sh',
1989
+ accepted: ['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef'],
1990
+ };
1991
+ /**
1992
+ * The claimed vault-write guard's script and the companions it reads (crates/hq-hook/src/ports.rs
1993
+ * `HOOK_SCRIPT_SHA256` and `HOOK_COMPANION_SHA256` for enforce-vault-write-access). Its arithmetic
1994
+ * library is left out, as in `CLAIMED_MEMBER_IGNORES`: the claimed member does not read it. The
1995
+ * credential guard holds that file.
1996
+ */
1997
+ export const PRE_TOOL_USE_VAULT_GUARD_PINS = [
1998
+ { relative: '.claude/hooks/enforce-vault-write-access.sh', accepted: ['1a139c4d45c687cce355333f445b7b1d6e0848f72c1f1fbae11229db93213dd9'] },
1999
+ {
2000
+ relative: 'core/scripts/hook-lib.sh',
2001
+ accepted: [
2002
+ '9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
2003
+ 'df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8',
2004
+ 'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb',
2005
+ ],
2006
+ },
2007
+ { relative: '.claude/hooks/enforce-vault-write-access-flag.cjs', accepted: ['87dbddf1867296562ce76096c47869bca5c1a6a262b526421ac96aecfef90c45'] },
2008
+ ];
2009
+ /**
2010
+ * The credential guard's script revisions, each with the arithmetic library its port follows
2011
+ * (ports.rs `HOOK_SCRIPT_SHA256`, `HOOK_COMPANION_SHA256` and `COMPANION_SCRIPT_BINDINGS`): the
2012
+ * 16.0.48 script 6512581d and its 16.0.51-beta.44 successor 5064061f only with e90d160f, every
2013
+ * other revision only with 0566180c.
2014
+ */
2015
+ export const PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS = [
2016
+ ['25f5507cc97bfe700a8505f59463b4f42280c60d4733110c0a5faabb87cda4f3', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
2017
+ ['0555a4bda2bbf5c4aa47f4bec2641e0db629d8b59a1042c8bee85adebd505c8f', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
2018
+ ['72296f0148eb32e1c00e34099109d919ea7cd22ae5e81517e95298a7f237498a', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
2019
+ ['30015cbcae48b7227d3e271dd73235b2eac8d7b86955ac653d30ca3c377bc599', '0566180ce52bed559d57a08247bf39c8ec1cec6b7e271da496d0c09077fc6f57'],
2020
+ ['6512581d1200558d4ef78dfb11eca4a92f663042c6b0b11b2e6664762139e2a0', 'e90d160fed02cbcf7e33aed679233af5a9cf9f9a87dd979aba04493a37c00ec8'],
2021
+ ['5064061fd64da6d56c0c974c0719f6729b23dba9ab1a768e1ba70d5a9645c8ae', 'e90d160fed02cbcf7e33aed679233af5a9cf9f9a87dd979aba04493a37c00ec8'],
2022
+ ];
2023
+ const CREDENTIAL_GUARD = '.claude/hooks/block-credential-file-read.sh';
2024
+ const CREDENTIAL_ARITH_LIB = '.claude/hooks/bash-arith-subst-guard-lib.sh';
2025
+ /**
2026
+ * The native policy-frontmatter check's evaluator scripts, in the order it reads them
2027
+ * (crates/hq-hook/src/policy_frontmatter.rs `EVAL_TRIGGER_SHA256`, `FORWARDER_LIB_SHA256`,
2028
+ * `FLOOR_LIB_SHA256`). Each is read only once the one before it is on its pin; a missing file
2029
+ * gives the same evaluator-unavailable answer bash gave (or skips the floor check), so it is not
2030
+ * held.
2031
+ */
2032
+ export const PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS = [
2033
+ { relative: 'core/scripts/eval-trigger.sh', accepted: ['0066d89590f96855d800cdce2b883f265eaa6b92ac3fbc6649b82bf768772328'], missing: 'allowed' },
2034
+ { relative: 'core/scripts/lib/forwarder.sh', accepted: ['a030068f482cac2ecbfad90394fd7bcd1e24926e9179bcec5c770076ad6e4fc4'], missing: 'allowed' },
2035
+ { relative: 'core/scripts/lib/hq-cli-floor.sh', accepted: ['d5087c69c33250a71dee35174c259e0a301cee1cd02110a1df5e5ca9d6334fac'], missing: 'allowed' },
2036
+ ];
2037
+ /** The native image rule's script (ports.rs `HOOK_SCRIPT_SHA256` image-context-guard) and the hook-lib.sh revisions it accepts. */
2038
+ export const PRE_TOOL_USE_IMAGE_GUARD_PINS = [
2039
+ { relative: '.claude/hooks/image-context-guard.sh', accepted: ['3580ee355d642012df30daa153fff368e6440dbdfea1ebee02ecd27f8f1eb45d'], missing: 'allowed' },
2040
+ {
2041
+ relative: 'core/scripts/hook-lib.sh',
2042
+ accepted: [
2043
+ 'df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8',
2044
+ 'c5c8153f1e6cead7a2cbfc9085788f26970efc79752660ff2c308112622a5c8e',
2045
+ 'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb',
2046
+ '9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
2047
+ ],
2048
+ missing: 'allowed',
2049
+ },
2050
+ ];
2051
+ const MERGED_WRITE_WRAPPER = '.claude/hooks/merged-write-guard-shadow.sh';
2052
+ const MERGED_WRITE_HELPER = '.claude/hooks/merged-write-guard-shadow.cjs';
2053
+ /**
2054
+ * The companion sets of the native merged-write-guard-shadow member
2055
+ * (crates/hq-hook/src/merged_write_guard.rs and merged_write_guard/release_1649.rs). The wrapper's
2056
+ * sha256 picks the set and never refuses by itself: the v16.0.49 wrapper (742870a2) picks
2057
+ * `released`, any other wrapper `legacy`. In a set the helper .cjs, when listed, must match; each
2058
+ * guard may be missing (bash exits 127) but not another revision; hook-lib.sh is read only once a
2059
+ * guard is on its pin, and must then be the set's library.
2060
+ */
2061
+ export const MERGED_WRITE_GUARD_SETS = {
2062
+ releasedWrapper: '742870a2ada4f9357320f7708fca7363be6d81fde374948b59873c327a7d7206',
2063
+ released: {
2064
+ helper: '6f65f2b9425612f9b2ec2590dace82585230210dcd69a124a9cdeb0116ea7f30',
2065
+ guards: [
2066
+ ['.claude/hooks/block-core-writes-bash.sh', '0b4ce070ef18595bd8ee794e2f364720854170a63eb0eb5999e135ada4d1b497'],
2067
+ ['.claude/hooks/block-core-writes.sh', 'a39061417bf31cf251c661ebc3e5bc87ee1bb2424a0552d2aeb266eec3d29fcc'],
2068
+ ['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
2069
+ ],
2070
+ hookLib: '9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f',
2071
+ },
2072
+ legacy: {
2073
+ helper: null,
2074
+ guards: [
2075
+ ['.claude/hooks/block-core-writes-bash.sh', '1c52342ab3030c1ee5540341dd1c8f6dbe7721c300d900c4947d98f1407638b2'],
2076
+ ['.claude/hooks/block-core-writes.sh', 'e6c14f48c38bd01ed0f2120fd7c18022fd7dd0dac18ed09f2307414a5646932f'],
2077
+ ['core/hooks/PreToolUse/10-Edit,Write,MultiEdit--block-repo-edits-use-worktree.sh', 'c4c0786ff75ef466f3cd6068e3d54b3fd68c3e3cfabb98debfe1de770523526c'],
2078
+ ],
2079
+ hookLib: 'df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8',
2080
+ },
2081
+ };
2082
+ /** The sha256 of `relative` under `root`, or null when it is not a regular file or cannot be read. */
2083
+ function fileSha256(root, relative) {
2084
+ const file = path.join(root, relative);
2085
+ if (!regularFile(file))
2086
+ return null;
2087
+ try {
2088
+ return createHash('sha256').update(fs.readFileSync(file)).digest('hex');
2089
+ }
2090
+ catch {
2091
+ return null;
2092
+ }
2093
+ }
2094
+ /**
2095
+ * Why the native merged-write-guard-shadow member would refuse a call in `root` (reported for
2096
+ * `event`), or null: see [`MERGED_WRITE_GUARD_SETS`]. A root with no wrapper runs no row. The member
2097
+ * reads these files only for a session whose shadow marker is on, which `hq reindex` cannot know,
2098
+ * so the hold assumes it is.
2099
+ */
2100
+ export function mergedWriteGuardHold(root, event) {
2101
+ if (!regularFile(path.join(root, MERGED_WRITE_WRAPPER)))
2102
+ return null;
2103
+ const set = fileSha256(root, MERGED_WRITE_WRAPPER) === MERGED_WRITE_GUARD_SETS.releasedWrapper ? MERGED_WRITE_GUARD_SETS.released : MERGED_WRITE_GUARD_SETS.legacy;
2104
+ if (set.helper) {
2105
+ const hold = pinnedFilesHold(root, event, [{ relative: MERGED_WRITE_HELPER, accepted: [set.helper] }]);
2106
+ if (hold)
2107
+ return hold;
2108
+ }
2109
+ const guards = pinnedFilesHold(root, event, set.guards.map(([relative, sha]) => ({ relative, accepted: [sha], missing: 'allowed' })));
2110
+ if (guards)
2111
+ return guards;
2112
+ if (!set.guards.some(([relative]) => regularFile(path.join(root, relative))))
2113
+ return null;
2114
+ return pinnedFilesHold(root, event, [{ relative: HOOK_LIB, accepted: [set.hookLib] }]);
2115
+ }
2116
+ /**
2117
+ * Why PreToolUse must stay on the old dispatcher in `root` on `host` once `master-hook:PreToolUse`
2118
+ * is claimed there (`hooks`: the old dispatcher's PreToolUse hooks there). Each part mirrors a
2119
+ * run-time refusal of the native PreToolUse:
2120
+ * - the files it reproduces at pinned revisions (pre_tool_use_master.rs `hold_pins`,
2121
+ * `changed_files_on`, checked by `guard_refusal_in` before any member): missing, not a regular
2122
+ * file or another revision, or the credential guard's script and library not a bound pair. The
2123
+ * Codex adapter is read on Codex only;
2124
+ * - the policy enforcement gate beside the hook-lib.sh its revision accepts (the injector runs it
2125
+ * on Bash calls whatever the registry lists), as for PostToolUse;
2126
+ * - the policy-frontmatter evaluator scripts;
2127
+ * - the merged-write-guard-shadow companions, where the registry lists that row;
2128
+ * - on Claude Code, the image rule's script.
2129
+ * Null when the native PreToolUse accepts every file.
2130
+ */
2131
+ export function preToolUseHold(root, host, hooks = []) {
2132
+ const files = host === 'codex' ? [...PRE_TOOL_USE_DISPATCHER_PINS, PRE_TOOL_USE_CODEX_ADAPTER_PIN] : PRE_TOOL_USE_DISPATCHER_PINS;
2133
+ const credential = PRE_TOOL_USE_CREDENTIAL_GUARD_GENERATIONS;
2134
+ const evaluator = () => {
2135
+ for (const pin of PRE_TOOL_USE_FRONTMATTER_EVALUATOR_PINS) {
2136
+ if (!regularFile(path.join(root, pin.relative)))
2137
+ return null;
2138
+ const hold = pinnedFilesHold(root, 'PreToolUse', [pin]);
2139
+ if (hold)
2140
+ return hold;
2141
+ }
2142
+ return null;
2143
+ };
2144
+ return pinnedFilesHold(root, 'PreToolUse', files)
2145
+ ?? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_VAULT_GUARD_PINS)
2146
+ ?? pinnedFilesHold(root, 'PreToolUse', [
2147
+ { relative: CREDENTIAL_GUARD, accepted: [...new Set(credential.map(([script]) => script))] },
2148
+ { relative: CREDENTIAL_ARITH_LIB, accepted: [...new Set(credential.map(([, lib]) => lib))] },
2149
+ ], credential)
2150
+ ?? policyGateHold(root, 'PreToolUse')
2151
+ ?? evaluator()
2152
+ ?? (hooks.includes('merged-write-guard-shadow') ? mergedWriteGuardHold(root, 'PreToolUse') : null)
2153
+ ?? (host === 'claude' ? pinnedFilesHold(root, 'PreToolUse', PRE_TOOL_USE_IMAGE_GUARD_PINS) : null);
1920
2154
  }
1921
2155
  /**
1922
2156
  * The scripts the native first-prompt company bind rebuilds, each at one revision:
@@ -1925,7 +2159,7 @@ export function grokPreToolUseHold(root, shadow) {
1925
2159
  */
1926
2160
  export const PROMPT_COMPANY_BIND_PINS = [
1927
2161
  { relative: 'core/scripts/lib/prompt-company-mention.sh', accepted: ['6c68e31d0605db272a6b922e361d1e7659ab77e96faaf613c62afa192aef4ee0'] },
1928
- { relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7'] },
2162
+ { relative: 'core/scripts/hq-session.sh', accepted: ['db701162f71b53fd2188974d2f46c58250593dde1252d65b36e6d02b9a765fe7', '02a37c5dbf4fb5af27cc64d0f271121e990758b757a479f60e9ce099f4d65ded'] },
1929
2163
  { relative: 'core/scripts/lib/session-id.sh', accepted: ['2ebbc50893c7c601a111b9e8f9945afeac88f552d7caeec09c4096f4c27a833d'] },
1930
2164
  { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] },
1931
2165
  ];
@@ -1967,14 +2201,14 @@ const HOOK_LIB = 'core/scripts/hook-lib.sh';
1967
2201
  * a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
1968
2202
  * script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
1969
2203
  */
1970
- export function policyGateHold(root) {
2204
+ export function policyGateHold(root, event = 'PostToolUse') {
1971
2205
  if (!regularFile(path.join(root, POLICY_GATE)))
1972
2206
  return null;
1973
2207
  const files = [
1974
2208
  { relative: POLICY_GATE, accepted: POLICY_GATE_REVISIONS.map(({ gate }) => gate) },
1975
2209
  { relative: HOOK_LIB, accepted: POLICY_GATE_REVISIONS.flatMap(({ hookLibs }) => hookLibs), missing: 'allowed' },
1976
2210
  ];
1977
- return pinnedFilesHold(root, 'PostToolUse', files, POLICY_GATE_REVISIONS.flatMap(({ gate, hookLibs }) => hookLibs.map((lib) => [gate, lib])));
2211
+ return pinnedFilesHold(root, event, files, POLICY_GATE_REVISIONS.flatMap(({ gate, hookLibs }) => hookLibs.map((lib) => [gate, lib])));
1978
2212
  }
1979
2213
  const CODEX_ADAPTER = '.codex/hooks/hq-codex-hook-adapter.sh';
1980
2214
  const GROK_ADAPTER = '.grok/hooks/hq-grok-hook-adapter.sh';
@@ -86,7 +86,8 @@
86
86
  "1741275eef31d7f656ed618f4c08814ff630b6664f98f18ebdd822b3d2270827"
87
87
  ],
88
88
  ".claude/hooks/conduct-lanes-link-deliver.sh": [
89
- "b1124363238ba405a0efd4bca08b4601430a596614037fbd30bf92b2e6bf8465"
89
+ "b1124363238ba405a0efd4bca08b4601430a596614037fbd30bf92b2e6bf8465",
90
+ "944c727a2161044d8444a2253528423fd7e278ac1a9077cf0c9dedc6fe597686"
90
91
  ],
91
92
  "core/hooks/Stop/40-auto-acl-share-suggestion.sh": [
92
93
  "286246caa6234ab2f449c1af987b4956b3afd0349ac310429ebd50fbaf594ab9"
@@ -105,7 +106,8 @@
105
106
  "9e6fa4930830624fd588241b24315f6e6b5f3ae6778e8f61020bf237490ac30c"
106
107
  ],
107
108
  ".claude/hooks/hq-autocommit.sh": [
108
- "f7c01bc6de7f79e51eedc9806a7c903fdf0947e540ba226d1b37fc3667919304"
109
+ "f7c01bc6de7f79e51eedc9806a7c903fdf0947e540ba226d1b37fc3667919304",
110
+ "66f5c09b16364e07c659c22d0b6c5519a05894918ea9d0749340023c00e231c2"
109
111
  ],
110
112
  ".claude/hooks/lib/parse-estimates.pl": [
111
113
  "absent"
@@ -118,7 +120,8 @@
118
120
  ],
119
121
  "core/hooks/SessionStart/35-work-mesh-session-start.sh": [
120
122
  "865e5855c72c5ac0d503efbbc095a2d2835396418a12b20fa0ce3bd2f66d8d27",
121
- "1653dd9f939b6bce651fb81a9619db6441ff56d3916bc05714424008719408be"
123
+ "1653dd9f939b6bce651fb81a9619db6441ff56d3916bc05714424008719408be",
124
+ "4ab85c27d7b78c7a4ccbf76b4f7e3e3ca6b4fdf14f09a63aac49d0c4dc44c8f1"
122
125
  ],
123
126
  "core/scripts/board-project-id.sh": [
124
127
  "b3c80668460c556267b06a0869e41e0088963ba2a709ac459d14bb8bd08252a7"
@@ -356,7 +359,9 @@
356
359
  "2962e17569d62f5953d41cd516bd7d1b3db9849c3c4fbbd750ae13d7d181bcbe"
357
360
  ],
358
361
  ".claude/hooks/master-hook.sh": [
359
- "1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29"
362
+ "1a2439aee50652c5143ccd18561a0aa84a1e94848d02c1aa1c99157f70023f29",
363
+ "d5049d5fb38d2b33467d493a4a136df8f6d9021c29e722df0d1e6a17d7f452ab",
364
+ "774bca73a2e806b4d9ad96b803525bdf25afd2265d63c9216881aa4ced403f16"
360
365
  ]
361
366
  }
362
367
  }
@@ -8,6 +8,11 @@ export interface NativeTarget {
8
8
  */
9
9
  export declare function launcherRoot(root: string): string;
10
10
  export declare function engineArgs(root: string, event: string, runtime: 'claude' | 'codex', global?: boolean): string[];
11
+ /**
12
+ * The `--hq-root` value of an HQ entry: the argument after it in exec form,
13
+ * or the single-quoted word after it in a POSIX or PowerShell command string.
14
+ */
15
+ export declare function hqRootArgument(entry: Record<string, unknown>): string | undefined;
11
16
  /**
12
17
  * True when an entry's `--hq-root` names this HQ root: the same spelling
13
18
  * (trailing separators aside), or another spelling of the same folder
@@ -17,7 +17,7 @@ export function engineArgs(root, event, runtime, global = false) {
17
17
  * The `--hq-root` value of an HQ entry: the argument after it in exec form,
18
18
  * or the single-quoted word after it in a POSIX or PowerShell command string.
19
19
  */
20
- function hqRootArgument(entry) {
20
+ export function hqRootArgument(entry) {
21
21
  if (Array.isArray(entry.args)) {
22
22
  const i = entry.args.indexOf('--hq-root');
23
23
  const value = i >= 0 ? entry.args[i + 1] : undefined;