Skip to content

Decouple workspace port from Conductor via WORKSPACE_PORT#1575

Merged
maebeale merged 2 commits into
mainfrom
maebeale/rename-conductor-port
Jun 6, 2026
Merged

Decouple workspace port from Conductor via WORKSPACE_PORT#1575
maebeale merged 2 commits into
mainfrom
maebeale/rename-conductor-port

Conversation

@maebeale
Copy link
Copy Markdown
Collaborator

@maebeale maebeale commented Jun 6, 2026

What is the goal of this PR and why is this important?

  • The per-workspace port — used for the workspace database name, session cookie, and dev host — was read directly from Conductor's CONDUCTOR_PORT, hardcoding a dependency on one specific tool.
  • This makes the parallel-worktree isolation mechanism generic so it works for anyone running multiple local instances, not just Conductor users.

How did you approach the change?

  • The app now reads a generic WORKSPACE_PORT env var everywhere (config/database.yml, config/initializers/session_store.rb, config/initializers/default_host.rb, ai/server).
  • The Conductor entry scripts (bin/conductor-setup, bin/conductor-server, bin/conductor-archive) are now the only place CONDUCTOR_PORT is referenced — each exports WORKSPACE_PORT=${WORKSPACE_PORT:-${CONDUCTOR_PORT:-}} near the top, so everything they spawn inherits it.
  • This matches reality: CONDUCTOR_PORT is only injected into those three script processes, not the interactive terminal — so translating it once, upstream, is the natural seam.
  • In bin/conductor-setup the export happens before bin/setup runs so the per-workspace database is created with the right suffix.
  • Documented the contract in CONTRIBUTING.md: Conductor is one optional platform; any other setup can get the same isolation by exporting WORKSPACE_PORT.

Verification

Confirmed via bin/rails runner that the resolved database/cookie are correct in each case:

Scenario Database / cookie
WORKSPACE_PORT=4567 (any system) awbw_development_4567 / _awbw_session_4567
Conductor: CONDUCTOR_PORT → script exports WORKSPACE_PORT suffixed correctly
Raw CONDUCTOR_PORT with no translation correctly ignored by app code
Nothing set base awbw_development

Shell scripts pass sh -n; Rubocop clean on changed Ruby files.

Anything else to add?

  • Trade-off: there's no implicit CONDUCTOR_PORT fallback in the app anymore, so a non-Conductor user must export WORKSPACE_PORT themselves to get an isolated DB/port. This is the intended decoupling and matches prior behavior in the interactive terminal (where CONDUCTOR_PORT was never present).

🤖 Generated with Claude Code

The per-workspace port (used for the database name, session cookie, and
dev host) was read directly from Conductor's CONDUCTOR_PORT, hardcoding a
dependency on one specific tool. This makes the isolation mechanism work
for anyone running parallel worktrees, not just Conductor users.

The app now reads the generic WORKSPACE_PORT everywhere. The Conductor
entry scripts (bin/conductor-*) are the only place CONDUCTOR_PORT is
referenced — they translate it into WORKSPACE_PORT, which is also the
only env Conductor actually injects into those processes. Non-Conductor
setups just export WORKSPACE_PORT themselves.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 6, 2026 21:18
@maebeale maebeale marked this pull request as ready for review June 6, 2026 21:18
Comment thread bin/conductor-setup
# bin/setup) only references WORKSPACE_PORT. Export it before bin/setup runs
# so the per-workspace database is created with the right suffix.
export WORKSPACE_PORT=${WORKSPACE_PORT:-${CONDUCTOR_PORT:-}}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: This export must stay above the bin/setup call so the per-workspace database is created with the right WORKSPACE_PORT suffix. These three conductor-* scripts are the only place CONDUCTOR_PORT is referenced now.

Comment thread config/database.yml Outdated
#
# WORKSPACE_PORT gives each parallel workspace its own database. Under Conductor
# it is derived from CONDUCTOR_PORT by the bin/conductor-* scripts.
<% workspace_port = ENV["WORKSPACE_PORT"] %>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

🤖 From Claude: The app intentionally reads only WORKSPACE_PORT — no CONDUCTOR_PORT fallback here. Translation happens once, upstream, in the bin/conductor-* scripts (the only processes Conductor injects CONDUCTOR_PORT into).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Decouples the app’s “per-workspace isolation” (DB name suffix, session cookie key, and dev hostname behavior) from Conductor-specific CONDUCTOR_PORT by standardizing on a generic WORKSPACE_PORT, with Conductor scripts translating CONDUCTOR_PORT → WORKSPACE_PORT.

Changes:

  • Switch Rails config points (DB, session store, default host) from CONDUCTOR_PORT to WORKSPACE_PORT.
  • Update Conductor lifecycle scripts to export WORKSPACE_PORT and drive PORT from it.
  • Document the new contract in CONTRIBUTING.md and update ai/server to use WORKSPACE_PORT.

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CONTRIBUTING.md Documents WORKSPACE_PORT as the app-level contract and Conductor as an optional provider.
config/initializers/session_store.rb Uses WORKSPACE_PORT to suffix the session cookie key for workspace isolation.
config/initializers/default_host.rb Uses WORKSPACE_PORT to choose awbw.local vs localhost in development.
config/database.yml Uses WORKSPACE_PORT to suffix development/test DB names.
bin/conductor-setup Exports WORKSPACE_PORT upstream of bin/setup; uses it to compute PORT.
bin/conductor-server Exports WORKSPACE_PORT and derives PORT/VITE_RUBY_PORT for Conductor workspaces.
bin/conductor-archive Uses WORKSPACE_PORT for port cleanup and deciding whether to drop workspace DBs.
ai/server Uses WORKSPACE_PORT (if set) as the chosen dev server port.

Comment thread config/initializers/session_store.rb Outdated
Comment thread config/initializers/default_host.rb Outdated
Comment thread config/initializers/default_host.rb Outdated
Comment thread config/database.yml Outdated
The conductor-* scripts export WORKSPACE_PORT even when neither it nor
CONDUCTOR_PORT is set, so Rails receives an empty string rather than nil.
Since "" is truthy in Ruby, that would suffix the database name and
session cookie with a bare underscore and switch the dev host to
awbw.local. Use `.presence` so only a non-empty value takes effect.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@maebeale maebeale merged commit e24a4c6 into main Jun 6, 2026
3 checks passed
@maebeale maebeale deleted the maebeale/rename-conductor-port branch June 6, 2026 22:29
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.

2 participants