@indigoai-us/hq-cli 5.345.250 → 5.345.252

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 (186) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/assets/scaffold/core/scripts/hq-session.sh +9 -0
  3. package/contracts/host-canary-release.json +9 -3
  4. package/dist/command-catalog.generated.d.ts +316 -2
  5. package/dist/command-catalog.generated.js +389 -2
  6. package/dist/commands/bot.js +12 -3
  7. package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
  8. package/dist/commands/core-hq-session-binding.d.ts +140 -0
  9. package/dist/commands/core-hq-session-binding.js +363 -0
  10. package/dist/commands/core-hq-session-native.d.ts +23 -0
  11. package/dist/commands/core-hq-session-native.js +59 -9
  12. package/dist/commands/core-stop-autosave.js +1 -1
  13. package/dist/commands/core.js +10 -0
  14. package/dist/commands/doctor.d.ts +5 -1
  15. package/dist/commands/doctor.js +42 -5
  16. package/dist/commands/files.js +1 -1
  17. package/dist/commands/install-global.js +4 -2
  18. package/dist/commands/lanes.d.ts +2 -0
  19. package/dist/commands/lanes.js +9 -4
  20. package/dist/commands/logout.js +4 -0
  21. package/dist/commands/ontology-graph.d.ts +11 -2
  22. package/dist/commands/ontology-graph.js +130 -4
  23. package/dist/commands/report.js +35 -2
  24. package/dist/commands/sources.js +26 -8
  25. package/dist/commands/storage-gate.js +1 -1
  26. package/dist/commands/vault-retention-flag.js +2 -1
  27. package/dist/commands/whoami.js +1 -1
  28. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
  29. package/dist/hq-cloud-sync-runner/package.json +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
  32. package/dist/lib/agent-kit/mcp/tools.js +48 -0
  33. package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
  34. package/dist/lib/bot/fleet-cron.d.ts +37 -0
  35. package/dist/lib/bot/fleet-cron.js +59 -12
  36. package/dist/lib/bot/fleet-local.d.ts +18 -0
  37. package/dist/lib/bot/fleet-local.js +51 -5
  38. package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
  39. package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
  40. package/dist/lib/bot/signals-engine-flag.js +1 -1
  41. package/dist/lib/cli-invite-nudge.js +1 -1
  42. package/dist/lib/client-version.d.ts +2 -0
  43. package/dist/lib/client-version.js +24 -0
  44. package/dist/lib/company-flag-gate.d.ts +30 -0
  45. package/dist/lib/company-flag-gate.js +104 -0
  46. package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
  47. package/dist/lib/daemon/flag.js +2 -1
  48. package/dist/lib/daemon/legacy-journal-gate.js +3 -1
  49. package/dist/lib/daemon/shared-flag-reads.js +1 -1
  50. package/dist/lib/doctor/checks/host-core.js +22 -4
  51. package/dist/lib/doctor/checks/jq.d.ts +27 -6
  52. package/dist/lib/doctor/checks/jq.js +46 -8
  53. package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
  54. package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
  55. package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
  56. package/dist/lib/flag-client-gate-headers.d.ts +38 -0
  57. package/dist/lib/flag-client-gate-headers.js +62 -0
  58. package/dist/lib/flag-client-headers.d.ts +15 -0
  59. package/dist/lib/flag-client-headers.js +25 -0
  60. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  61. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  62. package/dist/lib/flag-registry-worker.js +35 -0
  63. package/dist/lib/flag-registry.d.ts +1 -20
  64. package/dist/lib/flag-registry.js +5 -81
  65. package/dist/lib/hook-engine/adapter-core-pin.d.ts +29 -0
  66. package/dist/lib/hook-engine/adapter-core-pin.js +29 -0
  67. package/dist/lib/hook-engine/coverage.d.ts +68 -8
  68. package/dist/lib/hook-engine/coverage.js +167 -25
  69. package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
  70. package/dist/lib/hook-engine/reconcile.js +3 -2
  71. package/dist/lib/hot-channels/graph-context.d.ts +26 -1
  72. package/dist/lib/hot-channels/graph-context.js +76 -9
  73. package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
  74. package/dist/lib/hot-channels/run.d.ts +1 -0
  75. package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
  76. package/dist/lib/hot-channels/signal-changes.js +683 -0
  77. package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
  78. package/dist/lib/hot-channels/signals-pass.js +240 -15
  79. package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
  80. package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
  81. package/dist/lib/lanes/registry-flag.js +2 -1
  82. package/dist/lib/lanes/spawn.js +11 -1
  83. package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
  84. package/dist/lib/mesh/live/binding-intent.js +201 -0
  85. package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
  86. package/dist/lib/mesh/live/binding-receipt.js +365 -0
  87. package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
  88. package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
  89. package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
  90. package/dist/lib/mesh/live/daemon/install.js +2 -1
  91. package/dist/lib/mesh/live/daemon/presence.js +9 -0
  92. package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
  93. package/dist/lib/mesh/live/daemon/run.js +33 -1
  94. package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
  95. package/dist/lib/ontology-graph/lineage/index.js +1027 -0
  96. package/dist/lib/ontology-graph/model/files.d.ts +4 -0
  97. package/dist/lib/ontology-graph/model/files.js +23 -0
  98. package/dist/lib/ontology-graph/model/index.d.ts +65 -1
  99. package/dist/lib/ontology-graph/model/index.js +154 -18
  100. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +84 -1
  101. package/dist/lib/ontology-graph/model/pass-tasks.js +173 -4
  102. package/dist/lib/ontology-graph/model/pass.d.ts +11 -0
  103. package/dist/lib/ontology-graph/model/pass.js +17 -10
  104. package/dist/lib/ontology-graph/model/pending-items.d.ts +39 -0
  105. package/dist/lib/ontology-graph/model/pending-items.js +136 -0
  106. package/dist/lib/ontology-graph/model/step.d.ts +47 -2
  107. package/dist/lib/ontology-graph/model/step.js +202 -36
  108. package/dist/lib/ontology-graph/model/tasks.d.ts +28 -4
  109. package/dist/lib/ontology-graph/model/tasks.js +48 -15
  110. package/dist/lib/ontology-graph/pages/render.d.ts +1 -1
  111. package/dist/lib/ontology-graph/pages/render.js +4 -3
  112. package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
  113. package/dist/lib/ontology-graph/read/brief.js +349 -67
  114. package/dist/lib/ontology-graph/read/index.d.ts +5 -1
  115. package/dist/lib/ontology-graph/read/index.js +174 -30
  116. package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
  117. package/dist/lib/ontology-graph/read/lineage.js +262 -0
  118. package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
  119. package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
  120. package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
  121. package/dist/lib/ontology-graph/remodel/index.js +450 -0
  122. package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
  123. package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
  124. package/dist/lib/ontology-graph/replay/engine.js +213 -8
  125. package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
  126. package/dist/lib/ontology-graph/replay/extractors.js +25 -1
  127. package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
  128. package/dist/lib/ontology-graph/replay/index.js +120 -8
  129. package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
  130. package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
  131. package/dist/lib/ontology-graph/schema/authority.d.ts +14 -5
  132. package/dist/lib/ontology-graph/schema/authority.js +13 -3
  133. package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
  134. package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
  135. package/dist/lib/ontology-graph/schema/index.d.ts +2 -1
  136. package/dist/lib/ontology-graph/schema/index.js +2 -1
  137. package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
  138. package/dist/lib/ontology-graph/setup/index.js +499 -0
  139. package/dist/lib/ontology-graph/types.d.ts +21 -0
  140. package/dist/lib/ontology-graph/types.js +5 -0
  141. package/dist/lib/search-index/index.d.ts +33 -1
  142. package/dist/lib/search-index/index.js +180 -25
  143. package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
  144. package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
  145. package/dist/lib/signals/adapters-catalog.js +1 -1
  146. package/dist/lib/signals/failure-alert.js +4 -5
  147. package/dist/lib/signals/steps/adapters.js +3 -0
  148. package/dist/lib/sync-core/engine-holds.d.ts +1 -0
  149. package/dist/lib/sync-core/engine-holds.js +26 -0
  150. package/dist/lib/sync-core/engine-home.d.ts +3 -0
  151. package/dist/lib/sync-core/engine-home.js +41 -1
  152. package/dist/lib/sync-core/flag.js +2 -1
  153. package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
  154. package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
  155. package/dist/lib/sync-core/legacy-journal-export.js +120 -55
  156. package/dist/lib/sync-core/reconcile.d.ts +2 -1
  157. package/dist/lib/sync-core/reconcile.js +30 -5
  158. package/dist/lib/sync-invalid-entity-warning.js +2 -1
  159. package/dist/lib/windows/install-followup.d.ts +41 -0
  160. package/dist/lib/windows/install-followup.js +87 -0
  161. package/dist/lib/windows/jq.d.ts +59 -0
  162. package/dist/lib/windows/jq.js +154 -3
  163. package/dist/lib/windows/user-path.d.ts +5 -0
  164. package/dist/lib/windows/user-path.js +1 -1
  165. package/dist/lib/work-context/auto-bind.d.ts +12 -0
  166. package/dist/lib/work-context/auto-bind.js +49 -3
  167. package/dist/lib/work-context/organize.d.ts +4 -2
  168. package/dist/lib/work-context/organize.js +18 -8
  169. package/dist/lib/work-context/reconcile.js +16 -1
  170. package/dist/main.js +12 -1
  171. package/dist/utils/client-health-contract.d.ts +30 -0
  172. package/dist/utils/client-health-contract.js +111 -0
  173. package/dist/utils/client-health.d.ts +5 -2
  174. package/dist/utils/client-health.js +74 -5
  175. package/dist/utils/exclusive-lock.d.ts +5 -1
  176. package/dist/utils/exclusive-lock.js +9 -2
  177. package/dist/utils/host-registration.d.ts +7 -0
  178. package/dist/utils/host-registration.js +10 -1
  179. package/dist/utils/pid.d.ts +31 -0
  180. package/dist/utils/pid.js +65 -0
  181. package/dist/utils/resident-package-preload.js +12 -4
  182. package/dist/utils/sentry-fingerprint.js +3 -0
  183. package/dist/utils/sync-person.d.ts +15 -0
  184. package/dist/utils/sync-person.js +74 -0
  185. package/package.json +8 -8
  186. package/scripts/install-hook-engine.mjs +5 -3
@@ -33,7 +33,8 @@ import { DEEP_FAMILY_ID, DEEP_FAMILY_TITLE, runDeepGuardTests, } from "../lib/do
33
33
  import { PARITY_FAMILY_ID, PARITY_FAMILY_TITLE, runParityReplay, } from "../lib/doctor/deep/parity.js";
34
34
  import { applyFixes } from "../lib/doctor/fix/apply.js";
35
35
  import { renderDoctorFixJson } from "../lib/doctor/fix/json-output.js";
36
- import { installWindowsJq } from "../lib/windows/jq.js";
36
+ import { verifyJqForNewSessions } from "../lib/doctor/checks/jq.js";
37
+ import { ensureWindowsJq, jqRemainingStep } from "../lib/windows/jq.js";
37
38
  import { clientHealthCheckStatusEnabled as isActiveCompanyClientHealthCheckStatusEnabled, clientHealthCheckStatusEnabledForCompany, clientHealthReasonCodesEnabled as isActiveCompanyClientHealthReasonCodesEnabled, clientHealthReasonCodesEnabledForCompany, } from "../lib/doctor/client-health-reason-codes-flag.js";
38
39
  import { clientHealthCompanyScopeFromCheckId } from "../lib/doctor/checks/sync-health.js";
39
40
  import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
@@ -356,7 +357,7 @@ export function registerDoctorCommand(program, deps = {}) {
356
357
  .option("--company <slug>", "Company slug for integrations checks (otherwise resolves your single active company).")
357
358
  .option("--only <families>", "Run only these comma-separated check families (e.g. hooks). Unknown names are rejected; --json then records the scope.")
358
359
  .option("--fix", "Apply the allowlisted safe repairs (backs up first; read-only without this flag).")
359
- .option("--fix-jq", "Install the verified jq required by HQ hooks on Windows.")
360
+ .option("--fix-jq", "Install the verified jq required by HQ hooks on Windows, add it to your PATH, and check it.")
360
361
  .addOption(new Option("--client-health-report", "Resolve the opt-in hq-flags gate used by the client-health report hook.").hideHelp())
361
362
  .option("--sweep-temp-homes", "Delete idle temp homes (90+ minutes untouched, not in use): tmp.* folders holding .rustup or .cargo, and hq-temp-home.* folders left by the wrapper. Reports GB freed.")
362
363
  .option("--dry-run", "With --sweep-temp-homes, list what would be removed and delete nothing.")
@@ -370,10 +371,46 @@ export function registerDoctorCommand(program, deps = {}) {
370
371
  return;
371
372
  }
372
373
  try {
373
- const target = await (deps.installWindowsJq ?? installWindowsJq)();
374
- if (!target)
374
+ const ensured = await (deps.ensureWindowsJq ?? ensureWindowsJq)();
375
+ if (!ensured)
375
376
  throw new Error("The managed jq repair is only available on Windows.");
376
- process.stdout.write(opts.json ? `${JSON.stringify({ target })}\n` : `Verified jq is ready at ${target}.\n`);
377
+ // Installed is not repaired (hq-cli #3716): finish with the same
378
+ // check `hq doctor` runs, against the PATH a new session will get.
379
+ const check = (deps.verifyJq ?? verifyJqForNewSessions)()[0] ?? {
380
+ status: "FAIL",
381
+ checkId: "jq.on-path",
382
+ message: "The jq check returned no result.",
383
+ };
384
+ const ok = check.status === "PASS";
385
+ const remaining = ok ? undefined : jqRemainingStep(ensured, check);
386
+ if (opts.json) {
387
+ process.stdout.write(`${JSON.stringify({
388
+ target: ensured.target,
389
+ ...(ensured.sessionTarget === undefined ? {} : { sessionTarget: ensured.sessionTarget }),
390
+ onPath: ok,
391
+ userPath: ensured.path,
392
+ check: { status: check.status, message: check.message },
393
+ ...(remaining === undefined ? {} : { remaining }),
394
+ })}\n`);
395
+ }
396
+ else if (ok) {
397
+ // The check can pass through another jq, or the copy beside
398
+ // hq.cmd, when the PATH step did not happen: say which it was.
399
+ const pathLine = ensured.path === "written"
400
+ ? `Added ${ensured.dir} to your user PATH.`
401
+ : ensured.path === "present"
402
+ ? `${ensured.dir} is already on your user PATH.`
403
+ : `HQ did not add ${ensured.dir} to your user PATH (${ensured.path}); hooks find jq at the path above.`;
404
+ const sessionLine = ensured.sessionTarget
405
+ ? `Also placed at ${ensured.sessionTarget}, which terminals and Claude Code sessions that are already open can find.\n`
406
+ : "";
407
+ process.stdout.write(`Verified jq is ready at ${check.target ?? ensured.target}.\n${pathLine}\n${sessionLine}If a terminal or Claude Code session that was already open still reports jq missing, restart it.\n`);
408
+ }
409
+ else {
410
+ process.stderr.write(`hq doctor --fix-jq: jq is installed at ${ensured.target}, but HQ hooks will not find it yet. ${check.message}\n${remaining}\n`);
411
+ }
412
+ if (!ok)
413
+ process.exitCode = 1;
377
414
  }
378
415
  catch (error) {
379
416
  const message = error instanceof Error ? error.message : String(error);
@@ -14,7 +14,7 @@ import { suggestChannels, withChannelSuggestions } from "./channel-suggest.js";
14
14
  import { resolveCompanySlug, resolvePersonWithRosterFallback, } from "./people.js";
15
15
  import { findHqRoot } from "../utils/manifest.js";
16
16
  import { maxLength } from "../utils/table-width.js";
17
- import { resolveCompanyFlagGate } from "../lib/flag-registry.js";
17
+ import { resolveCompanyFlagGate } from "../lib/company-flag-gate.js";
18
18
  import { raiseAccessRefresh } from "../lib/sync-core/access-refresh.js";
19
19
  const PERSON_UID_PATTERN = /^(prs|agt)_[A-Za-z0-9_-]+$/;
20
20
  const AGENT_UID_PATTERN = /^agt_[A-Za-z0-9_-]+$/;
@@ -31,7 +31,7 @@ import { trustCodexUserHooks } from '../utils/hook-trust.js';
31
31
  import { assertProviderWrappersInstallable, installProviderWrappers, providerWrapperInstallPaths, removeProviderWrappers } from '../lib/install/provider-wrappers.js';
32
32
  import { checkShimOnPath, ensureShimOnUserPath, npmShimDir, shimPathWarning } from '../lib/windows/user-path.js';
33
33
  import { removeHqCliPs1Shims } from '../lib/windows/ps1-shims.js';
34
- import { installWindowsJq, WINDOWS_JQ_REPAIR } from '../lib/windows/jq.js';
34
+ import { ensureWindowsJq, WINDOWS_JQ_REPAIR } from '../lib/windows/jq.js';
35
35
  import { addAgentsMdBlock, addCodexHooks, classifyLegacySkills, codexAdapterPath, codexCharterSource, codexHookTrustKeys, codexTargets, hasAllCodexHooks, HQ_OWNED_MARKER, LEGACY_BACKUP_NAME, LEGACY_SKILLS_NAME, removeAgentsMdBlock, removeCodexHooks, } from '../lib/install/codex-targets.js';
36
36
  import { addClaudeMdBlock, addHqHooks, charterPath, claudeTargets, hasAllHqHooks, HQ_ANYWHERE_PACK, HQ_MCP_SERVER_NAME, hqSkillsSource, lineDiff, masterHookPath, shimPath, removeClaudeMdBlock, removeHqHooks, SKILL_LINK_PREFIX, } from '../lib/install/claude-targets.js';
37
37
  export { hookTargetFor, isDaemonInstalled } from '../lib/install/hook-target.js';
@@ -1291,7 +1291,9 @@ export async function runInstallGlobal(opts) {
1291
1291
  const install = runtime === 'codex' ? installGlobalCodex : installGlobalClaude;
1292
1292
  if (process.platform === 'win32' && !opts.dryRun) {
1293
1293
  try {
1294
- await installWindowsJq({ home: opts.home });
1294
+ // Installs jq and puts it where hooks find it; a home that is not the
1295
+ // signed-in profile gets the file but no user PATH entry.
1296
+ await ensureWindowsJq({ home: opts.home });
1295
1297
  }
1296
1298
  catch (error) {
1297
1299
  const message = error instanceof Error ? error.message : String(error);
@@ -136,6 +136,8 @@ export interface LanesCommandDeps {
136
136
  export type MonitorLaneMessageApi = (laneId: string, payload: MonitorLaneMessagePayload) => Promise<MonitorLaneMessageResult>;
137
137
  /** Build the same lane message handlers used by `hq runners _monitor-message`, without a CLI process boundary. */
138
138
  export declare function createMonitorLaneMessageApi(hqRoot: string, cwd: string, env?: NodeJS.ProcessEnv): MonitorLaneMessageApi;
139
+ /** The monitor lane message handler registered on `program`, if any. */
140
+ export declare function monitorLaneMessageApiFor(program: Command): MonitorLaneMessageApi | undefined;
139
141
  export declare function parseSeniorRef(raw: string): SeniorRef;
140
142
  export declare function parseQuestionBody(raw: unknown): QuestionBody | null;
141
143
  /**
@@ -265,11 +265,15 @@ export function createMonitorLaneMessageApi(hqRoot, cwd, env = process.env) {
265
265
  cwd: () => cwd,
266
266
  env: { ...env, HQ_ROOT: hqRoot },
267
267
  });
268
- const api = monitorLaneMessageApis.get(program);
268
+ const api = monitorLaneMessageApiFor(program);
269
269
  if (!api)
270
270
  throw new Error("Monitor lane message handler was not registered");
271
271
  return api;
272
272
  }
273
+ /** The monitor lane message handler registered on `program`, if any. */
274
+ export function monitorLaneMessageApiFor(program) {
275
+ return monitorLaneMessageApis.get(program);
276
+ }
273
277
  function withoutProviderHome(value) {
274
278
  if (Array.isArray(value))
275
279
  return value.map(withoutProviderHome);
@@ -11038,11 +11042,12 @@ export function registerRunnersCommand(parent, deps = {}) {
11038
11042
  daemonReconcileCtx.env.HQ_ROOT = hqRoot;
11039
11043
  daemonReconcileCtx.cwd = () => hqRoot;
11040
11044
  daemonReconcileCtx.callerCwd = () => hqRoot;
11041
- await runReconcile(daemonReconcileCtx, { inProcess: true }, async (lane) => {
11042
- await messageHandlers.recoverQueuedMessages(daemonReconcileCtx, lane.lane_id);
11045
+ const passCtx = { ...daemonReconcileCtx };
11046
+ await runReconcile(passCtx, { inProcess: true }, async (lane) => {
11047
+ await messageHandlers.recoverQueuedMessages(passCtx, lane.lane_id);
11043
11048
  });
11044
11049
  });
11045
- monitorLaneMessageApis.set(parent, (laneId, payload) => messageHandlers.deliverMonitorLaneMessage(ctx, laneId, payload));
11050
+ monitorLaneMessageApis.set(parent, (laneId, payload) => messageHandlers.deliverMonitorLaneMessage({ ...ctx }, laneId, payload));
11046
11051
  const resumeHandlers = createLaneResumeHandlers({
11047
11052
  onLaneWorkerStarted: deps.onLaneWorkerStarted,
11048
11053
  archiveResumeMessage,
@@ -12,6 +12,7 @@
12
12
  */
13
13
  import chalk from 'chalk';
14
14
  import { clearCachedTokens, loadCachedTokens } from '@indigoai-us/hq-cloud';
15
+ import { clearBindingReceipts } from '../lib/mesh/live/binding-receipt.js';
15
16
  import { retainUsageAttributionForPerson } from '../lib/work-context/config.js';
16
17
  import { workContextRoot } from '../lib/work-context/paths.js';
17
18
  import { DEFAULT_COGNITO } from '../utils/cognito-config.js';
@@ -30,6 +31,9 @@ export async function runLogout() {
30
31
  catch (error) {
31
32
  console.error(chalk.yellow('Could not withdraw the usage opt-in:'), error instanceof Error ? error.message : 'Unknown error');
32
33
  }
34
+ // Binding receipts record which company this person bound each session
35
+ // to. They belong to the person signing out.
36
+ clearBindingReceipts();
33
37
  const existing = loadCachedTokens();
34
38
  if (!existing) {
35
39
  console.log(chalk.yellow('No cached HQ session'));
@@ -5,10 +5,13 @@
5
5
  * src/lib/ontology-graph/ (see CONTRACT.md there), imported on demand so a
6
6
  * read command never loads the replay engine.
7
7
  *
8
- * hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--no-model] [--dry-run]
8
+ * hq ontology status | reader [graph|entities] | model [<model>] (setup: what this machine reads and builds with)
9
+ * hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--max-input-tokens N] [--max-output-tokens N] [--no-model] [--dry-run]
9
10
  * hq ontology update --company <slug> [--input <path>] [--budget-tokens N] [--no-model]
11
+ * hq ontology lineage backfill --company <slug> [--from D --to D] [--restart] [--retry-unanswered] [--allow-unanswered] [--max-input-tokens N] [--max-output-tokens N] [--dry-run]
12
+ * hq ontology lineage undo --company <slug> [--graph-root <dir>] [--dry-run]
10
13
  * hq ontology lookup <name> [--page] | neighbors <id> [--depth N] | search <text> | traverse <from> [<to>]
11
- * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief
14
+ * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
12
15
  * hq ontology org-chart draft | confirm --from <file> [--yes] | show
13
16
  * hq ontology activity [<person>] [--roles] [--compare] [--write] [--view company|member] [--as-of D] [--model]
14
17
  * (`hq ontology org observed|compare|person <name>` is the same thing under its first name, kept hidden)
@@ -26,6 +29,7 @@
26
29
  * the old `ontology/entities/` folder) is a different command and is unchanged.
27
30
  */
28
31
  import { Command } from "commander";
32
+ import type { SetupContext } from "../lib/ontology-graph/setup/index.js";
29
33
  import type { GraphContext, MemberIdentity } from "../lib/ontology-graph/types.js";
30
34
  export declare class OntologyGraphUsageError extends Error {
31
35
  constructor(message: string);
@@ -58,6 +62,11 @@ export interface OntologyGraphCommandDeps {
58
62
  }
59
63
  /** Resolves the company and the graph folder for one invocation. */
60
64
  export declare function resolveGraphContext(options: ScopeOptions): GraphContext;
65
+ /**
66
+ * The company and folders for a setup command (`status`, `reader`, `model`). The graph folder is not checked
67
+ * here: these commands report or refuse on its state themselves, and none reads a row from it.
68
+ */
69
+ export declare function resolveSetupContext(options: ScopeOptions): SetupContext;
61
70
  export declare function registerOntologyCommand(program: Command, deps?: OntologyGraphCommandDeps): Command;
62
71
  export {};
63
72
  //# sourceMappingURL=ontology-graph.d.ts.map
@@ -5,10 +5,13 @@
5
5
  * src/lib/ontology-graph/ (see CONTRACT.md there), imported on demand so a
6
6
  * read command never loads the replay engine.
7
7
  *
8
- * hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--no-model] [--dry-run]
8
+ * hq ontology status | reader [graph|entities] | model [<model>] (setup: what this machine reads and builds with)
9
+ * hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--max-input-tokens N] [--max-output-tokens N] [--no-model] [--dry-run]
9
10
  * hq ontology update --company <slug> [--input <path>] [--budget-tokens N] [--no-model]
11
+ * hq ontology lineage backfill --company <slug> [--from D --to D] [--restart] [--retry-unanswered] [--allow-unanswered] [--max-input-tokens N] [--max-output-tokens N] [--dry-run]
12
+ * hq ontology lineage undo --company <slug> [--graph-root <dir>] [--dry-run]
10
13
  * hq ontology lookup <name> [--page] | neighbors <id> [--depth N] | search <text> | traverse <from> [<to>]
11
- * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief
14
+ * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
12
15
  * hq ontology org-chart draft | confirm --from <file> [--yes] | show
13
16
  * hq ontology activity [<person>] [--roles] [--compare] [--write] [--view company|member] [--as-of D] [--model]
14
17
  * (`hq ontology org observed|compare|person <name>` is the same thing under its first name, kept hidden)
@@ -96,6 +99,11 @@ function clockArg(value) {
96
99
  throw new InvalidArgumentError("expected a time as HH:MM");
97
100
  return value;
98
101
  }
102
+ function briefStyleArg(value) {
103
+ if (value !== "map" && value !== "full")
104
+ throw new InvalidArgumentError("expected map or full");
105
+ return value;
106
+ }
99
107
  function depthArg(value) {
100
108
  const parsed = Number(value);
101
109
  if (!Number.isInteger(parsed) || parsed < 1 || parsed > 3)
@@ -135,6 +143,25 @@ export function resolveGraphContext(options) {
135
143
  ...(member ? { member } : {}),
136
144
  };
137
145
  }
146
+ /**
147
+ * The company and folders for a setup command (`status`, `reader`, `model`). The graph folder is not checked
148
+ * here: these commands report or refuse on its state themselves, and none reads a row from it.
149
+ */
150
+ export function resolveSetupContext(options) {
151
+ const hqRoot = resolveLiveRoot({ hqRoot: options.hqRoot });
152
+ const resolution = resolveOntologyCompany(hqRoot, options.company);
153
+ if (!resolution.ok) {
154
+ throw new OntologyGraphUsageError(options.company ? `ontology: company rejected: ${resolution.reason}` : "ontology: --company <slug> is required");
155
+ }
156
+ const companyRoot = resolution.company.dir;
157
+ return {
158
+ hqRoot,
159
+ company: resolution.company.slug,
160
+ companyRoot,
161
+ graphRoot: resolveGraphRoot({ companyRoot, flag: options.graphRoot }),
162
+ json: Boolean(options.json),
163
+ };
164
+ }
138
165
  function orgViewArg(value) {
139
166
  if (value !== "company" && value !== "member")
140
167
  throw new InvalidArgumentError("expected company or member");
@@ -179,15 +206,52 @@ export function registerOntologyCommand(program, deps = {}) {
179
206
  };
180
207
  /** A read command: `run` with the member filled in from the sign-in when no flag names one. */
181
208
  const read = (entry) => run(entry, "read");
209
+ /** Wraps a setup action: the company and folders, no member, and a graph folder the command looks at itself. */
210
+ const setup = (entry) => async function action(...raw) {
211
+ const args = raw.filter((value) => typeof value === "string");
212
+ const options = mergedOptions(this);
213
+ const context = resolveSetupContext(options);
214
+ const { OntologySetupError } = await import("../lib/ontology-graph/setup/index.js");
215
+ try {
216
+ emit(context, await entry(context, options, args));
217
+ }
218
+ catch (error) {
219
+ if (error instanceof OntologySetupError)
220
+ throw new OntologyGraphUsageError(error.message);
221
+ throw error;
222
+ }
223
+ };
182
224
  const ontology = program
183
225
  .command("ontology")
184
226
  .description("Ontology graph: sourced facts, typed relationships, rebuilt from the files on this machine (local only)");
227
+ scoped(ontology.command("status"))
228
+ .description("Show the reader, the model, the graph folder, its counts, pending model work, the last update and the brief (reads only)")
229
+ .action(setup(async (context) => {
230
+ const { statusCommand } = await import("../lib/ontology-graph/setup/index.js");
231
+ return statusCommand(context);
232
+ }));
233
+ scoped(ontology.command("reader"))
234
+ .description("Show or set which ontology this machine's sessions read for the company: graph, or entities (the old files)")
235
+ .argument("[reader]", "graph or entities; leave out to show the setting")
236
+ .action(setup(async (context, _options, args) => {
237
+ const { readerCommand } = await import("../lib/ontology-graph/setup/index.js");
238
+ return readerCommand(context, args[0] !== undefined ? { value: args[0] } : {});
239
+ }));
240
+ scoped(ontology.command("model"))
241
+ .description("Show or set the model the graph's model step uses for the company on this machine (per machine; the setting does not sync)")
242
+ .argument("[model]", "model name, for example haiku, sonnet or opus; leave out to show the setting")
243
+ .action(setup(async (context, _options, args) => {
244
+ const { modelCommand } = await import("../lib/ontology-graph/setup/index.js");
245
+ return modelCommand(context, args[0] !== undefined ? { value: args[0] } : {});
246
+ }));
185
247
  scoped(ontology.command("rebuild"))
186
248
  .description("Rebuild the graph: import the old entity files, then replay the vault day by day")
187
249
  .option("--from <date>", "first day to replay (YYYY-MM-DD)", isoDateArg)
188
250
  .option("--to <date>", "last day to replay (YYYY-MM-DD)", isoDateArg)
189
251
  .option("--resume", "continue from the last replayed day")
190
252
  .option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
253
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
254
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
191
255
  .option("--no-model", "rules only: make no model call and leave model work pending")
192
256
  .option("--dry-run", "read and count, write nothing")
193
257
  .action(run(async (context, options) => {
@@ -197,6 +261,8 @@ export function registerOntologyCommand(program, deps = {}) {
197
261
  ...(options.to ? { to: options.to } : {}),
198
262
  resume: Boolean(options.resume),
199
263
  ...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
264
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
265
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
200
266
  ...(options.model === false ? { noModel: true } : {}),
201
267
  dryRun: Boolean(options.dryRun),
202
268
  });
@@ -209,6 +275,7 @@ export function registerOntologyCommand(program, deps = {}) {
209
275
  .option("--full-listing", "list the whole corpus again instead of only new and changed files")
210
276
  .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
211
277
  .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
278
+ .option("--follow-up", "also send model work an earlier run left pending (profiles, retyped links, decisions, summaries), within the daily cap")
212
279
  .option("--dry-run", "read and count, write nothing")
213
280
  .action(run(async (context, options) => {
214
281
  const { updateCommand } = await import("../lib/ontology-graph/replay/index.js");
@@ -219,9 +286,67 @@ export function registerOntologyCommand(program, deps = {}) {
219
286
  ...(options.fullListing ? { fullListing: true } : {}),
220
287
  ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
221
288
  ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
289
+ ...(options.followUp ? { followUp: true } : {}),
222
290
  dryRun: Boolean(options.dryRun),
223
291
  });
224
292
  }));
293
+ scoped(ontology.command("remodel"))
294
+ .description("Ask again, on the model in use, what another model wrote, and close that model's rows (history kept)")
295
+ .requiredOption("--from <model>", "model whose rows to replace, for example haiku")
296
+ .option("--kinds <list>", "ask again only what wrote these fact fields and relationship verbs, comma-separated (role_title,affiliation,works_at)")
297
+ .option("--budget-tokens <n>", "stop model calls after this many input tokens", capArg)
298
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
299
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
300
+ .option("--dry-run", "count the rows and estimate the tokens; call no model and write nothing")
301
+ .action(run(async (context, options) => {
302
+ const { RemodelUsageError, remodelCommand } = await import("../lib/ontology-graph/remodel/index.js");
303
+ try {
304
+ return await remodelCommand(context, {
305
+ from: options.from,
306
+ ...(options.kinds ? { kinds: options.kinds.split(",") } : {}),
307
+ ...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
308
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
309
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
310
+ dryRun: Boolean(options.dryRun),
311
+ });
312
+ }
313
+ catch (error) {
314
+ if (error instanceof RemodelUsageError)
315
+ throw new OntologyGraphUsageError(error.message);
316
+ throw error;
317
+ }
318
+ }));
319
+ const lineage = ontology.command("lineage").description("Decision lineage: which decision replaced an earlier one");
320
+ scoped(lineage.command("backfill"))
321
+ .description("Ask the model, day by day from the oldest, whether each decision with no stated change replaces or reverses an earlier open one, and write a link for each that holds (model authority, no status row; each written link is listed in .state/lineage-backfill.jsonl, and `hq ontology lineage undo` removes exactly those). A day with a decision that got no usable reply is not written: the next run sends it again, and after 3 runs it is recorded as unanswered. Exit code 2 when the walk stopped early, 3 when it finished with a decision unanswered in this run. Runs whenever it is invoked, whatever model_tasks says")
322
+ .option("--from <date>", "first decision day to ask about (YYYY-MM-DD)", isoDateArg)
323
+ .option("--to <date>", "last decision day to ask about (YYYY-MM-DD)", isoDateArg)
324
+ .option("--restart", "forget what earlier runs settled, their attempt counts and their unanswered decisions, and walk from the first day; answers already given cost nothing")
325
+ .option("--retry-unanswered", "send the decisions earlier runs recorded as unanswered again")
326
+ .option("--allow-unanswered", "record a decision with no usable reply as unanswered at once instead of holding its day for the next run, and do not exit non-zero for it")
327
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
328
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
329
+ .option("--dry-run", "count the decisions and batches and estimate the tokens and the list-price cost as ranges, with the flags that let the estimate through the daily cap; call no model and write nothing")
330
+ .action(run(async (context, options) => {
331
+ const { lineageBackfillCommand } = await import("../lib/ontology-graph/lineage/index.js");
332
+ return lineageBackfillCommand(context, {
333
+ ...(options.from ? { from: options.from } : {}),
334
+ ...(options.to ? { to: options.to } : {}),
335
+ ...(options.restart ? { restart: true } : {}),
336
+ ...(options.retryUnanswered ? { retryUnanswered: true } : {}),
337
+ ...(options.allowUnanswered ? { allowUnanswered: true } : {}),
338
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
339
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
340
+ dryRun: Boolean(options.dryRun),
341
+ });
342
+ }));
343
+ scoped(lineage.command("undo"))
344
+ .description("Take back what `hq ontology lineage backfill` wrote: remove the rows .state/lineage-backfill.jsonl lists (each link's edge and its inverse) and clear the walk's state, so a later backfill starts from the first day. A row is removed only when the graph still holds it as the backfill wrote it; a row changed since is left and counted. No other row is touched, and no model is called")
345
+ .option("--dry-run", "count what would be removed and left; write nothing")
346
+ .action(run(async (context, options) => {
347
+ const { lineageUndoCommand } = await import("../lib/ontology-graph/lineage/index.js");
348
+ return lineageUndoCommand(context, { dryRun: Boolean(options.dryRun) });
349
+ }));
225
350
  scoped(ontology.command("lookup"))
226
351
  .description("Find an entity by name and print its facts, each with a source and date")
227
352
  .argument("<name>", "name, alias, email or <type>/<slug>")
@@ -283,11 +408,12 @@ export function registerOntologyCommand(program, deps = {}) {
283
408
  });
284
409
  }));
285
410
  scoped(ontology.command("brief"))
286
- .description("Write brief.md, the short summary every session starts with")
411
+ .description("Write brief.md, the short text every session starts with: a map of the graph and how to look things up")
287
412
  .option("--stdout", "print the brief without writing it")
413
+ .option("--style <style>", "map: what the graph holds, the lookup commands and names worth looking up, with no facts. full: the earlier summary with facts in it. Default: brief_style in the reader setting, else map", briefStyleArg)
288
414
  .action(read(async (context, options) => {
289
415
  const { briefCommand } = await import("../lib/ontology-graph/read/index.js");
290
- return briefCommand(context, { stdout: Boolean(options.stdout) });
416
+ return briefCommand(context, { stdout: Boolean(options.stdout), ...(options.style ? { style: options.style } : {}) });
291
417
  }));
292
418
  scoped(ontology.command("lint"))
293
419
  .description("Check the graph and print a count per kind of problem")
@@ -478,9 +478,39 @@ async function adoptAction(reportId, options) {
478
478
  rememberReportChannelAfterSuccess(updated);
479
479
  print(updated, options.json === true);
480
480
  }
481
+ async function retireReportRecord(token, report) {
482
+ const res = await vaultApiFetch({
483
+ token,
484
+ path: reportPath(report.channelId, report.reportId),
485
+ method: "DELETE",
486
+ body: { revision: report.revision },
487
+ });
488
+ if (res.status === 403) {
489
+ throw new ReportPublishError(`Only the report's creator or a company admin can retire this report (DELETE ${reportPath(report.channelId, report.reportId)}).`, "source-invalid");
490
+ }
491
+ if (res.status === 409) {
492
+ const body = await res.json().catch(() => ({}));
493
+ if (body.error === "revision-mismatch") {
494
+ throw new ReportPublishError("Report changed while it was being retired; refresh and retry.", "revision-conflict");
495
+ }
496
+ throw new ReportPublishError("Could not retire the report record.", "revision-conflict");
497
+ }
498
+ if (!res.ok)
499
+ throw new ReportPublishError("Could not retire the report record.");
500
+ const body = await res.json();
501
+ if (body.report?.state === "decommissioned")
502
+ return body.report;
503
+ const latest = await readReportInChannel(token, report.channelId, report.reportId);
504
+ if (latest?.state === "decommissioned")
505
+ return latest;
506
+ throw new ReportPublishError(`Report is still ${latest?.state ?? report.state}; DELETE ${reportPath(report.channelId, report.reportId)} did not retire it.`);
507
+ }
481
508
  async function decommissionAction(reportId, options) {
482
509
  const token = await ensureCognitoToken();
483
- const report = await resolveReport(token, reportId, options.channel);
510
+ let report = await resolveReport(token, reportId, options.channel);
511
+ if (report.state !== "decommissioned") {
512
+ report = await retireReportRecord(token, report);
513
+ }
484
514
  const org = await orgFor(token, report);
485
515
  const leftover = [];
486
516
  for (const id of [report.deployAppId, report.draft?.appId]) {
@@ -501,7 +531,6 @@ async function decommissionAction(reportId, options) {
501
531
  leftover.push("A deployment could not be reached.");
502
532
  }
503
533
  }
504
- // The durable report is marked decommissioned by hq-pro before this prompt.
505
534
  // Cleanup gaps stay on the result so a missing app or offline bot does not roll the record back.
506
535
  if (report.jobId) {
507
536
  try {
@@ -512,6 +541,10 @@ async function decommissionAction(reportId, options) {
512
541
  }
513
542
  }
514
543
  const note = leftover.length ? [...new Set(leftover)].join(" ") : null;
544
+ if (report.state !== "decommissioned") {
545
+ print({ reportId: report.reportId, decommissioned: false, state: report.state, note }, options.json === true);
546
+ throw new ReportPublishError(`Report is still ${report.state}.`);
547
+ }
515
548
  print({ reportId: report.reportId, decommissioned: true, note }, options.json === true);
516
549
  }
517
550
  export function registerReportCommand(program) {
@@ -33,6 +33,7 @@ import { isAuthError } from "../utils/auth-error.js";
33
33
  import { IntegrationsCliError, callGateway, fetchIntegrationsSummary, gatewayResultIsError, isBuiltInGatewayProvider, raiseForResponse, toolPrefixForProvider, unwrapGatewayResult, } from "./integrations-core.js";
34
34
  import { Sentry } from "../sentry.js";
35
35
  import { resolveUploadAuthor } from "../utils/upload-author.js";
36
+ import { resolveSyncPerson } from "../utils/sync-person.js";
36
37
  import { createSignalsAlertChannelPoster, raiseSignalsFailureAlerts } from "../lib/hot-channels/alert.js";
37
38
  import { audienceKey } from "../lib/hot-channels/audience.js";
38
39
  import { appendRunLedgerEntry, ledgerDay, readRunLedger, RUN_TRIGGERS, summarizeRunLedger, } from "../lib/hot-channels/ledger.js";
@@ -323,6 +324,7 @@ function renderRunsTable(report) {
323
324
  return lines.join("\n");
324
325
  }
325
326
  const SIGN_IN_PROMPT = "Your HQ session has expired or you're not signed in. Run `hq login`, then `hq sources sync` again.";
327
+ const NO_PERSON_IDENTITY_NOTICE = "No person identity on this machine: its HQ sign-in is a machine identity that acts for no person, so the hot-channel sync has no one to run for. Run the sync where its owner is signed in to HQ.";
326
328
  const MAX_TOOL_ERROR_TEXT = 500;
327
329
  /** The catalog API's `hotChannels` array, or null when the server has none. */
328
330
  async function fetchHotChannels(token, companyUid) {
@@ -386,6 +388,17 @@ function signInReport() {
386
388
  exitCode: 1,
387
389
  };
388
390
  }
391
+ function noPersonIdentityReport() {
392
+ return {
393
+ runId: null,
394
+ signInRequired: true,
395
+ noPersonIdentity: true,
396
+ outcomes: [],
397
+ entries: [],
398
+ notices: [NO_PERSON_IDENTITY_NOTICE],
399
+ exitCode: 1,
400
+ };
401
+ }
389
402
  async function signedInSession(company) {
390
403
  let token;
391
404
  try {
@@ -464,11 +477,12 @@ async function meetingIdentities(input, session, email) {
464
477
  */
465
478
  export async function runCompanyHotChannelSync(input) {
466
479
  assertSafeSegment(input.company, "company");
467
- // A sub-only upload author (machine token with no email) has no person key
468
- // for the hot-channel audience, so it is treated as not signed in.
469
- const author = resolveUploadAuthor();
470
- const session = author?.email ? await signedInSession(input.company) : null;
471
- if (!author?.email || !session)
480
+ const person = resolveSyncPerson();
481
+ if (person.kind === "no-person")
482
+ return noPersonIdentityReport();
483
+ const author = person.kind === "person" ? person.author : undefined;
484
+ const session = author ? await signedInSession(input.company) : null;
485
+ if (!author || !session)
472
486
  return signInReport();
473
487
  const vaultRoot = path.join(input.hqRoot, "companies", input.company);
474
488
  const personKey = audienceKey([author.email]);
@@ -631,8 +645,9 @@ export async function runSync(options, overrides = {}) {
631
645
  if (outcome.reconnect)
632
646
  process.stderr.write(chalk.yellow(`${outcome.reconnect.prompt}\n`));
633
647
  }
634
- if (report.signInRequired)
635
- process.stderr.write(chalk.yellow(`${SIGN_IN_PROMPT}\n`));
648
+ if (report.signInRequired) {
649
+ process.stderr.write(chalk.yellow(`${report.noPersonIdentity ? NO_PERSON_IDENTITY_NOTICE : SIGN_IN_PROMPT}\n`));
650
+ }
636
651
  if (report.exitCode !== 0)
637
652
  process.exitCode = report.exitCode;
638
653
  return report;
@@ -710,7 +725,10 @@ export async function runSignalsRedo(options, overrides = {}) {
710
725
  };
711
726
  const channels = [...new Set([...selection.pending.keys(), ...selection.worklist.keys()])];
712
727
  if (!report.dryRun && channels.length > 0) {
713
- const author = overrides.author !== undefined ? overrides.author : resolveUploadAuthor();
728
+ const person = overrides.author !== undefined ? null : resolveSyncPerson();
729
+ if (person?.kind === "no-person")
730
+ return fail(`${NO_PERSON_IDENTITY_NOTICE} (the run takes your hot-channel sync lock)`, 1);
731
+ const author = overrides.author !== undefined ? overrides.author : person?.kind === "person" ? person.author : null;
714
732
  // A sub-only author (machine token with no email) has no person key for
715
733
  // the hot-channel lock, so it is treated as not signed in.
716
734
  if (!author?.email)
@@ -12,7 +12,7 @@
12
12
  * already async; the registrar and every subcommand stay synchronous.
13
13
  */
14
14
  import { Command } from "commander";
15
- import { resolveCompanyFlagGate } from "../lib/flag-registry.js";
15
+ import { resolveCompanyFlagGate } from "../lib/company-flag-gate.js";
16
16
  import { HQ_STORAGE_FLAG, STORAGE_FEATURE_DISABLED_MESSAGE, storageFeatureDisabledJson, storageFeatureEnabledFromCache, hideStorageInCatalog, } from "../lib/storage-feature-flag.js";
17
17
  const MEMBERSHIP_TIMEOUT_MS = 3_000;
18
18
  async function defaultToken() {
@@ -1,4 +1,5 @@
1
- import { resolveCompanyFlagGate, resolveProcessFlagGate } from "../lib/flag-registry.js";
1
+ import { resolveCompanyFlagGate } from "../lib/company-flag-gate.js";
2
+ import { resolveProcessFlagGate } from "../lib/flag-registry.js";
2
3
  export const VAULT_RETENTION_SETTINGS_FLAG = "cli.vault-retention-settings";
3
4
  export function vaultRetentionSettingsEnabled(companyUid, idToken) {
4
5
  if (companyUid && idToken) {
@@ -6,7 +6,7 @@ import { loadCachedTokens, isExpiring, loadMachineCreds, } from '@indigoai-us/hq
6
6
  import { buildWhoamiIdentity, peekWhoamiTokenIdentity as peekIdToken, resolveWhoamiIdentity, } from "../utils/whoami-identity.js";
7
7
  import { ensureCognitoToken, loadMachineCachedTokens, resolveCognitoTokenSource, } from "../utils/cognito-session.js";
8
8
  import { colorizePlanLimitNotice, fetchPlanLimitStatus, renderPlanLine, renderPlanLimitNotice, } from "../lib/billing/plan-lock.js";
9
- import { resolveCompanyFlagGate, } from "../lib/flag-registry.js";
9
+ import { resolveCompanyFlagGate, } from "../lib/company-flag-gate.js";
10
10
  import { queuePlanLimitInviteTeammateExposure } from "../utils/cli-telemetry.js";
11
11
  import { resolveCallerPersonUid } from "../utils/vault-api.js";
12
12
  import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";