Skip to content

refactor: unify _daemon_os into detect_platform (#205, net -26) - #211

Merged
joelteply merged 1 commit into
canaryfrom
refactor/unify-detect_platform-205
Apr 28, 2026
Merged

joelteply merged 1 commit into
canaryfrom
refactor/unify-detect_platform-205

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Two near-identical OS-detection functions consolidated. detect_platform (lib/airc_bash/platform_adapters.sh) and _daemon_os (airc top-level) both did Darwin/Linux/MINGW switching with /proc/version WSL detection — unify on detect_platform's surface, with output names matching _daemon_os (darwin/linux/wsl/windows/unknown — closer to raw uname -s).

Diff: +10 / -36 = -26 lines. airc 5283 → 5265.

Continuum-b69f's #205 candidate #3 (OS-detection audit). Per his suggestion I leaned safe: pure cleanup, near-zero risk. Verified airc doctor + airc daemon status still work on Mac.

Two near-identical OS-detection functions: detect_platform in
lib/airc_bash/platform_adapters.sh + _daemon_os in airc top-level.
Both Darwin/Linux/MINGW switching with /proc/version WSL detection.

Unify on detect_platform's surface, with output names from _daemon_os
(darwin/linux/wsl/windows/unknown) since they match \`uname -s\` more
directly than detect_platform's prior \"macos\"/\"windows-bash\".

Changes:
- detect_platform: rename outputs (macos→darwin, windows-bash→windows),
  inline the WSL check (\`grep ... && echo wsl || echo linux\`).
- _daemon_os: deleted (16 lines).
- 4 daemon callers: \$(_daemon_os) → \$(detect_platform).
- cmd_doctor.sh _doctor_probe_sshd: case macos)→darwin), case
  windows-bash)→windows).

Diff: +10 / -36 = **-26 lines.** airc 5283 → 5265.

Verified: \`airc doctor\` still detects macOS Remote Login + Tailscale
on Mac; \`airc daemon status\` still works (uses the new unified function).
Copilot AI review requested due to automatic review settings April 28, 2026 14:58
@joelteply
joelteply merged commit 19ca947 into canary Apr 28, 2026
8 checks passed
@joelteply
joelteply deleted the refactor/unify-detect_platform-205 branch April 28, 2026 15:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Consolidates OS detection by removing the duplicated _daemon_os implementation in airc and standardizing on detect_platform from lib/airc_bash/platform_adapters.sh, while updating downstream callers to use the new platform tokens.

Changes:

  • Refactors detect_platform to emit darwin/linux/wsl/windows/unknown (matching the former _daemon_os vocabulary).
  • Updates doctor probes to switch on darwin and windows.
  • Removes _daemon_os from airc and replaces daemon callsites with detect_platform.

Reviewed changes

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

File Description
lib/airc_bash/platform_adapters.sh Changes detect_platform output tokens to match daemon expectations.
lib/airc_bash/cmd_doctor.sh Updates detect_platform case labels to the new tokens.
airc Deletes _daemon_os and switches daemon install/status logic to detect_platform.

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

Comment on lines +132 to +134
Darwin) echo darwin ;;
Linux) grep -qiE 'microsoft|wsl' /proc/version 2>/dev/null && echo wsl || echo linux ;;
MINGW*|MSYS*|CYGWIN*) echo windows ;;
Comment on lines 199 to 203
_doctor_probe_sshd() {
local plat; plat=$(detect_platform)
case "$plat" in
macos)
darwin)
# macOS Remote Login = launchd-managed sshd. Detect WITHOUT sudo:
joelteply added a commit that referenced this pull request Apr 28, 2026
feat(mesh): one gist per gh account — Phase 1 mesh-substrate switch

Architectural shift from per-room gists to per-account-singleton mesh.
Joel 2026-04-27: "B is the god damn correct shift. They all share the
same gist, stop being stupid. one goes down first one to resolve, posts
to gist. host goes down, new host, first one that posts, becomes it."

## What changes

- New `lib/airc_bash/mesh.sh` — primitives for the mesh-gist abstraction:
  _mesh_desc, _mesh_find (singleton lookup), _mesh_publish, _mesh_update,
  _mesh_age_secs, _mesh_take_over (race-aware oldest-by-created election)
- airc top-level: source mesh.sh; _self_heal_stale_host now takes only
  stale_id (no room_name discriminator — mesh is per-account, nothing
  to discriminate on)
- cmd_connect.sh:
  - Discovery: singleton lookup via _mesh_find (was: per-room awk filter)
  - Host publish: description "airc mesh", payload kind "mesh",
    channels: [\$room_name] array (replaces .name + .topic)
  - Heartbeat payload: same shape change
  - Race-loser: _mesh_take_over (jitter, list, oldest-by-created wins)
  - Joiner: kind "mesh" handled alongside legacy "room" for back-compat
    with gists that haven't rolled over yet
- cmd_rooms.sh: list display now recognizes mesh (◆), room (#), invite
  (1:1) — three kinds during the transition

## What's deferred to Phase 2/3/4

- Joiners adding their own channels to the mesh gist (currently the
  host's published channels list is set at create time and only the
  host updates it)
- Channel-as-message-metadata routing (messages still go to one log;
  per-channel filtering is local-only at display time)
- .general sidecar deletion (still spawned per spawn_general_sidecar_if_wanted)
- Sweep of legacy `airc room: *` gists on rollover

## Verification

- bash -n clean on all four files
- airc help / version / dispatch reach correct paths
- test/integration.sh tabs:    1/3 (rename-marker timing flake; 0/3 on
                                pristine canary HEAD too — not introduced
                                by this PR, predates mesh switch)
- test/integration.sh status:  7/0 ✓
- test/integration.sh room:    14/0 ✓
- test/integration.sh general_sidecar_default: 12/0 ✓
- test/integration.sh platform_adapters: 9/2 (darwin/macos rename
                                from PR #211, unrelated)

## Test plan

- [ ] CI integration suite on push to canary
- [ ] e2e: continuum-b69f (Windows) + Mac Claude on same gh account
      both run `airc update && airc join` — confirm both converge on
      a single new "airc mesh" gist; first to publish wins; second
      becomes joiner
- [ ] e2e takeover: kill the host, confirm joiner detects stale and
      becomes new host (mesh takeover via _mesh_take_over)
- [ ] migration grace: existing `airc room: *` gists left untouched;
      new mesh gist created alongside; cmd_rooms shows both with
      separate markers (◆ vs #)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Apr 28, 2026
* feat(mesh): one gist per gh account — Phase 1 mesh-substrate switch

Architectural shift from per-room gists to per-account-singleton mesh.
Joel 2026-04-27: "B is the god damn correct shift. They all share the
same gist, stop being stupid. one goes down first one to resolve, posts
to gist. host goes down, new host, first one that posts, becomes it."

## What changes

- New `lib/airc_bash/mesh.sh` — primitives for the mesh-gist abstraction:
  _mesh_desc, _mesh_find (singleton lookup), _mesh_publish, _mesh_update,
  _mesh_age_secs, _mesh_take_over (race-aware oldest-by-created election)
- airc top-level: source mesh.sh; _self_heal_stale_host now takes only
  stale_id (no room_name discriminator — mesh is per-account, nothing
  to discriminate on)
- cmd_connect.sh:
  - Discovery: singleton lookup via _mesh_find (was: per-room awk filter)
  - Host publish: description "airc mesh", payload kind "mesh",
    channels: [\$room_name] array (replaces .name + .topic)
  - Heartbeat payload: same shape change
  - Race-loser: _mesh_take_over (jitter, list, oldest-by-created wins)
  - Joiner: kind "mesh" handled alongside legacy "room" for back-compat
    with gists that haven't rolled over yet
- cmd_rooms.sh: list display now recognizes mesh (◆), room (#), invite
  (1:1) — three kinds during the transition

## What's deferred to Phase 2/3/4

- Joiners adding their own channels to the mesh gist (currently the
  host's published channels list is set at create time and only the
  host updates it)
- Channel-as-message-metadata routing (messages still go to one log;
  per-channel filtering is local-only at display time)
- .general sidecar deletion (still spawned per spawn_general_sidecar_if_wanted)
- Sweep of legacy `airc room: *` gists on rollover

## Verification

- bash -n clean on all four files
- airc help / version / dispatch reach correct paths
- test/integration.sh tabs:    1/3 (rename-marker timing flake; 0/3 on
                                pristine canary HEAD too — not introduced
                                by this PR, predates mesh switch)
- test/integration.sh status:  7/0 ✓
- test/integration.sh room:    14/0 ✓
- test/integration.sh general_sidecar_default: 12/0 ✓
- test/integration.sh platform_adapters: 9/2 (darwin/macos rename
                                from PR #211, unrelated)

## Test plan

- [ ] CI integration suite on push to canary
- [ ] e2e: continuum-b69f (Windows) + Mac Claude on same gh account
      both run `airc update && airc join` — confirm both converge on
      a single new "airc mesh" gist; first to publish wins; second
      becomes joiner
- [ ] e2e takeover: kill the host, confirm joiner detects stale and
      becomes new host (mesh takeover via _mesh_take_over)
- [ ] migration grace: existing `airc room: *` gists left untouched;
      new mesh gist created alongside; cmd_rooms shows both with
      separate markers (◆ vs #)

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

* feat(channels): channel field on every message envelope — Phase 2A

Stamps the active channel on every outgoing message envelope so the
monitor formatter can route display by channel uniformly, regardless
of which scope the message was emitted from. This is the substrate
for Phase 2B (collapsing the multi-scope sidecar into a single scope
with subscribed_channels).

## Envelope shape

Old (room implied by scope-level room_name file):
  {"from":"X","to":"Y","ts":"...","msg":"..."}

New (channel stamped on the line itself):
  {"from":"X","to":"Y","ts":"...","channel":"general","msg":"..."}

## Sites stamped

- cmd_send.sh: peer/broadcast envelope + sig over the new payload shape
- cmd_send.sh: queue marker (tailnet offline)
- cmd_send.sh: queue marker (network error)
- cmd_send.sh: fail marker (auth)
- airc top-level: drain marker
- handshake.py: peer-join system event

Rename markers go through cmd_send --internal and inherit the field.

## Display

monitor_formatter.py now prefers `m.get("channel")` over the scope-
level room_name when prefixing each emitted line. The scope-level
room_name remains as a fallback for pre-Phase-2 envelopes that lack
the field, so older messages still prefix correctly during rollover.

## Verification

- bash -n + python ast.parse on all four changed files
- test/integration.sh tabs:  19/0 ✓
- test/integration.sh room:  14/0 ✓
- test/integration.sh queue: 7/0 ✓

## Stacked on Phase 1

Branched off feat/one-mesh-gist-per-account (PR #222). When that
merges to canary, Phase 2A rebases cleanly. Phase 2B (sidecar
deletion + subscribed_channels config) follows.

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.

2 participants