Autoformalization agent configuration - #18
Conversation
This agent only write the comment for a proposal
Update description.md
KacperFKorban
left a comment
There was a problem hiding this comment.
My main comment is that we would like to have something that is one-click. It seems like there is a lot of steps that have to be done. And most of them can be automated (fairly) easily.
Disclaimer: I didn't try doing the setup myself, just did a review
| "command": [ | ||
| "/Users/valentinschneeberger/miniconda3/envs/coq-proof/bin/rocq-mcp" | ||
| ], | ||
| "environment": { | ||
| "ROCQ_WORKSPACE": "/Users/valentinschneeberger/epfl/masterProject/warblre", | ||
| "ROCQPATH": "_build/default/mechanization", | ||
| "ROCQ_COQC_BINARY": "/Users/valentinschneeberger/.opam/default/bin/coqc", | ||
| "ROCQ_PET_BINARY": "/Users/valentinschneeberger/.opam/default/bin/pet", |
There was a problem hiding this comment.
These should be relative or replaced by a template that can be easily replaced
| ``` | ||
| annotate_rocq ──► implement_from_comments ──► audit ──► fix_audit_batch ──► fix_proofs | ||
| ``` |
There was a problem hiding this comment.
There should be a single script that runs all of those in the correct order. Or it can even be a meta prompt.
There was a problem hiding this comment.
Please add a high level description of what this script does (preferably near the top of the file)
|
|
||
| ### 6.4 Step 3 — Audit | ||
|
|
||
| Run the audit tool on the files that changed in `mechanization/spec/`. |
There was a problem hiding this comment.
We want more fine-grained control– to audit only the definitions that were changed. (Maybe just the things present in git diff additions)
|
|
||
| ```bash | ||
| cd utils/autoformalization/audit | ||
| python comment_code_audit.py |
There was a problem hiding this comment.
This should document the full call with all necessary parameters
| | `annotate_rocq` | Reads an ECMA proposal diff and inserts specification comments (`(*>> … <<*)`) into Rocq `.v` files. **Comments only — never writes code.** | | ||
| | `implement_from_comments` | Implements the Rocq definitions,Fixpoints and algorithms that correspond to the spec comments added by `annotate_rocq`. | | ||
| | `implement_proposal` | End-to-end implementation of a proposal (syntax + semantics + tests) in one shot. | | ||
| | `run_local_audit` | Runs the audit tool **only on uncommitted changes**, restricting analysis to modified definitions for fast feedback. | | ||
| | `filter_audit` | Cleans raw audit results, keeping only entries that report concrete syntactic mismatches or missing steps. | | ||
| | `fix_audit_entry` | Fixes a **single** audited Coq snippet based on the reported issues and commits if the build passes. | | ||
| | `fix_audit_batch` | Orchestrates `fix_audit_entry` over many snippets **sequentially** (one at a time). | | ||
| | `fix_proofs` | Scans the entire mechanization for `Proof. Admitted.`, synthesizes missing proof scripts using `rocq-mcp` and existing patterns, and verifies with `dune build`. | | ||
| | `test262_converter` | Converts a **whole** Test262 branch into a fresh OCaml expect-test file (`tests/tests/Test262_<Feature>.ml`). | | ||
| | `fix_test262_batch` | Orchestrates conversion of all JS test files in a branch by calling `fix_test262_file` sequentially. | | ||
| | `fix_test262_file` | Generates complete OCaml expect-tests for a **single** JavaScript test file from Test262. | |
There was a problem hiding this comment.
Some of these aren't in this PR e.g. implement_proposal, run_local_audit
| ### 8.2 How to Add a New Agent | ||
|
|
||
| To extend the pipeline with a new agent: | ||
|
|
||
| 1. **Create the agent directory** | ||
| ```bash | ||
| mkdir -p .opencode/agents/<agent-name> | ||
| ``` | ||
|
|
||
| 2. **Add the files** | ||
|
|
||
| - **`description.md`** — Short summary (1 paragraph) of what the agent does, its inputs/outputs, and constraints. OpenCode uses this to decide when to invoke the agent. | ||
| - **`prompt.md`** — Detailed system prompt that the LLM will follow when the agent is called. Include task description, constraints, step-by-step workflow, output format, and error-handling rules. | ||
|
|
||
| 3. **Invoke it** | ||
| Once the folder exists, the agent is automatically available in OpenCode via: | ||
| ``` | ||
| @<agent-name> <your prompt> | ||
| ``` | ||
|
|
||
| > **Tip:** Follow the style of existing agents. Keep prompts concrete, give examples where possible, and always state whether the agent is allowed to modify code, run builds, or commit changes. |
There was a problem hiding this comment.
This doesn't seem specific to warblre
| - [ ] `dune build @all` succeeds without errors | ||
| - [ ] `dune test` passes | ||
| - [ ] `rocqchk` validates the compiled libraries | ||
| - [ ] No `Admitted.` proofs remain | ||
| - [ ] Code follows the repository naming conventions | ||
| - [ ] Spec comments reference the correct ECMAScript sections |
There was a problem hiding this comment.
Can we have a simple script that performs most of these checks?
|
|
||
| - [ ] `dune build @all` succeeds without errors | ||
| - [ ] `dune test` passes | ||
| - [ ] `rocqchk` validates the compiled libraries |
There was a problem hiding this comment.
I've never used rocqchk, does it check something more than dune build would?
bcc61a3 to
09faf94
Compare
Agent Configuration and Documentation
This PR introduces the agentic pipeline for autoformalizing ECMAScript regex proposals into the Warblre Rocq mechanization. It adds OpenCode agent definitions, MCP configuration, the audit tool, and documentation.
What This PR Adds
1. OpenCode Agents (
.opencode/agents/)Six agents that form the pipeline, each with
description.mdandprompt.md:annotate_rocq(*>> ... <<*)) into.vfiles.implement_from_commentsAdmitted.to compile.fix_audit_batchfix_audit_entrysequentially.fix_proofsProof. Admitted.and synthesizes proof scripts using rocq-mcpfilter_audit2. Server Configuration (
.opencode/)opencode.json— OpenCode workspace config pointing to the rocq-mcp server for interactive proof checkingAGENTS.md— Reference for all agents, their inputs/outputs, and invocation syntax3. Audit Tool (
utils/autoformalization/audit/)comment_code_audit.py— Audit scriptconfig.json,prompts.json,environment.yml— Model config, few-shot prompts, and conda environmentfrom_json_to_html.pyturns audit JSONs into reports4. Pipeline Documentation
utils/autoformalization/README.md— Complete guide covering:utils/autoformalization/audit/README.md— Guide for the audit tool