This repository is mostly Scala 3 compiler and tooling code. These are the coding and iteration expectations for day-to-day development.
-
Keep public APIs immutable.
- Do not expose mutable collections or mutable state from public APIs.
- Method-local mutation (
var, mutable builders, arrays) is acceptable when it clearly improves performance or keeps a hot path simple. - Encapsulate mutation and return immutable values.
-
Encode invariants in types ("parse, don't verify").
- Prefer representing valid states in types over repeating runtime assertions.
- Use Scala 3 features (opaque types, enums, ADTs, non-empty types) to express checked invariants.
- Parse/validate at boundaries, then pass strongly typed values internally.
-
Compile frequently during development:
sbt "coreJVM/test:compile"- This compiles both main and test code in
core, which covers most compiler logic.
-
Run focused tests while iterating:
- Use
testOnlyfor the suites you are touching. - Run
sbt "coreJVM/test; cli/test"before opening a PR for most Scala-only changes.
- Use
-
Expand test scope based on what changed:
- If CLI behavior changed, also run
./test_cli.sh. - If docs/paradox generation changed, run
sbt "doc; paradox". - If C/Python/Node codegen or runtime paths changed, run the full CI matrix in
.github/workflows/ci.yml(not only JVM tests).
- If CLI behavior changed, also run
- Team goal: at least 95% overall coverage, and ideally 100% on changed lines in a PR.
- Use the same coverage entry point as CI:
sbt "coverage; clean; coreJVM/test; cli/test; coverageReport"
- Check
.github/workflows/ci.yml,.github/workflows/codecov_main.yml, andcodecov.ymlfor current coverage/reporting behavior.
- The Scala build is strict: warnings are treated as errors (
-Werror) with additional warning flags inbuild.sbt. coreis compiled with-Yexplicit-nulls.- Generated ScalaPB sources in
src_managedhave a narrow warning suppression; handwritten code stays under strict warning rules. - Agents should not run scalafmt, but should strive to write code that matches the style in the files they are editing.
- Do not use fully qualified names in normal code or tests; import symbols at the top of the file.
- Prefer
cats.data.ValidatedNecovercats.data.ValidatedNelfor better asymptotic performance.