diff --git a/crates/geth-node/src/lib.rs b/crates/geth-node/src/lib.rs index 91280cf..5e24b70 100644 --- a/crates/geth-node/src/lib.rs +++ b/crates/geth-node/src/lib.rs @@ -7754,6 +7754,11 @@ pub fn handle_request( ControlRequest::DocumentCreate { name } => { geth_document::validate_document_name(&name) .map_err(|_| NodeError::InvalidDocumentName(name.clone()))?; + if let Some(existing) = store.get_document_resource_by_name(&name)? { + return Ok(ControlResponse::DocumentCreated { + document: document_resource_from_stored(&existing), + }); + } let resource_id = format!("resource:document:{name}"); let document_id = format!("document:{name}"); let resource = StoredResource { diff --git a/crates/geth/tests/bootstrap.rs b/crates/geth/tests/bootstrap.rs index 440e7ee..58d29fc 100644 --- a/crates/geth/tests/bootstrap.rs +++ b/crates/geth/tests/bootstrap.rs @@ -3617,6 +3617,14 @@ fn kv_create_set_get_use_local_store() { other => panic!("unexpected response: {other:?}"), } + geth_node::handle_request( + &node, + geth_control::ControlRequest::KvCreate { + name: "prefs".to_owned(), + }, + ) + .expect("repeat kv create"); + let response = geth_node::handle_request( &node, geth_control::ControlRequest::KvGet { @@ -3772,6 +3780,14 @@ fn document_create_and_status_use_local_store() { other => panic!("unexpected response: {other:?}"), } + geth_node::handle_request( + &node, + geth_control::ControlRequest::DocumentCreate { + name: "notes".to_owned(), + }, + ) + .expect("repeat document create"); + let reopened = geth_node::open_node(&paths).expect("reopen node"); let response = geth_node::handle_request( &reopened, diff --git a/docs/production-readiness-roadmap.md b/docs/production-readiness-roadmap.md index 63e2193..f78570a 100644 --- a/docs/production-readiness-roadmap.md +++ b/docs/production-readiness-roadmap.md @@ -252,11 +252,11 @@ Goal: make `geth` ergonomic and stable as a base layer for custom automation. or stale. - `[x]` Wait commands support JSON output and timeout flags. -- `[ ]` Make common commands idempotent. +- `[x]` Make common commands idempotent. Acceptance criteria: - - `[ ]` Resource creation commands can be safely repeated where practical. - - `[ ]` Grant creation supports deterministic caller-provided IDs. - - `[ ]` Repeated sync and import commands report no-op state clearly. + - `[x]` Resource creation commands can be safely repeated where practical. + - `[x]` Grant creation supports deterministic caller-provided IDs. + - `[x]` Repeated sync and import commands report no-op state clearly. - `[x]` Publish automation examples. Acceptance criteria: