@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.
- package/dist/modules/board/newServiceFrameDefaults.d.ts +0 -5
- package/dist/modules/board/newServiceFrameDefaults.d.ts.map +1 -1
- package/dist/modules/board/newServiceFrameDefaults.js +1 -1
- package/dist/modules/board/newServiceFrameDefaults.js.map +1 -1
- package/dist/modules/brainstorm/brainstorm.logic.d.ts +0 -7
- package/dist/modules/brainstorm/brainstorm.logic.d.ts.map +1 -1
- package/dist/modules/brainstorm/brainstorm.logic.js +1 -1
- package/dist/modules/brainstorm/brainstorm.logic.js.map +1 -1
- package/dist/modules/execution/BugFishingController.d.ts +35 -9
- package/dist/modules/execution/BugFishingController.d.ts.map +1 -1
- package/dist/modules/execution/BugFishingController.js +49 -14
- package/dist/modules/execution/BugFishingController.js.map +1 -1
- package/dist/modules/execution/DeployFixController.d.ts +0 -6
- package/dist/modules/execution/DeployFixController.d.ts.map +1 -1
- package/dist/modules/execution/DeployFixController.js +1 -1
- package/dist/modules/execution/DeployFixController.js.map +1 -1
- package/dist/modules/execution/InterviewGateController.d.ts +2 -1
- package/dist/modules/execution/InterviewGateController.d.ts.map +1 -1
- package/dist/modules/execution/RunDispatcher.d.ts.map +1 -1
- package/dist/modules/execution/RunDispatcher.js +7 -0
- package/dist/modules/execution/RunDispatcher.js.map +1 -1
- package/dist/modules/execution/block-reference-set.d.ts +0 -2
- package/dist/modules/execution/block-reference-set.d.ts.map +1 -1
- package/dist/modules/execution/block-reference-set.js +1 -1
- package/dist/modules/execution/block-reference-set.js.map +1 -1
- package/dist/modules/execution/bugFishing.logic.d.ts +37 -3
- package/dist/modules/execution/bugFishing.logic.d.ts.map +1 -1
- package/dist/modules/execution/bugFishing.logic.js +124 -23
- package/dist/modules/execution/bugFishing.logic.js.map +1 -1
- package/dist/modules/execution/bugFishingPass.d.ts +35 -0
- package/dist/modules/execution/bugFishingPass.d.ts.map +1 -0
- package/dist/modules/execution/bugFishingPass.js +45 -0
- package/dist/modules/execution/bugFishingPass.js.map +1 -0
- package/dist/modules/execution/bugFishingSurvey.d.ts +87 -0
- package/dist/modules/execution/bugFishingSurvey.d.ts.map +1 -0
- package/dist/modules/execution/bugFishingSurvey.js +130 -0
- package/dist/modules/execution/bugFishingSurvey.js.map +1 -0
- package/dist/modules/execution/bugFishingTerritories.logic.d.ts +89 -0
- package/dist/modules/execution/bugFishingTerritories.logic.d.ts.map +1 -0
- package/dist/modules/execution/bugFishingTerritories.logic.js +519 -0
- package/dist/modules/execution/bugFishingTerritories.logic.js.map +1 -0
- package/dist/modules/execution/dispatchPromptSettings.d.ts +0 -31
- package/dist/modules/execution/dispatchPromptSettings.d.ts.map +1 -1
- package/dist/modules/execution/dispatchPromptSettings.js +2 -2
- package/dist/modules/execution/dispatchPromptSettings.js.map +1 -1
- package/dist/modules/execution/dispatcher-registries.d.ts +8 -0
- package/dist/modules/execution/dispatcher-registries.d.ts.map +1 -1
- package/dist/modules/execution/dispatcher-registries.js +52 -8
- package/dist/modules/execution/dispatcher-registries.js.map +1 -1
- package/dist/modules/execution/linked-context.d.ts +3 -6
- package/dist/modules/execution/linked-context.d.ts.map +1 -1
- package/dist/modules/execution/linked-context.js +2 -2
- package/dist/modules/execution/linked-context.js.map +1 -1
- package/dist/modules/execution/prReport.commands.d.ts.map +1 -1
- package/dist/modules/execution/prReport.commands.js +2 -35
- package/dist/modules/execution/prReport.commands.js.map +1 -1
- package/dist/modules/execution/prReport.environments.d.ts.map +1 -1
- package/dist/modules/execution/prReport.environments.js +1 -5
- package/dist/modules/execution/prReport.environments.js.map +1 -1
- package/dist/modules/execution/prReport.logic.d.ts.map +1 -1
- package/dist/modules/execution/prReport.logic.js +1 -5
- package/dist/modules/execution/prReport.logic.js.map +1 -1
- package/dist/modules/execution/prReport.steps.d.ts +2 -0
- package/dist/modules/execution/prReport.steps.d.ts.map +1 -1
- package/dist/modules/execution/prReport.steps.js +5 -1
- package/dist/modules/execution/prReport.steps.js.map +1 -1
- package/dist/modules/execution/reproductionProof.logic.d.ts +0 -2
- package/dist/modules/execution/reproductionProof.logic.d.ts.map +1 -1
- package/dist/modules/execution/reproductionProof.logic.js +1 -1
- package/dist/modules/execution/reproductionProof.logic.js.map +1 -1
- package/dist/modules/execution/run-binary-output.d.ts +0 -21
- package/dist/modules/execution/run-binary-output.d.ts.map +1 -1
- package/dist/modules/execution/run-binary-output.js +1 -1
- package/dist/modules/execution/run-binary-output.js.map +1 -1
- package/dist/modules/execution/runMode.logic.d.ts +2 -13
- package/dist/modules/execution/runMode.logic.d.ts.map +1 -1
- package/dist/modules/execution/runMode.logic.js +1 -1
- package/dist/modules/execution/runMode.logic.js.map +1 -1
- package/dist/modules/initiative/initiative.logic.d.ts +0 -6
- package/dist/modules/initiative/initiative.logic.d.ts.map +1 -1
- package/dist/modules/initiative/initiative.logic.js +2 -6
- package/dist/modules/initiative/initiative.logic.js.map +1 -1
- package/dist/modules/kaizen/kaizen.logic.d.ts +0 -2
- package/dist/modules/kaizen/kaizen.logic.d.ts.map +1 -1
- package/dist/modules/kaizen/kaizen.logic.js +1 -1
- package/dist/modules/kaizen/kaizen.logic.js.map +1 -1
- package/dist/modules/merge/MergeTrackRecordService.d.ts +2 -1
- package/dist/modules/merge/MergeTrackRecordService.d.ts.map +1 -1
- package/dist/modules/merge/riskPolicyResolution.d.ts +2 -3
- package/dist/modules/merge/riskPolicyResolution.d.ts.map +1 -1
- package/dist/modules/merge/riskPolicyResolution.js +1 -1
- package/dist/modules/merge/riskPolicyResolution.js.map +1 -1
- package/dist/modules/observability/LlmObservabilityService.d.ts +2 -1
- package/dist/modules/observability/LlmObservabilityService.d.ts.map +1 -1
- package/dist/modules/pipelines/pipelineShape.d.ts +0 -18
- package/dist/modules/pipelines/pipelineShape.d.ts.map +1 -1
- package/dist/modules/pipelines/pipelineShape.js +1 -1
- package/dist/modules/pipelines/pipelineShape.js.map +1 -1
- package/dist/modules/requirements/requirements.logic.d.ts +0 -6
- package/dist/modules/requirements/requirements.logic.d.ts.map +1 -1
- package/dist/modules/requirements/requirements.logic.js +1 -1
- package/dist/modules/requirements/requirements.logic.js.map +1 -1
- package/dist/modules/sandbox/sandbox.logic.d.ts +1 -3
- package/dist/modules/sandbox/sandbox.logic.d.ts.map +1 -1
- package/dist/modules/sandbox/sandbox.logic.js +1 -1
- package/dist/modules/sandbox/sandbox.logic.js.map +1 -1
- package/dist/modules/useCases/LlmInlineUseCaseGenerator.d.ts +0 -8
- package/dist/modules/useCases/LlmInlineUseCaseGenerator.d.ts.map +1 -1
- package/dist/modules/useCases/LlmInlineUseCaseGenerator.js +1 -1
- package/dist/modules/useCases/LlmInlineUseCaseGenerator.js.map +1 -1
- package/dist/validation/validateRegistrations.d.ts +2 -1
- package/dist/validation/validateRegistrations.d.ts.map +1 -1
- package/package.json +11 -11
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BUG_FISHING_TERRITORY_CONTEXT_FILE, renderBugFishingTerritoryContext, } from '@cat-factory/agents';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the pass a planned phase describes against the survey.
|
|
4
|
+
*
|
|
5
|
+
* A phase with no `territoryId` is the PASS-THROUGH: a codebase small enough to fish whole, or an
|
|
6
|
+
* expedition planned before territories existed, or one whose survey could not read the
|
|
7
|
+
* repository. All three get no manifest, no scope and no territory in the brief, which is
|
|
8
|
+
* byte-for-byte the dispatch that shipped before this feature.
|
|
9
|
+
*
|
|
10
|
+
* A phase whose territory the CURRENT survey no longer produces (the tree moved between passes,
|
|
11
|
+
* or a fix merged and re-shaped a directory) falls back to the roots the run itself recorded, and
|
|
12
|
+
* gets no file manifest. That is deliberate: the run's own record is the better witness of what
|
|
13
|
+
* it planned, and a manifest re-derived from a different partition would describe a territory
|
|
14
|
+
* this pass was never given.
|
|
15
|
+
*/
|
|
16
|
+
export function bugFishingPassScope(state, phase, survey) {
|
|
17
|
+
const territoryId = phase.territoryId;
|
|
18
|
+
if (!territoryId)
|
|
19
|
+
return { territory: null, contextFile: null, scope: undefined };
|
|
20
|
+
const recorded = (state.territories ?? []).find((t) => t.id === territoryId);
|
|
21
|
+
const roots = recorded?.roots ?? [];
|
|
22
|
+
const label = phase.territoryLabel || recorded?.label || territoryId;
|
|
23
|
+
const files = (survey.filesByTerritory.get(territoryId) ?? []).map((file) => file.path);
|
|
24
|
+
const scope = { territoryId, roots, manifest: new Set(files) };
|
|
25
|
+
if (files.length === 0) {
|
|
26
|
+
// The survey has no manifest for this territory any more. The pass still owns the roots (the
|
|
27
|
+
// brief says so, and the scope enforces it); it just gets no map, which costs it the
|
|
28
|
+
// orientation saving rather than its correctness.
|
|
29
|
+
return { territory: { label, roots }, contextFile: null, scope };
|
|
30
|
+
}
|
|
31
|
+
const contextFile = {
|
|
32
|
+
path: BUG_FISHING_TERRITORY_CONTEXT_FILE,
|
|
33
|
+
content: renderBugFishingTerritoryContext({
|
|
34
|
+
territory: {
|
|
35
|
+
label,
|
|
36
|
+
roots,
|
|
37
|
+
...(recorded?.approxTokens !== undefined ? { approxTokens: recorded.approxTokens } : {}),
|
|
38
|
+
},
|
|
39
|
+
files,
|
|
40
|
+
neighbours: (state.territories ?? []).filter((t) => t.id !== territoryId).map((t) => t.label),
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
return { territory: { label, roots }, contextFile, scope };
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=bugFishingPass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugFishingPass.js","sourceRoot":"","sources":["../../../src/modules/execution/bugFishingPass.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,gCAAgC,GACjC,MAAM,qBAAqB,CAAA;AA4B5B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAA0B,EAC1B,KAAsB,EACtB,MAA4B;IAE5B,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAA;IAC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AC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;SAC9F,CAAC;KACH,CAAA;IACD,OAAO,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { BugFishingTerritory, Logger, RepoFiles, RunRepoContext } from '@cat-factory/kernel';
|
|
2
|
+
import { type SurveyedFile } from './bugFishingTerritories.logic.js';
|
|
3
|
+
/** What a survey produced, plus what it could not do. */
|
|
4
|
+
export interface CodebaseSurveyResult {
|
|
5
|
+
/** The partition, most worth fishing first once the caller has prioritised it. */
|
|
6
|
+
territories: BugFishingTerritory[];
|
|
7
|
+
/**
|
|
8
|
+
* Every fishable file of each territory, for the manifest and the coverage intersection. Paths
|
|
9
|
+
* are relative to the SURVEY ROOT (the service's own directory in a monorepo), which is the
|
|
10
|
+
* frame the agent's checkout is rooted at.
|
|
11
|
+
*/
|
|
12
|
+
filesByTerritory: Map<string, SurveyedFile[]>;
|
|
13
|
+
/** True when the provider cut the tree short: the territories cover a PREFIX of the codebase. */
|
|
14
|
+
treeTruncated: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Why the survey could not read the codebase, when it could not. Null on a real survey.
|
|
17
|
+
*
|
|
18
|
+
* Stated rather than left for the one-territory plan to imply, because the plan is the same
|
|
19
|
+
* VALUE for opposite FACTS: "this repository is small enough to fish whole" and "nobody could
|
|
20
|
+
* see this repository" produce an identical partition, and only the second is something a human
|
|
21
|
+
* has to act on.
|
|
22
|
+
*/
|
|
23
|
+
unavailableReason: string | null;
|
|
24
|
+
}
|
|
25
|
+
/** What the survey needs to read a codebase. */
|
|
26
|
+
export interface CodebaseSurveyInput {
|
|
27
|
+
/**
|
|
28
|
+
* The run's checkout-free repo facade, or null when no repository resolves for the block (no
|
|
29
|
+
* VCS connected, or the deployment wires no repo context).
|
|
30
|
+
*/
|
|
31
|
+
repo: RepoFiles | null;
|
|
32
|
+
/** The branch the expedition fishes: the base branch its read-only clone is taken from. */
|
|
33
|
+
branch: string;
|
|
34
|
+
/** The monorepo subdirectory the service lives in, when it has one. */
|
|
35
|
+
serviceDirectory?: string | null;
|
|
36
|
+
logger?: Logger;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The survey a caller gets when the codebase cannot be read: ONE whole-codebase territory,
|
|
40
|
+
* carrying the reason.
|
|
41
|
+
*
|
|
42
|
+
* A pass-through is the correct disposition for an unwired capability, and it must be invisible
|
|
43
|
+
* to the domain: the expedition this plans is byte-for-byte the eight-angle hunt that shipped
|
|
44
|
+
* before territories existed. What it must not be is silent, which is what `reason` is for.
|
|
45
|
+
*
|
|
46
|
+
* ONE territory rather than none, and the difference is not cosmetic: an empty list is what the
|
|
47
|
+
* step then persists as `territories: []`, the value the schema documents as forbidden because it
|
|
48
|
+
* claims the codebase was surveyed and found to contain nothing, and it is also what leaves the
|
|
49
|
+
* planner with no cell to name when the pass budget cuts an angle. The territory's counts are
|
|
50
|
+
* zero because nobody could count them; `unavailableReason` is what says so, and it is the only
|
|
51
|
+
* thing that tells this apart from a genuinely tiny repository.
|
|
52
|
+
*
|
|
53
|
+
* Exported because the seam that RESOLVES the run's repository sits outside this module and can
|
|
54
|
+
* fail on its own terms (an unlinked block chain refuses with a `ValidationError`), and this
|
|
55
|
+
* module's contract is that a survey never throws. That caller states its own reason through here
|
|
56
|
+
* rather than rebuilding the shape.
|
|
57
|
+
*/
|
|
58
|
+
export declare function unavailableSurvey(reason: string): CodebaseSurveyResult;
|
|
59
|
+
/**
|
|
60
|
+
* Read the repository tree and partition it into territories.
|
|
61
|
+
*
|
|
62
|
+
* Never throws: a tree read that fails degrades to the whole-codebase expedition WITH the cause
|
|
63
|
+
* recorded, because an expedition that cannot be partitioned is still worth running and a run
|
|
64
|
+
* that failed at planning because a contents API blipped is not. The blueprint read degrades the
|
|
65
|
+
* same way, one level finer: no blueprint means the directory heuristic, which is what a
|
|
66
|
+
* repository that was never blueprinted gets anyway.
|
|
67
|
+
*/
|
|
68
|
+
export declare function surveyCodebase(input: CodebaseSurveyInput): Promise<CodebaseSurveyResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Survey the codebase a RUN targets: resolve its repository, then partition the tree.
|
|
71
|
+
*
|
|
72
|
+
* The repo resolution is its own refusal and does not belong to a survey. An unlinked block chain
|
|
73
|
+
* throws a `ValidationError` rather than answering null, deliberately, because guessing a repo once
|
|
74
|
+
* pushed a task into someone else's; that refusal belongs to a DISPATCH, where a human can act on
|
|
75
|
+
* it. This module's contract is the opposite one, that a survey never throws, and its callers
|
|
76
|
+
* include the COMPLETION path of a pass that has already run and has nothing left to refuse.
|
|
77
|
+
*
|
|
78
|
+
* Here rather than on the dispatcher so the two halves of "never throws" sit together, and so the
|
|
79
|
+
* dispatcher keeps only the binding: which repo resolver, which logger.
|
|
80
|
+
*/
|
|
81
|
+
export declare function surveyRunCodebase(input: {
|
|
82
|
+
/** The run's repo resolution, bound to one workspace and block by the caller. */
|
|
83
|
+
resolveRunRepo: () => Promise<RunRepoContext | null>;
|
|
84
|
+
/** Bind the block id on it: everything below logs into this scope. */
|
|
85
|
+
logger?: Logger;
|
|
86
|
+
}): Promise<CodebaseSurveyResult>;
|
|
87
|
+
//# sourceMappingURL=bugFishingSurvey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugFishingSurvey.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/bugFishingSurvey.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,cAAc,EACf,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,kCAAkC,CAAA;AAiBzC,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,WAAW,EAAE,mBAAmB,EAAE,CAAA;IAClC;;;;OAIG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;IAC7C,iGAAiG;IACjG,aAAa,EAAE,OAAO,CAAA;IACtB;;;;;;;OAOG;IACH,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IACtB,2FAA2F;IAC3F,MAAM,EAAE,MAAM,CAAA;IACd,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAQtE;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAgC9F;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAC7C,iFAAiF;IACjF,cAAc,EAAE,MAAM,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;IACpD,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAiBhC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { BLUEPRINT_JSON_PATH, safeParseBlueprintService } from '@cat-factory/contracts';
|
|
2
|
+
import { describeError, noopLogger } from '@cat-factory/kernel';
|
|
3
|
+
import { partitionCodebase, wholeCodebaseTerritory, } from './bugFishingTerritories.logic.js';
|
|
4
|
+
/**
|
|
5
|
+
* The survey a caller gets when the codebase cannot be read: ONE whole-codebase territory,
|
|
6
|
+
* carrying the reason.
|
|
7
|
+
*
|
|
8
|
+
* A pass-through is the correct disposition for an unwired capability, and it must be invisible
|
|
9
|
+
* to the domain: the expedition this plans is byte-for-byte the eight-angle hunt that shipped
|
|
10
|
+
* before territories existed. What it must not be is silent, which is what `reason` is for.
|
|
11
|
+
*
|
|
12
|
+
* ONE territory rather than none, and the difference is not cosmetic: an empty list is what the
|
|
13
|
+
* step then persists as `territories: []`, the value the schema documents as forbidden because it
|
|
14
|
+
* claims the codebase was surveyed and found to contain nothing, and it is also what leaves the
|
|
15
|
+
* planner with no cell to name when the pass budget cuts an angle. The territory's counts are
|
|
16
|
+
* zero because nobody could count them; `unavailableReason` is what says so, and it is the only
|
|
17
|
+
* thing that tells this apart from a genuinely tiny repository.
|
|
18
|
+
*
|
|
19
|
+
* Exported because the seam that RESOLVES the run's repository sits outside this module and can
|
|
20
|
+
* fail on its own terms (an unlinked block chain refuses with a `ValidationError`), and this
|
|
21
|
+
* module's contract is that a survey never throws. That caller states its own reason through here
|
|
22
|
+
* rather than rebuilding the shape.
|
|
23
|
+
*/
|
|
24
|
+
export function unavailableSurvey(reason) {
|
|
25
|
+
const only = wholeCodebaseTerritory([]);
|
|
26
|
+
return {
|
|
27
|
+
territories: [only],
|
|
28
|
+
filesByTerritory: new Map([[only.id, []]]),
|
|
29
|
+
treeTruncated: false,
|
|
30
|
+
unavailableReason: reason,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Read the repository tree and partition it into territories.
|
|
35
|
+
*
|
|
36
|
+
* Never throws: a tree read that fails degrades to the whole-codebase expedition WITH the cause
|
|
37
|
+
* recorded, because an expedition that cannot be partitioned is still worth running and a run
|
|
38
|
+
* that failed at planning because a contents API blipped is not. The blueprint read degrades the
|
|
39
|
+
* same way, one level finer: no blueprint means the directory heuristic, which is what a
|
|
40
|
+
* repository that was never blueprinted gets anyway.
|
|
41
|
+
*/
|
|
42
|
+
export async function surveyCodebase(input) {
|
|
43
|
+
const log = input.logger ?? noopLogger;
|
|
44
|
+
const repo = input.repo;
|
|
45
|
+
if (!repo)
|
|
46
|
+
return unavailableSurvey('No repository is linked to this task, so the codebase was not surveyed.');
|
|
47
|
+
if (!repo.listTree) {
|
|
48
|
+
return unavailableSurvey('The connected VCS client cannot list a repository tree, so the codebase was not surveyed.');
|
|
49
|
+
}
|
|
50
|
+
let tree;
|
|
51
|
+
try {
|
|
52
|
+
tree = await repo.listTree(input.branch);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
log.warn('bugFishing.treeReadFailed', { branch: input.branch, ...describeError(error) });
|
|
56
|
+
return unavailableSurvey('The repository tree could not be read, so the codebase was not surveyed.');
|
|
57
|
+
}
|
|
58
|
+
const blueprint = await readBlueprint(repo, input.branch, log);
|
|
59
|
+
const survey = partitionCodebase(tree, {
|
|
60
|
+
serviceDirectory: input.serviceDirectory ?? null,
|
|
61
|
+
blueprint,
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
territories: survey.territories,
|
|
65
|
+
filesByTerritory: survey.filesByTerritory,
|
|
66
|
+
treeTruncated: survey.treeTruncated,
|
|
67
|
+
unavailableReason: null,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Survey the codebase a RUN targets: resolve its repository, then partition the tree.
|
|
72
|
+
*
|
|
73
|
+
* The repo resolution is its own refusal and does not belong to a survey. An unlinked block chain
|
|
74
|
+
* throws a `ValidationError` rather than answering null, deliberately, because guessing a repo once
|
|
75
|
+
* pushed a task into someone else's; that refusal belongs to a DISPATCH, where a human can act on
|
|
76
|
+
* it. This module's contract is the opposite one, that a survey never throws, and its callers
|
|
77
|
+
* include the COMPLETION path of a pass that has already run and has nothing left to refuse.
|
|
78
|
+
*
|
|
79
|
+
* Here rather than on the dispatcher so the two halves of "never throws" sit together, and so the
|
|
80
|
+
* dispatcher keeps only the binding: which repo resolver, which logger.
|
|
81
|
+
*/
|
|
82
|
+
export async function surveyRunCodebase(input) {
|
|
83
|
+
const log = input.logger ?? noopLogger;
|
|
84
|
+
let runRepo;
|
|
85
|
+
try {
|
|
86
|
+
runRepo = await input.resolveRunRepo();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
log.warn('bugFishing.repoResolveFailed', describeError(error));
|
|
90
|
+
return unavailableSurvey('The repository this task targets could not be resolved, so the codebase was not surveyed.');
|
|
91
|
+
}
|
|
92
|
+
return surveyCodebase({
|
|
93
|
+
repo: runRepo?.repo ?? null,
|
|
94
|
+
branch: runRepo?.baseBranch ?? 'HEAD',
|
|
95
|
+
serviceDirectory: runRepo?.serviceDirectory ?? null,
|
|
96
|
+
logger: log,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The service's committed blueprint, or null.
|
|
101
|
+
*
|
|
102
|
+
* Read at the REPOSITORY root, because that is where `blueprintPostOp` commits it: the post-op
|
|
103
|
+
* writes {@link BLUEPRINT_JSON_PATH} through a root-scoped `RepoFiles`, with no service prefix,
|
|
104
|
+
* whatever subdirectory the service that produced it lives in. Reading it under the service
|
|
105
|
+
* directory found nothing on every monorepo service, and found it silently: a blueprinted service
|
|
106
|
+
* fell through to the directory heuristic with nothing saying it had one. The constant is imported
|
|
107
|
+
* rather than restated so the reader cannot drift from the writer again.
|
|
108
|
+
*
|
|
109
|
+
* The blueprint is a DECOMPOSITION first and a file map second: its `references` were written by
|
|
110
|
+
* a model against an older tree, so the partition drops a reference the tree no longer has rather
|
|
111
|
+
* than trusting it, and a blueprint that parses to nothing usable is simply no blueprint. A read
|
|
112
|
+
* failure is the same answer for the same reason: the directory heuristic is a complete fallback,
|
|
113
|
+
* not a degraded one.
|
|
114
|
+
*/
|
|
115
|
+
async function readBlueprint(repo, branch, log) {
|
|
116
|
+
try {
|
|
117
|
+
const file = await repo.getFile(BLUEPRINT_JSON_PATH, branch);
|
|
118
|
+
if (!file?.content)
|
|
119
|
+
return null;
|
|
120
|
+
return safeParseBlueprintService(JSON.parse(file.content)) ?? null;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
log.warn('bugFishing.blueprintReadFailed', {
|
|
124
|
+
path: BLUEPRINT_JSON_PATH,
|
|
125
|
+
...describeError(error),
|
|
126
|
+
});
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=bugFishingSurvey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugFishingSurvey.js","sourceRoot":"","sources":["../../../src/modules/execution/bugFishingSurvey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAQvF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,kCAAkC,CAAA;AAsDzC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,IAAI,GAAG,sBAAsB,CAAC,EAAE,CAAC,CAAA;IACvC,OAAO;QACL,WAAW,EAAE,CAAC,IAAI,CAAC;QACnB,gBAAgB,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC1C,aAAa,EAAE,KAAK;QACpB,iBAAiB,EAAE,MAAM;KAC1B,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAA0B;IAC7D,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,IAAI,UAAU,CAAA;IACtC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACvB,IAAI,CAAC,IAAI;QACP,OAAO,iBAAiB,CACtB,yEAAyE,CAC1E,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iBAAiB,CACtB,2FAA2F,CAC5F,CAAA;IACH,CAAC;IACD,OAAO,cAAc,CAAC;QACpB,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;QAC3B,MAAM,EAAE,OAAO,EAAE,UAAU,IAAI,MAAM;QACrC,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,IAAI,IAAI;QACnD,MAAM,EAAE,GAAG;KACZ,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAe,EACf,MAAc,EACd,GAAW;IAEX,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;QAC5D,IAAI,CAAC,IAAI,EAAE,OAAO;YAAE,OAAO,IAAI,CAAA;QAC/B,OAAO,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,CAAA;IACpE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE;YACzC,IAAI,EAAE,mBAAmB;YACzB,GAAG,aAAa,CAAC,KAAK,CAAC;SACxB,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { BlueprintService, BugFishingPhase, BugFishingTerritory, BugFishingUnfishedCell, RepoTreeListing } from '@cat-factory/kernel';
|
|
2
|
+
/** Whether a repo-relative path is source the expedition should fish. */
|
|
3
|
+
export declare function isFishablePath(path: string): boolean;
|
|
4
|
+
/** One file of the survey's manifest: the path (survey-root-relative), and what it weighs. */
|
|
5
|
+
export interface SurveyedFile {
|
|
6
|
+
path: string;
|
|
7
|
+
bytes: number;
|
|
8
|
+
}
|
|
9
|
+
/** What a survey of the repository tree produced. */
|
|
10
|
+
export interface CodebaseSurvey {
|
|
11
|
+
/** The partition, in the order the expedition fishes it. Always at least one entry. */
|
|
12
|
+
territories: BugFishingTerritory[];
|
|
13
|
+
/**
|
|
14
|
+
* Every fishable file under the survey root, indexed by territory id, with paths in the survey
|
|
15
|
+
* root's frame (see this module's header).
|
|
16
|
+
*/
|
|
17
|
+
filesByTerritory: Map<string, SurveyedFile[]>;
|
|
18
|
+
/** True when the provider cut the tree short: the manifest is a prefix of the codebase. */
|
|
19
|
+
treeTruncated: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Options a survey takes beyond the tree itself. */
|
|
22
|
+
export interface SurveyOptions {
|
|
23
|
+
/**
|
|
24
|
+
* The monorepo subdirectory the service lives in, when it has one. The survey walks from here
|
|
25
|
+
* rather than from the repository root: a sibling service's code is out of scope for an
|
|
26
|
+
* expedition exactly as it is for every other run. It is also the frame every path this module
|
|
27
|
+
* emits is relative to, because it is the directory the agent's checkout is rooted at.
|
|
28
|
+
*/
|
|
29
|
+
serviceDirectory?: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* The service's committed blueprint, when the repository has one. Its modules are the
|
|
32
|
+
* platform's own decomposition and win over the directory heuristic; a module whose references
|
|
33
|
+
* the tree no longer has falls through to the directory rule rather than being guessed onto a
|
|
34
|
+
* new home.
|
|
35
|
+
*/
|
|
36
|
+
blueprint?: BlueprintService | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The single territory a codebase small enough to fish whole gets.
|
|
40
|
+
*
|
|
41
|
+
* The PASS-THROUGH: its phases carry no territory id, so the expedition is byte-for-byte the one
|
|
42
|
+
* that shipped before territories existed. Large-codebase mode is a size threshold crossed, never
|
|
43
|
+
* a mode a task opts into.
|
|
44
|
+
*/
|
|
45
|
+
export declare function wholeCodebaseTerritory(files: readonly SurveyedFile[]): BugFishingTerritory;
|
|
46
|
+
/**
|
|
47
|
+
* Partition a repository tree into the territories an expedition fishes.
|
|
48
|
+
*
|
|
49
|
+
* Blueprint modules first when the repository has a blueprint, then package and directory
|
|
50
|
+
* boundaries under the survey root, sized by the tree's blob bytes. A codebase that fits one
|
|
51
|
+
* territory yields exactly one, and the expedition it plans is today's.
|
|
52
|
+
*/
|
|
53
|
+
export declare function partitionCodebase(tree: RepoTreeListing, options?: SurveyOptions): CodebaseSurvey;
|
|
54
|
+
/** One planned cell: an angle fished over a territory. */
|
|
55
|
+
export interface PlannedCell {
|
|
56
|
+
territory: BugFishingTerritory;
|
|
57
|
+
phase: BugFishingPhase;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build the pass list from the territories and the angles, TERRITORY-MAJOR, trimmed to the pass
|
|
61
|
+
* budget.
|
|
62
|
+
*
|
|
63
|
+
* Territory-major so a human gets a complete answer for one territory early and can start its
|
|
64
|
+
* fixes while the rest is still being fished, which is what the separate-dispatch design is for.
|
|
65
|
+
* The budget trims from the BOTTOM of the order rather than the middle, and what it cuts is
|
|
66
|
+
* returned as unfished: a cap silent about its tail teaches the reader that the tail was clean.
|
|
67
|
+
*
|
|
68
|
+
* A single whole-codebase territory yields the angles unchanged, with no territory stamped on
|
|
69
|
+
* them, so a small codebase's plan is field-for-field the one that shipped before territories.
|
|
70
|
+
*/
|
|
71
|
+
export declare function planTerritoryPasses(input: {
|
|
72
|
+
territories: readonly BugFishingTerritory[];
|
|
73
|
+
angles: readonly BugFishingPhase[];
|
|
74
|
+
passBudget: number;
|
|
75
|
+
}): {
|
|
76
|
+
phases: BugFishingPhase[];
|
|
77
|
+
unfished: BugFishingUnfishedCell[];
|
|
78
|
+
plannedCells: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Order the territories a large expedition fishes, most worth fishing first.
|
|
82
|
+
*
|
|
83
|
+
* The creator's `fishingFocus` comes first, because naming a subsystem is the deliberate act and
|
|
84
|
+
* a budget that cut it would be cutting the one thing they asked for. Size decides the rest: with
|
|
85
|
+
* no scout rating relevance yet, the biggest territory is the one most likely to hide something,
|
|
86
|
+
* and it is a fact the platform can compute rather than a judgement it would be inventing.
|
|
87
|
+
*/
|
|
88
|
+
export declare function prioritiseTerritories(territories: readonly BugFishingTerritory[], focus: string | null | undefined): BugFishingTerritory[];
|
|
89
|
+
//# sourceMappingURL=bugFishingTerritories.logic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bugFishingTerritories.logic.d.ts","sourceRoot":"","sources":["../../../src/modules/execution/bugFishingTerritories.logic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EAEtB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AA0I5B,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,uFAAuF;IACvF,WAAW,EAAE,mBAAmB,EAAE,CAAA;IAClC;;;OAGG;IACH,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAAA;IAC7C,2FAA2F;IAC3F,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACpC;AA+ED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,GAAG,mBAAmB,CAU1F;AAsND;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EACrB,OAAO,GAAE,aAAkB,GAC1B,cAAc,CAuChB;AAID,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,SAA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