Skip to content

[Foundation] FT-2: Introduce internal BuildContext + ambient activation #307

Open

Description

@ChrisonSimtian

Summary

Introduce an internal BuildContext that owns per-run state, and activate it ambiently for the duration of a build. Foundation for de-statifying the engine (testability, reentrancy, parallel execution, and the plugin architecture in this milestone). No behavior change in this ticket — just stand up the context and make it active.

Why

The engine currently bootstraps per-run state into process-global statics in the FalloutBuild static ctor (FalloutBuild.Statics.cs:16-30), read directly throughout Execution/. That blocks isolation, safe parallelism, and a scoped plugin model.

Sketch

internal sealed class BuildContext
{
    public required FalloutBuild Build { get; init; }
    public required DirectoryConfig Directories { get; init; }   // Root, Temp, BuildAssembly…
    public required ParameterService Parameters { get; init; }
    public required ToolPathConfig Tools { get; init; }
    public required LoggingScope Logging { get; init; }
    public required HostInfo Host { get; init; }
    public IReadOnlyCollection<IBuildExtension> Extensions { get; init; }

    private static readonly AsyncLocal<BuildContext> s_current = new();
    public static BuildContext Current => s_current.Value ?? throw …;
    public static IDisposable Activate(BuildContext ctx); // set + restore
}

BuildManager.Execute builds the context and wraps the run in using (BuildContext.Activate(ctx)).

Acceptance criteria

  • BuildContext is constructed in BuildManager.Execute and active for the whole run.
  • All existing tests still pass (public statics untouched in this ticket).

Notes

  • Non-breaking. Internal only (stays internal per milestone policy).
  • Depends on: FT-1.
  • Blocks: FT-3, FT-4, FT-5, FT-6, FT-7, FT-8.
  • Size: L.

Activity

  1. changed the title [-]FT-2: Introduce internal BuildContext + ambient activation[/-] [+][Foundation] FT-2: Introduce internal BuildContext + ambient activation[/+] on Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions