@indigoai-us/hq-cli 5.345.246 → 5.345.248

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 (256) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/assets/lanes-hooks/hq-lanes-drain.sh +1 -1
  3. package/contracts/host-canary-release.json +14 -0
  4. package/dist/command-catalog.generated.d.ts +1116 -3
  5. package/dist/command-catalog.generated.js +1373 -3
  6. package/dist/command-registration-plan.d.ts +6 -0
  7. package/dist/command-registration-plan.js +1 -0
  8. package/dist/commands/install-global.d.ts +15 -0
  9. package/dist/commands/install-global.js +98 -4
  10. package/dist/commands/lanes-hold.js +7 -7
  11. package/dist/commands/lanes-resume.js +2 -2
  12. package/dist/commands/lanes-review.js +1 -1
  13. package/dist/commands/lanes-session-start.d.ts +1 -1
  14. package/dist/commands/lanes-session-start.js +3 -3
  15. package/dist/commands/lanes-shared.d.ts +1 -1
  16. package/dist/commands/lanes.d.ts +2 -2
  17. package/dist/commands/lanes.js +50 -50
  18. package/dist/commands/mcp-registration.d.ts +17 -0
  19. package/dist/commands/mcp-registration.js +119 -0
  20. package/dist/commands/mesh.d.ts +25 -0
  21. package/dist/commands/mesh.js +48 -8
  22. package/dist/commands/ontology-graph.d.ts +62 -0
  23. package/dist/commands/ontology-graph.js +439 -0
  24. package/dist/commands/pkg-install.js +1 -1
  25. package/dist/commands/reindex.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/lanes-monitor-check-argv.d.ts +1 -1
  28. package/dist/lanes-monitor-check-argv.js +1 -1
  29. package/dist/lanes-monitor-check-fast.d.ts +1 -1
  30. package/dist/lanes-monitor-check-fast.js +1 -1
  31. package/dist/lanes-session-start-argv.d.ts +1 -1
  32. package/dist/lanes-session-start-argv.js +1 -1
  33. package/dist/lib/capacity/sign-in.d.ts +1 -1
  34. package/dist/lib/capacity/sign-in.js +1 -1
  35. package/dist/lib/daemon/hook-requests-conduct-link.js +2 -2
  36. package/dist/lib/daemon/lanes-monitor-state.d.ts +2 -2
  37. package/dist/lib/daemon/lanes-monitor-state.js +2 -2
  38. package/dist/lib/daemon/merge-sections.d.ts +3 -3
  39. package/dist/lib/daemon/merge-sections.js +7 -7
  40. package/dist/lib/daemon/remote-control-pools.js +1 -1
  41. package/dist/lib/daemon/run.js +1 -1
  42. package/dist/lib/daemon/state-file.d.ts +1 -1
  43. package/dist/lib/daemon/state-file.js +1 -1
  44. package/dist/lib/doctor/checks/antigravity-wiring.d.ts +21 -0
  45. package/dist/lib/doctor/checks/antigravity-wiring.js +75 -0
  46. package/dist/lib/doctor/checks/anywhere.js +30 -0
  47. package/dist/lib/doctor/checks/runtime-probe.js +13 -0
  48. package/dist/lib/doctor/platform.d.ts +1 -1
  49. package/dist/lib/doctor/platform.js +5 -0
  50. package/dist/lib/doctor/registry.js +3 -0
  51. package/dist/lib/flag-snapshot-file.d.ts +2 -0
  52. package/dist/lib/flag-snapshot-file.js +118 -48
  53. package/dist/lib/hook-engine/canary-gate.d.ts +57 -3
  54. package/dist/lib/hook-engine/canary-gate.js +138 -6
  55. package/dist/lib/hook-engine/coverage.d.ts +91 -0
  56. package/dist/lib/hook-engine/coverage.js +184 -0
  57. package/dist/lib/hot-channels/graph-context.d.ts +105 -0
  58. package/dist/lib/hot-channels/graph-context.js +377 -0
  59. package/dist/lib/hot-channels/signals-pass.js +27 -1
  60. package/dist/lib/install/antigravity-targets.d.ts +39 -0
  61. package/dist/lib/install/antigravity-targets.js +122 -0
  62. package/dist/lib/lanes/claude-credential.d.ts +1 -1
  63. package/dist/lib/lanes/claude-credential.js +1 -1
  64. package/dist/lib/lanes/delivery-core.d.ts +1 -1
  65. package/dist/lib/lanes/delivery-core.js +1 -1
  66. package/dist/lib/lanes/delivery.d.ts +10 -10
  67. package/dist/lib/lanes/delivery.js +8 -8
  68. package/dist/lib/lanes/dropbox.d.ts +1 -1
  69. package/dist/lib/lanes/dropbox.js +1 -1
  70. package/dist/lib/lanes/hooks-install.js +2 -2
  71. package/dist/lib/lanes/index.d.ts +1 -1
  72. package/dist/lib/lanes/index.js +1 -1
  73. package/dist/lib/lanes/monitor.js +1 -1
  74. package/dist/lib/lanes/quota-notice.js +1 -1
  75. package/dist/lib/lanes/quota.d.ts +1 -1
  76. package/dist/lib/lanes/quota.js +1 -1
  77. package/dist/lib/lanes/repo-merge-hold.d.ts +2 -2
  78. package/dist/lib/lanes/repo-merge-hold.js +2 -2
  79. package/dist/lib/lanes/spawn.d.ts +4 -4
  80. package/dist/lib/lanes/spawn.js +5 -5
  81. package/dist/lib/mesh/live/company-flag-refresh.d.ts +61 -0
  82. package/dist/lib/mesh/live/company-flag-refresh.js +159 -0
  83. package/dist/lib/mesh/live/company-reporting-gaps.d.ts +61 -0
  84. package/dist/lib/mesh/live/company-reporting-gaps.js +238 -0
  85. package/dist/lib/mesh/live/daemon/duplicate-unit.d.ts +156 -0
  86. package/dist/lib/mesh/live/daemon/duplicate-unit.js +616 -0
  87. package/dist/lib/mesh/live/daemon/run.d.ts +13 -0
  88. package/dist/lib/mesh/live/daemon/run.js +35 -2
  89. package/dist/lib/mesh/live/direct-drain.js +1 -1
  90. package/dist/lib/mesh/live/emit.d.ts +3 -0
  91. package/dist/lib/mesh/live/emit.js +32 -9
  92. package/dist/lib/mesh/live/flush.d.ts +3 -0
  93. package/dist/lib/mesh/live/flush.js +115 -32
  94. package/dist/lib/mesh/live/liveness-carry.d.ts +1 -1
  95. package/dist/lib/mesh/live/liveness-carry.js +1 -1
  96. package/dist/lib/mesh/live/reporting-privacy.d.ts +119 -3
  97. package/dist/lib/mesh/live/reporting-privacy.js +235 -11
  98. package/dist/lib/mesh/live/spool.d.ts +17 -2
  99. package/dist/lib/mesh/live/spool.js +22 -6
  100. package/dist/lib/ontology-graph/legacy/coverage.d.ts +67 -0
  101. package/dist/lib/ontology-graph/legacy/coverage.js +192 -0
  102. package/dist/lib/ontology-graph/legacy/index.d.ts +199 -0
  103. package/dist/lib/ontology-graph/legacy/index.js +1150 -0
  104. package/dist/lib/ontology-graph/legacy/parse.d.ts +49 -0
  105. package/dist/lib/ontology-graph/legacy/parse.js +126 -0
  106. package/dist/lib/ontology-graph/legacy/report.d.ts +14 -0
  107. package/dist/lib/ontology-graph/legacy/report.js +254 -0
  108. package/dist/lib/ontology-graph/legacy/verb-map.d.ts +35 -0
  109. package/dist/lib/ontology-graph/legacy/verb-map.js +84 -0
  110. package/dist/lib/ontology-graph/lint/checks.d.ts +140 -0
  111. package/dist/lib/ontology-graph/lint/checks.js +717 -0
  112. package/dist/lib/ontology-graph/lint/coverage.d.ts +106 -0
  113. package/dist/lib/ontology-graph/lint/coverage.js +241 -0
  114. package/dist/lib/ontology-graph/lint/daily-job.d.ts +259 -0
  115. package/dist/lib/ontology-graph/lint/daily-job.js +595 -0
  116. package/dist/lib/ontology-graph/lint/index.d.ts +65 -0
  117. package/dist/lib/ontology-graph/lint/index.js +176 -0
  118. package/dist/lib/ontology-graph/model/files.d.ts +20 -0
  119. package/dist/lib/ontology-graph/model/files.js +89 -0
  120. package/dist/lib/ontology-graph/model/index.d.ts +65 -0
  121. package/dist/lib/ontology-graph/model/index.js +100 -0
  122. package/dist/lib/ontology-graph/model/pass-tasks.d.ts +156 -0
  123. package/dist/lib/ontology-graph/model/pass-tasks.js +345 -0
  124. package/dist/lib/ontology-graph/model/pass.d.ts +109 -0
  125. package/dist/lib/ontology-graph/model/pass.js +958 -0
  126. package/dist/lib/ontology-graph/model/runner.d.ts +50 -0
  127. package/dist/lib/ontology-graph/model/runner.js +160 -0
  128. package/dist/lib/ontology-graph/model/step.d.ts +195 -0
  129. package/dist/lib/ontology-graph/model/step.js +523 -0
  130. package/dist/lib/ontology-graph/model/tasks.d.ts +183 -0
  131. package/dist/lib/ontology-graph/model/tasks.js +349 -0
  132. package/dist/lib/ontology-graph/not-implemented.d.ts +5 -0
  133. package/dist/lib/ontology-graph/not-implemented.js +8 -0
  134. package/dist/lib/ontology-graph/org/compare.d.ts +28 -0
  135. package/dist/lib/ontology-graph/org/compare.js +239 -0
  136. package/dist/lib/ontology-graph/org/derive.d.ts +65 -0
  137. package/dist/lib/ontology-graph/org/derive.js +352 -0
  138. package/dist/lib/ontology-graph/org/index.d.ts +73 -0
  139. package/dist/lib/ontology-graph/org/index.js +513 -0
  140. package/dist/lib/ontology-graph/org/load.d.ts +31 -0
  141. package/dist/lib/ontology-graph/org/load.js +476 -0
  142. package/dist/lib/ontology-graph/org/role.d.ts +38 -0
  143. package/dist/lib/ontology-graph/org/role.js +268 -0
  144. package/dist/lib/ontology-graph/org/structure.d.ts +63 -0
  145. package/dist/lib/ontology-graph/org/structure.js +437 -0
  146. package/dist/lib/ontology-graph/org/text.d.ts +95 -0
  147. package/dist/lib/ontology-graph/org/text.js +315 -0
  148. package/dist/lib/ontology-graph/org/types.d.ts +452 -0
  149. package/dist/lib/ontology-graph/org/types.js +80 -0
  150. package/dist/lib/ontology-graph/pages/index.d.ts +64 -0
  151. package/dist/lib/ontology-graph/pages/index.js +193 -0
  152. package/dist/lib/ontology-graph/pages/render.d.ts +142 -0
  153. package/dist/lib/ontology-graph/pages/render.js +682 -0
  154. package/dist/lib/ontology-graph/proposals/apply.d.ts +109 -0
  155. package/dist/lib/ontology-graph/proposals/apply.js +468 -0
  156. package/dist/lib/ontology-graph/proposals/group.d.ts +63 -0
  157. package/dist/lib/ontology-graph/proposals/group.js +232 -0
  158. package/dist/lib/ontology-graph/proposals/index.d.ts +173 -0
  159. package/dist/lib/ontology-graph/proposals/index.js +474 -0
  160. package/dist/lib/ontology-graph/proposals/model.d.ts +162 -0
  161. package/dist/lib/ontology-graph/proposals/model.js +196 -0
  162. package/dist/lib/ontology-graph/proposals/org-chart.d.ts +82 -0
  163. package/dist/lib/ontology-graph/proposals/org-chart.js +340 -0
  164. package/dist/lib/ontology-graph/read/brief.d.ts +26 -0
  165. package/dist/lib/ontology-graph/read/brief.js +251 -0
  166. package/dist/lib/ontology-graph/read/graph-index.d.ts +76 -0
  167. package/dist/lib/ontology-graph/read/graph-index.js +198 -0
  168. package/dist/lib/ontology-graph/read/index.d.ts +59 -0
  169. package/dist/lib/ontology-graph/read/index.js +792 -0
  170. package/dist/lib/ontology-graph/read/member.d.ts +7 -0
  171. package/dist/lib/ontology-graph/read/member.js +34 -0
  172. package/dist/lib/ontology-graph/read/names.d.ts +44 -0
  173. package/dist/lib/ontology-graph/read/names.js +292 -0
  174. package/dist/lib/ontology-graph/read/reader-setting.d.ts +19 -0
  175. package/dist/lib/ontology-graph/read/reader-setting.js +62 -0
  176. package/dist/lib/ontology-graph/read/test-graph.d.ts +37 -0
  177. package/dist/lib/ontology-graph/read/test-graph.js +150 -0
  178. package/dist/lib/ontology-graph/replay/buffered-store.d.ts +33 -0
  179. package/dist/lib/ontology-graph/replay/buffered-store.js +50 -0
  180. package/dist/lib/ontology-graph/replay/config.d.ts +41 -0
  181. package/dist/lib/ontology-graph/replay/config.js +105 -0
  182. package/dist/lib/ontology-graph/replay/engine.d.ts +100 -0
  183. package/dist/lib/ontology-graph/replay/engine.js +1174 -0
  184. package/dist/lib/ontology-graph/replay/extractors.d.ts +59 -0
  185. package/dist/lib/ontology-graph/replay/extractors.js +1555 -0
  186. package/dist/lib/ontology-graph/replay/index.d.ts +90 -0
  187. package/dist/lib/ontology-graph/replay/index.js +220 -0
  188. package/dist/lib/ontology-graph/replay/listing-manifest.d.ts +66 -0
  189. package/dist/lib/ontology-graph/replay/listing-manifest.js +242 -0
  190. package/dist/lib/ontology-graph/replay/member.d.ts +19 -0
  191. package/dist/lib/ontology-graph/replay/member.js +65 -0
  192. package/dist/lib/ontology-graph/replay/mentions.d.ts +58 -0
  193. package/dist/lib/ontology-graph/replay/mentions.js +239 -0
  194. package/dist/lib/ontology-graph/replay/readers.d.ts +98 -0
  195. package/dist/lib/ontology-graph/replay/readers.js +1251 -0
  196. package/dist/lib/ontology-graph/replay/rules.d.ts +127 -0
  197. package/dist/lib/ontology-graph/replay/rules.js +374 -0
  198. package/dist/lib/ontology-graph/replay/scope.d.ts +35 -0
  199. package/dist/lib/ontology-graph/replay/scope.js +115 -0
  200. package/dist/lib/ontology-graph/replay/transcripts.d.ts +39 -0
  201. package/dist/lib/ontology-graph/replay/transcripts.js +224 -0
  202. package/dist/lib/ontology-graph/replay/util.d.ts +55 -0
  203. package/dist/lib/ontology-graph/replay/util.js +256 -0
  204. package/dist/lib/ontology-graph/resolve/entity-index.d.ts +159 -0
  205. package/dist/lib/ontology-graph/resolve/entity-index.js +652 -0
  206. package/dist/lib/ontology-graph/resolve/index.d.ts +113 -0
  207. package/dist/lib/ontology-graph/resolve/index.js +214 -0
  208. package/dist/lib/ontology-graph/resolve/machine.d.ts +34 -0
  209. package/dist/lib/ontology-graph/resolve/machine.js +95 -0
  210. package/dist/lib/ontology-graph/resolve/normalize.d.ts +35 -0
  211. package/dist/lib/ontology-graph/resolve/normalize.js +124 -0
  212. package/dist/lib/ontology-graph/resolve/org-chart.d.ts +107 -0
  213. package/dist/lib/ontology-graph/resolve/org-chart.js +578 -0
  214. package/dist/lib/ontology-graph/resolve/org-layer.d.ts +78 -0
  215. package/dist/lib/ontology-graph/resolve/org-layer.js +159 -0
  216. package/dist/lib/ontology-graph/resolve/org-seed.d.ts +141 -0
  217. package/dist/lib/ontology-graph/resolve/org-seed.js +631 -0
  218. package/dist/lib/ontology-graph/resolve/org-sources.d.ts +165 -0
  219. package/dist/lib/ontology-graph/resolve/org-sources.js +634 -0
  220. package/dist/lib/ontology-graph/resolve/roster.d.ts +76 -0
  221. package/dist/lib/ontology-graph/resolve/roster.js +226 -0
  222. package/dist/lib/ontology-graph/resolve/seed.d.ts +267 -0
  223. package/dist/lib/ontology-graph/resolve/seed.js +1198 -0
  224. package/dist/lib/ontology-graph/resolve/upsert.d.ts +58 -0
  225. package/dist/lib/ontology-graph/resolve/upsert.js +139 -0
  226. package/dist/lib/ontology-graph/resolve/writer.d.ts +128 -0
  227. package/dist/lib/ontology-graph/resolve/writer.js +351 -0
  228. package/dist/lib/ontology-graph/schema/authority.d.ts +73 -0
  229. package/dist/lib/ontology-graph/schema/authority.js +157 -0
  230. package/dist/lib/ontology-graph/schema/default-schema.d.ts +10 -0
  231. package/dist/lib/ontology-graph/schema/default-schema.js +242 -0
  232. package/dist/lib/ontology-graph/schema/grammar.d.ts +57 -0
  233. package/dist/lib/ontology-graph/schema/grammar.js +409 -0
  234. package/dist/lib/ontology-graph/schema/index.d.ts +12 -0
  235. package/dist/lib/ontology-graph/schema/index.js +10 -0
  236. package/dist/lib/ontology-graph/schema/validate.d.ts +13 -0
  237. package/dist/lib/ontology-graph/schema/validate.js +132 -0
  238. package/dist/lib/ontology-graph/store/files.d.ts +34 -0
  239. package/dist/lib/ontology-graph/store/files.js +207 -0
  240. package/dist/lib/ontology-graph/store/fs.d.ts +30 -0
  241. package/dist/lib/ontology-graph/store/fs.js +101 -0
  242. package/dist/lib/ontology-graph/store/graph-store.d.ts +14 -0
  243. package/dist/lib/ontology-graph/store/graph-store.js +520 -0
  244. package/dist/lib/ontology-graph/store/index.d.ts +18 -0
  245. package/dist/lib/ontology-graph/store/index.js +15 -0
  246. package/dist/lib/ontology-graph/store/ingest.d.ts +37 -0
  247. package/dist/lib/ontology-graph/store/ingest.js +323 -0
  248. package/dist/lib/ontology-graph/store/paths.d.ts +114 -0
  249. package/dist/lib/ontology-graph/store/paths.js +232 -0
  250. package/dist/lib/ontology-graph/types.d.ts +1183 -0
  251. package/dist/lib/ontology-graph/types.js +131 -0
  252. package/dist/lib/secret-scan/gitleaks-rules.generated.js +1 -1
  253. package/dist/utils/frontmatter.d.ts +14 -0
  254. package/dist/utils/frontmatter.js +18 -0
  255. package/dist/utils/interactive-caller.js +1 -1
  256. package/package.json +8 -8
@@ -0,0 +1,90 @@
1
+ /**
2
+ * WP-B entry points: replay engine, input readers, rule extractors.
3
+ * Signatures are fixed by CONTRACT.md. The engine is in engine.ts, the source
4
+ * classes in readers.ts, the rules in extractors.ts.
5
+ */
6
+ import { runLint as defaultRunLint } from "../lint/index.js";
7
+ import { runModelPass as defaultRunModelPass, type BatchModelStep, type PassTask } from "../model/index.js";
8
+ import { type CommandOutput, type GraphContext, type MemberIdentity, type RebuildOptions, type ReplayInputKind, type ReplayInputReader, type ReplayRunResult, type RuleExtractor, type UpdateOptions } from "../types.js";
9
+ import { type ReplayDeps, type ReplayReport } from "./engine.js";
10
+ export { scanCorpus, kindReaders, meetingSlug } from "./readers.js";
11
+ export type { ClassedInput, Corpus, CorpusStats, ScanOptions, SourceClass } from "./readers.js";
12
+ export { loadReplayConfig, REPLAY_CONFIG_RELATIVE } from "./config.js";
13
+ export type { ReplayConfig } from "./config.js";
14
+ export { resolveMemberScope } from "./scope.js";
15
+ export type { MemberScope } from "./scope.js";
16
+ export { FULL_LISTING_ENV, LISTING_MANIFEST_RELATIVE, NO_MODEL_ENV, PENDING_RELATIVE, TYPING_PROMPT_VERSION, formatReport, parseTypingReply } from "./engine.js";
17
+ export { LISTING_MANIFEST_VERSION, gitHeadCommit, openListingManifest } from "./listing-manifest.js";
18
+ export type { ListingManifest, ListingManifestStats } from "./listing-manifest.js";
19
+ export type { ReplayDeps, ReplayReport } from "./engine.js";
20
+ export { classOf, createExtractTools, registerExtractTools } from "./extractors.js";
21
+ export { countingResolver, createFallbackResolver, nameCandidates } from "./mentions.js";
22
+ export { extractTranscript, readTranscripts } from "./transcripts.js";
23
+ export { memberFromIdentity, resolveSignedInMember, withMember } from "./member.js";
24
+ /** What one model pass may spend when `--budget-tokens` does not say: input and output tokens per run. */
25
+ export declare const PASS_RUN_BUDGET: {
26
+ /** A daily update: about four times what one member's day was measured to need (2026-11-22). */
27
+ readonly update: {
28
+ readonly inputTokens: 600000;
29
+ readonly outputTokens: 300000;
30
+ };
31
+ /** A rebuild: one full pass over a vault of about 50,000 inputs, with room. Replies already cached cost nothing. */
32
+ readonly rebuild: {
33
+ readonly inputTokens: 8000000;
34
+ readonly outputTokens: 4000000;
35
+ };
36
+ };
37
+ /** Seams for the model pass that follows a replay. Production passes nothing. */
38
+ export interface ModelPassDeps {
39
+ /**
40
+ * The step the pass sends its work through. Default: a new step on the
41
+ * member's own sign-in, four turns at a time. Null switches the pass off.
42
+ * A test that injects `modelStep` for the replay gets no pass unless it
43
+ * also gives this one, so no test ever starts a real model turn.
44
+ */
45
+ passStep?: BatchModelStep | null;
46
+ /** Another step for some tasks. Default: the measured choice in `PASS_TASK_MODELS`. */
47
+ passTaskSteps?: Partial<Record<PassTask, BatchModelStep>>;
48
+ runModelPass?: typeof defaultRunModelPass;
49
+ }
50
+ /** Legacy import, then replay day by day, then the model pass, pages and brief. Resumable from `.state/cursor.json`. */
51
+ export declare function runRebuild(context: GraphContext, options: RebuildOptions, deps?: ReplayDeps & ModelPassDeps): Promise<ReplayReport>;
52
+ export interface UpdateDeps extends ReplayDeps, ModelPassDeps {
53
+ /** Default: WP-F's lint. Null switches it off. */
54
+ runLint?: typeof defaultRunLint | null;
55
+ }
56
+ /**
57
+ * Replays the days after the cursor, or one input file; runs the model pass
58
+ * on what is new; then lints the entities the run touched. The full lint
59
+ * (`hq ontology lint`, and the daily job once a week) reads the whole graph;
60
+ * this one reads only what changed.
61
+ */
62
+ export declare function runUpdate(context: GraphContext, options: UpdateOptions, deps?: UpdateDeps): Promise<ReplayReport>;
63
+ /**
64
+ * `hq ontology rebuild`. The command reads the org layer (reporting lines,
65
+ * workspace members) with the signed-in session before the legacy import;
66
+ * `HQ_ONTOLOGY_ORG_LAYER=cache|off` keeps it off the network. A dry run never
67
+ * fetches.
68
+ */
69
+ export declare function rebuildCommand(context: GraphContext, options: RebuildOptions, deps?: ReplayDeps & ModelPassDeps): Promise<CommandOutput>;
70
+ /** `hq ontology update`. */
71
+ export declare function updateCommand(context: GraphContext, options: UpdateOptions, deps?: UpdateDeps): Promise<CommandOutput>;
72
+ /**
73
+ * One reader per input kind present in the company folder, for the member in
74
+ * `context.member` (correction C2). Each is the union of that kind's source
75
+ * classes; `scanCorpus` gives the per-class readers.
76
+ */
77
+ export declare function createInputReaders(context: GraphContext, options?: {
78
+ resolveMember?: (context: GraphContext) => MemberIdentity | null;
79
+ /**
80
+ * List with the manifest the last `rebuild` or `update` kept: a file whose
81
+ * size and mtime are unchanged is not opened. Nothing is written, so the
82
+ * update that follows still finds what is new. For the daily job's check
83
+ * of whether anything changed.
84
+ */
85
+ incremental?: boolean;
86
+ }): Partial<Record<ReplayInputKind, ReplayInputReader>>;
87
+ /** The model-free extractors, in the order they run. */
88
+ export declare function ruleExtractors(): RuleExtractor[];
89
+ export type { ReplayRunResult };
90
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,220 @@
1
+ /**
2
+ * WP-B entry points: replay engine, input readers, rule extractors.
3
+ * Signatures are fixed by CONTRACT.md. The engine is in engine.ts, the source
4
+ * classes in readers.ts, the rules in extractors.ts.
5
+ */
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";
8
+ import { OntologyGraphNotImplementedError } from "../not-implemented.js";
9
+ import { compilePages as defaultCompilePages, summaryItemsFor } from "../pages/index.js";
10
+ import { briefCommand as defaultBriefCommand } from "../read/index.js";
11
+ import { graphPath, openGraphStore } from "../store/index.js";
12
+ import { MemberIdentityRequiredError, } from "../types.js";
13
+ 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 { allRuleExtractors } from "./extractors.js";
16
+ import { resolveSignedInMember, withMember } from "./member.js";
17
+ export { scanCorpus, kindReaders, meetingSlug } from "./readers.js";
18
+ export { loadReplayConfig, REPLAY_CONFIG_RELATIVE } from "./config.js";
19
+ export { resolveMemberScope } from "./scope.js";
20
+ export { FULL_LISTING_ENV, LISTING_MANIFEST_RELATIVE, NO_MODEL_ENV, PENDING_RELATIVE, TYPING_PROMPT_VERSION, formatReport, parseTypingReply } from "./engine.js";
21
+ export { LISTING_MANIFEST_VERSION, gitHeadCommit, openListingManifest } from "./listing-manifest.js";
22
+ export { classOf, createExtractTools, registerExtractTools } from "./extractors.js";
23
+ export { countingResolver, createFallbackResolver, nameCandidates } from "./mentions.js";
24
+ export { extractTranscript, readTranscripts } from "./transcripts.js";
25
+ export { memberFromIdentity, resolveSignedInMember, withMember } from "./member.js";
26
+ /** What one model pass may spend when `--budget-tokens` does not say: input and output tokens per run. */
27
+ export const PASS_RUN_BUDGET = {
28
+ /** A daily update: about four times what one member's day was measured to need (2026-11-22). */
29
+ update: { inputTokens: 600_000, outputTokens: 300_000 },
30
+ /** A rebuild: one full pass over a vault of about 50,000 inputs, with room. Replies already cached cost nothing. */
31
+ rebuild: { inputTokens: 8_000_000, outputTokens: 4_000_000 },
32
+ };
33
+ /** The cap per model per day, whatever the runs: a loop of updates stops here. */
34
+ const PASS_DAY_BUDGET = { inputTokens: 12_000_000, outputTokens: 6_000_000 };
35
+ const PASS_CONCURRENCY = 4;
36
+ /** True when this run makes no model call: the flags, the env var, a dry run, or a test that switched it off. */
37
+ function passIsOff(options, deps) {
38
+ const env = deps.env ?? process.env;
39
+ if (options.dryRun || options.noModel === true || options.budgetTokens === 0 || env[NO_MODEL_ENV] === "1")
40
+ return true;
41
+ if (deps.passStep === null || deps.modelStep === null)
42
+ return true;
43
+ return deps.modelStep !== undefined && deps.passStep === undefined;
44
+ }
45
+ /**
46
+ * The replay first, with rules and the few model calls it makes itself. Then,
47
+ * unless the model is off: the model pass over the graph (sources no signal
48
+ * covers, roles and stages from an entity's own lines, old untyped edges,
49
+ * decisions that replace each other, page summaries), then the pages it made
50
+ * dirty, then the brief. Replies are cached by content beside the graph folder
51
+ * (`.hq/ontology-graph-model`), which no rebuild touches, so a second run over
52
+ * unchanged sources makes no call.
53
+ */
54
+ async function replayThenPass(command, context, options, deps, run) {
55
+ if (passIsOff(options, deps))
56
+ return run(deps);
57
+ // Pages and the brief are written once, after the pass, not once before it and again after.
58
+ const report = await run({ ...deps, compilePages: null, brief: null });
59
+ const compiler = deps.compilePages === undefined ? defaultCompilePages : deps.compilePages;
60
+ const brief = deps.brief === undefined ? defaultBriefCommand : deps.brief;
61
+ const env = deps.env ?? process.env;
62
+ const scoped = withMember(context, deps.resolveMember ?? ((ctx) => resolveSignedInMember(ctx, env)));
63
+ const day = (deps.now ?? (() => new Date()))().toISOString().slice(0, 10);
64
+ 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))
67
+ return report;
68
+ const dirtyBefore = new Set(openGraphStore(context.graphRoot, { company: context.company }).readDirty());
69
+ const cap = options.budgetTokens;
70
+ const left = cap === undefined ? undefined : cap - report.totals.inputTokens;
71
+ let passStep = null;
72
+ if (left !== undefined && left <= 0) {
73
+ report.notes.push("Model pass not run: the replay spent the run's token budget.");
74
+ }
75
+ else {
76
+ const runBudget = left === undefined ? PASS_RUN_BUDGET[command] : { inputTokens: left, outputTokens: Math.ceil(left / 2) };
77
+ 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 } : {}) });
79
+ const step = deps.passStep ?? make();
80
+ passStep = step;
81
+ let taskSteps = deps.passTaskSteps;
82
+ if (!taskSteps && !deps.passStep && resolveModel(scoped) === DEFAULT_ONTOLOGY_MODEL) {
83
+ // The cheapest model was measured wrong too often on these tasks; a member who raised the model keeps theirs.
84
+ const stronger = new Map();
85
+ taskSteps = {};
86
+ for (const [task, model] of Object.entries(PASS_TASK_MODELS)) {
87
+ if (!stronger.has(model))
88
+ stronger.set(model, make(model));
89
+ taskSteps[task] = stronger.get(model);
90
+ }
91
+ }
92
+ const pass = await (deps.runModelPass ?? defaultRunModelPass)(scoped, {
93
+ step,
94
+ day,
95
+ // An update asks about what it touched; a rebuild about everything.
96
+ ...(report.touched ? { only: new Set(report.touched) } : {}),
97
+ ...(taskSteps ? { taskSteps } : {}),
98
+ summaryItems: (refs) => summaryItemsFor(openGraphStore(context.graphRoot, { company: context.company }), refs),
99
+ });
100
+ const steps = [step, ...Object.values(taskSteps ?? {})].filter((entry, index, all) => all.indexOf(entry) === index);
101
+ let halted = null;
102
+ for (const entry of steps)
103
+ halted = halted ?? entry.halted();
104
+ for (const task of pass.tasks) {
105
+ report.counters[`pass_${task.task}_calls`] = task.stats.calls;
106
+ report.counters[`pass_${task.task}_cache_hits`] = task.stats.cacheHits;
107
+ report.counters[`pass_${task.task}_rows`] = task.rowsNew;
108
+ report.counters[`pass_${task.task}_pending`] = task.stats.pending;
109
+ report.totals.modelCalls += task.stats.calls;
110
+ report.totals.cacheHits += task.stats.cacheHits;
111
+ report.totals.inputTokens += Math.round(task.stats.usage.inputTokens);
112
+ report.totals.outputTokens += Math.round(task.stats.usage.outputTokens);
113
+ report.totals.rowsAdded += task.rowsNew;
114
+ }
115
+ report.counters.pass_ms = Math.round(pass.seconds * 1000);
116
+ if (halted)
117
+ report.notes.push(`Model pass stopped (${halted}): what was not sent is left pending for the next run.`);
118
+ }
119
+ catch (error) {
120
+ if (!(error instanceof OntologyGraphNotImplementedError))
121
+ throw error;
122
+ report.notes.push("Model pass not run: the model step is a stub.");
123
+ }
124
+ }
125
+ // What the pass changed joins what the replay changed, so the closing lint of an update sees both.
126
+ if (report.touched) {
127
+ const byPass = openGraphStore(context.graphRoot, { company: context.company }).readDirty().filter((ref) => !dirtyBefore.has(ref));
128
+ report.touched = [...new Set([...report.touched, ...byPass])].sort();
129
+ }
130
+ if (compiler) {
131
+ const started = Date.now();
132
+ // 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 } : {}) });
134
+ report.counters.pages_compiled = (report.counters.pages_compiled ?? 0) + compiled.compiled;
135
+ report.counters.pages_compile_ms = (report.counters.pages_compile_ms ?? 0) + (Date.now() - started);
136
+ }
137
+ if (brief) {
138
+ try {
139
+ await brief(scoped, { stdout: false });
140
+ report.counters.brief_written = 1;
141
+ }
142
+ catch (error) {
143
+ report.notes.push(`Brief was not written (${error.name}).`);
144
+ }
145
+ }
146
+ return report;
147
+ }
148
+ /** Legacy import, then replay day by day, then the model pass, pages and brief. Resumable from `.state/cursor.json`. */
149
+ export async function runRebuild(context, options, deps = {}) {
150
+ return replayThenPass("rebuild", context, options, deps, (engineDeps) => runRebuildWith(context, options, engineDeps));
151
+ }
152
+ /**
153
+ * Replays the days after the cursor, or one input file; runs the model pass
154
+ * on what is new; then lints the entities the run touched. The full lint
155
+ * (`hq ontology lint`, and the daily job once a week) reads the whole graph;
156
+ * this one reads only what changed.
157
+ */
158
+ export async function runUpdate(context, options, deps = {}) {
159
+ const report = await replayThenPass("update", context, options, deps, (engineDeps) => runUpdateWith(context, options, engineDeps));
160
+ const lint = deps.runLint === undefined ? defaultRunLint : deps.runLint;
161
+ // A run that replayed nothing changed nothing, so it has nothing new to find.
162
+ if (lint && !options.dryRun && !report.partial && report.days > 0) {
163
+ try {
164
+ const started = Date.now();
165
+ const linted = await lint(context, { fileProposals: true, entities: report.touched ?? [] });
166
+ report.counters.lint_ms = Date.now() - started;
167
+ report.counters.lint_entities = (report.touched ?? []).length;
168
+ report.counters.lint_findings = linted.findings.length;
169
+ report.counters.lint_errors = linted.errors;
170
+ report.counters.proposals_filed = linted.proposalsFiled;
171
+ }
172
+ catch (error) {
173
+ if (!(error instanceof OntologyGraphNotImplementedError))
174
+ throw error;
175
+ report.notes.push("Lint did not run: WP-F's runLint is still a stub.");
176
+ }
177
+ }
178
+ return report;
179
+ }
180
+ function output(report) {
181
+ return { text: formatReport(report), json: report, ...(report.partial ? { exitCode: 2 } : {}) };
182
+ }
183
+ /**
184
+ * `hq ontology rebuild`. The command reads the org layer (reporting lines,
185
+ * workspace members) with the signed-in session before the legacy import;
186
+ * `HQ_ONTOLOGY_ORG_LAYER=cache|off` keeps it off the network. A dry run never
187
+ * fetches.
188
+ */
189
+ export async function rebuildCommand(context, options, deps = {}) {
190
+ const orgLayer = process.env.HQ_ONTOLOGY_ORG_LAYER ? {} : { orgLayer: "fetch" };
191
+ return output(await runRebuild(context, options, { ...orgLayer, ...deps }));
192
+ }
193
+ /** `hq ontology update`. */
194
+ export async function updateCommand(context, options, deps = {}) {
195
+ return output(await runUpdate(context, options, deps));
196
+ }
197
+ /**
198
+ * One reader per input kind present in the company folder, for the member in
199
+ * `context.member` (correction C2). Each is the union of that kind's source
200
+ * classes; `scanCorpus` gives the per-class readers.
201
+ */
202
+ export function createInputReaders(context, options = {}) {
203
+ const scoped = withMember(context, options.resolveMember);
204
+ if (!scoped.member)
205
+ throw new MemberIdentityRequiredError("input readers");
206
+ if (!options.incremental)
207
+ return kindReaders(scoped, scanCorpus(scoped));
208
+ return kindReaders(scoped, scanCorpus(scoped, {
209
+ manifestFile: graphPath(context.graphRoot, LISTING_MANIFEST_RELATIVE),
210
+ incremental: true,
211
+ writeManifest: false,
212
+ transcriptCacheFile: graphPath(context.graphRoot, TRANSCRIPT_CACHE_RELATIVE),
213
+ writeTranscriptCache: false,
214
+ }));
215
+ }
216
+ /** The model-free extractors, in the order they run. */
217
+ export function ruleExtractors() {
218
+ return allRuleExtractors();
219
+ }
220
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,66 @@
1
+ export declare const LISTING_MANIFEST_VERSION = 1;
2
+ export interface ListingManifestStats {
3
+ /** Files opened and read by the listing in this run. */
4
+ filesRead: number;
5
+ /** Files whose kept answer was used: not opened. */
6
+ filesReused: number;
7
+ /** Keyed answers (git) computed in this run, and reused. */
8
+ keyedComputed: number;
9
+ keyedReused: number;
10
+ /** Withheld files recognised by their hash: not opened. */
11
+ withheldKnown: number;
12
+ }
13
+ export interface ListingManifest {
14
+ readonly stats: ListingManifestStats;
15
+ /**
16
+ * The answer to `op` for one file. Reused when the file's size and mtime
17
+ * are what they were when the answer was kept; else `compute` reads the
18
+ * file. The value must survive a JSON round trip.
19
+ */
20
+ file<T>(section: string, op: string, file: string, compute: () => T): T;
21
+ /**
22
+ * An answer kept against `key`. Reused when the key is unchanged; else
23
+ * `compute` runs and is handed the previous key and value so it can extend
24
+ * them. A null key is never kept.
25
+ */
26
+ keyed<T>(section: string, name: string, key: string | null, compute: (previous: {
27
+ key: string;
28
+ value: T;
29
+ } | null) => T): T;
30
+ /** Says a section was listed in this run, so `save({ prune })` clears it even when no file is left in it. */
31
+ visit(section: string): void;
32
+ /** Drops everything kept about a file, in every section: the member may not read it. */
33
+ forget(file: string): void;
34
+ /**
35
+ * `forget`, and remember that this file, at this size and mtime, is withheld
36
+ * for `reason`. Only for a verdict that cannot change while the file and the
37
+ * member's scope stay the same.
38
+ */
39
+ withhold(file: string, reason: string): void;
40
+ /** The reason an unchanged file was withheld by an earlier run, else null. Never opens the file. */
41
+ withheldReason(file: string): string | null;
42
+ /**
43
+ * Writes the manifest. `prune` drops records the listing did not ask about
44
+ * in this run, for the sections it did visit (their files are gone).
45
+ * Returns false when nothing changed.
46
+ */
47
+ save(options?: {
48
+ prune?: boolean;
49
+ }): boolean;
50
+ }
51
+ export interface OpenListingManifestOptions {
52
+ /** Manifest file. Null: nothing is kept and every file is read. */
53
+ file: string | null;
54
+ /** Use kept answers. False reads everything again (a full listing) and still records it. */
55
+ reuse: boolean;
56
+ /** Who the listing is for. A manifest kept for another scope is not used. Default "". */
57
+ scope?: string;
58
+ }
59
+ export declare function openListingManifest(options: OpenListingManifestOptions): ListingManifest;
60
+ /**
61
+ * The commit a repo's HEAD points at, read from the files under `.git` with no
62
+ * git process. Null when it cannot be told (a worktree, a ref that is neither
63
+ * loose nor packed), and the caller then asks git as before.
64
+ */
65
+ export declare function gitHeadCommit(repoDir: string): string | null;
66
+ //# sourceMappingURL=listing-manifest.d.ts.map
@@ -0,0 +1,242 @@
1
+ /**
2
+ * The incremental listing for `hq ontology update`.
3
+ *
4
+ * Listing the corpus is the slow part of a daily update: it opens every file
5
+ * that carries a date or an owner in its frontmatter, parses every thread and
6
+ * runs one `git log` per repo. Almost none of that changes from one day to
7
+ * the next. This manifest keeps, per source class, what the listing learned
8
+ * from each file together with the file's size and mtime
9
+ * (`.state/replay-listing.json`). On the next run a file whose size and mtime
10
+ * are unchanged is not opened: the kept answer is used. A new or changed file
11
+ * is read as before. Git answers are kept against the repo's HEAD commit.
12
+ *
13
+ * The listing code itself is the same on both paths (readers.ts asks this
14
+ * module before every read), so the incremental listing returns exactly what a
15
+ * full listing returns. A file that vanished is dropped from the manifest the
16
+ * next time the whole corpus is listed.
17
+ *
18
+ * Scope (correction C2): the manifest lives in the member's graph folder, so it
19
+ * holds nothing from a file the member may not read. The listing calls
20
+ * `forget` for every file it finds withheld (another person's DM, a meeting
21
+ * for an audience the member is not in, a thread of another company): no
22
+ * answer, no size and no path of such a file is kept. The manifest is tied to
23
+ * the member and the keys they hold (`scope`); with a different member or key
24
+ * set it is not used at all.
25
+ *
26
+ * A withheld file whose verdict depends only on its own bytes and on who the
27
+ * member is (another person's DM, a thread of another company) is remembered
28
+ * by `withhold`: one hash of scope, path, size and mtime, and the reason word
29
+ * (`personal_not_owner`). Neither the path nor anything read from the file
30
+ * can be recovered from it. `withheldReason` answers from that hash, so the
31
+ * next run does not open the file again; a changed file has another hash and
32
+ * is read. On this Mac that is about 3,900 of the 4,300 files every listing
33
+ * used to open.
34
+ */
35
+ import { createHash } from "node:crypto";
36
+ import * as fs from "node:fs";
37
+ import * as path from "node:path";
38
+ export const LISTING_MANIFEST_VERSION = 1;
39
+ function emptyData(scope) {
40
+ return { version: LISTING_MANIFEST_VERSION, scope, classes: {}, keyed: {} };
41
+ }
42
+ function load(file, scope) {
43
+ if (!file)
44
+ return emptyData(scope);
45
+ try {
46
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
47
+ if (parsed?.version !== LISTING_MANIFEST_VERSION || parsed.scope !== scope || typeof parsed.classes !== "object" || parsed.classes === null)
48
+ return emptyData(scope);
49
+ return {
50
+ version: LISTING_MANIFEST_VERSION,
51
+ scope,
52
+ classes: parsed.classes,
53
+ keyed: typeof parsed.keyed === "object" && parsed.keyed !== null ? parsed.keyed : {},
54
+ withheld: typeof parsed.withheld === "object" && parsed.withheld !== null ? parsed.withheld : {},
55
+ };
56
+ }
57
+ catch {
58
+ // No manifest yet, or a torn one: the listing reads everything and writes a new one.
59
+ return emptyData(scope);
60
+ }
61
+ }
62
+ export function openListingManifest(options) {
63
+ const scope = options.scope ?? "";
64
+ const data = options.reuse ? load(options.file, scope) : emptyData(scope);
65
+ const stats = { filesRead: 0, filesReused: 0, keyedComputed: 0, keyedReused: 0, withheldKnown: 0 };
66
+ const tombstones = (data.withheld ??= {});
67
+ /** Tombstones asked about or written in this run; the rest belong to files that are gone or changed. */
68
+ const tombstonesSeen = new Set();
69
+ const tombstoneOf = (file) => {
70
+ try {
71
+ const stat = fs.statSync(file);
72
+ return createHash("sha256").update([scope, file, stat.size, Math.floor(stat.mtimeMs)].join("\u0000")).digest("hex").slice(0, 32);
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ };
78
+ // What this run asked about, so `save({ prune })` can drop the rest.
79
+ const touched = new Map();
80
+ let changed = !options.reuse;
81
+ const touch = (section, file) => {
82
+ let set = touched.get(section);
83
+ if (!set)
84
+ touched.set(section, (set = new Set()));
85
+ set.add(file);
86
+ };
87
+ return {
88
+ stats,
89
+ visit(section) {
90
+ if (!touched.has(section))
91
+ touched.set(section, new Set());
92
+ },
93
+ forget(file) {
94
+ for (const records of Object.values(data.classes)) {
95
+ if (records[file]) {
96
+ delete records[file];
97
+ changed = true;
98
+ }
99
+ }
100
+ for (const files of touched.values())
101
+ files.delete(file);
102
+ },
103
+ withhold(file, reason) {
104
+ this.forget(file);
105
+ const hash = tombstoneOf(file);
106
+ if (!hash)
107
+ return;
108
+ tombstonesSeen.add(hash);
109
+ if (tombstones[hash] !== reason) {
110
+ tombstones[hash] = reason;
111
+ changed = true;
112
+ }
113
+ },
114
+ withheldReason(file) {
115
+ if (!options.reuse)
116
+ return null;
117
+ const hash = tombstoneOf(file);
118
+ const reason = hash ? tombstones[hash] : undefined;
119
+ if (!hash || reason === undefined)
120
+ return null;
121
+ tombstonesSeen.add(hash);
122
+ stats.withheldKnown += 1;
123
+ return reason;
124
+ },
125
+ file(section, op, file, compute) {
126
+ let stat;
127
+ try {
128
+ stat = fs.statSync(file);
129
+ }
130
+ catch {
131
+ // A missing file is never kept: the caller's read decides what that means.
132
+ return compute();
133
+ }
134
+ touch(section, file);
135
+ const size = stat.size;
136
+ const mtimeMs = Math.floor(stat.mtimeMs);
137
+ const records = (data.classes[section] ??= {});
138
+ let record = records[file];
139
+ if (!record || record.size !== size || record.mtimeMs !== mtimeMs) {
140
+ record = { size, mtimeMs, ops: {} };
141
+ records[file] = record;
142
+ changed = true;
143
+ }
144
+ if (Object.prototype.hasOwnProperty.call(record.ops, op)) {
145
+ stats.filesReused += 1;
146
+ return record.ops[op];
147
+ }
148
+ const value = compute();
149
+ stats.filesRead += 1;
150
+ record.ops[op] = value === undefined ? null : value;
151
+ changed = true;
152
+ return value;
153
+ },
154
+ keyed(section, name, key, compute) {
155
+ const records = (data.keyed[section] ??= {});
156
+ const known = records[name];
157
+ if (key !== null && known && known.key === key) {
158
+ stats.keyedReused += 1;
159
+ return known.value;
160
+ }
161
+ const value = compute(known ? { key: known.key, value: known.value } : null);
162
+ stats.keyedComputed += 1;
163
+ if (key !== null) {
164
+ records[name] = { key, value };
165
+ changed = true;
166
+ }
167
+ return value;
168
+ },
169
+ save(saveOptions = {}) {
170
+ if (!options.file)
171
+ return false;
172
+ if (saveOptions.prune) {
173
+ for (const [section, files] of touched) {
174
+ const records = data.classes[section];
175
+ if (!records)
176
+ continue;
177
+ for (const file of Object.keys(records)) {
178
+ if (!files.has(file)) {
179
+ delete records[file];
180
+ changed = true;
181
+ }
182
+ }
183
+ }
184
+ // A tombstone nobody asked about belongs to a file that is gone or has changed.
185
+ for (const hash of Object.keys(tombstones)) {
186
+ if (!tombstonesSeen.has(hash)) {
187
+ delete tombstones[hash];
188
+ changed = true;
189
+ }
190
+ }
191
+ }
192
+ if (!changed)
193
+ return false;
194
+ fs.mkdirSync(path.dirname(options.file), { recursive: true });
195
+ const temp = `${options.file}.tmp-${process.pid}`;
196
+ try {
197
+ fs.writeFileSync(temp, JSON.stringify(data));
198
+ fs.renameSync(temp, options.file);
199
+ }
200
+ catch (error) {
201
+ fs.rmSync(temp, { force: true });
202
+ throw error;
203
+ }
204
+ changed = false;
205
+ return true;
206
+ },
207
+ };
208
+ }
209
+ /**
210
+ * The commit a repo's HEAD points at, read from the files under `.git` with no
211
+ * git process. Null when it cannot be told (a worktree, a ref that is neither
212
+ * loose nor packed), and the caller then asks git as before.
213
+ */
214
+ export function gitHeadCommit(repoDir) {
215
+ try {
216
+ const gitDir = path.join(repoDir, ".git");
217
+ const head = fs.readFileSync(path.join(gitDir, "HEAD"), "utf8").trim();
218
+ if (/^[0-9a-f]{40,64}$/.test(head))
219
+ return head;
220
+ const ref = /^ref:\s*(\S+)$/.exec(head)?.[1];
221
+ if (!ref || ref.includes(".."))
222
+ return null;
223
+ try {
224
+ const loose = fs.readFileSync(path.join(gitDir, ...ref.split("/")), "utf8").trim();
225
+ if (/^[0-9a-f]{40,64}$/.test(loose))
226
+ return loose;
227
+ }
228
+ catch {
229
+ // not a loose ref: look in packed-refs
230
+ }
231
+ for (const line of fs.readFileSync(path.join(gitDir, "packed-refs"), "utf8").split("\n")) {
232
+ const [sha, name] = line.split(" ");
233
+ if (name === ref && /^[0-9a-f]{40,64}$/.test(sha ?? ""))
234
+ return sha;
235
+ }
236
+ return null;
237
+ }
238
+ catch {
239
+ return null;
240
+ }
241
+ }
242
+ //# sourceMappingURL=listing-manifest.js.map
@@ -0,0 +1,19 @@
1
+ import type { GraphContext, MemberIdentity } from "../types.js";
2
+ /** What the roster lookup needs from the local sign-in. */
3
+ export interface SignedInIdentity {
4
+ authenticated: boolean;
5
+ tokenSource: string;
6
+ email: string | null;
7
+ delegatedEmail: string | null;
8
+ }
9
+ /**
10
+ * The member for a signed-in person: the cached person uid when there is one,
11
+ * else the one roster entry whose email is the signed-in email. A machine
12
+ * (agent) sign-in, a signed-out session, or an email on two roster entries
13
+ * gives no answer.
14
+ */
15
+ export declare function memberFromIdentity(context: Pick<GraphContext, "companyRoot">, identity: SignedInIdentity, cachedPersonUid?: string | null): MemberIdentity | null;
16
+ export declare function resolveSignedInMember(context: Pick<GraphContext, "companyRoot">, env?: NodeJS.ProcessEnv): MemberIdentity | null;
17
+ /** `context` with its member filled in from the sign-in when it had none. */
18
+ export declare function withMember(context: GraphContext, resolve?: (context: GraphContext) => MemberIdentity | null): GraphContext;
19
+ //# sourceMappingURL=member.d.ts.map