@indigoai-us/hq-cli 5.345.246 → 5.345.248

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 (256) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
  3. package/contracts/host-canary-release.json +14 -0
  4. package/dist/command-catalog.generated.d.ts +1116 -3
  5. package/dist/command-catalog.generated.js +1373 -3
  6. package/dist/command-registration-plan.d.ts +6 -0
  7. package/dist/command-registration-plan.js +1 -0
  8. package/dist/commands/install-global.d.ts +15 -0
  9. package/dist/commands/install-global.js +98 -4
  10. package/dist/commands/lanes-hold.js +7 -7
  11. package/dist/commands/lanes-resume.js +2 -2
  12. package/dist/commands/lanes-review.js +1 -1
  13. package/dist/commands/lanes-session-start.d.ts +1 -1
  14. package/dist/commands/lanes-session-start.js +3 -3
  15. package/dist/commands/lanes-shared.d.ts +1 -1
  16. package/dist/commands/lanes.d.ts +2 -2
  17. package/dist/commands/lanes.js +50 -50
  18. package/dist/commands/mcp-registration.d.ts +17 -0
  19. package/dist/commands/mcp-registration.js +119 -0
  20. package/dist/commands/mesh.d.ts +25 -0
  21. package/dist/commands/mesh.js +48 -8
  22. package/dist/commands/ontology-graph.d.ts +62 -0
  23. package/dist/commands/ontology-graph.js +439 -0
  24. package/dist/commands/pkg-install.js +1 -1
  25. package/dist/commands/reindex.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  28. package/dist/lanes-monitor-check-argv.js +1 -1
  29. package/dist/lanes-monitor-check-fast.d.ts +1 -1
  30. package/dist/lanes-monitor-check-fast.js +1 -1
  31. package/dist/lanes-session-start-argv.d.ts +1 -1
  32. package/dist/lanes-session-start-argv.js +1 -1
  33. package/dist/lib/capacity/sign-in.d.ts +1 -1
  34. package/dist/lib/capacity/sign-in.js +1 -1
  35. package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
  36. package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
  37. package/dist/lib/daemon/lanes-monitor-state.js +2 -2
  38. package/dist/lib/daemon/merge-sections.d.ts +3 -3
  39. package/dist/lib/daemon/merge-sections.js +7 -7
  40. package/dist/lib/daemon/remote-control-pools.js +1 -1
  41. package/dist/lib/daemon/run.js +1 -1
  42. package/dist/lib/daemon/state-file.d.ts +1 -1
  43. package/dist/lib/daemon/state-file.js +1 -1
  44. package/dist/lib/doctor/checks/antigravity-wiring.d.ts +21 -0
  45. package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
  46. package/dist/lib/doctor/checks/anywhere.js +30 -0
  47. package/dist/lib/doctor/checks/runtime-probe.js +13 -0
  48. package/dist/lib/doctor/platform.d.ts +1 -1
  49. package/dist/lib/doctor/platform.js +5 -0
  50. package/dist/lib/doctor/registry.js +3 -0
  51. package/dist/lib/flag-snapshot-file.d.ts +2 -0
  52. package/dist/lib/flag-snapshot-file.js +118 -48
  53. package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
  54. package/dist/lib/hook-engine/canary-gate.js +138 -6
  55. package/dist/lib/hook-engine/coverage.d.ts +91 -0
  56. package/dist/lib/hook-engine/coverage.js +184 -0
  57. package/dist/lib/hot-channels/graph-context.d.ts +105 -0
  58. package/dist/lib/hot-channels/graph-context.js +377 -0
  59. package/dist/lib/hot-channels/signals-pass.js +27 -1
  60. package/dist/lib/install/antigravity-targets.d.ts +39 -0
  61. package/dist/lib/install/antigravity-targets.js +122 -0
  62. package/dist/lib/lanes/claude-credential.d.ts +1 -1
  63. package/dist/lib/lanes/claude-credential.js +1 -1
  64. package/dist/lib/lanes/delivery-core.d.ts +1 -1
  65. package/dist/lib/lanes/delivery-core.js +1 -1
  66. package/dist/lib/lanes/delivery.d.ts +10 -10
  67. package/dist/lib/lanes/delivery.js +8 -8
  68. package/dist/lib/lanes/dropbox.d.ts +1 -1
  69. package/dist/lib/lanes/dropbox.js +1 -1
  70. package/dist/lib/lanes/hooks-install.js +2 -2
  71. package/dist/lib/lanes/index.d.ts +1 -1
  72. package/dist/lib/lanes/index.js +1 -1
  73. package/dist/lib/lanes/monitor.js +1 -1
  74. package/dist/lib/lanes/quota-notice.js +1 -1
  75. package/dist/lib/lanes/quota.d.ts +1 -1
  76. package/dist/lib/lanes/quota.js +1 -1
  77. package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
  78. package/dist/lib/lanes/repo-merge-hold.js +2 -2
  79. package/dist/lib/lanes/spawn.d.ts +4 -4
  80. package/dist/lib/lanes/spawn.js +5 -5
  81. package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
  82. package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
  83. package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
  84. package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
  85. package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
  86. package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
  87. package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
  88. package/dist/lib/mesh/live/daemon/run.js +35 -2
  89. package/dist/lib/mesh/live/direct-drain.js +1 -1
  90. package/dist/lib/mesh/live/emit.d.ts +3 -0
  91. package/dist/lib/mesh/live/emit.js +32 -9
  92. package/dist/lib/mesh/live/flush.d.ts +3 -0
  93. package/dist/lib/mesh/live/flush.js +115 -32
  94. package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
  95. package/dist/lib/mesh/live/liveness-carry.js +1 -1
  96. package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
  97. package/dist/lib/mesh/live/reporting-privacy.js +235 -11
  98. package/dist/lib/mesh/live/spool.d.ts +17 -2
  99. package/dist/lib/mesh/live/spool.js +22 -6
  100. package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
  101. package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
  102. package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
  103. package/dist/lib/ontology-graph/legacy/index.js +1150 -0
  104. package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
  105. package/dist/lib/ontology-graph/legacy/parse.js +126 -0
  106. package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
  107. package/dist/lib/ontology-graph/legacy/report.js +254 -0
  108. package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
  109. package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
  110. package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
  111. package/dist/lib/ontology-graph/lint/checks.js +717 -0
  112. package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
  113. package/dist/lib/ontology-graph/lint/coverage.js +241 -0
  114. package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
  115. package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
  116. package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
  117. package/dist/lib/ontology-graph/lint/index.js +176 -0
  118. package/dist/lib/ontology-graph/model/files.d.ts +20 -0
  119. package/dist/lib/ontology-graph/model/files.js +89 -0
  120. package/dist/lib/ontology-graph/model/index.d.ts +65 -0
  121. package/dist/lib/ontology-graph/model/index.js +100 -0
  122. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
  123. package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
  124. package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
  125. package/dist/lib/ontology-graph/model/pass.js +958 -0
  126. package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
  127. package/dist/lib/ontology-graph/model/runner.js +160 -0
  128. package/dist/lib/ontology-graph/model/step.d.ts +195 -0
  129. package/dist/lib/ontology-graph/model/step.js +523 -0
  130. package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
  131. package/dist/lib/ontology-graph/model/tasks.js +349 -0
  132. package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
  133. package/dist/lib/ontology-graph/not-implemented.js +8 -0
  134. package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
  135. package/dist/lib/ontology-graph/org/compare.js +239 -0
  136. package/dist/lib/ontology-graph/org/derive.d.ts +65 -0
  137. package/dist/lib/ontology-graph/org/derive.js +352 -0
  138. package/dist/lib/ontology-graph/org/index.d.ts +73 -0
  139. package/dist/lib/ontology-graph/org/index.js +513 -0
  140. package/dist/lib/ontology-graph/org/load.d.ts +31 -0
  141. package/dist/lib/ontology-graph/org/load.js +476 -0
  142. package/dist/lib/ontology-graph/org/role.d.ts +38 -0
  143. package/dist/lib/ontology-graph/org/role.js +268 -0
  144. package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
  145. package/dist/lib/ontology-graph/org/structure.js +437 -0
  146. package/dist/lib/ontology-graph/org/text.d.ts +95 -0
  147. package/dist/lib/ontology-graph/org/text.js +315 -0
  148. package/dist/lib/ontology-graph/org/types.d.ts +452 -0
  149. package/dist/lib/ontology-graph/org/types.js +80 -0
  150. package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
  151. package/dist/lib/ontology-graph/pages/index.js +193 -0
  152. package/dist/lib/ontology-graph/pages/render.d.ts +142 -0
  153. package/dist/lib/ontology-graph/pages/render.js +682 -0
  154. package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
  155. package/dist/lib/ontology-graph/proposals/apply.js +468 -0
  156. package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
  157. package/dist/lib/ontology-graph/proposals/group.js +232 -0
  158. package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
  159. package/dist/lib/ontology-graph/proposals/index.js +474 -0
  160. package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
  161. package/dist/lib/ontology-graph/proposals/model.js +196 -0
  162. package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
  163. package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
  164. package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
  165. package/dist/lib/ontology-graph/read/brief.js +251 -0
  166. package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
  167. package/dist/lib/ontology-graph/read/graph-index.js +198 -0
  168. package/dist/lib/ontology-graph/read/index.d.ts +59 -0
  169. package/dist/lib/ontology-graph/read/index.js +792 -0
  170. package/dist/lib/ontology-graph/read/member.d.ts +7 -0
  171. package/dist/lib/ontology-graph/read/member.js +34 -0
  172. package/dist/lib/ontology-graph/read/names.d.ts +44 -0
  173. package/dist/lib/ontology-graph/read/names.js +292 -0
  174. package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
  175. package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
  176. package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
  177. package/dist/lib/ontology-graph/read/test-graph.js +150 -0
  178. package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
  179. package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
  180. package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
  181. package/dist/lib/ontology-graph/replay/config.js +105 -0
  182. package/dist/lib/ontology-graph/replay/engine.d.ts +100 -0
  183. package/dist/lib/ontology-graph/replay/engine.js +1174 -0
  184. package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
  185. package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
  186. package/dist/lib/ontology-graph/replay/index.d.ts +90 -0
  187. package/dist/lib/ontology-graph/replay/index.js +220 -0
  188. package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
  189. package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
  190. package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
  191. package/dist/lib/ontology-graph/replay/member.js +65 -0
  192. package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
  193. package/dist/lib/ontology-graph/replay/mentions.js +239 -0
  194. package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
  195. package/dist/lib/ontology-graph/replay/readers.js +1251 -0
  196. package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
  197. package/dist/lib/ontology-graph/replay/rules.js +374 -0
  198. package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
  199. package/dist/lib/ontology-graph/replay/scope.js +115 -0
  200. package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
  201. package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
  202. package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
  203. package/dist/lib/ontology-graph/replay/util.js +256 -0
  204. package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
  205. package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
  206. package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
  207. package/dist/lib/ontology-graph/resolve/index.js +214 -0
  208. package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
  209. package/dist/lib/ontology-graph/resolve/machine.js +95 -0
  210. package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
  211. package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
  212. package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
  213. package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
  214. package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
  215. package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
  216. package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
  217. package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
  218. package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
  219. package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
  220. package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
  221. package/dist/lib/ontology-graph/resolve/roster.js +226 -0
  222. package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
  223. package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
  224. package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
  225. package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
  226. package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
  227. package/dist/lib/ontology-graph/resolve/writer.js +351 -0
  228. package/dist/lib/ontology-graph/schema/authority.d.ts +73 -0
  229. package/dist/lib/ontology-graph/schema/authority.js +157 -0
  230. package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
  231. package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
  232. package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
  233. package/dist/lib/ontology-graph/schema/grammar.js +409 -0
  234. package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
  235. package/dist/lib/ontology-graph/schema/index.js +10 -0
  236. package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
  237. package/dist/lib/ontology-graph/schema/validate.js +132 -0
  238. package/dist/lib/ontology-graph/store/files.d.ts +34 -0
  239. package/dist/lib/ontology-graph/store/files.js +207 -0
  240. package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
  241. package/dist/lib/ontology-graph/store/fs.js +101 -0
  242. package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
  243. package/dist/lib/ontology-graph/store/graph-store.js +520 -0
  244. package/dist/lib/ontology-graph/store/index.d.ts +18 -0
  245. package/dist/lib/ontology-graph/store/index.js +15 -0
  246. package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
  247. package/dist/lib/ontology-graph/store/ingest.js +323 -0
  248. package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
  249. package/dist/lib/ontology-graph/store/paths.js +232 -0
  250. package/dist/lib/ontology-graph/types.d.ts +1183 -0
  251. package/dist/lib/ontology-graph/types.js +131 -0
  252. package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
  253. package/dist/utils/frontmatter.d.ts +14 -0
  254. package/dist/utils/frontmatter.js +18 -0
  255. package/dist/utils/interactive-caller.js +1 -1
  256. package/package.json +8 -8
@@ -1705,12 +1705,37 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
1705
1705
  if (hold)
1706
1706
  missing.push(`(native SessionStart compatibility: ${hold})`);
1707
1707
  }
1708
+ if (host === 'grok' && GROK_STOP_OBSERVE.has(event) && covered.includes(`grok-adapter:${event}`)) {
1709
+ const hold = grokStopObserveHold(root, event);
1710
+ if (hold)
1711
+ missing.push(`(native ${event} compatibility: ${hold})`);
1712
+ }
1713
+ if (host === 'grok' && event === 'PreToolUse' && covered.includes('grok-adapter:PreToolUse')) {
1714
+ const shadow = covered.includes('merged-write-guard-shadow') && hooks.includes('merged-write-guard-shadow');
1715
+ const hold = grokPreToolUseHold(root, shadow);
1716
+ if (hold)
1717
+ missing.push(`(native PreToolUse compatibility: ${hold})`);
1718
+ }
1708
1719
  // The native natural-language-router runs where the registry lists it; its claim and master-hook's switch the event.
1709
1720
  if (event === 'UserPromptSubmit' && covered.includes('master-hook:UserPromptSubmit') && covered.includes('natural-language-router') && hooks.includes('natural-language-router')) {
1710
1721
  const hold = promptCompanyBindHold(root);
1711
1722
  if (hold)
1712
1723
  missing.push(`(native UserPromptSubmit compatibility: ${hold})`);
1713
1724
  }
1725
+ if (event === 'PostToolUse' && covered.includes('master-hook:PostToolUse')) {
1726
+ // The native policy gate runs where the registry lists it, on every host master-hook's PostToolUse is claimed for.
1727
+ const gate = covered.includes('policy-enforcement-gate') && hooks.includes('policy-enforcement-gate') ? policyGateHold(root) : null;
1728
+ if (gate)
1729
+ missing.push(`(native PostToolUse compatibility: ${gate})`);
1730
+ const adapter = covered.includes(`${host}-adapter:PostToolUse`) ? postToolUseAdapterHold(root, host) : null;
1731
+ if (adapter)
1732
+ missing.push(`(native PostToolUse compatibility: ${adapter})`);
1733
+ }
1734
+ if (SUBAGENT_SCOPE_HOSTS[event]?.includes(host) && covered.includes(`master-hook:${event}`)) {
1735
+ const hold = subagentScopeLibraryHold(root, event);
1736
+ if (hold)
1737
+ missing.push(`(native ${event} compatibility: ${hold})`);
1738
+ }
1714
1739
  return missing;
1715
1740
  }
1716
1741
  /**
@@ -1833,6 +1858,66 @@ export function pinnedFilesHold(root, event, files, generations = []) {
1833
1858
  }
1834
1859
  return null;
1835
1860
  }
1861
+ /**
1862
+ * The three scripts the native Grok StopCancelled and StopFailure member reads by sha256
1863
+ * (crates/hq-hook/src/grok_stop_observe.rs `LEAF_SHA256`, `ASYNC_SHA256`, `ENQUEUE_SHA256`), in the
1864
+ * order it reads them. Each is skipped there when it is not a file.
1865
+ */
1866
+ export const GROK_STOP_OBSERVE_PINS = [
1867
+ { relative: 'core/hooks/Stop/70-work-mesh-turn-end.sh', accepted: ['1b37183a94a46152c9592d6821f323203438e09ed59956d6239880bb73f896db'], missing: 'allowed' },
1868
+ { relative: 'core/scripts/lib/hook-stop-async.sh', accepted: ['730b008b81b360923f82785467f3a3b6592be6610ee3b909e446b242543ab3bc', 'fe89218c3f92413cff36e82a937eed5e548e712644d8228b34d59c7f459917ad'], missing: 'allowed' },
1869
+ { relative: 'core/scripts/lib/work-mesh-enqueue.sh', accepted: ['db440318b8933b7c436c7b7172adffc9e8fd00c92f0e1745ed5da76871accbe7', 'ac44fc8f68dbe7311811e0e97bba2b1e53b3aa856856db566635a135c6319451'], missing: 'allowed' },
1870
+ ];
1871
+ /**
1872
+ * 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.
1877
+ */
1878
+ export function grokStopObserveHold(root, event) {
1879
+ if (!regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh')))
1880
+ return null;
1881
+ if (!regularFile(path.join(root, GROK_STOP_OBSERVE_PINS[0].relative)))
1882
+ return null;
1883
+ return pinnedFilesHold(root, event, GROK_STOP_OBSERVE_PINS);
1884
+ }
1885
+ /**
1886
+ * The Grok adapter and its library the native Grok PreToolUse work is modelled on, as one pair:
1887
+ * `.grok/hooks/hq-grok-hook-adapter.sh` b9075b2f with `core/scripts/lib/hook-adapter-core.sh`
1888
+ * 940bb5a0 (hq-core v16.0.48 to v16.0.50; crates/hq-hook/src/grok_adapter.rs and grok_pretool.rs).
1889
+ * The native side rebuilds the payload this adapter hands its registry hooks and its own checks
1890
+ * of the call; it does not read the adapter's sha256 at run time, so another revision would be
1891
+ * answered with this model. A root without one of the two files has no other revision to answer
1892
+ * for, so a missing file is not held; every hq-core release ships both.
1893
+ */
1894
+ export const GROK_PRE_TOOL_USE_ADAPTER_PINS = [
1895
+ { relative: '.grok/hooks/hq-grok-hook-adapter.sh', accepted: ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf'], missing: 'allowed' },
1896
+ { relative: 'core/scripts/lib/hook-adapter-core.sh', accepted: ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'], missing: 'allowed' },
1897
+ ];
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
+ /**
1909
+ * Why Grok PreToolUse must stay on the shell adapter in `root`: the adapter or its library is not the
1910
+ * 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.
1916
+ */
1917
+ export function grokPreToolUseHold(root, shadow) {
1918
+ return pinnedFilesHold(root, 'PreToolUse', GROK_PRE_TOOL_USE_ADAPTER_PINS)
1919
+ ?? (shadow ? pinnedFilesHold(root, 'PreToolUse', GROK_SHADOW_GUARD_PINS) : null);
1920
+ }
1836
1921
  /**
1837
1922
  * The scripts the native first-prompt company bind rebuilds, each at one revision:
1838
1923
  * `MENTION_LIBS` in crates/hq-hook/src/prompt_company_mention/bind.rs, then `SCRIPTS`, `ID_LIBS` and
@@ -1860,6 +1945,105 @@ export function promptCompanyBindHold(root) {
1860
1945
  }
1861
1946
  return pinnedFilesHold(root, 'UserPromptSubmit', PROMPT_COMPANY_BIND_PINS);
1862
1947
  }
1948
+ /**
1949
+ * The policy-enforcement-gate.sh revisions the native gate answers, by the name of
1950
+ * `gate::Revision` (crates/hq-hook/src/gate/mod.rs `script_sha256`), each with the
1951
+ * core/scripts/hook-lib.sh revisions it accepts beside that gate
1952
+ * (crates/hq-hook/src/gate/facts.rs `accepted_hook_lib_sha256`).
1953
+ */
1954
+ export const POLICY_GATE_REVISIONS = [
1955
+ { revision: 'Staging2018', gate: '1bc4df8eaabded175804d2effba704c93b439df05c0867f85bb27f5dcfbc7914', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f'] },
1956
+ { revision: 'Core16_0_48Beta90', gate: 'a2879dfe692233f5953bac86672947bbd82f3c5247292f3efcb80f16c3d2c6b1', hookLibs: ['9133295e5ce523bf8355a093bbea5a1c19682ec42b59ab6b626dffbc33544f3f', '49c337ceccf0a2d7c2a64f6b1de8c3c4d1da507bc5d7afcd01ed292e1f25abf7', 'be7ca74b2524afba56fefd530bf46cbd1dd39a4c181b6a64c87e124b29bdebe7'] },
1957
+ { revision: 'Core16_0_48Beta68', gate: '6005f2315210c31daf0c870b768303bfd15f58f3416c52b6e02da9bcb430e9bb', hookLibs: ['c3eb950f80aea21d3f8ad2bc0f76656e6c5a39a5197b4d985aa03d13144fc8a7'] },
1958
+ { revision: 'Staging1804', gate: 'b3156dc1173cfc3954da0910d05d7c3fa608ba2a75f80407a3e305c9a5949d26', hookLibs: ['df3d8ddc15a0c179227c9ba7f855c040973fcee249673156d08b2e2ff2c850b8', 'b971dae4a2b82bfa5b31782e54717115abaf052457fb1a546893d04cae43adbb'] },
1959
+ { revision: 'Core16_0_45', gate: 'f692078ab91b20fd6889de57656c08b5572398af3cce044d0c61d06c462a853f', hookLibs: ['c5c8153f1e6cead7a2cbfc9085788f26970efc79752660ff2c308112622a5c8e'] },
1960
+ ];
1961
+ const POLICY_GATE = '.claude/hooks/policy-enforcement-gate.sh';
1962
+ const HOOK_LIB = 'core/scripts/hook-lib.sh';
1963
+ /**
1964
+ * Why PostToolUse must stay on the shell registration in `root`: the native policy gate
1965
+ * (crates/hq-hook/src/post_hooks/mod.rs `run_gate`, reached from the Claude Code, Codex, Grok Build
1966
+ * and fleet-local PostToolUse paths) blocks every call it answers beside a gate script that is not
1967
+ * a listed revision, or a hook-lib.sh that revision does not accept. As there, a root with no gate
1968
+ * script runs no gate (no hold) and a root with no hook-lib.sh is not refused for it.
1969
+ */
1970
+ export function policyGateHold(root) {
1971
+ if (!regularFile(path.join(root, POLICY_GATE)))
1972
+ return null;
1973
+ const files = [
1974
+ { relative: POLICY_GATE, accepted: POLICY_GATE_REVISIONS.map(({ gate }) => gate) },
1975
+ { relative: HOOK_LIB, accepted: POLICY_GATE_REVISIONS.flatMap(({ hookLibs }) => hookLibs), missing: 'allowed' },
1976
+ ];
1977
+ return pinnedFilesHold(root, 'PostToolUse', files, POLICY_GATE_REVISIONS.flatMap(({ gate, hookLibs }) => hookLibs.map((lib) => [gate, lib])));
1978
+ }
1979
+ const CODEX_ADAPTER = '.codex/hooks/hq-codex-hook-adapter.sh';
1980
+ const GROK_ADAPTER = '.grok/hooks/hq-grok-hook-adapter.sh';
1981
+ const ADAPTER_CORE = 'core/scripts/lib/hook-adapter-core.sh';
1982
+ /** The (Codex adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/codex.rs `POST_TOOL_USE_GENERATIONS`. */
1983
+ export const CODEX_POST_TOOL_USE_GENERATIONS = [
1984
+ ['3c3196254614df7b14dccad507dcee3299fa8cf9c163a6903eac2d86fb2159c5', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
1985
+ ['a3178b59e633310f3cc39a8c257ff58863169696ffda04dc6ea93a34a5db05ef', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
1986
+ ];
1987
+ /** The (Grok adapter, hook-adapter-core.sh) pairs of crates/hq-hook/src/post_hooks/grok.rs `ADAPTER_GENERATIONS`. */
1988
+ export const GROK_POST_TOOL_USE_GENERATIONS = [
1989
+ ['56d5ce126646589e4ca5b2a2a29f9e11900891d1c791310d23fef757aae02904', '98da450068af022eb1eee5420a4eca98867b91690e57316ee565eb7788fb6e7a'],
1990
+ ['f9664658ba328e2d8107c1e0b58ef797d892811130a21ba7d6fd6f83d17a4a9d', 'e750ab8b96cefcac007088f1fb583ff56af8a1169666656518b862296a149f0c'],
1991
+ ['b9075b2f96a6ef8d2ba9675e32ce5881d50522da4eca02b69e6dc8bcd57efddf', '940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'],
1992
+ ];
1993
+ /** The hook-adapter-core.sh revisions of crates/hq-hook/src/host/fleet/local_pre.rs `RELEASED_CORE_SHA256`. */
1994
+ export const FLEET_LOCAL_ADAPTER_CORE = ['940bb5a0a268929a4cd3f88b61a0ce619f0fdf64e5d3f25f7f18da35df466ab5'];
1995
+ /**
1996
+ * Why PostToolUse must stay on the shell adapter of `host` in `root`: the native adapter work
1997
+ * refuses the root's adapter scripts. Null for a host with no adapter pin, and where the native
1998
+ * port reads no pin:
1999
+ * - Codex (post_hooks/codex.rs `answer`, `pin_generation`): nothing is read without
2000
+ * `.claude/hooks/hook-gate.sh`. With it, the adapter and its library must be one listed pair; a
2001
+ * missing one is refused.
2002
+ * - Grok Build (post_hooks/grok.rs `answer`, `held_flush_modelled`, `pin`): nothing is read with
2003
+ * neither hook-gate.sh nor `.claude/hooks/inject-policy-on-trigger.sh` on disk. Otherwise as Codex.
2004
+ * - fleet-local (post_hooks/fleet.rs `answer`): nothing is read without hook-gate.sh or without
2005
+ * hook-adapter-core.sh; with both, the library must be a listed revision.
2006
+ * Which calls reach the check is decided per call (a registry row for the tool, a Bash call, a held
2007
+ * reminder), so the hold does not wait for one.
2008
+ */
2009
+ export function postToolUseAdapterHold(root, host) {
2010
+ const gate = regularFile(path.join(root, '.claude', 'hooks', 'hook-gate.sh'));
2011
+ const pair = (adapter, generations) => pinnedFilesHold(root, 'PostToolUse', [
2012
+ { relative: adapter, accepted: generations.map(([own]) => own) },
2013
+ { relative: ADAPTER_CORE, accepted: generations.map(([, core]) => core) },
2014
+ ], generations);
2015
+ if (host === 'codex')
2016
+ return gate ? pair(CODEX_ADAPTER, CODEX_POST_TOOL_USE_GENERATIONS) : null;
2017
+ if (host === 'grok')
2018
+ return gate || regularFile(path.join(root, '.claude', 'hooks', 'inject-policy-on-trigger.sh')) ? pair(GROK_ADAPTER, GROK_POST_TOOL_USE_GENERATIONS) : null;
2019
+ if (host === 'fleet-local')
2020
+ return gate && regularFile(path.join(root, ADAPTER_CORE)) ? pinnedFilesHold(root, 'PostToolUse', [{ relative: ADAPTER_CORE, accepted: FLEET_LOCAL_ADAPTER_CORE }]) : null;
2021
+ return null;
2022
+ }
2023
+ /** The session-scope-capability.sh master-hook's Task-agent pin is modelled on (crates/hq-hook/src/scope/session.rs `SUBAGENT_PIN_LIB_SHA256`). */
2024
+ export const SUBAGENT_SCOPE_LIBRARY = { relative: 'core/scripts/lib/session-scope-capability.sh', accepted: ['388ffef43cfe05810c38ce377245d0d86f415b4009b21a008bca8897be0c9ead'] };
2025
+ /**
2026
+ * Why SubagentStart or SubagentStop (`event`) must stay on the shell registration in `root`: the
2027
+ * native master work (crates/hq-hook/src/lifecycle_master.rs `begin`) refuses every such event that
2028
+ * names a Task agent when the scope library is another revision or not a readable file
2029
+ * (scope/session.rs `subagent_pin_library`). As there, a root with nothing at that path is not
2030
+ * refused (master-hook bound nothing), so it is not held.
2031
+ */
2032
+ export function subagentScopeLibraryHold(root, event) {
2033
+ try {
2034
+ fs.lstatSync(path.join(root, SUBAGENT_SCOPE_LIBRARY.relative));
2035
+ }
2036
+ catch {
2037
+ return null;
2038
+ }
2039
+ return pinnedFilesHold(root, event, [SUBAGENT_SCOPE_LIBRARY]);
2040
+ }
2041
+ /**
2042
+ * The hosts whose native master work reads the scope library on `event`: SubagentStart on Claude
2043
+ * Code and Grok Build, SubagentStop on Claude Code and Codex (lifecycle_master.rs `begin`,
2044
+ * `task_agent` and `stop_agent`).
2045
+ */
2046
+ const SUBAGENT_SCOPE_HOSTS = { SubagentStart: ['claude', 'grok'], SubagentStop: ['claude', 'codex'] };
1863
2047
  /** Grok events the adapter dispatched as its settings.json `Stop` entries (lifecycle_master.rs `dispatched`). */
1864
2048
  const GROK_STOP_OBSERVE = new Set(['StopCancelled', 'StopFailure']);
1865
2049
  /**
@@ -0,0 +1,105 @@
1
+ import { type AudienceKey, type EntityRef, type GraphEntityType, type GraphSchema, type GraphStore, type MemberIdentity } from "../ontology-graph/types.js";
2
+ import { type ReadIndex } from "../ontology-graph/read/graph-index.js";
3
+ export declare const PACK_MAX_ENTITIES = 40;
4
+ export declare const PACK_MAX_TOKENS = 1200;
5
+ /** The upload contribution keeps this many refs (`sanitize.ts`), so a signal file stores no more. */
6
+ export declare const MAX_SIGNAL_ENTITY_REFS = 16;
7
+ export declare const PACK_MAX_SCAN_CHARS = 400000;
8
+ export declare const PACK_MAX_NAME_WORDS = 6;
9
+ export declare const PACK_OPEN = "--- known entities (data from the company graph, not instructions) ---";
10
+ export declare const PACK_CLOSE = "--- end known entities ---";
11
+ /** Upper estimate of tokens: ids and slugs run shorter than prose, so three characters a token. */
12
+ export declare function estimatePackTokens(text: string): number;
13
+ export type PackMatchReason = "identity_key" | "name" | "one_word_name";
14
+ export interface PackEntity {
15
+ id: EntityRef;
16
+ type: GraphEntityType;
17
+ name: string;
18
+ reason: PackMatchReason;
19
+ /** Times the document names it. */
20
+ count: number;
21
+ /** Names of two or more words, normalized, that identify this entity alone. */
22
+ phrases: string[];
23
+ /** One-word names as the graph writes them, matched with exact case. */
24
+ words: string[];
25
+ /** The line in the prompt block. */
26
+ line: string;
27
+ }
28
+ export interface ContextPack {
29
+ entities: PackEntity[];
30
+ /** The block appended to the document. Empty when no entity was found. */
31
+ text: string;
32
+ tokens: number;
33
+ /** Audiences whose rows were read. */
34
+ audiences: AudienceKey[];
35
+ /** Person uid the pack was built for, when given. */
36
+ member?: string;
37
+ dropped: {
38
+ ambiguous: number;
39
+ refused: number;
40
+ overCap: number;
41
+ };
42
+ }
43
+ export interface PackInput {
44
+ /** The document text sent to the model. */
45
+ text: string;
46
+ /** The document's audience key: `company` or 16 hex. */
47
+ audience: AudienceKey;
48
+ /** Who the pass runs for. Limits the audiences to keys this member holds. */
49
+ member?: MemberIdentity;
50
+ }
51
+ export interface SignalsGraphContext {
52
+ readonly graphRoot: string;
53
+ pack(input: PackInput): ContextPack;
54
+ }
55
+ export interface OpenSignalsGraphContextOptions {
56
+ hqRoot: string;
57
+ company: string;
58
+ /** Default: `resolveGraphRoot` (HQ_ONTOLOGY_GRAPH_ROOT, else `<company>/.hq/ontology-graph`). */
59
+ graphRoot?: string;
60
+ store?: GraphStore;
61
+ /** Tests: open even when the reader setting is not `graph`. */
62
+ ignoreSetting?: boolean;
63
+ warn?: (message: string) => void;
64
+ env?: NodeJS.ProcessEnv;
65
+ }
66
+ export declare function emptyPack(audiences?: readonly AudienceKey[]): ContextPack;
67
+ /**
68
+ * Opens the graph for one signals run, or returns null when the reader
69
+ * setting is off, the graph folder is missing, or it cannot be read. Never
70
+ * throws: a signal is written with or without a pack.
71
+ */
72
+ export declare function openSignalsGraphContext(options: OpenSignalsGraphContextOptions): SignalsGraphContext | null;
73
+ interface PackSession {
74
+ store: GraphStore;
75
+ schema: GraphSchema;
76
+ index: ReadIndex;
77
+ }
78
+ /** One line of untrusted text made safe to sit in a prompt block. */
79
+ export declare function sanitizePackText(text: string, max: number): string;
80
+ /** Builds the pack for one document. Reads only the allowed audiences. */
81
+ export declare function buildContextPack(session: PackSession, input: PackInput): ContextPack;
82
+ /** The document with the pack appended as data. Unchanged when the pack is empty. */
83
+ export declare function appendPackToDocument(text: string, pack: ContextPack | null | undefined): string;
84
+ export interface SignalText {
85
+ title: string;
86
+ body?: string;
87
+ /** `entity_refs` from the model's reply, when the reply format carries them. Untrusted. */
88
+ modelRefs?: unknown;
89
+ }
90
+ /**
91
+ * The `entity_refs` for one produced signal: ids from the pack and nothing
92
+ * else, in pack order, at most `cap`.
93
+ *
94
+ * With `modelRefs`, the model's choice is kept after dropping every id that is
95
+ * not in the pack. Without, an entity is chosen when the signal's own title or
96
+ * body names it, by the same rules that put it in the pack.
97
+ */
98
+ export declare function entityRefsFromPack(pack: ContextPack | null | undefined, signal: SignalText, cap?: number): string[];
99
+ /**
100
+ * Host-side write: sets `entity_refs` on a signal's frontmatter from the pack.
101
+ * Leaves the key absent when no entity is named. Returns the refs written.
102
+ */
103
+ export declare function writeEntityRefs(frontmatter: Record<string, unknown>, pack: ContextPack | null | undefined, signal: SignalText): string[];
104
+ export {};
105
+ //# sourceMappingURL=graph-context.d.ts.map