@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
@@ -4,20 +4,22 @@
4
4
  * classes in readers.ts, the rules in extractors.ts.
5
5
  */
6
6
  import { runLint as defaultRunLint } from "../lint/index.js";
7
- import { DEFAULT_ONTOLOGY_MODEL, PASS_TASK_MODELS, createModelStep as defaultCreateModelStep, resolveModel, runModelPass as defaultRunModelPass, } from "../model/index.js";
7
+ import * as path from "node:path";
8
+ import { DEFAULT_ONTOLOGY_MODEL, MODEL_STATE_PATHS, PASS_TASK_MODELS, createModelStep as defaultCreateModelStep, followUpEntities, followUpScope, followUpTask, peekPendingMarkers, resolveModel, resolveModelStateDir, runModelPass as defaultRunModelPass, isHeldMarker, passTasksFor, readModelTasksSetting, } from "../model/index.js";
8
9
  import { OntologyGraphNotImplementedError } from "../not-implemented.js";
9
10
  import { compilePages as defaultCompilePages, summaryItemsFor } from "../pages/index.js";
10
11
  import { briefCommand as defaultBriefCommand } from "../read/index.js";
11
12
  import { graphPath, openGraphStore } from "../store/index.js";
12
13
  import { MemberIdentityRequiredError, } from "../types.js";
13
14
  import { kindReaders, scanCorpus } from "./readers.js";
14
- import { LISTING_MANIFEST_RELATIVE, NO_MODEL_ENV, TRANSCRIPT_CACHE_RELATIVE, formatReport, runRebuildWith, runUpdateWith } from "./engine.js";
15
+ import { LISTING_MANIFEST_RELATIVE, NO_MODEL_ENV, TRANSCRIPT_CACHE_RELATIVE, formatReport, resolveDayBudget, runRebuildWith, runUpdateWith } from "./engine.js";
15
16
  import { allRuleExtractors } from "./extractors.js";
16
17
  import { resolveSignedInMember, withMember } from "./member.js";
17
18
  export { scanCorpus, kindReaders, meetingSlug } from "./readers.js";
18
19
  export { loadReplayConfig, REPLAY_CONFIG_RELATIVE } from "./config.js";
19
20
  export { resolveMemberScope } from "./scope.js";
20
21
  export { DEFAULT_DAY_BUDGET, DayBudgetError, FULL_LISTING_ENV, LISTING_MANIFEST_RELATIVE, NO_MODEL_ENV, PENDING_RELATIVE, TYPING_PROMPT_VERSION, formatReport, modelCapLines, parseTypingReply, resolveDayBudget } from "./engine.js";
22
+ export { revisedFrom, revisedLines } from "./engine.js";
21
23
  export { LISTING_MANIFEST_VERSION, gitHeadCommit, openListingManifest } from "./listing-manifest.js";
22
24
  export { classOf, createExtractTools, registerExtractTools } from "./extractors.js";
23
25
  export { countingResolver, createFallbackResolver, nameCandidates } from "./mentions.js";
@@ -30,6 +32,12 @@ export const PASS_RUN_BUDGET = {
30
32
  /** A rebuild: one full pass over a vault of about 50,000 inputs, with room. Replies already cached cost nothing. */
31
33
  rebuild: { inputTokens: 8_000_000, outputTokens: 4_000_000 },
32
34
  };
35
+ /** Why a follow-up marker its task did not build again is dropped, by task. Said in the run summary with the count. */
36
+ const DROP_REASON = {
37
+ profile: "the entity no longer has recent lines that state a role, employer or stage",
38
+ retype: "the link is no longer an open untyped link with a dated line that names both ends",
39
+ supersede: "the decisions about the topic have changed since, and the new group was asked instead",
40
+ };
33
41
  /** The cap per model per day, whatever the runs: a loop of updates stops here. */
34
42
  const PASS_DAY_BUDGET = { inputTokens: 12_000_000, outputTokens: 6_000_000 };
35
43
  const PASS_CONCURRENCY = 4;
@@ -50,6 +58,12 @@ function passIsOff(options, deps) {
50
58
  * dirty, then the brief. Replies are cached by content beside the graph folder
51
59
  * (`.hq/ontology-graph-model`), which no rebuild touches, so a second run over
52
60
  * unchanged sources makes no call.
61
+ *
62
+ * An update also looks again at the follow-up work an earlier run left pending
63
+ * (profiles, retypes, decisions that replace each other, page summaries,
64
+ * digests), whether or not it found anything new: the pass is scoped to what
65
+ * the run touched and to the entities those markers name. A marker whose item
66
+ * the graph no longer builds is dropped.
53
67
  */
54
68
  async function replayThenPass(command, context, options, deps, run) {
55
69
  if (passIsOff(options, deps))
@@ -62,8 +76,45 @@ async function replayThenPass(command, context, options, deps, run) {
62
76
  const scoped = withMember(context, deps.resolveMember ?? ((ctx) => resolveSignedInMember(ctx, env)));
63
77
  const day = (deps.now ?? (() => new Date()))().toISOString().slice(0, 10);
64
78
  const changed = report.days > 0 || report.totals.rowsAdded > 0 || report.totals.rowsClosed > 0;
65
- // A stopped run is finished by the next one. An update that found nothing new has nothing to send.
66
- if (report.partial || (command === "update" && !changed))
79
+ // A stopped run is finished by the next one.
80
+ if (report.partial)
81
+ return report;
82
+ // Follow-up work an earlier run left pending (profiles, retyped links, decisions, summaries, digests) is sent
83
+ // only when the run asks for it (`--follow-up`): a plain update with nothing new makes no model call, as
84
+ // before. Without the flag the summary says how many items wait. A look at the file decides whether there is
85
+ // anything to count, so a quiet day with nothing pending still costs the listing and nothing else.
86
+ const isUpdate = command === "update";
87
+ const wantFollowUp = isUpdate && options.followUp === true;
88
+ const pendingFile = path.join(resolveModelStateDir(scoped, undefined, env), ...MODEL_STATE_PATHS.pending.replace(/^\.state\//, "").split("/"));
89
+ // `model_tasks` in the company's settings/ontology.yaml. A follow-up marker of a task that is off is held: it is
90
+ // not counted as work to send, not sent and not dropped. The replay's notes say how many are held.
91
+ const modelTasks = deps.modelTasks ?? readModelTasksSetting(context.companyRoot);
92
+ const followUpOf = (markers) => markers.filter((marker) => followUpTask(marker) !== null && !isHeldMarker(marker, modelTasks));
93
+ /** The follow-up markers that are really pending: the file's, less what any model has already answered. */
94
+ const pendingFollowUp = () => {
95
+ if (deps.passStep)
96
+ return followUpOf(deps.passStep.pending());
97
+ if (followUpOf(peekPendingMarkers(pendingFile)).length === 0)
98
+ return [];
99
+ // A step that writes nothing: opening it applies the same cleanup a real run would, in memory.
100
+ return followUpOf(defaultCreateModelStep(scoped, { budget: PASS_DAY_BUDGET, dryRun: true, readOnly: true }).pending());
101
+ };
102
+ const sayPending = (markers) => {
103
+ if (markers.length === 0)
104
+ return;
105
+ const byTask = new Map();
106
+ for (const marker of markers)
107
+ byTask.set(followUpTask(marker), (byTask.get(followUpTask(marker)) ?? 0) + 1);
108
+ report.counters.pass_follow_up_pending = markers.length;
109
+ const detail = [...byTask].sort().map(([task, count]) => `${task} ${String(count)}`).join(", ");
110
+ report.notes.push(`${String(markers.length)} follow-up ${markers.length === 1 ? "item is" : "items are"} pending from earlier runs (${detail}) and ${markers.length === 1 ? "was" : "were"} not sent. To send them within the daily cap: hq ontology update --follow-up`);
111
+ };
112
+ if (isUpdate && !changed && !wantFollowUp) {
113
+ sayPending(pendingFollowUp());
114
+ return report;
115
+ }
116
+ let followUp = new Set();
117
+ if (isUpdate && !changed && pendingFollowUp().length === 0)
67
118
  return report;
68
119
  const dirtyBefore = new Set(openGraphStore(context.graphRoot, { company: context.company }).readDirty());
69
120
  const cap = options.budgetTokens;
@@ -75,9 +126,22 @@ async function replayThenPass(command, context, options, deps, run) {
75
126
  else {
76
127
  const runBudget = left === undefined ? PASS_RUN_BUDGET[command] : { inputTokens: left, outputTokens: Math.ceil(left / 2) };
77
128
  try {
78
- const make = (model) => defaultCreateModelStep(scoped, { budget: PASS_DAY_BUDGET, runBudget, concurrency: PASS_CONCURRENCY, runId: report.run, ...(deps.now ? { now: deps.now } : {}), ...(model ? { model } : {}) });
129
+ // A pass that exists only for follow-up work stays inside the daily cap of the model step (150,000 input
130
+ // tokens a day unless the run raises it), counted from the call ledger with the day's other runs.
131
+ const dayCap = resolveDayBudget(options);
132
+ const budget = isUpdate && !changed ? { inputTokens: dayCap.inputTokens, outputTokens: dayCap.outputTokens } : PASS_DAY_BUDGET;
133
+ const make = (model) => defaultCreateModelStep(scoped, { budget, runBudget, concurrency: PASS_CONCURRENCY, runId: report.run, ...(deps.now ? { now: deps.now } : {}), ...(model ? { model } : {}) });
79
134
  const step = deps.passStep ?? make();
80
135
  passStep = step;
136
+ // Opening the step dropped the markers another model had already answered: the scope is what is left.
137
+ const waiting = isUpdate ? followUpOf(step.pending()) : [];
138
+ if (wantFollowUp)
139
+ followUp = followUpScope(waiting);
140
+ const only = isUpdate ? new Set([...(report.touched ?? []), ...followUp]) : undefined;
141
+ if (only && followUp.size > 0)
142
+ report.counters.pass_follow_up_entities = followUp.size;
143
+ // A digest queued while its source was inside the window is still asked when the source has aged past it.
144
+ const keepSources = new Set(wantFollowUp ? waiting.filter((marker) => followUpTask(marker) === "digest").map((marker) => marker.itemKey) : []);
81
145
  let taskSteps = deps.passTaskSteps;
82
146
  if (!taskSteps && !deps.passStep && resolveModel(scoped) === DEFAULT_ONTOLOGY_MODEL) {
83
147
  // The cheapest model was measured wrong too often on these tasks; a member who raised the model keeps theirs.
@@ -92,9 +156,12 @@ async function replayThenPass(command, context, options, deps, run) {
92
156
  const pass = await (deps.runModelPass ?? defaultRunModelPass)(scoped, {
93
157
  step,
94
158
  day,
95
- // An update asks about what it touched; a rebuild about everything.
96
- ...(report.touched ? { only: new Set(report.touched) } : {}),
159
+ // An update asks about what it touched and what an earlier run left pending; a rebuild about everything.
160
+ ...(only ? { only } : {}),
161
+ ...(keepSources.size > 0 ? { keepSources } : {}),
97
162
  ...(taskSteps ? { taskSteps } : {}),
163
+ // `model_tasks` in the company's settings/ontology.yaml: a task switched off there is not run by the pass.
164
+ tasks: passTasksFor(modelTasks),
98
165
  summaryItems: (refs) => summaryItemsFor(openGraphStore(context.graphRoot, { company: context.company }), refs),
99
166
  });
100
167
  const steps = [step, ...Object.values(taskSteps ?? {})].filter((entry, index, all) => all.indexOf(entry) === index);
@@ -113,6 +180,49 @@ async function replayThenPass(command, context, options, deps, run) {
113
180
  report.totals.rowsAdded += task.rowsNew;
114
181
  }
115
182
  report.counters.pass_ms = Math.round(pass.seconds * 1000);
183
+ if (only && wantFollowUp) {
184
+ // A follow-up marker inside the scope whose task ran and did not build its item again. For a profile,
185
+ // a retype or a decision group that means the graph no longer asks the question, and the marker is
186
+ // dropped, counted and named in the summary. A digest is never dropped: its source may only be off
187
+ // this machine for now. Page summaries are left to the page compiler, which sends its own.
188
+ const ran = new Set(pass.tasks.map((task) => task.task));
189
+ const seen = new Set();
190
+ for (const entry of steps)
191
+ for (const id of entry.seenItems())
192
+ seen.add(id);
193
+ const notBuilt = step.pending().filter((marker) => {
194
+ const task = followUpTask(marker);
195
+ if (!task || task === "summaries" || !ran.has(task) || seen.has(marker.id))
196
+ return false;
197
+ const refs = followUpEntities(marker);
198
+ return refs.length > 0 && refs.every((ref) => only.has(ref));
199
+ });
200
+ const dropped = new Map();
201
+ let keptDigests = 0;
202
+ for (const marker of notBuilt) {
203
+ const task = followUpTask(marker);
204
+ if (task === "digest")
205
+ keptDigests += 1;
206
+ else
207
+ dropped.set(task, [...(dropped.get(task) ?? []), marker]);
208
+ }
209
+ for (const [task, markers] of [...dropped].sort()) {
210
+ const count = step.dropPending(markers.map((marker) => marker.id));
211
+ report.counters[`pass_pending_dropped_${task}`] = count;
212
+ report.notes.push(`Dropped ${String(count)} pending ${task} ${count === 1 ? "item" : "items"}: ${DROP_REASON[task] ?? "the graph no longer builds the item"}.`);
213
+ }
214
+ if (keptDigests > 0) {
215
+ report.counters.pass_pending_digests_not_built = keptDigests;
216
+ report.notes.push(`${String(keptDigests)} pending ${keptDigests === 1 ? "digest was" : "digests were"} not built this run (the source file is not on this machine, or a signal covers the source now): kept pending, not dropped.`);
217
+ }
218
+ if (!changed) {
219
+ const sent = pass.tasks.reduce((sum, task) => sum + task.stats.calls, 0);
220
+ report.notes.push(`Nothing new; follow-up work from earlier runs was looked at again on ${String(followUp.size)} ${followUp.size === 1 ? "entity" : "entities"} (${String(sent)} model ${sent === 1 ? "call" : "calls"}).`);
221
+ }
222
+ }
223
+ else if (isUpdate) {
224
+ sayPending(followUpOf(step.pending()));
225
+ }
116
226
  if (halted)
117
227
  report.notes.push(`Model pass stopped (${halted}): what was not sent is left pending for the next run.`);
118
228
  }
@@ -123,6 +233,8 @@ async function replayThenPass(command, context, options, deps, run) {
123
233
  }
124
234
  }
125
235
  // What the pass changed joins what the replay changed, so the closing lint of an update sees both.
236
+ if (command === "update" && !report.touched)
237
+ report.touched = [];
126
238
  if (report.touched) {
127
239
  const byPass = openGraphStore(context.graphRoot, { company: context.company }).readDirty().filter((ref) => !dirtyBefore.has(ref));
128
240
  report.touched = [...new Set([...report.touched, ...byPass])].sort();
@@ -130,7 +242,7 @@ async function replayThenPass(command, context, options, deps, run) {
130
242
  if (compiler) {
131
243
  const started = Date.now();
132
244
  // A store opened now: the pass wrote through its own, and a store keeps what it has read.
133
- const compiled = await compiler(scoped, { store: openGraphStore(context.graphRoot, { company: context.company }), day, ...(passStep ? { model: passStep } : {}) });
245
+ const compiled = await compiler(scoped, { store: openGraphStore(context.graphRoot, { company: context.company }), day, ...(passStep && modelTasks.summaries ? { model: passStep } : {}) });
134
246
  report.counters.pages_compiled = (report.counters.pages_compiled ?? 0) + compiled.compiled;
135
247
  report.counters.pages_compile_ms = (report.counters.pages_compile_ms ?? 0) + (Date.now() - started);
136
248
  }
@@ -0,0 +1,118 @@
1
+ import { type AudienceKey, type EntityRef, type GraphStore, type IsoDate, type Origin, type SourceRef } from "../types.js";
2
+ export declare const SIGNAL_CHANGES_RULE: Origin;
3
+ /**
4
+ * Lower than the 0.90 a rule that copies a field from a record gets. The entry
5
+ * the rule applies was written by a model that read a document, and the quote
6
+ * check proves the words are in the source, not that they mean what the model
7
+ * took them to mean. Readers show the origin as `from a signal quote`.
8
+ */
9
+ export declare const SIGNAL_CHANGES_CONFIDENCE = 0.75;
10
+ /** Where the engine keeps every entry it has collected, inside the graph folder. */
11
+ export declare const SIGNAL_CHANGES_STATE_RELATIVE: string;
12
+ /** Kinds the rule acts on, and the status each gives the earlier decision. */
13
+ export declare const CHANGE_STATUS: Readonly<Record<string, string>>;
14
+ /** One `changes` entry of a signal, as the extractor collected it. */
15
+ export interface PendingSignalChange {
16
+ /** The signal that states the change: `signal:<12 hex>`. */
17
+ src: SourceRef;
18
+ day: IsoDate;
19
+ /** `written_at` of the signal when its file carries one, else empty. Orders two signals of one day. */
20
+ time?: string;
21
+ audience: AudienceKey;
22
+ /** The decision the signal itself produced, or null when the signal is not a decision. */
23
+ decision: EntityRef | null;
24
+ /** 64-hex id of the earlier signal. */
25
+ target: string;
26
+ targetType: string;
27
+ kind: string;
28
+ /** Set when the signal was replayed again and no longer states this entry. Its rows are closed. */
29
+ retracted?: boolean;
30
+ }
31
+ export interface SignalChangesResult {
32
+ /** `supersedes` edges written (one per pair; the inverse is not counted). */
33
+ links: number;
34
+ /** Status rows closed on earlier decisions. */
35
+ statusClosed: number;
36
+ /** Status rows written on earlier decisions. */
37
+ statusWritten: number;
38
+ /**
39
+ * Earlier decisions this call gave a status, by value (`superseded`, `reversed`, `withdrawn`). A decision is counted
40
+ * once however many audience folders hold the row, and not at all when the rule's open status of that value was
41
+ * already on it.
42
+ */
43
+ statusBy: Record<string, number>;
44
+ /** Model-written edges that pointed the other way and were closed. */
45
+ modelLinksClosed: number;
46
+ /** Model-written edges that point the other way from another audience: left as they are. */
47
+ modelLinksOtherAudience: number;
48
+ /** Rows taken out because the signal that stated them no longer does. */
49
+ rowsRemoved: number;
50
+ rowsAdded: number;
51
+ rowsClosed: number;
52
+ /** Entries left alone, by reason, over the whole set. */
53
+ skipped: Record<string, number>;
54
+ /** The reason each entry was left alone, by `signalChangeKey`. An entry that applies is absent. */
55
+ reasons: Map<string, string>;
56
+ /** Keys of entries whose edge was written and whose status was not: an older status of a person or a record stands. */
57
+ statusHeld: Set<string>;
58
+ touched: EntityRef[];
59
+ }
60
+ /** The `changes` list of a signal's frontmatter, with anything malformed left out. */
61
+ export declare function signalChangesOf(frontmatter: Record<string, unknown>): {
62
+ target: string;
63
+ targetType: string;
64
+ kind: string;
65
+ }[];
66
+ /** The time a signal file says it was written, as text that sorts in time order, or empty. */
67
+ export declare function signalTimeOf(frontmatter: Record<string, unknown>): string;
68
+ /** One entry of the set: a signal states one kind of change to one target in one audience. */
69
+ export declare function signalChangeKey(change: Pick<PendingSignalChange, "audience" | "src" | "target" | "targetType" | "kind">): string;
70
+ /** The order entries are applied in: day, then signal time, then signal id. Never the order they were read in. */
71
+ export declare function compareSignalChanges(a: PendingSignalChange, b: PendingSignalChange): number;
72
+ /**
73
+ * The set after a day's signals were replayed. `replayed` names every signal
74
+ * of the day (`<audience>|<src>`), with or without entries: an entry the set
75
+ * holds for one of them that the signal no longer states is marked retracted,
76
+ * so its rows are closed rather than left open with nothing behind them.
77
+ */
78
+ export declare function mergeSignalChanges(known: readonly PendingSignalChange[], replayed: ReadonlySet<string>, stated: readonly PendingSignalChange[]): PendingSignalChange[];
79
+ /** The version of the state file this code reads and writes. */
80
+ export declare const SIGNAL_CHANGES_STATE_VERSION = 1;
81
+ /** The entry when every field is what the rule can apply, else null. Nothing else reaches a row. */
82
+ export declare function validSignalChange(entry: unknown): PendingSignalChange | null;
83
+ /** What the state file holds, and whether it could be used. */
84
+ export interface SignalChangesState {
85
+ changes: PendingSignalChange[];
86
+ /** `missing`: no file. `invalid`: the file is there and cannot be used; `problem` says why and `changes` is empty. */
87
+ state: "ok" | "missing" | "invalid";
88
+ problem?: string;
89
+ }
90
+ /**
91
+ * Reads the entries kept in the graph folder. Never throws. A file that is not
92
+ * JSON, has another version, or holds one entry the rule could not apply is
93
+ * `invalid` as a whole: a set with a hole in it would give other rows than the
94
+ * signals state, so the caller builds the set again from the signal files.
95
+ */
96
+ export declare function loadSignalChangesState(graphRoot: string): SignalChangesState;
97
+ /** The entries kept in the graph folder. No file, or one that cannot be used: none (see `loadSignalChangesState`). */
98
+ export declare function readSignalChangesState(graphRoot: string): PendingSignalChange[];
99
+ /**
100
+ * Writes the set, sorted, so the file is the same for the same set. The write
101
+ * is a temp file renamed over the target (`atomicWriteFile`), so a reader sees
102
+ * the old set or the new one. Writes nothing when the file already says so.
103
+ */
104
+ export declare function writeSignalChangesState(graphRoot: string, changes: readonly PendingSignalChange[]): void;
105
+ /**
106
+ * The decision a signal produced, in one audience: the decision whose slug ends
107
+ * with the first six hex of the signal id and whose statement cites the signal.
108
+ */
109
+ export declare function decisionOfSignal(store: GraphStore, audience: AudienceKey, src: SourceRef, decisions?: readonly EntityRef[]): EntityRef | null;
110
+ /**
111
+ * Brings the rule's rows in line with the whole set of entries. The result
112
+ * does not depend on the order of `changes` or on what an earlier call wrote:
113
+ * applying the same set again writes nothing. `learned` on a row is its
114
+ * entry's day, so the bytes do not depend on the day of the run; the third
115
+ * argument is accepted for callers of the earlier signature and is not used.
116
+ */
117
+ export declare function applySignalChanges(store: GraphStore, changes: readonly PendingSignalChange[], _learned?: IsoDate): SignalChangesResult;
118
+ //# sourceMappingURL=signal-changes.d.ts.map