Skip to content

Proposal: split src/lib.rs by concern, in move-only steps #160

Backlog

Description

@ammartahamohamedy

Why

src/lib.rs is 2,589 lines: 1,914 lines of code across eight concerns, plus 675 lines of tests. Other modules also import shared helpers from the crate root: hooks.rs, deploy.rs, tools.rs and scan.rs all take say, RepositoryArgs, Verdict or connected_repository from it.

Every new command lands in the same file. 36 of the 71 open PRs touch src/lib.rs, including the five that each add a command (#68, #110, #111, #133, #153). They conflict with one another for that reason alone.

The other large files don't need this. deploy.rs is 843 lines of code and 1,239 lines of tests. hooks.rs, api.rs and git.rs each do one job.

Proposed map

Each new module takes one concern from lib.rs, together with its tests. Line numbers are at 1096f66.

New module Takes from lib.rs About
cli.rs The clap types, except Verdict (68–472) 405
account.rs login, logout, status, delegation, DEFAULT_SCOPES (728–898) 170
repository.rs Repository resolution, from repository_selector to latest (899–1150) 250
poll.rs Poll constants, poll_deadline, read_review, read_review_once, say_not_established 80
review.rs review*, finish, findings, show, review_verdict, print_review, print_audit 380
ci.rs ci review, from ci_commit to ci_verdict (1504–1827) 330
lib.rs mod declarations, Verdict, run, connect, completions, say ~330
  • lib.rs keeps pub(crate) use re-exports of the moved helpers, so hooks.rs, deploy.rs, tools.rs and scan.rs don't change. A last, optional step points their imports at the new modules.
  • deploy.rs's tests move to deploy/tests.rs, as agent/ and update/ already do.
  • Unchanged: the public surface (proofline_cli::{run, api, model, outcome, origin, device, credentials, update}), every other module, dependencies, lints and output.
  • Not proposed: a workspace or several crates, or renaming existing paths.

How

  • One module per commit, move only: cut and paste, adjust use lines and pub(crate), run cargo fmt. No renames and no logic changes. Each commit builds and passes the tests on its own.
  • Proof that nothing changed: the same cargo test and cargo clippy results before and after. Byte-identical --help for every subcommand, and byte-identical --json and text output for a fixed set of commands against the stand-in console. Each commit reviews well with git diff --color-moved.
  • Open PRs: a hunk in a moved function moves to the new file unchanged, so rebasing is mechanical.

This repository is a distribution

The history suggests the CLI is developed elsewhere and synced here. 62 of 191 main commits were "Update distribution" syncs when I counted on 2026-11-29, and build.rs reads ../sdk/openapi.public.json first. A split made here would be overwritten by the next sync, so I'm not opening a PR. If the map is useful, I can prepare it as move-only commits, plus a script that replays the moves, in whatever form suits your workflow.

Questions

  • Is a split wanted at all, or is the map more useful as a note for the monorepo?
  • Is there a good moment for it, such as right after a sync, so open PRs rebase once?
  • Do these seams match how you think about the commands? For example, account versus auth, or ci as a directory now?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions