@cleocode/core 2026.10.25 → 2026.10.26-rc.ci.697
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/build-provenance.json +2 -2
- package/dist/dispatch/contracts/output-contracts.d.ts +13 -0
- package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
- package/dist/dispatch/contracts/output-contracts.js +29 -0
- package/dist/dispatch/contracts/output-contracts.js.map +1 -1
- package/dist/docs/docs-ops.d.ts +8 -0
- package/dist/docs/docs-ops.d.ts.map +1 -1
- package/dist/docs/docs-ops.js +24 -1
- package/dist/docs/docs-ops.js.map +1 -1
- package/dist/docs/docs-update.d.ts +8 -5
- package/dist/docs/docs-update.d.ts.map +1 -1
- package/dist/docs/docs-update.js +16 -5
- package/dist/docs/docs-update.js.map +1 -1
- package/dist/gateway-client/generated/types.gen.d.ts +27 -0
- package/dist/gateway-client/generated/types.gen.d.ts.map +1 -1
- package/dist/hooks/handlers/watchdog-hooks.d.ts.map +1 -1
- package/dist/hooks/handlers/watchdog-hooks.js +5 -0
- package/dist/hooks/handlers/watchdog-hooks.js.map +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +5 -2
- package/dist/internal.js.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.d.ts.map +1 -1
- package/dist/lifecycle/verification/satisfies-validator.js +22 -10
- package/dist/lifecycle/verification/satisfies-validator.js.map +1 -1
- package/dist/memory/brain-writer-thread.d.ts +30 -0
- package/dist/memory/brain-writer-thread.d.ts.map +1 -1
- package/dist/memory/brain-writer-thread.js +46 -1
- package/dist/memory/brain-writer-thread.js.map +1 -1
- package/dist/memory/brain-writer-worker.js +13 -2
- package/dist/memory/brain-writer-worker.js.map +1 -1
- package/dist/memory/embedding-backfill.d.ts +12 -0
- package/dist/memory/embedding-backfill.d.ts.map +1 -1
- package/dist/memory/embedding-backfill.js +51 -31
- package/dist/memory/embedding-backfill.js.map +1 -1
- package/dist/orchestrate/include-deps.d.ts +58 -0
- package/dist/orchestrate/include-deps.d.ts.map +1 -0
- package/dist/orchestrate/include-deps.js +138 -0
- package/dist/orchestrate/include-deps.js.map +1 -0
- package/dist/orchestrate/spawn-ops.d.ts +14 -33
- package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
- package/dist/orchestrate/spawn-ops.js +49 -61
- package/dist/orchestrate/spawn-ops.js.map +1 -1
- package/dist/orchestrate/worktree-complete.d.ts +15 -1
- package/dist/orchestrate/worktree-complete.d.ts.map +1 -1
- package/dist/orchestrate/worktree-complete.js +36 -3
- package/dist/orchestrate/worktree-complete.js.map +1 -1
- package/dist/release/ci-evidence.d.ts +142 -4
- package/dist/release/ci-evidence.d.ts.map +1 -1
- package/dist/release/ci-evidence.js +298 -48
- package/dist/release/ci-evidence.js.map +1 -1
- package/dist/release/open.d.ts +25 -1
- package/dist/release/open.d.ts.map +1 -1
- package/dist/release/open.js +63 -11
- package/dist/release/open.js.map +1 -1
- package/dist/resources/admission-ledger.d.ts +83 -11
- package/dist/resources/admission-ledger.d.ts.map +1 -1
- package/dist/resources/admission-ledger.js +138 -39
- package/dist/resources/admission-ledger.js.map +1 -1
- package/dist/resources/governor.js +1 -1
- package/dist/resources/governor.js.map +1 -1
- package/dist/resources/hook-footprint.d.ts +24 -0
- package/dist/resources/hook-footprint.d.ts.map +1 -1
- package/dist/resources/hook-footprint.js +38 -1
- package/dist/resources/hook-footprint.js.map +1 -1
- package/dist/resources/run-class.d.ts +38 -5
- package/dist/resources/run-class.d.ts.map +1 -1
- package/dist/resources/run-class.js +60 -11
- package/dist/resources/run-class.js.map +1 -1
- package/dist/resources/run-governed.d.ts +13 -3
- package/dist/resources/run-governed.d.ts.map +1 -1
- package/dist/resources/run-governed.js +42 -9
- package/dist/resources/run-governed.js.map +1 -1
- package/dist/resources/slot-holder.d.ts +3 -3
- package/dist/resources/slot-holder.js +3 -3
- package/dist/resources/tool-groups.d.ts +11 -7
- package/dist/resources/tool-groups.d.ts.map +1 -1
- package/dist/resources/tool-groups.js +24 -13
- package/dist/resources/tool-groups.js.map +1 -1
- package/dist/spawn/branch-integration.d.ts +281 -0
- package/dist/spawn/branch-integration.d.ts.map +1 -0
- package/dist/spawn/branch-integration.js +715 -0
- package/dist/spawn/branch-integration.js.map +1 -0
- package/dist/spawn/branch-lock.d.ts +32 -270
- package/dist/spawn/branch-lock.d.ts.map +1 -1
- package/dist/spawn/branch-lock.js +59 -770
- package/dist/spawn/branch-lock.js.map +1 -1
- package/dist/spawn/index.d.ts +3 -1
- package/dist/spawn/index.d.ts.map +1 -1
- package/dist/spawn/index.js +5 -1
- package/dist/spawn/index.js.map +1 -1
- package/dist/store/exodus/recovery.d.ts.map +1 -1
- package/dist/store/exodus/recovery.js +9 -4
- package/dist/store/exodus/recovery.js.map +1 -1
- package/dist/system/health.d.ts.map +1 -1
- package/dist/system/health.js +3 -1
- package/dist/system/health.js.map +1 -1
- package/dist/tasks/ac-coverage-gate.d.ts +18 -2
- package/dist/tasks/ac-coverage-gate.d.ts.map +1 -1
- package/dist/tasks/ac-coverage-gate.js +40 -6
- package/dist/tasks/ac-coverage-gate.js.map +1 -1
- package/dist/tasks/ac-table.d.ts.map +1 -1
- package/dist/tasks/ac-table.js +3 -10
- package/dist/tasks/ac-table.js.map +1 -1
- package/dist/tasks/affected-packages.d.ts.map +1 -1
- package/dist/tasks/affected-packages.js +54 -10
- package/dist/tasks/affected-packages.js.map +1 -1
- package/dist/tasks/affected-scope.d.ts +10 -1
- package/dist/tasks/affected-scope.d.ts.map +1 -1
- package/dist/tasks/affected-scope.js +13 -3
- package/dist/tasks/affected-scope.js.map +1 -1
- package/dist/tasks/change-set.d.ts +9 -6
- package/dist/tasks/change-set.d.ts.map +1 -1
- package/dist/tasks/change-set.js +75 -97
- package/dist/tasks/change-set.js.map +1 -1
- package/dist/tasks/command-line.d.ts.map +1 -1
- package/dist/tasks/command-line.js +6 -2
- package/dist/tasks/command-line.js.map +1 -1
- package/dist/tasks/complete.d.ts.map +1 -1
- package/dist/tasks/complete.js +7 -2
- package/dist/tasks/complete.js.map +1 -1
- package/dist/tasks/done-plan.d.ts.map +1 -1
- package/dist/tasks/done-plan.js +111 -29
- package/dist/tasks/done-plan.js.map +1 -1
- package/dist/tasks/done-record.d.ts +14 -0
- package/dist/tasks/done-record.d.ts.map +1 -1
- package/dist/tasks/done-record.js +17 -10
- package/dist/tasks/done-record.js.map +1 -1
- package/dist/tasks/evidence-tree.d.ts +33 -0
- package/dist/tasks/evidence-tree.d.ts.map +1 -0
- package/dist/tasks/evidence-tree.js +132 -0
- package/dist/tasks/evidence-tree.js.map +1 -0
- package/dist/tasks/evidence.d.ts +42 -6
- package/dist/tasks/evidence.d.ts.map +1 -1
- package/dist/tasks/evidence.js +175 -79
- package/dist/tasks/evidence.js.map +1 -1
- package/dist/tasks/gate-preview.d.ts.map +1 -1
- package/dist/tasks/gate-preview.js +3 -2
- package/dist/tasks/gate-preview.js.map +1 -1
- package/dist/tasks/gate-runner.d.ts +11 -3
- package/dist/tasks/gate-runner.d.ts.map +1 -1
- package/dist/tasks/gate-runner.js +156 -37
- package/dist/tasks/gate-runner.js.map +1 -1
- package/dist/tasks/gate-staleness.d.ts +58 -0
- package/dist/tasks/gate-staleness.d.ts.map +1 -0
- package/dist/tasks/gate-staleness.js +78 -0
- package/dist/tasks/gate-staleness.js.map +1 -0
- package/dist/tasks/heavy-tool-env.d.ts +26 -1
- package/dist/tasks/heavy-tool-env.d.ts.map +1 -1
- package/dist/tasks/heavy-tool-env.js +92 -5
- package/dist/tasks/heavy-tool-env.js.map +1 -1
- package/dist/tasks/heavy-tool-limit.d.ts +24 -0
- package/dist/tasks/heavy-tool-limit.d.ts.map +1 -1
- package/dist/tasks/heavy-tool-limit.js +44 -1
- package/dist/tasks/heavy-tool-limit.js.map +1 -1
- package/dist/tasks/show.d.ts.map +1 -1
- package/dist/tasks/show.js +43 -0
- package/dist/tasks/show.js.map +1 -1
- package/dist/tasks/test-run-binding.d.ts +48 -3
- package/dist/tasks/test-run-binding.d.ts.map +1 -1
- package/dist/tasks/test-run-binding.js +111 -3
- package/dist/tasks/test-run-binding.js.map +1 -1
- package/dist/tasks/tool-cache.d.ts +58 -7
- package/dist/tasks/tool-cache.d.ts.map +1 -1
- package/dist/tasks/tool-cache.js +216 -16
- package/dist/tasks/tool-cache.js.map +1 -1
- package/dist/tasks/tool-resolver.d.ts +13 -0
- package/dist/tasks/tool-resolver.d.ts.map +1 -1
- package/dist/tasks/tool-resolver.js +34 -0
- package/dist/tasks/tool-resolver.js.map +1 -1
- package/dist/tasks/tool-runner-guard.d.ts +6 -0
- package/dist/tasks/tool-runner-guard.d.ts.map +1 -1
- package/dist/tasks/tool-runner-guard.js.map +1 -1
- package/dist/tasks/tool-semaphore.js +1 -1
- package/dist/tasks/tool-semaphore.js.map +1 -1
- package/dist/tasks/verification-policy.d.ts +26 -3
- package/dist/tasks/verification-policy.d.ts.map +1 -1
- package/dist/tasks/verification-policy.js +76 -11
- package/dist/tasks/verification-policy.js.map +1 -1
- package/dist/validation/doctor/checks.d.ts +12 -0
- package/dist/validation/doctor/checks.d.ts.map +1 -1
- package/dist/validation/doctor/checks.js +33 -0
- package/dist/validation/doctor/checks.js.map +1 -1
- package/dist/validation/engine-ops.d.ts +6 -0
- package/dist/validation/engine-ops.d.ts.map +1 -1
- package/dist/validation/engine-ops.js +51 -1
- package/dist/validation/engine-ops.js.map +1 -1
- package/dist/worktree/force-unlock.js +2 -2
- package/dist/worktree/force-unlock.js.map +1 -1
- package/dist/worktree/list.d.ts +7 -7
- package/dist/worktree/list.d.ts.map +1 -1
- package/dist/worktree/list.js +11 -56
- package/dist/worktree/list.js.map +1 -1
- package/dist/worktree/prune.d.ts +2 -2
- package/dist/worktree/prune.d.ts.map +1 -1
- package/dist/worktree/prune.js +4 -4
- package/dist/worktree/prune.js.map +1 -1
- package/package.json +13 -13
|
@@ -28,9 +28,12 @@ export declare function isProbeableId(id: unknown): id is number;
|
|
|
28
28
|
* process groups) and for an id that is not probeable.
|
|
29
29
|
*
|
|
30
30
|
* @param pgid - The group id: the pid of a child spawned with `detached: true`.
|
|
31
|
-
* @returns Marks the group as no longer running (idempotent).
|
|
31
|
+
* @returns Marks the group as no longer running (idempotent). Every slot this
|
|
32
|
+
* process holds is told, so its record drops the group: a finished group id
|
|
33
|
+
* that the system later reuses never keeps a dead holder's charge (T14066).
|
|
32
34
|
*
|
|
33
35
|
* @task T12963
|
|
36
|
+
* @task T14066
|
|
34
37
|
*/
|
|
35
38
|
export declare function trackToolGroup(pgid: number | undefined): () => void;
|
|
36
39
|
/**
|
|
@@ -42,16 +45,17 @@ export declare function trackToolGroup(pgid: number | undefined): () => void;
|
|
|
42
45
|
*/
|
|
43
46
|
export declare function activeToolGroups(): number[];
|
|
44
47
|
/**
|
|
45
|
-
* Follow the tool groups
|
|
46
|
-
* already running, then `
|
|
47
|
-
*
|
|
48
|
+
* Follow the tool groups running while a slot is held: seeded with the groups
|
|
49
|
+
* already running, then `onChange` is called with the full list each time one
|
|
50
|
+
* starts or finishes.
|
|
48
51
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @returns The groups
|
|
52
|
+
* @param onChange - Called with every group still running, after each change.
|
|
53
|
+
* @returns The groups running now (kept up to date) and `stop`.
|
|
51
54
|
*
|
|
52
55
|
* @task T12963
|
|
56
|
+
* @task T14066
|
|
53
57
|
*/
|
|
54
|
-
export declare function followToolGroups(
|
|
58
|
+
export declare function followToolGroups(onChange: (groups: readonly number[]) => void): {
|
|
55
59
|
groups: readonly number[];
|
|
56
60
|
stop: () => void;
|
|
57
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-groups.d.ts","sourceRoot":"","sources":["../../src/resources/tool-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,MAAM,CAEvD;AAED
|
|
1
|
+
{"version":3,"file":"tool-groups.d.ts","sourceRoot":"","sources":["../../src/resources/tool-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,IAAI,CAUnE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,EAAE,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,GAAG;IAC/E,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAgBA;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAU5E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C"}
|
|
@@ -32,9 +32,12 @@ export function isProbeableId(id) {
|
|
|
32
32
|
* process groups) and for an id that is not probeable.
|
|
33
33
|
*
|
|
34
34
|
* @param pgid - The group id: the pid of a child spawned with `detached: true`.
|
|
35
|
-
* @returns Marks the group as no longer running (idempotent).
|
|
35
|
+
* @returns Marks the group as no longer running (idempotent). Every slot this
|
|
36
|
+
* process holds is told, so its record drops the group: a finished group id
|
|
37
|
+
* that the system later reuses never keeps a dead holder's charge (T14066).
|
|
36
38
|
*
|
|
37
39
|
* @task T12963
|
|
40
|
+
* @task T14066
|
|
38
41
|
*/
|
|
39
42
|
export function trackToolGroup(pgid) {
|
|
40
43
|
if (process.platform === 'win32' || !isProbeableId(pgid) || _active.has(pgid)) {
|
|
@@ -42,9 +45,12 @@ export function trackToolGroup(pgid) {
|
|
|
42
45
|
}
|
|
43
46
|
_active.add(pgid);
|
|
44
47
|
for (const listener of _listeners)
|
|
45
|
-
listener(pgid);
|
|
48
|
+
listener(pgid, true);
|
|
46
49
|
return () => {
|
|
47
|
-
_active.delete(pgid)
|
|
50
|
+
if (!_active.delete(pgid))
|
|
51
|
+
return;
|
|
52
|
+
for (const listener of _listeners)
|
|
53
|
+
listener(pgid, false);
|
|
48
54
|
};
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
@@ -58,22 +64,27 @@ export function activeToolGroups() {
|
|
|
58
64
|
return [..._active];
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
|
-
* Follow the tool groups
|
|
62
|
-
* already running, then `
|
|
63
|
-
*
|
|
67
|
+
* Follow the tool groups running while a slot is held: seeded with the groups
|
|
68
|
+
* already running, then `onChange` is called with the full list each time one
|
|
69
|
+
* starts or finishes.
|
|
64
70
|
*
|
|
65
|
-
* @param
|
|
66
|
-
* @returns The groups
|
|
71
|
+
* @param onChange - Called with every group still running, after each change.
|
|
72
|
+
* @returns The groups running now (kept up to date) and `stop`.
|
|
67
73
|
*
|
|
68
74
|
* @task T12963
|
|
75
|
+
* @task T14066
|
|
69
76
|
*/
|
|
70
|
-
export function followToolGroups(
|
|
77
|
+
export function followToolGroups(onChange) {
|
|
71
78
|
const groups = activeToolGroups();
|
|
72
|
-
const listener = (pgid) => {
|
|
73
|
-
|
|
79
|
+
const listener = (pgid, running) => {
|
|
80
|
+
const at = groups.indexOf(pgid);
|
|
81
|
+
if (running === at >= 0)
|
|
74
82
|
return;
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
if (running)
|
|
84
|
+
groups.push(pgid);
|
|
85
|
+
else
|
|
86
|
+
groups.splice(at, 1);
|
|
87
|
+
onChange(groups);
|
|
77
88
|
};
|
|
78
89
|
_listeners.add(listener);
|
|
79
90
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-groups.js","sourceRoot":"","sources":["../../src/resources/tool-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;AAClC,MAAM,UAAU,GAAG,IAAI,GAAG,
|
|
1
|
+
{"version":3,"file":"tool-groups.js","sourceRoot":"","sources":["../../src/resources/tool-groups.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;AAClC,MAAM,UAAU,GAAG,IAAI,GAAG,EAA4C,CAAC;AAEvE;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,EAAW;IACvC,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAAC,IAAwB;IACrD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9E,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,KAAK,MAAM,QAAQ,IAAI,UAAU;QAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxD,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,OAAO;QAClC,KAAK,MAAM,QAAQ,IAAI,UAAU;YAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC;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AC,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Branch integration for agent worktrees (T10862): default-branch resolution,
|
|
3
|
+
* upstream fetch and landed-detection, the merge decision, the `--no-ff` merge
|
|
4
|
+
* of `task/<id>` into the local target branch (ADR-062) and its audit row.
|
|
5
|
+
*
|
|
6
|
+
* Owns merge / fetch / checkout policy only. Worktree add, remove, list and
|
|
7
|
+
* lock stay in the lifecycle module ({@link ./branch-lock.ts}) and the
|
|
8
|
+
* `@cleocode/worktree` facade; this module calls {@link pruneWorktree} after a
|
|
9
|
+
* merge and never touches `git worktree` itself.
|
|
10
|
+
*
|
|
11
|
+
* @task T10862
|
|
12
|
+
* @task T10863
|
|
13
|
+
* @task T10864
|
|
14
|
+
* @adr ADR-062
|
|
15
|
+
*/
|
|
16
|
+
import type { EvidenceAtom, WorktreeIntegrationOutcome, WorktreeIntegrationPlan, WorktreeMergeResult } from '@cleocode/contracts';
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the project's default integration branch in a project-agnostic way.
|
|
19
|
+
*
|
|
20
|
+
* Resolution order (per ADR-062):
|
|
21
|
+
*
|
|
22
|
+
* 1. `.cleo/config.json::git.defaultBranch` (explicit override).
|
|
23
|
+
* 2. `git symbolic-ref refs/remotes/origin/HEAD` (what the remote calls
|
|
24
|
+
* default — works for `master`, `main`, `trunk`, etc.).
|
|
25
|
+
* 3. Probe local branches in order: `main`, `master`, `develop`, `trunk`.
|
|
26
|
+
* 4. Fallback to `'main'`.
|
|
27
|
+
*
|
|
28
|
+
* @param projectRoot - Absolute path to the project root.
|
|
29
|
+
* @returns The resolved default branch name (never throws).
|
|
30
|
+
*
|
|
31
|
+
* @task T1587
|
|
32
|
+
* @adr ADR-062
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDefaultBranch(projectRoot: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Verdict of {@link assessUpstreamIntegration}.
|
|
37
|
+
*
|
|
38
|
+
* - `landed` — the task branch is already on the upstream default branch
|
|
39
|
+
* (ancestor of it, or its changes are fully contained in it). No local
|
|
40
|
+
* merge may run.
|
|
41
|
+
* - `nothing` — the task branch has no commits beyond the local default
|
|
42
|
+
* branch (e.g. a worktree that was never committed to). There is nothing to
|
|
43
|
+
* integrate, and it is NOT reported as landed upstream.
|
|
44
|
+
* - `stale-target` — the local default branch is behind the upstream default
|
|
45
|
+
* branch (possibly also ahead of it — diverged); a merge there would fork it
|
|
46
|
+
* from upstream. No local merge may run.
|
|
47
|
+
* - `proceed` — no upstream to compare against, or the local default branch is
|
|
48
|
+
* current; the ADR-062 local `--no-ff` integration may run.
|
|
49
|
+
*
|
|
50
|
+
* @task T12773
|
|
51
|
+
*/
|
|
52
|
+
export type UpstreamIntegrationKind = 'landed' | 'nothing' | 'stale-target' | 'proceed';
|
|
53
|
+
/**
|
|
54
|
+
* Result of {@link assessUpstreamIntegration}.
|
|
55
|
+
*
|
|
56
|
+
* @task T12773
|
|
57
|
+
*/
|
|
58
|
+
export interface UpstreamIntegrationAssessment {
|
|
59
|
+
/** What the caller may do next. */
|
|
60
|
+
kind: UpstreamIntegrationKind;
|
|
61
|
+
/** Remote-tracking ref compared against (e.g. `refs/remotes/origin/main`), or null. */
|
|
62
|
+
upstreamRef: string | null;
|
|
63
|
+
/**
|
|
64
|
+
* True when this assessment ran `git fetch <remote> <targetBranch>` (whether
|
|
65
|
+
* or not it succeeded), so a later integration step need not fetch again.
|
|
66
|
+
*/
|
|
67
|
+
fetched: boolean;
|
|
68
|
+
/** Commits on the upstream ref missing from the local default branch. */
|
|
69
|
+
behind: number;
|
|
70
|
+
/** Commits on the local default branch missing from the upstream ref. */
|
|
71
|
+
ahead: number;
|
|
72
|
+
/**
|
|
73
|
+
* Exact shell command that syncs the local default branch with upstream,
|
|
74
|
+
* or empty when no sync is needed. NEVER run by CLEO — the operator's
|
|
75
|
+
* checkout is never moved (hint-only policy).
|
|
76
|
+
*/
|
|
77
|
+
syncCommand: string;
|
|
78
|
+
/** Operator-facing explanation / next step (empty for `proceed`). */
|
|
79
|
+
hint: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Default timeout for the upstream `git fetch` in
|
|
83
|
+
* {@link assessUpstreamIntegration}. Short on purpose: the fetch is
|
|
84
|
+
* best-effort, and a hung network or credential prompt must never stall
|
|
85
|
+
* `cleo done` for the 180s generic git timeout.
|
|
86
|
+
*
|
|
87
|
+
* @task T12773
|
|
88
|
+
*/
|
|
89
|
+
export declare const UPSTREAM_FETCH_TIMEOUT_MS = 20000;
|
|
90
|
+
/**
|
|
91
|
+
* Decide whether a local ADR-062 `--no-ff` integration of `branch` into
|
|
92
|
+
* `targetBranch` is safe, by comparing against the upstream default branch
|
|
93
|
+
* (`<remote>/<targetBranch>`).
|
|
94
|
+
*
|
|
95
|
+
* T12773: `cleo done --pr <n>` for a task whose PR had already merged on
|
|
96
|
+
* origin ran `git merge --no-ff task/<id>` into a local `main` that was 199
|
|
97
|
+
* commits behind origin, creating a local merge commit that forked `main`
|
|
98
|
+
* from `origin/main`. This check runs BEFORE any checkout or merge:
|
|
99
|
+
*
|
|
100
|
+
* - branch has no commits beyond the local default branch → `nothing`.
|
|
101
|
+
* - branch already on upstream → `landed`; when the local default branch is
|
|
102
|
+
* behind, the hint names the exact sync command. The checkout is never
|
|
103
|
+
* moved (hint-only).
|
|
104
|
+
* - local default branch behind upstream → `stale-target`; a distinct hint
|
|
105
|
+
* when it is also ahead (diverged: unpushed local commits).
|
|
106
|
+
* - otherwise (no remote, no upstream ref, current target) → `proceed`.
|
|
107
|
+
*
|
|
108
|
+
* The fetch is best-effort, non-interactive (`GIT_TERMINAL_PROMPT=0`, ssh
|
|
109
|
+
* `BatchMode`) and bounded by {@link UPSTREAM_FETCH_TIMEOUT_MS}; offline, the
|
|
110
|
+
* last-known remote-tracking ref is used. Never creates a commit and never
|
|
111
|
+
* moves any ref other than the remote-tracking one the fetch updates.
|
|
112
|
+
*
|
|
113
|
+
* @param gitRoot - Absolute git root of the project checkout.
|
|
114
|
+
* @param branch - Task branch (e.g. `task/T123`).
|
|
115
|
+
* @param targetBranch - Resolved default branch (e.g. `main`).
|
|
116
|
+
* @param opts.skipFetch - Skip `git fetch <remote> <targetBranch>` (fixtures).
|
|
117
|
+
* @param opts.remote - Remote name (default `origin`).
|
|
118
|
+
* @param opts.fetchTimeoutMs - Fetch timeout (default {@link UPSTREAM_FETCH_TIMEOUT_MS}).
|
|
119
|
+
* @returns The assessment.
|
|
120
|
+
*
|
|
121
|
+
* @task T12773
|
|
122
|
+
* @adr ADR-062
|
|
123
|
+
*/
|
|
124
|
+
export declare function assessUpstreamIntegration(gitRoot: string, branch: string, targetBranch: string, opts?: {
|
|
125
|
+
skipFetch?: boolean;
|
|
126
|
+
remote?: string;
|
|
127
|
+
fetchTimeoutMs?: number;
|
|
128
|
+
}): UpstreamIntegrationAssessment;
|
|
129
|
+
/**
|
|
130
|
+
* Options for {@link planWorktreeIntegration} and the merge run that shares
|
|
131
|
+
* its decision (T14053).
|
|
132
|
+
*/
|
|
133
|
+
export interface WorktreeIntegrationDecisionOptions {
|
|
134
|
+
/** Override the resolved default branch. */
|
|
135
|
+
targetBranch?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Set when integration is switched off (`cleo complete --no-integrate`,
|
|
138
|
+
* `CLEO_NO_AUTO_WORKTREE_COMPLETE`): the decision is `skip` with this reason.
|
|
139
|
+
*/
|
|
140
|
+
disabledReason?: string;
|
|
141
|
+
/** Skip the upstream `git fetch` (the plan never fetches). */
|
|
142
|
+
skipFetch?: boolean;
|
|
143
|
+
/** Timeout for the upstream fetch. */
|
|
144
|
+
fetchTimeoutMs?: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Preview what completing `taskId` does with its worktree branch, without
|
|
148
|
+
* changing git: the same decision the merge run makes, from local refs only
|
|
149
|
+
* (no fetch). Shown by `cleo done --plan` (T14053).
|
|
150
|
+
*
|
|
151
|
+
* @param taskId - The CLEO task ID.
|
|
152
|
+
* @param projectRoot - Absolute path to the project root.
|
|
153
|
+
* @param opts - Target override and the switched-off reason, if any.
|
|
154
|
+
* @returns Branch, worktree path, target branch, `merge`/`skip`/`refuse` and why.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* planWorktreeIntegration('T123', root).action; // 'skip' for a task merged by PR
|
|
159
|
+
* ```
|
|
160
|
+
* @task T14053
|
|
161
|
+
*/
|
|
162
|
+
export declare function planWorktreeIntegration(taskId: string, projectRoot: string, opts?: Omit<WorktreeIntegrationDecisionOptions, 'skipFetch' | 'fetchTimeoutMs'>): WorktreeIntegrationPlan;
|
|
163
|
+
/**
|
|
164
|
+
* Complete a worker task's worktree via `git merge --no-ff` (ADR-062).
|
|
165
|
+
*
|
|
166
|
+
* Canonical worktree integration per ADR-062. Preserves the full agent
|
|
167
|
+
* commit graph instead of rewriting SHAs, so `git log --grep "T<id>"`
|
|
168
|
+
* returns the originating commits with their original authorship.
|
|
169
|
+
*
|
|
170
|
+
* Steps performed inside the worktree at
|
|
171
|
+
* `~/.local/share/cleo/worktrees/<projectHash>/<taskId>/`:
|
|
172
|
+
*
|
|
173
|
+
* 1. Resolve target branch via {@link getDefaultBranch} (or `opts.targetBranch`
|
|
174
|
+
* override). NEVER hardcodes "main".
|
|
175
|
+
* 1. T14053: {@link decideWorktreeIntegration} first — the same decision
|
|
176
|
+
* `cleo done --plan` shows. A branch CLEO did not provision is skipped
|
|
177
|
+
* (`notProvisioned`), never merged; a main checkout on another branch,
|
|
178
|
+
* with uncommitted tracked changes, or a linked worktree is refused
|
|
179
|
+
* (`rootRefused`) without switching or merging anything.
|
|
180
|
+
* 1a. T12773: {@link assessUpstreamIntegration} — when `task/<id>` already
|
|
181
|
+
* landed on `origin/<targetBranch>` the merge is skipped
|
|
182
|
+
* (`landedUpstream: true`); when it has no commits beyond the local
|
|
183
|
+
* target it is `nothingToIntegrate` without `landedUpstream`; when the
|
|
184
|
+
* local target is behind (or diverged from) origin the merge is refused
|
|
185
|
+
* (`staleTarget: true`) with a `hint`. None of these paths creates a
|
|
186
|
+
* commit or moves the operator's checkout — syncing is hint-only.
|
|
187
|
+
* 2. Optionally `git fetch` (skipped when step 1a already fetched), then
|
|
188
|
+
* `git checkout <targetBranch>` in the project's git root. The task
|
|
189
|
+
* branch is NOT rebased — agent SHAs are preserved.
|
|
190
|
+
* 3. Run `git merge --no-ff task/<taskId> -m "<taskId>: <title> (worktree
|
|
191
|
+
* merge)"`; a failed merge is aborted so the repo is left clean, and the
|
|
192
|
+
* worktree is preserved.
|
|
193
|
+
* 4. Capture the merge commit SHA and report it.
|
|
194
|
+
* 5. Delegate worktree+branch removal to {@link pruneWorktree} (T1462).
|
|
195
|
+
*
|
|
196
|
+
* Project-agnostic: no string in this function hardcodes "main", "master",
|
|
197
|
+
* or any other branch name. Test fixtures pass arbitrary `targetBranch`.
|
|
198
|
+
*
|
|
199
|
+
* @param taskId - The CLEO task ID (e.g. `"T1587"`).
|
|
200
|
+
* @param projectRoot - Absolute path to the project root.
|
|
201
|
+
* @param opts.targetBranch - Override the resolved default branch.
|
|
202
|
+
* @param opts.taskTitle - Task title used in the merge commit message subject.
|
|
203
|
+
* @param opts.skipFetch - Skip every `git fetch` (test fixtures).
|
|
204
|
+
* @param opts.evidence - The task's evidence atoms; the prune keeps a worktree holding the only copy (T13696).
|
|
205
|
+
* @param opts.fetchTimeoutMs - Timeout for the upstream fetch (default
|
|
206
|
+
* {@link UPSTREAM_FETCH_TIMEOUT_MS}).
|
|
207
|
+
* @param opts.disabledReason - Integration is switched off; nothing is touched (T14053).
|
|
208
|
+
* @returns Merge integration result, with the decision it acted on in `plan`.
|
|
209
|
+
*
|
|
210
|
+
* @task T1587
|
|
211
|
+
* @task T14053
|
|
212
|
+
* @adr ADR-062
|
|
213
|
+
*/
|
|
214
|
+
export declare function completeAgentWorktreeViaMerge(taskId: string, projectRoot: string, opts?: {
|
|
215
|
+
targetBranch?: string;
|
|
216
|
+
disabledReason?: string;
|
|
217
|
+
taskTitle?: string;
|
|
218
|
+
skipFetch?: boolean;
|
|
219
|
+
fetchTimeoutMs?: number;
|
|
220
|
+
evidence?: readonly EvidenceAtom[];
|
|
221
|
+
}): WorktreeMergeResult;
|
|
222
|
+
/**
|
|
223
|
+
* Result of a complete post-merge worktree integration.
|
|
224
|
+
*
|
|
225
|
+
* Extends `WorktreeMergeResult` with an additional audit log path field.
|
|
226
|
+
*
|
|
227
|
+
* @task T9043
|
|
228
|
+
* @adr ADR-062
|
|
229
|
+
*/
|
|
230
|
+
export interface WorktreeIntegrationResult extends WorktreeMergeResult {
|
|
231
|
+
/** Path to the audit log entry that was written (if any). */
|
|
232
|
+
auditLogEntry: string | null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Complete a worker task's worktree integration via merge, cleanup, and audit log.
|
|
236
|
+
*
|
|
237
|
+
* This is the orchestrator-facing convenience wrapper around
|
|
238
|
+
* `completeAgentWorktreeViaMerge`. In addition to the merge+prune steps it:
|
|
239
|
+
*
|
|
240
|
+
* 1. Delegates all merge and cleanup to `completeAgentWorktreeViaMerge`.
|
|
241
|
+
* 2. Appends a structured entry to `.cleo/audit/worktree-integration.jsonl`
|
|
242
|
+
* recording the merge commit, task ID, and cleanup outcome.
|
|
243
|
+
*
|
|
244
|
+
* Orchestrators MUST call this (not `completeAgentWorktreeViaMerge` directly)
|
|
245
|
+
* so every integration is auditable.
|
|
246
|
+
*
|
|
247
|
+
* @param taskId - The CLEO task ID (e.g. `"T1587"`).
|
|
248
|
+
* @param projectRoot - Absolute path to the project root.
|
|
249
|
+
* @param opts.targetBranch - Override the resolved default branch.
|
|
250
|
+
* @param opts.taskTitle - Task title used in the merge commit message subject.
|
|
251
|
+
* @param opts.skipFetch - Skip the `git fetch origin` step (test fixtures).
|
|
252
|
+
* @param opts.auditLogPath - Override the audit JSONL path (testing).
|
|
253
|
+
* @param opts.evidence - The task's evidence atoms; the prune keeps a worktree holding the only copy (T13696).
|
|
254
|
+
* @returns Integration result including audit log path.
|
|
255
|
+
*
|
|
256
|
+
* @task T9043
|
|
257
|
+
* @adr ADR-062
|
|
258
|
+
*/
|
|
259
|
+
export declare function completeAgentWorktreeIntegration(taskId: string, projectRoot: string, opts?: {
|
|
260
|
+
targetBranch?: string;
|
|
261
|
+
taskTitle?: string;
|
|
262
|
+
skipFetch?: boolean;
|
|
263
|
+
auditLogPath?: string;
|
|
264
|
+
evidence?: readonly EvidenceAtom[];
|
|
265
|
+
}): WorktreeIntegrationResult;
|
|
266
|
+
/**
|
|
267
|
+
* The single integration result for a completion envelope (T14053): what the
|
|
268
|
+
* run actually did, so it can never contradict the merge. `merge` only when a
|
|
269
|
+
* merge commit was made; a decided merge that failed reads as `refuse`.
|
|
270
|
+
*
|
|
271
|
+
* @param result - The merge run's result (its `plan` is the decision it acted on).
|
|
272
|
+
* @returns `{branch, worktreePath, targetBranch, action, reason, mergeCommit?, pushed: false}`.
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```ts
|
|
276
|
+
* integrationOutcome(completeAgentWorktreeIntegration('T1', root)).action; // 'skip'
|
|
277
|
+
* ```
|
|
278
|
+
* @task T14053
|
|
279
|
+
*/
|
|
280
|
+
export declare function integrationOutcome(result: WorktreeMergeResult): WorktreeIntegrationOutcome;
|
|
281
|
+
//# sourceMappingURL=branch-integration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-integration.d.ts","sourceRoot":"","sources":["../../src/spawn/branch-integration.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,YAAY,EACZ,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AA0B7B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CA4C5D;AAED;;;;;;;;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