@abelxiaoxing/cadence 1.3.0 → 1.4.1

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 (76) hide show
  1. package/README.md +172 -13
  2. package/agents/design-explorer.md +17 -11
  3. package/agents/diagnosis-worker.md +9 -1
  4. package/agents/implementation-worker.md +3 -1
  5. package/config/plan-draft.example.json +122 -0
  6. package/config/plan-draft.multiple-tasks.example.json +345 -0
  7. package/package.json +9 -5
  8. package/prompts/abel-design.md +141 -38
  9. package/prompts/abel-diagnose.md +10 -1
  10. package/prompts/abel-implement.md +118 -20
  11. package/prompts/abel-init.md +9 -2
  12. package/src/activity-contracts.ts +82 -0
  13. package/src/apply-transaction.ts +16 -14
  14. package/src/artifact-store.ts +17 -0
  15. package/src/candidate-artifact.ts +143 -0
  16. package/src/candidate-patch.ts +33 -12
  17. package/src/candidate-workspace.ts +74 -0
  18. package/src/canonical.ts +16 -0
  19. package/src/change-contract-schema.ts +191 -0
  20. package/src/change-contract.ts +273 -0
  21. package/src/change-verification.ts +896 -0
  22. package/src/child-model.ts +129 -0
  23. package/src/child-session.ts +296 -328
  24. package/src/contracts.ts +325 -109
  25. package/src/control-contracts.ts +51 -1
  26. package/src/delivery-compiler.ts +241 -141
  27. package/src/delivery-revision.ts +42 -0
  28. package/src/design-control.ts +182 -15
  29. package/src/design-diagnostics.ts +150 -0
  30. package/src/design-journal.ts +216 -72
  31. package/src/durable-contracts.ts +210 -0
  32. package/src/durable-workflow.ts +963 -0
  33. package/src/evidence-draft.ts +122 -0
  34. package/src/implement-graph.ts +14 -16
  35. package/src/implement-plan.ts +70 -0
  36. package/src/index.ts +341 -1405
  37. package/src/isolation-backend.ts +84 -23
  38. package/src/model-source.ts +22 -0
  39. package/src/package-candidate.ts +224 -0
  40. package/src/package-delivery.ts +486 -0
  41. package/src/package-verification.ts +509 -0
  42. package/src/package-workflow.ts +253 -0
  43. package/src/packet-runtime.ts +27 -48
  44. package/src/parent-provider.ts +86 -198
  45. package/src/phase-execution.ts +2248 -0
  46. package/src/pi-adapter.ts +19 -0
  47. package/src/plan-draft-summary.ts +146 -0
  48. package/src/plan-draft.ts +493 -0
  49. package/src/route-policy.ts +1 -11
  50. package/src/run-state.ts +4 -16
  51. package/src/run-store.ts +5 -144
  52. package/src/scoped-grep-worker.mjs +23 -0
  53. package/src/scoped-tools.ts +312 -116
  54. package/src/sqlite-schema.ts +171 -0
  55. package/src/storage-schema.ts +352 -0
  56. package/src/subagent-activity.ts +46 -67
  57. package/src/submit-tool.ts +40 -61
  58. package/src/task-ledger.ts +14 -55
  59. package/src/transport-budget.ts +32 -0
  60. package/src/verification-capability.ts +298 -102
  61. package/src/verification-environment.ts +213 -0
  62. package/src/verification-identity.ts +77 -0
  63. package/src/worker-broker.ts +134 -91
  64. package/src/workflow-engine.ts +28 -8285
  65. package/src/workflow-policy.ts +1388 -0
  66. package/src/workflow-recovery-policy.ts +95 -0
  67. package/src/workflow-scheduling.ts +105 -0
  68. package/src/workflow-state-machine.ts +4086 -0
  69. package/src/workflow-status.ts +384 -0
  70. package/src/workspace-io-entry.mjs +58 -0
  71. package/src/workspace-io-worker.mjs +991 -0
  72. package/src/workspace-io.ts +84 -0
  73. package/src/workspace-store.ts +125 -19
  74. package/skills/abel-workflow/SKILL.md +0 -205
  75. package/src/empty-resource-loader.ts +0 -38
  76. package/src/parent-payload-bridge.ts +0 -523
@@ -13,6 +13,12 @@ export const CONTROL_COMMANDS = [
13
13
 
14
14
  export const CONTROL_STAGES = ["abel-implement"] as const;
15
15
 
16
+ export interface RecoveryRequest {
17
+ incidentKey: string;
18
+ failureSequence: number;
19
+ reason: "parent-directed-retry" | "route-changed" | "context-extended";
20
+ }
21
+
16
22
  const CONTROL_SCHEMA_PROPERTIES = {
17
23
  command: {
18
24
  type: "string",
@@ -24,6 +30,19 @@ const CONTROL_SCHEMA_PROPERTIES = {
24
30
  deliveryRevision: { type: "integer", minimum: 1 },
25
31
  receiptHash: { type: "string" },
26
32
  routeId: { type: "string" },
33
+ recovery: {
34
+ type: "object",
35
+ additionalProperties: false,
36
+ properties: {
37
+ incidentKey: { type: "string", pattern: "^[a-f0-9]{64}$" },
38
+ failureSequence: { type: "integer", minimum: 1 },
39
+ reason: {
40
+ type: "string",
41
+ enum: ["parent-directed-retry", "route-changed", "context-extended"],
42
+ },
43
+ },
44
+ required: ["incidentKey", "failureSequence", "reason"],
45
+ },
27
46
  } as const;
28
47
 
29
48
  type ControlSchemaField = Exclude<
@@ -61,6 +80,15 @@ export const CONTROL_COMMAND_PARAMETERS = {
61
80
  commandSchema("start", ["stage", "change", "operationId"]),
62
81
  commandSchema("status", ["stage", "change"]),
63
82
  commandSchema("resume", ["stage", "change", "operationId"]),
83
+ commandSchema("resume", ["stage", "change", "operationId", "recovery"]),
84
+ commandSchema("resume", [
85
+ "stage",
86
+ "change",
87
+ "operationId",
88
+ "deliveryRevision",
89
+ "receiptHash",
90
+ "recovery",
91
+ ]),
64
92
  commandSchema("resume", [
65
93
  "stage",
66
94
  "change",
@@ -102,6 +130,7 @@ export interface ResumeControlCommand extends ControlBase {
102
130
  operationId: string;
103
131
  deliveryRevision?: number;
104
132
  receiptHash?: string;
133
+ recovery?: RecoveryRequest;
105
134
  }
106
135
 
107
136
  export interface RebindControlCommand extends ControlBase {
@@ -144,6 +173,7 @@ const CONTROL_TOOL_FIELDS = new Set([
144
173
  "deliveryRevision",
145
174
  "receiptHash",
146
175
  "routeId",
176
+ "recovery",
147
177
  ]);
148
178
 
149
179
  const COMMAND_FIELDS: Readonly<
@@ -158,6 +188,7 @@ const COMMAND_FIELDS: Readonly<
158
188
  "operationId",
159
189
  "deliveryRevision",
160
190
  "receiptHash",
191
+ "recovery",
161
192
  ]),
162
193
  rebind: new Set(["command", "stage", "change", "operationId", "routeId"]),
163
194
  cancel: new Set(["command", "stage", "change", "operationId"]),
@@ -282,13 +313,32 @@ export function validateControlCommand(
282
313
  !hasExactKeys(
283
314
  value,
284
315
  [...common, "operationId"],
285
- ["deliveryRevision", "receiptHash"],
316
+ ["deliveryRevision", "receiptHash", "recovery"],
286
317
  ) ||
287
318
  !validChange(value.change) ||
288
319
  !validOperationId(value.operationId)
289
320
  ) {
290
321
  break;
291
322
  }
323
+ if (
324
+ value.recovery !== undefined &&
325
+ (!isRecord(value.recovery) ||
326
+ !hasExactKeys(value.recovery, [
327
+ "incidentKey",
328
+ "failureSequence",
329
+ "reason",
330
+ ]) ||
331
+ typeof value.recovery.incidentKey !== "string" ||
332
+ !SHA256.test(value.recovery.incidentKey) ||
333
+ !Number.isSafeInteger(value.recovery.failureSequence) ||
334
+ (value.recovery.failureSequence as number) < 1 ||
335
+ ![
336
+ "parent-directed-retry",
337
+ "route-changed",
338
+ "context-extended",
339
+ ].includes(String(value.recovery.reason)))
340
+ )
341
+ break;
292
342
  const hasRevision = value.deliveryRevision !== undefined;
293
343
  const hasReceipt = value.receiptHash !== undefined;
294
344
  if (hasRevision !== hasReceipt) break;