Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Agents
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can delete it if it is not necessary.


This file contains instructions for agents working on this project.

## Mindset

**sbt is slow—minutes per compile/test.** Wasted cycles waste hours.

- **Batch edits.** Do not: edit → compile → edit → compile. Do: edit everything → compile once.
- **Design tests with code.** Cover every statement and branch; if coverage reveals gaps, fix all at once.
- **Extreme ownership.** "Optional" means required; do the work completely.

## Commands

```bash
# Discover project names and Scala versions
sbt projects
sbt e2eJVM2_12/test
sbt e2eJVM2_13/test
sbt e2eJVM3/test
```

## Workflow

Phases 1-3 repeat until verify passes. Phase 4 runs once at the end.

### 1. Edit
Batch code and tests together. For large changes, split into batches—each batch includes its tests.

### 2. Fast Loop
One project, one Scala version: get `<project>/test` green. Default Scala 3; use Scala 2 if editing `scala-2/` sources. No coverage here.

### 3. Verify
Enter only when fast loop is green. Run in order:

1. **Coverage** — Scala version you developed with
2. **Cross-Scala** — the other Scala version, same project
3. **Cross-platform** — other platform projects, if cross-built and you touched shared/ or platform sources

If any step fails: return to phase 1, fix, get green in phase 2, rerun the failing step.

### 4. Format

Run once after verify passes.

## Boundaries

### Always
- Follow workflow phases in order
- Batch edits; keep sbt runs scoped to one project
- Update AGENTS.md if you find errors or gaps
- Document new data types in `docs/`; update existing docs when behavior changes
- **README.md is auto-generated.** Never edit `README.md` directly. Edit `docs/index.md` instead, then run `sbt --client generateReadme` to regenerate `README.md`.

### Ask First
- Adding dependencies (even test-only)
- Creating or removing subprojects
- Any repo-wide test or coverage run
- **New modules:** When adding a new module, update the `testJVM`, `testJS`, `docJVM`, and `docJS` command aliases in `build.sbt`.

### Never
- Use coverage as starting point for test design (think first, verify with coverage)
- Iterate coverage in tiny steps (if gaps exist, fix ALL at once, then rerun once)
- Cheat: delete code/tests, lower thresholds, or game metrics to appear compliant
- Retest after formatting (unless formatting broke the build)
- Use `sbt test` (repo-wide) when `sbt <project>/test` works
- Call work "optional" or "good enough" to justify not doing it

## Benchmarks

To run the benchmarks, navigate to the `benchmarks` directory and run the following command:

```bash
amm run_benchmarks.sc --scalapb <scalapb_version> --scala <scala_version> --java <true|false> --mode <fast|full> --benchmarks <benchmark_name>
```

For example:

```bash
amm run_benchmarks.sc --scalapb 0.11.20 --scala 2.13.18 --java true --mode fast --benchmarks LargeStringMessage
```
17 changes: 17 additions & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Benchmarks

## How to run

Execute `run_benchmarks.sc` with [ammonite](https://ammonite.io/):

```bash
amm run_benchmarks.sc --help
```

Example:

```bash
amm run_benchmarks.sc --scalapb 0.11.20 --scala 2.13.18 --java false
```

Runs all benchmarks for scalapb version 0.11.20 and Scala version 2.13.18 without java benchmarks.
6 changes: 4 additions & 2 deletions benchmarks/build.sbt
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
val ProtobufJavaVersion = "3.11.1"
val ProtobufJavaVersion = "4.32.0"

val Scala213 = "2.13.1"

val Scala212 = "2.12.10"

val Scala3 = "3.3.7"

lazy val root = project
.in(file("."))
.enablePlugins(JmhPlugin)
.settings(
publish / skip := true,
crossScalaVersions := Seq(Scala213, Scala212),
crossScalaVersions := Seq(Scala213, Scala212, Scala3),
scalaVersion := Scala213,
Compile / PB.protocVersion := "-v" + ProtobufJavaVersion,
Compile / PB.targets := Seq(
Expand Down
6 changes: 5 additions & 1 deletion benchmarks/project/TestNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ object TestNames {
"IntVector",
"MessageContainer",
"SimpleMessage",
"StringMessage"
"StringMessage",
"LargeStringMessage",
"LargeNestedStringMessage",
"LargeByteMessage",
"LazyFieldsStringMessage"
)
}
4 changes: 2 additions & 2 deletions benchmarks/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
val ScalapbVersion = sys.env.getOrElse("SCALAPB", "0.10.0-SNAPSHOT")
val ScalapbVersion = sys.env.getOrElse("SCALAPB", "0.11.20")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.4")

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.27")
addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.33")

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.7")

Expand Down
Loading