6.5 KiB
6.5 KiB
AGENTS.md
This file provides guidance to coding agents collaborating on this repository.
Mission
Geolog is a Rust codebase for geometric logic:
- a parser and pretty-printer for the Geolog language,
- an elaboration layer that turns syntax into core structures,
- a REPL and workspace/persistence layer,
- a chase/query/solver runtime,
- and an optional egui GUI behind the
guiCargo feature.
Priorities, in order:
- Semantic correctness of theories, instances, queries, and chase behavior.
- Clear boundaries between parsing, elaboration, core structures, REPL/workspace, and GUI code.
- Focused, maintainable changes with good regression coverage.
- Performance only after correctness and testability are preserved.
Core Rules
- Use English for code, comments, docs, tests, and commit-facing text.
- Prefer small, targeted changes over broad rewrites.
- Fix root causes rather than layering on ad hoc workarounds.
- Keep modules decoupled: parsing in parser/lexer, semantics in
core/elaborate, runtime behavior inrepl/query/solver, presentation ingui. - Do not introduce unnecessary global mutable state.
- Preserve feature gating: GUI code must remain behind the
guifeature. - Avoid adding dependencies unless clearly justified.
- Add comments only when they clarify non-obvious invariants, algorithms, or semantic constraints.
Quick examples:
- Good: add a targeted regression test for a chase bug in an existing GUI or unit test module.
- Good: fix a REPL/workspace bug in
src/repl.rsorsrc/store/without refactoring unrelated parser code. - Bad: rewrite the AST/core boundary during a small GUI task.
- Bad: mix GUI presentation logic into core semantic modules.
Repository Layout
src/lib.rs: crate entrypoint and module exports.src/ast.rs,src/lexer.rs,src/parser.rs,src/pretty.rs: syntax pipeline and round-tripping.src/core.rs: core semantic data structures such as signatures, theories, and structures.src/elaborate/: elaboration from AST into core representations.src/repl.rs: REPL state, command handling, and top-level execution flow.src/store/: persistence/workspace and storage-related logic.src/query/: chase, query compilation, optimization, backend execution.src/solver/: solver and tactic logic.src/tensor/: tensor-based checking/evaluation support.src/gui/: egui GUI state, panels, and visualizations.src/bin/geolog.rs: CLI/REPL binary.src/bin/geolog-gui.rs: GUI binary (requires--features gui).examples/geolog/: sample Geolog programs.tests/: integration, regression, unit-style cross-module, and property tests.docs/: architecture and syntax documentation.proofs/: Lean proofs and formal artifacts.fuzz/: fuzzing targets.
Architecture Constraints
- Keep the syntax pipeline clean: text → lexer → parser → AST.
- Keep elaboration separate from parsing and separate from UI code.
coretypes should remain usable without the GUI.- GUI code should orchestrate and present existing behavior, not reimplement semantic logic.
- Workspace/persistence behavior belongs in
repl/store, not inside GUI widgets. - Query/chase behavior changes must preserve observable semantics and existing tests.
- If a change affects persistence or serialization, consider compatibility with existing workspace behavior.
GUI Rules
- The GUI is optional and must compile cleanly only when the
guifeature is enabled. - Prefer fixing GUI bugs in
src/gui/state.rs,src/gui/panels/, orsrc/gui/visualizations/before touching core logic. - Keep GUI state transitions explicit and centralized when possible.
- Avoid hard-coding theme assumptions; UI should remain readable in the intended visual style.
- File dialog, editor, browser, inspector, console, and visualization behavior should stay consistent with REPL/workspace state.
Testing Layout Rules
- Prefer unit tests near the code they exercise when there is already a local test module.
- Put broader cross-module coverage in
tests/. - Keep regression tests close to the bug they reproduce when that is the clearest fit.
- Do not add a new testing framework if existing
cargo test, property tests, or fuzz targets are sufficient. - If you move behavior across modules, move or rewrite the relevant tests with it.
Workflow
Before coding:
- Identify whether the task is parser, elaboration, runtime, persistence, solver/query, or GUI work.
- Read the touched module and nearby tests first.
- Check whether the change should live in
core/repl/storerather than the GUI.
Implement and validate:
- Make the smallest change that solves the problem.
- Add or update tests when behavior changes or a bug is fixed.
- Run the narrowest relevant command while iterating.
- Run broader validation once the change is stable.
- Update docs if user-facing behavior or workflow changed.
Validation Commands
Use the narrowest relevant command first:
- General compile check:
cargo check - Full test suite:
cargo test - GUI compile check:
cargo check --features gui --bin geolog-gui - GUI-related tests:
cargo test --features gui - Single test/module during iteration:
cargo test <name>
Formatting:
- Prefer formatting only touched Rust files when the repository is not already fully formatted.
- Avoid reformatting unrelated files as part of a focused bugfix.
Testing Expectations
- No semantic bugfix is complete without appropriate validation.
- Parser/elaboration changes should preserve round-trip and error-reporting behavior where relevant.
- Query/chase/solver changes need explicit coverage because regressions can be subtle.
- GUI bugfixes should get a focused test when practical, especially for state transitions or regressions.
- Keep tests deterministic and focused on observable behavior.
Documentation Expectations
- Update
README.mdwhen user workflow, CLI behavior, or GUI usage changes. - Update
docs/ARCHITECTURE.mdordocs/SYNTAX.mdwhen architectural or language behavior changes materially. - If you find stale docs directly related to your change, fix them in the same patch.
Review Guidelines
Review output should be concise and focus on real defects.
P0: broken build, broken tests, data loss, or incorrect core semantics.P1: likely semantic regression, unsafe state transition, missing validation on risky changes.
Use this review format:
Severity(P0/P1)File:lineIssueWhy it mattersMinimal fix direction
Do not include style-only feedback or broad praise.