@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
@@ -71,9 +71,9 @@ function honestyNotes(view, org, skewedShare, byClass) {
71
71
  }
72
72
  /** Where the derivation is known to be weak. Printed with every command output and stored with the view. */
73
73
  export const KNOWN_LIMITS = [
74
- "Commits count as at least half software engineering whatever the repository, so marketing-site, content and design work shipped as commits reads as engineering.",
74
+ "A commit counts as mostly software engineering unless the repository's own name says otherwise, so content and design work shipped in a product repository reads as engineering.",
75
75
  "Finance and operations work can read as deals, pricing and partnerships, because the same words appear in both.",
76
- "An action item filed under a meeting's host and not under a named person is counted for the host.",
76
+ "An action item a transcript files under a speaker label (Host, Speaker) and not a name is counted for nobody, so the person who took it looks less active.",
77
77
  "A bare first name that fits more than one roster member is not matched to either and shows as a separate person.",
78
78
  ];
79
79
  /** A role line with its status attached, for a table cell or a stored row read out of context. */
@@ -213,8 +213,34 @@ async function safeResolveMember(context) {
213
213
  // Derived rows on disk
214
214
  // ---------------------------------------------------------------------------
215
215
  const rowIdOf = (parts) => createHash("sha256").update(parts.join("\n")).digest("hex").slice(0, 12);
216
- /** Flattens an observed org into derived rows. Pure. */
217
- export function derivedRows(org) {
216
+ /** Row kinds that state a role, a line of direction or a stated-versus-observed finding. Kept out unless roles are asked for. */
217
+ export const ROLE_ROW_KINDS = new Set(["observed_role", "directs", "disagreement"]);
218
+ /** The part of an observed org that is about what people do: no role lines, no direction edges, no stated claims. */
219
+ export function activityOnly(org) {
220
+ const { directs: _directs, disagreements: _disagreements, stated: _stated, people, owners, ...rest } = org;
221
+ return {
222
+ ...rest,
223
+ people: people.map(withoutDirection).map(({ role, ...person }) => ({ ...person, mainAreas: role.mainAreas, change: role.change })),
224
+ // The listed owner and whether it agrees are stated claims: part of the comparison, not of what people do.
225
+ owners: owners.map(({ listed: _listed, agrees: _agrees, ...owner }) => owner),
226
+ };
227
+ }
228
+ /** Kinds of act that say who directs or approves whose work. Shown and stored only when roles are asked for. */
229
+ export const DIRECTION_KINDS = new Set(["directions_given", "directions_received", "approvals_given"]);
230
+ /** A person with every count and example of a direction or approval kind taken out. */
231
+ export function withoutDirection(person) {
232
+ const keep = (record) => Object.fromEntries(Object.entries(record).filter(([kind]) => !DIRECTION_KINDS.has(kind)));
233
+ const windows = Object.fromEntries(Object.entries(person.windows).map(([window, profile]) => [window, { ...profile, counts: keep(profile.counts) }]));
234
+ return { ...person, windows, examples: keep(person.examples) };
235
+ }
236
+ /** Flattens an observed org into derived rows. Pure. Role, direction and disagreement rows only with `roles`. */
237
+ export function derivedRows(org, options = {}) {
238
+ if (options.roles === true)
239
+ return allDerivedRows(org);
240
+ // Without roles the activity rows carry no direction or approval counts and cite no such example.
241
+ return allDerivedRows({ ...org, people: org.people.map(withoutDirection) }).filter((row) => !ROLE_ROW_KINDS.has(row.kind));
242
+ }
243
+ function allDerivedRows(org) {
218
244
  const { asOf, audience } = org.meta;
219
245
  const rows = [];
220
246
  const base = { learned: asOf, inferred: true, basis: "behavior", audience };
@@ -285,15 +311,15 @@ export function derivedDir(graphRoot, audience) {
285
311
  * Like every writer it first claims the folder for the company, and refuses a
286
312
  * folder that belongs to another company or an observed org built for another one.
287
313
  */
288
- export function writeObservedOrg(context, org) {
314
+ export function writeObservedOrg(context, org, options = {}) {
289
315
  if (org.meta.company !== context.company)
290
316
  throw new Error(`ontology graph: an observed org built for ${org.meta.company} cannot be stored in the graph of ${context.company}`);
291
317
  claimGraphRootFor(context.graphRoot, context.company, context.companyRoot);
292
318
  const dir = derivedDir(context.graphRoot, org.meta.audience);
293
319
  fs.mkdirSync(dir, { recursive: true });
294
- const rows = derivedRows(org);
320
+ const rows = derivedRows(org, options);
295
321
  const changedRows = atomicWriteFile(path.join(dir, "rows.jsonl"), rows.map((row) => JSON.stringify(row)).join("\n") + (rows.length > 0 ? "\n" : ""));
296
- const changedOrg = atomicWriteFile(path.join(dir, "observed.json"), `${JSON.stringify(org, null, 1)}\n`);
322
+ const changedOrg = atomicWriteFile(path.join(dir, "observed.json"), `${JSON.stringify(options.roles === true ? org : activityOnly(org), null, 1)}\n`);
297
323
  return { dir, rows: rows.length, changed: changedRows || changedOrg };
298
324
  }
299
325
  /** The derived rows a reader may see: the company folder, and the member's folder only when the reader is that member. */
@@ -349,7 +375,7 @@ export function collaboratorsOf(org, ref, limit = 3) {
349
375
  .map((edge) => `${nameIn(org, edge.a === ref ? edge.b : edge.a)} (${edge.score})`);
350
376
  }
351
377
  export function renderHeader(org) {
352
- const out = [`Observed org (${org.meta.company}), ${org.meta.view} view, as of ${org.meta.asOf}. Inferred from behavior; filed under audience ${org.meta.audience}.`, ""];
378
+ const out = [`Observed activity (${org.meta.company}), ${org.meta.view} view, as of ${org.meta.asOf}. Inferred from behavior; filed under audience ${org.meta.audience}.`, ""];
353
379
  for (const note of org.meta.honesty)
354
380
  out.push(`- ${note}`);
355
381
  out.push("", "Known limits of this derivation. Every line below is inferred and can be wrong in these ways:");
@@ -370,9 +396,47 @@ export function renderObservedTable(org) {
370
396
  }
371
397
  return out;
372
398
  }
373
- export function renderObserved(org) {
399
+ const WORK_KINDS = [
400
+ ["commits", "commits"],
401
+ ["decisions", "decisions"],
402
+ ["action_items", "action items"],
403
+ ["commitments", "commitments"],
404
+ ["meetings_attended", "meetings"],
405
+ ["meetings_led", "meetings led"],
406
+ ["external_meetings", "outside calls"],
407
+ ["threads_started", "threads started"],
408
+ ];
409
+ /** The kinds of work seen for a person in one window, each with its count. */
410
+ export function workLine(person, window = "90d") {
411
+ const counts = person.windows[window].counts;
412
+ const parts = WORK_KINDS.filter(([kind]) => counts[kind] > 0).map(([kind, label]) => `${label} ${counts[kind]}`);
413
+ return parts.length > 0 ? `seen in the rows: ${parts.join("; ")}` : "nothing seen";
414
+ }
415
+ export function shipsLine(person, window = "90d") {
416
+ const repos = person.windows[window].repos.slice(0, 4);
417
+ return repos.length > 0 ? repos.map((item) => `${item.name} (${item.count} commits)`).join(", ") : "-";
418
+ }
419
+ export function ownsLine(org, ref) {
420
+ const owned = org.owners.filter((owner) => owner.owner === ref).slice(0, 4);
421
+ return owned.length > 0 ? owned.map((owner) => `appears to own ${owner.subjectName} (${owner.events} events, confidence ${owner.conf.toFixed(2)})`).join(", ") : "-";
422
+ }
423
+ /** The default table: what each person does. No role line and no direction between people. */
424
+ export function renderActivityTable(org) {
425
+ const out = [
426
+ "| Person | Work, last 90 days (counts) | Main areas | Ships to (90d) | Owns (inferred) | Works most with (score) | Change over time | Evidence (90d / 365d / all) |",
427
+ "| --- | --- | --- | --- | --- | --- | --- | --- |",
428
+ ];
429
+ for (const person of org.people) {
430
+ const tag = person.actsInternal ? (person.maybe.length > 0 ? ` (not on roster; may be ${person.maybe.map((ref) => nameIn(org, ref)).join(" or ")})` : " (not on roster)") : person.isMember ? " (this member)" : "";
431
+ out.push(`| ${cell(person.name)}${tag} | ${cell(workLine(person))} | ${cell(areasLine(person))} | ${cell(shipsLine(person))} | ${cell(ownsLine(org, person.ref))} | ${cell(collaboratorsOf(org, person.ref).join(", ") || "-")} | ${cell(person.role.change?.text ?? "-")} | ${Math.round(person.windows["90d"].evidence)} / ${Math.round(person.windows["365d"].evidence)} / ${Math.round(person.windows.all.evidence)} |`);
432
+ }
433
+ return out;
434
+ }
435
+ export const ROLES_LEFT_OUT = "Role lines, direction between people and the stated-versus-observed comparison are left out. Add --roles to see the first two, or --compare for the comparison.";
436
+ export function renderObserved(org, options = {}) {
437
+ const roles = options.roles === true;
374
438
  const out = renderHeader(org);
375
- out.push(...renderObservedTable(org), "");
439
+ out.push(...(roles ? renderObservedTable(org) : renderActivityTable(org)), "");
376
440
  out.push("Working groups (clusters of who works with whom, named by what they work on):");
377
441
  for (const group of org.groups)
378
442
  out.push(`- ${group.id} ${group.name}: ${group.members.map((ref) => nameIn(org, ref)).join(", ")} (cohesion ${group.cohesion}, confidence ${group.conf.toFixed(2)})`);
@@ -383,14 +447,14 @@ export function renderObserved(org) {
383
447
  for (const bridge of org.bridges)
384
448
  out.push(`- ${nameIn(org, bridge.person)} (${bridge.home}): carries ${bridge.to.map((item) => `${Math.round(item.share * 100)}% of the collaboration between ${bridge.home} and ${item.group}`).join(", ")}`);
385
449
  }
386
- out.push("", "De facto owners, last 90 days, inferred from decisive activity (listed owner beside it):");
450
+ out.push("", `De facto owners, last 90 days, inferred from decisive activity${roles ? " (listed owner beside it)" : ""}:`);
387
451
  for (const owner of org.owners.slice(0, 25)) {
388
452
  const first = owner.candidates[0];
389
453
  const who = owner.verdict === "clear" && first ? `appears to be ${nameIn(org, first.person)} (${Math.round(first.share * 100)}% of decisive activity)` : owner.verdict === "shared" ? "appears shared by " + owner.candidates.slice(0, 2).map((candidate) => `${nameIn(org, candidate.person)} (${Math.round(candidate.share * 100)}%)`).join(" and ") : `no clear owner (most active: ${owner.candidates.slice(0, 2).map((candidate) => `${nameIn(org, candidate.person)} ${Math.round(candidate.share * 100)}%`).join(", ")})`;
390
454
  const listed = owner.listed.length > 0 ? owner.listed.map((claim) => claim.value).join(", ") : "none listed";
391
- out.push(`- ${owner.subjectName} [${owner.kind}]: ${who}; listed: ${listed}${owner.agrees === false ? " (disagrees)" : ""}; ${owner.events} events, confidence ${owner.conf.toFixed(2)}`);
455
+ out.push(`- ${owner.subjectName} [${owner.kind}]: ${who}${roles ? `; listed: ${listed}${owner.agrees === false ? " (disagrees)" : ""}` : ""}; ${owner.events} events, confidence ${owner.conf.toFixed(2)}`);
392
456
  }
393
- out.push("", `${org.disagreements.length} disagreements between stated and observed. Run \`hq ontology org compare\` to read them.`);
457
+ out.push("", roles ? `${org.disagreements.length} disagreements between stated and observed. Run \`hq ontology activity --compare\` to read them.` : ROLES_LEFT_OUT);
394
458
  return out.join("\n");
395
459
  }
396
460
  export function renderCompare(org, limit = 40) {
@@ -411,7 +475,47 @@ export function renderCompare(org, limit = 40) {
411
475
  out.push("No disagreement found in this view.");
412
476
  return out.join("\n");
413
477
  }
414
- export function renderPerson(org, person) {
478
+ export function renderPerson(org, person, options = {}) {
479
+ return options.roles === true ? renderPersonWithRoles(org, person) : renderPersonActivity(org, person);
480
+ }
481
+ /** One person, by what they do: work by window, what they ship and own, who they work with, change over time. */
482
+ function renderPersonActivity(org, whole) {
483
+ const person = withoutDirection(whole);
484
+ const out = renderHeader(org);
485
+ out.push(`${person.name} (${person.ref})${person.onRoster ? "" : ", not on the roster"}${person.isMember ? ", the member this graph was built for" : ""}`);
486
+ out.push(`Coverage: ${person.coverage.line}`);
487
+ for (const fold of person.folded)
488
+ out.push(`Folded in for this computation: ${fold.ref} (${fold.reason}).`);
489
+ out.push("", `Main areas (inferred from the mix of work): ${areasLine(person)}`);
490
+ out.push("", "Work by window:");
491
+ out.push("| Window | Commits | Decisions | Action items | Commitments | Meetings (led / outside) | Threads | Evidence |", "| --- | --- | --- | --- | --- | --- | --- | --- |");
492
+ for (const window of ["30d", "90d", "365d", "all"]) {
493
+ const c = person.windows[window].counts;
494
+ out.push(`| ${window} | ${c.commits} | ${c.decisions} | ${c.action_items} | ${c.commitments} | ${c.meetings_attended} (${c.meetings_led} / ${c.external_meetings}) | ${c.threads_started} | ${Math.round(person.windows[window].evidence)} |`);
495
+ }
496
+ out.push("", `Change over time: ${person.role.change ? `${person.role.change.text} [${person.role.change.cites.join(", ")}]` : "no change visible between the last 90 days and the nine months before"}`);
497
+ const year = person.windows["365d"];
498
+ if (year.repos.length > 0)
499
+ out.push("", `Ships to (365d): ${year.repos.map((item) => `${item.name} ${item.count}`).join(", ")}`);
500
+ if (year.projects.length > 0)
501
+ out.push(`Projects (365d): ${year.projects.map((item) => `${item.name} ${item.count}`).join(", ")}`);
502
+ if (year.customers.length > 0)
503
+ out.push(`Customers (365d): ${year.customers.map((item) => `${item.name} ${item.count}`).join(", ")}`);
504
+ if (person.isMember && (year.counts.own_sessions > 0 || year.counts.own_tracker > 0))
505
+ out.push(`Own sessions ${year.counts.own_sessions}, own tracker items ${year.counts.own_tracker} (365d): visible only on this machine, never compared with other people.`);
506
+ out.push("", `Owns (inferred): ${ownsLine(org, person.ref) === "-" ? "nothing observed" : ownsLine(org, person.ref)}`);
507
+ out.push(`Works most with: ${collaboratorsOf(org, person.ref, 5).join(", ") || "no one observed"}`);
508
+ const group = org.groups.find((item) => item.members.includes(person.ref));
509
+ if (group)
510
+ out.push(`Working group (inferred): ${group.id} ${group.name}`);
511
+ out.push("", "Examples:");
512
+ for (const [kind, list] of Object.entries(person.examples))
513
+ for (const example of (list ?? []).slice(0, 2))
514
+ out.push(`- ${kind} ${example.date}: ${example.text} (${example.src}; ${classWords(example.cls)})`);
515
+ out.push("", ROLES_LEFT_OUT);
516
+ return out.join("\n");
517
+ }
518
+ function renderPersonWithRoles(org, person) {
415
519
  const out = renderHeader(org);
416
520
  out.push(`${person.name} (${person.ref})${person.onRoster ? "" : ", not on the roster"}${person.isMember ? ", the member this graph was built for" : ""}`);
417
521
  out.push(`Coverage: ${person.coverage.line}`);
@@ -472,9 +576,10 @@ export function renderPerson(org, person) {
472
576
  /** `hq ontology org observed`: compute and print the observed org. Stores the derived rows only when `write` is set. */
473
577
  export async function orgObservedCommand(context, options = {}) {
474
578
  const org = await buildObservedOrg(context, options);
475
- const written = options.write === true ? writeObservedOrg(context, org) : null;
476
- const text = `${renderObserved(org)}\n\n${written ? `Stored ${written.rows} derived rows in ${written.dir}.` : "Nothing was stored. Pass --write to store the derived rows in the graph folder."}`;
477
- return { text, json: { ...org, stored: written } };
579
+ const roles = options.roles === true;
580
+ const written = options.write === true ? writeObservedOrg(context, org, { roles }) : null;
581
+ const text = `${renderObserved(org, { roles })}\n\n${written ? `Stored ${written.rows} derived rows in ${written.dir}.` : "Nothing was stored. Pass --write to store the derived rows in the graph folder."}`;
582
+ return { text, json: { ...(roles ? org : activityOnly(org)), stored: written } };
478
583
  }
479
584
  /** `hq ontology org compare`: stated versus observed. Writes nothing unless `write` is set. */
480
585
  export async function orgCompareCommand(context, options = {}) {
@@ -486,8 +591,9 @@ export async function orgCompareCommand(context, options = {}) {
486
591
  /** `hq ontology org person <name>`: one person. Writes nothing unless `write` is set. */
487
592
  export async function orgPersonCommand(context, options) {
488
593
  const org = await buildObservedOrg(context, options);
594
+ const roles = options.roles === true;
489
595
  if (options.write === true)
490
- writeObservedOrg(context, org);
596
+ writeObservedOrg(context, org, { roles });
491
597
  const wanted = normalizeName(options.name);
492
598
  const exact = org.people.filter((person) => normalizeName(person.name) === wanted || person.ref === options.name || person.ref === `person/${options.name}`);
493
599
  const loose = exact.length > 0 ? exact : org.people.filter((person) => normalizeName(person.name).split(" ").includes(wanted) || normalizeName(person.name).includes(wanted));
@@ -498,8 +604,19 @@ export async function orgPersonCommand(context, options) {
498
604
  return { text: `"${options.name}" matches ${loose.length} people: ${loose.map((person) => `${person.name} (${person.ref})`).join(", ")}. Name one.`, json: { meta: org.meta, matches: loose.map((person) => person.ref) }, exitCode: 1 };
499
605
  }
500
606
  const person = loose[0];
607
+ if (!roles) {
608
+ return {
609
+ text: renderPerson(org, person),
610
+ json: {
611
+ meta: org.meta,
612
+ person: activityOnly({ ...org, people: [person] }).people[0],
613
+ collaboration: org.collaboration.filter((edge) => edge.a === person.ref || edge.b === person.ref).slice(0, 10),
614
+ owns: activityOnly(org).owners.filter((owner) => owner.owner === person.ref),
615
+ },
616
+ };
617
+ }
501
618
  return {
502
- text: renderPerson(org, person),
619
+ text: renderPerson(org, person, { roles: true }),
503
620
  json: {
504
621
  meta: org.meta,
505
622
  person,
@@ -22,6 +22,8 @@ export interface NamedPerson {
22
22
  onRoster: boolean;
23
23
  }
24
24
  /** Finds people named in a line. Built once per graph. */
25
+ /** Labels a transcript uses when it does not know who spoke. Never a person. */
26
+ export declare const PLACEHOLDER_SPEAKERS: ReadonlySet<string>;
25
27
  export declare class NameIndex {
26
28
  private readonly entries;
27
29
  private readonly rosterFirst;
@@ -27,6 +27,8 @@ function escapeRegExp(text) {
27
27
  return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
28
28
  }
29
29
  /** Finds people named in a line. Built once per graph. */
30
+ /** Labels a transcript uses when it does not know who spoke. Never a person. */
31
+ export const PLACEHOLDER_SPEAKERS = new Set(["host", "speaker", "unknown", "participant", "guest", "attendee", "organizer", "presenter", "moderator"]);
30
32
  export class NameIndex {
31
33
  entries = new Map();
32
34
  rosterFirst = new Map();
@@ -69,6 +71,10 @@ export class NameIndex {
69
71
  const candidate = normalizeName(raw.replace(/(?:'s|’s)?[:,.]?$/, ""));
70
72
  if (candidate.length < 3)
71
73
  continue;
74
+ // A speaker label a transcript puts where a name should be is nobody, even when
75
+ // an entity carries it as an alias: the row is left unattributed.
76
+ if (take === 1 && PLACEHOLDER_SPEAKERS.has(candidate))
77
+ return null;
72
78
  const ref = this.match(candidate, filedOn);
73
79
  if (ref) {
74
80
  const consumed = new RegExp(`^(?:\\S+\\s+){${take - 1}}\\S+`).exec(stripped);
@@ -431,6 +431,11 @@ export interface OrgOptions {
431
431
  asOf?: IsoDate;
432
432
  /** Phrase each active person's role with one small model call. Default false. */
433
433
  model?: boolean;
434
+ /**
435
+ * Also show role lines, who appears to direct whom and stated claims. Default false:
436
+ * the output is about what people do, not about roles or reporting lines.
437
+ */
438
+ roles?: boolean;
434
439
  /** Write the derived rows. Default false: every command only prints unless this is set. */
435
440
  write?: boolean;
436
441
  /** Fold name variants of a roster member into that member. Default true. */
@@ -77,6 +77,8 @@ export interface PageModel {
77
77
  };
78
78
  /** Open legacy reference edges (`related_to`, `mentions`) left off the page. */
79
79
  hiddenEdges: number;
80
+ /** Open role and affiliation facts, and hierarchy relationships, a model wrote under the confidence line, left off the page. */
81
+ leftOutGuesses: number;
80
82
  /** Closed F and E rows, hidden unless `showClosed`. */
81
83
  closedHidden: number;
82
84
  conflicts: PageConflict[];
@@ -17,7 +17,7 @@
17
17
  * mixes rows of two audiences.
18
18
  */
19
19
  import yaml from "js-yaml";
20
- import { effectiveFacts, escapeText, formatConf, isOpen, isSingleValued, originTier } from "../schema/index.js";
20
+ import { dropUnverifiedGuesses, effectiveFacts, escapeText, formatConf, isOpen, isSingleValued, originTier } from "../schema/index.js";
21
21
  import { sha256Hex } from "../model/files.js";
22
22
  export const DEFAULT_PAGE_LIMITS = {
23
23
  edgesPerVerb: 25, timeline: 30, summarySentences: 6, recentDays: 30, decisions: 12, commitments: 12, showClosed: false,
@@ -145,7 +145,12 @@ export function buildPageModel(schema, entity, storedRows, nameOf, limits = DEFA
145
145
  if (!known || audienceRank(stored.audience) < audienceRank(known.audience))
146
146
  unique.set(stored.id, stored);
147
147
  }
148
- const rows = [...unique.values()];
148
+ // An open role or affiliation a model wrote at low confidence is left off the page before any winner or
149
+ // conflict is worked out, and counted in the frontmatter. Row counts still count every row. So is a
150
+ // model's low-confidence manager, report, team or lead. Employer relationships stay: a customer's
151
+ // contact list is built from model-written `employs` rows, and each line names who wrote it.
152
+ const everyRow = [...unique.values()];
153
+ const { rows, leftOut: leftOutGuesses } = dropUnverifiedGuesses(everyRow, { edges: "hierarchy" });
149
154
  const audiences = [...new Set(storedRows.map((stored) => stored.audience))].sort();
150
155
  const type = entity.type;
151
156
  const name = entity.canonical_name;
@@ -477,11 +482,12 @@ export function buildPageModel(schema, entity, storedRows, nameOf, limits = DEFA
477
482
  timelineTotal: allEntries.length,
478
483
  signals: timelineRows.length,
479
484
  counts: {
480
- facts: rows.filter((stored) => stored.row.kind === "F").length,
481
- edges: rows.filter((stored) => stored.row.kind === "E").length,
485
+ facts: everyRow.filter((stored) => stored.row.kind === "F").length,
486
+ edges: everyRow.filter((stored) => stored.row.kind === "E").length,
482
487
  timeline: timelineRows.length,
483
488
  },
484
489
  hiddenEdges,
490
+ leftOutGuesses,
485
491
  closedHidden: limits.showClosed ? 0 : closedRows.length,
486
492
  conflicts,
487
493
  rulesSummary: summary,
@@ -655,6 +661,7 @@ export function renderPage(model, nameOf, summary, state = "rules") {
655
661
  summary_by: summary ? summary.by : "rules",
656
662
  ...(summary ? {} : state === "rules" ? {} : { model_summary: state }),
657
663
  ...(model.hiddenEdges > 0 ? { hidden_legacy_reference_edges: model.hiddenEdges } : {}),
664
+ ...(model.leftOutGuesses > 0 ? { unconfirmed_model_guesses_left_out: model.leftOutGuesses } : {}),
658
665
  ...(model.closedHidden > 0 ? { closed_rows_hidden: model.closedHidden } : {}),
659
666
  ...(model.conflicts.length > 0 ? { conflicts: model.conflicts.map((conflict) => conflict.key).sort() } : {}),
660
667
  rows_hash: model.rowsHash,
@@ -1,9 +1,15 @@
1
- import { type AudienceKey, type BriefOptions, type CommandOutput, type GraphContext, type GraphStore } from "../types.js";
1
+ import { type AudienceKey, type BriefOptions, type BriefStyle, type CommandOutput, type GraphContext, type GraphStore } from "../types.js";
2
2
  export declare const BRIEF_MAX_TOKENS = 1500;
3
3
  export declare const BRIEF_MAX_PROJECTS = 15;
4
4
  export declare const BRIEF_MAX_CUSTOMERS = 8;
5
5
  export declare const BRIEF_MAX_CHANGES = 12;
6
6
  export declare const BRIEF_WINDOW_DAYS = 7;
7
+ export declare const BRIEF_DEFAULT_STYLE: BriefStyle;
8
+ /** Most names the map lists per kind before the token cap trims further. */
9
+ export declare const MAP_MAX_PROJECTS = 30;
10
+ export declare const MAP_MAX_CUSTOMERS = 15;
11
+ export declare const MAP_MAX_TEAMMATES = 30;
12
+ export declare const MAP_NAME_MAX_CHARS = 60;
7
13
  /**
8
14
  * Upper estimate of the token count. English prose runs near four characters
9
15
  * a token; ids, dates and slugs run shorter, so three is used.
@@ -18,9 +24,13 @@ export interface BriefExtras {
18
24
  store?: GraphStore;
19
25
  /** Token cap. Default `BRIEF_MAX_TOKENS`; a caller may only lower it. */
20
26
  maxTokens?: number;
27
+ /** `map` or `full`. Default: `brief_style` in the reader setting, else `map`. */
28
+ style?: BriefStyle;
21
29
  }
22
- /** Builds the brief text. Pure apart from reads through the store. */
30
+ /** The style a brief is built in: the caller's, else the reader setting's `brief_style`, else `map`. */
31
+ export declare function resolveBriefStyle(hqRoot: string, asked?: BriefStyle): BriefStyle;
32
+ /** Builds the brief text in the asked style. Pure apart from reads through the store. No model call. */
23
33
  export declare function buildBrief(context: GraphContext, extras?: BriefExtras): string;
24
- /** `hq ontology brief`: writes brief.md (1,500 tokens max). */
34
+ /** `hq ontology brief [--style map|full]`: writes brief.md (1,500 tokens max). */
25
35
  export declare function briefCommand(context: GraphContext, options: BriefOptions & BriefExtras): Promise<CommandOutput>;
26
36
  //# sourceMappingURL=brief.d.ts.map