Skip to content

RFC 07 — System Access Declarations + Auto-DAG (Units 1-5) - #276

Merged
nockawa merged 1 commit into
mainfrom
feature/270-phase-primitive
Apr 25, 2026
Merged

nockawa merged 1 commit into
mainfrom
feature/270-phase-primitive

Conversation

@nockawa

@nockawa nockawa commented Apr 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements RFC 07 — System Access Declarations + Auto-DAG (Units 1-5). This is the engine-side delivery; Workbench surfacing (Unit 6 / #275) is deferred pending runtime hosting in Workbench's OpenSession.

Closes #270, #271, #272, #273, #274.

What this delivers

  • Unit 1 — Phase primitive + registration (Auto-DAG Unit 1 — Phase primitive + registration #270): readonly struct wrapping string, Typhon-shipped statics (Input/Simulation/Output/Cleanup), RuntimeOptions.Phases ordered list + RuntimeOptions.DefaultPhase, phase-token → integer index map resolved at Build().
  • Unit 2 — SystemBuilder declaration methods (Auto-DAG Unit 2 — SystemBuilder declaration methods #271): converted all 14 existing methods to fluent (return this); added .Before(string); 11 new declaration methods (Reads/ReadsFresh/ReadsSnapshot/AdditionalReads/Writes/SideWrites/WritesEvents/ReadsEvents/WritesResource/ReadsResource/ExclusivePhase); batch overloads (arities 2–6) for Reads/Writes/ReadsFresh/ReadsSnapshot.
  • Unit 3 — Build() validator + auto-DAG derivation (Auto-DAG Unit 3 — Build() validator + auto-DAG derivation #272): per-phase conflict detection (W×W with XOR rule, R×W-plain hard error, R×W-fresh/snapshot edge derivation), event producer→consumer + named resource edges, ExclusivePhase enforcement, cross-phase chain over consecutive populated phases, merge with explicit .After()/.Before() edges, downstream Kahn cycle detection.
  • Unit 4 — Debug-runtime write assertion (Auto-DAG Unit 4 — Debug-runtime write assertion #273): [ThreadStatic] SystemAccessValidator with push/pop frame stack; [Conditional("DEBUG")] on EnterSystem/LeaveSystem/AssertWrite so all 7 dispatch-site call sites in DagScheduler strip entirely in RELEASE; InvalidAccessException thrown on undeclared writes in DEBUG with system name + undeclared type + declared summary.
  • Unit 5 — Phase enforcement + R3 retirement (Auto-DAG Unit 5 — Convert all existing systems + remove R3 manual-only path #274): RuntimeOptions.DefaultPhase ensures every system lands in some phase post-Build(); pragmatic divergence from "strict required Phase" documented in RFC body; 02-system-scheduling.md superseded by RFC 07; new claude/rules/runtime-scheduling.md codifies the auto-DAG invariants.

Test plan

  • dotnet build Typhon.slnx -c Debug clean (no new warnings)
  • dotnet test --filter "FullyQualifiedName~PhaseTests|SystemBuilderFluentTests|AccessDagDerivationTests|SystemAccessValidatorTests" — 61 RFC 07 tests green
  • Full dotnet test regression — 3387+ tests pass, no failures (one flaky concurrent BTree test passes on rerun)
  • Verify [Conditional("DEBUG")] stripping by inspecting Release IL for EntityRef.Write<T> (no validator calls present)

Documentation

  • RFC 07 amended with "Compatibility notes" + "Implementation note: default-phase divergence" sections
  • 02-system-scheduling.md header note → RFC 07 supersedes R3/R-Q6
  • claude/rules/runtime-scheduling.md — NEW rules file with 5 modules (Phase Resolution, Access Conflict Detection, Edge Derivation, Debug-Runtime Write Validation, API Contract Stability)
  • Workbench placeholder updates: SchemaRelationshipsPanel.tsx badge text + SystemRelationshipDto.cs doc-comment now point at Auto-DAG Unit 6 — Workbench Schema Inspector + Profiler surfacing #275 for runtime-hosting prerequisite

Known limitations / follow-ups

  1. Test fixture conversion deferred — DefaultPhase mechanism makes mass conversion of pre-RFC fixtures unnecessary; opportunistic cleanup as files are touched.
  2. W×W resolution = direct adjacency only — three writers of the same component need pairwise edges; transitive chain ordering is a future enhancement.
  3. Structured AccessConflictError envelope not built — current implementation uses formatted InvalidOperationException; substantive UX is met.
  4. Perf benchmarks not run — Goal Merge telemetry work into dev #5 < 20% overhead is structurally guaranteed by [Conditional("DEBUG")] IL stripping; BenchmarkDotNet measurement nice-to-have.
  5. claude/overview/13-runtime.md prose update pending — RFC body + rules file capture the design; overview prose is a follow-up.
  6. Unit 6 (Auto-DAG Unit 6 — Workbench Schema Inspector + Profiler surfacing #275) blocked on OpenSession hosting a live TyphonRuntime in Workbench.

Companion PR

claude/ documentation changes: see the typhon-claude repo PR (link to follow once created).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-DAG Unit 1 — Phase primitive + registration

1 participant