@indigoai-us/hq-cli 5.345.238 → 5.345.242

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 (206) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +170 -8
  3. package/assets/scaffold/core/scripts/hq-delegate-publish.sh +21 -1
  4. package/assets/scaffold/core/scripts/hq-delegate-repo.sh +7 -1
  5. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +95 -20
  6. package/assets/scaffold/core/scripts/hq-delegate-transfer.sh +57 -9
  7. package/assets/scaffold/core/scripts/lib/delegate-engine.sh +77 -0
  8. package/dist/command-catalog.generated.d.ts +212 -10
  9. package/dist/command-catalog.generated.js +260 -10
  10. package/dist/command-registration-plan.d.ts +6 -0
  11. package/dist/command-registration-plan.js +1 -0
  12. package/dist/commands/cloud-off-gate.d.ts +9 -8
  13. package/dist/commands/cloud-off-gate.js +41 -40
  14. package/dist/commands/cloud.d.ts +17 -2
  15. package/dist/commands/cloud.js +126 -24
  16. package/dist/commands/core-delegate-w1b.js +333 -27
  17. package/dist/commands/core-delegate.d.ts +2 -1
  18. package/dist/commands/core-delegate.js +209 -48
  19. package/dist/commands/core-handoff.js +1 -1
  20. package/dist/commands/core-job-model-auth.d.ts +95 -0
  21. package/dist/commands/core-job-model-auth.js +247 -0
  22. package/dist/commands/core-job-run-native.js +280 -12
  23. package/dist/commands/core.js +1 -0
  24. package/dist/commands/deploy-comments.js +8 -2
  25. package/dist/commands/deploy-events.d.ts +40 -0
  26. package/dist/commands/deploy-events.js +300 -0
  27. package/dist/commands/doctor.d.ts +4 -4
  28. package/dist/commands/doctor.js +2 -2
  29. package/dist/commands/feedback.js +2 -3
  30. package/dist/commands/files-browse.js +2 -0
  31. package/dist/commands/files.js +4 -0
  32. package/dist/commands/integrations-core.d.ts +11 -0
  33. package/dist/commands/integrations-core.js +15 -1
  34. package/dist/commands/keyed-sync-pull.d.ts +12 -0
  35. package/dist/commands/keyed-sync-pull.js +151 -0
  36. package/dist/commands/lanes-link.js +2 -2
  37. package/dist/commands/lanes-loop.d.ts +2 -2
  38. package/dist/commands/lanes-loop.js +5 -5
  39. package/dist/commands/lanes-questions.js +1 -1
  40. package/dist/commands/lanes-stories.js +1 -1
  41. package/dist/commands/lanes.js +80 -14
  42. package/dist/commands/library-add.d.ts +5 -2
  43. package/dist/commands/library-add.js +22 -9
  44. package/dist/commands/mcp-registration.d.ts +4 -18
  45. package/dist/commands/mcp-registration.js +9 -29
  46. package/dist/commands/mesh.d.ts +4 -0
  47. package/dist/commands/mesh.js +25 -5
  48. package/dist/commands/pack-install.d.ts +2 -3
  49. package/dist/commands/pack-install.js +6 -8
  50. package/dist/commands/rescue.d.ts +3 -2
  51. package/dist/commands/rescue.js +48 -34
  52. package/dist/commands/search.d.ts +6 -0
  53. package/dist/commands/search.js +24 -4
  54. package/dist/commands/secrets.d.ts +3 -4
  55. package/dist/commands/secrets.js +3 -20
  56. package/dist/commands/sources.js +6 -2
  57. package/dist/commands/sync-core.d.ts +8 -0
  58. package/dist/commands/sync-core.js +43 -0
  59. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1830 -1468
  60. package/dist/hq-cloud-sync-runner/package.json +1 -1
  61. package/dist/lib/bot/api.d.ts +2 -1
  62. package/dist/lib/bot/api.js +2 -15
  63. package/dist/lib/capacity/accounts.d.ts +1 -1
  64. package/dist/lib/capacity/accounts.js +1 -1
  65. package/dist/lib/capacity/collectors/claude-oauth.d.ts +0 -2
  66. package/dist/lib/capacity/collectors/claude-oauth.js +0 -5
  67. package/dist/lib/capacity/freshness.d.ts +1 -1
  68. package/dist/lib/capacity/freshness.js +1 -1
  69. package/dist/lib/capacity/route.js +1 -1
  70. package/dist/lib/core-utils/delegate-helper-paths.d.ts +26 -0
  71. package/dist/lib/core-utils/delegate-helper-paths.js +33 -0
  72. package/dist/lib/daemon/catalog.d.ts +3 -0
  73. package/dist/lib/daemon/hook-requests.d.ts +1 -1
  74. package/dist/lib/daemon/hook-requests.js +4 -2
  75. package/dist/lib/daemon/jq-provision.d.ts +63 -0
  76. package/dist/lib/daemon/jq-provision.js +155 -0
  77. package/dist/lib/daemon/lanes-reconcile-guard.d.ts +4 -3
  78. package/dist/lib/daemon/lanes-reconcile-guard.js +4 -4
  79. package/dist/lib/daemon/mesh-owner.d.ts +4 -0
  80. package/dist/lib/daemon/mesh-owner.js +20 -0
  81. package/dist/lib/daemon/ops/policy.d.ts +3 -0
  82. package/dist/lib/daemon/ops/policy.js +32 -4
  83. package/dist/lib/daemon/run.js +17 -22
  84. package/dist/lib/daemon/server.d.ts +6 -0
  85. package/dist/lib/daemon/server.js +5 -0
  86. package/dist/lib/daemon/verified-jq.d.ts +96 -0
  87. package/dist/lib/daemon/verified-jq.js +337 -0
  88. package/dist/lib/doctor/checks/jq.js +16 -0
  89. package/dist/lib/doctor/deep/executor.d.ts +7 -0
  90. package/dist/lib/doctor/deep/executor.js +1 -1
  91. package/dist/lib/doctor/deep/parity.js +1 -27
  92. package/dist/lib/doctor/deep/sandbox.d.ts +2 -2
  93. package/dist/lib/doctor/deep/sandbox.js +3 -19
  94. package/dist/lib/doctor/fix/refresh-sync-handoff.js +52 -21
  95. package/dist/lib/doctor/fixtures/discover.d.ts +2 -0
  96. package/dist/lib/doctor/fixtures/discover.js +1 -1
  97. package/dist/lib/doctor/json-output.d.ts +1 -1
  98. package/dist/lib/doctor/registry.d.ts +6 -7
  99. package/dist/lib/doctor/registry.js +6 -7
  100. package/dist/lib/doctor/report.d.ts +9 -10
  101. package/dist/lib/doctor/report.js +4 -4
  102. package/dist/lib/environment/work-requirements.d.ts +1 -1
  103. package/dist/lib/environment/work-requirements.js +1 -1
  104. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  105. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  106. package/dist/lib/hook-engine/coverage.js +11 -3
  107. package/dist/lib/hook-engine/git-stop-config.json +510 -510
  108. package/dist/lib/hook-engine/native-precompact-compatibility.json +443 -443
  109. package/dist/lib/hook-engine/native-stop-compatibility.json +359 -359
  110. package/dist/lib/hot-channels/adapters/meetings.d.ts +1 -16
  111. package/dist/lib/hot-channels/adapters/meetings.js +3 -28
  112. package/dist/lib/hot-channels/adapters/slack.d.ts +3 -1
  113. package/dist/lib/hot-channels/adapters/slack.js +4 -1
  114. package/dist/lib/hot-channels/contract.d.ts +14 -0
  115. package/dist/lib/hot-channels/fleet-complete.d.ts +18 -2
  116. package/dist/lib/hot-channels/fleet-complete.js +29 -4
  117. package/dist/lib/hot-channels/meeting-source-ref.d.ts +17 -0
  118. package/dist/lib/hot-channels/meeting-source-ref.js +32 -0
  119. package/dist/lib/hot-channels/prompts/signals-pass.md +6 -1
  120. package/dist/lib/hot-channels/run.d.ts +10 -0
  121. package/dist/lib/hot-channels/run.js +34 -0
  122. package/dist/lib/hot-channels/signals-pass.d.ts +27 -0
  123. package/dist/lib/hot-channels/signals-pass.js +57 -2
  124. package/dist/lib/hot-channels/signals-runtime.js +3 -2
  125. package/dist/lib/jq/install.d.ts +27 -0
  126. package/dist/lib/jq/install.js +156 -0
  127. package/dist/lib/lanes/accounts.js +2 -2
  128. package/dist/lib/lanes/claude-balance.d.ts +6 -0
  129. package/dist/lib/lanes/claude-balance.js +124 -0
  130. package/dist/lib/lanes/grants.js +15 -2
  131. package/dist/lib/lanes/hq-root.d.ts +1 -1
  132. package/dist/lib/lanes/hq-root.js +1 -1
  133. package/dist/lib/lanes/links.d.ts +1 -1
  134. package/dist/lib/lanes/liveness.d.ts +3 -0
  135. package/dist/lib/lanes/liveness.js +61 -7
  136. package/dist/lib/lanes/models.d.ts +1 -1
  137. package/dist/lib/lanes/models.js +1 -1
  138. package/dist/lib/lanes/outpost-dispatch.d.ts +1 -1
  139. package/dist/lib/lanes/outpost-dispatch.js +13 -13
  140. package/dist/lib/lanes/outpost-pruner-install.js +1 -1
  141. package/dist/lib/lanes/questions.d.ts +1 -1
  142. package/dist/lib/lanes/questions.js +2 -2
  143. package/dist/lib/lanes/spawn.js +4 -6
  144. package/dist/lib/lanes/store.d.ts +13 -2
  145. package/dist/lib/lanes/store.js +13 -5
  146. package/dist/lib/lanes/types.d.ts +7 -7
  147. package/dist/lib/lanes/types.js +1 -1
  148. package/dist/lib/lanes/watcher-main.js +1 -1
  149. package/dist/lib/lanes/watcher.d.ts +1 -1
  150. package/dist/lib/lanes/watcher.js +1 -1
  151. package/dist/lib/mesh/live/daemon/doctor.js +7 -1
  152. package/dist/lib/mesh/live/daemon/install.d.ts +4 -0
  153. package/dist/lib/mesh/live/daemon/install.js +10 -0
  154. package/dist/lib/mesh/live/daemon/run.js +17 -0
  155. package/dist/lib/mesh/live/emit-retry.d.ts +20 -2
  156. package/dist/lib/mesh/live/emit-retry.js +57 -4
  157. package/dist/lib/mesh/live/emit.js +25 -4
  158. package/dist/lib/mesh/live/flush.d.ts +2 -0
  159. package/dist/lib/mesh/live/flush.js +21 -8
  160. package/dist/lib/mesh/live/spool.d.ts +9 -1
  161. package/dist/lib/mesh/live/spool.js +41 -29
  162. package/dist/lib/onboarding/cli/onboard.js +5 -0
  163. package/dist/lib/signals/sanitize.d.ts +19 -0
  164. package/dist/lib/signals/sanitize.js +103 -7
  165. package/dist/lib/signals/steps/upload.d.ts +40 -1
  166. package/dist/lib/signals/steps/upload.js +122 -6
  167. package/dist/lib/sync-core/access-refresh.d.ts +29 -0
  168. package/dist/lib/sync-core/access-refresh.js +97 -0
  169. package/dist/lib/sync-core/company-adoption.d.ts +33 -0
  170. package/dist/lib/sync-core/company-adoption.js +223 -0
  171. package/dist/lib/sync-core/engine-home.d.ts +1 -0
  172. package/dist/lib/sync-core/engine-owned.d.ts +13 -0
  173. package/dist/lib/sync-core/engine-owned.js +38 -0
  174. package/dist/lib/sync-core/hand-back.d.ts +17 -0
  175. package/dist/lib/sync-core/hand-back.js +23 -0
  176. package/dist/lib/sync-core/post-apply-reindex.d.ts +33 -0
  177. package/dist/lib/sync-core/post-apply-reindex.js +149 -0
  178. package/dist/lib/sync-core/reconcile.d.ts +10 -0
  179. package/dist/lib/sync-core/reconcile.js +117 -12
  180. package/dist/lib/sync-core/rollout-state.d.ts +11 -1
  181. package/dist/lib/sync-core/rollout-state.js +40 -4
  182. package/dist/lib/vault-sync-switches.d.ts +14 -0
  183. package/dist/lib/vault-sync-switches.js +22 -0
  184. package/dist/lib/windows/jq.d.ts +4 -0
  185. package/dist/lib/windows/jq.js +10 -39
  186. package/dist/lib/workers-registry/index.d.ts +1 -1
  187. package/dist/lib/workers-registry/index.js +8 -12
  188. package/dist/utils/callback-port-busy.d.ts +2 -2
  189. package/dist/utils/callback-port-busy.js +2 -2
  190. package/dist/utils/cli-network-lifecycle.js +1 -0
  191. package/dist/utils/client-health-contract.d.ts +2 -0
  192. package/dist/utils/client-health-contract.js +1 -1
  193. package/dist/utils/client-health.js +1 -9
  194. package/dist/utils/cognito-config.js +5 -0
  195. package/dist/utils/cognito-session.d.ts +4 -6
  196. package/dist/utils/cognito-session.js +4 -24
  197. package/dist/utils/github-tag-fallback.d.ts +16 -0
  198. package/dist/utils/github-tag-fallback.js +126 -0
  199. package/dist/utils/incomplete-install-error.js +1 -11
  200. package/dist/utils/install-tree-torn.d.ts +11 -0
  201. package/dist/utils/install-tree-torn.js +1 -1
  202. package/dist/utils/resident-package-preload.js +2 -1
  203. package/dist/utils/version-report.d.ts +2 -1
  204. package/dist/utils/version-report.js +40 -27
  205. package/docs/anywhere-runtime.md +8 -0
  206. package/package.json +9 -9
@@ -30,9 +30,10 @@ import { createLegacyHandover, LEGACY_HANDOVER_STUCK_FILE, writeLegacyHandoverSt
30
30
  import { effectiveSyncOwner, readDaemonConfig } from "./config.js";
31
31
  import { backgroundQosCommand } from "./background-qos.js";
32
32
  import { serveQmdWorker } from "../search-index/worker-process.js";
33
- import { inspectEngineHome } from "../sync-core/engine-home.js";
33
+ import { inspectEngineHome, syncCoreUnitId } from "../sync-core/engine-home.js";
34
34
  import { fullModeHold } from "../sync-core/reconcile.js";
35
35
  import { engineVaultCount, readSyncCoreRolloutState } from "../sync-core/rollout-state.js";
36
+ import { engineOwnsVault, finishLegacyHandBack } from "../sync-core/hand-back.js";
36
37
  import { effectiveEngineSettings, readSyncCoreVaultSettings } from "../sync-core/vault-settings.js";
37
38
  import { assertPersonalServiceSessionCapability, readRemoteControlPoolsConfig, remoteControlPoolSecretsEnv, } from "./remote-control-pools.js";
38
39
  import { loadLanesConfig } from "../lanes/config.js";
@@ -48,7 +49,7 @@ import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
48
49
  import { createLanesReconcileStatus, withLanesReconcileUnit } from "./lanes-reconcile-status.js";
49
50
  import { findLegacyUnits, legacyMeshUnitsToRetire, legacyOwnerLookup, } from "./legacy.js";
50
51
  import { readLegacySyncEnv } from "./legacy-sync-env.js";
51
- import { readVaultSwitchOnTimes, readVaultSyncSwitches, unreadableSwitchesWarning, writeVaultSyncSwitches } from "../vault-sync-switches.js";
52
+ import { legacySwitchRestorePatch, readVaultSwitchOnTimes, readVaultSyncSwitches, unreadableSwitchesWarning } from "../vault-sync-switches.js";
52
53
  import { scheduleDaemonPlistRefresh } from "./plist-refresh.js";
53
54
  import { acquireDaemonLock, isProcessAlive, processCommandLine, releaseDaemonLock } from "./lock.js";
54
55
  import { retireLegacyMeshUnits } from "./migrate.js";
@@ -108,6 +109,7 @@ export function syncCoreVaultPlans(home, hqRoot, platform) {
108
109
  binaryPath: state.binaryPath,
109
110
  release: state.release,
110
111
  ...(vault.legacyOffSince ? { legacyOffSince: vault.legacyOffSince } : {}),
112
+ ...(vault.legacyAlreadyOff ? { legacyAlreadyOff: true } : {}),
111
113
  ...(effective ? { settings: effective } : {}),
112
114
  }, platform);
113
115
  const releaseHold = vault.phase === "full" ? fullModeHold(vault, state.release, platform) : undefined;
@@ -140,27 +142,18 @@ export function planUnitsWithSyncCoreInterlock(services, context, supervisor, re
140
142
  if (context.vaultSync && !context.vaultSync.allOff) {
141
143
  let personalOff = context.vaultSync.personalOff;
142
144
  const offCompanies = new Set(context.vaultSync.offCompanies);
143
- let restorePersonal = false;
144
- const restoreCompanies = {};
145
- for (const vault of context.syncCoreVaults ?? []) {
146
- if (vault.phase !== "full" || runningVaults.has(vault.uid) || !fullModeHold(vault, vault.release, context.platform))
147
- continue;
148
- if (vault.kind === "personal") {
149
- restorePersonal = personalOff;
150
- personalOff = false;
151
- }
152
- else if (vault.slug) {
153
- if (offCompanies.has(vault.slug))
154
- restoreCompanies[vault.slug] = true;
155
- offCompanies.delete(vault.slug);
156
- }
157
- }
158
- if (restorePersonal || Object.keys(restoreCompanies).length > 0) {
145
+ const engineStopped = (uid) => !!supervisor && supervisor.runningPlanKey(syncCoreUnitId(uid)) === undefined;
146
+ const held = (context.syncCoreVaults ?? []).filter((vault) => vault.phase === "full" && engineStopped(vault.uid) && fullModeHold(vault, vault.release, context.platform));
147
+ const handingBack = (context.syncCoreHandingBack ?? []).filter((vault) => engineStopped(vault.uid) && engineOwnsVault(context.home, vault.uid));
148
+ const handBack = [...held, ...handingBack];
149
+ const restore = legacySwitchRestorePatch(handBack, context.vaultSync);
150
+ if (restore.personal)
151
+ personalOff = false;
152
+ for (const slug of Object.keys(restore.companies))
153
+ offCompanies.delete(slug);
154
+ if (handBack.length > 0) {
159
155
  try {
160
- writeVaultSyncSwitches(context.home, {
161
- ...(restorePersonal ? { personal: true } : {}),
162
- companies: restoreCompanies,
163
- });
156
+ finishLegacyHandBack(context.home, handBack, context.vaultSync);
164
157
  }
165
158
  catch {
166
159
  fallbackPersistenceFailed = true;
@@ -1616,6 +1609,7 @@ export async function runDaemon(opts) {
1616
1609
  })(),
1617
1610
  syncOwner,
1618
1611
  syncCoreVaults: syncCoreVaultPlans(home, hqRoot, platform),
1612
+ syncCoreHandingBack: readSyncCoreRolloutState(home)?.handingBack ?? [],
1619
1613
  desktopAppManagesSync: appManagesSync,
1620
1614
  legacySyncUnitManagesSync: legacy.some((u) => u.service === "sync" && !u.migratable),
1621
1615
  syncRunnerProcesses,
@@ -1974,6 +1968,7 @@ export async function runDaemon(opts) {
1974
1968
  socketPath: hqdSocketPath(home, env),
1975
1969
  registryPath: registryFile(registryDir(home, env)),
1976
1970
  hqRoot,
1971
+ warmJq: true,
1977
1972
  log,
1978
1973
  flagSnapshots,
1979
1974
  onRuntimeChange: () => hqdRuntimeEvents.emit(),
@@ -30,6 +30,12 @@ export interface HqdServerOptions {
30
30
  /** registry.json to resolve against (US-004). */
31
31
  registryPath?: string;
32
32
  hqRoot?: string;
33
+ /**
34
+ * Find (or install) the jq policy checks run with as soon as the server
35
+ * starts, so the first check does not wait for it. Off by default; the
36
+ * daemon turns it on.
37
+ */
38
+ warmJq?: boolean;
33
39
  version?: string;
34
40
  now?: () => Date;
35
41
  /** Called when the Windows named-pipe helper fails and hqd must stop. */
@@ -20,6 +20,8 @@ import { sessionMetaCompanies } from "../core-utils/session-company.js";
20
20
  import { journalAppend, JournalOpError } from "./ops/journal.js";
21
21
  import { parseSkillCommandArgs, runSkillCommand, SkillCommandOpError } from "./ops/skill-command.js";
22
22
  import { PolicyIndex, PolicyOpError, policyCheck } from "./ops/policy.js";
23
+ import { withoutHookEnv } from "./hook-env.js";
24
+ import { resolveOrProvisionJq } from "./jq-provision.js";
23
25
  import { defaultMcpToken, HqMcpBridge, jsonResult, McpOpError, runWorker } from "./ops/mcp.js";
24
26
  import { authenticateMachineCredentials, machineTokenExpiresAt, MachineLoginError, parseStdinMachineCredentials } from "./machine-login.js";
25
27
  import { HQ_MCP_TOOL_NAMES, HQD_NATIVE_TOOL_NAMES } from "../mcp/tools.js";
@@ -315,6 +317,9 @@ export async function startHqdServer(opts) {
315
317
  const clock = opts.now ?? (() => new Date());
316
318
  const env = opts.env ?? process.env;
317
319
  const policyIndex = opts.hqRoot ? new PolicyIndex(opts.hqRoot, log) : null;
320
+ if (opts.hqRoot && opts.warmJq) {
321
+ resolveOrProvisionJq({ env: withoutHookEnv(env), waitMs: 180_000, provision: { log: (line) => log("info", line) } }).then((jq) => log("info", `policy checks run with ${jq.version} at ${jq.realPath}`), (err) => log("warn", `policy checks have no working jq yet: ${err.message}`));
322
+ }
318
323
  let ephemeralMachineToken;
319
324
  let flagRevocationGeneration = 0;
320
325
  const requireRoot = () => {
@@ -0,0 +1,96 @@
1
+ /**
2
+ * A jq the daemon can trust to run the hq-core hook scripts.
3
+ *
4
+ * The scope authorizer parses every hook payload with whatever `jq` is first on
5
+ * its PATH. The daemon's OS unit puts the login user's tool folders first
6
+ * (~/.local/bin, see tools.ts userToolDirs), and people keep homemade tools
7
+ * there. A `jq` that is not jq breaks the authorizer in both directions:
8
+ *
9
+ * - A stand-in that echoes stdin for the agent-field filter turned every
10
+ * main-thread check into "This call has an invalid agent_id".
11
+ * - A stand-in that echoes stdin for every filter makes the authorizer read no
12
+ * tool name or path at all, and it then allows Read, Write, Grep and Bash
13
+ * calls into another company's folder.
14
+ *
15
+ * So before the daemon runs a hook script it finds a jq that reports
16
+ * `jq-1.x` for `--version` and computes a known filter correctly, and gives the
17
+ * scripts a PATH whose `jq` is that binary and nothing else. If no candidate
18
+ * qualifies the caller fails closed.
19
+ *
20
+ * Probes run with stdin closed and a timeout: a stand-in that reads stdin and
21
+ * ignores flags hangs on `--version` otherwise.
22
+ */
23
+ export declare const JQ_VERSION_RE: RegExp;
24
+ /** Input, filter and exact output of the behavior probe. */
25
+ export declare const JQ_BEHAVIOR_PROBE: {
26
+ readonly input: "{\"a\":null,\"b\":\"x\",\"c\":[1,2],\"d\":{\"e\":\"f\"}}";
27
+ readonly filter: "(if .a == null then \"\" else .a end) + \"|\" + (.b | ascii_upcase) + \"|\" + (.c | map(. * 2 | tostring) | join(\",\")) + \"|\" + (.d | to_entries | map(.key + \"=\" + .value) | join(\";\"))";
28
+ readonly expected: "|X|2,4|e=f";
29
+ };
30
+ export interface JqProbe {
31
+ ok: boolean;
32
+ version: string | null;
33
+ /** Why the candidate was refused, in plain words. Empty when ok. */
34
+ reason: string;
35
+ }
36
+ export interface VerifiedJq {
37
+ /** The candidate as found (for example /opt/homebrew/bin/jq). */
38
+ path: string;
39
+ /** What that resolves to on disk. */
40
+ realPath: string;
41
+ version: string;
42
+ /** A folder to put first on PATH; its `jq` is this binary. */
43
+ binDir: string;
44
+ }
45
+ export interface JqRejection {
46
+ path: string;
47
+ reason: string;
48
+ }
49
+ export declare class JqUnavailableError extends Error {
50
+ readonly rejected: JqRejection[];
51
+ readonly note?: string | undefined;
52
+ constructor(rejected: JqRejection[], note?: string | undefined);
53
+ }
54
+ /** The plain-language reason a policy check gives when no jq qualifies. */
55
+ export declare function describeJqUnavailable(rejected: JqRejection[], note?: string): string;
56
+ export type JqRunner = (file: string, args: string[], input: string | null, timeoutMs: number) => Promise<{
57
+ code: number | null;
58
+ stdout: string;
59
+ timedOut: boolean;
60
+ error?: string;
61
+ }>;
62
+ /** Run `file args` with no shell, a small clean environment and a hard timeout. */
63
+ export declare const runJq: JqRunner;
64
+ /** Whether `file` is real jq: `--version` says jq-1.x and a known filter computes correctly. */
65
+ export declare function probeJq(file: string, run?: JqRunner, timeoutMs?: number): Promise<JqProbe>;
66
+ /**
67
+ * Where to look, best first. Folders the user's own tools cannot shadow come
68
+ * first (Apple's /usr/bin/jq on macOS 15+, then Homebrew and /usr/local), then
69
+ * every PATH entry in order. Every candidate is probed regardless.
70
+ */
71
+ export declare const VETTED_JQ_PATHS: readonly string[];
72
+ export declare function jqCandidates(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, vettedPaths?: readonly string[]): string[];
73
+ export interface ResolveJqDeps {
74
+ env: NodeJS.ProcessEnv;
75
+ /** Folder for the private `jq` link. Defaults to ~/.hq/daemon/verified-bin. */
76
+ binDir?: string;
77
+ platform?: NodeJS.Platform;
78
+ run?: JqRunner;
79
+ timeoutMs?: number;
80
+ /** Checked before PATH. Defaults to VETTED_JQ_PATHS. */
81
+ vettedPaths?: readonly string[];
82
+ /** Managed files which failed their checksum or path safety checks, including aliases. */
83
+ rejectedPaths?: readonly string[];
84
+ /** Refused locations: exclude their whole subtree, including realpath aliases. */
85
+ rejectedLocations?: readonly string[];
86
+ }
87
+ /** For tests. */
88
+ export declare function clearJqProbeCache(): void;
89
+ /**
90
+ * The first candidate that passes probeJq. Throws JqUnavailableError, listing
91
+ * what was refused and why, when none does.
92
+ */
93
+ export declare function resolveVerifiedJq(deps: ResolveJqDeps): Promise<VerifiedJq>;
94
+ /** `env` with `binDir` first on PATH. */
95
+ export declare function withJqFirst(env: NodeJS.ProcessEnv, binDir: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
96
+ //# sourceMappingURL=verified-jq.d.ts.map
@@ -0,0 +1,337 @@
1
+ /**
2
+ * A jq the daemon can trust to run the hq-core hook scripts.
3
+ *
4
+ * The scope authorizer parses every hook payload with whatever `jq` is first on
5
+ * its PATH. The daemon's OS unit puts the login user's tool folders first
6
+ * (~/.local/bin, see tools.ts userToolDirs), and people keep homemade tools
7
+ * there. A `jq` that is not jq breaks the authorizer in both directions:
8
+ *
9
+ * - A stand-in that echoes stdin for the agent-field filter turned every
10
+ * main-thread check into "This call has an invalid agent_id".
11
+ * - A stand-in that echoes stdin for every filter makes the authorizer read no
12
+ * tool name or path at all, and it then allows Read, Write, Grep and Bash
13
+ * calls into another company's folder.
14
+ *
15
+ * So before the daemon runs a hook script it finds a jq that reports
16
+ * `jq-1.x` for `--version` and computes a known filter correctly, and gives the
17
+ * scripts a PATH whose `jq` is that binary and nothing else. If no candidate
18
+ * qualifies the caller fails closed.
19
+ *
20
+ * Probes run with stdin closed and a timeout: a stand-in that reads stdin and
21
+ * ignores flags hangs on `--version` otherwise.
22
+ */
23
+ import { spawn } from "node:child_process";
24
+ import * as fs from "node:fs";
25
+ import * as path from "node:path";
26
+ import { checkJqDirectory, checkSystemJqDirectory, UnsafeJqPathError } from "../jq/install.js";
27
+ export const JQ_VERSION_RE = /^jq-1\.\d+/;
28
+ /** Input, filter and exact output of the behavior probe. */
29
+ export const JQ_BEHAVIOR_PROBE = {
30
+ input: '{"a":null,"b":"x","c":[1,2],"d":{"e":"f"}}',
31
+ filter: '(if .a == null then "" else .a end) + "|" + (.b | ascii_upcase) + "|" + (.c | map(. * 2 | tostring) | join(",")) + "|" + (.d | to_entries | map(.key + "=" + .value) | join(";"))',
32
+ expected: "|X|2,4|e=f",
33
+ };
34
+ /** Per probe step; real jq answers in milliseconds. Keeps a cold check well under the client's timeout. */
35
+ const PROBE_TIMEOUT_MS = 2_000;
36
+ export class JqUnavailableError extends Error {
37
+ rejected;
38
+ note;
39
+ constructor(rejected, note) {
40
+ super(describeJqUnavailable(rejected, note));
41
+ this.rejected = rejected;
42
+ this.note = note;
43
+ this.name = "JqUnavailableError";
44
+ }
45
+ }
46
+ /** The plain-language reason a policy check gives when no jq qualifies. */
47
+ export function describeJqUnavailable(rejected, note) {
48
+ const head = "HQ could not run the company access check, so it is blocking this call: the check needs jq, and";
49
+ const tail = note ? ` ${note}` : " Updating HQ installs a verified copy.";
50
+ if (rejected.length === 0)
51
+ return `${head} no jq was found on this computer.${tail}`;
52
+ const found = rejected.map((r) => `${r.path} (${r.reason})`).join("; ");
53
+ return `${head} no working jq was found. Found: ${found}.${tail}`;
54
+ }
55
+ /** Run `file args` with no shell, a small clean environment and a hard timeout. */
56
+ export const runJq = (file, args, input, timeoutMs) => new Promise((resolve) => {
57
+ let child;
58
+ try {
59
+ child = spawn(file, args, {
60
+ stdio: [input === null ? "ignore" : "pipe", "pipe", "ignore"],
61
+ env: { PATH: "/usr/bin:/bin", LC_ALL: "C" },
62
+ });
63
+ }
64
+ catch (err) {
65
+ resolve({ code: null, stdout: "", timedOut: false, error: err.message });
66
+ return;
67
+ }
68
+ let stdout = "";
69
+ let timedOut = false;
70
+ let settled = false;
71
+ const finish = (r) => {
72
+ if (settled)
73
+ return;
74
+ settled = true;
75
+ clearTimeout(timer);
76
+ resolve(r);
77
+ };
78
+ const timer = setTimeout(() => {
79
+ timedOut = true;
80
+ child.kill("SIGKILL");
81
+ finish({ code: null, stdout, timedOut: true });
82
+ }, timeoutMs);
83
+ child.stdout?.on("data", (c) => {
84
+ stdout += c.toString("utf8");
85
+ if (stdout.length > 64 * 1024)
86
+ child.kill("SIGKILL");
87
+ });
88
+ child.on("error", (err) => finish({ code: null, stdout, timedOut, error: err.message }));
89
+ child.on("close", (code) => finish({ code, stdout, timedOut }));
90
+ if (input !== null && child.stdin) {
91
+ child.stdin.on("error", () => {
92
+ // A candidate that exits without reading stdin is judged by its output.
93
+ });
94
+ child.stdin.end(input);
95
+ }
96
+ });
97
+ /** Whether `file` is real jq: `--version` says jq-1.x and a known filter computes correctly. */
98
+ export async function probeJq(file, run = runJq, timeoutMs = PROBE_TIMEOUT_MS) {
99
+ const v = await run(file, ["--version"], null, timeoutMs);
100
+ if (v.timedOut)
101
+ return { ok: false, version: null, reason: "jq --version did not answer" };
102
+ if (v.error)
103
+ return { ok: false, version: null, reason: `could not run it: ${v.error}` };
104
+ const version = v.stdout.trim().split(/\r?\n/)[0] ?? "";
105
+ if (v.code !== 0 || !JQ_VERSION_RE.test(version)) {
106
+ const shown = version.slice(0, 40).replace(/[^\x20-\x7e]/g, "?");
107
+ return { ok: false, version: null, reason: `jq --version printed "${shown}", not jq-1.x` };
108
+ }
109
+ const b = await run(file, ["-j", JQ_BEHAVIOR_PROBE.filter], JQ_BEHAVIOR_PROBE.input, timeoutMs);
110
+ if (b.timedOut)
111
+ return { ok: false, version, reason: "it did not answer a test filter" };
112
+ if (b.code !== 0 || b.stdout !== JQ_BEHAVIOR_PROBE.expected) {
113
+ return { ok: false, version, reason: "it answered a test filter wrongly, so it is not jq" };
114
+ }
115
+ return { ok: true, version, reason: "" };
116
+ }
117
+ /**
118
+ * Where to look, best first. Folders the user's own tools cannot shadow come
119
+ * first (Apple's /usr/bin/jq on macOS 15+, then Homebrew and /usr/local), then
120
+ * every PATH entry in order. Every candidate is probed regardless.
121
+ */
122
+ export const VETTED_JQ_PATHS = ["/usr/bin/jq", "/opt/homebrew/bin/jq", "/usr/local/bin/jq"];
123
+ export function jqCandidates(env, platform = process.platform, vettedPaths = VETTED_JQ_PATHS) {
124
+ const windows = platform === "win32";
125
+ const p = windows ? path.win32 : path.posix;
126
+ // Only files named jq: the hook scripts run `jq`, so another name on PATH
127
+ // could never be what they run.
128
+ const names = windows ? ["jq.exe", "jq"] : ["jq"];
129
+ const vetted = windows ? vettedPaths.filter((file) => /^[a-z]:[\\/]|^\\\\/i.test(file)) : vettedPaths;
130
+ const fromPath = [];
131
+ for (const dir of (env.PATH ?? env.Path ?? "").split(p.delimiter)) {
132
+ if (!dir || !p.isAbsolute(dir))
133
+ continue;
134
+ for (const name of names)
135
+ fromPath.push(p.join(dir, name));
136
+ }
137
+ return [...new Set([...vetted, ...fromPath])];
138
+ }
139
+ /** Probe results by real path, valid while the file's stat stamp is unchanged. */
140
+ const probeCache = new Map();
141
+ /** For tests. */
142
+ export function clearJqProbeCache() {
143
+ probeCache.clear();
144
+ }
145
+ function stampOf(file) {
146
+ try {
147
+ const st = fs.statSync(file);
148
+ if (!st.isFile())
149
+ return null;
150
+ return `${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}:${st.mode}`;
151
+ }
152
+ catch {
153
+ return null;
154
+ }
155
+ }
156
+ function isExecutable(file, windows) {
157
+ if (windows)
158
+ return true;
159
+ try {
160
+ fs.accessSync(file, fs.constants.X_OK);
161
+ return true;
162
+ }
163
+ catch {
164
+ return false;
165
+ }
166
+ }
167
+ /** Point `<binDir>/jq` at `target`, replacing a link that points elsewhere. */
168
+ function linkJq(home, binDir, target) {
169
+ const link = path.join(binDir, "jq");
170
+ checkJqDirectory(home, binDir, true);
171
+ try {
172
+ if (fs.readlinkSync(link) === target)
173
+ return;
174
+ }
175
+ catch {
176
+ // Missing or not a link: (re)create below.
177
+ }
178
+ const tmp = `${link}.${process.pid}.${Date.now()}.tmp`;
179
+ fs.symlinkSync(target, tmp);
180
+ fs.renameSync(tmp, link);
181
+ checkJqDirectory(home, binDir);
182
+ }
183
+ function within(location, file) {
184
+ const relative = path.relative(location, file);
185
+ return !relative || (relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
186
+ }
187
+ function refusedLocation(file, realFile, locations) {
188
+ for (const location of locations) {
189
+ const roots = [path.resolve(location)];
190
+ try {
191
+ roots.push(fs.realpathSync(location));
192
+ }
193
+ catch (error) {
194
+ if (error.code !== "ENOENT") {
195
+ throw new JqUnavailableError([{ path: location, reason: `could not resolve refused location: ${error.message}` }]);
196
+ }
197
+ }
198
+ if (roots.some((root) => within(root, path.resolve(file)) || within(root, realFile)))
199
+ return location;
200
+ }
201
+ return undefined;
202
+ }
203
+ /**
204
+ * The first candidate that passes probeJq. Throws JqUnavailableError, listing
205
+ * what was refused and why, when none does.
206
+ */
207
+ export async function resolveVerifiedJq(deps) {
208
+ const platform = deps.platform ?? process.platform;
209
+ const windows = platform === "win32";
210
+ const run = deps.run ?? runJq;
211
+ const rejected = [];
212
+ const rejectedLocations = [...(deps.rejectedLocations ?? [])];
213
+ const home = windows ? deps.env.USERPROFILE ?? deps.env.HOME : deps.env.HOME;
214
+ const privateDir = windows ? undefined : deps.binDir ?? (home ? path.join(home, ".hq", "daemon", "verified-bin") : undefined);
215
+ let privateAllowed = Boolean(privateDir && home);
216
+ if (privateDir && home) {
217
+ try {
218
+ checkJqDirectory(home, privateDir);
219
+ }
220
+ catch (error) {
221
+ privateAllowed = false;
222
+ if (error instanceof UnsafeJqPathError)
223
+ rejectedLocations.push(error.path);
224
+ rejected.push({ path: privateDir, reason: error.message });
225
+ }
226
+ }
227
+ const seenReal = new Set();
228
+ for (const candidate of jqCandidates(deps.env, platform, deps.vettedPaths)) {
229
+ if (!fs.existsSync(candidate))
230
+ continue;
231
+ let realPath;
232
+ let candidateDir;
233
+ try {
234
+ realPath = fs.realpathSync(candidate);
235
+ candidateDir = fs.realpathSync(path.dirname(candidate));
236
+ }
237
+ catch {
238
+ continue;
239
+ }
240
+ const refused = refusedLocation(candidate, realPath, rejectedLocations) ??
241
+ refusedLocation(path.dirname(candidate), candidateDir, rejectedLocations);
242
+ if (refused) {
243
+ rejected.push({ path: candidate, reason: `inside refused jq location: ${refused}` });
244
+ continue;
245
+ }
246
+ if (deps.rejectedPaths?.some((rejected) => {
247
+ if (path.resolve(rejected) === realPath || path.resolve(rejected) === path.resolve(candidate))
248
+ return true;
249
+ // A refused path may itself contain a symlink (including a parent).
250
+ // Reject aliases of its referent before any executable probe as well.
251
+ try {
252
+ return fs.realpathSync(rejected) === realPath;
253
+ }
254
+ catch {
255
+ return false;
256
+ }
257
+ })) {
258
+ rejected.push({ path: candidate, reason: "managed jq failed its checksum or path safety checks" });
259
+ continue;
260
+ }
261
+ if (seenReal.has(realPath))
262
+ continue;
263
+ seenReal.add(realPath);
264
+ const stamp = stampOf(realPath);
265
+ if (stamp === null || !isExecutable(realPath, windows))
266
+ continue;
267
+ let probe = probeCache.get(realPath);
268
+ if (!probe || probe.stamp !== stamp) {
269
+ probe = { stamp, probe: await probeJq(realPath, run, deps.timeoutMs) };
270
+ // A verdict about replaced bytes must neither be cached nor used.
271
+ if (stampOf(realPath) !== stamp) {
272
+ probeCache.delete(realPath);
273
+ rejected.push({ path: candidate, reason: "jq changed while it was being checked" });
274
+ continue;
275
+ }
276
+ probeCache.set(realPath, probe);
277
+ }
278
+ if (!probe.probe.ok) {
279
+ rejected.push({ path: candidate, reason: probe.probe.reason });
280
+ continue;
281
+ }
282
+ const version = probe.probe.version ?? "jq-1";
283
+ if (!windows) {
284
+ // The private folder holds only `jq`, so the scripts' bash and other tools
285
+ // resolve exactly as before.
286
+ if (privateAllowed && home && privateDir && !refusedLocation(privateDir, path.resolve(privateDir), rejectedLocations)) {
287
+ try {
288
+ linkJq(home, privateDir, realPath);
289
+ return { path: candidate, realPath, version, binDir: privateDir };
290
+ }
291
+ catch (error) {
292
+ privateAllowed = false;
293
+ if (error instanceof UnsafeJqPathError)
294
+ rejectedLocations.push(error.path);
295
+ rejected.push({ path: privateDir, reason: error.message });
296
+ }
297
+ }
298
+ }
299
+ // Fallback: the candidate's own folder. Candidates are always named jq
300
+ // (jq.exe on Windows), so a `jq` lookup there reaches this candidate, not
301
+ // the binary's real folder, whose `jq` may be something else.
302
+ const p = windows ? path.win32 : path.posix;
303
+ const binDir = candidateDir;
304
+ const newlyRefused = refusedLocation(candidate, realPath, rejectedLocations) ??
305
+ refusedLocation(path.dirname(candidate), binDir, rejectedLocations);
306
+ if (newlyRefused) {
307
+ rejected.push({ path: candidate, reason: `inside refused jq location: ${newlyRefused}` });
308
+ continue;
309
+ }
310
+ try {
311
+ checkSystemJqDirectory(binDir);
312
+ }
313
+ catch (error) {
314
+ rejected.push({ path: candidate, reason: error.message });
315
+ continue;
316
+ }
317
+ if (windows && p.basename(candidate).toLowerCase() === "jq.exe" && fs.existsSync(p.join(binDir, "jq"))) {
318
+ // Git Bash would run the extensionless `jq` next to it instead.
319
+ rejected.push({ path: candidate, reason: "an unchecked jq script sits next to it" });
320
+ continue;
321
+ }
322
+ return { path: candidate, realPath, version, binDir };
323
+ }
324
+ throw new JqUnavailableError(rejected);
325
+ }
326
+ /** `env` with `binDir` first on PATH. */
327
+ export function withJqFirst(env, binDir, platform = process.platform) {
328
+ const delimiter = platform === "win32" ? ";" : ":";
329
+ const key = platform === "win32" && env.PATH === undefined && env.Path !== undefined ? "Path" : "PATH";
330
+ const rest = (env[key] ?? "").split(delimiter).filter((d) => d && d !== binDir);
331
+ // An environment with no PATH used to get the OS default search path; keep
332
+ // bash and the coreutils the scripts need reachable.
333
+ if (rest.length === 0 && platform !== "win32")
334
+ rest.push("/usr/bin", "/bin");
335
+ return { ...env, [key]: [binDir, ...rest].join(delimiter) };
336
+ }
337
+ //# sourceMappingURL=verified-jq.js.map
@@ -1,5 +1,6 @@
1
1
  import { execFileSync } from "node:child_process";
2
2
  import { findExecutableOnPath } from "../../../utils/resolve-executable.js";
3
+ import { JQ_VERSION_RE } from "../../daemon/verified-jq.js";
3
4
  export const JQ_FAMILY_ID = "jq";
4
5
  export const JQ_CHECK_ID = "jq.on-path";
5
6
  /**
@@ -69,6 +70,21 @@ export function checkJq(_context, deps = defaultDeps) {
69
70
  },
70
71
  ];
71
72
  }
73
+ // A homemade or wrapper `jq` that is not jq breaks every
74
+ // hook payload parse, so it counts as missing. Real jq prints jq-1.x.
75
+ const firstLine = version.split(/\r?\n/)[0] ?? "";
76
+ if (!JQ_VERSION_RE.test(firstLine)) {
77
+ const shown = firstLine.slice(0, 40).replace(/[^\x20-\x7e]/g, "?");
78
+ return [
79
+ {
80
+ status: "FAIL",
81
+ checkId: JQ_CHECK_ID,
82
+ target: file,
83
+ message: `The jq on PATH at ${file} is not jq: \`jq --version\` printed "${shown}" instead of jq-1.x. HQ hooks cannot read tool calls with it.`,
84
+ remediation: `${jqInstallHint(deps.platform)} The HQ desktop app replaces a jq that is not jq when it next checks its tools.`,
85
+ },
86
+ ];
87
+ }
72
88
  return [
73
89
  {
74
90
  status: "PASS",
@@ -38,6 +38,7 @@
38
38
  */
39
39
  import type { CheckContext, CheckResult } from "../types.js";
40
40
  import { type GateProfile } from "../hook-gate-profiles.js";
41
+ import { type HookFixture } from "../fixtures/schema.js";
41
42
  /** The id of the deep-test family the command appends under `--deep-test`. */
42
43
  export declare const DEEP_FAMILY_ID = "deep";
43
44
  /** Human title of the deep-test family. */
@@ -102,5 +103,11 @@ export declare function cleanupAllDeepSandboxes(): void;
102
103
  * an empty list — creating no sandbox — when there is nothing to run.
103
104
  */
104
105
  export declare function runDeepGuardTests(context: CheckContext, options?: DeepTestOptions): Promise<CheckResult[]>;
106
+ /**
107
+ * The pure-guard fixtures worth executing: valid (US-007 already reports the
108
+ * invalid, unknown-version and orphan cases), registered, non-empty, and not a
109
+ * side-effecting hook (those are US-009's sandboxed effect tier).
110
+ */
111
+ export declare function selectRunnableFixtures(hqRoot: string): HookFixture[];
105
112
  export {};
106
113
  //# sourceMappingURL=executor.d.ts.map
@@ -173,7 +173,7 @@ export async function runDeepGuardTests(context, options = {}) {
173
173
  * invalid, unknown-version and orphan cases), registered, non-empty, and not a
174
174
  * side-effecting hook (those are US-009's sandboxed effect tier).
175
175
  */
176
- function selectRunnableFixtures(hqRoot) {
176
+ export function selectRunnableFixtures(hqRoot) {
177
177
  const registered = new Set(registeredHookIds(hqRoot));
178
178
  const discovery = discoverFixtures(hqRoot);
179
179
  const runnable = [];
@@ -43,9 +43,7 @@ import { spawnSync } from "node:child_process";
43
43
  import * as fs from "node:fs";
44
44
  import * as os from "node:os";
45
45
  import * as path from "node:path";
46
- import { discoverFixtures, registeredHookIds } from "../fixtures/discover.js";
47
- import { isPureGuard } from "./classify.js";
48
- import { SANDBOX_COPY_RELPATHS } from "./executor.js";
46
+ import { SANDBOX_COPY_RELPATHS, selectRunnableFixtures } from "./executor.js";
49
47
  import { grokCanBlock, grokToSnakePayload, interpretExitBlock, interpretGrokBlock, PARITY_PLATFORMS, toClaudePayload, toCodexPayload, toGrokPayload, } from "../payload-shapes.js";
50
48
  /** The id of the parity family the command appends under `--deep-test`. */
51
49
  export const PARITY_FAMILY_ID = "deep-parity";
@@ -213,30 +211,6 @@ export async function runParityReplay(context, options = {}) {
213
211
  }
214
212
  }
215
213
  }
216
- /**
217
- * The pure-guard fixtures worth replaying: valid, registered, non-empty, and not
218
- * side-effecting (those are US-009's sandboxed effect tier and must never be
219
- * fired through an adapter). Mirrors US-008's executor selection so parity
220
- * replays exactly the set `--deep-test` executes.
221
- */
222
- function selectRunnableFixtures(hqRoot) {
223
- const registered = new Set(registeredHookIds(hqRoot));
224
- const discovery = discoverFixtures(hqRoot);
225
- const runnable = [];
226
- for (const discovered of discovery.fixtures) {
227
- if (discovered.parsed.status !== "ok")
228
- continue;
229
- const fixture = discovered.parsed.fixture;
230
- if (!registered.has(fixture.hookId))
231
- continue;
232
- if (fixture.cases.length === 0)
233
- continue;
234
- if (!isPureGuard(fixture))
235
- continue;
236
- runnable.push(fixture);
237
- }
238
- return runnable;
239
- }
240
214
  /**
241
215
  * Replay one case through all three platforms and classify the aggregate:
242
216
  * - any platform NA (Grok passive event) -> NA, naming the limitation.