make_checkpoint.py: detect OCaml exceptions during loading#175
Merged
Conversation
The send_and_wait() function sends user code followed by a sentinel Printf as the next toplevel phrase. When the user code raises an exception (e.g. a failed proof or missing file), the OCaml toplevel catches it, prints the error, and continues to the next phrase, so the sentinel always appears regardless of success or failure. This means make_checkpoint.py silently creates checkpoints of broken or partial states. Fix: wrap each expression in try/with that emits a unique error sentinel (HOL_MCP_LOAD_ERROR) on exception. wait_for_line() detects this sentinel and reports the exception with a clear error message before the script can proceed to checkpointing. Also reject expressions containing ';;' (multiple toplevel phrases) upfront, since try/with can only wrap a single expression. The error message guides the user to place composite inputs in a file and load with needs or loadt instead. This does not affect the MCP server's interactive use, where the LLM reads the full output and sees exception messages directly. It only affects make_checkpoint.py's batch usage, where intermediate output is discarded and only sentinel arrival is checked.
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.
The send_and_wait() function sends user code followed by a sentinel Printf as the next toplevel phrase. When the user code raises an exception (e.g. a failed proof or missing file), the OCaml toplevel catches it, prints the error, and continues to the next phrase, so the sentinel always appears regardless of success or failure. This means make_checkpoint.py silently creates checkpoints of broken or partial states.
Fix: wrap each expression in try/with that emits a unique error sentinel (HOL_MCP_LOAD_ERROR) on exception. wait_for_line() detects this sentinel and reports the exception with a clear error message before the script can proceed to checkpointing.
Also reject expressions containing ';;' (multiple toplevel phrases) upfront, since try/with can only wrap a single expression. The error message guides the user to place composite inputs in a file and load with needs or loadt instead.
This does not affect the MCP server's interactive use, where the LLM reads the full output and sees exception messages directly. It only affects make_checkpoint.py's batch usage, where intermediate output is discarded and only sentinel arrival is checked.