Repository navigation
fix: mark incomplete run reports and refuse them in diff - #44
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The stream termination logic can suppress cancellation or deadline errors when stop closes, causing interrupted measurements to be written unmarked and accepted by diff.
1 open issue
What changed in this PR
Follow-up to #43 that makes command measurements safer to compare: partial run reports are preserved for diagnosis, marked incomplete, and rejected by diff.
Changes:
- Adds completeness metadata to results, JSON reports, and text output.
- Preserves partial results on collection errors and rejects incomplete comparisons with exit code 2.
- Adjusts simultaneous stop/stream-end handling and adds regression tests and documentation.
| File | Description |
|---|---|
run.go |
Writes incomplete reports on collection errors and updates exit-code priority. |
run_test.go |
Tests incomplete reports and replacement of stale output files. |
README.md |
Documents incomplete measurements and comparison rejection. |
diff.go |
Adds incomplete-report help and error guidance. |
diff_test.go |
Tests CLI rejection of incomplete reports. |
ci/watcher.go |
Preserves partial results and adjusts stream-end handling. |
ci/watcher_internal_test.go |
Tests stop-state decisions and partial-result retention. |
ci/json.go |
Encodes and decodes completeness metadata. |
ci/json_test.go |
Includes completeness metadata in round-trip coverage. |
ci/diff.go |
Rejects comparisons when either report is incomplete. |
ci/diff_test.go |
Tests rejection of incomplete before and after reports. |
ci/ci.go |
Adds the incomplete reason and displays it in text reports. |
ci/ci_test.go |
Tests conditional display of the incomplete reason. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The test relies on a 50 ms sleep rather than explicit synchronization before closing stop, allowing goroutine scheduling to produce a nil endErr and intermittent failures.
1 open issue
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because the documented report-writing guarantee conflicts with subscription-failure behavior and could lead users to trust a stale output file.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
|
Re: the review summary note that a stale |
|
Re: the review summary note that a flag-parsing failure can leave a stale
|


Summary
Follow-up to #43, addressing the Copilot review that arrived after it was merged. A
runreport that may have missed events is now written, marked incomplete, and refused bydiff, so a partial measurement can no longer show up as a clean improvement.Changes
fix: mark incomplete reports and reject them in diffci.Result.Incomplete/ JSONincomplete(omitted when empty) holds why a measurement may have missed events. The text report shows anIncomplete:line.runsets it when collection ends withErrStreamEndedorErrDrainLimit.ci.DiffreturnsErrIncompleteReportwhen either report is marked, andsql-tap diffexits 2. There is intentionally no override flag: incomplete numbers cannot serve as evidence. The report file is kept for diagnosis.version: 1.fix(ci): do not report a stream end as early once stop is closedselectcould pick the end of stream first whilestopwas already closed, returningErrStreamEndedand failing a complete measurement with exit 2.streamEndErr, which checks whetherstopis actually closed. It is unit-tested directly because theselectordering cannot be forced reliably from a test; the closed-stop case fails with the previous logic.fix: write partial run reports marked incomplete on collection errorsUnavailableused to discard the captured events and return before writing any report, which could leave a stale-outfile from an earlier run.Watcher.Collectnow returns the partial result with the error, andrunwrites the report marked incomplete for any collection error.Verification
go test -race ./...passesgolangci-lint run ./...: 0 issuesstreamEndErrclosed-stop case, partial result on receive error)