[codex] Replace CDB search callback assembly with exact C using REA #1164

Merged
coah80 merged 1 commits from agent/rea/cdb-callback into main 2026-10-05 01:31:37 +00:00
coah80 commented 2026-10-05 01:30:43 +00:00 (Migrated from github.com)

Replace CDBDatabaseSearchCallCallback's inline assembly with readable C using the existing database, search-condition, and record types. Correct the local CDBRecordOpenReadOnly declaration to return CDBErr.

REA's Wii PowerPC backend imported the original object and exported its assembly and pseudocode. Keeping the success path nested under result == CDB_ERROR_OK reproduces the branch missed by prior early-return attempts. This is an assembly-to-C conversion; the previous assembly was already counted as matching, so reported progress percentages do not increase.

Validation on baseline 9d40859ee8f4ee37dc692e444727d17367bfcbeb:

  • Clean full 43U gate: PASS; zero regressions and no added forbidden patterns or readability warnings.
  • Callback: objdiff 100.0%, ctxdiff 61/61 instructions and zero differences.
  • Entire unit: 33/33 exact functions; .text 12152/12152 bytes and .data 312/312 bytes both raw-byte-identical to target.
  • String pool identical, seven entries.
  • DOL SHA-1: 26116613f624061ba99c8d1a299aaa6efa85670d; build/43U/ok passes.
  • Overall completion checker remains failing because the project is incomplete: 92.73726% exact code, 76.40339% linked code, 99.99410% matched data.

Reviewer coordination: after reaching this exact candidate, I found the separate local data-d2 worker had independently converted the same callback as part of broader CDB work. Please choose one implementation; this draft is intentionally left unmerged for model review. No changes were made to that worker's checkout.

REA provenance and rejected filename-validator trials are recorded in tools/decomp-assist/rea-cdb.attempts.md. REA fork commit: d19af8526975e8380da733c4f7313f73ee6a1c74; Ghidra 12.1.4 with PowerPC:BE:32:Gekko_Broadway.

Note

Replace CDB search callback assembly with matching C in CDBDatabaseSearchCallCallback

  • Replaces the PowerPC assembly for CDBDatabaseSearchCallCallback with a C implementation verified to match the original 61-instruction target.
  • The C version reads database flags under the database lock, checks the search condition against the record key, opens the record as writable or read-only, invokes the callback, and closes opened records.
  • Corrects the CDBRecordOpenReadOnly external declaration to a typed signature taking a CDBRecord pointer and returning CDBErr.
  • Documents reverse-engineering attempts and verification in rea-cdb.attempts.md.
  • Risk: check CDBRecordOpenReadOnly's typed declaration in CDBDatabase.c — call sites relying on the old untyped extern may need matching updates.

Macroscope summarized 52ff8fb.

Replace `CDBDatabaseSearchCallCallback`'s inline assembly with readable C using the existing database, search-condition, and record types. Correct the local `CDBRecordOpenReadOnly` declaration to return `CDBErr`. REA's Wii PowerPC backend imported the original object and exported its assembly and pseudocode. Keeping the success path nested under `result == CDB_ERROR_OK` reproduces the branch missed by prior early-return attempts. This is an assembly-to-C conversion; the previous assembly was already counted as matching, so reported progress percentages do not increase. Validation on baseline `9d40859ee8f4ee37dc692e444727d17367bfcbeb`: - Clean full 43U gate: PASS; zero regressions and no added forbidden patterns or readability warnings. - Callback: objdiff 100.0%, ctxdiff 61/61 instructions and zero differences. - Entire unit: 33/33 exact functions; `.text` 12152/12152 bytes and `.data` 312/312 bytes both raw-byte-identical to target. - String pool identical, seven entries. - DOL SHA-1: `26116613f624061ba99c8d1a299aaa6efa85670d`; `build/43U/ok` passes. - Overall completion checker remains failing because the project is incomplete: 92.73726% exact code, 76.40339% linked code, 99.99410% matched data. Reviewer coordination: after reaching this exact candidate, I found the separate local `data-d2` worker had independently converted the same callback as part of broader CDB work. Please choose one implementation; this draft is intentionally left unmerged for model review. No changes were made to that worker's checkout. REA provenance and rejected filename-validator trials are recorded in `tools/decomp-assist/rea-cdb.attempts.md`. REA fork commit: `d19af8526975e8380da733c4f7313f73ee6a1c74`; Ghidra 12.1.4 with `PowerPC:BE:32:Gekko_Broadway`. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Replace CDB search callback assembly with matching C in `CDBDatabaseSearchCallCallback` > - Replaces the PowerPC assembly for `CDBDatabaseSearchCallCallback` with a C implementation verified to match the original 61-instruction target. > - The C version reads database flags under the database lock, checks the search condition against the record key, opens the record as writable or read-only, invokes the callback, and closes opened records. > - Corrects the `CDBRecordOpenReadOnly` external declaration to a typed signature taking a `CDBRecord` pointer and returning `CDBErr`. > - Documents reverse-engineering attempts and verification in [rea-cdb.attempts.md](https://github.com/coah80/wii-ipl/pull/1164/files#diff-f3e3a68d1ce67b7b709eeac175aaf69124a5254437b768e8b6993fe3430607e2). > - Risk: check `CDBRecordOpenReadOnly`'s typed declaration in [CDBDatabase.c](https://github.com/coah80/wii-ipl/pull/1164/files#diff-8bc86fdd4745305779d907e80a042c492894e4cbca78d03136797ab0a166f84e) — call sites relying on the old untyped extern may need matching updates. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 52ff8fb.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-05 01:31:35 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.