This document governs coding agents working on MathTrace.
MathTrace is an AI-powered mathematical problem-solving workflow and formal verification runtime. It features an append-only state ledger, scoped inference and cycle-free witness evaluation, nonparty challenge adjudication, Lean 4 proof verification with optional sandbox isolation, adaptive coordination frontiers, and an advisory learning layer.
mathtrace/: Authoritative Python runtime, CLI commands, and Lean semantic inspector.tests/: Deterministic regression test suite (313 tests).tools/: Reusable validation, native installer, and toolchain setup utilities.docs/: Operational documentation, workspace navigation guide, and architectural decisions.openspec/: OpenSpec capability specifications (specs/), change proposals (changes/), and configuration (config.yaml)..agents/: Generated native agent projection (roles, protocol, skills) and installed OpenSpec workflow skills..math/: Runtime campaign state (created per mathematical research campaign).work/: Retained validation runs, toolchains, archives, and historical provenance.
OpenSpec is the sole development and change-management system for MathTrace. Do not establish alternative planning systems, custom schemas, or ad-hoc task trackers.
All substantive enhancements, bug fixes, and architectural adjustments follow standard OpenSpec practices:
- Propose: Create a change with
openspec new change <name>or use theopenspec-proposeskill. - Specify: Author or modify requirements in the change's delta specs (
specs/<capability>/spec.md) conforming to OpenSpec schema. - Design & Tasks: Detail the design decisions and break implementation into verifiable tasks (
tasks.md). - Implement: Apply code and test changes (
openspec-apply-changeskill). - Verify: Ensure the test suite passes (
pytest tests), package builds cleanly (python tools/validate_package.py), and specs validate (openspec validate --all). - Archive: Sync delta specs to main specs and archive the change (
openspec-archive-changeskill oropenspec archive <name>).
The authoritative specifications of verified system behavior live under:
openspec/specs/
Always check existing specifications before modifying runtime capabilities.
Agents modifying MathTrace must strictly preserve the following invariants:
- State Immutability: All campaign data resides in transactional SQLite with append-only events. Projections are dynamically derived; historical events are never mutated in place. State integrity is verified via SHA-256 state digests.
- Formal Checking Integrity: Formal verification requires pinned Lean 4 fresh-context checked-target replay, retained compiled semantic evidence and independent target-fidelity review. Direct Execution is the default; explicitly selected Bubblewrap retains its original isolation requirements. Standalone checks retain
leanchecker --fresh. Never fabricate sandbox attestation or source-to-object correspondence; preserve historical protocols and all mathematical gates. - Sound Scoped Evaluation: Support and refutation propagation use conservative antitone bounds and selected witness forests (
scoped-selected-forest-v3). Circular reasoning is detected and rejected. - Independent Nonparty Adjudication: Objections, counterexamples, and findings require independent nonparty adjudication. Historical audit witnesses cannot be silently substituted under old certificates.
- Advisory Boundary: Advisory heuristics and research lessons are curated against immutable event lineage and must never become mathematical dependencies in proof trees or audit gates.
- Native Isolation & Preservation: Roles in
.agents/are managed viamathtrace.nativeand generated bytools/install_native.py. The installer strictly preserves external assets, including OpenSpec skills and workflows. - Model & Effort Inheritance: Autonomous subagents inherit the parent agent's foundation model and reasoning effort settings by default; automatic model routing or degradation is prohibited.
Run from the repository root:
- Run Test Suite:
python -m pytest tests
- Validate OpenSpec Specs and Changes:
openspec validate --all
- Verify Package Build and CLI Identity:
python tools/validate_package.py
- Update Native Projection:
python tools/install_native.py