Skip to content

fix(airc_core): config set_host_block — close last env-var-pass site (continuum's #174 follow-up) - #176

Merged
joelteply merged 1 commit into
canaryfrom
fix/airc-core-config-set-subcommand
Apr 27, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/airc-core-config-set-subcommand

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

continuum-b69f's #174 retest caught the host_* config WRITE site (post-handshake "store host details" block) still using env-vars. Same MSYS path-translation silent-fail class as the rest of #174 — $host_airc_home got mangled on Git Bash.

Fix

New subcommand `airc_core.config set_host_block` with proper `--flags`. Bash callsite is one airc_core invocation; no env-var pass; no python heredoc with bash substitutions.

Test posture

95 assertions / 9 scenarios green. Unit test of set_host_block confirms paths/keys/identity round-trip uncorrupted.

This was the LAST env-var-pass site in airc bash. With this PR, every airc_core invocation is argparse `--flags` end-to-end.

…site converted to argparse (continuum's PR #174 follow-up)

continuum-b69f's #174 retest 2026-04-27 found that PR #174 missed the
host_* config WRITE site (the post-handshake "store host details"
block). It still used env vars, so MSYS path-translated $host_airc_home
on Git Bash before python read it from os.environ. Same silent-fail
class as the rest of #174.

## Fix (matches PR #174 pattern verbatim)

New subcommand: `airc_core.config set_host_block`.

```bash
"$AIRC_PYTHON" -m airc_core.config set_host_block \
    --config "$CONFIG" \
    --host-airc-home "$host_airc_home" \
    --host-name "$peer_name" \
    --host-port "${peer_port:-7547}" \
    --host-ssh-pub "$host_ssh_pub" \
    --host-identity-json "$host_identity_json"
```

Bash callsite is one airc_core invocation; no env-var pass; no python
heredoc with bash substitutions; no `2>/dev/null` swallowing errors.
The CLI errors are surfaced via stderr per the never-swallow-errors
rule.

## Why this matters per Joel's "always the right fix"

PR #174 was the right approach for the SEND/PARSE/ACCEPT sites. PR
#165 (env-var hardening) was a defensive partial fix at the WRITE
site. Today we close the loop — same architecture across all
config-mutating sites.

## Test posture

95 assertions / 9 scenarios green:
- tabs 19, identity 19, whois 5, part_persists 8, list 4,
  general_sidecar_default 12, kick 12, events 5, platform_adapters 11

Unit test:
- set_host_block writes valid JSON with all fields preserved
  uncorrupted (path / SSH pubkey / identity dict round-trip)
Copilot AI review requested due to automatic review settings April 27, 2026 23:24
@joelteply
joelteply merged commit 1c172f4 into canary Apr 27, 2026
2 checks passed
@joelteply
joelteply deleted the fix/airc-core-config-set-subcommand branch April 27, 2026 23:24

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

This PR completes the migration away from passing path-like values via environment variables by introducing a dedicated airc_core.config set_host_block subcommand and switching the post-handshake “store host details” write to use argparse --flags, addressing MSYS/Git Bash path translation issues.

Changes:

  • Add airc_core.config set_host_block CLI subcommand to update host_* fields in config.json.
  • Replace the bash inline python -c heredoc config-write block with a single python -m airc_core.config set_host_block --... invocation.

Reviewed changes

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

File Description
lib/airc_core/config.py Adds set_host_block subcommand for writing post-handshake host details via argparse flags.
airc Updates the post-handshake config write callsite to invoke set_host_block with --flags instead of an inline heredoc.

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

Comment thread airc
Comment on lines 2384 to 2386
# to env-var pass — python reads from os.environ; bash never
# touches the python source. Also emit stderr to surface failures
# for the future debugger (not /dev/null).
Comment thread airc
--host-port "${peer_port:-7547}" \
--host-ssh-pub "$host_ssh_pub" \
--host-identity-json "$host_identity_json" \
|| echo " ⚠ config write failed (host_airc_home/host_name/host_port/host_ssh_pub may be unset). airc may still work if subsequent retries refresh." >&2
Comment thread airc
Comment on lines +2387 to +2389
"$AIRC_PYTHON" -m airc_core.config set_host_block \
--config "$CONFIG" \
--host-airc-home "$host_airc_home" \
Comment thread lib/airc_core/config.py
Comment on lines +48 to +49
"""Atomically write the post-handshake host_* fields into config.

Comment thread lib/airc_core/config.py
Comment on lines +70 to +73
try:
c["host_identity"] = json.loads(args.host_identity_json or "{}")
except ValueError:
c["host_identity"] = {}
Comment thread lib/airc_core/config.py
Comment on lines +59 to +60
c = json.load(open(args.config))
except (OSError, ValueError) as e:
Comment thread lib/airc_core/config.py
Comment on lines +75 to +76
json.dump(c, open(args.config, "w"), indent=2)
return 0
joelteply added a commit that referenced this pull request Apr 27, 2026
…nd-to-end (#177)

fix(msys): export MSYS2_ARG_CONV_EXCL at airc startup — last layer of cross-machine fix (continuum's catch + verify)

continuum-b69f's diagnosis 2026-04-27: even with PR #174 + #176's
argparse `--flags`, MSYS Git Bash on Windows translates argv VALUES
that look like Unix-rooted paths when bash invokes a Windows-native
binary. So `--host-airc-home /Users/joelteply/.airc` arrived at
python.exe as `--host-airc-home C:/Program Files/Git/Users/joelteply/.airc`,
the joiner cached the corrupted path, the SSH command later sent
it to a real Unix host that had no such file. Silent broadcast
failure.

## Fix

```bash
export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}"
```

Set once at airc startup, exported, every airc_core invocation
inherits the same translation policy. Targeted prefix list covers
macOS / Linux / root home prefixes without breaking `/tmp/` or `/c/`
paths (which DO need translation for `--config "$CONFIG"` where
$CONFIG is on the local Windows filesystem). Honors a user override
via the `${...:-...}` default-fallback.

## End-to-end verification

continuum-b69f shipped a test broadcast from Windows after their
local patch:

> WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with
> targeted MSYS exclude. should land!

Verified live in MY host's messages.jsonl on Mac:

```
{"from":"continuum-msyspatch","to":"all","ts":"2026-04-27T23:30:13Z",
 "msg":"WORKING TEST: Windows-Mac airc msg via continuum-msyspatch
 with targeted MSYS exclude. should land!","sig":"..."}
```

**Cross-machine Mac↔Windows airc end-to-end working.** This was the
last bug in the chain that started at PR #153 (Microsoft Store
python3 stub).

## Test posture (Mac, where the env var is a no-op)

- tabs 19/19, identity 19/19, whois 5/5, part_persists 8/8,
  list 4/4, general_sidecar_default 12/12, kick 12/12, events 5/5,
  platform_adapters 11/11, whois_cross_scope 6/6

## Today's full chain of cross-machine fixes

#153 → #154 → #155 → #156 → #157 → #158 → #159 → #160 → #162 →
#164 → #165 → #166 → ... → #176 → this. 27+ PRs to ship a working
cross-machine airc on Windows. Every step revealed a new layer.
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