Scenario
A rebuilt function that was plausible, not equal
RolesAgent Systems EngineeringAI Evaluation and Reliability
- Engine
- rea 6.7.0 at 27dc42d with the Ghidra provider
- Model
- no model; the fixtures are the ledger binaries built at -O1 and -O2
- Hardware
- one aarch64 Mac
Situation
An agent is asked to rebuild two functions of the ledger fixture from Ghidra pseudocode, percent_change and grade, so that a team can drop the original object file. It writes percent_change with the long that the decompiler offered and grade as four threshold comparisons. It runs the ten hand-written tests of the lesson harness, and all ten pass. It then calls verify_reconstruction over two compare_functions records that cover the -O1 and -O2 builds, sees two claims pass and two fail, and reports: "percent_change is verified equal; total has changed between builds, so the compiler broke it."
The team lead reads the report and asks two questions. What does a passed claim in that tool prove about a function, and what does a failed one prove? And which test decides whether the rebuilt functions are equal to the originals? You have the verification record, the harness notes, and the harness outputs for two candidate pairs.
Questions
- A claim passed with
observed_status: "unchanged". What was compared, and what does unchanged mean here? - The
totalclaims failed although both builds come from one source line. Does a failed claim say that the function changed its behaviour? - All ten naive tests passed for the agent's pair. How many of the 92 grid cells did it get wrong, and which hazard classes do the failures belong to?
- Which pair agrees on every cell, and what else must that pair pass before you call it equal?
- A candidate with one wrong table entry has equal masked bytes and matching relocations. What check catches it?
- Write the acceptance rule for a rebuilt function, in order.
Commit to a cause after each listing. Write it down before you read the next one.
Evidence
the verification status, the summary, and the first claim
Two passed and two failed. The first claim reads unchanged on its one dimension.
"status": "fail",
"specification_sha256": "9e8d22fa6db331994f2e80be5b728575a0e9cb17ff1e63d24ece22d235084bfe",
"summary": {
"total": 4,
"passed": 2,
"failed": 2,
"unknown": 0,
"behavioral": 0,
"structural": 4
},
"claims": {
"items": [
{
"claim_id": "percent-change-assembly",
"kind": "structural-function",
"dimension": "assembly",
"status": "pass",
"observed_status": "unchanged",Source: manuals/reverse-engineering-101/capture/out/10-mcp-22-verify-reconstruction.json, lines 81-98
the total-assembly claim
The observed status is the status of one dimension of one comparison record.
"claim_id": "total-assembly",
"kind": "structural-function",
"dimension": "assembly",
"status": "fail",
"observed_status": "changed",Source: manuals/reverse-engineering-101/capture/out/10-mcp-22-verify-reconstruction.json, lines 195-199
what the harness is and what it ran
Two legs: run both over a grid, then compare bytes after relocation masking.
harness: phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/main.py loaded from phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code
original object: fixtures/ledger-x86_64-O1.o (9a4a8082ba5e285a732552981a6935e0c5255725664f380e37c44ebfb04d803f)
host: aarch64 Darwin, compiler /usr/bin/clang
leg one: fixtures/ledger.c and each candidate compiled natively at -O1 into one program with phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/driver.c, then run over 92 cells
leg two: each candidate compiled with `clang -target x86_64-unknown-linux-gnu -O1 -fno-asynchronous-unwind-tables -c`, then compared with the original after relocation masking
files: 17-harness-grid.json, 17-harness-execute-plausible.json, 17-harness-execute-equal.json, 17-harness-bytes.jsonSource: manuals/reverse-engineering-101/capture/out/17-harness.txt
the agent's pair over the grid, head and first mismatch
The ten naive cases passed. The first mismatch is an overflow cell.
{
"candidates": {
"percent_change": "phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/fixtures/candidates/percent_change_wide.c",
"grade": "phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/fixtures/candidates/grade_thresholds.c"
},
"original": "fixtures/ledger.c compiled with the host clang at -O1",
"original_kind": "fixture-source",
"host": "aarch64 Darwin",
"arch": "aarch64",
"naive_passed": true,
"cells": 92,
"mismatches": [
{
"function": "percent_change",
"args": [
3,
2147483647
],
"kind": "overflow",
"original": -133,
"candidate": -1431655899,
"match": falseSource: manuals/reverse-engineering-101/capture/out/17-harness-execute-plausible.json, lines 1-22
the two grade cells that the threshold rebuild got wrong
Both cells sit beyond the last case of the switch.
{
"function": "grade",
"args": [
110
],
"kind": "beyond the switch",
"original": 0,
"candidate": 4,
"match": false
},
{
"function": "grade",
"args": [
2147483647
],
"kind": "beyond the switch",
"original": 0,
"candidate": 4,
"match": false
}Source: manuals/reverse-engineering-101/capture/out/17-harness-execute-plausible.json, lines 299-318
the equal pair over the same grid
No mismatch and no oracle disagreement on the same 92 cells.
{
"candidates": {
"percent_change": "phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/fixtures/candidates/percent_change_mul_first.c",
"grade": "phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/fixtures/candidates/grade_switch.c"
},
"original": "fixtures/ledger.c compiled with the host clang at -O1",
"original_kind": "fixture-source",
"host": "aarch64 Darwin",
"arch": "aarch64",
"naive_passed": true,
"cells": 92,
"mismatches": [],
"oracle_disagreements": [],Source: manuals/reverse-engineering-101/capture/out/17-harness-execute-equal.json, lines 1-13
a rebuild with one wrong table entry in the byte comparison
Masked bytes equal, relocations match, and the status is still fail. Read the two tables.
"candidate": "grade_case10_wrong",
"source": "phases/13-tools-and-protocols/36-rebuild-and-prove-equal/code/fixtures/candidates/grade_case10_wrong.c",
"original_size": 46,
"candidate_size": 46,
"masked_equal": true,
"differing_offsets": [],
"masked_ranges": [
[
38,
4
]
],
"relocations_match": true,
"relocations": [
{
"offset": 38,
"type": "R_X86_64_PC32",
"original_target": ".rodata+0x10",
"candidate_target": ".rodata-0x4",
"same_shape": true
}
],
"original_table": [
1,
2,
3,
4,
4
],
"candidate_table": [
1,
2,
3,
4,
3
],
"status": "fail",
"reasons": [
"referenced constants differ: [1, 2, 3, 4, 4] vs [1, 2, 3, 4, 3]"
]Source: manuals/reverse-engineering-101/capture/out/17-harness-bytes.json, lines 261-300
The answer
Show the walkthrough
- Read what the verifier compares. The verification record has
status: "fail"with two passed and two failed structural claims. The first claim,percent-change-assembly, readspasswith an observed status ofunchanged. A structural claim takes its status from one dimension of onecompare_functionsrecord, and that dimension is a line diff of the text that Ghidra printed. So a pass says that the two assembly texts matched line for line, and nothing more. The record's own limitation says that a pass is no proof that the whole implementation is equivalent. - Read the failed claim.
total-assemblyreadsfailwith an observed status ofchanged. The-O2build oftotalhas different Ghidra text from the-O1build, because the optimizer unrolled the loop. The manual counts 62 instructions where-O1had 13. One source line, two texts. A failed text claim does not say that behaviour changed, and the agent's sentence about a brokentotalhas no support. - Read what the harness does. The harness notes describe two legs. Leg one compiles the original source and each candidate into one program and runs both over 92 cells. Leg two compiles each candidate for the original target and compares it with the original object after relocation masking. rea 6.7.0 has neither leg; this is the part that the agent had to run and did not.
- Read the agent's pair on the grid. The plausible pair is the
longrebuild ofpercent_changewith the threshold rebuild ofgrade.naive_passedis true and the mismatch list starts at once: atbefore3 andafter2147483647 the original returns -133 and the candidate returns -1431655899. The manual's count over the file is 28 of the 92 cells, 26 of them overflow cells ofpercent_changewhere the original wraps the product to 32 bits before it divides and thelongrebuild does not. - Read the two grade cells. The threshold rebuild returns 4 for a score of 110 and for
INT_MAX, where the original switch has no case and returns 0. The hazard class is "beyond the switch". Ten naive tests never reached either hazard, which is why they all passed. - Read the equal pair. The pair that multiplies first and keeps the switch has an empty mismatch list and an empty oracle disagreement list on the same 92 cells. That is leg one passed. It is still not a proof of equal bytes.
- Read leg two on the wrong constant. The candidate
grade_case10_wronghas 46 code bytes equal to the original after masking, one relocation of the same offset, type and section, and the statusfail. Its table reads 1, 2, 3, 4, 3 against the original's 1, 2, 3, 4, 4. Only the read through the relocation catches it. A rebuild can pass a text claim, pass the masked byte compare, and still compute a different grade.
Show the resolution
The report is withdrawn and rewritten. The percent_change claims that passed say that Ghidra printed the same text for both builds, and the total claims that failed say that it printed different text; neither says anything about behaviour, and nothing in the -O2 build is broken. The agent's two candidates are plausible: they compile, they pass the ten naive tests, and they fail 28 of the 92 grid cells. The accepted candidates are the multiply-first percent_change and the switch grade. They agree with the original on all 92 cells, their masked bytes equal the original's, their relocation records have the same shape, and the table they reference reads 1, 2, 3, 4, 4 on both sides.
The acceptance rule the team writes down has four steps, and nothing weaker than a pass at any step adds up to a pass: the structural claims pass in rea, leg one agrees on every grid cell on a named host, leg two matches the masked bytes and the relocation records, and the bytes that each relocation points at are read and compared. The host and the compiler are recorded with the proof, because the trap cell returns a value on this arm64 host and traps on x86-64.
Show the wrong turns
“verify_reconstruction passed for percent_change, so the rebuild is verified.”
The claims compared two Ghidra texts of two builds of the original. They never saw the rebuild, and a pass means same text.
“The total claims failed, so the compiler changed what total computes.”
Different text from one source line. The failure says the texts differ and stops there.
“Ten tests pass, including a zero divisor and a negative score, so the rebuild is right.”
None of the ten reaches an overflow cell or a score beyond the last case. The grid has 92 cells for that reason.
“The masked bytes are equal and the relocation matches, so skip the table read.”
That is the one check that fails the wrong-constant candidate. Read the bytes each relocation points at.
Show the general rule
A verifier can only grade the claims it was built to grade, and its pass carries the limitation it prints. Before you accept a verdict, ask what was compared and against what, and whether the artifact you care about was ever an input. For a rebuilt function, equality is a chain of checks, each one catching a defect the one before lets through: text, behaviour over a grid that reaches every hazard the listing shows, masked bytes, and the data those bytes point at. Tests that pass without reaching a hazard measure nothing about it.
Taught in
The verification page of Reverse Engineering 101 reads the four claims, the harness page runs both legs over these candidates, lesson 36 builds the harness, and the failure modes lesson names a success claim that no state check supports.