Files
BFM-decomp/tools
Drew T 72fa482027 feat(tools): verbatim_to_stub.py — put the 147 asm-posing-as-C functions back where the gates can reach them
THE GAP. Every gate in this project substitutes a draft in place of an
INCLUDE_ASM line. A §265 verbatim __asm__ body has none, so:

  gate_main.substitute()    resolves each entry through the STUB map; a verbatim
                            function is reported "resolved to NO stub" and dropped
  gate_stage/harvest_verify same splice, same gap
  splat                     stops emitting <fn>.s once a function is not a stub

So all 147 were undecompilable AND ungateable -- not for want of information,
but because the information was in a form nothing consumes.

The fix is not a parallel gate (R33 -- one implementation). It is to put the
function back into the form every existing tool already understands: replace the
__asm__ block with INCLUDE_ASM. That is also the HONEST representation --
INCLUDE_ASM pastes the very same assembly the block transcribes, so the bytes
are identical either way, but a stub counts as OUTSTANDING WORK in progress.py
while a verbatim body counted as banked. The conversion moves a function from
"silently done" to "visibly to do".

Two refusals rather than guesses (R43), because both failure modes are silent
and destructive:
  * the block is located by brace/paren MATCHING via asm_in_c.asm_blocks, never
    regex-sliced -- these blocks are full of braces and parens inside string
    literals and an approximate cut corrupts a file that currently builds;
  * the asm subdir for the new INCLUDE_ASM is copied from a sibling stub IN THE
    SAME FILE. Subsegs are per-file, so a neighbouring file's spelling names a
    different subseg -- a stub with the wrong subdir compiles happily and
    includes ANOTHER FUNCTION'S ASSEMBLY. With no sibling to copy, it refuses.

--gate rebuilds and asserts the SHA is unchanged, restoring the file if not:
byte-neutrality here is a claim, and this tool exists to enable a byte gate, so
it declines to be the one link that goes unchecked.

Dry-run verified on main:func_80047E58 -> src/800b.c, 9-line block, subdir
correctly derived as asm/nonmatchings/800b. The --gate proof is deferred only
because another agent is mid-build on main right now.
2026-09-03 00:22:24 -06:00
..