Skip to content

feat(bench): enforce runner timing policy - #1899

Merged
vincentkoc merged 3 commits into
mainfrom
feat/bench-check-gates
Sep 7, 2026
Merged

feat(bench): enforce runner timing policy#1899
vincentkoc merged 3 commits into
mainfrom
feat/bench-check-gates

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 6, 2026

Copy link
Copy Markdown
Member

What Problem This Solves

Resolves a problem where local benchmark reports described runner timings but
could not enforce a repeatable performance policy in scripts or CI. A slow,
failed, undersampled, or legacy-only group could not fail a benchmark gate.

Related: #1896

Why This Change Was Made

Adds crabbox bench check, reusing the report command's store, provider,
command-fingerprint, and recency filters. The command evaluates every matched
group against successful-sample, failure-count, runner-telemetry, and required
p95 runner-total limits.

Policy failures return exit 1 after emitting the complete human or schema-v1
JSON result. Invalid flags, durations, and stores return exit 2. Check JSON is
deterministic and omits store paths, raw records, command text, command
fingerprints, and lease or run IDs.

The reporting prerequisite in #1896 is
merged. This branch preserves its existing history and merges main at
7de92efad4149a343b317e086051365a224be32b, following the earlier reconciliation
at 3eb7469107ab33471b4be0420af521c845b9dd94. Only changelog conflicts were
resolved; the four benchmark documentation, implementation, test, and CLI
registration files are byte-identical to audited head
bc819abc4f30c20a2c7d5e79c8326b5e6818c95b.

User Impact

Developers can gate local runner performance:

crabbox bench check --since 24h --providers aws,gcp \
  --max-p95-runner-total 5s --json

The default policy requires three successful runner-total samples per group
and allows zero failed observations. Existing bench report behavior remains
descriptive and now exposes runnerTotalN.

No provider, coordinator, Worker, workflow, credential, or image-publication
behavior changes. Thanks @vincentkoc.

Evidence

  • Exact signed head: 5ea4563c1f9059b01d826fe5d4d741c62040d87b.
  • GOTOOLCHAIN=go1.26.5 go test -race -timeout=20m ./internal/cli -run 'TestBench|TestBenchmark|TestPrintBenchmark' -count=1: passed.
  • GOTOOLCHAIN=go1.26.5 go vet ./internal/cli: passed.
  • GOTOOLCHAIN=go1.26.5 bash scripts/check-docs.sh: passed, including docs-site build and all 16 docs tests.
  • GOTOOLCHAIN=go1.26.5 go build -trimpath -o <task-binary> ./cmd/crabbox: passed.
  • Actual task-only CLI in isolated temporary state: 19 policy probes passed, plus help, descriptive report compatibility, malformed/unsupported-schema input, sanitized deterministic JSON, and ledger immutability.
  • Independent source-blind behavior validation of the earlier candidate corresponding to e616acf28375b41dc3a481ca17668f929efc9b0d: all nine contract clauses passed with no findings. Synthetic-ledger invocations verified exit codes 0/1/2, threshold boundaries, failure/sample budgets, filters, all-group semantics, privacy, deterministic JSON, report compatibility, and unchanged binary/ledger hashes. Help-only clarification changed no production code. Validated binary SHA-256: 9e6c9cc9ded02bad98acf1adc656130e3ef30ada9f1751f9fc50829ef116cb0a.
  • After main advanced with unrelated artifact-failure classification changes, the focused race tests, vet, docs checks/build, and isolated CLI probes above were rerun successfully on the reconciled candidate. The benchmark files remain unchanged. Rebuilt binary SHA-256: eb8bb555ceb61e333e9f626df4ebe7f27e7b6bf4c04105740356569daf4719af; no new source-blind run is claimed for this binary.
  • Fresh autoreview of the complete resolved candidate against the explicit main base: scoped-clean at the default P0 threshold, no accepted/actionable findings.
  • git diff --check 7de92efad4149a343b317e086051365a224be32b: passed.
  • Four-file byte-identity and candidate privacy/secret scans: passed.
  • Required hosted CI must pass on the new head before merge; old-head CI is not used.

Punchcard-Session: calm-lantern-orchard-dn

@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 6, 2026, 11:09 PM ET / September 7, 2026, 03:09 UTC.

ClawSweeper review

What this changes

Adds a local benchmark check command that enforces sample, failure-count, and runner-duration limits, with structured output, documentation, and tests.

Merge readiness

Ready for maintainer review

The policy gate remains a distinct, useful addition beyond current main’s descriptive reports. The reconciled candidate resolves the previous conflict blocker, and this review found no actionable correctness or security defects.

Priority: P2
Reviewed head: 5ea4563c1f9059b01d826fe5d4d741c62040d87b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with useful regression coverage and no actionable findings; the previous reconciliation blocker is resolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a MEMBER, so ordinary contributor proof is exempt; no authority boundary changes. The captured body nevertheless reports actual CLI checks against isolated ledgers covering the changed policy evaluator and compatibility behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a MEMBER, so ordinary contributor proof is exempt; no authority boundary changes. The captured body nevertheless reports actual CLI checks against isolated ledgers covering the changed policy evaluator and compatibility behavior.
Evidence reviewed 7 items Applicable repository policy: Read the complete root AGENTS.md and verified repository ownership through origin. No additional ancestor policy applies to the changed paths, and .agents/maintainer-notes is absent. Applied provider-neutrality, testing, and release-note guidance.
Policy evaluation and compatibility: The introduced command uses the existing ledger reader, filters, grouping, and percentile calculations; evaluates every group; emits results before policy exit 1; and does not rewrite the ledger. Existing reporting defaults remain intact.
Previous blocker resolved: The four benchmark documentation, implementation, test, and registration files have identical blobs at the previous reviewed head and current head. The test merge has the exact pinned main parent followed by the exact PR head, and its resulting tree matches the PR head.
Findings None None.
Security None None.

How this fits together

Crabbox records execution timings in a local JSONL ledger and groups those observations for comparison. The new check command reads those groups and returns policy results and an exit code for scripts or CI.

flowchart LR
  A[Local timing ledger] --> B[Read and validate records]
  C[Provider and recency filters] --> D[Group matching observations]
  B --> D
  D --> E[Evaluate samples and timing limits]
  F[Policy flags] --> E
  E --> G[Text or JSON results]
  E --> H[Pass or fail exit code]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +229 net lines; tests +347 net lines The production growth implements the new command and result format, with focused policy and compatibility coverage.

Technical review

Best possible solution:

Keep enforcement opt-in through the shared benchmark aggregation path while preserving descriptive reports and existing ledger compatibility.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this adds an explicit policy-checking capability rather than repairing a reported existing-behavior failure.

Is this the best way to solve the issue?

Yes: reusing the existing reader, filters, and aggregation avoids a competing benchmark implementation, and enforcement remains an explicitly invoked command.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 7de92efad414.

Labels

Label justifications:

  • P2: This is a bounded improvement for developers enforcing local benchmark budgets, without an urgent runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a MEMBER, so ordinary contributor proof is exempt; no authority boundary changes. The captured body nevertheless reports actual CLI checks against isolated ledgers covering the changed policy evaluator and compatibility behavior.

Evidence

What I checked:

  • Applicable repository policy: Read the complete root AGENTS.md and verified repository ownership through origin. No additional ancestor policy applies to the changed paths, and .agents/maintainer-notes is absent. Applied provider-neutrality, testing, and release-note guidance. (AGENTS.md:1, 5ea4563c1f90)
  • Policy evaluation and compatibility: The introduced command uses the existing ledger reader, filters, grouping, and percentile calculations; evaluates every group; emits results before policy exit 1; and does not rewrite the ledger. Existing reporting defaults remain intact. (internal/cli/bench.go:369, 5ea4563c1f90)
  • Previous blocker resolved: The four benchmark documentation, implementation, test, and registration files have identical blobs at the previous reviewed head and current head. The test merge has the exact pinned main parent followed by the exact PR head, and its resulting tree matches the PR head. (c9fbfe385a16)
  • Still necessary on main and latest release: Pinned main registers run, record, and report but no check command. Its report remains descriptive. The benchmark implementation and command-registration blobs are identical in v0.51.0 and pinned main. The merged prerequisite feat(bench): summarize runner phase timings #1896 adds timing summaries, not policy enforcement. (internal/cli/cli_kong.go:176, 7de92efad414)
  • Behavior coverage: Read tests covering threshold equality, over-budget durations, missing telemetry, failure allowances, empty matches, all-group semantics, filters, invalid policy input, deterministic sanitized output, and command help. Tests were inspected rather than executed under this read-only review. (internal/cli/bench_test.go:819, 5ea4563c1f90)
  • Captured contributor validation: The supplied PR body reports 19 actual CLI policy probes on the reconciled candidate, including exit codes, report compatibility, malformed input, deterministic sanitized JSON, and ledger immutability. It separately identifies earlier source-blind validation and does not claim that validation was repeated for the rebuilt binary. These are contributor-reported results, not reviewer-executed tests. (5ea4563c1f90)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Andy Ye: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-06T02:17:03.686Z sha b9ce9c3 :: needs changes before merge. :: none
  • reviewed 2026-09-06T03:19:19.891Z sha b9ce9c3 :: blocked before merge. :: none
  • reviewed 2026-09-06T15:57:00.654Z sha bc819ab :: needs changes before merge. :: none
  • reviewed 2026-09-06T16:20:43.839Z sha bc819ab :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T16:23:55.364Z sha bc819ab :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T02:40:18.128Z sha e616acf :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T02:51:45.690Z sha e616acf :: blocked before merge. :: none

Base automatically changed from feat/bench-source-summary to main September 6, 2026 03:15
@vincentkoc
vincentkoc force-pushed the feat/bench-check-gates branch from b9ce9c3 to bc819ab Compare September 6, 2026 15:54
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Rebased onto current main at 369574fea098e70038ed4cf53de7fafbfaadc154.
Please review exact signed head bc819abc4f30c20a2c7d5e79c8326b5e6818c95b.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc marked this pull request as ready for review September 6, 2026 16:18
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The exact reviewed head remains bc819abc4f30c20a2c7d5e79c8326b5e6818c95b.
The PR is now ready for review, all hosted checks are complete, and GitHub reports MERGEABLE/CLEAN.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Merge current main into the existing benchmark policy branch without rewriting
its history. Resolve only the changelog conflict, retaining the benchmark entry
under Unreleased with its PR link and verified contributor credit.

The benchmark documentation, implementation, tests, and CLI registration remain
byte-identical to the previously reviewed head.

Related: #1899

Punchcard-Session: calm-lantern-orchard-dn
Merge main at 7de92ef without
rewriting the benchmark policy branch. Preserve both Unreleased entries.
The four benchmark documentation, implementation, test, and registration
files remain byte-identical to the audited contributor head.

Related: #1899
Thanks @vincentkoc.

Punchcard-Session: calm-lantern-orchard-dn
@vincentkoc
vincentkoc merged commit 5a2586c into main Sep 7, 2026
25 checks passed
@vincentkoc
vincentkoc deleted the feat/bench-check-gates branch September 7, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant