fix: novelty gate on diff re-propagation + greetings_max reachable from app

Re-propagation fired on every receipt, so a duplicate diff spawned a fresh
round of sends with only sender-exclusion as a guard — no termination
condition in a dense holder cluster, which is exactly what hot open-slot
posts (registry, greeting-enabled bios) produce.

Now: every storage apply reports whether it actually changed state, and
apply_diff_ops returns only the ops that did. Nothing changed means no
header rebuild and no outbound push at all; a mixed diff re-propagates a
freshly built payload of only its novel ops rather than echoing what
arrived. Gating is on state change, not message identity — a hash seen-set
would break once coalescing lands, since no two pushes stay identical.

Tombstones count as changes even when their target is absent, so a delete
arriving before its comment still propagates.

Found while implementing: AddCommentSlots appended unconditionally, so a
re-delivered op grew the header forever AND looked novel forever —
unbounded amplification on precisely the clusters this gate targets. Now
idempotent on slot bytes.

Review found a remotely-triggerable blocker in the first cut: absent-target
tombstone placeholders were written with no expiry, and DeleteComment is
authorized per-op rather than per-cardinality, so one keypair could mint
unlimited valid deletes against any post a victim holds — permanent rows,
relayed onward, and served in the rebuilt header. The registry post is
universally held, making it network-wide unbounded growth. Fixed three
ways: a 64-per-post placeholder cap, a bounded expiry so the existing
sweep reclaims them, and exclusion from everything published (headers and
the uniques announce).

Also: RemoveReaction deliberately does NOT mirror the placeholder — it
carries no timestamp and is unsigned, so a guessed-timestamp placeholder
loses to a late AddReaction and the row key would be a free unbounded
write vector. Rationale documented on the arm; signed RemoveReaction
carrying the reaction timestamp is the named follow-up.

set_greetings_max/get_greetings_max exposed as Tauri commands and wired
next to the Accept-greetings consent control, clamped at the single read
point every writer funnels through.

267 core tests (was 250); a3 12/12; c_topology 33/33.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGiPD2cF75mnvneSCjdDC5
This commit is contained in:
Scott Reimers 2026-08-07 01:29:15 -04:00
parent bbc17f8855
commit 8d29cb918e
6 changed files with 1598 additions and 296 deletions

View file

@ -2015,6 +2015,34 @@ async fn get_greetings_open(
node.get_greetings_open(&posting_id).await.map_err(|e| e.to_string())
}
/// Ruling #6: author-declared cap on live stranger greetings for this
/// persona's bio. `None`/0 = the holder default; refusal is the separate
/// structural case (`set_greetings_open(false)`).
///
/// Republishes the bio, because the cap lives inside the bio post's SIGNED
/// `OpenSlotDecl` — writing the setting alone would never reach a holder.
#[tauri::command]
async fn set_greetings_max(
state: State<'_, AppNode>,
posting_id_hex: String,
max_comments: Option<u32>,
) -> Result<(), String> {
let node = get_node(&state).await;
let posting_id = parse_node_id(&posting_id_hex)?;
node.set_greetings_max(&posting_id, max_comments).await.map_err(|e| e.to_string())
}
/// Current author-declared greeting cap (`None` = holder default).
#[tauri::command]
async fn get_greetings_max(
state: State<'_, AppNode>,
posting_id_hex: String,
) -> Result<Option<u32>, String> {
let node = get_node(&state).await;
let posting_id = parse_node_id(&posting_id_hex)?;
node.get_greetings_max(&posting_id).await.map_err(|e| e.to_string())
}
/// Open a URL in the user's default system browser.
/// Desktop: spawns the platform opener (xdg-open / open / cmd start).
/// Only https:// URLs are accepted to avoid being a generic command exec.
@ -3746,6 +3774,8 @@ pub fn run() {
dismiss_greeting,
set_greetings_open,
get_greetings_open,
set_greetings_max,
get_greetings_max,
])
.build(tauri::generate_context!())
.expect("error while building tauri application")