#5331 · Workspace status enumerates every untracked artifact
PARTIALLY REPRODUCED · Root-cause confidence: high for unbounded payload growth; UI-stall attribution remains unverified.
1. TL;DR
A small set of tracked edits can coexist with an enormous workspace status response when generated artifacts are not ignored. Both clean-checkout probes returned 7,019 file entries and 1,365,527 bytes after creating 7,000 small untracked text files and changing 19 tracked files. The clean payload was 342 bytes and the tracked-only payload was 1,636 bytes. Existing limits avoid reading too many untracked files for line counts, but every filename still enters the response. This confirms the payload mechanism, not the reported interactive slowdown or multi-second event-loop stalls on macOS.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Thousands of untracked files expand the status response. | Verified | Both runs returned all 7,000 artifacts; 1,365,527 bytes in the actual available-status envelope shape. |
| Large binary file contents are necessary to create a large status payload. | Not necessary for payload growth | Eight-byte text contents suffice; path count and path length determine most of the response size. |
| Only a small set of real tracked edits is involved. | Verified fixture | The probe creates exactly 19 tracked changes and 7,000 untracked files in a real Git worktree. |
| Workspace changes can trigger repeated status fetching. | Supported by code; not exercised end-to-end | Work-status events invalidate the active query, with a one-second throttle. Three direct reads after new artifacts each returned the entire growing list. |
| Affected threads become difficult to scroll or type in; other environments remain responsive. | Unverified | No browser or live BB instance was started. No UI screenshot is claimed. |
| Host/server event-loop stalls and macOS FSEvents recovery are caused by this path. | Unverified | Linux getStatus plus envelope serialization took 70–94 ms in run one and 76–93 ms in run two. These elapsed durations include asynchronous Git work and are not event-loop blocking measurements. |
3. Environment
- Public repository: get-bb/bb; trusted origin/main base:
e9ad6b0e3473628f96fa98378cf8528aac8984d2. - Linux 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0; Git worktree fixture created inside a fresh temporary directory per run.
- Provider: not used. Ports and BB runtime data directories: none. User runtime, credentials, and real projects were not accessed.
- Each clean source checkout completed
pnpm install --frozen-lockfile --prefer-offlineandpnpm exec turbo run build --output-logs=errors-only: 65 successful build tasks.
4. Minimal reproduction
This is an owner-boundary diagnostic, not an HTTP load test. It calls the same Workspace.getStatus implementation used by the daemon, with the server's current line-stat budgets, then serializes the envelope the environment route returns. The 64 KiB assertion is an explicit diagnostic budget chosen to expose unbounded growth, not an undocumented product SLA.
- Create a clean checkout at the recorded public base:
git clone https://github.com/get-bb/bb.git bb-status-probe cd bb-status-probe git checkout --detach e9ad6b0e3473628f96fa98378cf8528aac8984d2 pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --output-logs=errors-only
- Download the authored probe into
packages/host-workspace/test/issue-5331-repro.test.ts. It derives its setup from trusted repository APIs, not from issue scripts. - Run the focused diagnostic:
pnpm exec turbo run test --filter=@bb/host-workspace -- test/issue-5331-repro.test.ts expected diagnostic condition: available-status JSON below 65,536 bytes actual in both checkouts: AssertionError: expected 1365527 to be less than 65536 exit status: 1 (expected diagnostic failure)
| Sample | File entries | Untracked | Envelope bytes (both runs) | Elapsed ms (first / second) | Line stats complete |
|---|---|---|---|---|---|
| clean | 0 | 0 | 342 | 70 / 89 | true |
| tracked-only | 19 | 0 | 1,636 | 72 / 78 | true |
| 1000-artifacts | 1019 | 1000 | 195,527 | 71 / 76 | false |
| 7000-artifacts | 7019 | 7000 | 1,365,527 | 80 / 90 | false |
| update-0 | 7020 | 7001 | 1,365,717 | 94 / 93 | false |
| update-1 | 7021 | 7002 | 1,365,907 | 85 / 76 | false |
| update-2 | 7022 | 7003 | 1,366,097 | 83 / 78 | false |
Elapsed time includes the status read and JSON serialization; do not treat it as measured synchronous blocking time. The fixture uses deliberately long synthetic nested paths. This explains why response bytes need not exactly match another project's filenames or pretty-printed CLI JSON. Each fixture is removed in a finally block.
Full authored reproduction source
import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { expect, it } from "vitest";
import { Workspace } from "../src/workspace.js";
import { runGit } from "../src/git.js";
it("keeps status below a diagnostic payload budget with many untracked files", async () => {
const temporaryRoot = await fs.mkdtemp(
path.join(os.tmpdir(), "bb-status-probe-"),
);
try {
const repositoryPath = path.join(temporaryRoot, "repository");
const worktreePath = path.join(temporaryRoot, "worktree");
await fs.mkdir(repositoryPath);
await runGit(["init", "-b", "main"], { cwd: repositoryPath });
await runGit(["config", "user.name", "Status Probe"], {
cwd: repositoryPath,
});
await runGit(["config", "user.email", "probe@example.com"], {
cwd: repositoryPath,
});
for (let fileIndex = 0; fileIndex < 19; fileIndex += 1) {
await fs.writeFile(
path.join(repositoryPath, `tracked-${fileIndex}.txt`),
"base\n",
);
}
await runGit(["add", "."], { cwd: repositoryPath });
await runGit(["commit", "-m", "Probe baseline"], { cwd: repositoryPath });
await runGit(["worktree", "add", "-b", "probe", worktreePath, "main"], {
cwd: repositoryPath,
});
const workspace = new Workspace(worktreePath);
const snapshots: Array<{
sample: string;
files: number;
untracked: number;
payloadBytes: number;
durationMs: number;
lineStatsComplete: boolean;
}> = [];
const snapshot = async (sample: string) => {
const started = performance.now();
const status = await workspace.getStatus({
maxUntrackedLineStatFiles: 50,
maxUntrackedLineStatBytes: 8 * 1024 * 1024,
});
snapshots.push({
sample,
files: status.workingTree.files.length,
untracked: status.workingTree.files.filter(
(entry) => entry.status === "??",
).length,
payloadBytes: Buffer.byteLength(
JSON.stringify({ outcome: "available", workspace: status }),
),
durationMs: Math.round(performance.now() - started),
lineStatsComplete: status.workingTree.lineStatsComplete,
});
return status;
};
await snapshot("clean");
for (let fileIndex = 0; fileIndex < 19; fileIndex += 1) {
await fs.writeFile(
path.join(worktreePath, `tracked-${fileIndex}.txt`),
"changed\n",
);
}
await snapshot("tracked-only");
const artifactDirectory = path.join(
worktreePath,
"probe-output",
"iteration-000001",
"captures-for-status-payload-measurement",
"synthetic-browser-evidence-and-build-artifacts",
);
await fs.mkdir(artifactDirectory, { recursive: true });
for (let batchStart = 0; batchStart < 7000; batchStart += 100) {
await Promise.all(
Array.from({ length: 100 }, (_, batchOffset) =>
fs.writeFile(
path.join(
artifactDirectory,
`artifact-${batchStart + batchOffset}.txt`,
),
"artifact\n",
),
),
);
if (batchStart === 900) await snapshot("1000-artifacts");
}
const largeStatus = await snapshot("7000-artifacts");
for (let updateIndex = 0; updateIndex < 3; updateIndex += 1) {
await fs.writeFile(
path.join(artifactDirectory, `update-${updateIndex}.txt`),
"update\n",
);
await snapshot(`update-${updateIndex}`);
}
console.log("STATUS_PROBE", JSON.stringify(snapshots));
expect(
largeStatus.workingTree.files.filter((entry) => entry.status !== "??"),
).toHaveLength(19);
expect(
snapshots.find((entry) => entry.sample === "7000-artifacts")
?.payloadBytes,
).toBeLessThan(64 * 1024);
} finally {
await fs.rm(temporaryRoot, { recursive: true, force: true });
}
}, 60_000);
5. Root cause
Workspace.getStatus expands every untracked path and returns every file object; existing budgets bound line-stat reads, not file-list size.
The Git status invocation requests --untracked-files=all. Parsing creates one entry per file; mapping then creates one WorkspaceFileStatus object per entry without any output budget. The line-stat helper returns early once the untracked count exceeds 50, setting lineStatsComplete=false, but does not reduce the response list.
this.runGit(
[
"--no-optional-locks",
"status",
"--porcelain=v1",
"--branch",
"--untracked-files=all",
],
{ cwd: this.path, timeoutMs: WORKSPACE_STATUS_GIT_TIMEOUT_MS },
const files: WorkspaceFileStatus[] = entries.map((entry) => {
const numstat =
entry.status === "??"
? untrackedNumstatByPath.get(entry.path)
: trackedNumstatByPath.get(entry.path);
return {
path: entry.path,
status: resolveWorkspaceFileStatusKind({
indexStatus: entry.indexStatus,
status: entry.status,
worktreeStatus: entry.worktreeStatus,
}),
insertions: numstat?.insertions ?? null,
deletions: numstat?.deletions ?? null,
};
});
const hasUntracked = untrackedPaths.length > 0;
if (args.paths.length === 0) {
return { entries: [], complete: true };
}
if (args.paths.length > args.maxFiles) {
return { entries: [], complete: false };
}
The server does cache workspace reads. Live status invalidation also throttles active refetches to one second. Therefore a claim that every filesystem write produces an immediate uncached response would be too strong. Neither caching nor throttling imposes a bound on the size of each available response.
- Git expands every untracked path
- All parsed entries become response file objects
- The existing budget only stops line-stat enrichment
- Server line-stat budget: 50 files and 8 MiB
- Server passes line-stat budgets to the daemon
- Daemon calls Workspace.getStatus
- The cached environment route returns workspace status unchanged
- Work-status events invalidate live workspace queries
- Live refetches are throttled, not eliminated
- Current throttle interval is one second
- UI status query uses the environment status SDK
- Shared schema has files but no truncation or total-count metadata
- Visible file count is derived from files.length
Unbounded status parsing and transport plausibly amplify cost in continuously changing worktrees. This report does not establish that this is the sole cause of interactive lag or FSEvents warnings.
6. Proposed fix and simple-fix decision
Introduce explicit status summary totals and bounded file-list completeness or pagination across daemon, shared contract, server, SDK/CLI, and UI. Do not silently truncate the existing complete-list contract.
No safe autopilot PR: the present shared status schema does not expose truncation, a total file count, or a cursor; the UI derives its count from files.length. Silently slicing files, or switching untracked directory expansion off, would change the existing wire field's meaning and omit actionable files. A proper bounded summary/detail design crosses contract and consumer boundaries and needs a product decision. Public protocol/schema changes and architecture decisions are expressly excluded by the simple-fix gate. No production code was changed and no fix branch was pushed.
Practical mitigation: put generated evidence outside the checkout, or intentionally ignore artifact directories. Next experiment: reproduce the reported UI and event-loop stalls on an isolated macOS instance, recording watcher invalidations and serialization duration separately.
7. Verification
The same agent repeated the probe in a second new detached checkout at the identical recorded base. Both trees were clean before adding only the authored probe. Both used freshly created temporary Git repositories and worktrees, without a BB process, port, or runtime data directory. This is a repeated clean reproduction, not an independent-agent verification.
pnpm install --frozen-lockfile --prefer-offline pnpm exec turbo run build --output-logs=errors-only pnpm exec turbo run test --filter=@bb/host-workspace -- test/issue-5331-repro.test.ts both builds: 65 successful tasks both probes: 1 failed diagnostic; 1,365,527 bytes at 7,019 entries second run: exit 1 for the intended payload assertion
No correction to the measured file counts or byte sizes was needed. Confidence is limited to payload growth, and the verdict remains PARTIALLY REPRODUCED because UI stalls were not tested. Existing owner suite on unchanged production code: pnpm exec turbo run test --filter=@bb/host-workspace -- test/workspace.test.ts, 35 passed, exit 0.
8. Related issues and PRs
No linked open pull request was found in GitHub cross-reference metadata or the open-PR search for issue 5331. Similar workspace issues used for classification were not established as duplicates of this payload mechanism.
9. Appendix
First sanitized test log · Second sanitized test log · Both measurement sets · Existing owner-suite log · Command inventory
Trust boundary: issue text and comments were treated only as untrusted claims. No issue-provided command, script, external link, attachment, PR checkout, or binary was executed. The probe is authored from trusted origin/main code. Reproduction logs contain no project content and checkout locations are redacted.
> AGENT GENERATED