fix: harden resumable discovery lifecycle integrity - #7
Open
Charlie-Wang-03 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR hardens runner-v2 branch discovery as a resumable workflow rather than relying on prompt-level assumptions about state integrity and object uniqueness.
It also keeps the existing Moonshine integration baseline update (
72a64f8→bb0e4aa) in this PR. The PR originally contained only that one-line pin update; before review, the related discovery reliability work was consolidated here to avoid creating another small upstream PR and to validate the final runner changes against the current Moonshine runtime in one reviewable milestone.Problem
The discovery workflow persisted enough state to resume work, but several invariants were not machine-enforced:
statusand still load.verifiedcould still load after its published archive was deleted or changed on disk.verifiedorfailedobject name to the acceptance gate.Those gaps can make a resumable run's ledger disagree with the actual artifact set or allow duplicate work to be accepted as new discovery.
Contract
For branch discovery, the runner now fails closed on these deterministic invariants:
status == "verified"implies that the bound archive exists and its content still matches the persisted SHA-256;verifiedorfailedin prior runner state;--retry-failedremains allowed.The duplicate contract is deliberately exact-name only. It does not claim semantic alias detection.
Implementation
Discovery state validation
load_or_create_state()now validates:Duplicate-safe new discovery
A shared
_ensure_discovery_name_unattempted()guard checks the existing attempted-object ledger before accepting a newly discovered object.The guard is applied at the relevant new-discovery boundaries:
ARCHIVE_PROPOSALfallback materializes a discovered object.The ordinary non-discovery verifier path is unchanged, so
--retry-failedcan still repair the original failed row rather than being mistaken for a new duplicate discovery.Current Moonshine integration baseline
The exact integration pin is advanced from:
to current Moonshine main:
The workflow remains commit-pinned for reproducibility.
Deterministic reproduction
The audit was established before the production fix.
Expanded negative-control run
34361711235failed on both Python 3.9 and 3.11 because the pre-fix runner did not reject:verifiedexact object name submitted as new discovery;failedexact object name submitted as new discovery.The positive controls in the same suite already passed for:
Verification
Fork validation after the fix:
34362129168: 27/27 passed on Python 3.9 and Python 3.11;34362129186: 7/7 passed on Python 3.11;34362539327: 7/7 passed using exactlybb0e4aa.The consolidated PR head (
12992a56) was then revalidated by upstream GitHub Actions:34362788841: success;34362788749: success.No real LLM/API credentials, Tavily calls, or MCP network behavior are required for these regressions.
Scope / limitations
This PR does not:
The intended guarantee is narrower: persisted discovery state and accepted exact-name discovery remain internally consistent, artifact-bound, and fail-closed across resume.