Skip to content

feat(relay): correct regional placement only when the source is idle - #20105

Merged
Jinwoo-H merged 2 commits into
mainfrom
relay-idle-cloud
Sep 11, 2026
Merged

Jinwoo-H merged 2 commits into
mainfrom
relay-idle-cloud

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 21 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2768 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1200 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1568
Prod 31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2189 $\color{#cf222e}{\Huge{\mathbf{−}}}$​964 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1225

Automatically correct a host’s relay region when the source has no client connections or pending admission/control work. Fresh incumbent-relative measurements select an eligible target; the source gates new admissions before atomically updating the assignment, then releases its empty control. Returning devices use normal reconnect, and a failed target uses existing migration recovery.

Replaces the earlier live-retention proposal. Reuses the worker, assignment locks, reservations and recovery; no retained-source lease or mobile protocol. Correction defaults off and requires protocol3 cells plus an idle-capable desktop. Deployment and enablement remain separate.

Validation: 77 cloud files / 682 tests passed with PostgreSQL16 on55440, zero skips; cloud typecheck passes. Source admission, authority-tuple dedupe and locked reconciliation have negative-control evidence. Fifth Astra low implementation audit approved within scope. Desktop PR adds real two-cell transport coverage.

Remaining: fresh CI for this head, packaged mixed versions and platform/device release validation, then measured bounded rollout. No deployment performed.

Published from the locally validated baseline 74cc9b50390b481009b34823a35eee01a5b90e40. Main has since advanced; current-main integration and fresh hosted CI remain required. Historical status text in the acceptance document records the pre-publication snapshot.

@Jinwoo-H
Jinwoo-H marked this pull request as ready for review September 11, 2026 17:42

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — two non-blocking observations and a couple of nits.

Reviewed changes

This replaces the earlier live-retention rehome with an idle-gated region correction: a host measures RTT to both regions through an assignment-embedded "measurement window", the director records a per-host preferred_region decision, and a worker dispatches moves that the source cell only commits when the host session is genuinely idle.

  • Idle-gated regional rehome — the director-side claimRegionalRehome drain loop is replaced by a candidate scan plus a cell-side idleRehome gate that commits the move only when the source session has no connections, pending conns, or splices, fencing concurrent admission.
  • Region-correction measurement window — new relay_region_decisions table and exchangeRegionCorrection (issue-window/report) that converts host RTT measurements into a durable preferred_region.
  • Capability + protocol plumbing — idle-regional-rehome-v1 host capability, an idle_regional_rehome control-capability flag, and regionalRehomeProtocol bumped 1 → 3 with selection and commit gates.
  • Recovery + ops — the evacuation abort/rollback and lease-refresh sweeps are extended to cover idle rehome attempts; cohort-percent plumbing through the deploy workflow, blue-green script, and Terraform, plus new preview/outcomes admin endpoints, docs, and a large test suite.

ℹ️ Idle guarantee rests on the in-process fence, not a durable data-connection check

The "only when idle" property is enforced entirely by the single-process fence in HostSessionRegistry: idleRehome installs idleAttempts in the same synchronous block as its busy check, and every admission path (acceptClient, acceptHostData, activateControl, acceptRefresh, acceptControlCommand) funnels through beginIdleWork. The reused durable assertAssignmentActivityCounts(assignment, activityLeases, 0) does not reject active data connections — it only checks accounting consistency and that no migration is in flight. That is correct as written today, but the durable assertion is not the cross-process backstop its name implies, so any future second admission surface for the same cell would silently break the guarantee.

Technical details
# Idle gate is fence-only; durable assertion is not a data-connection check

## Affected sites
- cloud/apps/relay/src/host-session-registry.ts:235-276 — `idleRehome` busy check + `idleAttempts.set` in one synchronous block; `beginIdleWork` fences all admission.
- cloud/apps/relay/src/assignment-store.ts:5395 — `assertAssignmentActivityCounts(assignment, activityLeases, 0)`.
- cloud/apps/relay/src/assignment-store.ts:8265-8279 — the assertion only compares `ACTIVITY_COLUMN` counters to lease counts and rejects `migration !== 0`; a live splice/pending confirmation/invite passes.

## Required outcome
- Idle correctness is preserved (it is, via the fence). No code change is strictly required.
- Make the reliance on the in-process fence explicit, or add a genuine durable idle check, so a future contributor does not treat `assertAssignmentActivityCounts(..., 0)` as a connection-rejecting backstop.

## Open questions for the human (optional)
- Is the fence intended to be the sole idleness guard, or should a durable zero-connection check be added for defense in depth?

ℹ️ Protocol-3 bump degrades safely but logs per-heartbeat during a mixed-version window

In a rolling deploy, a new cell (reporting regionalRehomeProtocol: 3) behind an old director (schema still capped at 1) gets a 400 on /v1/admin/cell-rehome-status, which the cell reduces to a console.warn every heartbeat interval. Liveness is unaffected because the separate /v1/admin/cell-heartbeat call still succeeds. Old cells are cleanly excluded at selection and commit (the >= 3 gates plus the missing idle_regional_rehome = 1 flag), so nothing is ever dispatched to a protocol-1 cell. Safe, but the per-interval warn could be noisy during the transition.

Technical details
# Mixed-version behavior of the protocol 1->3 bump

## Affected sites
- cloud/apps/relay/src/cell-heartbeat-client.ts:96-103 — throws on non-404 rehome-status failure.
- cloud/apps/relay/src/app.ts:1476 — `CellRegionalRehomeStatusSchema` widened to `max(3)`.
- cloud/apps/relay/src/idle-regional-rehome-selection.ts:68 — `>= 3` selection gate.
- cloud/apps/relay/src/assignment-store.ts:5464,5531 — commit re-gates source/target protocol.

## Required outcome
- No data-plane impact in either direction (verified). Nothing blocks merge.

## Open questions for the human (optional)
- Is director-first deploy ordering required to avoid the transient `console.warn` spam, and is that ordering captured anywhere?

ℹ️ Nitpicks

  • relay_region_decisions.last_considered_at (cloud/apps/relay/src/database.ts:206) is added, migrated, and even asserted in a test, but is never read or written anywhere in this PR — a dead column.
  • source_generation is written via a follow-up UPDATE ... SET source_generation = ? WHERE attempt_id = ? (cloud/apps/relay/src/assignment-store.ts:5707) immediately after the INSERT into relay_region_rehome_attempts; the column could be carried in the INSERT itself.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1a75f208-3100-4d41-ab62-b23344e6cd65

📥 Commits

Reviewing files that changed from the base of the PR and between a8a38a6 and 01bd113.

📒 Files selected for processing (2)
  • cloud/apps/relay/src/idle-regional-rehome-selection.ts
  • cloud/apps/relay/src/idle-regional-rehome-store.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The change adds region-correction wire contracts and durable decision state. It replaces the regional rehome claim path with idle candidate selection, commit, and reconciliation flows. Host sessions now fence concurrent cutovers and validate authority, generations, and cell incarnations. New admin endpoints expose idle rehome and eligibility preview operations. Deployment workflows, Terraform, telemetry, protocol versions, migrations, fixtures, and tests are updated.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 01bd1

Regional correction can make unsafe moves when fleet safety is omitted and may leave rehome enabled after a failed rollback. Correct these behaviors and the rollout prerequisite before enabling the feature.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation and validation, but it does not follow the required template. It omits the required headings, linked issue, visual-proof statement, testing checklist, AI di… Rewrite the description using the repository template. Add all required sections, provide a linked issue after "Fixes #", state "N/A" with a reason for visual proof if applicable, complete the testing and checklist items, and document revie…
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 60 functions across 47 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: regional correction occurs only when the source is idle.
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.
Full details: Description check

Explanation

The description explains the implementation and validation, but it does not follow the required template. It omits the required headings, linked issue, visual-proof statement, testing checklist, AI disclosure, review sections, boundary checklist, notes, and final checklist.

Resolution

Rewrite the description using the repository template. Add all required sections, provide a linked issue after "Fixes #", state "N/A" with a reason for visual proof if applicable, complete the testing and checklist items, and document review, compatibility, security, and performance considerations.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
cloud/apps/relay/src/assignment-store.ts (2)

6436-6436: 🩺 Stability & Availability | 🔵 Trivial | ⚖️ Poor tradeoff

Isolate per-candidate invariant failures in abortExpiredEvacuations.

The transaction callback throws migration_assignment_missing and migration_assignment_mismatch. The catch handler rethrows both errors, which terminates the sweep and leaves later candidates unprocessed. Record the failure for the current candidate and continue, as the regional rehome sweeps do.


6594-6599: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Document why this rollback leaves relay_region_rehome_control enabled.

abortExpiredEvacuations treats an unregistered target as normal rollback. It aborts the migration and regional attempt without calling disableRegionalRehomeControl. reapRegionalRehomeAttempts then makes no update because aborted_at is already set. Add a comment that this cleanup is not a regional-rehome safety signal.

cloud/apps/relay/src/regional-rehome-store.test.ts (1)

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

The scan hook couples to an SQL alias and fails silently if that alias changes.

hookAfterCandidateScan fires only when a query string contains the exact text FROM relay_region_rehome_control policy. That text is an alias inside the production selection query. If the query is reworded or the policy alias is renamed or removed, fired stays false, the hook never runs, and the raced state the caller wants to create never exists. The test then asserts an outcome that it did not actually race, so it can keep passing while covering nothing.

Match on a stable anchor instead, and fail loudly when the hook did not fire. Returning a fired flag from hookAfterCandidateScan and asserting it in each caller would make the regression visible.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: cc81329e-f58f-45b3-af14-c918734c6db2

📥 Commits

Reviewing files that changed from the base of the PR and between 08a24ef and a8a38a6.

📒 Files selected for processing (52)
  • .github/workflows/cloud-deploy-relay-production-director.yml
  • cloud/apps/relay/src/admin-token-verifier.ts
  • cloud/apps/relay/src/app.ts
  • cloud/apps/relay/src/assignment-store.ts
  • cloud/apps/relay/src/cell-heartbeat-client.test.ts
  • cloud/apps/relay/src/cell-heartbeat-client.ts
  • cloud/apps/relay/src/cell-inventory-lock-census.test.ts
  • cloud/apps/relay/src/config.test.ts
  • cloud/apps/relay/src/config.ts
  • cloud/apps/relay/src/database.test.ts
  • cloud/apps/relay/src/database.ts
  • cloud/apps/relay/src/host-session-client-accept.test.ts
  • cloud/apps/relay/src/host-session-registry.test.ts
  • cloud/apps/relay/src/host-session-registry.ts
  • cloud/apps/relay/src/idle-regional-rehome-reconciliation.test.ts
  • cloud/apps/relay/src/idle-regional-rehome-selection.ts
  • cloud/apps/relay/src/idle-regional-rehome-store.test.ts
  • cloud/apps/relay/src/idle-regional-rehome-test-database.ts
  • cloud/apps/relay/src/idle-regional-rehome-worker.test.ts
  • cloud/apps/relay/src/index.ts
  • cloud/apps/relay/src/region-correction-outcomes.ts
  • cloud/apps/relay/src/region-correction-preview.ts
  • cloud/apps/relay/src/region-correction-restart.test.ts
  • cloud/apps/relay/src/region-correction-state.ts
  • cloud/apps/relay/src/region-correction-store.test.ts
  • cloud/apps/relay/src/regional-host-drain-app.test.ts
  • cloud/apps/relay/src/regional-rehome-postgres.test.ts
  • cloud/apps/relay/src/regional-rehome-store.test.ts
  • cloud/apps/relay/src/regional-rehome-target-selection.test.ts
  • cloud/apps/relay/src/regional-rehome-worker.test.ts
  • cloud/apps/relay/src/regional-rehome-worker.ts
  • cloud/apps/relay/src/relay-region-app.test.ts
  • cloud/apps/relay/src/relay-server.ts
  • cloud/apps/relay/src/relay-sweep-schedule.test.ts
  • cloud/apps/relay/src/test-fixtures/relay-contract-baseline/README.md
  • cloud/apps/relay/src/test-fixtures/relay-contract-baseline/control-messages.ts
  • cloud/apps/relay/src/test-fixtures/relay-contract-baseline/director-messages.ts
  • cloud/apps/relay/src/test-fixtures/relay-contract-baseline/relay-regions.ts
  • cloud/apps/relay/src/test-fixtures/relay-contract-baseline/wire-scalars.ts
  • cloud/apps/relay/tsconfig.build.json
  • cloud/dev/scripts/deploy-relay-blue-green.mjs
  • cloud/dev/scripts/deploy-relay-blue-green.test.mjs
  • cloud/dev/scripts/read-relay-serving-regional-placement-version.mjs
  • cloud/dev/scripts/read-relay-serving-regional-placement-version.test.mjs
  • cloud/docs/orca-relay-operations.md
  • cloud/infra/terraform/relay.tf
  • cloud/packages/relay-contract/src/control-messages.ts
  • cloud/packages/relay-contract/src/director-messages.ts
  • cloud/packages/relay-contract/src/idle-regional-rehome.ts
  • cloud/packages/relay-contract/src/index.ts
  • cloud/packages/relay-contract/src/region-correction.test.ts
  • cloud/packages/relay-contract/src/region-correction.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

slow.resolve()
await accepting
expect(control.send).not.toHaveBeenCalledWith(expect.stringContaining('conn-open'))
expect(capacity.bind).not.toHaveBeenCalled()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Assert the capacity release after drain crosses activity acquisition.

When drainHost crosses the acquireActivity await, acceptClient skips capacity.bind and calls capacityReservation.release(). Assert capacity.release here so removing that cleanup exposes the connection-unit leak.

💚 Proposed assertion
     expect(capacity.bind).not.toHaveBeenCalled()
+    expect(capacity.release).toHaveBeenCalled()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(capacity.bind).not.toHaveBeenCalled()
expect(capacity.bind).not.toHaveBeenCalled()
expect(capacity.release).toHaveBeenCalled()

Comment on lines +30 to +31
const claimRegionalRehome = vi.fn()
const recordRegionalRehomeDispatchFailure = vi.fn()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Assert continuation after a lost response.

await c.worker.run() already verifies error containment because the test fails if run() rejects. The recordRegionalRehomeDispatchFailure assertion is vacuous, and the single candidate does not test continuation. Configure two candidates, make the first request fail and the second return committed, then assert that run() resolves and fetch is called twice. Remove the unused store-method stubs and assertions.

Comment on lines +41 to +48
it('advances past a full candidate page whose destination lacks capacity', async () => {
const context = await setup()
for (let i = 0; i < 10; i++) {
await activatePreferredSource(context, {
userId: `blocked-${i}`,
relayHostId: 'abcdefghijklmnop'
})
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Resolve IDLE_REHOME_PAGE_SIZE and its use in candidate selection.
set -euo pipefail

rg -nP -C3 '\bIDLE_REHOME_PAGE_SIZE\b' cloud/apps/relay/src

# Confirm the offset-advance condition that depends on the page size.
ast-grep run --pattern 'this.idleRegionalCandidateOffset = $$$' --lang typescript cloud/apps/relay/src/assignment-store.ts

Repository: stablyai/orca

Length of output: 2611


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/conventions

Length of output: 41509


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1,130p' cloud/apps/relay/src/regional-rehome-store.test.ts
sed -n '3310,3370p' cloud/apps/relay/src/assignment-store.ts
sed -n '1,120p' cloud/apps/relay/src/idle-regional-rehome-selection.ts

Repository: stablyai/orca

Length of output: 13426


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C6 'function (activatePreferredSource|activateReversePreferredSource)|activatePreferredSource|activateReversePreferredSource|class IdleRehomeTestStore|tryIdleRehome' cloud/apps/relay/src/regional-rehome-store.test.ts

Repository: stablyai/orca

Length of output: 33524


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '650,900p' cloud/apps/relay/src/regional-rehome-store.test.ts
rg -n -C10 'tryIdleRehome|selectIdleRegionalRehomeCandidates|activatePreferredSource|activateReversePreferredSource' cloud/apps/relay/src/assignment-store.ts cloud/apps/relay/src/regional-rehome-store.test.ts

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail
sed -n '1670,1785p' cloud/apps/relay/src/regional-rehome-store.test.ts
sed -n '1900,1985p' cloud/apps/relay/src/regional-rehome-store.test.ts
rg -n -C4 'IDLE_REHOME_PAGE_SIZE|target\.reserved_requests|candidates\.length|idleRegionalCandidateOffset' cloud/apps/relay/src/idle-regional-rehome-selection.ts cloud/apps/relay/src/assignment-store.ts

Repository: stablyai/orca

Length of output: 12365


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -C12 'async tryIdleRehome|hookAfterCandidateScan|selectIdleRegionalRehomeCandidates\(' cloud/apps/relay/src/assignment-store.ts cloud/apps/relay/src/regional-rehome-store.test.ts

Repository: stablyai/orca

Length of output: 19499


Make the test exercise the full-page offset.

IDLE_REHOME_PAGE_SIZE is 100. Because the test fills target before selection, the query excludes all 10 preferred sources and returns only the reverse source. Create 100 blocked sources plus the reverse source, then fill target in hookAfterCandidateScan; this makes the first page fail during commit and the next selection reach the reverse source.

Comment on lines +143 to +146
() => assignments.commitIdleRegionalRehome(input, combineRegionalRehomeSafety(
input.directorSafety,
{ ...observability.regionalRehomeRuntimeSafety(), ...readRelayDatabasePoolPressure(database) }
), input.cohortPercent),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Pass process safety before fleet safety.

combineRegionalRehomeSafety copies reconnects from its second argument. The current call passes local process safety second, so the commit gate can omit the director fleet reconnect count. Swap the arguments.

Proposed fix
-        () => assignments.commitIdleRegionalRehome(input, combineRegionalRehomeSafety(
-          input.directorSafety,
-          { ...observability.regionalRehomeRuntimeSafety(), ...readRelayDatabasePoolPressure(database) }
+        () => assignments.commitIdleRegionalRehome(input, combineRegionalRehomeSafety(
+          { ...observability.regionalRehomeRuntimeSafety(), ...readRelayDatabasePoolPressure(database) },
+          input.directorSafety
         ), input.cohortPercent),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
() => assignments.commitIdleRegionalRehome(input, combineRegionalRehomeSafety(
input.directorSafety,
{ ...observability.regionalRehomeRuntimeSafety(), ...readRelayDatabasePoolPressure(database) }
), input.cohortPercent),
() => assignments.commitIdleRegionalRehome(input, combineRegionalRehomeSafety(
{ ...observability.regionalRehomeRuntimeSafety(), ...readRelayDatabasePoolPressure(database) },
input.directorSafety
), input.cohortPercent),

including explicit zero; only an absent service/setting bootstraps to0. Malformed
or ambiguous live settings fail the plan instead of silently resetting the cohort.
The audited director workflow owns subsequent changes.
Before the first nonzero cohort, verify compatible protocol2 cells, updated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require protocol3 cells in the rollout checklist.

Line 501 and the region-correction contract require regional protocol3. Line 552 instead tells operators to verify protocol2 cells. Change protocol2 to protocol3 so the launch gate checks the required capability.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The delta since the prior Pullfrog review is a single test commit that pins the target-capacity accounting for idle regional rehome, plus a clarifying comment in the selection query.

  • Source-activity capacity boundary test — idle-regional-rehome-store.test.ts gains an it.each([10, 11]) case asserting a candidate is committed only when the target has room for the moving host's source activity plus its assignment (7 reserved + 3 activity + 1 assignment = 11); at capacity 10 it defers and leaves the assignment on the source. The negative control makes the boundary exact rather than a truthiness check.
  • Selection-query comment — idle-regional-rehome-selection.ts now documents that the target.reserved_requests + 1 + SUM(activity.request_units) predicate reserves the source's activity units plus the assignment on the target.

The production predicate itself is unchanged from the prior commit; only the comment and the locking test are new, and the test asserts concrete final state (reserved_requests, resolved cellId/assignmentEpoch), so it fails rather than passes vacuously if the accounting regresses.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit cd9aa43 into main Sep 11, 2026
25 checks passed
Jinwoo-H added a commit that referenced this pull request Sep 16, 2026
Snapshot of the uncommitted working tree so nothing is lost when the worktree is
removed. Superseded by main: the region-correction feature landed via #20105,
#20712, #20749, and the pool-canary gate it was blocking on was retired after
the contention was traced to the fleet-wide cell-inventory lock (#21067).
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