Repository navigation
refactor(data): loss codes travel with reader, source and export notes (#2371) - #2757
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| } | ||
|
|
||
| /// Their words alone, for a consumer that shows text only. | ||
| pub fn texts(&self) -> impl Iterator<Item = &str> { |
There was a problem hiding this comment.
Notes::texts() (and into_vec() at line 250, plus Note::as_str() at line 132) hand the words out without their loss codes. The type docs say a code can't be dropped by formatting the note and that a hop that would drop it fails to build, which overstates things: these are escape hatches. Today the callers that use them are text-only sinks (Wrote::completion_notes in cmd/exports.rs, the archive manifest in cmd/field.rs), so nothing is lost now, but a future producer that routes a coded note through one of them would silently lose its code. Suggest making the doc say so, and naming these as text-only sinks where they're used.
Category: quality
There was a problem hiding this comment.
Fixed in 51ef05b: the Note docs now say formatting or passing a note on as text keeps its code, and that text, as_str and texts give the words alone, for sinks that show or store text only, such as a manifest or a refusal message.
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { |
There was a problem hiding this comment.
The new Note and Notes types carry the core invariants of this PR (plain and coded notes never compare equal to a plain string, says matches wording only, prefixed keeps the code, the From/FromIterator/Extend conversions keep codes), but nothing in this test module checks them directly. They are only exercised indirectly through readers and the map test. A few unit tests here would pin the behaviour the rest of the PR depends on, and would catch a regression in PartialEq or prefixed without needing a reader fixture.
Category: quality
There was a problem hiding this comment.
Added in 51ef05b: notes_keep_their_codes checks plain and coded equality with strings, prefixed and map_text, collecting and extending, says, and From<Vec<String>>.
Code reviewI found no bugs, security problems or performance problems in the changed lines. I checked the call sites that carry the new Bugs
Security
Performance
Quality
AGENTS.md
PR description accuracy
Change sizeCompared with
|
📖 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 |
opengeos#2371) A reader's, a source's and an export's notes are now Notes: each a Note holding its text and, when it reports a loss, its code, so a code put on a note reaches the notice that says it however many hops it takes. A Note has no Display and turns into no String, so a hop that would drop its code fails to build; the engine says one with Session::say. ReadReport.losses folds into ReadReport.messages. Nothing reports a new code yet: the readers and writers move to codes in the batches that follow.
… notes keep their codes
88e5fef to
51ef05b
Compare
| @@ -6885,10 +6883,7 @@ pub(crate) fn add_read( | |||
| ds.name = n.to_string(); | |||
| } | |||
| for m in report.messages { | |||
There was a problem hiding this comment.
The PR body says notices keep "the same text, order, severity", but this loop changes order. Before, add_read said all of report.messages and then all of report.losses (notify_loss). Now coded and plain notes are said in the order they were pushed, so a reader that pushes a coded note before plain ones shows it earlier than before.
No current producer hits this: georss pushes its only coded note last in its report. The same change to ordering applies to the gp.rs batch reader loop and to the add_picked file-wide merge (kept.report.messages.extend(said.messages)), where a layer's coded note can now precede a file-wide plain one. Either correct the PR text to say that order matches only for today's producers, or keep the two groups separate in the shared list.
Category: quality
There was a problem hiding this comment.
Right: coded and plain notes are now said in the order the reader gave them. That is unchanged for every producer today, since GeoRSS gives its coded note last. I have corrected the PR text to say that order matches for today's producers.
| @@ -2833,7 +2833,6 @@ fn add_picked( | |||
| for (source, said) in file_wide { | |||
| if let Some(kept) = reads.iter_mut().find(|r| r.dataset.source == source) { | |||
| kept.report.messages.extend(said.messages); | |||
There was a problem hiding this comment.
The drain at line 2825 (said.messages.drain(..usize::from(r.dataset.zm_dropped)…), outside this diff hunk) assumes the layer's zm note is the first entry of report.messages. Before this PR that held because messages was plain text only; coded losses sat in the separate losses vector. Now messages holds coded notes too, so if a reader with zm_dropped set pushes a coded note before its zm note, the drain removes the coded loss notice and keeps the zm note. That is a silently dropped data-loss notice.
Nothing reachable today triggers it: the only coded producer in this diff is georss.rs, which never sets zm_dropped. The position-based assumption is still fragile after this change. Suggest removing the zm note by its text (crate::zm_note(...)) rather than by position, or only draining plain notes, so coded notes are never removed. This line merges the same list, so the fix belongs with the drain.
Category: bug
There was a problem hiding this comment.
Fixed in b2b8010: the file-wide drain takes the leading note only when it is plain, so a note that reports a loss is never removed in its place. The Z/M batch that follows will remove the Z/M note by its code.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Checked and found correct
Prior reviews
Inline comments posted: 2 (one bug, one quality). Change sizeCompared with the base branch: the whole PR against main (merge base 12ffc6c to head 51ef05b).
|
| && let Some(generic) = rustgis_data::zm_export_note([ds], file) | ||
| { | ||
| notes.retain(|note| note != &generic); | ||
| notes.retain(|note| note.text != generic); |
There was a problem hiding this comment.
This removes any note whose words equal the generic Z/M warning, whatever its code. That is the wording-only matching this PR otherwise avoids (a coded note is not folded into a plain one that reads the same). Nothing reaches it with a coded note today: every caller passes only the plain export_notes output, so this is latent, not a current loss. A coded note with the same wording would still be dropped if a producer ever sets a code on it. Keeping coded notes costs nothing:
| notes.retain(|note| note.text != generic); | |
| notes.retain(|note| note.loss.is_some() || note.text != generic); |
Confidence: high that the logic is as described; low that it matters before a producer codes a Z/M-worded note.
Category: quality
There was a problem hiding this comment.
Every caller passes plain export_notes output today. The Z/M batch that follows codes the generic note and compares notes whole, code included, which removes this wording-only match. Left for the release quality pass.
Code reviewScope: the whole PR (69 files, +653/−292 lines), read against Bugs
Security
Performance
Quality
AGENTS.md
Concerns already raised (left alone)Four earlier threads are on this PR. I did not re-post any of them:
Earlier concerns left alone: 4. Confidence overall: moderate-high that there is no blocking defect. I read the code but did not compile or run the tests here. Change sizeCompared with
Largest changes:
|
Summary
Loss codes now travel with the text that reports them, through every hop a reader's, a source's or an export's notes take to the notice. The remaining step of #2371, giving the losses still reported as plain text their codes, then needs one change at each producer instead of new plumbing at each hop.
rustgis_data::lossaddsNote(the text, and the loss code when it reports one) andNotes(a list of them that still takes plain text, sopush(format!(…))keeps working). These now carryNotes:ReadReport.messages: the separateReadReport.lossesfrom feat(engine): carry loss codes through reader and tool results #2479 folds into it;SourceInfo.notes, a view read'sBatch.notesand a GDAL conversion's notes;Unreadable.messages, and a streamed layer's view-read and conversion notes;Wrote.notes), a field package's, an item's, and a search area's.A
Notehas noDisplayand turns into noString. A hop that would drop its code by formatting it or passing it on as text fails to build. The engine says a note withSession::say: one that reports a loss as that loss, with its code, and any other as before. Matching keeps the distinction too. A plain note equals its text; a note with a code equals no plain string; andNotes::saysmatches by wording alone.Nothing reports a new code yet, so no notice changes: the same text, severity and written-file retention, and the same order for every producer today. A reader's coded and plain notes are now said in the order it gave them, where coded ones used to follow the rest; GeoRSS, the only reader with one, gives it last. GeoRSS's
dropped.ringand the other codes from #2467 and #2479 reach their notices as before. Two things that would have dropped a code once producers set them are handled here:Still plain text, and changed with the producers that will put codes on them:
export_notesandexport_losses_notes;lossesfrom feat(engine): carry loss codes through reader and tool results #2479 for now.Memory: a note grows by one optional code beside its text; no layer data is held or copied.
This reaches every surface the notices do (desktop, browser, phone, command line, Python, MCP and the Assistant) with no change to what they show.
Testing
-D warnings) across the workspace, and the browser build (wasm32).UI evidence
No visible UI change.
Related issue
Part of #2371.
Summary by CodeRabbit