You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add multiplayer console bundles and bounded replay diagnostics - #16
GB/GBC player-specific multiplayer views need an ordered bundle of independent consoles; shared-screen games and NES four-pad games use one console. Add a fresh bundle adapter, bounded replay, checkpoints, compiler memory checks, logical-world diagnostics and an automatic device harness. Remove the experimental bridge without a compatibility layer.
Tracks https://github.com/ssk-play/chiptoy/issues/96. Lower dependencies are romdev #7, #8 and the new bootstrap OAM fix#9. Source is clean 2ba6b52aee3cdc477fa107c9513deccb5c6c7145, containing merged M1. The dev host/report collector is chiptoy #104. The GPL package remains a separate worker/iframe/server program.
Draft: ready for renewed code/correctness review; physical-phone performance qualification is still open. This does not authorize room integration or claim the 60fps worst-correction gate passed.
Contracts
Immutable occupied slots, 1–4 players and gapped seats. GB/GBC support shared and player-views; one isolated console per occupied slot in player-views, with its fixed slot before world initialization. Shared ROMs see 0xff. NES uses one console and native controller latches/Four Score; context masks are engine-owned mirrors.
MP ABI 1 at physical bank-1 $D0F0 / NES $03F0; context lives outside the reserved state page. Seeded boot, zero cartridge RAM, deterministic RTC and preserved touch header.
Contiguous bounded inputs, immutable confirmation, merged corrections and resumable replay. A pump permits at most 8ms and 128 native operations; a native operation cannot be preempted, so overshoot is reported. Hold the last complete bundle during replay; discard only already-presented historical audio. Capture/transmission stays outside the worker.
Fixed descriptor, ROM/build/schema binding, separate transport payload hash and causal boundary digest. Multi-console restore is transactional; failed verified undo retires all cores.
Trusted memory contracts use SDCC allocation/debug output and cc65 assembly/maps. Reject statically identifiable header/context writes and allocation overlaps. These are authoring checks, not a hostile-ROM sandbox. Pinned engine identity verification remains M3.
/bundle/run shares the worker adapter. Optional world validation uses the lower core's nonintrusive pre-render publication and compares matching LE32 logical ticks. Reject missing/repeated ticks, overflow, reserved-memory overlap, excessive skew and differing fields. Trusted engine publisher/schema integration remains M3; the logical-tick hook and negative world fixtures are already implemented.
Review follow-up (P2)
Config rejects unknown keys. Descriptor hashing uses a fixed-order tuple of known fields, normalized occupied slots and ordered schemas; property order cannot alter agreement. Actual-core tests cover reordered keys/slots, unknown keys and changed semantic values.
Compiler write checks recognize SDCC # immediates, known ld hl,#symbol+offset followed by (hl) writes, and ca65 a:/z: address prefixes. Pointer tracking clears on register/control-flow clobbers. Actual GB/GBC compiler negatives reject mp_context[3], [16] and literal header writes; positive boundaries and NES prefixed stores are covered.
Validate frame slice budget before enqueue. An invalid budget leaves frame/input state untouched, and the same frame can be retried.
Add rejection/atomicity coverage for noncontiguous frames, window/backlog limits, changed confirmed inputs, unavailable retained boundaries, oversized corrections, malformed worker messages and queue admission limits. Correcting a partially executed three-console frame now agrees with uninterrupted raw states, pixels and first-presentation audio.
Review follow-up (P3)
Checkpoint restore keeps the prior complete displayed image and explicitly returns presentationStale until a new complete bundle is available.
Replay audio suppression ends at the last completed frame; the partially executed, never-presented frame keeps its first audio.
Compiler/runtime share contextLocation: GB/GBC unbanked $C000–$CFFF; NES $0400–$07FF or $6100–$7FFF, with the complete 32-byte context fitting. NES zero-page/stack/state-page locations are rejected.
Pin @types/node to 22.19.0. Normal npm ci plus npm run typecheck passed in a clean temporary checkout with local Node types, without the user's global types.
Add digest-only worker requests for retained corrected/confirmed boundaries. They return the same agreement digest as checkpoints without copying native snapshot bytes or encoding a checkpoint.
Ignore identical retained confirmed duplicates, including repeated frames in a batch; reject retained conflicts. Confirmed history is bounded to one window. Older pruned confirmed entries are ignored without mutating execution; the authoritative room verifies their original content. Document that bounded rule.
Expand memory-contract, headless, benchmark and related changed modules into readable control flow. Worker tests execute the same extracted message handler used in production, with actual native cores.
Additional native correction
The new partial-bootstrap regression exposed a real GBC OAM reader restore defect: after restoring the first LCD-off frame, sprite-position-buffer offsets 1980/1982 differed from uninterrupted execution although pixels matched. romdev #9 preserves the pending scan position and sprite-size source in the core-owned deterministic envelope, validates both, and bumps Gambatte's deterministic schema to 0x47420103. Ordinary disk savestates remain unchanged. A control using the previous payload reproduces the mismatch; new GB/GBC future-state tests pass. No consumer-side bytes are filtered.
Self-review and validation
npm run build, npm run typecheck, npm test: 94/94. Clean normal npm ci and typecheck also pass.
Native multiplayer/world-observation suites: 29/29, including ordinary legacy save fixtures and first-frame future execution. Lower build recipe repeated successfully; published payload comes from that recipe.
Previous c33e403 dev Mac Chrome 152 and Android emulator Chrome 154 each completed 15/15 deterministic smoke cases, one coalesced correction per case, no hidden interruption. Private reports read back from dev matched the current build and clean core source. Chrome app console errors: zero.
Previous c33e403 dev logical-world checker passed 9/9 on both browsers, including deliberate slot-dependent simulation rejected at the first logical tick. These correctness runs are not physical-phone performance evidence. Earlier iOS Simulator checks were on the previous build and are not claimed as current-build tests.
Checkpoint/digest/descriptor/duplicate contracts are documented in docs/checkpoint-wire.md; payload bytes/hash differ from causal agreement and transport compression. HTTP compression/retention is later M4c client work.
Dev version and repeatable external test
Worker: 1b4eea3b-cbff-4123-a0e0-083ec35e7f23.
chiptoy: 597bb9252f59200057bd9e960a0b3aec783491dc, containing cable stack 9ed46c8f64e0087212fd2113a2d404ca8b43ba12 and existing DO migrations.
This PR: 3cedc6f7d1ac0c7ba80f3567fcc6ab037a2bf2c2; library 1.1.0 at /lib/romdev-browser/1.1.0-dd23c2485c/.
Open https://dev.chiptoy.com/benchmark?profile=smoke&device=Windows-test at portrait phone width. No Google login is required: the host creates an anonymous Firebase identity. A signed-in account also works. Keep foreground; expect 15 completed cases, Measurement complete. Physical-phone acceptance is assessed separately. and Report saved on dev. Return report ID/browser/device. Reports are owner/operator only.
During a running case hold the P1 control at least 50ms, preferably 100–200ms, then release. Confirm movement, touch handling and no horizontal overflow. The control disables on completion. Reload to repeat correctness checks. Reports expire after seven days; the owner can stop uploads/delete the report.
Physical qualification: https://dev.chiptoy.com/benchmark?profile=full&device=MODEL-OS-BROWSER on a named midrange Android and iPhone, foreground approximately 25 minutes. Includes repeated corrections and ten-minute GBC-four-view/NES-four-pad runs. Interrupted/incomplete runs and emulators cannot pass this gate.
Remaining performance gate
Depth-24 four-view corrections still hold presentation beyond one native frame. The earlier c33e403 smoke's maximum GBC-four-view hold was about 1.55s on desktop Chrome and 155ms on the Android emulator. Each case has only two bursts, and these runs are not isolated physical-device performance samples: their p95/p99 fields are diagnostic, not acceptance evidence. Snapshot history is about 9.7MB for four GBC consoles and 4.6MB for one NES console. Bounded slices alone do not establish responsive 60fps recovery.
Actual phone worst-correction p95/p99, ten-minute behavior and the frozen window remain required. Follow the approved mitigation order: bounded/coalesced replay (implemented), measured smaller player-view window, sparse snapshots only if measured beneficial, then a separately reviewed view-buffer redesign. Sparse snapshots are not implemented or claimed. Keep this PR draft and do not start room integration on a presumed performance pass.
No room authority, client pacing/timeline, fast-path client adapters or Tetris UI is added here. No merge or production deployment.
Observation review follow-up
Merged lower PRs #7/#8/#9 are followed by romdev #10, which only expands host observation setup validation. Native payloads remain unchanged. The new 15-case regression executes the same BundleSession handler as /benchmark with actual cores through partial/coalesced replay and restores. It rejects any diagnostic start, counts zero native arm calls, and checks zero native publication/events. Probe assertions run outside performance measurements; the browser measurement worker has no WorldObserver path. Deliberate world checks remain a separate worker. Library build/typecheck and 94/94 tests pass; physical-phone acceptance remains pending.
Current follow-up dev smoke: Mac Chrome 152 and Android emulator Chrome 154 each completed 15/15 deterministic cases, one coalesced correction per case and zero hidden interruptions. Owner/operator read-back matched build 86a58c7defbc31eef0291a8be2cdf757a3cfffba1f7898e7cfa8e0d2000ab3ff and clean core/host 2ba6b52aee3cdc477fa107c9513deccb5c6c7145. Chrome console errors: zero. The separate Chrome world-check page passed 9/9, confirming deliberate diagnostic observation still works. Reports: Chrome 6a659ba9d5c5dd5716ea76b5bb0f71e923d62b4458bd376c09e5763decf855bd (Chrome-observation-3cedc6f), Android f3f8c9862710a6a661be2843900d022d7e58b3a5a0508a6fd165b63fca54b1c1 (Android-observation-3cedc6f). These correctness checks do not qualify physical-phone performance.
Re-reviewed at c33e403: the four P2s are fixed with tests. Config hashing uses known fields in a fixed order and rejects unknown keys. SDCC # immediates, ld hl,#sym+k / (hl) stores and ca65 a:/z: prefixes are refused, with GB/GBC negatives. A frame request's budget is checked before its input is accepted. Worker message handling is tested through BundleSession. The P3s are also covered: stale presentation after restore, first audio of a partly run frame, one NES context-range rule, digest-only requests, and duplicate confirmed frames ignored. npm test 79/79 here. chiptoy's linked runtime (chiptoy#106) plays a 2-player NES match on this worker between two Android emulators, with state checks agreeing.
Merging as the M2 library. The phone worst-case correction gate (four views, 24-frame correction) stays open and moves to M4v, as decided for #96.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GB/GBC player-specific multiplayer views need an ordered bundle of independent consoles; shared-screen games and NES four-pad games use one console. Add a fresh bundle adapter, bounded replay, checkpoints, compiler memory checks, logical-world diagnostics and an automatic device harness. Remove the experimental bridge without a compatibility layer.
Tracks https://github.com/ssk-play/chiptoy/issues/96. Lower dependencies are romdev #7, #8 and the new bootstrap OAM fix #9. Source is clean
2ba6b52aee3cdc477fa107c9513deccb5c6c7145, containing merged M1. The dev host/report collector is chiptoy #104. The GPL package remains a separate worker/iframe/server program.Draft: ready for renewed code/correctness review; physical-phone performance qualification is still open. This does not authorize room integration or claim the 60fps worst-correction gate passed.
Contracts
0xff. NES uses one console and native controller latches/Four Score; context masks are engine-owned mirrors.$D0F0/ NES$03F0; context lives outside the reserved state page. Seeded boot, zero cartridge RAM, deterministic RTC and preserved touch header./bundle/runshares the worker adapter. Optional world validation uses the lower core's nonintrusive pre-render publication and compares matching LE32 logical ticks. Reject missing/repeated ticks, overflow, reserved-memory overlap, excessive skew and differing fields. Trusted engine publisher/schema integration remains M3; the logical-tick hook and negative world fixtures are already implemented.Review follow-up (P2)
#immediates, knownld hl,#symbol+offsetfollowed by(hl)writes, and ca65a:/z:address prefixes. Pointer tracking clears on register/control-flow clobbers. Actual GB/GBC compiler negatives rejectmp_context[3],[16]and literal header writes; positive boundaries and NES prefixed stores are covered.Review follow-up (P3)
presentationStaleuntil a new complete bundle is available.contextLocation: GB/GBC unbanked$C000–$CFFF; NES$0400–$07FFor$6100–$7FFF, with the complete 32-byte context fitting. NES zero-page/stack/state-page locations are rejected.@types/nodeto22.19.0. Normalnpm ciplusnpm run typecheckpassed in a clean temporary checkout with local Node types, without the user's global types.Additional native correction
The new partial-bootstrap regression exposed a real GBC OAM reader restore defect: after restoring the first LCD-off frame, sprite-position-buffer offsets 1980/1982 differed from uninterrupted execution although pixels matched. romdev #9 preserves the pending scan position and sprite-size source in the core-owned deterministic envelope, validates both, and bumps Gambatte's deterministic schema to
0x47420103. Ordinary disk savestates remain unchanged. A control using the previous payload reproduces the mismatch; new GB/GBC future-state tests pass. No consumer-side bytes are filtered.Self-review and validation
npm run build,npm run typecheck,npm test: 94/94. Clean normalnpm ciand typecheck also pass.docs/checkpoint-wire.md; payload bytes/hash differ from causal agreement and transport compression. HTTP compression/retention is later M4c client work.Dev version and repeatable external test
1b4eea3b-cbff-4123-a0e0-083ec35e7f23.597bb9252f59200057bd9e960a0b3aec783491dc, containing cable stack9ed46c8f64e0087212fd2113a2d404ca8b43ba12and existing DO migrations.3cedc6f7d1ac0c7ba80f3567fcc6ab037a2bf2c2; library1.1.0at/lib/romdev-browser/1.1.0-dd23c2485c/.86a58c7defbc31eef0291a8be2cdf757a3cfffba1f7898e7cfa8e0d2000ab3ff.2ba6b52aee3cdc477fa107c9513deccb5c6c7145. Payload browser-payloads-4be2b1a7777a, SHA-2566a05620de4728392867eea07e87c2f6677cb0789197645c7b3559f9b0353c95d.6a659ba9d5c5dd5716ea76b5bb0f71e923d62b4458bd376c09e5763decf855bd; Android emulator:f3f8c9862710a6a661be2843900d022d7e58b3a5a0508a6fd165b63fca54b1c1.PASS: 9 world checks, current build, matching worlds and deliberate score mismatches at tick 1. Reload and expect the same result.Measurement complete. Physical-phone acceptance is assessed separately.andReport saved on dev. Return report ID/browser/device. Reports are owner/operator only.Remaining performance gate
Depth-24 four-view corrections still hold presentation beyond one native frame. The earlier c33e403 smoke's maximum GBC-four-view hold was about 1.55s on desktop Chrome and 155ms on the Android emulator. Each case has only two bursts, and these runs are not isolated physical-device performance samples: their p95/p99 fields are diagnostic, not acceptance evidence. Snapshot history is about 9.7MB for four GBC consoles and 4.6MB for one NES console. Bounded slices alone do not establish responsive 60fps recovery.
Actual phone worst-correction p95/p99, ten-minute behavior and the frozen window remain required. Follow the approved mitigation order: bounded/coalesced replay (implemented), measured smaller player-view window, sparse snapshots only if measured beneficial, then a separately reviewed view-buffer redesign. Sparse snapshots are not implemented or claimed. Keep this PR draft and do not start room integration on a presumed performance pass.
No room authority, client pacing/timeline, fast-path client adapters or Tetris UI is added here. No merge or production deployment.
Observation review follow-up
Merged lower PRs #7/#8/#9 are followed by romdev #10, which only expands host observation setup validation. Native payloads remain unchanged. The new 15-case regression executes the same BundleSession handler as /benchmark with actual cores through partial/coalesced replay and restores. It rejects any diagnostic start, counts zero native arm calls, and checks zero native publication/events. Probe assertions run outside performance measurements; the browser measurement worker has no WorldObserver path. Deliberate world checks remain a separate worker. Library build/typecheck and 94/94 tests pass; physical-phone acceptance remains pending.
Current follow-up dev smoke: Mac Chrome 152 and Android emulator Chrome 154 each completed 15/15 deterministic cases, one coalesced correction per case and zero hidden interruptions. Owner/operator read-back matched build
86a58c7defbc31eef0291a8be2cdf757a3cfffba1f7898e7cfa8e0d2000ab3ffand clean core/host2ba6b52aee3cdc477fa107c9513deccb5c6c7145. Chrome console errors: zero. The separate Chrome world-check page passed 9/9, confirming deliberate diagnostic observation still works. Reports: Chrome6a659ba9d5c5dd5716ea76b5bb0f71e923d62b4458bd376c09e5763decf855bd(Chrome-observation-3cedc6f), Androidf3f8c9862710a6a661be2843900d022d7e58b3a5a0508a6fd165b63fca54b1c1(Android-observation-3cedc6f). These correctness checks do not qualify physical-phone performance.