aboutsummaryrefslogtreecommitdiffstats
path: root/src/document
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-15 23:34:11 +0000
committertv <tv@krebsco.de>2026-11-15 23:34:11 +0000
commit3827195e784999c772357e547d3d4efc9bb8d627 (patch)
tree0f0806ee290bfb779b5dcf15c9936f44da3b75d2 /src/document
parentcc998c1d45939d170bcf8a6512817405ed2b44a3 (diff)
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.
Diffstat (limited to 'src/document')
-rw-r--r--src/document/store.rs11
1 files changed, 10 insertions, 1 deletions
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<Option<JsonValue>, 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<Option<JsonValue>, 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)),