Code governance
- Status: active
- Audience: contributors, maintainers
- Authority: repository code-organization policy; subordinate to QED formal specification, current code/tests, and Documentation governance
- Scope: package layering, alias entrypoints, source responsibilities, and code-change documentation obligations
- Last reviewed: 2026-10-08
This document defines the code governance rules for the QED repository. It adds no new semantic specification layer; it only fixes package boundaries, alias entry points, and documentation write-back obligations, so that the code structure does not drift over time.
Layering
The default dependency direction is fixed as:
kernel -> logic/elab -> parser -> tactics -> prover -> cmd
Governance requirements:
kernelis the only theorem-construction boundary.logicmay only provide checked helpers, definition/unfold, replay helpers, and theorem catalog organization; it must not add new primitive authority.parseris only responsible for textual syntax, normalization, resolution, and lowering; it must not depend directly on tactics execution objects.tacticsis only responsible for goal-state transformation and replay orchestration; it must not write back into parser semantics.proveronly orchestrates parser/tactics/kernel and produces structured diagnostics; it must not become a new logical authority.cmdstays the thinnest outer layer; it only consumes stable facades and adds no low-level knowledge.
research_rewrite sits outside this chain: it is a research-only prototype that depends only on kernel
and logic, and no shipped package depends on it. cmd is an executable package (pkgtype(kind: "executable")
in its moon.pkg), so no other package can import it.
If a change requires a reverse dependency, treat it as a design problem by default; prefer introducing a neutral data structure or an explicit bridge over a direct cross-layer reference.
Alias entry points
Each package has exactly two kinds of official alias entry points:
alias.mbtProduction source entry point.alias_test.mbtBlackbox test entry point.
The constraints are:
alias.mbtonly exposes the stable symbols that the package’s production source actually needs.alias_test.mbtmust first mirror the production exports ofalias.mbt, then add test-only imports.alias_test.mbtis not a second public API; it must not follow an export philosophy different from the production entry point.- The header comment of an alias file must state the scope of the entry point and its maintenance rules.
- An alias file must not be used as an unbounded re-export table for lower-layer symbols.
- When a blackbox test references symbols of its own package,
alias_test.mbtmust import them explicitly withusing @<package> {...}(MoonBit’stest_unqualified_packagerule); tests must not rely on implicit imports. kerneldepends on no other QED package, so it has noalias.mbt, only analias_test.mbtthat lists the package symbols its tests use.
Source responsibilities
A single file or module should, as far as possible, carry only one primary responsibility:
- pure data objects and accessors
- pure lowering / normalization / rendering
- replay / orchestration
- corpus / mapping / fixtures
The following cases should be split first:
- orchestration logic and error rendering stay mixed in the same file over the long term
- parser-side lowering constructs tactics objects directly
- a façade-layer file gradually turns into a cross-layer catch-all entry point
The first governance patterns currently in place in this repository include:
- parser outputs a parser-owned
ParsedGoal, which the upper layer explicitly bridges totactics.Goal - prover keeps its orchestration role, but continues to separate diagnostic rendering and corpus data from the main execution path
Documentation obligations
When a code change affects any of the following, the documentation must be updated in step:
- public capability claims
- package responsibilities or layering boundaries
- alias entry-point semantics
- failure semantics or structured diagnostic fields
Default maintenance order:
- Code and tests
- User manual
- The package pages of the affected packages (
api/,design/,tutorial/) - Specification conformance
README.mdandCHANGELOG.md- Workspace audit (2026-04-18) (only when the point-in-time conclusions change)
Review checklist
On submission and review, check at least:
- whether new dependencies follow the established layering
- whether
alias.mbt/alias_test.mbtare still the single official entry points - whether the responsibilities of parser/tactics/prover are being coupled together again
- whether
.mbtichanges match the intended public boundary - whether the documentation reflects the new shipped state in step