Skip to content

feat(metrics): Add rework rate CLI command (5th DORA metric)#381

Closed
tamirdresher wants to merge 1 commit intobradygaster:mainfrom
tamirdresher:feat/rework-rate-metric
Closed

feat(metrics): Add rework rate CLI command (5th DORA metric)#381
tamirdresher wants to merge 1 commit intobradygaster:mainfrom
tamirdresher:feat/rework-rate-metric

Conversation

@tamirdresher
Copy link
Copy Markdown
Collaborator

Summary

Adds a \squad rework\ CLI subcommand that measures PR rework rate — the emerging 5th DORA metric — by analyzing merged pull requests for post-review revision patterns.

What is Rework Rate?

Rework Rate measures what percentage of code changes require revision after initial review. It captures:

  • Review Cycles — How many times a PR goes through changes-requested → push → approval loops
  • Post-review commits — Commits pushed after the first review
  • Rejection Rate — Percentage of PRs receiving \changes-requested\
  • Rework Time — Calendar time spent in rework

Changes

File Description
\lib/rework.js\ Pure calculation functions for PR rework analysis (zero-dep)
\index.js\ \
ework\ CLI subcommand with --days, --limit, --json\ flags
\ emplates/skills/rework-rate/SKILL.md\ Agent skill template for rework analysis
\ est/rework-rate.test.js\ 10 unit tests for calculation logic
\package.json\ Include \lib/\ in published files

Usage

\\�ash

Analyze last 30 days (default)

npx github:bradygaster/squad rework

Custom period and limit

npx github:bradygaster/squad rework --days 7 --limit 50

Machine-readable JSON output

npx github:bradygaster/squad rework --json
\\

Design Decisions

  • Zero dependencies — Uses only Node.js built-ins + \gh\ CLI (matching squad convention)
  • Separated concerns — Pure calculation logic in \lib/rework.js\ for clean testing
  • Skill template — Includes a rework-rate skill template so agents understand the metric
  • Follows existing patterns — Same structure as \watch\ subcommand (execSync + gh CLI)

Tests

All 96 tests pass (10 new + 86 existing).

Future Work

This is Phase 1 of the rework rate integration. Future phases could add:

  • Azure DevOps adapter support (ADO has native PR iterations API)
  • Ralph integration for periodic reporting
  • AI code retention rate tracking
  • OpenTelemetry metric emission

Add 'squad rework' subcommand that analyzes PR rework rate by examining
merged PRs for post-review commits, review cycles, and changes-requested
patterns using the gh CLI.

Changes:
- lib/rework.js: Pure calculation functions for PR rework analysis
- index.js: 'rework' CLI subcommand with --days, --limit, --json flags
- templates/skills/rework-rate/SKILL.md: Agent skill for rework analysis
- test/rework-rate.test.js: 10 unit tests for calculation logic
- package.json: Include lib/ in published files

The rework command outputs:
- Per-PR rework rate (% of commits after first review)
- Review cycle count (changes-requested → approved loops)
- Aggregate rejection rate and average rework time
- Color-coded health indicators (green/yellow/red)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tamirdresher added a commit to tamirdresher/squad that referenced this pull request Mar 15, 2026
…ORA metric

Add PR rework rate as OTEL metrics in squad-sdk, following the exact
pattern of existing metrics (bradygaster#261-bradygaster#264) in otel-metrics.ts.

New modules:
- runtime/rework.ts: Pure calculation module with typed interfaces
  (PrInfo, PrReview, PrCommit, PrReworkResult, ReworkSummary) and
  functions (calculatePrRework, calculateReworkSummary)
- otel-metrics.ts bradygaster#265 section: Four OTEL instruments
  - squad.rework.rate (Gauge) — rework rate percentage
  - squad.rework.cycles (Histogram) — review cycles per PR
  - squad.rework.rejection_rate (Gauge) — rejection percentage
  - squad.rework.time_ms (Histogram) — time spent in rework
- Export functions: recordReworkMetrics(), recordReworkSummary()

Includes 19 Vitest tests (9 for calculatePrRework, 4 for
calculateReworkSummary, 6 for OTEL metric recording).

Replaces bradygaster#381 (CLI command approach) with proper SDK-level OTEL metrics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bradygaster added a commit that referenced this pull request Mar 15, 2026
Cherry-pick of tamirdresher's PR #381 onto dev.
Adds `squad rework` CLI subcommand + lib/rework.js calculation module + skill template.

Co-authored-by: Tamir Dresher <tamird@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster
Copy link
Copy Markdown
Owner

Cherry-picked to dev at c58640f 🎉

Merged alongside your OTEL metrics PR (#415, already squash-merged to dev). Both contributions are now on dev — the CLI command from this PR and the SDK-level OTEL metrics from #415. Thanks Tamir!

@bradygaster
Copy link
Copy Markdown
Owner

Closed — cherry-picked to dev (c58640f). See comment above.

tamirdresher pushed a commit to tamirdresher/squad that referenced this pull request Mar 16, 2026
* chore(squad): quality review findings — 7 issues filed

Quality audit complete: 5 agents assessed CLI across testing, coverage, stability, accessibility, UX.
Results: 4 P0 blockers (bradygaster#365bradygaster#368), 3 P1 items (bradygaster#369bradygaster#371).
Blocking: Waingro dead sessions, ErrorBoundary, dropped input; Marquez help text consistency.

Changes:
- Logged session summary to .squad/log/2026-02-24T0205-quality-review-complete.md
- Updated .squad/identity/now.md with quality review findings and new issue numbers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(squad): merge decision — Marquez UX audit findings

Quality assessment merged from inbox (Grade B): 11 improvements (3 P0, 4 P1, 4 P2). help text, stub commands, vocabulary, separators, roster.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix: P0 quality fixes — ErrorBoundary, session eviction, input buffer, stub removal (closes bradygaster#365, closes bradygaster#366, closes bradygaster#367, closes bradygaster#371)

- Add ErrorBoundary class component wrapping App in Ink render call (bradygaster#365)
  Shows friendly message on crash, logs error to stderr
- Dead session eviction in dispatchToAgent/dispatchToCoordinator (bradygaster#366)
  Deletes dead session from Map on error so next attempt creates fresh one
- Input buffering while disabled in InputPrompt (bradygaster#367)
  Buffers keystrokes via useRef, restores on re-enable, no auto-submit
- Remove stub commands: loop, hire; wire triage/watch to real runWatch (bradygaster#371)
  Remove stub help text entries for loop and hire
- 10 new tests across repl-ux and cli-shell-comprehensive

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tamirdresher pushed a commit to tamirdresher/squad that referenced this pull request Mar 16, 2026
…l paths (bradygaster#440)

* chore(squad): quality review findings — 7 issues filed

Quality audit complete: 5 agents assessed CLI across testing, coverage, stability, accessibility, UX.
Results: 4 P0 blockers (bradygaster#365bradygaster#368), 3 P1 items (bradygaster#369bradygaster#371).
Blocking: Waingro dead sessions, ErrorBoundary, dropped input; Marquez help text consistency.

Changes:
- Logged session summary to .squad/log/2026-02-24T0205-quality-review-complete.md
- Updated .squad/identity/now.md with quality review findings and new issue numbers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* chore(squad): merge decision — Marquez UX audit findings

Quality assessment merged from inbox (Grade B): 11 improvements (3 P0, 4 P1, 4 P2). help text, stub commands, vocabulary, separators, roster.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix bradygaster#418: Add progress indicator for long operations

Show 'Still working... (Xm Ys elapsed)' after 30 seconds, updating
every 30 seconds during sendAndWait timeout. Prevents users from
thinking the system has hung during long agent operations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix bradygaster#428/bradygaster#401: Add pending input queue for disabled→enabled transition

The ref-based buffer from bradygaster#381 handles keystrokes during disabled state, but
fast typing during the disabled→enabled transition could race with React's
useEffect. Added pendingInputRef queue to catch characters that arrive before
the effect drains bufferRef.

Edge cases fixed:
- Paste events (rapid character arrival)
- Fast typing during transition window
- Race between useInput and useEffect restoration

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix bradygaster#430: Document and enhance coordinator streaming diagnostics

Verified that coordinator message_delta event wiring is correct:
- Both dispatchToCoordinator and dispatchToAgent use identical streaming patterns
- message_delta listener registered BEFORE awaitStreamedResponse call
- CopilotSessionAdapter maps 'message_delta' -> 'assistant.message_delta' correctly
- Coordinator session created with streaming: true config

Enhanced diagnostics:
- Added session creation logging (sessionId, capabilities)
- Added listener registration/removal logging
- Added fallback path logging to track when sendAndWait content is used
- Documented streaming architecture in function comments

All 41 streaming tests pass. No functional changes, only diagnostic improvements.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update Kovash history: input buffering fix bradygaster#428/bradygaster#401

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants