own_binary_fork_guard_test reads binary cache files and errors with invalid byte sequence #671
Labels
No labels
P0
P1
P2
P3
bug
category/code-change
category/cross-repo
category/eval-run
category/investigation
category/no-test-target
category/owner-ruling
category/prose-artifact
category/recurring-chore
category/structure
category/umbrella
crc-refactor
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
rule-proposal
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#671
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
plugins/os-sdlc/tests/own_binary_fork_guard_test.rb globs
plugins/{*/tests,cc-architect/scripts/plugin_config/test}/**/*and callsFile.read(path)thenString#match?on every file.On a checkout where Python tests have run,
plugins/*/tests/__pycache__/*.pycfiles exist (gitignored).Reading them yields a string with invalid UTF-8 and
match?raises ArgumentError.The suite on main shows 1 error while the same commit in a fresh worktree is green.
Observed
Reproduce
Run any plugin's pytest suite so pycache exists, then
ruby tests/all.rbin plugins/os-sdlc.Approach
Restrict the glob to source extensions (rb, py, sh) or skip files where
content.valid_encoding?is false.Acceptance criteria
ruby tests/all.rbon main with pycache dirs present: 0 errorsOrigin
Session: 6d6f7dfd-b7cc-41b1-a401-71f83f4d5c77
Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/6d6f7dfd-b7cc-41b1-a401-71f83f4d5c77.jsonl
Where: plugins/os-sdlc/tests/own_binary_fork_guard_test.rb:48
Parent: #642
VERDICT: CREATE — real reproducible test-environment bug with root cause identified; not speculative hardening.
The bug
__pycache__/*.pycunderplugins/*/tests?ruby tests/all.rbmainon a machine that ran pytestThe error every run on such a machine:
Why it happens
plugins/os-sdlc/tests/own_binary_fork_guard_test.rbscans every file under the plugin test trees:File.readreturns a UTF-8 tagged string for a.pycfile. The bytes are not valid UTF-8.String#match?raises on the first invalid byte.The fix
Only source files can spawn a process. Restrict the glob to source extensions:
One line. The scan never opens a
.pyc,.json, or fixture binary again.Why this shape and not
valid_encoding?*.{rb,py,sh}next unless content.valid_encoding?Option A is the recommendation. It states the test's real scope. A fork can only come from a source file. Option B keeps reading files that cannot be offenders.
Verify
__pycache__dirs exist:find plugins -path '*tests/__pycache__' -type d.ruby tests/all.rbinplugins/os-sdlc..rb,.py, and.shtest files.Resolution
Done: candidate_files now uses git ls-files over the two test pathspecs instead of Dir.glob, so gitignored pycache/*.pyc and other untracked files are never read
Evidence: commit
6ee5fe3con main; ruby tests/all.rb in plugins/os-sdlc with 4 tests/pycache dirs present: 1419 runs, 0 failures, 0 errorsFollow-ups: none