Repository navigation
Description
What happened
The hermetic floor leaves some host state visible to tests, so the same test can take a different path in the devcontainer and on a stock GitHub runner. CI run 40123645251 on ubuntu-24.04 skipped 45 tests at df8e2ee, and the devcontainer skipped 1. The test-suite audit of 2026-10-24 found these gaps:
- Tokenizer cache.
_resolve_tiktoken_cache_dirreads the tiktoken cache from the environment, from~/.cache/tiktoken, and then from fixed directories. The devcontainer image holds the BPE file in one of them, and the runner does not. So token counts in tests come from tiktoken in the devcontainer and from the fallback counter on the runner. The audit sawtests/test_agent.py:34,tests/test_model_contract.py:122andtests/test_review_group_analysis.py:1700open/usr/local/share/tiktoken/.... - Mounts.
ci/diagnostics.pyreads the host's/proc/mountswhen the caller gives no mounts text. 11 dry-run tests intests/test_ci_dry_run.pyandtests/test_docs.py:294read it. - Process table.
k8s/port_forward_daemon.pyreads/proc/<pid>/stat. 6 tests intests/test_k8s_port_forward_daemon.pyread the stat file of a real process. - PATH.
scanner_fakeputs its stand-ins in front of the realPATH. A tool that the fake does not record is still found on the host, which holds the scanners in the devcontainer and not on the runner. - Program lookups. About 27 tests make a real
shutil.whichlookup of bandit, gitleaks, ruff, semgrep, kube-linter, pluto or mypy (section 2.which-real), for exampletests/ai/review/test_runner.py:261andtests/review/test_review_tool_binary_digest.py:126-231. - Skips that the host decides.
tests/test_data_dir_worktrees.py:156andtests/test_repos.py:522(the git version),tests/test_repos.py:758(non-UTF-8 names),tests/test_consolidation_core_paths.py:49,:68,:83,tests/test_repomap.py:163,:189,tests/test_review_defenses_and_verification.py:35andtests/test_subsystem_containment_and_redaction.py:49(symlinks),tests/test_openblas_worker_threads.py:26(/proc/self/status),tests/test_security_checkov.py:429(libyaml) andtests/test_code_metrics.py:358(pre-commit).
What should happen
Every test sees the same tokenizer, mounts, process table, PATH and programs on every host, and no skip depends on the host.
- The floor points the tiktoken cache at an empty directory of the test. A test that needs real token counts reads a recorded encoding file from
tests/fixtures/. - The floor gives
ci/diagnostics.pyandk8s/port_forward_daemon.pya fixed mounts table and process table through their seams, so no test reads/proc. scanner_fakeand the floor set aPATHthat holds only the fake's stand-ins and the interpreter's directory.- A program lookup goes to the process fake, which answers it.
- Each host-decided skip goes. The test then runs everywhere on fakes, or it moves to a contract suite or a
devops cirow (docs(testing): adr 0007 and docs/testing.md say that a test of src starts no program, and real processes stay in the process runner's contract suite #2143).
Evidence
At b170358:
src/devops_cli/ai/context_budget.py:27-39.src/devops_cli/ci/diagnostics.py:10,:19-27.src/devops_cli/k8s/port_forward_daemon.py:21.tests/support/fakes/scanners.py:188-198, withPATHat:194.tests/conftest.py:1375-1395: the collection hook that skipsbwrapandliveitems where the program is missing..data/agent/scratch/audit/full_list.txtof the 2026-10-24 audit, sections 2.host-files, 2.which-real and 2.host-skips.
Acceptance criteria
- Tests first: with the floor's tokenizer cache, a test that counts tokens gets the same count in the devcontainer and on the runner.
- No test opens a file under
/proc,/usr/local/share/tiktokenor another host path outsidetmp_path, the repository and the interpreter. A floor check fails a test that does. -
scanner_fakebuildsPATHwithout the host's directories, and no test makes a realshutil.whichlookup of a scanner. -
rg -n "pytest.mark.skipif|pytest.skip\(" testsshows no skip that reads the host: no git version, file system,/proc, libyaml or installed program. - A default run in the devcontainer and on the stock runner reports the same number of skipped tests. The pull request gives both counts.
-
uv run devops cipasses.
Follows ADR 0007 as #2143 amends it. Related: #1331 decides that tests select the fallback token counter and keeps one live tiktoken test; under #2143 that test reads a recorded encoding instead. The bwrap skips belong to #2149, and the live skips to #2170.
Source: #2143
Proposed design
Problem statement
The hermetic test floor leaves host state visible to tests. The same test takes a different path in the devcontainer and on a stock GitHub runner. CI run 40123645251 skipped 45 tests on ubuntu-24.04, and the devcontainer skipped 1. The audit of 2026-10-24 found gaps in the tokenizer cache, mounts, process table, PATH, program lookups, and host-decided skips.
Acceptance criteria
- Criterion 1: A test that counts tokens gets the same count in the devcontainer and on the runner with the floor's tokenizer cache.
Verification: Run the token-counting test in both environments and confirm the counts match. - Criterion 2: No test opens a file under /proc, /usr/local/share/tiktoken, or another host path outside tmp_path, the repository, and the interpreter.
Verification: A floor check fails a test that opens such a path. Run the full suite and confirm no test triggers this failure. - Criterion 3: scanner_fake builds PATH without the host's directories, and no test makes a real shutil.which lookup of a scanner.
Verification: Runrg -n "shutil.which" testsand confirm no test calls it for a scanner. Run the scanner tests and confirm they pass. - Criterion 4: No skip in the test suite reads the host for git version, file system, /proc, libyaml, or an installed program.
Verification: Runrg -n "pytest.mark.skipif|pytest.skip\(" testsand confirm no skip reads the host. - Criterion 5: A default run in the devcontainer and on the stock runner reports the same number of skipped tests.
Verification: Run the test suite in both environments, compare the skip counts, and record both counts in the pull request. - Criterion 6:
uv run devops cipasses.
Verification: Runuv run devops ciand confirm exit code 0.
Key questions
- Where does the recorded tiktoken encoding file live?: In tests/fixtures/. A test that needs real token counts reads the file from there. (proposed)
- Which host-decided skips does this issue remove, and which belong to other issues?: This issue removes all host-decided skips except bwrap (which belongs to test(sandbox): the host sandbox and the sandbox tool executor are tested through the process fake on every runner, src detects no mock, and the real bwrap cases are an opt-in contract suite #2149) and live (which belongs to test(cli): live marks sit on the tests that start a program, not on whole modules #2170). (proposed)
- What is the seam through which ci/diagnostics.py receives a fixed mounts table?: The function that reads /proc/mounts when the caller gives no mounts text already takes a mounts parameter. The floor supplies the fixed table through that parameter. [sources: src/devops_cli/ci/diagnostics.py:19-27]
- What is the seam through which k8s/port_forward_daemon.py receives a fixed process table?: The code at line 21 reads /proc//stat. The floor supplies a fixed process table through the existing seam so no test reads /proc. [sources: src/devops_cli/k8s/port_forward_daemon.py:21]
- How does a program lookup (shutil.which) get answered in the hermetic floor?: A program lookup goes to the process fake, which answers it. No test makes a real shutil.which lookup of a scanner. (proposed)
- What does the floor point the tiktoken cache at?: An empty directory of the test. A test that needs real token counts reads a recorded encoding file from tests/fixtures/. (proposed)
- What does scanner_fake put on PATH?: Only the fake's stand-ins and the interpreter's directory. The host's directories are excluded. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsNew
Activity
dan-petty commentedon Oct 24, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.
The candidate proposes changes to the test environment and how tests run, which is a test type of change.The issue impacts test consistency and reliability across different environments, affecting CI runs.Fixing host state visibility ensures reliable testing across devcontainer and GitHub runners.Changing the hermetic floor requires significant refactoring of test infrastructure and tooling.Both items address test environment consistency but the candidate focuses on host state visibility while #1666 targets slow tests using real tools.dan-petty commentedon Oct 27, 2026
Status set to Ready at 0abf552 (see proposed design in issue body).
dan-petty commentedon Oct 31, 2026
New evidence for this issue, found on 2026-10-31 while a pull request ran
uv run devops ciin the devcontainer:tests/commands/test_scan_outcomes_and_gating.py::test_scan_report_skips_named_scannersfails here and passes on the GitHub runner. The devcontainer haskube-linterin~/.local/bin, and the runner has not. The test reaches the real program:So the test sees a different PATH on each host. A test that skips a scanner by name still starts the others that it finds on PATH. The fix is the one this issue asks for: the floor gives every test the same PATH and programs. The test also needs a fake for
kube-linter.test(tests): isolate tokenizer cache mounts process table and path ac…
test(tests): isolate tokenizer cache mounts process table and path ac…
test(tests): isolate tokenizer cache mounts process table and path
test(tests): isolate tokenizer cache mounts process table and path
test(tests): isolate tokenizer cache mounts process table and path
test(tests): isolate tokenizer cache mounts process table and path
test(tests): isolate tokenizer cache mounts process table and path
test(tests): isolate tokenizer cache mounts process table and path