summaryrefslogtreecommitdiffstats
path: root/src/remake/records.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-21 04:08:26 +0200
committertv <tv@krebsco.de>2026-10-21 04:08:26 +0200
commitcae74a1abc23aa0e72eca1b5668d9bba87ea4c1e (patch)
tree0811bfdcf686874cf80dd8f9992ca37c3923b022 /src/remake/records.rs
parent5e710513e5dee0e1a715680da2c2953692dcb377 (diff)
turn compaction into a kind of remake
Diffstat (limited to 'src/remake/records.rs')
-rw-r--r--src/remake/records.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/remake/records.rs b/src/remake/records.rs
index 219fc9b..5e7841f 100644
--- a/src/remake/records.rs
+++ b/src/remake/records.rs
@@ -17,8 +17,10 @@
use automerge::{AutoCommit, ChangeHash};
use serde::{Deserialize, Serialize};
+use serde_json::Value as JsonValue;
use tracing::warn;
+use super::kind::DEFAULT_KIND;
use super::snapshot::{SnapshotRequest, META_ROOT, REMAKES};
use crate::document::replica::Epoch;
use crate::document::store::{self, StoreError};
@@ -123,6 +125,19 @@ pub(crate) struct Proposal {
pub(crate) settle_until: u64,
/// Peers that must stay active during the settle period.
pub(crate) peers_considered: Vec<String>,
+ /// The remake kind (`compact` for records written before kinds existed).
+ #[serde(default = "default_kind")]
+ pub(crate) kind: String,
+ /// The kind's build input.
+ #[serde(default, skip_serializing_if = "JsonValue::is_null")]
+ pub(crate) content: JsonValue,
+ /// The kind's translation input.
+ #[serde(default, skip_serializing_if = "JsonValue::is_null")]
+ pub(crate) translation: JsonValue,
+}
+
+fn default_kind() -> String {
+ DEFAULT_KIND.to_owned()
}
impl Proposal {
@@ -204,6 +219,9 @@ impl Record {
base_heads: self.proposal.base_change_hashes()?,
policy: serde_json::to_value(&self.proposal.policy).ok()?,
proposed_at: self.proposal.proposed_at,
+ kind: self.proposal.kind.clone(),
+ content: self.proposal.content.clone(),
+ translation: self.proposal.translation.clone(),
})
}
@@ -338,6 +356,9 @@ mod tests {
proposed_at: settle_until.saturating_sub(1_000),
settle_until,
peers_considered: vec!["node-b".into()],
+ kind: DEFAULT_KIND.to_owned(),
+ content: JsonValue::Null,
+ translation: JsonValue::Null,
}
}