Skip to content

make_checkpoint.py: detect OCaml exceptions during loading#175

Merged
jrh13 merged 2 commits into
jrh13:masterfrom
jargh:master
May 19, 2026
Merged

make_checkpoint.py: detect OCaml exceptions during loading#175
jrh13 merged 2 commits into
jrh13:masterfrom
jargh:master

Conversation

@jargh
Copy link
Copy Markdown
Contributor

@jargh jargh commented Apr 24, 2026

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.

jargh and others added 2 commits April 23, 2026 17:21
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.
@jrh13 jrh13 merged commit 43ae32d into jrh13:master May 19, 2026
4 checks passed
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.

2 participants