Skip to content

feat(routing): EventPublishAdapter — the emit() landing (4th SDK verb) - #1668

Merged
joelteply merged 1 commit into
canaryfrom
feat/event-publish-adapter
Jun 17, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/event-publish-adapter

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

The client-side emit() (BigMama, #1666) builds an AircEventPublish envelope. This is its peer-side landing — the ConsumerAdapter that receives a publish, gates it, fans it out to every matching subscriber, and acks the delivered count.

Completes the Event primitive's write half on the core:

primitive read write
Command execute (#1663) provide (#1664)
Event subscribe (#1663) publish (this PR)

Built lowest-level-out, mirroring subscribe line-for-line

  • protocol (continuum-airc-protocol, already on canary): AircEventPublish, AircEventPublishAck, EVENT_PUBLISH_BODY_HINT, resolve_publish, decode_publish_ack — single source of truth for the wire shape.
  • routing/airc_event_protocol.rs + mod.rs: re-export the publish symbols beside the subscribe ones.
  • routing/airc_event_publisher.rs: ParsedPublish + parse_publish_envelope (twin of parse_subscribe_envelope) + build_publish_ack (twin of build_subscribe_ack, carrying the fan-out count).
  • routing/airc_event_adapters.rs: EventPublishAdapter — gate_publish (pure WRITE-gate seam) + process_publish (gate → AircEventPublisher::publish fan-out → ack) + the ConsumerAdapter impl claiming EVENT_PUBLISH_BODY_HINT.

Why publish is gated as a WRITE

Unlike subscribe (registers the caller's own interest), a publish mutates every subscriber's stream. It runs through the same AuthPolicy chokepoint on the synthetic URI events/<topic>/publish — without it, any reachable peer could inject events onto any topic, including internal substrate signals other personas act on. Empty topic refused upfront ([[no-fallbacks-ever]]).

Test

cargo test -p continuum-core --lib --features metal,accelerate,test-fixtures routing::airc_event_adapters::tests → 15 passed (4 new publish-gate/ack tests + the existing subscribe suite). Clippy clean on touched files. The async fan-out half composes AircEventPublisher::publish, covered without airc by the existing build_publish_envelopes tests.

Scope

Boot wiring (register_consumer_adapter for the whole event surface) is the same not-yet-present integration step the subscribe/unsubscribe adapters await — this lands the publish adapter ready to register beside them.

🤖 Generated with Claude Code

…4th SDK verb)

The client-side emit() (BigMama, #1666) builds an AircEventPublish envelope;
this is its peer-side landing — the ConsumerAdapter that receives a publish,
gates it, fans it out to every matching subscriber, and acks the delivered
count. Completes the Event primitive's write half on the core: subscribe
(read) + publish (write), the twin of execute + provide on the Command side.

Built from the lowest shared level outward, mirroring the subscribe path
line-for-line so a reader who knows one knows the other:

  protocol (continuum-airc-protocol, already on canary): AircEventPublish,
    AircEventPublishAck, EVENT_PUBLISH_BODY_HINT, resolve_publish,
    decode_publish_ack — the single source of truth for the wire shape.
  routing/airc_event_protocol.rs + mod.rs: re-export the publish symbols
    alongside the subscribe ones.
  routing/airc_event_publisher.rs: ParsedPublish + parse_publish_envelope
    (twin of parse_subscribe_envelope) + build_publish_ack (twin of
    build_subscribe_ack, carrying the fan-out count).
  routing/airc_event_adapters.rs: EventPublishAdapter — gate_publish (the
    pure WRITE-gate seam) + process_publish (gate → AircEventPublisher::publish
    fan-out → ack) + the ConsumerAdapter impl claiming EVENT_PUBLISH_BODY_HINT.

Publish is a WRITE: unlike subscribe (registers the caller's own interest), a
publish MUTATES every subscriber's stream. So it is gated through the same
AuthPolicy chokepoint on the synthetic URI events/<topic>/publish — without
it any reachable peer could inject events onto ANY topic, including internal
substrate signals other personas act on. Empty topic refused upfront
([[no-fallbacks-ever]]).

Tests (routing::airc_event_adapters::tests, mirroring the subscribe suite):
  - gate_publish_threads_caller_into_gate — the verified sender reaches the
    gate (no silent privilege escalation)
  - gate_publish_refuses_empty_topic_with_typed_error
  - gate_publish_refuses_when_policy_forbids
  - gate_publish_decision_path_is_stable — pins events/<topic>/publish
  - build_publish_ack_carries_topic_and_delivered_count
  - adapter name + body_hint pinned to the protocol constants
The async fan-out half composes AircEventPublisher::publish, whose
composition is covered without airc by build_publish_envelopes tests.

Boot wiring (register_consumer_adapter for the whole event surface) is the
same not-yet-present integration step the subscribe/unsubscribe adapters
await — this lands the publish adapter ready to register beside them.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply
joelteply merged commit 3145c87 into canary Jun 17, 2026
4 checks passed
@joelteply
joelteply deleted the feat/event-publish-adapter branch June 17, 2026 23:09
joelteply added a commit that referenced this pull request Nov 8, 2026
…anchored clone holding nothing unpublished is re-allocated (card 7f824214) (#5873)

* Every held card checkout goes through airc's ensure_card_clone: an unanchored clone holding nothing unpublished is re-allocated (card 7f824214)

Kimi on the Windows node, 2026-11-08: a clean, weeks-old card clone (e5fe473) with no
allocation evidence was handed back to her as-is by stage_for_card's early return, so her hands
sat on old code and work/submit could never name a base. airc e05c44d (#1668) makes
ensure_card_clone re-allocate such a clone when nothing in it is unpublished (HEAD and every branch
tip on the remote, clean tree, no stash) and refuse naming what it holds otherwise. The early
return is deleted, so every existing checkout reaches it (the linked-worktree migration of #1582
needed the same path), and a re-allocation is probed as card.checkout.reallocated.

Bumps the airc pin 22c9c0e -> e05c44d (6 commits; IPC_PROTOCOL_VERSION unchanged at 6).

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

* A held turn and a submit route a checkout without allocation evidence through the stager too (Codex on #5873)

Two more paths handed an existing checkout back as-is, so Kimi's anchorless clone never reached
ensure_card_clone: restage_held_linked_checkout returned early for any present non-linked
checkout, and next_after_submission submitted from any found path. One predicate,
card_checkout::lacks_allocation_evidence (airc's allocation_evidence, off the runtime threads), is
true unless evidence decodes against its creation anchor; both paths now send such a checkout to
the stager (re-allocate, or refuse naming what it holds). A checkout with its evidence keeps the
fast path. Test: none, valid, then the anchor deleted. continuum-mind card_checkout + card_staging:
12 passed (IntelMac, --features metal).

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

* Only a checkout with no creation anchor goes to airc's stager; an anchored one predating the full allocation record keeps working (#5873 CI)

32ea routed any checkout without airc's full allocation record to ensure_card_clone, which refuses
one holding unpushed work: a checkout with its creation anchor but from before airc wrote the record
(continuum-core's a_checkout_derived_submit_publishes_her_patch_and_records_its_issuer) could no
longer submit. Submit needs only the anchor. The predicate is now card_checkout::lacks_creation_anchor:
Kimi's clone has none and still goes to the stager; an anchored one is reused. stage_for_card keeps
its early return for an anchored, non-linked clone, so a claim never sends old anchored work to that
refusal. Tests: none / anchor only / anchor gone; card_checkout + card_staging 12 passed, the failing
continuum-core test passes (IntelMac, --features metal).

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

---------

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant