Skip to content

fix(tests): twelve tests still assert elapsed wall-clock time, and no check enforces the rule in docs/TESTING.md #1902

Closed

Description

@dan-petty

Problem

docs/TESTING.md says that no test asserts on elapsed wall-clock time. No check enforces this rule, and 12 sites break it. A busy machine fails a bound of this kind with correct code. Three pre-push gates failed this way on 2026-10-22, and each failure cost a rerun of about 10 minutes.

Evidence

Issues #1825 and #1888 fix three of the tests that failed. These sites remain (found on 2026-10-22 at release tip b2b67df5):

  • tests/test_url_credential_masking.py:388: elapsed < 1.0 for each of four 100 KB inputs.
  • tests/test_rag_investigator.py:218: elapsed < 1.0 for 20 concurrent lookups.
  • tests/test_pydantic_ai_exceptions.py:152: elapsed < 0.5.
  • tests/test_ui_reactive.py:1460: elapsed < 1.0 for a refresh key press.
  • tests/test_treesitter_engine.py:258: elapsed_ms < 1000.0.
  • tests/test_context_packer.py:296: duration < 2.0.
  • tests/test_fastmcp_in_process.py:130: elapsed_ms < 10000.0.
  • tests/test_devcontainer.py:1927: time.monotonic() - start < 3.
  • tests/test_github_session.py:513: time.monotonic() - started < 5.0.
  • tests/test_process.py:433 and tests/test_process.py:459: a real sh child gets a timeout of HUNG_RUN_TIMEOUT_SECONDS (1.0 s) from the spawn, and the test waits for its pids inside it. These two can race like the test of fix(test): the process-group timeout test waits for its grandchild to start, not for 0.6 seconds #1888. The spawn wrapper of fix(test): the process-group timeout test waits for its grandchild to start, not for 0.6 seconds #1888 can serve them.
  • Three more sites assert a lower bound (tests/test_ai_review_pool.py:44 and :102, tests/core/test_clock_contract.py:48). Load only lengthens the time, so these do not fail under load.

Remedy

Fix each upper-bound site so that the test proves the behaviour without a clock. Use the fake clock or the shared bounds in tests/support/waits.py. Then add a check, so the rule has an enforcer: a rule for the ast-grep scan that the repository already runs, or another open tool that finds a clock read in an assertion. Show that the check fails on a new violation. If no check is possible, delete the sentence from docs/TESTING.md, because a rule with no check is pruned. Do not build a custom scanner (see the rule "Open Tools Before Internal Code").

regression of #1825, shipped in v0.2.39

Proposed design

Problem statement

Tests assert on elapsed wall-clock time. This causes test failures on busy machines. The rule in docs/TESTING.md is not enforced.

Acceptance criteria

  • Criterion 1: Each of the twelve listed tests no longer asserts on elapsed wall-clock time.
    Verification: Run the twelve tests and confirm they do not use time assertions.
  • Criterion 2: A check enforces the rule that no test asserts on elapsed wall-clock time.
    Verification: Run an ast-grep scan or another tool to verify no clock assertion exists in test files.

Key questions

  • How should the upper-bound time assertions be fixed?: Fix each upper-bound site so that the test proves the behaviour without a clock. Use the fake clock or the shared bounds in tests/support/waits.py. (proposed) [sources: docs/TESTING.md]
  • What check enforces the rule against asserting elapsed wall-clock time?: Add a rule for the ast-grep scan that the repository already runs, or another open tool that finds a clock read in an assertion. (proposed) [sources: docs/TESTING.md]

Open questions

  • What are the twelve tests that still assert on elapsed wall-clock time? (missing verified source)

Fit

Needs splitting into 2 items:

  1. Fix twelve tests to remove wall-clock time assertions.
  2. Add check to enforce rule against wall-clock time assertions.

Suspected block

None.

Dependencies

#1825, #1888

Activity

  1. added
    source/agent
    type/test
    on Oct 22, 2026
  2. dan-petty commented on Oct 22, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Type: type/test. The candidate is about fixing tests that assert elapsed wall-clock time, which is a test-related issue.
    • Priority: P1-High. The issue affects CI reliability and causes reruns, impacting development speed and resource usage.
    • Value: High. Fixing flaky tests under load improves project stability and developer experience.
    • Effort: Medium. Requires fixing multiple test locations and adding an enforcement check, which is substantial but not overly complex.
  3. dan-petty commented on Oct 23, 2026

    @dan-petty
    OwnerAuthor

    Proposal needs splitting into 2 items at 72b8a3c (see proposed design in issue body).

  4. added a commit that references this issue on Oct 23, 2026
    dd6052c
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

    source/agenttype/test

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions