Skip to content

Keep the whole Debug mode rule in createBintastic - #372

Merged
scalvert merged 2 commits into
mainfrom
refactor/debug-mode-lifecycle
Nov 3, 2026
Merged

scalvert merged 2 commits into
mainfrom
refactor/debug-mode-lifecycle

Conversation

@scalvert

@scalvert scalvert commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #358.

Problem

The rule for keeping a Project on disk at teardown was split across three places. createBintastic marked the Project preserved after a Debug mode Run and logged its path. The Project lifecycle read BINTASTIC_DEBUG again at teardown. The lifecycle also exposed preserve() and active only so that createBintastic could reach in. Understanding Debug mode meant reading all three.

Change

  • Merge project-lifecycle.ts into createBintastic. One module now owns the active Project, its preserved flag, starting Runs, and teardown. planRun stays the pure seam for args, binPath, and Node flags.
  • The rule is now written down in CONTEXT.md as Preserved Project: a Project is kept when any Run against it was in Debug mode, or when BINTASTIC_DEBUG is on in the process env at teardown. A Run's own env can turn Debug mode on for that Run, which also preserves its Project, but it can't stop the Project being preserved. This matches the behavior on Keep preserved fixtures across the suite and make teardown safe #358. The debugging and usage guides now say so too.
  • "Debugging enabled. Fixture: …" is logged once per Project, at its first Debug mode Run, not on every Run. This is the only visible behavior change.

Tests

The tests now run against the public interface, with one test per behavior.

  • create-bintastic-test.ts replaces project-lifecycle-test.ts and the createBintastic block of index-test.ts. Fake Projects come in through createProject, and env changes use vi.stubEnv.
  • Cases that run-plan-test.ts already covers (binPath variants, static args) are no longer repeated end to end.
  • The json, text, and BintasticProject tests move to their own files unchanged.
  • New: a test for "a Run's own env can't stop its Project being preserved", a test for the log-once behavior, and a test for setupProject right after a Debug mode Run.

Verification

  • npm test passes: lint, format, docs check, and 73 tests.
  • Self-review with six lenses on two model families found 3 smaller items. All are fixed in "fix: address self-review findings".
  • npm run build and npm run test:package pass.
  • Mutation check: removing the teardown env check, or the log-once guard, fails 4 tests in create-bintastic-test.ts.

@scalvert
scalvert force-pushed the fix/project-lifecycle branch from e70f5c0 to f1f9339 Compare November 3, 2026 17:05
Base automatically changed from fix/project-lifecycle to main November 3, 2026 17:07
The rule for keeping a Project on disk was split across three places:
createBintastic marked the Project preserved after a Debug mode Run, the
Project lifecycle read BINTASTIC_DEBUG again at teardown, and the
lifecycle exposed preserve() and `active` only so that glue could reach in.

Merge the lifecycle into createBintastic so one module owns the active
Project, its preserved flag, starting Runs, and teardown. planRun stays
the pure seam for args, binPath, and Node flags.

The one visible change: "Debugging enabled" is logged once per Project,
at its first Debug mode Run, not on every Run.

Tests now sit at the public interface. project-lifecycle-test.ts and
index-test.ts are replaced by create-bintastic-test.ts, with one test
per behavior, and the json, text, and BintasticProject tests move to
their own files unchanged. CONTEXT.md adds "Preserved Project", and the
debugging guide states that a Run's own env can't stop its Project being
kept.
- Guide says a Run's env only controls the inspector, but a Run's env
  that turns Debug mode on also preserves the Project
- Usage guide says teardownProject removes the directory, without the
  debug-mode exception
- No test for setupProject after a Debug mode Run without an explicit
  teardown
@scalvert
scalvert marked this pull request as ready for review November 3, 2026 17:07
@scalvert
scalvert force-pushed the refactor/debug-mode-lifecycle branch from 4e30dec to 9d8ffc9 Compare November 3, 2026 17:07
@scalvert
scalvert merged commit 8906b09 into main Nov 3, 2026
5 checks passed
@scalvert
scalvert deleted the refactor/debug-mode-lifecycle branch November 3, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant