Skip to content

feat(ipc): typed AttachStart — the flood-by-default footgun dies at the type level (card c0cb6cdc) - #1114

Merged
joelteply merged 1 commit into
rust-rewritefrom
fix/attach-start-typed-c0cb6cdc
Jun 11, 2026
Merged

joelteply merged 1 commit into
rust-rewritefrom
fix/attach-start-typed-c0cb6cdc

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

bf0b5790 existed because AttachRequest's DEFAULT was the dangerous
behavior: '..Default::default()' silently meant full-transcript
replay, and three interacting fields (from, from_now,
coalesce_backlog) carried precedence rules documented in a server-side
comment. PR #1113 fixed the symptom at one call site; any of the 11
construction sites could re-create the flood by forgetting a flag.

The protocol now states intent in one type:

  • AttachStart { Live (#[default]), After(IpcCursor),
    FromTranscriptStart }. Live is the only start that can never flood
    a consumer; both replaying variants must be named at the call site.
  • AttachRequest fields go private. Construction only via
    AttachRequest::new(channel, start) / ::live(channel) plus with_*
    builders; '..Default::default()' literals are impossible outside
    airc-ipc.
  • Wire encoding unchanged (from + from_now encode the enum), so
    version-skewed daemon/client pairs interoperate; a legacy bare
    request still decodes as FromTranscriptStart. The
    from_now-overrides-from precedence now exists in exactly ONE place
    (AttachRequest::start) instead of a comment, pinned by unit tests.
  • Daemon stream_attach matches on the typed start via into_parts()
    (moves filter vectors, no clone); 'Live + coalesce' is structurally
    a no-op rather than a documented caveat.
  • airc-lib daemon_subscribe + monitor CLI + 9 daemon-test sites move
    to constructors.

Tests: 5 new unit tests pin wire round-trip per variant, legacy
bare-request decode, precedence, Live-by-default, and into_parts.
Full workspace suite green (81 test binaries); fmt + clippy clean.

Co-Authored-By: Claude Fable 5 [email protected]

@joelteply

Copy link
Copy Markdown
Contributor Author

Adversarial review — VERDICT: APPROVE (card c0cb6cdc, commit aca9eeb, delta vs fix/join-live-edge-bf0b5790)

Wire compat (the critical claim): verified empirically. Built a throwaway crate against the branch's airc-ipc and printed actual encodings:

  • AttachRequest::live(ch) → {"channel":...,"from_now":true,"headers":"any"} — byte-identical to the old struct-literal shape (serde attrs on all fields unchanged: same skip_serializing_if on from/from_now/coalesce_backlog, headers still always serialized).
  • FromTranscriptStart → {"channel":...,"headers":"any"} (legacy bare shape); After(c) → from key only.
  • New daemon + old client: legacy_bare_attach_decodes_as_transcript_start pins that a bare request decodes to FromTranscriptStart; from_now_takes_precedence_over_cursor_on_the_wire pins precedence from raw JSON keys (decode-side field names pinned; serde derive is symmetric).

Precedence: all 8 (from_now, from, coalesce) combos preserved. start() maps from_now→Live else Some(from)→After else FromTranscriptStart; server maps Live→head(ring∥sink), After→cursor, FromTranscriptStart→None — exactly the old branch arms. parts.coalesce_backlog && parts.start != Live ≡ old coalesce_backlog && !from_now since start==Live ⟺ from_now (Live wins even with a cursor present, both old and new).

Call sites: monitor attach.rs covers all 4 CLI combos with identical wire bytes (coalesce builder applied independent of start). airc-lib daemon.rs initial attach and reconnect (cursor→After, none→Live) byte-identical to base. 10 daemon-test sites migrated; 6 of them intentionally moved from implicit full-replay to live() — behaviorally equivalent because each uses a fresh RoomId and attaches+acks before a Barrier gates publishing (subscribe-before-ack). No remaining AttachRequest { literals outside request.rs; AttachStart/AttachParts exported.

Tests: cargo test -p airc-ipc -p airc-daemon -p airc-lib in a clean worktree — all green (194+41 unit + all integration suites, 0 failed). cargo clippy -p airc-ipc --tests — 0 warnings.

Minor notes (non-blocking): no test pins the exact serialized JSON for live() (round-trip only — a symmetric serde rename would slip past; verified manually this time). A pre-7d5b6a65 daemon ignores from_now and would full-replay a live() attach — pre-existing skew from the base card, not introduced here.

@joelteply
joelteply force-pushed the fix/attach-start-typed-c0cb6cdc branch from aca9eeb to 5a93b78 Compare June 10, 2026 18:14
joelteply added a commit that referenced this pull request Jun 11, 2026
GitHub-hosted windows-latest has been queue-starved for days, blocking
sentinel-approved merges (#1114) on a job that never starts. The 5090
grid node now runs a registered self-hosted runner (name=bigmama,
labels=self-hosted,windows,x64, user-mode run.cmd; service install is
queued for the next operator session).

Scope: ONLY the cargo-test matrix leg moves. The clean-install smoke
jobs in ci.yml stay on windows-latest on purpose — they perform real
machine-wide winget installs and are only meaningful on a virgin box,
which a persistent self-hosted runner is not.

Security posture for self-hosted on a public repo: the repository's
fork-PR approval policy has been set to all_external_contributors
(verified via the actions/permissions API), so workflow runs from fork
PRs require an explicit maintainer approval before any code reaches
the runner.

Co-Authored-By: Claude Fable 5 <[email protected]>
joelteply added a commit that referenced this pull request Jun 11, 2026
* ci(rust): route the Windows test leg to the self-hosted bigmama runner

GitHub-hosted windows-latest has been queue-starved for days, blocking
sentinel-approved merges (#1114) on a job that never starts. The 5090
grid node now runs a registered self-hosted runner (name=bigmama,
labels=self-hosted,windows,x64, user-mode run.cmd; service install is
queued for the next operator session).

Scope: ONLY the cargo-test matrix leg moves. The clean-install smoke
jobs in ci.yml stay on windows-latest on purpose — they perform real
machine-wide winget installs and are only meaningful on a virgin box,
which a persistent self-hosted runner is not.

Security posture for self-hosted on a public repo: the repository's
fork-PR approval policy has been set to all_external_contributors
(verified via the actions/permissions API), so workflow runs from fork
PRs require an explicit maintainer approval before any code reaches
the runner.

Co-Authored-By: Claude Fable 5 <[email protected]>

* ci(rust): name the matrix legs explicitly — '(Array)' was the self-hosted leg's rendered job name

Co-Authored-By: Claude Fable 5 <[email protected]>

* ci(rust): self-hosted leg refuses fork-PR events in-workflow

Sentinel residual-risk ask #1 on #1116: the fork-PR approval policy
is a mutable repo setting; this guard makes the workflow refuse
fork-origin PR events on the self-hosted leg regardless of settings
drift. Hosted legs unaffected.

Co-Authored-By: Claude Fable 5 <[email protected]>

* ci: same-repo guard moves to step level — matrix context is unavailable in job-level if (fixes zero-jobs startup failures)

Co-Authored-By: Claude Fable 5 <[email protected]>

---------

Co-authored-by: Claude Fable 5 <[email protected]>
@joelteply
joelteply force-pushed the fix/attach-start-typed-c0cb6cdc branch from 5a93b78 to 5e0632f Compare June 11, 2026 02:32
…he type level (card c0cb6cdc)

bf0b5790 existed because AttachRequest's DEFAULT was the dangerous
behavior: '..Default::default()' silently meant full-transcript
replay, and three interacting fields (from, from_now,
coalesce_backlog) carried precedence rules documented in a server-side
comment. PR #1113 fixed the symptom at one call site; any of the 11
construction sites could re-create the flood by forgetting a flag.

The protocol now states intent in one type:

- AttachStart { Live (#[default]), After(IpcCursor),
  FromTranscriptStart }. Live is the only start that can never flood
  a consumer; both replaying variants must be named at the call site.
- AttachRequest fields go private. Construction only via
  AttachRequest::new(channel, start) / ::live(channel) plus with_*
  builders; '..Default::default()' literals are impossible outside
  airc-ipc.
- Wire encoding unchanged (from + from_now encode the enum), so
  version-skewed daemon/client pairs interoperate; a legacy bare
  request still decodes as FromTranscriptStart. The
  from_now-overrides-from precedence now exists in exactly ONE place
  (AttachRequest::start) instead of a comment, pinned by unit tests.
- Daemon stream_attach matches on the typed start via into_parts()
  (moves filter vectors, no clone); 'Live + coalesce' is structurally
  a no-op rather than a documented caveat.
- airc-lib daemon_subscribe + monitor CLI + 9 daemon-test sites move
  to constructors.

Tests: 5 new unit tests pin wire round-trip per variant, legacy
bare-request decode, precedence, Live-by-default, and into_parts.
Full workspace suite green (81 test binaries); fmt + clippy clean.

Co-Authored-By: Claude Fable 5 <[email protected]>
@joelteply
joelteply force-pushed the fix/attach-start-typed-c0cb6cdc branch from 5e0632f to 793b429 Compare June 11, 2026 02:47
@joelteply

Copy link
Copy Markdown
Contributor Author

Merging per tightened doctrine (bd61836b): ALL hosted legs COMPLETED green including the production no-silent-fallback gate; windows-self-hosted leg pending under the documented SAC-enforcement exception (NeedsOperator item 0 — OS policy on the runner box, not code signal). Sentinel record: full adversarial review at PR open (wire-compat verified empirically, 8 flag-combination enumeration, byte-identical TS encodings) — verdict comment 4673581570. This PR closes the arc that opened the session: AttachStart makes the flood-by-default unwritable at the type level.

@joelteply
joelteply merged commit 7c7d18a into rust-rewrite Jun 11, 2026
6 of 7 checks passed
@joelteply
joelteply deleted the fix/attach-start-typed-c0cb6cdc branch June 11, 2026 02:53
joelteply added a commit that referenced this pull request Aug 10, 2026
…ruth + name the gaps (#1338)

* feat(backfill): peer-to-peer transcript backfill request/response (S1 of #47)

A message published while a peer is unreachable is LOST, not queued — measured
three times on 2026-08-08, once inside the investigation of it. Replay resumes
from the RECEIVER's cursor against the RECEIVER's store, so a frame that never
arrived cannot be replayed and the receiver cannot know it missed one.

PULL, not an outbox. An outbox needs new per-event durable state AND an
eviction decision (a queue growing while a peer is away a week is its own
incident). Pull needs neither: the sender already has the events in its durable
transcript, the receiver already holds a per-room cursor. Backfill is the
daemon's existing resume, crossing a peer boundary instead of a process one.
DeliveryLedger cannot serve this — it is per-peer COUNTERS, so it knows a peer
has not acked but not WHICH events it missed.

Carried on the existing command bus (request/reply/await_reply over
FrameKind::Command); nothing new invented on the wire. Receive-side dedup
already exists, so an overlapping page costs bandwidth, never correctness —
which is what lets the asker be sloppy about its cursor.

Extracted command_bus::reply_addressing: every responder needs (reply_to,
correlation_id) off a request, and each one re-deriving it from raw headers is
how they drift.

`truncated` is on the response because a bounded page presented as a complete
one lets the gap survive the mechanism built to close it — worse than no
backfill, because it looks fixed.

NOTHING CALLS THIS YET. The reconnect watcher is S2; landing them separately
keeps this slice incapable of changing existing behaviour. Validated on ALL
targets per [[validate-lib-tests-before-push]], not just --lib.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

* fix(ci): the windows leg was a phantom; docs: lead with delivery truth, name the gaps

## CI: a check that never ran, for months

`cargo test (windows-self-hosted)` has been reporting a permanently-pending
check on every PR. Not slow, not offline — the runner does not exist:

    gh api repos/CambrianTech/airc/actions/runners  ->  total_count 0

and bigmama itself has no runner service, no Runner.Listener process, and no
actions-runner directory. On #1336 the job sat `pending` at 0s. It came one
check away from blocking the canary->main release, while reporting Windows
coverage that never ran a single test.

The #1114 rationale for moving off hosted Windows (queue starvation) is stale:
ci.yml's clean-install-windows and clean-install-windows-ps5 run on
windows-latest and passed in 9m10s / 8m42s the same day. So the leg moves back
to windows-latest, where it actually executes. This RESTORES Windows coverage
rather than removing it. The fork-PR guard stays for the day a real self-hosted
runner is registered.

## README: it never mentioned the one thing that makes airc different

In 366 lines the word "ack" did not appear once. The lead was an inventory of
plumbing ("channels, peers, presence, messages, typed headers, replay, and
transport routing") — true, and no reason to care.

The property that actually matters is delivery truth: most surfaces say "sent",
airc says "delivered", with a count. That distinction did real work this week —
a daemon at 21h uptime told us nothing, and `1305 of 1305 acked, rtt ~134ms`
told us everything. Now it is the lead and a first-class part of Reliability,
with the real command output.

## README: an honest gaps section

There was none. Added "What Doesn't Work Yet" for four things hit while building
ON airc, each of which reads as inattention or a broken peer when you meet it
cold: `@Name` in a body is decorative (every send is MentionTarget::All, so a
peer is structurally unable to see it was addressed), long bodies clip on the
receiving side, an offline peer gets no store-and-forward, and the ACK proves
transport delivery rather than that any agent read it.

Verified rather than recalled: the MentionTarget::All hardcoding was re-grepped
across the send sites, and the truncation was reproduced live in a two-part
message whose second half never arrived.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant