Project-specific instructions. AGENTS.md defines how work is done in this repository; this file defines what the project is, which sources are authoritative, and what to optimize for when goals compete.
Solvik is a small, statically typed language that transpiles to standalone Java 25 source. The compiler is a Java 25 application built with the Maven wrapper in this repository. Generated programs depend only on the JDK and the Java libraries they bind explicitly: there is no Solvik runtime jar, no interpreter loop, and no reflective dispatch.
The language supports signature-based overloading, nominal traits with stateless defaults,
native Java bindings, modules that map to Java packages, and a packaged standard library.
example.sol and include.sol exercise the implemented surface; the packaged library lives
under src/main/resources/solvik/.
These priorities are ordered. When they compete, the lower number wins:
- Correctness and consistency of the Solvik language.
- Performance of the Solvik language and its generated Java code.
- Clean transpiled Java output.
A lower-priority improvement never justifies a higher-priority regression. Do not trade observable behavior or language consistency for speed, and do not trade runtime cost for prettier output.
LANGUAGE.mdis the language contract. Where code and documentation disagree, the code wins and the documentation is the bug: fix the drift rather than letting either side stand. A deliberate language change updatesLANGUAGE.mdand the focused regression together.- A program means the same thing from the source AST and its generated Java, whether it runs from the cache or from a fresh compile. The backend has one lowering path and one renderer.
- Compile-time rejection, stable diagnostics (
SOL-L###,SOL-P###,SOL-T###,SOL-I###,SOL-R###), and runtime abort behavior must match the documented rules. No silent coercion, no undocumented acceptance, and no documented rule left unimplemented. - Correctness includes preserved contracts: null and untyped-slot behavior, numeric promotion
and overflow, array bounds, checked Java exceptions surfacing as
SOL-R011, cache-key completeness, and the reservedsolvikroot namespace. - Cover negative, boundary, null, overflow, and failure paths — not just the happy path — before calling a feature complete.
- Generated programs run directly on the JDK. Do not add a Solvik runtime jar, an interpreter loop, reflection-based dispatch, or per-operation helper calls where direct Java lowering has the same semantics.
- Prefer the cheapest lowering that preserves Solvik semantics: direct field access,
List.get/List.setfor arrays, unboxed primitive arithmetic where the checker has fixed the carrier, no avoidable boxing or allocation, and temporaries only when evaluation order requires them. - Emit support code only for what the program actually reaches. Helper blocks are embedded source selected by recorded uses, not an installed runtime.
- Performance work needs evidence: inspect the emitted Java, use output-shape tests or measurements, and state the observed effect. Do not claim a speedup that was not measured.
- Compiler and launcher turnaround (caching, incremental rebuild) matters for iteration, but it never outranks correctness or cache-key safety.
- Generated Java is a product: readable, deterministic, idiomatic, and warning-free under the
project's
-Xlint:all -Werrorgate. Every emitted file must compile standalone withjavac --release 25and the supplied classpath only. - Keep output minimal: no unused support members, imports, wrappers, casts, or dead
scaffolding; stable generated names; no redundant
toStringOf-style layers. Support code is the transitive closure of what is used. GeneratedOutputOptimizationTestpins the emitted shape. Change it deliberately when the shape genuinely improves, never to accommodate accidental churn.- Formatting and cleanup changes must be behavior-preserving and must not add runtime cost. If a cleaner form is slower or less faithful to the semantics, keep the current form and record why.
- A correctness fix that costs performance is acceptable; report the cost and note any follow-up rather than weakening the fix.
- A performance change that alters observable semantics is rejected. If the language itself should change, that is a contract decision requiring explicit authorization and a spec update first.
- An output-cleanliness change that would change behavior or slow the generated code is not made. Clean output is valuable, but it is the last tiebreaker.
- If a genuine conflict cannot be resolved within the requested scope, surface the trade-off and the options instead of silently choosing one.
example.sol must use and exercise all Solvik language constructs, syntax, and documented
features — not a convenient subset. It is the executable inventory of the language surface:
if Solvik can express it, example.sol (with include.sol for included declarations)
demonstrates it, and ./solvik run example.sol must run it end to end.
- Adding or changing a language construct, syntax form, declaration kind, operator, literal form, standard-library type, or binding shape updates the corpus in the same change.
- Prefer live, observable use over dead declarations: the construct should execute and its effect should be visible in the program's output or behavior where the language allows it.
include.solexists to exercise includes, aliases, and cross-file declarations; it is not a place to park unused constructs.- Negative and diagnostic cases stay in the test suite; the corpus demonstrates valid language surface, while tests prove rejection and failure behavior.
| Source | Authority |
|---|---|
LANGUAGE.md |
Current language behavior; code wins where they disagree |
JAVA_BACKEND.md |
Java representation, lowering, and code-generation contract |
README.md |
Build, run, CLI, caching, and repository overview |
src/main/resources/solvik/**/*.sol |
Packaged standard library, loaded into every program |
example.sol, include.sol |
Language corpus: must exercise the complete implemented surface |
plans/*.design.md, plans/*.impl.md |
Decision and execution records for past features |
AGENTS.md, DESIGN.md, IMPLEMENT.md |
Engineering workflow; not project behavior |
Planning documents record decisions; they do not prove the implementation still matches them. Verify important claims against current source and tests.
- JDK 25 is required.
./mvnw verifyis the definition of a healthy build and runs in CI (.github/workflows/build.yml). - Gates:
-Xlint:all -Werrorfor main and test sources, Surefire unit tests, Failsafe packaged-JAR integration tests, and JaCoCo thresholds of 85% instruction and 80% branch coverage. - Focused checks come first, then the broader gate. The language-consistency suite compiles and runs generated Java with an empty dependency classpath.
./solvik run example.solis the end-to-end smoke test;--keep-sourcesretains the generated.javafiles in the cache for inspection.- Java sources use four-space indentation, LF line endings, and an ASCII-sorted import block
after any
import staticlines (.editorconfig). - Behavior changes update the authoritative documentation and add the focused regression that
proves them; language-surface changes also update
example.solper the corpus rule above. Do not edittarget/output by hand.
- No Solvik runtime jar. A generated program needs the JDK plus only the JARs supplied with
--cp, and resolves native bindings at compile time. - Packaged
.solresources are the standard-library registration mechanism: adding a file undersrc/main/resourcesis the only step, and packaged source text is part of the compilation-cache key. - The root
solvikmodule is compiler-owned; only packaged library resources may declare it. - Diagnostics keep their stable codes and actionable source/caret rendering. CLI exit codes
stay
0success,1compile error or runtime abort,2bad usage. - Source-level immutability,
pub, andmutare Solvik semantic rules even where emitted Java does not yet enforce them at the Java boundary.
- Substantial changes, contract/interface/persistent-data changes, and language-surface
changes use a design plan and an implementation plan under
plans/perAGENTS.md. A small, well-bounded fix may be implemented directly when requested. - Preserve unrelated user edits and untracked work. Do not stage, commit, push, install, or deploy unless the user asks.