@fitlab-ai/agent-infra 0.11.6 → 0.11.8
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/bin/internal-cli.js +8 -2
- package/dist/lib/agent-clients/adapters/codex.js +1 -1
- package/dist/lib/agent-clients/config.js +11 -3
- package/dist/lib/defaults.json +6 -3
- package/dist/lib/git/primary-worktree.js +58 -0
- package/dist/lib/internal/cli-route-inventory.js +3 -0
- package/dist/lib/internal/platform-pr-review.js +20 -3
- package/dist/lib/internal/task-operation-registry.js +3 -1
- package/dist/lib/internal/task-platform-recovery.js +56 -0
- package/dist/lib/merge.js +25 -5
- package/dist/lib/platform/completion-backfill.js +2 -1
- package/dist/lib/platform/in-label-sync.js +12 -1
- package/dist/lib/platform/issue-comments.js +58 -4
- package/dist/lib/platform/issues.js +105 -5
- package/dist/lib/platform/operation-coordinator.js +74 -0
- package/dist/lib/platform/pr-review.js +107 -1
- package/dist/lib/platform/pr-summary.js +79 -57
- package/dist/lib/platform/pull-requests.js +125 -7
- package/dist/lib/sandbox/commands/create.js +6 -3
- package/dist/lib/sandbox/commands/ls.js +4 -3
- package/dist/lib/sandbox/commands/rm.js +1 -1
- package/dist/lib/sandbox/config.js +22 -4
- package/dist/lib/sandbox/control/server.js +6 -2
- package/dist/lib/sandbox/git-metadata.js +50 -0
- package/dist/lib/sandbox/index.js +1 -1
- package/dist/lib/sandbox/mounts.js +12 -0
- package/dist/lib/sandbox/recovery.js +11 -0
- package/dist/lib/sandbox/removal.js +58 -20
- package/dist/lib/sandbox/tools.js +29 -7
- package/dist/lib/server/config.js +7 -27
- package/dist/lib/server/daemon.js +4 -3
- package/dist/lib/server/process-control.js +4 -2
- package/dist/lib/server/runner.js +4 -3
- package/dist/lib/task/activity-intent.js +4 -3
- package/dist/lib/task/artifact-lifecycle.js +42 -10
- package/dist/lib/task/artifact-receipts.js +62 -22
- package/dist/lib/task/capabilities.js +22 -4
- package/dist/lib/task/completion-facts.js +56 -0
- package/dist/lib/task/create-service.js +11 -5
- package/dist/lib/task/create.js +60 -79
- package/dist/lib/task/events.js +268 -195
- package/dist/lib/task/finalization-artifacts.js +4 -1
- package/dist/lib/task/finalization-handoff.js +2 -1
- package/dist/lib/task/finalization.js +157 -24
- package/dist/lib/task/invalidation-command.js +4 -2
- package/dist/lib/task/invalidation.js +38 -9
- package/dist/lib/task/lifecycle.js +38 -2
- package/dist/lib/task/local-artifact-finalization.js +17 -3
- package/dist/lib/task/platform-operation-journal.js +152 -0
- package/dist/lib/task/platform-operation-recovery.js +459 -0
- package/dist/lib/task/qualification-audit.js +23 -105
- package/dist/lib/task/review-finalization.js +7 -0
- package/dist/lib/task/review-identity.js +69 -0
- package/dist/lib/task/sections.js +6 -5
- package/dist/lib/task/task-execution-lock.js +6 -3
- package/dist/lib/task/verification-engine.js +14 -63
- package/dist/lib/task/verification.js +35 -38
- package/dist/lib/task/workflow-warning-intents.js +7 -1
- package/dist/lifecycle-build-manifest.json +3 -3
- package/lib/agent-clients/adapters/codex.ts +1 -1
- package/lib/agent-clients/config.ts +9 -3
- package/lib/defaults.json +6 -3
- package/lib/git/primary-worktree.ts +62 -0
- package/lib/internal/cli-route-inventory.ts +2 -0
- package/lib/internal/platform-pr-review.ts +14 -3
- package/lib/internal/task-operation-registry.ts +3 -1
- package/lib/internal/task-platform-recovery.ts +53 -0
- package/lib/merge.ts +26 -6
- package/lib/platform/completion-backfill.ts +2 -1
- package/lib/platform/in-label-sync.ts +12 -0
- package/lib/platform/issue-comments.ts +59 -3
- package/lib/platform/issues.ts +103 -5
- package/lib/platform/operation-coordinator.ts +96 -0
- package/lib/platform/pr-review.ts +113 -1
- package/lib/platform/pr-summary.ts +22 -1
- package/lib/platform/pull-requests.ts +132 -8
- package/lib/sandbox/commands/create.ts +7 -8
- package/lib/sandbox/commands/ls.ts +4 -3
- package/lib/sandbox/commands/rm.ts +1 -1
- package/lib/sandbox/config.ts +23 -5
- package/lib/sandbox/control/server.ts +5 -2
- package/lib/sandbox/git-metadata.ts +66 -0
- package/lib/sandbox/index.ts +1 -1
- package/lib/sandbox/mounts.ts +14 -0
- package/lib/sandbox/recovery.ts +13 -0
- package/lib/sandbox/removal.ts +57 -19
- package/lib/sandbox/tool-types.ts +1 -1
- package/lib/sandbox/tools.ts +36 -7
- package/lib/server/config.ts +7 -29
- package/lib/server/daemon.ts +5 -3
- package/lib/server/process-control.ts +4 -2
- package/lib/server/runner.ts +7 -4
- package/lib/server/server.schema.json +0 -4
- package/lib/task/activity-intent.ts +4 -3
- package/lib/task/artifact-lifecycle.ts +35 -11
- package/lib/task/artifact-receipts.ts +55 -15
- package/lib/task/capabilities.ts +17 -3
- package/lib/task/completion-facts.ts +66 -0
- package/lib/task/create-service.ts +12 -6
- package/lib/task/create.ts +54 -69
- package/lib/task/events.ts +248 -182
- package/lib/task/finalization-artifacts.ts +4 -1
- package/lib/task/finalization-handoff.ts +2 -1
- package/lib/task/finalization.ts +154 -21
- package/lib/task/invalidation-command.ts +4 -2
- package/lib/task/invalidation.ts +35 -10
- package/lib/task/lifecycle.ts +35 -3
- package/lib/task/local-artifact-finalization.ts +13 -3
- package/lib/task/platform-operation-journal.ts +230 -0
- package/lib/task/platform-operation-recovery.ts +435 -0
- package/lib/task/qualification-audit.ts +21 -114
- package/lib/task/review-finalization.ts +7 -0
- package/lib/task/review-identity.ts +85 -0
- package/lib/task/sections.ts +6 -6
- package/lib/task/task-execution-lock.ts +7 -3
- package/lib/task/verification-engine.ts +13 -86
- package/lib/task/verification.ts +34 -38
- package/lib/task/workflow-warning-intents.ts +9 -1
- package/package.json +1 -1
- package/templates/.agents/README.en.md +19 -17
- package/templates/.agents/README.zh-CN.md +18 -16
- package/templates/.agents/rules/README.en.md +2 -1
- package/templates/.agents/rules/README.zh-CN.md +2 -1
- package/templates/.agents/rules/decision-qualification.en.md +4 -3
- package/templates/.agents/rules/decision-qualification.zh-CN.md +4 -3
- package/templates/.agents/rules/task-management.en.md +12 -0
- package/templates/.agents/rules/task-management.zh-CN.md +12 -0
- package/templates/.agents/rules/validation-output.en.md +19 -0
- package/templates/.agents/rules/validation-output.zh-CN.md +19 -0
- package/templates/.agents/skills/analyze-task/SKILL.en.md +3 -1
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/block-task/SKILL.en.md +2 -0
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/cancel-task/SKILL.en.md +6 -2
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +5 -3
- package/templates/.agents/skills/code-task/SKILL.en.md +5 -3
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/code-task/reference/report-template.en.md +4 -8
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +4 -8
- package/templates/.agents/skills/commit/SKILL.en.md +1 -1
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/SKILL.en.md +1 -1
- package/templates/.agents/skills/complete-manual-validation/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/complete-task/SKILL.en.md +4 -0
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +4 -0
- package/templates/.agents/skills/create-pr/SKILL.en.md +2 -0
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/create-task/SKILL.en.md +2 -0
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.en.md +2 -0
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +2 -0
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/import-issue/SKILL.en.md +2 -0
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/plan-task/SKILL.en.md +3 -1
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -1
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +4 -8
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +4 -8
- package/templates/.agents/skills/review-code/SKILL.en.md +13 -12
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +11 -12
- package/templates/.agents/skills/review-code/config/verify.en.json +1 -3
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +1 -3
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +23 -46
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +27 -48
- package/templates/.agents/skills/review-code/reference/report-template.en.md +8 -11
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +8 -11
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +2 -2
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +2 -2
- package/templates/.agents/skills/review-plan/SKILL.en.md +3 -1
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -1
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +5 -9
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +5 -9
- package/templates/.agents/skills/review-pr/SKILL.en.md +13 -11
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +13 -11
- package/templates/.agents/skills/review-pr/reference/output-guidance.en.md +3 -3
- package/templates/.agents/skills/review-pr/reference/output-guidance.zh-CN.md +3 -3
- package/templates/.agents/skills/review-pr/reference/report-template.en.md +4 -0
- package/templates/.agents/skills/review-pr/reference/report-template.zh-CN.md +4 -0
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/run-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +19 -6
- package/templates/.agents/skills/watch-pr/SKILL.en.md +2 -0
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +1 -1
- package/templates/.agents/templates/task.en.md +2 -2
- package/templates/.agents/templates/task.zh-CN.md +2 -2
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
|
|
6
|
+
import { inspectPlatformCommentOperation, normalizeCommentContent, syncPlatformComment } from '../platform/issue-comments.ts';
|
|
7
|
+
import { inspectPlatformIssue, syncPlatformIssue } from '../platform/issues.ts';
|
|
8
|
+
import { resolvePlatformProviderContext } from '../platform/context.ts';
|
|
9
|
+
import { providerOperationContext, providerError, unsupportedProviderOperation } from '../platform/provider-bridge.ts';
|
|
10
|
+
import { inLabelMappingDigest } from '../platform/in-label-sync.ts';
|
|
11
|
+
import { bindPlatformPullRequest, inspectPlatformPullRequest, recoverCreatedPullRequest, syncPlatformPullRequest } from '../platform/pull-requests.ts';
|
|
12
|
+
import { syncPullRequestSummary } from '../platform/pr-summary.ts';
|
|
13
|
+
import { publishPrReview, readReviewBodyFile } from '../platform/pr-review.ts';
|
|
14
|
+
import type { PlatformClient } from '../platform/context.ts';
|
|
15
|
+
import { parseTaskFrontmatter } from './frontmatter.ts';
|
|
16
|
+
import { taskIssueIdentity } from '../platform/task-identities.ts';
|
|
17
|
+
import { parseResourceIdentity, resourceIdentityEquals } from '../platform/resource-identity.ts';
|
|
18
|
+
import { operationId } from './platform-operation-journal.ts';
|
|
19
|
+
import { canonicalizeSummaryBody } from '../platform/comment-safety.ts';
|
|
20
|
+
import { platformResult } from '../platform/types.ts';
|
|
21
|
+
import type { PlatformResult } from '../platform/types.ts';
|
|
22
|
+
import { resolveTaskRef } from './resolve-ref.ts';
|
|
23
|
+
import { readPlatformOperationJournal, recordPlatformOperation } from './platform-operation-journal.ts';
|
|
24
|
+
|
|
25
|
+
type RecoveryOptions = Readonly<{ agent: string; client?: PlatformClient; cwd?: string; limit?: number; excludeId?: string }>;
|
|
26
|
+
type RecoveryResult = Readonly<{
|
|
27
|
+
status: 'applied' | 'no-op' | 'blocked' | 'failed';
|
|
28
|
+
changed: boolean;
|
|
29
|
+
recovered: readonly string[];
|
|
30
|
+
pending: readonly string[];
|
|
31
|
+
error: { code: string; message: string; retryable: boolean } | null;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
34
|
+
function labelsMatchOwnedPrefix(actual: readonly string[], expected: readonly string[], prefix: 'status:' | 'in:'): boolean {
|
|
35
|
+
return actual.filter((label) => label.startsWith(prefix)).sort().join('\0')
|
|
36
|
+
=== expected.filter((label) => label.startsWith(prefix)).sort().join('\0');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fieldsMatchExpected(
|
|
40
|
+
actual: Readonly<Record<string, string | number | null>>,
|
|
41
|
+
expected: Readonly<Record<string, string | number | null>>
|
|
42
|
+
): boolean {
|
|
43
|
+
return Object.entries(expected).every(([name, value]) => actual[name] === value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function result(status: RecoveryResult['status'], recovered: string[], pending: string[], error: RecoveryResult['error'] = null): RecoveryResult {
|
|
47
|
+
return { status, changed: recovered.length > 0, recovered, pending, error };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function summaryPayload(taskDir: string, taskId: string): { body: string; sha256: string } | null {
|
|
51
|
+
const file = path.join(taskDir, '.delivery-summary.json');
|
|
52
|
+
if (!fs.existsSync(file)) return null;
|
|
53
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf8')) as { taskId?: unknown; body?: unknown; sha256?: unknown };
|
|
54
|
+
const canonical = typeof data.body === 'string' ? canonicalizeSummaryBody(data.body) : null;
|
|
55
|
+
if (data.taskId !== taskId || typeof data.body !== 'string' || typeof data.sha256 !== 'string'
|
|
56
|
+
|| !canonical?.ok || canonical.value !== data.body
|
|
57
|
+
|| createHash('sha256').update(data.body).digest('hex') !== data.sha256) {
|
|
58
|
+
throw Object.assign(new Error('delivery summary staging record is invalid'), { code: 'SUMMARY_STAGING_INVALID' });
|
|
59
|
+
}
|
|
60
|
+
return { body: data.body, sha256: data.sha256 };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function replayComment(taskId: string, taskDir: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], agent: string, cwd: string, client?: PlatformClient): Promise<PlatformResult> {
|
|
64
|
+
if (operation.kind === 'task-comment') {
|
|
65
|
+
return syncPlatformComment(taskId, { kind: 'task', agent, cwd, client, dependency: operation.dependency, skipQueue: true });
|
|
66
|
+
}
|
|
67
|
+
if (operation.kind === 'artifact-comment') {
|
|
68
|
+
return syncPlatformComment(taskId, { kind: 'artifact', artifact: operation.target, agent, cwd, client, dependency: operation.dependency, skipQueue: true });
|
|
69
|
+
}
|
|
70
|
+
if (operation.kind === 'summary-comment') {
|
|
71
|
+
const summary = summaryPayload(taskDir, taskId);
|
|
72
|
+
if (!summary) return platformResult('failed', { error: { code: 'SUMMARY_STAGING_MISSING', message: 'delivery summary staging record is unavailable', retryable: false } });
|
|
73
|
+
return syncPlatformComment(taskId, {
|
|
74
|
+
kind: 'summary', body: summary.body, agent, cwd,
|
|
75
|
+
summaryAuthorization: { sha256: summary.sha256 }, dependency: operation.dependency, client, skipQueue: true
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (operation.kind === 'cancel-comment') {
|
|
79
|
+
return syncPlatformComment(taskId, { kind: 'cancel', agent, cwd, client, dependency: operation.dependency, skipQueue: true });
|
|
80
|
+
}
|
|
81
|
+
return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_UNSUPPORTED', message: `operation kind '${operation.kind}' has no registered recovery handler`, retryable: false } });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function currentIssueMetadataOperation(taskId: string, taskMdPath: string, repoRoot: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number]) {
|
|
85
|
+
if (operation.kind !== 'issue-metadata' || !operation.issueMetadata) return null;
|
|
86
|
+
const content = fs.readFileSync(taskMdPath, 'utf8');
|
|
87
|
+
const frontmatter = parseTaskFrontmatter(content);
|
|
88
|
+
const identity = taskIssueIdentity(frontmatter);
|
|
89
|
+
if (!identity) return null;
|
|
90
|
+
let fromDiffFiles: string[] | undefined;
|
|
91
|
+
let mappingDigest: string | undefined;
|
|
92
|
+
if (operation.issueMetadata.inLabels === 'from-diff') {
|
|
93
|
+
const taskBase = typeof frontmatter.delivery_base_ref === 'string' ? frontmatter.delivery_base_ref.trim() : '';
|
|
94
|
+
if (!taskBase || (operation.issueMetadata.base && operation.issueMetadata.base !== taskBase)) return null;
|
|
95
|
+
try {
|
|
96
|
+
fromDiffFiles = execFileSync('git', ['diff', `${taskBase}...HEAD`, '--name-only'], {
|
|
97
|
+
cwd: repoRoot, encoding: 'utf8'
|
|
98
|
+
}).trim().split(/\r?\n/).filter(Boolean).sort();
|
|
99
|
+
const config = JSON.parse(fs.readFileSync(path.join(repoRoot, '.agents', '.airc.json'), 'utf8')) as { labels?: { in?: unknown } };
|
|
100
|
+
const mapping = inLabelMappingDigest(config.labels?.in);
|
|
101
|
+
if (!mapping.ok) return null;
|
|
102
|
+
mappingDigest = mapping.digest;
|
|
103
|
+
} catch { return null; }
|
|
104
|
+
}
|
|
105
|
+
const currentMetadata = {
|
|
106
|
+
...operation.issueMetadata,
|
|
107
|
+
...(fromDiffFiles ? { fromDiffFiles } : {}),
|
|
108
|
+
...(mappingDigest ? { inLabelMappingDigest: mappingDigest } : {})
|
|
109
|
+
};
|
|
110
|
+
const target = JSON.stringify(identity);
|
|
111
|
+
const expectedDigest = createHash('sha256').update(JSON.stringify({
|
|
112
|
+
...currentMetadata,
|
|
113
|
+
task: taskId,
|
|
114
|
+
taskContent: createHash('sha256').update(content).digest('hex')
|
|
115
|
+
})).digest('hex');
|
|
116
|
+
return { kind: 'issue-metadata' as const, target, expectedDigest, issueMetadata: currentMetadata, id: operationId({ kind: 'issue-metadata', target, expectedDigest }) };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function replayIssueMetadata(taskId: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], agent: string, cwd: string, client?: PlatformClient): Promise<PlatformResult> {
|
|
120
|
+
if (!operation.issueMetadata) return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Issue metadata recovery parameters are missing', retryable: false } });
|
|
121
|
+
let expectedIdentity;
|
|
122
|
+
try { expectedIdentity = parseResourceIdentity(JSON.parse(operation.target), 'journal Issue identity'); }
|
|
123
|
+
catch { return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Journal Issue identity is invalid', retryable: false } }); }
|
|
124
|
+
const before = await inspectPlatformIssue(taskId, { cwd, client });
|
|
125
|
+
if (before.status !== 'no-op' || before.error || !before.issue
|
|
126
|
+
|| !resourceIdentityEquals(before.issue.identity, expectedIdentity)) {
|
|
127
|
+
return platformResult('blocked', { error: before.error ?? { code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Bound Issue identity differs from the journal target', retryable: false } });
|
|
128
|
+
}
|
|
129
|
+
const sync = await syncPlatformIssue(taskId, { ...operation.issueMetadata, agent, cwd, client, dependency: operation.dependency, skipQueue: true });
|
|
130
|
+
if ((sync.status !== 'applied' && sync.status !== 'no-op') || sync.error) return sync;
|
|
131
|
+
const after = await inspectPlatformIssue(taskId, { cwd, client });
|
|
132
|
+
if (after.status !== 'no-op' || after.error || !after.issue
|
|
133
|
+
|| !resourceIdentityEquals(after.issue.identity, expectedIdentity)) {
|
|
134
|
+
return platformResult('blocked', { error: after.error ?? { code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Issue identity changed during metadata recovery', retryable: false } });
|
|
135
|
+
}
|
|
136
|
+
const issue = after.issue;
|
|
137
|
+
const metadata = operation.issueMetadata;
|
|
138
|
+
const failedOperation = sync.operations.find((item) => item.status === 'failed' || item.status === 'skipped');
|
|
139
|
+
if (failedOperation) return platformResult('blocked', { error: {
|
|
140
|
+
code: failedOperation.reasonCode || 'PLATFORM_OPERATION_METADATA_UNCONFIRMED',
|
|
141
|
+
message: `Issue metadata recovery did not confirm operation '${failedOperation.name}'`, retryable: true
|
|
142
|
+
} });
|
|
143
|
+
const unconfirmed = sync.operations.some((item) => {
|
|
144
|
+
if (!('value' in item) || item.value === undefined) return false;
|
|
145
|
+
if (item.name === 'labels:status' || item.name === 'labels:in') {
|
|
146
|
+
const prefix = item.name === 'labels:status' ? 'status:' : 'in:';
|
|
147
|
+
return !labelsMatchOwnedPrefix(issue!.labels, item.value as string[], prefix);
|
|
148
|
+
}
|
|
149
|
+
if (item.name === 'assignees') return [...issue!.assignees].sort().join('\0') !== [...item.value as string[]].sort().join('\0');
|
|
150
|
+
if (item.name === 'milestone') return issue!.milestone !== item.value;
|
|
151
|
+
if (item.name === 'requirements') return issue!.body !== item.value;
|
|
152
|
+
if (item.name === 'state') return issue!.state !== item.value;
|
|
153
|
+
if (item.name === 'issue-type') return issue!.issueType !== item.value;
|
|
154
|
+
if (item.name === 'fields') return !fieldsMatchExpected(issue!.fields, item.value as Record<string, string | number | null>);
|
|
155
|
+
return false;
|
|
156
|
+
}) || (metadata.state !== undefined && issue!.state !== metadata.state)
|
|
157
|
+
|| (metadata.assignees === 'none' && issue!.assignees.length !== 0)
|
|
158
|
+
|| (metadata.milestone === 'none' && issue!.milestone !== null);
|
|
159
|
+
if (unconfirmed) return platformResult('blocked', { error: {
|
|
160
|
+
code: 'PLATFORM_OPERATION_METADATA_UNCONFIRMED',
|
|
161
|
+
message: 'Issue metadata differs from the requested recovery target after reread', retryable: true
|
|
162
|
+
} });
|
|
163
|
+
return platformResult('no-op', { changed: sync.changed || after.changed });
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function verifyIssueCreate(taskId: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], cwd: string, client?: PlatformClient): Promise<PlatformResult> {
|
|
167
|
+
if (!operation.issueCreate) return platformResult('failed', { error: {
|
|
168
|
+
code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Issue creation recovery identity is missing', retryable: false
|
|
169
|
+
} });
|
|
170
|
+
const current = await inspectPlatformIssue(taskId, { cwd, client });
|
|
171
|
+
if (!current.issue) return platformResult('blocked', { error: current.error ?? {
|
|
172
|
+
code: 'PLATFORM_OPERATION_TARGET_UNAVAILABLE',
|
|
173
|
+
message: 'Issue creation outcome is unknown and the task has no bound Issue identity; bind the verified remote Issue before continuing',
|
|
174
|
+
retryable: true
|
|
175
|
+
} });
|
|
176
|
+
if (current.issue.title !== operation.issueCreate.title
|
|
177
|
+
|| createHash('sha256').update(current.issue.body).digest('hex') !== operation.issueCreate.bodyDigest) return platformResult('blocked', { error: {
|
|
178
|
+
code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Bound Issue does not match the queued creation intent', retryable: false
|
|
179
|
+
} });
|
|
180
|
+
return platformResult('no-op');
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function replayPullRequestSummary(taskId: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], agent: string, cwd: string, client?: PlatformClient): Promise<PlatformResult> {
|
|
184
|
+
let identity;
|
|
185
|
+
try { identity = parseResourceIdentity(JSON.parse(operation.target), 'queued pull-request summary identity'); }
|
|
186
|
+
catch { return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Queued pull-request summary identity is invalid', retryable: false } }); }
|
|
187
|
+
const resolved = await resolvePlatformProviderContext({ cwd, client });
|
|
188
|
+
if (!resolved.ok) return resolved.context;
|
|
189
|
+
const listed = resolved.value.provider.comments?.list
|
|
190
|
+
? await resolved.value.provider.comments.list({ context: providerOperationContext(resolved.value), parent: identity })
|
|
191
|
+
: unsupportedProviderOperation(resolved.value.provider, 'comments.list');
|
|
192
|
+
if (!listed.ok) return platformResult(listed.error.retryable ? 'blocked' : 'failed', { error: providerError(listed.error, 'PLATFORM_PROVIDER_OPERATION_FAILED') });
|
|
193
|
+
const marker = `<!-- sync-pr:${taskId}:summary -->`;
|
|
194
|
+
const summaries = listed.value.filter((comment) => normalizeCommentContent(comment.body).split('\n', 1)[0] === marker);
|
|
195
|
+
if (summaries.length > 1) return platformResult('blocked', { error: {
|
|
196
|
+
code: 'PR_SUMMARY_MARKER_AMBIGUOUS', message: 'Multiple pull-request comments contain the queued summary marker', retryable: false
|
|
197
|
+
} });
|
|
198
|
+
if (summaries.length === 1 && createHash('sha256').update(normalizeCommentContent(summaries[0]!.body)).digest('hex') === operation.expectedDigest) {
|
|
199
|
+
return platformResult('no-op');
|
|
200
|
+
}
|
|
201
|
+
if (!operation.pullRequestSummary) return platformResult('blocked', { error: {
|
|
202
|
+
code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Pull-request summary recovery content is missing', retryable: false
|
|
203
|
+
} });
|
|
204
|
+
const bound = await inspectPlatformPullRequest(taskId, { cwd, client });
|
|
205
|
+
if (!bound.pullRequest || !resourceIdentityEquals(bound.pullRequest.identity, identity)) return platformResult('blocked', { error: bound.error ?? {
|
|
206
|
+
code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Bound pull request differs from the queued summary target', retryable: false
|
|
207
|
+
} });
|
|
208
|
+
const replayed = await syncPullRequestSummary(taskId, {
|
|
209
|
+
agent,
|
|
210
|
+
cwd,
|
|
211
|
+
client,
|
|
212
|
+
body: operation.pullRequestSummary.body,
|
|
213
|
+
changeReportFile: operation.pullRequestSummary.changeReportFile,
|
|
214
|
+
primaryResult: 'no_op',
|
|
215
|
+
strict: true,
|
|
216
|
+
skipQueue: true,
|
|
217
|
+
lockAlreadyHeld: true
|
|
218
|
+
});
|
|
219
|
+
if ((replayed.status === 'applied' || replayed.status === 'no-op') && !replayed.error && replayed.warnings.length === 0) {
|
|
220
|
+
return platformResult(replayed.status, { changed: replayed.changed });
|
|
221
|
+
}
|
|
222
|
+
return platformResult('blocked', { error: replayed.error ?? {
|
|
223
|
+
code: 'PR_SUMMARY_RECOVERY_UNCONFIRMED', message: 'Pull-request summary replay did not confirm the requested remote state', retryable: true
|
|
224
|
+
} });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function replayPullRequestReview(operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], agent: string, cwd: string, client?: PlatformClient): Promise<PlatformResult> {
|
|
228
|
+
const intent = operation.pullRequestReview;
|
|
229
|
+
if (!intent) return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Pull-request review recovery parameters are missing', retryable: false } });
|
|
230
|
+
let target;
|
|
231
|
+
try { target = parseResourceIdentity(JSON.parse(operation.target), 'queued pull-request review identity'); }
|
|
232
|
+
catch { return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Queued pull-request review identity is invalid', retryable: false } }); }
|
|
233
|
+
if (!intent.resource || !resourceIdentityEquals(target, intent.resource)) return platformResult('failed', { error: {
|
|
234
|
+
code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Pull-request review identity differs from the journal target', retryable: false
|
|
235
|
+
} });
|
|
236
|
+
let body: string;
|
|
237
|
+
try { body = readReviewBodyFile(intent.scope, intent.round, intent.artifactFile, intent.bodyDigest, cwd); }
|
|
238
|
+
catch { return platformResult('failed', { error: {
|
|
239
|
+
code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Canonical pull-request review body is unavailable or does not match the queued digest', retryable: false
|
|
240
|
+
} }); }
|
|
241
|
+
return publishPrReview({
|
|
242
|
+
cwd,
|
|
243
|
+
client,
|
|
244
|
+
agent,
|
|
245
|
+
prNumber: intent.prNumber,
|
|
246
|
+
expectedResource: target,
|
|
247
|
+
expectedProviderScopeId: intent.providerScopeId,
|
|
248
|
+
identity: { scope: intent.scope, round: intent.round, commitSha: intent.commitSha, ...(intent.resource ? { resource: intent.resource } : {}) },
|
|
249
|
+
event: intent.event,
|
|
250
|
+
body,
|
|
251
|
+
recoveryArtifact: intent.artifactFile,
|
|
252
|
+
skipQueue: true
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function replayPullRequest(taskId: string, operation: ReturnType<typeof readPlatformOperationJournal>['operations'][number], agent: string, cwd: string): Promise<PlatformResult> {
|
|
257
|
+
const intent = operation.pullRequest;
|
|
258
|
+
if (!intent) return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Pull-request recovery parameters are missing', retryable: false } });
|
|
259
|
+
if (intent.action === 'bind') {
|
|
260
|
+
if (!intent.prToken) return platformResult('failed', { error: { code: 'PLATFORM_OPERATION_PAYLOAD_INVALID', message: 'Pull-request bind identity is missing', retryable: false } });
|
|
261
|
+
return bindPlatformPullRequest(taskId, { agent, cwd, pr: intent.prToken, skipQueue: true });
|
|
262
|
+
}
|
|
263
|
+
if (intent.action === 'sync') {
|
|
264
|
+
const synced = await syncPlatformPullRequest(taskId, {
|
|
265
|
+
agent, cwd, metadata: intent.metadata === true, closingIssue: intent.closingIssue === true, primaryResult: 'no_op', skipQueue: true
|
|
266
|
+
});
|
|
267
|
+
if (synced.warnings.length > 0 || synced.result?.endsWith('_with_warnings')) {
|
|
268
|
+
return platformResult('blocked', { error: { code: 'PLATFORM_OPERATION_PR_SYNC_UNCONFIRMED', message: 'Pull-request metadata sync remains degraded', retryable: true } });
|
|
269
|
+
}
|
|
270
|
+
return synced;
|
|
271
|
+
}
|
|
272
|
+
return recoverCreatedPullRequest(taskId, { agent, cwd, base: intent.baseRef || '', head: intent.headRef || '', skipQueue: true });
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
async function recoverPlatformOperations(
|
|
276
|
+
taskRef: string,
|
|
277
|
+
selection: 'required' | 'deferred' | 'all',
|
|
278
|
+
options: RecoveryOptions
|
|
279
|
+
): Promise<RecoveryResult> {
|
|
280
|
+
const resolved = resolveTaskRef(taskRef, options.cwd ? { repoRoot: options.cwd } : {});
|
|
281
|
+
if (!resolved.ok) return result('failed', [], [], { code: resolved.code, message: resolved.message, retryable: false });
|
|
282
|
+
let journal;
|
|
283
|
+
try { journal = readPlatformOperationJournal(resolved.taskId, resolved.repoRoot); }
|
|
284
|
+
catch (error) {
|
|
285
|
+
const value = error as { code?: string; message?: string };
|
|
286
|
+
return result('failed', [], [], { code: value.code || 'PLATFORM_OPERATION_JOURNAL_INVALID', message: value.message || String(error), retryable: false });
|
|
287
|
+
}
|
|
288
|
+
const candidates = journal.operations.filter((operation) => operation.id !== options.excludeId
|
|
289
|
+
&& (operation.state === 'queued' || operation.state === 'pending' || operation.state === 'unknown'
|
|
290
|
+
|| (operation.state === 'failed' && operation.lastCode !== 'PLATFORM_OPERATION_SUPERSEDED')))
|
|
291
|
+
.filter((operation) => selection === 'all' || operation.dependency === selection)
|
|
292
|
+
.sort((left, right) => left.updatedAt.localeCompare(right.updatedAt));
|
|
293
|
+
if (!candidates.length) return result('no-op', [], []);
|
|
294
|
+
const limit = options.limit === undefined ? candidates.length : Math.max(1, options.limit);
|
|
295
|
+
const recovered: string[] = [];
|
|
296
|
+
const pending: string[] = [];
|
|
297
|
+
const selected = candidates.slice(0, limit);
|
|
298
|
+
for (const [index, operation] of selected.entries()) {
|
|
299
|
+
if (operation.state === 'failed') {
|
|
300
|
+
pending.push(operation.id);
|
|
301
|
+
return result('blocked', recovered, pending, {
|
|
302
|
+
code: operation.lastCode || 'PLATFORM_OPERATION_FAILED',
|
|
303
|
+
message: 'A previous platform operation failed permanently; later writes remain queued',
|
|
304
|
+
retryable: false
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (operation.attempts >= operation.maxAttempts) {
|
|
308
|
+
pending.push(operation.id, ...selected.slice(index + 1).map((next) => next.id));
|
|
309
|
+
pending.push(...candidates.slice(limit).map((next) => next.id));
|
|
310
|
+
return result('blocked', recovered, pending, {
|
|
311
|
+
code: operation.lastCode || 'PLATFORM_OPERATION_RETRY_LIMIT_REACHED',
|
|
312
|
+
message: 'A previous platform operation exhausted its recovery attempts; later writes remain queued',
|
|
313
|
+
retryable: false
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (operation.kind !== 'issue-create') {
|
|
317
|
+
try {
|
|
318
|
+
recordPlatformOperation({
|
|
319
|
+
taskRef: resolved.taskId, cwd: resolved.repoRoot, kind: operation.kind,
|
|
320
|
+
target: operation.target, expectedDigest: operation.expectedDigest,
|
|
321
|
+
dependency: operation.dependency, state: 'pending',
|
|
322
|
+
...(operation.issueMetadata ? { issueMetadata: operation.issueMetadata } : {}),
|
|
323
|
+
...(operation.issueCreate ? { issueCreate: operation.issueCreate } : {}),
|
|
324
|
+
...(operation.pullRequest ? { pullRequest: operation.pullRequest } : {}),
|
|
325
|
+
...(operation.pullRequestSummary ? { pullRequestSummary: operation.pullRequestSummary } : {}),
|
|
326
|
+
...(operation.pullRequestReview ? { pullRequestReview: operation.pullRequestReview } : {})
|
|
327
|
+
});
|
|
328
|
+
} catch (error) {
|
|
329
|
+
const value = error as { code?: string; message?: string };
|
|
330
|
+
return result('blocked', recovered, [...pending, operation.id], {
|
|
331
|
+
code: value.code || 'PLATFORM_OPERATION_JOURNAL_WRITE_FAILED',
|
|
332
|
+
message: value.message || String(error), retryable: true
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
let targetOperation = operation;
|
|
337
|
+
if (operation.kind === 'issue-metadata') {
|
|
338
|
+
const current = currentIssueMetadataOperation(resolved.taskId, resolved.taskMdPath, resolved.repoRoot, operation);
|
|
339
|
+
if (!current) {
|
|
340
|
+
pending.push(operation.id);
|
|
341
|
+
return result('blocked', recovered, pending, { code: 'PLATFORM_OPERATION_TARGET_UNAVAILABLE', message: 'Current Issue metadata target cannot be reconstructed safely', retryable: true });
|
|
342
|
+
}
|
|
343
|
+
if (current.target !== operation.target) {
|
|
344
|
+
return result('blocked', recovered, [...pending, operation.id], { code: 'PLATFORM_OPERATION_IDENTITY_MISMATCH', message: 'Bound Issue identity differs from the journal target', retryable: false });
|
|
345
|
+
}
|
|
346
|
+
if (current.id !== operation.id) {
|
|
347
|
+
try {
|
|
348
|
+
recordPlatformOperation({ taskRef: resolved.taskId, cwd: resolved.repoRoot, kind: operation.kind, target: operation.target,
|
|
349
|
+
expectedDigest: operation.expectedDigest, issueMetadata: operation.issueMetadata, dependency: operation.dependency,
|
|
350
|
+
state: 'failed', lastCode: 'PLATFORM_OPERATION_SUPERSEDED' });
|
|
351
|
+
targetOperation = { ...operation, expectedDigest: current.expectedDigest, issueMetadata: current.issueMetadata, id: current.id };
|
|
352
|
+
} catch (error) {
|
|
353
|
+
const value = error as { code?: string; message?: string };
|
|
354
|
+
return result('blocked', recovered, [...pending, operation.id], { code: value.code || 'PLATFORM_OPERATION_JOURNAL_WRITE_FAILED', message: value.message || String(error), retryable: true });
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (operation.kind === 'task-comment' || operation.kind === 'artifact-comment'
|
|
359
|
+
|| operation.kind === 'summary-comment' || operation.kind === 'cancel-comment') {
|
|
360
|
+
const commentOptions = operation.kind === 'task-comment'
|
|
361
|
+
? { kind: 'task' as const, agent: options.agent, cwd: resolved.repoRoot, dependency: operation.dependency }
|
|
362
|
+
: operation.kind === 'artifact-comment'
|
|
363
|
+
? { kind: 'artifact' as const, artifact: operation.target, agent: options.agent, cwd: resolved.repoRoot, dependency: operation.dependency }
|
|
364
|
+
: operation.kind === 'summary-comment' ? (() => {
|
|
365
|
+
const summary = summaryPayload(resolved.taskDir, resolved.taskId);
|
|
366
|
+
return summary ? { kind: 'summary' as const, body: summary.body, agent: options.agent, cwd: resolved.repoRoot, summaryAuthorization: { sha256: summary.sha256 }, dependency: operation.dependency } : null;
|
|
367
|
+
})() : { kind: 'cancel' as const, agent: options.agent, cwd: resolved.repoRoot, dependency: operation.dependency };
|
|
368
|
+
const current = commentOptions ? inspectPlatformCommentOperation(resolved.taskId, commentOptions) : null;
|
|
369
|
+
if (!current) {
|
|
370
|
+
pending.push(operation.id);
|
|
371
|
+
return result('blocked', recovered, pending, { code: 'PLATFORM_OPERATION_TARGET_UNAVAILABLE', message: 'Current comment target cannot be reconstructed safely', retryable: true });
|
|
372
|
+
}
|
|
373
|
+
if (current.id !== operation.id) {
|
|
374
|
+
try {
|
|
375
|
+
recordPlatformOperation({ taskRef: resolved.taskId, cwd: resolved.repoRoot, kind: operation.kind, target: operation.target,
|
|
376
|
+
expectedDigest: operation.expectedDigest, dependency: operation.dependency, state: 'failed', lastCode: 'PLATFORM_OPERATION_SUPERSEDED' });
|
|
377
|
+
targetOperation = { ...operation, expectedDigest: current.expectedDigest, id: current.id };
|
|
378
|
+
} catch (error) {
|
|
379
|
+
const value = error as { code?: string; message?: string };
|
|
380
|
+
return result('blocked', recovered, [...pending, operation.id], { code: value.code || 'PLATFORM_OPERATION_JOURNAL_WRITE_FAILED', message: value.message || String(error), retryable: true });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
let remote: PlatformResult;
|
|
385
|
+
try {
|
|
386
|
+
remote = operation.kind === 'issue-create'
|
|
387
|
+
? await verifyIssueCreate(resolved.taskId, operation, resolved.repoRoot)
|
|
388
|
+
: operation.kind === 'pull-request-summary'
|
|
389
|
+
? await replayPullRequestSummary(resolved.taskId, operation, options.agent, resolved.repoRoot, options.client)
|
|
390
|
+
: operation.kind === 'pull-request-review'
|
|
391
|
+
? await replayPullRequestReview(operation, options.agent, resolved.repoRoot, options.client)
|
|
392
|
+
: operation.kind === 'issue-metadata'
|
|
393
|
+
? await replayIssueMetadata(resolved.taskId, targetOperation, options.agent, resolved.repoRoot)
|
|
394
|
+
: operation.kind === 'pull-request'
|
|
395
|
+
? await replayPullRequest(resolved.taskId, targetOperation, options.agent, resolved.repoRoot)
|
|
396
|
+
: await replayComment(resolved.taskId, resolved.taskDir, operation, options.agent, resolved.repoRoot);
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
const value = error as { code?: string; message?: string };
|
|
400
|
+
remote = platformResult('blocked', { error: { code: value.code || 'PLATFORM_OPERATION_RECOVERY_FAILED', message: value.message || String(error), retryable: true } });
|
|
401
|
+
}
|
|
402
|
+
const succeeded = (remote.status === 'applied' || remote.status === 'no-op') && !remote.error;
|
|
403
|
+
try {
|
|
404
|
+
recordPlatformOperation({
|
|
405
|
+
taskRef: resolved.taskId,
|
|
406
|
+
cwd: resolved.repoRoot,
|
|
407
|
+
kind: operation.kind,
|
|
408
|
+
target: operation.target,
|
|
409
|
+
expectedDigest: targetOperation.expectedDigest,
|
|
410
|
+
...(targetOperation.issueMetadata ? { issueMetadata: targetOperation.issueMetadata } : {}),
|
|
411
|
+
...(operation.issueCreate ? { issueCreate: operation.issueCreate } : {}),
|
|
412
|
+
...(operation.pullRequest ? { pullRequest: operation.pullRequest } : {}),
|
|
413
|
+
...(operation.pullRequestSummary ? { pullRequestSummary: operation.pullRequestSummary } : {}),
|
|
414
|
+
...(operation.pullRequestReview ? { pullRequestReview: operation.pullRequestReview } : {}),
|
|
415
|
+
dependency: operation.dependency,
|
|
416
|
+
state: succeeded ? 'succeeded' : remote.status === 'failed' && remote.error?.retryable === false ? 'failed' : 'unknown',
|
|
417
|
+
lastCode: remote.error?.code ?? null
|
|
418
|
+
});
|
|
419
|
+
} catch (error) {
|
|
420
|
+
const value = error as { code?: string; message?: string };
|
|
421
|
+
return result('blocked', recovered, [...pending, operation.id], { code: value.code || 'PLATFORM_OPERATION_JOURNAL_WRITE_FAILED', message: value.message || String(error), retryable: true });
|
|
422
|
+
}
|
|
423
|
+
if (!succeeded) {
|
|
424
|
+
pending.push(targetOperation.id);
|
|
425
|
+
return result(remote.status === 'failed' ? 'failed' : 'blocked', recovered, pending, remote.error ?? { code: 'PLATFORM_OPERATION_RECOVERY_UNKNOWN', message: 'Platform operation outcome remains unknown', retryable: true });
|
|
426
|
+
}
|
|
427
|
+
recovered.push(targetOperation.id);
|
|
428
|
+
}
|
|
429
|
+
const remaining = candidates.slice(limit).map((operation) => operation.id);
|
|
430
|
+
pending.push(...remaining);
|
|
431
|
+
return result(pending.length ? 'blocked' : recovered.length ? 'applied' : 'no-op', recovered, pending, pending.length ? { code: 'PLATFORM_OPERATION_RECOVERY_PENDING', message: 'Platform operations remain pending after the recovery budget', retryable: true } : null);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export { fieldsMatchExpected, labelsMatchOwnedPrefix, recoverPlatformOperations };
|
|
435
|
+
export type { RecoveryOptions, RecoveryResult };
|