Skip to content

test: build a differential bus state-machine oracle #509

Description

Part of #497. Uses the evidence format from #508. Blocks runtime candidates in #501 through #505.

Question

Can a candidate bus implementation be shown trace-equivalent to the control over generated sequences of dispatch, mutation, reentrancy, reset, failure, and lifecycle operations?

Mechanism

Example tests cover known cases but miss interactions and operation ordering. A differential state-machine runner can execute one deterministic sequence against control and candidate implementations, compare externally observable state, and shrink a failure without copying production routing logic.

Contract

Observe production implementations; do not reimplement their algorithms. Compare callback order, message/context values, found result, diagnostics, exception outcome, registration counters, occupied slots, trim result, retained references, and subsequent usability.

Generate register, duplicate register, enable, disable, deregister, emit, nested emit, self-mutation, reset, trim, scene transition, host destruction, and throw operations. Preserve live activity, emission-start snapshots, deferred reset, exception cleanup, stale-handle safety, multiple-bus isolation, and all message kinds.

Factors and workloads

  • MessageScenarios.AllKinds through shared parameterization.
  • Sequence length, seed, type count, fan-out, priorities, active density, and route cardinality.
  • Same-kind and all six cross-kind reentrancy combinations through depth 10.
  • Copied, duplicate, foreign-token, out-of-order, reused, stale, and generation-wrap handles.
  • Scene unload, DontDestroyOnLoad, prefab churn, disable/re-enable, quit, and host destruction.
  • Empty, boundary, invalid, unexpected, and throwing operations.
  • Stable, same-type churn, and unrelated-type churn.

Primary response

The number of observable trace mismatches between control and candidate.

Independent unit

One deterministic seed and its complete operation sequence. Operations inside the sequence are correlated.

Effect threshold

Behavioral acceptance is exact: zero mismatches across all preregistered seeds and canonical fixtures. One reproducible mismatch rejects a candidate regardless of throughput.

RED proof

Supply test-only faulty adapters that independently drop a callback, reorder equal-priority callbacks, continue after reset, reuse a stale handle, skip exception cleanup, misreport diagnostics, retain a dead reference, and leak a registration. Detect and shrink each mutant.

GREEN suites

Pass focused oracle tests, parameterized runtime tests, LifecycleEdgeCasesTests, ReentrantEmissionExtendedTests, allocation-matrix rows for candidate paths, LeakWatcher over whole scenarios, reclamation/trim tests, public-surface checks, and applicable EditMode, PlayMode, and Standalone legs.

Stop rule

Do not promote a candidate if a mismatch cannot be replayed and explained. Reject an oracle design that duplicates production logic, depends on sleeps or retries, swallows exceptions, or cannot shrink while preserving a valid sequence.

Immutable evidence

Retain generator version, seed manifest, original/minimized sequences, both traces, environment/profile/candidate hashes, classification, coverage, and replay command.

Dependencies

Implementation can start independently. Durable failures use #508. This task becomes a prerequisite for every runtime implementation PR in the campaign.

Completion checklist

Verified foundation status (2026-09-07)

The checked items identify delivered mechanisms; they do not close the remaining factor, observation, or durable-evidence work. At source a75f054f493789707d451f523f82df2227b7dea4, the Unity 2021.3 Standalone run passed all 196 pure differential cases and all 24 native host cases. This includes detection and shrinking for the eight required fault classes. Artifact 10002799467 has archive SHA-256 8e190ebc29327ef4c7540f3ded3cb89388883edf1dffd3bfa280e5325480105d; its XML was inspected directly. This ordinary CI artifact is not the immutable campaign bundle required below.

PR #551 at commit 0a7b798ff44ae009f4235004cfe34905132e7094 adds generator version 8 independent registration handles, duplicate registrations, copied/stale aliases, reused slots, and dependency-preserving shrinking. Observation schema 2 records final typed payload/context values and actual unmatched diagnostics, including nested-call attribution and scoped logger restoration. The focused native replay/lifecycle selection passes 377 cases with zero failures, skips, or inconclusives; the ordinary runtime selection passes 1,412 cases with one expected interactive-editor optimization skip. Both runs restore the original clean scene. These local results use Unity 6000.4.6f1. The same source also passes the Unity 2021.3 Standalone job: all 286 differential, 24 native-host, 37 lifecycle, and 30 reentrant cases passed. The complete player result contains 1,406 passes, zero failures/inconclusives, and three undefined optional-integration skips. Artifact 10003892476 has archive SHA-256 d51f68c2b2807c9924c692abf1e4a2b8e5cf735651abb1537b6c0b4926293bf2; the archive digest and actual XML cases were verified. This ordinary CI artifact is not immutable campaign evidence.

Remaining work includes broader workload factors, generation wrap, generated and shrinkable native lifecycle transitions, untyped internal final values, arbitrary retained-reference coverage, allocation-factor mapping, and sealed replay bundles. The public emission API returns void: unmatched-handler diagnostics are observable, but their absence must not be mislabeled as a found=true result. PR #551 remains an increment toward this issue's full acceptance.

Explicit-handle callback replay in PR #552

PR #552, source 3e67087da13cf3d191a739d4342d204141de24c5, adds generator version 9 while retaining versions 1 through 8. Reset, throwing-callback cleanup, token disable, handler activity, and nested emission can now select explicit registration handles. Replay retains callback identity through copies, duplicates, and reused slots; stale aliases cannot arm later callbacks. Nested replay covers all message kinds and depth 10.

Dependency validation and shrinking cover these operations. Faulty adapters demonstrate skipped-action and wrong-handle cleanup detection, including a removed alias whose duplicate callback remains live. Independent review reports no remaining findings.

Local Unity 6000.4.6f1 passes 422 focused oracle, native-host, lifecycle, reentrant, and contract cases with zero failures, skips, or inconclusives. Exact CI-filter runtime runs pass 1,445 cases plus the same expected editor-only skip; the control passed 1,412. Both repeated runs restore the original clean scene and finish framework cleanup. Control/treatment means are 24.65/23.95 seconds locally. These repeated measurements use the ordinary CI filter and preserve all existing cases.

All PR checks pass, including all four Unity versions and all three modes. The downloaded native artifacts match their published SHA-256 digests. Every existing case and outcome is preserved, with the unsupported-version case moving from 9 to 10 now that 9 is supported. Each runtime mode passes all 319 differential cases, up from 286, and retains all 12 contract cases. Each version reports 941 EditMode, 1,443 PlayMode, and 1,439 Standalone passes with the same 11/3/3 expected skips and zero failures or inconclusives. The tested merge tree matches the PR source tree. For the Unity 2021.3 Standalone artifact 10006012973, archive SHA-256 is 1b219ede0f07c22f63ea513de960236e09cb8551c25187d503fa022fe4ac499c.

Observed Unity test-step time across the twelve scopes is 787 seconds before and 772 seconds after. The 2022 comparison uses the preceding PR551 run on the same runner; its complete source tree equals the main baseline. Runner assignments vary for other versions, so the aggregate reduction is not a causal speedup claim. The same-runner 6000.5 test suites are 2.66 seconds faster, although their surrounding build/startup steps cost more in this run. The ordinary CI workload retains its filters and gains coverage. Generated native lifecycle transitions, generation wrap, broader workload factors, untyped internal final values, arbitrary retained references, allocation mapping, and sealed cross-backend evidence remain open.

Reset-generation boundaries in PR #554

PR #554, source 5afd1aabc2470d8bcf721f66a9a9f28a10d2e818, adds 12 parameterized cases across all message kinds. They seed isolated real buses at signed-wrap and zero-wrap boundaries, then exercise reset during dispatch, copied and stale handles, replacement registrations, disable/re-enable recovery, a second reset, and forced trim. A real adapter fault that refuses the boundary reset is detected and reduced to a valid deletion-minimal sequence. A checked-arithmetic mutation of the production increment fails the leak guard.

Both final native Unity MCP runs pass 1,457 ordinary runtime cases with one unchanged expected skip, zero failures/inconclusives, matching run/cleanup identity, and clean restored scenes. All 1,446 previous leaf outcomes are retained as a multiset, with 12 additional passes. Independent adversarial review is clear.

The same PR keeps every comparison, callback, registration, and emission in 24 priority/interceptor assertion loops, but constructs NUnit diagnostics only when integer values differ. Baseline durations are 24.3663277 and 23.8647054 seconds; final durations are 6.469511 and 5.3421594 seconds. Means are 24.11551655 and 5.9058352 seconds. NUnit assertion calls decrease; behavioral comparisons and coverage remain intact. These are local Mono observations. The Windows CI evidence below measures the final source separately.

Generated native scene/host lifecycle factors, generation-bearing override leases, untyped final internal values, and durable cross-backend campaign evidence remain open. This does not close the full oracle issue.

Checklist scope audit

The checked schema mechanism refers to generator version 9 and observation schema 2. It does not mean every required observation or factor exists. PR #554 passes all four editors in EditMode, PlayMode, and Standalone. Independent raw-artifact review verifies every prior fullname/result/label outcome and multiplicity. Each of the eight runtime legs adds exactly the same 12 expected reset-boundary passes; no case is removed or changes status. All mode and cleanup steps pass. Historical PR #551/#552 statements that generation wrap remained open describe their state at delivery. PR #554 adds reset-generation boundaries; generation-bearing override leases and the other remaining observations/lifecycle factors remain open. No full oracle or durable cross-backend acceptance is claimed.

Final PR #554 native acceptance

The four-version correctness run passes at source 5afd1aabc2470d8bcf721f66a9a9f28a10d2e818. Actual checkout logs and Git trees bind the tested merge to that source. All 24 baseline/candidate correctness ZIP digests and complete outcome multisets were independently verified. The 24 guarded integer-comparison sites and eight containing tests remain intact.

Unity Baseline Unity execution seconds Candidate seconds Runner comparison
2021.3 205 150 DAD-MACHINE on both
2022.3 202 154 DAD-MACHINE on both
6000.3 224 158 DAD-MACHINE on both
6000.5 247 137 DAD-MACHINE to ELI-MACHINE

The matched-runner correctness subtotal is 631 to 462 seconds. The full observed correctness subtotal is 878 to 599 seconds. These are sequential elapsed-work observations; the hardware change in the final pair prevents attributing its whole difference to this change. Queue time is excluded, and nested XML suite durations are not added to Unity-step time. Shipping was skipped in all these ordinary correctness jobs. Full campaign lifecycle coverage and durable cross-backend evidence remain open.

Global override lease replay in PR #555

PR #555, source fc3927cf63f7061b01b8808cf3aa2a6b1fdcc930, adds generator version 10 while preserving versions 1 through 9. Generated actions acquire, copy, dispose, and replace real global bus leases. Replay observes actual bus identity and preserves primary emitter fault injection. Validation and shrinking preserve lease dependencies, stale copies, slot reuse, and out-of-order cleanup.

Parameterized native tests cover generation zero, signed wrap, and final issuance before exhaustion. Nine emitter mutation regressions fail before the adapter correction and pass afterward. All 500 focused native cases pass, including memory reclamation and cleanup-on-failure coverage. Two ordinary Runtime runs each pass 1,495 cases with the same expected skip, zero failures/inconclusives, matching cleanup identities, and clean restored scenes.

The exact prior outcome multiset is preserved after two reviewed replacements: unsupported generator 10 becomes 11, and the original exhausted-generation case becomes the equivalent -2L row. The suite gains 38 passing cases. Disposable scopes preserve cleanup order, exceptions, inputs, and assertions. Independent review is clear.

The source-scan optimization preserves all 38 matches across 229 files. Local timings vary; the final four-version native matrix and complete CI timing acceptance are pending.

This completes the bounded generation-bearing override lease factor. Generated native scene/host transitions, broader workload factors, untyped internal final values, retained-reference and allocation mapping, and sealed cross-backend campaign evidence remain open. Observation schema 2 remains current; the full oracle issue stays open.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions