Skip to content

refactor: extract CooldownBeltComputer from CooldownSession (Wave 1B, #375)#397

Merged
cmbays merged 1 commit intomainfrom
worktree-kind-baking-pelican
Mar 22, 2026
Merged

refactor: extract CooldownBeltComputer from CooldownSession (Wave 1B, #375)#397
cmbays merged 1 commit intomainfrom
worktree-kind-baking-pelican

Conversation

@cmbays
Copy link
Owner

@cmbays cmbays commented Mar 22, 2026

Summary

  • Extract belt computation and agent confidence tracking into CooldownBeltComputer (85L)
  • CooldownSession delegates via this.beltComputer.compute() and this.beltComputer.computeAgentConfidence()
  • Per-agent error isolation: one failing agent no longer poisons the batch
  • CooldownSession: 1,225 → 1,201 lines (-24)

Quality

Metric Result
BDD scenarios 10 pass
Unit tests 17 pass (+ 3,416 existing)
Acceptance tests 66 pass
TypeScript Clean
ArchUnit 14 of 15 (pre-existing CycleManager LCOM4)
Mutation score 82% total, 100% covered

Review Findings Addressed

  • Per-agent error isolation (silent failure hunter, MEDIUM): moved try-catch inside the agent loop so one bad agent doesn't skip the rest
  • Type design (type analyzer): grouped sub-objects deferred to Wave 3A
  • Registry injection (silent failure hunter): deferred to Wave 3A DI cleanup
  • Code review: clean, no issues above threshold

Deferred to Wave 3A

  • Group co-dependent deps into sub-objects (belt?: { calculator, projectStateFile })
  • @deprecated tags on kataka legacy fields
  • Injectable KataAgentRegistry

Closes #375 partially (Wave 1B of 6)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Belt level recomputation after cooldown with advancement logging and configuration control
    • Per-agent confidence computation including legacy practitioner alias support
    • Robust error handling for belt and confidence computation failures (logged as warnings without interrupting cooldown)
  • Tests

    • Added acceptance criteria and unit test coverage for belt and confidence computation

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3453083e-9d80-4d23-b7f3-8dd46ede178d

📥 Commits

Reviewing files that changed from the base of the PR and between c3429f0 and 8d953ce.

📒 Files selected for processing (7)
  • src/acceptance/setup.ts
  • src/features/cycle-management/cooldown-belt-computer.feature
  • src/features/cycle-management/cooldown-belt-computer.steps.ts
  • src/features/cycle-management/cooldown-belt-computer.test.ts
  • src/features/cycle-management/cooldown-belt-computer.ts
  • src/features/cycle-management/cooldown-session.ts
  • stryker.config.mjs

📝 Walkthrough

Walkthrough

Extracts belt computation and agent-confidence tracking logic from CooldownSession into a new CooldownBeltComputer collaborator class. Introduces implementation, unit tests, acceptance tests, and configuration updates to include the new module in mutation testing scope.

Changes

Cohort / File(s) Summary
CooldownBeltComputer Core Implementation
src/features/cycle-management/cooldown-belt-computer.ts
New module exporting CooldownBeltComputer class and CooldownBeltDeps interface. Implements compute() (loads project state, runs belt calculator, logs advancement, returns result or undefined on failure) and computeAgentConfidence() (resolves calculator/directory with fallbacks, iterates registered agents, catches and logs per-agent exceptions).
Acceptance Tests
src/features/cycle-management/cooldown-belt-computer.feature, src/features/cycle-management/cooldown-belt-computer.steps.ts
New Gherkin feature file specifying belt evaluation (feature flag gating, missing state handling, advancement vs. steady behavior, error handling) and agent confidence tracking (per-agent computation, registry resolution, failure handling). Step definitions with world setup, spies, and assertions for belt results, advancement logging, calculator invocations, and warning messages.
Unit Tests
src/features/cycle-management/cooldown-belt-computer.test.ts
Comprehensive unit tests for compute() (dependency gating, argument passing, advancement logging, error handling) and computeAgentConfidence() (per-agent iteration, calculator precedence, fallback behavior, missing input no-ops, exception continuation, registry loading failures).
Integration
src/features/cycle-management/cooldown-session.ts
Removed inline belt/confidence computation methods; added beltComputer: CooldownBeltComputer collaborator initialized in constructor; delegated compute() and computeAgentConfidence() calls to collaborator in run() and complete().
Configuration
src/acceptance/setup.ts, stryker.config.mjs
Added side-effect import for cooldown-belt-computer acceptance steps; added new module to Stryker mutation testing scope.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #396 — Applies identical extraction pattern to CooldownSession, moving cycle/bridge-run syncing logic into a new BridgeRunSyncer collaborator class
  • PR #387 — Adds unit tests exercising CooldownSession cooldown-related flows, overlapping with the refactored belt-computation behavior
  • PR #378 — Adds acceptance setup import for session-bridge steps in src/acceptance/setup.ts, following the same side-effect import pattern

Poem

🐰 Belt logic hops away free,
A tidy new class, small and clean,
Agent confidence tracked in between,
Tests woven tight as can be!
Refactoring done with glee! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: extract CooldownBeltComputer from CooldownSession (Wave 1B, #375)' accurately summarizes the main change: extracting belt computation logic into a new class and reducing CooldownSession complexity.
Linked Issues check ✅ Passed The PR successfully addresses objectives from #375 Wave 1B by extracting CooldownBeltComputer to isolate belt/confidence computation, improving mutation-testing signal through reduced class complexity and better per-agent error handling, with 10 BDD scenarios and 17 unit tests passing.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to extracting belt computation: new CooldownBeltComputer class, updated CooldownSession delegation, supporting tests/features, and Stryker config updates. No unrelated refactoring or scope creep detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-kind-baking-pelican

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…375)

Extract belt computation and agent confidence tracking into a dedicated
CooldownBeltComputer class (85L), reducing CooldownSession from 1,225 to
1,201 lines. Per-agent error isolation ensures one bad agent does not
poison the batch.

Quality: 10 BDD, 17 unit, ArchUnit 14 of 15, mutation 82% (100% covered)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cmbays cmbays force-pushed the worktree-kind-baking-pelican branch from c3429f0 to 8d953ce Compare March 22, 2026 19:10
@cmbays cmbays merged commit 1146853 into main Mar 22, 2026
1 of 2 checks passed
@cmbays cmbays deleted the worktree-kind-baking-pelican branch March 22, 2026 19:11
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.

Refactor and re-scope mutation testing for core execution paths after PR #374

1 participant