@abelxiaoxing/cadence 1.4.0 → 1.5.0

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 (66) hide show
  1. package/README.md +130 -8
  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/config/plan-draft.quick.example.json +78 -0
  8. package/package.json +10 -4
  9. package/prompts/abel-design.md +101 -44
  10. package/prompts/abel-implement.md +9 -0
  11. package/src/activity-contracts.ts +82 -0
  12. package/src/candidate-artifact.ts +143 -0
  13. package/src/candidate-patch.ts +31 -11
  14. package/src/candidate-workspace.ts +74 -0
  15. package/src/change-contract-schema.ts +191 -0
  16. package/src/change-contract.ts +5 -0
  17. package/src/change-verification.ts +920 -0
  18. package/src/child-budget.ts +58 -0
  19. package/src/child-model.ts +142 -0
  20. package/src/child-session.ts +289 -326
  21. package/src/contracts.ts +200 -76
  22. package/src/delivery-compiler.ts +105 -120
  23. package/src/delivery-revision.ts +42 -0
  24. package/src/design-control.ts +113 -4
  25. package/src/design-diagnostics.ts +150 -0
  26. package/src/durable-contracts.ts +213 -0
  27. package/src/durable-workflow.ts +148 -3570
  28. package/src/evidence-draft.ts +122 -0
  29. package/src/execution-profile.ts +38 -0
  30. package/src/implement-graph.ts +3 -0
  31. package/src/implement-plan.ts +70 -0
  32. package/src/index.ts +59 -522
  33. package/src/isolation-backend.ts +62 -40
  34. package/src/model-source.ts +22 -0
  35. package/src/operator-cli-entry.mjs +24 -0
  36. package/src/operator-cli.mjs +1421 -0
  37. package/src/operator-tools.ts +249 -0
  38. package/src/package-candidate.ts +227 -0
  39. package/src/package-verification.ts +86 -8
  40. package/src/package-workflow.ts +291 -0
  41. package/src/packet-runtime.ts +27 -48
  42. package/src/parent-provider.ts +86 -198
  43. package/src/phase-execution.ts +2248 -0
  44. package/src/pi-adapter.ts +19 -0
  45. package/src/plan-draft-summary.ts +149 -0
  46. package/src/plan-draft.ts +493 -0
  47. package/src/single-task-draft.ts +142 -0
  48. package/src/subagent-activity.ts +32 -66
  49. package/src/submit-tool.ts +20 -59
  50. package/src/transport-budget.ts +52 -0
  51. package/src/verification-capability.ts +5 -3
  52. package/src/verification-diagnostics.ts +76 -0
  53. package/src/verification-environment-io.ts +280 -0
  54. package/src/verification-environment.ts +56 -154
  55. package/src/verification-scan.ts +64 -0
  56. package/src/worker-broker.ts +39 -57
  57. package/src/workflow-policy.ts +14 -53
  58. package/src/workflow-recovery-policy.ts +95 -0
  59. package/src/workflow-scheduling.ts +105 -0
  60. package/src/workflow-state-machine.ts +105 -497
  61. package/src/workflow-status.ts +384 -0
  62. package/src/workspace-io-entry.mjs +19 -1
  63. package/src/workspace-io-worker.mjs +275 -50
  64. package/src/workspace-io.ts +6 -1
  65. package/src/empty-resource-loader.ts +0 -38
  66. package/src/parent-payload-bridge.ts +0 -523
@@ -0,0 +1,122 @@
1
+ import { StringEnum } from "@earendil-works/pi-ai";
2
+ import { Type } from "typebox";
3
+ import { AGENTS_IMPACTS, RELATIVE_PATH_PATTERN } from "./contracts.ts";
4
+
5
+ // The authoring boundary is smaller than the sealed EvidenceResult. Only
6
+ // code-owned identity and explicitly advisory fields may be omitted.
7
+ const advisoryStrings = () => Type.Optional(Type.Array(Type.String()));
8
+ const relativePath = () =>
9
+ Type.String({
10
+ pattern: RELATIVE_PATH_PATTERN,
11
+ minLength: 1,
12
+ maxLength: 512,
13
+ description:
14
+ "Canonical workspace-relative path or module slug; no absolute paths, ./, .., backslashes, or trailing slash.",
15
+ });
16
+ const pathSet = (minItems = 0) =>
17
+ Type.Array(relativePath(), { uniqueItems: true, minItems });
18
+
19
+ export function evidenceDraftSchema(requestId: string, role: string) {
20
+ const identity = {
21
+ id: Type.Optional(
22
+ Type.Literal(requestId, {
23
+ description:
24
+ "Omit: bound by the submit tool. If supplied, must match this request.",
25
+ }),
26
+ ),
27
+ role: Type.Optional(Type.Literal(role)),
28
+ kind: Type.Optional(Type.Literal("evidence")),
29
+ };
30
+ return role === "design-explorer"
31
+ ? Type.Object(
32
+ {
33
+ ...identity,
34
+ packet_id: Type.Optional(Type.Literal(requestId)),
35
+ module_name: relativePath(),
36
+ scope: pathSet(1),
37
+ files_read: pathSet(),
38
+ evidence: Type.Array(
39
+ Type.Object(
40
+ {
41
+ claim: Type.String({ minLength: 1 }),
42
+ path: relativePath(),
43
+ line_start: Type.Integer({ minimum: 1 }),
44
+ line_end: Type.Integer({
45
+ minimum: 1,
46
+ description:
47
+ "Inclusive end line, greater than or equal to line_start.",
48
+ }),
49
+ },
50
+ { additionalProperties: false },
51
+ ),
52
+ ),
53
+ existing_structures: advisoryStrings(),
54
+ existing_conventions: advisoryStrings(),
55
+ constraints_discovered: Type.Array(Type.String()),
56
+ open_questions: Type.Array(Type.String()),
57
+ dependencies: advisoryStrings(),
58
+ write_set_hints: Type.Optional(pathSet()),
59
+ validation_hints: advisoryStrings(),
60
+ agents_impact_hints: advisoryStrings(),
61
+ risks: Type.Array(Type.String()),
62
+ success_criteria_hints: advisoryStrings(),
63
+ },
64
+ { additionalProperties: false },
65
+ )
66
+ : Type.Object(
67
+ {
68
+ ...identity,
69
+ conclusions: Type.Array(Type.String()),
70
+ citations: Type.Array(
71
+ Type.Object(
72
+ { path: relativePath(), lines: Type.String() },
73
+ { additionalProperties: false },
74
+ ),
75
+ ),
76
+ constraints: Type.Array(Type.String()),
77
+ dependencies: advisoryStrings(),
78
+ risks: Type.Array(Type.String()),
79
+ blockingQuestions: Type.Array(Type.String()),
80
+ hints: Type.Optional(
81
+ Type.Object(
82
+ {
83
+ writeSet: pathSet(),
84
+ verification: Type.String(),
85
+ agentsImpact: StringEnum(AGENTS_IMPACTS),
86
+ },
87
+ { additionalProperties: false },
88
+ ),
89
+ ),
90
+ },
91
+ { additionalProperties: false },
92
+ );
93
+ }
94
+
95
+ export function completeEvidenceDraft(
96
+ value: unknown,
97
+ requestId: string,
98
+ role: string,
99
+ ): unknown {
100
+ if (!value || typeof value !== "object" || Array.isArray(value)) return value;
101
+ const draft = value as Record<string, unknown>;
102
+ const defaults: Record<string, unknown> = {
103
+ id: requestId,
104
+ role,
105
+ kind: "evidence",
106
+ dependencies: [],
107
+ ...(role === "design-explorer"
108
+ ? {
109
+ packet_id: requestId,
110
+ existing_structures: [],
111
+ existing_conventions: [],
112
+ write_set_hints: [],
113
+ validation_hints: [],
114
+ agents_impact_hints: [],
115
+ success_criteria_hints: [],
116
+ }
117
+ : { hints: { writeSet: [], verification: "", agentsImpact: "none" } }),
118
+ };
119
+ // Defaults mean "no advisory information supplied", never verified facts or
120
+ // authority. Explicit wrong values (including null/undefined) survive validation.
121
+ return { ...defaults, ...draft };
122
+ }
@@ -0,0 +1,38 @@
1
+ export interface ExecutionProfile {
2
+ mode: "isolated" | "local-trusted";
3
+ timeoutMs: number;
4
+ bwrapPath: string;
5
+ inheritEnvironment: string[];
6
+ }
7
+
8
+ /** Operator configuration only. Unknown modes never silently disable isolation. */
9
+ export function executionProfile(
10
+ env: NodeJS.ProcessEnv = process.env,
11
+ ): ExecutionProfile {
12
+ const mode = env.ABEL_EXECUTION_MODE ?? "isolated";
13
+ if (mode !== "isolated" && mode !== "local-trusted")
14
+ throw new Error("execution-mode-invalid");
15
+ const timeoutMs = Number(env.ABEL_VERIFICATION_TIMEOUT_MS ?? 600_000);
16
+ if (
17
+ !Number.isSafeInteger(timeoutMs) ||
18
+ timeoutMs < 1 ||
19
+ timeoutMs > 86_400_000
20
+ )
21
+ throw new Error("verification-timeout-invalid");
22
+ const inheritEnvironment = (env.ABEL_VERIFICATION_ENV ?? "")
23
+ .split(",")
24
+ .map((name) => name.trim())
25
+ .filter(Boolean);
26
+ if (
27
+ inheritEnvironment.some((name) => !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(name))
28
+ )
29
+ throw new Error("verification-environment-names-invalid");
30
+ if (mode === "isolated" && inheritEnvironment.length)
31
+ throw new Error("verification-environment-requires-trusted-mode");
32
+ return {
33
+ mode,
34
+ timeoutMs,
35
+ bwrapPath: env.ABEL_BWRAP_PATH ?? "/usr/bin/bwrap",
36
+ inheritEnvironment,
37
+ };
38
+ }
@@ -348,6 +348,9 @@ export function assessImplementGraphReadiness(
348
348
  taskId: task.taskId,
349
349
  phase,
350
350
  verificationId,
351
+ field: `phases.${phase}.verificationInputs`,
352
+ expectedPaths: [...requiredPaths].sort(),
353
+ actualPaths: [...boundPaths].sort(),
351
354
  }),
352
355
  );
353
356
  }
@@ -0,0 +1,70 @@
1
+ import type { ChangeContract } from "./change-contract.ts";
2
+ import type {
3
+ AgentsImpact,
4
+ ImplementGraphOutput,
5
+ ImplementTaskBoundary,
6
+ PhaseBoundary,
7
+ StructuredVerificationContract,
8
+ } from "./contracts.ts";
9
+
10
+ /** Complete execution contracts. No authoring references or defaults cross this boundary. */
11
+ export interface PlanTaskDraft extends Omit<ImplementTaskBoundary, "phases"> {
12
+ phases: {
13
+ red: PhaseBoundary;
14
+ green: PhaseBoundary;
15
+ refactor?: PhaseBoundary;
16
+ };
17
+ affectedVerification: StructuredVerificationContract;
18
+ repairVerification: StructuredVerificationContract;
19
+ }
20
+
21
+ export interface PlanVerification {
22
+ baseline: {
23
+ target: "task-red-contracts";
24
+ affected: "task-affected-contracts";
25
+ fullSuite: StructuredVerificationContract;
26
+ failureIdentity: "normalized";
27
+ };
28
+ change: {
29
+ affected: "task-affected-contracts";
30
+ fullSuite: StructuredVerificationContract;
31
+ postApply: StructuredVerificationContract;
32
+ };
33
+ artifactCorrection: {
34
+ maxAttempts: number;
35
+ };
36
+ repair: {
37
+ maxAttempts: number;
38
+ inBoundaryOnly: true;
39
+ approvalOnBoundaryExpansion: true;
40
+ attribution: ["pre-existing", "introduced", "unresolved", "environment"];
41
+ };
42
+ agentsCheckpoint: {
43
+ required: boolean;
44
+ verification: StructuredVerificationContract | null;
45
+ operations: PlanAgentsCheckpointOperation[];
46
+ };
47
+ }
48
+
49
+ export interface PlanAgentsCheckpointOperation {
50
+ target: string;
51
+ impact: Exclude<AgentsImpact, "none">;
52
+ taskIds: string[];
53
+ managedBlock: string | null;
54
+ }
55
+
56
+ export interface PlanTracking {
57
+ path: "tasks.md";
58
+ format: "markdown-checkbox";
59
+ taskIds: string[];
60
+ completionOwner: "parent";
61
+ }
62
+
63
+ export interface ImplementPlan {
64
+ changeContract?: ChangeContract;
65
+ changeId: string;
66
+ tasks: PlanTaskDraft[];
67
+ outputs: ImplementGraphOutput[];
68
+ verification: PlanVerification;
69
+ tracking: PlanTracking;
70
+ }