Skip to content

fix(derive_name): bump basename cap 12 → 20 so repo names fit - #69

Merged
joelteply merged 1 commit into
canaryfrom
fix/derive-name-truncation
Apr 25, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/derive-name-truncation

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

derive_name was truncating common repo names: ~/Development/ideem/authenticator came back as authenticato-fd63 (missing trailing 'r'). Bump the cap from 12 to 20 chars so full names fit, plus tighten the sanitization pipeline (collapse double dashes, strip leading/trailing).

dir before after
~/Development/ideem/authenticator authenticato-fd63 authenticator-d1f4
~/Development/ideem/vHSM vhsm-2c84 vhsm-d1f4 (unchanged shape)
~/Development/ideem/trusted-app-service trusted-app-s-XXXX trusted-app-service-993e
~/.airc-src (was cambriantech--airc-src) (n/a, hadn't shipped) airc-src-7079

Why short-form, not <org>-<repo>

We considered useideem-authenticator-448f to give cross-room context, but within an auto-scoped room every peer is from the same org by construction (see #66's infer_repo_org), so the org prefix is redundant noise. <repo>-<hash> is the right granularity for the room's audience — easy @-typing, immediately recognizable, no cognitive truncation tax.

Migration note

Existing names persist in <scope>/.airc/identity (derive_name fires on first-init, not every connect). To adopt the new form on a pre-existing scope:

  • airc nick <new> — in-place rename, paired peers auto-update.
  • airc teardown --flush && airc join — fresh derive.

Test plan

  • test/integration.sh — 97/97 pass on this branch
  • Manual spot-check via the helper functions across useideem/cambriantech/personal/non-git dirs

🤖 Generated with Claude Code

The 12-char truncation was producing awkward stubs in the auto-derived
agent name. `~/Development/ideem/authenticator` came back as
`authenticato-fd63` instead of `authenticator-fd63`; the missing
trailing 'r' was an immediate cognitive speed bump for anyone trying
to match agent names to repos in a busy multi-tab room.

Bump the cap to 20 chars so common repo names fit cleanly:
  authenticator        → authenticator-d1f4
  vHSM                 → vhsm-d1f4
  trusted-app-service  → trusted-app-service-993e
  merchant-browser-sim → merchant-browser-sim-XXXX
  airc                 → airc-d1f4

Also tighten the sanitization pipeline: collapse runs of dashes
(`cambriantech--airc-src` → `cambriantech-airc-src`), strip leading
and trailing dashes, and re-strip after the cut so a truncation that
falls on a dash doesn't leave a dangling tail. Pure cosmetic — safer
default, no behavior change beyond the cap.

Within an auto-scoped room, every peer is from the same org by
construction (see infer_repo_org from #66), so the org prefix would
just be redundant noise on every name. The repo basename + 4-char
hash is the right granularity for the room's audience.

Existing names persist in `<scope>/.airc/identity` — derive_name
fires on first-init, not on every connect. To pick up the new form
in an existing scope: `airc nick <new>` for in-place rename, or
`airc teardown --flush && airc join` for a fresh derive.

97/97 integration tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 25, 2026 04:16
@joelteply
joelteply merged commit 91f81a9 into canary Apr 25, 2026
3 checks passed
@joelteply
joelteply deleted the fix/derive-name-truncation branch April 25, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates derive_name so auto-derived peer nicknames better fit common repo names and are more consistently sanitized.

Changes:

  • Increase derived basename cap from 12 → 20 characters.
  • Tighten basename sanitization (collapse repeated dashes; strip leading/trailing dashes).
  • Update derive_name doc comment to reflect the naming intent in org-scoped rooms.
Comments suppressed due to low confidence (1)

airc:85

  • derive_name computes hash via a shasum | cut pipeline under set -euo pipefail. If shasum is missing or errors, the script will exit immediately and the cksum fallback below will never run. Consider guarding with command -v shasum (or otherwise making the shasum attempt non-fatal) so the fallback is actually reachable.
  hash=$(printf '%s' "$dir" | shasum -a 256 2>/dev/null | cut -c1-4)
  [ -z "$hash" ] && hash=$(printf '%s' "$dir" | cksum | cut -c1-4)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread airc
Comment on lines +60 to +81
# Format: <repo>-<4-char-hash> when in a git repo (basename of the git
# top-level), or <dir-basename>-<4-char-hash> otherwise. Hash
# disambiguates same-name directories across different parent paths
# (two "src" dirs, two clones of the same repo, etc.).
#
# Within a room scoped to a single org (which is the auto-scope default
# — see infer_repo_org), every peer is from that org by construction, so
# adding the org as a name prefix is redundant and lengthens @-mentions.
# Cap is 20 chars on the basename, comfortably fitting common repo names
# (`authenticator-d1f4`, `merchant-browser-d1f4`) without truncation.
# Users can override any time with `airc nick`.
derive_name() {
local dir="${1:-$(pwd -P)}"
# Prefer git root basename — more meaningful than a subdir basename when
# the user happens to be deep in a repo — but hash the actual cwd so
# subdirs still get unique names.
local base_dir git_root
local base_dir git_root base
git_root=$(cd "$dir" 2>/dev/null && git rev-parse --show-toplevel 2>/dev/null)
base_dir="${git_root:-$dir}"
local base
base=$(basename "$base_dir" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | cut -c1-12)
base=$(basename "$base_dir" \
| tr '[:upper:]' '[:lower:]' \
| sed 's/[^a-z0-9-]/-/g' \
| sed 's/--*/-/g; s/^-*//; s/-*$//' \
| cut -c1-20 \
| sed 's/-*$//')

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

This PR updates bash derive_name to cap/sanitize repo basenames, but the Windows implementation in airc.ps1 (Derive-Name, currently caps at 12 and doesn’t collapse/trim dashes; see airc.ps1:145-164) still derives different/truncated names. If Windows is a supported platform, the PowerShell version should be updated in the same way (or the docs should clarify the behavior divergence).

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +76 to +81
base=$(basename "$base_dir" \
| tr '[:upper:]' '[:lower:]' \
| sed 's/[^a-z0-9-]/-/g' \
| sed 's/--*/-/g; s/^-*//; s/-*$//' \
| cut -c1-20 \
| sed 's/-*$//')

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

The basename sanitization + length cap behavior here is user-visible and easy to regress, but it isn’t covered by the integration suite today (the suite typically sets AIRC_NAME). Consider adding a small test that runs airc debug-name in temp dirs with representative names (e.g., long repo name, leading dot, double dashes) to assert the expected <base>-<hash> shape and the 20-char cap.

Copilot uses AI. Check for mistakes.
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