Repository navigation
fix: resolve_gh_bin fallback to known winget paths (closes #85) - #86
Conversation
On Windows native + Git Bash (BigMama 5090, 2026-04-25), gh is installed via winget at the standard location `C:\Program Files\GitHub CLI\gh.exe`, but Git Bash's PATH doesn't inherit it. Result: airc skips its gist substrate, leaving the user stuck on legacy long-invite-string flow with no auto-discovery. resolve_tailscale_bin already solves the equivalent problem for tailscale by checking known platform install locations as fallbacks. There was no analogous resolve_gh_bin — so tailscale-on-Git-Bash worked out of the box, but gh-on-Git-Bash silently degraded airc. Fix: mirror the tailscale solution. Add resolve_gh_bin (bash) / Resolve-GhBin (ps1) that checks PATH first, then falls back to known install locations: /c/Program Files/GitHub CLI/gh.exe /mnt/c/Program Files/GitHub CLI/gh.exe (WSL2 cross-mount) /c/Program Files (x86)/GitHub CLI/gh.exe (legacy 32-bit) /usr/local/bin/gh (mac homebrew x86) /opt/homebrew/bin/gh (mac homebrew arm) Approach: rather than wrap every gh callsite (~20 places in bash, ps1 parallel), do a one-time PATH-prepend at script startup if gh resolves via fallback. All existing `gh` calls keep working transparently. ~50 lines total across both languages. Side-fix: original placement attempt had a forward-reference ordering bug (called resolve_gh_bin before its definition); moved the helper above the PATH-fixup invocation and added a comment noting why it sits separately from resolve_tailscale_bin. 133/133 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a cross-platform gh (GitHub CLI) discovery fallback so Windows Git Bash / native shells can still use airc’s gist substrate even when gh is installed but not on PATH.
Changes:
- Add
resolve_gh_bintoaircwith a PATH-prepend startup fixup using known install locations. - Add early
ghdiscovery + PATH fixup toairc.ps1, plus aResolve-GhBinhelper mirroring theResolve-TailscaleBinpattern.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
airc |
Adds gh resolver + PATH-prepend fallback to keep existing gh ... callsites working when gh isn’t on PATH. |
airc.ps1 |
Adds early gh resolution + PATH fixup and a Resolve-GhBin helper for Windows PowerShell parity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function Resolve-GhBin { | ||
| # Same shape as Resolve-TailscaleBin. Issue #85: on Windows native + | ||
| # Git Bash, gh is installed via winget at the standard location but | ||
| # the path doesn't get inherited into Git Bash's PATH. The bash side | ||
| # has the equivalent helper; ps1 keeps lockstep so gist substrate | ||
| # works without manual PATH edits. | ||
| foreach ($name in @('gh', 'gh.exe')) { | ||
| $cmd = Get-Command $name -ErrorAction SilentlyContinue | ||
| if ($cmd) { return $cmd.Source } | ||
| } | ||
| foreach ($p in @( | ||
| 'C:\Program Files\GitHub CLI\gh.exe', | ||
| 'C:\Program Files (x86)\GitHub CLI\gh.exe' | ||
| )) { | ||
| if (Test-Path $p) { return $p } | ||
| } | ||
| return $null | ||
| } | ||
|
|
There was a problem hiding this comment.
Resolve-GhBin is introduced here but doesn’t appear to be called anywhere (the script uses Get-Command gh / & gh ... directly, and PATH is already patched earlier). If the intent is just the early PATH fixup, consider removing this unused helper; otherwise, update the gh wrapper/helpers to use this resolver so there’s a single source of truth for gh discovery.
| function Resolve-GhBin { | |
| # Same shape as Resolve-TailscaleBin. Issue #85: on Windows native + | |
| # Git Bash, gh is installed via winget at the standard location but | |
| # the path doesn't get inherited into Git Bash's PATH. The bash side | |
| # has the equivalent helper; ps1 keeps lockstep so gist substrate | |
| # works without manual PATH edits. | |
| foreach ($name in @('gh', 'gh.exe')) { | |
| $cmd = Get-Command $name -ErrorAction SilentlyContinue | |
| if ($cmd) { return $cmd.Source } | |
| } | |
| foreach ($p in @( | |
| 'C:\Program Files\GitHub CLI\gh.exe', | |
| 'C:\Program Files (x86)\GitHub CLI\gh.exe' | |
| )) { | |
| if (Test-Path $p) { return $p } | |
| } | |
| return $null | |
| } |
| _gh_resolved=$(resolve_gh_bin 2>/dev/null || true) | ||
| if [ -n "$_gh_resolved" ] && ! command -v gh >/dev/null 2>&1; then | ||
| export PATH="$(dirname "$_gh_resolved"):$PATH" | ||
| fi |
There was a problem hiding this comment.
In the PATH-prepend block, dirname "$_gh_resolved" can evaluate to . if resolve_gh_bin returned a bare command name like gh.exe (which it currently does when command -v gh.exe succeeds). That would prepend the current working directory to PATH, which is a security risk and can also fail to fix gh resolution. Consider only prepending when the resolver returns an absolute path, or have resolve_gh_bin emit the full path for the gh.exe case (e.g., via command -v gh.exe) before calling dirname.
| # Defined inline here so the PATH-fixup below can use it before the | ||
| # main helpers section below runs. Issue #85. | ||
| function _Resolve-GhBinEarly { | ||
| foreach ($name in @('gh', 'gh.exe')) { | ||
| $cmd = Get-Command $name -ErrorAction SilentlyContinue | ||
| if ($cmd) { return $cmd.Source } | ||
| } | ||
| foreach ($p in @( | ||
| 'C:\Program Files\GitHub CLI\gh.exe', | ||
| 'C:\Program Files (x86)\GitHub CLI\gh.exe' | ||
| )) { | ||
| if (Test-Path $p) { return $p } | ||
| } | ||
| return $null | ||
| } | ||
|
|
||
| # gh PATH-fixup: if gh resolved via fallback rather than PATH, prepend its | ||
| # directory to PATH so every later `gh` invocation transparently finds it. | ||
| $_ghResolved = _Resolve-GhBinEarly |
There was a problem hiding this comment.
_Resolve-GhBinEarly duplicates the later Resolve-GhBin logic, and Resolve-GhBin is currently unused in this script (all gh usage relies on PATH + Get-Command gh). This increases maintenance risk if one list of fallback paths changes and the other doesn’t. Suggest consolidating to a single resolver (e.g., move Resolve-GhBin above the PATH fixup and use it there) and removing the unused early helper / dead code.
| # Defined inline here so the PATH-fixup below can use it before the | |
| # main helpers section below runs. Issue #85. | |
| function _Resolve-GhBinEarly { | |
| foreach ($name in @('gh', 'gh.exe')) { | |
| $cmd = Get-Command $name -ErrorAction SilentlyContinue | |
| if ($cmd) { return $cmd.Source } | |
| } | |
| foreach ($p in @( | |
| 'C:\Program Files\GitHub CLI\gh.exe', | |
| 'C:\Program Files (x86)\GitHub CLI\gh.exe' | |
| )) { | |
| if (Test-Path $p) { return $p } | |
| } | |
| return $null | |
| } | |
| # gh PATH-fixup: if gh resolved via fallback rather than PATH, prepend its | |
| # directory to PATH so every later `gh` invocation transparently finds it. | |
| $_ghResolved = _Resolve-GhBinEarly | |
| # Reuse the shared resolver so there is only one fallback-path list to | |
| # maintain. PowerShell parses function definitions for the whole script | |
| # before execution, so Resolve-GhBin can be called here even if its | |
| # definition appears later in the file. Issue #85. | |
| # gh PATH-fixup: if gh resolved via fallback rather than PATH, prepend its | |
| # directory to PATH so every later `gh` invocation transparently finds it. | |
| $_ghResolved = Resolve-GhBin |
…ard c9b28925) (#1105) * feat(airc-lib): `Airc::attach_as(home, agent_name, socket)` — citizen-host constructor Multi-citizen hosts (Continuum personas, future external-agent hosts) need to spawn each hosted citizen with BOTH: 1. Its own identity (so `airc peers` from another scope sees each citizen as a separate enrolled participant), and 2. The daemon's live publish/subscribe (so the citizen can `say()` / `subscribe()` over the router, not just inspect local state). Today the constructor matrix only offers ONE of these per call: - `Airc::open_as(home, agent_name)` — identity ✓, daemon ✗ - `Airc::attach(home, socket)` — daemon ✓, identity ✗ So a host hosting N citizens has to reach for the (intentionally private) `with_daemon_client` builder via some awkward dance — or fork the bootstrap inline. Neither is ergonomic; both leak abstraction the public API meant to seal. This PR adds the natural diagonal of the matrix: pub async fn attach_as(home, agent_name, socket) -> Result<Self> Equivalent to `open_as(home, agent_name).await?.with_daemon_client (DaemonClient::new(socket))` but spelled as one method so consumers don't reach for the private builder. ### Concrete consumer Continuum-core's upcoming `PersonaAircRuntime` (continuum PR #1, see continuum task #86) spawns one `Airc` instance per hosted persona — each persona at its own `~/.continuum/personas/<name>/airc/` home, with its own Ed25519 identity, addressed by `agent_name = <persona>` — and needs the daemon-connected variant so the persona can participate in live rooms. The mental model: continuum is to airc what Codex is to airc — a host that runs N citizens, each first-class on the substrate. That host needs one constructor that gives it (identity × daemon) cleanly. `attach_as` IS that. ### Drift guard The implementation is a 5-line delegation to the existing `open_as` + `with_daemon_client` private helper, so this constructor cannot drift from the pair it composes. Any future change to either half automatically applies here. ### Test plan - [x] `cargo test -p airc-lib` — 1 passed, 0 failed (existing doctests; new constructor uses the same delegation paths that `attach` and `open_as` already cover) - [x] `cargo clippy -p airc-lib --no-deps -- -D warnings` clean - [x] `cargo fmt --check` clean - [ ] Adversarial reviewer agent verdict per AGENTS.md §0 + airc#1094 - [ ] Continuum PR #1 (task #86) consumes this constructor in `PersonaAircRuntime::bootstrap` — substantive integration test ### References - Continuum memory `personas-are-citizens-airc-is-identity-provider` - Continuum memory `airc-headers-are-the-routing-layer` - Continuum workflow w801jcu9r design synthesis — identified this missing constructor in the airc-lib API audit's `gaps` field - Joel, 2026-05-31: "We can enhance facilities we edit airc. They use airc as their identity provider and their own connection to the grid." This PR is the airc-side facility enhancement for the persona-as-citizen architecture. Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(airc-ipc): `impl From<>` blocks bridging SDK transcript types to IPC wire vocabulary External consumers building `PublishRequest`/`InboxRequest` from SDK- shaped state (continuum-core, OpenClaw, Hermes, future grid workers, this repo's own CLI) need to translate the chat-flavored types (`FrameKind`, `MentionTarget`, `TranscriptCursor`) into the v5 IPC wire vocabulary (`IpcKind`, `IpcTarget`, `IpcCursor`). Before this PR these conversions lived as private free functions (`framekind_to_ipc`, `mention_to_ipc_target`, `pack_seq`, `unpack_seq`) in `airc-lib/src/daemon.rs`. Any external consumer had to either: (a) Pull all of `airc-lib` for one private function — wrong surface for drive-by use, and the helpers are `fn` not `pub fn`. (b) Re-implement the same bit-shifting + variant matching in their own code — drift class. Continuum did this transitionally during the v5 migration before promoting them here. This PR promotes them to **`impl From<>` blocks in airc-ipc**, the smallest crate that depends on both `airc-core` (where the SDK types live) and `airc-protocol` (where `FrameKind` lives). Co- locating the conversions with the IPC vocabulary they produce gives every consumer `pub_req.kind = frame_kind.into()` instead of reaching for a free function. ### What ships - `crates/airc-ipc/src/sdk_conversions.rs` (NEW, ~170 lines including 6 tests): - `impl From<FrameKind> for IpcKind` — total, lossless - `impl From<MentionTarget> for IpcTarget` — total, lossless (room mentions round-trip via the `room:<uuid>` endpoint convention) - `impl From<TranscriptCursor> for IpcCursor` — total, lossless - `impl From<IpcCursor> for TranscriptCursor` — total, lossless, round-trip safe - `pub const COUNTER_BITS: u32 = 40` + `COUNTER_MASK` — published so any consumer needing to reproduce the lamport-packing layout (without going through the conversion) pins against the same constant. If anyone shifts the layout, every dependent recompiles + the round-trip tests fail loud. - `crates/airc-ipc/src/lib.rs` — re-export `COUNTER_BITS`/`COUNTER_MASK`; declare the new module. - `crates/airc-lib/src/daemon.rs` — delete the private duplicates (`framekind_to_ipc`, `mention_to_ipc_target`); switch call sites to `.into()`; import `COUNTER_BITS`/`COUNTER_MASK` from `airc-ipc` so the local `pack_seq`/`unpack_seq` helpers stay byte-compatible via shared constant. ### Doctrinal alignment Joel, 2026-05-31: > "I always simultaneously develop the sdk and consumer of it. It > helps you build the best patterns." This PR is the SDK half of the v5 owner-core consumer migration landing in continuum's sibling PR. The conversion shape was chosen to fit continuum's call sites (idiomatic `.into()` in `PublishRequest`/`InboxRequest` construction) — exactly the co-evolution pattern. Doing them simultaneously also caught the "airc-lib internals are the wrong surface" anti-pattern that would have otherwise persisted as drift. Pattern memory for future PRs: when continuum (or any other airc consumer) needs an airc-side helper that's currently private, upstream it as the natural extension of the existing public vocabulary — not as a "consumer-shaped" SDK method nor a duplicated helper in the consumer. ### Test plan - [x] `cargo test -p airc-ipc` — 33/33 pass (6 new tests in `sdk_conversions::tests`) - [x] `cargo test -p airc-lib` — 1 passed, 0 failed, 4 ignored (doc-test compile check); no regressions from removing the internal `framekind_to_ipc`/`mention_to_ipc_target` helpers - [x] `cargo build --release --bin airc` — clean - [ ] Adversarial reviewer agent verdict (per AGENTS.md §0 doctrine) ### References - Continuum task #82 — headless break #3 (Response::Event schema mismatch); this airc PR is the SDK half, continuum sibling PR is the consumer half. - AGENTS.md §0 + airc#1094 — agent sign-off doctrine. - airc#1095 (still open pending Windows CI) — `airc ipc-endpoint` command. Same iteration loop pattern. - `crates/airc-lib/src/daemon.rs` — historical home of these helpers, now thinned to call the From impls. Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(README): cross-surface identity doctrine — bridges are translators, not identity-holders When a bridge connects an external surface (Slack, Discord, Telegram, Teams, Zoom, X, etc.) the citizen's stable identity stays in airc. The bridge holds whatever platform credentials it needs to post on the citizen's behalf, but it never owns the persona. Unplug a bridge and the citizen persists; plug in a different platform's bridge and the same citizen appears there with the same keypair, name, and reputation. This formalizes what "same personas, everywhere" means at the substrate level — pairing with the continuum-side README change on feat/persona-helper-ai-as-airc-citizen. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(work): work_board(usize::MAX) trips 16 MiB IPC cap (card acd72c81) (#1100) * fix(work): work_board(usize::MAX) → work_board_complete(PAGE_SIZE) at all 9 callsites (card acd72c81) `airc work state X closed` and 8 other CLI paths called `airc.work_board(usize::MAX)` to look up a single card or compute a snapshot. With `usize::MAX`, the daemon-attached path issues ONE Inbox RPC asking for every event in the room (the fetch multiplier saturates), and the daemon serializes all of them into a single CBOR frame. Once the room accumulates ~9000+ bus events (operationally hit on Joel's box 2026-06-01), the response trips `airc_ipc::codec::MAX_FRAME_BYTES`: daemon I/O: ipc frame too large: 16973574 bytes exceeds 16777216 Every state transition through these callsites then fails, the kanban freezes behind merged PRs, and other agents pile up on the same flake without recourse. ## Fix `work_board_complete(page_size)` already exists for the same intent (complete projection) but paginates the IPC transcript fetch (airc-lib/src/work.rs:776 → daemon_room_transcripts at airc-lib/src/daemon.rs:314). Each Inbox RPC asks for `page_size` events, the client loops until done, no individual frame exceeds the cap. Same projection completeness, low-latency per RPC, correct architecture. This commit: 1. Introduces `pub const WORK_BOARD_PROJECTION_PAGE_SIZE: usize = 1024` in airc-lib/src/work.rs as the canonical page size for complete-projection callers. 1024 events per page is comfortably under the 16 MiB cap (events are typed records in the kilobyte range, not blobs) and keeps the round-trip count low for 9000+ event rooms. 2. Updates `work_board(limit)`'s docstring to call out `usize::MAX` as forbidden and point at `work_board_complete`. 3. Swaps all 9 `work_board(usize::MAX)` callsites to `work_board_complete(WORK_BOARD_PROJECTION_PAGE_SIZE)`: - airc-cli/src/work_commands.rs (5 sites) - airc-cli/src/work_commands_git.rs (1 site) - airc-cli/src/work_commands_gh.rs (2 sites) - airc-lib/src/agent_heartbeat.rs (1 site) 4. Exports `WORK_BOARD_PROJECTION_PAGE_SIZE` from the airc-lib crate root so future callers reference one canonical constant instead of re-picking page sizes. ## Verification - `cargo check --workspace`: clean. - `cargo build --release -p airc-cli`: clean. - Reinstalled the binary to /Users/joel/.local/bin/airc, restarted daemon, ran `airc work state 0462c1a8... closed` — the 16 MiB IPC frame error is gone; the CLI now correctly reports the close-lifecycle gate's actual semantic refusal ("requires Merged predecessor"). Same writes that failed pre-fix now reach the daemon successfully. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: fix the immediate symptom AND the class. Every existing callsite gets the paginated path; future ones reference the canonical const. [[host-the-seemingly-impossible]]: the substrate now scales to 9000+ events without IPC-cap failures on routine writes. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(merger): reconcile already-merged PRs instead of skipping (card acd72c81 follow-up) When `gh pr view` reports `state="MERGED"` for a card's linked PR, the merger previously returned `GateResult::NotReady("PR state is MERGED (not OPEN)")` and skipped. That left the kanban projection permanently out of sync with GitHub: the PR was merged but the card stayed in Review. Stale cards accumulated; closure (Review → Closed) needs a Merged predecessor and never got one. This is the third symptom of the same root cause as the IPC cap fix: the merger had every piece of information it needed to reconcile, but the gate only had a "merge it" path and a "skip it" path — no "the merge already happened, just update our projection" path. ## Behavior change The merger now distinguishes: - `GateResult::Green` — open + green CI → call `gh pr merge` + emit `PullRequestMerged` (unchanged) - `GateResult::AlreadyMerged { merged_at_ms }` — state==MERGED → emit `PullRequestMerged` ONLY; no `gh pr merge` call (new) - `GateResult::NotReady(reason)` — state != OPEN and != MERGED, or open with failures (unchanged) The reconcile path uses `view.mergedAt` as the canonical `merged_at_ms` when gh supplies it, falling back to wall-clock-now. gh's `--json` query now includes `mergedAt` (one extra field; no new RPC). ## Symmetry with `airc work merge` The manual `airc work merge X` CLI command consumes the same gate. It now handles `AlreadyMerged` symmetrically: reconciles without a `gh pr merge` call, prints `reconciled: card=X pr=#N repo=R (PR was already merged on GitHub)`. ## End-to-end verification Built + reinstalled the binary, ran the merger against the Joel-box backlog of 4 already-merged cards (PR #1500, #1501, #1502, #1503): airc-merger: reconciled already-merged card=0462c1a8 pr=#1502 airc-merger: reconciled already-merged card=2c844fae pr=#1500 airc-merger: reconciled already-merged card=63ca1f00 pr=#1501 airc-merger: reconciled already-merged card=87fbb385 pr=#1503 Board after: all 4 transitioned Review → Merged. `airc work close` then succeeded on each (Merged → Closed). Kanban finally matches GitHub reality. ## Tests - `evaluate_gh_view_routes_merged_state_to_already_merged`: MERGED + mergedAt → AlreadyMerged with parsed canonical ms - `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent`: the fallback path produces a nonzero ms - `evaluate_gh_view_routes_closed_state_to_not_ready`: CLOSED (without merge) stays NotReady — we don't auto-reconcile abandoned PRs into Merged state - `parse_iso8601_to_ms_handles_standard_gh_format`: the helper handles the standard gh timestamp shape + invalid input - Updated `refuses_when_pr_is_already_merged` → `reconciles_when_pr_is_already_merged` to encode the new behavior and the rationale All 28 merger tests pass. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: the "skip-and-leak" anti-pattern is gone — every terminal PR state the merger sees now has a kanban-reconciliation action, not just the happy-path "merge". Card: acd72c81 (follow-up slice; same PR #1100) Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(merger): cargo fmt + clippy fixes for CI green (card acd72c81 follow-up) PR #1100's CI surfaced three issues missed in local cargo check: 1. cargo fmt: AlreadyMerged variant's anonymous field, the "MERGED + mergedAt" json test literal, and the work_board_complete call sites reflowed by rustfmt's wrap rules. 2. clippy --deny-warnings: the new test `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent` used `mergedAt` (camelCase from gh) in the function name — clippy non_snake_case lint. Renamed to `merged_at`. 3. workspace test: airc-lib's internal `ok_view` test helper constructs PrView { state, mergeable, status_check_rollup, .. } without the new `merged_at` field. Added `merged_at: None`. Local cargo fmt --check + clippy --deny-warnings + cargo test -p airc-cli -p airc-lib are now green; the same three CI jobs that failed on the prior push (cargo fmt, cargo clippy, cargo test on macos/ubuntu/windows) should pass on this push. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * feat(work): `airc work cleanup` — auto-prune merged-card worktrees (card c9b28925) Today's session manually ran `git worktree remove acd72c81` after PR #1100 merged, then cleaned 75+ GiB of stale build caches by hand across two repos and four worktrees. Multi-session reality is worse — a sustained operator builds up 10+ stale worktrees over weeks, each holding a checkout + (when rebuilt) GiB of target cache. The substrate already names the principle (`local-worktree-is-temp-dir`, `substrate-is-a-good-citizen-on-the-host`); this commit starts automating it. ## What ships `airc work cleanup [--dry-run] [--force]`: $ airc work cleanup worktrees scanned: 4 KeepActive: 800ce5bd PR #1103 Review 807193ab PR #1102 Review c409eaf5 PR #1104 Review SkipDirty: c9b28925 no PR InProgress uncommitted changes Nothing to remove. Scan logic: - List `~/.airc/worktrees/*/`. - Resolve each worktree's card by short id (first 8 hex chars of the worktree dir name) via `work_board_complete`. - Probe `git status --porcelain` for dirty / clean / unknown. - Classify into one of five dispositions: - `Removable` — card is Closed or Merged, worktree is clean. - `KeepActive` — card is Open / Claimed / InProgress / Review / Blocked. - `SkipDirty` — worktree has uncommitted changes. - `SkipNotGit` — `git status` probe failed. - `SkipUnknownCard` — basename matches the short-id pattern but no card on the current board (orphan). Default behaviour: classify + print + do nothing destructive. `--force` runs `git worktree remove` against everything in `Removable`. `--dry-run` is the explicit-intent alias of the default. ## Safety: operator's WIP outranks hygiene Worktrees in `SkipDirty`, `SkipNotGit`, or `SkipUnknownCard` are NEVER removed silently — even with `--force`. The first slice refuses to make destructive decisions on dirty / unknown state. The operator commits, pushes, deletes manually, then re-runs cleanup — which is the same discipline a careful human applies today. ## What this DOES NOT do (yet) - Doesn't touch `target/` dirs. Build caches are per-project under operator-owned paths; the substrate can't safely wipe them without consent. Follow-up. - Doesn't run on a timer. The always-on hygiene tick (with typed `WorkspaceCleaned` / `WorkspaceSkipped` events, disk-pressure thresholds) is the next slice on continuum task #88. - Doesn't detect `git worktree lock`. The locked .claude/worktrees in Joel's setup are under `Development/airc/.claude/worktrees/` (outside the lease zone), so they're never seen by the scan today; explicit lock detection is a follow-up. ## Tests Pure-function classifier + parser get unit-tested in isolation: - `parse_worktree_short_id_accepts_canonical_shape` / rejects / truncates — covers the parser. - `classifier_closed_clean_removes` - `classifier_merged_clean_removes` - `classifier_active_states_keep` — table-drive every active state. - `classifier_dirty_never_removes_even_when_card_closed` — pins the WIP-outranks-hygiene contract. - `classifier_no_card_returns_skip_unknown_card` - `classifier_not_git_returns_skip_not_git` - `disposition_display_priority_orders_removable_first` — pin the table sort so the operator sees actionable items first. 34/34 work_commands tests pass. ## Live smoke Built + reinstalled + ran on Joel's machine after today's session. Result above: 3 open PRs correctly identified as KeepActive, this card's own worktree correctly identified as SkipDirty (in-flight code), nothing destroyed. Exactly the desired safety posture. Card: c9b28925 Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(work): probe_dirty_status — detect unpushed commits, close WIP footgun (PR #1105 reviewer round 1) Adversarial reviewer caught the headline footgun: the original `git_status_porcelain` only checked working-tree-vs-HEAD (uncommitted/untracked), NEVER HEAD-vs-upstream (unpushed commits). A closed-card worktree with committed-but-unpushed WIP on a branch with upstream tracking would have been classified Clean → Removable → silently destroyed by `airc work cleanup --force`. The PR's headline safety claim ("operator's WIP outranks hygiene") was effectively false-advertised — the doc on `cleanup_card_worktree` even explicitly promised an unpushed-commits check the body never implemented. This commit ships the actual check + reconciles the doc. ## Fixes ### BLOCK 1 — `cleanup_card_worktree` doc lie Old doc claimed: > REFUSES if the worktree has unpushed commits AND its branch is > the worktree's current HEAD — those commits would be unreachable > after pruning. Body did no such check; only `git status --porcelain` was probed. New doc describes ACTUAL behavior + the new two-pass `probe_dirty_status` contract. ### BLOCK 2 — `probe_dirty_status` adds unpushed-commits probe Renamed `git_status_porcelain` → `probe_dirty_status`. New two-pass check: 1. `git status --porcelain` — uncommitted/untracked. Non-empty ⇒ Dirty (unchanged from prior behavior). 2. `git rev-list --count @{u}..HEAD` — committed-but-not-pushed. Non-zero ⇒ Dirty. - If `@{u}` errors (no upstream tracking, detached HEAD, orphan branch): refuse to classify, return Unknown. Per `[[no-fallbacks-ever]]` we don't guess Clean for the ambiguous case. ### BLOCK 3 — unify protection across both terminal paths `cleanup_card_worktree` (called by merger via #1091 and CLI `work close`) now calls `probe_dirty_status` instead of its inline porcelain-only check. Both terminal paths apply identical safety: - merger `perform_merge` → `cleanup_card_worktree` → `probe_dirty_status` (uncommitted + unpushed) - CLI `airc work close` → `cleanup_card_worktree` → same - CLI `airc work cleanup --force` → classifier-filtered to Removable (which means probe_dirty_status returned Clean) → `git_worktree_remove` Same probe drives both gate decisions; no semantic drift. ## Doc updates - `Disposition::SkipDirty` — clarified to "uncommitted or unpushed work" (was "uncommitted / unpushed" but only the first was actually checked). - `Disposition::suffix(SkipDirty)` — "uncommitted or unpushed work" in the operator-facing table. - `DirtyStatus` enum — variant docs describe the new two-pass contract + the Unknown-refuses-rather-than-guesses doctrine. ## Tests (+5 new, all 40 pass) Real-git fixture tests (vs the prior tests which only exercised the classifier's reaction to the `DirtyStatus` enum): - `probe_dirty_status_clean_when_committed_and_pushed` — happy path - `probe_dirty_status_dirty_on_uncommitted_change` — porcelain pass - `probe_dirty_status_dirty_on_unpushed_commit` — the BLOCK 2 scenario specifically; pins the safety contract on the function where the bug lived - `probe_dirty_status_unknown_when_no_upstream_tracking` — ambiguous case refuses to classify - `probe_dirty_status_unknown_when_not_a_git_dir` — probe failure → Unknown 40/40 work_commands tests pass. ## Doctrine - `[[no-fallbacks-ever]]` — Unknown-on-ambiguous probe; no silent Clean assumption - `[[local-worktree-is-temp-dir]]` — extended: the worktree IS the temp dir AS LONG AS its content is captured upstream; unpushed work is not captured upstream - `[[every-error-is-an-opportunity-to-battle-harden]]` — the reviewer caught a real foot-gun; the fix is the production fix, not a test workaround Card: c9b28925 Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(work): fmt + clippy compliance on probe_dirty_status touch-up CI on cce1b8a flagged cargo fmt + cargo clippy (deny warnings). Both auto-fixable: - cargo fmt — reformat the new test block + doc comments to repo style (74 lines reflowed in work_commands.rs) - clippy doc_lazy_continuation — the four-line "REFUSES via probe_dirty_status if..." bullet had inner sub-bullets at inconsistent indentation; collapsed to a single prose paragraph that conveys the same three conditions inline. No behavior change; the probe_dirty_status logic + tests from cce1b8a are untouched. Card: c9b28925 Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
…out misses (card 800ce5bd) (#1103) * feat(airc-lib): `Airc::attach_as(home, agent_name, socket)` — citizen-host constructor Multi-citizen hosts (Continuum personas, future external-agent hosts) need to spawn each hosted citizen with BOTH: 1. Its own identity (so `airc peers` from another scope sees each citizen as a separate enrolled participant), and 2. The daemon's live publish/subscribe (so the citizen can `say()` / `subscribe()` over the router, not just inspect local state). Today the constructor matrix only offers ONE of these per call: - `Airc::open_as(home, agent_name)` — identity ✓, daemon ✗ - `Airc::attach(home, socket)` — daemon ✓, identity ✗ So a host hosting N citizens has to reach for the (intentionally private) `with_daemon_client` builder via some awkward dance — or fork the bootstrap inline. Neither is ergonomic; both leak abstraction the public API meant to seal. This PR adds the natural diagonal of the matrix: pub async fn attach_as(home, agent_name, socket) -> Result<Self> Equivalent to `open_as(home, agent_name).await?.with_daemon_client (DaemonClient::new(socket))` but spelled as one method so consumers don't reach for the private builder. ### Concrete consumer Continuum-core's upcoming `PersonaAircRuntime` (continuum PR #1, see continuum task #86) spawns one `Airc` instance per hosted persona — each persona at its own `~/.continuum/personas/<name>/airc/` home, with its own Ed25519 identity, addressed by `agent_name = <persona>` — and needs the daemon-connected variant so the persona can participate in live rooms. The mental model: continuum is to airc what Codex is to airc — a host that runs N citizens, each first-class on the substrate. That host needs one constructor that gives it (identity × daemon) cleanly. `attach_as` IS that. ### Drift guard The implementation is a 5-line delegation to the existing `open_as` + `with_daemon_client` private helper, so this constructor cannot drift from the pair it composes. Any future change to either half automatically applies here. ### Test plan - [x] `cargo test -p airc-lib` — 1 passed, 0 failed (existing doctests; new constructor uses the same delegation paths that `attach` and `open_as` already cover) - [x] `cargo clippy -p airc-lib --no-deps -- -D warnings` clean - [x] `cargo fmt --check` clean - [ ] Adversarial reviewer agent verdict per AGENTS.md §0 + airc#1094 - [ ] Continuum PR #1 (task #86) consumes this constructor in `PersonaAircRuntime::bootstrap` — substantive integration test ### References - Continuum memory `personas-are-citizens-airc-is-identity-provider` - Continuum memory `airc-headers-are-the-routing-layer` - Continuum workflow w801jcu9r design synthesis — identified this missing constructor in the airc-lib API audit's `gaps` field - Joel, 2026-05-31: "We can enhance facilities we edit airc. They use airc as their identity provider and their own connection to the grid." This PR is the airc-side facility enhancement for the persona-as-citizen architecture. Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(airc-ipc): `impl From<>` blocks bridging SDK transcript types to IPC wire vocabulary External consumers building `PublishRequest`/`InboxRequest` from SDK- shaped state (continuum-core, OpenClaw, Hermes, future grid workers, this repo's own CLI) need to translate the chat-flavored types (`FrameKind`, `MentionTarget`, `TranscriptCursor`) into the v5 IPC wire vocabulary (`IpcKind`, `IpcTarget`, `IpcCursor`). Before this PR these conversions lived as private free functions (`framekind_to_ipc`, `mention_to_ipc_target`, `pack_seq`, `unpack_seq`) in `airc-lib/src/daemon.rs`. Any external consumer had to either: (a) Pull all of `airc-lib` for one private function — wrong surface for drive-by use, and the helpers are `fn` not `pub fn`. (b) Re-implement the same bit-shifting + variant matching in their own code — drift class. Continuum did this transitionally during the v5 migration before promoting them here. This PR promotes them to **`impl From<>` blocks in airc-ipc**, the smallest crate that depends on both `airc-core` (where the SDK types live) and `airc-protocol` (where `FrameKind` lives). Co- locating the conversions with the IPC vocabulary they produce gives every consumer `pub_req.kind = frame_kind.into()` instead of reaching for a free function. ### What ships - `crates/airc-ipc/src/sdk_conversions.rs` (NEW, ~170 lines including 6 tests): - `impl From<FrameKind> for IpcKind` — total, lossless - `impl From<MentionTarget> for IpcTarget` — total, lossless (room mentions round-trip via the `room:<uuid>` endpoint convention) - `impl From<TranscriptCursor> for IpcCursor` — total, lossless - `impl From<IpcCursor> for TranscriptCursor` — total, lossless, round-trip safe - `pub const COUNTER_BITS: u32 = 40` + `COUNTER_MASK` — published so any consumer needing to reproduce the lamport-packing layout (without going through the conversion) pins against the same constant. If anyone shifts the layout, every dependent recompiles + the round-trip tests fail loud. - `crates/airc-ipc/src/lib.rs` — re-export `COUNTER_BITS`/`COUNTER_MASK`; declare the new module. - `crates/airc-lib/src/daemon.rs` — delete the private duplicates (`framekind_to_ipc`, `mention_to_ipc_target`); switch call sites to `.into()`; import `COUNTER_BITS`/`COUNTER_MASK` from `airc-ipc` so the local `pack_seq`/`unpack_seq` helpers stay byte-compatible via shared constant. ### Doctrinal alignment Joel, 2026-05-31: > "I always simultaneously develop the sdk and consumer of it. It > helps you build the best patterns." This PR is the SDK half of the v5 owner-core consumer migration landing in continuum's sibling PR. The conversion shape was chosen to fit continuum's call sites (idiomatic `.into()` in `PublishRequest`/`InboxRequest` construction) — exactly the co-evolution pattern. Doing them simultaneously also caught the "airc-lib internals are the wrong surface" anti-pattern that would have otherwise persisted as drift. Pattern memory for future PRs: when continuum (or any other airc consumer) needs an airc-side helper that's currently private, upstream it as the natural extension of the existing public vocabulary — not as a "consumer-shaped" SDK method nor a duplicated helper in the consumer. ### Test plan - [x] `cargo test -p airc-ipc` — 33/33 pass (6 new tests in `sdk_conversions::tests`) - [x] `cargo test -p airc-lib` — 1 passed, 0 failed, 4 ignored (doc-test compile check); no regressions from removing the internal `framekind_to_ipc`/`mention_to_ipc_target` helpers - [x] `cargo build --release --bin airc` — clean - [ ] Adversarial reviewer agent verdict (per AGENTS.md §0 doctrine) ### References - Continuum task #82 — headless break #3 (Response::Event schema mismatch); this airc PR is the SDK half, continuum sibling PR is the consumer half. - AGENTS.md §0 + airc#1094 — agent sign-off doctrine. - airc#1095 (still open pending Windows CI) — `airc ipc-endpoint` command. Same iteration loop pattern. - `crates/airc-lib/src/daemon.rs` — historical home of these helpers, now thinned to call the From impls. Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(README): cross-surface identity doctrine — bridges are translators, not identity-holders When a bridge connects an external surface (Slack, Discord, Telegram, Teams, Zoom, X, etc.) the citizen's stable identity stays in airc. The bridge holds whatever platform credentials it needs to post on the citizen's behalf, but it never owns the persona. Unplug a bridge and the citizen persists; plug in a different platform's bridge and the same citizen appears there with the same keypair, name, and reputation. This formalizes what "same personas, everywhere" means at the substrate level — pairing with the continuum-side README change on feat/persona-helper-ai-as-airc-citizen. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(work): work_board(usize::MAX) trips 16 MiB IPC cap (card acd72c81) (#1100) * fix(work): work_board(usize::MAX) → work_board_complete(PAGE_SIZE) at all 9 callsites (card acd72c81) `airc work state X closed` and 8 other CLI paths called `airc.work_board(usize::MAX)` to look up a single card or compute a snapshot. With `usize::MAX`, the daemon-attached path issues ONE Inbox RPC asking for every event in the room (the fetch multiplier saturates), and the daemon serializes all of them into a single CBOR frame. Once the room accumulates ~9000+ bus events (operationally hit on Joel's box 2026-06-01), the response trips `airc_ipc::codec::MAX_FRAME_BYTES`: daemon I/O: ipc frame too large: 16973574 bytes exceeds 16777216 Every state transition through these callsites then fails, the kanban freezes behind merged PRs, and other agents pile up on the same flake without recourse. ## Fix `work_board_complete(page_size)` already exists for the same intent (complete projection) but paginates the IPC transcript fetch (airc-lib/src/work.rs:776 → daemon_room_transcripts at airc-lib/src/daemon.rs:314). Each Inbox RPC asks for `page_size` events, the client loops until done, no individual frame exceeds the cap. Same projection completeness, low-latency per RPC, correct architecture. This commit: 1. Introduces `pub const WORK_BOARD_PROJECTION_PAGE_SIZE: usize = 1024` in airc-lib/src/work.rs as the canonical page size for complete-projection callers. 1024 events per page is comfortably under the 16 MiB cap (events are typed records in the kilobyte range, not blobs) and keeps the round-trip count low for 9000+ event rooms. 2. Updates `work_board(limit)`'s docstring to call out `usize::MAX` as forbidden and point at `work_board_complete`. 3. Swaps all 9 `work_board(usize::MAX)` callsites to `work_board_complete(WORK_BOARD_PROJECTION_PAGE_SIZE)`: - airc-cli/src/work_commands.rs (5 sites) - airc-cli/src/work_commands_git.rs (1 site) - airc-cli/src/work_commands_gh.rs (2 sites) - airc-lib/src/agent_heartbeat.rs (1 site) 4. Exports `WORK_BOARD_PROJECTION_PAGE_SIZE` from the airc-lib crate root so future callers reference one canonical constant instead of re-picking page sizes. ## Verification - `cargo check --workspace`: clean. - `cargo build --release -p airc-cli`: clean. - Reinstalled the binary to /Users/joel/.local/bin/airc, restarted daemon, ran `airc work state 0462c1a8... closed` — the 16 MiB IPC frame error is gone; the CLI now correctly reports the close-lifecycle gate's actual semantic refusal ("requires Merged predecessor"). Same writes that failed pre-fix now reach the daemon successfully. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: fix the immediate symptom AND the class. Every existing callsite gets the paginated path; future ones reference the canonical const. [[host-the-seemingly-impossible]]: the substrate now scales to 9000+ events without IPC-cap failures on routine writes. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(merger): reconcile already-merged PRs instead of skipping (card acd72c81 follow-up) When `gh pr view` reports `state="MERGED"` for a card's linked PR, the merger previously returned `GateResult::NotReady("PR state is MERGED (not OPEN)")` and skipped. That left the kanban projection permanently out of sync with GitHub: the PR was merged but the card stayed in Review. Stale cards accumulated; closure (Review → Closed) needs a Merged predecessor and never got one. This is the third symptom of the same root cause as the IPC cap fix: the merger had every piece of information it needed to reconcile, but the gate only had a "merge it" path and a "skip it" path — no "the merge already happened, just update our projection" path. ## Behavior change The merger now distinguishes: - `GateResult::Green` — open + green CI → call `gh pr merge` + emit `PullRequestMerged` (unchanged) - `GateResult::AlreadyMerged { merged_at_ms }` — state==MERGED → emit `PullRequestMerged` ONLY; no `gh pr merge` call (new) - `GateResult::NotReady(reason)` — state != OPEN and != MERGED, or open with failures (unchanged) The reconcile path uses `view.mergedAt` as the canonical `merged_at_ms` when gh supplies it, falling back to wall-clock-now. gh's `--json` query now includes `mergedAt` (one extra field; no new RPC). ## Symmetry with `airc work merge` The manual `airc work merge X` CLI command consumes the same gate. It now handles `AlreadyMerged` symmetrically: reconciles without a `gh pr merge` call, prints `reconciled: card=X pr=#N repo=R (PR was already merged on GitHub)`. ## End-to-end verification Built + reinstalled the binary, ran the merger against the Joel-box backlog of 4 already-merged cards (PR #1500, #1501, #1502, #1503): airc-merger: reconciled already-merged card=0462c1a8 pr=#1502 airc-merger: reconciled already-merged card=2c844fae pr=#1500 airc-merger: reconciled already-merged card=63ca1f00 pr=#1501 airc-merger: reconciled already-merged card=87fbb385 pr=#1503 Board after: all 4 transitioned Review → Merged. `airc work close` then succeeded on each (Merged → Closed). Kanban finally matches GitHub reality. ## Tests - `evaluate_gh_view_routes_merged_state_to_already_merged`: MERGED + mergedAt → AlreadyMerged with parsed canonical ms - `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent`: the fallback path produces a nonzero ms - `evaluate_gh_view_routes_closed_state_to_not_ready`: CLOSED (without merge) stays NotReady — we don't auto-reconcile abandoned PRs into Merged state - `parse_iso8601_to_ms_handles_standard_gh_format`: the helper handles the standard gh timestamp shape + invalid input - Updated `refuses_when_pr_is_already_merged` → `reconciles_when_pr_is_already_merged` to encode the new behavior and the rationale All 28 merger tests pass. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: the "skip-and-leak" anti-pattern is gone — every terminal PR state the merger sees now has a kanban-reconciliation action, not just the happy-path "merge". Card: acd72c81 (follow-up slice; same PR #1100) Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(merger): cargo fmt + clippy fixes for CI green (card acd72c81 follow-up) PR #1100's CI surfaced three issues missed in local cargo check: 1. cargo fmt: AlreadyMerged variant's anonymous field, the "MERGED + mergedAt" json test literal, and the work_board_complete call sites reflowed by rustfmt's wrap rules. 2. clippy --deny-warnings: the new test `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent` used `mergedAt` (camelCase from gh) in the function name — clippy non_snake_case lint. Renamed to `merged_at`. 3. workspace test: airc-lib's internal `ok_view` test helper constructs PrView { state, mergeable, status_check_rollup, .. } without the new `merged_at` field. Added `merged_at: None`. Local cargo fmt --check + clippy --deny-warnings + cargo test -p airc-cli -p airc-lib are now green; the same three CI jobs that failed on the prior push (cargo fmt, cargo clippy, cargo test on macos/ubuntu/windows) should pass on this push. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * fix(daemon): make subscribe-loop silent failures loud (card 807193ab) * refactor(daemon): structured tracing::warn fields, not eprintln Replace the previous eprintln!-based silent-fail surfacing with structured tracing::warn! calls. Each warning carries the channel UUID, the error chain, and (for reattach paths) the current backoff_ms as KV fields — operators can filter by field, parse with jq, alert on specific channel/error pairs. Matches the airc-relay convention (server.rs / connection.rs use tracing::warn! the same way) and lets airc-lib's diagnostics land in whatever subscriber the embedder installs. Adds tracing = "0.1" to airc-lib's deps; sibling crates (airc-relay, airc-transport via their own deps) already pull the same major. Card: 807193ab Co-Authored-By: Claude Opus 4.7 <[email protected]> * diagnose(bus): per-publish + per-subscribe tracing::info — finds fan-out misses (card 800ce5bd) Live-empirical 2026-06-01: with the instrumentation enabled (RUST_LOG=airc_bus=info), one probe pinpointed the entire chat-carry stall in one log file: airc-bus subscribe_with_lag: registered channel=5d33e2a7-67b4-521b-9911-f46724af297f shard_idx=15 subscribers_after=1 ... airc-bus publish: fan-out summary channel=11c1a7ac-cb85-5ca0-a5b4-2847280ea3fa subscribers_before=0 matched=0 sent_ok=0 ... Two channels, zero overlap. The subscribe registered on a different channel from the publish; fan-out had nobody to deliver to. Root cause was in the consumer (continuum demo passing a uuid-shaped string to Airc::join, which derives a NEW channel name from the uuid), but the substrate's opacity hid it. After the consumer fix: airc-bus subscribe_with_lag: registered channel=11c1a7ac-cb85-5ca0-a5b4-2847280ea3fa shard_idx=10 subscribers_after=1 ... airc-bus publish: fan-out summary channel=11c1a7ac-cb85-5ca0-a5b4-2847280ea3fa subscribers_before=1 matched=1 sent_ok=1 ... Round-trip works. What lands: - tracing-subscriber installed in run_daemon (commands.rs:713). Every existing tracing::warn! / tracing::info! across the workspace (airc-bus, airc-lib, airc-relay) was a no-op before — no subscriber registered means events go nowhere. Default filter is 'warn' so steady-state stays quiet; RUST_LOG=airc_bus=info turns on the fan-out + subscribe diagnostics. - airc-bus::router::publish: per-publish summary (channel/epoch/counter/kind/delivery/subscribers_before/ matched/sent_ok/sent_lagged/sent_closed) so an operator can tell at a glance whether a publish reached the fan-out loop and what each subscriber's outcome was. - airc-bus::router::subscribe_with_lag: per-registration log (channel/shard_idx/subscribers_after/buffer_capacity/filter) so subscribes can be correlated with subsequent publishes — a subscribe that doesn't show up in a later publish's subscribers_before is the smoking gun for wrong-shard / wrong-channel / wrong-state. Card: 800ce5bd Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
…#1102) * feat(airc-lib): `Airc::attach_as(home, agent_name, socket)` — citizen-host constructor Multi-citizen hosts (Continuum personas, future external-agent hosts) need to spawn each hosted citizen with BOTH: 1. Its own identity (so `airc peers` from another scope sees each citizen as a separate enrolled participant), and 2. The daemon's live publish/subscribe (so the citizen can `say()` / `subscribe()` over the router, not just inspect local state). Today the constructor matrix only offers ONE of these per call: - `Airc::open_as(home, agent_name)` — identity ✓, daemon ✗ - `Airc::attach(home, socket)` — daemon ✓, identity ✗ So a host hosting N citizens has to reach for the (intentionally private) `with_daemon_client` builder via some awkward dance — or fork the bootstrap inline. Neither is ergonomic; both leak abstraction the public API meant to seal. This PR adds the natural diagonal of the matrix: pub async fn attach_as(home, agent_name, socket) -> Result<Self> Equivalent to `open_as(home, agent_name).await?.with_daemon_client (DaemonClient::new(socket))` but spelled as one method so consumers don't reach for the private builder. ### Concrete consumer Continuum-core's upcoming `PersonaAircRuntime` (continuum PR #1, see continuum task #86) spawns one `Airc` instance per hosted persona — each persona at its own `~/.continuum/personas/<name>/airc/` home, with its own Ed25519 identity, addressed by `agent_name = <persona>` — and needs the daemon-connected variant so the persona can participate in live rooms. The mental model: continuum is to airc what Codex is to airc — a host that runs N citizens, each first-class on the substrate. That host needs one constructor that gives it (identity × daemon) cleanly. `attach_as` IS that. ### Drift guard The implementation is a 5-line delegation to the existing `open_as` + `with_daemon_client` private helper, so this constructor cannot drift from the pair it composes. Any future change to either half automatically applies here. ### Test plan - [x] `cargo test -p airc-lib` — 1 passed, 0 failed (existing doctests; new constructor uses the same delegation paths that `attach` and `open_as` already cover) - [x] `cargo clippy -p airc-lib --no-deps -- -D warnings` clean - [x] `cargo fmt --check` clean - [ ] Adversarial reviewer agent verdict per AGENTS.md §0 + airc#1094 - [ ] Continuum PR #1 (task #86) consumes this constructor in `PersonaAircRuntime::bootstrap` — substantive integration test ### References - Continuum memory `personas-are-citizens-airc-is-identity-provider` - Continuum memory `airc-headers-are-the-routing-layer` - Continuum workflow w801jcu9r design synthesis — identified this missing constructor in the airc-lib API audit's `gaps` field - Joel, 2026-05-31: "We can enhance facilities we edit airc. They use airc as their identity provider and their own connection to the grid." This PR is the airc-side facility enhancement for the persona-as-citizen architecture. Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(airc-ipc): `impl From<>` blocks bridging SDK transcript types to IPC wire vocabulary External consumers building `PublishRequest`/`InboxRequest` from SDK- shaped state (continuum-core, OpenClaw, Hermes, future grid workers, this repo's own CLI) need to translate the chat-flavored types (`FrameKind`, `MentionTarget`, `TranscriptCursor`) into the v5 IPC wire vocabulary (`IpcKind`, `IpcTarget`, `IpcCursor`). Before this PR these conversions lived as private free functions (`framekind_to_ipc`, `mention_to_ipc_target`, `pack_seq`, `unpack_seq`) in `airc-lib/src/daemon.rs`. Any external consumer had to either: (a) Pull all of `airc-lib` for one private function — wrong surface for drive-by use, and the helpers are `fn` not `pub fn`. (b) Re-implement the same bit-shifting + variant matching in their own code — drift class. Continuum did this transitionally during the v5 migration before promoting them here. This PR promotes them to **`impl From<>` blocks in airc-ipc**, the smallest crate that depends on both `airc-core` (where the SDK types live) and `airc-protocol` (where `FrameKind` lives). Co- locating the conversions with the IPC vocabulary they produce gives every consumer `pub_req.kind = frame_kind.into()` instead of reaching for a free function. ### What ships - `crates/airc-ipc/src/sdk_conversions.rs` (NEW, ~170 lines including 6 tests): - `impl From<FrameKind> for IpcKind` — total, lossless - `impl From<MentionTarget> for IpcTarget` — total, lossless (room mentions round-trip via the `room:<uuid>` endpoint convention) - `impl From<TranscriptCursor> for IpcCursor` — total, lossless - `impl From<IpcCursor> for TranscriptCursor` — total, lossless, round-trip safe - `pub const COUNTER_BITS: u32 = 40` + `COUNTER_MASK` — published so any consumer needing to reproduce the lamport-packing layout (without going through the conversion) pins against the same constant. If anyone shifts the layout, every dependent recompiles + the round-trip tests fail loud. - `crates/airc-ipc/src/lib.rs` — re-export `COUNTER_BITS`/`COUNTER_MASK`; declare the new module. - `crates/airc-lib/src/daemon.rs` — delete the private duplicates (`framekind_to_ipc`, `mention_to_ipc_target`); switch call sites to `.into()`; import `COUNTER_BITS`/`COUNTER_MASK` from `airc-ipc` so the local `pack_seq`/`unpack_seq` helpers stay byte-compatible via shared constant. ### Doctrinal alignment Joel, 2026-05-31: > "I always simultaneously develop the sdk and consumer of it. It > helps you build the best patterns." This PR is the SDK half of the v5 owner-core consumer migration landing in continuum's sibling PR. The conversion shape was chosen to fit continuum's call sites (idiomatic `.into()` in `PublishRequest`/`InboxRequest` construction) — exactly the co-evolution pattern. Doing them simultaneously also caught the "airc-lib internals are the wrong surface" anti-pattern that would have otherwise persisted as drift. Pattern memory for future PRs: when continuum (or any other airc consumer) needs an airc-side helper that's currently private, upstream it as the natural extension of the existing public vocabulary — not as a "consumer-shaped" SDK method nor a duplicated helper in the consumer. ### Test plan - [x] `cargo test -p airc-ipc` — 33/33 pass (6 new tests in `sdk_conversions::tests`) - [x] `cargo test -p airc-lib` — 1 passed, 0 failed, 4 ignored (doc-test compile check); no regressions from removing the internal `framekind_to_ipc`/`mention_to_ipc_target` helpers - [x] `cargo build --release --bin airc` — clean - [ ] Adversarial reviewer agent verdict (per AGENTS.md §0 doctrine) ### References - Continuum task #82 — headless break #3 (Response::Event schema mismatch); this airc PR is the SDK half, continuum sibling PR is the consumer half. - AGENTS.md §0 + airc#1094 — agent sign-off doctrine. - airc#1095 (still open pending Windows CI) — `airc ipc-endpoint` command. Same iteration loop pattern. - `crates/airc-lib/src/daemon.rs` — historical home of these helpers, now thinned to call the From impls. Co-Authored-By: Claude Opus 4.7 <[email protected]> * docs(README): cross-surface identity doctrine — bridges are translators, not identity-holders When a bridge connects an external surface (Slack, Discord, Telegram, Teams, Zoom, X, etc.) the citizen's stable identity stays in airc. The bridge holds whatever platform credentials it needs to post on the citizen's behalf, but it never owns the persona. Unplug a bridge and the citizen persists; plug in a different platform's bridge and the same citizen appears there with the same keypair, name, and reputation. This formalizes what "same personas, everywhere" means at the substrate level — pairing with the continuum-side README change on feat/persona-helper-ai-as-airc-citizen. Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(work): work_board(usize::MAX) trips 16 MiB IPC cap (card acd72c81) (#1100) * fix(work): work_board(usize::MAX) → work_board_complete(PAGE_SIZE) at all 9 callsites (card acd72c81) `airc work state X closed` and 8 other CLI paths called `airc.work_board(usize::MAX)` to look up a single card or compute a snapshot. With `usize::MAX`, the daemon-attached path issues ONE Inbox RPC asking for every event in the room (the fetch multiplier saturates), and the daemon serializes all of them into a single CBOR frame. Once the room accumulates ~9000+ bus events (operationally hit on Joel's box 2026-06-01), the response trips `airc_ipc::codec::MAX_FRAME_BYTES`: daemon I/O: ipc frame too large: 16973574 bytes exceeds 16777216 Every state transition through these callsites then fails, the kanban freezes behind merged PRs, and other agents pile up on the same flake without recourse. ## Fix `work_board_complete(page_size)` already exists for the same intent (complete projection) but paginates the IPC transcript fetch (airc-lib/src/work.rs:776 → daemon_room_transcripts at airc-lib/src/daemon.rs:314). Each Inbox RPC asks for `page_size` events, the client loops until done, no individual frame exceeds the cap. Same projection completeness, low-latency per RPC, correct architecture. This commit: 1. Introduces `pub const WORK_BOARD_PROJECTION_PAGE_SIZE: usize = 1024` in airc-lib/src/work.rs as the canonical page size for complete-projection callers. 1024 events per page is comfortably under the 16 MiB cap (events are typed records in the kilobyte range, not blobs) and keeps the round-trip count low for 9000+ event rooms. 2. Updates `work_board(limit)`'s docstring to call out `usize::MAX` as forbidden and point at `work_board_complete`. 3. Swaps all 9 `work_board(usize::MAX)` callsites to `work_board_complete(WORK_BOARD_PROJECTION_PAGE_SIZE)`: - airc-cli/src/work_commands.rs (5 sites) - airc-cli/src/work_commands_git.rs (1 site) - airc-cli/src/work_commands_gh.rs (2 sites) - airc-lib/src/agent_heartbeat.rs (1 site) 4. Exports `WORK_BOARD_PROJECTION_PAGE_SIZE` from the airc-lib crate root so future callers reference one canonical constant instead of re-picking page sizes. ## Verification - `cargo check --workspace`: clean. - `cargo build --release -p airc-cli`: clean. - Reinstalled the binary to /Users/joel/.local/bin/airc, restarted daemon, ran `airc work state 0462c1a8... closed` — the 16 MiB IPC frame error is gone; the CLI now correctly reports the close-lifecycle gate's actual semantic refusal ("requires Merged predecessor"). Same writes that failed pre-fix now reach the daemon successfully. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: fix the immediate symptom AND the class. Every existing callsite gets the paginated path; future ones reference the canonical const. [[host-the-seemingly-impossible]]: the substrate now scales to 9000+ events without IPC-cap failures on routine writes. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> * feat(merger): reconcile already-merged PRs instead of skipping (card acd72c81 follow-up) When `gh pr view` reports `state="MERGED"` for a card's linked PR, the merger previously returned `GateResult::NotReady("PR state is MERGED (not OPEN)")` and skipped. That left the kanban projection permanently out of sync with GitHub: the PR was merged but the card stayed in Review. Stale cards accumulated; closure (Review → Closed) needs a Merged predecessor and never got one. This is the third symptom of the same root cause as the IPC cap fix: the merger had every piece of information it needed to reconcile, but the gate only had a "merge it" path and a "skip it" path — no "the merge already happened, just update our projection" path. ## Behavior change The merger now distinguishes: - `GateResult::Green` — open + green CI → call `gh pr merge` + emit `PullRequestMerged` (unchanged) - `GateResult::AlreadyMerged { merged_at_ms }` — state==MERGED → emit `PullRequestMerged` ONLY; no `gh pr merge` call (new) - `GateResult::NotReady(reason)` — state != OPEN and != MERGED, or open with failures (unchanged) The reconcile path uses `view.mergedAt` as the canonical `merged_at_ms` when gh supplies it, falling back to wall-clock-now. gh's `--json` query now includes `mergedAt` (one extra field; no new RPC). ## Symmetry with `airc work merge` The manual `airc work merge X` CLI command consumes the same gate. It now handles `AlreadyMerged` symmetrically: reconciles without a `gh pr merge` call, prints `reconciled: card=X pr=#N repo=R (PR was already merged on GitHub)`. ## End-to-end verification Built + reinstalled the binary, ran the merger against the Joel-box backlog of 4 already-merged cards (PR #1500, #1501, #1502, #1503): airc-merger: reconciled already-merged card=0462c1a8 pr=#1502 airc-merger: reconciled already-merged card=2c844fae pr=#1500 airc-merger: reconciled already-merged card=63ca1f00 pr=#1501 airc-merger: reconciled already-merged card=87fbb385 pr=#1503 Board after: all 4 transitioned Review → Merged. `airc work close` then succeeded on each (Merged → Closed). Kanban finally matches GitHub reality. ## Tests - `evaluate_gh_view_routes_merged_state_to_already_merged`: MERGED + mergedAt → AlreadyMerged with parsed canonical ms - `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent`: the fallback path produces a nonzero ms - `evaluate_gh_view_routes_closed_state_to_not_ready`: CLOSED (without merge) stays NotReady — we don't auto-reconcile abandoned PRs into Merged state - `parse_iso8601_to_ms_handles_standard_gh_format`: the helper handles the standard gh timestamp shape + invalid input - Updated `refuses_when_pr_is_already_merged` → `reconciles_when_pr_is_already_merged` to encode the new behavior and the rationale All 28 merger tests pass. ## Doctrine [[every-error-is-an-opportunity-to-battle-harden]]: the "skip-and-leak" anti-pattern is gone — every terminal PR state the merger sees now has a kanban-reconciliation action, not just the happy-path "merge". Card: acd72c81 (follow-up slice; same PR #1100) Co-Authored-By: Claude Opus 4.7 <[email protected]> * fix(merger): cargo fmt + clippy fixes for CI green (card acd72c81 follow-up) PR #1100's CI surfaced three issues missed in local cargo check: 1. cargo fmt: AlreadyMerged variant's anonymous field, the "MERGED + mergedAt" json test literal, and the work_board_complete call sites reflowed by rustfmt's wrap rules. 2. clippy --deny-warnings: the new test `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent` used `mergedAt` (camelCase from gh) in the function name — clippy non_snake_case lint. Renamed to `merged_at`. 3. workspace test: airc-lib's internal `ok_view` test helper constructs PrView { state, mergeable, status_check_rollup, .. } without the new `merged_at` field. Added `merged_at: None`. Local cargo fmt --check + clippy --deny-warnings + cargo test -p airc-cli -p airc-lib are now green; the same three CI jobs that failed on the prior push (cargo fmt, cargo clippy, cargo test on macos/ubuntu/windows) should pass on this push. Card: acd72c81 Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]> * fix(daemon): make subscribe-loop silent failures loud (card 807193ab) * refactor(daemon): structured tracing::warn fields, not eprintln Replace the previous eprintln!-based silent-fail surfacing with structured tracing::warn! calls. Each warning carries the channel UUID, the error chain, and (for reattach paths) the current backoff_ms as KV fields — operators can filter by field, parse with jq, alert on specific channel/error pairs. Matches the airc-relay convention (server.rs / connection.rs use tracing::warn! the same way) and lets airc-lib's diagnostics land in whatever subscriber the embedder installs. Adds tracing = "0.1" to airc-lib's deps; sibling crates (airc-relay, airc-transport via their own deps) already pull the same major. Card: 807193ab Co-Authored-By: Claude Opus 4.7 <[email protected]> --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
* feat(airc-lib): `Airc::attach_as(home, agent_name, socket)` — citizen-host constructor
Multi-citizen hosts (Continuum personas, future external-agent
hosts) need to spawn each hosted citizen with BOTH:
1. Its own identity (so `airc peers` from another scope sees
each citizen as a separate enrolled participant), and
2. The daemon's live publish/subscribe (so the citizen can
`say()` / `subscribe()` over the router, not just inspect
local state).
Today the constructor matrix only offers ONE of these per call:
- `Airc::open_as(home, agent_name)` — identity ✓, daemon ✗
- `Airc::attach(home, socket)` — daemon ✓, identity ✗
So a host hosting N citizens has to reach for the
(intentionally private) `with_daemon_client` builder via some
awkward dance — or fork the bootstrap inline. Neither is
ergonomic; both leak abstraction the public API meant to seal.
This PR adds the natural diagonal of the matrix:
pub async fn attach_as(home, agent_name, socket) -> Result<Self>
Equivalent to `open_as(home, agent_name).await?.with_daemon_client
(DaemonClient::new(socket))` but spelled as one method so
consumers don't reach for the private builder.
### Concrete consumer
Continuum-core's upcoming `PersonaAircRuntime` (continuum PR
#1, see continuum task #86) spawns one `Airc` instance per
hosted persona — each persona at its own
`~/.continuum/personas/<name>/airc/` home, with its own
Ed25519 identity, addressed by `agent_name = <persona>` — and
needs the daemon-connected variant so the persona can
participate in live rooms.
The mental model: continuum is to airc what Codex is to airc —
a host that runs N citizens, each first-class on the substrate.
That host needs one constructor that gives it (identity ×
daemon) cleanly. `attach_as` IS that.
### Drift guard
The implementation is a 5-line delegation to the existing
`open_as` + `with_daemon_client` private helper, so this
constructor cannot drift from the pair it composes. Any future
change to either half automatically applies here.
### Test plan
- [x] `cargo test -p airc-lib` — 1 passed, 0 failed (existing
doctests; new constructor uses the same delegation paths
that `attach` and `open_as` already cover)
- [x] `cargo clippy -p airc-lib --no-deps -- -D warnings` clean
- [x] `cargo fmt --check` clean
- [ ] Adversarial reviewer agent verdict per AGENTS.md §0 + airc#1094
- [ ] Continuum PR #1 (task #86) consumes this constructor in
`PersonaAircRuntime::bootstrap` — substantive integration test
### References
- Continuum memory `personas-are-citizens-airc-is-identity-provider`
- Continuum memory `airc-headers-are-the-routing-layer`
- Continuum workflow w801jcu9r design synthesis — identified
this missing constructor in the airc-lib API audit's `gaps`
field
- Joel, 2026-05-31: "We can enhance facilities we edit airc.
They use airc as their identity provider and their own
connection to the grid." This PR is the airc-side facility
enhancement for the persona-as-citizen architecture.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* feat(airc-ipc): `impl From<>` blocks bridging SDK transcript types to IPC wire vocabulary
External consumers building `PublishRequest`/`InboxRequest` from SDK-
shaped state (continuum-core, OpenClaw, Hermes, future grid workers,
this repo's own CLI) need to translate the chat-flavored types
(`FrameKind`, `MentionTarget`, `TranscriptCursor`) into the v5 IPC
wire vocabulary (`IpcKind`, `IpcTarget`, `IpcCursor`).
Before this PR these conversions lived as private free functions
(`framekind_to_ipc`, `mention_to_ipc_target`, `pack_seq`,
`unpack_seq`) in `airc-lib/src/daemon.rs`. Any external consumer
had to either:
(a) Pull all of `airc-lib` for one private function — wrong
surface for drive-by use, and the helpers are `fn` not `pub fn`.
(b) Re-implement the same bit-shifting + variant matching in their
own code — drift class. Continuum did this transitionally
during the v5 migration before promoting them here.
This PR promotes them to **`impl From<>` blocks in airc-ipc**, the
smallest crate that depends on both `airc-core` (where the SDK
types live) and `airc-protocol` (where `FrameKind` lives). Co-
locating the conversions with the IPC vocabulary they produce gives
every consumer `pub_req.kind = frame_kind.into()` instead of
reaching for a free function.
### What ships
- `crates/airc-ipc/src/sdk_conversions.rs` (NEW, ~170 lines including
6 tests):
- `impl From<FrameKind> for IpcKind` — total, lossless
- `impl From<MentionTarget> for IpcTarget` — total, lossless
(room mentions round-trip via the `room:<uuid>` endpoint convention)
- `impl From<TranscriptCursor> for IpcCursor` — total, lossless
- `impl From<IpcCursor> for TranscriptCursor` — total, lossless,
round-trip safe
- `pub const COUNTER_BITS: u32 = 40` + `COUNTER_MASK` — published
so any consumer needing to reproduce the lamport-packing layout
(without going through the conversion) pins against the same
constant. If anyone shifts the layout, every dependent recompiles
+ the round-trip tests fail loud.
- `crates/airc-ipc/src/lib.rs` — re-export `COUNTER_BITS`/`COUNTER_MASK`;
declare the new module.
- `crates/airc-lib/src/daemon.rs` — delete the private duplicates
(`framekind_to_ipc`, `mention_to_ipc_target`); switch call sites
to `.into()`; import `COUNTER_BITS`/`COUNTER_MASK` from `airc-ipc`
so the local `pack_seq`/`unpack_seq` helpers stay byte-compatible
via shared constant.
### Doctrinal alignment
Joel, 2026-05-31:
> "I always simultaneously develop the sdk and consumer of it. It
> helps you build the best patterns."
This PR is the SDK half of the v5 owner-core consumer migration
landing in continuum's sibling PR. The conversion shape was chosen
to fit continuum's call sites (idiomatic `.into()` in
`PublishRequest`/`InboxRequest` construction) — exactly the
co-evolution pattern. Doing them simultaneously also caught the
"airc-lib internals are the wrong surface" anti-pattern that would
have otherwise persisted as drift.
Pattern memory for future PRs: when continuum (or any other airc
consumer) needs an airc-side helper that's currently private,
upstream it as the natural extension of the existing public
vocabulary — not as a "consumer-shaped" SDK method nor a duplicated
helper in the consumer.
### Test plan
- [x] `cargo test -p airc-ipc` — 33/33 pass (6 new tests in
`sdk_conversions::tests`)
- [x] `cargo test -p airc-lib` — 1 passed, 0 failed, 4 ignored
(doc-test compile check); no regressions from removing the
internal `framekind_to_ipc`/`mention_to_ipc_target` helpers
- [x] `cargo build --release --bin airc` — clean
- [ ] Adversarial reviewer agent verdict (per AGENTS.md §0 doctrine)
### References
- Continuum task #82 — headless break #3 (Response::Event schema
mismatch); this airc PR is the SDK half, continuum sibling PR is
the consumer half.
- AGENTS.md §0 + airc#1094 — agent sign-off doctrine.
- airc#1095 (still open pending Windows CI) — `airc ipc-endpoint`
command. Same iteration loop pattern.
- `crates/airc-lib/src/daemon.rs` — historical home of these helpers,
now thinned to call the From impls.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* docs(README): cross-surface identity doctrine — bridges are translators, not identity-holders
When a bridge connects an external surface (Slack, Discord, Telegram,
Teams, Zoom, X, etc.) the citizen's stable identity stays in airc.
The bridge holds whatever platform credentials it needs to post on
the citizen's behalf, but it never owns the persona. Unplug a bridge
and the citizen persists; plug in a different platform's bridge and
the same citizen appears there with the same keypair, name, and
reputation.
This formalizes what "same personas, everywhere" means at the
substrate level — pairing with the continuum-side README change
on feat/persona-helper-ai-as-airc-citizen.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* fix(work): work_board(usize::MAX) trips 16 MiB IPC cap (card acd72c81) (#1100)
* fix(work): work_board(usize::MAX) → work_board_complete(PAGE_SIZE) at all 9 callsites (card acd72c81)
`airc work state X closed` and 8 other CLI paths called
`airc.work_board(usize::MAX)` to look up a single card or compute
a snapshot. With `usize::MAX`, the daemon-attached path issues
ONE Inbox RPC asking for every event in the room (the fetch
multiplier saturates), and the daemon serializes all of them
into a single CBOR frame. Once the room accumulates ~9000+ bus
events (operationally hit on Joel's box 2026-06-01), the response
trips `airc_ipc::codec::MAX_FRAME_BYTES`:
daemon I/O: ipc frame too large: 16973574 bytes exceeds 16777216
Every state transition through these callsites then fails, the
kanban freezes behind merged PRs, and other agents pile up on
the same flake without recourse.
## Fix
`work_board_complete(page_size)` already exists for the same
intent (complete projection) but paginates the IPC transcript
fetch (airc-lib/src/work.rs:776 → daemon_room_transcripts at
airc-lib/src/daemon.rs:314). Each Inbox RPC asks for `page_size`
events, the client loops until done, no individual frame exceeds
the cap. Same projection completeness, low-latency per RPC,
correct architecture.
This commit:
1. Introduces `pub const WORK_BOARD_PROJECTION_PAGE_SIZE: usize = 1024`
in airc-lib/src/work.rs as the canonical page size for
complete-projection callers. 1024 events per page is
comfortably under the 16 MiB cap (events are typed records
in the kilobyte range, not blobs) and keeps the round-trip
count low for 9000+ event rooms.
2. Updates `work_board(limit)`'s docstring to call out
`usize::MAX` as forbidden and point at
`work_board_complete`.
3. Swaps all 9 `work_board(usize::MAX)` callsites to
`work_board_complete(WORK_BOARD_PROJECTION_PAGE_SIZE)`:
- airc-cli/src/work_commands.rs (5 sites)
- airc-cli/src/work_commands_git.rs (1 site)
- airc-cli/src/work_commands_gh.rs (2 sites)
- airc-lib/src/agent_heartbeat.rs (1 site)
4. Exports `WORK_BOARD_PROJECTION_PAGE_SIZE` from the airc-lib
crate root so future callers reference one canonical
constant instead of re-picking page sizes.
## Verification
- `cargo check --workspace`: clean.
- `cargo build --release -p airc-cli`: clean.
- Reinstalled the binary to /Users/joel/.local/bin/airc,
restarted daemon, ran `airc work state 0462c1a8... closed` —
the 16 MiB IPC frame error is gone; the CLI now correctly
reports the close-lifecycle gate's actual semantic
refusal ("requires Merged predecessor"). Same writes that
failed pre-fix now reach the daemon successfully.
## Doctrine
[[every-error-is-an-opportunity-to-battle-harden]]: fix the
immediate symptom AND the class. Every existing callsite gets
the paginated path; future ones reference the canonical const.
[[host-the-seemingly-impossible]]: the substrate now scales to
9000+ events without IPC-cap failures on routine writes.
Card: acd72c81
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* feat(merger): reconcile already-merged PRs instead of skipping (card acd72c81 follow-up)
When `gh pr view` reports `state="MERGED"` for a card's linked PR,
the merger previously returned `GateResult::NotReady("PR state is
MERGED (not OPEN)")` and skipped. That left the kanban projection
permanently out of sync with GitHub: the PR was merged but the
card stayed in Review. Stale cards accumulated; closure
(Review → Closed) needs a Merged predecessor and never got one.
This is the third symptom of the same root cause as the IPC
cap fix: the merger had every piece of information it needed to
reconcile, but the gate only had a "merge it" path and a "skip
it" path — no "the merge already happened, just update our
projection" path.
## Behavior change
The merger now distinguishes:
- `GateResult::Green` — open + green CI → call `gh pr merge` +
emit `PullRequestMerged` (unchanged)
- `GateResult::AlreadyMerged { merged_at_ms }` — state==MERGED
→ emit `PullRequestMerged` ONLY; no `gh pr merge` call
(new)
- `GateResult::NotReady(reason)` — state != OPEN and !=
MERGED, or open with failures (unchanged)
The reconcile path uses `view.mergedAt` as the canonical
`merged_at_ms` when gh supplies it, falling back to wall-clock-now.
gh's `--json` query now includes `mergedAt` (one extra field; no
new RPC).
## Symmetry with `airc work merge`
The manual `airc work merge X` CLI command consumes the same
gate. It now handles `AlreadyMerged` symmetrically: reconciles
without a `gh pr merge` call, prints
`reconciled: card=X pr=#N repo=R (PR was already merged on GitHub)`.
## End-to-end verification
Built + reinstalled the binary, ran the merger against the
Joel-box backlog of 4 already-merged cards (PR #1500, #1501,
#1502, #1503):
airc-merger: reconciled already-merged card=0462c1a8 pr=#1502
airc-merger: reconciled already-merged card=2c844fae pr=#1500
airc-merger: reconciled already-merged card=63ca1f00 pr=#1501
airc-merger: reconciled already-merged card=87fbb385 pr=#1503
Board after: all 4 transitioned Review → Merged. `airc work
close` then succeeded on each (Merged → Closed). Kanban finally
matches GitHub reality.
## Tests
- `evaluate_gh_view_routes_merged_state_to_already_merged`: MERGED
+ mergedAt → AlreadyMerged with parsed canonical ms
- `evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent`:
the fallback path produces a nonzero ms
- `evaluate_gh_view_routes_closed_state_to_not_ready`: CLOSED
(without merge) stays NotReady — we don't auto-reconcile abandoned
PRs into Merged state
- `parse_iso8601_to_ms_handles_standard_gh_format`: the helper
handles the standard gh timestamp shape + invalid input
- Updated `refuses_when_pr_is_already_merged` →
`reconciles_when_pr_is_already_merged` to encode the new
behavior and the rationale
All 28 merger tests pass.
## Doctrine
[[every-error-is-an-opportunity-to-battle-harden]]: the
"skip-and-leak" anti-pattern is gone — every terminal PR state
the merger sees now has a kanban-reconciliation action, not just
the happy-path "merge".
Card: acd72c81 (follow-up slice; same PR #1100)
Co-Authored-By: Claude Opus 4.7 <[email protected]>
* fix(merger): cargo fmt + clippy fixes for CI green (card acd72c81 follow-up)
PR #1100's CI surfaced three issues missed in local cargo check:
1. cargo fmt: AlreadyMerged variant's anonymous field, the
"MERGED + mergedAt" json test literal, and the work_board_complete
call sites reflowed by rustfmt's wrap rules.
2. clippy --deny-warnings: the new test
`evaluate_gh_view_falls_back_to_wallclock_when_mergedAt_absent`
used `mergedAt` (camelCase from gh) in the function name — clippy
non_snake_case lint. Renamed to `merged_at`.
3. workspace test: airc-lib's internal `ok_view` test helper
constructs PrView { state, mergeable, status_check_rollup, .. }
without the new `merged_at` field. Added `merged_at: None`.
Local cargo fmt --check + clippy --deny-warnings + cargo test
-p airc-cli -p airc-lib are now green; the same three CI jobs
that failed on the prior push (cargo fmt, cargo clippy, cargo
test on macos/ubuntu/windows) should pass on this push.
Card: acd72c81
Co-Authored-By: Claude Opus 4.7 <[email protected]>
---------
Co-authored-by: Claude Opus 4.7 <[email protected]>
* fix(lib): Airc::join refuses uuid-shaped strings (card c409eaf5)
`Airc::join(name)` ran `ChannelName::new(name)` which hashes the
name into the channel UUID. Passing a uuid-shaped string as the
"name" silently re-hashed it into a DIFFERENT channel UUID — the
subscription registered on a channel nobody else was publishing
to, fan-out missed every publish, the substrate looked broken.
Empirically captured 2026-06-01 (card 800ce5bd diagnostics on
the live daemon): the continuum airc_chat_demo passed a uuid
string '11c1a7ac-...' to .join(), Paige landed on derived
channel '5d33e2a7-...' (shard 15), Joel's `airc msg` published
to the real '11c1a7ac-...' (shard 10), and the fan-out summary
showed subscribers_before=0. Hours of substrate diagnostic work
to surface a one-line consumer bug.
This commit makes the trap loud at the API boundary. `Airc::join`
now refuses uuid-shaped names with a typed error
`AircError::JoinUuidString { string }` whose Display names the
offending string, explains the hash-derivation, and points at the
two correct remedies:
- Pass the channel NAME (like "continuum" or "general").
- If you have a channel UUID and want to attach to the existing
channel, look it up via the subscription set and pass its
actual name.
Tests:
- `join_uuid_string_error_names_the_input` — the Display
surfaces the offending string + the doctrinal phrases
("looks like a UUID", "channel NAME"). If a future refactor
drops the diagnostic detail, this test catches it.
- `uuid_detection_canonical_shapes_all_trip` — pins that every
shape `uuid::Uuid::parse_str` accepts (hyphenated, bare hex,
braced, whitespace-padded) trips the guard. The guard
delegates to the standard parser; if any of these stops
tripping it, the trap re-opens for whoever's holding that
format.
- `uuid_detection_rejects_real_channel_names` — false-positive
guard. Real channel names ("continuum", "general", "ai-dev",
"room-1") must pass through unchanged; the predicate is
uuid-specific, not "anything hex-looking."
Doctrine: every load-bearing API gets a typed-error path for
its silent-failure modes. The next consumer who reaches for
`.join()` with a uuid in hand gets a refusal that names the
remedy, not a silent wrong-channel subscription.
Card: c409eaf5
Co-Authored-By: Claude Opus 4.7 <[email protected]>
---------
Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
Closes #85 — the BigMama 5090 case where Git Bash on Windows had gh installed via winget but not on PATH, silently disabling airc's gist substrate.
Mirrors the existing `resolve_tailscale_bin` pattern: check PATH first, fall back to known platform install locations. PATH-prepend at startup if found via fallback so every existing `gh` callsite keeps working transparently — no need to wrap each invocation.
Test plan
C:\\Program Files\\GitHub CLI\\gh.exewithout manual ~/.bashrc editWhy bash + ps1 together
Per joel: don't neglect Windows. Keeps the lockstep discipline from #84.
Related issues
airc doctor --connectpre-flight) — would surface this kind of issue at install-time too; bigger PR, future🤖 Generated with Claude Code