@indigoai-us/hq-cli 5.345.248 → 5.345.251

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/contracts/host-canary-release.json +3 -3
  3. package/dist/command-catalog.generated.d.ts +288 -9
  4. package/dist/command-catalog.generated.js +355 -9
  5. package/dist/commands/bot.js +5 -1
  6. package/dist/commands/core-job-run-native.js +4 -0
  7. package/dist/commands/core-knowledge-prefs.d.ts +1 -1
  8. package/dist/commands/core-knowledge-prefs.js +1 -16
  9. package/dist/commands/core.js +0 -2
  10. package/dist/commands/daemon.js +21 -0
  11. package/dist/commands/lanes.d.ts +2 -0
  12. package/dist/commands/lanes.js +9 -4
  13. package/dist/commands/ontology-graph.d.ts +11 -3
  14. package/dist/commands/ontology-graph.js +138 -14
  15. package/dist/commands/sources.js +26 -8
  16. package/dist/commands/sync-core.js +6 -0
  17. package/dist/fast-scaffold.js +1 -3
  18. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +281 -256
  19. package/dist/hq-cloud-sync-runner/package.json +1 -1
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +47 -0
  22. package/dist/lib/bot/fleet-cron.d.ts +2 -0
  23. package/dist/lib/bot/fleet-cron.js +5 -0
  24. package/dist/lib/daemon/installed-cli-restart.d.ts +57 -0
  25. package/dist/lib/daemon/installed-cli-restart.js +114 -0
  26. package/dist/lib/daemon/legacy-journal-gate.d.ts +32 -0
  27. package/dist/lib/daemon/legacy-journal-gate.js +102 -0
  28. package/dist/lib/daemon/machine-checks.d.ts +7 -0
  29. package/dist/lib/daemon/machine-checks.js +10 -0
  30. package/dist/lib/daemon/run.d.ts +3 -1
  31. package/dist/lib/daemon/run.js +48 -5
  32. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  33. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  34. package/dist/lib/hook-engine/coverage.d.ts +99 -19
  35. package/dist/lib/hook-engine/coverage.js +269 -35
  36. package/dist/lib/hook-engine/native-stop-compatibility.json +9 -4
  37. package/dist/lib/hook-engine/registration-identity.d.ts +5 -0
  38. package/dist/lib/hook-engine/registration-identity.js +1 -1
  39. package/dist/lib/hook-engine/resolve.d.ts +23 -0
  40. package/dist/lib/hook-engine/resolve.js +48 -1
  41. package/dist/lib/hook-engine/stable-heal.d.ts +87 -0
  42. package/dist/lib/hook-engine/stable-heal.js +214 -0
  43. package/dist/lib/hot-channels/graph-context.d.ts +26 -1
  44. package/dist/lib/hot-channels/graph-context.js +80 -10
  45. package/dist/lib/hot-channels/run.d.ts +1 -0
  46. package/dist/lib/hot-channels/signals-pass.js +9 -4
  47. package/dist/lib/ontology-graph/model/files.d.ts +4 -0
  48. package/dist/lib/ontology-graph/model/files.js +23 -0
  49. package/dist/lib/ontology-graph/model/index.d.ts +11 -1
  50. package/dist/lib/ontology-graph/model/index.js +42 -18
  51. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +9 -1
  52. package/dist/lib/ontology-graph/model/pass-tasks.js +7 -4
  53. package/dist/lib/ontology-graph/model/pass.d.ts +5 -0
  54. package/dist/lib/ontology-graph/model/pass.js +8 -8
  55. package/dist/lib/ontology-graph/model/pending-items.d.ts +31 -0
  56. package/dist/lib/ontology-graph/model/pending-items.js +113 -0
  57. package/dist/lib/ontology-graph/model/step.d.ts +48 -1
  58. package/dist/lib/ontology-graph/model/step.js +205 -36
  59. package/dist/lib/ontology-graph/model/tasks.d.ts +17 -1
  60. package/dist/lib/ontology-graph/model/tasks.js +28 -8
  61. package/dist/lib/ontology-graph/org/derive.d.ts +2 -0
  62. package/dist/lib/ontology-graph/org/derive.js +9 -2
  63. package/dist/lib/ontology-graph/org/index.d.ts +35 -6
  64. package/dist/lib/ontology-graph/org/index.js +136 -19
  65. package/dist/lib/ontology-graph/org/text.d.ts +2 -0
  66. package/dist/lib/ontology-graph/org/text.js +6 -0
  67. package/dist/lib/ontology-graph/org/types.d.ts +5 -0
  68. package/dist/lib/ontology-graph/pages/render.d.ts +2 -0
  69. package/dist/lib/ontology-graph/pages/render.js +11 -4
  70. package/dist/lib/ontology-graph/read/brief.d.ts +13 -3
  71. package/dist/lib/ontology-graph/read/brief.js +312 -62
  72. package/dist/lib/ontology-graph/read/index.d.ts +1 -1
  73. package/dist/lib/ontology-graph/read/index.js +14 -3
  74. package/dist/lib/ontology-graph/read/names.d.ts +6 -1
  75. package/dist/lib/ontology-graph/read/names.js +8 -3
  76. package/dist/lib/ontology-graph/read/reader-setting.d.ts +2 -0
  77. package/dist/lib/ontology-graph/read/reader-setting.js +4 -1
  78. package/dist/lib/ontology-graph/remodel/index.d.ts +174 -0
  79. package/dist/lib/ontology-graph/remodel/index.js +450 -0
  80. package/dist/lib/ontology-graph/replay/engine.d.ts +47 -1
  81. package/dist/lib/ontology-graph/replay/engine.js +68 -2
  82. package/dist/lib/ontology-graph/replay/index.d.ts +2 -1
  83. package/dist/lib/ontology-graph/replay/index.js +114 -8
  84. package/dist/lib/ontology-graph/schema/authority.d.ts +43 -0
  85. package/dist/lib/ontology-graph/schema/authority.js +39 -0
  86. package/dist/lib/ontology-graph/schema/index.d.ts +1 -1
  87. package/dist/lib/ontology-graph/schema/index.js +1 -1
  88. package/dist/lib/ontology-graph/setup/index.d.ts +88 -0
  89. package/dist/lib/ontology-graph/setup/index.js +489 -0
  90. package/dist/lib/ontology-graph/types.d.ts +28 -0
  91. package/dist/lib/ontology-graph/types.js +5 -0
  92. package/dist/lib/signals/failure-alert.js +4 -5
  93. package/dist/lib/signals/steps/adapters.js +3 -0
  94. package/dist/lib/sync-core/engine-holds.d.ts +1 -1
  95. package/dist/lib/sync-core/engine-holds.js +12 -2
  96. package/dist/lib/sync-core/hand-back.d.ts +2 -1
  97. package/dist/lib/sync-core/hand-back.js +16 -2
  98. package/dist/lib/sync-core/legacy-journal-export-child.d.ts +2 -0
  99. package/dist/lib/sync-core/legacy-journal-export-child.js +24 -0
  100. package/dist/lib/sync-core/legacy-journal-export.d.ts +39 -0
  101. package/dist/lib/sync-core/legacy-journal-export.js +241 -0
  102. package/dist/lib/sync-core/legacy-journal-reader.d.ts +15 -0
  103. package/dist/lib/sync-core/legacy-journal-reader.js +56 -0
  104. package/dist/lib/sync-core/reconcile.d.ts +3 -0
  105. package/dist/lib/sync-core/reconcile.js +43 -3
  106. package/dist/utils/cli-telemetry.d.ts +1 -0
  107. package/dist/utils/cli-telemetry.js +6 -3
  108. package/dist/utils/hook-engine-rollup.d.ts +96 -0
  109. package/dist/utils/hook-engine-rollup.js +725 -0
  110. package/dist/utils/sync-person.d.ts +15 -0
  111. package/dist/utils/sync-person.js +74 -0
  112. package/package.json +8 -8
  113. package/scripts/install-hook-engine.mjs +4 -0
  114. package/assets/scaffold/core/scripts/knowledge-prefs.sh +0 -55
@@ -5,12 +5,14 @@
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]
10
11
  * 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
12
+ * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
12
13
  * hq ontology org-chart draft | confirm --from <file> [--yes] | show
13
- * hq ontology org observed [--write] | compare | person <name> [--view company|member] [--as-of D] [--model]
14
+ * hq ontology activity [<person>] [--roles] [--compare] [--write] [--view company|member] [--as-of D] [--model]
15
+ * (`hq ontology org observed|compare|person <name>` is the same thing under its first name, kept hidden)
14
16
  * hq ontology daily | job install|uninstall|status
15
17
  *
16
18
  * No identity flag is needed (correction C5). Without `--member` the read
@@ -25,6 +27,7 @@
25
27
  * the old `ontology/entities/` folder) is a different command and is unchanged.
26
28
  */
27
29
  import { Command } from "commander";
30
+ import type { SetupContext } from "../lib/ontology-graph/setup/index.js";
28
31
  import type { GraphContext, MemberIdentity } from "../lib/ontology-graph/types.js";
29
32
  export declare class OntologyGraphUsageError extends Error {
30
33
  constructor(message: string);
@@ -57,6 +60,11 @@ export interface OntologyGraphCommandDeps {
57
60
  }
58
61
  /** Resolves the company and the graph folder for one invocation. */
59
62
  export declare function resolveGraphContext(options: ScopeOptions): GraphContext;
63
+ /**
64
+ * The company and folders for a setup command (`status`, `reader`, `model`). The graph folder is not checked
65
+ * here: these commands report or refuse on its state themselves, and none reads a row from it.
66
+ */
67
+ export declare function resolveSetupContext(options: ScopeOptions): SetupContext;
60
68
  export declare function registerOntologyCommand(program: Command, deps?: OntologyGraphCommandDeps): Command;
61
69
  export {};
62
70
  //# sourceMappingURL=ontology-graph.d.ts.map
@@ -5,12 +5,14 @@
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]
10
11
  * 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
12
+ * hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
12
13
  * hq ontology org-chart draft | confirm --from <file> [--yes] | show
13
- * hq ontology org observed [--write] | compare | person <name> [--view company|member] [--as-of D] [--model]
14
+ * hq ontology activity [<person>] [--roles] [--compare] [--write] [--view company|member] [--as-of D] [--model]
15
+ * (`hq ontology org observed|compare|person <name>` is the same thing under its first name, kept hidden)
14
16
  * hq ontology daily | job install|uninstall|status
15
17
  *
16
18
  * No identity flag is needed (correction C5). Without `--member` the read
@@ -84,11 +86,22 @@ function budgetArg(value) {
84
86
  throw new InvalidArgumentError("expected a whole number, 0 or more");
85
87
  return parsed;
86
88
  }
89
+ function capArg(value) {
90
+ const parsed = Number(value);
91
+ if (value.trim() === "" || !Number.isSafeInteger(parsed) || parsed < 1)
92
+ throw new InvalidArgumentError("expected a whole number, 1 or more");
93
+ return parsed;
94
+ }
87
95
  function clockArg(value) {
88
96
  if (!/^([01]?\d|2[0-3]):[0-5]\d$/.test(value))
89
97
  throw new InvalidArgumentError("expected a time as HH:MM");
90
98
  return value;
91
99
  }
100
+ function briefStyleArg(value) {
101
+ if (value !== "map" && value !== "full")
102
+ throw new InvalidArgumentError("expected map or full");
103
+ return value;
104
+ }
92
105
  function depthArg(value) {
93
106
  const parsed = Number(value);
94
107
  if (!Number.isInteger(parsed) || parsed < 1 || parsed > 3)
@@ -128,6 +141,25 @@ export function resolveGraphContext(options) {
128
141
  ...(member ? { member } : {}),
129
142
  };
130
143
  }
144
+ /**
145
+ * The company and folders for a setup command (`status`, `reader`, `model`). The graph folder is not checked
146
+ * here: these commands report or refuse on its state themselves, and none reads a row from it.
147
+ */
148
+ export function resolveSetupContext(options) {
149
+ const hqRoot = resolveLiveRoot({ hqRoot: options.hqRoot });
150
+ const resolution = resolveOntologyCompany(hqRoot, options.company);
151
+ if (!resolution.ok) {
152
+ throw new OntologyGraphUsageError(options.company ? `ontology: company rejected: ${resolution.reason}` : "ontology: --company <slug> is required");
153
+ }
154
+ const companyRoot = resolution.company.dir;
155
+ return {
156
+ hqRoot,
157
+ company: resolution.company.slug,
158
+ companyRoot,
159
+ graphRoot: resolveGraphRoot({ companyRoot, flag: options.graphRoot }),
160
+ json: Boolean(options.json),
161
+ };
162
+ }
131
163
  function orgViewArg(value) {
132
164
  if (value !== "company" && value !== "member")
133
165
  throw new InvalidArgumentError("expected company or member");
@@ -172,15 +204,52 @@ export function registerOntologyCommand(program, deps = {}) {
172
204
  };
173
205
  /** A read command: `run` with the member filled in from the sign-in when no flag names one. */
174
206
  const read = (entry) => run(entry, "read");
207
+ /** Wraps a setup action: the company and folders, no member, and a graph folder the command looks at itself. */
208
+ const setup = (entry) => async function action(...raw) {
209
+ const args = raw.filter((value) => typeof value === "string");
210
+ const options = mergedOptions(this);
211
+ const context = resolveSetupContext(options);
212
+ const { OntologySetupError } = await import("../lib/ontology-graph/setup/index.js");
213
+ try {
214
+ emit(context, await entry(context, options, args));
215
+ }
216
+ catch (error) {
217
+ if (error instanceof OntologySetupError)
218
+ throw new OntologyGraphUsageError(error.message);
219
+ throw error;
220
+ }
221
+ };
175
222
  const ontology = program
176
223
  .command("ontology")
177
224
  .description("Ontology graph: sourced facts, typed relationships, rebuilt from the files on this machine (local only)");
225
+ scoped(ontology.command("status"))
226
+ .description("Show the reader, the model, the graph folder, its counts, pending model work, the last update and the brief (reads only)")
227
+ .action(setup(async (context) => {
228
+ const { statusCommand } = await import("../lib/ontology-graph/setup/index.js");
229
+ return statusCommand(context);
230
+ }));
231
+ scoped(ontology.command("reader"))
232
+ .description("Show or set which ontology this machine's sessions read for the company: graph, or entities (the old files)")
233
+ .argument("[reader]", "graph or entities; leave out to show the setting")
234
+ .action(setup(async (context, _options, args) => {
235
+ const { readerCommand } = await import("../lib/ontology-graph/setup/index.js");
236
+ return readerCommand(context, args[0] !== undefined ? { value: args[0] } : {});
237
+ }));
238
+ scoped(ontology.command("model"))
239
+ .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)")
240
+ .argument("[model]", "model name, for example haiku, sonnet or opus; leave out to show the setting")
241
+ .action(setup(async (context, _options, args) => {
242
+ const { modelCommand } = await import("../lib/ontology-graph/setup/index.js");
243
+ return modelCommand(context, args[0] !== undefined ? { value: args[0] } : {});
244
+ }));
178
245
  scoped(ontology.command("rebuild"))
179
246
  .description("Rebuild the graph: import the old entity files, then replay the vault day by day")
180
247
  .option("--from <date>", "first day to replay (YYYY-MM-DD)", isoDateArg)
181
248
  .option("--to <date>", "last day to replay (YYYY-MM-DD)", isoDateArg)
182
249
  .option("--resume", "continue from the last replayed day")
183
250
  .option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
251
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
252
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
184
253
  .option("--no-model", "rules only: make no model call and leave model work pending")
185
254
  .option("--dry-run", "read and count, write nothing")
186
255
  .action(run(async (context, options) => {
@@ -190,6 +259,8 @@ export function registerOntologyCommand(program, deps = {}) {
190
259
  ...(options.to ? { to: options.to } : {}),
191
260
  resume: Boolean(options.resume),
192
261
  ...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
262
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
263
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
193
264
  ...(options.model === false ? { noModel: true } : {}),
194
265
  dryRun: Boolean(options.dryRun),
195
266
  });
@@ -200,6 +271,9 @@ export function registerOntologyCommand(program, deps = {}) {
200
271
  .option("--budget-tokens <n>", "stop model calls after this many input tokens; 0 runs rules only", budgetArg)
201
272
  .option("--no-model", "rules only: make no model call and leave model work pending")
202
273
  .option("--full-listing", "list the whole corpus again instead of only new and changed files")
274
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
275
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
276
+ .option("--follow-up", "also send model work an earlier run left pending (profiles, retyped links, decisions, summaries), within the daily cap")
203
277
  .option("--dry-run", "read and count, write nothing")
204
278
  .action(run(async (context, options) => {
205
279
  const { updateCommand } = await import("../lib/ontology-graph/replay/index.js");
@@ -208,9 +282,38 @@ export function registerOntologyCommand(program, deps = {}) {
208
282
  ...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
209
283
  ...(options.model === false ? { noModel: true } : {}),
210
284
  ...(options.fullListing ? { fullListing: true } : {}),
285
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
286
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
287
+ ...(options.followUp ? { followUp: true } : {}),
211
288
  dryRun: Boolean(options.dryRun),
212
289
  });
213
290
  }));
291
+ scoped(ontology.command("remodel"))
292
+ .description("Ask again, on the model in use, what another model wrote, and close that model's rows (history kept)")
293
+ .requiredOption("--from <model>", "model whose rows to replace, for example haiku")
294
+ .option("--kinds <list>", "ask again only what wrote these fact fields and relationship verbs, comma-separated (role_title,affiliation,works_at)")
295
+ .option("--budget-tokens <n>", "stop model calls after this many input tokens", capArg)
296
+ .option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
297
+ .option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
298
+ .option("--dry-run", "count the rows and estimate the tokens; call no model and write nothing")
299
+ .action(run(async (context, options) => {
300
+ const { RemodelUsageError, remodelCommand } = await import("../lib/ontology-graph/remodel/index.js");
301
+ try {
302
+ return await remodelCommand(context, {
303
+ from: options.from,
304
+ ...(options.kinds ? { kinds: options.kinds.split(",") } : {}),
305
+ ...(options.budgetTokens !== undefined ? { budgetTokens: options.budgetTokens } : {}),
306
+ ...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
307
+ ...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
308
+ dryRun: Boolean(options.dryRun),
309
+ });
310
+ }
311
+ catch (error) {
312
+ if (error instanceof RemodelUsageError)
313
+ throw new OntologyGraphUsageError(error.message);
314
+ throw error;
315
+ }
316
+ }));
214
317
  scoped(ontology.command("lookup"))
215
318
  .description("Find an entity by name and print its facts, each with a source and date")
216
319
  .argument("<name>", "name, alias, email or <type>/<slug>")
@@ -272,11 +375,12 @@ export function registerOntologyCommand(program, deps = {}) {
272
375
  });
273
376
  }));
274
377
  scoped(ontology.command("brief"))
275
- .description("Write brief.md, the short summary every session starts with")
378
+ .description("Write brief.md, the short text every session starts with: a map of the graph and how to look things up")
276
379
  .option("--stdout", "print the brief without writing it")
380
+ .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)
277
381
  .action(read(async (context, options) => {
278
382
  const { briefCommand } = await import("../lib/ontology-graph/read/index.js");
279
- return briefCommand(context, { stdout: Boolean(options.stdout) });
383
+ return briefCommand(context, { stdout: Boolean(options.stdout), ...(options.style ? { style: options.style } : {}) });
280
384
  }));
281
385
  scoped(ontology.command("lint"))
282
386
  .description("Check the graph and print a count per kind of problem")
@@ -366,34 +470,54 @@ export function registerOntologyCommand(program, deps = {}) {
366
470
  const { orgChartShowCommand } = await import("../lib/ontology-graph/proposals/org-chart.js");
367
471
  return orgChartShowCommand(context);
368
472
  }));
473
+ // The first name of the activity view. Hidden, and kept so nothing that calls it breaks.
369
474
  const org = ontology
370
- .command("org")
371
- .description("The org as observed from behavior in the graph, beside the stated one. Inferred, never a confirmed fact");
372
- /** The options the three observed-org commands share. */
475
+ .command("org", { hidden: true })
476
+ .description("Earlier name of `hq ontology activity`. Inferred from behavior, never a confirmed fact");
477
+ /** The options the activity commands share. */
373
478
  const orgScoped = (command) => scoped(command)
374
479
  .option("--view <view>", "company (company-wide rows only) or member (also the rows only this member may read)", orgViewArg)
375
480
  .option("--as-of <date>", "the day the 30, 90 and 365 day windows end on (YYYY-MM-DD; default today)", isoDateArg)
376
- .option("--model", "phrase each active person's observed role with one small model call");
481
+ .option("--roles", "also show the inferred role line and who appears to direct whom")
482
+ .option("--model", "with --roles, phrase each active person's role line with one small model call");
377
483
  const orgOptions = (options) => ({
378
484
  ...(options.view ? { view: options.view } : {}),
379
485
  ...(options.asOf ? { asOf: options.asOf } : {}),
380
- model: Boolean(options.model),
486
+ // The model only phrases role lines, so it is never called for output that shows none.
487
+ model: Boolean(options.model) && Boolean(options.roles),
488
+ roles: Boolean(options.roles),
381
489
  });
490
+ orgScoped(ontology.command("activity"))
491
+ .description("What each person does, from behavior in the graph: kinds of work with counts, what they ship and own, who they work with, change over time. Inferred; stores nothing without --write")
492
+ .argument("[person]", "one person's name or slug; without it, everyone")
493
+ .option("--compare", "print stated beside observed instead: title, manager and listed owner against behavior")
494
+ .option("--write", "also store the derived rows in the graph folder, marked as inferred")
495
+ .action(read(async (context, options, args) => {
496
+ const lib = await import("../lib/ontology-graph/org/index.js");
497
+ if (options.compare) {
498
+ if (args[0] !== undefined)
499
+ throw new OntologyGraphUsageError("--compare covers everyone; leave the person out");
500
+ return lib.orgCompareCommand(context, { ...orgOptions(options), model: Boolean(options.model) });
501
+ }
502
+ if (args[0] !== undefined)
503
+ return lib.orgPersonCommand(context, { ...orgOptions(options), name: args[0], write: options.write === true });
504
+ return lib.orgObservedCommand(context, { ...orgOptions(options), write: options.write === true });
505
+ }));
382
506
  orgScoped(org.command("observed"))
383
- .description("Print the observed org: role, areas, who appears to direct whom, groups and de facto owners. Stores nothing without --write")
507
+ .description("Same as `hq ontology activity`")
384
508
  .option("--write", "also store the derived rows in the graph folder, marked as inferred")
385
509
  .action(read(async (context, options) => {
386
510
  const { orgObservedCommand } = await import("../lib/ontology-graph/org/index.js");
387
511
  return orgObservedCommand(context, { ...orgOptions(options), write: options.write === true });
388
512
  }));
389
513
  orgScoped(org.command("compare"))
390
- .description("Print stated beside observed: title, manager and listed owner against behavior. Changes nothing")
514
+ .description("Same as `hq ontology activity --compare`")
391
515
  .action(read(async (context, options) => {
392
516
  const { orgCompareCommand } = await import("../lib/ontology-graph/org/index.js");
393
- return orgCompareCommand(context, orgOptions(options));
517
+ return orgCompareCommand(context, { ...orgOptions(options), model: Boolean(options.model) });
394
518
  }));
395
519
  orgScoped(org.command("person"))
396
- .description("Print one person's observed activity by window, coverage, edges and stated claims. Changes nothing")
520
+ .description("Same as `hq ontology activity <person>`")
397
521
  .argument("<name>", "the person's name or slug")
398
522
  .action(read(async (context, options, args) => {
399
523
  const { orgPersonCommand } = await import("../lib/ontology-graph/org/index.js");
@@ -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)
@@ -91,6 +91,11 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
91
91
  if (!fs.existsSync(tokenFile))
92
92
  throw new Error(`the token file ${tokenFile} does not exist`);
93
93
  const client = new VaultClient(buildVaultConfig(token));
94
+ const [{ bundledHqCloud, currentHqCloud }, { loadLegacyJournalReader }] = await Promise.all([
95
+ import("../lib/daemon/hq-cloud.js"),
96
+ import("../lib/sync-core/legacy-journal-reader.js"),
97
+ ]);
98
+ const journal = await loadLegacyJournalReader([currentHqCloud(daemonPaths(d.home, d.env).root), bundledHqCloud()]);
94
99
  const { resolveCanonicalPersonUid } = await import("./cloud.js");
95
100
  const result = await reconcileSyncCore({
96
101
  home: d.home,
@@ -105,6 +110,7 @@ export async function runSyncCoreReconcile(opts, d = defaultDeps()) {
105
110
  }),
106
111
  readRolloutFlag: (companyUid) => readCompanyRolloutFlag(companyUid, token, { env: d.env }),
107
112
  resolveCompany: (companyUid) => client.entity.get(companyUid),
113
+ ...(journal.reader ? { readLegacyJournal: journal.reader } : { legacyJournalUnavailable: journal.reason }),
108
114
  machineType: await machineTypeHere(d),
109
115
  readDownloadStreams: (companyUid) => readCompanyDownloadStreams(companyUid, token, { env: d.env }),
110
116
  ensureBinary: (release) => ensureSyncCoreBinary({ home: d.home, platform: d.platform, arch: d.arch, release, env: d.env }),
@@ -483,10 +483,8 @@ export const FAST_SCAFFOLD_SCRIPTS = [
483
483
  exportName: "runKnowledgePrefsFast",
484
484
  flagKey: "hq-core-native-fast-route",
485
485
  familyFlagKey: "core-native-policy",
486
- asset: "core/scripts/knowledge-prefs.sh",
487
486
  root: "live",
488
- shellCwd: "live",
489
- shellHqRoot: "live",
487
+ fallbackToCommandGraph: true,
490
488
  },
491
489
  ...["finalize", "post", "open-steps"].map((name) => ({
492
490
  name: `handoff ${name}`,