Repository navigation
feat(cli): run --strict stops at a loss a job does not allow (#2371) - #2736
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 seconds. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| None => (c.as_str(), Value::Null), | ||
| }; | ||
| let out = run(&mut s, id, p)?; | ||
| let out = run_strict(&mut s, strict, id, p)?; |
There was a problem hiding this comment.
When a strict stop fires, run_strict returns Err and the ? skips print(&out) for the command that stopped the run. Its result never reaches stdout, even though its effect already happened. For example, share.exportMap can write the PNG and the path is never printed. The stop message names the code but not that result. Suggest printing the stopping command's output before returning the stop error, so a job can still find what the command wrote.
Category: quality
There was a problem hiding this comment.
Printing the stopping command's result before the stop report would help a job find what it wrote. Left for the release quality pass.
| ### Strict runs | ||
|
|
||
| Some notices that say a command lost data carry a loss code, such as `dropped.ring`, that stays | ||
| the same however their wording changes. `run --strict` stops after the first command that reports a |
There was a problem hiding this comment.
The guide says the run stops "before the commands after it", but the check runs only after a whole --cmd returns. A script.run is one command, so its later steps still run after a step reports a disallowed loss, and the stop comes after the script ends. The script.run case is covered only by the failed-command test. Suggest saying in this section that the check is per top-level --cmd, and that a script's steps are not stopped one by one.
Category: quality
There was a problem hiding this comment.
Saying that the check runs per top-level --cmd, so the steps inside a script.run aren't stopped one by one, would make the guide more precise. Left for the release quality pass.
Code reviewI found no correctness bugs. The engine's loss counting holds up: Bugs
Security
Performance
Quality
AGENTS.md
Already raised: none. Change sizeCompared: the whole PR against main (merge base e78939a to PR head 26d4479).
|
…s#2371) `rustgis-cli run --strict` stops after the first command that reports a classified loss no `--allow <kind or code>` accepts, before later commands and `--save`, and exits with status 3, listing each loss by code with what to do. A failed command's losses that outlive its rollback count too. The loss registry declares each code once, giving `LossCode::ALL` and `from_id`; the command line guide lists every code, checked by a test. `Session::losses_given` counts loss notices per code beyond the notice queue's 200, so a strict run can't miss one.
…me losses have codes
26d4479 to
f8be5e1
Compare
| loss, | ||
| }); | ||
| self.notices_given += 1; | ||
| if let Some(code) = loss { |
There was a problem hiding this comment.
Strict runs can miss a classified loss when counted notices overflow. notify_counted (lib.rs ~3418-3424) keeps at most MAX_LOSS_NOTICE_KINDS (32) pending (code, template) pairs per outer command. Past that, the occurrences go to loss_notice_overflow and flush as a self.warn(...), which has no code. So a dropped.legend loss that is the 33rd distinct template never reaches losses_given, and --strict exits 0. The existing test counted_notice_overflow_warns_without_assigning_a_cause asserts loss() == None, which locks this in. The warning is visible, so this is not silent, but the strict contract ("stops at a loss a job does not allow") is broken for that case.
Reachability is low today: it needs 32 distinct counted templates (advisories included) in one outer command, such as a large script. Confidence about the code path is high; confidence it is hit in practice is medium-low.
Suggested direction: keep a per-code overflow count (for example Vec<(Option<LossCode>, u32)>) and flush a coded notice for each code at the end, so the code survives the cap.
Category: bug
There was a problem hiding this comment.
Fixed in 2f1241b. Overflow past the 32-kind cap is now kept per cause. Each code flushes its own coded notice ("3 further dropped.legend occurrence(s) could not be described"), so --strict sees it, and unclassified advisories keep the uncoded warning. counted_notice_overflow_keeps_each_cause replaces the test that pinned the uncoded behaviour and checks both cases and losses_given.
|
|
||
| /// How many loss notices this session has given for each code, including those the notice | ||
| /// queue no longer keeps: compare two of these to learn what a run lost, however much it said. | ||
| /// A failed command's losses are taken back with its changes, except one whose notice the |
There was a problem hiding this comment.
This doc says a failed command's losses are taken back with its changes. Counted losses (notify_counted) don't work that way: they are flushed after the outermost rollback (see flush_loss_notices and the comment at ~2537), so a counted omission from a failed command stays counted. The behaviour the strict run relies on is right, and the PR body says so, but this comment describes the wrong rule. Suggest naming the counted case explicitly, for example: "Losses reported by a command that failed are taken back with its changes, except counted losses, which outlive the rollback, and one whose notice the queue had already let go."
Category: quality
There was a problem hiding this comment.
Fixed in 2f1241b: the doc now names counted losses as outliving the rollback.
| let mut said = format!("--strict: stopped after {id}, which reported a loss no --allow accepts:"); | ||
| for (code, n) in lost { | ||
| let spec = code.spec(); | ||
| let notices = if n == 1 { "1 notice".to_string() } else { format!("{n} notices") }; |
There was a problem hiding this comment.
The stop report counts notices, not occurrences. A counted notice aggregates occurrences in its text, so one notice saying "2 omitted legends" prints as dropped.legend (1 notice). The doc's "how many notices reported it" is literally true, but a job reading the report would take it as a count of lost items. Consider wording such as "(1 notice; see its text for the count)", or counting occurrences if that is available here.
Category: quality
There was a problem hiding this comment.
Fixed in 2f1241b: the guide now says the report counts notices and each notice says how much it lost. The CLI has a comment saying the same.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Already raised, left alone (2)
Checked and found sound
Change sizeCompared with the base branch: merge base e66b2e7 to PR head f8be5e1.
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
A loss counted after 32 other counted notices in one command went into an uncoded overflow warning, so `run --strict` passed it. The overflow is now kept per cause: each code flushes its own coded notice, and unclassified advisories keep the uncoded one.
|
|
||
| /// How many loss notices this session has given for each code, including those the notice | ||
| /// queue no longer keeps: compare two of these to learn what a run lost, however much it said. | ||
| /// A failed command's losses are taken back with its changes, except counted losses |
There was a problem hiding this comment.
The doc says a failed command's losses are "taken back with its changes". The withdrawal only runs in the (Err(_), Some(snap)) branch of guarded_inner, which is taken only for commands that mutate. A failed read-only command has no snapshot, so every immediate loss it reported stays counted and --strict stops on it. That is the intended direction (it errs towards a loss), but the sentence reads as if it holds for every failed command.
Suggested wording: "A failed command that changed the project takes back its losses with those changes; a failed read-only command keeps them. Counted losses outlive any rollback, and so does one whose notice the queue had already let go, which stays counted, erring towards a loss."
Category: quality
There was a problem hiding this comment.
Right: only a failed command that changed the project takes its losses back, and a failed read-only command keeps them, which errs towards a loss. Rewording the doc to say so is left for the release quality pass.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Prior review threads
Change sizeCompared: the whole PR against main (merge base e66b2e7 to PR head 2f1241b).
|
Summary
rustgis-cli run --strictstops after the first command that reports a classified loss, before later commands and--save, and exits with status 3. Standard error lists each loss by code, with its notice count and what to do. A command that fails still reports the losses that outlive its rollback, such as a counted legend omission. The strict report then follows the error, and the run exits with status 3. Repeat--allow <kind or code>(or--allow=…) to accept losses a job expects (--allow dropped,--allow dropped.ring). An unknown kind or code, a missing value, or--allowwithout--strictis refused with status 2 before anything runs.The registry in
rustgis_data::lossnow declares each code once, which generatesLossCode::ALL,from_idandspec. The command line guide has a table of every code, and a test fails when the table and the registry disagree.The session keeps a count of loss notices per code (
Session::losses_given), so a strict run sees a loss even after the 200-notice queue has dropped it. A loss reported by a command that failed and rolled back is withdrawn from the count, as its notice is. One that had already left the queue stays counted, because the engine no longer knows whether it described a committed write. That errs towards failing a strict run.This is an optional flag whose absence keeps today's behaviour (any maintainer). It reaches the command line only. The desktop, browser and phone show the same notices as before. Python and MCP get the codes in the next step of #2371. Losses that don't have a code yet don't stop a strict run, and the guide says so.
Memory: the count holds one entry per code that has occurred, independent of layer size.
Testing
layer.addDatawithdropped.ring. The next command doesn't run and the project isn't saved.--allow dropped.ringand--allow droppedlet it finish,--allow changeddoesn't, and clean input passes. A Calculate Field truncation stops the run afteredit.calculateField. A script whose WMS layer drops an oversized legend and then fails exits with status 3, reporting both the failure anddropped.legend. Bad--allowvalues exit with status 2.losses_givencounts a loss after the queue has dropped its notice, and a rolled-back loss is withdrawn.-D warnings) on data, engine and CLI; enginewasm32check.Related issue
Part of #2371.
Summary by CodeRabbit
--stricttorustgis-cli run. It stops the run after a command reports an unallowed data loss, skips subsequent commands and the final save, and exits with status 3.--allowoptions to permit specific loss codes or entire loss categories. Without--strict, run behavior is unchanged.