agents-relay 2.0.263 → 2.0.264
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/README.md +57 -52
- package/bin/migrate-task-ids.mjs +12 -0
- package/dist/blocker-recovery.js +9 -16
- package/dist/cli-blocker.js +2 -1
- package/dist/cli-coordinator.js +19 -7
- package/dist/cli-foreground.js +82 -0
- package/dist/cli-help.js +61 -72
- package/dist/cli-job-create.js +15 -9
- package/dist/cli-prompt.js +9 -5
- package/dist/cli-support.js +21 -8
- package/dist/cli-worker-task.js +9 -3
- package/dist/cli.js +50 -36
- package/dist/dag-task-runtime.js +16 -12
- package/dist/dashboard-html.js +28 -14
- package/dist/dashboard-jel.js +87 -31
- package/dist/dashboard-style.js +2 -8
- package/dist/dependency-revision-execution.js +15 -6
- package/dist/final-review-role.js +0 -12
- package/dist/job-local-repository-migration.js +137 -0
- package/dist/job-pr-number-migration.js +0 -4
- package/dist/job-task-id-sequence.js +18 -9
- package/dist/job-worktree-cleanup.js +3 -3
- package/dist/local-job-registry.js +2 -2
- package/dist/local-managed-store.js +2 -2
- package/dist/local-merge-delivery.js +16 -3
- package/dist/local-merge-projection.js +192 -49
- package/dist/no-github.js +2 -1
- package/dist/planner-recovery.js +8 -3
- package/dist/planner.js +5 -5
- package/dist/pool.js +3 -3
- package/dist/projection-failure-recovery.js +6 -46
- package/dist/reconciler-context.js +5 -5
- package/dist/reconciler-review.js +12 -37
- package/dist/reconciler-runtime.js +1 -4
- package/dist/reconciler.js +5 -5
- package/dist/relay-job-merge.js +33 -0
- package/dist/relay-store.js +8 -30
- package/dist/relay-workflow-operations.js +2 -0
- package/dist/relayd-control.js +22 -25
- package/dist/relayd-dashboard-actions.js +4 -5
- package/dist/relayd-utilities.js +15 -20
- package/dist/relayd.js +59 -299
- package/dist/review-generation-fence.js +1 -1
- package/dist/review-replan.js +6 -1
- package/dist/review-revision-model.js +11 -6
- package/dist/task-context.js +1 -1
- package/dist/task-id-migration.js +229 -0
- package/dist/task-transitions.js +1 -1
- package/dist/troubleshooter.js +13 -16
- package/dist/unified-job-registry.js +9 -0
- package/dist/workflow/projection-conflict-v2.js +30 -26
- package/dist/workflow/task-related-action-v2.js +1 -2
- package/dist/workspace.js +52 -56
- package/package.json +4 -2
- package/skills/agents-relay/SKILL.md +35 -60
- package/skills/agents-relay/agents/planner.agent.md +5 -5
- package/skills/agents-relay/bin/services.mjs +21 -3
- package/skills/agents-relay/contracts/task-job-contract.md +11 -2
- package/skills/agents-relay/evals/capabilities.json +6 -1
- package/workflow/projection-conflict.mmd +59 -56
- package/workflow/projection-outbox-conflict.mmd +20 -0
- package/dist/cli-projection.js +0 -29
- package/dist/projection-recovery-runtime.js +0 -121
- package/dist/projection-recovery.js +0 -101
package/dist/dashboard-jel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Keep this function self-contained: dashboard-html embeds its JS source in the browser. */
|
|
2
2
|
export function jobJelDiagram(job) {
|
|
3
3
|
const lines = ['flowchart LR'];
|
|
4
|
-
const safe = (value) => String(value ?? 'Unknown').replace(/[
|
|
4
|
+
const safe = (value) => String(value ?? 'Unknown').replace(/https?:\/\/[^\s]*/gi, '').replace(/[^\p{L}\p{N} _./()—:-]/gu, '').slice(0, 100);
|
|
5
5
|
const now = Date.now();
|
|
6
6
|
const instant = (value) => {
|
|
7
7
|
if (typeof value !== 'string' || !value)
|
|
@@ -13,58 +13,51 @@ export function jobJelDiagram(job) {
|
|
|
13
13
|
const from = instant(start);
|
|
14
14
|
const to = end === 'NOW' ? now : instant(end);
|
|
15
15
|
if (from === null || to === null || to < from)
|
|
16
|
-
return '
|
|
16
|
+
return '—';
|
|
17
17
|
const seconds = Math.floor((to - from) / 1000);
|
|
18
18
|
if (seconds < 60)
|
|
19
19
|
return seconds + 's';
|
|
20
20
|
const minutes = Math.floor(seconds / 60);
|
|
21
21
|
if (minutes < 60)
|
|
22
|
-
return minutes + 'm
|
|
22
|
+
return minutes + 'm' + String(seconds % 60).padStart(2, '0') + 's';
|
|
23
23
|
const hours = Math.floor(minutes / 60);
|
|
24
24
|
if (hours < 24)
|
|
25
|
-
return hours + 'h
|
|
26
|
-
return Math.floor(hours / 24) + 'd
|
|
25
|
+
return hours + 'h' + String(minutes % 60).padStart(2, '0') + 'm';
|
|
26
|
+
return Math.floor(hours / 24) + 'd' + String(hours % 24).padStart(2, '0') + 'h';
|
|
27
27
|
};
|
|
28
28
|
const terminalTask = (task) => ['SUCCEEDED', 'FAILED', 'CANCELLED'].includes(task.state || '');
|
|
29
29
|
const workElapsed = (work) => {
|
|
30
30
|
const starts = work.map(task => instant(task.createdAt)).filter((time) => time !== null);
|
|
31
31
|
if (starts.length !== work.length || !starts.length)
|
|
32
|
-
return '
|
|
32
|
+
return '—';
|
|
33
33
|
const ends = work.map(task => instant(task.updatedAt)).filter((time) => time !== null);
|
|
34
34
|
return elapsed(new Date(Math.min(...starts)).toISOString(), work.every(terminalTask) && ends.length === work.length ? new Date(Math.max(...ends)).toISOString() : 'NOW');
|
|
35
35
|
};
|
|
36
|
-
const node = (id, label, time) => lines.push(' ' + id + '["' + safe(label + '
|
|
36
|
+
const node = (id, label, time) => lines.push(' ' + id + '["' + safe(label).slice(0, 80) + ' (' + safe(time) + ')"]');
|
|
37
37
|
const edge = (from, to, reason = '') => lines.push(' ' + from + ' -->' + (reason ? '|' + safe(reason) + '|' : '') + ' ' + to);
|
|
38
38
|
const tasks = Array.isArray(job.tasks) ? job.tasks : [];
|
|
39
|
-
const isReviewer = (task) =>
|
|
39
|
+
const isReviewer = (task) => ['job-acceptance-reviewer', 'reviewer'].includes(task.agentName || '');
|
|
40
40
|
const isTroubleshooter = (task) => task.agentName === 'troubleshooter';
|
|
41
|
-
const state = (value, fallback) => typeof value === 'string' && value ? safe(value).toUpperCase() : fallback;
|
|
42
|
-
const workLabel = (work) => {
|
|
43
|
-
const succeeded = work.filter(task => task.state === 'SUCCEEDED').length;
|
|
44
|
-
const failed = work.filter(task => task.state === 'FAILED').length;
|
|
45
|
-
const active = work.filter(task => !['SUCCEEDED', 'FAILED', 'CANCELLED'].includes(task.state || '')).length;
|
|
46
|
-
return work.length + ' tasks / ' + succeeded + ' succeeded / ' + failed + ' failed / ' + active + ' active';
|
|
47
|
-
};
|
|
48
41
|
// These dashed observation branches are not workflow transitions: persisted
|
|
49
42
|
// Task facts are projected without inferring a new scheduling decision.
|
|
50
43
|
const diagnostics = (executionId, suffix, work, troubleshoot) => {
|
|
51
44
|
const failed = new Set();
|
|
52
|
-
const add = (kind, label, time) => {
|
|
45
|
+
const add = (kind, label, time, origin) => {
|
|
53
46
|
const id = kind + '_' + suffix + '_' + String(lines.filter(line => line.startsWith(' ' + kind + '_' + suffix + '_')).length);
|
|
54
47
|
node(id, label, time);
|
|
55
|
-
lines.push(' ' + executionId + ' -.-> ' + id);
|
|
48
|
+
lines.push(' ' + (origin ? taskNodeId(origin) : executionId) + ' -.-> ' + id);
|
|
56
49
|
lines.push(' class ' + id + ' jel' + kind[0].toUpperCase() + kind.slice(1));
|
|
57
50
|
};
|
|
58
51
|
for (const task of work) {
|
|
59
52
|
if (task.state === 'FAILED') {
|
|
60
53
|
const key = (task.id || 'unknown') + ':' + String(task.attempt ?? '?');
|
|
61
54
|
failed.add(key);
|
|
62
|
-
add('failed', 'Failed
|
|
55
|
+
add('failed', 'Failed', elapsed(task.createdAt, task.updatedAt), task);
|
|
63
56
|
}
|
|
64
57
|
if (typeof task.attempt === 'number' && Number.isInteger(task.attempt) && task.attempt > 1) {
|
|
65
58
|
const history = Array.isArray(task.executionHistory) ? task.executionHistory : [];
|
|
66
59
|
const current = history.slice().reverse().find(record => record.attempt === task.attempt);
|
|
67
|
-
add('retry', 'Retry
|
|
60
|
+
add('retry', 'Retry', elapsed(current?.startedAt, terminalTask(task) ? task.updatedAt : 'NOW'), task);
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
for (const task of troubleshoot) {
|
|
@@ -75,10 +68,43 @@ export function jobJelDiagram(job) {
|
|
|
75
68
|
failed.add(key);
|
|
76
69
|
// Recovery-for-attempt is durable evidence of a failed attempt, but
|
|
77
70
|
// not of its terminal timestamp: display unknown, never fabricate.
|
|
78
|
-
add('failed', 'Failed
|
|
71
|
+
add('failed', 'Failed', '—', parent);
|
|
79
72
|
}
|
|
80
73
|
}
|
|
81
|
-
add('troubleshooter',
|
|
74
|
+
add('troubleshooter', task.title || task.agentName || 'Troubleshooter', workElapsed([task]), parent);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Exact Task IDs, DAG lineage and dependencies are persisted facts, not inferred
|
|
78
|
+
// workflow transitions. Task nodes are clickable in the dashboard after SVG sanitization.
|
|
79
|
+
const taskNodeId = (task) => 'task_' + tasks.indexOf(task);
|
|
80
|
+
const taskElapsed = (task) => {
|
|
81
|
+
const end = terminalTask(task) ? task.updatedAt : 'NOW';
|
|
82
|
+
const coordinator = (task.kind || '').toLowerCase() === 'coordinator' ||
|
|
83
|
+
(/coordinator/i.test(task.agentName || '') && !task.dagNode) || !!task.agentGraph;
|
|
84
|
+
const history = Array.isArray(task.executionHistory) ? task.executionHistory : [];
|
|
85
|
+
const last = history.slice().reverse().find(record => record.attempt === task.attempt);
|
|
86
|
+
const run = coordinator ? '—' : elapsed(last?.startedAt, end);
|
|
87
|
+
return run !== '—' ? run : elapsed(task.createdAt, end);
|
|
88
|
+
};
|
|
89
|
+
const taskNodes = (stage, work) => {
|
|
90
|
+
const byId = new Map(work.filter(task => task.id).map(task => [task.id, task]));
|
|
91
|
+
for (const task of work) {
|
|
92
|
+
const id = taskNodeId(task);
|
|
93
|
+
node(id, task.title?.trim() || task.agentName?.trim() || task.id || 'Task', taskElapsed(task));
|
|
94
|
+
if (task.state === 'FAILED')
|
|
95
|
+
lines.push(' class ' + id + ' jelFailed');
|
|
96
|
+
else if ((task.attempt || 0) > 1)
|
|
97
|
+
lines.push(' class ' + id + ' jelRetry');
|
|
98
|
+
const parent = task.parentTaskId ? byId.get(task.parentTaskId) : undefined;
|
|
99
|
+
if (parent)
|
|
100
|
+
edge(taskNodeId(parent), id, 'DAG child');
|
|
101
|
+
else
|
|
102
|
+
lines.push(' ' + stage + ' -.-> ' + id);
|
|
103
|
+
for (const dependency of task.dependencies || []) {
|
|
104
|
+
const upstream = byId.get(dependency);
|
|
105
|
+
if (upstream && upstream !== parent)
|
|
106
|
+
edge(taskNodeId(upstream), id, 'depends');
|
|
107
|
+
}
|
|
82
108
|
}
|
|
83
109
|
};
|
|
84
110
|
const finish = () => {
|
|
@@ -87,14 +113,16 @@ export function jobJelDiagram(job) {
|
|
|
87
113
|
lines.push(' classDef jelFailed fill:#fee2e2,stroke:#b91c1c,color:#991b1b,stroke-width:2px');
|
|
88
114
|
lines.push(' classDef jelRetry fill:#ede9fe,stroke:#7c3aed,color:#5b21b6,stroke-width:2px');
|
|
89
115
|
lines.push(' classDef jelTroubleshooter fill:#fef3c7,stroke:#b45309,color:#92400e,stroke-width:2px');
|
|
116
|
+
lines.push(' classDef jelReviewer fill:#dbeafe,stroke:#2563eb,color:#1e40af,stroke-width:2px');
|
|
90
117
|
return lines.join('\n');
|
|
91
118
|
};
|
|
92
119
|
const plans = Array.isArray(job.plans) ? job.plans : [];
|
|
93
120
|
const jobEnd = ['COMPLETED', 'CANCELLED'].includes(job.state || '') ? job.updatedAt : 'NOW';
|
|
94
121
|
const firstStart = plans[0]?.createdAt || (job.tasks || []).map(task => task.createdAt).filter(Boolean).sort()[0];
|
|
95
|
-
node('created', 'Create
|
|
122
|
+
node('created', 'Create', elapsed(job.createdAt, firstStart || jobEnd));
|
|
96
123
|
const rounds = plans.length ? plans : [{ id: '', round: 1, status: 'NOT STARTED', generatedTaskIds: [] }];
|
|
97
124
|
let previous = 'created';
|
|
125
|
+
const allocated = new Set();
|
|
98
126
|
for (let i = 0; i < rounds.length; i++) {
|
|
99
127
|
const plan = rounds[i];
|
|
100
128
|
const number = Number.isInteger(plan.round) && (plan.round ?? 0) > 0 ? plan.round : i + 1;
|
|
@@ -103,21 +131,49 @@ export function jobJelDiagram(job) {
|
|
|
103
131
|
const executeId = 'execute_' + suffix;
|
|
104
132
|
const reviewId = 'review_' + suffix;
|
|
105
133
|
const assigned = new Set(Array.isArray(plan.generatedTaskIds) ? plan.generatedTaskIds : []);
|
|
106
|
-
const
|
|
134
|
+
const candidates = tasks.filter(task => !isReviewer(task) && !isTroubleshooter(task));
|
|
135
|
+
if (plans.length) {
|
|
136
|
+
for (const task of candidates)
|
|
137
|
+
if (task.planningDecisionId === plan.id || task.planningRound === number)
|
|
138
|
+
assigned.add(task.id || '');
|
|
139
|
+
// DAG children often have only parentTaskId; inherit the parent round.
|
|
140
|
+
for (let depth = 0; depth < candidates.length; depth++) {
|
|
141
|
+
let changed = false;
|
|
142
|
+
for (const task of candidates)
|
|
143
|
+
if (task.parentTaskId && assigned.has(task.parentTaskId) && !assigned.has(task.id || '')) {
|
|
144
|
+
assigned.add(task.id || '');
|
|
145
|
+
changed = true;
|
|
146
|
+
}
|
|
147
|
+
if (!changed)
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const work = plans.length
|
|
152
|
+
? candidates.filter(task => !allocated.has(task.id || '') && (assigned.has(task.id || '') || (i === rounds.length - 1)))
|
|
153
|
+
: candidates;
|
|
154
|
+
for (const task of work)
|
|
155
|
+
if (task.id)
|
|
156
|
+
allocated.add(task.id);
|
|
107
157
|
if (plans.length)
|
|
108
|
-
node(planId, 'Plan ' + number
|
|
109
|
-
node(executeId, 'Execute ' + number
|
|
158
|
+
node(planId, 'Plan ' + number, elapsed(plan.createdAt, plan.status === 'PLANNING' ? 'NOW' : plan.updatedAt));
|
|
159
|
+
node(executeId, 'Execute ' + number, workElapsed(work));
|
|
110
160
|
const workIds = new Set(work.map(task => task.id));
|
|
111
161
|
const troubleshoot = tasks.filter(task => isTroubleshooter(task) &&
|
|
112
162
|
(workIds.has(task.parentTaskId || '') || task.planningDecisionId === plan.id || !plans.length));
|
|
163
|
+
taskNodes(executeId, work);
|
|
113
164
|
diagnostics(executeId, suffix, work, troubleshoot);
|
|
114
165
|
const nextPlan = plans[i + 1];
|
|
115
|
-
const review = job.reviewEnabled === false ? 'NOT REQUIRED' : nextPlan?.trigger?.source === 'review' ? 'CHANGES REQUIRED' : i === rounds.length - 1 ? state(job.review?.outcome, 'NOT STARTED') : 'NOT RECORDED';
|
|
116
166
|
// Review Tasks are not guaranteed to carry the Plan ID. Use their persisted
|
|
117
167
|
// timestamps within the current round, never guess a Review duration.
|
|
118
|
-
const reviewTasks = tasks.filter(task => isReviewer(task) &&
|
|
119
|
-
|
|
120
|
-
|
|
168
|
+
const reviewTasks = tasks.filter(task => isReviewer(task) &&
|
|
169
|
+
(!plans.length || (instant(task.createdAt) !== null && instant(plan.createdAt) !== null &&
|
|
170
|
+
instant(task.createdAt) >= instant(plan.createdAt) && (!nextPlan?.createdAt || (instant(nextPlan.createdAt) !== null && instant(task.createdAt) < instant(nextPlan.createdAt))))));
|
|
171
|
+
node(reviewId, 'Final Review ' + number, workElapsed(reviewTasks));
|
|
172
|
+
for (const task of reviewTasks) {
|
|
173
|
+
node(taskNodeId(task), task.title?.trim() || task.agentName || task.id || 'Final Review', taskElapsed(task));
|
|
174
|
+
lines.push(' ' + reviewId + ' -.-> ' + taskNodeId(task));
|
|
175
|
+
lines.push(' class ' + taskNodeId(task) + (task.state === 'FAILED' ? ' jelFailed' : ' jelReviewer'));
|
|
176
|
+
}
|
|
121
177
|
if (plans.length) {
|
|
122
178
|
edge(previous, planId, i > 0 && plan.trigger?.source === 'review' ? 'changes required' : '');
|
|
123
179
|
edge(planId, executeId);
|
|
@@ -130,8 +186,8 @@ export function jobJelDiagram(job) {
|
|
|
130
186
|
const merge = job.localMerge?.status === 'failed' ? 'FAILED' : job.localMerge?.status === 'succeeded' || job.githubState === 'MERGED' || job.publication?.version ? 'DONE' : job.state === 'COMPLETED' ? 'NOT RECORDED' : 'PENDING';
|
|
131
187
|
const mergeStart = job.review?.outcome === 'approved' ? job.review.updatedAt : undefined;
|
|
132
188
|
const mergeEnd = merge === 'DONE' ? job.localMerge?.updatedAt || job.mergedAt : merge === 'PENDING' && mergeStart ? 'NOW' : undefined;
|
|
133
|
-
node('merge', 'Merge
|
|
134
|
-
node('finished', 'Job
|
|
189
|
+
node('merge', 'Merge', elapsed(mergeStart, mergeEnd));
|
|
190
|
+
node('finished', 'Job', elapsed(job.createdAt, jobEnd));
|
|
135
191
|
edge(previous, 'merge');
|
|
136
192
|
edge('merge', 'finished');
|
|
137
193
|
return finish();
|
package/dist/dashboard-style.js
CHANGED
|
@@ -131,20 +131,14 @@ export const dashboardStyles = ` <style>
|
|
|
131
131
|
.graph-navigation { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; margin-bottom:.7rem; }
|
|
132
132
|
.graph-canvas .node.drillable { cursor:pointer; }
|
|
133
133
|
.graph-canvas .node.drillable text, .graph-canvas .node.drillable tspan { fill:#2367b1; }
|
|
134
|
-
.jel-
|
|
135
|
-
.jel-
|
|
136
|
-
.jel-legend-failed { background:#fee2e2; border-color:#b91c1c!important; color:#991b1b; }
|
|
137
|
-
.jel-legend-retry { background:#ede9fe; border-color:#7c3aed!important; color:#5b21b6; }
|
|
138
|
-
.jel-legend-troubleshooter { background:#fef3c7; border-color:#b45309!important; color:#92400e; }
|
|
134
|
+
.jel-chart .node.jel-inspectable { cursor:pointer; }
|
|
135
|
+
.jel-chart .node.jel-inspectable:focus-visible { outline:2px solid #2563eb; outline-offset:3px; }
|
|
139
136
|
.jel-source { overflow:auto; white-space:pre; font:12px/1.5 ui-monospace,monospace; }
|
|
140
137
|
.graph-dialog { box-sizing:border-box; width:98vw; height:96vh; height:96dvh; max-width:none; max-height:none; padding:.55rem; border:1px solid var(--border); border-radius:.5rem; background:var(--surface); color:var(--text); }
|
|
141
138
|
.graph-dialog[open] { display:flex; flex-direction:column; gap:.25rem; }
|
|
142
139
|
.graph-dialog::backdrop { background:#17202b99; }
|
|
143
140
|
.graph-dialog-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:.7rem; padding:.3rem .5rem; }
|
|
144
141
|
.graph-dialog-viewport { flex:1; min-height:0; min-width:0; overflow:auto; cursor:grab; background:var(--surface2); border:1px solid var(--border); border-radius:.4rem; }
|
|
145
|
-
.graph-jel-meta { display:grid; gap:.2rem; padding:.1rem .3rem .25rem; }
|
|
146
|
-
.graph-jel-meta[hidden] { display:none; }
|
|
147
|
-
.graph-jel-meta #jel-status { margin:0; font-size:.74rem; }
|
|
148
142
|
.graph-dialog-viewport:active { cursor:grabbing; }
|
|
149
143
|
.graph-dialog-viewport .graph-canvas { display:grid; width:max-content; min-width:100%; min-height:100%; overflow:visible; }
|
|
150
144
|
.graph-canvas .node text { pointer-events:none; }
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
1
|
import { createTaskEntity } from './workflow/entity-creation.js';
|
|
3
2
|
import { tryApplyTaskCancelAction } from './task-actions.js';
|
|
4
3
|
import { decideDependencyRevision } from './workflow/dependency-revision-v2.js';
|
|
5
4
|
import { dependencyRevisionVector, dependencyValidity, sameDependencyRevisionVector } from './review-revision-model.js';
|
|
6
5
|
import { isFinalReviewAgent } from './final-review-role.js';
|
|
6
|
+
import { allocateEntityId } from './job-task-id-sequence.js';
|
|
7
|
+
import { relayStoreDirectory } from './relay-store.js';
|
|
7
8
|
function latestDirectRevision(job, original) {
|
|
8
9
|
return job.tasks.filter(task => task.revision?.originalTaskId === original.id && task.state === 'SUCCEEDED')
|
|
9
10
|
.sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.id.localeCompare(b.id)).at(-1);
|
|
@@ -40,7 +41,7 @@ export function dependencyRevisionStillCurrent(job, task) {
|
|
|
40
41
|
return false;
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
export function reconcileDependencyRevisionFacts(job) {
|
|
44
|
+
export function reconcileDependencyRevisionFacts(job, reservedIds = []) {
|
|
44
45
|
const created = [];
|
|
45
46
|
const changedStale = [];
|
|
46
47
|
const originals = job.tasks.filter(task => task.kind !== 'planner' && !isFinalReviewAgent(task.agentName)
|
|
@@ -61,6 +62,7 @@ export function reconcileDependencyRevisionFacts(job) {
|
|
|
61
62
|
sorted.push(task);
|
|
62
63
|
};
|
|
63
64
|
originals.forEach(visit);
|
|
65
|
+
let allocatedIndex = 0;
|
|
64
66
|
for (const original of sorted) {
|
|
65
67
|
// A queued/DRAFT child whose upstream evidence moved is superseded by the
|
|
66
68
|
// authoritative Task cancellation graph. Running work is settled via the
|
|
@@ -86,9 +88,7 @@ export function reconcileDependencyRevisionFacts(job) {
|
|
|
86
88
|
const previous = priorVector(job, original);
|
|
87
89
|
const changed = !sameDependencyRevisionVector(vector, previous);
|
|
88
90
|
const rerunRequired = policies.some(id => vector[id] !== previous[id] && dependencyValidity(original, id) === 'rerun');
|
|
89
|
-
const
|
|
90
|
-
const id = 'dependency-revision-' + createHash('sha256').update(stableKey).digest('hex').slice(0, 24);
|
|
91
|
-
const duplicate = job.tasks.some(task => task.id === id || task.revision?.originalTaskId === original.id
|
|
91
|
+
const duplicate = job.tasks.some(task => task.revision?.originalTaskId === original.id
|
|
92
92
|
&& task.revision.kind !== 'targeted' && sameDependencyRevisionVector(task.revision.dependencyVector ?? {}, vector));
|
|
93
93
|
const decision = decideDependencyRevision('dependency.reconcile', {
|
|
94
94
|
upstreamEvidenceChanged: changed, explicitValidityPolicy: policies.length > 0,
|
|
@@ -103,6 +103,9 @@ export function reconcileDependencyRevisionFacts(job) {
|
|
|
103
103
|
throw new Error('Dependency Revision Graph did not select exactly one child action');
|
|
104
104
|
}
|
|
105
105
|
const mode = selectedActions[0] === 'dependencyRevision.createRerun' ? 'rerun' : 'revalidate';
|
|
106
|
+
const id = reservedIds[allocatedIndex++];
|
|
107
|
+
if (!id)
|
|
108
|
+
throw new Error('Dependency Revision reconciliation requires preallocated numeric Task IDs');
|
|
106
109
|
const inputs = policies.map(id => {
|
|
107
110
|
const originalDependency = job.tasks.find(task => task.id === id);
|
|
108
111
|
return latestDirectRevision(job, originalDependency) ?? originalDependency;
|
|
@@ -143,9 +146,15 @@ export function reconcileDependencyRevisionFacts(job) {
|
|
|
143
146
|
export async function reconcileDependencyRevisions(store, jobId) {
|
|
144
147
|
if (!store.mutateJob)
|
|
145
148
|
return [];
|
|
149
|
+
const snapshot = await store.load(jobId);
|
|
150
|
+
// Preview the pure reducer against a clone: allocate only IDs for actual new Tasks,
|
|
151
|
+
// not one unused global ID for every historical Task on every reconcile.
|
|
152
|
+
const previewIds = snapshot.tasks.map((_, index) => `preview-dependency-${index}`);
|
|
153
|
+
const planned = reconcileDependencyRevisionFacts(structuredClone(snapshot), previewIds);
|
|
154
|
+
const reservedIds = planned.map(() => allocateEntityId(relayStoreDirectory(), snapshot.repository, 'task'));
|
|
146
155
|
let created = [];
|
|
147
156
|
await store.mutateJob(jobId, job => {
|
|
148
|
-
created = reconcileDependencyRevisionFacts(job);
|
|
157
|
+
created = reconcileDependencyRevisionFacts(job, reservedIds);
|
|
149
158
|
return job;
|
|
150
159
|
});
|
|
151
160
|
return created;
|
|
@@ -3,15 +3,3 @@ export const FINAL_REVIEW_AGENT = 'job-acceptance-reviewer';
|
|
|
3
3
|
export function isFinalReviewAgent(name) {
|
|
4
4
|
return name === FINAL_REVIEW_AGENT || name === 'reviewer';
|
|
5
5
|
}
|
|
6
|
-
export function nextFinalReviewTaskId(job, headSha) {
|
|
7
|
-
const base = 'final-review-' + headSha.slice(0, 12);
|
|
8
|
-
const ids = new Set(job.tasks.filter(task => task.reviewHeadSha === headSha && isFinalReviewAgent(task.agentName)).map(task => task.id));
|
|
9
|
-
if (!ids.has(base))
|
|
10
|
-
return base;
|
|
11
|
-
for (let round = 2; round < 1000; round += 1) {
|
|
12
|
-
const candidate = base + '-r' + round;
|
|
13
|
-
if (!ids.has(candidate))
|
|
14
|
-
return candidate;
|
|
15
|
-
}
|
|
16
|
-
throw new Error('Too many final review rounds for ' + headSha);
|
|
17
|
-
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { access, copyFile, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
4
|
+
import { validateProjectRoot } from './workspace.js';
|
|
5
|
+
/** Explicit, idempotent migration. Requires daemon downtime; writes only after full preflight and a verified backup. */
|
|
6
|
+
export async function migrateJobLocalRepositories(databasePath, mappingPath) {
|
|
7
|
+
const dbPath = resolve(databasePath);
|
|
8
|
+
const mappings = JSON.parse(await readFile(mappingPath, 'utf8'));
|
|
9
|
+
if (mappings.version !== 1 || !Array.isArray(mappings.jobs))
|
|
10
|
+
throw new Error('Mapping file must have version: 1 and jobs: []');
|
|
11
|
+
const db = new DatabaseSync(dbPath);
|
|
12
|
+
try {
|
|
13
|
+
db.exec('PRAGMA busy_timeout=10000; PRAGMA wal_checkpoint(FULL)');
|
|
14
|
+
const rows = db.prepare('SELECT job_id,json FROM job_snapshot ORDER BY job_id').all();
|
|
15
|
+
const byId = new Map(mappings.jobs.map(item => [item.jobId, item]));
|
|
16
|
+
if (byId.size !== mappings.jobs.length || byId.size !== rows.length || rows.some(row => !byId.has(row.job_id)) || mappings.jobs.some(item => !rows.some(row => row.job_id === item.jobId)))
|
|
17
|
+
throw new Error('Migration mapping must contain exactly one entry for every durable Job ID');
|
|
18
|
+
const identities = new Map();
|
|
19
|
+
const plans = [];
|
|
20
|
+
for (const row of rows) {
|
|
21
|
+
const job = JSON.parse(row.json);
|
|
22
|
+
const mapping = byId.get(job.id);
|
|
23
|
+
const root = await validateProjectRoot(mapping.projectRoot, basename(await realpath(mapping.projectRoot)));
|
|
24
|
+
const repository = basename(root);
|
|
25
|
+
const collision = identities.get(repository);
|
|
26
|
+
if (collision && collision !== root)
|
|
27
|
+
throw new Error(`Local repository identity collision ${repository}: ${collision} and ${root}`);
|
|
28
|
+
identities.set(repository, root);
|
|
29
|
+
if (mapping.githubRepo && !/^[^/]+\/[^/]+$/.test(mapping.githubRepo))
|
|
30
|
+
throw new Error(`Invalid GitHub remote for Job ${job.id}`);
|
|
31
|
+
plans.push({ id: job.id, oldRepository: job.repository, job, root, repository, githubRepo: mapping.githubRepo });
|
|
32
|
+
}
|
|
33
|
+
const aliases = new Map();
|
|
34
|
+
for (const item of plans) {
|
|
35
|
+
const prior = aliases.get(item.oldRepository);
|
|
36
|
+
if (prior && prior !== item.repository)
|
|
37
|
+
throw new Error(`Historical repository alias ${item.oldRepository} maps to multiple local repositories`);
|
|
38
|
+
aliases.set(item.oldRepository, item.repository);
|
|
39
|
+
}
|
|
40
|
+
for (const item of plans) {
|
|
41
|
+
const registered = db.prepare('SELECT repository FROM source_registry WHERE job_id=?').get(item.id);
|
|
42
|
+
if (!registered || registered.repository !== item.oldRepository)
|
|
43
|
+
throw new Error(`source_registry does not match Job ${item.id}; repair mapping explicitly before migration`);
|
|
44
|
+
}
|
|
45
|
+
const updates = plans.map(item => {
|
|
46
|
+
const rewritten = rewriteRepositoryReferences(item.job, aliases);
|
|
47
|
+
rewritten.projectRoot = item.root;
|
|
48
|
+
rewritten.repository = item.repository;
|
|
49
|
+
if (item.githubRepo)
|
|
50
|
+
rewritten.githubRepo = item.githubRepo;
|
|
51
|
+
else
|
|
52
|
+
delete rewritten.githubRepo;
|
|
53
|
+
return { id: item.id, json: JSON.stringify(rewritten), repository: item.repository };
|
|
54
|
+
});
|
|
55
|
+
const plannedById = new Map(plans.map(item => [item.id, item]));
|
|
56
|
+
const pendingOutbox = db.prepare('SELECT scope_job_id,id,operation,payload_json,conflict_definition_json,conflict_evidence_json,conflict_resolution_json FROM projection_outbox').all();
|
|
57
|
+
const rewrittenOutbox = pendingOutbox.map(row => {
|
|
58
|
+
const owner = plannedById.get(row.scope_job_id);
|
|
59
|
+
if (!owner)
|
|
60
|
+
throw new Error(`Pending external operation is scoped to unmapped Job ${row.scope_job_id}`);
|
|
61
|
+
const rewrite = (json, external = false) => {
|
|
62
|
+
if (json === null)
|
|
63
|
+
return null;
|
|
64
|
+
const parsed = JSON.parse(json);
|
|
65
|
+
const output = rewriteRepositoryReferences(parsed, aliases);
|
|
66
|
+
if (external && typeof output.repository === 'string') {
|
|
67
|
+
if (!owner.githubRepo)
|
|
68
|
+
throw new Error(`Job ${owner.id} has pending GitHub operation ${row.operation} but no explicit githubRepo mapping`);
|
|
69
|
+
output.repository = owner.githubRepo;
|
|
70
|
+
}
|
|
71
|
+
return JSON.stringify(output);
|
|
72
|
+
};
|
|
73
|
+
const pendingGitHubEffect = row.operation === 'create_pull_request' || row.operation === 'close_pull_request';
|
|
74
|
+
return { ...row, payload_json: rewrite(row.payload_json, pendingGitHubEffect),
|
|
75
|
+
conflict_definition_json: rewrite(row.conflict_definition_json, pendingGitHubEffect),
|
|
76
|
+
conflict_evidence_json: rewrite(row.conflict_evidence_json, pendingGitHubEffect),
|
|
77
|
+
conflict_resolution_json: rewrite(row.conflict_resolution_json, pendingGitHubEffect) };
|
|
78
|
+
});
|
|
79
|
+
const backupPath = `${dbPath}.pre-local-repository-v1.bak`;
|
|
80
|
+
try {
|
|
81
|
+
await access(backupPath);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
try {
|
|
85
|
+
await copyFile(dbPath, backupPath, 0);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw new Error(`Cannot create migration backup ${backupPath}: ${String(error)}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const backup = new DatabaseSync(backupPath, { readOnly: true });
|
|
92
|
+
try {
|
|
93
|
+
const backupCount = Number(backup.prepare('SELECT COUNT(*) AS n FROM job_snapshot').get().n);
|
|
94
|
+
if (backupCount !== rows.length)
|
|
95
|
+
throw new Error('Migration backup verification failed');
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
backup.close();
|
|
99
|
+
}
|
|
100
|
+
db.exec('BEGIN IMMEDIATE');
|
|
101
|
+
try {
|
|
102
|
+
const updateJob = db.prepare('UPDATE job_snapshot SET json=?,updated_at=updated_at WHERE job_id=?');
|
|
103
|
+
const updateRegistry = db.prepare('UPDATE source_registry SET repository=? WHERE job_id=?');
|
|
104
|
+
const updateOutbox = db.prepare('UPDATE projection_outbox SET payload_json=?,conflict_definition_json=?,conflict_evidence_json=?,conflict_resolution_json=? WHERE scope_job_id=? AND id=?');
|
|
105
|
+
for (const row of updates) {
|
|
106
|
+
updateJob.run(row.json, row.id);
|
|
107
|
+
const result = updateRegistry.run(row.repository, row.id);
|
|
108
|
+
if (Number(result.changes) !== 1)
|
|
109
|
+
throw new Error(`Missing source_registry entry for Job ${row.id}`);
|
|
110
|
+
}
|
|
111
|
+
for (const row of rewrittenOutbox) {
|
|
112
|
+
updateOutbox.run(row.payload_json, row.conflict_definition_json, row.conflict_evidence_json, row.conflict_resolution_json, row.scope_job_id, row.id);
|
|
113
|
+
}
|
|
114
|
+
db.prepare("INSERT INTO migration_metadata(key,value) VALUES('local-repository-v1',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value").run(new Date().toISOString());
|
|
115
|
+
db.exec('COMMIT');
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
db.exec('ROLLBACK');
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
return { migrated: updates.length, backupPath };
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
db.close();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function rewriteRepositoryReferences(value, aliases) {
|
|
128
|
+
if (Array.isArray(value))
|
|
129
|
+
return value.map(item => rewriteRepositoryReferences(item, aliases));
|
|
130
|
+
if (!value || typeof value !== 'object')
|
|
131
|
+
return value;
|
|
132
|
+
const output = {};
|
|
133
|
+
for (const [key, item] of Object.entries(value))
|
|
134
|
+
output[key] = key === 'repository' && typeof item === 'string' && aliases.has(item) ? aliases.get(item) : rewriteRepositoryReferences(item, aliases);
|
|
135
|
+
return output;
|
|
136
|
+
}
|
|
137
|
+
export function migrationBackupPath(databasePath) { return join(dirname(resolve(databasePath)), `${basename(databasePath)}.pre-local-repository-v1.bak`); }
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { isFinalReviewAgent } from './final-review-role.js';
|
|
2
1
|
import { deriveTaskTitle } from './task-title.js';
|
|
3
2
|
export function normalizeLegacyJobPrNumber(input) {
|
|
4
3
|
const record = input;
|
|
@@ -8,9 +7,6 @@ export function normalizeLegacyJobPrNumber(input) {
|
|
|
8
7
|
input.prNumber = Number(legacy);
|
|
9
8
|
delete record[legacyKey];
|
|
10
9
|
for (const task of input.tasks ?? []) {
|
|
11
|
-
if (task.id.startsWith('final-review-') && isFinalReviewAgent(task.agentName) && /^Job ID:\s*\d+$/i.test(task.title?.trim() ?? '')) {
|
|
12
|
-
task.title = `Final review: ${input.title}`;
|
|
13
|
-
}
|
|
14
10
|
if (!task.title?.trim())
|
|
15
11
|
task.title = deriveTaskTitle(task.input, task.agentName ? `${task.agentName} task` : 'Task');
|
|
16
12
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { DatabaseSync } from 'node:sqlite';
|
|
2
2
|
import { mkdirSync } from 'node:fs';
|
|
3
3
|
import { relayUnifiedStorePath } from './relay-store-discovery.js';
|
|
4
|
-
|
|
5
|
-
const [owner, repo, extra] = repository.split('/');
|
|
6
|
-
if (!owner || !repo || extra || !/^[\w.-]+$/.test(owner) || !/^[\w.-]+$/.test(repo) || owner === '..' || repo === '..')
|
|
7
|
-
throw new Error('Invalid repository');
|
|
8
|
-
}
|
|
9
|
-
/** A generated ID is always a positive decimal. Historic nonnumeric Task IDs remain ordinary Task identifiers. */
|
|
4
|
+
/** All durable Job and Task IDs are positive decimal strings. */
|
|
10
5
|
export function isGeneratedEntityId(id, _repository, _kind) {
|
|
11
6
|
return /^[1-9][0-9]*$/.test(id);
|
|
12
7
|
}
|
|
13
8
|
/** Job and Task IDs each use their own store-global sequence. SQLite serializes allocation. */
|
|
14
9
|
export function allocateEntityId(directory, repository, kind, requestKey, occupied = new Set()) {
|
|
15
|
-
|
|
10
|
+
if (!repository)
|
|
11
|
+
throw new Error('Task ID allocation requires a repository context');
|
|
16
12
|
const prefix = '';
|
|
17
13
|
const scope = '*';
|
|
14
|
+
// Idempotency keys are repository-scoped for both globally allocated Job and Task IDs.
|
|
18
15
|
const scopedRequestKey = requestKey ? `${repository}:${requestKey}` : undefined;
|
|
19
16
|
if (requestKey !== undefined && (!requestKey || requestKey.length > 512))
|
|
20
17
|
throw new Error('Invalid idempotency key');
|
|
@@ -33,8 +30,20 @@ export function allocateEntityId(directory, repository, kind, requestKey, occupi
|
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
const old = db.prepare('SELECT value FROM sequences WHERE repository=? AND kind=?').get(scope, kind);
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
const hasSnapshots = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='job_snapshot'").get() !== undefined;
|
|
34
|
+
const snapshots = hasSnapshots ? db.prepare('SELECT json FROM job_snapshot').all() : [];
|
|
35
|
+
let storedMax = 0;
|
|
36
|
+
for (const { json } of snapshots) {
|
|
37
|
+
try {
|
|
38
|
+
const value = JSON.parse(json);
|
|
39
|
+
for (const id of kind === 'job' ? [value.id] : value.tasks?.map(task => task.id) ?? []) {
|
|
40
|
+
if (id && /^[1-9][0-9]*$/.test(id))
|
|
41
|
+
storedMax = Math.max(storedMax, Number(id));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch { /* Corrupt snapshots are rejected by normal store reads. */ }
|
|
45
|
+
}
|
|
46
|
+
let next = Math.max(old?.value ?? 0, storedMax) + 1;
|
|
38
47
|
while (occupied.has(prefix + next))
|
|
39
48
|
next++;
|
|
40
49
|
db.prepare('INSERT INTO sequences VALUES (?,?,?) ON CONFLICT(repository,kind) DO UPDATE SET value=excluded.value').run(scope, kind, next);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { cleanupCompletedJobWorktree } from './workspace.js';
|
|
2
2
|
/** Mechanical effect selected by job-lifecycle Graph on a completed PR. */
|
|
3
|
-
export async function cleanupMergedJobWorktree(job,
|
|
4
|
-
if (!
|
|
3
|
+
export async function cleanupMergedJobWorktree(job, cwdForJob) {
|
|
4
|
+
if (!cwdForJob)
|
|
5
5
|
throw new Error('No canonical project resolver for Worktree cleanup');
|
|
6
|
-
const result = await cleanupCompletedJobWorktree(await
|
|
6
|
+
const result = await cleanupCompletedJobWorktree(await cwdForJob(job), job);
|
|
7
7
|
// A blocked cleanup must be retried on a subsequent completed-Job reconcile.
|
|
8
8
|
if (result.status === 'blocked')
|
|
9
9
|
throw new Error(result.reason ?? 'Unsafe Worktree cleanup');
|
|
@@ -24,9 +24,9 @@ export function createJobIdRegistryResolver(directory, openStores, options = {})
|
|
|
24
24
|
}
|
|
25
25
|
// SQLite remains lifecycle authority. A positive PR binding only enables
|
|
26
26
|
// the external collaboration adapter for projection/merge side effects.
|
|
27
|
-
const githubEnabled = !options.noGitHub && job.prNumber > 0 && options.client;
|
|
27
|
+
const githubEnabled = !options.noGitHub && !!job.githubRepo && job.prNumber > 0 && options.client;
|
|
28
28
|
const github = githubEnabled
|
|
29
|
-
? new GitHubStore(options.client, job.
|
|
29
|
+
? new GitHubStore(options.client, job.githubRepo, job.prNumber, options.trustedAuthors ?? new Set())
|
|
30
30
|
: new InMemoryStore();
|
|
31
31
|
return { job, relay, store: new LocalAuthorityDurableStore(relay, github, undefined, !githubEnabled) };
|
|
32
32
|
};
|
|
@@ -5,8 +5,8 @@ import { LocalAuthorityDurableStore } from './local-authority-store.js';
|
|
|
5
5
|
import { relayStoreDirectory, relayUnifiedStorePath, resolveUnifiedJobScope, SQLiteRelayStore } from './relay-store.js';
|
|
6
6
|
/** Open the canonical V2 SQLite authority without making any GitHub request. */
|
|
7
7
|
export function openLocalManagedStore(repository, prNumber, options = {}) {
|
|
8
|
-
if (!/^[A-Za-z0-9_.-]
|
|
9
|
-
throw new Error('Local managed store requires a repository and either a positive PR number or immutable jobId');
|
|
8
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(repository) || repository === '.' || repository === '..' || !Number.isInteger(prNumber) || prNumber < 0 || (prNumber === 0 && !options.jobId)) {
|
|
9
|
+
throw new Error('Local managed store requires a local repository identity and either a positive PR number or immutable jobId');
|
|
10
10
|
}
|
|
11
11
|
const directory = options.directory ?? relayStoreDirectory();
|
|
12
12
|
const path = relayUnifiedStorePath(directory);
|
|
@@ -4,11 +4,23 @@ import { transitionJobEvent } from './task-transitions.js';
|
|
|
4
4
|
import { deliverLocalMerge, localMergeFacts } from './local-git-merge.js';
|
|
5
5
|
import { errorMessage } from './observability.js';
|
|
6
6
|
import { decideJobLifecycle } from './workflow/lifecycle.js';
|
|
7
|
+
/** A completed local merge records an optional, durable post-terminal effect.
|
|
8
|
+
* Existing completed Jobs without this marker are historical audit records,
|
|
9
|
+
* never silently published during a daemon upgrade. */
|
|
10
|
+
function recordPendingRemoteDelivery(job) {
|
|
11
|
+
const sha = job.localMerge?.mergedCommitSha;
|
|
12
|
+
if (job.state !== 'COMPLETED' || job.localMerge?.status !== 'succeeded' || !sha)
|
|
13
|
+
return;
|
|
14
|
+
if (job.remoteDelivery?.mergedCommitSha === sha)
|
|
15
|
+
return;
|
|
16
|
+
job.remoteDelivery = { mergedCommitSha: sha, status: 'pending', attempts: 0, updatedAt: new Date().toISOString() };
|
|
17
|
+
}
|
|
7
18
|
/** Graph-selected durable local merge and completion; no checked-out worktree is ever changed. */
|
|
8
|
-
export async function reconcileLocalGitCompletion(store, finalState, headSha, noGitHub,
|
|
19
|
+
export async function reconcileLocalGitCompletion(store, finalState, headSha, noGitHub, cwdForJob, emit, mergeEffect = deliverLocalMerge, now = Date.now) {
|
|
9
20
|
const facts = localMergeFacts(finalState, headSha, now);
|
|
10
21
|
if (decideJobLifecycle(finalState, 'local.completed', facts).target === 'COMPLETED') {
|
|
11
22
|
await transitionJobEvent(finalState, 'local.completed', facts);
|
|
23
|
+
recordPendingRemoteDelivery(finalState);
|
|
12
24
|
await store.saveJob(finalState);
|
|
13
25
|
return true;
|
|
14
26
|
}
|
|
@@ -29,9 +41,9 @@ export async function reconcileLocalGitCompletion(store, finalState, headSha, no
|
|
|
29
41
|
finalState.updatedAt = new Date().toISOString();
|
|
30
42
|
await store.saveJob(finalState);
|
|
31
43
|
}
|
|
32
|
-
if (!
|
|
44
|
+
if (!cwdForJob)
|
|
33
45
|
throw new Error('Local Git merge requires an explicit project path');
|
|
34
|
-
const repoPath = await
|
|
46
|
+
const repoPath = await cwdForJob(finalState);
|
|
35
47
|
const delivered = mergeEffect(repoPath, { ...activeReceipt, sourceSha: activeReceipt.sourceSha ?? headSha ?? undefined,
|
|
36
48
|
correlationJobId: finalState.id, displayPrNumber: finalState.prNumber > 0 ? finalState.prNumber : undefined });
|
|
37
49
|
finalState.localMerge = { ...activeReceipt, ...delivered, status: 'succeeded', projectionStrategy: 'target_ref_push',
|
|
@@ -80,6 +92,7 @@ export async function reconcileLocalGitCompletion(store, finalState, headSha, no
|
|
|
80
92
|
if (finalState.localMerge?.status === 'succeeded') {
|
|
81
93
|
const completionFacts = localMergeFacts(finalState, headSha, now);
|
|
82
94
|
await transitionJobEvent(finalState, 'local.completed', completionFacts);
|
|
95
|
+
recordPendingRemoteDelivery(finalState);
|
|
83
96
|
await store.saveJob(finalState);
|
|
84
97
|
return true;
|
|
85
98
|
}
|