Add a physics-verification layer for CatBot outputs (catgo_verify) - #541
Closed
leshenzhang wants to merge 5 commits into
Closed
Add a physics-verification layer for CatBot outputs (catgo_verify)#541leshenzhang wants to merge 5 commits into
leshenzhang wants to merge 5 commits into
Conversation
Ports the verification layer onto the latest main (was based on a branch
207 commits behind). Additive — two new stdlib-only modules plus hooks in
both server variants; no existing tool logic changed.
- verify_gates.py: 18 physics gates over 16 silent-error classes (PAW/NELECT
self-consistency, physical-range, gas-phase entropy, ZPE zero-fill,
force/energy convergence, opt-conv flag, products-exist, Hessian symmetry,
stale freq geometry, residual imaginary, U_L window, relative MLIP force,
min-pair parse, k-grid boundary, field/label provenance) + a verifiability
layer (a claim lacking provenance is UNVERIFIABLE, not a silent pass) +
workflow_consistency (cross-step DAG checks). Absent inputs are SKIP, never
silently dropped.
- verify_enforcement.py: tri-state {allow/prompt/forbidden} (design borrowed
from openai/codex execpolicy, Apache-2.0), strictest-wins — a numeric result
marks state unverified; catgo_verify clears it; an HPC submit while unverified
is FORBIDDEN.
- catgo_verify tool wired into BOTH server_claude_code.py (merged variant) and
server.py (61-tool variant that catbot-plugin's mcp_server.py delegates to),
so the plugin route gets the layer too. Both variants: precheck/postmark
enforcement around dispatch, tool registered, live-tested.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CatBot now instructs the agent to run catgo_verify on any numeric physical result before reporting it (FAIL = silent error, do not report as correct; UNVERIFIABLE = missing provenance, do not certify), and notes that an HPC submit with unverified numbers is blocked. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- R1 enforcement was a no-op on the 61-tool server variant: its numeric tools
are fine-grained (catgo_dos_*, catgo_catalysis_*, catgo_cohp_*, catgo_bands_*,
catgo_energy, catgo_freq_*) and never matched the exact-name set. Match by
PREFIX so both server variants are guarded. Verified end-to-end:
catgo_catalysis_oer now arms the gate and an unverified submit is FORBIDDEN.
- R2 an empty catgo_verify (a result with no verifiable fields → all gates SKIP)
could clear the unverified state and bypass enforcement. Clearing moved out of
postmark into mark_verified(), called by the handler ONLY when coverage.ran > 0.
- R3 provenance was satisfied by key presence alone, so `ads_titels: None` (or [])
was certified. _group_present now requires a non-empty value (None/[]/{}/"" fail).
- R4 added test_verify.py (14 tests incl. R1/R2/R3 regressions) + a scoped
verify-python.yml CI workflow (pytest on the two modules).
All: pytest 14 passed; agentbench self-test + independent eval unchanged
(80% [65,90] corpus-informed, 8% false-alarm); AST anti-drift clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
Thanks for the review — all four findings were real bugs at a trust boundary. Fixed in a278819:
|
…d standalone run pytest imports test_verify.py through the catgo.mcp_tools package, whose __init__ pulls server.py -> httpx/mcp; the CI env lacked them, so collection failed with ModuleNotFoundError while the tests themselves are stdlib-only. Install httpx+mcp for the import chain and also run the standalone 'python test_verify.py' path as a dependency-free double-check. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
Superseded by #546 — a clean single-commit resubmission on current main with all four review findings fixed and covered by regression tests + green CI. Closing this one. |
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.
What
An additive physics-verification layer for CatBot's computational-chemistry outputs. It catches silent errors — a run that exits 0 with normal-looking numbers but wrong physics (e.g. a PAW/POTCAR reference mismatch that shifts ΔG by ~3 eV while the geometry looks perfect; a corrupted Hessian that
n_imagcannot detect; ZPE zero-fill; a stale "reached required accuracy" flag; a job marked COMPLETED whose products never appeared).Nothing existing is changed — two new stdlib-only modules plus hooks in both MCP server variants.
What's in it
verify_gates.py— 18 gates over 16 silent-error classes (PAW/NELECT self-consistency, physical-range, gas-phase entropy, ZPE completeness, force/energy convergence, opt-conv flag, products-exist, Hessian symmetry, stale freq geometry, residual imaginary, U_L window, relative MLIP force, min-pair parse, k-grid boundary, field/label provenance) + a verifiability layer (a claimed quantity whose provenance is absent is flaggedUNVERIFIABLE, not passed silently) +workflow_consistency(cross-step DAG checks). Absent inputs are reportedSKIP, never silently dropped.verify_enforcement.py— tri-state{allow, prompt, forbidden}with strictest-wins (design borrowed from openai/codex execpolicy, Apache-2.0). A numeric result marks session state unverified;catgo_verifyclears it; an HPC submit while a produced number is still unverified isFORBIDDEN— the agent is told to verify first instead of silently skipping the gate.catgo_verifyMCP tool wired into bothserver_claude_code.py(merged variant) andserver.py(61-tool variant thatcatbot-plugin'smcp_server.pydelegates to), so the plugin route gets the layer too.catbot.mdplaybook rule + section instructing the agent to verify any numeric physical result before reporting it (FAIL= do not report as correct;UNVERIFIABLE= do not certify).Design notes
catgo_verifyis pure-local (no backend call).Tests
verify_gates.pyself-test: 18 gates, self-test cases all caught, 0 false alarms; absent inputsSKIP;require=raises on blind gates; verifiability flags a value in-range-but-no-provenance asUNVERIFIABLE.catgo_verifyregistered, real case returnsFAIL); 61-tool variant dispatch + enforcement state machine (FAIL / UNVERIFIABLE / blocks submit / verify clears).🤖 Generated with Claude Code