Skip to content

test(engine): the cancel tests run every read made ahead, from one registry - #2662

Merged
Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:test/read-ahead-registry
Nov 22, 2026
Merged

Mavrick-F merged 2 commits into
opengeos:mainfrom
Mavrick-F:test/read-ahead-registry

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

The cancel tests covered only the read-ahead commands someone remembered to add. AGENTS.md said read-ahead commands have "no registry: add its call to long_commands by hand", and eight never got added: Load All Features, Convert To Annotation, Reload Data, Run Model, the tile archive reload and repair, the Error Inspector and Source File State. These commands are now listed in one place, and the test fails when one of them is missing.

  • One registry. reads::IN_BACKGROUND lists every command read ahead, with the name its progress shows. reads::prepare and the admission check in policy/dispatch.rs both read it. Before, each had its own copy of the id list and its own hand-written error naming the commands, and those copies drifted apart.
  • Opt-out coverage. long_commands records every command it runs as a read. It then checks that set against the registry plus edit::TABLE_EDITS, and fails unless each command is run or listed in its exemptions with a reason. The exemption list is empty: all eight missing commands now run in both cancel tests.
  • One small fix the test found. When a model or script runs on the copy, the check between its tools read the Cancel flag without counting the look. So the first-check test saw a run that stopped at Cancel but never looked at it. That check now goes through the counting probe the work's own checks use. This changes nothing for an ordinary control.
  • cmd::tiles::NETWORK removed. Only three tests read this list. Plugins and the policy use each command's declared Effect::Network (with per-call additions in policy/effects.rs), and every id on the list already declares it, except map.body, whose network reach is decided per call there (it fetches unless basemap is false). Removing the list changes no permission: nothing but the tests read it. The three tests now check the declaration, so a new network command no longer needs adding to a second list. The last two ids added to it, stac.addBands and stac.addIndex in chore(sweep): data fixes from the release quality pass #2648, already declared Effect::Network.
  • AGENTS.md's "Never hold the window" line about read-ahead commands now names the registry.

This addresses part of #2641 (the read-ahead commands missing from long_commands). It doesn't change how a plugin call is found to reach files: the special cases by command id in policy/effects.rs are the open design in #1316, and they are left as they are.

Reach: this is registry and test plumbing in rustgis-engine. The desktop app, CLI, Python and the phone dispatch through the same read_ahead, and what each command does is unchanged. In the browser, each command prepares the same work as before (none for the desktop-only reads). The ribbon, shortcuts, command search, Assistant, MCP and plugins see no new command or parameter. Nothing new is saved, so there is nothing to undo or reopen. It adds no copy of layer data.

Testing

  • cargo fmt --all --check, cargo clippy -p rustgis-engine --all-targets -D warnings, cargo check -p rustgis-engine --target wasm32-unknown-unknown with -D warnings
  • cargo test -p rustgis-engine --lib: 2036 passed. Both cancel tests run the eight newly covered commands.
  • Rebased over fix(engine): honor row policies and prepare Similar in background #2480, which added data.similar to the hand-kept lists: it is now one registry entry, run by both cancel tests. The registry check is made in the first-check pass, which reaches every read; the boundary sweep leaves out service.add and edit.previewShapeConversion. Both cancel tests pass on the rebased head, and the fork's CI passed on it.
  • Removing one of the new calls (source.syncState) makes long_commands_stop_when_cancelled_while_they_run fail, naming the missing command. Without the gp.rs change, the same test fails on model.run with "didn't reach Cancel".
  • Full CI on the fork.

UI evidence

No visible UI change.

Related issue

Part of #2641.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change centralizes background-read eligibility and progress names in a registry, updates cancellation coverage to check against it, and replaces network-command list assertions with checks against the session registry.

Changes: Background Read Preparation

Layer / File(s) Summary
Registry-backed read preparation
crates/engine/src/cmd/reads.rs, crates/engine/src/policy/dispatch.rs
The registry supplies progress names and eligibility for read preparation and dispatch. Unsupported commands receive a command-specific error.
Cancellation checks and read coverage
crates/engine/src/cmd/gp.rs, crates/engine/src/tests/cancellation.rs, AGENTS.md
The pre-run check uses Probe::cancelled. Cancellation tests record exercised reads and compare them with registered background reads and table edits. The instructions describe the coverage requirement.

Network Effect Registry

Layer / File(s) Summary
Network effect assertions
crates/engine/src/cmd/tiles.rs, crates/engine/src/tests.rs
The public NETWORK command list is removed. Tests check network effects through the session registry.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Possibly related issues

Possibly related PRs

  • opengeos/RustGIS#1670: Both PRs modify the cancellation test; this PR expands its read-command coverage and updates network-effect assertions.

Suggested reviewers: giswqs, robmarkcole

Merge Risk: Minimal · up to 89008

This is internal engine registry and test plumbing and does not change command behavior. I found no concrete merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the cancel tests now run every read-ahead command, using one registry. The changeset adds a registry (reads::IN_BACKGROUND), extends long_commands coverage, and remove…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description covers the main change: a single registry (reads::IN_BACKGROUND) for read-ahead commands, opt-out coverage checks in long_commands, a cancellation-probe fix in gp.rs, and removal of cm…
Full details: Title check

Explanation

The title names the main change: the cancel tests now run every read-ahead command, using one registry. The changeset adds a registry (reads::IN_BACKGROUND), extends long_commands coverage, and removes cmd::tiles::NETWORK. The title is specific and matches the primary intent, and it follows the conventional commit style.

Full details: Description check

Explanation

The description covers the main change: a single registry (reads::IN_BACKGROUND) for read-ahead commands, opt-out coverage checks in long_commands, a cancellation-probe fix in gp.rs, and removal of cmd::tiles::NETWORK. It lists the testing done (fmt, clippy, wasm check, 2036 lib tests, mutation checks) and states no visible UI change. It also names the related issue, Part of #2641. Every template section is present and filled in, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each read in flight,
And tracks its name from morn to night.
A progress probe can spot “cancel,”
While tables join the tested panel.
The network list now rests away,
Registry checks hop through the day.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 74e382c6-c924-486e-b189-40e038e9c514
Commits

Reviewing files that changed from the base of the PR and between 4032491 and 89008c7.

Files selected for processing: 5

  • AGENTS.md
  • crates/engine/src/cmd/gp.rs
  • crates/engine/src/cmd/reads.rs
  • crates/engine/src/policy/dispatch.rs
  • crates/engine/src/tests/cancellation.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Comment thread crates/engine/src/tests/cancellation.rs Outdated
// The Add Service dialog replays supplied metadata off the desktop frame too.
let params = json!({"url":"https://maps.example.org/dataset","type":"ogcapi","text":"{\"collections\":[]}"});
for command in ["service.layers", "service.add"] {
covered.borrow_mut().insert(command);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low severity, test accuracy. This marks service.add as covered before the if !boundaries || … that skips it in the boundary sweep. The same happens for edit.previewShapeConversion a few lines down. The coverage assertion at the end runs in both modes, so the boundary pass only passes because these names were marked there without running. The first-check pass does run both, so the guard still works, but the boundary pass isn't checking what the comment says it checks. A clean fix would be to assert coverage only when !boundaries, or to track coverage per mode. I'm not suggesting a one-line change because that restructures the assertion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 89008c7: a read is marked as run only where it runs, and the registry check belongs to the first-check pass, which reaches every read. The boundary sweep no longer claims the two it leaves out.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

I found no bugs or security issues in the changed code. The PR is test plumbing: it moves the read-ahead id lists into one registry, removes the unused tiles::NETWORK list, and makes one tool start check count as a look at Cancel. I checked Probe::cancelled on Control, the pmtiles API used by the new fixture, the effects registry lookup, and the fixture names. Nothing in the diff breaks those.

I did not run the tests or the wasm build. I had no shell, so hostile_params_never_panic, the cancel tests, and the long_commands coverage assertion are unverified.

Bugs: none found.

Security: none found. The rewritten capture_read error echoes the caller's command id. That is bounded and matches the other engine errors, so I'm not raising it.

Performance: none found. The one changed hot path, the tool start check in gp.rs, only counts a look in test builds. In production looked_at returns the same flag as before. (confidence: high)

Quality:

  • Test accuracy (low, inline posted at crates/engine/src/tests/cancellation.rs:174): service.add and edit.previewShapeConversion are marked covered before the boundary-mode skip. The first-check pass still covers them, so the guard works, but the boundary pass's coverage claim is overstated. (confidence: high)
  • Outside the diff (medium): crates/ui-egui/src/readjob.rs:529–539 keeps a third hard-coded list of read-ahead ids for the spawn-failure path. It is not fed from reads::IN_BACKGROUND and omits nine of its seventeen entries. The PR body says copies drifted and this one was left out. Also, for unlisted reads a failed spawn falls through to run on the UI thread (ahead.run near line 558), which conflicts with "never hold the window". This predates the PR, so it is a follow-up rather than a blocker.
  • Nits, grouped: the comment in gp.rs:2837–2838 is hard to read ("as the work's own are"). The removed NETWORK list also dropped its explanatory comments about sign-ins; the effects declarations still carry the behaviour.

AGENTS.md: the updated "Never hold the window" line matches the new registry, and the PR updates the rule as the guidelines require. Changed-surface reach is described in the PR body. I checked the wasm-only and desktop-only branches in reads.rs: the new registry and helpers are used on both targets, so there is no new dead code.

Prior reviews: there were no existing threads on this PR, so nothing was left alone as already raised.

Change size

Compared with the base branch (merge base 9ac6068 to PR head 4032491), across the whole PR.

Measure Value
Files changed 7 (added 0, modified 7, removed 0, renamed 0)
Size before 3.81 MB
Size after 3.81 MB
Total size change +2.0 KB
Path Before After Change
crates/engine/src/tests.rs 3.31 MB 3.31 MB +190 B
crates/engine/src/tests/cancellation.rs 34.0 KB 37.0 KB +2.9 KB
crates/engine/src/cmd/tiles.rs 60.5 KB 59.0 KB −1.5 KB
crates/engine/src/cmd/reads.rs 17.3 KB 18.3 KB +1.0 KB
crates/engine/src/policy/dispatch.rs 65.6 KB 64.7 KB −885 B
crates/engine/src/cmd/gp.rs 322.3 KB 322.5 KB +201 B
AGENTS.md 13.8 KB 13.8 KB +26 B

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-2662/
Web app https://preview.rustgis.app/pr-2662/app/
Commit 89008c7

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 preview label (once per commit).

…gistry

The commands the desktop app reads ahead on a thread of its own were named
in three hand-kept places (the reads::prepare match, the admission check in
dispatch.rs and long_commands), and long_commands had fallen behind: Load
All, Convert To Annotation, Reload Data, Run Model, the tile archive reload
and repair, the Error Inspector and Source File State were never run under
Cancel. They are now listed once, in reads::IN_BACKGROUND, which prepare
and admission both read; long_commands fails unless it runs every one there
(and every table edit) or names why it doesn't in its exemptions.

All eight now run in both cancel tests. A model's tool looked at Cancel
between steps without counting the look, so the first-check test saw a
cancelled run that never looked; that check now counts, like the work's
own checks.

cmd::tiles::NETWORK, a list of network commands nothing but three tests
read, is removed: each command's declared effects (Effect::Network) are
what the policy uses, and those tests now check them.
…runs

The boundary sweep marked service.add and edit.previewShapeConversion as run though it leaves
them out, so the registry check passed there without them. The check now belongs to the
first-check pass, which reaches every read.
@Mavrick-F
Mavrick-F force-pushed the test/read-ahead-registry branch from 4032491 to 89008c7 Compare November 22, 2026 08:17
"copernicus.login",
];

/// Registers commands for tile-layer sources, drawing properties, coverage and celestial bodies.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description says every id on the removed NETWORK list already declares Effect::Network, and that doesn't hold for map.body. It was on the list, but it is declared with .effects(crate::policy::Effects::NONE) (crates/engine/src/cmd/tiles.rs:42). map.body switches the basemap to remote planetary tiles, so the map fetches from the network when drawn. A plugin without the network permission could therefore run it. The fixed host list limits the exposure, and I haven't traced every path, so my confidence is medium. Either declare Effect::Network on map.body, or say in the PR why it is not a network command.

Category: security

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No permission changes. On main the removed list is read only by three tests; a plugin call's effects come from policy::command_effects, which gives map.body Effect::Network per call unless basemap is false (policy/effects.rs:57). The description overstated it and is corrected: every id but map.body declares the effect on its spec.

) && crate::cmd::edit::table_edit_in_background(command).is_none()
{
return Err("only Add Data, Load All, Repair/Reload Data, Convert To Annotation, models, scripts, tile archives, service reads, topology, Source File State, Read Original Image Grid, Preview Shape Conversion, Column Statistics, Similar and Size by Field prepare background work".into());
if crate::cmd::reads::in_background(command).is_none() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The registry isn't the only copy of these ids. start_scoped_archive_read still has its own hardcoded list of eight ids and its own error text (dispatch.rs:129-143). Its error text also still lists different commands from the new message. The names are duplicated as well: reads::IN_BACKGROUND and about a dozen reads::ahead("…") constructors (for example repair.rs:208, publish.rs:198, layer.rs:4452) each hardcode a progress name. The work's own name wins whenever work exists, so a drift between them would go unnoticed. Consider having the scoped path check in_background as well, and taking the name from the registry, or a test that the two names match. Confidence high.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scoped list names a different property (which reads may start scoped), and the description lists it among the lists left alone. Checking it against the registry and taking the progress names from one place are left for the release quality pass.

let control = current.as_ref().unwrap_or(control);
let t0 = now_ms();
if control.is_cancelled() {
// A look at Cancel as the work's own are (counted for a test's control): a model's or script's

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, grouped: the comment reads "A look at Cancel as the work's own are", which is hard to parse. "As the work's own checks are" would say it. The new not_in_background message (reads.rs:252) is also much less helpful than the old one, which listed the commands that do prepare background work. The behaviour change is fine: in production looked_at counts only for a test control, so the pre-start check behaves as before.

Category: quality

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left for the release quality pass: the comment's wording, and naming the commands in the refusal.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. I checked the gp.rs Probe change: in production looked_at only counts under a test control, so the pre-start check behaves as before. The new cancellation.rs coverage asserts are set-equal against IN_BACKGROUND plus TABLE_EDITS in the first-check pass, and every registry entry has a matching prepare arm.

Security:

  • map.body was on the removed NETWORK list but declares no Effect::Network (crates/engine/src/cmd/tiles.rs:42). It switches the basemap to remote planetary tiles, so a plugin without network permission could trigger a fetch. The PR says every removed id declares Network, which is false here. Exposure looks limited because the hosts are fixed. Confidence: medium. Inline comment posted.

Performance: None found.

Quality:

  • Unification is incomplete. start_scoped_archive_read (crates/engine/src/policy/dispatch.rs:129-143) keeps its own hardcoded list of eight ids and its own error text. Progress names are still hardcoded in about a dozen reads::ahead("…") constructors, and the work's name overrides the registry's. Confidence: high. Inline comment posted.
  • Nits, grouped in one inline comment on gp.rs:2895: an unclear comment, and a less helpful not_in_background message.

AGENTS.md: No breaks found. The AGENTS.md update matches the code.

Already raised, left alone: 1. The prior thread on the boundary sweep marking service.add and edit.previewShapeConversion as covered was answered by the author in 89008c7, and the code now matches that answer.

Change size

Compared: the whole PR against main (merge base 35abb81 to PR head 89008c7).

Measure Value
Files changed 7 (0 added, 7 modified, 0 removed, 0 renamed)
Size before 3.9 MB
Size after 3.9 MB
Total size change +1.9 KB
Path Before After Change
crates/engine/src/tests/cancellation.rs 34.0 KB 36.8 KB +2.8 KB
crates/engine/src/cmd/tiles.rs 60.5 KB 59.0 KB −1.5 KB
crates/engine/src/cmd/reads.rs 17.6 KB 18.7 KB +1.1 KB
crates/engine/src/policy/dispatch.rs 67.0 KB 66.1 KB −0.9 KB
crates/engine/src/cmd/gp.rs 325.6 KB 325.8 KB +0.2 KB
crates/engine/src/tests.rs 3.35 MB 3.35 MB +0.2 KB
AGENTS.md 14.2 KB 14.2 KB +10 B

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 22, 2026
Merged via the queue into opengeos:main with commit 0b55b34 Nov 22, 2026
28 checks passed
@Mavrick-F
Mavrick-F deleted the test/read-ahead-registry branch November 22, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant