5.2 KiB
5.2 KiB
AGENTS.md — Syphon Filter 3 Decompilation
Matching decompilation of Syphon Filter 3 (USA) for PlayStation. The goal is to rebuild original game binaries from C source with byte-for-byte identical output. A native PC port is out of scope until the matching decompilation is established.
Session-start load order
At the start of every session, read these files in order:
AGENTS.md— standing agent rules.PROJECT_CONTEXT.md— permanent project constitution.phase-ends/DIGEST.md— completed-phase findings.phase-ends/CURRENT_PHASE.md— active in-phase state, when present.- The active phase plan in
phase-ends/. - Task-relevant records under
docs/.
The active plan and current-phase record govern day-to-day execution; do not duplicate their evolving state in this file.
Mandatory behavior
- One task at a time. Present and complete one task before beginning the next. A task that writes code, changes a design, or modifies project state is its own task.
- Explain before changing code or design. State the approach, significant choices, and verification method before writing non-trivial code or changing architecture.
- Never overwrite blind. Read an existing file before changing it. State what changes and why. Preserve comments and document headers.
- Evidence first. Ghidra is the static oracle and PCSX-Redux is the runtime oracle. Do not present assumptions about game behavior, addresses, ABI, types, file formats, or compiler behavior as facts.
- A match is byte-for-byte. A function is matched only if its compiled code is instruction-identical to the original and the full-binary hash check remains green. Functional equivalence is not a match.
- Keep unmatched code as assembly. Correct-looking C that does not match stays behind an explicit
NON_MATCHINGguard or assembly stub; it must not enter the default matching build. - Verify from clean state. Report a build or match only after the documented clean rebuild and relevant object/binary comparison pass. Read command exit codes, not merely their final output line.
- Check duplicates before matching. Match a shared body once where possible, then share it through a documented source/registry mechanism.
- Document uncertainty. Label hypotheses and unverified addresses. Record source build/region for every externally sourced address; never treat JP or prototype data as USA evidence without validation.
- Stop on unexplained failure. If two distinct root-cause attempts fail, stop and report the evidence rather than masking the failure or redefining success.
ROM and repository firewall
- Never commit the disc dump, extracted disc contents, disassembly generated from the game, assets, build outputs, expected binaries, Ghidra database, RAM dumps, proprietary Sony SDK files, or session archives.
- Review
git statusbefore every commit. - Never use
git clean -xorgit clean -fdx. It can destroy ignored reverse-engineering databases and local dumps. Define a project-specificmake cleanlater for regenerable build output only. - Keep generated ROM-derived material in ignored paths such as
disks/,extracted/,asm/,assets/,build/,expected/,ghidra/, anddumps/. - Do not copy game bytes, disassembly listings, or ROM-derived fixtures into documentation, tests, badges, reports, or public artifacts.
Environment
- Use the installed Ghidra PSX loader when importing PS-X EXE files. Record the detected PsyQ/SDK evidence rather than assuming a toolchain.
- Use PCSX-Redux for runtime breakpoints, RAM snapshots, and controlled before/after tests when static analysis cannot prove a load address or behavior.
- Before any build pipeline work, verify the repository resides on a native Linux filesystem with reliable file permissions and watching. Do not build on a network/shared mount.
- Keep local tools under
tools/; record versions, commands, and download provenance indocs/SETUP.mdonce Phase 0 creates it.
Matching workflow
- Extract the original binary deterministically and record hashes.
- Import it with the PSX loader; preserve loader settings and record static findings.
- Build a splat/disassembly/linker baseline that rebuilds the original binary from assembly before introducing C.
- Fingerprint the original compiler/assembler/flags using small probe functions; do not copy another project’s settings without byte evidence.
- For each C candidate: inspect references and duplicates, compile, compare against the original object/function, then run the full binary check.
- Record reusable compiler/codegen discoveries in a matching cookbook and tooling immediately after a verified match.
Phase and session discipline
- Every phase begins with a task-by-task plan, verification criteria, and explicit developer approval.
- Keep current in-phase state in
phase-ends/CURRENT_PHASE.md; write a checkpoint before ending a session. - After every four completed tasks, re-read these mandatory rules and state:
Rules check — re-read complete. Continuing with [next task]. - A phase closes only after every checklist item is explicitly verified and the developer confirms the milestone. Then write a PhaseEnd file, update the digest, and stop; do not begin the next phase in the same session.