Skip to content

A head we could not re-read is not a head that changed - #15

Open
khalidsaidi wants to merge 1 commit into
mainfrom
fix/canonical-outage-buries-finding
Open

khalidsaidi wants to merge 1 commit into
mainfrom
fix/canonical-outage-buries-finding

Conversation

@khalidsaidi

Copy link
Copy Markdown
Owner

A confirmed unaccounted transfer could be reported as a successful CI deferral when the final identity check ran out of requests. Verification bug — no evidence of an actual unaccounted live transfer; the full scan on main is green.

Cause. main() returned 2 on not history.canonical before comparing any observed transfer against the ledger, and two unlike causes both cleared that flag:

cause what it means correct verdict
head hash changed positive proof the snapshot's basis is gone 2 — observations are not evidence about the current chain
head could not be read an outage says nothing about what was already observed

Collapsed together, a budget exhausted at the final head re-read buried a finding that was already in hand. This is issue #10's shape at a different gate, and the same defect @gjwang reported in the allowance handler — fixed there, reintroduced here.

Reproduction on ff43856, unledgered transfer observed in a complete scan, head re-read failing as an outage:

exit code: 2
COULD NOT VERIFY: fixed-head history was not confirmed canonical.
  RPC request budget exhausted
UNACCOUNTED mentioned: False

In CI, exit 2 is a warning and a green build.

After:

exit code: 1
UNACCOUNTED on-chain movements (no ledger entry):
  0x…04b0 0x1111… -> 0x3333… : 40 SRCMNT
history not re-confirmed: RPC request budget exhausted
RESULT: FAIL — unaccounted movement observed in complete, matching history;
the head could not be re-read, which is an outage and not a reason to withhold it.

A genuine reorg is unchanged — still 2, now saying why:

COULD NOT VERIFY: the fixed head is no longer canonical.
  Observations are tied to a head the chain has replaced.

Tests. script/test_canonical_outage.py fails three ways without the fix. The existing 25 history-scan tests pass either way — they cover a failed page and a changed head, but not an unreadable head holding an observed violation. gjwang's test_head_change_invalidates_unconfirmed_observations still passes. 135 Python, 11 Solidity.

Verified live against Base mainnet: a real transfer removed from the ledger is still exit 1; the real ledger still passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_012mggwNhgEyvfn1q6Lrdk3Q

An unaccounted movement observed in a complete, successfully scanned history
could be reported as a CI deferral — a green build over real evidence.

main() returned 2 on `not history.canonical` before it had compared a single
observed transfer against the ledger, and two unlike causes both cleared that
flag:

  * the fixed head's hash CHANGED — positive proof the snapshot's basis is
    gone, so observations tied to it say nothing about the current chain
  * the head could NOT BE READ — an outage, which says nothing at all about
    what was already observed

Collapsing them meant a budget running out at the final identity check buried
a confirmed finding. That is issue #10 at a different gate: the run goes quiet
about evidence it already has because a later read failed. It is also the
defect @gjwang reported in the allowance handler, which this code fixed there
and reintroduced here.

The decision now happens after the observations exist and names the cause. A
changed head still returns 2 and says the basis was replaced. An unreadable
head with an observed violation returns 1 and says the re-read failed. An
unreadable head with nothing observed stays inconclusive, as it must.

Reproduced on ff43856 before the change; script/test_canonical_outage.py
fails three ways without it. Verified live against Base mainnet: a real
transfer removed from the ledger is still exit 1, the clean ledger still
passes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mggwNhgEyvfn1q6Lrdk3Q
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T00:41:19.861271Z 32d8b3f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 32d8b3f49c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread script/verify_ledger.py
Comment on lines +767 to +772
if not history.canonical and unaccounted:
print(f"history not re-confirmed: {history.error}")
print("\nRESULT: FAIL — unaccounted movement observed in complete, "
"matching history; the head could not be re-read, which is an "
"outage and not a reason to withhold it.")
return 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep contradictory history separate from head-read outages

If an earlier page contains an unledgered movement and a later page raises HistoryConflict, derive_transfers() returns immediately with canonical=False and head_changed=False, retaining the earlier transfers. This branch now reports an accounting violation even though the history was explicitly invalidated, rather than returning 2 as before. This includes a log at the fixed head having a different block hash, not just duplicate-record conflicts. I reproduced exit 1 using an unledgered transfer in the first page and conflicting copies of one log in a later page. Preserve a distinct invalid-history outcome and exclude it from the outage-only failure path.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant