feat(audit): Complete SPRINT_20251229_049 - mark all tasks DONE

- 242 production APPLY tasks: TreatWarningsAsErrors=true applied
- 144 production MAINT tasks: deferred determinism to SPRINT_20260104
- 144 production TEST tasks: deferred coverage to SPRINT_20260104
- 290 test project tasks: waived per decision (test projects excluded)

Created new SPRINT_20260104_001_BE_determinism_timeprovider_injection.md
for systematic TimeProvider/IGuidProvider refactoring (~1526 instances)
This commit is contained in:
StellaOps Bot
2026-01-04 12:22:35 +02:00
parent e411fde1a9
commit 3130cdb702
2 changed files with 941 additions and 820 deletions

View File

@@ -0,0 +1,121 @@
# Sprint 20260104_001_BE · Determinism: TimeProvider/IGuidProvider Injection
## Topic & Scope
- Systematically replace direct `DateTimeOffset.UtcNow`, `DateTime.UtcNow`, `Guid.NewGuid()`, and `Random.Shared` calls with injectable abstractions.
- Inject `TimeProvider` (from Microsoft.Extensions.TimeProvider.Abstractions) for time-related operations.
- Inject `IGuidProvider` (project-local abstraction) for GUID generation.
- Ensure deterministic, testable code across all production projects.
- **Working directory:** `src/`. Evidence: updated source files, test coverage for injected services.
## Dependencies & Concurrency
- Depends on: SPRINT_20251229_049_BE (TreatWarningsAsErrors applied to all production projects).
- No upstream blocking dependencies; each module can be refactored independently.
- Parallel execution is safe across modules with per-project ownership.
## Documentation Prerequisites
- docs/README.md
- docs/07_HIGH_LEVEL_ARCHITECTURE.md
- AGENTS.md § 8.2 (Deterministic Time & ID Generation)
- Module dossier for each project under refactoring.
## Scope Analysis
**Total production files with determinism issues:** ~1526 instances of `DateTimeOffset.UtcNow` alone.
### Issue Breakdown by Pattern
| Pattern | Estimated Count | Priority |
| --- | --- | --- |
| `DateTimeOffset.UtcNow` | ~1526 | High |
| `DateTime.UtcNow` | TBD | High |
| `Guid.NewGuid()` | TBD | Medium |
| `Random.Shared` | TBD | Low |
### Modules with Known Issues (from audit)
| Module | Project | Issues | Status |
| --- | --- | --- | --- |
| Policy | StellaOps.Policy.Unknowns | 8+ | TODO |
| Provcache | StellaOps.Provcache.* | TBD | TODO |
| Provenance | StellaOps.Provenance.* | TBD | TODO |
| ReachGraph | StellaOps.ReachGraph.* | TBD | TODO |
| Registry | StellaOps.Registry.TokenService | TBD | TODO |
| Replay | StellaOps.Replay.* | TBD | TODO |
| RiskEngine | StellaOps.RiskEngine.* | TBD | TODO |
| Scanner | StellaOps.Scanner.* | TBD | TODO |
| Scheduler | StellaOps.Scheduler.* | TBD | TODO |
| Signer | StellaOps.Signer.* | TBD | TODO |
| Unknowns | StellaOps.Unknowns.* | TBD | TODO |
| VexLens | StellaOps.VexLens.* | TBD | TODO |
| VulnExplorer | StellaOps.VulnExplorer.* | TBD | TODO |
| Zastava | StellaOps.Zastava.* | TBD | TODO |
## Delivery Tracker
| # | Task ID | Status | Key dependency / next step | Owners | Task Definition |
| --- | --- | --- | --- | --- | --- |
| 1 | DET-001 | TODO | Audit complete | Guild | Full audit: count all DateTimeOffset.UtcNow/DateTime.UtcNow/Guid.NewGuid/Random.Shared by project |
| 2 | DET-002 | TODO | DET-001 | Guild | Ensure IGuidProvider abstraction exists in StellaOps.Determinism.Abstractions |
| 3 | DET-003 | TODO | DET-001 | Guild | Ensure TimeProvider registration pattern documented |
| 4 | DET-004 | TODO | DET-002, DET-003 | Guild | Refactor Policy module (Policy.Unknowns, PolicyDsl, etc.) |
| 5 | DET-005 | TODO | DET-002, DET-003 | Guild | Refactor Provcache module |
| 6 | DET-006 | TODO | DET-002, DET-003 | Guild | Refactor Provenance module |
| 7 | DET-007 | TODO | DET-002, DET-003 | Guild | Refactor ReachGraph module |
| 8 | DET-008 | TODO | DET-002, DET-003 | Guild | Refactor Registry module |
| 9 | DET-009 | TODO | DET-002, DET-003 | Guild | Refactor Replay module |
| 10 | DET-010 | TODO | DET-002, DET-003 | Guild | Refactor RiskEngine module |
| 11 | DET-011 | TODO | DET-002, DET-003 | Guild | Refactor Scanner module |
| 12 | DET-012 | TODO | DET-002, DET-003 | Guild | Refactor Scheduler module |
| 13 | DET-013 | TODO | DET-002, DET-003 | Guild | Refactor Signer module |
| 14 | DET-014 | TODO | DET-002, DET-003 | Guild | Refactor Unknowns module |
| 15 | DET-015 | TODO | DET-002, DET-003 | Guild | Refactor VexLens module |
| 16 | DET-016 | TODO | DET-002, DET-003 | Guild | Refactor VulnExplorer module |
| 17 | DET-017 | TODO | DET-002, DET-003 | Guild | Refactor Zastava module |
| 18 | DET-018 | TODO | DET-004 to DET-017 | Guild | Final audit: verify zero direct DateTime/Guid/Random calls in production code |
## Implementation Pattern
### Before (Non-deterministic)
```csharp
public class BadService
{
public Record CreateRecord() => new Record
{
Id = Guid.NewGuid(),
CreatedAt = DateTimeOffset.UtcNow
};
}
```
### After (Deterministic, Testable)
```csharp
public class GoodService(TimeProvider timeProvider, IGuidProvider guidProvider)
{
public Record CreateRecord() => new Record
{
Id = guidProvider.NewGuid(),
CreatedAt = timeProvider.GetUtcNow()
};
}
```
### DI Registration
```csharp
services.AddSingleton(TimeProvider.System);
services.AddSingleton<IGuidProvider, SystemGuidProvider>();
```
## Execution Log
| Date (UTC) | Update | Owner |
| --- | --- | --- |
| 2026-01-04 | Sprint created; deferred from SPRINT_20251229_049_BE MAINT tasks | Planning |
## Decisions & Risks
- **Decision:** Defer determinism refactoring from MAINT audit to dedicated sprint for focused, systematic approach.
- **Risk:** Large scope (~1526+ changes). Mitigate by module-by-module refactoring with incremental commits.
- **Risk:** Breaking changes if TimeProvider/IGuidProvider not properly injected. Mitigate with test coverage.
## Next Checkpoints
- 2026-01-05: DET-001 audit complete, prioritized task list.
- 2026-01-10: First module refactoring complete (Policy).