Skip to content

fix: atomically dedupe GitHub lifecycle aliases#163

Merged
kjgbot merged 2 commits into
mainfrom
fix/atomic-github-lifecycle-alias
Jul 21, 2026
Merged

fix: atomically dedupe GitHub lifecycle aliases#163
kjgbot merged 2 commits into
mainfrom
fix/atomic-github-lifecycle-alias

Conversation

@kjgbot

@kjgbot kjgbot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Prevents Relayfile by-id and slugged meta.json paths for the same GitHub issue from creating separate durable dispatch lifecycles.

The state-store claim now resolves the logical GitHub identity under the same mutation lock, adopts the existing persisted key, and returns that actual key for lease fencing. Historical duplicate cleanup remains covered.

Verification:

  • 54 test files, 1089 tests passed
  • TypeScript build passed
  • Exact packed consumer E2E: 9/9 checks at head 63b0fe4

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 53 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e7a5ee2-db5e-4bce-868d-c90ce8b0e171

📥 Commits

Reviewing files that changed from the base of the PR and between 63b0fe4 and 748ff58.

📒 Files selected for processing (2)
  • src/state/github-lifecycle-identity.test.ts
  • src/state/github-lifecycle-identity.ts
📝 Walkthrough

Walkthrough

Dispatch lifecycle claims now match equivalent GitHub issue paths, adopt one persisted lifecycle across aliases, return its canonical key, and use that key for orchestrator epoch tracking. Tests cover file and in-memory stores plus legacy persisted watch state.

Changes

GitHub lifecycle alias adoption

Layer / File(s) Summary
GitHub identity matching
src/ports/state.ts, src/state/github-lifecycle-identity.ts
Claims expose the persisted key, and shared helpers parse GitHub issue identities and select matching lifecycle candidates deterministically.
State-store claim adoption
src/state/file-state-store.ts, src/state/in-memory-state-store.ts, src/state/file-state-store.test.ts
Both state stores reuse matching lifecycle records under alias keys, return the resolved key, and test canonical lifecycle completion and re-claim behavior.
Orchestrator canonical epoch tracking
src/orchestrator/factory.ts, src/orchestrator/factory.test.ts
Lifecycle epochs are stored under returned canonical keys during startup adoption, claims, and dispatch driving; the factory test persists legacy watch state before restart.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Factory
  participant StateStore
  participant IdentityMatcher
  participant LifecycleRecord
  Factory->>StateStore: claim dispatch lifecycle by requested key
  StateStore->>IdentityMatcher: match GitHub issue identity
  IdentityMatcher->>LifecycleRecord: inspect existing lifecycle entries
  LifecycleRecord-->>IdentityMatcher: canonical lifecycle entry
  IdentityMatcher-->>StateStore: canonical key and lifecycle
  StateStore-->>Factory: claim with persisted key and epoch
  Factory->>Factory: record epoch under canonical key
Loading

Possibly related PRs

Suggested reviewers: khaliqgant

Poem

I’m a rabbit guarding aliases tight,
One lifecycle hops through paths at night.
The canonical key leads the way,
Epochs stay fenced till break of day.
By-id or slug, the claim is right—
One bun, one record, all is bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: atomic deduplication of GitHub lifecycle aliases.
Description check ✅ Passed The description matches the changeset and explains the alias deduplication and lease-fencing behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/atomic-github-lifecycle-alias

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.

@kjgbot
kjgbot marked this pull request as ready for review July 21, 2026 05:28

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a mechanism to atomically adopt existing GitHub lifecycles across Relayfile issue aliases, ensuring that logical GitHub identities are matched before creating new rows. The changes include updates to the state stores, the addition of matching logic in a new helper file, and comprehensive test coverage. The review feedback suggests several improvements to the new helper functions: adding defensive checks to prevent runtime TypeErrors when accessing issue paths, optimizing the matching function to run in a single pass (O(N) complexity) instead of sorting, and defensively handling potentially missing updatedAtMs values to avoid NaN comparison results.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/state/github-lifecycle-identity.ts
Comment thread src/state/github-lifecycle-identity.ts
Comment thread src/state/github-lifecycle-identity.ts
@kjgbot
kjgbot merged commit cebf3c5 into main Jul 21, 2026
2 of 3 checks passed
@kjgbot
kjgbot deleted the fix/atomic-github-lifecycle-alias branch July 21, 2026 05:38
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.

1 participant