Skip to content

feat(airc): use structured publish for chat dual-write - #1433

Merged
joelteply merged 1 commit into
canaryfrom
feat/airc-structured-publish
May 25, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/airc-structured-publish

Conversation

@joelteply

@joelteply joelteply commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route Continuum Stage 1 chat dual-write through AIRC structured publish (airc publish --body-json -) instead of airc msg
  • send the generated AircRealtimeEnvelope over stdin, add filterable forge.* / continuum.* headers, and consume only the JSON receipt from AIRC
  • return the AIRC receipt event/channel ids from chat-send results and update the migration gate docs
  • add focused publisher contract checks for args, JSON stdin, receipt parsing, and malformed receipt rejection

References CambrianTech/airc#990 and work card b66dced9-02a4-43e0-8b05-915ce67077dc.

Verification

  • cd src && npx tsx system/airc-chat/test/unit/AircChatEnvelopeCheck.ts && npx tsx system/airc-chat/test/unit/AircChatDualWriteServiceCheck.ts && npx tsx system/airc-chat/test/unit/AircChatPublisherCheck.ts
  • cd src && npx tsx generator/generate-config.ts && npx tsc --noEmit --project tsconfig.json --pretty false
  • cd src && npx eslint --max-warnings 0 system/airc-chat/server/AircChatPublisher.ts --no-warn-ignored
  • cd src && npm run build:ts
  • pre-commit hook: TypeScript passed, lint baseline held, chat-roundtrip passed; browser-ping hit the hook timeout and was skipped by the configured gate
  • pre-push hook: TypeScript clean, ESLint baseline ratchet held, Rust gates skipped because no Rust-relevant changes

@joelteply
joelteply merged commit 1a3b2e3 into canary May 25, 2026
3 checks passed
@joelteply
joelteply deleted the feat/airc-structured-publish branch May 25, 2026 12:50
joelteply pushed a commit that referenced this pull request May 25, 2026
Joel reviewed v1 (review id PRR_kwDOOWWUNc8AAAABA7qHUQ) with 7 substantive
points. v2 addresses all 7:

  1. Naming vs semantics (§3.4) — rename airc/subscribe-channel and
     airc/lifecycle-watch to airc/channel-stream-start and
     airc/lifecycle-stream-start respectively. The commands hand back a
     stream handle and events fan out on the bus; the old names misled
     readers into expecting synchronous request/response.

  2. Event-bus fan-out trade-off (§3.4) — make bus semantics explicit:
     bounded-channel-per-subscriber (not broadcast-all-or-nothing). A
     slow subscriber back-pressures its own channel and may drop past
     the high-water mark; the dropped count surfaces on the stream
     handle so the consumer learns it fell behind rather than silently
     losing data.

  3. Result asymmetry (§3.2) — committed to keeping AircQueueScanResult
     (structured failure inside the success type) as the IPC contract
     so TS callers don't change shape; other methods use Result<_,
     AdapterError>. Adapter converts at ServiceModule boundary.
     Documented on the list_queue trait method.

  4. Trust on receive (§3.1) — lifted from open question to trait
     constraint. subscribe() and replay() now return BoxStream<
     VerifiedEnvelope> / Vec<VerifiedEnvelope> instead of raw
     AircRealtimeEnvelope. The new VerifiedEnvelope struct pairs the
     body with VerificationResult { Verified { signer } | Unverified
     { reason } } so consumers cannot accidentally bypass signature
     verification.

  5. Parallelization (§4) — explicit note: steps 1 (chat) and 3 (room
     membership) build on independent traits and can land in parallel;
     steps 4 (signaling) and 5 (live/media) gate on step 1.

  6. Cargo dep trigger condition (§5) — committed to a concrete minimal
     contract: workspace path dep pinned to a specific commit SHA,
     rebased weekly, never auto-updated. Spells out the Cargo.toml
     entry shape. Both deferral gates now have either a met condition
     or a concrete plan.

  7. Current TS chat path (§1) — confirmed: chat goes pure-TS shell-out
     to airc msg (continuum#1432) then airc publish JSON-CLI (#1433).
     The in-process Vec in realtime_store.rs is reachable from
     airc/realtime-publish but NOT on the live chat path. Removes the
     implicit ambiguity in the v1 doc.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request May 25, 2026
* docs(chat-airc): Stage 1 → 2 design + decision resolutions for #6b564a9a

Continuum chat substrate migration card 6b564a9a (Replace Continuum
chat/Postgres dependency with AIRC Rust SQLite substrate) — Stage 1
of the proof-gates doc is now complete (continuum#1432 publisher seam,
#1433 structured airc-publish CLI, #1435 smoke proof, all merged to
canary). This PR appends the Stage 1 → 2 design + resolves the four
open decisions that were explicitly blocking that transition:

  1. Dual-write atomicity: pick (b) append-only with reconciler for
     Stage 2 (AIRC primary, mirror writer subscribes + back-fills on
     restart + every 60s).
  2. Message ID: invert from Stage 1 — AIRC event_id becomes canonical
     at Stage 2 cutover; legacy ORM ids retained in metadata for
     pre-Stage-1 history rows; same UUID shape so no schema change.
  3. Backfill: none. Pre-Stage-1 history stays in ORM, served via the
     mirror reader path. Known migration boundary, not a regression.
  4. Tombstones: stay ORM-local at Stage 2 (mirror retains deletedAt).
     Stage 3 introduces chat.redact AIRC event type (out of scope).

Plus the Stage 2 architecture: new AircToORMMirrorWriter daemon that
subscribes via LibAircSubstrate (gated on continuum#1434 wiring slice
landing first), ON CONFLICT DO NOTHING for idempotency, cursor-resumed
reconciler. Producers (ChatSendServerCommand, PersonaUser persona
replies) drop their direct ORM write; readers stay unchanged.

And the Stage 1 → 2 PR sequence: PR-A mirror writer skeleton, PR-B
producer cutover, PR-C reader audit, PR-D 1h soak. PR-A is the gating
slice on this lane.

Status log updated to mark Stage 1 complete with PR refs.

Does NOT touch ORM-side code (Stage 3 is the only irreversible step
and is out of scope), does NOT change the AIRC wire format, does NOT
touch persona memory / engram admission.

Closes design portion of work card 6b564a9a-ba4f-4bc4-8ba8-c0fe88dd0eaa.
Implementation lands in follow-up PRs A-D.

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

* feat(airc): project active realtime subscriptions (#1437)

Co-authored-by: Test <[email protected]>

* feat(chat-airc): add mirror writer skeleton

---------

Co-authored-by: Test <[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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant