Skip to content

Collapse thread catalog into one coordinator operation - #69

Merged
soorya-u merged 4 commits into
mainfrom
issue-65-collapse-thread-catalog
Jul 17, 2026
Merged

soorya-u merged 4 commits into
mainfrom
issue-65-collapse-thread-catalog

Conversation

@soorya-u

@soorya-u soorya-u commented Jul 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Collapses models/modes/efforts/personas get/set into one field-parameterized ThreadCoordinator.catalog operation and deletes the threads/catalog forwarding module
  • Runs catalog setters under the same per-thread lock as bind/close, with a mutual-exclusion test at the coordinator seam
  • Rewrites catalog/binding unit tests against the coordinator with a faked agent runtime; exhaustive catalog-field switches use panic from better-result

Closes #65

Test plan

  • cd apps/cli && bun run check:types
  • cd apps/cli && bun test src __tests__/integration
  • Confirm catalog get/set still works from a controller for model, mode, effort, and persona
  • Confirm concurrent catalog set and bind no longer race (covered by unit test)

soorya-u and others added 2 commits July 17, 2026 22:38
Replace the four parallel getter/setter pairs and the threads/catalog
forwarding module with a field-parameterized catalog op, and hold the
per-thread lock on setters so catalog changes cannot race bind/close.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cyrus Ready Ready Preview, Comment Jul 17, 2026 5:30pm

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@soorya-u, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: daf5124e-76f1-4cb2-af6c-9068e032c550

📥 Commits

Reviewing files that changed from the base of the PR and between 1e5536e and 8be8281.

📒 Files selected for processing (4)
  • apps/cli/src/core/agents/runtime.ts
  • apps/cli/src/core/threads/coordinator.ts
  • tests/e2e/harness/controller.ts
  • tests/e2e/manual/verify-catalog-rpc.ts
📝 Walkthrough

Walkthrough

Catalog reads and writes now use field-parameterized APIs across agent runtime, thread coordination, and controller handlers. Catalog writes acquire the per-thread lock, and coordinator tests cover binding, errors, field operations, and concurrency ordering.

Changes

Thread catalog consolidation

Layer / File(s) Summary
Generic agent catalog API
apps/cli/src/core/agents/catalog-ops.ts, apps/cli/src/core/agents/runtime.ts
Introduces typed catalog fields and generic runtime read/write methods, replacing model-, mode-, effort-, and persona-specific APIs.
Coordinator dispatch and locking
apps/cli/src/core/threads/coordinator.ts
Adds overloaded catalog operations, resolves bound sessions, dispatches field operations, and locks writes.
Catalog callers and session binding
apps/cli/src/core/threads/bind.ts, apps/cli/src/handlers/controller/catalog/*, apps/cli/__tests__/integration/draft-session-lifecycle.test.ts
Updates bound-session assembly, controller handlers, and integration coverage to use the unified catalog API.
Coordinator and runtime validation
apps/cli/src/core/threads/coordinator.*.test.ts, apps/cli/src/core/agents/runtime.test.ts
Adds coverage for field reads and writes, binding resolution, project and unbound errors, and setter/binding mutual exclusion.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Controller
  participant ThreadCoordinator
  participant AgentRuntime
  Controller->>ThreadCoordinator: catalog(field, operation)
  ThreadCoordinator->>AgentRuntime: getCatalogField or setCatalogField
  AgentRuntime-->>ThreadCoordinator: catalog values or completion
  ThreadCoordinator-->>Controller: Result response
Loading

Possibly related PRs

  • soorya-u/cyrus#18: Overlaps in coordinator-level model, mode, effort, and persona selection handling.
  • soorya-u/cyrus#51: Overlaps in bound-session catalog access and migration to the generic catalog API.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Linked Issues check ✅ Passed The PR matches #65: it adds one coordinator catalog API, removes the forwarding module and parallel getters/setters, adds lock coverage, and rewrites tests at the coordinator seam.
Out of Scope Changes check ✅ Passed No unrelated code changes stand out beyond the catalog refactor, test rewrites, and directly adjacent cleanup needed to remove the old forwarding path.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: consolidating thread catalog get/set APIs into one coordinator operation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issue-65-collapse-thread-catalog

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.

@soorya-u soorya-u changed the title Collapse thread catalog into one coordinator operation (#65) Collapse thread catalog into one coordinator operation Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
apps/cli/src/core/threads/coordinator.catalog.test.ts (2)

174-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the specific unbound error.

Checking only isErr() allows unrelated repository or runtime failures to satisfy this test. Assert the expected coordinator error tag as done in the project-mismatch test.

Proposed assertion
 	expect(result.isErr()).toBe(true);
+	if (result.isErr()) {
+		expect(result.error._tag).toBe("coordinator.not_found");
+	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/cli/src/core/threads/coordinator.catalog.test.ts` around lines 174 -
180, Update the “catalog get surfaces unbound errors” test to assert the
specific expected coordinator error tag, matching the assertion pattern used by
the project-mismatch test, rather than only checking result.isErr(). Keep the
existing catalog invocation and verify the unbound error identity explicitly.

182-238: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Make the lock assertion deterministic.

Line 226 does not prove bindAgent is blocked: an unlocked bind can require several awaits, while the set gate is released after only one microtask, still producing the expected final order.

Gate bindAgent inside a mocked dependency, wait until it has entered, then start the catalog setter and verify setModel cannot enter until the bind gate is released.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/cli/src/core/threads/coordinator.catalog.test.ts` around lines 182 -
238, Make the mutual-exclusion test deterministic by mocking a dependency used
by bindAgent, adding a bind-entry signal and release gate, and awaiting
bindAgent’s entry before starting the catalog set operation. Assert the setter’s
setModel mock has not entered while bindAgent is gated, then release bindAgent
and verify both operations succeed in bind-before-set order; update the existing
setModel gating accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/cli/src/core/threads/coordinator.catalog.test.ts`:
- Around line 174-180: Update the “catalog get surfaces unbound errors” test to
assert the specific expected coordinator error tag, matching the assertion
pattern used by the project-mismatch test, rather than only checking
result.isErr(). Keep the existing catalog invocation and verify the unbound
error identity explicitly.
- Around line 182-238: Make the mutual-exclusion test deterministic by mocking a
dependency used by bindAgent, adding a bind-entry signal and release gate, and
awaiting bindAgent’s entry before starting the catalog set operation. Assert the
setter’s setModel mock has not entered while bindAgent is gated, then release
bindAgent and verify both operations succeed in bind-before-set order; update
the existing setModel gating accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 213538d7-8b67-40c9-96e0-ed1c0995929c

📥 Commits

Reviewing files that changed from the base of the PR and between f47afe2 and 1e5536e.

📒 Files selected for processing (15)
  • apps/cli/__tests__/integration/draft-session-lifecycle.test.ts
  • apps/cli/src/core/agents/catalog-ops.ts
  • apps/cli/src/core/agents/runtime.test.ts
  • apps/cli/src/core/agents/runtime.ts
  • apps/cli/src/core/threads/bind.ts
  • apps/cli/src/core/threads/binding.test.ts
  • apps/cli/src/core/threads/catalog.test.ts
  • apps/cli/src/core/threads/catalog.ts
  • apps/cli/src/core/threads/coordinator.binding.test.ts
  • apps/cli/src/core/threads/coordinator.catalog.test.ts
  • apps/cli/src/core/threads/coordinator.ts
  • apps/cli/src/handlers/controller/catalog/effort.ts
  • apps/cli/src/handlers/controller/catalog/mode.ts
  • apps/cli/src/handlers/controller/catalog/model.ts
  • apps/cli/src/handlers/controller/catalog/persona.ts
💤 Files with no reviewable changes (3)
  • apps/cli/src/core/threads/catalog.test.ts
  • apps/cli/src/core/threads/binding.test.ts
  • apps/cli/src/core/threads/catalog.ts

soorya-u and others added 2 commits July 17, 2026 22:59
Keep the field-parameterized catalog API while preserving getDraftCatalog
and probeCatalog from the draft-catalog probe work.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@soorya-u
soorya-u merged commit db0c284 into main Jul 17, 2026
9 checks passed
@soorya-u
soorya-u deleted the issue-65-collapse-thread-catalog branch July 17, 2026 17:32

This branch was successfully deployed

1 active deployment
Preview — 8be82814 Deployed Jul 17, 2026 by vercel[bot]
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.

Prefactor: collapse the thread-catalog chain into the coordinator

1 participant