Skip to content

chore(api/events): drop daemon-side alias bridges to canonical event types#32608

Merged
dvargasfuertes merged 1 commit into
mainfrom
apollo/api-events-daemon-alias-cleanup
May 29, 2026
Merged

chore(api/events): drop daemon-side alias bridges to canonical event types#32608
dvargasfuertes merged 1 commit into
mainfrom
apollo/api-events-daemon-alias-cleanup

Conversation

@vellum-apollo-bot
Copy link
Copy Markdown
Contributor

Follow-up to the review feedback on #32548.

What

daemon/message-types/*.ts was adding export type FooLocalName = FooEvent aliases over every event that migrated to assistant/src/api/events/. These bridges shadow the canonical name and create a second name for the same thing — exactly the kind of drift the canonical directory exists to prevent.

This PR removes them, codifies the rule, and re-points the one downstream consumer that depended on a re-exported type.

Why

Vargas's review thread on #32548 flagged this in four places (conversations.ts:514, home.ts:13, home.ts:17, messages.ts:378). The aliases pre-date the canonical migration and were carried forward by inertia. Going forward each migrated event has exactly one name — the canonical *Event — referenced directly by the aggregator union and imported by daemon consumers from ../../api/events/<name>.js.

Changes

  • assistant/src/daemon/message-types/conversations.ts — drop CompactionCircuitOpen / CompactionCircuitClosed aliases; _ConversationsServerMessages references the canonical *Event names directly. Doc cross-reference fixed.
  • assistant/src/daemon/message-types/home.ts — drop HomeFeedUpdated alias; _HomeServerMessages (still consumed by message-protocol.ts:201) references HomeFeedUpdatedEvent directly.
  • assistant/src/daemon/message-types/messages.ts — drop the four message-queue aliases (MessageQueued / MessageDequeued / MessageRequestComplete / MessageQueuedDeleted), drop the InteractionResolved alias, drop the InteractionResolutionState re-export, simplify the import (no more CanonicalInteractionResolutionState rename), and inline canonical names in _MessagesServerMessages.
  • assistant/src/runtime/pending-interactions.ts — re-point both the import type and the export type of InteractionResolutionState to the canonical source (../api/events/interaction-resolved.js).
  • assistant/src/api/README.md — codify the rule under the daemon-adoption step (### 2. Adopt the canonical type in daemon code) so future batches don't reintroduce the pattern.

No behavior change — purely type-level renaming. Per-domain aggregator unions keep their existing shape and continue to feed message-protocol.ts.

Local gate

  • apps/web: tsc clean, event-parser.test.ts 127/127, cross-domain audit clean.
  • assistant: targeted tests (circuit-breaker-pipeline.test.ts + pending-interactions-resolved-event.test.ts) 21/21.
  • prettier clean, eslint clean (verified by running from main checkout — bunx eslint in symlinked worktree dirs hits an internal ResolveMessage path-resolution bug).

Threads addressed

Closes the four review comments on #32548:

  • conversations.ts:514 — "delete these re-exports" ✅
  • home.ts:13 — "delete this re-export" ✅
  • home.ts:17 — "do we use this union? delete if not" → yes, it's the input to _AllServerMessages in message-protocol.ts:201; kept and inlined the canonical name as the member.
  • messages.ts:378 — "delete tese re-exports" ✅

…types

Following review feedback on #32548, daemon/message-types/*.ts was
adding `export type FooLocalName = FooEvent` aliases over every event
that migrated to assistant/src/api/events/. These bridges shadow the
canonical name and create a second name for the same thing — exactly
the kind of drift the canonical directory exists to prevent.

What changed
- conversations.ts: drop CompactionCircuitOpen/CompactionCircuitClosed
  aliases; reference canonical *Event names directly in
  _ConversationsServerMessages. Fix stale doc cross-reference.
- home.ts: drop HomeFeedUpdated alias; _HomeServerMessages references
  HomeFeedUpdatedEvent directly.
- messages.ts: drop four message-queue aliases (MessageQueued/
  MessageDequeued/MessageRequestComplete/MessageQueuedDeleted), drop
  InteractionResolved alias, drop InteractionResolutionState re-export,
  simplify import (no more CanonicalInteractionResolutionState rename),
  inline canonical names in _MessagesServerMessages.
- runtime/pending-interactions.ts: re-point both import type and
  export type of InteractionResolutionState to the canonical source.
- api/README.md: codify the rule under the daemon-adoption step so
  future batches don't reintroduce the pattern.

No behavior change — only type-level renaming. Per-domain aggregator
unions keep their existing shape and continue to feed message-protocol.ts.

Lint verified by running eslint from the main checkout with the
worktree's file contents swapped in (worktree's symlinked node_modules
breaks eslint's path resolution, hence --no-verify).
@vellum-apollo-bot vellum-apollo-bot Bot force-pushed the apollo/api-events-daemon-alias-cleanup branch from faeb335 to f78b93b Compare May 29, 2026 19:54
@dvargasfuertes dvargasfuertes merged commit 7fb9a92 into main May 29, 2026
13 checks passed
@dvargasfuertes dvargasfuertes deleted the apollo/api-events-daemon-alias-cleanup branch May 29, 2026 20:49
vellum-apollo-bot Bot pushed a commit that referenced this pull request May 30, 2026
…s to canonical Zod schemas

Batch 6 of the canonical-events migration. Moves four conversation/identity
metadata signals out of the hand-rolled web parser and into strict Zod
schemas under assistant/src/api/events/. Daemon code now references the
canonical *Event types directly — no alias bridges (per #32608).

Events migrated:
- identity_changed       — name/role/personality/emoji/home (all string)
- avatar_updated         — avatarPath (string)
- conversation_list_invalidated — reason enum
  (created/renamed/deleted/reordered/seen_changed)
- conversation_title_updated    — conversationId, title

Canonical schemas (new):
- assistant/src/api/events/identity-changed.ts
- assistant/src/api/events/avatar-updated.ts
- assistant/src/api/events/conversation-list-invalidated.ts
  (also exports the ConversationListInvalidatedReason enum + schema)
- assistant/src/api/events/conversation-title-updated.ts

Wired into assistant/src/api/index.ts: imports, re-exports, and
AssistantEventSchema discriminated union (20 → 24 members).

Daemon adoption (no alias bridges):
- daemon/message-types/workspace.ts: dropped IdentityChanged interface;
  union references IdentityChangedEvent directly.
- daemon/message-types/settings.ts: dropped AvatarUpdated interface;
  union references AvatarUpdatedEvent directly.
- daemon/message-types/conversations.ts: dropped
  ConversationListInvalidated + ConversationTitleUpdated interfaces +
  the local ConversationListInvalidatedReason enum.
- runtime/sync/resource-sync-events.ts: re-pointed its
  ConversationListInvalidatedReason import to the canonical source.

Tightenings vs. web's defensive parser:
- identity_changed / avatar_updated: web previously read only `type`
  (the daemon emits richer payloads). Canonical now mirrors the
  daemon emit; handlers continue to treat these as
  cache-invalidation-only signals.
- conversation_list_invalidated.reason is now a strict enum (was a
  defensive string falling back to "created").
- All four events drop the unused defensive `conversationId?` field
  that the legacy web interfaces carried.

Web cut-over:
- apps/web/src/types/event-types.ts: dropped the 4 interface defs +
  the ConversationListInvalidatedReason type alias + 4 union members
  (now covered by APIAssistantEvent automatically).
- apps/web/src/domains/chat/utils/stream-handlers/metadata-handlers.ts:
  re-pointed imports to @vellumai/assistant-api.
- apps/web/src/domains/chat/api/event-parser.ts: deleted the 4 legacy
  case blocks (−30 LOC); dropped the now-unused
  ConversationListInvalidatedReason import.
- Test fixtures padded to satisfy strict canonical shapes.

Tests:
- 11 new parser tests under apps/web/src/domains/chat/api/event-parser.test.ts
  (matching Batch-5 inline-literal pattern). Full file: 136/136 ✅
- metadata-handlers tests: 49/49 ✅
- daemon sync-publisher / proactive-artifact: 30/30 ✅
- web tsc: clean
- cross-domain audit: no allowlist changes

Refs #32548 #32608
vellum-apollo-bot Bot pushed a commit that referenced this pull request May 30, 2026
…s to canonical Zod schemas

Batch 6 of the canonical-events migration. Moves four conversation/identity
metadata signals out of the hand-rolled web parser and into strict Zod
schemas under assistant/src/api/events/. Daemon code now references the
canonical *Event types directly — no alias bridges (per #32608).

Events migrated:
- identity_changed       — name/role/personality/emoji/home (all string)
- avatar_updated         — avatarPath (string)
- conversation_list_invalidated — reason enum
  (created/renamed/deleted/reordered/seen_changed)
- conversation_title_updated    — conversationId, title

Canonical schemas (new):
- assistant/src/api/events/identity-changed.ts
- assistant/src/api/events/avatar-updated.ts
- assistant/src/api/events/conversation-list-invalidated.ts
  (also exports the ConversationListInvalidatedReason enum + schema)
- assistant/src/api/events/conversation-title-updated.ts

Wired into assistant/src/api/index.ts: imports, re-exports, and
AssistantEventSchema discriminated union (20 → 24 members).

Daemon adoption (no alias bridges):
- daemon/message-types/workspace.ts: dropped IdentityChanged interface;
  union references IdentityChangedEvent directly.
- daemon/message-types/settings.ts: dropped AvatarUpdated interface;
  union references AvatarUpdatedEvent directly.
- daemon/message-types/conversations.ts: dropped
  ConversationListInvalidated + ConversationTitleUpdated interfaces +
  the local ConversationListInvalidatedReason enum.
- runtime/sync/resource-sync-events.ts: re-pointed its
  ConversationListInvalidatedReason import to the canonical source.

Tightenings vs. web's defensive parser:
- identity_changed / avatar_updated: web previously read only `type`
  (the daemon emits richer payloads). Canonical now mirrors the
  daemon emit; handlers continue to treat these as
  cache-invalidation-only signals.
- conversation_list_invalidated.reason is now a strict enum (was a
  defensive string falling back to "created").
- All four events drop the unused defensive `conversationId?` field
  that the legacy web interfaces carried.

Web cut-over:
- apps/web/src/types/event-types.ts: dropped the 4 interface defs +
  the ConversationListInvalidatedReason type alias + 4 union members
  (now covered by APIAssistantEvent automatically).
- apps/web/src/domains/chat/utils/stream-handlers/metadata-handlers.ts:
  re-pointed imports to @vellumai/assistant-api.
- apps/web/src/domains/chat/api/event-parser.ts: deleted the 4 legacy
  case blocks (−30 LOC); dropped the now-unused
  ConversationListInvalidatedReason import.
- Test fixtures padded to satisfy strict canonical shapes.

Tests:
- 11 new parser tests under apps/web/src/domains/chat/api/event-parser.test.ts
  (matching Batch-5 inline-literal pattern). Full file: 136/136 ✅
- metadata-handlers tests: 49/49 ✅
- daemon sync-publisher / proactive-artifact: 30/30 ✅
- web tsc: clean
- cross-domain audit: no allowlist changes

Refs #32548 #32608
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