docs: development workflow + phase-by-phase audit

Adds mandatory decompile→verify→port workflow to CLAUDE.md:
- DECOMPILE FIRST before writing ANY AC-specific code
- Cross-reference against ACE/ACME (interpretation aids)
- Write pseudocode before porting (catches misinterpretations)
- Port faithfully — don't "improve" the retail code
- Conformance test the critical paths
- Integrate surgically — minimum changes to working code
- Phase completion checklist with decompiled-reference citations

Phase audit (docs/audit/2026-04-13-phase-audit.md) reviews all
shipped phases:
- 53% verified (decompiled/ACME conformance)
- 34% from good references (ACE/ACViewer/holtburger)
- 5% guessed (lighting, indoor transitions)
- 8% not AC-specific (streaming, culling)

Key gaps identified:
1. Lighting uses guessed sun direction — should use decompiled AdjustPlanes
2. Indoor transitions disabled — needs decompiled CEnvCell port
3. SceneryGenerator LCG not verified against decompiled code
4. CreateObject parser incomplete
5. Movement messages missing sequence counters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-13 13:27:08 +02:00
parent 0335e317d2
commit 9e5258152d
2 changed files with 207 additions and 0 deletions

View file

@ -64,6 +64,79 @@ a phase just landed, and move to the next todo item.
always yes — keep going.** The single exception is visual verification;
otherwise, act.
## Development workflow: decompile → verify → port
**This is the mandatory workflow for implementing ANY AC-specific behavior.**
The triangle-boundary Z bug cost 5 failed fix attempts from guessing.
The animation frame-swap bug cost 4 failed attempts. Every time we
checked the decompiled code first, we got it right on the first try.
### For each new feature or bug fix:
1. **DECOMPILE FIRST.** Before writing any AC-specific code, find the
matching function in the decompiled client (`docs/research/decompiled/`)
or decompile a new region using `tools/decompile_acclient.py`. Use
the function map at `docs/research/acclient_function_map.md` to find
known functions. If the function isn't mapped yet, search by
characteristic constants (motion commands, magic numbers, string
literals).
2. **CROSS-REFERENCE.** Check the decompiled code against ACE's C# port
(`references/ACE/Source/ACE.Server/Physics/`) and ACME's
`ClientReference.cs`. The decompiled code is ground truth; ACE and
ACME are interpretation aids. If they disagree, the decompiled code
wins.
3. **WRITE PSEUDOCODE.** Translate the decompiled C into readable
pseudocode before porting to C#. Save it in
`docs/research/*_pseudocode.md` for future reference. This step
catches misinterpretations before they become bugs.
4. **PORT FAITHFULLY.** Translate the pseudocode to C# line-by-line.
Use the same variable names, the same control flow, the same boundary
conditions. Do not "improve" or "simplify" the algorithm — the retail
client's code works; our job is to match it.
5. **CONFORMANCE TEST.** Write tests that verify our port matches the
decompiled behavior. Use golden values from the decompiled code or
from ACME's conformance tests. If the function touches terrain, port
the 4M-cell sweep from `TerrainConformanceTests.cs`.
6. **INTEGRATE SURGICALLY.** When wiring ported code into the renderer
or game loop, change the MINIMUM necessary. Keep existing working
transform pipelines, only replace the specific computation. The
animation sequencer integration proved this: replacing the slerp
source was safe; replacing the entire transform composition broke
everything.
### What NOT to do:
- **Do not guess** at AC-specific algorithms, formulas, constants, wire
formats, or coordinate conventions. Ever.
- **Do not "fix" the decompiled code.** If the retail client does
something that looks wrong, it's probably right. Verify before
changing.
- **Do not skip the pseudocode step.** The frame-swap bug was caused by
misreading the decompiled C directly into C# without an intermediate
translation.
- **Do not integrate via subagent** unless the subagent has the full
context of the existing code it's modifying. The first animation
sequencer integration was done by a subagent that didn't understand
the transform pipeline — it broke everything.
### Phase completion checklist:
Before marking any phase as done:
- [ ] Every AC-specific algorithm has a decompiled reference cited in
comments (function address + chunk file)
- [ ] Conformance tests exist for the critical paths
- [ ] The code was cross-referenced against at least 2 reference repos
- [ ] `dotnet build` green, `dotnet test` green
- [ ] Visual verification by the user (if applicable)
- [ ] Roadmap updated
- [ ] Memory updated if there's a durable lesson
## Subagent policy
Subagents are the primary tool for saving parent-context and keeping one