fix(caller): _default_repl_caller convention-safe slug (closes #83)#84
Merged
Conversation
The repl-default caller rolled its own slug that — unlike caller._sanitize_username which default_caller uses — didn't guarantee a leading letter / collapse underscores / fall back on empty. So a leading-digit OS username produced a non-conforming 'cli.repl.3bob' that crashes SwarphCall at runtime (the #80 crash-class on the dynamic path). Fix is DRY: reuse the one robust sanitizer, eliminating the divergence (USER=3bob -> cli.repl.u_3bob; !!! -> cli.repl.unknown). + a parametrized adversarial- username regression test (leading-digit/all-special/empty/etc). No production behavior change for normal usernames; 53 chat/caller tests green, #80+#82 unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
darw007d
added a commit
that referenced
this pull request
Jun 21, 2026
…, repl-caller #83/#84) Ships the dotted caller-convention fixes that were merged to main but unreleased: - #80: compress shorthand + verify-expand model paths were DEAD at runtime (hyphenated callers rejected by swarph_shared's dotted convention) — now dotted constants. - #82: repo-wide validate_caller meta-guard so the bug class can't be re-introduced. - #83/#84: _default_repl_caller convention-safe slug (reuses _sanitize_username). Anyone on 0.13.2 running `swarph compress` hit the dead path; this releases the fix. Co-Authored-By: Claude Opus 4.8 <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.
Closes #83 — the #80/#82 sibling on the dynamic caller path, surfaced by the PR #82 meta-guard.
Bug
_default_repl_caller(chat.py) built its slug with an inline"".join(c if c.isalnum() else "_" ...)that, unlikecaller._sanitize_username(whichdefault_calleruses), did NOT guarantee an[a-z]-leading char, collapse underscores, or fall back on empty. So a leading-digit OS username →USER=3bob→cli.repl.3bob→ fails^[a-z]...→ crashes SwarphCall at runtime (same class as #80, dynamic path).Fix (DRY — droplet's narrowing: default_caller is the template)
Reuse the one robust sanitizer:
return f"cli.repl.{_sanitize_username(user)}". Eliminates the divergence (two sanitizers, one safe one not → now one). No circular import (caller.py imports only getpass/os/re).Tests (TDD — written failing first)
test_repl_caller_convention.py: parametrized over adversarial usernames (leading-digit, all-digit, all-special, uppercase, dotted, hyphenated, underscore-only, whitespace) — each mustvalidate_callerclean; + a guard that it stayscli.repl.*(distinct fromcli.oneshot.*). RED before the fix (5 failures), GREEN after. No regression: #80 compress + #82 meta-guard + 53 chat/caller tests green.Found-by: the #82 meta-guard's ambient-state surface. Narrowing: droplet.
🤖 Generated with Claude Code