fix(metrics): exclude dry-run shadow actions from the gate-outcome breakdown - #9791
Conversation
…eakdown
`listGateOutcomeAuditEventRollups` counted every agent.action.{merge,close,hold}
row whose outcome is a terminal disposition, but a dry-run shadow lands in exactly
that set: agent-action-executor rewrites its outcome to "completed" and the mode
discriminator lives only in metadata.mode. So a repo's gate-outcome breakdown
inflated its auto-merge/close/hold counts with shadow actions that never touched
a PR — and a repo whose window held only dry-run actions produced a zeroed-rate
report instead of the "no events" summary.
Add the same dry-run exclusion the public accuracy trend already applies
(loadReversalDayRows) as a `sql` fragment inside the existing `and(...)`:
`coalesce(json_extract(metadata_json, '$.mode'), 'live') <> 'dry_run'` — same
COALESCE default of 'live' so a legacy row without a mode key is still counted.
The pure builders and the rollup type are unchanged; the exclusion is in the query.
Closes JSONbored#9694
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-29 09:05:36 UTC
Review summary Nits — 4 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. Decision record
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9791 +/- ##
===========================================
- Coverage 90.30% 77.24% -13.07%
===========================================
Files 913 283 -630
Lines 113595 61437 -52158
Branches 26963 9134 -17829
===========================================
- Hits 102584 47454 -55130
- Misses 9682 13648 +3966
+ Partials 1329 335 -994
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Held for manual review: the gate and required CI are green, but GitHub reports this pull request's mergeable state as |
What & why
The gate-outcome breakdown's contract is "auto-merged, auto-closed, and held/manual terminal dispositions only". But
listGateOutcomeAuditEventRollups(src/db/repositories.ts) counted everyagent.action.{merge,close,hold}row whose outcome is terminal — and a dry-run shadow lands in exactly that set:agent-action-executor.tsrewrites a dry-run's outcome to"completed", and the only discriminator ismetadata.mode = "dry_run". The rollup query groups by(eventType, outcome)and never readsmetadata_json, so shadow actions inflated the auto-merge/close/hold counts, and a repo whose window held only dry-run actions produced a zeroed-but-nonzero-total report instead of the "no events" summary.The fix
Add the same dry-run exclusion the public accuracy trend already applies (
public-accuracy-trend.ts'sloadReversalDayRows) as asqlfragment inside the existingand(...)— not a raw-string rewrite:Same
COALESCEdefault of'live', so a legacy row without amodekey is still counted.classifyGateOutcomeAuditBucketandbuildGateOutcomeBreakdownkeep their pure{ eventType, outcome, count }shape — the exclusion belongs in the query, exactly as it does for the accuracy trend. Nomodefield added to the rollup type; no change to whatagent-action-executor.tswrites.Tests (
test/unit/gate-outcome-audit-rollups.test.ts)mode) close are counted — the merge count is 1, not 2 (fails onmain).[](fails onmain) — which, viabuildGateOutcomeBreakdown([])(already covered), yieldstotal: 0and the "No gate-outcome audit events…" summary rather than a zeroed report.Validation
npm run typecheckgreen; the rollup suite green.git diff --check <base> HEADclean; diff is two files, no route/schema/migration change (a pure query predicate).Closes #9694