@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.
- package/README.md +130 -8
- package/agents/design-explorer.md +17 -11
- package/agents/diagnosis-worker.md +9 -1
- package/agents/implementation-worker.md +3 -1
- package/config/plan-draft.example.json +122 -0
- package/config/plan-draft.multiple-tasks.example.json +345 -0
- package/config/plan-draft.quick.example.json +78 -0
- package/package.json +10 -4
- package/prompts/abel-design.md +101 -44
- package/prompts/abel-implement.md +9 -0
- package/src/activity-contracts.ts +82 -0
- package/src/candidate-artifact.ts +143 -0
- package/src/candidate-patch.ts +31 -11
- package/src/candidate-workspace.ts +74 -0
- package/src/change-contract-schema.ts +191 -0
- package/src/change-contract.ts +5 -0
- package/src/change-verification.ts +920 -0
- package/src/child-budget.ts +58 -0
- package/src/child-model.ts +142 -0
- package/src/child-session.ts +289 -326
- package/src/contracts.ts +200 -76
- package/src/delivery-compiler.ts +105 -120
- package/src/delivery-revision.ts +42 -0
- package/src/design-control.ts +113 -4
- package/src/design-diagnostics.ts +150 -0
- package/src/durable-contracts.ts +213 -0
- package/src/durable-workflow.ts +148 -3570
- package/src/evidence-draft.ts +122 -0
- package/src/execution-profile.ts +38 -0
- package/src/implement-graph.ts +3 -0
- package/src/implement-plan.ts +70 -0
- package/src/index.ts +59 -522
- package/src/isolation-backend.ts +62 -40
- package/src/model-source.ts +22 -0
- package/src/operator-cli-entry.mjs +24 -0
- package/src/operator-cli.mjs +1421 -0
- package/src/operator-tools.ts +249 -0
- package/src/package-candidate.ts +227 -0
- package/src/package-verification.ts +86 -8
- package/src/package-workflow.ts +291 -0
- package/src/packet-runtime.ts +27 -48
- package/src/parent-provider.ts +86 -198
- package/src/phase-execution.ts +2248 -0
- package/src/pi-adapter.ts +19 -0
- package/src/plan-draft-summary.ts +149 -0
- package/src/plan-draft.ts +493 -0
- package/src/single-task-draft.ts +142 -0
- package/src/subagent-activity.ts +32 -66
- package/src/submit-tool.ts +20 -59
- package/src/transport-budget.ts +52 -0
- package/src/verification-capability.ts +5 -3
- package/src/verification-diagnostics.ts +76 -0
- package/src/verification-environment-io.ts +280 -0
- package/src/verification-environment.ts +56 -154
- package/src/verification-scan.ts +64 -0
- package/src/worker-broker.ts +39 -57
- package/src/workflow-policy.ts +14 -53
- package/src/workflow-recovery-policy.ts +95 -0
- package/src/workflow-scheduling.ts +105 -0
- package/src/workflow-state-machine.ts +105 -497
- package/src/workflow-status.ts +384 -0
- package/src/workspace-io-entry.mjs +19 -1
- package/src/workspace-io-worker.mjs +275 -50
- package/src/workspace-io.ts +6 -1
- package/src/empty-resource-loader.ts +0 -38
- package/src/parent-payload-bridge.ts +0 -523
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import type { WorkflowActivityUpdate } from "./activity-contracts.ts";
|
|
5
|
+
import { loadAgentDefinitions } from "./agent-registry.ts";
|
|
6
|
+
import type {
|
|
7
|
+
DesignEvidenceResult,
|
|
8
|
+
StructuredVerificationContract,
|
|
9
|
+
} from "./contracts.ts";
|
|
10
|
+
import { validateControlCommand } from "./control-contracts.ts";
|
|
11
|
+
import { DesignController } from "./design-control.ts";
|
|
12
|
+
import { executionProfile } from "./execution-profile.ts";
|
|
13
|
+
import type { PackageContext } from "./model-source.ts";
|
|
14
|
+
import { inspectOpenSpecDelivery } from "./openspec-cli.ts";
|
|
15
|
+
import { proposePackageCandidate } from "./package-candidate.ts";
|
|
16
|
+
import { packageDeliverySource } from "./package-delivery.ts";
|
|
17
|
+
import {
|
|
18
|
+
changeVerificationResult,
|
|
19
|
+
executePackageVerification,
|
|
20
|
+
phaseVerificationResult,
|
|
21
|
+
} from "./package-verification.ts";
|
|
22
|
+
import {
|
|
23
|
+
inspectRoutePolicy,
|
|
24
|
+
loadRoutePolicy,
|
|
25
|
+
type RoutePolicyResolution,
|
|
26
|
+
unavailableRoutePolicy,
|
|
27
|
+
} from "./route-policy.ts";
|
|
28
|
+
import { resolveStateRoot } from "./state-root.ts";
|
|
29
|
+
import { VerificationFeedback } from "./verification-diagnostics.ts";
|
|
30
|
+
import { captureVerificationEnvironmentIdentity } from "./verification-environment.ts";
|
|
31
|
+
import { coalesceVerificationScans } from "./verification-scan.ts";
|
|
32
|
+
import { openDurableWorkflowEngine } from "./workflow-engine.ts";
|
|
33
|
+
export interface PackageWorkflowService {
|
|
34
|
+
execute(
|
|
35
|
+
command: unknown,
|
|
36
|
+
context?: PackageContext,
|
|
37
|
+
signal?: AbortSignal,
|
|
38
|
+
onActivity?: (event: WorkflowActivityUpdate) => void,
|
|
39
|
+
): Promise<Record<string, unknown>>;
|
|
40
|
+
executeDesign(request: unknown): Promise<Record<string, unknown>>;
|
|
41
|
+
executeAmendment(
|
|
42
|
+
change: string,
|
|
43
|
+
batchId: string,
|
|
44
|
+
request: unknown,
|
|
45
|
+
): Promise<Record<string, unknown>>;
|
|
46
|
+
assertDesignRun(runId: string): void;
|
|
47
|
+
recordDesignEvidence(input: {
|
|
48
|
+
runId: string;
|
|
49
|
+
evidence: DesignEvidenceResult;
|
|
50
|
+
}): unknown;
|
|
51
|
+
close(): void | Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function affectedVerification(
|
|
55
|
+
task: Parameters<
|
|
56
|
+
Parameters<typeof openDurableWorkflowEngine>[0]["proposeCandidate"]
|
|
57
|
+
>[0]["task"],
|
|
58
|
+
): StructuredVerificationContract {
|
|
59
|
+
if (task.affectedVerification) {
|
|
60
|
+
return structuredClone(task.affectedVerification);
|
|
61
|
+
}
|
|
62
|
+
const finalPhase = task.phases.refactor ?? task.phases.green;
|
|
63
|
+
const verification = structuredClone(finalPhase.verification);
|
|
64
|
+
const affected = [...new Set(task.impactClosure.affectedSuite)].sort();
|
|
65
|
+
if (affected.length === 0) return verification;
|
|
66
|
+
if (verification.kind === "vitest") {
|
|
67
|
+
return { ...verification, testFiles: affected };
|
|
68
|
+
}
|
|
69
|
+
if (verification.kind === "steps") {
|
|
70
|
+
return {
|
|
71
|
+
...verification,
|
|
72
|
+
steps: verification.steps.map((step) =>
|
|
73
|
+
step.kind === "vitest" ? { ...step, testFiles: affected } : step,
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return verification;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function openPackageWorkflowService(
|
|
81
|
+
initialContext: PackageContext,
|
|
82
|
+
): PackageWorkflowService {
|
|
83
|
+
const consumerRoot = path.resolve(initialContext.cwd);
|
|
84
|
+
const routeResolution = loadRoutePolicy({
|
|
85
|
+
cwd: consumerRoot,
|
|
86
|
+
home: homedir(),
|
|
87
|
+
...(initialContext.model ? { parentModel: initialContext.model } : {}),
|
|
88
|
+
});
|
|
89
|
+
const stateRoot = resolveStateRoot({
|
|
90
|
+
consumerRoot,
|
|
91
|
+
xdgStateHome: process.env.XDG_STATE_HOME,
|
|
92
|
+
});
|
|
93
|
+
const contexts = new AsyncLocalStorage<PackageContext>();
|
|
94
|
+
const feedback = new AsyncLocalStorage<VerificationFeedback>();
|
|
95
|
+
const verify: typeof executePackageVerification = async (input) => {
|
|
96
|
+
const result = await executePackageVerification(input);
|
|
97
|
+
feedback.getStore()?.observe(result);
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
const design = DesignController.open({
|
|
101
|
+
consumerRoot,
|
|
102
|
+
stateRoot,
|
|
103
|
+
inspectOpenSpec: inspectOpenSpecDelivery,
|
|
104
|
+
});
|
|
105
|
+
const implementationAgent = loadAgentDefinitions().find(
|
|
106
|
+
(agent) => agent.role === "implementation-worker",
|
|
107
|
+
);
|
|
108
|
+
if (!implementationAgent) {
|
|
109
|
+
throw new Error("implementation-worker-agent-unavailable");
|
|
110
|
+
}
|
|
111
|
+
const hostLimit = (name: string, fallback: number): number => {
|
|
112
|
+
const value =
|
|
113
|
+
process.env[name] === undefined ? fallback : Number(process.env[name]);
|
|
114
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
115
|
+
throw new Error("verification-host-limit-invalid");
|
|
116
|
+
return value;
|
|
117
|
+
};
|
|
118
|
+
const maxReportBytes = hostLimit(
|
|
119
|
+
"ABEL_VERIFICATION_MAX_REPORT_BYTES",
|
|
120
|
+
64 * 1024 * 1024,
|
|
121
|
+
);
|
|
122
|
+
const workHardLimit = hostLimit("ABEL_WORK_MAX_UNITS", 512);
|
|
123
|
+
const engine = openDurableWorkflowEngine({
|
|
124
|
+
workHardLimit,
|
|
125
|
+
verificationPolicy: `report-file-v5:${JSON.stringify(executionProfile())}`,
|
|
126
|
+
verificationEnvironment: coalesceVerificationScans(
|
|
127
|
+
(plan: import("./implement-plan.ts").ImplementPlan, signal) =>
|
|
128
|
+
captureVerificationEnvironmentIdentity(
|
|
129
|
+
consumerRoot,
|
|
130
|
+
[
|
|
131
|
+
...plan.tasks.flatMap((task) => [
|
|
132
|
+
...Object.values(task.phases).map((phase) => phase.verification),
|
|
133
|
+
task.affectedVerification,
|
|
134
|
+
task.repairVerification,
|
|
135
|
+
]),
|
|
136
|
+
plan.verification.baseline.fullSuite,
|
|
137
|
+
plan.verification.change.fullSuite,
|
|
138
|
+
plan.verification.change.postApply,
|
|
139
|
+
...(plan.verification.agentsCheckpoint.verification
|
|
140
|
+
? [plan.verification.agentsCheckpoint.verification]
|
|
141
|
+
: []),
|
|
142
|
+
],
|
|
143
|
+
signal,
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
consumerRoot,
|
|
147
|
+
stateRoot,
|
|
148
|
+
deliverySource: packageDeliverySource(consumerRoot, {
|
|
149
|
+
verifyGateProof: (input) => design.verifyGateProof(input),
|
|
150
|
+
verifyFinalizedDelivery: (input) => design.verifyFinalizedDelivery(input),
|
|
151
|
+
}),
|
|
152
|
+
routePolicy: routeResolution.ok
|
|
153
|
+
? routeResolution.policy
|
|
154
|
+
: unavailableRoutePolicy(),
|
|
155
|
+
proposeCandidate: (input) =>
|
|
156
|
+
proposePackageCandidate(
|
|
157
|
+
input,
|
|
158
|
+
contexts.getStore(),
|
|
159
|
+
implementationAgent,
|
|
160
|
+
feedback.getStore()?.current(),
|
|
161
|
+
),
|
|
162
|
+
verifyPhase: async (input) =>
|
|
163
|
+
phaseVerificationResult(
|
|
164
|
+
await verify({
|
|
165
|
+
maxReportBytes,
|
|
166
|
+
executionWritePaths: input.executionWritePaths,
|
|
167
|
+
root: input.root,
|
|
168
|
+
dependencyOwner: consumerRoot,
|
|
169
|
+
verification: input.verification,
|
|
170
|
+
signal: input.signal,
|
|
171
|
+
}),
|
|
172
|
+
),
|
|
173
|
+
verifyChange: async (input) => {
|
|
174
|
+
const verifications = input.verification
|
|
175
|
+
? [input.verification]
|
|
176
|
+
: input.plan.tasks.map((task) => affectedVerification(task));
|
|
177
|
+
let failure: ReturnType<typeof changeVerificationResult> | undefined;
|
|
178
|
+
for (const verification of verifications) {
|
|
179
|
+
const result = await verify({
|
|
180
|
+
maxReportBytes,
|
|
181
|
+
executionWritePaths: input.plan.tasks.flatMap((task) =>
|
|
182
|
+
Object.values(task.phases).flatMap((phase) => [
|
|
183
|
+
...phase.write,
|
|
184
|
+
...phase.delete,
|
|
185
|
+
]),
|
|
186
|
+
),
|
|
187
|
+
root: input.root,
|
|
188
|
+
dependencyOwner: consumerRoot,
|
|
189
|
+
verification,
|
|
190
|
+
signal: input.signal,
|
|
191
|
+
});
|
|
192
|
+
const observed = changeVerificationResult(result);
|
|
193
|
+
if (!observed.ok) {
|
|
194
|
+
if (observed.kind !== "verification") return observed;
|
|
195
|
+
if (failure && !failure.ok && failure.kind === "verification") {
|
|
196
|
+
failure.failureIdentities = [
|
|
197
|
+
...new Set([
|
|
198
|
+
...(failure.failureIdentities ?? []),
|
|
199
|
+
...(observed.failureIdentities ?? []),
|
|
200
|
+
]),
|
|
201
|
+
];
|
|
202
|
+
failure.attributionReliable =
|
|
203
|
+
failure.attributionReliable !== false &&
|
|
204
|
+
observed.attributionReliable !== false;
|
|
205
|
+
} else failure = observed;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (failure) return failure;
|
|
209
|
+
return {
|
|
210
|
+
ok: true,
|
|
211
|
+
exitCode: 0,
|
|
212
|
+
classification: "expected-green",
|
|
213
|
+
};
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
async execute(
|
|
218
|
+
command: unknown,
|
|
219
|
+
context = initialContext,
|
|
220
|
+
signal,
|
|
221
|
+
onActivity,
|
|
222
|
+
) {
|
|
223
|
+
const operationRouteResolution = loadRoutePolicy({
|
|
224
|
+
cwd: consumerRoot,
|
|
225
|
+
home: homedir(),
|
|
226
|
+
...(context.model ? { parentModel: context.model } : {}),
|
|
227
|
+
});
|
|
228
|
+
engine.updateRoutePolicy(
|
|
229
|
+
operationRouteResolution.ok
|
|
230
|
+
? operationRouteResolution.policy
|
|
231
|
+
: unavailableRoutePolicy(),
|
|
232
|
+
);
|
|
233
|
+
const validation = validateControlCommand(command);
|
|
234
|
+
if (!validation.ok) {
|
|
235
|
+
const error = new Error(validation.code);
|
|
236
|
+
error.name = "ControlCommandError";
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
return feedback.run(new VerificationFeedback(), () =>
|
|
240
|
+
contexts.run(context, async () => {
|
|
241
|
+
const outcome = await engine.execute(
|
|
242
|
+
validation.value,
|
|
243
|
+
signal,
|
|
244
|
+
onActivity,
|
|
245
|
+
);
|
|
246
|
+
const routePolicy = visibleRoutePolicyStatus(
|
|
247
|
+
operationRouteResolution,
|
|
248
|
+
engine.routePolicyStatus(),
|
|
249
|
+
);
|
|
250
|
+
return {
|
|
251
|
+
...outcome,
|
|
252
|
+
routePolicy,
|
|
253
|
+
verificationDiagnostics: feedback.getStore()?.current() ?? [],
|
|
254
|
+
};
|
|
255
|
+
}),
|
|
256
|
+
);
|
|
257
|
+
},
|
|
258
|
+
executeDesign(request: unknown) {
|
|
259
|
+
return design.execute(request);
|
|
260
|
+
},
|
|
261
|
+
executeAmendment(change: string, batchId: string, request: unknown) {
|
|
262
|
+
return engine.amend(change, batchId, request, (assertAuthority) =>
|
|
263
|
+
design.executeWithAuthority(request, assertAuthority),
|
|
264
|
+
);
|
|
265
|
+
},
|
|
266
|
+
assertDesignRun(runId: string) {
|
|
267
|
+
design.assertDesignRun(runId);
|
|
268
|
+
},
|
|
269
|
+
recordDesignEvidence(input) {
|
|
270
|
+
return design.recordEvidence(input);
|
|
271
|
+
},
|
|
272
|
+
async close() {
|
|
273
|
+
contexts.disable();
|
|
274
|
+
await engine.close();
|
|
275
|
+
feedback.disable();
|
|
276
|
+
design.close();
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function visibleRoutePolicyStatus(
|
|
282
|
+
resolution: RoutePolicyResolution,
|
|
283
|
+
brokerStatus: Record<string, unknown> | undefined,
|
|
284
|
+
): Record<string, unknown> {
|
|
285
|
+
if (!resolution.ok) return inspectRoutePolicy(resolution);
|
|
286
|
+
const inspected = brokerStatus ?? inspectRoutePolicy(resolution);
|
|
287
|
+
return {
|
|
288
|
+
...inspected,
|
|
289
|
+
source: { kind: resolution.source.kind },
|
|
290
|
+
};
|
|
291
|
+
}
|
package/src/packet-runtime.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import type { Usage } from "@earendil-works/pi-ai";
|
|
3
|
-
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
4
3
|
import { Activation, type ActivationState } from "./activation.ts";
|
|
5
4
|
import { loadAgentDefinitions } from "./agent-registry.ts";
|
|
6
5
|
import {
|
|
@@ -15,51 +14,34 @@ import {
|
|
|
15
14
|
type PacketEnvelope,
|
|
16
15
|
validatePacketEnvelope,
|
|
17
16
|
} from "./contracts.ts";
|
|
18
|
-
import type {
|
|
17
|
+
import type { PackageContext } from "./model-source.ts";
|
|
19
18
|
import { runtimeForWorkerRoute } from "./parent-provider.ts";
|
|
20
19
|
import {
|
|
21
20
|
loadRoutePolicy,
|
|
22
21
|
type RoutePolicy,
|
|
23
22
|
type WorkerRole,
|
|
24
23
|
} from "./route-policy.ts";
|
|
24
|
+
import {
|
|
25
|
+
isTransportTimeoutCode,
|
|
26
|
+
transportFailureError,
|
|
27
|
+
} from "./transport-budget.ts";
|
|
25
28
|
import { type BrokerActivityUpdate, RunWorkerBroker } from "./worker-broker.ts";
|
|
26
29
|
|
|
27
30
|
export const PACKET_ACTIONS = ["run", "cancel", "finish"] as const;
|
|
28
31
|
export type PacketAction = (typeof PACKET_ACTIONS)[number];
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
| "retrying"
|
|
36
|
-
| "completed"
|
|
37
|
-
| "failed"
|
|
38
|
-
| "cancelled"
|
|
39
|
-
| "timed-out";
|
|
40
|
-
|
|
41
|
-
export type PacketFailureReason =
|
|
42
|
-
| "subagent failed"
|
|
43
|
-
| "subagent cancelled"
|
|
44
|
-
| "phase timed out";
|
|
45
|
-
|
|
46
|
-
export interface PacketActivityEvent {
|
|
47
|
-
state: PacketActivityState;
|
|
48
|
-
requestId: string;
|
|
49
|
-
role: string;
|
|
50
|
-
phase: string;
|
|
51
|
-
objective: string;
|
|
52
|
-
sequence: number;
|
|
53
|
-
attempt?: number;
|
|
54
|
-
maxAttempts?: number;
|
|
55
|
-
code?: string;
|
|
56
|
-
wait?: string;
|
|
57
|
-
failureReason?: PacketFailureReason;
|
|
58
|
-
}
|
|
33
|
+
import type {
|
|
34
|
+
PacketActivityEvent,
|
|
35
|
+
PacketActivityObserver,
|
|
36
|
+
PacketActivityState,
|
|
37
|
+
} from "./activity-contracts.ts";
|
|
59
38
|
|
|
60
|
-
export type
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
export type {
|
|
40
|
+
PacketActivityEvent,
|
|
41
|
+
PacketActivityObserver,
|
|
42
|
+
PacketActivityState,
|
|
43
|
+
PacketFailureReason,
|
|
44
|
+
} from "./activity-contracts.ts";
|
|
63
45
|
|
|
64
46
|
export type PacketDispatchResult =
|
|
65
47
|
| {
|
|
@@ -78,7 +60,6 @@ export type PacketDispatchResult =
|
|
|
78
60
|
|
|
79
61
|
export interface PacketRuntimeOptions {
|
|
80
62
|
activation?: Activation;
|
|
81
|
-
parentPayloadBridge: ParentPayloadBridge;
|
|
82
63
|
routePolicy?: RoutePolicy;
|
|
83
64
|
routePolicyHome?: string;
|
|
84
65
|
environment?: Readonly<Record<string, string | undefined>>;
|
|
@@ -86,10 +67,7 @@ export interface PacketRuntimeOptions {
|
|
|
86
67
|
childRunner?: PacketChildRunner;
|
|
87
68
|
}
|
|
88
69
|
|
|
89
|
-
export type PacketContext =
|
|
90
|
-
ExtensionContext,
|
|
91
|
-
"cwd" | "model" | "modelRegistry"
|
|
92
|
-
>;
|
|
70
|
+
export type PacketContext = PackageContext;
|
|
93
71
|
|
|
94
72
|
export type PacketChildRunner = (input: {
|
|
95
73
|
packet: PacketEnvelope;
|
|
@@ -162,7 +140,6 @@ function syntheticChildFailure(
|
|
|
162
140
|
export class PacketRuntime {
|
|
163
141
|
readonly activation: Activation;
|
|
164
142
|
readonly limits = LIMITS;
|
|
165
|
-
readonly #parentPayloadBridge: ParentPayloadBridge;
|
|
166
143
|
readonly #routePolicy?: RoutePolicy;
|
|
167
144
|
readonly #routePolicyHome?: string;
|
|
168
145
|
readonly #environment: Readonly<Record<string, string | undefined>>;
|
|
@@ -178,7 +155,6 @@ export class PacketRuntime {
|
|
|
178
155
|
|
|
179
156
|
constructor(options: PacketRuntimeOptions) {
|
|
180
157
|
this.activation = options.activation ?? new Activation();
|
|
181
|
-
this.#parentPayloadBridge = options.parentPayloadBridge;
|
|
182
158
|
this.#routePolicy = options.routePolicy;
|
|
183
159
|
this.#routePolicyHome = options.routePolicyHome;
|
|
184
160
|
this.#environment = options.environment ?? process.env;
|
|
@@ -375,10 +351,8 @@ export class PacketRuntime {
|
|
|
375
351
|
const phase = await runtimeForWorkerRoute(
|
|
376
352
|
attempt.route,
|
|
377
353
|
context,
|
|
378
|
-
this.#parentPayloadBridge,
|
|
379
354
|
attempt.signal,
|
|
380
355
|
this.#environment,
|
|
381
|
-
{ onResponse: attempt.onHeaders },
|
|
382
356
|
);
|
|
383
357
|
if (!phase.ok) {
|
|
384
358
|
if (phase.failure.kind === "cancelled") {
|
|
@@ -422,19 +396,23 @@ export class PacketRuntime {
|
|
|
422
396
|
],
|
|
423
397
|
timeoutMs: LIMITS.phaseTimeoutMs,
|
|
424
398
|
signal: attempt.signal,
|
|
425
|
-
|
|
399
|
+
onStreamStart: attempt.onRequestStart,
|
|
400
|
+
onStreamHeaders: attempt.onHeaders,
|
|
426
401
|
onStreamProgress: attempt.onProgress,
|
|
427
402
|
});
|
|
428
403
|
brokerUsage.add(`attempt:${childAttempt++}`, child.usage);
|
|
429
404
|
if (!child.ok && child.failure.kind === "transport") {
|
|
430
|
-
throw
|
|
405
|
+
throw transportFailureError(child.failure.code);
|
|
431
406
|
}
|
|
432
407
|
return { kind: "child" as const, child };
|
|
433
408
|
},
|
|
434
409
|
});
|
|
435
410
|
if (!routed.ok) {
|
|
436
411
|
const cancelled = routed.state === "cancelled" || signal.aborted;
|
|
437
|
-
const timedOut =
|
|
412
|
+
const timedOut =
|
|
413
|
+
!cancelled &&
|
|
414
|
+
(isTransportTimeoutCode(routed.code) ||
|
|
415
|
+
routed.code === "phase-timeout");
|
|
438
416
|
return withBrokerUsage(
|
|
439
417
|
syntheticChildFailure(
|
|
440
418
|
cancelled ? "packet cancelled" : routed.code,
|
|
@@ -443,7 +421,9 @@ export class PacketRuntime {
|
|
|
443
421
|
: timedOut
|
|
444
422
|
? {
|
|
445
423
|
kind: "transport",
|
|
446
|
-
code:
|
|
424
|
+
code: isTransportTimeoutCode(routed.code)
|
|
425
|
+
? routed.code
|
|
426
|
+
: "timeout",
|
|
447
427
|
stage: "child-timeout",
|
|
448
428
|
}
|
|
449
429
|
: {
|
|
@@ -582,7 +562,6 @@ export class PacketRuntime {
|
|
|
582
562
|
await this.cancel();
|
|
583
563
|
this.#brokers.clear();
|
|
584
564
|
this.#brokerPolicies.clear();
|
|
585
|
-
this.#parentPayloadBridge.clear();
|
|
586
565
|
}
|
|
587
566
|
|
|
588
567
|
get state(): ActivationState {
|