Skip to content

fix(lab): rebind CL-08 runtime ownership across server replacement - #1719

Merged
lidge-jun merged 2 commits into
devfrom
fix/cl08-activation-runtime-rebind
Aug 15, 2026
Merged

fix(lab): rebind CL-08 runtime ownership across server replacement#1719
lidge-jun merged 2 commits into
devfrom
fix/cl08-activation-runtime-rebind

Conversation

@Wibias

@Wibias Wibias commented Aug 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Split Compatibility Lab activation into process-wide static registration and server-owned CL-08 runtime ownership.
  • Rebind dispatch authority and the automation scheduler when a predecessor server owner has ended or a fresh same-root server instance takes over.
  • Keep successor ownership safe from predecessor cleanup by installing the new runtime binding before releasing the old one.
  • Add regressions for both an overlapping same-root successor and a sequential same-process restart.

Root cause

Follow-up to #1447.

activateLab() cached activation by configDir for the process lifetime. Later lifecycle hardening made setLabAutomationDispatchDeps() and the scheduler server-owner scoped. When that owner released, CL-08 dispatch authority and its scheduler were removed, but the process-wide activation cache still said the root was active. A replacement server then returned early from activateLab() and never restored CL-08 runtime authority.

The same mismatch also meant an overlapping same-root successor could not take ownership before its predecessor released.

Fix

The activation record now keeps static Lab slots separate from the current runtime binding. Runtime cleanup updates that record through the existing server-resource owner. A fresh config object can take over an active root, while already-seen predecessor configs cannot steal authority back on a later management request. If the current runtime owner has already ended, the next activation can rebind even when the same config object is reused.

The existing dispatcher token semantics remain authoritative: the successor is installed first, then predecessor release becomes a no-op for the successor scheduler and dispatch authority.

Verification

  • Branch is based on current dev SHA 81ada7cd092d4be3b25f3013c996cd3262a2f99b.
  • Compare against dev: 2 commits ahead, 0 behind.
  • Diff is limited to src/lib/lab-activation.ts and tests/lab-activation.test.ts.
  • Added regression coverage for:
    • same-root successor surviving predecessor owner release;
    • same-process restart reacquiring automation after the prior owner ended.
  • This execution environment has no Bun runtime or gh, so local test/typecheck execution is not available. GitHub Actions is the execution authority for this branch.

Scope

No user-facing configuration, database migration, dependency, environment-variable, routing-policy, or documentation changes.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes are not needed for this internal lifecycle correction.
  • Security-sensitive authority handoff was reviewed for stale-owner cleanup and successor isolation.

Summary by CodeRabbit

  • New Features

    • Improved lab activation handling for repeated starts, restarts, and server ownership changes.
    • Preserved static registrations while allowing runtime automation services to be reassigned safely.
    • Added clearer handling when automation startup is blocked or configuration is invalid.
  • Bug Fixes

    • Improved cleanup and recovery of automation services after ownership changes.
    • Prevented duplicate runtime bindings and ensured reliable release behavior.

@Wibias Wibias added the bug Something isn't working label Aug 14, 2026 — with ChatGPT Codex Connector
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f56a0edd-96ee-4bfa-91ac-23fda51d650f

📥 Commits

Reviewing files that changed from the base of the PR and between 81ada7c and 8acdb23.

📒 Files selected for processing (2)
  • src/lib/lab-activation.ts
  • tests/lab-activation.test.ts

📝 Walkthrough

Walkthrough

Lab activation now separates static registrations from server-owned runtime bindings. Automation dependencies and route execution are rebound per owner, with idempotent cleanup and isolated startup errors. Tests cover successor ownership, same-process restart, and scheduler lifecycle.

Changes

Lab activation runtime lifecycle

Layer / File(s) Summary
Runtime binding state model
src/lib/lab-activation.ts
Activation records static detach handlers, optional runtime bindings, and configurations that previously owned the runtime.
Runtime installation and rebinding
src/lib/lab-activation.ts
Automation startup installs dispatch dependencies and route execution for the active owner. Successor bindings replace predecessors after installation. Startup errors distinguish lock contention from configuration failures.
Cleanup and lifecycle validation
src/lib/lab-activation.ts, tests/lab-activation.test.ts
Teardown releases runtime bindings before static handlers. Tests cover successor ownership, same-process restart, scheduler persistence, ownership resets, and failed scheduler startup.

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

Merge Risk: ⚪ Minimal · up to 8acdb

The PR makes a localized lifecycle fix for CL-08 runtime ownership and adds regressions for successor handoff and same-process restart behavior; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant LabActivation
  participant ServerResourceOwnership
  participant AutomationScheduler
  LabActivation->>ServerResourceOwnership: Install runtime binding
  ServerResourceOwnership-->>LabActivation: Establish active owner
  LabActivation->>AutomationScheduler: Start automation
  AutomationScheduler-->>LabActivation: Return startup result
  LabActivation->>ServerResourceOwnership: Release predecessor binding
Loading

Possibly related PRs

Suggested labels: chore

Suggested reviewers: lidge-jun, ingwannu

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: rebinding CL-08 runtime ownership during server replacement.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cl08-activation-runtime-rebind

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.

@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@Wibias
Wibias marked this pull request as ready for review August 15, 2026 00:08
@lidge-jun
lidge-jun merged commit a2f01ac into dev Aug 15, 2026
36 of 37 checks passed
@Wibias
Wibias deleted the fix/cl08-activation-runtime-rebind branch August 15, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants