Skip to content

feat(engine): Phase 0 RZF engine with gating oracle suite + spec v2.2#1

Merged
justin06lee merged 1 commit into
masterfrom
phase-0-engine
May 22, 2026
Merged

feat(engine): Phase 0 RZF engine with gating oracle suite + spec v2.2#1
justin06lee merged 1 commit into
masterfrom
phase-0-engine

Conversation

@justin06lee

Copy link
Copy Markdown
Owner

Build the zeroforce RZF engine first (per spec §15), since a subtly wrong EPT is silent and catastrophic. Math-correctness gates CI before anything is built on top.

Engine (packages/zeroforce/):

  • engine_py: pure-Python reference Markov-chain DP (normalized weights so denominator = 1; self-loop fixed via next_mask != mask).
  • engine_numba: nopython JIT mirror of the reference DP.
  • reachability: R(v) closure + induced subgraph G[R(v)]; EPT scoped to R(v).
  • ranking: impact_score = n_reachable / EPT (excludes self), sink separation.
  • simulator: independent Monte Carlo RZF (second definition for differential).
  • api.compute(graph): asserts the §7.2 row-stochastic invariant on the FULL graph, runs per-seed DP on induced subgraphs, ranks.

Gating tests (41 passed, pristine under -W error):

  • hand-computed 3-node oracle (EPT derived from first principles, trusts paper 0)
  • Monte Carlo differential (sim vs DP, n<=6, <2e-2)
  • engine parity (py vs numba, n<=10, <1e-10)
  • properties (directed-path depth, seed monotonicity) + invariant guards
  • §4.6 closed forms kept xfail(strict=False) until paper-body verified

Two clarifications over the spec pseudocode, documented in the engine README:

  • the row-stochastic invariant is asserted on the full graph, not subgraphs (unreachable suppliers leave subgraph rows summing < 1; this is correct)
  • the recurrence uses the unconditional P(next) divided once by (1 - p_stay) (the prose's "P(next | flip)" plus a second division would double-divide)

Spec bumped to v2.2: rename Foresight -> zeroforce; widen numpy pin to

=1.26,<3.0 with an import numba CI smoke test; explicit async polling
contract + 5-min job timeout; Gemini Pass B retry/fallback; oracle strategy promoted to a standalone callout.

Build the zeroforce RZF engine first (per spec §15), since a subtly wrong
EPT is silent and catastrophic. Math-correctness gates CI before anything
is built on top.

Engine (packages/zeroforce/):
- engine_py: pure-Python reference Markov-chain DP (normalized weights so
  denominator = 1; self-loop fixed via next_mask != mask).
- engine_numba: nopython JIT mirror of the reference DP.
- reachability: R(v) closure + induced subgraph G[R(v)]; EPT scoped to R(v).
- ranking: impact_score = n_reachable / EPT (excludes self), sink separation.
- simulator: independent Monte Carlo RZF (second definition for differential).
- api.compute(graph): asserts the §7.2 row-stochastic invariant on the FULL
  graph, runs per-seed DP on induced subgraphs, ranks.

Gating tests (41 passed, pristine under -W error):
- hand-computed 3-node oracle (EPT derived from first principles, trusts paper 0)
- Monte Carlo differential (sim vs DP, n<=6, <2e-2)
- engine parity (py vs numba, n<=10, <1e-10)
- properties (directed-path depth, seed monotonicity) + invariant guards
- §4.6 closed forms kept xfail(strict=False) until paper-body verified

Two clarifications over the spec pseudocode, documented in the engine README:
- the row-stochastic invariant is asserted on the full graph, not subgraphs
  (unreachable suppliers leave subgraph rows summing < 1; this is correct)
- the recurrence uses the unconditional P(next) divided once by (1 - p_stay)
  (the prose's "P(next | flip)" plus a second division would double-divide)

Spec bumped to v2.2: rename Foresight -> zeroforce; widen numpy pin to
>=1.26,<3.0 with an `import numba` CI smoke test; explicit async polling
contract + 5-min job timeout; Gemini Pass B retry/fallback; oracle strategy
promoted to a standalone callout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@justin06lee
justin06lee merged commit b3c62b6 into master May 22, 2026
2 checks passed
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.

1 participant