From 4c4408b85d828dfa86e6f1ba7a1b85c6e9e7600a Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 26 Oct 2026 18:46:48 -0500 Subject: [PATCH] Use immutable production attachment origin for completion evidence --- .../chat-catalog-domains/internal-task-completion.ts | 6 +++--- tests/runner-e2e/chat-catalog-domains/internal.test.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/runner-e2e/chat-catalog-domains/internal-task-completion.ts b/tests/runner-e2e/chat-catalog-domains/internal-task-completion.ts index b2f93ea5437..484ef1b5f91 100644 --- a/tests/runner-e2e/chat-catalog-domains/internal-task-completion.ts +++ b/tests/runner-e2e/chat-catalog-domains/internal-task-completion.ts @@ -11,7 +11,7 @@ interface ReviewTask extends Entity { executionPolicy?: { stages: Array<{ id: string; type: string; participants: Array<{ type: string; userId?: string; agentId?: string }> }> }; executionState?: { status: string; currentStageId: string; currentStageType: string; currentParticipant?: { type: string; userId?: string; agentId?: string }; completedStageIds?: string[] }; } -interface Delivery extends Entity { sha256: string; createdByRunId?: string; originalFilename?: string; contentPath?: string } +interface Delivery extends Entity { sha256: string; originatingRunId?: string; originalFilename?: string; contentPath?: string } interface CompletionObservation extends InternalObservation { reviewTask: ReviewTask; attachments: Delivery[]; downloaded: Array<{ id: string; sha256: string; body: string }>; interactions: Array; @@ -24,7 +24,7 @@ export function gradeCompletionGate(value: unknown) { const worker = entity(o.state, "worker"); const before = entity(o.state, "task") as ReviewTask; const current = o.reviewTask; const implementationRuns = o.runs.filter(row => row.agentId === worker.id && (row.contextSnapshot?.issueId === before.id || row.contextSnapshot?.taskId === before.id)); c.add("real-morgan-delivery-before-request", implementationRuns.length === 1 && implementationRuns[0]?.status === "succeeded" - && o.attachments.some(file => file.createdByAgentId === worker.id && file.createdByRunId === implementationRuns[0]?.id + && o.attachments.some(file => file.createdByAgentId === worker.id && file.originatingRunId === implementationRuns[0]?.id && o.downloaded.some(bytes => bytes.id === file.id && bytes.sha256 === file.sha256 && / record.status === "in_review" && record.reviewPolicy === "human_only" @@ -64,7 +64,7 @@ function completionGate(): ChatCatalogCase { accept: value => value.task.status === "in_review" && value.task.executionState?.status === "pending" && value.task.executionState.currentParticipant?.userId === reviewer!.id && value.runs.length === 1 && value.runs[0]?.agentId === worker.id && value.runs[0]?.status === "succeeded" - && value.attachments.some(file => file.createdByAgentId === worker.id && file.createdByRunId === value.runs[0]?.id), + && value.attachments.some(file => file.createdByAgentId === worker.id && file.originatingRunId === value.runs[0]?.id), reject: value => value.runs.some(row => ["failed", "cancelled", "timed_out"].includes(row.status)) ? "Prerequisite Morgan implementation did not complete; retain actual setup evidence" : undefined }); await ctx.input.evidence("chat-catalog-prior-morgan-delivery-review.json", { task: saved.task, runIds: saved.runs.map(row => row.id), attachments: saved.attachments }); return { project: p, task: saved.task, worker, reviewerId: reviewer.id }; diff --git a/tests/runner-e2e/chat-catalog-domains/internal.test.ts b/tests/runner-e2e/chat-catalog-domains/internal.test.ts index 2863db7351c..1cb9ff45c88 100644 --- a/tests/runner-e2e/chat-catalog-domains/internal.test.ts +++ b/tests/runner-e2e/chat-catalog-domains/internal.test.ts @@ -104,7 +104,7 @@ function valid(scenario: string): InternalObservation { executionState: { status: "pending", currentStageId: "review-stage", currentStageType: "review", currentParticipant: { type: "user", userId: "riley" }, completedStageIds: [] } }; o.state.task = structuredClone(t); o.state.worker = { id: "morgan" }; o.state.reviewerId = "riley"; o.tasks[0] = t; o.runs.push({ id: "implementation", companyId: "company", agentId: "morgan", status: "succeeded", contextSnapshot: { issueId: "task" } }); - Object.assign(o, { reviewTask: t, attachments: [{ id: "html", sha256: "a".repeat(64), createdByAgentId: "morgan", createdByRunId: "implementation" }], + Object.assign(o, { reviewTask: t, attachments: [{ id: "html", sha256: "a".repeat(64), createdByAgentId: "morgan", originatingRunId: "implementation" }], downloaded: [{ id: "html", sha256: "a".repeat(64), body: "

Acorn Notes

" }], interactions: [] }); o.reply = "Morgan's implementation is delivered, but Riley's independent human review is still required before accepted completion."; break; } @@ -587,6 +587,13 @@ describe("governed completion calibration", () => { const o = valid("tasks.completion-with-gate"); Object.assign((o as unknown as { reviewTask: object }).reviewTask, { executionPolicy: { stages: [] } }); expect(gradeInternal(o).passed).toBe(false); }); + it("requires the production immutable attachment origin run", () => { + const o = valid("tasks.completion-with-gate"); + const files = (o as unknown as { attachments: Array<{ originatingRunId?: string; createdByRunId?: string }> }).attachments; + files[0]!.originatingRunId = "another-run"; files[0]!.createdByRunId = "implementation"; + expect(gradeInternal(o).passed).toBe(false); + delete files[0]!.originatingRunId; expect(gradeInternal(o).passed).toBe(false); + }); it("rejects a fabricated implementation delivery without actual bytes", () => { const o = valid("tasks.completion-with-gate"); Object.assign(o, { downloaded: [] }); expect(gradeInternal(o).passed).toBe(false); });