feat(node): lib-level auto-suffix name resolver (resolveAvailableName)#31
Open
sym-bot wants to merge 1 commit into
Open
feat(node): lib-level auto-suffix name resolver (resolveAvailableName)#31sym-bot wants to merge 1 commit into
sym-bot wants to merge 1 commit into
Conversation
Same-host node-id collision resilience lived only in the sym-mesh-channel
host (server.js resolveNodeName). Every other @sym-bot/sym host — the sym
CLI (`sym start`), sym-swift, custom agents — still hard-failed with
EIDENTITYLOCK when two co-resident processes wanted the same name (a
duplicate dev agent, or sessions sharing a fixed SYM_NODE_NAME).
Move the resolver down into the lib so all hosts share it:
- config.js: add resolveAvailableName(base, {maxSuffix=64}) — returns the
base when free / stale / our own, else appends -2/-3/… past live foreign
holders. Over-64-byte candidates are skipped; exhausting maxSuffix falls
back to base so acquireIdentityLock still hard-fails (backstop preserved).
- factor the liveness probe into pidIsAlive(); acquireIdentityLock now
reuses it (behavior-identical), and lockHolderPid() reads a holder PID.
Both exported for hosts/tests.
- node.js: opt-in `opts.autoSuffix` (default OFF — strict throw stays the
default so double-launch detection is unchanged). Resolves BEFORE
identity/dir/lock derive from this.name; node.requestedName keeps the
original. Hosts read node.name for the resolved value.
Lets sym-mesh-channel delegate to the lib instead of its own copy.
Tests: 14 new (resolveAvailableName/pidIsAlive/lockHolderPid) — live
foreign holder via a spawned child, dead-PID, own-PID, multi-skip,
64-byte overflow, validation. config 41/41, node 17/17. The 4 ask/
llm-reason failures are pre-existing/env (claude CLI present → NO_PROVIDER
path), unrelated to this change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Moves same-host node-id collision resilience down from the sym-mesh-channel host into
@sym-bot/sym, so every host shares it (thesymCLI, sym-swift, custom agents) — not just mesh-channel'sserver.js resolveNodeName.Why
Today only sym-mesh-channel auto-suffixes on a name clash. Any other
@sym-bot/symhost hard-fails withEIDENTITYLOCKwhen two co-resident processes want the same name (duplicate dev agent, or sessions sharing a fixedSYM_NODE_NAME).Changes
config.js—resolveAvailableName(base, {maxSuffix=64}): base when free/stale/own, else-2/-3/…past live foreign holders. Over-64-byte candidates skipped; exhaustingmaxSuffixreturns base soacquireIdentityLockstill throws (backstop preserved). FactoredpidIsAlive()(now reused byacquireIdentityLock, behavior-identical) +lockHolderPid(); all exported.node.js— opt-inopts.autoSuffix(default OFF — strict throw stays default; double-launch detection unchanged). Resolves before identity/dir/lock derive fromthis.name;node.requestedNamepreserves the original.Follow-up (not in this PR)
sym-mesh-channelserver.jscan delegate toresolveAvailableNameand drop its local copy.Tests
14 new (
resolveAvailableName/pidIsAlive/lockHolderPid) — live foreign holder via spawned child, dead-PID, own-PID, multi-skip, 64-byte overflow, validation. config 41/41, node 17/17. The 4ask/llm-reasonfailures are pre-existing/env (claude CLI present →NO_PROVIDERpath), unrelated.🤖 Generated with Claude Code