@allocator-one/rcl 4.5.3 → 4.5.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 +12 -3
- package/dist/converge/attempt-budget.d.ts +14 -0
- package/dist/converge/attempt-budget.js +216 -1
- package/dist/converge/attempt-budget.js.map +1 -1
- package/dist/converge/historical-delivery-reconciliation-schema.d.ts +131 -0
- package/dist/converge/historical-delivery-reconciliation-schema.js +111 -0
- package/dist/converge/historical-delivery-reconciliation-schema.js.map +1 -0
- package/dist/converge/historical-delivery-reconciliation.d.ts +15 -0
- package/dist/converge/historical-delivery-reconciliation.js +326 -0
- package/dist/converge/historical-delivery-reconciliation.js.map +1 -0
- package/dist/converge/launch-guard.js +25 -6
- package/dist/converge/launch-guard.js.map +1 -1
- package/dist/converge/launch-record.d.ts +36 -0
- package/dist/converge/launch-record.js +9 -3
- package/dist/converge/launch-record.js.map +1 -1
- package/dist/converge/legacy-launch-health.d.ts +36 -0
- package/dist/converge/native-lock.d.ts +3 -1
- package/dist/converge/native-lock.js +4 -4
- package/dist/converge/native-lock.js.map +1 -1
- package/dist/converge/ordinary-pending-export.d.ts +3 -0
- package/dist/converge/ordinary-pending-export.js +64 -17
- package/dist/converge/ordinary-pending-export.js.map +1 -1
- package/dist/converge/ordinary-pending-package.d.ts +11 -0
- package/dist/converge/ordinary-pending-package.js +18 -4
- package/dist/converge/ordinary-pending-package.js.map +1 -1
- package/dist/converge/pending-finalization-receipt.d.ts +4 -0
- package/dist/converge/pending-finalization-receipt.js +102 -0
- package/dist/converge/pending-finalization-receipt.js.map +1 -0
- package/dist/converge/pending-legacy-resume.d.ts +42 -3
- package/dist/converge/pending-legacy-resume.js +164 -32
- package/dist/converge/pending-legacy-resume.js.map +1 -1
- package/dist/converge/pending-recovery-source.d.ts +114 -0
- package/dist/converge/pending-recovery-source.js +36 -1
- package/dist/converge/pending-recovery-source.js.map +1 -1
- package/dist/converge/process-identity.d.ts +51 -0
- package/dist/converge/process-identity.js +190 -0
- package/dist/converge/process-identity.js.map +1 -0
- package/dist/converge/recovery-launch.js +39 -17
- package/dist/converge/recovery-launch.js.map +1 -1
- package/dist/converge/recovery-state.d.ts +55 -0
- package/dist/converge/recovery-state.js +306 -0
- package/dist/converge/recovery-state.js.map +1 -0
- package/dist/converge/run-state.d.ts +43 -1
- package/dist/converge/run-state.js +252 -18
- package/dist/converge/run-state.js.map +1 -1
- package/dist/converge/semantic-state.d.ts +55 -0
- package/dist/converge/semantic-state.js +666 -0
- package/dist/converge/semantic-state.js.map +1 -0
- package/dist/converge/stale-report.d.ts +412 -0
- package/dist/converge/stale-report.js +42 -0
- package/dist/converge/stale-report.js.map +1 -1
- package/dist/converge/terminal-rejection.d.ts +1 -0
- package/dist/converge/terminal-rejection.js +6 -6
- package/dist/converge/terminal-rejection.js.map +1 -1
- package/dist/dispatch/async-lane.d.ts +12 -0
- package/dist/dispatch/async-lane.js +94 -0
- package/dist/dispatch/async-lane.js.map +1 -1
- package/dist/evidence/claim-recovery/validation/native-state.d.ts +22 -0
- package/dist/evidence/claim-recovery/validation/native-state.js +91 -9
- package/dist/evidence/claim-recovery/validation/native-state.js.map +1 -1
- package/dist/evidence/claim-recovery/validation/obligations.js +2 -1
- package/dist/evidence/claim-recovery/validation/obligations.js.map +1 -1
- package/dist/evidence/claim-recovery/validation/semantic-validation.d.ts +11 -0
- package/dist/evidence/claim-recovery/validation/semantic-validation.js +105 -28
- package/dist/evidence/claim-recovery/validation/semantic-validation.js.map +1 -1
- package/dist/evidence/claim-recovery/validation/types.d.ts +10 -0
- package/dist/evidence/original-run/lock-scope.d.ts +12 -6
- package/dist/evidence/original-run/lock-scope.js +12 -9
- package/dist/evidence/original-run/lock-scope.js.map +1 -1
- package/dist/index.js +74 -11
- package/dist/index.js.map +1 -1
- package/dist/telemetry/recovery/files.d.ts +4 -0
- package/dist/telemetry/recovery/files.js +15 -5
- package/dist/telemetry/recovery/files.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { reviewerHealthSchema, strongDeliveryReconciliationSchema } from './launch-record.js';
|
|
4
|
+
import { decodeRecoveryDocument } from '../evidence/original-run/decode.js';
|
|
5
|
+
import { serializeRecoveryDocument } from '../evidence/original-run/journal.js';
|
|
6
|
+
import { sha256 } from '../telemetry/recovery/files.js';
|
|
7
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
8
|
+
const commit = z.string().regex(/^[a-f0-9]{40}$/);
|
|
9
|
+
const uuid = z.string().uuid();
|
|
10
|
+
export const historicalServerProjectionSchema = z.object({
|
|
11
|
+
origin: z.string().url(),
|
|
12
|
+
runId: uuid,
|
|
13
|
+
provenance: z.literal('live'),
|
|
14
|
+
receivedAt: z.string().datetime({ offset: true }),
|
|
15
|
+
cycleId: uuid,
|
|
16
|
+
repoVerified: z.literal(true),
|
|
17
|
+
isCrossRepository: z.literal(false),
|
|
18
|
+
headVerified: z.string().min(1),
|
|
19
|
+
target: z.object({
|
|
20
|
+
kind: z.enum(['pr', 'patch']),
|
|
21
|
+
repo: z.string().min(1),
|
|
22
|
+
prNumber: z.number().int().positive().safe(),
|
|
23
|
+
headSha: commit,
|
|
24
|
+
baseSha: commit,
|
|
25
|
+
diffSha256: digest,
|
|
26
|
+
}).strict(),
|
|
27
|
+
converge: z.object({
|
|
28
|
+
target: z.string().min(1),
|
|
29
|
+
attempt: z.number().int().positive().safe(),
|
|
30
|
+
round: z.number().int().positive().safe(),
|
|
31
|
+
}).strict(),
|
|
32
|
+
report: z.object({
|
|
33
|
+
declaredSha256: digest,
|
|
34
|
+
declaredBytes: z.number().int().nonnegative().safe(),
|
|
35
|
+
stored: z.literal(true),
|
|
36
|
+
}).strict(),
|
|
37
|
+
}).strict();
|
|
38
|
+
export const historicalDeliveryReconciliationManifestSchema = z.object({
|
|
39
|
+
kind: z.literal('rcl-historical-delivery-reconciliation'),
|
|
40
|
+
version: z.literal(1),
|
|
41
|
+
operationId: uuid,
|
|
42
|
+
createdAt: z.string().datetime({ offset: true }),
|
|
43
|
+
gitCommonDir: z.string().min(1),
|
|
44
|
+
target: z.string().min(1),
|
|
45
|
+
runId: uuid,
|
|
46
|
+
nativeStateSha256: digest,
|
|
47
|
+
attemptStateSha256: digest,
|
|
48
|
+
sourceStaleManifestSha256s: z.array(digest).min(1).max(100).refine(values => new Set(values).size === values.length && isDeepStrictEqual(values, [...values].sort()), 'Historical stale manifest digests must be unique and sorted'),
|
|
49
|
+
successor: z.object({
|
|
50
|
+
runId: uuid,
|
|
51
|
+
attempt: z.number().int().positive().safe(),
|
|
52
|
+
round: z.number().int().positive().safe(),
|
|
53
|
+
headSha: commit,
|
|
54
|
+
inputSha256: digest,
|
|
55
|
+
}).strict(),
|
|
56
|
+
reconciliation: strongDeliveryReconciliationSchema,
|
|
57
|
+
baseSha: commit,
|
|
58
|
+
diffSha256: digest,
|
|
59
|
+
reviewerHealth: reviewerHealthSchema,
|
|
60
|
+
server: historicalServerProjectionSchema,
|
|
61
|
+
serverProjectionSha256: digest,
|
|
62
|
+
}).strict();
|
|
63
|
+
export const historicalDeliveryReconciliationReceiptSchema = z.object({
|
|
64
|
+
kind: z.literal('rcl-historical-delivery-reconciliation-receipt'),
|
|
65
|
+
version: z.literal(1),
|
|
66
|
+
operationId: uuid,
|
|
67
|
+
runId: uuid,
|
|
68
|
+
manifestSha256: digest,
|
|
69
|
+
beforeStateSha256: digest,
|
|
70
|
+
afterStateSha256: digest,
|
|
71
|
+
attemptStateSha256: digest,
|
|
72
|
+
sourceStaleManifestSha256s: z.array(digest).min(1).max(100),
|
|
73
|
+
serverProjectionSha256: digest,
|
|
74
|
+
}).strict();
|
|
75
|
+
const historicalDeliveryReconciliationEntrySchema = z.object({
|
|
76
|
+
manifestJson: z.string().max(128 * 1024), manifestSha256: digest,
|
|
77
|
+
}).strict();
|
|
78
|
+
export function historicalDeliveryManifest(entry) {
|
|
79
|
+
const parsedEntry = historicalDeliveryReconciliationEntrySchema.parse(entry);
|
|
80
|
+
if (sha256(parsedEntry.manifestJson) !== parsedEntry.manifestSha256)
|
|
81
|
+
throw new Error('historical_delivery_reconciliation_manifest_digest_mismatch');
|
|
82
|
+
const manifest = historicalDeliveryReconciliationManifestSchema.parse(decodeRecoveryDocument(parsedEntry.manifestJson));
|
|
83
|
+
if (parsedEntry.manifestJson !== serializeRecoveryDocument(manifest)) {
|
|
84
|
+
throw new Error('historical_delivery_reconciliation_manifest_noncanonical');
|
|
85
|
+
}
|
|
86
|
+
return manifest;
|
|
87
|
+
}
|
|
88
|
+
export function validateHistoricalDeliveryReconciliationAudit(value) {
|
|
89
|
+
const audit = value.historicalDeliveryReconciliationAudit;
|
|
90
|
+
if (audit === undefined) {
|
|
91
|
+
if (value.historicalDeliveryReconciliationAuditCount !== undefined) {
|
|
92
|
+
throw new Error('historical_delivery_reconciliation_audit_count_mismatch');
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (!Array.isArray(audit) || audit.length === 0 || audit.length > 10_000 ||
|
|
97
|
+
value.historicalDeliveryReconciliationAuditCount !== audit.length) {
|
|
98
|
+
throw new Error('historical_delivery_reconciliation_audit_count_mismatch');
|
|
99
|
+
}
|
|
100
|
+
const operations = new Set();
|
|
101
|
+
const runs = new Set();
|
|
102
|
+
for (const entry of audit) {
|
|
103
|
+
const manifest = historicalDeliveryManifest(entry);
|
|
104
|
+
if (manifest.target !== value.target || operations.has(manifest.operationId) || runs.has(manifest.runId)) {
|
|
105
|
+
throw new Error('historical_delivery_reconciliation_audit_duplicate');
|
|
106
|
+
}
|
|
107
|
+
operations.add(manifest.operationId);
|
|
108
|
+
runs.add(manifest.runId);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=historical-delivery-reconciliation-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historical-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AK,SAAS,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QACD,OAAO;IACT,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,MAAM;QACtE,KAAK,CAAC,0CAA0C,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACpE,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzG,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type HistoricalDeliveryReconciliationManifest } from './historical-delivery-reconciliation-schema.js';
|
|
2
|
+
import { type ConvergeRunState } from './run-state.js';
|
|
3
|
+
import { getRun } from '../evidence/reads.js';
|
|
4
|
+
import type { HarnessSink } from '../telemetry/sink.js';
|
|
5
|
+
interface HistoricalReconciliationOptions {
|
|
6
|
+
getRun?: typeof getRun;
|
|
7
|
+
now?: () => Date;
|
|
8
|
+
}
|
|
9
|
+
/** Print-only qualification; callers may write the returned reviewed manifest separately. */
|
|
10
|
+
export declare function previewHistoricalDeliveryReconciliation(input: unknown, gitCommonDir: string, sink: HarnessSink, options?: HistoricalReconciliationOptions): Promise<HistoricalDeliveryReconciliationManifest>;
|
|
11
|
+
/** Reverify every authority source under the target lock, then append one local receipt atomically. */
|
|
12
|
+
export declare function applyHistoricalDeliveryReconciliation(input: unknown, gitCommonDir: string, sink: HarnessSink, options?: HistoricalReconciliationOptions): Promise<'applied' | 'unchanged'>;
|
|
13
|
+
/** Local fail-closed verification used before claims and report admission. */
|
|
14
|
+
export declare function verifyHistoricalDeliveryReconciliations(common: string, state: ConvergeRunState): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { realpath } from 'node:fs/promises';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { convergeAttemptStatePath, validateConvergeAttemptState } from './attempt-budget.js';
|
|
7
|
+
import { assertNoPendingFreshReview } from './fresh-review.js';
|
|
8
|
+
import { historicalDeliveryManifest, historicalDeliveryReconciliationManifestSchema, historicalDeliveryReconciliationReceiptSchema, historicalServerProjectionSchema, validateHistoricalDeliveryReconciliationAudit, } from './historical-delivery-reconciliation-schema.js';
|
|
9
|
+
import { strongDeliveryReconciliationSchema } from './launch-record.js';
|
|
10
|
+
import { convergeRunStatePath, loadConvergeRunStateEvidence, writeState, } from './run-state.js';
|
|
11
|
+
import { inspectVerifiedStaleReportReceipts } from './stale-report.js';
|
|
12
|
+
import { readStaleObject, retainStaleFile as retain, selectedStaleFile as selected } from './stale-report-storage.js';
|
|
13
|
+
import { assertDeadOwner } from './terminal-rejection.js';
|
|
14
|
+
import { withRecoveryTarget } from './target-ownership.js';
|
|
15
|
+
import { getRun } from '../evidence/reads.js';
|
|
16
|
+
import { decodeRecoveryDocument } from '../evidence/original-run/decode.js';
|
|
17
|
+
import { serializeRecoveryDocument, syncDirectory } from '../evidence/original-run/journal.js';
|
|
18
|
+
import { inspectRecoveryDirectory, prepareLockRoot } from '../evidence/original-run/lock-path.js';
|
|
19
|
+
import { normalizeUrl } from '../telemetry/credentials.js';
|
|
20
|
+
import { readStable, sha256 } from '../telemetry/recovery/files.js';
|
|
21
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
22
|
+
const selectionSchema = z.object({
|
|
23
|
+
target: z.string().min(1).max(200).refine(value => value.trim() === value),
|
|
24
|
+
runId: z.string().uuid(),
|
|
25
|
+
}).strict();
|
|
26
|
+
const applySchema = z.object({ manifest: z.string().min(1), manifestSha256: digest }).strict();
|
|
27
|
+
function fail(code) { throw new Error(`historical_delivery_reconciliation_${code}`); }
|
|
28
|
+
function endpoint(value) {
|
|
29
|
+
const normalized = normalizeUrl(value);
|
|
30
|
+
if (!normalized)
|
|
31
|
+
fail('origin_invalid');
|
|
32
|
+
return normalized;
|
|
33
|
+
}
|
|
34
|
+
function selectedServerProjection(sink, detail, local) {
|
|
35
|
+
const cycle = local.state.cycle;
|
|
36
|
+
if (!cycle || endpoint(sink.baseUrl) !== endpoint(cycle.url))
|
|
37
|
+
fail('server_origin_mismatch');
|
|
38
|
+
const reports = detail.artifacts?.filter(artifact => artifact.kind === 'report_json') ?? [];
|
|
39
|
+
const report = reports[0];
|
|
40
|
+
if (detail.id.toLowerCase() !== local.runId.toLowerCase() || detail.provenance !== 'live' ||
|
|
41
|
+
detail.repo_verified !== true || detail.is_cross_repository !== false ||
|
|
42
|
+
typeof detail.head_verified !== 'string' || detail.head_verified.length === 0 ||
|
|
43
|
+
detail.cycle_id !== cycle.id || reports.length !== 1 || !report ||
|
|
44
|
+
report.stored !== true || report.declared_sha256 !== local.reportSha256 ||
|
|
45
|
+
report.declared_bytes !== local.reportBytes || detail.target.kind !== local.targetKind ||
|
|
46
|
+
detail.target.repo?.toLowerCase() !== cycle.repo.toLowerCase() || detail.target.pr_number !== cycle.prNumber ||
|
|
47
|
+
detail.target.head_sha !== local.headSha || detail.target.base_sha !== local.baseSha ||
|
|
48
|
+
detail.target.diff_sha256 !== local.diffSha256 ||
|
|
49
|
+
detail.converge?.target !== local.target || detail.converge.attempt !== local.attempt ||
|
|
50
|
+
detail.converge.round !== local.round || typeof detail.received_at !== 'string') {
|
|
51
|
+
fail('server_binding_mismatch');
|
|
52
|
+
}
|
|
53
|
+
const parsed = z.string().datetime({ offset: true }).safeParse(detail.received_at);
|
|
54
|
+
if (!parsed.success)
|
|
55
|
+
fail('server_binding_mismatch');
|
|
56
|
+
return historicalServerProjectionSchema.parse({
|
|
57
|
+
origin: endpoint(sink.baseUrl), runId: detail.id, provenance: 'live', receivedAt: detail.received_at,
|
|
58
|
+
cycleId: cycle.id, repoVerified: true, isCrossRepository: false,
|
|
59
|
+
headVerified: detail.head_verified,
|
|
60
|
+
target: { kind: detail.target.kind, repo: detail.target.repo, prNumber: detail.target.pr_number,
|
|
61
|
+
headSha: detail.target.head_sha, baseSha: detail.target.base_sha, diffSha256: detail.target.diff_sha256 },
|
|
62
|
+
converge: { target: detail.converge.target, attempt: detail.converge.attempt, round: detail.converge.round },
|
|
63
|
+
report: { declaredSha256: report.declared_sha256, declaredBytes: report.declared_bytes, stored: true },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
async function readServerProjection(sink, local, options) {
|
|
67
|
+
const outcome = await (options.getRun ?? getRun)(sink, local.runId, { requireCompleteRead: true });
|
|
68
|
+
if (outcome.kind !== 'ok')
|
|
69
|
+
fail(`server_${outcome.kind}`);
|
|
70
|
+
return selectedServerProjection(sink, outcome.value, local);
|
|
71
|
+
}
|
|
72
|
+
function commonPredecessor(proofs, target, runId) {
|
|
73
|
+
const matches = proofs.filter((proof) => proof.m.version === 2 &&
|
|
74
|
+
proof.m.outcome === 'delivered-hard-failure' && proof.m.target === target &&
|
|
75
|
+
proof.m.runId.toLowerCase() === runId.toLowerCase());
|
|
76
|
+
if (matches.length === 0)
|
|
77
|
+
fail('predecessor_not_found');
|
|
78
|
+
const first = matches[0];
|
|
79
|
+
const launch = first.previous;
|
|
80
|
+
const marker = launch.deliveryReconciliation;
|
|
81
|
+
if (marker?.version !== 1 || launch.status !== 'completed' || launch.hardFailure !== true ||
|
|
82
|
+
launch.deliveryPending !== false || launch.exitCode !== 4 || !launch.reviewerHealth ||
|
|
83
|
+
launch.runId !== runId || launch.reportJsonSha256 !== first.m.reportSha256 ||
|
|
84
|
+
first.m.deliveryReconciliation.version !== 1 || !isDeepStrictEqual(first.m.deliveryReconciliation, marker)) {
|
|
85
|
+
fail('predecessor_ineligible');
|
|
86
|
+
}
|
|
87
|
+
const binding = {
|
|
88
|
+
target: first.m.target, runId: first.m.runId, reportSha256: first.m.reportSha256,
|
|
89
|
+
headSha: first.m.previousHeadSha, inputSha256: first.m.previousInputSha256,
|
|
90
|
+
attempt: first.m.attempt, round: first.m.round, cycleId: first.m.cycleId,
|
|
91
|
+
marker: first.m.deliveryReconciliation, reviewerHealth: first.m.reviewerHealth,
|
|
92
|
+
launch, evidence: first.evidence,
|
|
93
|
+
};
|
|
94
|
+
for (const proof of matches.slice(1)) {
|
|
95
|
+
const candidate = {
|
|
96
|
+
target: proof.m.target, runId: proof.m.runId, reportSha256: proof.m.reportSha256,
|
|
97
|
+
headSha: proof.m.previousHeadSha, inputSha256: proof.m.previousInputSha256,
|
|
98
|
+
attempt: proof.m.attempt, round: proof.m.round, cycleId: proof.m.cycleId,
|
|
99
|
+
marker: proof.m.deliveryReconciliation, reviewerHealth: proof.m.reviewerHealth,
|
|
100
|
+
launch: proof.previous, evidence: proof.evidence,
|
|
101
|
+
};
|
|
102
|
+
if (!isDeepStrictEqual(candidate, binding))
|
|
103
|
+
fail('predecessor_ambiguous');
|
|
104
|
+
}
|
|
105
|
+
return { binding, sourceDigests: matches.map(proof => proof.entry.manifestSha256).sort() };
|
|
106
|
+
}
|
|
107
|
+
async function deriveLocalAuthority(common, target, runId, state, nativeSha256, attemptFile, requireDeadOwner) {
|
|
108
|
+
validateHistoricalDeliveryReconciliationAudit(state);
|
|
109
|
+
if (!state.cycle)
|
|
110
|
+
fail('cycle_missing');
|
|
111
|
+
const attemptsPath = convergeAttemptStatePath(common, target);
|
|
112
|
+
const attempts = validateConvergeAttemptState(decodeRecoveryDocument(attemptFile.text), target, attemptsPath);
|
|
113
|
+
if (!isDeepStrictEqual(attempts.cycle, state.cycle))
|
|
114
|
+
fail('cycle_mismatch');
|
|
115
|
+
const proofs = await inspectVerifiedStaleReportReceipts(common, state.staleReportAudit ?? []);
|
|
116
|
+
const { binding, sourceDigests } = commonPredecessor(proofs, target, runId);
|
|
117
|
+
if (binding.cycleId !== state.cycle.id || !isDeepStrictEqual(binding.evidence.attempts.cycle, state.cycle)) {
|
|
118
|
+
fail('cycle_mismatch');
|
|
119
|
+
}
|
|
120
|
+
const claim = attempts.attempts.find(record => record.attempt === binding.attempt && record.source === 'claim');
|
|
121
|
+
if (!claim || claim.pid !== binding.launch.pid || binding.launch.pid !== binding.evidence.attempts.attempts
|
|
122
|
+
.find(record => record.attempt === binding.attempt && record.source === 'claim')?.pid)
|
|
123
|
+
fail('attempt_mismatch');
|
|
124
|
+
if (requireDeadOwner)
|
|
125
|
+
assertDeadOwner(binding.launch.pid);
|
|
126
|
+
const reportTarget = binding.evidence.report.run.target;
|
|
127
|
+
if (!['pr', 'patch'].includes(reportTarget.kind))
|
|
128
|
+
fail('retained_report_target_kind_mismatch');
|
|
129
|
+
if (reportTarget.repo?.toLowerCase() !== state.cycle.repo.toLowerCase())
|
|
130
|
+
fail('retained_report_repository_mismatch');
|
|
131
|
+
if (reportTarget.pr_number !== state.cycle.prNumber)
|
|
132
|
+
fail('retained_report_pull_request_mismatch');
|
|
133
|
+
if (reportTarget.head_sha !== binding.headSha)
|
|
134
|
+
fail('retained_report_head_mismatch');
|
|
135
|
+
if (!/^[a-f0-9]{40}$/.test(reportTarget.base_sha ?? ''))
|
|
136
|
+
fail('retained_report_base_missing');
|
|
137
|
+
if (!/^[a-f0-9]{64}$/.test(reportTarget.diff_sha256 ?? ''))
|
|
138
|
+
fail('retained_report_diff_missing');
|
|
139
|
+
const retainedReport = await readStaleObject(common, binding.reportSha256);
|
|
140
|
+
const successor = state.lastLaunch;
|
|
141
|
+
if (!successor?.runId || successor.status !== 'completed' || successor.attempt <= binding.attempt ||
|
|
142
|
+
successor.runId === binding.runId)
|
|
143
|
+
fail('successor_missing');
|
|
144
|
+
const successorClaim = attempts.attempts.find(record => record.attempt === successor.attempt && record.source === 'claim');
|
|
145
|
+
if (attempts.attemptsUsed !== successor.attempt || !successorClaim || successorClaim.pid !== successor.pid) {
|
|
146
|
+
fail('successor_attempt_mismatch');
|
|
147
|
+
}
|
|
148
|
+
const reconciliation = strongDeliveryReconciliationSchema.parse({ version: 2, runId: binding.runId,
|
|
149
|
+
reportJsonSha256: binding.reportSha256, headSha: binding.headSha, inputSha256: binding.inputSha256,
|
|
150
|
+
attempt: binding.attempt, round: binding.round, claimPid: binding.launch.pid, cycleId: state.cycle.id,
|
|
151
|
+
reconciledAt: '1970-01-01T00:00:00.000Z' });
|
|
152
|
+
return { common, target, runId, state, nativeSha256, attempts, attemptFile, attemptSha256: attemptFile.sha256,
|
|
153
|
+
sourceDigests, headSha: binding.headSha, reportSha256: binding.reportSha256, attempt: binding.attempt,
|
|
154
|
+
round: binding.round, reviewerHealth: binding.reviewerHealth, reconciliation,
|
|
155
|
+
targetKind: reportTarget.kind, baseSha: reportTarget.base_sha,
|
|
156
|
+
diffSha256: reportTarget.diff_sha256, reportBytes: retainedReport.raw.byteLength,
|
|
157
|
+
successor: { runId: successor.runId, attempt: successor.attempt, round: successor.round,
|
|
158
|
+
headSha: successor.headSha, inputSha256: successor.inputSha256 } };
|
|
159
|
+
}
|
|
160
|
+
async function localAuthority(common, target, runId) {
|
|
161
|
+
await assertNoPendingFreshReview(common, target);
|
|
162
|
+
const native = await loadConvergeRunStateEvidence(common, target);
|
|
163
|
+
if (!native)
|
|
164
|
+
fail('state_missing');
|
|
165
|
+
if (native.state.historicalDeliveryReconciliationAudit?.some(entry => historicalDeliveryManifest(entry).runId === runId))
|
|
166
|
+
fail('already_applied');
|
|
167
|
+
const attemptFile = await readStable(convergeAttemptStatePath(common, target));
|
|
168
|
+
return deriveLocalAuthority(common, target, runId, native.state, native.sha256, attemptFile, true);
|
|
169
|
+
}
|
|
170
|
+
function assertServerBinding(local, server) {
|
|
171
|
+
const cycle = local.state.cycle;
|
|
172
|
+
if (!cycle || server.origin !== endpoint(cycle.url) || server.runId.toLowerCase() !== local.runId.toLowerCase() ||
|
|
173
|
+
server.cycleId !== cycle.id || server.target.kind !== local.targetKind ||
|
|
174
|
+
server.target.repo.toLowerCase() !== cycle.repo.toLowerCase() || server.target.prNumber !== cycle.prNumber ||
|
|
175
|
+
server.target.headSha !== local.headSha || server.target.baseSha !== local.baseSha ||
|
|
176
|
+
server.target.diffSha256 !== local.diffSha256 || server.converge.target !== local.target ||
|
|
177
|
+
server.converge.attempt !== local.attempt || server.converge.round !== local.round ||
|
|
178
|
+
server.report.declaredSha256 !== local.reportSha256 || server.report.declaredBytes !== local.reportBytes) {
|
|
179
|
+
fail('retained_server_binding_mismatch');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function buildManifest(local, server, operationId, createdAt) {
|
|
183
|
+
assertServerBinding(local, server);
|
|
184
|
+
return historicalDeliveryReconciliationManifestSchema.parse({
|
|
185
|
+
kind: 'rcl-historical-delivery-reconciliation', version: 1, operationId, createdAt,
|
|
186
|
+
gitCommonDir: local.common, target: local.target, runId: local.runId,
|
|
187
|
+
nativeStateSha256: local.nativeSha256, attemptStateSha256: local.attemptSha256,
|
|
188
|
+
sourceStaleManifestSha256s: local.sourceDigests, successor: local.successor,
|
|
189
|
+
reconciliation: { ...local.reconciliation, reconciledAt: createdAt },
|
|
190
|
+
baseSha: server.target.baseSha, diffSha256: server.target.diffSha256,
|
|
191
|
+
reviewerHealth: local.reviewerHealth, server,
|
|
192
|
+
serverProjectionSha256: sha256(Buffer.from(serializeRecoveryDocument(server))),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/** Print-only qualification; callers may write the returned reviewed manifest separately. */
|
|
196
|
+
export async function previewHistoricalDeliveryReconciliation(input, gitCommonDir, sink, options = {}) {
|
|
197
|
+
const selection = selectionSchema.parse(input);
|
|
198
|
+
const common = await realpath(resolve(gitCommonDir));
|
|
199
|
+
const local = await localAuthority(common, selection.target, selection.runId);
|
|
200
|
+
const server = await readServerProjection(sink, local, options);
|
|
201
|
+
return buildManifest(local, server, randomUUID(), (options.now ?? (() => new Date()))().toISOString());
|
|
202
|
+
}
|
|
203
|
+
function nextState(before, entry, at) {
|
|
204
|
+
const { staleReportAudit, staleReportAuditCount, historicalDeliveryReconciliationAudit: audit = [], historicalDeliveryReconciliationAuditCount: _historicalCount, updatedAt: _updatedAt, ...rest } = before;
|
|
205
|
+
return {
|
|
206
|
+
...(staleReportAudit ? { staleReportAudit } : {}), ...rest,
|
|
207
|
+
historicalDeliveryReconciliationAudit: [...audit, entry],
|
|
208
|
+
historicalDeliveryReconciliationAuditCount: audit.length + 1,
|
|
209
|
+
...(staleReportAuditCount !== undefined ? { staleReportAuditCount } : {}), updatedAt: at,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function directory(common, manifest) {
|
|
213
|
+
return join(common, 'rcl-historical-delivery-reconciliations', manifest.operationId);
|
|
214
|
+
}
|
|
215
|
+
function receiptFor(manifest, manifestSha256, afterStateSha256) {
|
|
216
|
+
return historicalDeliveryReconciliationReceiptSchema.parse({
|
|
217
|
+
kind: 'rcl-historical-delivery-reconciliation-receipt', version: 1,
|
|
218
|
+
operationId: manifest.operationId, runId: manifest.runId, manifestSha256,
|
|
219
|
+
beforeStateSha256: manifest.nativeStateSha256, afterStateSha256,
|
|
220
|
+
attemptStateSha256: manifest.attemptStateSha256,
|
|
221
|
+
sourceStaleManifestSha256s: manifest.sourceStaleManifestSha256s,
|
|
222
|
+
serverProjectionSha256: manifest.serverProjectionSha256,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
/** Reverify every authority source under the target lock, then append one local receipt atomically. */
|
|
226
|
+
export async function applyHistoricalDeliveryReconciliation(input, gitCommonDir, sink, options = {}) {
|
|
227
|
+
const pinned = applySchema.parse(input);
|
|
228
|
+
const selectedManifest = await readStable(pinned.manifest, 128 * 1024);
|
|
229
|
+
if (selectedManifest.sha256 !== pinned.manifestSha256)
|
|
230
|
+
fail('manifest_digest_mismatch');
|
|
231
|
+
const manifest = historicalDeliveryReconciliationManifestSchema.parse(decodeRecoveryDocument(selectedManifest.text));
|
|
232
|
+
if (selectedManifest.text !== serializeRecoveryDocument(manifest))
|
|
233
|
+
fail('manifest_noncanonical');
|
|
234
|
+
const common = await realpath(resolve(gitCommonDir));
|
|
235
|
+
if (manifest.gitCommonDir !== common)
|
|
236
|
+
fail('repository_mismatch');
|
|
237
|
+
return withRecoveryTarget(common, manifest.target, async (ownership) => {
|
|
238
|
+
const currentFile = await readStable(convergeRunStatePath(common, manifest.target));
|
|
239
|
+
const current = await loadConvergeRunStateEvidence(common, manifest.target);
|
|
240
|
+
if (!current || current.sha256 !== currentFile.sha256)
|
|
241
|
+
fail('state_missing');
|
|
242
|
+
validateHistoricalDeliveryReconciliationAudit(current.state);
|
|
243
|
+
await verifyHistoricalDeliveryReconciliations(common, current.state);
|
|
244
|
+
const entry = {
|
|
245
|
+
manifestJson: selectedManifest.text, manifestSha256: selectedManifest.sha256,
|
|
246
|
+
};
|
|
247
|
+
const prior = current.state.historicalDeliveryReconciliationAudit?.find(entry => historicalDeliveryManifest(entry).runId === manifest.runId);
|
|
248
|
+
if (prior) {
|
|
249
|
+
if (!isDeepStrictEqual(prior, entry))
|
|
250
|
+
fail('operation_conflict');
|
|
251
|
+
return 'unchanged';
|
|
252
|
+
}
|
|
253
|
+
await assertNoPendingFreshReview(common, manifest.target);
|
|
254
|
+
if (current.sha256 !== manifest.nativeStateSha256)
|
|
255
|
+
fail('state_changed');
|
|
256
|
+
const attemptFile = await readStable(convergeAttemptStatePath(common, manifest.target));
|
|
257
|
+
const local = await deriveLocalAuthority(common, manifest.target, manifest.runId, current.state, current.sha256, attemptFile, true);
|
|
258
|
+
const server = await readServerProjection(sink, local, options);
|
|
259
|
+
assertServerBinding(local, server);
|
|
260
|
+
const expected = buildManifest(local, server, manifest.operationId, manifest.createdAt);
|
|
261
|
+
if (!isDeepStrictEqual(expected, manifest))
|
|
262
|
+
fail('manifest_binding_mismatch');
|
|
263
|
+
const next = nextState(current.state, entry, manifest.createdAt);
|
|
264
|
+
validateHistoricalDeliveryReconciliationAudit(next);
|
|
265
|
+
const afterBytes = Buffer.from(serializeRecoveryDocument(next));
|
|
266
|
+
const serverBytes = Buffer.from(serializeRecoveryDocument(server));
|
|
267
|
+
if (sha256(serverBytes) !== manifest.serverProjectionSha256)
|
|
268
|
+
fail('server_projection_digest_mismatch');
|
|
269
|
+
const receipt = receiptFor(manifest, selectedManifest.sha256, sha256(afterBytes));
|
|
270
|
+
const dir = directory(common, manifest);
|
|
271
|
+
await prepareLockRoot(dirname(dir));
|
|
272
|
+
await syncDirectory(common);
|
|
273
|
+
await prepareLockRoot(dir);
|
|
274
|
+
await syncDirectory(dirname(dir));
|
|
275
|
+
await retain(join(dir, 'manifest.json'), selectedManifest.raw);
|
|
276
|
+
await retain(join(dir, 'native-before.json'), currentFile.raw);
|
|
277
|
+
await retain(join(dir, 'attempts-before.json'), attemptFile.raw);
|
|
278
|
+
await retain(join(dir, 'server-projection.json'), serverBytes);
|
|
279
|
+
await retain(join(dir, 'complete.json'), Buffer.from(serializeRecoveryDocument(receipt)));
|
|
280
|
+
const finalState = await selected(convergeRunStatePath(common, manifest.target), manifest.nativeStateSha256);
|
|
281
|
+
const finalAttempts = await selected(convergeAttemptStatePath(common, manifest.target), manifest.attemptStateSha256);
|
|
282
|
+
const finalLocal = await deriveLocalAuthority(common, manifest.target, manifest.runId, decodeRecoveryDocument(finalState.text), finalState.sha256, finalAttempts, true);
|
|
283
|
+
const finalServer = await readServerProjection(sink, finalLocal, options);
|
|
284
|
+
assertServerBinding(finalLocal, finalServer);
|
|
285
|
+
if (!isDeepStrictEqual(buildManifest(finalLocal, finalServer, manifest.operationId, manifest.createdAt), manifest)) {
|
|
286
|
+
fail('manifest_binding_mismatch');
|
|
287
|
+
}
|
|
288
|
+
await verifyHistoricalDeliveryReconciliations(common, next);
|
|
289
|
+
await writeState(common, next, ownership);
|
|
290
|
+
await selected(convergeRunStatePath(common, manifest.target), sha256(afterBytes));
|
|
291
|
+
return 'applied';
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/** Local fail-closed verification used before claims and report admission. */
|
|
295
|
+
export async function verifyHistoricalDeliveryReconciliations(common, state) {
|
|
296
|
+
validateHistoricalDeliveryReconciliationAudit(state);
|
|
297
|
+
const audit = state.historicalDeliveryReconciliationAudit ?? [];
|
|
298
|
+
if (audit.length === 0)
|
|
299
|
+
return;
|
|
300
|
+
const root = join(common, 'rcl-historical-delivery-reconciliations');
|
|
301
|
+
await inspectRecoveryDirectory(root, true);
|
|
302
|
+
const prefix = [];
|
|
303
|
+
for (const entry of audit) {
|
|
304
|
+
const manifest = historicalDeliveryManifest(entry);
|
|
305
|
+
const dir = directory(common, manifest);
|
|
306
|
+
await inspectRecoveryDirectory(dir, true);
|
|
307
|
+
await selected(join(dir, 'manifest.json'), entry.manifestSha256);
|
|
308
|
+
const beforeFile = await selected(join(dir, 'native-before.json'), manifest.nativeStateSha256);
|
|
309
|
+
const before = decodeRecoveryDocument(beforeFile.text);
|
|
310
|
+
if (!isDeepStrictEqual(before.historicalDeliveryReconciliationAudit ?? [], prefix))
|
|
311
|
+
fail('audit_prefix');
|
|
312
|
+
const attemptFile = await selected(join(dir, 'attempts-before.json'), manifest.attemptStateSha256);
|
|
313
|
+
const serverFile = await selected(join(dir, 'server-projection.json'), manifest.serverProjectionSha256);
|
|
314
|
+
const server = historicalServerProjectionSchema.parse(decodeRecoveryDocument(serverFile.text));
|
|
315
|
+
const local = await deriveLocalAuthority(common, manifest.target, manifest.runId, before, beforeFile.sha256, attemptFile, false);
|
|
316
|
+
assertServerBinding(local, server);
|
|
317
|
+
if (!isDeepStrictEqual(buildManifest(local, server, manifest.operationId, manifest.createdAt), manifest)) {
|
|
318
|
+
fail('retained_source_mismatch');
|
|
319
|
+
}
|
|
320
|
+
const after = Buffer.from(serializeRecoveryDocument(nextState(before, entry, manifest.createdAt)));
|
|
321
|
+
const receipt = receiptFor(manifest, entry.manifestSha256, sha256(after));
|
|
322
|
+
await selected(join(dir, 'complete.json'), sha256(Buffer.from(serializeRecoveryDocument(receipt))));
|
|
323
|
+
prefix.push(entry);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
//# sourceMappingURL=historical-delivery-reconciliation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historical-delivery-reconciliation.js","sourceRoot":"","sources":["../../src/converge/historical-delivery-reconciliation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,0BAA0B,EAC1B,8CAA8C,EAC9C,6CAA6C,EAC7C,gCAAgC,EAChC,6CAA6C,GAG9C,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,kC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CAAC,EAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAClG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -19,6 +19,8 @@ import { scrubText } from '../telemetry/scrub.js';
|
|
|
19
19
|
import { verifyBoundFixRecovery } from './bound-fix-recovery.js';
|
|
20
20
|
import { boundFixRecoverySourceSchema } from './bound-fix-recovery-source.js';
|
|
21
21
|
import { createOriginalLaunch, encodeOriginalLaunch, remainingOriginalBudget } from '../dispatch/original-launch.js';
|
|
22
|
+
import { verifyCyclePendingFinalization } from './pending-finalization-receipt.js';
|
|
23
|
+
import { captureCurrentProcessIdentity } from './process-identity.js';
|
|
22
24
|
export class ReviewLaunchRefused extends Error {
|
|
23
25
|
code;
|
|
24
26
|
constructor(code, message) {
|
|
@@ -120,6 +122,18 @@ async function requireLaunch(options, state, attemptsUsed) {
|
|
|
120
122
|
return { round };
|
|
121
123
|
}
|
|
122
124
|
if (previous.status !== 'completed') {
|
|
125
|
+
if (state.cycle && ((previous.status === 'pending' && !previous.runId) || previous.pendingRecovery)) {
|
|
126
|
+
if (!await verifyCyclePendingFinalization(options.gitCommonDir, state, previous)) {
|
|
127
|
+
refuse('cycle_pending_recovery_required', 'The previous cycle dispatch is not terminal. Authenticate and finalize its pending recovery before launching a successor.');
|
|
128
|
+
}
|
|
129
|
+
if (previous.headSha === options.headSha && previous.inputSha256 === options.inputSha256) {
|
|
130
|
+
refuse('cycle_pending_inputs_unchanged', 'The recovered dispatch remains unknown; its successor must use materially changed exact review inputs.');
|
|
131
|
+
}
|
|
132
|
+
if (!options.retryReason) {
|
|
133
|
+
refuse('dispatch_unknown', 'The recovered dispatch remains spent; supply a bounded retry reason for its successor.');
|
|
134
|
+
}
|
|
135
|
+
return { round };
|
|
136
|
+
}
|
|
123
137
|
if (!options.retryReason)
|
|
124
138
|
refuse('dispatch_unknown', 'Previous dispatch is unknown; no automatic retry. Supply a bounded retry reason only after recovery.');
|
|
125
139
|
return { round };
|
|
@@ -280,6 +294,9 @@ async function guardReviewLaunchOwned(options, ownership) {
|
|
|
280
294
|
else {
|
|
281
295
|
await assertNoPendingFreshReview(options.gitCommonDir, options.target);
|
|
282
296
|
}
|
|
297
|
+
const processIdentity = process.platform === 'linux' || process.platform === 'darwin' || process.platform === 'win32'
|
|
298
|
+
? await captureCurrentProcessIdentity()
|
|
299
|
+
: undefined;
|
|
283
300
|
const claim = await claimConvergeAttempt({
|
|
284
301
|
gitCommonDir: options.gitCommonDir,
|
|
285
302
|
target: options.target,
|
|
@@ -290,6 +307,8 @@ async function guardReviewLaunchOwned(options, ownership) {
|
|
|
290
307
|
try {
|
|
291
308
|
state = await loadConvergeRunState(options.gitCommonDir, options.target) ?? initialConvergeRunState(options.target);
|
|
292
309
|
await verifyStaleReportReceipts(options.gitCommonDir, state.staleReportAudit ?? []);
|
|
310
|
+
const { verifyHistoricalDeliveryReconciliations } = await import('./historical-delivery-reconciliation.js');
|
|
311
|
+
await verifyHistoricalDeliveryReconciliations(options.gitCommonDir, state);
|
|
293
312
|
await verifyTerminalRejections(options.gitCommonDir, state);
|
|
294
313
|
}
|
|
295
314
|
catch (error) {
|
|
@@ -331,13 +350,12 @@ async function guardReviewLaunchOwned(options, ownership) {
|
|
|
331
350
|
await options.originalLaunch.beforeClaim(preparedOriginal, ownership);
|
|
332
351
|
assertOriginalLive();
|
|
333
352
|
}
|
|
334
|
-
//
|
|
335
|
-
// modes keep their own
|
|
336
|
-
|
|
337
|
-
const ordinaryLaunch = !options.startOver && !state.cycle && !options.originalLaunch &&
|
|
338
|
-
!options.legacyRetry && !options.boundFixRecovery;
|
|
353
|
+
// Retain normal dispatch inputs, including cycle-backed launches. Bound
|
|
354
|
+
// original/retry recovery modes keep their own immutable input contract.
|
|
355
|
+
const ordinaryLaunch = !options.originalLaunch && !options.legacyRetry && !options.boundFixRecovery;
|
|
339
356
|
const retained = ordinaryLaunch ? await options.beforeClaim?.(Object.freeze({ target: options.target, round,
|
|
340
|
-
attempt: (attempts?.attemptsUsed ?? 0) + 1
|
|
357
|
+
attempt: (attempts?.attemptsUsed ?? 0) + 1,
|
|
358
|
+
...(state.cycle ? { cycleId: state.cycle.id } : {}) }), ownership) : undefined;
|
|
341
359
|
const ordinaryInputs = retained === undefined ? undefined : ordinaryLaunchInputsBindingSchema.parse(retained.ordinaryInputs);
|
|
342
360
|
if (retryProof)
|
|
343
361
|
await retainLegacyRetry(options.gitCommonDir, retryProof);
|
|
@@ -346,6 +364,7 @@ async function guardReviewLaunchOwned(options, ownership) {
|
|
|
346
364
|
status: 'pending', attempt: (attempts?.attemptsUsed ?? 0) + 1, round,
|
|
347
365
|
headSha: options.headSha, inputSha256: options.inputSha256,
|
|
348
366
|
startedAt: new Date().toISOString(), pid: process.pid,
|
|
367
|
+
...(processIdentity ? { processIdentity } : {}),
|
|
349
368
|
...(ordinaryInputs ? { ordinaryInputs } : {}),
|
|
350
369
|
...(preparedOriginal ? { retainedOriginal: { version: 1, runId: preparedOriginal.launch.runId,
|
|
351
370
|
planDigest: preparedOriginal.launch.planDigest, capturedInputsSha256: preparedOriginal.launch.capturedInputsSha256 } } : {}),
|