Skip to content

fix(compress): dotted caller convention — unbreak shorthand + verify-expand#80

Merged
darw007d merged 1 commit into
mainfrom
fix/compress-caller-convention
Jun 20, 2026
Merged

fix(compress): dotted caller convention — unbreak shorthand + verify-expand#80
darw007d merged 1 commit into
mainfrom
fix/compress-caller-convention

Conversation

@darw007d

Copy link
Copy Markdown
Collaborator

Summary

swarph compress --lever shorthand (and the adversarial verify-expand) have been dead at runtime since a caller-convention validator landed in swarph_shared after #64. Both constructed SwarphCall with hyphenated caller tags (swarph-compress / swarph-compress-verify), which the validator rejects:

CALLER_PATTERN = ^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$   # dotted, not hyphenated
ValueError: caller 'swarph-compress' does not match convention

The archival lever (no model call) was unaffected, which masked the break.

Fix

  • Extract the tags to module constants: SHORTHAND_CALLER="swarph.compress", VERIFY_EXPAND_CALLER="swarph.compress.verify".
  • Use them in the SwarphCall(...) construction.
  • Add tests/test_compress_caller_convention.py that runs validate_caller() on the real tags — the existing levers/verify tests inject a fake chat and never build a real SwarphCall, which is exactly why this shipped silently.

How found

Dry-run of swarph compress on a live memory-index surface (commander-requested) crashed at SwarphCall(...); archival on a manual surface ran clean. Verified the fix at the exact crash point (SwarphCall now constructs with both dotted callers) + 20/20 compress tests green.

Notes for review

  • Touches only compress/levers.py, compress/verify.py, and a new test — zero overlap with watchdog.py.
  • Requesting the 6-dim hardening gate review.

🤖 Generated with Claude Code

… model calls

The shorthand and verify-expand paths constructed SwarphCall with hyphenated
caller tags ('swarph-compress' / 'swarph-compress-verify'). A caller-convention
validator added to swarph_shared after #64 requires dotted role.subrole form
(^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$), so both model-driven paths crashed at
runtime with ValueError — archival (no model call) was unaffected, masking it.

Extract the tags to module constants SHORTHAND_CALLER='swarph.compress' and
VERIFY_EXPAND_CALLER='swarph.compress.verify', and add a regression test that
validates them directly. The existing levers/verify tests inject a fake chat and
never construct a real SwarphCall, which is why the break shipped silently.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@darw007d darw007d merged commit 930263b into main Jun 20, 2026
2 checks passed
@darw007d darw007d deleted the fix/compress-caller-convention branch June 20, 2026 20:24
darw007d pushed a commit that referenced this pull request Jun 20, 2026
…oplet review)

Folds in droplet's two non-blocking polish items pre-merge:
1. COMMIT the catch-property (don't manually-verify-once) — test_guard_catches_a_planted_bad_caller
   plants a hyphenated *_CALLER on a discovered module + asserts the guard discovers AND
   rejects it. This is #80's own lesson applied to the meta-guard: pin it, don't remember it.
2. test_no_modules_skipped_by_the_walk asserts the introspection walk skips ZERO modules, so a
   bad caller in a module importable-in-prod-but-not-CI can't ship silently uncaught.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
darw007d added a commit that referenced this pull request Jun 20, 2026
* harden(caller): repo-wide validate_caller meta-guard (#81)

Import-introspection over every `*_CALLER` constant in the swarph_cli package +
validate_caller each, so the #80 hyphenated-caller bug class can't be re-introduced
in ANY module without a per-caller test. Converged design (lab+droplet): introspect
named constants, not AST literal-walk — `caller=SHORTHAND_CALLER` is an ast.Name,
not a literal, so a literal-walk would miss exactly the callers #80 hardened.
Negative-control verified (a planted hyphenated *_CALLER is discovered + caught).
Test-only; no production change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* harden(caller): pin the negative-control + assert exhaustive walk (droplet review)

Folds in droplet's two non-blocking polish items pre-merge:
1. COMMIT the catch-property (don't manually-verify-once) — test_guard_catches_a_planted_bad_caller
   plants a hyphenated *_CALLER on a discovered module + asserts the guard discovers AND
   rejects it. This is #80's own lesson applied to the meta-guard: pin it, don't remember it.
2. test_no_modules_skipped_by_the_walk asserts the introspection walk skips ZERO modules, so a
   bad caller in a module importable-in-prod-but-not-CI can't ship silently uncaught.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: lab-ovh <lab@brainsurfing.tech>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
darw007d added a commit that referenced this pull request Jun 20, 2026
…) (#84)

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: lab-ovh <lab@brainsurfing.tech>
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>
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.

1 participant