Deep-check the live-test VibeComfy claim isolation issue in /Users/user_c042661f/Documents/reigh-workspace. Context: in reigh-app-cloud-chain, claim-next-task appears to evaluate route_backend_claim_decision with v_effective_selector_namespace rather than each task's selector_namespace, so a production VibeComfy worker claimed live-test tasks intended for pod uem4ds6heuwu83. Inspect the claim RPC/migrations and reigh-worker live_test task stamping, then report: (1) the smallest correct DB/function fix, (2) any harness changes needed to create/use isolated selector namespaces, (3) tests that should be updated. Do not edit files.
Assistant
I’ll inspect the relevant app and worker code paths without editing files. I’ll trace the DB claim function first, then the live-test task creation/stamping path, and finally map the existing tests around those contracts.
Assistant
The broad search found the likely culprit in two recent migrations: the first selector migration and the later VibeComfy GPU-claim migration. I’m narrowing onto the final function definitions and the live-test insertion code now.
Assistant
The live harness does stamp params.route_contract and task columns from CLI --selector-namespace, but the DB claim path is still using the worker namespace for every queued row. I’m checking whether the edge function passes that through unchanged and whether the tests already encode the weaker behavior.
Assistant
I inspected the claim RPC, edge function, and live-test stamping. I did not edit files.
1. Smallest Correct DB Fix
The real fix belongs in the SQL RPCs, not the edge function.
In 20260507165000_allow_vibecomfy_gpu_claims_for_route_selected_api_tasks.sql, claim_next_task_service_role calls:
again in the main ready-task CTE at line 196. That lets a production VibeComfy worker evaluate isolated live-test rows against production, then claim them.
Apply that in both claim-decision sites inside claim_next_task_service_role: the same-model/starvation pre-scan and the ready_tasks CTE.
The count RPCs have the same issue. count_eligible_tasks_service_role and count_queued_tasks_breakdown_service_role also evaluate queued rows with the worker namespace. They should use the same task-effective namespace filter, otherwise worker polling/count telemetry can still report cross-namespace work.
No edge-function change is needed for the claim path: claim-next-task/index.ts already passes p_selector_namespace through.
2. Harness Changes Needed
The live-test harness currently defaults --selector-namespace to production in main.py. It does stamp route contracts and task columns correctly via matrix.py and task_spoofer.py, but it does not create isolated selector rows.
Needed harness behavior:
Default live tests to a generated namespace such as lt-<timestamp>-<short-pod-id> instead of production.
Use the same namespace in worker env, worker metadata, route contract, and task columns.
Before queueing VibeComfy route cases, create or copy route_backend_selectors rows for that isolated namespace and the selected route keys.
Set expires_at or clean up/disable those rows after the run.
For update mode, either require --selector-namespace or derive it deterministically from the target pod id.
Without selector rows, isolated VibeComfy tasks should fail closed as missing_selector_vibecomfy_no_claim, which is correct but means the harness must provision the namespace.
3. Tests To Update
Update/add tests in both repos:
App SQL test: claim-next-task/index.test.ts currently reads the older 20260506113000 migration and only checks broad SQL strings. It should read the latest claim migration and assert queued decisions use task-effective namespace plus worker/task namespace equality.
Add a migration-level regression test for: production VibeComfy worker cannot claim a queued task with tasks.selector_namespace = 'uem4ds6heuwu83'.
Add the inverse: worker with p_selector_namespace = 'uem4ds6heuwu83' can claim that row only when a selector exists in that namespace.
Add count RPC coverage for the same isolation behavior.
Worker live-test tests in test_primitives.py should expect non-production generated/explicit namespaces and verify selector provisioning, not just task stamping.
Keep the existing task spoofer promotion test, but change it away from production so it catches regressions in isolated namespace stamping.