Skip to content

test(runtime): internal/runtime tests fill production-sized caches under -race (99 s to 350-590 s in CI) #9347

Closed

Description

@waynesun09

What happens

internal/runtime is the package that makes the CI test job (go test -race -coverprofile=coverage.out ./...) hit Go's 10-minute per-package timeout on unrelated PRs (#9210). Its time in that job on main:

Commit on main Run internal/runtime
f24d145 (2026-11-04, before #8913) 41923315717 99 s
32d3cd8 (2026-11-05, #8913 merge) 41943203088 348 s
35228e6 (2026-11-11) 43067882310 463 s

#9304 raises the timeout to 20 minutes. That stops the false failures but leaves the cost. This issue removes the cost.

Cause

Five tests fill production-sized caches and buffers. Under the race detector each event pays for secret-pattern regex scans, so the loops are slow. Times are from go test -race -count=1 -json ./internal/runtime on an arm64 Mac (package total 255 s; the 74 tests added by #8913 take 118 s of it):

Test File Time Why it is slow
TestTaskProgressCacheAdmissionRetainsGuardsAndDedup task_progress_cache_test.go 74 s 17 tasks x 1,034 agent events to overflow the 16,384-row cache, then replays every cached row
TestCodexRedactingWriter_FlushesAtTheLineCap codex_redact_test.go 26 s writes 9 MiB through the redacting writer to cross the 8 MiB line cap
TestTaskProgressRelaunchRetiresSupersededRows task_progress_cache_test.go 19 s 4 generations x 2,000 agent events
TestClaudeWorkflowLargeSnapshotsDoNotReprint claude_task_cache_test.go 12 s 20 repeats of a 1,000-agent and a 500-agent snapshot
TestProgressCacheOwnsNormalizedStrings progress_allocation_test.go 8.5 s 32 rows x three 1 MiB padded strings, each scanned for secrets

The first test takes 1.2 s without -race, so the cost is the event count times the race detector, not a bug in the renderer.

The behaviour these tests prove (admission limits hold, existing rows and guards survive overflow, unchanged snapshots are not reprinted, cached strings do not pin large backing arrays, an endless line is flushed) does not depend on the limits being 1,024 or 16,384 or 8 MiB. It can be proved with limits of a few entries.

What to change

Scope is internal/runtime only. Default limits and production behaviour stay exactly as they are.

  1. Make the limits settable in tests.
    • progressReconciler (progress_reconciler.go): hold the task-entry, agents-per-task, row and status-entry limits as fields that default to maxTaskProgressEntries, maxTaskProgressAgentsPerTask, maxTaskProgressRows and maxStatusProgressEntries. The three checks in task_progress_reconciler.go and status_progress.go read the fields.
    • codexRedactingWriter (codex_redact.go): hold the line cap as a field that defaults to codexRedactMaxLine.
    • No exported API, flag, config field or environment variable. Tests in the same package set the fields directly.
  2. Shrink the five tests to run against small limits (for example 4 agents per task, 8 rows, a 1 KiB line cap) with the same assertions:
    • TestTaskProgressCacheAdmissionRetainsGuardsAndDedup: keep every assertion; overflow small limits instead of the defaults.
    • TestTaskProgressRelaunchRetiresSupersededRows: two generations and a handful of agents are enough to show that a relaunch retires the old rows and keeps dedup.
    • TestClaudeWorkflowLargeSnapshotsDoNotReprint: small snapshots, two or three repeats; keep the "printed once", hidden-task and stale-run assertions and adjust the expected counts.
    • TestProgressCacheOwnsNormalizedStrings: a few rows instead of 32, with the heap threshold scaled so that retaining the padded strings still fails the test.
    • TestCodexRedactingWriter_FlushesAtTheLineCap: small cap, a few KiB of input.
  3. One cheap test that the defaults are wired: a new reconciler and a new redacting writer carry the constant values. This replaces the slow tests as the guard against a default being dropped.
  4. Optional, same PR if trivial: TestTaskControlAdmissionNeverFlushesExistingTasks, TestTaskProgressRendererBoundedState and TestStatusProgressCapacityUpdateKeepsExistingEntries (about 1 s each) can use the same small limits.

Do not delete any of the five tests outright unless a shrunk version cannot keep its assertion; if one is deleted, say which and why in the PR description.

Note on #8913

Four of the five tests came in with #8913 (cc @jctanner). Nothing they assert is removed. What changes is that they overflow small test-only limits rather than the production defaults, so the default sizes themselves are covered by the wiring test in item 3 and not by a fill-to-the-limit run.

Out of scope

Done when

  • go test -race -count=1 ./internal/runtime passes, and none of the five tests takes more than 1 s on a developer machine.
  • The test job on the PR reports internal/runtime at or below about 150 s (348 to 590 s today). Put the before and after lines from the job log in the PR description.
  • Package coverage in the same job does not drop by more than rounding from 93.9%.
  • make lint passes.

Activity

  1. waynesun09 commented on Nov 11, 2026

    @waynesun09
    MemberAuthor

    /fs-code
    Do not sign off commits: no git commit -s, no Signed-off-by trailer.

  2. fullsend-ai-triage commented on Nov 11, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 11:41 PM UTC · Completed 11:43 PM UTC

    Commit: 35228e6 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.17

  3. fullsend-ai-coder commented on Nov 11, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Code · ⚠️ Cancelled · Started 11:41 PM UTC · Ended 11:43 PM UTC

    Commit: 35228e6 · View workflow run →

  4. added
    ready-to-code
    on Nov 11, 2026
  5. fullsend-ai-triage commented on Nov 11, 2026

    @fullsend-ai-triage

    Triage found this issue ready for implementation. The fix targets and the five constants you named exist in internal/runtime where described. No open PR or sub-issue addresses it. #9210 (the timeout symptom) and #8651 (broader slow-test tracking) are related context but not blockers.

    Implementation notes

    • The production limits are defined in task_progress_reconciler.go, status_progress.go and codex_redact.go. The check sites are in task_progress_reconciler.go (two places), status_progress.go and codex_redact.go.
    • Keep the limit fields unexported and defaulted to the existing constants, so production behaviour is unchanged.
    • The wiring test in item 3 is the only guard against a dropped default, so it should assert every constant.
    • Per your comment, commits must not be signed off.

    Proposed test case

    For each shrunk test: set small limits on the reconciler/writer, overflow them,
    and assert the original invariants (admission caps hold, existing rows and guards
    survive, unchanged snapshots print once, padded strings are not pinned, an
    over-long line is flushed). The allocation test must still fail if strings are
    retained.
    Wiring test: new reconciler/writer fields == maxTaskProgressEntries,
    maxTaskProgressAgentsPerTask, maxTaskProgressRows, maxStatusProgressEntries,
    codexRedactMaxLine.
    

    Done criteria: go test -race -count=1 ./internal/runtime passes with none of the five tests above 1 s, the CI package time is at or below about 150 s, coverage stays within rounding of 93.9%, and make lint passes.


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  6. fullsend-ai-coder commented on Nov 11, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ⚠️ Cancelled · Started 11:41 PM UTC · Completed 11:43 PM UTC

    Commit: 35228e6 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high

  7. fullsend-ai-coder commented on Nov 11, 2026

    @fullsend-ai-coder
    Contributor

    🤖 Finished Code · ✅ Success · Started 11:45 PM UTC · Completed 12:01 AM UTC

    Commit: 35228e6 · View workflow run →

    Runtime: claude · Model: opus → claude-opus-5-5 · Effort: high · Cost: $2.11

  8. added a commit that references this issue on Nov 12, 2026
  9. added 2 commits that reference this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-to-code

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions