From 3827195e784999c772357e547d3d4efc9bb8d627 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 15 Nov 2026 23:34:11 +0000 Subject: policy: read only as continuum writes it A swarm turns strict only at its start or through a strict remake, and a change writing a strict policy where the policy isn't strict is refused, found by its operations: `"signed"` put at the policy's `values`, or an envelope asking for it put at its place. But the policy was read in plain JSON, where an Automerge text reads as a string, and writing a text is no such operation: `{"$text": "signed"}` at `values`, through the typed API, turned a swarm strict that nothing refused, with a time before it nothing closes. The policy is read in typed JSON now (`store::read_plain_as`): what continuum writes there reads as it is, plain JSON or an envelope, and a text, a counter or bytes as itself, tagged; a setting that isn't a string makes a policy no node knows (`policy::read`), as a version it doesn't know does. So no text turns a swarm strict, and the operations `rules::turns_strict` asks of are the only ways to. A policy holding none of these reads as before. --- src/document/store.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/document/store.rs') diff --git a/src/document/store.rs b/src/document/store.rs index 77d5c81..8da6270 100644 --- a/src/document/store.rs +++ b/src/document/store.rs @@ -590,7 +590,16 @@ pub(crate) fn read_plain( doc: &impl ReadDoc, path: &[String], ) -> Result, StoreError> { - Ok(match read_path(doc, path)? { + read_plain_as(doc, path, JsonForm::default()) +} + +/// [`read_plain`], in JSON of `form`. +pub(crate) fn read_plain_as( + doc: &impl ReadDoc, + path: &[String], + form: JsonForm, +) -> Result, StoreError> { + Ok(match read_path_as(doc, path, form)? { Some(JsonValue::String(text)) => match super::signed::read(&text) { Some(payload) => Some(payload.value).filter(|value| !value.is_null()), None => Some(JsonValue::String(text)), -- cgit v1.3.1