Skip to content

feat(just): run the Go unit tests under -race in just check #52

Open

Description

@pascalandy

The problem (CMO)

Agent role: COD in s3, owner of the M01+M02 stack

Area: Automated checks

Problem Statement: As an agent working in pascalandy/nicely, I want just check to run the Go unit tests under the race detector, so that a data race between goroutines fails a check before a reviewer has to hunt for it.

REF: #47

Analogy

A smoke alarm that beeps only when you open the oven door: smoke can fill the kitchen while the door stays shut.

  • What should happen: the alarm watches the whole room, so smoke sets it off whether or not someone opens the oven
  • What happened in ✨ feat: sdk: run a Go extension from one value #47: a reviewer wrote a separate probe and ran it with -race to see the problem. just check stayed green before and after the fix

What we saw

What exists today

just test runs go test ./... ./testdata/extensions/... without -race. On main (c6ccccb), go test -race -count=1 ./sdk/... ./internal/... passes in about 3 seconds, so the unit tests already pass under the race detector, for a small cost. The SDK and the runner use goroutines for handlers, pipe drains, and signals, and later work adds more, such as #49 in M05.

Start, Stop, Continue (FMO)

  • Start: just test also runs go test -race ./sdk/... ./internal/.... A unit test covers a handler that keeps writing after the timeout, so the race of ✨ feat: sdk: run a Go extension from one value #47 fails it
  • Stop: relying on a reviewer's one-off -race probe to find a goroutine race and to prove its fix
  • Continue: the testscript scenarios run without -race, so the timing-sensitive cancellation cases, such as the 25 ms settle and the 15 seconds of cleanup, keep their speed and behavior

How we'll know it works

  1. Today: add the unit test, revert the mutex in sdk/command/answer.go locally, and run just check: it passes
  2. After the change: the same revert makes just check fail with WARNING: DATA RACE. With the mutex, it passes
  3. Nothing else changes: the scenarios keep their run time and results, and just check grows by a few seconds

👨🏻‍🍳 For the agent

👨🏻‍🍳 Details
  • Race site before the fix: Output.Write sets err, and Output.Err reads it, in sdk/command/answer.go. handle in sdk/extension/extension.go reaches the read after time.After(runner.Cleanup + runner.DrainLimit), while the handler goroutine still runs. ✨ feat: sdk: run a Go extension from one value #47 fixed it with a sync.Mutex that guards err alone
  • The reviewer's probe: a handler that waits for SIGTERM, then writes to a stdout pipe whose reader is closed and never returns, with runner.Cleanup shortened
  • Two test shapes: one goroutine writes to a closed pipe through Output while another calls Err, which is small but proves nothing about handle; or a seam in sdk/extension that runs Main with given files, which proves the timeout path
  • Keep -race off the testscript binary at first. The scenarios re-exec the test binary, so -race there would slow every scenario and stress the timing-sensitive cancellation cases
  • -race needs cgo and a C toolchain. It ran on Linux in this session. Check macOS before wiring it into just check. Release builds are unaffected, since only the tests use -race
  • Blast radius: the test recipe of the justfile, and one new test file

by Opus-5.5 via Claude Code

Activity

  1. self-assigned this
    on Oct 12, 2026
  2. added
    1-needs-triageScope, approach, or direction needs evaluation
    2-type:taskSupporting work such as maintenance, documentation, refactoring, or verification
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

1-needs-triageScope, approach, or direction needs evaluation2-type:taskSupporting work such as maintenance, documentation, refactoring, or verification

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions