Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 50 additions & 32 deletions apps/web/src/components/ManagedRunEvidence.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@ vi.mock(import("~/state/entities"), async (original) => ({
ref?.threadId === "mcp:launch:known" ? ({ threadId: ref.threadId } as never) : null,
}));

it("links an operator wait to the locally known worker and preserves unknown evidence", async () => {
const run: ManagedRun = {
version: 1,
runId: "00000000-0000-0000-0000-000000000000",
ticket: "fixture",
revision: "a".repeat(64),
status: "approved",
brief: {
workspaceId: "fixture",
repository: "lab/fixture",
baseSha: "b".repeat(40),
scope: "Fixture",
tokens: 100,
const run: ManagedRun = {
version: 1,
runId: "00000000-0000-0000-0000-000000000000",
ticket: "fixture",
revision: "a".repeat(64),
status: "approved",
brief: {
workspaceId: "fixture",
repository: "lab/fixture",
baseSha: "b".repeat(40),
scope: "Fixture",
tokens: 100,
},
budget: { reserved: 100, used: null, remaining: null },
stages: [
{
stageId: "known",
role: "implementation",
status: "waiting_for_operator",
threadId: "mcp:launch:known",
providerInstanceId: "codex",
toolCalls: 0,
},
{
stageId: "unknown",
role: "qa",
status: "queued",
threadId: "mcp:launch:unknown",
providerInstanceId: null,
},
budget: { reserved: 100, used: null, remaining: null },
stages: [
{
stageId: "known",
role: "implementation",
status: "waiting_for_operator",
threadId: "mcp:launch:known",
providerInstanceId: "codex",
toolCalls: 0,
},
{
stageId: "unknown",
role: "qa",
status: "queued",
threadId: "mcp:launch:unknown",
providerInstanceId: null,
},
],
};
],
};
it("links an operator wait to the locally known worker and preserves unknown evidence", async () => {
await using screen = await render(<ManagedRunEvidence run={run} />);
await expect.element(screen.getByText("implementation · Waiting for operator")).toBeVisible();
await expect
Expand All @@ -57,3 +57,21 @@ it("links an operator wait to the locally known worker and preserves unknown evi
await expect.element(screen.getByText("Tool calls 0")).toBeVisible();
await expect.element(screen.getByText("Tool calls Unknown")).toBeVisible();
});

it("shows the exact reviewed commit and reports a budget overrun separately from the verdict", async () => {
const reviewedSha = "715f6adc7f373f7e17fb2f41a2dc373e8785caca";
await using screen = await render(
<ManagedRunEvidence
run={{
...run,
budget: { reserved: 340000, used: 344693, remaining: 0 },
qa: { reviewedSha, verdict: "pass", source: "operator", budgetExceeded: true },
}}
/>,
);
const review = screen.getByRole("region", { name: "Independent QA" });
await expect.element(review.getByText("Passed")).toBeVisible();
await expect.element(review.getByText(reviewedSha)).toBeVisible();
await expect.element(review.getByText("Operator", { exact: true })).toBeVisible();
await expect.element(review.getByText("Token budget exceeded")).toBeVisible();
});
16 changes: 15 additions & 1 deletion apps/web/src/components/ManagedRunEvidence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function formatCount(value: number | null): string {
}

export function ManagedRunEvidence({ run }: { run: ManagedRun }) {
const { brief, budget } = run;
const { brief, budget, qa } = run;
const fields = [
["Run ID", run.runId],
["Status", run.status],
Expand Down Expand Up @@ -58,6 +58,20 @@ export function ManagedRunEvidence({ run }: { run: ManagedRun }) {
</div>
))}
</dl>
{qa && (
<section className="mt-4 text-sm" aria-label="Independent QA">
<h3 className="font-medium">Independent QA</h3>
<dl className="mt-2 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-6 gap-y-2">
<dt className="text-muted-foreground">Verdict</dt>
<dd>{qa.verdict === "pass" ? "Passed" : "Failed"}</dd>
<dt className="text-muted-foreground">Reviewed commit</dt>
<dd className="break-all font-mono">{qa.reviewedSha}</dd>
<dt className="text-muted-foreground">Recorded by</dt>
<dd>{qa.source === "operator" ? "Operator" : "Provider"}</dd>
</dl>
{qa.budgetExceeded && <p className="mt-2 font-medium">Token budget exceeded</p>}
</section>
)}
<h3 className="mt-4 text-sm font-medium">Stages</h3>
{run.stages.length === 0 ? (
<p className="mt-2 text-sm text-muted-foreground">No stages recorded.</p>
Expand Down
11 changes: 10 additions & 1 deletion apps/web/src/lib/managedRunDelivery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Schema from "effect/Schema";

const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
const CommitSha = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/));
const Tokens = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));
const ManagedRun = Schema.Struct({
version: Schema.Literal(1),
Expand All @@ -11,7 +12,7 @@ const ManagedRun = Schema.Struct({
brief: Schema.Struct({
workspaceId: Schema.String,
repository: Schema.String,
baseSha: Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}$/)),
baseSha: CommitSha,
scope: Schema.String,
tokens: Tokens,
}),
Expand All @@ -20,6 +21,14 @@ const ManagedRun = Schema.Struct({
used: Schema.NullOr(Tokens),
remaining: Schema.NullOr(Tokens),
}),
qa: Schema.optionalKey(
Schema.Struct({
reviewedSha: CommitSha,
verdict: Schema.Literals(["pass", "fail"]),
source: Schema.Literals(["provider", "operator"]),
budgetExceeded: Schema.Boolean,
}),
),
stages: Schema.Array(
Schema.Struct({
stageId: Schema.String,
Expand Down
Loading