Skip to content

canary→main bundle 3: Codex parity (centralized monitor liveness + command-rule pre-approval) - #376

Merged
joelteply merged 2 commits into
mainfrom
canary
Apr 30, 2026
Merged

joelteply merged 2 commits into
mainfrom
canary

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Third canary→main bundle of the day. Tight scope: the two Codex-parity follow-ups from tonight's deep QA.

Bundled fixes (2 PRs)

Net effect

Combined with bundle 2 (#349, #350, #356, #361 etc):

  • ✅ Fresh-Mac Carl install path solid (Claude Code AND Codex)
  • ✅ Codex auto-config: skill symlinks + permission profile + GH_TOKEN injection + command-rules pre-approval — friction-free first-encounter
  • ✅ Cross-vendor mesh proven (Codex + Claude Code peer-to-peer over gist substrate, real bidirectional comms tonight)

Carl story end-to-end

Curl-install on a fresh Mac (LibreSSL only, no brew openssl, no Codex pre-config) → install.sh handles every prereq, gh auth, skills, Codex config — user runs codex, types /join, lands in the mesh. No friction prompts, no manual flags.

Known followups (queued, all tracked)

Required gates

4 platforms green on each constituent PR. Integration-suite expected red per the documented #351 known-issue (cluster A+B fixed real regressions; remaining failures are scenario-specific test rig issues — separate from the real-user paths which are validated via clean-install + live mesh exercise).

🤖 Generated with Claude Code

joelteply and others added 2 commits April 29, 2026 23:02
…back (generalizes #371 to cmd_send + cmd_connect) (#374)

fix(monitor-liveness): centralize via _monitor_alive_with_bearer_fallback (cmd_send + cmd_status + cmd_connect short-circuit) — generalizes #371

#371 fixed cmd_status to fall back to bearer-state freshness when
kill -0 was sandbox-blind (Codex). But cmd_send and cmd_connect's
#369 short-circuit had the SAME blindness in the SAME way, and #371
only patched one site. Joel hit this immediately when Codex
(continuum-2c54, hosting #cambriantech with bearer_state.general
fresh 60s ago) tried `airc msg "hello mesh"` — got "Send NOT
delivered — this scope's monitor isn't running" while the bearer
was provably alive. Then `airc connect` didn't trust-existing-monitor
either (#369 short-circuit also kill -0 blind), tried gh auth login,
hit the same Forbidden wall.

Root cause for all three: kill -0 across process trees is broken
inside Codex's sandbox. Fix: extract a centralized helper at airc
top-level + use everywhere.

New helper: _monitor_alive_with_bearer_fallback(pidfile)
  Phase 1: kill -0 against PIDs in pidfile (canonical, fast)
  Phase 2: bearer-state freshness fallback when phase 1 returns no
           live PIDs but pidfile exists. If any bearer_state.<ch>.json
           in scope has last_recv_ts within 2x reminder interval
           (default 600s), bearer-recv child is provably alive.

Pure read — does NOT mutate the pidfile (the older
prune_pidfile_and_count would actively delete a "no live PIDs"
pidfile, silently corrupting state when phase 1 was wrong about
death). prune_pidfile_and_count remains for explicit cleanup paths
where pruning IS desired (teardown).

Three call sites updated to use the helper:

1. cmd_send.sh: monitor-liveness gate before "Send NOT delivered"
   refusal. Codex can now broadcast even though kill -0 is blind.

2. cmd_connect.sh #369 short-circuit: trust-existing-monitor early
   return now fires for Codex too (was kill -0 inline, missed
   sandbox-blind case).

3. cmd_status.sh: switched from inline #371 fallback to the shared
   helper. Same behavior, less duplicated code, single source of
   truth for liveness semantics.

cmd_status retains the diagnostic split between "running (PID X)"
(verified via kill -0) and "likely-alive (Ns via #channel; kill -0
blind ...)" (verified via bearer-state only) so the user can tell
which path confirmed liveness.

Tested locally: airc status from a no-pidfile scope still reports
"not running" (helper returns no on missing pidfile — correct).
Live-test path: Joel runs airc msg from Codex's continuum-2c54 scope
post-merge — expect successful broadcast instead of "monitor isn't
running" refusal.

Closes the operational half of #372 (Codex can now send + status
correctly). The agent-side event surfacing (auto-receive for Codex)
is still tracked there as the broader UX fix.

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…lock — final piece for friction-free Codex (#375)

feat(install): pre-approve airc command prefix in Codex via [rules] block (closes the per-command-approval gate finding)

Codex's per-command approval gate doesn't just control prompts — it
ALSO restricts network access for un-approved commands. A command not
in the user's "always run commands starting with X" allowlist runs in
a stricter sandbox where its gh API calls are blocked silently.

Joel's Codex first-encounter QA caught this live: `airc join` had
been pre-approved earlier so its gh calls reached the network, but
`airc msg` hadn't, so its gh calls hit the network sandbox and
failed. Codex prompted the user to "always run commands that start
with airc msg" and once approved, it worked instantly. Same for
every other airc verb (status, peers, etc) until each was
approved.

That's friction. Codex docs (config-reference) document a [rules]
block with prefix_rules for declaring approved command prefixes
statically. install.sh now writes a marker-bracketed block to
~/.codex/config.toml that pre-approves ALL `airc *` verbs at once:

  [rules]
  prefix_rules = [
    { pattern = [{ token = "airc" }], decision = "allow" }
  ]

Net: user installs Codex + runs install.sh + restarts Codex → every
airc verb works without per-command approval prompts, even on first
encounter.

Idempotent: grep guard on AIRC-COMMAND-RULES-START marker, no
duplicate writes.

uninstall.sh: matching cleanup strips the marker-bracketed block
when airc is removed (paired with the GH_TOKEN block strip already
in place).

Honors AIRC_SKIP_CODEX_RULES=1 if user wants to manage approvals
interactively (matches AIRC_SKIP_CODEX_TOKEN / _CONFIG patterns).

README: full section explaining what the gate is, why it bites,
how the [rules] block solves it, and how the three Codex-side
auto-config layers (network permission profile + GH_TOKEN
injection + command-rule pre-approval) compose into a friction-free
Codex airc surface.

Tested on this Mac:
  - install.sh wrote the block once + Codex starts clean
  - re-run no-op (idempotent)
  - bash -n syntax check passes for both install.sh + uninstall.sh

Joel's framing: "if we get this, we can now have codex and decent
claude code airc, fairly reliable into main." This PR is that "this."

Co-authored-by: joel <[email protected]>
Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@joelteply
joelteply merged commit 3263708 into main Apr 30, 2026
11 of 12 checks passed
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