more progress
This commit is contained in:
1 parent
0c4c027e92
commit
96d610b1f8
5 files changed
+154
-6
No files matched your search
@@ -53,8 +53,8 @@ Counts: active `53` (`valid=34`, `partially-valid=19`), closed-invalid `5`
|
||||
- Threads: PRRT_kwDORLtfbc5wkPaL
|
||||
- Audit note: SessionId-only routing can misassociate events under races/rebinds.
|
||||
|
||||
- [ ] `C020` On `message.completed`, the message ID is added to the set and `thread.message.assistant.complete` is dispatched. On `turn.completed`, the same set is iterated and `thread.message.assistant.complete` is dispatched again for each ID—including already-completed ones. Consider removing message IDs from the set after dispatching on `message.completed`, or filtering out already-completed IDs before the `turn.completed` loop.
|
||||
- Status: `TODO`
|
||||
- [x] `C020` On `message.completed`, the message ID is added to the set and `thread.message.assistant.complete` is dispatched. On `turn.completed`, the same set is iterated and `thread.message.assistant.complete` is dispatched again for each ID—including already-completed ones. Consider removing message IDs from the set after dispatching on `message.completed`, or filtering out already-completed IDs before the `turn.completed` loop.
|
||||
- Status: `DONE`
|
||||
- Verdict: `partially-valid`
|
||||
- Severity: `Medium`
|
||||
- Area: `Runtime resilience and failure handling`
|
||||
@@ -80,8 +80,8 @@ Counts: active `53` (`valid=34`, `partially-valid=19`), closed-invalid `5`
|
||||
- Threads: PRRT_kwDORLtfbc5wyTaW, PRRT_kwDORLtfbc5wzli3 (+1 duplicate thread(s))
|
||||
- Audit note: Same unhandled rejection path remains in WS message handler.
|
||||
|
||||
- [ ] `C042` Duplicated `resolveThreadWorkspaceCwd` across three files
|
||||
- Status: `TODO`
|
||||
- [x] `C042` Duplicated `resolveThreadWorkspaceCwd` across three files
|
||||
- Status: `DONE`
|
||||
- Verdict: `partially-valid`
|
||||
- Severity: `Low`
|
||||
- Area: `Runtime resilience and failure handling`
|
||||
@@ -98,8 +98,8 @@ Counts: active `53` (`valid=34`, `partially-valid=19`), closed-invalid `5`
|
||||
- Threads: PRRT_kwDORLtfbc5wnWwM, PRRT_kwDORLtfbc5w1C3-, PRRT_kwDORLtfbc5w1HGZ (+2 duplicate thread(s))
|
||||
- Audit note: Workspace CWD resolution duplication still present across modules.
|
||||
|
||||
- [ ] `C044` Checkpoint reactor swallows diff errors silently for `turn.completed`
|
||||
- Status: `TODO`
|
||||
- [x] `C044` Checkpoint reactor swallows diff errors silently for `turn.completed`
|
||||
- Status: `DONE`
|
||||
- Verdict: `partially-valid`
|
||||
- Severity: `Low`
|
||||
- Area: `Runtime resilience and failure handling`
|
||||
|
||||
@@ -379,6 +379,54 @@ describe("CheckpointReactor", () => {
|
||||
).toBe("v2\n");
|
||||
});
|
||||
|
||||
it("appends capture failure activity when turn diff summary cannot be derived", async () => {
|
||||
const harness = await createHarness({ seedFilesystemCheckpoints: false });
|
||||
const createdAt = new Date().toISOString();
|
||||
|
||||
await Effect.runPromise(
|
||||
harness.engine.dispatch({
|
||||
type: "thread.session.set",
|
||||
commandId: CommandId.makeUnsafe("cmd-session-set-missing-baseline-diff"),
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
session: {
|
||||
threadId: ThreadId.makeUnsafe("thread-1"),
|
||||
status: "ready",
|
||||
providerName: "codex",
|
||||
providerSessionId: asSessionId("sess-1"),
|
||||
providerThreadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
activeTurnId: null,
|
||||
lastError: null,
|
||||
updatedAt: createdAt,
|
||||
},
|
||||
createdAt,
|
||||
}),
|
||||
);
|
||||
|
||||
harness.provider.emit({
|
||||
type: "turn.completed",
|
||||
eventId: EventId.makeUnsafe("evt-turn-completed-missing-baseline"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: new Date().toISOString(),
|
||||
threadId: ProviderThreadId.makeUnsafe("provider-thread-1"),
|
||||
turnId: asTurnId("turn-missing-baseline"),
|
||||
status: "completed",
|
||||
});
|
||||
|
||||
await waitForEvent(harness.engine, (event) => event.type === "thread.turn-diff-completed");
|
||||
const thread = await waitForThread(
|
||||
harness.engine,
|
||||
(entry) =>
|
||||
entry.checkpoints.length === 1 &&
|
||||
entry.activities.some((activity) => activity.kind === "checkpoint.capture.failed"),
|
||||
);
|
||||
|
||||
expect(thread.checkpoints[0]?.checkpointTurnCount).toBe(1);
|
||||
expect(
|
||||
thread.activities.some((activity) => activity.kind === "checkpoint.capture.failed"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("captures pre-turn baseline from project workspace root when thread worktree is unset", async () => {
|
||||
const harness = await createHarness({
|
||||
hasSession: false,
|
||||
|
||||
@@ -244,6 +244,14 @@ const make = Effect.gen(function* () {
|
||||
deletions: file.deletions,
|
||||
})),
|
||||
),
|
||||
Effect.tapError((error) =>
|
||||
appendCaptureFailureActivity({
|
||||
sessionId: event.sessionId,
|
||||
turnId,
|
||||
detail: `Checkpoint captured, but turn diff summary is unavailable: ${error.message}`,
|
||||
createdAt: event.createdAt,
|
||||
}),
|
||||
),
|
||||
Effect.catch((error) =>
|
||||
Effect.logWarning("failed to derive checkpoint file summary", {
|
||||
threadId: thread.id,
|
||||
|
||||
@@ -258,6 +258,78 @@ describe("ProviderRuntimeIngestion", () => {
|
||||
expect(message?.streaming).toBe(false);
|
||||
});
|
||||
|
||||
it("does not duplicate assistant completion when message.completed is followed by turn.completed", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
harness.emit({
|
||||
type: "turn.started",
|
||||
eventId: asEventId("evt-turn-started-for-complete-dedup"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: now,
|
||||
turnId: asProviderTurnId("turn-complete-dedup"),
|
||||
});
|
||||
|
||||
await waitForThread(
|
||||
harness.engine,
|
||||
(thread) =>
|
||||
thread.session?.status === "running" && thread.session?.activeTurnId === "turn-complete-dedup",
|
||||
);
|
||||
|
||||
harness.emit({
|
||||
type: "message.delta",
|
||||
eventId: asEventId("evt-message-delta-for-complete-dedup"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: now,
|
||||
turnId: asProviderTurnId("turn-complete-dedup"),
|
||||
itemId: asItemId("item-complete-dedup"),
|
||||
delta: "done",
|
||||
});
|
||||
harness.emit({
|
||||
type: "message.completed",
|
||||
eventId: asEventId("evt-message-completed-for-complete-dedup"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: now,
|
||||
turnId: asProviderTurnId("turn-complete-dedup"),
|
||||
itemId: asItemId("item-complete-dedup"),
|
||||
});
|
||||
harness.emit({
|
||||
type: "turn.completed",
|
||||
eventId: asEventId("evt-turn-completed-for-complete-dedup"),
|
||||
provider: "codex",
|
||||
sessionId: asSessionId("sess-1"),
|
||||
createdAt: now,
|
||||
turnId: asProviderTurnId("turn-complete-dedup"),
|
||||
status: "completed",
|
||||
});
|
||||
|
||||
await waitForThread(
|
||||
harness.engine,
|
||||
(thread) =>
|
||||
thread.session?.status === "ready" &&
|
||||
thread.session?.activeTurnId === null &&
|
||||
thread.messages.some(
|
||||
(message) => message.id === "assistant:item-complete-dedup" && !message.streaming,
|
||||
),
|
||||
);
|
||||
|
||||
const events = await Effect.runPromise(
|
||||
Stream.runCollect(harness.engine.readEvents(0)).pipe(Effect.map((chunk) => Array.from(chunk))),
|
||||
);
|
||||
const completionEvents = events.filter((event) => {
|
||||
if (event.type !== "thread.message-sent") {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
event.payload.messageId === "assistant:item-complete-dedup" && event.payload.streaming === false
|
||||
);
|
||||
});
|
||||
expect(completionEvents).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("maps runtime.error into errored session state", async () => {
|
||||
const harness = await createHarness();
|
||||
const now = new Date().toISOString();
|
||||
|
||||
@@ -145,6 +145,22 @@ const make = Effect.gen(function* () {
|
||||
}
|
||||
};
|
||||
|
||||
const forgetAssistantMessageId = (
|
||||
sessionId: ProviderSessionId,
|
||||
turnId: TurnId,
|
||||
messageId: MessageId,
|
||||
) => {
|
||||
const key = providerTurnKey(sessionId, turnId);
|
||||
const existingIds = turnMessageIdsByTurnKey.get(key);
|
||||
if (!existingIds) {
|
||||
return;
|
||||
}
|
||||
existingIds.delete(messageId);
|
||||
if (existingIds.size === 0) {
|
||||
turnMessageIdsByTurnKey.delete(key);
|
||||
}
|
||||
};
|
||||
|
||||
const getAssistantMessageIdsForTurn = (sessionId: ProviderSessionId, turnId: TurnId) => {
|
||||
return turnMessageIdsByTurnKey.get(providerTurnKey(sessionId, turnId)) ?? new Set<MessageId>();
|
||||
};
|
||||
@@ -257,6 +273,10 @@ const make = Effect.gen(function* () {
|
||||
...(turnId ? { turnId } : {}),
|
||||
createdAt: now,
|
||||
});
|
||||
|
||||
if (turnId) {
|
||||
forgetAssistantMessageId(event.sessionId, turnId, assistantMessageId);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.type === "turn.completed") {
|
||||
|
||||
Reference in new issue
Block a user