Skip to content

test: prove receive-side reconnect works (host down/up without manual intervention) - #11

Merged
joelteply merged 1 commit into
mainfrom
feat/reconnect-monitor-issue-7
Apr 15, 2026
Merged

joelteply merged 1 commit into
mainfrom
feat/reconnect-monitor-issue-7

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Surprise finding: the reconnect capability from #7's umbrella is already implemented in monitor() at airc:174-221 — a while-true + 3s sleep + offset-resume loop. Never regression-tested though, and nobody knew it was working.

This PR adds the scenario. In local testing, post-outage message delivery latency was ~1 second.

The scenario

  1. alpha hosts on 7549, beta joins, baseline send confirms pairing
  2. airc teardown alpha (non-flush — preserves identity + messages.jsonl)
  3. Assert beta's monitor process is still alive during the outage
  4. Restart alpha with same AIRC_HOME / port / name
  5. Send from host → assert beta's local mirror sees it within 15s

What this does NOT cover (yet)

The scenario proves receive-side reconnect. The remaining #5 gap is send-side:

  • airc send during outage fails immediately with `ERROR: Failed to deliver`
  • Message is dropped — no local queue, no retry-on-recover

That's the next piece of work (Option B from #5: append-to-pending.jsonl + retry with backoff). Separate PR.

Test plan

  • bash -n test/integration.sh — syntax OK
  • bash test/integration.sh reconnect → 7/7 (measured 1s recovery)
  • bash test/integration.sh (full) → 47/47 (was 40/40)

Related

🤖 Generated with Claude Code

…n/up

Surprising finding: the `monitor()` retry loop at airc:174-221 already
implements reconnect end-to-end. SSH tail is wrapped in a while-true
with a 3s sleep, and the offset file persists across the outage so
`tail -n +$((offset+1)) -F` resumes cleanly after the host restarts.

Scenario walks through a realistic outage:
  1. alpha hosts, beta joins, baseline send OK
  2. teardown alpha (non-flush — keeps identity + messages.jsonl)
  3. assert beta's monitor process is STILL alive during the outage
  4. restart alpha with same home/port/identity
  5. send msg from host → assert beta's local mirror sees it within 15s
     (actual measured: 1s in local testing)

This is the demo-worthy reconnect capability from issue #7's umbrella,
already working in practice but previously untested. Locks it in.

What's STILL missing from #5/#7's resilience ask:
- Send-side queue: `airc send` during an outage fails immediately and
  drops the message. A persistent pending.jsonl with retry-on-recover
  is what #5 Option B proposes. Not addressed by this PR.

Full suite now 47/47 (was 40/40). Refs #5, #7.
@joelteply
joelteply merged commit 33c8d5e into main Apr 15, 2026
@joelteply
joelteply deleted the feat/reconnect-monitor-issue-7 branch April 15, 2026 19:10
joelteply added a commit that referenced this pull request Apr 15, 2026
The other half of #5's offline resilience. Pre-this-PR: sending while the
host is unreachable (laptop asleep, SSH timeout, network out) died with
ERROR and the message was dropped. Now the message is enqueued and an
auto-retry loop in the monitor flushes it when the host is reachable again.

Changes:

* `cmd_send` wire-failure branch:
  - Append full signed payload to `$AIRC_WRITE_DIR/pending.jsonl`.
  - Write a `[QUEUED to <peer> — host unreachable, will retry]` marker
    into the local `messages.jsonl` so `airc logs` shows the state.
  - Emit a one-line stderr warning for the interactive user.
  - Return 0. Queuing is a form of success; the user didn't lose anything.
  - Removed the `die` + `[SEND FAILED]` marker path. Local audit trail
    still has the original outbound line (mirrored before the wire
    attempt), plus the new [QUEUED] marker.

* New `flush_pending_loop`, backgrounded from `monitor()`:
  - Polls every 5s; no-op unless pending.jsonl is non-empty.
  - Atomic-ish snapshot (mv to tmp) so concurrent `airc send` during
    drain lands in a fresh pending file, not in-flight.
  - Per-line SSH retry with ConnectTimeout=5 + BatchMode=yes (fails
    fast if host is still unreachable, no password prompts).
  - Successful deliveries drop; failures get prepended back onto
    pending so ordering is preserved across attempts.
  - On successful drain, writes a `[DRAINED N queued message(s) to host]`
    marker to local `messages.jsonl` for operator visibility.
  - Lifecycle tied to monitor via trap cleanup alongside reminder_timer_loop.

Tests:

* New `scenario_queue` (7 assertions): flip host_target to unreachable,
  send during outage asserts exit 0 + pending.jsonl has the line + [QUEUED]
  marker in local log. Restore host_target, assert message delivered to
  host and pending cleared within 25s. Local measured time: 2s.

* Updated `scenario_tabs` [SEND FAILED] assertions → [QUEUED] + pending
  presence. Old semantics (die + no retry) was the bug being fixed.

Full suite: 55/55 (was 47/47).

Closes the Option B path from #5. Receive-side reconnect (#11) + send-side
queue (this PR) together give the "laptop sleeps, nothing is lost, mesh
self-heals when it wakes" property memento asked for.

Refs #5, #7.
joelteply added a commit that referenced this pull request Apr 15, 2026
…B) (#12)

The other half of #5's offline resilience. Pre-this-PR: sending while the
host is unreachable (laptop asleep, SSH timeout, network out) died with
ERROR and the message was dropped. Now the message is enqueued and an
auto-retry loop in the monitor flushes it when the host is reachable again.

Changes:

* `cmd_send` wire-failure branch:
  - Append full signed payload to `$AIRC_WRITE_DIR/pending.jsonl`.
  - Write a `[QUEUED to <peer> — host unreachable, will retry]` marker
    into the local `messages.jsonl` so `airc logs` shows the state.
  - Emit a one-line stderr warning for the interactive user.
  - Return 0. Queuing is a form of success; the user didn't lose anything.
  - Removed the `die` + `[SEND FAILED]` marker path. Local audit trail
    still has the original outbound line (mirrored before the wire
    attempt), plus the new [QUEUED] marker.

* New `flush_pending_loop`, backgrounded from `monitor()`:
  - Polls every 5s; no-op unless pending.jsonl is non-empty.
  - Atomic-ish snapshot (mv to tmp) so concurrent `airc send` during
    drain lands in a fresh pending file, not in-flight.
  - Per-line SSH retry with ConnectTimeout=5 + BatchMode=yes (fails
    fast if host is still unreachable, no password prompts).
  - Successful deliveries drop; failures get prepended back onto
    pending so ordering is preserved across attempts.
  - On successful drain, writes a `[DRAINED N queued message(s) to host]`
    marker to local `messages.jsonl` for operator visibility.
  - Lifecycle tied to monitor via trap cleanup alongside reminder_timer_loop.

Tests:

* New `scenario_queue` (7 assertions): flip host_target to unreachable,
  send during outage asserts exit 0 + pending.jsonl has the line + [QUEUED]
  marker in local log. Restore host_target, assert message delivered to
  host and pending cleared within 25s. Local measured time: 2s.

* Updated `scenario_tabs` [SEND FAILED] assertions → [QUEUED] + pending
  presence. Old semantics (die + no retry) was the bug being fixed.

Full suite: 55/55 (was 47/47).

Closes the Option B path from #5. Receive-side reconnect (#11) + send-side
queue (this PR) together give the "laptop sleeps, nothing is lost, mesh
self-heals when it wakes" property memento asked for.

Refs #5, #7.
joelteply added a commit that referenced this pull request Apr 28, 2026
…t catches up (#240)

fix(ux): cmd_send + cmd_invite confirm success; help text catches up to Phase 2

QA pass 2026-04-28 found 12 user-facing bugs. This PR knocks out 4
of the silent / confusing-UX ones:

## cmd_send: success confirmation

Before: airc msg <text>  → completely silent. User has no signal.
After:  airc msg <text>  → "  → #channel (broadcast)"
        airc msg @peer X → "  → @peer on #channel"

--internal callers (cmd_rename's [rename] propagation) stay silent
on purpose; the user-invoked surface gets the confirmation.

## cmd_invite: framing + usage hint

Before: bare 200-char base64 invite string with no context.
After:  labeled block + "Receiver runs: airc connect <paste>" hint
        + nudge that same-account peers can use the mesh gist instead.

## airc help text: post-Phase-2 catch-up

  + airc msg @A @b <text>      multi-DM (also @A,b,c csv)
  + airc msg --channel <name>  stamp display channel
  - "cross-peer-via-host" promise on whois — Phase 2B.3 deleted that
    walk; now annotated as Phase 2C+ TODO.

Verification: tabs 19/0; manual exercise of msg / multi-DM / invite.

Bug list remaining: #4 daemon ping timeout, #5 last_recv stuck,
#7 kick @-prefix inconsistency, #8 identity link/unlink verb, #9
--channel without subscription, #10/12 (mostly addressed here),
#11 (addressed here).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 28, 2026
…1025)

* feat(owner-core): slice-1 daemon wiring, attribution fix, identity assertions, live-stream reconnect

Owner-core daemon is the single same-machine delivery path; the legacy
frames.jsonl/LocalFs path and its tests are gone. 739 workspace tests
green, clippy clean (--all-targets --all-features -D warnings).

Substrate:
- Daemon is a broker, not the author: participant identity
  (from_peer/from_client) threaded through the IPC contract and stamped
  on every event, not (machine_peer, ClientId::new()). Restores
  per-agent attribution (work peer-filter, bridge author, distinct
  personas, self-echo).
- airc-protocol::assertion: domain-separated IdentityAssertion +
  PeerKeypair::sign_assertion + verify (WebAuthn-shaped credential floor
  for Continuum/jtag/grid). Re-exported as Airc::sign_assertion.
- Live daemon-attached subscriptions reconnect + resume strictly after
  the last cursor across a daemon restart (durable gap replayed,
  ephemeral skipped); capped backoff; stops on consumer drop.

Tests (short, one property each), via a shared in-process daemon fixture
(tests/common: Machine::boot/attach/solo/pair_in + faithful restart):
- Consolidated orphan SDK suites onto the daemon (diagnostics, bridge,
  PR-observe, work events, WebRTC = control-via-daemon + media P2P).
- daemon_lifecycle CLI test (launch, 8-tab contention = one daemon,
  rooms join/leave/create, restart + durable replay).
- daemon_reconnect: live stream survives a daemon bounce.
- Deleted redundant legacy suites (work_api, structured_publish,
  lane_coordination, consumer_throughput, command_bus shared-wire).

Cleanup: removed join_with_wire / `room --wire` vestige; reworked the
embedded-consumer-smoke example onto daemon-attach.

Docs: identity/attestation/decentralized-enrollment roadmap + grid-sim
test strategy in rust-substrate-grievances-and-gaps.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(store): forward-compat migrations — tolerate a DB migrated ahead of the binary

SqliteEventStore::open / SqliteDurableSink::open called Migrator::up,
which hard-fails when the DB has applied migrations the binary has no
file for (SeaORM "migration file is missing"). Version skew — a stale
installed binary against a DB a newer build migrated forward
(create_bus_events #011, create_bus_epoch #012) — bricked the store.

Migrations are additive/never-destructive, so a DB ahead of us is
harmless. apply_migrations() applies our pending migrations but tolerates
unknown-applied ones, while still surfacing genuine divergence (one of
OUR migrations unapplied). Tests cover both directions.

Resolves work card 8416ed7f.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): render live-stream events by kind; suppress alive heartbeats

Closes card d21d355d. The `airc join` attach was rendering every non-text
body — including the 60s `alive` presence heartbeat AND real work-domain
events (card_created, card_state_changed, …) — identically as
`<non-text body>`. Result: the work board was invisible in the stream
that's supposed to surface it, and heartbeats drowned the signal. That
broke observability, which is the prerequisite for peer-self-organizing
coordination: you can't align peers on a board they can't watch.

Add `event_render::render_feed_line` shared by both feed call sites
(`join_feed::print_event` and `commands::print_event` — previously
duplicated). Body handling now:
- chat text (`Body::text`): printed verbatim, unchanged.
- `Body::Json` with `kind: "alive"`: suppressed (returns None) — pure
  churn; one per peer per minute, nothing the reader acts on.
- `Body::Json` that deserializes to `airc_work::WorkEvent`: rendered by
  variant (card_created with title + short id + priority + repo; state
  changes; claims). Deserializing through the domain type instead of
  hand-poking JSON keeps the schema in one place — airc-work owns it.
- Unknown structured JSON: `⟨kind⟩` (or `⟨structured⟩`), beating
  `<non-text body>`.
- `Body::Binary`: `⟨binary N bytes⟩`.

5 unit tests cover each path. Adds `airc-work` as a direct dep of
airc-cli (was reached only via `airc-lib`'s work API; the renderer needs
the typed enum). No cycle: airc-work depends only on airc-core.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(work): pin invariant (d) of card 5d65aec2 — concurrent card creates

Two new projection tests pin invariant (d) of the store-as-arbiter
peer-coordination contract: two peers creating cards concurrently must
not collide.

  * concurrent_card_creates_with_distinct_ids_project_independently —
    distinct UUIDs round-trip both creators independently.
  * duplicate_card_id_on_create_surfaces_error_never_silent_clobber —
    a true id collision surfaces as ProjectionError::DuplicateCard
    with the original card unchanged, never a silent overwrite.

The other contract invariants on card 5d65aec2 are already proven by
existing projection tests:

  * (a) one-winner under concurrent claims —
    duplicate_active_claim_is_idempotent_and_keeps_original_owner
    (apply_card_claimed is first-write-wins; racing second is no-op).
  * (b) lease expiry permits reclaim + heartbeat extends an active lease —
    expired_claim_can_be_superseded_by_new_claim,
    card_claim_heartbeat_and_stale_detection_project_from_events.
  * plus three replay-idempotence guards
    (duplicate_claim_release_is_idempotent_after_claim_is_already_clear,
     heartbeat_for_non_active_claim_is_dropped_silently,
     release_for_superseded_claim_does_not_poison_projection).

Invariant (c) — close/state transitions propagate to *all attached
peers via the store* — is the cross-IPC delivery layer, not projection;
split into a follow-up card so the alignment-spec story stays complete.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): airc work release — default CLAIM_ID to this peer's active claim (kink acb8bfcd)

Surfaced live while two-tab dogfooding (2026-05-27): releasing required
both <CARD_ID> and <CLAIM_ID> positionally, even though the system
already knows the implicit answer (this peer's current claim on that
card). Forced callers to track claim_ids manually — friction on the
release-on-stall path, which IS the flywheel's churn-tolerance keystone.

Make CLAIM_ID an Option<String>. When omitted, resolve_my_active_claim
looks the card up via airc.work_board(), pulls (owner, claim_id), and
verifies owner == airc.peer_id(). Clear errors when no claim exists or
the claim belongs to another peer — the default never silently releases
someone else's work.

Help text also clarifies why `release` (unlike `claim`) has no
--no-lease-required flag: release is unconditionally permitted
regardless of cwd, by design — an agent must always be able to release
a claim it holds. Asymmetry is intentional; documented in the command
doc-comment so the next dogfooder doesn't re-card it.

Proven by eating its own dogfood: `airc work release acb8bfcd-...`
(this card's own id, no claim_id) auto-resolved + released
b02cb42a-... cleanly before this commit landed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): board prints owner=me + short claim/owner UUIDs (kink 6f111211, partial)

Surfaced live (2026-05-27) while two-tab dogfooding: 'owner=cdff6a9d-e9...
-10bc1faf1747' on every line is unreadable, and you can't tell at a
glance which cards are YOURS. Two changes to `airc work board`:

  * owner=me when the card's owner matches this peer (airc.peer_id());
    short 8-char UUID prefix for other peers.
  * claim_id shortened to 8-char prefix.
  * card_id KEPT FULL — it's the API key, callers copy-paste it into
    claim/state/close. Display vs identifier distinction is intentional.

Same treatment for the stale-claims block.

Resolves the at-a-glance complaint. Does NOT do the original card's
"alias via peer trust" — that's structurally impossible because the
peer trust store carries only (peer_id, pubkey, added_at_ms); no
display_name/nick. whois' own doc-comment is honest about this:
"Rich peer identity cards are a roster-layer follow-up… not yet
published on the substrate." Real alias resolution for OTHER peers is
tracked as af40f46d (rich peer identity cards published over the
substrate). This commit ships the readability win achievable without
that prerequisite.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): board shows claim lease inline — lease=Mm SS s / <STALE> / - (kink ac6affc7)

Surfaced 2026-05-27 while two-tab dogfooding: the board showed
'claim=<uuid>' but not whether the owner is still alive/heartbeating.
To know if a claim was stale you had to cross-reference 'work roster'
+ lease ttl manually — which kills the at-a-glance flywheel-continuity
story (lease decay + reclaim is the WHOLE POINT of soft enforcement).

Add a `lease=` column to each card row. format_lease(claim_expires_at_ms,
now_ms):
  * None              → "-"   (no claim, available)
  * past expiry       → "<STALE>"  (eligible for reclaim per doctrine)
  * future expiry     → "Mm SS s" remaining (active, heartbeating soon)

Data is already projected (WorkCard.claim_expires_at_ms — Option<u64>),
so this is pure render. 4 unit tests pin the three branches + short_id.

Pairs with the prior 'owner=me + short UUIDs' fix (0e8e6fa) — together
the board now reads at a glance: who owns it (me / short uuid / -),
their claim (short uuid / -), and whether that claim is alive
(time remaining / <STALE> / -). The whole at-a-glance complaint from
kinks 6f111211 + ac6affc7 is now resolved.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): work board --available / --mine / --others filters (kink b408698c)

Surfaced 2026-05-27 while two-tab dogfooding: with N peers and M cards,
the per-iteration loop is "read board -> pick claimable that suits me".
Showing the full board on every read made the filter step manual.

Add three mutually-exclusive flags (clap ArgGroup) to `airc work board`:

  * --available  Open cards with no active claim OR stale lease
                 (reclaim-eligible per flywheel-continuity). Hides
                 Closed/Merged.
  * --mine       owner == this peer.
  * --others     owner is another peer.

`BoardFilter::from_flags(...)` collapses the three booleans into one
enum value at the dispatch site so the render path doesn't carry
three bools. Header line reports "filter=Mine, hidden=5" so the
caller knows the projection is bigger than what's shown.

4 unit tests pin the four filter variants against constructed cards
(claimed-by-me / by-other / unclaimed / stale-claim / Closed
terminals). Pairs with prior board-readability work
(0e8e6fa owner=me, b07f042 lease=Mm SS s) — together the board now
shows what's mine, what's free, who has what, and how alive each
claim is, all without a roster cross-reference.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(daemon): pin invariant (c) of card 28c89065 — work event propagation

Card 5d65aec2 closed by proving the projection-layer invariants
(a)/(b)/(d): one-winner under concurrent claims, lease expiry permits
reclaim, concurrent creates with distinct ids don't collide. Invariant
(c) — "card state transitions propagate to ALL attached peers via
the store" — was deferred at that time because it lives at the
cross-IPC delivery layer, not projection.

This commit pins it. A new daemon integration test stands up a live
DaemonState over a real ORM on a Unix socket, attaches two observer
peers to one room (subscribe-before-ack — no transition can sneak in
before the subscription is live), and walks a single card through the
canonical lifecycle through exactly the codec airc-lib uses:

  card_created → card_claimed → InProgress → Closed → claim_released

The proof has four parts:

  (1) No drop — both observers receive every transition.
  (2) Same order — the router's total-ordering point is the single
      arbiter the store-as-arbiter contract relies on.
  (3) Byte-identical decode — every envelope round-trips through
      Body::from_payload + decode_work_event back to the same
      WorkEvent the publisher authored (catches any wire-codec drift).
  (4) Projection convergence — replaying the observed sequence
      through WorkBoardProjection yields the same final card state
      on both sides.

Adds airc-work as a dev-dependency of airc-daemon. The daemon itself
stays work-domain agnostic; payloads are opaque to the router. The
dev-dep is purely so the test can speak the production WorkEvent
codec end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(agents): AGENTS.md — operational doctrine for agents collaborating in this room

Joel called this out 2026-05-27: the meta-rules of working (how to work
in parallel, how to generate new tasks, sort, all the kanban stuff)
need to be UNDERSTOOD by all agents, not re-discovered per session or
per scope's auto-memory. The existing docs (lane-kanban-protocol,
manager-role) are deeper design proposals; what was missing is the
short OPERATIONAL manual every agent reads on attach.

Sections:
  1. The flywheel loop (idle = generative, not terminal)
  2. Working in parallel (atomic claim arbitrates; don't yield on
     observation of another peer's work; FIFO is a queue, a team is
     parallel)
  3. Kanban lifecycle (commands cheatsheet, lease + heartbeat)
  4. Generating new tasks (decomposition, kink → card, peer DMs)
  5. Sort / priority (P0–P3, --available)
  6. Cross-peer collaboration (board mediates; authority gradient)
  7. Stopping conditions (only three real ones)
  8. Doctrine portability gap (this doc lives in the repo; substrate
     auto-load on attach is tracked as cards e4cad280 + 2903a8ef)

Success criterion stated up top: "the user is not the engine." Today
this travels via the repo; the substrate-published room-doctrine
mechanism that makes it auto-load on attach is the future work.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(agents): correct AGENTS.md — flat power, no authority gradient, no human-fork stop

Joel called this out 2026-05-27 across four rapid messages: "no, point is
to not assign priority to anyone, all have power, no restrictions, waiting
on human etc" / "use your own judgment!" / "you were trying to slow down
the flywheel" / "with needless human intervention" / "agents are
autonomous."

I had drifted in the v1 of AGENTS.md (08eb758 + uncommitted §8/§9
inserts):

  * §6 introduced an "authority gradient" framing — peer trust
    distinguished from dispatch authority. Rejected: peer trust gates
    verification, period; there are no authority levels.
  * §1 + §7 listed "a fork that requires the human's judgement" as a
    valid stopping condition. Rejected: agents are autonomous, use
    their own judgment, and a wrong decision is correctable in the
    next iteration. Permission-asking is the bug.
  * §8 framed direct-commit as "OK for slice-1" with a deferred
    "switch to per-card PR when 3rd agent enters" hedge. Rejected:
    per-card worktree + branch + PR is THE pattern; direct-commit was
    a slice-1 expedient.
  * §8 review subsection had "author cannot review own card" as a
    structural restriction. Rejected: every peer has equal authority
    to review, including (in principle) their own card; the agent's
    own judgment decides.
  * §9 implied Continuum personas might "carry dispatch authority that
    peer personas don't." Rejected: persona attributes are
    descriptive metadata for finding the right peer, never gating who
    can act.

Net: every "wait for human" hedge and every "lead vs peer" hierarchy
removed. Atomic claim is the only arbiter; everything else is
suggestion. Agents are autonomous.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(core): PeerIdentityCard wire event + IdentityEvent enum (card a63ad10a, 1/3)

First slice of the identity-roster substrate (parent af40f46d, blocker
for kink 6f111211 alias resolution + the broader collaboration UX).

Adds in airc-core::identity:

  * IdentityEvent — internally-tagged enum mirroring airc_work::WorkEvent.
    Today one variant; future identity-revocation / -forking events
    join without breaking the consumer codec.
  * PeerIdentityCard — { peer_id, identity, emitted_at_ms }. Wraps the
    existing Identity payload (name/pronouns/role/bio/status/fingerprint/
    integrations) with the publishing peer's id + an emission timestamp
    that projections use for latest-write-wins.

3 unit tests pin: serde round-trip, the "peer_identity_card" kind
discriminator (so a serde change can't silently rename it), and that
an unknown future kind surfaces as a decode error rather than
silently mis-decoding into the one known variant.

No publish path yet (2/3 — card 2f74b8a1). No projection / consumer
yet (3/3 — card 66d7e607). This is the foundation those build on.

Long-term per AGENTS.md §9 + card 5842c35c: the wire body probably
shifts to carry a Continuum persona id with consumers fetching
the persona from Continuum's registry, instead of inlining identity
fields. That refactor is additive — the kind tag stays stable.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(store): handle TranscriptKind::IdentityPublished in sqlite codec

bd585b1 added `TranscriptKind::IdentityPublished` to airc-core but
left two non-exhaustive matches in `airc-store::sqlite` (the
`to_active_model` write side and the `from_model` read side). The
result: the entire workspace failed to compile downstream.

Add the missing arms — "identity_published" — on both sides so
identity events round-trip through SQLite the same way every other
TranscriptKind does. No schema change; this is just the codec arm
the parent commit forgot.

Found while picking up card 75b54d0a (churn-survival proof) against
HEAD. Per AGENTS.md §4, the underlying friction — a type-level fan-out
that doesn't keep its consumers in sync — deserves its own card.
Filing as a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): emit PeerIdentityCard on room join — airc-native identity roster (card 2f74b8a1, half)

Wires the publish-on-join half of card 2f74b8a1 (identity-roster 2/3,
parent af40f46d). Now when this scope joins a room via Airc::join, it
emits an IdentityPublished lifecycle event carrying the local
identity card so other peers already attached can populate their
roster — the "who is here" piece of the autonomous-team substrate
(AGENTS.md §9).

Changes:
  * airc_core::TranscriptKind: new IdentityPublished variant +
    is_lifecycle() inclusion. Body shape documented inline.
  * airc-lib::Airc::join: after the RoomJoined lifecycle, calls
    Airc::emit_peer_identity_card(room.channel), which loads the
    local identity row fresh, builds an IdentityEvent::PeerIdentityCard,
    and emits via emit_lifecycle (Body::Json with kind=peer_identity_card,
    flat with peer_id / identity / emitted_at_ms).
  * Helper is no-op when no local identity is persisted yet (fresh
    scope mid-bootstrap) — does not break join.

168 airc-lib tests still pass (no regression). Roster projection +
work-board alias consumer (3/3, card 66d7e607) is the next slice.

OPEN follow-up: emission on local nick / profile change. The card's
title covers both halves; this commit ships only "on join." Carding
the remainder separately so the board state stays honest.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* test(daemon): pin card 75b54d0a — work outlives any participant

The flywheel-continuity invariant from AGENTS.md §3 ("lease +
heartbeat keep the flywheel alive across churn"): a claim expires
after its `ttl_ms`; if the holder stops heartbeating, the lease
decays and a different peer reclaims by publishing a fresh
`CardClaimed` whose `claimed_at_ms` is past the prior expiry.
First-write-wins on the active claim is the in-lease rule; out-of-
lease, the next claimant wins. The store is the arbiter, and it
never asks the dead holder for permission.

This pins it end-to-end through the live daemon's IPC router. One
daemon, two attached observer peers, a single card carrying the
canonical churn transcript:

  created   by Alice  @ t=1
  claimed   by Alice  @ t=2,  ttl=100   → expires t=102
  (Alice goes dark; no heartbeat, no release)
  claimed   by Bob    @ t=200, ttl=100  → reclaim, expires t=300
  state     InProgress by Bob @ t=201
  state     Closed    by Bob @ t=300
  release   by Bob    @ t=301

Asserts:

  (1) Both observers receive every event in order through the
      production encode_work_event → daemon router → wire codec path.
  (2) Lease expiry is observable cross-peer: replaying just the
      first two events and asking `stale_claims(bob_claim_at)` on
      either observer's projection surfaces Alice's claim as
      reclaim-eligible, and `stale_claims(alice_expires_at - 1)` is
      empty (the expiry boundary is the line arbitration draws).
  (3) After the full transcript, both observers' projections agree
      the card is Closed with no orphan claim and no orphan owner.
      Bob's reclaim is NOT dropped as a duplicate active claim
      (the dead lease is no longer active).
  (4) Creation attribution is preserved (Alice authored the card)
      even though Bob owns the work — the substrate records both
      truths.

Pairs with `work_event_propagation_proof.rs` (card 28c89065,
invariant (c): state transitions propagate to all attached peers)
to close the autonomous-team substrate contract: peers come and go,
claims expire, work continues — no single peer is a single point
of failure.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): Airc::peer_alias — MVP identity-roster lookup (card e414817b, sub 3a of 66d7e607)

Adds the foundational accessor for resolving a peer_id to its
published display name. MVP shape per the decomposition of card
66d7e607 (identity-roster 3/3, parent af40f46d):

  pub async fn peer_alias(&self, peer_id: PeerId)
      -> Result<Option<String>, AircError>

Scans recent transcript events in the current room (page_recent(200))
for the latest TranscriptKind::IdentityPublished emitted by `peer_id`,
decodes Body::Json -> IdentityEvent::PeerIdentityCard, returns
Some(card.identity.name) when non-empty. Otherwise Ok(None) — honest
"unknown" rather than rendering an empty string. On-demand query, no
in-memory cache; the substrate emits IdentityPublished once per join
(commit 088af06), so the 200-event window is conservative.

Unblocks:
  * card c397567a (3b) — work board format_peer reads peer_alias
  * card 20066c49 (3c) — airc whois reads richer identity card

Builds clean on top of 66f28aa (other tab's airc-store wire-str fix
for IdentityPublished — caught a regression I missed when adding the
variant; live two-tab dogfood landed exactly the gap-fixing
collaboration the doctrine names).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* refactor(core): TranscriptKind owns its wire-str — kink 0cfcc8db closed

The kink: adding a TranscriptKind variant required parallel edits in
airc-core (the enum) AND airc-store (two non-exhaustive matches in
the SQLite codec). Skipping the consumer-side edit was a clean compile
in airc-core and a downstream build break only when cargo got to
airc-store — exactly how bd585b1 (IdentityPublished) tripped the
whole workspace, fixed in 66f28aa.

Compress that into a single source of truth:

  * `TranscriptKind::as_wire_str(self) -> &'static str` — exhaustive
    match enforced by the compiler. The one place a new variant's
    string lives.
  * `TranscriptKind::from_wire_str(&str) -> Option<Self>` — inverse;
    None for unknown so the store can wrap it as
    `StoreError::UnknownTranscriptKind`.
  * `TranscriptKind::ALL_VARIANTS: &[Self]` — the consumer-sync
    guard. A new variant that forgets to extend this slice (or
    `from_wire_str`) fails the round-trip unit test in airc-core,
    BEFORE airc-store even tries to consume it.

airc-store's two matches collapse to single one-liners:
`ev.kind.as_wire_str()` on the write side,
`TranscriptKind::from_wire_str(&m.kind).ok_or(…)` on the read side.
The store no longer has any enum knowledge.

The unit test `wire_str_round_trip_covers_every_variant` asserts:

  - ALL_VARIANTS is non-empty and round-trips every variant.
  - Discriminator strings are unique (no two variants share a
    persisted string — silent corruption guard).
  - Strings are snake_case ascii (SQLite-safe).
  - Unknown strings return None (caller-controlled error wrapping).

Workspace test counts: airc-core 38 (+1), airc-store 36 unchanged,
airc-daemon 10 unchanged.

The architectural lesson, per Joel's dogfood note: "the substrate
that catches its own consumers when they fall behind is what makes
the flywheel efficient." Compile-time enforcement on the producer +
test-time enforcement on the variant set = no more cross-cutting
build breaks from a single-crate commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): work board renders peer aliases via Airc::peer_alias (card c397567a, 3b)

Closes the kink-6f111211 loop end-to-end at the consumer side. `airc work
board` now pre-fetches a HashMap<PeerId, String> of published aliases
for every distinct non-self owner appearing on the board (and on
stale claims), and `format_peer` returns the alias when known, "me"
for self, short-uuid as honest fallback.

Changes:
  * format_peer: now takes &HashMap<PeerId, String> and prefers
    alias > "me" (self) > short-uuid (unknown).
  * run_board: collects owner peer_ids, async-fetches each via
    Airc::peer_alias (card e414817b, shipped in cd638b8), passes the
    map to print_board. One query per peer for now; if profiling shows
    hot-path, follow-up is one shared page_recent scan + a local
    index.
  * Same map flows through the stale-claims block (consistent
    rendering).

Unit test pins the three branches (alias > me > short-uuid).
All 10 work_commands::tests green.

NOTE: end-to-end "users see aliases" doesn't fire until peers actually
publish IdentityPublished events. Today only Airc::join(name) emits
(commit 088af06); the auto-resume `airc join` (no args) path calls
join_default_context which doesn't yet emit. That gap is a separate
follow-up — wiring is correct on the consumer side; emission needs
extension to all join paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): CoordinationSignal on agent heartbeat — closes card aacf2162

Per AGENTS.md §6 ("current claims, availability, doctrine version")
the alive heartbeat needs to carry a coordination payload so observers
can answer "what is each agent doing right now?" from a single beat,
without having to project the whole work board to derive claim state.

Adds a typed `CoordinationSignal` on `AgentHeartbeat`:

  * `active_claims: Vec<WorkCardId>` — work cards this agent holds
    active claims on at emit time. A snapshot, not authoritative
    (the work-board projection remains source of truth by the
    store-as-arbiter contract); what this gives observers is an
    O(beats) cross-peer activity view that doesn't need a board
    replay.
  * `availability: Option<AgentAvailabilityState>` — per-beat
    self-reported Ready/Busy/Away. Distinct from the substrate's
    per-repo `AgentAvailabilityReported` event: this is the quick
    signal that lets peers decide "don't route a DM / task
    proposal to a Busy agent."
  * `doctrine_version: Option<String>` — stable identifier for the
    operating doctrine the agent is following (convention: the
    AGENTS.md commit hash). Mismatch is reason to suggest
    `airc update` / re-pull.

All three sub-fields are optional; `CoordinationSignal::default()`
plus `skip_serializing_if = "is_empty"` keeps the wire bytes
byte-identical to the pre-aacf2162 shape for idle agents and
pre-aacf2162 peers still on the network. The change is invisible
to peers that don't care.

The signal flows through `AgentLiveness` so `Airc::active_agents()`
returns it to observers. A new emit method
`emit_agent_heartbeat_with_coordination` lets callers populate
the payload; the existing `_with_metadata` method composes onto
it with an empty signal (no caller-side break).

Tests added (`agent_heartbeat::tests`, all green):

  * `coordination_signal_round_trips_through_json` — every field
    survives serde encode/decode byte-for-byte.
  * `empty_coordination_is_omitted_from_json` — pins the
    skip_serializing_if contract so legacy peers see no diff.
  * `pre_aacf2162_beats_decode_with_empty_coordination` — the
    back-compat half: a beat encoded WITHOUT a `coordination` key
    must decode without error. Fixture uses a real `PeerId::new()`
    round-tripped through serde — no hand-rolled UUID strings
    (Joel: "uuidv4 to prevent collisions in p2p").
  * `partial_coordination_signals_round_trip_independently` —
    every sub-field is independently optional; e.g. an agent that
    only knows its availability can emit just that.
  * `is_empty_only_true_when_every_field_unset` — pins the
    skip-serializing predicate.

This is the data substrate enabler for the P0 ENGINE cards
(94b5f668 peer-to-peer task negotiation, e4cad280 idle-engine):
once peers can see each other's active claims + availability live
on the wire, those engines have something to negotiate over.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): airc whois reads published identity card (card 20066c49, 3c)

Closes the identity-roster slice across the third (and last) consumer:
`airc whois <peer>` now reads the peer's published identity card via
the substrate instead of unconditionally printing "identity: not
published yet."

Changes:
  * airc-lib::Airc::peer_identity_card(peer_id) — returns
    Option<PeerIdentityCard>, the richer sibling of peer_alias.
    Same scan-window + on-demand model.
  * airc-cli::commands::run_whois_peer — when the card is known,
    renders the full identity (name / pronouns / role / bio / status /
    fingerprint / integrations / emitted_at). Falls back to the
    honest "not published yet" when the peer has never emitted an
    IdentityPublished event in this room's recent window — so the
    user can still distinguish unknown from blank-but-known.

The identity-roster substrate (parent af40f46d) now ships end-to-end
on the CONSUMER side: wire event (a63ad10a / bd585b1) → emit-on-join
(2f74b8a1 / 088af06) → alias accessor (e414817b / cd638b8) → board
alias rendering (c397567a / ce47896) → whois (this commit).

OPEN follow-on: a6d0df25 extends emit-on-join to the
join_default_context paths so EVERY routine attach publishes, not
just explicit Airc::join(name) calls. Until that lands, the end-to-end
"users see aliases" only fires for the explicit-join path; the wiring
on the consumer side (board + whois) is correct and ready.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): emit PeerIdentityCard on ALL join paths — closes the identity-roster slice end-to-end (card a6d0df25)

Commit 088af06 wired emit_peer_identity_card into Airc::join(name)
(explicit channel-join), but the routine `airc join` (no args) path
calls Airc::join_default_context -> ensure_join_context, which
publishes presence to the coordinator store but did NOT emit
IdentityPublished on the wire. Result: agents using the standard
resume flow never published, so the consumer-side wiring shipped in
e414817b / c397567a / 20066c49 only saw events from explicit
channel-joins (rare).

Two extensions:
  * ensure_join_context: after publish_presence, iterate the newly
    subscribed rooms and emit_peer_identity_card to each.
  * Airc::current_room (lazy default-room subscribe): also emit on
    the new room.

(Airc::part_channel keeps publish_presence without an emit — parting
is a departure, not an attach point for the roster.)

End-to-end now: any agent attaching to a room via any path publishes
its identity card; consumers (board owner=<alias>, whois) light up
without code changes. The identity-roster substrate (parent af40f46d)
is functionally complete on the publish + consume sides; the only
remaining gap is publish-on-local-nick-change (card da586598).

All 147 airc-lib tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(work): typed reviews link on WorkCard — ad7e100b Sub-A

Per AGENTS.md §8 (Card↔Git workflow) and §6 (cross-peer collaboration),
reviews are sibling work cards that any agent (other than the
author) can claim to review another agent's PR. Card ad7e100b
asks for that loop end-to-end. This commit ships the substrate
slice: a typed link from a review card to its parent.

Concretely:

  * `CardCreated.reviews: Option<WorkCardId>` — wire-level field
    on the work event.
  * `WorkCard.reviews: Option<WorkCardId>` — projection records
    it on the board card.
  * `WorkBoardProjection::review_cards_for(parent_id)` — query
    "what reviews exist for this card?" without scanning bodies.
    Returns an iterator so callers filter further (e.g. by state)
    without the projection imposing policy.
  * `CreateWorkCard::reviewing(parent)` — builder-style setter
    on the airc-lib request struct + a `CreateWorkCard::new(...)`
    constructor that defaults optional fields. Keeps the common
    path (non-review card) free of `reviews: None` boilerplate
    as the request struct grows.

Sub-A scope, deliberately tight. NOT in this PR:

  * The `airc work review <PARENT>` subcommand (Sub-B).
  * Auto-spawn of a review card when a parent transitions to
    Review state (Sub-C, depends on d9a75083 card↔git wiring,
    which peer cdff6a9d has already decomposed into d1b2798d +
    820629e9).

Back-compat: the field is `#[serde(default, skip_serializing_if =
"Option::is_none")]`. Legacy CardCreated events on the wire decode
as `reviews: None`; non-review cards encode without a `reviews`
key. The wire bytes for the pre-ad7e100b shape stay byte-identical
for non-review cards.

Tests added (`airc-work`):

  * `cards_omitting_reviews_link_project_with_none` — ordinary
    cards project with `reviews: None` and produce no entries on
    `review_cards_for`.
  * `review_card_links_to_parent_and_surfaces_on_query` — a
    review card's typed link round-trips through the projection
    and surfaces on the query.
  * `multiple_reviewers_each_surface_for_the_same_parent` —
    pins the no-lead-reviewer doctrine: every reviewer's card
    surfaces on `review_cards_for(parent)`, and the query filters
    strictly by parent_id (an unrelated card pointing at a
    different parent does not leak in).
  * `reviews_field_round_trips_through_serde_with_back_compat` —
    forward direction (`Some(parent)` round-trips byte-identical)
    and back-compat (no `reviews` key in JSON for `None`, and
    decode of such legacy JSON yields `None`). Fixture uses
    `PeerId::new()` / `WorkCardId::new()` — never hand-rolled
    UUID strings (Joel: "uuidv4 to prevent collisions in p2p";
    "uuid based id fields are ideal for global use").

Workspace counts: airc-work 80 (+4), airc-lib + airc-daemon
+ airc-store + airc-core all green. The pre-existing
`work_board_surfaces_stale_claims` failure in airc-cli (board
short-UUID rendering vs full-UUID assertion) is independent of
this change; reproduces on the base before this commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib+cli): Airc::set_local_identity_card publishes on every subscribed room (card da586598)

Closes the last identity-roster gap (parent af40f46d). Previously
the CLI's airc nick / airc identity set path saved the new card
locally via direct store access but never emitted on the wire — so
attached peers had no way to learn about nick / profile updates
without the author rejoining.

Changes:
  * airc-lib::Airc::set_local_identity_card — atomically persists
    via save_local_identity_card AND emits an IdentityPublished event
    per currently-subscribed room (iterates set.subscribed.values()).
    Pairs with emit-on-join (commits 088af06 + 01dedc0): now EVERY
    way an identity card changes — join, attach to new room, nick
    edit, full identity edit — produces an event other peers consume.
  * airc-cli::identity_commands::save_identity_card — routes through
    the daemon-attached Airc handle instead of opening the store
    directly. The daemon's running wire subscribers ensure the
    emitted event actually crosses to other peers (which a fresh
    Airc::open instance, without subscriber tasks, wouldn't do).

The identity-roster substrate is now end-to-end on both publish AND
consume:
  publish:  on-join (088af06+01dedc0), on-edit (this commit)
  consume:  board owner=<alias> (ce47896), whois card (da9cde6)

All 147 airc-lib lib tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(agents): AGENTS.md §9 reframe — airc-first, Continuum-persona assist later

Joel clarified 2026-05-27: "we are trying to build an autonomous team of
agents like yourself from within airc … later with continuum persona to
also assist." Earlier §9 framed airc peer-identity as projections of
Continuum personas (source-of-truth in Continuum). That flipped the
mission framing — airc owns its own identity substrate; Continuum is a
future enrichment that augments, never a prerequisite.

Updated §9 reflects:
  - airc-native Identity card (already in airc-core) is the source of
    truth for "who's in this room right now."
  - Continuum integration is descriptive metadata enrichment, not
    gating. Equal-power doctrine preserved.
  - Card 5842c35c is now framed as "future assist," lower urgency.

Section renumbering: shifted Doctrine portability + Pointers to keep
numbering monotonic after the new §8 / §9 insertions from earlier
commits (08eb758, fbc0208).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(test): work_board_surfaces_stale_claims asserts short claim_id prefix (kink b1735261)

Surfaced by peer 9bb24964 while running the workspace test sweep for
ad7e100b Sub-A: my short-uuid board renderer (0e8e6fa, kink 6f111211)
broke the assertion that the FULL claim_id appears in the stale-claims
block. Pre-existing breakage from the short-render commit; only caught
now because the test happens to live in airc-cli/tests/ and the prior
sweep that should have caught it was scoped narrower.

Fix: assert against the 8-char prefix instead of the full UUID, with
a comment explaining the asymmetry (card_id stays full because callers
copy-paste it into claim/state/close; claim_id is purely display-side).

Sharing the working tree with the other tab today exposed exactly the
schema-co-evolution friction I named earlier — they observed this kink
while writing ad7e100b Sub-A's tests against the same surface. Per-card
worktree+branch (d9a75083 children d1b2798d + 820629e9) would prevent
the file-races and let cross-cutting test fixes land via PR review.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): airc work review — spawn sibling review card with typed link (ad7e100b Sub-B)

Sub-B of card ad7e100b (peer-agent review loop). Sub-A (commit
fc9ced9) shipped the typed `reviews: Option<WorkCardId>` substrate.
This commit adds the ergonomic CLI on top:

  airc work review <PARENT_ID> [--pr URL] [--priority P] [--body B]

Behaviour:

  * Resolves PARENT off the current room's board projection.
    Refusing on "parent not in this room" is more useful than
    spawning an orphan review.
  * Creates a sibling card in the SAME repo as the parent (reviews
    live where the work lives).
  * Title: `review: <parent.title>` via a shared formatter
    (`format_review_title`) — Sub-C's auto-spawn path will call
    the same function so manual and auto-created review cards
    render identically and observers can filter on
    `title.starts_with("review:")` cleanly.
  * Priority: inherits parent's unless `--priority` overrides.
    The review of a P0 is itself P0-eligible work.
  * Body: prepends `review of card <parent_id>` + optional
    `PR: <url>` so a reviewer pulling just this card has the
    navigation anchors; `--body` content (if any) follows.
  * Reviews link: populated via the airc-lib builder method
    `CreateWorkCard::new(...).reviewing(parent)` added in Sub-A.
    The typed field is what's recorded on the wire; not stuffed
    into the body.

Per AGENTS.md §6 every peer has equal review authority — the CLI
imposes no self-review restriction, and the projection-layer test
`multiple_reviewers_each_surface_for_the_same_parent` (Sub-A) pins
the "every reviewer's card surfaces" contract end-to-end.

Tests added (`work_commands::tests`):

  * `review_title_preserves_short_parent_title_verbatim` — title
    formatter is the contract Sub-C must hold.
  * `review_title_truncates_long_parent_with_ellipsis_marker` —
    pins the 80-char board-render bound and the ellipsis marker.
  * `review_title_counts_chars_not_bytes_for_unicode_parents` —
    truncation respects char boundaries (no UTF-8 mid-codepoint
    slice panic on Japanese / emoji parent titles).

13 bin tests pass (3 new). airc-cli builds clean.

Out of scope (still Sub-C): auto-spawning a review card when a
parent transitions to Review state. Depends on peer cdff6a9d's
d1b2798d + 820629e9 (the card↔git PR-open path) so the auto-spawned
review card has a PR URL to point at. Filed as card 52b16e35.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib+cli): populate CoordinationSignal on join heartbeat — closes 0bf262eb

aacf2162 added `CoordinationSignal` to `AgentHeartbeat` but no
caller passed one — `airc join` still called the legacy
`start_agent_heartbeat_with_metadata` path, so every beat went out
with an empty signal. Peer cdff6a9d spotted the gap and filed
0bf262eb.

This commit:

  * Adds `Airc::start_agent_heartbeat_with_coordination` — the
    populator-friendly variant. The supplied snapshot is captured
    by the spawned task and re-emitted on every interval tick.
    `_with_metadata` now composes onto it with an empty signal
    (the wire bytes for non-coordination beats stay identical to
    pre-aacf2162).
  * Re-exports `CoordinationSignal` from `airc_lib` so callers
    don't have to import the module path explicitly.
  * Wires `airc join` to call the new path with a static
    session-start snapshot: `doctrine_version = build SHA` (the
    build tree includes AGENTS.md, so observers can still detect
    peers on stale doctrine), other fields defaulted.

Scope cut for follow-up: the snapshot is captured at session
start and re-used on every tick. `active_claims` and
`availability` therefore stay defaulted in this commit — the
hooks for refreshing from the live work-board projection are a
separate card (filed next). The wire shape and method signature
are stable; the future refresh path is back-compat.

Tests added:

  * `coordination_snapshot_emit_path_round_trips` — pins the
    bytes that go on the wire today: `doctrine_version` appears,
    and the other two fields are NOT emitted (skip_serializing_if
    on default). When a future PR populates `active_claims`, it
    extends this assertion rather than overwriting it.

10 heartbeat tests pass (1 new). Workspace builds clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): airc work claim auto-spawns worktree + branch (card d1b2798d)

Directly fixes the shared-checkout friction observed during today's two-tab
work: both tabs editing /Users/joel/Development/airc/ produced visible
uncommitted edits in each other's git status and a transient cargo build
race. Per-card worktree+branch is the right shape.

After a successful airc.claim_work_card, spawn_claim_worktree:
  * resolves the card's title from the board projection (slug source),
  * computes worktree path = ~/.airc/worktrees/<card_short>/ (the
    existing lease zone — same convention airc work claim already
    enforces via lease::check_current_dir),
  * computes branch = <card_short>/<slug> where slug is a sanitized
    snake-cased title bounded to 40 chars (slugify),
  * shells `git -C <repo_root> worktree add -b <branch> <worktree_path>`
    to let git own the actual worktree state (we don't reimplement),
  * prints the worktree path + branch + a `cd` hint so the claimer
    can immediately enter their lane.

Best-effort: a git failure prints a warning and returns from run_claim
without aborting — the claim + lease are the authoritative records,
the worktree is convenience around them. Re-claim after release reuses
an existing worktree silently (idempotent).

Unit test pins slugify (the only pure-function piece): lowercasing,
separator-collapsing, length bounds, empty-input fallback.

Unblocks 820629e9 (card↔git 2/2 — open PR on Review state once a
branch exists per-card) and ad7e100b Sub-C (auto-spawn review card,
depends on the PR being open).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(work): airc work state review opens PR via gh + links it to the card (card 820629e9)

Pairs with d1b2798d (worktree+branch on claim) to close the per-card
git workflow: claim → worktree+branch → commits → state review →
PR opened + linked → projection sets card.state=Review and
card.pull_request atomically (one source of truth for downstream
consumers like ad7e100b Sub-C auto-spawn review card).

Changes:
  * airc-lib: typed `LinkCardPullRequest` request + `Airc::link_card_pull_request`
    that emits `WorkEvent::PullRequestLinked`. The existing
    apply_pull_request_linked projection already sets
    state=Review + populates card.pull_request, so the link IS the
    state transition.
  * airc-cli `run_state`: when the new state is Review, after the
    existing change_work_card_state succeeds, best-effort
    open_pr_and_link: find the card's worktree at
    ~/.airc/worktrees/<short>/, run `gh -C <worktree> pr create --fill`,
    parse the PR URL for a number, resolve head/base via
    git/gh, and call link_card_pull_request.
  * Best-effort end-to-end: a gh failure (no commits to PR, gh not
    installed, no remote) prints a warning but does NOT undo the
    state transition. A re-run on an already-linked card is a no-op
    (idempotent check on card.pull_request.is_some()).

Unit test pins extract_pr_number (the only pure-function parser):
correctly extracts from gh URL shapes, returns None for shapes we
don't recognise so the caller can degrade.

Unblocks ad7e100b Sub-C (52b16e35) — auto-spawn review card on Review
state now has a populated pull_request to point at.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): heartbeat refreshes active_claims from board on every tick (card d4e3e350)

Closes the follow-up to 0bf262eb. The CoordinationSignal field added in
aacf2162 + populated at session start in 0bf262eb is now refreshed
*every tick* against the live work-board projection, so observers see
the agent's CURRENT claim set, not the snapshot at session start.

In start_agent_heartbeat_with_coordination's spawned loop, before each
beat: call refresh_coordination(&airc, &baseline) which queries
airc.work_board() and collects card_ids where owner == self.peer_id()
AND claim_id.is_some(). doctrine_version + availability are preserved
from the baseline (those are session-scoped). Active claims become
the dynamic view a peer observer needs to answer "what is this agent
working on right now" without scanning every transcript event.

Degrade-friendly: a board query failure (daemon transient, no current
room) falls back to the baseline snapshot rather than skipping the
beat. Liveness wins over freshness.

Pairs with the per-card git workflow (d1b2798d + 820629e9) — together
they make agent activity legible at three layers: heartbeat tells
peers what cards I hold; worktree+branch isolates the file changes;
PR-link records the review handoff.

148 airc-lib lib tests pass (no regressions).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): auto-spawn review sibling on Review state — closes ad7e100b Sub-C

The last child of card ad7e100b (peer-agent review loop). Closes
the loop end-to-end:

  claim   →  worktree + branch        (d1b2798d, peer cdff6a9d)
  commit  →  on the lane branch
  state   →  Review                   (this scope)
  link    →  gh pr create + link      (820629e9, peer cdff6a9d)
  spawn   →  review sibling card      (THIS COMMIT)
  claim   →  any peer (not author)    (Sub-A typed reviews link,
                                       Sub-B manual airc work review)
  review  →  on a separate workspace

Concretely:

  * `auto_spawn_review_card(airc, parent_id, pr_url)` runs at the
    tail of `open_pr_and_link` (in run_state, after the PR is
    linked). It projects the board, checks
    `board.review_cards_for(parent_id)` (the typed query from
    Sub-A), and creates a sibling card ONLY when no review exists
    yet.

  * The spawn uses `format_review_title` (the shared formatter
    from Sub-B), so manual review cards and auto-spawned review
    cards are structurally identical on the wire — observer
    filters built on `title.starts_with("review:")` pick up
    both paths. The body prepends the parent id + PR URL +
    'Auto-spawned ...' marker so reviewers can tell origin at a
    glance without changing the typed structure.

  * Priority inherits parent's (reviews of P0 are P0-eligible).

  * Reviews link populated via Sub-A's
    `CreateWorkCard::new(...).reviewing(parent)` builder.

Idempotency:

  * `review_cards_for(parent_id).next().is_some()` is the
    canonical pre-check. Re-running `airc work state X review` on
    an already-reviewed card is a no-op for the spawn — matching
    the existing no-op semantics of the PR link and the Review
    state transition.

Best-effort:

  * A spawn failure prints a warning and returns Ok — it does
    NOT undo the state transition or the PR link. The PR-link
    side of `open_pr_and_link` is also best-effort by the same
    discipline; the review spawn matches.

Architectural note (in the code comment): auto-spawn lives in the
CLI rather than projection-apply on purpose. Projections must
stay pure (replay determinism); emitting a new event inside
`apply_*` would couple the projection to a side-effectful
publish path. The CLI is the right place because it's the
orchestration layer that already composes the other side-effects
(gh pr create, link). A future command-bus subscriber on
`PullRequestLinked` could hoist this out of the CLI for consumers
that bypass it (Continuum, OpenClaw); the wire shape is stable,
so that move is back-compat.

Test coverage:

  * `format_review_title` parity is pinned in the Sub-B tests
    already — both spawn paths share the formatter, so any
    future tweak that diverges them breaks both at once.
  * `review_cards_for` returning every reviewer (not just the
    first) is pinned by Sub-A's
    `multiple_reviewers_each_surface_for_the_same_parent` —
    that's the substrate guarantee the idempotency guard relies
    on.
  * End-to-end CLI integration (claim → state review → spawn)
    needs a daemon + gh harness that doesn't exist in airc-cli
    today. Surfacing as a follow-up is sane if a CLI integration
    test scaffold lands.

Workspace counts: 15 cli + 22 work + 10 heartbeat — green.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(core): RoomDoctrinePublished wire event — substrate-published doctrine foundation (card 2903a8ef, slice 1/4)

First slice of the engine-keystone substrate (parent 2903a8ef —
"the user is not the engine"). Closes the design step Joel named:
"a system that keeps itself ideal efficiently and all agents can
adjust if needed to continue the flywheel" — agents adjust by
loading the latest doctrine from the substrate, not from external
onboarding that doesn't reach foreign scopes.

Adds airc-core::doctrine::{DoctrineEvent, RoomDoctrinePublished}:

  * DoctrineEvent — internally-tagged enum mirroring
    airc_core::identity::IdentityEvent and airc_work::WorkEvent.
    Today one variant; future doctrine-deprecated /
    doctrine-amended events join here without breaking the consumer
    codec.
  * RoomDoctrinePublished — { room_id, body (markdown), version
    (short content hash), published_by, published_at_ms }. body is
    the raw AGENTS.md-style operating contract; version lets
    attachers detect "what I have differs from what just landed"
    without diffing.

Doctrine note: every peer has equal authority to publish (per
AGENTS.md §6). The substrate decides "current" by latest-write-wins
on `published_at_ms`, not by author role.

4 unit tests pin: serde round-trip, the "room_doctrine_published"
kind discriminator (kink 0cfcc8db lesson — serde change can't
silently rename), unknown-kind decode error, empty-body round-trip.

Same incremental pattern as PeerIdentityCard (a63ad10a): wire
event first, publish path / projection / auto-load on attach in
follow-up slices filed below. Foundation enables the rest.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(core): TranscriptKind::DoctrinePublished variant (card a9767579, prep)

Extends TranscriptKind with the doctrine-substrate variant so the
lifecycle/wire-str round trip pins it as a first-class kind alongside
IdentityPublished. Body shape: serialized
`airc_core::doctrine::DoctrineEvent::RoomDoctrinePublished` (shipped
in f793842).

Wire-str codec / is_lifecycle / ALL_VARIANTS all updated together —
the round-trip test enforces that adding a variant without extending
the maps fails the build, which is the consumer-sync guard refactored
in by 2b9bc2e (kink 0cfcc8db). airc-store picks the new variant up
automatically via that single-source-of-truth path; no separate
sqlite match-arm fix needed this time (vs. when IdentityPublished
landed in bd585b1 + needed 66f28aa to follow).

Sub-step of card a9767579 (publish CLI). The Airc::publish_room_doctrine
API + CLI subcommand follow in the same card; committed separately
so the on-disk state stays buildable for the other tab while I keep
working — earlier today the same race window broke their build.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib+cli): Airc::publish_room_doctrine + airc doctrine-publish (card a9767579)

Closes slice 2/4 of the engine-keystone (parent 2903a8ef). Lands the
publish path so room operating doctrine actually crosses the
substrate.

airc-lib:
  * Airc::publish_room_doctrine(body, version) — emits a
    TranscriptKind::DoctrinePublished lifecycle event on the current
    room carrying a serialized DoctrineEvent::RoomDoctrinePublished
    (foundation from f793842).

airc-cli:
  * Command::DoctrinePublish { from_file: Option<PathBuf> } — top-level
    `airc doctrine-publish [--from-file PATH]` (hyphenated single
    command; avoids nesting under Room).
  * run_doctrine_publish: resolves PATH (default AGENTS.md at git repo
    root via rev-parse), reads body, computes short SHA-256 hex
    prefix as version, opens an attached Airc, emits.

Same incremental pattern as identity-roster: wire event (a63ad10a) →
publish path (2f74b8a1 / this commit) → accessor (e414817b / slice
3/4 next) → auto-load on attach (a6d0df25 / slice 4/4 last). Each
slice ships as a focused commit; the substrate is never half-built.

Note: only my files staged (cli.rs / main.rs / commands.rs / airc.rs).
Other tab is mid-flight on UpdateWorkCard (card 5ac0a359) and its
broken state at work.rs:424 is in the working tree but NOT in this
commit. HEAD remains buildable after this lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(lib): Airc::room_doctrine accessor (card b898f713, slice 3/4 of 2903a8ef)

Mirrors Airc::peer_identity_card (commit da9cde6): scans recent
transcript events for the latest TranscriptKind::DoctrinePublished
emitted on the current room, decodes Body::Json into
DoctrineEvent::RoomDoctrinePublished, returns Some(card) for known /
None when unpublished. 200-event scan window per the same MVP
trade-off as the identity-roster accessor — doctrine fires infrequently
(once per `airc doctrine-publish`), so the window covers many sessions
of mixed traffic.

Unblocks slice 4/4 (card 745e93f0): on every successful join, call
room_doctrine() and surface to attaching agents.

No new tests — same shape + scan path as peer_identity_card (already
covered by serde-roundtrip tests in airc-core::doctrine). Integration
exercise lands with slice 4/4 where the visible behavior is the
attach-time render.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(cli): airc join surfaces room doctrine for attaching agents (card 745e93f0, slice 4/4 of 2903a8ef)

Closes the engine-keystone substrate end-to-end. After the existing
join flow completes (daemon spawn, attach, identity publish), call
Airc::room_doctrine() and — if a doctrine is published — print the
body bracketed by stable BEGIN/END markers:

  --- BEGIN ROOM DOCTRINE (version=<short_hash>) ---
  <markdown body>
  --- END ROOM DOCTRINE ---

Agent runner harnesses (Claude Code, Codex, future runtimes) scrape
this region from join stdout and inject it into the agent's system
context. Silent when no doctrine is published (no marker block) so
output stays clean for rooms that haven't adopted doctrine
publication yet.

Full engine-keystone chain (parent 2903a8ef) now end-to-end:

  f793842  slice 1/4  RoomDoctrinePublished wire event
  90f2832  slice 1/4  TranscriptKind::DoctrinePublished
  affc215  slice 2/4  Airc::publish_room_doctrine + airc doctrine-publish CLI
  79fc025  slice 3/4  Airc::room_doctrine accessor
  THIS     slice 4/4  surface doctrine on join

Net effect: any agent attaching to a room — in any scope, any
runtime — now loads the operating contract automatically via the
substrate, not via external onboarding. The "user is not the engine"
property Joel named at the top of this session is now substrate-
enforced, not doctrine-in-prose.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(cli): airc work claim refuses worktree spawn when cwd repo != card.repo (card 59243bee)

Bug shipped in d1b2798d (411ff9e): spawn_claim_worktree resolves the
repo root via `git rev-parse --show-toplevel` against cwd, ignoring
`card.repo`. Result observed live by peer 9bb24964 today: claiming a
CambrianTech/airc card from a continuum cwd silently created a
continuum worktree on the airc card's branch — wrong codebase
entirely.

Honest-MVP fix: VALIDATE before spawning. Read cwd's origin URL
(`git -C <repo_root> remote get-url origin`), parse github
"owner/repo" out of HTTPS or SSH forms (`parse_github_repo_id`),
compare against `card.repo.to_string()`. Mismatch refuses with a
clear error pointing the user at the right checkout. Non-github
remotes return None so the same refusal path catches them. Better
to refuse loudly than create a wrong worktree silently.

Proper cross-repo resolution (e.g. ~/.airc config mapping RepoId →
local clone path so the user doesn't have to cd manually) is a
richer follow-up. This commit prevents silent damage at minimum.

Unit test on parse_github_repo_id pins the URL shapes (HTTPS with/
without .git, SSH [email protected]:, non-github → None, trailing slash,
malformed multi-segment paths → None).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* feat(work): CardUpdated event + UpdateWorkCard API — closes 5ac0a359

The recurring friction during this session: cards were filed with
provisional bodies that needed updating once decomposition / scope
refinement landed, but the substrate had no typed way to amend a
card after creation. The workaround (close + recreate) loses the
card's UUID — which breaks every `reviews` link pointing at the
old id, every observer subscription keyed on it, and every
projection's continuity guarantee.

Substrate (this commit):

  * `WorkEvent::CardUpdated` variant on the wire — typed
    amendment with editable fields as Options (`title`, `body`,
    `priority`). `None` = leave alone; an all-None event projects
    as a no-op that still bumps `updated_at_ms` (useful as a
    liveness marker).
  * `UpdateWorkCard` request type in airc-lib with a builder API
    (`.amend(id).with_title(...).with_body(...).with_priority(...)`)
    so the common path stays terse as the request struct grows.
  * `Airc::update_work_card` — reuses the
    `ensure_work_card_in_current_room` guard so out-of-room
    amendments surface a typed error, not a silent miss.
  * Projection `apply_card_updated` writes only the supplied
    fields; preserves `card_id`, `repo`, `created_by`,
    `created_at_ms`, `reviews`, `lane_id`, `state`, `owner`,
    `claim_id`. Updates `updated_at_ms` unconditionally.
  * Codec: new `card_updated` event kind + the `forge.work.card_id`
    header so subscribers watching a single card pick it up.
  * Wire-str + ALL_VARIANTS guard the TranscriptKind side
    already gives us; the WorkEvent enum side relies on the
    serde-tag exhaustive match.

Design notes encoded in the type:

  * Fields that CAN change: title, body, priority — exactly what
    the card 5ac0a359 brief asks for.
  * Fields that explicitly CANNOT: card_id (identity), repo (cards
    live where the work lives), created_by/created_at_ms
    (attribution / temporal anchor — append-only), reviews (rebinding
    a review to a different parent is structurally a different card),
    lane_id (lane reassignment is a separate concern).
  * `body: Option<String>` not `Option<Option<String>>` — the
    tri-state "leave / clear / set" doesn't round-trip through
    serde's defaults (null decodes to None, not Some(None)). The
    canonical clear is `Some("".into())` — empty string is the
    markdown "no body" idiom, and observers render them
    identically anyway. Doc comment on `CardUpdated` flags the
    swap-to-tagged-enum path if that distinction ever matters.

Tests (`airc-work` projection — 86 pass, +6 new):

  * `card_updated_title_only_preserves_body_and_priority` —
    pins the per-field independence contract.
  * `card_updated_body_leave_alone_vs_set_vs_empty_string_clear` —
    all three body modes round-trip through the projection.
  * `card_updated_priority_only_rewrites_priority` —
    priority-only update.
  * `card_updated_all_none_bumps_updated_at_only` — pins the
    no-op-amendment liveness-marker contract.
  * `card_updated_for_unknown_card_surfaces_error` —
    UnknownCard surfaces so `ensure_work_card_in_current_room`
    can wrap it as the typed AircError.
  * `card_updated_round_trips_through_serde_with_skip_on_none` —
    wire-shape contract: None fields are omitted, the empty-string
    clear shape is preserved byte-for-byte. Fixture uses
    `PeerId::new()` / `WorkCardId::new()` — no hand-rolled UUID
    strings (uuidv4 typed-newtype discipline).

CLI surface (`airc work update <CARD_ID> [--title T] [--body B]
[--priority P]`) landed via peer cdff6a9d's commit affc215 — my
work_commands.rs / main.rs edits were absorbed into that commit
during the shared-checkout window (peer's `git add .` picked up
my uncommitted CLI pieces alongside their doctrine-publish work).
Per-card worktrees (peer's 411ff9e + my-filed 59243bee +
peer's 399e3c3 fix) prevent this going forward.

Workspace counts: airc-work 86, airc-lib 14, airc-cli 15+12 — green.
Pre-existing failure in airc-cli's `work_create_claim_release_projects_on_board`
(short-uuid render vs full-uuid assertion, same root cause as
b1735261 / fixed via e9b12e6 for its sibling test) is independent;
reproduces on the base.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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