Fallout-build / Fallout-build/Fallout

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

Open
#307 0 comments 0 reactions 0 assignees View on GitHub
enhancement target/vCurrent
Dominant language
C#
Stars
154
Forks
19
Avg merge
1d 22h
Merged PRs (30d)
15

Description

## 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

```csharp
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 Extensions { get; init; }

private static readonly AsyncLocal 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**.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.