Repository navigation
Description
Epic: Engine de-statification & extension-pipeline formalization
Foundation work for the plugin architecture (this milestone). The current engine bootstraps per-run state into process-global statics, walks targets strictly sequentially, and discovers extensions via magic priority numbers with non-deterministic tie-breaking. This epic makes the engine reentrant, test-isolatable, parallel-ready, and plugin-ready — entirely via backwards-compatible (facade-preserving) refactors.
All public static build properties (FalloutBuild.RootDirectory, Verbosity, Host, …) are preserved as facades over an internal BuildContext — no public breakage, so this stays on the 2026 line and does not need the year-cut breaking-change flow.
Out of scope
- Caching / incrementality. Verified there is zero infrastructure for it today (only the coarse
--continueinvocation-hash). It's a large, product-level decision and the "delegate to MSBuild" stance is defensible. Tracked separately if/when desired.
Tickets & dependency order
- [Foundation] FT-1: Fix cross-invocation static-state leaks (event handlers, log sink, verbosity mappings) #306 — FT-1: Fix cross-invocation static-state leaks (bug, S, no deps — ship first)
- [Foundation] FT-2: Introduce internal BuildContext + ambient activation #307 — FT-2: Introduce internal
BuildContext+ ambient activation (L, deps FT-1) - [Foundation] FT-3: Convert public static build properties to BuildContext-backed facades #308 — FT-3: Convert public statics to
BuildContext-backed facades (M, deps FT-2) - [Foundation] FT-4: Make ParameterService instance-based and re-parseable #309 — FT-4: Instance-based, re-parseable
ParameterService(M, deps FT-2) - [Foundation] FT-5: Context-scope tool-path resolvers and process defaults #310 — FT-5: Context-scope tool-path resolvers + process defaults (M, deps FT-2)
- [Foundation] FT-6: Make logging thread-safe and per-run scoped (prereq for parallel execution) #311 — FT-6: Thread-safe, per-run-scoped logging (M, deps FT-2; prereq FT-8)
- [Foundation] FT-7: Formalize the build extension pipeline (deterministic ordering + typed phases) #312 — FT-7: Formalize the extension pipeline (M, deps FT-2)
- [Foundation] FT-8: Opt-in DAG-parallel target execution #313 — FT-8: Opt-in DAG-parallel target execution (L, deps FT-3/4/5/6)
- [Foundation] FT-9: Reentrancy/isolation test harness #314 — FT-9: Reentrancy/isolation test harness (S, deps FT-1..FT-5)
FT-1 ─▶ FT-2 ─┬─▶ FT-3 ─┐
├─▶ FT-4 ─┼─▶ FT-8 (parallel exec)
├─▶ FT-5 ─┤
├─▶ FT-6 ─┘
└─▶ FT-7
FT-1..FT-5 ─▶ FT-9 (isolation tests)
Evidence base
Findings grounded in: BuildManager.cs, BuildExecutor.cs, ExecutionPlanner.cs, ExecutableTargetFactory.cs, FalloutBuild.Statics.cs, FalloutBuild.Events.cs, Logging.cs, ParameterService.Statics.cs, EnvironmentInfo.Arguments.cs, VerbosityMappingAttribute.cs, Fallout.Core/Planning/TopoSort.cs. Verified: execution is strictly sequential; there is no input/output caching.
Activity
[-]Epic: Engine de-statification & extension-pipeline formalization (plugin foundation)[/-][+][Foundation] Epic: Engine de-statification & extension-pipeline formalization (plugin foundation)[/+]ChrisonSimtian commentedon Jun 16, 2026
Architecture assessment — why
BuildContext, not Generic Host, not a full DI containerRecording the rationale behind this epic so the design choice is durable. This is an independent read of the engine grounded in the current code (file:line throughout), plus the reasoning for the de-statification approach we picked over the alternatives (and why #89 — full DI container — was correctly superseded).
TL;DR
There are effectively three codebases stacked here, at very different quality levels:
Fallout.Core) — clean.TopoSortis a pure function (no I/O, no input mutation, no ambient reads);ExecutableTarget/ExecutionPlanare effectively immutable. Keep as-is.Target X => _ => _.DependsOn(...).Executes(...),RootDirectory / "out",DotNetBuild(...). The static-ness here is an intentional ergonomics choice (same as Cake/MSBuild). Must stay static — do not "fix" it.The fix is an internal
BuildContext(ambient, per-run) with the static surface preserved as facades over it — notMicrosoft.Extensions.Hosting(IHost), and not a fullMicrosoft.Extensions.DependencyInjectioncontainer. Rationale at the bottom.Current architecture (as-is)
flowchart TB subgraph SURF["Authoring DSL surface — clean, deliberate (KEEP)"] T["Target Compile => _ => _.DependsOn(...).Executes(...)"] F["static facades: DotNetBuild(), RootDirectory, Verbosity, Host"] end subgraph ENG["Orchestration engine — the debt"] BM["BuildManager (static)<br/>Execute<T> = composition root + Console wiring + events"] FB["FalloutBuild god class<br/>base class + orchestration state + output + extension host"] BE["BuildExecutor (static, sequential ForEach)"] STATE["process-global MUTABLE statics<br/>Logging.LevelSwitch / InMemorySink.Instance<br/>ParameterService.Instance / ValueInjection cache<br/>NuGetToolPathResolver.* / cancellation handlers"] end subgraph CORE["Domain core: Fallout.Core — clean (KEEP)"] TS["TopoSort (pure)"] ET["ExecutableTarget / ExecutionPlan (immutable)"] end SURF --> ENG --> CORE BM -.- STATE FB -.- STATE BE -.- STATE classDef good fill:#e3f6e3,stroke:#2a2,color:#000; classDef bad fill:#ffe0e0,stroke:#d33,color:#000; class SURF,CORE,TS,ET,T,F good class STATE badHow a run actually touches global state, and where it leaks across invocations:
flowchart TD Main["Build.Main()"] --> Exec["BuildManager.Execute<T>()"] Exec --> W1["Console.CancelKeyPress +=<br/>ToolOptions.Created +=<br/>CancellationHandler += Finish"] Exec --> NewT["new T() : FalloutBuild"] NewT -. "static ctor" .-> SC["FalloutBuild.Statics:<br/>RootDirectory, Host, Verbosity"] Exec --> Cfg["Logging.Configure() → global Log.Logger"] Exec --> Res["NuGetToolPathResolver.* = build.*"] Exec --> BE["BuildExecutor.Execute (sequential)"] BE --> PS["ParameterService.Instance"] BE --> VC["ValueInjectionUtility.s_valueCache"] BE --> FS["File.AppendAllLines(BuildAttemptFile)"] BE --> IO["Host.Error() / Console"] classDef leak fill:#ffe0e0,stroke:#d33,color:#000; class W1,Cfg,Res,PS,VC,FS,IO leakProblems (all in the engine, red nodes above):
FalloutBuildis 456 LOC across 5 partials with 4 responsibilities: inheritable base class (FalloutBuild.cs), process-global state + static ctor (FalloutBuild.Statics.cs:16-30), output formatting (FalloutBuild.Output.cs), extension host (FalloutBuild.Events.cs). The partials hide the size, not the coupling.BuildManager.cs:20,41,69(handlers accumulate),Logging.cs:20,214(LevelSwitch+InMemorySink.Instancecarry log events over),ValueInjectionUtility.cs:13(s_valueCachepersists),NuGetToolPathResolver.cs:14-17(set per-run atBuildManager.cs:53-56, never reset). → tracked by #306.ParameterService.Instance(ParameterService.Statics.cs:11-13), butParameterServiceTest.cs:14-22constructs a freshParameterService(funcs)to inject args. Tests exercise a different object than production. → #309.BuildManager.cs:39-41pokesConsoledirectly;BuildExecutor.cs:81writes the filesystem directly; output goes through staticHost.Error(). Nothing substitutable.What's already good (and stays): planning vs execution is cleanly split (
ExecutionPlannervsBuildExecutor); extension discovery is deterministic (FalloutBuild.Events.cs:21-25, source-order + stable priority sort) and fully visible in one place (FalloutBuild.cs:45-62); parameter injection is type-safe/lazy via expressions.Target architecture (to-be) — clean where it makes sense
flowchart TB subgraph SURF["Authoring DSL surface — UNCHANGED (static facades preserved)"] F["DotNetBuild(), RootDirectory, Verbosity, Host"] end subgraph ENG["Engine — de-statified"] CR["BuildManager.Execute<T><br/>= composition root: build + activate context, run, dispose"] CTX["BuildContext (internal, per-run, ambient via AsyncLocal)<br/>owns: parameters, logging scope, tool-path config, cancellation"] ORCH["BuildOrchestrator (instance)<br/>replaces BuildManager/BuildExecutor statics"] end subgraph CORE["Fallout.Core — UNCHANGED (already clean)"] TS["TopoSort (pure) + immutable ExecutionPlan"] end F -. "read through" .-> CTX CR --> CTX CR --> ORCH ORCH --> CTX ORCH --> CORE OUT["OUT OF SCOPE BY DESIGN:<br/>Generic Host / IHost — one-shot console, no hosted services<br/>full DI container — BuildContext is lighter and sufficient"] classDef keep fill:#e3f6e3,stroke:#2a2,color:#000; classDef change fill:#e0ecff,stroke:#36c,color:#000; classDef no fill:#f3f3f3,stroke:#999,color:#555; class SURF,CORE,F,TS keep class CTX,ORCH,CR change class OUT noMaps directly onto the FT tickets in this epic:
BuildContext+ ambient activationBuildContext.CurrentParameterServiceinstance-based + re-parseable (kills test/prod divergence)The god-class split (base class / orchestration state →
BuildOrchestrator/ output formatter) rides along with FT-2/FT-3 rather than as a separate breaking step.Why not
IHost, why not a full DI containerHostApplicationBuilder/IHost) is the wrong shape. It exists for long-running processes —IHostedService/BackgroundService, host lifetime, graceful shutdown. A Fallout build is a one-shot synchronous pass returning anintexit code (BuildManager.cs:74) with cancellation already hand-wired (BuildManager.cs:20-26,41).IHostwould add ceremony for zero payoff.BuildContextgives us reentrancy + testability + a single composition root without forcing constructor-injection through a surface that is, by design, static. DI is available (net10.0 everywhere,global.json:3) and we may register a small service set insideExecute<T>(), but the container is not the architecture — the context is.DotNetBuild(...)(DotNet.Generated.cs:22-62) andRootDirectory(read unqualified inside instance members) have nothisto inject into. The facades reach an ambient accessor — the same pattern already used byParameterService.InstanceandHost.Instance. So we relocate ambient state behind a context; we don't eliminate it.Honest caveat
Because the real "injection" today is reflection-based attribute middleware (
FalloutBuild.cs:45-62) + ambient singletons, this is plumbing modernization, not an IoC inversion. The wins are concrete — safe reentrancy, real unit-testability ofParameterService/resolvers, one composition root, and it unblocks opt-in parallel execution (#313) — but incremental. Worth setting that expectation so nobody pitches this as a clean-architecture rewrite. The core domain and the authoring DSL are already where they should be; this epic is about the engine in between.ChrisonSimtian commentedon Jun 29, 2026
Design note: GitHub as the worked example for plugin extraction
Added a concrete design note grounding this foundation work in a real first-party extraction —
docs/plugin-extraction-github.md(uses GitHub-CI as the canonical case, i.e. the dogfood proof named in #187 / SDK-11).Key findings:
Host/IBuildServer/ConfigurationAttributeBase/ theIBuildExtensionlisteners are real abstraction points. Extraction is "formalize three seams + split one assembly," not "invent a plugin system."GitHubActions : Host, IBuildServer), config generator (GitHubActionsAttribute), tool wrapper (GitHubTasks/Octokit), component (ICreateGitHubRelease), theme. Maps ~1:1 onto SDK-6a..6f ([SDK-6a] Extension point: IBuildMiddleware #151–[SDK-6f] Extension point: IOutputSink #156).BuildContext(FT-2 [Foundation] FT-2: Introduce internal BuildContext + ambient activation #307 / FT-3 [Foundation] FT-3: Convert public static build properties to BuildContext-backed facades #308), not theHost.Instanceprocess global, or reentrancy / multiple plugins / test isolation break.Three seams to formalize:
IsRunning<Name>static +AppDomainscan → typed registry +IHostDetector.IsActive(env)([SDK-6b] Extension point: IHost + IHostDetector #152, Refactor Host activation: replace by-name reflection with a typed HostRegistry #426).Staged path (steps 1–4 in-repo before any physical split): carve
Fallout.Plugin.Sdk(#146/#147) → formalize seams (#152/#148/#426) → move GitHub to in-repoFallout.Plugin.CI.GitHub(#158/#187) →Fallout.Commonback-compat meta-package → lift to side-by-side repo (~zero code change, gated on milestone #7).Caveats flagged: VCS is not symmetric with CI — only a concrete git-only
GitRepository, noIVcsinterface; pluggable VCS needs a new abstraction first. SplittingFallout.Common+ moving publicICreateGitHubReleaseare the consumer-facing breaks (meta-package +[Obsolete]type-forward shim mitigate).Open questions for design (in the note):
IHostvs existingHostname collision; whether tool-wrapper plugins ship pre-generated.csor run the generator; long-term home forICreateGitHubRelease.ChrisonSimtian commentedon Jun 29, 2026
Plugin-extraction design note — rounds 2–3 update
Following up on the earlier comment.
docs/plugin-extraction-github.mdnow carries a type-by-type move manifest, three locked decisions, three design sketches, and a multi-provider validation pass. Highlights since round 1:Decisions locked.
IHost/IHostDetector+ opt-in capability interfaces;Fallout.Corehas zero awareness of how a host detects/presents. Heavy presentation (logo, target-outcome table, Serilog) stays engine-side as defaults.ITargetModel, notExecutableTarget. That projection already exists inFallout.Core(self-documented as the SDK-facing view);ExecutableTargetalready implements it. Gaps: addArtifactProducts/ArtifactDependenciesto the interface + change theGetConfigurationsignature. FullExecutableTarget→Core move ([Foundation] Extract Fallout.Core domain project #88) deferred, not required.Load mechanic mostly already exists.
BuildManager.Initialize()([ModuleInitializer]) already force-loads referenced assemblies viaDependencyContext(.deps.json) — the exact fix for "referenced-but-unused assembly isn't loaded." A first-partyFallout.Plugin.CI.GitHubwould load as-is; only theStartsWith("Fallout.")filter needs broadening for third-party. Discovery flips from today'sGetTypes()type-walk + magicIsRunning{Name}statics to a single[assembly: FalloutPlugin]read +builder.AddHost<>(). Today's host selection (Host.Default…First()) is silent winner-takes-all — moving to detector+priority+throw is a behavior improvement (RFC #101).Multi-provider validation (GitHub/Azure/GitLab/Bitbucket + out-of-tree Gitea/Forgejo). Composition confirmed — GitLab = detect+branch/commit+theme, Bitbucket = detect+branch/commit only; a god base forces empty overrides. Two refinements:
IHostOutput. Azure overrides ~12 output cmds vs GitHub's ~6, barely overlapping beyond grouping + issue annotation. Segregate into small portable interfaces (IBuildLogGrouping,IBuildIssueReporter); leave the provider-specific tail on the plugin's own public type.IHostDetector.Priorityis mandatory. Gitea/Forgejo Actions setGITHUB_ACTIONS=trueplus their own var → both detectors match on a Gitea runner → RFC [RFC #5] Conflict resolution semantics between plugins #101 single-winner conflict resolved by priority.Next: probing the VCS side (no
IVcsProviderexists today — the asymmetric, harder half of the "VCS + CI as plugins" goal).ChrisonSimtian commentedon Jun 29, 2026
Plugin-extraction note — round 4 (VCS axis)
Full note now lives on a branch:
docs/plugin-extraction-github.md. Probed the VCS side; it inverts the earlier "VCS is the harder, asymmetric half" assumption — VCS is lighter than CI.Git core is already platform-agnostic.
GitRepository(src/Fallout.Build/VCS/GitRepository.cs) parses.git+ remote URLs into a host-neutral model (Endpoint,Identifier, branch/commit/tags/remote). No GitHub baked in — it already works for gitlab.com, self-hosted gitea, bitbucket.org. Git is the substrate, not "a VCS provider among many.""VCS" conflates two orthogonal axes:
IVcsReaderslot.GetGitHubOwner/Name(GitHubTasks.cs:134-140) already just split the genericIdentifier; they belong in the GitHub plugin next to OctokitGitHubTasks.So "the GitHub plugin" is one cohesive package: CI host + config-gen + forge API + git-host flavour + release component. No separate "GitHub VCS plugin."
Recommendation: don't build
IVcsProvidernow (premature for a near-empty set — TFS dead, SVN/hg long-tail). KeepGitRepositoryconcrete; reserve theIVcsReaderextension-point slot in the RFC #98 catalogue, ship only the Git impl. The only platform coupling in the core git type is the sameHost.Instance as IBuildServerambient seam already on the critical path (FT-2/FT-3).Branch-naming conventions (
IsOnMainBranch/IsOnReleaseBranch…) are git-generic → stay core/SDK.Recurring theme across all four rounds: the seams already exist (
ITargetModelin Core, the[ModuleInitializer]DependencyContextforce-load, genericGitRepository). The work is formalizing + relocating, not inventing.ChrisonSimtian commentedon Jun 29, 2026
Round-5 finding (log masking) is now filed as #443 — a plugin-SDK security prerequisite:
[Secret]is a passive marker today, no scrubber exists, so a full-trust plugin can leak resolved secrets to logs. Must land before the SDK exposes resolved secrets to third-party plugins.