codex-workflow-v2 2.0.0-beta.2 → 2.0.0-beta.4
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 +35 -2
- package/dist/src/alpha6/adoption.js +13 -3
- package/dist/src/alpha6/adoption.js.map +1 -1
- package/dist/src/alpha6/handoff.d.ts +21 -0
- package/dist/src/alpha6/handoff.js +100 -19
- package/dist/src/alpha6/handoff.js.map +1 -1
- package/dist/src/alpha6/milestone.d.ts +2 -0
- package/dist/src/alpha6/milestone.js +15 -0
- package/dist/src/alpha6/milestone.js.map +1 -1
- package/dist/src/alpha6/plan-risk.d.ts +1 -0
- package/dist/src/alpha6/plan-risk.js +6 -0
- package/dist/src/alpha6/plan-risk.js.map +1 -1
- package/dist/src/cli.js +188 -65
- package/dist/src/cli.js.map +1 -1
- package/dist/src/contracts.d.ts +111 -5
- package/dist/src/contracts.js +1 -1
- package/dist/src/credential-output.d.ts +10 -0
- package/dist/src/credential-output.js +73 -0
- package/dist/src/credential-output.js.map +1 -0
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lifecycle/canonical-hash.d.ts +6 -0
- package/dist/src/lifecycle/canonical-hash.js +24 -0
- package/dist/src/lifecycle/canonical-hash.js.map +1 -0
- package/dist/src/lifecycle/catalog.d.ts +26 -0
- package/dist/src/lifecycle/catalog.js +208 -0
- package/dist/src/lifecycle/catalog.js.map +1 -0
- package/dist/src/lifecycle/compiler-inspection.d.ts +48 -0
- package/dist/src/lifecycle/compiler-inspection.js +29 -0
- package/dist/src/lifecycle/compiler-inspection.js.map +1 -0
- package/dist/src/lifecycle/core-static-readiness.d.ts +6 -0
- package/dist/src/lifecycle/core-static-readiness.js +130 -0
- package/dist/src/lifecycle/core-static-readiness.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan-authority.d.ts +53 -0
- package/dist/src/lifecycle/corrective-replan-authority.js +139 -0
- package/dist/src/lifecycle/corrective-replan-authority.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan-binding-manifest.d.ts +21 -0
- package/dist/src/lifecycle/corrective-replan-binding-manifest.js +35 -0
- package/dist/src/lifecycle/corrective-replan-binding-manifest.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan-credential-core.d.ts +86 -0
- package/dist/src/lifecycle/corrective-replan-credential-core.js +534 -0
- package/dist/src/lifecycle/corrective-replan-credential-core.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan-credential-schema.d.ts +17 -0
- package/dist/src/lifecycle/corrective-replan-credential-schema.js +44 -0
- package/dist/src/lifecycle/corrective-replan-credential-schema.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan-credentials.d.ts +47 -0
- package/dist/src/lifecycle/corrective-replan-credentials.js +103 -0
- package/dist/src/lifecycle/corrective-replan-credentials.js.map +1 -0
- package/dist/src/lifecycle/corrective-replan.d.ts +64 -0
- package/dist/src/lifecycle/corrective-replan.js +548 -0
- package/dist/src/lifecycle/corrective-replan.js.map +1 -0
- package/dist/src/lifecycle/evaluator.d.ts +2 -0
- package/dist/src/lifecycle/evaluator.js +35 -0
- package/dist/src/lifecycle/evaluator.js.map +1 -0
- package/dist/src/lifecycle/fingerprint.d.ts +31 -0
- package/dist/src/lifecycle/fingerprint.js +388 -0
- package/dist/src/lifecycle/fingerprint.js.map +1 -0
- package/dist/src/lifecycle/immutable.d.ts +1 -0
- package/dist/src/lifecycle/immutable.js +10 -0
- package/dist/src/lifecycle/immutable.js.map +1 -0
- package/dist/src/lifecycle/implementation-table.d.ts +29 -0
- package/dist/src/lifecycle/implementation-table.js +87 -0
- package/dist/src/lifecycle/implementation-table.js.map +1 -0
- package/dist/src/lifecycle/index.d.ts +4 -0
- package/dist/src/lifecycle/index.js +5 -0
- package/dist/src/lifecycle/index.js.map +1 -0
- package/dist/src/lifecycle/schema-artifact.d.ts +12 -0
- package/dist/src/lifecycle/schema-artifact.js +214 -0
- package/dist/src/lifecycle/schema-artifact.js.map +1 -0
- package/dist/src/lifecycle/semantic-registry.d.ts +6 -0
- package/dist/src/lifecycle/semantic-registry.js +489 -0
- package/dist/src/lifecycle/semantic-registry.js.map +1 -0
- package/dist/src/lifecycle/types.d.ts +718 -0
- package/dist/src/lifecycle/types.js +4 -0
- package/dist/src/lifecycle/types.js.map +1 -0
- package/dist/src/observation.d.ts +20 -0
- package/dist/src/observation.js +171 -0
- package/dist/src/observation.js.map +1 -0
- package/dist/src/state/corrective-replan-executor.d.ts +64 -0
- package/dist/src/state/corrective-replan-executor.js +598 -0
- package/dist/src/state/corrective-replan-executor.js.map +1 -0
- package/dist/src/state/corrective-replan-public-schema.d.ts +3 -0
- package/dist/src/state/corrective-replan-public-schema.js +43 -0
- package/dist/src/state/corrective-replan-public-schema.js.map +1 -0
- package/dist/src/state/corrective-replan-public.d.ts +95 -0
- package/dist/src/state/corrective-replan-public.js +618 -0
- package/dist/src/state/corrective-replan-public.js.map +1 -0
- package/dist/src/state/corrective-replan-transaction.d.ts +158 -0
- package/dist/src/state/corrective-replan-transaction.js +723 -0
- package/dist/src/state/corrective-replan-transaction.js.map +1 -0
- package/dist/src/state/corrective-yield-executor.d.ts +31 -0
- package/dist/src/state/corrective-yield-executor.js +236 -0
- package/dist/src/state/corrective-yield-executor.js.map +1 -0
- package/dist/src/state/corrective-yield-transaction.d.ts +97 -0
- package/dist/src/state/corrective-yield-transaction.js +591 -0
- package/dist/src/state/corrective-yield-transaction.js.map +1 -0
- package/dist/src/state/lock.d.ts +75 -3
- package/dist/src/state/lock.js +582 -30
- package/dist/src/state/lock.js.map +1 -1
- package/dist/src/state/store.d.ts +3 -0
- package/dist/src/state/store.js +65 -12
- package/dist/src/state/store.js.map +1 -1
- package/dist/src/transition-core.d.ts +67 -0
- package/dist/src/transition-core.js +318 -0
- package/dist/src/transition-core.js.map +1 -0
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/workflow.d.ts +34 -22
- package/dist/src/workflow.js +486 -141
- package/dist/src/workflow.js.map +1 -1
- package/docs/lifecycle/state-machine-stabilization.md +641 -0
- package/docs/release.md +4 -2
- package/docs/updating-existing-project.md +9 -0
- package/package.json +4 -1
- package/schemas/adoption-posture-event.schema.json +1 -1
- package/schemas/context-envelope.schema.json +1 -1
- package/schemas/corrective-replan-credentials.private.schema.json +98 -0
- package/schemas/corrective-replan-execution-event.private.schema.json +53 -0
- package/schemas/corrective-replan-public.schema.json +142 -0
- package/schemas/corrective-replan-task-transaction.private.schema.json +151 -0
- package/schemas/corrective-yield-task-transaction.private.schema.json +98 -0
- package/schemas/remediation-event.schema.json +11 -1
- package/schemas/task-handoff-event.schema.json +1 -1
- package/schemas/transition-definition.schema.json +2609 -0
- package/schemas/transition-payloads.schema.json +140 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lifecycle/types.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAU,CAAC;AAC1C,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAU,CAAC;AAC/D,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AdoptionPostureEvent, ProjectRecord, WorkflowObservation, WriterLease } from './contracts.js';
|
|
2
|
+
import type { RepositoryIdentity } from './repository.js';
|
|
3
|
+
import type { FileStateStore } from './state/store.js';
|
|
4
|
+
export interface WorkflowObservationBoundary {
|
|
5
|
+
identity: RepositoryIdentity;
|
|
6
|
+
project: ProjectRecord | null;
|
|
7
|
+
currentAdoptionPosture: AdoptionPostureEvent | null;
|
|
8
|
+
leases: WriterLease[];
|
|
9
|
+
observation: WorkflowObservation;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Reads only the persistence boundary needed to decide whether a coherent lifecycle snapshot can
|
|
13
|
+
* be loaded. It deliberately does not register a project, recover a journal, initialize adoption,
|
|
14
|
+
* or construct a WriterLockManager.
|
|
15
|
+
*/
|
|
16
|
+
export declare function inspectWorkflowObservationBoundary(options: {
|
|
17
|
+
store: FileStateStore;
|
|
18
|
+
identity: RepositoryIdentity;
|
|
19
|
+
now: Date;
|
|
20
|
+
}): WorkflowObservationBoundary;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { existsSync, readdirSync, realpathSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readCurrentAdoptionPosture } from './alpha6/adoption.js';
|
|
4
|
+
import { listMilestoneTransactionJournals } from './alpha6/journal.js';
|
|
5
|
+
import { assertNoSymlinkPathComponents } from './alpha6/store-sidecars.js';
|
|
6
|
+
import { listProjectTransactions } from './beta1/project-transaction.js';
|
|
7
|
+
import { listCoreTaskOperationMutexes, listWriterLeases, toPublicCoreTaskOperation, toPublicWriterLease, } from './state/lock.js';
|
|
8
|
+
import { inspectCorrectiveReplanTaskTransactions } from './state/corrective-replan-transaction.js';
|
|
9
|
+
import { inspectCorrectiveYieldTaskTransactions } from './state/corrective-yield-transaction.js';
|
|
10
|
+
/**
|
|
11
|
+
* Reads only the persistence boundary needed to decide whether a coherent lifecycle snapshot can
|
|
12
|
+
* be loaded. It deliberately does not register a project, recover a journal, initialize adoption,
|
|
13
|
+
* or construct a WriterLockManager.
|
|
14
|
+
*/
|
|
15
|
+
export function inspectWorkflowObservationBoundary(options) {
|
|
16
|
+
const { store, identity, now } = options;
|
|
17
|
+
const projectRoot = store.projectRoot(identity.projectId);
|
|
18
|
+
const projectFile = path.join(projectRoot, 'project.json');
|
|
19
|
+
const lockRoot = store.lockRoot(identity.projectId);
|
|
20
|
+
const stateRootPresent = existsSync(store.root);
|
|
21
|
+
const projectRootPresent = existsSync(projectRoot);
|
|
22
|
+
const lockRootPresent = existsSync(lockRoot);
|
|
23
|
+
const missingRegistration = !existsSync(projectFile);
|
|
24
|
+
const pendingProjectTransactions = observeProjectTransactions(projectRoot, identity.projectId);
|
|
25
|
+
const pendingMilestoneTransactions = observeMilestoneTransactions(store, identity.projectId);
|
|
26
|
+
const replanTransactions = inspectCorrectiveReplanTaskTransactions(projectRoot, store.root);
|
|
27
|
+
const yieldTransactions = inspectCorrectiveYieldTaskTransactions(projectRoot, store.root);
|
|
28
|
+
const taskTransactions = {
|
|
29
|
+
pending: [...replanTransactions.pending, ...yieldTransactions.pending]
|
|
30
|
+
.sort((left, right) => left.taskId.localeCompare(right.taskId) || left.transactionId.localeCompare(right.transactionId)),
|
|
31
|
+
corrupt: [...replanTransactions.corrupt, ...yieldTransactions.corrupt]
|
|
32
|
+
.sort((left, right) => left.taskId.localeCompare(right.taskId) || left.transactionId.localeCompare(right.transactionId)),
|
|
33
|
+
};
|
|
34
|
+
const pendingTaskTransitionIds = [...new Set(taskTransactions.pending.map((transaction) => transaction.transitionId))];
|
|
35
|
+
const mixedPendingTaskTransitions = pendingTaskTransitionIds.length > 1;
|
|
36
|
+
const leases = listWriterLeases(lockRoot);
|
|
37
|
+
const coreTaskOperations = listCoreTaskOperationMutexes(lockRoot, store.root)
|
|
38
|
+
.map((mutex) => toPublicCoreTaskOperation(mutex, now));
|
|
39
|
+
const orphanCoreTaskOperations = coreTaskOperations.filter((operation) => !taskTransactions.pending.some((transaction) => transaction.taskId === operation.entityId && transaction.transactionId === operation.operationId));
|
|
40
|
+
const project = !missingRegistration && pendingProjectTransactions.length === 0
|
|
41
|
+
? store.readProject(identity.projectId)
|
|
42
|
+
: null;
|
|
43
|
+
const repositoryRootBound = project?.repositoryRoots.includes(identity.repositoryRoot) ?? false;
|
|
44
|
+
const adoptionAssessed = pendingProjectTransactions.length === 0
|
|
45
|
+
&& pendingMilestoneTransactions.length === 0
|
|
46
|
+
&& taskTransactions.pending.length === 0
|
|
47
|
+
&& taskTransactions.corrupt.length === 0
|
|
48
|
+
&& orphanCoreTaskOperations.length === 0;
|
|
49
|
+
const currentAdoptionPosture = adoptionAssessed && stateRootPresent
|
|
50
|
+
? readCurrentAdoptionPosture(store, identity.projectId)
|
|
51
|
+
: null;
|
|
52
|
+
const missingAdoption = adoptionAssessed && currentAdoptionPosture === null;
|
|
53
|
+
const observedLeases = leases.map((lease) => toPublicWriterLease(lease, now));
|
|
54
|
+
const activeLeases = observedLeases.filter((lease) => !lease.stale);
|
|
55
|
+
const staleLeases = observedLeases.filter((lease) => lease.stale);
|
|
56
|
+
const reasonCodes = [];
|
|
57
|
+
if (missingRegistration)
|
|
58
|
+
reasonCodes.push('PROJECT_REGISTRATION_MISSING');
|
|
59
|
+
if (project && !repositoryRootBound)
|
|
60
|
+
reasonCodes.push('PROJECT_REPOSITORY_ROOT_UNBOUND');
|
|
61
|
+
if (pendingProjectTransactions.length > 0)
|
|
62
|
+
reasonCodes.push('PROJECT_RECOVERY_REQUIRED');
|
|
63
|
+
if (pendingMilestoneTransactions.length > 0)
|
|
64
|
+
reasonCodes.push('MILESTONE_RECOVERY_REQUIRED');
|
|
65
|
+
if (taskTransactions.pending.length > 0)
|
|
66
|
+
reasonCodes.push('TASK_RECOVERY_REQUIRED');
|
|
67
|
+
if (taskTransactions.corrupt.length > 0)
|
|
68
|
+
reasonCodes.push('TASK_TRANSACTION_INTEGRITY_FAILED');
|
|
69
|
+
if (orphanCoreTaskOperations.some((operation) => !operation.stale))
|
|
70
|
+
reasonCodes.push('TASK_OPERATION_IN_PROGRESS');
|
|
71
|
+
if (orphanCoreTaskOperations.some((operation) => operation.stale))
|
|
72
|
+
reasonCodes.push('STALE_TASK_OPERATION');
|
|
73
|
+
if (activeLeases.length > 0)
|
|
74
|
+
reasonCodes.push('ACTIVE_WRITER_LEASE');
|
|
75
|
+
if (staleLeases.length > 0)
|
|
76
|
+
reasonCodes.push('STALE_WRITER_LEASE');
|
|
77
|
+
if (missingAdoption)
|
|
78
|
+
reasonCodes.push('ADOPTION_MISSING');
|
|
79
|
+
const blocked = missingRegistration
|
|
80
|
+
|| (project !== null && !repositoryRootBound)
|
|
81
|
+
|| pendingProjectTransactions.length > 0
|
|
82
|
+
|| taskTransactions.corrupt.length > 0
|
|
83
|
+
|| mixedPendingTaskTransitions
|
|
84
|
+
|| orphanCoreTaskOperations.length > 0;
|
|
85
|
+
const repairable = taskTransactions.pending.length > 0
|
|
86
|
+
|| pendingMilestoneTransactions.length > 0
|
|
87
|
+
|| staleLeases.length > 0;
|
|
88
|
+
const kind = blocked ? 'blocked' : repairable ? 'repair' : 'assessment';
|
|
89
|
+
const repair = kind !== 'repair'
|
|
90
|
+
? null
|
|
91
|
+
: taskTransactions.pending.length > 0
|
|
92
|
+
? {
|
|
93
|
+
command: pendingTaskTransitionIds[0] === 'task.coordination.corrective-yield'
|
|
94
|
+
? 'task corrective-yield-recover'
|
|
95
|
+
: 'task corrective-replan-recover',
|
|
96
|
+
cataloged: false,
|
|
97
|
+
available: true,
|
|
98
|
+
projectId: identity.projectId,
|
|
99
|
+
taskIds: [...new Set(taskTransactions.pending.map((transaction) => transaction.taskId))].sort(),
|
|
100
|
+
transactionIds: taskTransactions.pending.map((transaction) => transaction.transactionId).sort(),
|
|
101
|
+
}
|
|
102
|
+
: pendingMilestoneTransactions.length > 0
|
|
103
|
+
? {
|
|
104
|
+
command: 'milestone recover',
|
|
105
|
+
cataloged: false,
|
|
106
|
+
projectId: identity.projectId,
|
|
107
|
+
milestoneIds: [...new Set(pendingMilestoneTransactions.map((transaction) => transaction.milestoneId))].sort(),
|
|
108
|
+
transactionIds: pendingMilestoneTransactions.map((transaction) => transaction.transactionId).sort(),
|
|
109
|
+
}
|
|
110
|
+
: {
|
|
111
|
+
command: 'locks repair',
|
|
112
|
+
cataloged: false,
|
|
113
|
+
projectId: identity.projectId,
|
|
114
|
+
entityIds: staleLeases.map((lease) => lease.entityId).sort(),
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
identity,
|
|
118
|
+
project,
|
|
119
|
+
currentAdoptionPosture,
|
|
120
|
+
leases,
|
|
121
|
+
observation: {
|
|
122
|
+
kind,
|
|
123
|
+
reasonCodes,
|
|
124
|
+
stateRootPresent,
|
|
125
|
+
projectRootPresent,
|
|
126
|
+
lockRootPresent,
|
|
127
|
+
missingRegistration,
|
|
128
|
+
repositoryRootBound,
|
|
129
|
+
adoptionAssessed,
|
|
130
|
+
missingAdoption,
|
|
131
|
+
pendingProjectTransactions,
|
|
132
|
+
pendingMilestoneTransactions,
|
|
133
|
+
pendingTaskTransactions: taskTransactions.pending,
|
|
134
|
+
corruptTaskTransactions: taskTransactions.corrupt,
|
|
135
|
+
coreTaskOperations,
|
|
136
|
+
leases: observedLeases,
|
|
137
|
+
availableRepairTransitionId: null,
|
|
138
|
+
repair,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function observeProjectTransactions(projectRoot, projectId) {
|
|
143
|
+
return listProjectTransactions(projectRoot, projectId)
|
|
144
|
+
.map((transaction) => ({ ...transaction }))
|
|
145
|
+
.sort((left, right) => left.preparedAt.localeCompare(right.preparedAt)
|
|
146
|
+
|| left.transactionId.localeCompare(right.transactionId));
|
|
147
|
+
}
|
|
148
|
+
function observeMilestoneTransactions(store, projectId) {
|
|
149
|
+
const milestonesRoot = path.join(store.projectRoot(projectId), 'milestones');
|
|
150
|
+
if (!existsSync(milestonesRoot))
|
|
151
|
+
return [];
|
|
152
|
+
assertNoSymlinkPathComponents(milestonesRoot, {
|
|
153
|
+
label: 'Milestones observation root',
|
|
154
|
+
requireLeaf: true,
|
|
155
|
+
trustedRoot: store.root,
|
|
156
|
+
});
|
|
157
|
+
return readdirSync(milestonesRoot, { withFileTypes: true })
|
|
158
|
+
.filter((entry) => entry.isDirectory())
|
|
159
|
+
.flatMap((entry) => listMilestoneTransactionJournals(realpathSync(path.join(milestonesRoot, entry.name)), {
|
|
160
|
+
expectedMilestoneId: entry.name,
|
|
161
|
+
}).map((journal) => ({
|
|
162
|
+
milestoneId: journal.milestoneId,
|
|
163
|
+
transactionId: journal.transactionId,
|
|
164
|
+
phase: journal.phase,
|
|
165
|
+
preparedAt: journal.preparedAt,
|
|
166
|
+
updatedAt: journal.updatedAt,
|
|
167
|
+
})))
|
|
168
|
+
.sort((left, right) => left.preparedAt.localeCompare(right.preparedAt)
|
|
169
|
+
|| left.transactionId.localeCompare(right.transactionId));
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observation.js","sourceRoot":"","sources":["../../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uCAAuC,EAAE,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,sCAAsC,EAAE,MAAM,yCAAyC,CAAC;AAWjG;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAAC,OAIlD;IACC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACzC,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC1D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC3D,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,gB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,CAAC,gCAAgC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE;QACxG,mBAAmB,EAAE,KAAK,CAAC,IAAI;KAChC,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACnB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC,CAAC,CAAC;SACH,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC;WACjE,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { PlanRiskAuditDecision, PlanRiskAuditStepClassification, TaskPlanInput, TaskState } from '../contracts.js';
|
|
2
|
+
import type { CorrectiveReplanCredentialKernel, ReceiptHandle, StoredPlanValidationEventHandle } from '../lifecycle/corrective-replan-credential-core.js';
|
|
3
|
+
import { type CoreTaskOperationHandle } from './lock.js';
|
|
4
|
+
import { CorrectiveReplanTaskTransactionStore, type CorrectiveReplanTaskTransactionJournal } from './corrective-replan-transaction.js';
|
|
5
|
+
type JsonRecord = Record<string, unknown>;
|
|
6
|
+
export interface CorrectiveReplanRiskAuditInput {
|
|
7
|
+
readonly summary: string;
|
|
8
|
+
readonly decision: PlanRiskAuditDecision;
|
|
9
|
+
readonly splitRationale: string | null;
|
|
10
|
+
readonly stepClassifications: readonly PlanRiskAuditStepClassification[];
|
|
11
|
+
}
|
|
12
|
+
export type CorrectiveReplanCrashBoundary = 'after-intent' | 'after-applying-phase' | `after-target-${0 | 1 | 2 | 3 | 4}` | `after-target-phase-${0 | 1 | 2 | 3 | 4}` | 'after-published-phase' | 'after-domain-readback' | 'after-completed-phase' | 'after-terminal-readback';
|
|
13
|
+
export interface ExecuteCorrectiveReplanInput {
|
|
14
|
+
readonly projectId: string;
|
|
15
|
+
readonly taskId: string;
|
|
16
|
+
readonly receipt: ReceiptHandle;
|
|
17
|
+
readonly candidateReceipt: unknown;
|
|
18
|
+
readonly planValidationEvent: StoredPlanValidationEventHandle;
|
|
19
|
+
readonly candidatePlanValidationEvent: unknown;
|
|
20
|
+
readonly plan: TaskPlanInput;
|
|
21
|
+
readonly riskAudit: CorrectiveReplanRiskAuditInput;
|
|
22
|
+
}
|
|
23
|
+
export interface CorrectiveReplanExecutionResult {
|
|
24
|
+
readonly kind: 'corrective-replan-execution-result';
|
|
25
|
+
readonly disposition: 'executed' | 'recovered' | 'replayed';
|
|
26
|
+
readonly taskId: string;
|
|
27
|
+
readonly transactionId: string;
|
|
28
|
+
readonly resultSha256: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CorrectiveReplanExecutor {
|
|
31
|
+
execute(input: ExecuteCorrectiveReplanInput): CorrectiveReplanExecutionResult;
|
|
32
|
+
recover(input: {
|
|
33
|
+
taskId: string;
|
|
34
|
+
transactionId: string;
|
|
35
|
+
}): CorrectiveReplanExecutionResult;
|
|
36
|
+
replay(input: {
|
|
37
|
+
taskId: string;
|
|
38
|
+
transactionId: string;
|
|
39
|
+
receiptHash: string;
|
|
40
|
+
}): CorrectiveReplanExecutionResult;
|
|
41
|
+
}
|
|
42
|
+
interface ExecutorOptions {
|
|
43
|
+
readonly taskRoot: string;
|
|
44
|
+
readonly locksRoot: string;
|
|
45
|
+
readonly trustedRoot: string;
|
|
46
|
+
readonly credentialKernel: CorrectiveReplanCredentialKernel;
|
|
47
|
+
readonly admissionCheck?: (input: Readonly<{
|
|
48
|
+
task: TaskState;
|
|
49
|
+
plan: TaskPlanInput;
|
|
50
|
+
riskAudit: CorrectiveReplanRiskAuditInput;
|
|
51
|
+
receiptVerified: true;
|
|
52
|
+
validationEventVerified: true;
|
|
53
|
+
taskOperationLockHeld: true;
|
|
54
|
+
}>) => void;
|
|
55
|
+
readonly now?: () => Date;
|
|
56
|
+
readonly faultInjector?: (boundary: CorrectiveReplanCrashBoundary) => void;
|
|
57
|
+
}
|
|
58
|
+
export declare function createCorrectiveReplanExecutor(options: ExecutorOptions): CorrectiveReplanExecutor;
|
|
59
|
+
export declare function correctiveReplanStepSetHash(stepIds: readonly string[]): string;
|
|
60
|
+
export declare function correctiveReplanRiskAuditHash(bindingValues: unknown, input: CorrectiveReplanRiskAuditInput): string;
|
|
61
|
+
export declare function driveCorrectiveReplanTransaction(transactions: CorrectiveReplanTaskTransactionStore, handle: CoreTaskOperationHandle, transactionId: string, disposition: CorrectiveReplanExecutionResult['disposition'], fault: (boundary: CorrectiveReplanCrashBoundary) => void): CorrectiveReplanExecutionResult;
|
|
62
|
+
export declare function correctiveReplanTerminalReadback(transactions: CorrectiveReplanTaskTransactionStore, handle: CoreTaskOperationHandle, journal: CorrectiveReplanTaskTransactionJournal): string;
|
|
63
|
+
export declare function correctiveReplanExecutionKeyHash(binding: JsonRecord): string;
|
|
64
|
+
export {};
|