Skip to content

Autoformalization agent configuration - #18

Draft
Valentin889 wants to merge 11 commits into
mainfrom
vs/autoformalization/agent-config
Draft

Autoformalization agent configuration#18
Valentin889 wants to merge 11 commits into
mainfrom
vs/autoformalization/agent-config

Conversation

@Valentin889

Copy link
Copy Markdown
Collaborator

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.md and prompt.md:

Agent Role
annotate_rocq Reads ECMA proposal diffs and inserts spec comments ((*>> ... <<*)) into .v files.
implement_from_comments Implements Rocq definitions and algorithms below existing spec comments. May use Admitted. to compile.
fix_audit_batch Orchestrates fix_audit_entry sequentially.
fix_proofs Scans for Proof. Admitted. and synthesizes proof scripts using rocq-mcp
filter_audit Cleans JSON audit, keeping only entries with concrete mismatches.

2. Server Configuration (.opencode/)

  • opencode.json — OpenCode workspace config pointing to the rocq-mcp server for interactive proof checking
  • AGENTS.md — Reference for all agents, their inputs/outputs, and invocation syntax

3. Audit Tool (utils/autoformalization/audit/)

  • comment_code_audit.py — Audit script
  • config.json, prompts.json, environment.yml — Model config, few-shot prompts, and conda environment
  • HTML report generationfrom_json_to_html.py turns audit JSONs into reports

4. Pipeline Documentation

  • utils/autoformalization/README.md — Complete guide covering:
    • Installation (OpenCode CLI, EPFL RCP provider, rocq-mcp)
    • The 6-step pipeline workflow
    • Agent invocation examples
    • Verification checklist
  • utils/autoformalization/audit/README.md — Guide for the audit tool

@Valentin889 Valentin889 self-assigned this May 18, 2026

@KacperFKorban KacperFKorban left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread .opencode/opencode.json Outdated
Comment on lines +7 to +14
"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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be relative or replaced by a template that can be easily replaced

Comment on lines +202 to +204
```
annotate_rocq ──► implement_from_comments ──► audit ──► fix_audit_batch ──► fix_proofs
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a single script that runs all of those in the correct order. Or it can even be a meta prompt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should document the full call with all necessary parameters

Comment on lines +312 to +322
| `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. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these aren't in this PR e.g. implement_proposal, run_local_audit

Comment on lines +324 to +344
### 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem specific to warblre

Comment on lines +352 to +357
- [ ] `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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never used rocqchk, does it check something more than dune build would?

@Valentin889
Valentin889 force-pushed the vs/autoformalization/agent-config branch from bcc61a3 to 09faf94 Compare June 25, 2026 13:50
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