Public: anyone can read this; the crew can change it.

A crew run's page says how its model was fed, so a packed SubQ run compares with its explored run and with Claude #17925

opened this

Merged 21h 13m ago, live in production

mason/forge:mason/17920-a-crew-run-s-page-says-how-its-model-was → main 0 commits fork 2 threads · 2 unresolved

  • Merged. mason/17920-a-crew-run-s-page-says-how-its-model-was was merged into main as 52b26cd.

Review

Sign in to review this change.
17 files changed +250 −7
docs/features/model-feed.md +11
@@ -44,3 +44,14 @@ you write the line, and Talk's turns are never packed.
4444
4545 The run log says it: `packed 1.2M tokens (812 files), cached 1.1M, 2 rounds, 14.2 s + 31.0 s per
4646 round`, and each round's time, tokens read (and cached) and written.
47
48 ## Read it on the run (#17920)
49
50 Every crew run records its feed as data: `explored`, or `packed` with the pack (tokens, files, the
51 cached share), the rounds used and the time of each. The run's page and the terminal's run screen
52 show it as a **Fed** line: `packed 1.2M tokens (812 files), cached 1.1M · 3 rounds · 40 s, 35 s,
53 22 s`, or `explored with tools`. The runs list, on the page and in the terminal, gives each agent
54 run one row of `feed · steps or rounds · time · outcome` (`packed · 3 rounds · 1m 37s · ok`,
55 `explored · 12 steps · 4m 2s · ok`), so a packed run, its explored run and a Claude run compare
56 without opening a log. The run's JSON answer (`/api/v1/repos/:owner/:name/runs/:id`) has the same
57 record as `feed` (null for a run from before this).
src/contract/openapi/schemas/run.ts +15
@@ -20,6 +20,19 @@ const CHECK_DETAIL: Schema = obj(
2020 ["files", "failures"],
2121 );
2222
23 /** How an agent run's model was fed: the pack and the rounds when packed (#17920). */
24 const RUN_FEED: Schema = obj(
25 {
26 feed: words("explored", "packed"),
27 tokens: int,
28 files: int,
29 cached: int,
30 rounds: int,
31 roundMs: list(int),
32 },
33 ["tokens", "files", "cached", "rounds", "roundMs"],
34 );
35
2336 /** One run of a deploy, an agent or a check. */
2437 const RUN: Schema = obj({
2538 id: str,
@@ -42,6 +55,7 @@ const RUN: Schema = obj({
4255 turns: int,
4356 contextTokens: int,
4457 model: str,
58 feed: orNull(ref("RunFeed")),
4559 tokensIn: orNull(int),
4660 tokensOut: orNull(int),
4761 pushed: orNull(bool),
@@ -96,6 +110,7 @@ const PROPOSAL: Schema = obj(
96110
97111 export const RUN_SCHEMAS: Readonly<Record<string, Schema>> = {
98112 CheckDetail: CHECK_DETAIL,
113 RunFeed: RUN_FEED,
99114 Run: RUN,
100115 Look: LOOK,
101116 Plan: PLAN,
src/core/migration-pins/20261203060000-run-feed.pin added +1
@@ -0,0 +1,1 @@
1 80c29655712294b27c79f5b22c21f0d8a996fdb7379ee5df532bf63351cfebd7
src/core/migrations/20261203060000-run-feed.ts added +5
@@ -0,0 +1,5 @@
1 // How a crew run's model was fed (#17920, core/run_feed.ts): JSON {feed, tokens, files, cached,
2 // rounds, roundMs} for packed, {feed} for explored; '' for a run that recorded none. Additive.
3 export default `
4 ALTER TABLE run ADD COLUMN feed TEXT NOT NULL DEFAULT '';
5 `;
src/core/run_feed.ts added +54
@@ -0,0 +1,54 @@
1 /**
2 * How a crew run's model was fed, kept as data on the run (#17920): `explored` (the tool loop,
3 * every model's default) or `packed` (the repository sent once, `crew/packed_run.ts`) with the
4 * pack, the rounds used and the time of each. The run's page, the terminal, the runs list and the
5 * JSON API all say it from this one record, so a packed run, its explored run and a Claude run
6 * compare without opening a log. Plain data in, plain words out.
7 */
8
9 export type RunFeed =
10 | { readonly feed: "explored" }
11 | {
12 readonly feed: "packed";
13 /** The pack's size in tokens, and the files in it. */
14 readonly tokens: number;
15 readonly files: number;
16 /** Prompt tokens the provider read from its cache, summed over the rounds. */
17 readonly cached: number;
18 /** Rounds asked so far, and how long each took in milliseconds. */
19 readonly rounds: number;
20 readonly roundMs: readonly number[];
21 };
22
23 /** A token count as a person reads it: 1.2M, 340k, 812. */
24 export const compact = (n: number): string => (n >= 1_000_000 ? `${(n / 1_000_000).toFixed(1)}M` : n >= 1_000 ? `${String(Math.round(n / 1_000))}k` : String(n));
25
26 const whole = (v: unknown): number => (typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0);
27
28 /** A stored feed back into data; undefined for none, or for what is not one. */
29 export function parseFeed(text: string): RunFeed | undefined {
30 if (text === "") return undefined;
31 try {
32 const v = JSON.parse(text) as Record<string, unknown> | null;
33 if (v === null || typeof v !== "object") return undefined;
34 if (v.feed === "explored") return { feed: "explored" };
35 if (v.feed !== "packed") return undefined;
36 const ms = Array.isArray(v.roundMs) ? v.roundMs.map(whole) : [];
37 return { feed: "packed", tokens: whole(v.tokens), files: whole(v.files), cached: whole(v.cached), rounds: whole(v.rounds), roundMs: ms };
38 } catch {
39 return undefined;
40 }
41 }
42
43 const secs = (ms: number): string => `${String(Math.round(ms / 1000))} s`;
44
45 /**
46 * The feed in one line:
47 * `packed 1.2M tokens (812 files), cached 1.1M · 3 rounds · 40 s, 35 s, 22 s`, or
48 * `explored with tools`.
49 */
50 export function feedLine(f: RunFeed): string {
51 if (f.feed === "explored") return "explored with tools";
52 const rounds = f.rounds === 0 ? "no round yet" : `${String(f.rounds)} round${f.rounds === 1 ? "" : "s"}`;
53 return [`packed ${compact(f.tokens)} tokens (${String(f.files)} file${f.files === 1 ? "" : "s"}), cached ${compact(f.cached)}`, rounds, ...(f.roundMs.length === 0 ? [] : [f.roundMs.map(secs).join(", ")])].join(" · ");
54 }
src/core/runs.ts +13 −1
@@ -14,6 +14,7 @@ import { BUDGET_PREFIX } from "../kernel/budgets.ts";
1414 import { id } from "../kernel/id.ts";
1515 import { appendRun } from "./ledger.ts";
1616 import { meterOf } from "./run_compute.ts";
17 import { parseFeed, type RunFeed } from "./run_feed.ts";
1718
1819 export type RunKind = "deploy" | "agent" | "check";
1920
@@ -118,6 +119,11 @@ export interface Run {
118119 readonly contextTokens: number;
119120 /** For an agent run: the model it ran on; empty when not recorded. */
120121 readonly model: string;
122 /**
123 * For an agent run: how its model was fed, the pack and the rounds (#17920); null when
124 * unrecorded.
125 */
126 readonly feed: RunFeed | null;
121127 /**
122128 * For an agent run: tokens it read and wrote, all invocations summed;
123129 * null when unknown (never 0 for unknown).
@@ -184,6 +190,7 @@ interface RunRow {
184190 turns: number;
185191 context_tokens: number;
186192 model: string | null;
193 feed: string;
187194 tokens_in: number | null;
188195 tokens_out: number | null;
189196 pushed: number | null;
@@ -226,6 +233,7 @@ const toRun = (r: RunRow): Run => ({
226233 turns: r.turns,
227234 contextTokens: r.context_tokens,
228235 model: r.model ?? "",
236 feed: parseFeed(r.feed ?? "") ?? null,
229237 tokensIn: r.tokens_in ?? null,
230238 tokensOut: r.tokens_out ?? null,
231239 pushed: r.pushed === null ? null : r.pushed !== 0,
@@ -554,6 +562,8 @@ export function noteRunProgress(
554562 /** Why that model: the agent's own, or what escalated the run to Opus. */
555563 modelReason?: string | undefined;
556564 promptVersion?: string | undefined;
565 /** How the model is fed, with what the run has used of it so far (#17920). */
566 feed?: RunFeed | undefined;
557567 },
558568 ): void {
559569 db.query(
@@ -567,7 +577,8 @@ export function noteRunProgress(
567577 prompt_version = COALESCE(?11, prompt_version),
568578 model_reason = COALESCE(?12, model_reason),
569579 start = COALESCE(?13, start),
570 setup_ms = COALESCE(?14, setup_ms)
580 setup_ms = COALESCE(?14, setup_ms),
581 feed = COALESCE(?15, feed)
571582 WHERE id = ?1`,
572583 ).run(
573584 runId,
@@ -584,6 +595,7 @@ export function noteRunProgress(
584595 progress.modelReason?.slice(0, 60) ?? null,
585596 progress.start ?? null,
586597 progress.setupMs === undefined ? null : Math.max(0, Math.trunc(progress.setupMs)),
598 progress.feed === undefined ? null : JSON.stringify(progress.feed),
587599 );
588600 }
589601
src/crew/agent_runner.ts +3
@@ -8,6 +8,7 @@
88 */
99
1010 import type { Measure } from "../core/measure.ts";
11 import type { RunFeed } from "../core/run_feed.ts";
1112 import type { ModelProfile } from "../core/model_profile.ts";
1213 import type { LimitWindow } from "../core/standing.ts";
1314 import type { RunLimits } from "./run-cell.ts";
@@ -75,6 +76,8 @@ export interface AgentRun {
7576 * for this invocation, never deltas.
7677 */
7778 readonly onUsage?: ((spent: Spent) => void) | undefined;
79 /** How the model is being fed, said at the start and again after each packed round (#17920). */
80 readonly onFeed?: ((feed: RunFeed) => void) | undefined;
7881 /** The provider's measurement of a window, each time the session reports one (#8960). */
7982 readonly onMeasure?: ((measure: Measure) => void) | undefined;
8083 /** The provider said this window is under its thresholds: a stored reading of it is stale. */
src/crew/openai_runner.ts +1
@@ -620,6 +620,7 @@ export async function runOpenAI(run: AgentRun, config: Record<string, string | u
620620 test: () => shell(TEST_COMMAND),
621621 push: (message) => shell(PUSH_COMMAND, { FORGE_PACKED_MESSAGE: message.slice(0, 500) }),
622622 log: (line) => run.log(line),
623 feed: (f) => run.onFeed?.(f),
623624 say: (text) => run.onSaid?.({ kind: "text", text }),
624625 },
625626 });
src/crew/packed_run.ts +6 −3
@@ -11,6 +11,7 @@
1111 import type { AgentOutcome } from "./agent_runner.ts";
1212 import type { Pack } from "./context_pack.ts";
1313 import type { ModelProfile } from "../core/model_profile.ts";
14 import { compact, type RunFeed } from "../core/run_feed.ts";
1415
1516 /** One answer of the model, with what the endpoint said it read. */
1617 export type Asked =
@@ -31,6 +32,8 @@ export interface Hands {
3132 /** Commit with `message` and push; the output with `[forge-exit N]` last. */
3233 push(message: string): Promise<string>;
3334 log(line: string): void;
35 /** The feed as the run's record, said at the start and after each round (#17920). */
36 feed?(feed: RunFeed): void;
3437 /** What the run says in its thread. */
3538 say(text: string): void;
3639 }
@@ -105,9 +108,6 @@ export const exitOf = (output: string): number | undefined => {
105108 return m === null ? undefined : Number(m[1]);
106109 };
107110
108 /** A token count as a person reads it: 1.2M, 340k, 812. */
109 export const compact = (n: number): string => (n >= 1_000_000 ? `${(n / 1_000_000).toFixed(1)}M` : n >= 1_000 ? `${String(Math.round(n / 1_000))}k` : String(n));
110
111111 const seconds = (ms: number): string => `${(ms / 1000).toFixed(1)} s`;
112112
113113 /**
@@ -123,6 +123,8 @@ export async function runPacked(input: { pack: Pack; system: string; task: strin
123123 hands.log(`packed ${compact(pack.tokens)} tokens (${String(pack.files)} files${pack.whole ? ", the whole repository" : ` of ${String(pack.offered)}`}), at most ${String(profile.rounds)} rounds`);
124124 let cached = 0;
125125 const times: number[] = [];
126 const record = () => hands.feed?.({ feed: "packed", tokens: pack.tokens, files: pack.files, cached, rounds: times.length, roundMs: [...times] });
127 record();
126128 const wrap = (ok: boolean, result: string, rounds: number) => {
127129 hands.log(`packed ${compact(pack.tokens)} tokens (${String(pack.files)} files), cached ${compact(cached)}, ${String(rounds)} round${rounds === 1 ? "" : "s"}, ${times.map(seconds).join(" + ") || "no time"} per round`);
128130 return { ok, result, rounds };
@@ -135,6 +137,7 @@ export async function runPacked(input: { pack: Pack; system: string; task: strin
135137 if ("outcome" in got) return got;
136138 times.push(Date.now() - began);
137139 cached += got.cachedTokens;
140 record();
138141 hands.log(`round ${String(round)}: ${seconds(times.at(-1)!)}, read ${compact(got.promptTokens)} tokens (cached ${compact(got.cachedTokens)}), wrote ${compact(got.outputTokens)}`);
139142 messages.push({ role: "assistant", content: got.content });
140143 const parsed = parseChange(got.content);
src/crew/run_prepare.ts +2
@@ -269,6 +269,7 @@ export async function prepareAgent(s: PrepareState): Promise<Prepared> {
269269 onSteer: (send) => {
270270 listenForSteer(run.id, send);
271271 },
272 onFeed: (feed) => noteRunProgress(app.db, run.id, { feed }),
272273 onMeasure: (m) => noteMeasure(app.db, meter.subscriptionId ?? PLATFORM, m),
273274 onCleared: (window) => forgetMeasure(app.db, meter.subscriptionId ?? PLATFORM, window),
274275 onUsage: (so) =>
@@ -301,6 +302,7 @@ export async function prepareAgent(s: PrepareState): Promise<Prepared> {
301302 );
302303 if (!s.reviewing && s.resumeWhy !== "") write(s.resumeWhy);
303304 noteRunProgress(app.db, run.id, {
305 feed: { feed: "explored" },
304306 model: chosen.model,
305307 modelReason: chosen.reason,
306308 promptVersion: promptVersion(agent, brief.role),
src/runs/run_compare.ts added +16
@@ -0,0 +1,16 @@
1 /**
2 * One agent run as a row to read beside its neighbours (#17920): how its model was fed, the steps
3 * (explored) or rounds (packed) it took, how long, and how it ended. The runs list on the page and
4 * in the terminal prints it, so a packed run, its explored run and a Claude run on the same kind of
5 * issue compare without opening a log. Nothing for a run that is not an agent's or recorded no
6 * feed.
7 */
8 import type { Run } from "../core/runs.ts";
9 import { durationText } from "./run_facts.ts";
10
11 export function compareWords(run: Run): string {
12 if (run.kind !== "agent" || run.feed === null) return "";
13 const n = run.feed.feed === "packed" ? run.feed.rounds : run.turns;
14 const unit = run.feed.feed === "packed" ? "round" : "step";
15 return [run.model, run.feed.feed, `${String(n)} ${unit}${n === 1 ? "" : "s"}`, durationText(run), run.state].filter((p) => p !== undefined && p !== "").join(" · ");
16 }
outdated

Principle 1 / issue box 3: the row has no model, so packed SubQ, explored and Claude runs cannot be told apart in the list. Lead with run.model when it is not empty. Add a test that two rows on different models show their model names.

src/runs/run_facts.ts +2
@@ -8,6 +8,7 @@
88
99 import { placementWords } from "../checks/placement.ts";
1010 import { tookParts } from "../checks/took_line.ts";
11 import { feedLine } from "../core/run_feed.ts";
1112 import type { Run } from "../core/runs.ts";
1213
1314 export interface RunFact {
@@ -126,6 +127,7 @@ export function runFacts(i: RunFactsInput): RunFact[] {
126127 facts.push({ label: "Ran on", text: where, ...(run.placement === "runner" && i.admin ? { href: "/settings/runners" } : {}) });
127128 }
128129 if (i.account !== undefined) facts.push({ label: "Account", text: i.account });
130 if (run.feed !== null) facts.push({ label: "Fed", text: feedLine(run.feed) });
129131 if (run.startedAt !== null) facts.push({ label: "Started", text: run.startedAt, at: run.startedAt });
130132 if (i.took !== undefined) facts.push({ label: run.finishedAt === null ? "Running for" : "Took", text: i.took });
131133 if (run.attempt > 0) facts.push({ label: "Attempt", text: String(run.attempt + 1) });
src/tui/screens/runlist.ts +2
@@ -20,6 +20,7 @@ import type { Run, RunState } from "../../core/runs.ts";
2020 import { getUsersByIds } from "../../core/users.ts";
2121 import { getUsage } from "../../core/usage.ts";
2222 import { priceWords } from "../../core/run_price.ts";
23 import { compareWords } from "../../runs/run_compare.ts";
2324 import { stillEnding } from "../../runs/ending.ts";
2425 import type { Ctx, Screen } from "../app/app.ts";
2526 import type { Rect, Screen as Surface } from "../term/screen.ts";
@@ -111,6 +112,7 @@ export function runRows(
111112 run.commitOid === "" ? "" : run.commitOid.slice(0, 7),
112113 costText(run.costUsd),
113114 counted(run),
115 compareWords(run),
114116 placementWords(run),
115117 relTime(runWhen(run)),
116118 ),
src/web/studio/lists.ts +9 −2
@@ -61,6 +61,7 @@ import {
6161 } from "../ui.ts";
6262 import { emptyList } from "../empty_words.ts";
6363 import type { Run, RunState } from "../../core/runs.ts";
64 import { compareWords } from "../../runs/run_compare.ts";
6465 import { actorsFor, issuesFor, runTitleFrom } from "../pages/runs.ts";
6566 import { originGlyph } from "../pages/thread.ts";
6667 import { changeHref, listLine, PAGE_TITLES, pageTitle, tellHref } from "./nouns.ts";
@@ -823,6 +824,12 @@ const RUNS_KIND_WORDS: Record<RunsKind, string> = {
823824 check: "Checks",
824825 };
825826
827 /** An agent run's feed, steps or rounds, time and outcome, ahead of its date (#17920). */
828 const compareLead = (run: Run): string => {
829 const words = compareWords(run);
830 return words === "" ? "" : `${words} · `;
831 };
832
826833 /**
827834 * GET /:owner/:name/runs: every run, for every repository and every viewer,
828835 * one row per run in its studio word — who ran it, when it last moved, and
@@ -905,12 +912,12 @@ export async function runsListPage(ctx: Ctx, repo: Repo): Promise<Response> {
905912 ? avatar(who)
906913 : icon(run.kind === "check" ? "check" : "rocket"),
907914 title: runTitleFrom(run, actors, issues),
908 meta:
915 meta: html`${compareLead(run)}${
909916 run.state === "failed"
910917 ? html`${noteLine(info.note)} · ${time(run.finishedAt ?? run.createdAt)}`
911918 : run.state === "queued" && run.notBefore !== null
912919 ? html`${noteLine(info.note)} · ${time(run.createdAt)}`
913 : time(run.finishedAt ?? run.createdAt),
920 : time(run.finishedAt ?? run.createdAt)}`,
914921 trail: wordBadge(info.word),
915922 });
916923 }),
test/model-feed.test.ts +2 −1
@@ -18,7 +18,8 @@ import { buildPack, gitSource, type Source } from "../src/crew/context_pack.ts";
1818 import { runOpenAI } from "../src/crew/openai_runner.ts";
1919 import { runAccount } from "../src/crew/runner_env.ts";
2020 import { wordsOf } from "../src/crew/pack_rank.ts";
21 import { compact, exitOf, parseChange, runPacked, type Asked, type Hands } from "../src/crew/packed_run.ts";
21 import { exitOf, parseChange, runPacked, type Asked, type Hands } from "../src/crew/packed_run.ts";
22 import { compact } from "../src/core/run_feed.ts";
2223 import { seedAdmin } from "./helpers/admin.ts";
2324 import { gitRun } from "./helpers/git-client.ts";
2425 import { quietLogs } from "./helpers/globals.ts";
test/run-feed.test.ts added +107
@@ -0,0 +1,107 @@
1 /**
2 * A crew run records how its model was fed (#17920): packed with the pack and rounds, or explored.
3 * The run's page, the terminal's rows and facts, the runs list and the JSON answer all say it.
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtemp, rm } from "node:fs/promises";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createRepo } from "../src/actions/repos.ts";
10 import { createApp, type App } from "../src/app.ts";
11 import { feedLine, parseFeed, type RunFeed } from "../src/core/run_feed.ts";
12 import { claimRun, createRun, finishRun, getRun, noteRunProgress, type Run } from "../src/core/runs.ts";
13 import { createSession } from "../src/core/sessions.ts";
14 import { runPacked, type Asked, type Hands } from "../src/crew/packed_run.ts";
15 import { serve, type Servers } from "../src/http/server.ts";
16 import { runFacts } from "../src/runs/run_facts.ts";
17 import { runRows } from "../src/tui/screens/runlist.ts";
18 import { seedAdmin } from "./helpers/admin.ts";
19 import { quietLogs } from "./helpers/globals.ts";
20
21 quietLogs();
22
23 const PACKED: RunFeed = { feed: "packed", tokens: 1_200_000, files: 812, cached: 1_100_000, rounds: 3, roundMs: [40_000, 35_000, 22_000] };
24 const LINE = "packed 1.2M tokens (812 files), cached 1.1M · 3 rounds · 40 s, 35 s, 22 s";
25
26 let dir: string, app: App, servers: Servers, cookie: string, packed: Run, explored: Run, bare: Run;
27 const get = async (path: string) => fetch(`${servers.url}${path}`, { headers: { cookie } });
28
29 beforeAll(async () => {
30 dir = await mkdtemp(join(tmpdir(), "forge-run-feed-"));
31 app = createApp({ dataDir: dir, port: 0 });
32 servers = await serve(app);
33 const made = await seedAdmin(app, { username: "alice", email: "[email protected]", password: "a-good-passphrase" });
34 if (!made.ok) throw new Error(made.error);
35 const repo = await createRepo(app, made.value, { name: "feed", visibility: "public" });
36 if (!repo.ok) throw new Error(String(repo.error));
37 cookie = `forge_session=${createSession(app.db, made.value.id).token}`;
38 const make = (feed: RunFeed | undefined, turns: number, model = "") => {
39 const r = createRun(app.db, { repoId: repo.value.id, kind: "agent", actorId: made.value.id, reason: "assigned" });
40 claimRun(app.db, r.id);
41 if (feed !== undefined) noteRunProgress(app.db, r.id, { feed, ...(model === "" ? {} : { model }) });
42 return finishRun(app.db, r.id, { state: "ok", summary: "All done", turns })!;
43 };
44 packed = make(PACKED, 3, "subq-savant");
45 explored = make({ feed: "explored" }, 12, "claude-opus-5-5");
46 bare = make(undefined, 2);
47 }, 60_000);
48
49 afterAll(async () => {
50 servers.stop();
51 app.close();
52 await rm(dir, { recursive: true, force: true });
53 });
54
55 test("a packed run's record carries the pack and the rounds, and the page says them in one line", async () => {
56 expect(getRun(app.db, packed.id)!.feed).toEqual(PACKED);
57 expect(feedLine(PACKED)).toBe(LINE);
58 const page = await (await get(`/alice/feed/runs/${packed.id}`)).text();
59 expect(page).toContain(`<dt>Fed</dt><dd>${LINE}</dd>`);
60 });
61
62 test("an explored run's page says it explored with tools, and a run with no record says nothing", async () => {
63 expect(await (await get(`/alice/feed/runs/${explored.id}`)).text()).toContain("<dt>Fed</dt><dd>explored with tools</dd>");
64 expect(await (await get(`/alice/feed/runs/${bare.id}`)).text()).not.toContain("<dt>Fed</dt>");
65 });
66
67 test("the terminal's facts and the JSON answer carry the same feed", async () => {
68 const facts = runFacts({ run: getRun(app.db, packed.id)!, base: "/alice/feed", defaultBranch: "main", admin: false, writer: true });
69 expect(facts.find((f) => f.label === "Fed")?.text).toBe(LINE);
70 const one = (await (await get(`/api/v1/repos/alice/feed/runs/${packed.id}`)).json()) as { feed: unknown };
71 expect(one.feed).toEqual(PACKED);
72 const list = (await (await get("/api/v1/repos/alice/feed/runs")).json()) as { items: { id: string; feed: unknown }[] };
73 expect(list.items.find((r) => r.id === explored.id)?.feed).toEqual({ feed: "explored" });
74 expect(list.items.find((r) => r.id === bare.id)?.feed).toBeNull();
75 });
76
77 test("the runs list reads side by side: feed, steps or rounds, time and outcome", async () => {
78 const rows = runRows([getRun(app.db, packed.id)!, getRun(app.db, explored.id)!, getRun(app.db, bare.id)!], new Map());
79 expect(rows[0]!.meta).toContain("subq-savant · packed · 3 rounds");
80 expect(rows[0]!.meta).toContain("· ok");
81 expect(rows[1]!.meta).toContain("claude-opus-5-5 · explored · 12 steps");
82 expect(rows[2]!.meta).not.toContain("steps");
83 const page = await (await get("/alice/feed/runs")).text();
84 expect(page).toContain("subq-savant · packed · 3 rounds");
85 expect(page).toContain("claude-opus-5-5 · explored · 12 steps");
86 });
87
88 test("what is not a feed reads as none", () => {
89 for (const junk of ["", "{", "null", "[]", '{"feed":"x"}']) expect(parseFeed(junk)).toBeUndefined();
90 expect(parseFeed('{"feed":"packed","tokens":"x","roundMs":[-1,5]}')).toEqual({ feed: "packed", tokens: 0, files: 0, cached: 0, rounds: 0, roundMs: [0, 5] });
91 });
92
93 test("a packed run says its feed at the start and after every round", async () => {
94 const said: RunFeed[] = [];
95 const hands: Hands = {
96 ask: async (): Promise<Asked> => ({ content: "=== file: a.ts ===\nx\n=== end ===\n=== message ===\nm\n=== end ===", promptTokens: 10, cachedTokens: 4, outputTokens: 1 }),
97 write: () => {},
98 remove: () => {},
99 test: async () => "[forge-exit 0]",
100 push: async () => "[forge-exit 0]",
101 log: () => {},
102 feed: (f) => void said.push(f),
103 say: () => {},
104 };
105 await runPacked({ pack: { text: "P", tokens: 2_000, files: 3, offered: 3, whole: true, ranked: [] }, system: "", task: "t", profile: { model: "m", feed: "packed", window: 8_000, rounds: 2 }, hands });
106 expect(said.map((f) => (f.feed === "packed" ? [f.rounds, f.cached] : []))).toEqual([[0, 0], [1, 4]]);
107 });

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs