@cat-factory/orchestration 0.301.2 → 0.302.0

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 (113) hide show
  1. package/dist/modules/board/newServiceFrameDefaults.d.ts +0 -5
  2. package/dist/modules/board/newServiceFrameDefaults.d.ts.map +1 -1
  3. package/dist/modules/board/newServiceFrameDefaults.js +1 -1
  4. package/dist/modules/board/newServiceFrameDefaults.js.map +1 -1
  5. package/dist/modules/brainstorm/brainstorm.logic.d.ts +0 -7
  6. package/dist/modules/brainstorm/brainstorm.logic.d.ts.map +1 -1
  7. package/dist/modules/brainstorm/brainstorm.logic.js +1 -1
  8. package/dist/modules/brainstorm/brainstorm.logic.js.map +1 -1
  9. package/dist/modules/execution/BugFishingController.d.ts +35 -9
  10. package/dist/modules/execution/BugFishingController.d.ts.map +1 -1
  11. package/dist/modules/execution/BugFishingController.js +49 -14
  12. package/dist/modules/execution/BugFishingController.js.map +1 -1
  13. package/dist/modules/execution/DeployFixController.d.ts +0 -6
  14. package/dist/modules/execution/DeployFixController.d.ts.map +1 -1
  15. package/dist/modules/execution/DeployFixController.js +1 -1
  16. package/dist/modules/execution/DeployFixController.js.map +1 -1
  17. package/dist/modules/execution/InterviewGateController.d.ts +2 -1
  18. package/dist/modules/execution/InterviewGateController.d.ts.map +1 -1
  19. package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
  20. package/dist/modules/execution/RunDispatcher.js +7 -0
  21. package/dist/modules/execution/RunDispatcher.js.map +1 -1
  22. package/dist/modules/execution/block-reference-set.d.ts +0 -2
  23. package/dist/modules/execution/block-reference-set.d.ts.map +1 -1
  24. package/dist/modules/execution/block-reference-set.js +1 -1
  25. package/dist/modules/execution/block-reference-set.js.map +1 -1
  26. package/dist/modules/execution/bugFishing.logic.d.ts +37 -3
  27. package/dist/modules/execution/bugFishing.logic.d.ts.map +1 -1
  28. package/dist/modules/execution/bugFishing.logic.js +124 -23
  29. package/dist/modules/execution/bugFishing.logic.js.map +1 -1
  30. package/dist/modules/execution/bugFishingPass.d.ts +35 -0
  31. package/dist/modules/execution/bugFishingPass.d.ts.map +1 -0
  32. package/dist/modules/execution/bugFishingPass.js +45 -0
  33. package/dist/modules/execution/bugFishingPass.js.map +1 -0
  34. package/dist/modules/execution/bugFishingSurvey.d.ts +87 -0
  35. package/dist/modules/execution/bugFishingSurvey.d.ts.map +1 -0
  36. package/dist/modules/execution/bugFishingSurvey.js +130 -0
  37. package/dist/modules/execution/bugFishingSurvey.js.map +1 -0
  38. package/dist/modules/execution/bugFishingTerritories.logic.d.ts +89 -0
  39. package/dist/modules/execution/bugFishingTerritories.logic.d.ts.map +1 -0
  40. package/dist/modules/execution/bugFishingTerritories.logic.js +519 -0
  41. package/dist/modules/execution/bugFishingTerritories.logic.js.map +1 -0
  42. package/dist/modules/execution/dispatchPromptSettings.d.ts +0 -31
  43. package/dist/modules/execution/dispatchPromptSettings.d.ts.map +1 -1
  44. package/dist/modules/execution/dispatchPromptSettings.js +2 -2
  45. package/dist/modules/execution/dispatchPromptSettings.js.map +1 -1
  46. package/dist/modules/execution/dispatcher-registries.d.ts +8 -0
  47. package/dist/modules/execution/dispatcher-registries.d.ts.map +1 -1
  48. package/dist/modules/execution/dispatcher-registries.js +52 -8
  49. package/dist/modules/execution/dispatcher-registries.js.map +1 -1
  50. package/dist/modules/execution/linked-context.d.ts +3 -6
  51. package/dist/modules/execution/linked-context.d.ts.map +1 -1
  52. package/dist/modules/execution/linked-context.js +2 -2
  53. package/dist/modules/execution/linked-context.js.map +1 -1
  54. package/dist/modules/execution/prReport.commands.d.ts.map +1 -1
  55. package/dist/modules/execution/prReport.commands.js +2 -35
  56. package/dist/modules/execution/prReport.commands.js.map +1 -1
  57. package/dist/modules/execution/prReport.environments.d.ts.map +1 -1
  58. package/dist/modules/execution/prReport.environments.js +1 -5
  59. package/dist/modules/execution/prReport.environments.js.map +1 -1
  60. package/dist/modules/execution/prReport.logic.d.ts.map +1 -1
  61. package/dist/modules/execution/prReport.logic.js +1 -5
  62. package/dist/modules/execution/prReport.logic.js.map +1 -1
  63. package/dist/modules/execution/prReport.steps.d.ts +2 -0
  64. package/dist/modules/execution/prReport.steps.d.ts.map +1 -1
  65. package/dist/modules/execution/prReport.steps.js +5 -1
  66. package/dist/modules/execution/prReport.steps.js.map +1 -1
  67. package/dist/modules/execution/reproductionProof.logic.d.ts +0 -2
  68. package/dist/modules/execution/reproductionProof.logic.d.ts.map +1 -1
  69. package/dist/modules/execution/reproductionProof.logic.js +1 -1
  70. package/dist/modules/execution/reproductionProof.logic.js.map +1 -1
  71. package/dist/modules/execution/run-binary-output.d.ts +0 -21
  72. package/dist/modules/execution/run-binary-output.d.ts.map +1 -1
  73. package/dist/modules/execution/run-binary-output.js +1 -1
  74. package/dist/modules/execution/run-binary-output.js.map +1 -1
  75. package/dist/modules/execution/runMode.logic.d.ts +2 -13
  76. package/dist/modules/execution/runMode.logic.d.ts.map +1 -1
  77. package/dist/modules/execution/runMode.logic.js +1 -1
  78. package/dist/modules/execution/runMode.logic.js.map +1 -1
  79. package/dist/modules/initiative/initiative.logic.d.ts +0 -6
  80. package/dist/modules/initiative/initiative.logic.d.ts.map +1 -1
  81. package/dist/modules/initiative/initiative.logic.js +2 -6
  82. package/dist/modules/initiative/initiative.logic.js.map +1 -1
  83. package/dist/modules/kaizen/kaizen.logic.d.ts +0 -2
  84. package/dist/modules/kaizen/kaizen.logic.d.ts.map +1 -1
  85. package/dist/modules/kaizen/kaizen.logic.js +1 -1
  86. package/dist/modules/kaizen/kaizen.logic.js.map +1 -1
  87. package/dist/modules/merge/MergeTrackRecordService.d.ts +2 -1
  88. package/dist/modules/merge/MergeTrackRecordService.d.ts.map +1 -1
  89. package/dist/modules/merge/riskPolicyResolution.d.ts +2 -3
  90. package/dist/modules/merge/riskPolicyResolution.d.ts.map +1 -1
  91. package/dist/modules/merge/riskPolicyResolution.js +1 -1
  92. package/dist/modules/merge/riskPolicyResolution.js.map +1 -1
  93. package/dist/modules/observability/LlmObservabilityService.d.ts +2 -1
  94. package/dist/modules/observability/LlmObservabilityService.d.ts.map +1 -1
  95. package/dist/modules/pipelines/pipelineShape.d.ts +0 -18
  96. package/dist/modules/pipelines/pipelineShape.d.ts.map +1 -1
  97. package/dist/modules/pipelines/pipelineShape.js +1 -1
  98. package/dist/modules/pipelines/pipelineShape.js.map +1 -1
  99. package/dist/modules/requirements/requirements.logic.d.ts +0 -6
  100. package/dist/modules/requirements/requirements.logic.d.ts.map +1 -1
  101. package/dist/modules/requirements/requirements.logic.js +1 -1
  102. package/dist/modules/requirements/requirements.logic.js.map +1 -1
  103. package/dist/modules/sandbox/sandbox.logic.d.ts +1 -3
  104. package/dist/modules/sandbox/sandbox.logic.d.ts.map +1 -1
  105. package/dist/modules/sandbox/sandbox.logic.js +1 -1
  106. package/dist/modules/sandbox/sandbox.logic.js.map +1 -1
  107. package/dist/modules/useCases/LlmInlineUseCaseGenerator.d.ts +0 -8
  108. package/dist/modules/useCases/LlmInlineUseCaseGenerator.d.ts.map +1 -1
  109. package/dist/modules/useCases/LlmInlineUseCaseGenerator.js +1 -1
  110. package/dist/modules/useCases/LlmInlineUseCaseGenerator.js.map +1 -1
  111. package/dist/validation/validateRegistrations.d.ts +2 -1
  112. package/dist/validation/validateRegistrations.d.ts.map +1 -1
  113. package/package.json +11 -11
@@ -0,0 +1,519 @@
1
+ import { WHOLE_CODEBASE_TERRITORY_ID } from '@cat-factory/kernel';
2
+ // ---------------------------------------------------------------------------
3
+ // Partitioning a codebase into TERRITORIES, and planning the (territory x angle) matrix an
4
+ // expedition fishes over them.
5
+ //
6
+ // Everything here is a pure function of (tree, options) -> plan, so the rule that decides what a
7
+ // large expedition covers is unit-testable without a repository, a run, or a model. The design
8
+ // record is docs/initiatives/bug-fishing-expedition.md ("Large codebases"); the one sentence that
9
+ // governs the whole module is its rule: the platform COMPUTES the partition, the model JUDGES the
10
+ // code. Nothing below asks an LLM where the modules are.
11
+ //
12
+ // THE FRAME, and it binds every path this module emits: a territory's roots and its manifest are
13
+ // relative to the SURVEY ROOT, which is the service's own directory in a monorepo and the
14
+ // repository root otherwise. That is the frame the agent works in — the harness roots its checkout
15
+ // at `<clone>/<serviceDirectory>` — so it is the frame the manifest has to be written in, the
16
+ // frame the pass reports its reads and its findings in, and therefore the frame the scope check
17
+ // and the coverage intersection have to judge in. A repo-relative manifest handed to a service
18
+ // agent lists paths it cannot open, and every finding it reports back lands outside every root.
19
+ // The tree read is repo-relative, so the prefix is stripped ONCE, here, in `fishableFiles`.
20
+ // ---------------------------------------------------------------------------
21
+ /**
22
+ * Target source tokens per territory: roughly what one pass can read a meaningful share of with
23
+ * ranged reads. Bytes / 4 over the tree's blob sizes, so it is an estimate by construction, which
24
+ * is why the persisted field is named `approxTokens`.
25
+ */
26
+ const TARGET_TERRITORY_TOKENS = 150_000;
27
+ /** No territory may exceed twice the target; one that would is split along its sub-directories. */
28
+ const MAX_TERRITORY_TOKENS = TARGET_TERRITORY_TOKENS * 2;
29
+ /** Bytes per token, the estimator every sizing decision here uses. */
30
+ const BYTES_PER_TOKEN = 4;
31
+ /**
32
+ * What a file with no reported size is assumed to weigh.
33
+ *
34
+ * GitHub's tree read carries a blob size per file; GitLab's does not. Rather than sizing a GitLab
35
+ * repository as weightless (which would pack the whole codebase into one territory and silently
36
+ * undo the partition), a size-less entry counts as a middling source file. The estimate is stated
37
+ * here in one place so the failure mode is "territories are sized coarsely" rather than "sizing
38
+ * silently stopped applying on one provider".
39
+ */
40
+ const ASSUMED_FILE_BYTES = 4_000;
41
+ /**
42
+ * Paths never worth fishing: generated output, vendored trees, dependency directories, lockfiles
43
+ * and fixtures. The finding bar cannot be applied to code nobody in this repository wrote, and a
44
+ * territory packed with `dist/` is budget spent on nothing.
45
+ *
46
+ * The vocabulary the file-size ratchet skips (`scripts/check-file-size.mjs`'s `SKIP_DIRS`) plus
47
+ * the generated/vendored shapes that ratchet never has to see, because it scans a checkout and
48
+ * this reads a provider's whole tree.
49
+ */
50
+ const IGNORED_DIR_SEGMENTS = new Set([
51
+ 'node_modules',
52
+ 'dist',
53
+ 'build',
54
+ 'out',
55
+ 'vendor',
56
+ 'vendored',
57
+ 'third_party',
58
+ 'coverage',
59
+ '.git',
60
+ '.turbo',
61
+ '.nuxt',
62
+ '.output',
63
+ '.next',
64
+ '.venv',
65
+ '.stryker-tmp',
66
+ '__snapshots__',
67
+ '__pycache__',
68
+ ]);
69
+ /** File names that are generated or otherwise not source anybody reads for defects. */
70
+ const IGNORED_FILE_NAMES = new Set([
71
+ 'pnpm-lock.yaml',
72
+ 'package-lock.json',
73
+ 'yarn.lock',
74
+ 'bun.lockb',
75
+ 'poetry.lock',
76
+ 'Cargo.lock',
77
+ 'go.sum',
78
+ 'composer.lock',
79
+ 'Gemfile.lock',
80
+ ]);
81
+ /** A file name suffix that marks generated output regardless of where it sits. */
82
+ const IGNORED_FILE_SUFFIXES = ['.generated.ts', '.generated.js', '.min.js', '.snap', '.map'];
83
+ /**
84
+ * A file that marks the directory it sits in as a PACKAGE boundary. A territory stops here rather
85
+ * than packing across it, because a package is a unit somebody already decided was cohesive, and
86
+ * "has something else already handled it?" is answered inside one far more often than across two.
87
+ */
88
+ const PACKAGE_MARKERS = new Set([
89
+ 'package.json',
90
+ 'pyproject.toml',
91
+ 'setup.py',
92
+ 'go.mod',
93
+ 'Cargo.toml',
94
+ 'pom.xml',
95
+ 'build.gradle',
96
+ 'build.gradle.kts',
97
+ 'composer.json',
98
+ 'Gemfile',
99
+ ]);
100
+ /**
101
+ * The id and label stem for the files sitting DIRECTLY in a root, beside its sub-directories.
102
+ *
103
+ * They are a group in their own right rather than a claim on the root itself: see
104
+ * {@link groupByChildDirectory} for why owning the root would be either an over-claim or, at the
105
+ * survey root, nothing at all.
106
+ */
107
+ const LOOSE_FILES_SEGMENT = 'root-files';
108
+ /** The label those loose files get, under a root and at the survey root. */
109
+ function looseFilesLabel(root) {
110
+ return root ? `${root} (files)` : 'Top-level files';
111
+ }
112
+ /**
113
+ * Whether any of a candidate's roots is a directory carrying a package marker.
114
+ *
115
+ * Asked of every root rather than only of a lone one: a candidate that already packed two
116
+ * directories together is exactly the one that must stop packing when the next is a package, and
117
+ * the earlier "only when there is a single root" reading meant the first pack disabled the
118
+ * boundary check for everything after it.
119
+ */
120
+ function isPackageRoot(candidate) {
121
+ return candidate.roots.some((root) => {
122
+ const prefix = root ? `${root}/` : '';
123
+ return candidate.files.some((file) => file.path.startsWith(prefix) && PACKAGE_MARKERS.has(file.path.slice(prefix.length)));
124
+ });
125
+ }
126
+ /** Whether a repo-relative path is source the expedition should fish. */
127
+ export function isFishablePath(path) {
128
+ if (!path)
129
+ return false;
130
+ const segments = path.split('/');
131
+ const name = segments[segments.length - 1] ?? '';
132
+ if (segments.some((segment) => IGNORED_DIR_SEGMENTS.has(segment)))
133
+ return false;
134
+ if (IGNORED_FILE_NAMES.has(name))
135
+ return false;
136
+ return !IGNORED_FILE_SUFFIXES.some((suffix) => name.endsWith(suffix));
137
+ }
138
+ /** Normalise a repo-relative path: no leading or trailing slash, no `./`. */
139
+ function normalizePath(path) {
140
+ return path.replace(/^\.\//, '').replace(/^\/+/, '').replace(/\/+$/, '');
141
+ }
142
+ /**
143
+ * The fishable FILES of a tree, scoped to the survey root, sized, and REBASED onto that root.
144
+ *
145
+ * Directories are dropped here rather than filtered at each later step: a territory is a set of
146
+ * files, and a `dir` entry carries no bytes to size it with. The ignore rules are applied to the
147
+ * FULL repo path, before the rebase, so `packages/api/dist` is still recognised as generated
148
+ * output once the prefix is gone.
149
+ */
150
+ function fishableFiles(entries, root) {
151
+ const prefix = root ? `${root}/` : '';
152
+ const files = [];
153
+ for (const entry of entries) {
154
+ if (entry.type !== 'file')
155
+ continue;
156
+ const path = normalizePath(entry.path);
157
+ if (prefix && !path.startsWith(prefix))
158
+ continue;
159
+ if (!isFishablePath(path))
160
+ continue;
161
+ files.push({
162
+ path: path.slice(prefix.length),
163
+ bytes: typeof entry.size === 'number' ? entry.size : ASSUMED_FILE_BYTES,
164
+ });
165
+ }
166
+ return files.sort((a, b) => a.path.localeCompare(b.path));
167
+ }
168
+ /**
169
+ * Shas of the tree's entries, keyed by normalised REPO-relative path.
170
+ *
171
+ * Directories and files both: a territory root is usually a directory, whose subtree sha answers
172
+ * "has this changed since it was fished" with a string compare, but the loose-files group's roots
173
+ * are individual files, and a blob sha answers exactly the same question about one of those.
174
+ */
175
+ function entryShas(entries) {
176
+ const shas = new Map();
177
+ for (const entry of entries) {
178
+ if (entry.sha)
179
+ shas.set(normalizePath(entry.path), entry.sha);
180
+ }
181
+ return shas;
182
+ }
183
+ function tokensOf(files) {
184
+ return Math.round(files.reduce((sum, file) => sum + file.bytes, 0) / BYTES_PER_TOKEN);
185
+ }
186
+ /** The slug a territory id is built from: path-shaped, safe to read and to put in a log field. */
187
+ function territorySlug(idBase) {
188
+ const slug = idBase.replace(/[^a-zA-Z0-9._/-]/g, '-').replace(/\//g, '.');
189
+ return slug || WHOLE_CODEBASE_TERRITORY_ID;
190
+ }
191
+ /**
192
+ * Stamp a territory id that no other territory of this survey carries.
193
+ *
194
+ * Ids are DERIVED from paths, and derived ids collide: two blueprint modules whose first reference
195
+ * is the same directory produce the same stem, and so does a directory whose name happens to match
196
+ * the loose-files stem. A collision is not cosmetic — `filesByTerritory` is keyed by id, so the
197
+ * second territory would overwrite the first's manifest and every lookup by id would resolve both
198
+ * to one set of roots. Suffixing is enough because an id only has to be stable and distinct WITHIN
199
+ * one expedition: nothing looks a territory up across surveys (see the schema's note on why the
200
+ * label and roots are recorded rather than re-derived).
201
+ */
202
+ function uniqueTerritoryId(stem, used) {
203
+ let id = stem;
204
+ for (let n = 2; used.has(id); n++)
205
+ id = `${stem}~${n}`;
206
+ used.add(id);
207
+ return id;
208
+ }
209
+ /** The label a human reads for a territory rooted at `root` (already in the survey frame). */
210
+ function labelForRoot(root) {
211
+ return root || 'Whole codebase';
212
+ }
213
+ /**
214
+ * The single territory a codebase small enough to fish whole gets.
215
+ *
216
+ * The PASS-THROUGH: its phases carry no territory id, so the expedition is byte-for-byte the one
217
+ * that shipped before territories existed. Large-codebase mode is a size threshold crossed, never
218
+ * a mode a task opts into.
219
+ */
220
+ export function wholeCodebaseTerritory(files) {
221
+ return {
222
+ id: WHOLE_CODEBASE_TERRITORY_ID,
223
+ label: 'Whole codebase',
224
+ roots: [],
225
+ fileCount: files.length,
226
+ approxTokens: tokensOf(files),
227
+ source: 'whole-codebase',
228
+ subtreeShas: [],
229
+ };
230
+ }
231
+ /**
232
+ * Group a set of files by their first path segment BELOW `root`, so a directory stays whole
233
+ * whenever it fits.
234
+ *
235
+ * Files sitting DIRECTLY in `root` form their own group, and that group owns its FILES rather than
236
+ * `root`. Owning `root` would be an over-claim wherever `root` is a real directory — it is a prefix
237
+ * over every sibling group here too, so a finding in one of them would be attributed to this one —
238
+ * and at the SURVEY root, where `root` is the empty string, it is worse than that: read as a
239
+ * prefix, the empty root matches no path at all, so every finding a pass raised on a top-level file
240
+ * was dropped as out of scope, and the empty id it derived was falsy enough that the pass was
241
+ * dispatched with no manifest and no scope in the first place.
242
+ */
243
+ function groupByChildDirectory(files, root) {
244
+ const directories = new Map();
245
+ const loose = [];
246
+ const prefixLength = root ? root.length + 1 : 0;
247
+ for (const file of files) {
248
+ const rest = file.path.slice(prefixLength);
249
+ const slash = rest.indexOf('/');
250
+ if (slash === -1) {
251
+ loose.push(file);
252
+ continue;
253
+ }
254
+ const child = rest.slice(0, slash);
255
+ const key = root ? `${root}/${child}` : child;
256
+ const bucket = directories.get(key);
257
+ if (bucket)
258
+ bucket.push(file);
259
+ else
260
+ directories.set(key, [file]);
261
+ }
262
+ const groups = [...directories.entries()].map(([key, groupFiles]) => ({
263
+ key,
264
+ idBase: key,
265
+ roots: [key],
266
+ label: labelForRoot(key),
267
+ files: groupFiles,
268
+ }));
269
+ if (loose.length > 0) {
270
+ groups.push({
271
+ // A trailing slash sorts the loose group immediately before the child directories of the
272
+ // same root, and the survey root's loose group first of all.
273
+ key: root ? `${root}/` : '',
274
+ idBase: root ? `${root}/${LOOSE_FILES_SEGMENT}` : LOOSE_FILES_SEGMENT,
275
+ roots: loose.map((file) => file.path),
276
+ label: looseFilesLabel(root),
277
+ files: loose,
278
+ });
279
+ }
280
+ return groups.sort((a, b) => a.key.localeCompare(b.key));
281
+ }
282
+ /** A file group as a directory-sourced candidate. */
283
+ function directoryCandidate(group) {
284
+ return {
285
+ idBase: group.idBase,
286
+ roots: group.roots,
287
+ labels: [group.label],
288
+ files: group.files,
289
+ source: 'directory',
290
+ };
291
+ }
292
+ /**
293
+ * Split a candidate that is over the hard ceiling along its own sub-directories, recursively.
294
+ *
295
+ * A group that cannot be split further (one directory whose own files exceed the ceiling) is
296
+ * KEPT oversized rather than chopped at an arbitrary file boundary: a territory is meant to be a
297
+ * unit somebody could reason about, and half of one is worse for the finding bar than a big one.
298
+ */
299
+ function splitOversized(candidate) {
300
+ if (tokensOf(candidate.files) <= MAX_TERRITORY_TOKENS)
301
+ return [candidate];
302
+ const root = candidate.roots[0];
303
+ if (candidate.roots.length !== 1 || root === undefined) {
304
+ // A multi-root candidate over the ceiling is a blueprint module spanning several references
305
+ // (packing runs after this), so give each reference its own territory rather than chopping the
306
+ // module at a file boundary.
307
+ return candidate.roots
308
+ .map((r) => ({
309
+ idBase: r,
310
+ roots: [r],
311
+ labels: [labelForRoot(r)],
312
+ files: candidate.files.filter((f) => f.path === r || f.path.startsWith(`${r}/`)),
313
+ source: candidate.source,
314
+ }))
315
+ .filter((unpacked) => unpacked.files.length > 0)
316
+ .flatMap(splitOversized);
317
+ }
318
+ const groups = groupByChildDirectory(candidate.files, root);
319
+ if (groups.length <= 1)
320
+ return [candidate];
321
+ return groups.flatMap((group) => splitOversized({ ...directoryCandidate(group), source: candidate.source }));
322
+ }
323
+ /**
324
+ * Pack small candidates together up to the target size, keeping catalog order.
325
+ *
326
+ * Sibling directories of a few hundred lines each are not worth their own dispatch: eight angles
327
+ * over a five-file territory spends the pass budget on orientation. Packing is ordered rather
328
+ * than best-fit so two surveys of the same tree produce the same partition.
329
+ */
330
+ function packSmall(candidates) {
331
+ const packed = [];
332
+ for (const candidate of candidates) {
333
+ const previous = packed[packed.length - 1];
334
+ if (previous &&
335
+ previous.source === candidate.source &&
336
+ !isPackageRoot(candidate) &&
337
+ !isPackageRoot(previous) &&
338
+ tokensOf(previous.files) + tokensOf(candidate.files) <= TARGET_TERRITORY_TOKENS) {
339
+ previous.roots.push(...candidate.roots);
340
+ previous.labels.push(...candidate.labels);
341
+ previous.files.push(...candidate.files);
342
+ continue;
343
+ }
344
+ packed.push({
345
+ idBase: candidate.idBase,
346
+ roots: [...candidate.roots],
347
+ labels: [...candidate.labels],
348
+ files: [...candidate.files],
349
+ source: candidate.source,
350
+ });
351
+ }
352
+ return packed;
353
+ }
354
+ /**
355
+ * A blueprint module's references, in the SURVEY root's frame.
356
+ *
357
+ * A reference is written by whoever ran the Blueprinter, and the two authorings differ by exactly
358
+ * the service prefix: an agent rooted at the service directory writes `src/billing`, while one
359
+ * that saw the repository root writes `packages/api/src/billing`. Both name the same code, so the
360
+ * prefix is stripped where it is present rather than assumed either way. A reference that matches
361
+ * nothing is dropped downstream, which is what makes normalising safe: nothing here can move a
362
+ * module onto code it does not name.
363
+ */
364
+ function blueprintReferenceRoots(module, serviceRoot) {
365
+ return (module.references ?? [])
366
+ .map((reference) => normalizePath(reference))
367
+ .map((reference) => serviceRoot && (reference === serviceRoot || reference.startsWith(`${serviceRoot}/`))
368
+ ? reference.slice(serviceRoot.length).replace(/^\/+/, '')
369
+ : reference)
370
+ .filter((reference) => reference.length > 0);
371
+ }
372
+ /**
373
+ * The blueprint's own decomposition as candidates, plus whatever it does not cover.
374
+ *
375
+ * A blueprint's `references` were written by a model against an older tree, so a reference the
376
+ * tree no longer has is DROPPED and its module falls through to the directory rule for its part
377
+ * of the tree, never guessed onto a new home. Anything no module claims is partitioned by the
378
+ * directory rule too, so a partial blueprint narrows the heuristic rather than replacing it.
379
+ */
380
+ function blueprintCandidates(files, blueprint, serviceRoot) {
381
+ const claimed = new Set();
382
+ const candidates = [];
383
+ for (const module of blueprint.modules ?? []) {
384
+ const roots = blueprintReferenceRoots(module, serviceRoot);
385
+ const moduleFiles = files.filter((file) => !claimed.has(file.path) &&
386
+ roots.some((root) => file.path === root || file.path.startsWith(`${root}/`)));
387
+ if (moduleFiles.length === 0)
388
+ continue;
389
+ for (const file of moduleFiles)
390
+ claimed.add(file.path);
391
+ // The module NAME is both the better label and the better id stem: it is what the person who
392
+ // decomposed the service called this, and unlike the first reference it distinguishes two
393
+ // modules that happen to share one.
394
+ const name = module.name?.trim() ?? '';
395
+ candidates.push({
396
+ idBase: name || (roots[0] ?? ''),
397
+ roots,
398
+ labels: [name || roots.map(labelForRoot).join(', ')],
399
+ files: moduleFiles,
400
+ source: 'blueprint',
401
+ });
402
+ }
403
+ return { candidates, unclaimed: files.filter((file) => !claimed.has(file.path)) };
404
+ }
405
+ /**
406
+ * Partition a repository tree into the territories an expedition fishes.
407
+ *
408
+ * Blueprint modules first when the repository has a blueprint, then package and directory
409
+ * boundaries under the survey root, sized by the tree's blob bytes. A codebase that fits one
410
+ * territory yields exactly one, and the expedition it plans is today's.
411
+ */
412
+ export function partitionCodebase(tree, options = {}) {
413
+ const serviceRoot = normalizePath(options.serviceDirectory ?? '');
414
+ const files = fishableFiles(tree.entries, serviceRoot);
415
+ const shas = entryShas(tree.entries);
416
+ const filesByTerritory = new Map();
417
+ if (tokensOf(files) <= MAX_TERRITORY_TOKENS) {
418
+ const only = wholeCodebaseTerritory(files);
419
+ filesByTerritory.set(only.id, files);
420
+ return { territories: [only], filesByTerritory, treeTruncated: tree.truncated };
421
+ }
422
+ const blueprint = options.blueprint
423
+ ? blueprintCandidates(files, options.blueprint, serviceRoot)
424
+ : { candidates: [], unclaimed: files };
425
+ const byDirectory = groupByChildDirectory(blueprint.unclaimed, '').map(directoryCandidate);
426
+ const candidates = packSmall([...blueprint.candidates, ...byDirectory].flatMap((candidate) => splitOversized(candidate)));
427
+ const usedIds = new Set();
428
+ const territories = candidates.map((candidate) => {
429
+ const id = uniqueTerritoryId(territorySlug(candidate.idBase), usedIds);
430
+ filesByTerritory.set(id, candidate.files);
431
+ return {
432
+ id,
433
+ label: candidate.labels.join(', '),
434
+ roots: candidate.roots,
435
+ fileCount: candidate.files.length,
436
+ approxTokens: tokensOf(candidate.files),
437
+ source: candidate.source,
438
+ // The sha map is keyed in the tree's own repo-relative frame, so the survey-framed root goes
439
+ // back through the service prefix to look itself up.
440
+ subtreeShas: candidate.roots.map((root) => shas.get(serviceRoot ? `${serviceRoot}/${root}` : root) ?? ''),
441
+ };
442
+ });
443
+ return { territories, filesByTerritory, treeTruncated: tree.truncated };
444
+ }
445
+ /**
446
+ * Build the pass list from the territories and the angles, TERRITORY-MAJOR, trimmed to the pass
447
+ * budget.
448
+ *
449
+ * Territory-major so a human gets a complete answer for one territory early and can start its
450
+ * fixes while the rest is still being fished, which is what the separate-dispatch design is for.
451
+ * The budget trims from the BOTTOM of the order rather than the middle, and what it cuts is
452
+ * returned as unfished: a cap silent about its tail teaches the reader that the tail was clean.
453
+ *
454
+ * A single whole-codebase territory yields the angles unchanged, with no territory stamped on
455
+ * them, so a small codebase's plan is field-for-field the one that shipped before territories.
456
+ */
457
+ export function planTerritoryPasses(input) {
458
+ const { territories, angles, passBudget } = input;
459
+ const only = territories[0];
460
+ if (territories.length === 0 || (territories.length === 1 && only?.source === 'whole-codebase')) {
461
+ // The whole-codebase branch names its cut cells from the ANGLES rather than from a cell list,
462
+ // because a survey that could not read the repository hands over no territory to build cells
463
+ // from — and the budget can cut angles all the same. Deriving the tail from the cells left the
464
+ // one case the record exists for, a cut nobody can see, as the one case it did not cover.
465
+ return {
466
+ phases: angles.slice(0, passBudget),
467
+ unfished: angles.slice(passBudget).map((phase) => ({
468
+ territoryId: only?.id ?? WHOLE_CODEBASE_TERRITORY_ID,
469
+ territoryLabel: only?.label ?? 'Whole codebase',
470
+ phaseId: phase.id,
471
+ phaseTitle: phase.title,
472
+ })),
473
+ plannedCells: angles.length,
474
+ };
475
+ }
476
+ const cells = territories.flatMap((territory) => angles.map((phase) => ({ territory, phase })));
477
+ const kept = cells.slice(0, passBudget);
478
+ return {
479
+ phases: kept.map(({ territory, phase }) => ({
480
+ ...phase,
481
+ territoryId: territory.id,
482
+ territoryLabel: territory.label,
483
+ })),
484
+ unfished: unfishedFor(cells.slice(passBudget)),
485
+ plannedCells: cells.length,
486
+ };
487
+ }
488
+ function unfishedFor(cells) {
489
+ return cells.map(({ territory, phase }) => ({
490
+ territoryId: territory.id,
491
+ territoryLabel: territory.label,
492
+ phaseId: phase.id,
493
+ phaseTitle: phase.title,
494
+ }));
495
+ }
496
+ /**
497
+ * Order the territories a large expedition fishes, most worth fishing first.
498
+ *
499
+ * The creator's `fishingFocus` comes first, because naming a subsystem is the deliberate act and
500
+ * a budget that cut it would be cutting the one thing they asked for. Size decides the rest: with
501
+ * no scout rating relevance yet, the biggest territory is the one most likely to hide something,
502
+ * and it is a fact the platform can compute rather than a judgement it would be inventing.
503
+ */
504
+ export function prioritiseTerritories(territories, focus) {
505
+ const needles = (focus ?? '')
506
+ .toLowerCase()
507
+ .split(/[\s,;]+/)
508
+ .map((needle) => needle.trim())
509
+ .filter((needle) => needle.length >= 3);
510
+ const focused = (territory) => needles.some((needle) => territory.label.toLowerCase().includes(needle) ||
511
+ (territory.roots ?? []).some((root) => root.toLowerCase().includes(needle)));
512
+ return [...territories].sort((a, b) => {
513
+ const byFocus = Number(focused(b)) - Number(focused(a));
514
+ if (byFocus !== 0)
515
+ return byFocus;
516
+ return (b.approxTokens ?? 0) - (a.approxTokens ?? 0);
517
+ });
518
+ }
519
+ //# sourceMappingURL=bugFishingTerritories.logic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bugFishingTerritories.logic.js","sourceRoot":"","sources":["../../../src/modules/execution/bugFishingTerritories.logic.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CA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AAS,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC9C,CAAC,SAAS,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAC9E,CAAA;IACH,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QACvD,IAAI,OAAO,KAAK,CAAC;YAAE,OAAO,OAAO,CAAA;QACjC,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -59,37 +59,6 @@ export interface DispatchPromptSettingsDeps {
59
59
  localModelDeclarationsCache?: GroupCacheHandle<LocalModelDeclarationsCacheValue>;
60
60
  logger?: Logger;
61
61
  }
62
- /**
63
- * The base system prompt this dispatch replaces the shipped one with, or undefined to run the
64
- * shipped one. Two tiers converge here — the deployment's registered agent-kind VARIANT for this
65
- * step and the WORKSPACE's edited prompt for the kind — because they are the same unit of text.
66
- *
67
- * The head revision's `text` is `null` when the workspace deliberately went BACK to the built-in —
68
- * a real state, distinct from never having edited the kind, which is why it is recorded rather than
69
- * deleted. Both resolve to "no override" here, so a revert keeps tracking the shipped prompt as the
70
- * product bumps it instead of pinning a stale copy.
71
- *
72
- * MUTATES the step to pin what it resolved (`promptRevision`, `promptVariant`), because neither can
73
- * be re-derived afterwards: the prompt log is append-only, so re-reading it at any later point — a
74
- * Kaizen grading, a debug read, a post-mortem — would answer about whatever landed since. The
75
- * VARIANT is pinned for a second reason: `stepOptions.agentVariantId` is what the pipeline ASKED
76
- * for, and a workspace override or a withdrawal can mean the variant's text never reached the
77
- * prompt, so only a pin taken HERE can answer what the step actually ran under.
78
- */
79
- export declare function resolveDispatchSystemPrompt(deps: DispatchPromptSettingsDeps, workspaceId: string, agentKind: string, step: PipelineStep): Promise<{
80
- systemPromptOverride?: string;
81
- }>;
82
- /**
83
- * The output-token ceiling this dispatch runs under, or undefined to run the deployment routing
84
- * default.
85
- *
86
- * NARROWEST TIER WINS: the step's own `stepOptions.maxOutputTokens` beats the workspace's per-kind
87
- * setting, which beats the deployment routing ceiling. The step value is read WITHOUT touching the
88
- * repository, so a pipeline that pins its own budget costs no query.
89
- */
90
- export declare function resolveDispatchMaxOutputTokens(deps: DispatchPromptSettingsDeps, workspaceId: string, agentKind: string, step: PipelineStep): Promise<{
91
- maxOutputTokens?: number;
92
- }>;
93
62
  /**
94
63
  * The order this dispatch prefers a model's ROUTES in, or undefined to walk the deployment's
95
64
  * default order.
@@ -1 +1 @@
1
- {"version":3,"file":"dispatchPromptSettings.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/dispatchPromptSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,KAAK,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gCAAgC,EAChC,4BAA4B,EAC5B,MAAM,EACN,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,gCAAgC,EACjC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAyB5D,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACrC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;IAC3C,sBAAsB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAC3D;AAED;;;;;G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jB,OAAO,CAAC;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAKvC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,iCAAiC,CACrD,IAAI,EAAE,0BAA0B,EAChC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,GACX,OAAO,CAAC;IAAE,kBAAkB,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,CAAC,CAS1D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,qCAAqC,CACzD,IAAI,EAAE,0BAA0B,EAChC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,OAAO,CAAC;IAAE,sBAAsB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAAE,CAAC,CAYzE"}
1
+ {"version":3,"file":"dispatchPromptSettings.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/dispatchPromptSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,KAAK,EACL,gBAAgB,EAChB,sBAAsB,EACtB,gCAAgC,EAChC,4BAA4B,EAC5B,MAAM,EACN,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,EACZ,gCAAgC,EACjC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAyB5D,wFAAwF;AACxF,MAAM,WAAW,sBAAsB;IACrC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,kBAAkB,CAAC,EAAE,SAAS,WAAW,EAAE,CAAA;IAC3C,sBAAsB,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAC3D;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,4FAA4F;IAC5F,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,E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35
  * for, and a workspace override or a withdrawal can mean the variant's text never reached the
36
36
  * prompt, so only a pin taken HERE can answer what the step actually ran under.
37
37
  */
38
- export async function resolveDispatchSystemPrompt(deps, workspaceId, agentKind, step) {
38
+ async function resolveDispatchSystemPrompt(deps, workspaceId, agentKind, step) {
39
39
  const head = await deps.agentPrompts?.head(workspaceId, agentKind);
40
40
  // Cleared, not left stale: a re-dispatch after the workspace reverted must not keep reporting
41
41
  // the revision the previous attempt ran under.
@@ -85,7 +85,7 @@ export async function resolveDispatchSystemPrompt(deps, workspaceId, agentKind,
85
85
  * setting, which beats the deployment routing ceiling. The step value is read WITHOUT touching the
86
86
  * repository, so a pipeline that pins its own budget costs no query.
87
87
  */
88
- export async function resolveDispatchMaxOutputTokens(deps, workspaceId, agentKind, step) {
88
+ async function resolveDispatchMaxOutputTokens(deps, workspaceId, agentKind, step) {
89
89
  const fromStep = step.stepOptions?.maxOutputTokens;
90
90
  if (fromStep != null)
91
91
  return { maxOutputTokens: fromStep };
@@ -1 +1 @@
1
- {"version":3,"file":"dispatchPromptSettings.js","sourceRoot":"","sources":["../../../src/modules/execution/dispatchPromptSettings.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAA;AAEtE,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAA;AA+CvF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,IAAgC,EAChC,MAA8B;IAE9B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,CAAA;IACnE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC9D,2BAA2B,CAAC,IAAI,EAAE,WAAW,EAAE,S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AC,aAAa,EAAE,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IACxE,OAAO,UAAU,EAAE,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACnG,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,IAAgC,EAChC,WAAmB,EACnB,KAAY;IAEZ,IAAI,CAAC,IAAI,CAAC,YAAY;QAAE,OAAO,EAAE,CAAA;IACjC,MAAM,UAAU,GAAG,MAAM,+BAA+B,CACtD,IAAI,CAAC,YAAY,EACjB,WAAW,EACX,KAAK,CAAC,aAAa,EACnB,IAAI,CAAC,gBAAgB,CACtB,CAAA;IACD,OAAO,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACrE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,IAAgC,EAChC,iBAA4C;IAE5C,IAAI,CAAC,IAAI,CAAC,mBAAmB,IAAI,CAAC,iBAAiB;QAAE,OAAO,EAAE,CAAA;IAC9D,MAAM,QAAQ,GAAG,MAAM,gCAAgC,CACrD,IAAI,CAAC,2BAA2B,EAChC,IAAI,CAAC,mBAAmB,EACxB,iBAAiB,CAClB,CAAA;IACD,8FAA8F;IAC9F,8FAA8F;IAC9F,gGAAgG;IAChG,uEAAuE;IACvE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,sBAAsB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACpE,CAAC"}
1
+ {"version":3,"file":"dispatchPromptSettings.js","sourceRoot":"","sources":["../../../src/modules/execution/dispatchPromptSettings.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gCAA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CAAC,iBAAiB;QAAE,OAAO,EAAE,CAAA;IAC9D,MAAM,QAAQ,GAAG,MAAM,gCAAgC,CACrD,IAAI,CAAC,2BAA2B,EAChC,IAAI,CAAC,mBAAmB,EACxB,iBAAiB,CAClB,CAAA;IACD,8FAA8F;IAC9F,8FAA8F;IAC9F,gGAAgG;IAChG,uEAAuE;IACvE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,sBAAsB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACpE,CAAC"}
@@ -11,6 +11,7 @@ import type { BinaryCandidateController } from './BinaryCandidateController.js';
11
11
  import type { ForkDecisionController } from './ForkDecisionController.js';
12
12
  import { PrReviewController } from './PrReviewController.js';
13
13
  import { BugFishingController } from './BugFishingController.js';
14
+ import type { CodebaseSurveyResult } from './bugFishingSurvey.js';
14
15
  import type { InterviewGateController } from './InterviewGateController.js';
15
16
  import type { TesterController } from './TesterController.js';
16
17
  import type { RalphController } from './RalphController.js';
@@ -68,6 +69,13 @@ export interface DispatcherRegistryDeps {
68
69
  handleForkDecisionPhase: (ctx: StepHandlerContext) => Promise<AdvanceResult>;
69
70
  handlePrReviewResolution: (ctx: StepHandlerContext) => Promise<AdvanceResult>;
70
71
  handleAgentStep: (ctx: StepHandlerContext, dispatchKind?: string, augmentContext?: (context: AgentRunContext) => void) => Promise<AdvanceResult>;
72
+ /**
73
+ * Survey the codebase a block's run targets: the repository tree partitioned into the
74
+ * TERRITORIES a bug-fishing expedition fishes. Bound to the dispatcher, which owns the run's
75
+ * repo resolution; the read is cached per ref, so the dispatch and completion paths of one
76
+ * expedition share it.
77
+ */
78
+ surveyCodebase: (workspaceId: string, blockId: string) => Promise<CodebaseSurveyResult>;
71
79
  ingestBlueprint: (workspaceId: string, blockId: string, rawService: unknown) => Promise<void>;
72
80
  ingestSpec: (workspaceId: string, rawDoc: unknown) => Promise<void>;
73
81
  }