Skip to content

Commit ff1717a

Browse files
authored
feat: close phase 0 infrastructure baseline (#1)
* feat: close phase 0 infrastructure baseline * ci: speed up tooling checks and enforce local verification
1 parent d817ad4 commit ff1717a

44 files changed

Lines changed: 3359 additions & 24 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ fmt-check = "fmt --all --check"
33
lint = "clippy --workspace --all-targets -- -D warnings"
44
tests = "test --workspace"
55
cov = "llvm-cov --workspace --summary-only"
6+
cov-check = "llvm-cov -p gb-core -p gb-test-runner --summary-only --fail-under-lines 90 --fail-under-regions 90 --fail-under-functions 90"
67
cov-html = "llvm-cov --workspace --html"
78
cov-lcov = "llvm-cov --workspace --lcov --output-path lcov.info"
89
deny-check = "deny check"

.githooks/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
set -eu
33

4-
cargo tests
4+
make check

.github/workflows/ci.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,23 @@ jobs:
1818
with:
1919
components: rustfmt, clippy, llvm-tools
2020

21-
- name: Install cargo tools
22-
run: |
23-
cargo install --locked cargo-llvm-cov
24-
cargo install --locked cargo-deny
25-
cargo install --locked typos-cli
21+
- name: Cache Rust artifacts
22+
uses: Swatinem/rust-cache@v2
23+
24+
- name: Install cargo-llvm-cov
25+
uses: taiki-e/install-action@v2
26+
with:
27+
tool: cargo-llvm-cov
28+
29+
- name: Install cargo-deny
30+
uses: taiki-e/install-action@v2
31+
with:
32+
tool: cargo-deny
33+
34+
- name: Install typos-cli
35+
uses: taiki-e/install-action@v2
36+
with:
37+
tool: typos-cli
2638

2739
- name: Rustfmt
2840
run: cargo fmt-check

AI/ARCHITECTURE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ to immediately materialize as a separate directory.
324324
- watchpoints
325325
- snapshots
326326
- state inspection
327+
- freeze typed breakpoint/watchpoint target categories early enough that `PC`,
328+
memory, MMIO, and cartridge-visible state do not need a public API redesign
329+
once CPU and bus hooks become real
327330
- targeted subsystem viewers or equivalent structured dumps for CPU, scheduler, PPU, DMA, APU, IRQ, and cartridge state
328331
- internal analysis and comparison tools
329332
- utilities for synchronization and trace-debug workflows

AI/ROADMAP.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@ Boundary note: Phase `0` fixes architecture, tracing, and the scheduler
276276
skeleton. Phase `1` is where that skeleton becomes hardware-visible stepping,
277277
arbitration, MMIO, and startup behavior.
278278

279+
Status note (`2026-03-15`): Phase `0` baseline is closed in the current repo.
280+
The project now has the documented test layout, `gb-test-runner` contract
281+
crate, typed debugger breakpoints/watchpoints, `Machine` plus
282+
`step_t_cycle()`, explicit scheduler phases, stubbed subsystem boundaries,
283+
typed debug snapshots, and deterministic scheduler-aligned subsystem trace
284+
hooks. Remaining work moves to Phase `1`.
285+
279286
---
280287

281288
### Phase 1 — Temporal foundation and hardware access

AI/TESTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Every subsystem change should aim to leave behind one of these:
4949
- The harness should support at least framebuffer capture and serial / link-port capture when the ROM exposes machine-readable output there.
5050
- Prefer serial / link-port capture for suites such as Blargg `cpu_instrs` when that path is available, because it avoids treating a scrolling framebuffer as the primary machine-readable result channel.
5151
- Each ROM case should define a timeout, an explicit pass/fail rule, and retained failure artifacts such as serial output, framebuffer output, trace excerpts, and optional snapshots.
52+
- During early Phase `0`, `gb-test-runner` may still be a contract-only crate, but it should already own typed ROM-case and suite metadata including console model, startup mode, execution mode, emulation-progress timeout, explicit pass/fail rule, requested captures, and retained failure-artifact policy.
5253
- The minimum DMG closure baseline should include automated CPU / interrupt coverage through `retrio/gb-test-roms` or equivalent Blargg automation, `dmg-acid2` for basic DMG PPU validation, and `mealybug-tearoom-tests` for fine PPU rendering / timing validation.
5354
- Keep explicit roadmap space for broader closure suites such as Mooneye / Gekkio coverage, SameSuite, GB Accuracy Tests, 144p Test Suite, and MBC3 RTC-focused ROMs.
5455

@@ -83,9 +84,30 @@ Every subsystem change should aim to leave behind one of these:
8384
- New production code should normally introduce automated unit tests or integration tests in the same change.
8485
- Prefer unit tests for local logic and integration tests when the behavior only becomes meaningful across subsystem boundaries.
8586
- Treat "code first, tests later" as an exception that must be justified explicitly, not as the default workflow.
87+
- Before opening or updating a pull request, run at least `make check` locally so formatting, clippy, tests, typos, and `cargo deny` failures do not first surface in CI.
88+
- When a change touches CI, coverage, dependency policy, repo tooling, or other workflow-critical infrastructure, run `make ci` locally as well before the PR is updated.
89+
- For the current infrastructure-heavy stage, keep `gb-core` and `gb-test-runner` at or above `90%` line, region, and function coverage as a guardrail, but do not satisfy that threshold with hollow tests that only exercise trivial getters or app placeholders.
8690
- When immediate automated coverage is temporarily impractical, record the missing test coverage, the reason it is deferred, and the remaining risk in the change report; add a roadmap TODO as well if the gap is concrete and non-trivial.
8791
- ROM-based validation and oracle comparison complement automated tests; they do not replace the expectation that new code should usually leave behind unit or integration coverage.
8892

93+
## Phase 0 baseline test layout
94+
95+
- Until dedicated tooling such as `gb-test-runner` exists, keep the initial automated-validation baseline inside `crates/gb-core`.
96+
- Keep subsystem-local invariant tests close to the production code under `crates/gb-core/src/**`.
97+
- Keep public-API and cross-module smoke coverage under `crates/gb-core/tests/*.rs`.
98+
- Keep shared integration-test helpers under `crates/gb-core/tests/common/`.
99+
- Reserve `crates/gb-core/tests/fixtures/roms/` for ROM fixtures and synthetic cartridge images used by automated harnesses.
100+
- Reserve `crates/gb-core/tests/fixtures/traces/` for golden trace artifacts and other debugger-facing snapshots.
101+
- During early Phase `0`, prefer stable UTF-8 text trace fixtures with explicit `seq=`, `subsystem=`, `level=`, and quoted `message=` fields so ordering regressions can be locked down before richer scheduler-visible traces exist.
102+
- During early Phase `0`, cover `ConsoleModel`, `StartupMode`, `ExecutionMode`, and `CompatibilityPolicy` defaults explicitly so DMG-first behavior and future CGB extension seams remain stable before scheduler and loader work land.
103+
- During early Phase `0`, cover `SchedulerPhase` order, the global T-cycle counter, and `CycleContext` reset semantics explicitly so later subsystem work cannot smuggle timing assumptions in through accidental call order.
104+
- During early Phase `0`, cover the single top-level `step_t_cycle()` machine entry point explicitly so the core keeps one deterministic timing boundary instead of growing multiple unsynchronized stepping APIs.
105+
- During early Phase `0`, cover subsystem-boundary wiring explicitly so `Machine` ownership of CPU, bus, PPU, DMA, timer, boot, and cartridge remains stable before Phase `1` introduces hardware-visible behavior.
106+
- During early Phase `0`, lock one deterministic trace order for stubbed CPU, bus, PPU, DMA, timer, boot, and cartridge hooks relative to scheduler phases so later subsystem implementation can grow observability without silently redefining trace chronology.
107+
- During early Phase `0`, expose typed breakpoint and watchpoint contracts for `PC`, memory, MMIO, and cartridge-visible state even before CPU and bus evaluation hooks are fully wired, so debugger tooling can grow without redefining its public targets later.
108+
- During early Phase `0`, treat debugger snapshots as typed inspection artifacts only; lock their contents with tests, but keep them explicitly separate from the whole-machine save-state work reserved for Phase `8`.
109+
- Keep the Phase `0` baseline fast, deterministic, and frontend-independent; `gb-core` validation must not require `gb-cli`, desktop, web, or host-specific I/O.
110+
89111
## ROM-based validation policy
90112

91113
Map tests to the subsystem they validate:

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[workspace]
2-
members = ["crates/gb-core", "crates/gb-cli"]
2+
members = ["crates/gb-core", "crates/gb-test-runner", "crates/gb-cli"]
33
resolver = "2"

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
.PHONY: help setup hooks tools typos check ci
1+
.PHONY: help setup hooks tools typos check ci cov-check
22

33
help:
44
@echo "Available targets:"
55
@echo " make setup - Configure project environment and install local cargo tools"
66
@echo " make hooks - Configure git hooks path to .githooks"
77
@echo " make tools - Install local cargo tools used by this repository"
88
@echo " make typos - Run typos spellcheck"
9-
@echo " make check - Run local checks (fmt, clippy, test, typos, deny)"
10-
@echo " make ci - Run CI-like pipeline locally including LCOV coverage"
9+
@echo " make check - Run the required local checks before push/PR (fmt, clippy, test, typos, deny)"
10+
@echo " make ci - Run the full CI-like pipeline locally including coverage artifacts"
11+
@echo " make cov-check - Enforce >=90% coverage on gb-core and gb-test-runner"
1112

1213
setup: hooks tools
1314

@@ -32,4 +33,8 @@ check:
3233
cargo deny-check
3334

3435
ci: check
36+
cargo cov-check
3537
cargo cov-lcov
38+
39+
cov-check:
40+
cargo cov-check

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The current workspace already uses the `crates/`-based layout, leaving other com
2424
```text
2525
crates/
2626
gb-core/ Pure emulation logic
27+
gb-test-runner/ Typed ROM-harness contracts and validation helpers
2728
gb-cli/ Current CLI frontend
2829
AI/ Architecture, roadmap, and technical documentation
2930
Makefile Local verification pipeline and utilities
@@ -33,7 +34,7 @@ Mid-term planned extensions, not yet materialized as separate crates:
3334

3435
- `gb-desktop`
3536
- `gb-web`
36-
- additional tooling such as a test runner, debugger, and utilities
37+
- additional tooling such as richer debugger and utilities
3738
- host persistence/save adapters outside the core, with any cartridge-facing persistence contract kept narrow and typed inside `gb-core`
3839
- broader integration tests and ROM suites
3940

@@ -68,6 +69,7 @@ make setup
6869

6970
```bash
7071
cargo cov
72+
cargo cov-check
7173
cargo cov-html
7274
cargo cov-lcov
7375
```
@@ -79,6 +81,9 @@ make check
7981
make ci
8082
```
8183

84+
Before opening or updating a PR, run at least `make check` locally.
85+
When changing CI, coverage, dependency policy, or repository tooling, run `make ci` locally as well so failures such as `cargo deny` do not first appear in GitHub Actions.
86+
8287

8388
## Documentation
8489

0 commit comments

Comments
 (0)