feat(holdings): holdings are DECLARED, not inferred from transport
Until now every receive path recorded the SENDER in `file_holders`, and
those rows went straight back out on the wire to third parties as
`cdn_redirect_peers`, as worm holder answers, and as HTTP 302 targets.
Exchanging bytes with a peer enrolled its node id -- and its addresses --
into a list we republished to anyone who asked.
Two things follow, and both matter. The concealment model the erasure
work depends on ("hold k shards quietly, announce exactly one slot") is
impossible on an inferred foundation: acquiring a shard registers you as
its holder whether you consented or not. And an enumerator never had to
hold anything -- it just asked holders who else holds.
`file_holders` rows now split two ways:
* local hint (`declared = 0`) -- "we exchanged bytes about this file
with that peer". Drives fetch retry, diff-propagation targets and
manifest refresh. Never published as a holder of a specific file.
* declaration (`declared = 1`) -- the peer told us "I hold this and you
may advertise me for it" (0xD3). The only holder list that may leave
the node.
All 12 inference sites were triaged into hints with a per-site reason
rather than deleted. 0xD3 became the declaration handler and is validated
hard, since it is now the only unauthenticated input reaching an outbound
holder surface: 16 KB read ceiling (was MAX_PAYLOAD, 64 MB), reject rather
than truncate oversized batches, a `tracks_file` gate so a stranger cannot
mint rows for arbitrary 32-byte ids, a per-peer token bucket and row
budget, and normalised publicly-routable addresses capped at 4. An
introducer nominee must be a known anchor -- otherwise a peer could make
us publish an arbitrary victim's address.
Declarations are soft state: a rotating per-peer sweep rides each
content-sync cycle and `DECLARATION_TTL_MS` (30d) ages out a holder that
goes quiet, so a peer that wipes its database re-learns them.
Durability decisions count EVIDENCE, never claims. A new `witnessed`
column records transport events we handled ourselves, independent of
`declared` because a peer can be both; keying the count on `declared = 0`
instead dropped every honest custodian that declared out of its author's
durability count, making the post look less durable and provoking
replication it did not need. Gating replication on claims would also let
five Sybil identities declare a post and silently stop its author
replicating it -- the data-availability attack the erasure study rules
against.
Alpha policy defaults are deliberately generous (both classes declare,
per-author cap off) because a tight cap makes content unfindable and
there is no spare holder population yet. Own-authored content is never
declared by default: it publishes device <-> posting identity, the
binding the manifest address strip exists to prevent. Non-public content
is never declared at all, at a single chokepoint. Policy changes are
retroactive, so the open alpha shape is transitional.
Known limit, documented in `holdings.rs` and design.html: this hides
WHICH and HOW MANY of an author's posts you hold, not THAT you hold some
of that author's content -- `build_own_uniques` still announces every
distinct author, deliberately interest-blind-but-complete so discovery
works. The one-shard-announcement property holds at file granularity
only; closing the author-level surface is a discovery trade Round 10 has
not ruled on.
Wire format (clean break, zero users): drops
`BlobRequestPayload.requester_addresses`, `BlobResponsePayload`'s
`cdn_registered`, and `CdnManifest.host` -- the last rode every blob
response and was relayed verbatim, so a third party learned "node A holds
this CID" with no declaration from A. ALPN is NOT bumped here; see the PR.
301 core tests (was 267), a3 23/23 (12 pre-existing + 11 new behavioural
assertions), c_topology 33/33 unchanged. Policy knobs reachable from the
desktop app, not CLI-only.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LGiPD2cF75mnvneSCjdDC5
This commit is contained in:
parent
eebf0d86f0
commit
3430a9d4c9
17 changed files with 3560 additions and 157 deletions
|
|
@ -2043,6 +2043,93 @@ async fn get_greetings_max(
|
|||
node.get_greetings_max(&posting_id).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
// ---- v0.8.1 PHASE 2: declared-holdings policy ----
|
||||
//
|
||||
// Holdings are DECLARED, not inferred from transport. These commands are what
|
||||
// make the policy reachable from the apps rather than CLI-only — the 4-device
|
||||
// alpha runs the deliberately GENEROUS default (`cap_per_author = 0`), so a
|
||||
// tester who finds the footprint leakier than they want needs a way to tighten
|
||||
// it without a terminal.
|
||||
|
||||
/// Current policy + footprint, as a flat object for the Settings panel.
|
||||
#[tauri::command]
|
||||
async fn get_holdings_policy(state: State<'_, AppNode>) -> Result<serde_json::Value, String> {
|
||||
let node = get_node(&state).await;
|
||||
let p = node.holdings_policy().await;
|
||||
let summary = node.holdings_summary().await;
|
||||
let introducer_enabled = node
|
||||
.get_setting(itsgoin_core::holdings::SETTING_INTRODUCER_ENABLED)
|
||||
.await
|
||||
.ok()
|
||||
.flatten()
|
||||
.as_deref()
|
||||
== Some("true");
|
||||
Ok(serde_json::json!({
|
||||
"declare_custodial": p.declare_custodial,
|
||||
"declare_interest": p.declare_interest,
|
||||
"declare_own_authored": p.declare_own_authored,
|
||||
"cap_per_author": p.cap_per_author,
|
||||
"introducer_enabled": introducer_enabled,
|
||||
"round10_target_cap": itsgoin_core::holdings::ROUND10_TARGET_CAP_PER_AUTHOR,
|
||||
"summary": summary,
|
||||
}))
|
||||
}
|
||||
|
||||
/// Per-(us, author) cap on distinct declared posts. `0` = unlimited (the alpha
|
||||
/// default). Retroactive: lowering it retracts what it no longer admits.
|
||||
#[tauri::command]
|
||||
async fn set_holdings_cap_per_author(
|
||||
state: State<'_, AppNode>,
|
||||
cap: u32,
|
||||
) -> Result<(), String> {
|
||||
let node = get_node(&state).await;
|
||||
node.set_holdings_cap_per_author(cap).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Enable/disable a declaration class. `class` is "custodial" or "interest".
|
||||
#[tauri::command]
|
||||
async fn set_holdings_declare_class(
|
||||
state: State<'_, AppNode>,
|
||||
class: String,
|
||||
enabled: bool,
|
||||
) -> Result<(), String> {
|
||||
let reason = match class.as_str() {
|
||||
"custodial" => itsgoin_core::holdings::DeclareReason::Custodial,
|
||||
"interest" => itsgoin_core::holdings::DeclareReason::Interest,
|
||||
other => return Err(format!("unknown holdings class: {other}")),
|
||||
};
|
||||
let node = get_node(&state).await;
|
||||
node.set_holdings_declare_class(reason, enabled).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Declare holdings of content WE authored. Default OFF — enabling it
|
||||
/// publishes `device <-> posting identity` in third-party holder lists.
|
||||
#[tauri::command]
|
||||
async fn set_holdings_declare_own_authored(
|
||||
state: State<'_, AppNode>,
|
||||
enabled: bool,
|
||||
) -> Result<(), String> {
|
||||
let node = get_node(&state).await;
|
||||
node.set_holdings_declare_own_authored(enabled).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Publish an introducer's address in place of ours. Default OFF. Empty
|
||||
/// `peer_hex` auto-picks a CONNECTED anchor. Hole-punch coordination only —
|
||||
/// this is NOT session relay and does not touch `relay.session_relay_enabled`.
|
||||
#[tauri::command]
|
||||
async fn set_holdings_introducer(
|
||||
state: State<'_, AppNode>,
|
||||
enabled: bool,
|
||||
peer_hex: Option<String>,
|
||||
) -> Result<(), String> {
|
||||
let peer = match peer_hex.as_deref() {
|
||||
Some(h) if !h.is_empty() => Some(parse_node_id(h)?),
|
||||
_ => None,
|
||||
};
|
||||
let node = get_node(&state).await;
|
||||
node.set_holdings_introducer(enabled, peer).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.
|
||||
|
|
@ -3776,6 +3863,11 @@ pub fn run() {
|
|||
get_greetings_open,
|
||||
set_greetings_max,
|
||||
get_greetings_max,
|
||||
get_holdings_policy,
|
||||
set_holdings_cap_per_author,
|
||||
set_holdings_declare_class,
|
||||
set_holdings_declare_own_authored,
|
||||
set_holdings_introducer,
|
||||
])
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue