Skip to content

feat(go): codeupipe for Go, the fourth runtime - #27

Merged
JoshuaWink merged 2 commits into
mainfrom
feat/go-runtime
Oct 29, 2026
Merged

JoshuaWink merged 2 commits into
mainfrom
feat/go-runtime

Conversation

@JoshuaWink

Copy link
Copy Markdown
Member

What

The Go runtime, packages/codeupipe-go, written to the contract in
conformance/API.md. It has no dependencies, and it passes all 30
conformance cases (python conformance/run.py go:run).

  • The eight primitives. Payload, Filter, Predicate, Valve
    (AddValve), Tap, Hook, State and Pipeline. Each step method and
    Run take a context.Context first. The Pipeline gives it to each step
    and does nothing else with it.
  • A type of your own. Each primitive has a generic form, such as
    FilterOf[P] and PipelineOf[P]. Filter is FilterOf[*Payload], so it
    is the same type, not a second one.
  • Refused at compile time. A function as a step, a Tap that is a Filter,
    AddValve with its arguments in the wrong order, and a step for another
    type do not compile. refused_test.go builds each shape and checks the
    error.
  • The conformance runner in conformance/runners/go/, with one file for
    each step type. It reads JSON with encoding/json and runs with
    GOPROXY=off.
  • run.py and bench.py have a go:run target. A machine with no go
    leaves it out. The Go benchmark baseline has its own key.
  • CI: a go job for gofmt, vet, staticcheck, go test -race, the
    example, go:run, and the tests on Go 1.22.
  • Docs: conformance/API.md has a Go column and notes. It also fixes a
    sentence that was cut in its Rust notes (from A Rust runtime, written to the contract #18). MATRIX.md and
    BENCH.md are regenerated. docs/go-plan.md has the plan and its
    decisions.

How it is checked

  • go test -race ./..., go vet, gofmt and staticcheck are clean on Go
    1.22.12 and 1.25.0.
  • The full matrix passes: every target passes every case, and the Python
    suite passes (581 tests).
  • The judge catches a broken runtime. With a Tap failure not recorded, 4 cases
    fail. With the State of a run that did not start last kept, 1 case fails.
    With OnError not sent for the pipeline, 2 cases fail.

Not in this PR

  • No linter and no compiler for Go yet. The plan has them as phases 3 and 4.
  • No version is tagged. The package is version 0.1.0 and is used from main.

Benchmark

Apple Silicon, µs per run. Lower is better.

scenario python:run rust:run go:run
10 filters 4.79 0.28 0.55
50 inserts 15.03 4.40 2.15

The numbers are a snapshot. CI measures them and does not compare them.

🤖 Generated with Claude Code

JoshuaWink and others added 2 commits October 29, 2026 11:26
packages/codeupipe-go is the Go runtime, written to conformance/API.md
with no dependencies. A Filter, Predicate, Tap and Hook take a
context.Context first and the data second. Payload is the default; each
primitive also has a generic form (FilterOf[P]) for a type of your own,
and the short name is the same type.

What the contract refuses is a compile error: a function as a step, a Tap
that is a Filter, AddValve with its arguments in the wrong order, a step
for another type. refused_test.go builds each shape and checks the error.

Tests are ported from packages/codeupipe-ts, with the ones that only Go
can express: ctx reaches each step, 50 runs in goroutines keep their own
State, and a nil step is refused when it is added. go test -race, go vet,
gofmt and staticcheck are clean on Go 1.22.12 and 1.25.0.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
go:run passes all 30 conformance cases, with nothing unsupported, and
every other target still passes in the same run of conformance/run.py.

- conformance/runners/go: the runner, with one file for each step type in
  cup_ops/, named as the TypeScript and Rust runners name them. It reads
  and writes JSON with encoding/json, and runs with GOPROXY=off.
- run.py and bench.py: the go:run target. Go is left out of a run on a
  machine with no go. The Go baseline is kept under its own key.
- CI: a go job for gofmt, vet, staticcheck, go test -race, the example,
  go:run, and the tests again on Go 1.22.
- conformance/API.md: a Go column and notes. Also fixes a sentence that
  was cut in the Rust notes (since #18).
- MATRIX.md and BENCH.md regenerated from these runs.
- docs/go-plan.md: the plan, with its decisions and the two phases.

Checked by breaking the runtime on purpose: not recording a Tap failure
fails 4 cases; keeping the State of a run that did not start last fails
1; not sending OnError for the pipeline fails 2.

Benchmark, Apple Silicon: a 10-step run takes 0.55 µs for Go, 0.28 for
Rust, 4.8 for python:run. Sizing the executed list once in State took 10
no-op steps from 356 to 217 ns.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@JoshuaWink
JoshuaWink merged commit d59d783 into main Oct 29, 2026
14 checks passed
@JoshuaWink
JoshuaWink deleted the feat/go-runtime branch October 29, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant