feat(watch): circuit breaker integration — additive patch (#515)#552
Merged
bradygaster merged 2 commits intobradygaster:devfrom Mar 23, 2026
Merged
Conversation
…radygaster#515) Adds rate limit protection to Ralph's watch command as an additive patch on top of the existing watch flow. No existing functions are modified. Changes: - gh-cli.ts: +ghRateLimitCheck(), +isRateLimitError() helpers - watch.ts: +CircuitBreakerState type, persistence helpers - watch.ts: +executeRound() wrapper gates existing runCheck through pre-flight quota checks (traffic light + predictive CB) - watch.ts: +roundInProgress flag prevents overlapping setInterval rounds - 16 new tests: state machine transitions, race guard, isRateLimitError State machine: closed → open (quota critical) → half-open (cooldown expires) → closed (2 consecutive successes) or re-open (429 during probe). Cooldown doubles on each failure (2m → 4m → ... → 30m cap). State persists to .squad/ralph-circuit-breaker.json. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Linux chmod 444 returns EACCES, not EPERM. Handle both codes for cross-platform compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
chrislomonico
pushed a commit
to clomonico/squad
that referenced
this pull request
Mar 26, 2026
Session: 2026-02-27T23-18-55Z-repo-assessment Requested by: Scribe Changes: - Logged orchestration for Kobayashi (branch cleanup, 57 refs pruned) - Logged orchestration for Keaton (full repo assessment, replatform readiness) - Logged session: full repo assessment with concrete timeline - Merged 5 decisions from inbox to decisions.md (deduplicated) - Cleared decisions/inbox/ directory **Merged decisions:** - Fenster: Ghost command aliasing strategy - Fenster: Per-command --help/-h intercept-before-dispatch pattern - Keaton: Replatform readiness assessment (APPROVE launch, contingent on bradygaster#532) - Kovash: REPL cancellation and configurable timeout - Saul: Shell observability metrics design **Deduplication:** No exact duplicates found. All decisions preserved. **Cross-agent impact:** - Keaton's replatform decision affects all agents: v1 public alpha approved for Feb 28-Mar 1 launch - Timeline: Close bradygaster#532 (dogfood), merge bradygaster#552 (Ralph triage), ship v0.8.5.1 public alpha - Wave E queued: bradygaster#553 (personal consult), bradygaster#547 (remote control), bradygaster#542 (board automation)
chrislomonico
pushed a commit
to clomonico/squad
that referenced
this pull request
Mar 26, 2026
bradygaster#552) * feat(ralph): routing-aware triage, PR monitoring, board state tracking - Add packages/squad-sdk/src/ralph/triage.ts with parseRoutingRules(), parseModuleOwnership(), parseRoster(), and triageIssue() that reads routing.md for smart work assignment (module path > routing keyword > role keyword > Lead fallback) - Add templates/ralph-triage.js standalone CJS script for heartbeat workflow (zero deps, reads .squad/ files, outputs triage-results.json) - Update squad-heartbeat.yml to use ralph-triage.js instead of inline keyword matching - Update watch.ts to use SDK triage module instead of hardcoded keywords - Add PR/CI monitoring to watch: drafts, review feedback, CI failures, merge-ready PRs - Add BoardState tracking, board-clear detection, round counting - Wire RalphMonitor into watch for health checks and state persistence - Add body field to GhIssue, add GhPullRequest/ghPrList to gh-cli.ts - Fix Ralph charter: "Persistent Memory Agent" -> "Work Monitor" - Create ralph-reference.md template (was referenced but missing) - Add SDK subpath export for ralph/triage - Update docs/features/ralph.md with routing-aware triage, WIP monitoring, board state, and wake-up event documentation - 57 tests across 3 test files (ralph-triage, ralph-monitor, ralph-board) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * docs(ai-team): Ralph smart triage session — merge inbox, log, dedupe Session: 2026-02-27T03-25-00Z-ralph-smart-triage Requested by: Copilot CLI Changes: - Logged session: triage engine build (Fenster), 57 passing tests (Hockney), architecture review approved (Keaton), docs updated (McManus) - Merged 6 inbox decisions: shell metrics, REPL improvements, triage review, watch integration, CLI help, ghost commands - Deduplicated 0 exact duplicates; consolidated 0 overlapping decisions - Deleted 6 inbox files after merge * fix(ralph): address PR bradygaster#552 review feedback - Fix assigned issue count: use raw count instead of PR-derived subtraction - Change squad-sdk dependency to workspace:* for monorepo correctness - Fix ralph-reference.md: replace non-existent label refs with actual API fields - Add sync headers to ralph-triage.js (3 copies) and squad-heartbeat.yml (4 copies) - Add triage parity tests: syntax validation + routing priority verification Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds rate limit protection to Ralph's watch command as a surgical additive patch on the existing flow. Reworked from #522 per Brady's feedback — no full rewrite, no existing functions modified.
Closes #515
What changed
gh-cli.tsghRateLimitCheck(),isRateLimitError()helperswatch.tsexecuteRound()wrapper,roundInProgressguardwatch-circuit-breaker.test.tsArchitecture: Additive wrapper
Existing functions are completely untouched:
runCheck,checkPRs,reportBoard,emptyBoardState.The only change is in
runWatch():PredictiveCircuitBreaker+ load persisted stateexecuteRound()gates existing call: pre-flight quota check -> delegate torunCheck()-> post-round updateroundInProgressflag +try/finallyprevents overlapping roundsState machine
CLOSED -> OPEN(red/predicted) ->HALF-OPEN(cooldown expires) ->CLOSED(2 successes) or back toOPEN(429 during probe)Cooldown: 2m -> 4m -> 8m -> ... -> 30m cap. Persists to
.squad/ralph-circuit-breaker.json.Addressed feedback from #522
saveCBStateis sync (writeFileSync, no await)Test results