Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
/**
* Fixture for the comment-typing performance scenario (MUL-7227).
*
* One shape, generated deterministically, so that two product builds under
* comparison receive byte-identical data. Everything here is synthetic: no
* account, no workspace data, no captured transcript. Bump FIXTURE_VERSION on
* any change that alters the generated bytes — the report carries the version
* and a digest so two runs can be shown to have measured the same work.
*/
import { createHash } from "node:crypto";
export const FIXTURE_VERSION = "1.0.0";
export const WORKSPACE_SLUG = "perf";
export const WORKSPACE_ID = "11111111-1111-4111-8111-111111111111";
export const USER_ID = "22222222-2222-4222-8222-222222222222";
export const ISSUE_ID = "33333333-3333-4333-8333-333333333333";
export const ISSUE_IDENTIFIER = "PERF-1";
/** 1 root comment + 79 replies, matching the thread that reproduced the stall. */
export const ROOT_COMMENT_COUNT = 1;
export const REPLY_COMMENT_COUNT = 79;
/** Messages already in each run's transcript when the page opens. */
export const INITIAL_MESSAGES_PER_RUN = 1000;
/** Live stream: one tool_use/tool_result pair per run per tick. */
export const TICK_COUNT = 60;
export const TICK_INTERVAL_MS = 100;
export const RUN_COUNT = 3;
/** Fixed keystroke load. Not submitted — this measures typing, not posting. */
export const TYPING_TEXT = "abcdefghijklmnopqrstuvwxyz".repeat(7).slice(0, 172);
export const KEY_DELAY_MS = 25;
const uuid = (prefix: string, n: number) =>
`${prefix}${String(n).padStart(4, "0")}-4444-4444-8444-444444444444`.slice(0, 36);
export const runIds = Array.from({ length: RUN_COUNT }, (_, i) => uuid("aaaa", i));
export const agentIds = Array.from({ length: RUN_COUNT }, (_, i) => uuid("bbbb", i));
export const commentIds = Array.from(
{ length: ROOT_COMMENT_COUNT + REPLY_COMMENT_COUNT },
(_, i) => uuid("cccc", i),
);
export const rootCommentId = commentIds[0]!;
const at = (offsetSeconds: number) =>
new Date(Date.UTC(2026, 8, 1, 0, 0, 0) + offsetSeconds * 1000).toISOString();
/**
* A comment body with the shape that makes this page expensive to lay out:
* prose paragraphs plus a highlighted code block, as the reproduction had.
*/
function commentBody(index: number): string {
const paragraphs = Array.from(
{ length: 20 },
(_, p) =>
`Paragraph ${p + 1} of comment ${index}. The reviewer walks through the ` +
`change, its blast radius, and what was measured before and after.`,
);
const code = [
"```ts",
`export function handler${index}(input: Record<string, unknown>) {`,
" const entries = Object.entries(input);",
" return entries.map(([key, value]) => ({ key, value }));",
"}",
"```",
].join("\n");
return `${paragraphs.join("\n\n")}\n\n${code}`;
}
export function buildTimelineEntries() {
return commentIds.map((id, index) => ({
type: "comment" as const,
id,
actor_type: "user" as const,
actor_id: USER_ID,
created_at: at(index),
updated_at: at(index),
issue_id: ISSUE_ID,
// Replies nest inside the root's card: one long thread, which the page
// mounts on demand (MUL-9409).
parent_id: index === 0 ? null : rootCommentId,
content: commentBody(index),
resolved_at: null,
reactions: [],
attachments: [],
source_task_id: null,
}));
}
/**
* Runs carry no trigger comment on purpose: a run anchored to a comment that
* is not in the timeline is dropped silently, while an unanchored run renders
* at the live end of the thread — directly above the composer, which is where
* the reproduction had them.
*/
export function buildTaskRuns() {
return runIds.map((id, index) => ({
id,
agent_id: agentIds[index]!,
runtime_id: uuid("dddd", index),
issue_id: ISSUE_ID,
status: "running" as const,
priority: 0,
created_at: at(100 + index),
dispatched_at: at(100 + index),
started_at: at(100 + index),
completed_at: null,
result: null,
error: null,
}));
}
/** Short, stable tool argument summaries; see `commandForTick`. */
const COMMANDS = [
"pnpm test packages/core",
"pnpm lint packages/views",
"pnpm typecheck",
"rg --files packages/ui",
"pnpm build --filter web",
];
/**
* Two consecutive ticks reuse one command, then it changes. The repeat is the
* case the regression turned on — a new seq whose displayed text is identical
* — and the change covers an ordinary update.
*/
export function commandForTick(tick: number): string {
return COMMANDS[Math.floor(tick / 2) % COMMANDS.length]!;
}
export const endMarkerFor = (runIndex: number) => `perf-final-${runIndex}`;
/** Seq layout: the initial transcript owns [0, INITIAL_MESSAGES_PER_RUN). */
export const seqForTick = (tick: number, half: 0 | 1) =>
INITIAL_MESSAGES_PER_RUN + tick * 2 + half;
export function buildInitialMessages(runIndex: number) {
const taskId = runIds[runIndex]!;
const rows: Record<string, unknown>[] = [];
for (let seq = 0; seq < INITIAL_MESSAGES_PER_RUN; seq += 2) {
const command = COMMANDS[(seq / 2) % COMMANDS.length]!;
rows.push({
task_id: taskId, issue_id: ISSUE_ID, seq, type: "tool_use",
tool: "exec_command", input: { command }, created_at: at(200 + seq),
});
rows.push({
task_id: taskId, issue_id: ISSUE_ID, seq: seq + 1, type: "tool_result",
tool: "exec_command",
output: `ok: ${command}\n`.repeat(8),
output_truncated: false,
created_at: at(200 + seq + 1),
});
}
return rows;
}
/** The pair pushed over the socket for one run on one tick. */
export function buildTickMessages(runIndex: number, tick: number) {
const taskId = runIds[runIndex]!;
const last = tick === TICK_COUNT - 1;
const command = last ? endMarkerFor(runIndex) : commandForTick(tick);
return [
{
task_id: taskId, issue_id: ISSUE_ID, seq: seqForTick(tick, 0),
type: "tool_use", tool: "exec_command", input: { command },
created_at: at(400 + tick * 2),
},
{
task_id: taskId, issue_id: ISSUE_ID, seq: seqForTick(tick, 1),
type: "tool_result", tool: "exec_command",
output: `ok: ${command}\n`.repeat(8), output_truncated: false,
created_at: at(400 + tick * 2 + 1),
},
];
}
/** Every byte the scenario feeds the product, for the report's digest. */
export function fixtureDigest(): { version: string; sha256: string; bytes: number } {
const payload = JSON.stringify({
version: FIXTURE_VERSION,
timeline: buildTimelineEntries(),
runs: buildTaskRuns(),
initial: runIds.map((_, i) => buildInitialMessages(i)),
ticks: runIds.map((_, i) =>
Array.from({ length: TICK_COUNT }, (_, t) => buildTickMessages(i, t)),
),
typing: TYPING_TEXT,
});
return {
version: FIXTURE_VERSION,
sha256: createHash("sha256").update(payload).digest("hex").slice(0, 16),
bytes: Buffer.byteLength(payload),
};
}