feat: per-service port drift in wt new and wt setup#2
Merged
Conversation
Replaces the current behavior where slots are skipped (auto path) or errors are thrown (--slot N path) when ports are already in use. Per- service drift forward by 1 until a port is both OS-free and not in the registry, with a stderr line identifying the listener via lsof. Also fixes a latent bug in setup.ts where re-running setup on an existing allocation would overwrite registered ports with formula values — invisible today but harmful once drift exists. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Eight-task plan with TDD steps for each: types, parseLsofOutput, describeListener, allocateServicePorts core, wiring into new.ts, wiring into setup.ts (with the existing-allocation port-reuse fix), removal of dead code, and final verification. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ocument conflict invariant Replace hard-coded 3200/4200 with OS-assigned ephemeral ports to prevent spurious test failures when those ports are bound on the developer's machine or CI runner. Add an explanatory comment next to the conflict! non-null assertion to document the invariant that makes it safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…gging Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t-slot test coverage Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ailablePortSafeSlot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
wt neworwt setupallocates ports, in-use ports now drift forward by 1 instead of failing or silently skipping the slot.Port 3200 (web) in use by node[12345]; using 3201 instead.vialsof(best-effort, never throws).reserved by slot 1 (web)instead.data.portDrifts: PortDrift[]in--jsonpayloads from both commands; stderr lines are suppressed in that mode.findAvailablePortSafeSlot(which silently skipped slots with port conflicts) is gone, so you no longer end up in a higher slot for non-obvious reasons.wt setupport-reuse fix. Re-running setup on an existing worktree (e.g., from thepost-checkouthook) now reuses the registered ports verbatim. Previously it recomputed via the formula, which is invisible today but would silently overwrite drifted ports once drift exists.Spec:
docs/superpowers/specs/2026-04-24-port-drift-allocation-design.mdPlan:
docs/superpowers/plans/2026-04-25-port-drift-allocation.mdBumps version to 0.4.1.
Test Plan
🤖 Generated with Claude Code