Skip to content

T-1ZRX-gitignore-plugin-pycache

Status: closed/done · Impact: low · Complexity: small

Auto-generated from a /sdlc:task-work post-mortem. Review and promote to open/ready before picking up.

Running plugin test scripts (e.g. python3 plugin/skills/pr-check/test_classify_pr.py) materializes __pycache__/ directories alongside the source. The compiled .pyc files embed the original source path inside the bytecode, which trips path-grep ACs on a clean tree. The implementer of T-G834-move-plugin-runtime-state-to-sdlc-dir had to clean the caches and pass --binary-files=without-match to grep just to get a meaningful AC-1 result. Closing this gap means plugin tests stop polluting the working tree (or stop polluting it in a way that confuses text-search ACs).

  • Repo-level gitignore: add plugin/**/__pycache__/ to the repo’s .gitignore. Cheapest, but only suppresses tracking — the .pyc files still sit on disk and still get hit by grep unless --exclude-dir=__pycache__ is passed.
  • Bytecode-free test runs: set sys.dont_write_bytecode = True (or PYTHONDONTWRITEBYTECODE=1) in plugin test runners. Eliminates the __pycache__/ materialization entirely, so grep never has anything to skip.

The post-mortem captures the exact symptom:

__pycache__ directories under plugin/scripts/ and plugin/skills/pr-check/ got created when running python3 plugin/skills/pr-check/test_classify_pr.py and the compiled bytecode’s embedded source path strings tripped AC-1 grep. Required cleanup + --binary-files=without-match. Suggests: plugin/**/__pycache__/ should be explicitly gitignored at the plugin level, or test runners should set sys.dont_write_bytecode = True.

Today, neither the repo .gitignore nor any plugin test runner addresses this. Running plugin tests cold leaves __pycache__/ under plugin/scripts/ and plugin/skills/<any>/ until manually cleaned.

The simpler fix first: every plugin test entry-point sets sys.dont_write_bytecode = True at the top of if __name__ == "__main__": (or imports a small shared helper that does so). No __pycache__/ directories are created during test runs, so path-grep ACs see only source tree content.

Belt-and-braces: add plugin/**/__pycache__/ to the repo .gitignore as well, so even an accidentally-bytecode-writing run doesn’t leak into committed state.

  1. Survey every plugin test file (plugin/**/test_*.py, plugin/**/*test*.py, plugin/**/tests/run_evals.py) for an if __name__ == "__main__": entry-point.
  2. At the top of each entry-point, add import sys; sys.dont_write_bytecode = True before any other plugin imports.
  3. Add plugin/**/__pycache__/ to the repo .gitignore under the appropriate ignore-block header.
  4. Spot-verify by deleting all existing __pycache__/ directories under plugin/, running the test suites, and confirming no new caches are produced.
LocationKindChange
plugin/skills/pr-check/test_classify_pr.pymodifyadd dont_write_bytecode.
plugin/skills/task-work/test_dedup_search.pymodifysame.
plugin/skills/task-work/test_start_task.pymodifysame.
plugin/skills/task-work/test_check_ancestry.pymodifysame.
plugin/skills/task-work/test_preflight_permissions.pymodifysame.
plugin/scripts/test_schema_patterns.pymodifysame.
plugin/skills/setup/tests/run_evals.pymodifysame.
plugin/validators/tests/test_validate_sdlc_yaml.pymodifysame.
modify<migrated from v2 — no note recorded>
.gitignoremodifyadd plugin/**/__pycache__/ entry.
  • AC-1: After deleting every __pycache__/ under plugin/ and running every plugin test entry-point, no new __pycache__/ directory exists anywhere under plugin/.
  • AC-2: A grep AC of the form grep -rn -E '<pattern>' plugin/ returns the same hit count whether or not a fresh test run has happened — i.e. bytecode pollution can no longer change the AC’s verdict.
  • Migrating plugin tests to pytest or to a proper test runner — the fix is a one-line guard at the entry-point.
  • none

Spawned by /sdlc:task-work post-mortem of T-G834-move-plugin-runtime-state-to-sdlc-dir on 2026-05-22.

Bullet: pycache directories under plugin/scripts/ and plugin/skills/pr-check/ got created when running python3 plugin/skills/pr-check/test_classify_pr.py and the compiled bytecode embedded source path strings tripped AC-1 grep. Required cleanup + —binary-files=without-match. Suggests: plugin/**/pycache/ should be explicitly gitignored at the plugin level, or test runners should set sys.dont_write_bytecode = True. Keywords searched: dont_write_bytecode, test_classify_pr, without-match, binary-files, directories, explicitly, gitignored, pycache__ Excluded: 2026-05-22-move-plugin-runtime-state-to-sdlc-dir Top candidates (score / status / headline):

  • 6 / closed/done / 2026-05-19-add-epic-entity-task-depends-on-dependencies — Add epic entity + task depends_on dependencies
  • 4 / closed/done / 2026-05-20-task-work-sub-agent-verdict-contract-clarity — Tighten task-work sub-agent verdict contract so ensure-ready’s READY marker isn’t mistaken for task-work’s final verdict
  • 3 / closed/done / 2026-05-19-task-work-emit-completion-marker — task-work emits a final completion marker to signal end-of-flow
  • 3 / closed/done / 2026-05-20-orchestrator-categorized-in-flight-limits — Replace orchestrator parallelism cap with categorized in-flight limits configurable in sdlc.yaml
  • 3 / closed/done / 2026-05-21-project-local-skill-extension-mechanism — Project-local skill extension / shadowing mechanism Decision: SPAWNED

← Back to Tasks