Skip to content

Driven adapters stop calling application; layering test - #136

Open
austin-barrington wants to merge 5 commits into
refactor/peer-rpcfrom
refactor/adapter-inversions
Open

austin-barrington wants to merge 5 commits into
refactor/peer-rpcfrom
refactor/adapter-inversions

Conversation

@austin-barrington

Copy link
Copy Markdown
Member

Stacked on #135. Plan: docs/superpowers/plans/2026-11-03-adapter-application-inversions.md.

Driven adapters no longer call into application, and a test now enforces the layering:

  • Tag backfill is a provided MetadataPort::backfill_tag_keys method; the free backfill_tag_metadata is gone.

  • StageTimer moves to crate::telemetry.

  • columnar_timestamps_ns moves to domain/columnar_batch.rs.

  • SyncClient is replaced by application/cluster/catch_up.rs (CatchUpService):

    • It fetches through new PeerRpc methods: join, sync_metadata_snapshot, sync_wal and ping. The existing sync_manifest and shard_map methods are reused.
    • Timeouts (300 s per request), the WAL query, the cluster credential and the call order are unchanged.
    • The unused PeerClient::fetch_map_version is removed.
  • tests/architecture.rs scans src/ and fails on a forbidden import. Grouped use crate::{…} imports are checked too. The rules:

    • domain imports no other layer;
    • ports imports neither adapters nor application;
    • application does not import adapters;
    • adapters imports application only from adapters/http/ and the Raft state machine.

    The allowlist is empty: there are no violations today.

One change in error mapping: a peer's 2xx sync reply that fails to parse now reports PeerUnreachable instead of SyncFailed. Both callers handle every sync error the same way, so only the log text changes.

Gate: fmt, clippy -D warnings, unit, integration 375 and CLI 54 tests all pass.

@cursor

cursor Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches cluster join/WAL catch-up and metadata tag backfill on ingest paths; behavior is largely preserved but sync error labeling and layering moves affect operational debugging.

Overview
This PR inverts adapter→application dependencies and adds a CI guard so they stay fixed.

Metadata / domain moves: Tag key backfill is now MetadataPort::backfill_tag_keys (default on the port); the free backfill_tag_metadata in application is removed. Call sites use the port method directly. columnar_timestamps_ns lives in domain/columnar_batch. StageTimer and spawn_scheduling_probe move to crate::telemetry.

Cluster sync refactor: The adapter sync_client module is deleted. CatchUpService in application/cluster/catch_up.rs replaces SyncClient, driving catch-up through SharedPeerRpc instead of a raw reqwest::Client. HttpPeerRpc implements new PeerRpc methods (join, sync_metadata_snapshot, sync_wal, ping) plus a shared decode helper. Bootstrap and peer HTTP handlers wire HttpPeerRpc into CatchUpService. PeerClient::fetch_map_version is dropped.

Enforcement: tests/architecture.rs scans src/ for forbidden cross-layer imports (including grouped use crate::{…}), with an empty allowlist.

Behavior note: A successful HTTP sync response that fails JSON parse is now classified as PeerUnreachable (was SyncFailed); callers treat sync errors uniformly, so impact is mainly log text.

Reviewed by Cursor Bugbot for commit 6bad45b. Configure here.

This branch has not been deployed

No deployments
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