Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions docs/brief.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ rally's projects, with every list bounded and every note cut short (well under 2
- `service`: a file the service runs changed (`builds::SERVICE_MODULES`, or `Cargo.toml`, `Cargo.lock`,
`build.rs`), listed in `service_files`. Only these are counted: "2 stories merged, not live on the service;
the oldest for 6 h", and `count` and `oldest_age_ms` are theirs.
- `can't tell`: only files the service shares changed, listed in `shared_files`: `src/main.rs` (every
command, `serve` among them), `src/web.rs` (the viewer, and the roadmap parser the service uses) and
`src/lib.rs` unless its patch only names modules the service doesn't run; or a commit's files couldn't be
read. Read the diff. It's never counted as live.
- `can't tell`: only files the service shares changed, listed in `shared_files`: `src/web.rs` (the viewer,
and the roadmap parser the service uses) and `src/lib.rs` unless its patch only names modules the service
doesn't run; or a commit's files couldn't be read. Read the diff. It's never counted as live.
`src/main.rs` was one of these until RAL-196 moved `serve`'s flags and startup to `src/serve.rs`, which is
the service's, and the `--db`, `--head-file` and `--db-password-file` flags to the store: `main` now only
passes that command on and declares none of them, and a test keeps it so.
- `cli or viewer`: only code the CLI or the viewer runs changed. It's live wherever those are on a build that
has it: `cli_build` says this CLI's commit, how far behind main it is and which stories it `lacks`, and
`viewer_build` the build of the viewer `rally view` started on this machine, from its run file.
Expand Down
7 changes: 7 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -1539,3 +1539,10 @@ principles named were durable, accurate and reactive. Found in rally 0x7 by plus
told and is never called live; the rest say they change only the CLI, the viewer, docs or tests, and the
section says which build this CLI and the viewer here are on; a test keeps every file in `src/` placed as the
service's, shared or the client's; with tests of each reading (docs/brief.md).
- [ ] **RAL-196: Serve's wiring in its own file.** Follow-up to RAL-195, agreed with the watchman (2026-11-15):
`src/main.rs` held every command, `serve` among them, so the brief's builds read "can't tell" for each story
that touched it (three of the eight on 2026-11-15). Done when: `serve`'s flags, their checks and the service's
start are in `src/serve.rs`, and the `--db`, `--head-file` and `--db-password-file` flags are declared and read
in the store, with no
change to what `rally serve` accepts or does; `src/main.rs` is placed with the client's files, and
`src/serve.rs` with the service's; with a test that `main` only passes `serve` on (docs/brief.md).
61 changes: 49 additions & 12 deletions src/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,20 @@ pub const SERVICE_MODULES: &[&str] = &[
"next",
"record",
"secrets",
"serve",
"server",
"store",
"views",
"watchman_brief",
];

/// The files every part shares: `main` holds each command, `serve` among them; `lib` names each
/// module; `web` is the viewer and also the roadmap parser the service's evidence checks use.
pub const SHARED_MODULES: &[&str] = &["lib", "main", "web"];
/// The files every part shares: `lib` names each module; `web` is the viewer and also the roadmap
/// parser the service's evidence checks use.
pub const SHARED_MODULES: &[&str] = &["lib", "web"];

/// The modules only the CLI or the viewer runs.
/// The modules only the CLI or the viewer runs. `main` is among them since RAL-196: it holds
/// every command but the service's, which it passes on whole to `serve`
/// (`tests::main_only_passes_serve_on` keeps it so).
pub const CLIENT_MODULES: &[&str] = &[
"backup",
"builds",
Expand All @@ -113,6 +116,7 @@ pub const CLIENT_MODULES: &[&str] = &[
"init",
"levi",
"lock_holder",
"main",
"merge_notes",
"rebased",
"resume",
Expand Down Expand Up @@ -675,7 +679,7 @@ pub fn section(read: Read) -> Value {
(a pull request's merge lists all it changed) go to the stories it names \
or brought, or to `unnamed` when it names none; a file the service runs \
(builds::SERVICE_MODULES, Cargo.toml, Cargo.lock, build.rs) waits on the \
service; src/main.rs, src/web.rs and most of src/lib.rs are shared, so \
service; src/web.rs and most of src/lib.rs are shared, so \
the path can't tell",
});
}
Expand Down Expand Up @@ -849,7 +853,7 @@ mod tests {
]});
let mut read = files(&[
("a", &["docs/watchman.md", "src/session.rs"]),
("b", &["src/main.rs", "src/session.rs"]),
("b", &["src/web.rs", "src/session.rs"]),
(
"d",
&[
Expand All @@ -859,7 +863,7 @@ mod tests {
],
),
("e", &["web/app.js", "web/app.css"]),
("f", &["src/server.rs", "src/main.rs"]),
("f", &["src/server.rs", "src/web.rs"]),
]);
// A patch to lib.rs that only names a module the service doesn't run changes nothing
// the service runs.
Expand Down Expand Up @@ -925,7 +929,7 @@ mod tests {
assert_eq!(
merged["summary"],
"1 story merged, not live on the service; the oldest for 6 h; 1 story can't be told \
from the paths (shared with the service: src/main.rs): read the diff; 4 stories \
from the paths (shared with the service: src/web.rs): read the diff; 4 stories \
change only the CLI, the viewer, docs or tests: live wherever those builds have \
them (see cli_build and viewer_build)"
);
Expand Down Expand Up @@ -1018,7 +1022,7 @@ mod tests {
("a", &["docs/watchman.md"]),
("b", &["src/server.rs", "tests/service.rs"]),
("c", &["docs/brief.md"]),
("d", &["src/main.rs"]),
("d", &["src/web.rs"]),
])));
let merged = &out["merged_not_live"];
assert_eq!(merged["stories"][0]["waits_on"], "nothing running");
Expand All @@ -1030,7 +1034,7 @@ mod tests {
"unread": null},
{"commit": "ddddddd", "message": "a flag for every command",
"age_ms": 8 * 3_600_000, "waits_on": "can't tell", "service_files": [],
"shared_files": ["src/main.rs"], "unread": null},
"shared_files": ["src/web.rs"], "unread": null},
])
);
assert_eq!(
Expand All @@ -1040,7 +1044,7 @@ mod tests {
assert_eq!(merged["oldest_age_ms"], 10 * 3_600_000);
assert_eq!(
merged["summary"],
"1 commit naming no story merged, not live on the service; the oldest for 10 h; 1 commit naming no story can't be told from the paths (shared with the service: src/main.rs): read the diff; 1 story changes only the CLI, the viewer, docs or tests: live wherever those builds have it (see cli_build and viewer_build)"
"1 commit naming no story merged, not live on the service; the oldest for 10 h; 1 commit naming no story can't be told from the paths (shared with the service: src/web.rs): read the diff; 1 story changes only the CLI, the viewer, docs or tests: live wherever those builds have it (see cli_build and viewer_build)"
);
assert!(out["hint"].is_string(), "a commit waits on the service");

Expand Down Expand Up @@ -1174,7 +1178,8 @@ mod tests {
assert_eq!(part_of("src/server.rs"), Part::Service);
assert_eq!(part_of("src/views.rs"), Part::Service);
assert_eq!(part_of("Cargo.lock"), Part::Service);
assert_eq!(part_of("src/main.rs"), Part::Shared);
assert_eq!(part_of("src/main.rs"), Part::Client);
assert_eq!(part_of("src/serve.rs"), Part::Service);
assert_eq!(part_of("src/web.rs"), Part::Shared);
assert_eq!(part_of("src/a_module_added_since.rs"), Part::Shared);
assert_eq!(part_of("src/session.rs"), Part::Client);
Expand Down Expand Up @@ -1202,6 +1207,38 @@ mod tests {
);
}

/// RAL-196: `main` is the client's because all it does for the service is pass `serve` on.
/// If serve's wiring comes back into it, a change to it could be the service's again.
#[test]
fn main_only_passes_serve_on() {
let main = include_str!("main.rs");
assert!(
main.contains("Command::Serve(args) => return rally::serve::run(location, args),"),
"main passes `serve` on whole"
);
assert!(main.contains(" Serve(rally::serve::Args),"));
// The flags that name the ledger are the store's, flattened in: main declares none.
assert!(main.contains(" ledger: rally::store::LedgerFlags,"));
assert!(main.contains("cli.ledger.location(uses_database)?"));
for services in [
"server::",
"RateLimit",
"evidence::Settings",
"RALLY_DB",
"RALLY_HEAD_FILE",
"cli.db",
"cli.head_file",
" head_file: ",
"Location {",
] {
assert!(
!main.contains(services),
"src/main.rs names {services}, which is the service's: keep it in src/serve.rs, \
or move `main` back to builds::SHARED_MODULES"
);
}
}

/// Every file in `src/` is placed in one list, so a new module makes its author say whether
/// the service runs it; and the service's list holds what `server` and `store` name.
#[test]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub mod roadmaps;
pub mod scratch_pg;
pub mod script;
pub mod secrets;
pub mod serve;
pub mod server;
pub mod session;
pub mod shims;
Expand Down
Loading
Loading