Repository navigation
docs(agents): traps, not maps: shorter architecture, a surface checklist and a bar for new rules #2166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(agents): traps, not maps: shorter architecture, a surface checklist and a bar for new rules #2166
Changes from all commits
c8bd8d6
ceccae1
6493e25
4ac4b03
63675e3
33b2a6b
044b8c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -39,41 +39,38 @@ is out of scope. | |||||
| - The work looks at Cancel between items of its long loops (`control::check`, `Pace`, | ||||||
| `progress::check`) and counts its progress. Where progress can't be measured, a busy indicator | ||||||
| without a count is fine; Cancel is not optional. | ||||||
| - Work that splits into independent parts runs on several threads where practical: the same | ||||||
| output as one thread, bit for bit; one thread below a size threshold and in the browser; the | ||||||
| shared helpers (`parallel::for_each_row`, `try_map`, `try_map_on`); the thread count from | ||||||
| `rustgis_data::threads` (it follows the user's setting), never `available_parallelism` or a | ||||||
| fixed number; scratch memory within `memory::thread_scratch`; a thread the OS refuses costs | ||||||
| speed, not the run (`Builder::spawn_scoped`). | ||||||
| - A command that must run on the UI thread says why in its doc comment. | ||||||
| - `crates/engine/src/tests.rs::long_commands_stop_when_cancelled_while_they_run` cancels each | ||||||
| background command as its work starts and fails one that never looks; its lists must match the | ||||||
| background registries, so a new background command is added there. It also runs the long tools | ||||||
| (Buffer, Dissolve, Spatial Join, Clip, Erase, Intersect, Identity, Union, Symmetrical | ||||||
| Difference, Update, Split, Minimum Bounding Geometry, Kernel Density, Kriging); a new tool | ||||||
| whose work grows with its input is added to that list. Passing shows the work looks | ||||||
| at Cancel, not that it looks often: a long step without a check (one union, one read) is said in | ||||||
| its doc comment. | ||||||
| `cancelling_at_each_check_leaves_nothing_behind` reads the same lists and cancels each command at | ||||||
| its 1st, 2nd, 3rd… check and its last, then looks at what Cancel leaves: the project and undo steps, | ||||||
| the files, and that the command runs again. | ||||||
| - A new background raster command or export, or a tool whose work grows with its input, goes in | ||||||
| the lists in `crates/engine/src/tests.rs` (`cancel_rasters`, `cancel_exports`, `cancel_tools`); | ||||||
| `cancel_rasters` and `cancel_exports` must match the background registries. A read-ahead command | ||||||
| (`reads::prepare`, such as `service.layers`) has no list: add its call to the test below by hand. | ||||||
| `long_commands_stop_when_cancelled_while_they_run` fails one that never looks at Cancel; | ||||||
| `cancelling_at_each_check_leaves_nothing_behind` cancels each command of the three lists at its | ||||||
| first three checks and its last, and fails one that leaves the project, its undo steps or the | ||||||
| files changed, or can't run again (read-aheads and commands that read from the network are left | ||||||
| out). Passing shows the work looks, not that | ||||||
| it looks often: a long step without a check (one union, one read) is said in its doc comment. | ||||||
|
|
||||||
| ## Use the threads | ||||||
| Work that splits into independent parts runs on several threads where practical: | ||||||
| - the same output as one thread, bit for bit; one thread below a size threshold and in the browser; | ||||||
| - in `analysis`, the shared helpers (`parallel::for_each_row`, `try_map`, `try_map_on`); | ||||||
| everywhere, the thread count from `rustgis_data::threads` (it follows the user's setting), never | ||||||
| `available_parallelism` or a fixed number, and scratch memory within `memory::thread_scratch`; | ||||||
| - a thread the OS refuses costs speed, not the run (`Builder::spawn_scoped`). | ||||||
|
|
||||||
| ## Architecture | ||||||
| | Layer | Crate | Job | | ||||||
| |---|---|---| | ||||||
| | L0 | `geom` | coordinates, extents, Web Mercator, geodesic measurement, scale | | ||||||
| | L1 | `data` | features, typed attributes, GeoJSON/CSV/Shapefile/KML/GPX I/O, GeoPackage/GeoParquet/FlatGeobuf/LiDAR (LAS/LAZ)/PostGIS/MySQL providers (`source`; PostGIS through the pure-Rust `postgres` client, MySQL and MariaDB through the pure-Rust `mysql` client, desktop only; GeoPackages in the browser through the pure-Rust `sqlite` reader; GDAL formats and DuckDB queries through their programs), SQL where clauses, rasters (GeoTIFF/ASCII grid, Zarr stores, EPSG reprojection) | | ||||||
| | L2 | `map`, `analysis` | layers, symbology, labels, camera, basemaps, web tile layers; geoprocessing tools | | ||||||
| | L2 | `tiles` | web map tiles: XYZ/TMS/WMS rasters, Mapbox Vector Tiles, PMTiles and MBTiles archives, a MapLibre style subset; the tile cache and background fetching (see `docs/user-guide/maps.md` › Basemaps) | | ||||||
| | L2 | `keychain` | the system's secret store (macOS Keychain, Windows Credential Manager, Secret Service) behind `SecretStore`; the desktop app, the CLI's `--use-saved-secrets` and Python's `use_saved_secrets` | | ||||||
| | L3 | `render` | tiny-skia map renderer, label placement, PNG export, font discovery | | ||||||
| | L3 | `plugins` | plugins: sandboxed WebAssembly modules (`wasmi`) adding commands and tools; `.rgplugin` packages, the plugin registry (see `docs/plugins.md`) | | ||||||
| | L3 | `geolibre` | the GeoLibre/Whitebox tool suite as geoprocessing tools (engine feature `geolibre`): run by the optional `geolibre` program natively, by geolibre-rust's WASI runner in the browser | | ||||||
| | L4 | `engine` | `Session`, undo, command registry, sample project | | ||||||
| | L5 | `assistant` | the AI Assistant: a chat agent (sans I/O: `provider` builds and reads OpenAI Chat Completions/Responses, Anthropic and Gemini requests, `chatgpt` signs in with ChatGPT to use the user's plan, `agent` loops, `tools` run commands; file, network and plugin commands wait for the user's approval) | | ||||||
| | L6 | `ui-egui` | ribbon, panes, map view, attribute table, dialogs (swappable) | | ||||||
| | L7 | `ui-touch` | the touch interface for phones: a bar of large buttons and sheets around `ui-egui`'s map view (`RustGisApp::chrome`) | | ||||||
| | apps | `rustgis`, `rustgis-cli`, `rustgis-web`, `rustgis-python`, `rustgis-mobile` | desktop app, command line, browser (WebAssembly), the `rustgis` Python package (PyO3, built with maturin), Android (a `NativeActivity`; see its README) | | ||||||
| | L0 | `geom` | coordinates, extents, projections, geodesic measurement | | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The table drops constraints that are rules (confidence: medium). The old L1 row said PostGIS and MySQL are pure-Rust clients and desktop only, that GeoPackage in the browser uses the pure-Rust
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4ac4b03: the L1 row keeps the pure-Rust, desktop-only database clients, the browser GeoPackage reader and GDAL/DuckDB through their programs; the L3 row says how GeoLibre runs in each place. |
||||||
| | L1 | `data` | features and attributes, file formats, database providers (PostGIS and MySQL through pure-Rust clients, desktop only; GeoPackage in the browser through a pure-Rust `sqlite` reader), queries, rasters; GDAL and DuckDB through their programs | | ||||||
| | L2 | `map`, `analysis`, `tiles`, `keychain` | layers and symbology; geoprocessing tools; web map tiles; the system's secret store | | ||||||
| | L3 | `render`, `plugins`, `geolibre` | map rendering and export; WebAssembly plugins; the GeoLibre tool suite (its program natively, its WASI runner in the browser) | | ||||||
| | L4 | `engine` | `Session`, undo, the command registry, the sample project | | ||||||
| | L5 | `assistant` | the AI Assistant (sans I/O); file, network and plugin commands wait for approval | | ||||||
| | L6 | `ui-egui` | ribbon, panes, map view, attribute table, dialogs | | ||||||
| | L7 | `ui-touch` | the phone interface around `ui-egui`'s map view | | ||||||
| | apps | `rustgis`, `rustgis-cli`, `rustgis-web`, `rustgis-python`, `rustgis-mobile` | desktop, command line, browser, Python package, Android and iOS | | ||||||
|
|
||||||
| - **Everything is a command**: a `CommandSpec` in `crates/engine/src/cmd/*.rs`. UI-only | ||||||
| commands (`ui.*`) live in `crates/ui-egui/src/lib.rs`. The ribbon, shortcuts, command search | ||||||
|
|
@@ -87,11 +84,14 @@ is out of scope. | |||||
| [ribbon guidelines](docs/contributing.md#ribbon-guidelines): the tab's purpose, one button per | ||||||
| destination, labels that say what happens, and what a ribbon pull request states. | ||||||
| - **Never break wasm**: everything below `apps/` must build for `wasm32-unknown-unknown` | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rule removed, not just architecture. The old "Never break wasm" bullet also said that
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restored in ceccae1: GeoLibre tools run asynchronously in the browser ( |
||||||
| (CI runs `cargo build --target wasm32-unknown-unknown -p rustgis-web`; the Zstandard decoder in | ||||||
| `rustgis-data` is C, so this needs clang). Use `web_time`, not | ||||||
| `std::time`; file access goes through `Services` on the web. `rustgis-geolibre` builds for | ||||||
| both: natively it runs the `geolibre` program; in the browser the web app runs geolibre-rust's | ||||||
| WASI runner asynchronously (`external_start` → `Services::geolibre_run` → `gp.finish`). | ||||||
| (CI runs `cargo build --target wasm32-unknown-unknown -p rustgis-web` with warnings as errors; | ||||||
| the Zstandard decoder in `rustgis-data` is C, so this needs clang). Use `web_time`, not | ||||||
| `std::time`; file access goes through `Services` on the web. In the browser, GeoLibre tools run | ||||||
| asynchronously (`external_start` → `Services::geolibre_run` → `gp.finish`), never as a blocking | ||||||
| call. Code only the desktop calls is | ||||||
| dead code in the browser build and fails it: put it behind `#[cfg(not(target_arch = "wasm32"))]` | ||||||
| and check as CI does, with | ||||||
| `RUSTFLAGS='-D warnings' cargo build --locked --target wasm32-unknown-unknown -p rustgis-web`. | ||||||
| - **Interface text is translatable**: wrap user-visible literals in `tl!("…")`, use | ||||||
| `i18n::fmt("… {name} …", &[("name", …)])` instead of `format!` for messages, and pass labels to | ||||||
| the ribbon widgets (they translate). Pull requests don't need to add the new strings to the | ||||||
|
|
@@ -104,6 +104,15 @@ is out of scope. | |||||
| reads, and in `docs/user-guide/expressions.md`; the `query` tests fail when the guide misses | ||||||
| a signature, unit, variable or keyword, or names a function that doesn't exist. | ||||||
|
|
||||||
| ## Reach every surface | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section adds a new rule the file says should not be added directly (confidence: medium). The new "This file" section (end of the file) says a new rule goes under "Suggested AGENTS.md additions" in the pull request description, and a maintainer decides. This PR adds "Reach every surface" as a rule in the file, and the PR body calls it new. Either move it to that suggestion list or state in the PR that the maintainer approved it. It also fails the bar in "This file" ("says exactly what to do"): it asks for a statement in the PR, not a check.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two new sections were agreed by a maintainer before this PR, which is the decision "This file" asks for; the description now says so. The surface rule does name the action: list in the PR which surfaces the change reaches and why the others don't apply. A reviewer can check that list, while a test can't know which surfaces a feature should reach. |
||||||
| A change that works where you tried it is often missing elsewhere. Before calling it done, say in | ||||||
| the pull request which of these it reaches and why the rest don't apply: | ||||||
| - the desktop app, the browser (file access through `Services`), the command line, Python, the | ||||||
| phone (the touch bar); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quality (nit, confidence: medium): "the phone (the touch bar)" will read to most people as the MacBook Touch Bar, and the term appears nowhere else in the repo. The phone interface is
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair: "the touch interface ( |
||||||
| - the ribbon, shortcuts and command search; the Assistant and MCP (do their tool descriptions | ||||||
| show the new option?); plugins; | ||||||
| - the way back: what you add can be undone, removed or reopened. | ||||||
|
|
||||||
| ## Assets | ||||||
| - No third-party vendor icons, images, styles, fonts, help text or code. Icons are drawn in | ||||||
| code (`icons.rs`). Every asset file has a row in `ATTRIBUTION.md`. | ||||||
|
|
@@ -117,18 +126,18 @@ is out of scope. | |||||
|
|
||||||
| ## Quality gates | ||||||
| `cargo xtask ci` (fmt, clippy -D warnings, tests, layers) before every commit. | ||||||
| `cargo xtask test-hygiene` (also in CI) requires `// test-wait: reason` on timer waits in tests and `#[ignore = "reason"]` on ignored tests; prefer completion or progress signals. | ||||||
| `cargo xtask test-hygiene` (also in CI) requires `// test-wait: reason` on timer waits in tests and | ||||||
| `#[ignore = "reason"]` on ignored tests; prefer completion or progress signals. | ||||||
| While you work, `cargo xtask changed` runs the same checks on only the packages your branch changes | ||||||
| and those that depend on them, or on the whole workspace when a changed file such as `Cargo.lock` is | ||||||
| outside every package and nothing includes it. | ||||||
| and those that depend on them (and `test-hygiene` on the whole workspace), or everything when a | ||||||
| changed file such as `Cargo.lock` is outside every package and nothing includes it. | ||||||
| A new dependency must have a licence `deny.toml` allows (CI runs `cargo deny check licenses`); after | ||||||
| changing dependencies, run `cargo xtask notices` to refresh the `THIRD-PARTY-LICENSES.txt` files the | ||||||
| packages ship (the release build fails on stale ones). | ||||||
| Pull requests run CI on Linux; pushes to `main` add macOS and Windows (x64 and ARM64). Label a | ||||||
| pull request `ci:windows`, `ci:macos` or `ci:full` to test there before merging (platform-specific | ||||||
| code, paths, file dialogs). The release build of the apps runs nightly | ||||||
| (`.github/workflows/nightly.yml`), with every platform's tests; a failure opens a | ||||||
| `Nightly build failed` issue. `ci:full` also runs the release build on the pull request. | ||||||
| Pull requests run CI on Linux (plus the Android and iOS builds when they touch | ||||||
| `apps/rustgis-mobile`); pushes to `main` test every platform. When a pull request touches | ||||||
| platform-specific code, paths or file dialogs, label it `ci:windows` or `ci:macos` to test there, | ||||||
| or `ci:full` for every platform and the release build. | ||||||
|
Mavrick-F marked this conversation as resolved.
Resolved
|
||||||
|
|
||||||
| ## Review comments | ||||||
| - Fix in the pull request what a review finds wrong: bugs, crash paths, silent data loss, a broken | ||||||
|
|
@@ -145,3 +154,10 @@ code, paths, file dialogs). The release build of the apps runs nightly | |||||
| For any visible change, include screenshots in the PR (before and after for changed UI, after | ||||||
| only for new UI); see [attachment guidance](docs/contributing.md#documentation). | ||||||
| - CLI: `rustgis-cli run --sample --cmd 'gp.run={"tool":"buffer","params":{"input":"Cities","distance":100}}' --cmd 'share.exportMap={"path":"out.png"}'`. | ||||||
|
|
||||||
| ## This file | ||||||
| A rule here names a trap, not a map of the code: agents can read the code. A new rule earns its | ||||||
| place when someone who knows the code would still get it wrong, it has happened more than once, and | ||||||
| it says exactly what to do. A pull request that adds a check or a test list updates its line here; | ||||||
| any other new rule goes under "Suggested AGENTS.md additions" in the pull request description, and a | ||||||
| maintainer decides. | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quality (nit, confidence: medium): "add its call to the test below by hand" doesn't say which test. The sentence that follows names
long_commands_stop_when_cancelled_while_they_run, butcancelling_at_each_check_leaves_nothing_behindalso sits in this bullet and it leaves read-aheads out, so a reader could pick the wrong one. Naming the test here would remove the ambiguity:Left for the release quality pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair: the next sentence names
long_commands_stop_when_cancelled_while_they_run, but naming it in this one would be clearer. Left for the release quality pass.