Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c2aeba6
feat(tiles): manually reload linked tile archives
deniial00 Nov 6, 2026
814df3d
test(tiles): synchronize deferred cache fetch completions
deniial00 Nov 6, 2026
10bcb51
fix(tiles): validate archive reloads before background installation
deniial00 Nov 6, 2026
1c00994
Merge main at 3225fd60 into reload-tiles-pr2
deniial00 Nov 7, 2026
a691883
Merge main at cb80aee7 into reload-tiles-pr2
deniial00 Nov 8, 2026
96f1d6e
Merge main at 4032f0e0 and preserve archive reload generations
deniial00 Nov 8, 2026
1dc97c1
fix(tiles): reject overlapping PMTiles runs and honor cancellation du…
deniial00 Nov 8, 2026
696df29
fix(engine): bind archive approvals to the selected source and reject…
deniial00 Nov 8, 2026
f766c1b
fix(relay): validate direct relay archive reloads on the background r…
deniial00 Nov 8, 2026
e2b4671
Merge remote-tracking branch 'origin/main' into reload-tiles-pr2
deniial00 Nov 8, 2026
8be9319
fix: preserve archive batch intent and validate nested tile ranges
deniial00 Nov 8, 2026
ff6bb9c
fix: bind archive continuations to maps and reject hidden tile ranges
deniial00 Nov 8, 2026
82a2d89
fix: refuse lossy archive metadata and bound PMTiles writer output
deniial00 Nov 9, 2026
0eebe72
Merge main and preserve archive epochs with destination provenance
deniial00 Nov 9, 2026
44819bf
Fix archive reload cancellation and render consistency
deniial00 Nov 9, 2026
2a36d36
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
3650754
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
200dc9a
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
fd7989c
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
8fe3cf6
Name Reload Tile Archive in the tile archive reload docs
deniial00 Nov 9, 2026
9671320
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
09e959e
Keep the MBTiles pool test valid across a concurrent pool clear
deniial00 Nov 9, 2026
f57ea79
Observe MBTiles sidecars beside both the link and its target
deniial00 Nov 9, 2026
287d490
Answer and end relay archive batches when reads stop at exit
deniial00 Nov 9, 2026
0984fb1
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
628d473
Merge main into reload-tiles-pr2
deniial00 Nov 9, 2026
33e17dc
Say where archive reload and repair validate inline
deniial00 Nov 10, 2026
0384c75
Merge main into reload-tiles-pr2
deniial00 Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ arrow-schema = { version = "60", default-features = false }
bytes = "1"
flatgeobuf = { version = "6", default-features = false }
geozero = { version = "0.15", default-features = false, features = ["with-wkb"] }
rusqlite = { version = "0.41", features = ["bundled", "functions"] }
rusqlite = { version = "0.41", features = ["bundled", "functions", "hooks"] }
# PostgreSQL/PostGIS, in pure Rust: the client, and TLS through rustls (ring, as ureq has it).
postgres = { version = "0.19", default-features = false }
tokio-postgres-rustls = { version = "0.14", default-features = false, features = ["ring"] }
Expand Down
3 changes: 2 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Correct, robust and recoverable, with the foundations other themes stand on.
GDA94↔GDA2020 and OSGB36, and a notice whenever a layer is read without its shift; GDA94
([#730](https://github.com/opengeos/RustGIS/issues/730)) is one case. _Coordinate first._
- Reloading files changed on disk ([#1477](https://github.com/opengeos/RustGIS/issues/1477)):
manual Reload Data for linked layers; automatic detection and notifications remain open.
manual Reload Data for linked layers and local PMTiles/MBTiles archives; automatic detection and
notifications remain open.
- Autosave and crash recovery in the browser: reopen unsaved work after a crash. The desktop app
has them ([#873](https://github.com/opengeos/RustGIS/issues/873)).
- Signed Windows builds (no SmartScreen warning), then a signature check, by publisher name, in
Expand Down
199 changes: 184 additions & 15 deletions crates/assistant/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,132 @@ pub(crate) fn request_key(root: &str, position: usize) -> String {
format!("{root}/{position}")
}

/// A relay message paused at an admitted standalone archive command. Batch positions and
/// one-use permits remain owned here; no suffix entry runs until the actual command lands.
#[cfg(not(target_arch = "wasm32"))]
pub(crate) struct ArchiveBatch {
server: Server,
scope: Scope,
permits: Vec<(String, Permit)>,
request: String,
messages: std::vec::IntoIter<Value>,
position: usize,
batch: bool,
replies: Vec<Value>,
pending: Option<(Value, tools::CommandCompletion)>,
ahead: Option<rustgis_engine::cmd::reads::ReadAhead>,
/// Successful explicit selections in the current uninterrupted execution segment.
picked: bool,
}
#[cfg(not(target_arch = "wasm32"))]
pub(crate) enum ArchiveStep {
Done(Option<String>, bool),
Read(Box<ArchiveBatch>),
}
#[cfg(not(target_arch = "wasm32"))]
impl ArchiveBatch {
pub(crate) fn take_read(&mut self) -> Option<rustgis_engine::cmd::reads::ReadAhead> {
self.ahead.take()
}
pub(crate) fn picked(&self) -> bool {
self.picked
}
/// The command's reply reports changes made from the moment it actually runs, not from its
/// admission: the queue may run user work or other reads first.
pub(crate) fn begin_landing(&mut self, s: &Session) {
if let Some((_, completion)) = &mut self.pending {
*completion = tools::CommandCompletion::capture(s);
}
}
pub(crate) fn finish(mut self, s: &mut Session, result: Result<Value, String>) -> ArchiveStep {
self.finish_pending(s, result);
self.advance(s)
}
/// A changed project or map invalidates the suffix, not the command's actual result; so does
/// the app closing. Complete every remaining request with `remaining` as its error, without
/// dispatching even a read-only tool.
pub(crate) fn cancel_remaining(mut self, s: &mut Session, result: Result<Value, String>, remaining: &str) -> ArchiveStep {
self.finish_pending(s, result);
for msg in self.messages.by_ref() {
match request_identity(&msg) {
Ok(Some((_, id))) => {
self.replies.push(error_value(&id, -32000, remaining));
}
Ok(None) => {}
Err(reply) => self.replies.push(reply),
}
}
self.done()
}
fn finish_pending(&mut self, s: &mut Session, result: Result<Value, String>) {
self.picked = false;
if let Some((id, completion)) = self.pending.take() {
self.replies.push(archive_reply(id, completion.finish(s, result)));
}
}
fn advance(mut self, s: &mut Session) -> ArchiveStep {
while let Some(msg) = self.messages.next() {
let request = request_key(&self.request, self.position);
self.position += 1;
let archive = (|| {
let id = msg.get("id")?;
if !matches!(id, Value::String(_) | Value::Number(_)) || msg.get("method").and_then(Value::as_str) != Some("tools/call") {
return None;
}
let (name, args) = tool_request(msg.get("params")?).ok()?;
if name != "run_command"
|| !matches!(args.get("command").and_then(Value::as_str).map(str::trim), Some("map.reloadTiles" | "map.repairTiles"))
{
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return None;
}
Some((id.clone(), ToolCall { id: request.clone(), name: name.into(), args }))
})();
if let Some((id, call)) = archive {
let permit = self.permits.iter().position(|(key, _)| key == &request).map(|i| self.permits.remove(i).1);
let completion = tools::CommandCompletion::capture(s);
let admitted = tools::policy_call(&call)
.and_then(|call| call.ok_or_else(|| "missing archive adapter".to_string()))
.and_then(|call| s.start_scoped_archive_read(self.scope.clone(), &call, permit));
match admitted {
Ok(ahead) => {
self.pending = Some((id, completion));
self.ahead = Some(ahead);
return ArchiveStep::Read(Box::new(self));
}
Err(error) => self.replies.push(archive_reply(id, completion.finish(s, Err(error)))),
}
} else if let Some(reply) = self.server.handle_value(s, &msg, &self.scope, &mut self.permits, &request) {
if reply.get("error").is_none() && reply.pointer("/result/isError") == Some(&Value::Bool(false)) {
self.picked |= msg.get("params").is_some_and(|params| {
let Some(name) = params.get("name").and_then(Value::as_str) else { return false };
params.get("arguments").is_some_and(|args| tools::selects_layer(name, args))
});
}
self.replies.push(reply);
}
}
self.done()
}
fn done(mut self) -> ArchiveStep {
let reply = if self.replies.is_empty() {
None
} else if self.batch {
Some(Value::Array(self.replies).to_string())
} else {
self.replies.pop().map(|reply| reply.to_string())
};
ArchiveStep::Done(reply, self.picked)
}
}
#[cfg(not(target_arch = "wasm32"))]
fn archive_reply(id: Value, result: Result<String, String>) -> Value {
let (text, failed) = match result {
Ok(text) => (text, false),
Err(error) => (error, true),
};
json!({"jsonrpc":"2.0","id":id,"result":{"content":[{"type":"text","text":text}],"isError":failed}})
}

impl Server {
/// A server with the built-in skills. `rustgis-cli mcp` and the desktop's relay replace them
/// with the skills switched on (`skills::installed`): the user's, the plugins' and shared ones.
Expand All @@ -100,6 +226,38 @@ impl Server {
pub fn handle(&self, s: &mut Session, message: &str) -> Option<String> {
self.handle_scoped(s, message, self.scope(s), Vec::new(), "")
}
#[cfg(not(target_arch = "wasm32"))]
/// Desktop relay ingress; only direct archive commands pause. Scripts and other transports
/// retain their synchronous contract, and malformed messages keep normal JSON-RPC handling.
pub(crate) fn start_archive_batch(
self,
s: &mut Session,
message: &str,
scope: Scope,
permits: Vec<(String, Permit)>,
request: &str,
) -> ArchiveStep {
let parsed = serde_json::from_str::<Value>(message);
let (messages, batch) = match parsed {
Ok(Value::Array(batch)) if !batch.is_empty() && batch.len() <= MAX_BATCH => (batch, true),
Ok(msg) if !msg.is_array() => (vec![msg], false),
_ => return ArchiveStep::Done(self.handle_scoped(s, message, scope, permits, request), false),
};
ArchiveBatch {
server: self,
scope,
permits,
request: request.into(),
messages: messages.into_iter(),
position: 0,
batch,
replies: Vec::new(),
pending: None,
ahead: None,
picked: false,
}
.advance(s)
}
/// Named relay/file-bridge ingress; permits are engine plans stored when approval was shown.
pub(crate) fn handle_scoped(
&self,
Expand Down Expand Up @@ -145,22 +303,12 @@ impl Server {
permits: &mut Vec<(String, Permit)>,
request: &str,
) -> Option<Value> {
let Some(obj) = msg.as_object() else {
return Some(error_value(&Value::Null, INVALID_REQUEST, "expected a JSON-RPC object"));
};
let id = obj.get("id").cloned();
let Some(method) = obj.get("method").and_then(Value::as_str) else {
// A response to a request of ours (we send none), or junk.
return id
.filter(|_| !obj.contains_key("result") && !obj.contains_key("error"))
.map(|id| error_value(&id, INVALID_REQUEST, "expected a method"));
let (method, id) = match request_identity(msg) {
Ok(Some(request)) => request,
Ok(None) => return None,
Err(reply) => return Some(reply),
};
// Notifications (no id) get no reply.
let id = id?;
if !matches!(id, Value::String(_) | Value::Number(_)) {
return Some(error_value(&Value::Null, INVALID_REQUEST, "id must be a string or a number"));
}
let params = obj.get("params").cloned().unwrap_or(Value::Null);
let params = msg.get("params").cloned().unwrap_or(Value::Null);
Some(match self.call(s, method, &params, scope, permits, request) {
Ok(result) => json!({"jsonrpc": "2.0", "id": id, "result": result}),
Err((code, message)) => error_value(&id, code, &message),
Expand Down Expand Up @@ -537,6 +685,27 @@ pub fn expects_reply(message: &str) -> bool {
}
}

/// Applies JSON-RPC identity rules without executing a request.
fn request_identity(msg: &Value) -> Result<Option<(&str, Value)>, Value> {
let Some(obj) = msg.as_object() else {
return Err(error_value(&Value::Null, INVALID_REQUEST, "expected a JSON-RPC object"));
};
let id = obj.get("id").cloned();
let Some(method) = obj.get("method").and_then(Value::as_str) else {
// A response to a request of ours (we send none), or junk.
return match id.filter(|_| !obj.contains_key("result") && !obj.contains_key("error")) {
Some(id) => Err(error_value(&id, INVALID_REQUEST, "expected a method")),
None => Ok(None),
};
};
// Notifications (no id) get no reply.
let Some(id) = id else { return Ok(None) };
if !matches!(id, Value::String(_) | Value::Number(_)) {
return Err(error_value(&Value::Null, INVALID_REQUEST, "id must be a string or a number"));
}
Ok(Some((method, id)))
}

/// Projects generated RPC error text while retaining the exact correlation id and code.
fn error_value(id: &Value, code: i64, message: &str) -> Value {
let message = rustgis_engine::render::rustgis_tiles::logins::scrub_error(message);
Expand Down
Loading
Loading