offline suite litters the checkout: fleet-tui tests leave __pycache__/ behind (#58's class, one level in) #88

Closed
opened 2026-08-25 21:59:11 +00:00 by matou-build-agent · 3 comments

Found while working #76 (out of its scope — filed rather than fixed).

What

Running the full offline suite from a clean tree leaves two untracked
directories behind in the repo checkout:

?? fleet-tui/__pycache__/
?? fleet-tui/tests/__pycache__/

Reproduce from a clean main:

for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" >/dev/null 2>&1; done
git status --porcelain

Why it matters

#58 closed the "the suite litters the live host it runs on" class for host
state (SWARM_RUNLOG, SWARM_DB, SWARM_VERDICT_PATH, SESSION_RUNNER_TMP).
This is the same class one level in: the litter lands in the checkout, so
every session that runs the suite before git status sees noise it did not
create, and a git add -A would commit bytecode. .sandcastle/.gitignore
already carries __pycache__/ (for swarm-db.py); the repo-root .gitignore
does not, and fleet-tui/ is operator-side and never vendored, so it is not
covered by the nested rule.

Suggested fix

Add __pycache__/ to the repo-root .gitignore (matching the reason already
written in .sandcastle/.gitignore: "Python bytecode cache — regenerated on
demand"), and/or have tests/fleet-tui-test.sh run its python with
PYTHONDONTWRITEBYTECODE=1 so nothing is produced in the first place. The
second is the stronger form — it keeps the tree clean rather than hiding the
artefacts — and matches #58's "structural fix, not per-instance cleanup".

Acceptance

  • The full offline suite run from a clean tree leaves git status --porcelain
    empty.
  • Full offline suite green.
Found while working #76 (out of its scope — filed rather than fixed). ## What Running the full offline suite from a clean tree leaves two untracked directories behind **in the repo checkout**: ``` ?? fleet-tui/__pycache__/ ?? fleet-tui/tests/__pycache__/ ``` Reproduce from a clean `main`: ```sh for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" >/dev/null 2>&1; done git status --porcelain ``` ## Why it matters #58 closed the "the suite litters the live host it runs on" class for host state (`SWARM_RUNLOG`, `SWARM_DB`, `SWARM_VERDICT_PATH`, `SESSION_RUNNER_TMP`). This is the same class one level in: the litter lands in the *checkout*, so every session that runs the suite before `git status` sees noise it did not create, and a `git add -A` would commit bytecode. `.sandcastle/.gitignore` already carries `__pycache__/` (for `swarm-db.py`); the repo-root `.gitignore` does not, and `fleet-tui/` is operator-side and never vendored, so it is not covered by the nested rule. ## Suggested fix Add `__pycache__/` to the repo-root `.gitignore` (matching the reason already written in `.sandcastle/.gitignore`: "Python bytecode cache — regenerated on demand"), and/or have `tests/fleet-tui-test.sh` run its python with `PYTHONDONTWRITEBYTECODE=1` so nothing is produced in the first place. The second is the stronger form — it keeps the tree clean rather than hiding the artefacts — and matches #58's "structural fix, not per-instance cleanup". ## Acceptance - The full offline suite run from a clean tree leaves `git status --porcelain` empty. - Full offline suite green.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

Ruling: bug + ready-for-agent.

Why this is a two-way door: the fix is a .gitignore line and/or a
PYTHONDONTWRITEBYTECODE=1 on the python invocation in
tests/fleet-tui-test.sh — a few-line change fully reversible by a follow-up
commit, with no security, credential, trust, or spend surface.

What proves it: the issue's own reproduction is the acceptance test —
running the full offline suite from a clean tree and checking
git status --porcelain is empty. I confirmed the claim by inspection:
tests/fleet-tui-test.sh runs "$py" -m pytest -q from inside fleet-tui/
whenever pytest+textual are importable, with no PYTHONDONTWRITEBYTECODE
set; the repo-root .gitignore has no __pycache__/ entry (only
.sandcastle/.gitignore does, for swarm-db.py), and fleet-tui/ is
operator-side, outside the .sandcastle/ nesting that rule covers. pytest
isn't installed in this sandbox so I couldn't force the write directly, but
the code path matches the reported litter exactly (fleet-tui/__pycache__/,
fleet-tui/tests/__pycache__/).

Agent Brief

Category: bug
Summary: The offline test suite leaves untracked __pycache__/
directories inside the repo checkout when the fleet-tui pytest suite runs.

Current behavior:
When python3 -m pytest (or any bytecode-caching Python invocation) runs
against the fleet-tui source and its tests as part of the offline suite,
CPython writes __pycache__/ directories into the checkout. Neither the
repo-root .gitignore nor the test invocation suppresses this, so a suite
run leaves untracked directories behind (git status --porcelain is
non-empty after a clean run), and a careless git add -A would commit
bytecode.

Desired behavior:
Running the full offline suite from a clean tree leaves git status --porcelain empty afterward — no bytecode artefacts land in the checkout,
regardless of whether pytest is available.

Key interfaces:

  • The repo-root .gitignore — should ignore __pycache__/ the same way
    .sandcastle/.gitignore already does (with the same justification comment:
    "Python bytecode cache — regenerated on demand").
  • The fleet-tui test suite's python invocation — should set
    PYTHONDONTWRITEBYTECODE=1 (or equivalent) so no bytecode is written in
    the first place, which is the stronger fix per the issue: it keeps the
    tree clean rather than hiding the artefacts after the fact.

Acceptance criteria:

  • Running the full offline suite (for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t"; done) from a clean tree leaves
    git status --porcelain empty.
  • The full offline suite stays green.
  • The fix holds whether or not pytest/textual are installed (no
    regression to the existing "SKIPPED the pytest suite" structural-only
    path).

Out of scope:

  • Any other suite's litter class — #58 already closed the host-state
    version of this; this ticket is scoped to the checkout-local
    fleet-tui/__pycache__/ case only.
  • Vendoring or manifest changes to fleet-tui/ itself.
> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime** **Ruling:** `bug` + `ready-for-agent`. **Why this is a two-way door:** the fix is a `.gitignore` line and/or a `PYTHONDONTWRITEBYTECODE=1` on the python invocation in `tests/fleet-tui-test.sh` — a few-line change fully reversible by a follow-up commit, with no security, credential, trust, or spend surface. **What proves it:** the issue's own reproduction is the acceptance test — running the full offline suite from a clean tree and checking `git status --porcelain` is empty. I confirmed the claim by inspection: `tests/fleet-tui-test.sh` runs `"$py" -m pytest -q` from inside `fleet-tui/` whenever pytest+textual are importable, with no `PYTHONDONTWRITEBYTECODE` set; the repo-root `.gitignore` has no `__pycache__/` entry (only `.sandcastle/.gitignore` does, for `swarm-db.py`), and `fleet-tui/` is operator-side, outside the `.sandcastle/` nesting that rule covers. pytest isn't installed in this sandbox so I couldn't force the write directly, but the code path matches the reported litter exactly (`fleet-tui/__pycache__/`, `fleet-tui/tests/__pycache__/`). ## Agent Brief **Category:** bug **Summary:** The offline test suite leaves untracked `__pycache__/` directories inside the repo checkout when the fleet-tui pytest suite runs. **Current behavior:** When `python3 -m pytest` (or any bytecode-caching Python invocation) runs against the fleet-tui source and its tests as part of the offline suite, CPython writes `__pycache__/` directories into the checkout. Neither the repo-root `.gitignore` nor the test invocation suppresses this, so a suite run leaves untracked directories behind (`git status --porcelain` is non-empty after a clean run), and a careless `git add -A` would commit bytecode. **Desired behavior:** Running the full offline suite from a clean tree leaves `git status --porcelain` empty afterward — no bytecode artefacts land in the checkout, regardless of whether pytest is available. **Key interfaces:** - The repo-root `.gitignore` — should ignore `__pycache__/` the same way `.sandcastle/.gitignore` already does (with the same justification comment: "Python bytecode cache — regenerated on demand"). - The fleet-tui test suite's python invocation — should set `PYTHONDONTWRITEBYTECODE=1` (or equivalent) so no bytecode is written in the first place, which is the stronger fix per the issue: it keeps the tree clean rather than hiding the artefacts after the fact. **Acceptance criteria:** - [ ] Running the full offline suite (`for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t"; done`) from a clean tree leaves `git status --porcelain` empty. - [ ] The full offline suite stays green. - [ ] The fix holds whether or not pytest/textual are installed (no regression to the existing "SKIPPED the pytest suite" structural-only path). **Out of scope:** - Any other suite's litter class — #58 already closed the host-state version of this; this ticket is scoped to the checkout-local `fleet-tui/__pycache__/` case only. - Vendoring or manifest changes to `fleet-tui/` itself.
Author
Member

swarm-claim host=matou-dev-server-01 run=1016
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=1016 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #88 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 88,
  "status": "success",
  "commits": [
    "805aea0e22bff05a9222fc10a5ad5b204551be40"
  ],
  "changed_files": [
    "tests/fleet-tui-test.sh",
    ".gitignore",
    "docs/GOTCHAS.md",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL: $t; done",
      "exit_code": 0
    },
    {
      "command": "git status --porcelain (clean-tree, after simulating fleet-tui/__pycache__)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "The full offline suite run from a clean tree leaves git status --porcelain empty": "tests/fleet-tui-test.sh runs pytest under PYTHONDONTWRITEBYTECODE=1 (source suppression) and __pycache__/ added to repo-root .gitignore (.gitignore:15); git check-ignore -v confirms fleet-tui/__pycache__/ and fleet-tui/tests/__pycache__/ both matched by the new rule, git status --porcelain shows no pycache noise",
    "Full offline suite green": "full suite loop ran with zero FAIL lines"
  },
  "summary": "fleet-tui pytest run no longer litters the checkout with __pycache__ — suppressed at source via PYTHONDONTWRITEBYTECODE=1 plus a belt-and-braces repo-root .gitignore rule.",
  "blockers": []
}
**close-report** for #88 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 88, "status": "success", "commits": [ "805aea0e22bff05a9222fc10a5ad5b204551be40" ], "changed_files": [ "tests/fleet-tui-test.sh", ".gitignore", "docs/GOTCHAS.md", "STATUS.md" ], "tests": [ { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL: $t; done", "exit_code": 0 }, { "command": "git status --porcelain (clean-tree, after simulating fleet-tui/__pycache__)", "exit_code": 0 } ], "criteria": { "The full offline suite run from a clean tree leaves git status --porcelain empty": "tests/fleet-tui-test.sh runs pytest under PYTHONDONTWRITEBYTECODE=1 (source suppression) and __pycache__/ added to repo-root .gitignore (.gitignore:15); git check-ignore -v confirms fleet-tui/__pycache__/ and fleet-tui/tests/__pycache__/ both matched by the new rule, git status --porcelain shows no pycache noise", "Full offline suite green": "full suite loop ran with zero FAIL lines" }, "summary": "fleet-tui pytest run no longer litters the checkout with __pycache__ — suppressed at source via PYTHONDONTWRITEBYTECODE=1 plus a belt-and-braces repo-root .gitignore rule.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#88
No description provided.