decomp(fat): improve SD initialization branch structure to 93.125% #1078

Merged
coah80 merged 1 commits from agent/bittle/sd-init-partial into main 2026-10-03 07:40:52 +00:00
coah80 commented 2026-10-03 07:40:30 +00:00 (Migrated from github.com)

Source change

Separate already-initialized and new-initialization paths in pfd_sddrv_init, retaining the common success return. A different disk still returns -44; all error returns, state writes, reports, callback registrations, and external calls retain their ordering. This replaces the baseline's branchless identity-result selection with target-style control flow. No artificial state, assembly, shared-header or linking changes.

Independent parent verification

Rebased onto 93e97b7f, which includes #1077, and rebuilt.

  • Function fuzzy: 92.326385% → 93.125%; unit: 99.10204% → 99.14116%
  • Candidate is 141/144 instructions, an honest partial, not exact
  • All 25 sibling instruction streams unchanged; 22/26 exact functions, 9260 matched code bytes and 3592 matched data bytes preserved
  • Full report comparison: only this function improves; no regressions
  • All 1027 allocated objects audited: only sd_drv text changes; nontext data unchanged
  • All 46 pooled strings and offsets identical; literal audit 24 functions / 38 arguments, no candidates or errors. pfd_sddrv_init and existing FAT32 builder skipped due unequal sizes
  • Parent extracted actual baseline/candidate C bodies into an external-call/state oracle: 279,936 cases compare return values, full driver state, device storage, event selection and ordered external traces, including error paths. Passed both optimized and ASan/UBSan builds (leak detection disabled for execution environment). This is mocked-host behavior validation, not a Wii runtime proof
  • Full 43U all_source/progress/report/ok passes; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d
  • Worktree and diff checks pass; worker additionally passed all eight workflow tests

Historical larger branch-form gain was reproduced; one smaller documented accumulator alternative scored 92.94444% and was discarded. No broad search. Evidence and limitations in attempts log.

Final source object SHA256 1206b4a1af2b2e9071430d43bdb30e6591ff11c389934c7564bb52eac77cf721 is unchanged after rebase. Uploaded tree 6b9405fb18 equals independently tested tree. No merge or auto-merge requested.

Note

Restructure pfd_sddrv_init init branch in SD driver to 93.125% match

Rewrites the control flow in pfd_sddrv_init in sd_drv.c: a call for a different disk now returns -44, while the matching disk falls through to the shared success return. First-time initialization, mount, status, callback registration, and disk assignment stay in the uninitialized branch, with the same operations and error returns.

Also adds a record of the two source-structure trials and matching metrics in sd-init-partial-recovery.attempts.md.

  • Behavioral Change: calling pfd_sddrv_init for a different disk than the initialized one now returns -44 instead of taking the success path.

Macroscope summarized 7b21962.

## Source change Separate already-initialized and new-initialization paths in pfd_sddrv_init, retaining the common success return. A different disk still returns -44; all error returns, state writes, reports, callback registrations, and external calls retain their ordering. This replaces the baseline's branchless identity-result selection with target-style control flow. No artificial state, assembly, shared-header or linking changes. ## Independent parent verification Rebased onto 93e97b7f, which includes #1077, and rebuilt. - Function fuzzy: 92.326385% → 93.125%; unit: 99.10204% → 99.14116% - Candidate is 141/144 instructions, an honest partial, not exact - All 25 sibling instruction streams unchanged; 22/26 exact functions, 9260 matched code bytes and 3592 matched data bytes preserved - Full report comparison: only this function improves; no regressions - All 1027 allocated objects audited: only sd_drv text changes; nontext data unchanged - All 46 pooled strings and offsets identical; literal audit 24 functions / 38 arguments, no candidates or errors. pfd_sddrv_init and existing FAT32 builder skipped due unequal sizes - Parent extracted actual baseline/candidate C bodies into an external-call/state oracle: 279,936 cases compare return values, full driver state, device storage, event selection and ordered external traces, including error paths. Passed both optimized and ASan/UBSan builds (leak detection disabled for execution environment). This is mocked-host behavior validation, not a Wii runtime proof - Full 43U all_source/progress/report/ok passes; DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d - Worktree and diff checks pass; worker additionally passed all eight workflow tests Historical larger branch-form gain was reproduced; one smaller documented accumulator alternative scored 92.94444% and was discarded. No broad search. Evidence and limitations in attempts log. Final source object SHA256 1206b4a1af2b2e9071430d43bdb30e6591ff11c389934c7564bb52eac77cf721 is unchanged after rebase. Uploaded tree 6b9405fb18cfa3f894b663dd5dfc46aa216f91a6 equals independently tested tree. No merge or auto-merge requested. <!-- 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] > ### Restructure `pfd_sddrv_init` init branch in SD driver to 93.125% match > Rewrites the control flow in `pfd_sddrv_init` in [sd_drv.c](https://github.com/coah80/wii-ipl/pull/1078/files#diff-cff6d99ae65b0a148b6ad31c34a72f78c4e3887de7fe48985cea8c41063e52e2): a call for a different disk now returns -44, while the matching disk falls through to the shared success return. First-time initialization, mount, status, callback registration, and disk assignment stay in the uninitialized branch, with the same operations and error returns. > > Also adds a record of the two source-structure trials and matching metrics in [sd-init-partial-recovery.attempts.md](https://github.com/coah80/wii-ipl/pull/1078/files#diff-4a1d82e388c335514e8189e5b0638be4a89c6850fb966554b854eb46e457db3f). > > - Behavioral Change: calling `pfd_sddrv_init` for a different disk than the initialized one now returns -44 instead of taking the success path. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 7b21962.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-03 07:40:50 +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.
coah80 commented 2026-10-03 07:43:00 +00:00 (Migrated from github.com)

Clarification to the generated summary: a different disk already returned -44 before this change. Both baseline and candidate return 0 for the same already-initialized disk and -44 for a different disk. This PR restructures those existing branches; it does not fix or introduce different-disk rejection. The source diff and the 279,936-case baseline/candidate oracle confirm unchanged return/state/call behavior.

Clarification to the generated summary: a different disk already returned -44 before this change. Both baseline and candidate return 0 for the same already-initialized disk and -44 for a different disk. This PR restructures those existing branches; it does not fix or introduce different-disk rejection. The source diff and the 279,936-case baseline/candidate oracle confirm unchanged return/state/call behavior.
Sign in to join this conversation.