Skip to content

feat(client): emit() — the publish verb; the four-method facade is complete - #1666

Merged
joelteply merged 1 commit into
canaryfrom
feat/client-ffi-emit
Jun 17, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/client-ffi-emit

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

emit — the publish side of the Event primitive, and the fourth and final facade verb. With this the SDK facade is complete:

call/listen serve/publish
Command execute (#1663) provide (#1664)
Event subscribe (#1663) emit (this)

Two primitives × two directions = four verbs. The platform tracks (mobile/cli/nodejs, all held until the facade completes) can now build against the full surface + the conformance spec.

How (mirrors the subscribe wire path — zero drift)

  • continuum-airc-protocol/event.rs (the wire type — unblocks M5's substrate-side adapter): AircEventPublish { topic, payload } + AircEventPublishAck { topic, delivered } + EVENT_PUBLISH_BODY_HINT + resolve_publish / decode_publish_ack — the publish twins of the subscribe envelopes/helpers (empty-topic refused upfront, same as subscribe).
  • continuum-client: Transport::emit + AircIpcTransport::emit (resolve_publish → airc.request → await → decode the fan-out ack; same shared helpers the substrate's EventPublishAdapter will receive) + MockTransport::emit + Connection::emit.
  • Facade: ContinuumClient::emit(class, payload_json) -> Result<(), FfiError> (the trivial publish verb — no callback).

Composition with M5's substrate work

This ships the client side; the live fan-out lights up when M5's EventPublishAdapter (the receive-door twin of EventSubscribeAdapter) lands — it receives the AircEventPublish wire type added here and hands it to the existing AircEventPublisher::publish. The wire type is the contract between them.

Validation

cargo fmt + cargo clippy -D warnings + cargo test — continuum-airc-protocol 18, continuum-client 18, facade 8 (the new emit test publishes to a subscriber via the mock fan-out, end-to-end). Plus 5 new protocol tests (publish/ack roundtrip, resolve_publish envelope + empty-topic refusal, decode_publish_ack).

Next

Facade complete → the uniffi .udl binds all four verbs in one pass → native swift/kotlin SDKs (Android here, xcframework on macOS CI). The three parallel-outlier platform tracks unblock against the shared conformance spec.

🤖 Generated with Claude Code

@joelteply
joelteply merged commit 4ae252e into canary Jun 17, 2026
4 checks passed
@joelteply
joelteply deleted the feat/client-ffi-emit branch June 17, 2026 20:59
joelteply added a commit that referenced this pull request Jun 17, 2026
…4th SDK verb) (#1668)

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]>
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