Repository navigation
fix(engine): a saved step that opens a project from its text requires what the project requires - #3608
Conversation
… what the project requires (opengeos#3462) Each capability's check decided on its own whether to read the text of a project.openText or project.fromTemplate step, and 45 of 51 never did, so a task, model or script could open a project using a setting an older release doesn't know and save the rest without a word. The text is now read once per step, as the project is read without repair, and the project's own capabilities are added to the step's, down to 32 projects deep. The eight checks that did read a project's text for these two commands no longer do: each read the project again, and a project opening a project that opens one cost about three times more at every level (31 s at 680 KB, 357 s at 2.7 MB). It is now 7 ms and 21 ms. Part of opengeos#3476
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewScope: 3 files, +246/−99 lines. I read the diff, the surrounding Bugs
Security
Performance
Quality
AGENTS.md
Twins checked
Change sizeCompared: the whole PR against main (merge base a458559 to PR head c06b661).
|
📖 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 |
Code reviewInline comments are on Bugs
Security
Quality
AGENTS.md
Twins checked
Earlier concerns: none. The review thread list for this PR was empty. Change sizeCompared with
|
…tep (opengeos#3462) Two steps opening the same zip of a template, which deflate stores once, branched at every level of the nest, so a small file made the walk read about k^depth projects. What each text required is now kept for the walk, by its depth, length and hash.
Code reviewI read the diff, the staged AGENTS.md, the prior threads and the changed code in context. I could not run the tests, clippy or the wasm build (no shell here), so everything below comes from reading the code. Bugs
Security
Performance
Quality
AGENTS.md
Earlier concerns I left alone
Change sizeCompared with the base branch (merge base a458559 to PR head 0671cfc).
|
… it (opengeos#3462) Two texts of the same length and depth whose 64-bit digests collide shared one entry, so one could inherit the other's capabilities. The cache is now keyed by the depth and the text itself.
Code reviewI read the diff, the staged AGENTS.md, the prior review threads, and the surrounding engine code. I could not build or run the tests here (no shell), so the findings below rest on reading the code. Bugs: none new. I checked the walk for re-entrant Security: none. Nothing new is parsed beyond what Performance (1, medium confidence, inline):
Quality (1, low severity, inline):
AGENTS.md: none. Surfaces are covered in the PR body. The change touches no command ids or parameters, so the command-surface snapshot is unaffected. The Twins checked:
Already raised, left alone (3 threads):
Change sizeCompared: the whole PR against main (merge base a458559 to PR head cbc1e15).
|
…e is per depth (opengeos#3462) A hit in the walk's cache copied the whole opened text first, since the key was built before the lookup. It is now keyed by depth and then the text, looked up borrowed and copied on insert only. The docs say a text is read once at each depth, which is what the cache does.
…thing past the depth limit (opengeos#3462) The walk kept every decoded text until it ended, so steps opening zips that inflate to a gigabyte held that much on every save. It keeps a SHA-256 of the step's text or data now, looked up before anything is decoded. Past 32 levels a step that opens a text requires every capability a release knows, so an older release refuses it instead of dropping what it can't see.
Code reviewScope: The PR makes BugsNone found. What I checked and ruled out:
SecurityNone found. The walk is depth-bounded (32), the per-walk cache is keyed by a SHA-256 of the source, and it never panics on junk parameters. Performance
Quality
AGENTS.mdNo breaks found.
Prior reviewsFive earlier threads are on this PR. I left all five alone:
Change sizeCompared with the base branch (merge base a458559 to PR head afbc88f), across the whole PR.
|
…pth limit requires (opengeos#3462)
Code reviewScope: 3 files: Bugs
Security
Performance
Quality
AGENTS.md
Prior review threads
Change sizeCompared with the base branch (merge base a458559 to PR head ec71b52). Files changed: 3 (1 added, 2 modified, 0 removed, 0 renamed). Size before 4.16 MB (4,366,126 B), after 4.17 MB (4,377,040 B), change +10.7 KB (+10,914 B).
|
…pengeos#3462) The depth limit bounds the length of a chain of templates, not their size: 32 zips that each inflate to a gigabyte are tens of megabytes in the file. A walk counts the bytes of the texts it reads, and past what a project may hold a step that opens a text requires everything, as at the depth limit.
Code reviewI read the full diff, the base-branch AGENTS.md, and the prior review threads. I could not build or run the tests here (no shell), so the findings below come from reading the code. BugsNone new that I'd call a clear defect. Security
PerformanceNone new. The walk is now one pass, the cache is keyed by a digest, and decoded text isn't kept between steps. Quality
AGENTS.mdNone found. I checked:
Prior threads: 8 existed. I re-raised 1 (the byte budget), and left 7 alone because they are answered and the code matches the answer. Change sizeCompared with the base branch (merge base a458559 to PR head 06ac65c).
|
…#3462) The budget of bytes was checked after a template was inflated, so each later one was still inflated whole and only its parse was skipped. Once the budget is spent a text is not decoded: the step requires everything.
…eos#3462) A walk could read 512 MiB of opened texts, about two seconds on the calling thread at every save. The budget is a fixed 64 MiB now, a quarter of a second at the limit and the same on every computer.
Code reviewPR #3608 makes a saved step that opens a project from its text ( Bugs
Security
Performance
Quality
AGENTS.md
Earlier review threads: There are 21. I re-raised none verbatim. Two of my comments build on earlier threads and say what is new: the budget (the constant changed from the 512 MiB the thread discussed) and the 1 GiB decode (the earlier answer relied on Change sizeCompared with the base branch (the whole PR, merge base a458559 to PR head 779b473).
|
…pengeos#3462) inline_text_within bounded the base64 only, so a package was inflated up to 1 GiB before the walk's budget applied. The package is read within the limit it is given, and a template past it requires everything.
Code reviewI read the full diff, the staged PR metadata and prior review threads, and checked the walk against the surrounding code: Bugs
Security
Performance
Quality
AGENTS.md
I left 23 earlier threads alone. They are either answered by the author or already reflected in the current code, such as the 64 MiB budget, the fixed budget, the cache key, and the removed text checks. The stack-test point above is new evidence on an answered thread, not a repeat. Change sizeCompared: the whole PR against main (merge base a458559 to PR head 8742b0a).
|
…st reach the depth limit (opengeos#3462) The zip budget of the walk also cut what the other readers of inline_text take, so a package that inflated past the limit of the computer for a file but under the zip limit was refused inline and read by path. inline_text takes the inflation limit apart from the text's. The stack test moves next to the walk, with a budget no chain reaches, and asserts that a text was read at each depth. A very large limit no longer overflows.
Code reviewI found no new bugs in this pass. I posted one inline quality comment (the depth test's Bugs
Security
Performance
Quality
AGENTS.md
Twins and surfaces checked
Prior threads
Change sizeCompared: the whole PR against main (merge base a458559 to PR head f355ec4).
|
Code reviewI reviewed the saved-step walk in Bugs: none new. I checked the RefCell borrows in the walk and found no overlapping borrow. The zip budget refuses an oversized package rather than truncating it. Security: none. The walk parses saved text without reading any path, connection or reach. The #3530 test still covers this for the leaf checks, and the walk has no separate test for it. Confidence: medium-high. Performance: nothing new. The earlier thread on parsing each opened text on every save is still open and still applies. The author measured it and declined to gate it. I did not re-raise it, since the code it points at has not changed. Quality:
AGENTS.md: none found. No Twins checked:
Earlier concerns: there are about 26 earlier threads on this PR. I did not re-raise any of them. One thread on the test's Change sizeCompared with the base branch (merge base a458559 to PR head 17983bc).
|
Code reviewI read the full diff, the base What I checked
Bugs
Security
Performance
Quality
AGENTS.md
Verified by reading only: I did not build or run the tests. The PR reports Change sizeCompared: the whole PR against main (merge base a458559 to PR head 170e565).
|
Code reviewI read the PR diff, the staged metadata, and the surrounding code ( Bugs: None new. I checked the following and found them sound:
Security: None found. Performance:
Quality: None new. The earlier quality points are answered in the threads. AGENTS.md: None new. The walk's no-Cancel doc, the wasm and Twins checked:
Earlier concerns left alone: 28 review threads were already raised on this PR, and the author replied to each. I did not repeat them. Several were fixed in later commits, and the rest were answered with measurements or reasoning I could verify. Change sizeCompared against
|
…ng it (opengeos#3462) The SHA-256 of a step's source ran before the budget was looked at, so a text past the whole budget was hashed in full on every save. Its answer is known: it requires everything.
Code reviewI read the diff, the base-branch AGENTS.md and the 29 earlier review threads. I also checked the changed code against the call sites it touches: Bugs
Security
Performance
Quality
AGENTS.md
Prior concerns: 29 threads, 28 resolved and 1 open. I left the open one alone. I checked the fixes for the budget mismatch, zip inflation before the budget, the Change sizeCompared: the whole PR against main (merge base a458559 to PR head 7b2f5ef).
|
Summary
A saved step that opens a project from its text (
project.openText,project.fromTemplate) now requires every capability that project requires.Before, each capability's check decided on its own whether to read that text, and 45 of the 51 command checks never did. A task, model or script step could open a project that uses a setting an older release doesn't know (several extent indicators in a map frame, a colorbar's text size, a graticule colour, …). The saved outer project didn't require it, so the older release opened the step, dropped the setting and saved the rest without a word.
Project::from_peer_raw), and itsrequired_capabilities()are added to what the step already requires. Text that isn't a project requires nothing (except past the depth limit below).textthat holds a project escapes it, so only so much nests; adatatemplate (base64, a zip) isn't longer, hence the depth. A step that opens a project at that depth requires every capability a release knows, so an older release refuses it rather than dropping what it can't see. The same goes once a walk has read more bytes of opened texts than a fixed 64 MiB (the same on every computer, since what a project requires is saved in it, and small enough that a walk at the limit costs about a quarter of a second: reading a project costs about 4 ms per MB with real structure, 1 ms for a text-heavy one, measured 15 ms for 16 MB and 61 ms for 64 MB). Adatatemplate that can't be decoded requires everything too, so the limits of the computer saving the project don't change the header (one broken template makes older releases refuse the project, not just that step: deliberate, and the safe side), so a chain of templates that each inflate to a gigabyte can't make a save read them all. This bounds the walk of these two commands only: the checks that read a style, layer or map given inline still start again from the top when that text is a project, as they did before; that is for the PR of [Bug]: Inline styles, layers, maps, projects and templates with a label weight, clearance or duplicate setting don't require their capability #3589.Surfaces: saved tasks, models, scripts and notebooks of the desktop and web apps,
rustgis-cli, Python, the Assistant and MCP. Nothing visible changes; a project saved with such a step now carries more entries in itsrequiresheader, so an older release refuses it instead of dropping settings.Not in this PR (own PRs, same cause):
model.importandnotebook.open(#3476), and a style, layer or map given inline (#3589). A step that names a project file bypathisn't read here: a saved project file carries its ownrequiresheader, which an older release checks when it opens it.Testing
crates/engine/src/tests/capabilities_inline_project.rs, written first and seen failing (project.openTextoflayout_extent_indicators.rgiswithout its header required nothing):requiresheader, opened byproject.openTextandproject.fromTemplate(bytextand by base64data), in a recorded model step, a task step, a script line and a project's task, requires each capability of its header;project.openText,project.fromTemplate) now ask what a saved model step requires; their cases are unchanged, and the sample of aproject.fromTemplatethat requireslabel-obstaclesis covered by the fixtures test.the_deepest_chain_of_opened_projects_fits_a_small_stackbuilds a real chain of 33 base64 templates, each opening the next, and reads it, with a budget of bytes that no chain reaches so that the depth limit is what stops the walk (it checks that a text was read at each of the 32 depths), on a thread with 1 MiB of stack (Windows' main thread) in a debug build. Reading a project costs about 4 ms per MB (the 5.4 MB read in a 13-deep nest took 21 ms); what a walk keeps of what it read is a 64-byte digest per text, and the parsed projects of the levels it is inside of. Memory, measured on a chain of 3 base64 templates around a project with a 10 MB name (a 23 MB text, a debug build): the walk peaked 32 MB above what the opened project already held, about 1.4 times the text, in 64 ms. A text a project opens past the 64 MiB budget (a template embedding a raster of about 50 MB, say) makes the project require everything, so an older release refuses it: rare, and the safe side.cargo fmt --check, workspace-scoped clippy onrustgis-engine, doctests, the layering check andcargo xtask schema --checkpass.nextest: all ofrustgis-enginepasses; 8 failures are in other crates (7 inrustgis-geolibre, 1 in therustgis-ui-eguismoke tests) and fail the same onmainwithout this change.UI evidence
No visible UI change.
Related issue
Closes #3462
Part of #3476