Skip to content

feat(identity): agent identity layer + cross-platform linking (closes #34) - #70

Merged
joelteply merged 1 commit into
canaryfrom
feat/agent-identity-layer
Apr 25, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/agent-identity-layer

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Implements issue #34 — agent identity layer with cross-platform linking. Five structured fields layered on top of the derived bootstrap name, exchanged at pair-handshake so airc whois <peer> works without round-trips. Plus IRC-style airc kick for host-only peer eviction.

What's in

command purpose
airc identity show print own pronouns/role/bio/status/integrations
airc identity set [--pronouns X] [--role Y] [--bio \"…\"] [--status \"…\"] write fields
airc identity link <platform> <handle> record cross-platform mapping
airc identity import continuum:<persona> live pull from continuum CLI; stubs error gracefully for slack/telegram/discord
airc identity push continuum live send to continuum
airc whois [<peer>] self / host / paired peer / cross-peer-via-host
airc kick <peer> [reason] host-only IRC-style boot

Why

A name like authenticator-d1f4 tells you which repo an agent is running from but nothing about who they are. In a multi-agent room — agents from different orgs, different roles, different contexts — that's a meaningful gap. Pronouns enable correct grammatical narration. Role disambiguates without lengthening names. Bio gives one-line context. The integrations map is the high-leverage piece: an agent can be "Earl" on continuum AND device-link-d1f4 on airc AND U07ABC on slack — same persona, three surfaces.

The IRC verb set in airc was almost complete (#67) — this PR closes the WHOIS gap and adds kick. After this lands, airc covers IRC's primitives 1:1 and adds the cross-platform identity layer where IRC stopped.

Handshake protocol changes

Backward compatible — every missing field defaults to {}:

  • Joiner sends identity blob alongside ssh_pub / sign_pub.
  • Host stores it in peers/<jname>.json under identity.
  • Host returns own identity in response; joiner caches as host_identity.
  • Cross-peer WHOIS reads remote peer file via single SSH cat.

A v1 host pairing with a legacy bash joiner (or a PS1 joiner — see deferred) just gets empty identity, no breakage.

Skill updates

  • New §2a "Identity bootstrap" — prompt agent to fill empty fields on every /join with persistent (non-nagging) re-prompts. AIRC_NO_IDENTITY_PROMPT=1 skips for tests.
  • §2b updated — narrate auto-WHOIS on peer-join: when a new peer joins, run airc whois <peer> and surface their role + bio in chat so context loads automatically.

Test harness fix (incidental)

While building this I discovered cleanup_dirs was silently broken on macOS — find /tmp -maxdepth 1 doesn't traverse the /tmp → /private/tmp symlink, so stale state from previous suite invocations leaked forward indefinitely. Resolve to canonical path before walking. Linux unaffected.

This was making scenario_identity flaky in all mode (saw "pronouns: they" survive across runs). Fix is in this PR because it surfaced here, but it's an independent test-harness improvement.

Test plan

  • test/integration.sh — 126/126 pass on macOS (clean ports + clean state)
  • Three new scenarios: scenario_identity (16 assertions), scenario_whois (5), scenario_kick (6)
  • Manual smoke: identity show/set/link/whois on a single scope; whois roundtrip across host↔joiner; kick removes peer file + SSH key
  • Live cross-tab demo on #useideem (vhsm tab + authenticator tab) once merged

Out of scope (deferred follow-ups, separate issues/PRs)

  • airc.ps1 parity for Windows. Reaching out to green (the PS1 author) about coordination.
  • airc ban — permanent block list, complement to airc kick which currently lets kicked peers re-pair.
  • Live slack / telegram / discord import-push — only continuum works in v1; others are typed stubs that error gracefully with the manual-link fallback.

🤖 Generated with Claude Code

Adds structured agent persona on top of the bootstrap name from
derive_name. Five fields, all optional, all settable post-pair:

  pronouns      she/they/he/it for grammatical narration
  role          short hyphenated tag, e.g. device-link-orchestrator
  bio           one-line free-form, IRC-realname analog
  status        mutable "what I'm working on now" (Slack-like)
  integrations  {platform: handle} mappings (continuum, slack, …)

Stored under config.json's `identity` key (single-file scope) and
exchanged at pair-handshake time so peers cache each other's identity
locally and `airc whois` works without round-trips.

New commands:
  airc identity show
  airc identity set [--pronouns X] [--role Y] [--bio "…"] [--status "…"]
  airc identity link <platform> <handle>
  airc identity import <platform>:<id>      # continuum live, others stub
  airc identity push <platform>             # continuum live, others stub
  airc whois [<peer>]                       # self / host / paired peer / cross-peer-via-host
  airc kick <peer> [reason]                 # host-only IRC-style kick

Handshake protocol additions (backward compatible — missing fields
default to {}, so a v1 host pairing with a legacy joiner just gets
empty identity):
  - Joiner sends `identity` blob alongside ssh_pub/sign_pub
  - Host stores it in peers/<jname>.json under `identity`
  - Host returns own identity in response; joiner caches as host_identity
  - Cross-peer WHOIS reads remote peer file via single SSH cat

Skill updates (skills/join/SKILL.md):
  - New §2a "Identity bootstrap" — prompt agent to fill empty fields
    on every /join with persistent (non-nagging) re-prompts, skip
    via AIRC_NO_IDENTITY_PROMPT=1
  - §2b updated — auto-WHOIS on peer-join so context loads when a
    new peer joins the room

Test harness fix (incidental but load-bearing):
  cleanup_dirs was silently broken on macOS — `find /tmp -maxdepth 1`
  doesn't traverse the /tmp → /private/tmp symlink, so stale state from
  previous suite invocations leaked forward and caused flaky
  scenario_identity failures (saw "pronouns: they" survive into a
  fresh run). Resolve to canonical path before walking. Linux
  unaffected.

cmd_connect's host-mode + joiner-mode config writes converted from
heredoc to python json-merge so the `identity` block survives
re-pairs (teardown + airc connect), matching user expectation that
identity is sticky like nick.

Three new integration scenarios (29 new assertions, 126/126 total):
  scenario_identity   — local set/show/link/whois/persistence
  scenario_whois      — handshake exchange (host→joiner direction)
  scenario_kick       — host kicks joiner; joiner kick attempt refused

Deferred to follow-ups (not blocking this PR):
  - airc.ps1 parity for Windows (talking to green on continuum side)
  - airc ban (permanent block, complement to kick)
  - Live slack/telegram/discord import-push (continuum is the v1
    integration that actually works)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 25, 2026 12:15
@joelteply
joelteply merged commit 424f31b into canary Apr 25, 2026
3 checks passed
@joelteply
joelteply deleted the feat/agent-identity-layer branch April 25, 2026 12:19

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

Adds an identity layer to AIRC and exchanges it during the pairing handshake so airc whois can display peer metadata locally, plus introduces a host-only airc kick command and updates docs/tests around these behaviors.

Changes:

  • Add airc identity {show,set,link,import,push} and store identity fields in config.json.
  • Extend the pair-handshake payload/response to include identity and cache host/joiner identity for airc whois (including cross-peer lookup via host SSH).
  • Add airc kick and new integration scenarios; fix macOS /tmp cleanup behavior in the test harness.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
airc Implements identity storage/printing, handshake identity exchange, whois, and kick, plus config merge behavior.
test/integration.sh Fixes macOS tmp cleanup and adds new integration scenarios for identity/whois/kick.
skills/join/SKILL.md Documents identity bootstrap prompting and adds guidance to run whois on peer join.

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

Comment thread airc
Comment on lines +2404 to +2410
local host_target; host_target=$(get_config_val host_target "")
local host_airc_home; host_airc_home=$(get_config_val host_airc_home "")
if [ -n "$host_target" ] && [ -n "$host_airc_home" ]; then
local remote_blob
remote_blob=$(relay_ssh "$host_target" "cat $host_airc_home/peers/$target.json 2>/dev/null" 2>/dev/null || true)
if [ -n "$remote_blob" ]; then
local peer_id; peer_id=$(printf '%s' "$remote_blob" | python3 -c '

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.

cmd_whois builds a remote shell command using unquoted $host_airc_home and the user-supplied $target (e.g. cat $host_airc_home/peers/$target.json). Because relay_ssh passes this through ssh to a remote shell, names with spaces/metacharacters can break the command or be used for command injection. Please validate $target against the allowed peer-name pattern (e.g. ^[a-z0-9-]+$) and safely quote/escape the remote path (or pass it via a Python helper / printf %q) before executing over SSH.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +2489 to +2503
# Pull peer's SSH pubkey out of authorized_keys (best-effort — pubkey
# lives in $PEERS_DIR/$target.pub if recorded; otherwise we leave the
# ssh key in place and rely on peer-file deletion to break the
# bookkeeping). Each step `|| true` since set -euo pipefail is active
# and benign no-match / missing-file cases are normal here.
local peer_pub_file="$PEERS_DIR/$target.pub"
if [ -f "$peer_pub_file" ] && [ -f "$HOME/.ssh/authorized_keys" ]; then
local peer_pub; peer_pub=$(cat "$peer_pub_file" 2>/dev/null || echo "")
if [ -n "$peer_pub" ]; then
# grep -v returns 1 when every line matches (or the file is empty);
# both are fine outcomes here, so eat the exit code.
grep -vF "$peer_pub" "$HOME/.ssh/authorized_keys" > "$HOME/.ssh/authorized_keys.tmp" 2>/dev/null || true
[ -f "$HOME/.ssh/authorized_keys.tmp" ] && mv "$HOME/.ssh/authorized_keys.tmp" "$HOME/.ssh/authorized_keys"
chmod 600 "$HOME/.ssh/authorized_keys" 2>/dev/null || true
fi

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.

cmd_kick attempts to remove the peer’s SSH key from ~/.ssh/authorized_keys by reading $PEERS_DIR/$target.pub, but that .pub file is written from the handshake’s sign_pub (public.pem), not the SSH public key. As a result, the grep -vF removal will usually be a no-op and the kicked joiner can still SSH/append messages. To make kick effective, persist the joiner’s ssh_pub in the peer record (or a dedicated file) during pairing and use that exact line to remove from authorized_keys.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines 2106 to 2115
json.dump({
'name': jname,
'host': joiner.get('host',''),
'airc_home': joiner.get('airc_home', ''),
'paired': '$(timestamp)'
'paired': '$(timestamp)',
# Cache joiner's identity blob (issue #34 v2). Empty on legacy
# peers that don't send the field — airc whois prints the
# 'not exchanged yet' fallback gracefully.
'identity': joiner.get('identity', {})
}, f, indent=2)

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 host pairing code stores joiner identity into peers/.json but does not persist the joiner’s ssh_pub anywhere in peers/. cmd_kick needs the ssh_pub to reliably revoke access by removing the exact key line from authorized_keys. Consider writing joiner['ssh_pub'] into the peer JSON (e.g. ssh_pub field) or a dedicated peers/.ssh.pub file at pair-time so kick can be implemented correctly and deterministically.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +1599 to +1608
import json, os
try:
c = json.load(open(os.environ["CONFIG"]))
except Exception:
c = {}
c["name"] = os.environ["MY_NAME"]
c["host"] = os.environ["MY_HOST"]
c["host_target"] = os.environ["SSH_TARGET"]
c["created"] = os.environ["CREATED"]
json.dump(c, open(os.environ["CONFIG"], "w"), indent=2)

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 new config.json merge writes directly to the config file with json.dump(open(..., "w")), which is not atomic and can be observed as a partially-written file by concurrent reads (the new integration test even adds a sleep to avoid this). Consider writing to a temp file and renaming it into place (atomic on the same filesystem) to avoid transient JSON corruption and remove the need for timing sleeps.

Suggested change
import json, os
try:
c = json.load(open(os.environ["CONFIG"]))
except Exception:
c = {}
c["name"] = os.environ["MY_NAME"]
c["host"] = os.environ["MY_HOST"]
c["host_target"] = os.environ["SSH_TARGET"]
c["created"] = os.environ["CREATED"]
json.dump(c, open(os.environ["CONFIG"], "w"), indent=2)
import json, os, tempfile
config_path = os.environ["CONFIG"]
try:
c = json.load(open(config_path))
except Exception:
c = {}
c["name"] = os.environ["MY_NAME"]
c["host"] = os.environ["MY_HOST"]
c["host_target"] = os.environ["SSH_TARGET"]
c["created"] = os.environ["CREATED"]
config_dir = os.path.dirname(config_path) or "."
tmp_path = None
try:
with tempfile.NamedTemporaryFile("w", dir=config_dir, delete=False) as tmp:
json.dump(c, tmp, indent=2)
tmp.flush()
os.fsync(tmp.fileno())
tmp_path = tmp.name
os.replace(tmp_path, config_path)
finally:
if tmp_path and os.path.exists(tmp_path):
os.unlink(tmp_path)

Copilot uses AI. Check for mistakes.
Comment thread test/integration.sh
Comment on lines +1349 to +1352
# ── Peer file gone ──
[ ! -f /tmp/airc-it-k-h/state/peers/kjoiner.json ] \
&& pass "kicked peer's file removed" \
|| fail "peer file still present after kick"

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.

scenario_kick asserts the peer file is removed, but it doesn’t verify that the kicked peer’s SSH key was actually removed from the host’s authorized_keys (which is the key security invariant for making kick effective). Please add an assertion that the joiner’s ssh_key.pub is no longer present in the host’s ~/.ssh/authorized_keys after airc kick.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +2473 to +2487
local target="${1:-}"
[ -z "$target" ] && die "Usage: airc kick <peer> [reason]"
shift || true
local reason="${*:-no reason given}"

# Joiner role check — kicking only makes sense as host.
local host_target; host_target=$(get_config_val host_target "")
if [ -n "$host_target" ]; then
die "kick: only the room host can kick. You are a joiner of $host_target — talk to the host."
fi

local peer_file="$PEERS_DIR/$target.json"
if [ ! -f "$peer_file" ]; then
die "kick: '$target' not in peers list (try: airc peers)"
fi

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.

cmd_kick uses the user-supplied $target directly to form paths like "$PEERS_DIR/$target.json" and then rm -f’s them. Without validating that $target is a simple peer name (e.g. ^[a-z0-9-]+$), a typo or malicious input containing path separators could delete files outside the peers dir. Please enforce the same peer-name validation used for identity names before constructing file paths.

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +2594 to +2601
for k in ("pronouns", "role", "bio"):
v = src.get(k)
if v:
ident[k] = v
ints = ident.setdefault("integrations", {})
ints["continuum"] = src.get("name", "")
json.dump(c, open(os.environ["CONFIG"], "w"), indent=2)
print(f" imported continuum:{src.get(\"name\", \"?\")} → pronouns={src.get(\"pronouns\", \"\")} role={src.get(\"role\", \"\")} bio set={bool(src.get(\"bio\"))}")

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.

_identity_import_continuum sets integrations["continuum"] from src.get("name", ""), but the comment above says continuum persona show <name> returns JSON with fields like {pronouns, role, bio, ...} (not necessarily a name). If name is absent, this records an empty continuum handle and later identity push continuum will fail. Prefer linking to the requested id (the CLI arg) when src.name is missing/empty.

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 25, 2026
docs(readme): cover the new identity layer (post-#70)
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