Repository navigation
feat(engine): carry loss codes through reader and tool results - #2479
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| const NAMED: usize = 50; | ||
| let classified = distinct_tool_messages.iter().filter_map(|(text, code, count)| Some((text, (*code)?, count))); | ||
| let listed = classified.clone().take(NAMED); | ||
| for (text, code, count) in listed { |
There was a problem hiding this comment.
Batch loss notices are no longer aggregated by kind. Before this change, every tool message in a batch went into one gp.batch: N item(s) reported messages (…) notice. Now each distinct loss text gets its own Warning notice, up to 50, and the text usually embeds a per-item count (for example the features(tally.extra) figure in Repair Geometry). A batch over many layers with varying counts can therefore produce dozens of notices.
AGENTS.md asks for "one notice per kind with a count". Consider aggregating by code, for example one gp.batch: N item(s) lost <kind>: … notice per LossCode, with the sample and the "and N more, in the result" tail as the plain-message notice already does. Confidence: medium. I have not run a batch with varying counts to confirm the notice count.
There was a problem hiding this comment.
Batch runs now emit one warning per loss code with a count and up to three examples. Full messages remain in the result. The expanded regression exercises different counts for the same code in one batch. It passed locally, and fork CI passed. fad00b6
| pub struct ToolResult { | ||
| pub output: Output, | ||
| pub messages: Vec<String>, | ||
| /// Losses identified by the producer. Text-only consumers also display their text. |
There was a problem hiding this comment.
This doc comment says text-only consumers "also display their text", but the producers this PR changes don't follow that contract. Repair Geometry now puts its extra-attributes text only in losses, not in messages. The engine merges the two, so the desktop, CLI and Python paths are fine. Any direct analysis::run caller that reads only messages now silently loses that notice, which AGENTS.md's "Never silent" rule forbids.
Suggest stating the contract exactly, for example: "messages holds text only; a producer with a classified loss puts it in losses and not in messages, so a consumer reads both." Alternatively, keep the text in messages too and dedupe in the engine. Confidence: low to medium; it depends on whether any non-engine consumer reads messages alone today. My search found none outside tests.
There was a problem hiding this comment.
The field docs now say that classified losses appear in the losses list only, and that consumers displaying plain text must read both lists. The engine still retains both in history and delivery results. Fork CI passed. fad00b6
Code reviewI read the full diff, the base-branch AGENTS.md, and the surrounding code. Bugs
Security
Performance
Quality
AGENTS.md
Earlier concerns left alone: 0 (no prior threads). I could not compile or run the tests in this environment, so the findings above rest on reading the code. Change sizeCompared with
The table lists the 20 largest changes. The other six files changed by under 20 bytes each. |
📖 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 |
|
The two inline findings are addressed in the fix commit. On failed file delivery, the report retains the error and the loss text. A coded delivery loss describes a file that reached its destination. The constructor and cfg-binding suggestions are left for the release quality pass. fad00b6 |
| assert!(lossy[0].0.features[0].geometry.is_some()); | ||
| assert!( | ||
| lossy[0].1.messages.iter().any(|m| m.contains("1 hole in a polygon was unreadable and left out")), | ||
| lossy[0].1.losses.iter().any(|m| m.code == crate::loss::LossCode::DroppedRing && m.text.contains("1 hole in a polygon was unreadable and left out")), |
There was a problem hiding this comment.
This line is 141+ characters, and the repo's rustfmt.toml sets max_width = 140, so cargo fmt --check (part of cargo xtask ci) will fail on it. Splitting the closure body keeps the same assertion:
| lossy[0].1.losses.iter().any(|m| m.code == crate::loss::LossCode::DroppedRing && m.text.contains("1 hole in a polygon was unreadable and left out")), | |
| lossy[0].1.losses.iter().any(|m| { | |
| m.code == crate::loss::LossCode::DroppedRing && m.text.contains("1 hole in a polygon was unreadable and left out") | |
| }), |
Confidence: high (line length measured from the diff).
There was a problem hiding this comment.
The formatting hook passed on this exact head in fork and upstream CI. Splitting the assertion for readability is left for the release quality pass.
| return Err(format!("{path} has more than {} features: simplify it or use a bounding box", area::MAX_FEATURES)); | ||
| } | ||
| let mut messages: Vec<String> = report.messages.into_iter().map(|m| format!("{path}: {m}")).collect(); | ||
| let mut messages: Vec<String> = report.into_messages().map(|m| format!("{path}: {m}")).collect(); |
There was a problem hiding this comment.
into_messages() turns a classified dropped.ring loss from a GeoRSS hole back into plain text, and from_file then calls s.warn(m). The STAC search-area path therefore reports the loss without its code, so a scheduled job checking codes won't see it. The text is kept, so nothing is silent, but the classification this PR adds is lost on this path. The same gap applies to a file read as a tool input through inputs_of, which this PR also covers.
Suggest carrying Vec<LossMessage> (or (String, Option<LossCode>)) out of read_geometries and publishing coded losses through s.notify_loss in from_file, so the code survives. Confidence: medium. I did not find a test for the STAC path or for a file-input tool loss.
There was a problem hiding this comment.
STAC uses read_path, which does not accept GeoRSS. ZIP members use read_bytes, which also does not accept GeoRSS. The classified producer reaches Add Data via read_layers. The tool input adapter already transfers report.losses into the tool result. Carrying codes on the STAC path when it gains a classified producer is left for the release quality pass.
| #[cfg(target_arch = "wasm32")] | ||
| { | ||
| let msgs = result.messages.clone(); | ||
| let msgs = result.messages.iter().cloned().map(|m| (m, None)).collect(); |
There was a problem hiding this comment.
On the queued path (browser, and tests with queue_gp_files), the returned msgs drop result.losses and keep only the plain messages. A batch running a file-output tool therefore never sees those losses, so BatchLosses can't aggregate them. The losses are published one at a time later, in file_delivered, which is the per-item behaviour this PR removes for batches. The same thing happens at the test-only branch on line 2895.
No tool that produces losses today has a file output on this path, so this is latent. Still, the returned messages should be built the same way as the native path (plain messages plus coded losses, around line 3003), so the batch aggregator sees them. Confidence: medium on the fix, low on whether a user can hit it today.
There was a problem hiding this comment.
A queued result has not reached its destination. Its typed losses are retained with the pending file and published on successful delivery. Returning them to the batch early would report them before delivery and can report them again at delivery. No file-output tool currently produces coded losses. Grouping successful queued deliveries can be revisited with the first such producer and is left for the release quality pass.
Code reviewBugs
Security
Performance
Quality
AGENTS.md
Earlier concerns
Change sizeCompared with
The table lists the 20 largest changes. The remaining 6 files changed by under 20 B each. |
|
The inline replies cover formatting, STAC and queued output. A failed delivery retains the diagnostic text and has no committed file loss to report. The constructor, batch prefix, cfg binding, and future source and file-output coverage suggestions are left for the release quality pass. |
Summary
Carry typed loss messages from readers and geoprocessing tools into the engine. GeoRSS classifies unreadable polygon holes as
dropped.ring. Repair Geometry classifies attribute values with no matching field asdropped.extra-attributes.Batch messages retain their codes for warnings, and tool history and delivery results retain the text. The WMS regression now checks the legend warning text as well as its code and severity.
The shared engine supplies the notices on desktop, browser, mobile, CLI, Python, MCP and Assistant. Public code fields for the automation adapters and strict mode remain part of #2371.
Testing
UI evidence
Before — The GeoRSS import reported the unreadable hole under Info.
After — The same message appears under Warnings.
Related issue
Part of #2371. Follow-up to #2467.
Summary by CodeRabbit