Skip to content

refactor(events): downshift server.stream.events schemas to aragora.events (P4a Batch 1d)#8732

Merged
scarmani merged 1 commit into
mainfrom
structex/p4a-downshift-stream-schemas
Jun 30, 2026
Merged

refactor(events): downshift server.stream.events schemas to aragora.events (P4a Batch 1d)#8732
scarmani merged 1 commit into
mainfrom
structex/p4a-downshift-stream-schemas

Conversation

@scarmani

Copy link
Copy Markdown
Collaborator

Summary

P4a Batch 1d (Tier 1-2). Completes the downshift of the importable stream event schema surface (StreamEvent, StreamEventType, AudienceMessage) to the aragora.events layer, so foundation/infrastructure modules can reach the event dataclasses without importing aragora.server.

The schemas already live in aragora.events.types; this PR:

  • Turns aragora/server/stream/events.py into a DeprecationWarning shim that re-exports the schemas from aragora.events.types (back-compat preserved; the warning message carries the old dotted path aragora.server.stream.events).

  • Repoints the foundation/infrastructure-layer importers off the old path:

    • aragora/billing/cost_tracker.py (BUDGET_ALERT emit path)
    • aragora/events/dispatcher.py (TYPE_CHECKING import)

    so they no longer contribute the stream.events link to the events -> server / billing -> server layer edges.

Server-side stream runtime stays in place; only the importable schema surface moves. Domain/app callers (debate/, explainability/, ranking/) and the server-internal stream modules stay on the shim by-design - their DeprecationWarning is the intended two-sided signal (VAL-CROSS-004); full caller migration is post-mission shim-retire.

Refs: P4a layering foundation, epic #8257.

Validation (worktree off origin/main 3d2af8d)

  • Two-sided shim (VAL-CROSS-004): importing aragora.server.stream.events emits a DeprecationWarning whose message contains aragora.server.stream.events; the shim re-exports all three symbols and imports only aragora.events (allowed-imports check PASS). Robust isolated check (worktree-resolved, __file__ asserted, token-filtered): TWO_SIDED_OK: True.
  • Changed-file typecheck gate (required CI flags): mypy --ignore-missing-imports --follow-imports=skip --show-error-codes over the 3 touched files -> Success: no issues found in 3 source files.
  • make lint: All checks passed. ruff format --check aragora/ tests/ scripts/: 10603 files already formatted.
  • Targeted pytest: tests/billing/test_cost_tracker.py tests/server/stream/test_emitter.py tests/events/test_async_dispatcher.py tests/events/test_batch_dispatcher.py tests/events/test_security_dispatcher.py -> 218 passed (shim DeprecationWarning observed firing via emitter.py:19).
  • make test-smoke (VAL-P4A-013): Core/Server/Memory imports OK, Smoke tests passed (exit 0).
  • Smoke tier: PYTEST_BIN="python3 -m pytest" bash scripts/test_tiers.sh smoke -> 138 passed (exit 0).

Risks / notes

…vents (P4a Batch 1d)

Complete the downshift of the importable stream event schema surface
(StreamEvent, StreamEventType, AudienceMessage) to the aragora.events layer.

- aragora/server/stream/events.py is now a DeprecationWarning shim that
  re-exports the schemas from aragora.events.types (back-compat preserved;
  the warning message carries the old dotted path).
- Repoint the foundation/infrastructure-layer importers off the old path:
  billing/cost_tracker.py and events/dispatcher.py now import the schemas
  from aragora.events.types directly, so they no longer contribute the
  stream.events link to the events->server / billing->server layer edges.

Server-side stream runtime stays in place; only the importable schema surface
moves. Domain/app callers (debate/, explainability/, ranking/) remain on the
shim by-design (their DeprecationWarning is the intended two-sided signal).

Refs: P4a layering foundation (epic #8257).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@scarmani scarmani marked this pull request as ready for review June 30, 2026 21:54
@scarmani scarmani requested a review from an0mium as a code owner June 30, 2026 21:54
@github-actions

Copy link
Copy Markdown
Contributor

Aragora Code Review

Advisory-only review. No issues found.

@scarmani

Copy link
Copy Markdown
Collaborator Author

Claude independent model review

Reviewer: claude (anthropic) — independent adversarial model review via the Aragora Claude reviewer, grounded on the exact PR head.
Head: 2b7b0f7 (2b7b0f7), committed 2026-06-30T21:51:13Z.
PR: #8732.
Model family: claude

Verdict: PASS

Reviewed the full change against the codebase. The refactor is backward-compatible and correct:

  • cost_tracker.py / dispatcher.py now import StreamEvent/StreamEventType from aragora.events.types, where both symbols genuinely live — and the billing change correctly removes a billing → server layering import.

  • events.py shim re-exports all three symbols (StreamEvent, StreamEventType, AudienceMessage) with a complete __all__; no symbol dropped. No circular-import risk (aragora.events.types imports only stdlib).

  • No filterwarnings = error / -W error / simplefilter("error") anywhere in pyproject.toml, conftests, or test markers (the only filterwarnings uses are ignore:: filters), so the new module-level DeprecationWarning will not break collection or the suite.

  • [P3] aragora/server/stream/events.py:20 — the new import-time warnings.warn(..., DeprecationWarning) is triggered by Aragora's own internal modules that still import from this deprecated path (e.g. aragora/server/stream/emitter.py:19, the lazy __getattr__ map in aragora/server/stream/__init__.py:24-26, plus debate_factory.py, broadcaster.py, voice_stream.py, arena_hooks.py, debate/intervention.py, explainability/builder.py, ranking/elo_matchmaking.py). The library thus emits its own deprecation warning during normal server startup. Since this is the "downshift" PR, prefer migrating the internal importers to aragora.events (or scoping the warning) so only external/legacy callers see it; harmless functionally (DeprecationWarnings are ignored by default), but self-inflicted and noisy.

dogfood: yes

@scarmani scarmani merged commit fce9aa5 into main Jun 30, 2026
158 of 164 checks passed
@scarmani scarmani deleted the structex/p4a-downshift-stream-schemas branch June 30, 2026 22:08
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