Skip to content

refactor(cluster): modularize lib.rs — pure code movement#188

Merged
aaltshuler merged 7 commits into
mainfrom
refactor/cluster-modularize
Jun 11, 2026
Merged

refactor(cluster): modularize lib.rs — pure code movement#188
aaltshuler merged 7 commits into
mainfrom
refactor/cluster-modularize

Conversation

@aaltshuler

Copy link
Copy Markdown
Collaborator

Mechanical-only PR (per the repo rule: refactors land separately from the behavior changes they enable — the RFC-006 object-storage port follows as a focused diff against store.rs). Every commit is a verbatim move + visibility bumps, suite-green at each step.

Before → after

lib.rs was 7,857 lines (4,750 impl + 3,100 tests). Now:

Module Contents Lines
lib.rs command pipeline (validate/plan/apply/approve/status/sync/force-unlock) + public API + shared helpers 1,927
tests.rs the in-source suite, verbatim (#[path] module; indentation preserved — raw-string fixtures are content) 3,019
config.rs cluster.yaml parsing, query discovery, digesting, validation, live-graph observation 881
store.rs the storage backend: state ledger, lock, sidecars, approvals — the single home for stored-state I/O 588
types.rs output/diagnostic types + internal state/sidecar/approval models 510
diff.rs resource diffing, binding changes, blast radius, approval gating, classification, demotion 420
sweep.rs the roll-forward recovery sweep (all RFC-004 D3 rows) 386
serve.rs the Phase-5 serving snapshot 189

Guarantees

  • Zero behavior change: 95 cluster tests green after every one of the 7 commits; public re-exports preserved (server/CLI compile untouched); full cargo test --workspace --locked green (46 suites).
  • Visibility changes only where moves required them (pub(crate) on previously position-private items).
  • One deliberate deviation from the proposed map: the command pipeline stays in lib.rs rather than an apply.rs — it is the crate's public API and reads coherently as the orchestrator; a further split remains cheap if it grows.

Known cost: one-time git blame discontinuity across moved lines.

🤖 Generated with Claude Code

aaltshuler and others added 7 commits June 11, 2026 05:25
Verbatim move (indentation preserved — embedded raw-string fixtures are
content). lib.rs drops from 7,857 to ~4,750 lines; `use super::*` resolves
to the crate root through the #[path] module declaration unchanged. 95
tests green before and after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of LocalStateBackend, StateSnapshot, StateLockGuard and their
impls — the single home for stored-state I/O (state ledger, lock, recovery
sidecars, approval artifacts), where the RFC-006 object-storage port lands
next as a focused diff. Visibility bumps (pub(crate)) only; 95 tests green
before and after.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of the Serving* types, read_serving_snapshot, and
read_verified_payload; public re-exports preserved (the server's imports
are unchanged). 95 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of the sidecar classification (all RFC-004 D3 rows),
tombstoning, and approval-consumption helpers. 95 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of diff_resources, binding-change diffing, blast radius,
approval gating, ResourceKind, classify_changes, and demotion. 95 tests
green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of cluster.yaml parsing, query discovery, source digesting,
header/id validation, path resolution, and live-graph observation. Two
helpers that the cut swept along were relocated to their right homes
(state-status helpers back to lib.rs, lock-file helpers to store.rs). 95
tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move of the public output/diagnostic types and the internal
state/sidecar/approval models; previously-private types and their fields
get pub(crate) (they were crate-visible by position before). lib.rs is now
the command pipeline + public API. 95 tests green; full workspace gate
green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaltshuler has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

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