codex-workflow-v2 2.0.0-beta.13.9 → 2.0.0-beta.14

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.
Files changed (271) hide show
  1. package/README.md +27 -388
  2. package/dist/reviewer-runtime-build.json +89 -29
  3. package/dist/src/alpha6/adoption.d.ts +2 -0
  4. package/dist/src/alpha6/adoption.js +22 -0
  5. package/dist/src/alpha6/adoption.js.map +1 -1
  6. package/dist/src/alpha6/captured-check-evidence.d.ts +51 -0
  7. package/dist/src/alpha6/captured-check-evidence.js +152 -0
  8. package/dist/src/alpha6/captured-check-evidence.js.map +1 -0
  9. package/dist/src/alpha6/component-owner.d.ts +15 -1
  10. package/dist/src/alpha6/component-owner.js +44 -2
  11. package/dist/src/alpha6/component-owner.js.map +1 -1
  12. package/dist/src/alpha6/corrective-decision-boundary.d.ts +4 -0
  13. package/dist/src/alpha6/corrective-decision-boundary.js +47 -0
  14. package/dist/src/alpha6/corrective-decision-boundary.js.map +1 -0
  15. package/dist/src/alpha6/downstream-proof.d.ts +1 -25
  16. package/dist/src/alpha6/downstream-proof.js +0 -171
  17. package/dist/src/alpha6/downstream-proof.js.map +1 -1
  18. package/dist/src/alpha6/literal-test-invocation.d.ts +2 -0
  19. package/dist/src/alpha6/literal-test-invocation.js +106 -0
  20. package/dist/src/alpha6/literal-test-invocation.js.map +1 -0
  21. package/dist/src/alpha6/milestone.d.ts +2 -0
  22. package/dist/src/alpha6/milestone.js +10 -1
  23. package/dist/src/alpha6/milestone.js.map +1 -1
  24. package/dist/src/alpha6/navigation-dirty-carryover.d.ts +11 -0
  25. package/dist/src/alpha6/navigation-dirty-carryover.js +130 -0
  26. package/dist/src/alpha6/navigation-dirty-carryover.js.map +1 -0
  27. package/dist/src/alpha6/plan-integrity.js +7 -5
  28. package/dist/src/alpha6/plan-integrity.js.map +1 -1
  29. package/dist/src/alpha6/remediation.d.ts +6 -21
  30. package/dist/src/alpha6/remediation.js +161 -476
  31. package/dist/src/alpha6/remediation.js.map +1 -1
  32. package/dist/src/alpha6/root-cause-replan-carryover.d.ts +4 -1
  33. package/dist/src/alpha6/root-cause-replan-carryover.js +29 -5
  34. package/dist/src/alpha6/root-cause-replan-carryover.js.map +1 -1
  35. package/dist/src/beta1/project-transaction.d.ts +3 -1
  36. package/dist/src/beta1/project-transaction.js +6 -2
  37. package/dist/src/beta1/project-transaction.js.map +1 -1
  38. package/dist/src/checks/runner.d.ts +26 -0
  39. package/dist/src/checks/runner.js +223 -0
  40. package/dist/src/checks/runner.js.map +1 -0
  41. package/dist/src/checks/task-sync.d.ts +10 -0
  42. package/dist/src/checks/task-sync.js +41 -0
  43. package/dist/src/checks/task-sync.js.map +1 -0
  44. package/dist/src/checks/worker.d.ts +1 -0
  45. package/dist/src/checks/worker.js +154 -0
  46. package/dist/src/checks/worker.js.map +1 -0
  47. package/dist/src/cli-actions.d.ts +2 -2
  48. package/dist/src/cli-actions.js +3 -15
  49. package/dist/src/cli-actions.js.map +1 -1
  50. package/dist/src/cli.js +14 -98
  51. package/dist/src/cli.js.map +1 -1
  52. package/dist/src/contracts.d.ts +35 -32
  53. package/dist/src/dependency-provenance.d.ts +2 -2
  54. package/dist/src/dependency-provenance.js +12 -69
  55. package/dist/src/dependency-provenance.js.map +1 -1
  56. package/dist/src/domain/base-sync-conflict.d.ts +13 -0
  57. package/dist/src/domain/base-sync-conflict.js +32 -0
  58. package/dist/src/domain/base-sync-conflict.js.map +1 -0
  59. package/dist/src/domain/step-start-admission.d.ts +4 -0
  60. package/dist/src/domain/step-start-admission.js +9 -0
  61. package/dist/src/domain/step-start-admission.js.map +1 -0
  62. package/dist/src/domain/virgin-registration.d.ts +3 -0
  63. package/dist/src/domain/virgin-registration.js +65 -0
  64. package/dist/src/domain/virgin-registration.js.map +1 -0
  65. package/dist/src/errors.d.ts +1 -1
  66. package/dist/src/errors.js.map +1 -1
  67. package/dist/src/gateway-handshake.js +0 -8
  68. package/dist/src/gateway-handshake.js.map +1 -1
  69. package/dist/src/git.d.ts +3 -1
  70. package/dist/src/git.js +41 -14
  71. package/dist/src/git.js.map +1 -1
  72. package/dist/src/graph.js +25 -3
  73. package/dist/src/graph.js.map +1 -1
  74. package/dist/src/index.d.ts +1 -0
  75. package/dist/src/navigation-actions.d.ts +9 -0
  76. package/dist/src/navigation-actions.js +72 -0
  77. package/dist/src/navigation-actions.js.map +1 -0
  78. package/dist/src/navigation-update-artifact.d.ts +5 -0
  79. package/dist/src/navigation-update-artifact.js +227 -0
  80. package/dist/src/navigation-update-artifact.js.map +1 -0
  81. package/dist/src/navigation-update.d.ts +39 -0
  82. package/dist/src/navigation-update.js +82 -0
  83. package/dist/src/navigation-update.js.map +1 -0
  84. package/dist/src/observation.js +52 -29
  85. package/dist/src/observation.js.map +1 -1
  86. package/dist/src/observed-routes.js +5 -6
  87. package/dist/src/observed-routes.js.map +1 -1
  88. package/dist/src/pending-review-update.d.ts +0 -13
  89. package/dist/src/pending-review-update.js +1 -6
  90. package/dist/src/pending-review-update.js.map +1 -1
  91. package/dist/src/reviewer.d.ts +1 -1
  92. package/dist/src/reviewer.js +20 -17
  93. package/dist/src/reviewer.js.map +1 -1
  94. package/dist/src/runtime.d.ts +3 -0
  95. package/dist/src/runtime.js +6 -0
  96. package/dist/src/runtime.js.map +1 -0
  97. package/dist/src/state/corrective-replan-executor.d.ts +10 -0
  98. package/dist/src/state/corrective-replan-executor.js +37 -1
  99. package/dist/src/state/corrective-replan-executor.js.map +1 -1
  100. package/dist/src/state/corrective-replan-public-schema.js +15 -2
  101. package/dist/src/state/corrective-replan-public-schema.js.map +1 -1
  102. package/dist/src/state/corrective-replan-public.js +1 -1
  103. package/dist/src/state/corrective-replan-public.js.map +1 -1
  104. package/dist/src/state/corrective-replan-transaction.d.ts +1 -0
  105. package/dist/src/state/corrective-replan-transaction.js +12 -11
  106. package/dist/src/state/corrective-replan-transaction.js.map +1 -1
  107. package/dist/src/state/corrective-yield-transaction.d.ts +1 -0
  108. package/dist/src/state/corrective-yield-transaction.js +11 -10
  109. package/dist/src/state/corrective-yield-transaction.js.map +1 -1
  110. package/dist/src/state/lock.d.ts +4 -0
  111. package/dist/src/state/lock.js +21 -0
  112. package/dist/src/state/lock.js.map +1 -1
  113. package/dist/src/version.d.ts +1 -1
  114. package/dist/src/version.js +1 -1
  115. package/dist/src/version.js.map +1 -1
  116. package/dist/src/workflow-blocker-route.d.ts +8 -0
  117. package/dist/src/workflow-blocker-route.js +106 -0
  118. package/dist/src/workflow-blocker-route.js.map +1 -0
  119. package/dist/src/workflow.d.ts +48 -63
  120. package/dist/src/workflow.js +666 -1460
  121. package/dist/src/workflow.js.map +1 -1
  122. package/docs/autonomy-guardrails.md +26 -304
  123. package/docs/decisions.md +14 -112
  124. package/docs/development-flow.md +35 -238
  125. package/docs/project-memory.md +31 -50
  126. package/docs/release-app-evidence.md +190 -0
  127. package/docs/release.md +95 -388
  128. package/docs/updating-existing-project.md +19 -717
  129. package/package.json +11 -13
  130. package/plugins/codex-workflow-gateway/.codex-plugin/plugin.json +2 -2
  131. package/plugins/codex-workflow-gateway/references/chat-dispatch.md +73 -197
  132. package/plugins/codex-workflow-gateway/references/codebase-memory-routing.md +57 -0
  133. package/plugins/codex-workflow-gateway/references/protocol.md +42 -445
  134. package/plugins/codex-workflow-gateway/scripts/chat-dispatch.mjs +7 -1
  135. package/plugins/codex-workflow-gateway/scripts/chat-model-policy.mjs +10 -8
  136. package/plugins/codex-workflow-gateway/scripts/chat-registry.mjs +23 -5
  137. package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +66 -757
  138. package/references/state-machine.md +4 -4
  139. package/roles/technical-planner.md +1 -1
  140. package/schemas/corrective-decision-event.schema.json +3 -1
  141. package/schemas/project-knowledge-map.schema.json +3 -1
  142. package/schemas/remediation-event.schema.json +10 -1
  143. package/schemas/task.schema.json +46 -2
  144. package/schemas/transition-payloads.schema.json +16 -1
  145. package/src/alpha6/adoption.ts +1123 -0
  146. package/src/alpha6/captured-check-evidence.ts +132 -0
  147. package/src/alpha6/check-support-anchor.ts +128 -0
  148. package/src/alpha6/component-owner.ts +168 -0
  149. package/src/alpha6/corrective-decision-boundary.ts +39 -0
  150. package/src/alpha6/downstream-proof.ts +520 -0
  151. package/src/alpha6/failed-step-planning-recovery.ts +88 -0
  152. package/src/alpha6/handoff.ts +1443 -0
  153. package/src/alpha6/journal.ts +473 -0
  154. package/src/alpha6/literal-test-invocation.ts +84 -0
  155. package/src/alpha6/mechanical-feasibility.ts +488 -0
  156. package/src/alpha6/milestone.ts +2192 -0
  157. package/src/alpha6/navigation-dirty-carryover.ts +154 -0
  158. package/src/alpha6/npm-check-contract.ts +47 -0
  159. package/src/alpha6/plan-integrity.ts +298 -0
  160. package/src/alpha6/plan-risk.ts +1480 -0
  161. package/src/alpha6/preexecution-replan.ts +187 -0
  162. package/src/alpha6/remediation-cause.ts +98 -0
  163. package/src/alpha6/remediation.ts +2438 -0
  164. package/src/alpha6/review.ts +1198 -0
  165. package/src/alpha6/root-cause-replan-carryover.ts +491 -0
  166. package/src/alpha6/store-sidecars.ts +335 -0
  167. package/src/alpha7/autonomy.ts +411 -0
  168. package/src/alpha7/corrective-recovery.ts +1332 -0
  169. package/src/artifacts.ts +130 -0
  170. package/src/beta1/project-transaction.ts +355 -0
  171. package/src/change-explanation.ts +153 -0
  172. package/src/checks/runner.ts +245 -0
  173. package/src/checks/task-sync.ts +41 -0
  174. package/src/checks/worker.ts +149 -0
  175. package/src/cli-actions.ts +107 -0
  176. package/src/cli.ts +1457 -0
  177. package/src/contracts.ts +1494 -0
  178. package/src/credential-output.ts +89 -0
  179. package/src/credential-transport.ts +215 -0
  180. package/src/delegation.ts +190 -0
  181. package/src/dependency-provenance.ts +472 -0
  182. package/src/diagnostics.ts +93 -0
  183. package/src/domain/base-sync-conflict.ts +35 -0
  184. package/src/domain/completed-step-carryover.ts +76 -0
  185. package/src/domain/discovery.ts +27 -0
  186. package/src/domain/plan-semantics.ts +58 -0
  187. package/src/domain/step-start-admission.ts +10 -0
  188. package/src/domain/validation.ts +177 -0
  189. package/src/domain/virgin-registration.ts +46 -0
  190. package/src/errors.ts +24 -0
  191. package/src/fs-utils.ts +61 -0
  192. package/src/gateway-handshake.ts +95 -0
  193. package/src/git.ts +183 -0
  194. package/src/graph.ts +342 -0
  195. package/src/historical-step-provenance.ts +136 -0
  196. package/src/index.ts +23 -0
  197. package/src/lifecycle/canonical-hash.ts +28 -0
  198. package/src/lifecycle/catalog.ts +202 -0
  199. package/src/lifecycle/compiler-inspection.ts +29 -0
  200. package/src/lifecycle/core-static-readiness.ts +132 -0
  201. package/src/lifecycle/corrective-replan-authority.ts +136 -0
  202. package/src/lifecycle/corrective-replan-binding-manifest.ts +51 -0
  203. package/src/lifecycle/corrective-replan-credential-core.ts +408 -0
  204. package/src/lifecycle/corrective-replan-credential-schema.ts +54 -0
  205. package/src/lifecycle/corrective-replan-credentials.ts +48 -0
  206. package/src/lifecycle/corrective-replan.ts +843 -0
  207. package/src/lifecycle/evaluator.ts +48 -0
  208. package/src/lifecycle/fingerprint.ts +488 -0
  209. package/src/lifecycle/immutable.ts +8 -0
  210. package/src/lifecycle/implementation-table.ts +118 -0
  211. package/src/lifecycle/index.ts +8 -0
  212. package/src/lifecycle/schema-artifact.ts +263 -0
  213. package/src/lifecycle/semantic-registry.ts +572 -0
  214. package/src/lifecycle/types.ts +838 -0
  215. package/src/memory.ts +273 -0
  216. package/src/migration.ts +161 -0
  217. package/src/navigation-actions.ts +70 -0
  218. package/src/navigation-update-artifact.ts +198 -0
  219. package/src/navigation-update.ts +121 -0
  220. package/src/observation.ts +225 -0
  221. package/src/observed-routes.ts +660 -0
  222. package/src/operational-contract.ts +125 -0
  223. package/src/pending-review-update.ts +175 -0
  224. package/src/repository.ts +99 -0
  225. package/src/reviewer.ts +1879 -0
  226. package/src/runtime.ts +6 -0
  227. package/src/state/corrective-replan-executor.ts +818 -0
  228. package/src/state/corrective-replan-public-schema.ts +83 -0
  229. package/src/state/corrective-replan-public.ts +908 -0
  230. package/src/state/corrective-replan-transaction.ts +949 -0
  231. package/src/state/corrective-yield-executor.ts +327 -0
  232. package/src/state/corrective-yield-transaction.ts +730 -0
  233. package/src/state/lock.ts +902 -0
  234. package/src/state/store.ts +567 -0
  235. package/src/transition-core.ts +330 -0
  236. package/src/ulid.ts +24 -0
  237. package/src/version.ts +2 -0
  238. package/src/workflow-blocker-route.ts +109 -0
  239. package/src/workflow.ts +10172 -0
  240. package/docs/alpha7.1-implementation-brief.md +0 -268
  241. package/docs/alpha7.2-corrective-context-refresh-brief.md +0 -484
  242. package/docs/alpha7.2.1-remediation-recovery-brief.md +0 -86
  243. package/docs/beta1-stabilization-brief.md +0 -165
  244. package/docs/beta11-plan-integrity-recovery-brief.md +0 -38
  245. package/docs/beta13.2-signal-review-recovery.md +0 -38
  246. package/docs/beta2-initial-assembly-navigation-brief.md +0 -616
  247. package/docs/change-model.md +0 -118
  248. package/docs/delegated-approval.md +0 -254
  249. package/docs/lifecycle/state-machine-stabilization.md +0 -641
  250. package/docs/pdf/README.md +0 -24
  251. package/docs/pdf/codex-workflow-v2-architecture-ru.pdf +0 -0
  252. package/docs/pdf/codex-workflow-v2-chat-only-guide-ru.pdf +0 -0
  253. package/docs/pdf/codex-workflow-v2-technical-reference-ru.pdf +0 -0
  254. package/docs/pdf/requirements.txt +0 -1
  255. package/docs/pdf/sources/codex-workflow-v2-architecture-ru.md +0 -478
  256. package/docs/pdf/sources/codex-workflow-v2-chat-only-guide-ru.md +0 -506
  257. package/docs/pdf/sources/codex-workflow-v2-technical-reference-ru.md +0 -778
  258. package/docs/pending-review-update.md +0 -15
  259. package/docs/problem-briefs/01-pre-implementation-integrity.md +0 -482
  260. package/docs/problem-briefs/02-minimal-step-integrity.md +0 -411
  261. package/docs/problem-briefs/03-minimal-agent-context-integrity.md +0 -358
  262. package/docs/problem-briefs/04-task-dependency-and-structural-replacement-integrity.md +0 -573
  263. package/docs/problem-briefs/BRIEF-TEMPLATE.md +0 -56
  264. package/docs/problem-briefs/README.md +0 -120
  265. package/docs/problem-briefs/evidence/p01-mechanical-feasibility-corpus.md +0 -90
  266. package/docs/problem-briefs/evidence/signal-v4-pre-m3-replay.md +0 -246
  267. package/docs/split-required-recovery.md +0 -47
  268. package/docs/stable-release-defect-register.md +0 -730
  269. package/docs/validation-report.md +0 -182
  270. package/scripts/generate-pdf-docs.py +0 -524
  271. package/scripts/run-pdf-docs.mjs +0 -62
@@ -0,0 +1,1494 @@
1
+ export const STATE_SCHEMA_VERSION = 2 as const;
2
+ export const PROTOCOL_VERSION = 2 as const;
3
+
4
+ export type DiscoveryStatus =
5
+ | 'needs_discovery'
6
+ | 'needs_clarification'
7
+ | 'ready_to_materialize'
8
+ | 'materialized'
9
+ | 'abandoned';
10
+
11
+ export type TaskStatus =
12
+ | 'planning'
13
+ | 'awaiting_execution_authorization'
14
+ | 'ready'
15
+ | 'in_progress'
16
+ | 'validating'
17
+ | 'needs_fix'
18
+ | 'awaiting_final_acceptance'
19
+ | 'merging'
20
+ | 'ready_to_merge'
21
+ | 'merged'
22
+ | 'blocked'
23
+ | 'cancelled';
24
+
25
+ export type MilestoneStatus =
26
+ | 'planning'
27
+ | 'awaiting_execution_authorization'
28
+ | 'active'
29
+ | 'validating'
30
+ | 'awaiting_final_acceptance'
31
+ | 'accepted'
32
+ | 'blocked'
33
+ | 'cancelled';
34
+
35
+ export type StepStatus = 'planned' | 'in_progress' | 'completed' | 'failed' | 'blocked' | 'skipped';
36
+ export type WorkspaceOwner = 'local' | 'external';
37
+ export type ReviewStatus = 'pending' | 'passed' | 'failed' | 'unverified';
38
+ export type AuthorizationKind = 'execution' | 'final_acceptance' | 'exception';
39
+ export type AuthorizationMode = 'human' | 'delegated' | 'corrective-derived';
40
+ export type DelegationStatus = 'active' | 'revoked';
41
+ export type DelegationTransition =
42
+ | 'project_memory.approve'
43
+ | 'task.execution_authorize'
44
+ | 'task.final_accept'
45
+ | 'milestone.execution_authorize'
46
+ | 'milestone.final_accept';
47
+ export type KnowledgeImpact = 'none' | 'update' | 'create' | 'retire';
48
+ export type GraphUse = 'code-aware' | 'not-applicable';
49
+ export type GraphKind = 'product' | 'workflow';
50
+ export type GraphMode = 'moderate' | 'full';
51
+ export type GraphBindingStatus = 'ready' | 'stale' | 'unavailable' | 'fallback';
52
+ export type KnowledgeCategory =
53
+ | 'agent-guidance'
54
+ | 'onboarding'
55
+ | 'architecture'
56
+ | 'decisions'
57
+ | 'commands'
58
+ | 'ownership'
59
+ | 'testing'
60
+ | 'operations'
61
+ | 'domain';
62
+ export type KnowledgeAuthority = 'canonical' | 'supporting';
63
+ export type KnowledgeMapStatus = 'draft' | 'awaiting_approval' | 'active' | 'stale' | 'conflicted';
64
+ export type WorkflowRole =
65
+ | 'scope-lead'
66
+ | 'technical-planner'
67
+ | 'delivery-coordinator'
68
+ | 'worker'
69
+ | 'independent-reviewer';
70
+
71
+ export interface RevisionedRecord {
72
+ schemaVersion: typeof STATE_SCHEMA_VERSION;
73
+ revision: number;
74
+ id: string;
75
+ projectId: string;
76
+ createdAt: string;
77
+ updatedAt: string;
78
+ }
79
+
80
+ export interface DiscoveryState extends RevisionedRecord {
81
+ kind: 'discovery';
82
+ status: DiscoveryStatus;
83
+ goal: string;
84
+ outcome: string | null;
85
+ facts: string[];
86
+ decisions: string[];
87
+ assumptions: string[];
88
+ unknowns: string[];
89
+ blockingUnknowns: string[];
90
+ scope: string[];
91
+ outOfScope: string[];
92
+ constraints: string[];
93
+ acceptance: string[];
94
+ materializedEntityId: string | null;
95
+ }
96
+
97
+ export interface PlanStepInput {
98
+ id: string;
99
+ title: string;
100
+ objective: string;
101
+ requirements: string[];
102
+ dependencies: string[];
103
+ expectedOutputs: string[];
104
+ allowedWrites: string[];
105
+ forbiddenScope: string[];
106
+ checks: string[];
107
+ }
108
+
109
+ /** A declared production hand-off; never inferred from component prose. */
110
+ export interface ProductionEdgeInput {
111
+ ownerStepId: string;
112
+ consumerStepId: string;
113
+ checkRef: string;
114
+ }
115
+
116
+ export interface TaskPlanInput {
117
+ objective: string;
118
+ requirements: string[];
119
+ acceptance: string[];
120
+ risks: string[];
121
+ knowledgeImpact: KnowledgeImpact;
122
+ knowledgeImpactReason: string;
123
+ knowledgeTargets: KnowledgeTarget[];
124
+ knowledgeMapRevision: number;
125
+ knowledgeMapHash: string;
126
+ graphUse: GraphUse;
127
+ steps: PlanStepInput[];
128
+ /** Structural integration declaration, independently required by runtime-composition PRA authority. */
129
+ productionEdges?: ProductionEdgeInput[];
130
+ /** Explicit acknowledgement of the derived structural boundary; never the trigger by itself. */
131
+ requiresProductionEdges?: boolean;
132
+ }
133
+
134
+ export interface KnowledgeTarget {
135
+ category: KnowledgeCategory;
136
+ path: string;
137
+ reason: string;
138
+ requirementIds: string[];
139
+ }
140
+
141
+ export interface KnowledgeSource {
142
+ id: string;
143
+ category: KnowledgeCategory;
144
+ path: string;
145
+ scope: string;
146
+ authority: KnowledgeAuthority;
147
+ contentHash: string;
148
+ discoveredBy: string;
149
+ lastVerifiedAt: string;
150
+ }
151
+
152
+ export interface KnowledgeGap {
153
+ category: KnowledgeCategory;
154
+ scope: string;
155
+ reason: string;
156
+ }
157
+
158
+ export interface KnowledgeConflict {
159
+ category: KnowledgeCategory;
160
+ scope: string;
161
+ sourceIds: string[];
162
+ reason: string;
163
+ }
164
+
165
+ export interface KnowledgeMapApproval {
166
+ mapHash: string;
167
+ actor: string;
168
+ approvedAt: string;
169
+ authorizationMode?: AuthorizationMode;
170
+ delegation?: DelegatedAuthorizationEvidence;
171
+ }
172
+
173
+ export interface ProjectKnowledgeMap extends RevisionedRecord {
174
+ kind: 'knowledge-map';
175
+ status: KnowledgeMapStatus;
176
+ entries: KnowledgeSource[];
177
+ gaps: KnowledgeGap[];
178
+ conflicts: KnowledgeConflict[];
179
+ approval: KnowledgeMapApproval | null;
180
+ }
181
+
182
+ export interface GraphBindingSnapshot {
183
+ projectKey: string | null;
184
+ rootFingerprint: string;
185
+ indexedHead: string | null;
186
+ packageVersion: string | null;
187
+ manifestHash: string | null;
188
+ mode: GraphMode;
189
+ status: GraphBindingStatus;
190
+ nodeCount: number | null;
191
+ edgeCount: number | null;
192
+ observedAt: string;
193
+ evidenceHash: string;
194
+ fallbackReason: string | null;
195
+ }
196
+
197
+ export interface GraphBinding extends RevisionedRecord, GraphBindingSnapshot {
198
+ kind: 'graph-binding';
199
+ graphKind: GraphKind;
200
+ provider: 'codebase-memory-mcp';
201
+ previous: GraphBindingSnapshot | null;
202
+ }
203
+
204
+ export interface GraphRefreshRequest {
205
+ protocolVersion: typeof PROTOCOL_VERSION;
206
+ requestId: string;
207
+ projectId: string;
208
+ graphKind: GraphKind;
209
+ sourceRoot: string;
210
+ rootFingerprint: string;
211
+ indexedHead: string | null;
212
+ packageVersion: string | null;
213
+ manifestHash: string | null;
214
+ mode: GraphMode;
215
+ persistence: false;
216
+ issuedAt: string;
217
+ }
218
+
219
+ export interface GraphRefreshEvidence {
220
+ requestId: string;
221
+ provider: 'codebase-memory-mcp';
222
+ projectKey: string;
223
+ rootFingerprint: string;
224
+ indexedHead: string | null;
225
+ packageVersion: string | null;
226
+ manifestHash: string | null;
227
+ mode: GraphMode;
228
+ status: 'ready' | 'stale' | 'unavailable';
229
+ nodeCount: number | null;
230
+ edgeCount: number | null;
231
+ observedAt: string;
232
+ }
233
+
234
+ export interface KnowledgeSelection {
235
+ sourceId: string;
236
+ authority: KnowledgeAuthority;
237
+ }
238
+
239
+ export interface StepEvidence {
240
+ recordedAt: string;
241
+ commitSha: string;
242
+ changedFiles: string[];
243
+ checks: Array<{
244
+ command: string;
245
+ passed: boolean;
246
+ exitCode: number;
247
+ output: string;
248
+ }>;
249
+ notes: string[];
250
+ }
251
+
252
+ export interface StepFailurePause {
253
+ recordedAt: string;
254
+ dirtyFiles: string[];
255
+ dirtyWorktreeHash: string;
256
+ checksHash: string;
257
+ checksEvidence?: { kind: 'captured-checks/v1'; artifactHash: string };
258
+ failedChecks?: Array<{
259
+ command: string;
260
+ exitCode: number;
261
+ diagnosticCodes: string[];
262
+ diagnosticShape: string[];
263
+ diagnosticPaths: string[];
264
+ causeFingerprint: string;
265
+ }>;
266
+ }
267
+
268
+ export interface TaskStep extends PlanStepInput {
269
+ status: StepStatus;
270
+ evidence: StepEvidence | null;
271
+ failurePause?: StepFailurePause | null;
272
+ }
273
+
274
+ export type MechanicalFeasibilityResult = 'pass' | 'blocked' | 'unverified';
275
+
276
+ export interface MechanicalFeasibilityAnalyzer {
277
+ analyzerId:
278
+ | 'wf2.root-npm-script'
279
+ | 'wf2.root-npm-script-arguments'
280
+ | 'wf2.check-support-anchor'
281
+ | 'wf2.exact-output-path'
282
+ | 'wf2.exact-predecessor-path';
283
+ analyzerVersion: 1;
284
+ }
285
+
286
+ export interface MechanicalFeasibilityFinding extends MechanicalFeasibilityAnalyzer {
287
+ result: MechanicalFeasibilityResult;
288
+ stepId: string;
289
+ subject: string;
290
+ evidence: string;
291
+ reasonCode: string;
292
+ }
293
+
294
+ export interface MechanicalFeasibilityEvidence {
295
+ schemaVersion: 1;
296
+ taskId: string;
297
+ evaluatedTaskRevision: number;
298
+ briefHash: string;
299
+ planHash: string;
300
+ sourceKind: 'pre-start-base' | 'corrective-task-workspace';
301
+ sourceBranch: string;
302
+ evaluatedHead: string;
303
+ baseCommit: string | null;
304
+ analyzerSetHash: string;
305
+ analyzerInputHash: string;
306
+ analyzers: MechanicalFeasibilityAnalyzer[];
307
+ findings: MechanicalFeasibilityFinding[];
308
+ decision: 'clear' | 'blocked';
309
+ }
310
+
311
+ export interface AuthorizationEvent {
312
+ kind: AuthorizationKind;
313
+ decision: 'approved' | 'rejected' | 'waived' | 'superseded';
314
+ actor: string;
315
+ recordedAt: string;
316
+ briefHash: string | null;
317
+ planHash: string | null;
318
+ resultHash: string | null;
319
+ evidenceHash: string | null;
320
+ headCommit: string | null;
321
+ reason: string;
322
+ authorizationMode?: AuthorizationMode;
323
+ delegation?: DelegatedAuthorizationEvidence;
324
+ /** Missing only on execution authorizations written before P01-A. */
325
+ mechanicalFeasibility?: MechanicalFeasibilityEvidence;
326
+ }
327
+
328
+ export interface DelegatedAuthorizationEvidence {
329
+ grantId: string;
330
+ policyHash: string;
331
+ principal: string;
332
+ delegate: string;
333
+ transition: DelegationTransition;
334
+ }
335
+
336
+ export type DelegationScope =
337
+ | { kind: 'project' }
338
+ | { kind: 'milestone'; id: string }
339
+ | { kind: 'task'; id: string };
340
+
341
+ export interface DelegationPolicyInput {
342
+ principal: string;
343
+ delegate: string;
344
+ scope: DelegationScope;
345
+ transitions: DelegationTransition[];
346
+ expiresAt: string;
347
+ }
348
+
349
+ export interface DelegationGrant extends RevisionedRecord {
350
+ kind: 'delegation-grant';
351
+ status: DelegationStatus;
352
+ principal: string;
353
+ delegate: string;
354
+ scope: DelegationScope;
355
+ transitions: DelegationTransition[];
356
+ expiresAt: string;
357
+ policyHash: string;
358
+ revokedAt: string | null;
359
+ revokedBy: string | null;
360
+ revokeReason: string | null;
361
+ }
362
+
363
+ export interface DelegationGrantGate {
364
+ kind: 'delegation_grant_issuance';
365
+ projectId: string;
366
+ policy: DelegationPolicyInput;
367
+ policyHash: string;
368
+ confirmationCode: string;
369
+ }
370
+
371
+ export interface DelegatedApprovalOption {
372
+ grantId: string;
373
+ principal: string;
374
+ delegate: string;
375
+ transition: DelegationTransition;
376
+ scope: DelegationScope;
377
+ expiresAt: string;
378
+ policyHash: string;
379
+ }
380
+
381
+ export interface TaskKnowledgeRebindRecord {
382
+ recordedAt: string;
383
+ fromKnowledgeMapRevision: number;
384
+ fromKnowledgeMapHash: string;
385
+ toKnowledgeMapRevision: number;
386
+ toKnowledgeMapHash: string;
387
+ previousPlanHash: string;
388
+ reboundPlanHash: string;
389
+ }
390
+
391
+ export interface ReviewRecord {
392
+ status: ReviewStatus;
393
+ reviewer: string;
394
+ recordedAt: string | null;
395
+ headCommit: string | null;
396
+ briefHash: string | null;
397
+ planHash: string | null;
398
+ evidenceHash: string | null;
399
+ summary: string;
400
+ findings: Array<{
401
+ id: string;
402
+ severity: 'critical' | 'major' | 'minor';
403
+ requirement: string | null;
404
+ summary: string;
405
+ evidence: string;
406
+ requiredAction: string;
407
+ /** Stable identity for the underlying cause, not for this review attempt. */
408
+ causeId?: string;
409
+ route?: 'fix' | 'replan';
410
+ planConflict?: {
411
+ planClause: string;
412
+ whyFixCannotFit: string;
413
+ minimalPlanChange: string;
414
+ } | null;
415
+ }>;
416
+ }
417
+
418
+ export type ReviewInput = Pick<ReviewRecord, 'status' | 'reviewer' | 'summary' | 'findings'>;
419
+
420
+ export interface CorrectivePlanAuditInput {
421
+ auditor: string;
422
+ summary: string;
423
+ decision: 'continue-fix' | 'replan-required' | 'split-required' | 'stop-escalate';
424
+ reviewedFindingIds: string[];
425
+ }
426
+
427
+ export type GuardedRiskCategory =
428
+ | 'migration'
429
+ | 'concurrency'
430
+ | 'restart-replay'
431
+ | 'crash-window'
432
+ | 'external-provider'
433
+ | 'runtime-composition'
434
+ | 'security-boundary'
435
+ | 'auth-secrets'
436
+ | 'irreversible-execution';
437
+
438
+ export type PlanRiskAuditDecision =
439
+ | 'approved'
440
+ | 'approved-with-rationale'
441
+ | 'split-required'
442
+ | 'stop-escalate';
443
+ export type StepReviewEventType = 'pending' | 'review-recorded' | 'attestation-verified';
444
+ export type RemediationMode = 'ordinary' | 'corrective';
445
+ export type RemediationFailureKind = 'checks-failed' | 'review-failed' | 'review-unverified';
446
+ export type TaskHandoffEventType = 'handoff' | 'claim' | 'credential-replace' | 'yield' | 'handback';
447
+ export type TaskCoordinationLevel = 'C1';
448
+ export type AdoptionPostureEventType = 'project-registration' | 'adoption-apply';
449
+ export type MilestoneTransactionPhase = 'prepared' | 'applying' | 'applied' | 'rolled_back';
450
+
451
+ export interface SidecarEventRecord {
452
+ eventId: string;
453
+ previousEventHash: string | null;
454
+ recordedAt: string;
455
+ eventHash: string;
456
+ }
457
+
458
+ export interface DownstreamProofInvalidationEvent extends SidecarEventRecord {
459
+ taskId: string;
460
+ previousTaskRevision: number;
461
+ resultTaskRevision: number;
462
+ planHash: string;
463
+ activeStepId: string;
464
+ invalidatedSteps: Array<{
465
+ stepId: string;
466
+ evidenceCommit: string;
467
+ triggerFiles: string[];
468
+ }>;
469
+ dirtyFiles: string[];
470
+ dirtyWorktreeHash?: string;
471
+ preservedHeadCommit: string;
472
+ actor: string;
473
+ reason: string;
474
+ packageVersion: string;
475
+ }
476
+
477
+ export interface DownstreamProofReplanRecoveryEvent extends SidecarEventRecord {
478
+ taskId: string;
479
+ previousTaskRevision: number;
480
+ resultTaskRevision: number;
481
+ invalidationEventId: string;
482
+ invalidationPlanHash: string;
483
+ reboundPlanHash: string;
484
+ knowledgeRebindRecordedAt: string;
485
+ dirtyFiles: string[];
486
+ dirtyWorktreeHash: string;
487
+ preservedHeadCommit: string;
488
+ dependencyRecoveryCommit: string | null;
489
+ actor: string;
490
+ reason: string;
491
+ packageVersion: string;
492
+ }
493
+
494
+ export interface DownstreamProofReplanCompatibility {
495
+ invalidationEventId: string;
496
+ activeStepId: string;
497
+ sourcePlanHash: string;
498
+ reboundPlanHash: string;
499
+ knowledgeRebindRecordedAt: string;
500
+ dirtyFiles: string[];
501
+ dirtyWorktreeHash: string;
502
+ invalidatedStepIds: string[];
503
+ }
504
+
505
+ export interface PlanRiskAuditStepClassification {
506
+ stepId: string;
507
+ categories: GuardedRiskCategory[];
508
+ reviewRequired: boolean;
509
+ failureModes: string[];
510
+ requiredEvidence: string[];
511
+ proofObligations?: PlanRiskProofObligation[];
512
+ }
513
+
514
+ export interface PlanRiskProofObligation {
515
+ failureMode: string;
516
+ counterexample: string;
517
+ expectedResult: string;
518
+ evidence: string;
519
+ }
520
+
521
+ export interface PlanRiskAuditEvent extends SidecarEventRecord {
522
+ taskId: string;
523
+ taskRevision: number;
524
+ briefHash: string;
525
+ planHash: string;
526
+ knowledgeMapRevision: number;
527
+ knowledgeMapHash: string;
528
+ planner: string;
529
+ auditor: string;
530
+ summary: string;
531
+ decision: PlanRiskAuditDecision;
532
+ splitRationale: string | null;
533
+ stepClassifications: PlanRiskAuditStepClassification[];
534
+ /** Hash-chained marker: audits written by the structural-edge contract retain that authority on readback. */
535
+ structuralProductionEdgeAuthority?: 'required-v1';
536
+ }
537
+
538
+ export interface StepReviewEvent extends SidecarEventRecord {
539
+ taskId: string;
540
+ taskRevision: number;
541
+ stepId: string;
542
+ stepDefinitionHash: string;
543
+ completionCommit: string;
544
+ checksHash: string;
545
+ planHash: string;
546
+ evidenceHash: string | null;
547
+ eventType: StepReviewEventType;
548
+ decision: ReviewStatus;
549
+ reviewerAttestationHash: string | null;
550
+ remediationRoute?: 'fix' | 'replan' | null;
551
+ planConflicts?: Array<{
552
+ findingId: string;
553
+ planClause: string;
554
+ whyFixCannotFit: string;
555
+ minimalPlanChange: string;
556
+ }>;
557
+ remediationCauses?: Array<{
558
+ findingId: string;
559
+ causeId: string;
560
+ causeFingerprint: string;
561
+ route: 'fix' | 'replan';
562
+ planConflict: boolean;
563
+ }>;
564
+ }
565
+
566
+ export interface ReviewerAttestationEvent extends SidecarEventRecord {
567
+ taskId: string;
568
+ stepId: string;
569
+ reviewer: string;
570
+ isolationResult: 'verified' | 'unverified';
571
+ outputHash: string;
572
+ reviewedCommit: string;
573
+ reviewEventHash: string;
574
+ planHash: string;
575
+ evidenceHash: string | null;
576
+ }
577
+
578
+ export interface UnclaimedExecutionBoundary {
579
+ kind: 'native-unclaimed-check-failure';
580
+ actor: string;
581
+ priorHandoffEventHash: string | null;
582
+ }
583
+
584
+ export interface RemediationFailureEvidence {
585
+ completionCommit: string;
586
+ checksHash: string;
587
+ reviewEventHash: string | null;
588
+ reviewerAttestationHash: string | null;
589
+ /**
590
+ * Present on native checks-failed events. The revision is assigned by task run and therefore
591
+ * identifies one declared execution independently of volatile check output or unchanged Git HEAD.
592
+ */
593
+ executionTaskRevision?: number;
594
+ /** Exact dirty product bytes protected by the failed-Step continuation transaction. */
595
+ dirtyWorktreeHash?: string;
596
+ /** Native verified lease owner and exact historical no-C1 boundary, covered by the event hash. */
597
+ unclaimedExecutionBoundary?: UnclaimedExecutionBoundary;
598
+ }
599
+
600
+ export interface RemediationCauseBinding {
601
+ authority: 'mechanical' | 'external-reviewer';
602
+ causeId: string;
603
+ causeFingerprint: string;
604
+ planConflict: boolean;
605
+ }
606
+
607
+ export interface RemediationEvent extends SidecarEventRecord {
608
+ taskId: string;
609
+ stepId: string;
610
+ guardedCategory: GuardedRiskCategory;
611
+ failureKind: RemediationFailureKind;
612
+ failureEvidence: RemediationFailureEvidence;
613
+ attemptOrdinal: number;
614
+ mode: RemediationMode;
615
+ /** Missing only on historical beta.11/beta.12 events retained as a compatibility bridge. */
616
+ causeBindings?: RemediationCauseBinding[];
617
+ }
618
+
619
+ export interface PlanIntegrityConflictEvidenceV1 {
620
+ kind: 'missing-npm-script-outside-allowed-writes';
621
+ taskRevision: number;
622
+ remediationEventId: string;
623
+ remediationEventHash: string;
624
+ manifestPath: 'package.json';
625
+ manifestHash: string | null;
626
+ gitHead: string;
627
+ stepDefinitionHash: string;
628
+ missingScripts: string[];
629
+ checkCommands: string[];
630
+ changedFiles: string[];
631
+ conflictHash: string;
632
+ }
633
+
634
+ export interface PlanIntegrityConflictEvidenceV2 {
635
+ kind: 'non-executable-npm-check-outside-allowed-writes';
636
+ taskRevision: number;
637
+ remediationEvents: Array<{
638
+ eventId: string;
639
+ eventHash: string;
640
+ attemptOrdinal: number;
641
+ }>;
642
+ manifestPath: 'package.json';
643
+ manifestHash: string | null;
644
+ gitHead: string;
645
+ stepDefinitionHash: string;
646
+ conflicts: Array<{
647
+ reasonCode: 'MISSING_NPM_SCRIPT' | 'REQUIRED_SELECTOR_MISSING';
648
+ script: string;
649
+ command: string;
650
+ scriptCommand: string | null;
651
+ runnerPath: string | null;
652
+ runnerHash: string | null;
653
+ }>;
654
+ changedFiles: string[];
655
+ conflictHash: string;
656
+ }
657
+
658
+ export interface PlanIntegrityConflictEvidenceV3 {
659
+ kind: 'check-support-anchor-outside-allowed-writes';
660
+ taskRevision: number;
661
+ remediationEvents: Array<{
662
+ eventId: string;
663
+ eventHash: string;
664
+ attemptOrdinal: number;
665
+ }>;
666
+ manifestPath: 'package.json';
667
+ manifestHash: string | null;
668
+ gitHead: string;
669
+ stepDefinitionHash: string;
670
+ conflicts: Array<{
671
+ reasonCode: 'CHECK_SUPPORT_ANCHOR_OUTSIDE_ALLOWED_WRITES';
672
+ script: string;
673
+ command: string;
674
+ scriptCommand: string;
675
+ runnerPath: string;
676
+ runnerHash: string;
677
+ supportPath: string;
678
+ supportHash: string;
679
+ importSpecifier: string;
680
+ expectedOutputPaths: string[];
681
+ anchoredMigrationNames: string[];
682
+ }>;
683
+ scopeExtensions: string[];
684
+ changedFiles: string[];
685
+ conflictHash: string;
686
+ }
687
+
688
+ export interface PlanIntegrityConflictEvidenceV4 {
689
+ kind: 'failed-check-component-owner-outside-allowed-writes';
690
+ taskRevision: number;
691
+ remediationEvents: Array<{
692
+ eventId: string;
693
+ eventHash: string;
694
+ attemptOrdinal: number;
695
+ }>;
696
+ gitHead: string;
697
+ stepDefinitionHash: string;
698
+ semanticBoundaryHash: string;
699
+ failedCheckCauseFingerprint: string;
700
+ conflicts: Array<{
701
+ reasonCode: 'FAILED_CHECK_COMPONENT_OWNER_OUTSIDE_ALLOWED_WRITES';
702
+ command: string;
703
+ runnerPath: string;
704
+ ownerPath: string;
705
+ ownerHash: string;
706
+ importChain: string[];
707
+ testInvocation?: {
708
+ kind: 'literal-vitest-catalog';
709
+ runnerHash: string;
710
+ argv: string[];
711
+ migrationOutputs: string[];
712
+ catalogNames: string[];
713
+ };
714
+ diagnosticPath: string;
715
+ componentRoot: string;
716
+ }>;
717
+ scopeExtensions: string[];
718
+ changedFiles: string[];
719
+ conflictHash: string;
720
+ }
721
+
722
+ export type PlanIntegrityConflictEvidence =
723
+ | PlanIntegrityConflictEvidenceV1
724
+ | PlanIntegrityConflictEvidenceV2
725
+ | PlanIntegrityConflictEvidenceV3
726
+ | PlanIntegrityConflictEvidenceV4;
727
+
728
+ export interface CorrectiveDecisionEvent extends SidecarEventRecord {
729
+ taskId: string;
730
+ stepId: string;
731
+ triggeringAttemptCount: number;
732
+ decision: CorrectivePlanAuditInput['decision'];
733
+ auditor: string;
734
+ coveredFindingIds: string[];
735
+ coveredEventIds: string[];
736
+ planHash: string;
737
+ recoveryBasis?: 'plan-integrity';
738
+ planIntegrityEvidence?: PlanIntegrityConflictEvidence;
739
+ }
740
+
741
+ export interface CorrectiveDecisionRecoveryEvent extends SidecarEventRecord {
742
+ taskId: string;
743
+ stepId: string;
744
+ triggeringAttemptCount: number;
745
+ correctiveDecisionEventId: string;
746
+ correctiveDecisionEventHash: string;
747
+ decisionPlanHash: string;
748
+ reboundPlanHash: string;
749
+ semanticPlanHash: string;
750
+ fromKnowledgeMapRevision: number;
751
+ fromKnowledgeMapHash: string;
752
+ toKnowledgeMapRevision: number;
753
+ toKnowledgeMapHash: string;
754
+ rebindRecordedAt: string;
755
+ sourcePlanRiskAuditEventId: string;
756
+ sourcePlanRiskAuditEventHash: string;
757
+ reboundPlanRiskAuditEventId: string;
758
+ reboundPlanRiskAuditEventHash: string;
759
+ knowledgeMapApprovalFingerprint: string;
760
+ taskAuthorizationFingerprint: string;
761
+ delegationGrantFingerprint: string;
762
+ c1EvidenceFingerprint: string;
763
+ evidenceFingerprint: string;
764
+ actor: string;
765
+ }
766
+
767
+ export interface RemediationModeRecoveryEvent extends SidecarEventRecord {
768
+ taskId: string;
769
+ stepId: string;
770
+ taskRevision: number;
771
+ remediationEventId: string;
772
+ remediationEventHash: string;
773
+ correctiveDecisionEventId: string;
774
+ correctiveDecisionEventHash: string;
775
+ correctiveDecisionRecoveryEventId: string;
776
+ correctiveDecisionRecoveryEventHash: string;
777
+ attemptOrdinal: 3;
778
+ planHash: string;
779
+ actor: string;
780
+ c1ClaimEventHash: string | null;
781
+ writerLeaseTokenHash: string | null;
782
+ fromMode: 'ordinary';
783
+ toMode: 'corrective';
784
+ reason: 'alpha7.2-recovered-continue-fix-mode-omission';
785
+ }
786
+
787
+ export interface StopEscalateOverrideEvent extends SidecarEventRecord {
788
+ taskId: string;
789
+ taskRevision: number;
790
+ stepId: string;
791
+ stopDecisionEventId: string;
792
+ stopDecisionEventHash: string;
793
+ priorContinueDecisionEventId: string;
794
+ priorContinueDecisionEventHash: string;
795
+ triggeringAttemptCount: 4;
796
+ coveredEventIds: string[];
797
+ planHash: string;
798
+ headCommit: string;
799
+ actor: string;
800
+ reason: string;
801
+ packageVersion: string;
802
+ confirmationCodeBindingHash: string;
803
+ policy: 'beta11-attempt4-stop-compatibility-v1';
804
+ }
805
+
806
+ export interface TaskHandoffMachineEvidence {
807
+ hostname: string;
808
+ pid: number;
809
+ platform: string;
810
+ arch: string;
811
+ nodeVersion: string;
812
+ }
813
+
814
+ export interface TaskHandbackRecord {
815
+ status: TaskStatus;
816
+ mergedCommit: string | null;
817
+ planHash: string | null;
818
+ resultHash: string | null;
819
+ evidenceHash: string | null;
820
+ reviewAttestationHash: string | null;
821
+ knowledgeMapRevision: number | null;
822
+ knowledgeMapHash: string | null;
823
+ limitations: string[];
824
+ recommendedNext: string;
825
+ }
826
+
827
+ export interface MilestoneDependencyBinding {
828
+ milestoneRevision: number;
829
+ membershipRevision: number;
830
+ milestonePlanHash: string;
831
+ }
832
+
833
+ export interface TaskHandoffBundle {
834
+ handoffId: string;
835
+ milestoneId: string | null;
836
+ milestoneDisplayNumber: number | null;
837
+ taskId: string;
838
+ taskDisplayNumber: number | null;
839
+ taskRevision: number;
840
+ briefHash: string;
841
+ planHash: string | null;
842
+ knowledgeMapRevision: number | null;
843
+ knowledgeMapHash: string | null;
844
+ dependencyBinding: MilestoneDependencyBinding | null;
845
+ expectedNext: string;
846
+ delegate: string;
847
+ grantId: string | null;
848
+ claimToken: string;
849
+ createdAt: string;
850
+ expiresAt: string;
851
+ prompt: string;
852
+ }
853
+
854
+ export interface TaskHandoffEvent extends SidecarEventRecord {
855
+ handoffId: string;
856
+ taskId: string;
857
+ taskRevision: number;
858
+ milestoneId: string | null;
859
+ milestoneDisplayNumber: number | null;
860
+ taskDisplayNumber: number | null;
861
+ briefHash: string;
862
+ planHash: string | null;
863
+ knowledgeMapRevision: number | null;
864
+ knowledgeMapHash: string | null;
865
+ /** Missing only on legacy sidecar events written before canonical Milestone dependencies. */
866
+ dependencyBinding?: MilestoneDependencyBinding | null;
867
+ expectedNext: string;
868
+ delegate: string;
869
+ grantId: string | null;
870
+ claimTokenHash: string;
871
+ expiresAt: string;
872
+ eventType: TaskHandoffEventType;
873
+ coordinationLevel: TaskCoordinationLevel;
874
+ actor: string;
875
+ targetActor: string | null;
876
+ machineEvidence: TaskHandoffMachineEvidence;
877
+ writerLeaseTokenHash: string | null;
878
+ reason: string;
879
+ handback: TaskHandbackRecord | null;
880
+ }
881
+
882
+ export interface MilestoneScopeSnapshot {
883
+ outcome: string;
884
+ successSignal: string;
885
+ acceptance: string[];
886
+ checks: string[];
887
+ taskIds: string[];
888
+ memberships: MilestoneMembership[];
889
+ }
890
+
891
+ export interface AuditedRemediationEvidence {
892
+ blockedTaskId: string;
893
+ blockedTaskRevision: number;
894
+ blockedBriefHash: string;
895
+ blockedPlanHash: string;
896
+ planRiskAuditEventId: string;
897
+ planRiskAuditEventHash: string;
898
+ remediationTaskId: string;
899
+ predecessorTaskIds: string[];
900
+ }
901
+
902
+ export interface MilestoneScopeChangeEvent extends SidecarEventRecord {
903
+ milestoneId: string;
904
+ previousMilestoneRevision: number;
905
+ previousPlanHash: string | null;
906
+ previousMembershipRevision: number;
907
+ candidatePlanHash: string;
908
+ candidateMembershipRevision: number;
909
+ before: MilestoneScopeSnapshot;
910
+ after: MilestoneScopeSnapshot;
911
+ actor: string;
912
+ confirmationCodeBindingHash: string;
913
+ authorizationMode?: 'human' | 'milestone-autonomy' | 'audited-remediation';
914
+ autonomyContractEventHash?: string | null;
915
+ remediationEvidence?: AuditedRemediationEvidence | null;
916
+ }
917
+
918
+ export interface AdoptionTaskStepSnapshot {
919
+ stepId: string;
920
+ status: 'completed' | 'skipped';
921
+ evidenceHash: string | null;
922
+ }
923
+
924
+ export interface AdoptionTaskBaseline {
925
+ taskId: string;
926
+ taskRevision: number;
927
+ status: Exclude<TaskStatus, 'merged' | 'cancelled'>;
928
+ completedSteps: AdoptionTaskStepSnapshot[];
929
+ remainingStepIds: string[];
930
+ }
931
+
932
+ export interface AdoptionRepositoryIdentity {
933
+ repositoryRoot: string;
934
+ gitCommonDir: string;
935
+ }
936
+
937
+ export interface AdoptionPostureEvent extends SidecarEventRecord {
938
+ projectId: string;
939
+ eventType: AdoptionPostureEventType;
940
+ actor: string | null;
941
+ packageVersion: string;
942
+ /** Persisted protocol evidence. Version 1 remains readable for the exact state-schema-v2 compatibility boundary. */
943
+ protocolVersion: 1 | typeof PROTOCOL_VERSION;
944
+ stateSchemaVersion: typeof STATE_SCHEMA_VERSION;
945
+ adoptionBoundaryAt: string;
946
+ baselineDigestHash: string;
947
+ sidecarBaselineHash: string;
948
+ confirmationCodeBindingHash: string | null;
949
+ repositoryIdentity: AdoptionRepositoryIdentity;
950
+ terminalMilestones: Array<{
951
+ milestoneId: string;
952
+ revision: number;
953
+ status: Extract<MilestoneStatus, 'accepted' | 'cancelled'>;
954
+ }>;
955
+ terminalTasks: Array<{
956
+ taskId: string;
957
+ revision: number;
958
+ status: Extract<TaskStatus, 'merged' | 'cancelled'>;
959
+ }>;
960
+ activeTasks: AdoptionTaskBaseline[];
961
+ }
962
+
963
+ export interface MilestoneTransactionJournalFileSnapshot {
964
+ exists: boolean;
965
+ contentHash: string | null;
966
+ contentBase64: string | null;
967
+ contentPath: string | null;
968
+ }
969
+
970
+ export interface MilestoneTransactionJournalTarget {
971
+ path: string;
972
+ preimage: MilestoneTransactionJournalFileSnapshot;
973
+ staged: MilestoneTransactionJournalFileSnapshot;
974
+ }
975
+
976
+ export interface MilestoneTransactionJournal {
977
+ transactionId: string;
978
+ milestoneId: string;
979
+ expectedMilestoneRevision: number;
980
+ actor: string;
981
+ confirmationCodeBindingHash: string;
982
+ phase: MilestoneTransactionPhase;
983
+ targetFiles: MilestoneTransactionJournalTarget[];
984
+ preparedAt: string;
985
+ updatedAt: string;
986
+ }
987
+
988
+ export interface TaskContextRefreshResult {
989
+ authority?: 'planning-only' | 'execution';
990
+ mode: 'delegated-content-only' | 'delegated-plan-bounded-supporting-source';
991
+ transitions: string[];
992
+ addedSources: Array<Pick<KnowledgeSource, 'id' | 'path' | 'category' | 'scope' | 'authority'>>;
993
+ knowledgeMap: ProjectKnowledgeMap;
994
+ task: TaskState;
995
+ }
996
+
997
+ export type ObservationReasonCode =
998
+ | 'PROJECT_REGISTRATION_MISSING'
999
+ | 'PROJECT_REPOSITORY_ROOT_UNBOUND'
1000
+ | 'PROJECT_RECOVERY_REQUIRED'
1001
+ | 'MILESTONE_RECOVERY_REQUIRED'
1002
+ | 'TASK_RECOVERY_REQUIRED'
1003
+ | 'TASK_TRANSACTION_INTEGRITY_FAILED'
1004
+ | 'TASK_OPERATION_IN_PROGRESS'
1005
+ | 'STALE_TASK_OPERATION'
1006
+ | 'ACTIVE_WRITER_LEASE'
1007
+ | 'STALE_WRITER_LEASE'
1008
+ | 'ADOPTION_MISSING';
1009
+
1010
+ export interface ObservedProjectTransaction {
1011
+ transactionId: string;
1012
+ kind: string;
1013
+ phase: 'prepared' | 'applying' | 'applied' | 'rolled_back';
1014
+ preparedAt: string;
1015
+ ownerActive: boolean;
1016
+ }
1017
+
1018
+ export interface ObservedMilestoneTransaction {
1019
+ milestoneId: string;
1020
+ transactionId: string;
1021
+ phase: MilestoneTransactionPhase;
1022
+ preparedAt: string;
1023
+ updatedAt: string;
1024
+ }
1025
+
1026
+ export interface ObservedTaskTransaction {
1027
+ transitionId: 'task.plan.corrective-replan' | 'task.coordination.corrective-yield';
1028
+ taskId: string;
1029
+ transactionId: string;
1030
+ phase: 'intent' | 'applying' | 'published-pending-readback' | 'completed';
1031
+ phaseRevision: number;
1032
+ updatedAt: string;
1033
+ }
1034
+
1035
+ export interface CorruptObservedTaskTransaction {
1036
+ taskId: string;
1037
+ transactionId: string;
1038
+ reason: 'journal-invalid';
1039
+ }
1040
+
1041
+ export interface PublicWriterLease {
1042
+ schemaVersion: typeof STATE_SCHEMA_VERSION;
1043
+ entityId: string;
1044
+ owner: string;
1045
+ pid: number;
1046
+ hostname: string;
1047
+ acquiredAt: string;
1048
+ heartbeatAt: string;
1049
+ expiresAt: string;
1050
+ stale: boolean;
1051
+ }
1052
+
1053
+ export interface PublicCoreTaskOperation {
1054
+ schemaVersion: typeof STATE_SCHEMA_VERSION;
1055
+ entityId: string;
1056
+ operationId: string;
1057
+ transitionId: string;
1058
+ owner: 'workflow-core';
1059
+ acquiredAt: string;
1060
+ expiresAt: string;
1061
+ stale: boolean;
1062
+ }
1063
+
1064
+ export interface PublicWriterLeaseDiagnostic extends PublicWriterLease {
1065
+ tokenFingerprint: string;
1066
+ }
1067
+
1068
+ export interface PublicWriterLeaseRepairResult extends PublicWriterLeaseDiagnostic {
1069
+ repaired: true;
1070
+ }
1071
+
1072
+ export interface WriterCredentialStatus {
1073
+ disposition: 'issued' | 'renewed';
1074
+ }
1075
+
1076
+ export type WriterCredentialResult =
1077
+ | { disposition: 'issued'; token: string }
1078
+ | { disposition: 'renewed' };
1079
+
1080
+ export interface MilestoneObservationRepairCommand {
1081
+ command: 'milestone recover';
1082
+ cataloged: false;
1083
+ projectId: string;
1084
+ milestoneIds: string[];
1085
+ transactionIds: string[];
1086
+ }
1087
+
1088
+ export interface LeaseObservationRepairCommand {
1089
+ command: 'locks repair';
1090
+ cataloged: false;
1091
+ projectId: string;
1092
+ entityIds: string[];
1093
+ }
1094
+
1095
+ export interface TaskTransactionObservationRepairCommand {
1096
+ command: 'task corrective-replan-recover' | 'task corrective-yield-recover';
1097
+ cataloged: false;
1098
+ available: true;
1099
+ projectId: string;
1100
+ taskIds: string[];
1101
+ transactionIds: string[];
1102
+ }
1103
+
1104
+ export type ObservationRepairCommand =
1105
+ | MilestoneObservationRepairCommand
1106
+ | LeaseObservationRepairCommand
1107
+ | TaskTransactionObservationRepairCommand;
1108
+
1109
+ export interface WorkflowObservation {
1110
+ kind: 'assessment' | 'repair' | 'blocked';
1111
+ reasonCodes: ObservationReasonCode[];
1112
+ stateRootPresent: boolean;
1113
+ projectRootPresent: boolean;
1114
+ lockRootPresent: boolean;
1115
+ missingRegistration: boolean;
1116
+ repositoryRootBound: boolean;
1117
+ adoptionAssessed: boolean;
1118
+ missingAdoption: boolean;
1119
+ pendingProjectTransactions: ObservedProjectTransaction[];
1120
+ pendingMilestoneTransactions: ObservedMilestoneTransaction[];
1121
+ pendingTaskTransactions: ObservedTaskTransaction[];
1122
+ corruptTaskTransactions: CorruptObservedTaskTransaction[];
1123
+ coreTaskOperations: PublicCoreTaskOperation[];
1124
+ leases: PublicWriterLease[];
1125
+ availableRepairTransitionId: null;
1126
+ repair: ObservationRepairCommand | null;
1127
+ }
1128
+
1129
+ export interface UpdatePreflightResult {
1130
+ safe: boolean;
1131
+ packageVersion: string;
1132
+ protocolVersion: typeof PROTOCOL_VERSION;
1133
+ stateSchemaVersion: typeof STATE_SCHEMA_VERSION;
1134
+ projectId: string;
1135
+ repositoryRoot: string;
1136
+ clean: boolean;
1137
+ changedFiles: string[];
1138
+ runningSteps: Array<{ taskId: string; stepId: string }>;
1139
+ activeLeases: PublicWriterLease[];
1140
+ staleLeases: PublicWriterLease[];
1141
+ blockers: string[];
1142
+ workflowVersions: {
1143
+ runtime: string;
1144
+ declared: string | null;
1145
+ locked: string | null;
1146
+ installed: string | null;
1147
+ currentBranch: string | null;
1148
+ milestoneBases: Array<{ branch: string; version: string | null; milestoneIds: string[] }>;
1149
+ };
1150
+ dependencyTransport: {
1151
+ safe: boolean;
1152
+ requiredAction: string | null;
1153
+ };
1154
+ observation: WorkflowObservation;
1155
+ }
1156
+
1157
+ export interface DependencyProvenanceRecoveryRecord {
1158
+ commitSha: string;
1159
+ parentCommitSha: string;
1160
+ packageName: string;
1161
+ packageVersion: string;
1162
+ files: ['package-lock.json', 'package.json'];
1163
+ actor: string;
1164
+ reason: string;
1165
+ recordedAt: string;
1166
+ retainedHistoricalCommits?: string[];
1167
+ activeDownstreamProof?: {
1168
+ activeStepId: string;
1169
+ planHash: string;
1170
+ dirtyFiles: string[];
1171
+ dirtyWorktreeHash: string;
1172
+ invalidatedStepIds: string[];
1173
+ };
1174
+ downstreamProofReplan?: DownstreamProofReplanCompatibility;
1175
+ historicalStepProvenance?: HistoricalStepDependencyCompatibility;
1176
+ planIntegrity?: PlanIntegrityUpdateCompatibility;
1177
+ rootCauseReplan?: RootCauseReplanDirtyCarryoverCompatibility;
1178
+ }
1179
+
1180
+ export interface RootCauseReplanDirtyCarryoverCompatibility {
1181
+ kind: 'root-cause-corrective-replan-dirty-carryover';
1182
+ taskId: string;
1183
+ sourceTaskRevision: number;
1184
+ stepId: string;
1185
+ sourcePlanHash: string;
1186
+ sourcePlanSemanticHash: string;
1187
+ replacementPlanHash: string;
1188
+ replacementPlanSemanticHash: string;
1189
+ sourceHeadCommit: string;
1190
+ remediationEvents: Array<{ eventId: string; eventHash: string; attemptOrdinal: number }>;
1191
+ terminalRemediationEventId: string;
1192
+ terminalRemediationEventHash: string;
1193
+ terminalExecutionTaskRevision: number;
1194
+ repeatedCauseFingerprint: string;
1195
+ correctiveYieldEventId: string | null;
1196
+ correctiveYieldEventHash: string | null;
1197
+ unclaimedExecutionBoundary?: UnclaimedExecutionBoundary;
1198
+ dirtyFiles: string[];
1199
+ dirtyWorktreeHash: string;
1200
+ replacementPlanRiskAuditEventId: string;
1201
+ replacementPlanRiskAuditEventHash: string;
1202
+ executionAuthorizationHash: string;
1203
+ executionAuthorizationHead: string;
1204
+ completedStepsHash: string;
1205
+ c1ClaimEventId: string;
1206
+ c1ClaimEventHash: string;
1207
+ claimant: string;
1208
+ compatibilityHash: string;
1209
+ }
1210
+
1211
+ export interface HistoricalStepDependencyCompatibility {
1212
+ activeStepId: string;
1213
+ planHash: string;
1214
+ dirtyFiles: string[];
1215
+ dirtyWorktreeHash: string;
1216
+ retainedCommitSha: string;
1217
+ }
1218
+
1219
+ export interface PlanIntegrityUpdateCompatibility {
1220
+ stepId: string;
1221
+ planHash: string;
1222
+ conflictHash: string;
1223
+ dirtyFiles: string[];
1224
+ dirtyWorktreeHash: string;
1225
+ remediationEventIds: string[];
1226
+ mode?:
1227
+ | 'failed-step-conflict'
1228
+ | 'post-rebind-scope-adoption'
1229
+ | 'post-rebind-dirty-carryover'
1230
+ | 'navigation-fix-dirty-carryover';
1231
+ scopeExtensions?: string[];
1232
+ }
1233
+
1234
+ export interface DependencyProvenanceRecoveryPreflight {
1235
+ eligible: boolean;
1236
+ action:
1237
+ | 'update dependency-provenance-recover'
1238
+ | 'update downstream-proof-dependency-recover'
1239
+ | 'update historical-step-dependency-recover'
1240
+ | null;
1241
+ projectId: string;
1242
+ taskId: string;
1243
+ taskRevision: number;
1244
+ commitSha: string | null;
1245
+ parentCommitSha: string | null;
1246
+ packageVersion: string;
1247
+ changedFiles: string[];
1248
+ /** Oldest-to-newest exact dependency-only commits recovered atomically. */
1249
+ dependencyCommits: Array<{
1250
+ commitSha: string;
1251
+ parentCommitSha: string;
1252
+ packageVersion: string;
1253
+ }>;
1254
+ retainedHistoricalCommits: string[];
1255
+ activeDownstreamProof: {
1256
+ activeStepId: string;
1257
+ planHash: string;
1258
+ dirtyFiles: string[];
1259
+ dirtyWorktreeHash: string;
1260
+ invalidatedStepIds: string[];
1261
+ } | null;
1262
+ historicalStepProvenance: HistoricalStepDependencyCompatibility | null;
1263
+ /** Derived from an existing, native-evidence-bound navigation checkpoint; never caller authority. */
1264
+ retainedNavigationCarryover?: PlanIntegrityUpdateCompatibility | null;
1265
+ blockers: string[];
1266
+ }
1267
+
1268
+ export interface HistoricalStepProvenanceRecoveryRecord {
1269
+ commitSha: string;
1270
+ actor: string;
1271
+ reason: string;
1272
+ recordedAt: string;
1273
+ sourceFinalAcceptanceRecordedAt: string;
1274
+ sourcePlanHash: string;
1275
+ sourceResultHash: string;
1276
+ sourceEvidenceHash: string;
1277
+ }
1278
+
1279
+ export interface HistoricalStepProvenanceRecoveryPreflight {
1280
+ eligible: boolean;
1281
+ action: 'task historical-step-provenance-recover' | null;
1282
+ projectId: string;
1283
+ taskId: string;
1284
+ taskRevision: number;
1285
+ briefHash: string;
1286
+ planHash: string | null;
1287
+ headCommit: string;
1288
+ activeStepId: string | null;
1289
+ dirtyFiles: string[];
1290
+ commitSha: string | null;
1291
+ sourceFinalAcceptanceRecordedAt: string | null;
1292
+ blockers: string[];
1293
+ }
1294
+
1295
+ export interface MilestoneProgressStepProjection {
1296
+ ordinal: string;
1297
+ stepId: string;
1298
+ title: string;
1299
+ status: StepStatus;
1300
+ }
1301
+
1302
+ export interface MilestoneProgressTaskProjection {
1303
+ ordinal: string;
1304
+ taskId: string;
1305
+ title: string;
1306
+ status: TaskStatus;
1307
+ revision: number;
1308
+ disposition: MilestoneMembership['disposition'];
1309
+ membershipReason: string;
1310
+ dependencyState: 'canonical' | 'legacy-unknown';
1311
+ dependsOnTaskIds: string[];
1312
+ unsatisfiedPredecessors: Array<{
1313
+ taskId: string;
1314
+ disposition: MilestoneMembership['disposition'] | 'missing';
1315
+ status: TaskStatus | 'missing';
1316
+ }>;
1317
+ runnable: boolean;
1318
+ dependencyBlockReason: string | null;
1319
+ replacementForTaskId: string | null;
1320
+ replacedByTaskId: string | null;
1321
+ stepsCompleted: number;
1322
+ stepsTotal: number;
1323
+ steps: MilestoneProgressStepProjection[];
1324
+ }
1325
+
1326
+ export interface MilestoneProgressProjection {
1327
+ readOnly: true;
1328
+ projectId: string;
1329
+ milestoneId: string;
1330
+ milestoneTitle: string;
1331
+ milestoneStatus: MilestoneStatus;
1332
+ milestoneRevision: number;
1333
+ membershipRevision: number;
1334
+ tasksCompleted: number;
1335
+ tasksRequired: number;
1336
+ tasks: MilestoneProgressTaskProjection[];
1337
+ }
1338
+
1339
+ export interface TaskState extends RevisionedRecord {
1340
+ kind: 'task';
1341
+ status: TaskStatus;
1342
+ title: string;
1343
+ slug: string;
1344
+ discoveryId: string;
1345
+ milestoneId: string | null;
1346
+ repositoryRoot: string;
1347
+ baseBranch: string;
1348
+ baseCommit: string | null;
1349
+ taskBranch: string | null;
1350
+ workspaceOwner: WorkspaceOwner | null;
1351
+ briefHash: string;
1352
+ planHash: string | null;
1353
+ planObjective: string | null;
1354
+ resultHash: string | null;
1355
+ evidenceHash: string | null;
1356
+ requirements: string[];
1357
+ acceptance: string[];
1358
+ risks: string[];
1359
+ knowledgeImpact: KnowledgeImpact | null;
1360
+ knowledgeImpactReason: string | null;
1361
+ knowledgeTargets: KnowledgeTarget[];
1362
+ knowledgeMapRevision: number | null;
1363
+ knowledgeMapHash: string | null;
1364
+ graphUse: GraphUse | null;
1365
+ /** Optional structural production-path contract persisted with the approved Plan. */
1366
+ productionEdges?: ProductionEdgeInput[];
1367
+ /** Explicit structural boundary acknowledgement; runtime-composition PRA remains authoritative. */
1368
+ requiresProductionEdges?: boolean;
1369
+ steps: TaskStep[];
1370
+ authorizations: AuthorizationEvent[];
1371
+ knowledgeRebinds: TaskKnowledgeRebindRecord[];
1372
+ review: ReviewRecord;
1373
+ blockReason: string | null;
1374
+ mergedCommit: string | null;
1375
+ systemCommits: string[];
1376
+ /** Durable unvalidated merge checkpoint; never approval or successful check evidence. */
1377
+ pendingBaseSyncValidation?: { baseCommit: string; syncCommit: string; checksHash: string; headCommit: string };
1378
+ /** Product commits retained after bounded invalidation of stale completed-Step authority. */
1379
+ invalidatedStepCommits?: string[];
1380
+ /** Audit trail for bounded recovery of previously reviewed Step commits omitted by a corrective Plan. */
1381
+ historicalStepProvenanceRecoveries?: HistoricalStepProvenanceRecoveryRecord[];
1382
+ /** Audit trail for bounded adoption of exact Workflow dependency-only commits. */
1383
+ dependencyProvenanceRecoveries?: DependencyProvenanceRecoveryRecord[];
1384
+ /** Set only by the beta replacement transaction; absent on legacy states. */
1385
+ replacementForTaskId?: string | null;
1386
+ /** Set only on the terminal historical Task consumed by a replacement transaction. */
1387
+ replacedByTaskId?: string | null;
1388
+ }
1389
+
1390
+ export interface MilestoneState extends RevisionedRecord {
1391
+ kind: 'milestone';
1392
+ status: MilestoneStatus;
1393
+ title: string;
1394
+ discoveryId: string;
1395
+ outcome: string;
1396
+ successSignal: string;
1397
+ acceptance: string[];
1398
+ baseBranch: string;
1399
+ taskIds: string[];
1400
+ memberships: MilestoneMembership[];
1401
+ checks: string[];
1402
+ membershipRevision: number;
1403
+ authorizations: AuthorizationEvent[];
1404
+ planHash: string | null;
1405
+ resultHash: string | null;
1406
+ evidenceHash: string | null;
1407
+ acceptedHead: string | null;
1408
+ cancellationReason: string | null;
1409
+ }
1410
+
1411
+ export interface MilestoneMembership {
1412
+ taskId: string;
1413
+ disposition: 'required' | 'waived' | 'cancelled';
1414
+ reason: string;
1415
+ /** Missing only on legacy persisted Milestones whose dependency graph is unknown. */
1416
+ dependsOnTaskIds?: string[];
1417
+ }
1418
+
1419
+ export interface MilestonePlanMembershipInput extends MilestoneMembership {
1420
+ dependsOnTaskIds: string[];
1421
+ }
1422
+
1423
+ export interface MilestonePlanInput {
1424
+ outcome: string;
1425
+ successSignal: string;
1426
+ acceptance: string[];
1427
+ memberships: MilestonePlanMembershipInput[];
1428
+ checks: string[];
1429
+ }
1430
+
1431
+ export interface MilestoneFinalAcceptanceGate {
1432
+ kind: 'milestone_final_acceptance';
1433
+ milestoneId: string;
1434
+ revision: number;
1435
+ planHash: string | null;
1436
+ resultHash: string;
1437
+ evidenceHash: string;
1438
+ headCommit: string;
1439
+ confirmationCode: string;
1440
+ }
1441
+
1442
+ export interface ProjectRecord {
1443
+ schemaVersion: typeof STATE_SCHEMA_VERSION;
1444
+ projectId: string;
1445
+ gitCommonDir: string;
1446
+ repositoryRoots: string[];
1447
+ createdAt: string;
1448
+ updatedAt: string;
1449
+ }
1450
+
1451
+ export interface WriterLease {
1452
+ schemaVersion: typeof STATE_SCHEMA_VERSION;
1453
+ entityId: string;
1454
+ token: string;
1455
+ owner: string;
1456
+ pid: number;
1457
+ hostname: string;
1458
+ acquiredAt: string;
1459
+ heartbeatAt: string;
1460
+ expiresAt: string;
1461
+ }
1462
+
1463
+ export interface ContextEnvelope {
1464
+ protocolVersion: typeof PROTOCOL_VERSION;
1465
+ packageVersion: string;
1466
+ role: WorkflowRole;
1467
+ objective: string;
1468
+ inputs: string[];
1469
+ allowedReads: string[];
1470
+ allowedWrites: string[];
1471
+ commands: string[];
1472
+ forbiddenScope: string[];
1473
+ resultSchema: Record<string, unknown>;
1474
+ stopConditions: string[];
1475
+ contextBudget: 'small' | 'medium' | 'large';
1476
+ taskId: string;
1477
+ stepId: string;
1478
+ expectedRevision: number;
1479
+ writerToken: string | null;
1480
+ knowledgeMap: {
1481
+ revision: number;
1482
+ hash: string;
1483
+ status: KnowledgeMapStatus;
1484
+ };
1485
+ knowledgeSources: string[];
1486
+ }
1487
+
1488
+ export type EntityState =
1489
+ | DiscoveryState
1490
+ | TaskState
1491
+ | MilestoneState
1492
+ | ProjectKnowledgeMap
1493
+ | GraphBinding
1494
+ | DelegationGrant;