Fallout-build / Fallout-build/Fallout
[Foundation] FT-1: Fix cross-invocation static-state leaks (event handlers, log sink, verbosity mappings)
- Dominant language
- C#
- Stars
- 154
- Forks
- 19
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 15
Description
## Summary
Fix cross-invocation static-state leaks in the engine. These are **latent bugs today** — they manifest whenever `BuildManager.Execute` runs twice in one process (test harnesses, the `dotnet fallout` global tool, future in-process/IDE scenarios).
## Findings (file:line)
- `BuildManager.cs:42` — `ToolOptions.Created += …` subscribed every run, never removed.
- `BuildManager.cs:41` / `:69` — `Console.CancelKeyPress +=` and `CancellationHandler += Finish` accumulate; `s_cancellationHandlers` (`:20`) is never cleared.
- `Logging.cs:214-233` — `InMemorySink.Instance._logEvents` accumulates; `Dispose()` (which clears) is never called → run 2 reports run 1's errors/warnings.
- `VerbosityMappingAttribute.cs:34-46` — `Mappings` is a `LookupTable` (dict-of-lists) appended to on every `OnBuildInitialized` with no dedup → duplicate keys pile up.
## Scope
- Make event subscriptions idempotent (subscribe-once, or unsubscribe in `finally`).
- Clear/reset `InMemorySink` per run (or call `Dispose`).
- Dedup or reset `VerbosityMapping.Mappings` per run.
## Acceptance criteria
- A test that calls `Execute` twice in one process shows: no duplicated handlers firing, no carried-over log events, no duplicate verbosity mappings.
- No public API change.
## Notes
- **Non-breaking.** No dependencies — do this first; it's shippable on its own.
- Size: **S**.
Contributor guide
Assessment
This issue has not been assessed yet.