@fitlab-ai/agent-infra 0.9.3 → 0.9.5
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 +3 -1
- package/README.zh-CN.md +3 -1
- package/bin/cli.ts +12 -0
- package/dist/bin/cli.js +14 -0
- package/dist/bin/internal-cli.js +144 -123
- package/dist/lib/agent-clients/adapter.js +94 -4
- package/dist/lib/{sandbox/credentials.js → agent-clients/adapters/claude-code-credentials.js} +4 -14
- package/dist/lib/agent-clients/adapters/claude-code-refresh.js +85 -0
- package/dist/lib/agent-clients/adapters/claude-code-sandbox.js +247 -0
- package/dist/lib/agent-clients/adapters/claude-code.js +17 -3
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +382 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +163 -0
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +211 -0
- package/dist/lib/agent-clients/adapters/codex.js +2 -2
- package/dist/lib/agent-clients/adapters/opencode-sandbox.js +108 -0
- package/dist/lib/agent-clients/adapters/opencode.js +15 -3
- package/dist/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/dist/lib/agent-clients/registry.js +9 -1
- package/dist/lib/git/worktree-identity.js +64 -0
- package/dist/lib/internal/codex-lifecycle.js +202 -0
- package/dist/lib/internal/sandbox-control.js +24 -0
- package/dist/lib/internal/task-activity.js +45 -13
- package/dist/lib/internal/task-create.js +48 -0
- package/dist/lib/internal/task-ledger.js +12 -3
- package/dist/lib/internal/task-lifecycle.js +19 -1
- package/dist/lib/internal/task-orchestration.js +170 -27
- package/dist/lib/platform/github-client.js +19 -2
- package/dist/lib/platform/pr-checks.js +1 -1
- package/dist/lib/platform/pull-requests.js +47 -1
- package/dist/lib/platform/releases.js +13 -5
- package/dist/lib/process-data/index.js +239 -0
- package/dist/lib/process-data/normalize.js +198 -0
- package/dist/lib/process-data/privacy.js +33 -0
- package/dist/lib/process-data/reconcile.js +95 -0
- package/dist/lib/process-data/repair.js +58 -0
- package/dist/lib/process-data/sources.js +345 -0
- package/dist/lib/process-data/store.js +282 -0
- package/dist/lib/process-data/types.js +2 -0
- package/dist/lib/run/index.js +4 -3
- package/dist/lib/run/tui.js +7 -8
- package/dist/lib/sandbox/agent-client-reconciler.js +26 -2
- package/dist/lib/sandbox/capture.js +7 -2
- package/dist/lib/sandbox/commands/create.js +110 -228
- package/dist/lib/sandbox/commands/enter.js +15 -47
- package/dist/lib/sandbox/commands/list-running.js +16 -6
- package/dist/lib/sandbox/commands/ls.js +10 -6
- package/dist/lib/sandbox/commands/rebuild.js +4 -3
- package/dist/lib/sandbox/commands/refresh.js +4 -84
- package/dist/lib/sandbox/commands/rm.js +24 -3
- package/dist/lib/sandbox/commands/show.js +12 -3
- package/dist/lib/sandbox/commands/start.js +7 -4
- package/dist/lib/sandbox/config.js +2 -0
- package/dist/lib/sandbox/constants.js +6 -0
- package/dist/lib/sandbox/control/client.js +58 -0
- package/dist/lib/sandbox/control/protocol.js +54 -0
- package/dist/lib/sandbox/control/server.js +144 -0
- package/dist/lib/sandbox/dockerfile.js +36 -13
- package/dist/lib/sandbox/mounts.js +17 -4
- package/dist/lib/sandbox/recovery.js +128 -5
- package/dist/lib/sandbox/redaction.js +12 -0
- package/dist/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/dist/lib/sandbox/workspace-identity.js +95 -0
- package/dist/lib/sandbox/workspace-view.js +109 -0
- package/dist/lib/task/activity-intent.js +257 -51
- package/dist/lib/task/activity-log.js +32 -5
- package/dist/lib/task/commit-finalization.js +278 -0
- package/dist/lib/task/commit-intent.js +165 -0
- package/dist/lib/task/create-service.js +137 -0
- package/dist/lib/task/create.js +333 -0
- package/dist/lib/task/decision-intents.js +31 -17
- package/dist/lib/task/delegation-receipts.js +2 -2
- package/dist/lib/task/implementation-inputs.js +54 -7
- package/dist/lib/task/ledger-intents.js +35 -1
- package/dist/lib/task/orchestration.js +505 -34
- package/dist/lib/task/resolve-ref.js +41 -1
- package/dist/lib/task/review-fingerprint.js +4 -0
- package/dist/lib/task/workspace-snapshot.js +78 -3
- package/lib/agent-clients/adapter.ts +130 -6
- package/lib/{sandbox/credentials.ts → agent-clients/adapters/claude-code-credentials.ts} +3 -18
- package/lib/agent-clients/adapters/claude-code-refresh.ts +128 -0
- package/lib/agent-clients/adapters/claude-code-sandbox.ts +295 -0
- package/lib/agent-clients/adapters/claude-code.ts +21 -3
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +442 -0
- package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +307 -0
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +250 -0
- package/lib/agent-clients/adapters/codex.ts +2 -2
- package/lib/agent-clients/adapters/opencode-sandbox.ts +136 -0
- package/lib/agent-clients/adapters/opencode.ts +18 -3
- package/lib/agent-clients/adapters/runtimes/claude-code.dockerfile +65 -0
- package/lib/agent-clients/registry.ts +9 -1
- package/lib/git/worktree-identity.ts +86 -0
- package/lib/internal/codex-lifecycle.ts +204 -0
- package/lib/internal/sandbox-control.ts +24 -0
- package/lib/internal/task-activity.ts +50 -14
- package/lib/internal/task-create.ts +49 -0
- package/lib/internal/task-ledger.ts +12 -3
- package/lib/internal/task-lifecycle.ts +22 -1
- package/lib/internal/task-orchestration.ts +117 -21
- package/lib/platform/github-client.ts +20 -2
- package/lib/platform/pr-checks.ts +1 -1
- package/lib/platform/pull-requests.ts +49 -1
- package/lib/platform/releases.ts +16 -4
- package/lib/process-data/index.ts +224 -0
- package/lib/process-data/normalize.ts +202 -0
- package/lib/process-data/privacy.ts +41 -0
- package/lib/process-data/reconcile.ts +110 -0
- package/lib/process-data/repair.ts +64 -0
- package/lib/process-data/sources.ts +354 -0
- package/lib/process-data/store.ts +315 -0
- package/lib/process-data/types.ts +135 -0
- package/lib/run/index.ts +5 -3
- package/lib/run/tui.ts +11 -8
- package/lib/sandbox/agent-client-reconciler.ts +44 -2
- package/lib/sandbox/capture.ts +9 -2
- package/lib/sandbox/commands/create.ts +127 -260
- package/lib/sandbox/commands/enter.ts +13 -59
- package/lib/sandbox/commands/list-running.ts +23 -6
- package/lib/sandbox/commands/ls.ts +22 -6
- package/lib/sandbox/commands/rebuild.ts +4 -3
- package/lib/sandbox/commands/refresh.ts +4 -126
- package/lib/sandbox/commands/rm.ts +24 -3
- package/lib/sandbox/commands/show.ts +29 -3
- package/lib/sandbox/commands/start.ts +6 -4
- package/lib/sandbox/config.ts +4 -0
- package/lib/sandbox/constants.ts +8 -0
- package/lib/sandbox/control/client.ts +79 -0
- package/lib/sandbox/control/protocol.ts +110 -0
- package/lib/sandbox/control/server.ts +155 -0
- package/lib/sandbox/dockerfile.ts +66 -13
- package/lib/sandbox/mounts.ts +24 -4
- package/lib/sandbox/recovery.ts +163 -6
- package/lib/sandbox/redaction.ts +14 -0
- package/lib/sandbox/runtimes/base.dockerfile +24 -74
- package/lib/sandbox/tool-types.ts +16 -0
- package/lib/sandbox/workspace-identity.ts +123 -0
- package/lib/sandbox/workspace-view.ts +150 -0
- package/lib/task/activity-intent.ts +350 -61
- package/lib/task/activity-log.ts +46 -7
- package/lib/task/commit-finalization.ts +376 -0
- package/lib/task/commit-intent.ts +230 -0
- package/lib/task/create-service.ts +171 -0
- package/lib/task/create.ts +372 -0
- package/lib/task/decision-intents.ts +32 -12
- package/lib/task/delegation-receipts.ts +2 -2
- package/lib/task/implementation-inputs.ts +62 -8
- package/lib/task/ledger-intents.ts +43 -3
- package/lib/task/orchestration.ts +673 -41
- package/lib/task/resolve-ref.ts +46 -1
- package/lib/task/review-fingerprint.ts +9 -0
- package/lib/task/workspace-snapshot.ts +98 -4
- package/package.json +7 -7
- package/templates/.agents/hooks/lifecycle-delegation.js +47 -3
- package/templates/.agents/rules/README.en.md +1 -1
- package/templates/.agents/rules/README.zh-CN.md +1 -1
- package/templates/.agents/rules/human-decision-context.en.md +11 -2
- package/templates/.agents/rules/human-decision-context.zh-CN.md +11 -2
- package/templates/.agents/rules/pr-checks-commands.en.md +1 -1
- package/templates/.agents/rules/pr-checks-commands.github.en.md +1 -1
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +2 -2
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +1 -1
- package/templates/.agents/rules/review-handshake.zh-CN.md +1 -1
- package/templates/.agents/rules/task-management.en.md +3 -0
- package/templates/.agents/rules/task-management.zh-CN.md +3 -0
- package/templates/.agents/skills/code-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/commit/SKILL.en.md +21 -17
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +28 -16
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +50 -0
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +56 -0
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +4 -4
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +4 -4
- package/templates/.agents/skills/complete-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/create-pr/SKILL.en.md +4 -4
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/create-task/SKILL.en.md +26 -43
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +26 -43
- package/templates/.agents/skills/create-task/reference/context-capture.en.md +34 -0
- package/templates/.agents/skills/create-task/reference/context-capture.zh-CN.md +34 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +2 -2
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +1 -1
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +1 -1
- package/templates/.agents/skills/review-pr/SKILL.en.md +36 -8
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +36 -8
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +1 -1
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +1 -1
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +67 -50
- package/templates/.agents/skills/watch-pr/SKILL.en.md +4 -4
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +2 -2
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +2 -2
- package/templates/.agents/templates/task.en.md +1 -1
- package/templates/.agents/templates/task.zh-CN.md +1 -1
- package/templates/.claude/commands/watch-pr.en.md +1 -1
- package/templates/.claude/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.claude/rules/tool-preferences.en.md +20 -0
- package/templates/.claude/rules/tool-preferences.zh-CN.md +20 -0
- package/templates/.codex/hooks.json +50 -0
- package/templates/.opencode/commands/watch-pr.en.md +1 -1
- package/templates/.opencode/commands/watch-pr.zh-CN.md +1 -1
- package/templates/.gemini/commands/_project_/review-pr.en.toml +0 -10
- package/templates/.gemini/commands/_project_/review-pr.zh-CN.toml +0 -10
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { execFileSync, spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { locateActivityLog, appendActivityEntry, pairEntries, parseCommitAttemptStarted } from './activity-log.js';
|
|
5
|
+
import { commitIntentPath, digest, readCommitIntent } from './commit-intent.js';
|
|
6
|
+
import { parseTypedTaskFrontmatter } from './frontmatter.js';
|
|
7
|
+
import { parseReviewSummary } from './review-artifacts.js';
|
|
8
|
+
import { extractReviewBaseline, extractReviewedSnapshotTree, findAuthoritativeReviewCodeArtifact, parseReviewedGitTree } from './review-fingerprint.js';
|
|
9
|
+
const SHA_RE = /^[a-f0-9]{40,64}$/;
|
|
10
|
+
function git(repoRoot, args) {
|
|
11
|
+
return execFileSync('git', args, {
|
|
12
|
+
cwd: repoRoot,
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
stdio: ['ignore', 'pipe', 'pipe']
|
|
15
|
+
}).trim();
|
|
16
|
+
}
|
|
17
|
+
function commitExists(repoRoot, value) {
|
|
18
|
+
return SHA_RE.test(value) && spawnSync('git', ['cat-file', '-e', `${value}^{commit}`], {
|
|
19
|
+
cwd: repoRoot,
|
|
20
|
+
stdio: 'ignore'
|
|
21
|
+
}).status === 0;
|
|
22
|
+
}
|
|
23
|
+
function isAncestor(repoRoot, ancestor, descendant) {
|
|
24
|
+
return spawnSync('git', ['merge-base', '--is-ancestor', ancestor, descendant], {
|
|
25
|
+
cwd: repoRoot,
|
|
26
|
+
stdio: 'ignore'
|
|
27
|
+
}).status === 0;
|
|
28
|
+
}
|
|
29
|
+
function outcome(disposition, overrides = {}) {
|
|
30
|
+
return {
|
|
31
|
+
disposition,
|
|
32
|
+
code: null,
|
|
33
|
+
message: disposition,
|
|
34
|
+
currentHead: '',
|
|
35
|
+
committedHead: null,
|
|
36
|
+
commitNote: null,
|
|
37
|
+
needsAnchor: false,
|
|
38
|
+
needsLog: false,
|
|
39
|
+
intent: null,
|
|
40
|
+
intentDigest: null,
|
|
41
|
+
attempt: null,
|
|
42
|
+
...overrides
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function invalid(message, currentHead = '', code = 'COMMIT_FINALIZATION_EVIDENCE_INVALID', overrides = {}) {
|
|
46
|
+
return outcome('invalid', { code, message, currentHead, ...overrides });
|
|
47
|
+
}
|
|
48
|
+
function inspectCommitFinalization(taskDir, repoRoot, taskId) {
|
|
49
|
+
let currentHead;
|
|
50
|
+
let taskContent;
|
|
51
|
+
let metadata;
|
|
52
|
+
try {
|
|
53
|
+
currentHead = git(repoRoot, ['rev-parse', 'HEAD']);
|
|
54
|
+
taskContent = fs.readFileSync(path.join(taskDir, 'task.md'), 'utf8');
|
|
55
|
+
metadata = parseTypedTaskFrontmatter(taskContent);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return invalid(error instanceof Error ? error.message : String(error));
|
|
59
|
+
}
|
|
60
|
+
const activity = locateActivityLog(taskContent);
|
|
61
|
+
if (!activity)
|
|
62
|
+
return invalid('task activity log is missing or ambiguous', currentHead);
|
|
63
|
+
const commitRows = pairEntries(activity.entries).filter((row) => row.step === 'Commit');
|
|
64
|
+
const openRows = commitRows.filter((row) => row.started !== '' && row.done === '');
|
|
65
|
+
const file = commitIntentPath(taskDir);
|
|
66
|
+
if (!fs.existsSync(file)) {
|
|
67
|
+
if (openRows.length === 1) {
|
|
68
|
+
const attempt = parseCommitAttemptStarted(openRows[0].note);
|
|
69
|
+
if (attempt && attempt.baseline === currentHead) {
|
|
70
|
+
return outcome('retryable-start', {
|
|
71
|
+
message: 'a structured Commit attempt can be safely reused',
|
|
72
|
+
currentHead,
|
|
73
|
+
attempt
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (openRows.length > 0) {
|
|
78
|
+
return outcome('orphaned-start', {
|
|
79
|
+
code: 'COMMIT_FINALIZATION_EVIDENCE_MISSING',
|
|
80
|
+
message: 'an open Commit activity entry exists without a commit intent',
|
|
81
|
+
currentHead
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return outcome('idle', { message: 'no active commit finalization exists', currentHead });
|
|
85
|
+
}
|
|
86
|
+
let raw;
|
|
87
|
+
let intent;
|
|
88
|
+
try {
|
|
89
|
+
raw = fs.readFileSync(file, 'utf8');
|
|
90
|
+
intent = readCommitIntent(taskDir, taskId);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return invalid(error instanceof Error ? error.message : String(error), currentHead);
|
|
94
|
+
}
|
|
95
|
+
const intentDigest = digest(raw);
|
|
96
|
+
const shared = { currentHead, intent, intentDigest, committedHead: intent.committedHead };
|
|
97
|
+
if (!commitExists(repoRoot, intent.baselineHead)) {
|
|
98
|
+
return invalid('commit intent baseline is not a valid Git commit', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
99
|
+
}
|
|
100
|
+
if (intent.phase === 'prepared') {
|
|
101
|
+
if (intent.committedHead !== null || intent.pushEvidence !== null) {
|
|
102
|
+
return invalid('prepared commit intent contains commit or push evidence', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
103
|
+
}
|
|
104
|
+
if (currentHead !== intent.baselineHead || openRows.length !== 1) {
|
|
105
|
+
return outcome('conflict', {
|
|
106
|
+
...shared,
|
|
107
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
108
|
+
message: 'prepared commit intent does not match HEAD and exactly one open Commit entry'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return outcome('prepared', { ...shared, message: 'prepared commit intent can be safely retried' });
|
|
112
|
+
}
|
|
113
|
+
if (!intent.committedHead || !commitExists(repoRoot, intent.committedHead)) {
|
|
114
|
+
return invalid('committed intent head is missing or invalid', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
115
|
+
}
|
|
116
|
+
if (intent.phase === 'committed' && intent.pushEvidence !== null) {
|
|
117
|
+
return invalid('committed intent contains premature push evidence', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
118
|
+
}
|
|
119
|
+
if (intent.phase === 'pushed'
|
|
120
|
+
&& (intent.pushEvidence === null
|
|
121
|
+
|| intent.pushEvidence.head !== intent.committedHead
|
|
122
|
+
|| !intent.pushEvidence.remote
|
|
123
|
+
|| !intent.pushEvidence.ref)) {
|
|
124
|
+
return invalid('pushed intent evidence is missing or inconsistent', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
125
|
+
}
|
|
126
|
+
if (currentHead !== intent.committedHead || !isAncestor(repoRoot, intent.baselineHead, intent.committedHead)) {
|
|
127
|
+
return outcome('conflict', {
|
|
128
|
+
...shared,
|
|
129
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
130
|
+
message: 'repository HEAD or ancestry conflicts with the commit intent'
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const review = findAuthoritativeReviewCodeArtifact(taskDir);
|
|
134
|
+
let needsAnchor = false;
|
|
135
|
+
if (review.ok && review.path) {
|
|
136
|
+
let reviewContent;
|
|
137
|
+
try {
|
|
138
|
+
reviewContent = fs.readFileSync(review.path, 'utf8');
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
return invalid(error instanceof Error ? error.message : String(error), currentHead, 'COMMIT_FINALIZATION_EVIDENCE_MISSING', shared);
|
|
142
|
+
}
|
|
143
|
+
const summary = parseReviewSummary(reviewContent);
|
|
144
|
+
const reviewBaseline = extractReviewBaseline(reviewContent);
|
|
145
|
+
const reviewTree = extractReviewedSnapshotTree(reviewContent);
|
|
146
|
+
if (!summary.ok || summary.summary.verdict !== 'Approved' || !commitExists(repoRoot, reviewBaseline) || !parseReviewedGitTree(reviewTree)) {
|
|
147
|
+
return invalid('authoritative review-code evidence is not a valid approved snapshot', currentHead, 'COMMIT_FINALIZATION_EVIDENCE_INVALID', shared);
|
|
148
|
+
}
|
|
149
|
+
const committedTree = git(repoRoot, ['rev-parse', `${intent.committedHead}^{tree}`]);
|
|
150
|
+
if (reviewBaseline !== intent.baselineHead || reviewTree !== committedTree) {
|
|
151
|
+
return outcome('conflict', {
|
|
152
|
+
...shared,
|
|
153
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
154
|
+
message: 'review baseline or snapshot tree conflicts with the committed intent'
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const anchor = String(metadata.last_reviewed_commit ?? '').trim();
|
|
158
|
+
if (anchor && anchor !== intent.committedHead) {
|
|
159
|
+
return outcome('conflict', {
|
|
160
|
+
...shared,
|
|
161
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
162
|
+
message: 'task review anchor conflicts with the committed intent'
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
needsAnchor = anchor === '';
|
|
166
|
+
}
|
|
167
|
+
const commitNote = git(repoRoot, ['show', '-s', '--format=%h%x20%s', intent.committedHead]);
|
|
168
|
+
const matchingDone = commitRows.filter((row) => row.done !== '' && row.note === commitNote);
|
|
169
|
+
const needsLog = matchingDone.length === 0 && openRows.length === 1;
|
|
170
|
+
if (!(needsLog || (matchingDone.length === 1 && openRows.length === 0))) {
|
|
171
|
+
return outcome('conflict', {
|
|
172
|
+
...shared,
|
|
173
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
174
|
+
message: 'Commit activity identity is missing, duplicated, or ambiguous',
|
|
175
|
+
commitNote
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return outcome('recoverable', {
|
|
179
|
+
...shared,
|
|
180
|
+
message: 'commit finalization can be recovered',
|
|
181
|
+
commitNote,
|
|
182
|
+
needsAnchor,
|
|
183
|
+
needsLog
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function planCommitTaskFinalization(taskDir, inspection, agent, timestamp) {
|
|
187
|
+
if (inspection.disposition !== 'recoverable' || !inspection.committedHead || !inspection.commitNote) {
|
|
188
|
+
throw new Error('commit finalization task mutations require a recoverable inspection');
|
|
189
|
+
}
|
|
190
|
+
const taskContent = fs.readFileSync(path.join(taskDir, 'task.md'), 'utf8');
|
|
191
|
+
const frontmatter = { assigned_to: agent };
|
|
192
|
+
if (inspection.needsAnchor)
|
|
193
|
+
frontmatter.last_reviewed_commit = inspection.committedHead;
|
|
194
|
+
const mutations = [{
|
|
195
|
+
kind: 'frontmatter',
|
|
196
|
+
set: frontmatter
|
|
197
|
+
}];
|
|
198
|
+
if (inspection.needsLog) {
|
|
199
|
+
const activity = locateActivityLog(taskContent);
|
|
200
|
+
if (!activity)
|
|
201
|
+
throw new Error('task activity log is missing or ambiguous');
|
|
202
|
+
mutations.push({
|
|
203
|
+
kind: 'section',
|
|
204
|
+
aliases: ['活动日志', 'Activity Log'],
|
|
205
|
+
heading: activity.heading,
|
|
206
|
+
body: appendActivityEntry(activity, {
|
|
207
|
+
time: timestamp,
|
|
208
|
+
step: 'Commit',
|
|
209
|
+
agent,
|
|
210
|
+
note: inspection.commitNote
|
|
211
|
+
})
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
return { mutations, commitNote: inspection.commitNote };
|
|
215
|
+
}
|
|
216
|
+
function inspectCreatePrCommitGate(taskDir, repoRoot, taskId) {
|
|
217
|
+
const lifecycle = inspectCommitFinalization(taskDir, repoRoot, taskId);
|
|
218
|
+
if (lifecycle.disposition !== 'idle') {
|
|
219
|
+
const pending = lifecycle.disposition === 'prepared' || lifecycle.disposition === 'recoverable';
|
|
220
|
+
return {
|
|
221
|
+
allowed: false,
|
|
222
|
+
code: pending ? 'COMMIT_FINALIZATION_PENDING' : lifecycle.code ?? 'COMMIT_FINALIZATION_CONFLICT',
|
|
223
|
+
message: pending ? 'commit finalization must complete before creating a pull request' : lifecycle.message,
|
|
224
|
+
disposition: lifecycle.disposition,
|
|
225
|
+
action: 'rerun-commit'
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
const review = findAuthoritativeReviewCodeArtifact(taskDir);
|
|
229
|
+
if (!review.ok || !review.path) {
|
|
230
|
+
return { allowed: true, code: null, message: 'no review-code history requires an anchor', disposition: 'idle', action: 'continue' };
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
const content = fs.readFileSync(review.path, 'utf8');
|
|
234
|
+
const summary = parseReviewSummary(content);
|
|
235
|
+
if (!summary.ok || summary.summary.verdict !== 'Approved') {
|
|
236
|
+
return {
|
|
237
|
+
allowed: false,
|
|
238
|
+
code: 'COMMIT_FINALIZATION_EVIDENCE_INVALID',
|
|
239
|
+
message: 'latest authoritative review-code is not approved',
|
|
240
|
+
disposition: 'idle',
|
|
241
|
+
action: 'rerun-review-code'
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const task = parseTypedTaskFrontmatter(fs.readFileSync(path.join(taskDir, 'task.md'), 'utf8'));
|
|
245
|
+
const currentHead = git(repoRoot, ['rev-parse', 'HEAD']);
|
|
246
|
+
const anchor = String(task.last_reviewed_commit ?? '').trim();
|
|
247
|
+
if (!anchor || !commitExists(repoRoot, anchor)) {
|
|
248
|
+
return {
|
|
249
|
+
allowed: false,
|
|
250
|
+
code: 'COMMIT_FINALIZATION_EVIDENCE_MISSING',
|
|
251
|
+
message: 'approved review snapshot is not anchored to a Git commit',
|
|
252
|
+
disposition: 'idle',
|
|
253
|
+
action: 'rerun-commit'
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (anchor !== currentHead || extractReviewedSnapshotTree(content) !== git(repoRoot, ['rev-parse', 'HEAD^{tree}'])) {
|
|
257
|
+
return {
|
|
258
|
+
allowed: false,
|
|
259
|
+
code: 'COMMIT_FINALIZATION_CONFLICT',
|
|
260
|
+
message: 'approved review anchor or tree does not match repository HEAD',
|
|
261
|
+
disposition: 'idle',
|
|
262
|
+
action: 'rerun-review-code'
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
return { allowed: true, code: null, message: 'commit finalization evidence is complete', disposition: 'idle', action: 'continue' };
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
return {
|
|
269
|
+
allowed: false,
|
|
270
|
+
code: 'COMMIT_FINALIZATION_EVIDENCE_INVALID',
|
|
271
|
+
message: error instanceof Error ? error.message : String(error),
|
|
272
|
+
disposition: 'idle',
|
|
273
|
+
action: 'rerun-review-code'
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
export { inspectCommitFinalization, inspectCreatePrCommitGate, planCommitTaskFinalization };
|
|
278
|
+
//# sourceMappingURL=commit-finalization.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { createHash, randomBytes, randomUUID, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
class CommitIntentError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
constructor(code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'CommitIntentError';
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function commitIntentPath(taskDir) {
|
|
13
|
+
return path.join(taskDir, 'commit-intent.json');
|
|
14
|
+
}
|
|
15
|
+
function digest(value) {
|
|
16
|
+
return createHash('sha256').update(value).digest('hex');
|
|
17
|
+
}
|
|
18
|
+
function serialize(value) {
|
|
19
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
20
|
+
}
|
|
21
|
+
function atomicWrite(file, value) {
|
|
22
|
+
const temp = `${file}.${process.pid}.${randomUUID()}.tmp`;
|
|
23
|
+
try {
|
|
24
|
+
fs.writeFileSync(temp, serialize(value), { encoding: 'utf8', flag: 'wx', mode: 0o600 });
|
|
25
|
+
const handle = fs.openSync(temp, 'r+');
|
|
26
|
+
try {
|
|
27
|
+
fs.fsyncSync(handle);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
fs.closeSync(handle);
|
|
31
|
+
}
|
|
32
|
+
fs.renameSync(temp, file);
|
|
33
|
+
fs.chmodSync(file, 0o600);
|
|
34
|
+
try {
|
|
35
|
+
const directory = fs.openSync(path.dirname(file), 'r');
|
|
36
|
+
try {
|
|
37
|
+
fs.fsyncSync(directory);
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
fs.closeSync(directory);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const code = error.code;
|
|
45
|
+
if (!['EACCES', 'EISDIR', 'EINVAL', 'EPERM'].includes(code ?? ''))
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
if (fs.existsSync(temp))
|
|
51
|
+
fs.unlinkSync(temp);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function isRecord(value) {
|
|
55
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
56
|
+
}
|
|
57
|
+
function keysEqual(value, expected) {
|
|
58
|
+
return Object.keys(value).sort().join('\0') === [...expected].sort().join('\0');
|
|
59
|
+
}
|
|
60
|
+
function validPushEvidence(value) {
|
|
61
|
+
return value === null || (isRecord(value)
|
|
62
|
+
&& keysEqual(value, ['remote', 'ref', 'head'])
|
|
63
|
+
&& ['remote', 'ref', 'head'].every((key) => typeof value[key] === 'string' && value[key] !== ''));
|
|
64
|
+
}
|
|
65
|
+
function validOrchestration(value) {
|
|
66
|
+
if (value === null)
|
|
67
|
+
return true;
|
|
68
|
+
if (!isRecord(value) || !keysEqual(value, [
|
|
69
|
+
'runId', 'receiptId', 'authorizationIssuedAt', 'sourceRunDigest', 'plannedRunDigest',
|
|
70
|
+
'completionUpdatedAt', 'plannedReceipt'
|
|
71
|
+
]))
|
|
72
|
+
return false;
|
|
73
|
+
return [
|
|
74
|
+
'runId', 'receiptId', 'authorizationIssuedAt', 'sourceRunDigest', 'plannedRunDigest', 'completionUpdatedAt'
|
|
75
|
+
].every((key) => typeof value[key] === 'string' && value[key] !== '') && isRecord(value.plannedReceipt);
|
|
76
|
+
}
|
|
77
|
+
function parseIntent(raw, taskId) {
|
|
78
|
+
let value;
|
|
79
|
+
try {
|
|
80
|
+
value = JSON.parse(raw);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_INVALID', 'commit intent is not valid JSON');
|
|
84
|
+
}
|
|
85
|
+
if (!isRecord(value) || !keysEqual(value, [
|
|
86
|
+
'schemaVersion', 'taskId', 'mode', 'phase', 'tokenDigest', 'baselineHead', 'committedHead',
|
|
87
|
+
'pushEvidence', 'orchestration', 'createdAt', 'updatedAt'
|
|
88
|
+
])) {
|
|
89
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_INVALID', 'commit intent has an invalid schema');
|
|
90
|
+
}
|
|
91
|
+
if (value.schemaVersion !== 1
|
|
92
|
+
|| value.taskId !== taskId
|
|
93
|
+
|| !['standalone', 'orchestrated'].includes(String(value.mode))
|
|
94
|
+
|| !['prepared', 'committed', 'pushed'].includes(String(value.phase))
|
|
95
|
+
|| typeof value.tokenDigest !== 'string'
|
|
96
|
+
|| !/^[a-f0-9]{64}$/.test(value.tokenDigest)
|
|
97
|
+
|| typeof value.baselineHead !== 'string'
|
|
98
|
+
|| (value.committedHead !== null && typeof value.committedHead !== 'string')
|
|
99
|
+
|| !validPushEvidence(value.pushEvidence)
|
|
100
|
+
|| !validOrchestration(value.orchestration)
|
|
101
|
+
|| typeof value.createdAt !== 'string'
|
|
102
|
+
|| typeof value.updatedAt !== 'string'
|
|
103
|
+
|| (value.mode === 'standalone') !== (value.orchestration === null)) {
|
|
104
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_INVALID', 'commit intent has invalid field values');
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
function tokenMatches(actualDigest, token) {
|
|
109
|
+
const actual = Buffer.from(actualDigest, 'hex');
|
|
110
|
+
const supplied = Buffer.from(digest(token), 'hex');
|
|
111
|
+
return actual.length === supplied.length && timingSafeEqual(actual, supplied);
|
|
112
|
+
}
|
|
113
|
+
function readCommitIntent(taskDir, taskId, token) {
|
|
114
|
+
const file = commitIntentPath(taskDir);
|
|
115
|
+
const intent = parseIntent(fs.readFileSync(file, 'utf8'), taskId);
|
|
116
|
+
if (token !== undefined && !tokenMatches(intent.tokenDigest, token)) {
|
|
117
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_TOKEN_MISMATCH', 'commit intent token does not match');
|
|
118
|
+
}
|
|
119
|
+
return intent;
|
|
120
|
+
}
|
|
121
|
+
function createCommitIntent(taskDir, input, options = {}) {
|
|
122
|
+
const file = commitIntentPath(taskDir);
|
|
123
|
+
if (fs.existsSync(file)) {
|
|
124
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_BUSY', 'an active commit intent already exists');
|
|
125
|
+
}
|
|
126
|
+
const token = (options.token ?? (() => randomBytes(32).toString('base64url')))();
|
|
127
|
+
const intent = Object.freeze({ schemaVersion: 1, ...input, tokenDigest: digest(token) });
|
|
128
|
+
atomicWrite(file, intent);
|
|
129
|
+
return { intent, token };
|
|
130
|
+
}
|
|
131
|
+
function updateCommitIntent(taskDir, taskId, token, updates) {
|
|
132
|
+
const current = readCommitIntent(taskDir, taskId, token);
|
|
133
|
+
const nextPhase = updates.phase ?? current.phase;
|
|
134
|
+
const transitions = {
|
|
135
|
+
prepared: ['prepared', 'committed', 'pushed'],
|
|
136
|
+
committed: ['committed', 'pushed'],
|
|
137
|
+
pushed: ['pushed']
|
|
138
|
+
};
|
|
139
|
+
if (!transitions[current.phase].includes(nextPhase)) {
|
|
140
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_INTENT_STATE_INVALID', `cannot move commit intent from ${current.phase} to ${nextPhase}`);
|
|
141
|
+
}
|
|
142
|
+
const updated = Object.freeze({ ...current, ...updates, phase: nextPhase });
|
|
143
|
+
atomicWrite(commitIntentPath(taskDir), updated);
|
|
144
|
+
return updated;
|
|
145
|
+
}
|
|
146
|
+
function removeCommitIntent(taskDir, taskId, token) {
|
|
147
|
+
readCommitIntent(taskDir, taskId, token);
|
|
148
|
+
fs.unlinkSync(commitIntentPath(taskDir));
|
|
149
|
+
}
|
|
150
|
+
function removeCommitIntentByDigest(taskDir, taskId, expectedDigest) {
|
|
151
|
+
const file = commitIntentPath(taskDir);
|
|
152
|
+
const raw = fs.readFileSync(file);
|
|
153
|
+
parseIntent(raw.toString('utf8'), taskId);
|
|
154
|
+
const actual = digest(raw);
|
|
155
|
+
const expected = Buffer.from(expectedDigest, 'hex');
|
|
156
|
+
const observed = Buffer.from(actual, 'hex');
|
|
157
|
+
if (!/^[a-f0-9]{64}$/.test(expectedDigest)
|
|
158
|
+
|| expected.length !== observed.length
|
|
159
|
+
|| !timingSafeEqual(expected, observed)) {
|
|
160
|
+
throw new CommitIntentError('ORCHESTRATION_COMMIT_RECOVERY_REQUIRED', 'commit intent changed after recovery inspection');
|
|
161
|
+
}
|
|
162
|
+
fs.unlinkSync(file);
|
|
163
|
+
}
|
|
164
|
+
export { CommitIntentError, commitIntentPath, createCommitIntent, digest, readCommitIntent, removeCommitIntent, removeCommitIntentByDigest, serialize, updateCommitIntent };
|
|
165
|
+
//# sourceMappingURL=commit-intent.js.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { syncPlatformComment } from '../platform/issue-comments.js';
|
|
4
|
+
import { createPlatformIssue, syncPlatformIssue } from '../platform/issues.js';
|
|
5
|
+
import { VERSION } from '../version.js';
|
|
6
|
+
import { applyWorkflowWarningIntent } from './workflow-warning-intents.js';
|
|
7
|
+
import { createLocalTask } from './create.js';
|
|
8
|
+
import { verifyTaskEvent } from './verification.js';
|
|
9
|
+
const DEFAULT_DEPENDENCIES = {
|
|
10
|
+
createIssue: createPlatformIssue,
|
|
11
|
+
syncIssue: syncPlatformIssue,
|
|
12
|
+
syncComment: syncPlatformComment,
|
|
13
|
+
addWarning: applyWorkflowWarningIntent
|
|
14
|
+
};
|
|
15
|
+
function verifyCreatedTask(repoRoot, taskId) {
|
|
16
|
+
const verification = verifyTaskEvent({ taskRef: taskId, event: 'create-task.completed' }, { repoRoot });
|
|
17
|
+
if (verification.status === 'pass') {
|
|
18
|
+
return { operation: { name: 'task:verify', status: 'pass', reasonCode: null }, error: null };
|
|
19
|
+
}
|
|
20
|
+
const blocked = verification.status === 'blocked';
|
|
21
|
+
return {
|
|
22
|
+
operation: {
|
|
23
|
+
name: 'task:verify', status: verification.status,
|
|
24
|
+
reasonCode: verification.error?.code ?? 'TASK_CREATE_VERIFICATION_FAILED'
|
|
25
|
+
},
|
|
26
|
+
error: {
|
|
27
|
+
code: verification.error?.code ?? 'TASK_CREATE_VERIFICATION_FAILED',
|
|
28
|
+
message: `Created task did not pass the ${verification.event} gate`,
|
|
29
|
+
retryable: blocked
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function platformOperations(prefix, operations) {
|
|
34
|
+
return operations.map((operation) => ({
|
|
35
|
+
name: `${prefix}:${operation.name}`,
|
|
36
|
+
status: operation.status,
|
|
37
|
+
reasonCode: operation.reasonCode ?? null
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
function issueFromTask(repoRoot, taskId) {
|
|
41
|
+
const content = fs.readFileSync(path.join(repoRoot, '.agents', 'workspace', 'active', taskId, 'task.md'), 'utf8');
|
|
42
|
+
const match = /^issue_number:\s*(\d+)\s*$/m.exec(content);
|
|
43
|
+
return match ? { number: Number(match[1]), url: '' } : null;
|
|
44
|
+
}
|
|
45
|
+
function createTask(value, options) {
|
|
46
|
+
const dependencies = { ...DEFAULT_DEPENDENCIES, ...options.dependencies };
|
|
47
|
+
let candidate;
|
|
48
|
+
let local;
|
|
49
|
+
try {
|
|
50
|
+
candidate = value;
|
|
51
|
+
local = createLocalTask(candidate, {
|
|
52
|
+
repoRoot: options.repoRoot,
|
|
53
|
+
agentInfraVersion: options.agentInfraVersion ?? VERSION
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
58
|
+
const code = /^([A-Z][A-Z0-9_]+)/.exec(message)?.[1] ?? 'TASK_CREATE_FAILED';
|
|
59
|
+
return {
|
|
60
|
+
status: 'failed', changed: false, task: { id: null, shortId: null }, issue: null,
|
|
61
|
+
operations: [], warnings: [], error: { code, message, retryable: code === 'TASK_CREATE_LOCK_TIMEOUT' }
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const operations = [{
|
|
65
|
+
name: 'task:local', status: local.status, reasonCode: null
|
|
66
|
+
}];
|
|
67
|
+
let issue = issueFromTask(options.repoRoot, local.task.id);
|
|
68
|
+
const created = dependencies.createIssue(local.task.id, { cwd: options.repoRoot, agent: candidate.agent });
|
|
69
|
+
operations.push(...platformOperations('platform-create', created.operations));
|
|
70
|
+
if (created.issue)
|
|
71
|
+
issue = { number: created.issue.number, url: created.issue.url };
|
|
72
|
+
let platformFailure = created.status === 'failed' || created.status === 'blocked' ? created : null;
|
|
73
|
+
if (!platformFailure && (created.task.issueNumber || issue)) {
|
|
74
|
+
const synced = dependencies.syncIssue(local.task.id, {
|
|
75
|
+
cwd: options.repoRoot,
|
|
76
|
+
agent: candidate.agent,
|
|
77
|
+
status: 'waiting-for-triage',
|
|
78
|
+
assignees: 'current',
|
|
79
|
+
milestone: 'initial',
|
|
80
|
+
issueType: true,
|
|
81
|
+
fields: true
|
|
82
|
+
});
|
|
83
|
+
operations.push(...platformOperations('platform-sync', synced.operations));
|
|
84
|
+
if (synced.issue)
|
|
85
|
+
issue = { number: synced.issue.number, url: synced.issue.url };
|
|
86
|
+
if (synced.status === 'failed' || synced.status === 'blocked')
|
|
87
|
+
platformFailure = synced;
|
|
88
|
+
if (!platformFailure) {
|
|
89
|
+
const commented = dependencies.syncComment(local.task.id, { cwd: options.repoRoot, kind: 'task', agent: candidate.agent });
|
|
90
|
+
operations.push(...platformOperations('platform-comment', commented.operations));
|
|
91
|
+
if (commented.status === 'failed' || commented.status === 'blocked')
|
|
92
|
+
platformFailure = commented;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (platformFailure) {
|
|
96
|
+
const error = platformFailure.error ?? { code: 'ISSUE_CREATE_FAILED', message: 'Platform operation failed', retryable: false };
|
|
97
|
+
dependencies.addWarning({
|
|
98
|
+
kind: 'add', taskRef: local.task.id, step: 'create-task', severity: 'ACTION_REQUIRED',
|
|
99
|
+
code: 'ISSUE_CREATE_FAILED', target: 'issue', message: `${error.code}: ${error.message}`,
|
|
100
|
+
action: 'Fix platform authentication or connectivity, then retry Issue creation for this task.'
|
|
101
|
+
}, { repoRoot: options.repoRoot });
|
|
102
|
+
const verified = verifyCreatedTask(options.repoRoot, local.task.id);
|
|
103
|
+
operations.push(verified.operation);
|
|
104
|
+
if (verified.error)
|
|
105
|
+
return {
|
|
106
|
+
status: verified.error.retryable ? 'blocked' : 'failed', changed: local.changed,
|
|
107
|
+
task: local.task, issue, operations, warnings: [], error: verified.error
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
status: platformFailure.status === 'blocked' ? 'blocked' : 'degraded',
|
|
111
|
+
changed: local.changed,
|
|
112
|
+
task: local.task,
|
|
113
|
+
issue,
|
|
114
|
+
operations,
|
|
115
|
+
warnings: [{ code: 'ISSUE_CREATE_FAILED', severity: 'ACTION_REQUIRED', action: 'Retry Issue creation after fixing the platform failure.' }],
|
|
116
|
+
error
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const verified = verifyCreatedTask(options.repoRoot, local.task.id);
|
|
120
|
+
operations.push(verified.operation);
|
|
121
|
+
if (verified.error)
|
|
122
|
+
return {
|
|
123
|
+
status: verified.error.retryable ? 'blocked' : 'failed', changed: local.changed,
|
|
124
|
+
task: local.task, issue, operations, warnings: [], error: verified.error
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
status: local.status,
|
|
128
|
+
changed: local.changed,
|
|
129
|
+
task: local.task,
|
|
130
|
+
issue,
|
|
131
|
+
operations,
|
|
132
|
+
warnings: [],
|
|
133
|
+
error: null
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export { createTask };
|
|
137
|
+
//# sourceMappingURL=create-service.js.map
|