IRON_PARITY_PLAN.md
Outcome Notice (Read First)
As of March 4, 2026, Operation Iron Parity is considered unsuccessful as the repository’s primary execution strategy for near-term parity closure.
Mandatory interpretation for readers:
- This document is now architecture/policy reference, not the active day-to-day delivery plan.
- Translator output is permitted only as a first-draft accelerator for specific functions.
- No translator output counts as parity progress until validated by core JS review plus replay/session evidence.
- Active near-term execution is driven by
/share/u/davidbau/git/mazesofmenace/mazes/docs/CURSOR_PLAN.mdand direct gameplay parity burndown priorities.
Status Update (March 4, 2026)
Operation Iron Parity is currently in archived-guidance mode rather than active execution mode.
Reason for status change:
- Current branch evidence shows baseline instability (tool/source-path drift, compiled-data fixture drift) and broad replay regressions that reduce signal quality.
- Translator throughput work is therefore not the current highest-leverage path to gameplay parity closure.
Active execution pivot:
- Stabilize baseline and restore trustworthy parity/test signal first.
- Prioritize direct Tier-1 gameplay parity burndown (monster movement, pet AI, and first-divergence clusters).
- Execute cursor-parity closure from
/share/u/davidbau/git/mazesofmenace/mazes/docs/CURSOR_PLAN.mdas the near-term concrete plan. - Keep translator work gated and limited to support tasks until baseline and gameplay parity are stable again.
- When used, translator output should be treated as first-draft scaffolding, then corrected by C-faithful manual review before parity sign-off.
This document remains authoritative for naming, canonical-state targets, and translator policy constraints when translator work resumes.
Campaign Name
Operation Iron Parity
Mission
Achieve durable C-faithful gameplay parity by combining:
- canonical runtime-state alignment under
game.*, and - rule-driven mechanical translation for scalable porting.
This campaign treats green tests as guardrails, not the goal. The goal is faithful C behavior and architecture.
Source Plans
- State refactor plan: STRUCTURES.md
- Translator architecture: C_TRANSLATOR_ARCHITECTURE_SPEC.md
- Translator parser strategy: C_TRANSLATOR_PARSER_IMPLEMENTATION_SPEC.md
- Translator out-param/format strategy: C_TRANSLATOR_OUTPARAM_AND_FORMAT_ARCHITECTURE.md
- Coverage ledger: CODEMATCH.md
- Parity debugging workflow: RNG_ALIGNMENT_GUIDE.md
- Learnings: LORE.md
- Translator capability gap tracker: C_TRANSLATOR_99_PERCENT_CAPABILITY_GAPS.md
Strategic Thesis
- State refactor is the foundation.
- Translator is the force multiplier.
- Translator coverage only scales after canonical state is stable.
- Every increment must hold or improve replay parity evidence.
Campaign Outcomes
Primary outcomes:
- Canonical C-shaped runtime state under
game.*in parity-critical modules. - Measurable reduction in hidden-state divergence classes.
- Mechanical translation pipeline producing safe, reviewable patches for large portions of C gameplay code.
Secondary outcomes:
- Faster function-surface closure in CODEMATCH.
- Lower manual churn for repetitive ports.
- Better long-term maintainability with explicit translation policies and boundary contracts.
Scope Baseline (Operational)
From docs/CODEMATCH.md function-level rows (snapshot 2026-02-26):
- Total function rows tracked:
5000. - Missing rows (raw):
3863. - Missing rows excluding files marked
N/A:3242.
Execution implication:
- The campaign must explicitly scale translation throughput from validated pilots to large batches; one-function-at-a-time porting cannot close this backlog.
Non-Negotiable Constraints
- No comparator exceptions that hide real mismatches.
- No synthetic replay behavior that changes semantics.
- No big-bang refactor without parity gates.
- No widening of legacy mirror state paths.
- Headless replay speed remains high; animation timing is boundary-correct but skippable in headless.
Canonical Naming and Notation Rules (Campaign-Wide)
Purpose:
- Remove ambiguity during migration.
- Ensure translator output converges directly to final-state architecture.
- Keep review and issue triage mechanically checkable.
Authoritative target names:
- Runtime/global ownership must converge to canonical
game.*paths. - Translator output must target canonical names by default, never ad-hoc aliases.
- Legacy names are allowed only as explicitly marked transitional bridges.
- Within canonical paths, prefer C-like symbol names to maximize mechanical translation fidelity.
Canonical path policy:
- Use this form for all parity-critical state reads/writes:
game.<namespace>.<field>. - Preferred namespaces:
game.u,game.flags,game.iflags,game.gd,game.gm,game.gn,game.lev,game.svc.*. - C symbol names remain C-shaped when they are semantic entities (for example
youmonst,moves,mvitals), but mounted at canonical ownership paths. - Prefer C field/function naming and ordering over JS-style cosmetic rewrites when behavior is equivalent.
- Do not introduce new top-level mirrors (
context.*,map.*,state.*,globals.*) as long-term ownership.
Legacy bridge policy:
- Transitional aliases are permitted only when required to avoid large-batch regressions.
- Every alias bridge must carry an explicit marker comment:
IRON_PARITY_ALIAS_BRIDGE. - Every alias bridge must reference a milestone retirement target (
M1,M2, …M6) and follow-up issue. - Alias bridges are read-through/write-through adapters only; they must not become independent state owners.
- Any new alias bridge without retirement metadata is a policy violation.
Translator naming and notation policy:
- Rewrite tables must map C globals/paths directly to canonical
game.*targets. - Rule tables may include compatibility profiles, but default emit profile is canonical-only.
- Generated identifiers should be deterministic and C-first:
- preserve C local/global/member names whenever they are valid JS identifiers,
- only rename when required by JS syntax/reserved words or established exported API contracts,
- do not camelize/simplify names for style alone.
- Generated function names stay aligned to C function names unless file-level JS API constraints require wrappers.
- Temporary translator shims must be marked as
TRANSITIONAL_SHIMand tracked in campaign issues.
Issue and doc notation rules:
- Always describe state locations as canonical path pairs:
C:<symbol/path> -> JS:<game.path>. - For divergences, include
file:function, divergence channel, and first step/index. - For migration notes, explicitly tag status:
canonical(final target),bridge(temporary alias),legacy(to be removed).
docs/port-status/IRON_PARITY_ALIAS_BRIDGE_LEDGER_*.mdis the running bridge inventory and retirement tracker.
Milestone enforcement:
M1: canonical namespaces exist; no untracked alias bridges.M2: movement/turn modules stop writing through legacy ownership paths.M3+: translator output must be canonical-first; compatibility profile usage requires explicit justification.M6: Tier-1 legacy bridges removed, except explicitly approved long-tail exceptions.
Program Structure
Run three coordinated workstreams:
- Workstream A: State Canonicalization
- Workstream B: Translator Infrastructure
- Workstream C: Parity Operations and Governance
Workstream A: State Canonicalization
Objective:
- Move parity-critical ownership to canonical namespaces (
game.u,game.svc.context,game.flags,game.iflags,game.gd,game.gm,game.gn,game.lev).
Module priority:
- Tier 1:
hack.js,allmain.js,cmd.js,monmove.js,mon.js,uhitm.js,mhitu.js,mhitm.js,trap.js - Tier 2:
dungeon.js,mkroom.js,makemon.js,u_init.js,sp_lev.js,bones.js - Tier 3: display/animation/input-edge consistency files
Exit conditions for A:
- Tier 1 modules contain no active legacy mirror ownership.
- Alias invariants validated in CI/debug.
- Session pass count stable or improved versus baseline.
Workstream B: Translator Infrastructure
Objective:
- Build and deploy project-specific C-to-JS translator with deterministic rule tables and risk controls.
Required assets:
tools/c_translator/rulesets/*rule tables and schemas- coverage policy manifest:
tools/c_translator/rulesets/file_policy.json - policy checker:
scripts/check-translator-file-policy.mjs - annotation-driven mixed-file controls (
Autotranslated from <file>.c:<line>/TRANSLATOR: MANUAL/MANUAL-BEGIN/MANUAL-END)
Translation policy classes:
manual_onlyfor runtime/platform/harness gluegenerated_datafor generated tables and static datamixedwith annotation-derived allowlistautofor gameplay modules
Exit conditions for B:
- Schema + rule loader stable.
- Translator regression tests in place.
- Pilot files translated with no parity regression.
Translation Throughput Ramp (Authoritative)
Stage 0: Scrutinized pilots
- Batch size:
1-12functions. - Scope: hand-audited exemplars (sync, async, boundary, macro-heavy, control-flow variants).
- Promotion gate:
- translator regression tests green,
- policy checks green (
translator:check-policy,translator:check-annotations), - no parity regression in targeted session subset.
Stage 1: Dozens
- Batch size:
12-60functions per wave. - Scope: one subsystem slice with shared rewrite policy.
- Promotion gate:
- stable idempotence/static gates across repeated runs,
- unresolved-token diagnostics trend downward,
- parity baseline stable/improving on campaign dashboard.
Stage 2: Hundreds
- Batch size:
60-400functions per wave. - Scope: multi-file subsystem families after canonical state ownership is stable.
- Promotion gate:
- automated triage for blocked/partial emits,
- issue workflow keeps follow-ups bounded and linked,
- no unreviewed growth in bridge/compatibility debt.
Stage 3: Thousands
- Batch size: campaign-scale closure waves (
400+cumulative per wave window). - Scope: full backlog burn-down with mixed auto/manual policy.
- Gate discipline:
- all prior stage gates remain active,
- high-risk files remain policy-constrained (
manual_onlyor strictmixed), - release-critical parity suites remain authoritative for accept/reject.
Common Helper and Out-Param Normalization Lane (High Priority)
Purpose:
- Remove high-volume translator blockers caused by unresolved C helper idioms and out-param mutation patterns.
- Convert these blockers into deterministic lowering rules so large-batch autotranslation can scale safely.
Current audited scope (full pipeline snapshot):
298unsafe functions are blocked by common C helper symbols (sprintf/strcpy/strlen/...family).203functions containSprintf/Snprintfcalls.116functions contain detected direct out-param writes.
Authoritative helper automation tranche (Phase B-H1):
sprintf/snprintf(includingSprintf/Snprintf)strcpy/strcat/strncpystrlenstrchr/strrchrstrcmpi/strncmpiatoiabseos
Execution rules:
- Implement as translator lowering/normalization, not comparator exceptions.
- Keep C order and branch structure; only replace helper semantics with JS-equivalent expression/helpers.
- Add function-summary metadata for out-param role classification and callsite rewrite (
single,single+result,multi). - Gate each wave with unit tests, translator regression tests, and session parity baseline check.
- For printf-family sinks (
Sprintf,Snprintf,pline,raw_printf), enforce one shared formatter contract and explicit unsupported-specifier diagnostics.
Exit gate for B-H1:
- Marked-function audit shows reduced
unsafe_unknown_calls_and_identifierscount in helper-driven categories. Sprintf/Snprintf-blocked marked set reduced by at least50%from current baseline.- No regression in parity baseline (
test:session) and no unit-test failures.
Workstream C: Parity Operations and Governance
Objective:
- Keep campaign evidence-driven with reproducible parity deltas and tight rollback paths.
Operational loop:
- Capture baseline metrics (all sessions, gameplay subset, failing session taxonomy).
- Apply scoped batch.
- Run gates.
- Record deltas (first divergence step, RNG/events matched prefixes, pass counts).
- Update docs and issue tracker.
Governance rules:
- No merge without evidence artifact.
- Any regression requires explicit disposition:
- fix immediately,
- rollback,
- documented known regression with approved follow-up issue.
Integrated Phase Plan
Shared milestone IDs in this table are authoritative for all three planning docs.
STRUCTURES.md and translator specs must reference these IDs.
| Milestone | Scope lead | Exit gate |
|---|---|---|
| M0 | Baseline + policy/CI guardrails | Baseline reproducible; policy checks green |
| M1 | Canonical state spine | No regression in unit/sessions; alias invariants active |
| M2 | Movement/turn canonicalization | Movement-divergence seeds stable/improving |
| M3 | Translator alpha (safe subset) | Idempotence + static gates green |
| M4 | Combat/monster + translator pilot | Targeted parity stable/improving |
| M5 | Generation/startup + translator expansion | Early-step divergence class improved |
| M6 | Boundary hardening + legacy removal | Campaign metrics stable; docs synchronized |
Phase 0: Baseline and Tooling Guardrails
Deliver:
- Baseline parity report.
- Failing-session divergence taxonomy by
file:function. - CI checks for translator file-policy completeness.
Gate:
- Current baseline captured and reproducible.
Phase 1: Canonical State Spine
Deliver:
- Canonical
game.*namespaces established. - Transitional alias checks active.
- No new mirrors introduced.
Gate:
- Unit and session suites non-regressing.
Phase 2: Movement/Turn Control Canonicalization
Deliver:
hack.js,cmd.js,allmain.jsmovement/run/travel paths on canonical state.- Legacy sync glue reduced/removed.
Gate:
- Movement-centric failing seeds stable or improved.
Phase 3: Translator Alpha (Safe Subset)
Deliver:
- Translator end-to-end pipeline operational.
- Rule tables loaded and validated.
- Pure/helper function translation proven.
Gate:
- Idempotence and static checks pass.
- Stage-0 throughput ramp gate passes (scrutinized pilot set complete).
Phase 3 Hard-Part Execution Order (Authoritative)
Work packages are intentionally ordered to avoid rework:
T3.1Parser bootstrap (clang.cindexTU load + compile command profile)T3.2Source/PP span map + macro provenance extractionT3.3NIR core model + deterministic function-level serializationT3.4Rule/schema loader + strict validationT3.5Rewrite pass engine wiring (state/macros/function/boundary/controlflow)T3.6JS backend emitter skeleton (stable formatting + source map sidecar)T3.7CLI orchestration (main.py) and artifact writing (meta/diag)T3.8Idempotence/static gates + translator unit suiteT3.9Safe-subset pilot translation on curated helper functions
Dependency constraints:
T3.3depends onT3.1andT3.2.T3.5depends onT3.3andT3.4.T3.6depends onT3.3.T3.7depends onT3.5andT3.6.T3.8depends onT3.7.T3.9depends onT3.8.
Parallelization rule:
T3.4can run in parallel withT3.2/T3.3.T3.6can start onceT3.3is stable, in parallel with lateT3.5.- Final gate still requires all
T3.xto be green.
Phase 4: Combat/Monster Core Canonicalization + Translator Pilot
Deliver:
- Canonicalization of combat and monster turn core paths.
- Translator pilot for selected
hack.c,monmove.c,uhitm.cfunctions.
Gate:
- No parity regression on targeted seeds; at least one divergence cluster improves.
- Stage-1 throughput ramp gate passes (dozens-scale subsystem wave).
Phase 5: Generation/Startup Canonicalization + Translator Expansion
Deliver:
- Startup and generation ownership aligned (
u_init,dungeon,makemon,sp_lev,bones). - Translator expands to additional
automodules.
Gate:
- Early-step divergence class improved.
- Stage-2 throughput ramp gate passes (hundreds-scale wave reliability).
Phase 6: Boundary Hardening and Legacy Path Elimination
Deliver:
- Mixed-file boundaries fully annotation-managed.
- Remaining legacy mirrors removed in Tier 1.
- Documentation finalized and synchronized.
Gate:
- Stable campaign-level parity metrics and clean policy checks.
- Stage-3 throughput operation is stable for remaining backlog closure.
Artifacts and Evidence Required Per Batch
- Changed files and rationale.
- Unit test result summary.
- Session test summary:
- overall pass/fail
- gameplay subset pass/fail
- top failing divergences with
file:function.
- Delta note:
- improved/unchanged/regressed seeds
- reasoned explanation for changes.
Metrics Dashboard (Minimum)
sessions_passed_totalgameplay_passed_totalfailing_gameplay_count- median first RNG divergence step (failing gameplay set)
- median first event divergence index (failing gameplay set)
- top-10 divergence origins by frequency (
file:function)
Risks and Countermeasures
- Risk: State migration introduces hidden behavior drift.
- Countermeasure: small batches + focused parity reruns + rapid rollback.
- Risk: Translator rules overfit and mis-translate edge cases.
- Countermeasure: strict-mode conflicts + risk scoring + manual-required high-risk paths.
- Risk: Mixed-file boundaries become stale.
- Countermeasure: annotation-first policy + CI enforcement.
- Risk: Development velocity drops due to process overhead.
- Countermeasure: keep artifacts lightweight and script-assisted.
Decision Framework for “Should This Be Auto-Translated?”
Auto-translate if all are true:
- file policy is
autoormixedwith annotation-allowed region/function, - no unresolved parity-critical macros/symbols,
- boundary semantics resolved by table rules,
- risk score below configured threshold.
Manual required if any are true:
manual_onlyorgenerated_datapolicy,- unresolved boundary/async rule,
- high-risk control-flow transform not proven for this pattern,
- translation touches blocked mixed-file region.
Rollback Strategy
- Keep changes in small commits aligned to one module cluster.
- If parity regresses, revert the offending batch cleanly.
- Preserve diagnostics artifacts so the same bug is not reintroduced.
Completion Criteria for Operation Iron Parity
- Canonical state ownership complete for Tier 1 and Tier 2 modules.
- Translator v1 operational and trusted on safe/high-value subsets.
- Remaining non-translated zones are explicitly policy-marked and justified.
- Replay parity trend is stable/improving with reduced hidden-state divergence clusters.
- All campaign plan docs remain synchronized and current: