From 3e36103264b1fd18faa72d2da070ca8dcbc2a2a3 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Tue, 20 Oct 2026 08:56:19 +0300 Subject: [PATCH 1/5] feat(repo,cli): --no-transcripts opt-out on fetch, clone and push (ref #211) Client-side only, no PROTOCOL_VERSION bump. push leaves indexed transcripts and their signatures out of the pack; fetch/clone verify and then discard received transcripts and signatures over them, so no object or index entry lands. Per command, not persisted. ADR-0038 addendum. --- .claude/skills/sc-cli-reference/SKILL.md | 9 + CLAUDE.md | 2 +- ROADMAP.md | 7 +- crates/cli/src/main.rs | 47 +++- crates/cli/tests/transcripts.rs | 197 +++++++++++++++ crates/repo/src/sync.rs | 278 ++++++++++++++++++++- crates/repo/src/transport.rs | 37 ++- docs/adr/0038-agent-session-transcripts.md | 35 ++- 8 files changed, 589 insertions(+), 23 deletions(-) diff --git a/.claude/skills/sc-cli-reference/SKILL.md b/.claude/skills/sc-cli-reference/SKILL.md index f0bc86d8..dcf4caaf 100644 --- a/.claude/skills/sc-cli-reference/SKILL.md +++ b/.claude/skills/sc-cli-reference/SKILL.md @@ -220,6 +220,15 @@ cargo run --bin sc -- transcript show [--identity ] # decrypt + pri cargo run --bin sc -- transcript list [] [--json] # list transcripts (never decrypts) cargo run --bin sc -- transcript sign [--identity ] # retroactively sign a tip's # transcript(s) (P30) +cargo run --bin sc -- clone|fetch|push --no-transcripts ... # leave transcripts (P30) out of one + # transfer (#211): clone/fetch verify then discard + # received transcripts + their signatures (sender + # still sends them, so no bandwidth saved); push + # does not send them. Per command, not remembered: + # a later plain fetch brings them in; a plain push + # carries them only once the branch moves again. + # Snapshots transfer and verify as usual; no-op for + # git remotes cargo run --bin sc -- ws harvest --transcript [--sign] [--identity ] # attach the # file to each harvested workspace's landed snapshot # (P30; landing status prints before the attach) diff --git a/CLAUDE.md b/CLAUDE.md index 7c22a353..9bc2a53e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -144,7 +144,7 @@ the code, those win. | P27 | Partial clone: `sc clone --filter `, `.sc/promisor`, `sc backfill [--all]`; wire `PROTOCOL_VERSION` 3 | [0037](docs/adr/0037-partial-clone.md) | | P28 | Security hardening: `MAX_OBJECT_SIZE` (256 MiB) caps on every untrusted transfer length; strict ref-name validation | [0039](docs/adr/0039-security-hardening-sweep.md) | | P29 | `sc serve --http` access control: bearer tokens (`sc serve token`), `--read-only`, fail-closed non-loopback bind gate | [0040](docs/adr/0040-sc-http-access-control.md) | -| P30 | Sealed agent-session transcripts: `sc transcript attach/show/list/sign`, always-encrypted body, gc-coupled index | [0038](docs/adr/0038-agent-session-transcripts.md) | +| P30 | Sealed agent-session transcripts: `sc transcript attach/show/list/sign`, always-encrypted body, gc-coupled index; `--no-transcripts` on fetch/clone/push (client-side, per command) | [0038](docs/adr/0038-agent-session-transcripts.md) | | P31 | Listener resource limits: `--max-connections`, `--timeout`, `--max-pack-size` (both transports), capped read-only drain, accept backoff | [0041](docs/adr/0041-listener-resource-limits.md) | | P32 | In-binary TLS: `sc+https://` via leaf crate `tlsio`; accept-new TOFU pinning; public plaintext bind no longer justified by tokens alone | [0042](docs/adr/0042-in-binary-tls-sc-https.md) | | P33 | Randomized protected sealing (fresh DEK + nonce; `RANDOMIZED` perms bit); dual-read of pre-P33 convergent ciphertext; per-checkout keyed stat cache; `sc rewrap` upgrades convergent blobs at the tip | [0043](docs/adr/0043-randomized-protected-encryption.md) | diff --git a/ROADMAP.md b/ROADMAP.md index 8ee5352b..f6760e94 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -881,9 +881,10 @@ scale-&-reach horizon): rewrap/grant/revoke surface — sealed once, to the recipient set at attach time, permanently. Extending P17's rewrap and P16's grant/revoke machinery to transcripts is deferred. -- **`--no-transcripts` transfer knob (P30).** `fetch`/`clone`/`push` - always carry every indexed transcript covering a transferred snapshot; - an opt-out for bandwidth- or exposure-sensitive transfers is deferred. +- **Sender-side `--no-transcripts` for fetch/clone (P30).** The #211 + opt-out is client-side: `fetch`/`clone` still receive transcripts and + discard them, so only `push` saves bandwidth. Having the server skip + them needs a `GetPack` request field and a `PROTOCOL_VERSION` bump. - **`sc export --transcripts=entire` (P30).** Git export unconditionally drops transcripts (reported via `transcripts_dropped`); an opt-in mode that carries them as detached Git notes or a sidecar format is diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 7efe3e88..0c43b792 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -317,6 +317,11 @@ enum Cmd { /// process. Requires `--filter`. #[arg(long, requires = "filter")] lazy: bool, + /// Leave transcript objects (P30) out of this transfer: they are + /// verified and discarded, never stored or indexed. Per command, not + /// remembered by the clone. Git remotes carry no transcripts anyway. + #[arg(long)] + no_transcripts: bool, }, /// Serve a repo to a remote `sc` client, either over stdin/stdout /// (invoked by `ssh` for ssh:// remotes) or over TCP (`sc+http://` @@ -393,6 +398,11 @@ enum Cmd { Fetch { #[arg(default_value = "origin")] remote: String, + /// Leave transcript objects (P30) out of this fetch: they are + /// verified and discarded, never stored or indexed. Per command, not + /// remembered; a later plain fetch brings them in. Git remotes carry no transcripts anyway. + #[arg(long)] + no_transcripts: bool, }, /// Push the current branch to a remote (fast-forward-only). Push { @@ -401,6 +411,11 @@ enum Cmd { /// For git remotes: allow pushing protected ciphertext and dropping secrets. #[arg(long)] include_encrypted: bool, + /// Do not send transcript objects (P30) or their signatures. Sealed + /// bodies stay sealed either way; snapshots still transfer. Ignored + /// for git remotes, which never carry transcripts. + #[arg(long)] + no_transcripts: bool, }, /// Protect a path prefix: files under it are convergently encrypted for the /// named recipients on commit. With `--list` (or no prefix), list the rules. @@ -1012,7 +1027,8 @@ fn main() -> Result<()> { git, filter, lazy, - } => run_clone(src, dst, git, filter, lazy), + no_transcripts, + } => run_clone(src, dst, git, filter, lazy, no_transcripts), Cmd::Cat { target } => run_cat(&target), Cmd::Serve { sub, @@ -1061,11 +1077,15 @@ fn main() -> Result<()> { } }, Cmd::Remote { op } => run_remote(op), - Cmd::Fetch { remote } => run_fetch(&remote), + Cmd::Fetch { + remote, + no_transcripts, + } => run_fetch(&remote, no_transcripts), Cmd::Push { remote, include_encrypted, - } => run_push(&remote, include_encrypted), + no_transcripts, + } => run_push(&remote, include_encrypted, no_transcripts), Cmd::Protect { prefix, to, @@ -3586,7 +3606,14 @@ fn absolute_local_source(src: String) -> String { .unwrap_or(src) } -fn run_clone(src: String, dst: PathBuf, git: bool, filter: Vec, lazy: bool) -> Result<()> { +fn run_clone( + src: String, + dst: PathBuf, + git: bool, + filter: Vec, + lazy: bool, + no_transcripts: bool, +) -> Result<()> { // Auto-detect unambiguous git URL forms (https/http, scp-style, file://): // those can never be sc-native, so no flag is needed. Bare `ssh://` is // ambiguous — it means an sc-native remote (ADR-0022) unless `--git` @@ -3600,7 +3627,7 @@ fn run_clone(src: String, dst: PathBuf, git: bool, filter: Vec, lazy: bo } let src = absolute_local_source(src); let filter_opt = (!filter.is_empty()).then_some(filter.as_slice()); - let repo = scl_repo::Repo::clone_url_filtered(&src, &dst, filter_opt)?; + let repo = scl_repo::Repo::clone_url_opts(&src, &dst, filter_opt, no_transcripts)?; if lazy { scl_repo::promisor::set_lazy(repo.layout(), true)?; } @@ -3944,13 +3971,13 @@ fn run_remote(op: RemoteOp) -> Result<()> { /// remote gets a full-history import into a remote-tracking ref (see /// `run_fetch_git`); an `sc`-kind remote (or unconfigured, defaulting to `sc`) /// uses the existing object-transport fetch. -fn run_fetch(remote: &str) -> Result<()> { +fn run_fetch(remote: &str, no_transcripts: bool) -> Result<()> { let repo = open_repo()?; let cfg = scl_repo::RemoteConfig::load(repo.layout())?; match cfg.kind(remote) { Some(scl_repo::RemoteKind::Git) => run_fetch_git(&repo, remote), _ => { - let remote_refs = repo.fetch(remote)?; + let remote_refs = repo.fetch_opts(remote, no_transcripts)?; println!("fetched {remote}: {} remote branch(es)", remote_refs.len()); for (branch, tip) in remote_refs { println!(" {remote}/{branch} -> {}", tip.short()); @@ -4011,7 +4038,7 @@ fn run_fetch_git(repo: &scl_repo::Repo, remote: &str) -> Result<()> { Ok(()) } -fn run_push(remote: &str, include_encrypted: bool) -> Result<()> { +fn run_push(remote: &str, include_encrypted: bool, no_transcripts: bool) -> Result<()> { let repo = open_repo()?; let cfg = scl_repo::RemoteConfig::load(repo.layout())?; match cfg.kind(remote) { @@ -4039,7 +4066,7 @@ fn run_push(remote: &str, include_encrypted: bool) -> Result<()> { run_push_git(&repo, remote, include_encrypted) } _ => { - let tip = repo.push(remote)?; + let tip = repo.push_opts(remote, no_transcripts)?; println!("pushed to {remote}: {}", tip.short()); Ok(()) } @@ -4834,6 +4861,7 @@ mod tests { false, Vec::new(), false, + false, ) .unwrap(); let repo = scl_repo::Repo::open(&dst).unwrap(); @@ -4884,6 +4912,7 @@ mod tests { false, Vec::new(), false, + false, ) .unwrap_err(); std::env::remove_var("SC_SSH"); diff --git a/crates/cli/tests/transcripts.rs b/crates/cli/tests/transcripts.rs index fa25209d..16dfa81a 100644 --- a/crates/cli/tests/transcripts.rs +++ b/crates/cli/tests/transcripts.rs @@ -288,3 +288,200 @@ fn ws_harvest_transcript_prints_landing_before_reporting_attach_failure() { std::fs::remove_dir_all(&root).unwrap(); } + +/// `--no-transcripts` (#211) fixture: an `origin` repo with a signed commit +/// carrying a signed transcript. Returns (root, origin dir, identity file). +fn origin_with_transcript( + tag: &str, +) -> (std::path::PathBuf, std::path::PathBuf, std::path::PathBuf) { + let root = tmp(tag); + let origin = root.join("origin"); + std::fs::create_dir_all(&origin).unwrap(); + let keys = root.join("keys"); + std::fs::create_dir_all(&keys).unwrap(); + let (id, enc_pk, _sig_pk) = keygen(&keys, "alice"); + assert!(sc(&origin, &["init"]).status.success()); + std::fs::write( + origin.join(".sc/recipients.toml"), + format!("[recipients]\nalice = \"{enc_pk}\"\n"), + ) + .unwrap(); + std::fs::write(origin.join("a.txt"), "hello\n").unwrap(); + assert!(sc(&origin, &["commit", "-m", "c1"]).status.success()); + let idp = id.to_str().unwrap(); + assert!(sc(&origin, &["sign", "main", "--identity", idp]) + .status + .success()); + let body = keys.join("session.txt"); + std::fs::write(&body, "USER: fix\nAGENT: done\n").unwrap(); + let attach = sc( + &origin, + &[ + "transcript", + "attach", + "main", + body.to_str().unwrap(), + "--agent", + "claude", + "--sign", + "--identity", + idp, + ], + ); + assert!( + attach.status.success(), + "{}", + String::from_utf8_lossy(&attach.stderr) + ); + (root, origin, id) +} + +/// Number of lines in a repo's `.sc/transcripts` index (0 if absent). +fn transcript_index_len(repo: &Path) -> usize { + std::fs::read_to_string(repo.join(".sc/transcripts")) + .map(|t| t.lines().filter(|l| !l.trim().is_empty()).count()) + .unwrap_or(0) +} + +/// The snapshot is intact and verifiable, and the repo shows no transcript. +fn assert_snapshot_ok_and_no_transcript(repo: &Path, refname: &str, file: &str) { + let cat = sc(repo, &["cat", &format!("{refname}:{file}")]); + assert!( + cat.status.success(), + "snapshot content transfers: {}", + String::from_utf8_lossy(&cat.stderr) + ); + let verify = sc(repo, &["verify", refname]); + assert!( + verify.status.success(), + "snapshot signature verifies: {}", + String::from_utf8_lossy(&verify.stderr) + ); + assert_eq!(transcript_index_len(repo), 0, "no transcript index entry"); + assert!( + !stdout(&sc(repo, &["log", refname])).contains("transcript:"), + "log shows no transcript marker" + ); +} + +#[test] +fn clone_no_transcripts_leaves_transcripts_out_and_plain_fetch_brings_them() { + let (root, origin, id) = origin_with_transcript("nt-clone"); + let dst = root.join("clone"); + let out = sc( + &root, + &[ + "clone", + origin.to_str().unwrap(), + dst.to_str().unwrap(), + "--no-transcripts", + ], + ); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stderr) + ); + assert_snapshot_ok_and_no_transcript(&dst, "main", "a.txt"); + + // Per command: a later plain fetch brings the sealed transcript in. + assert!(sc(&dst, &["fetch"]).status.success()); + assert_eq!(transcript_index_len(&dst), 1); + let show = sc( + &dst, + &[ + "transcript", + "show", + "main", + "--identity", + id.to_str().unwrap(), + ], + ); + assert!(show.status.success()); + assert!(stdout(&show).contains("USER: fix")); + std::fs::remove_dir_all(&root).unwrap(); +} + +#[test] +fn fetch_no_transcripts_leaves_transcripts_out() { + let (root, origin, _id) = origin_with_transcript("nt-fetch"); + let dst = root.join("clone"); + assert!(sc( + &root, + &[ + "clone", + origin.to_str().unwrap(), + dst.to_str().unwrap(), + "--no-transcripts" + ], + ) + .status + .success()); + // Origin moves on with a second commit; the clone fetches it opted out. + std::fs::write(origin.join("b.txt"), "two\n").unwrap(); + assert!(sc(&origin, &["commit", "-m", "c2"]).status.success()); + let out = sc(&dst, &["fetch", "--no-transcripts"]); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stderr) + ); + assert_snapshot_ok_and_no_transcript(&dst, "origin/main", "b.txt"); + assert_eq!(transcript_index_len(&dst), 0); + + assert!(sc(&dst, &["fetch"]).status.success()); + assert_eq!(transcript_index_len(&dst), 1); + std::fs::remove_dir_all(&root).unwrap(); +} + +#[test] +fn push_no_transcripts_sends_snapshot_but_not_transcript() { + let (root, origin, id) = origin_with_transcript("nt-push"); + let dst = root.join("clone"); + assert!(sc( + &root, + &["clone", origin.to_str().unwrap(), dst.to_str().unwrap()] + ) + .status + .success()); + // The clone commits, signs and attaches a transcript, then pushes opted out. + let idp = id.to_str().unwrap(); + // recipients.toml is local config, not cloned. + std::fs::copy( + origin.join(".sc/recipients.toml"), + dst.join(".sc/recipients.toml"), + ) + .unwrap(); + std::fs::write(dst.join("b.txt"), "two\n").unwrap(); + assert!(sc(&dst, &["commit", "-m", "c2"]).status.success()); + assert!(sc(&dst, &["sign", "main", "--identity", idp]) + .status + .success()); + let body = root.join("keys/s2.txt"); + std::fs::write(&body, "second session\n").unwrap(); + assert!(sc( + &dst, + &[ + "transcript", + "attach", + "main", + body.to_str().unwrap(), + "--identity", + idp + ], + ) + .status + .success()); + let before = transcript_index_len(&origin); + let out = sc(&dst, &["push", "--no-transcripts"]); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stderr) + ); + // Origin got the new snapshot (verifiable) and no new transcript. + assert!(sc(&origin, &["cat", "main:b.txt"]).status.success()); + assert!(sc(&origin, &["verify", "main"]).status.success()); + assert_eq!(transcript_index_len(&origin), before); + std::fs::remove_dir_all(&root).unwrap(); +} diff --git a/crates/repo/src/sync.rs b/crates/repo/src/sync.rs index 5ca6a6a7..b860f368 100644 --- a/crates/repo/src/sync.rs +++ b/crates/repo/src/sync.rs @@ -79,6 +79,21 @@ impl Repo { src_url: &str, dst: impl AsRef, filter: Option<&[String]>, + ) -> Result { + Self::clone_url_opts(src_url, dst, filter, false) + } + + /// [`Repo::clone_url_filtered`] with the `--no-transcripts` switch + /// (ADR-0038 addendum, #211). With `no_transcripts`, transcript objects + /// (and signatures over them) in the received pack are verified but not + /// stored, so the clone holds no transcript object and no index entry. + /// Snapshots, trees and blobs transfer unchanged. Per command, not + /// persisted: a later plain `fetch` brings the transcripts in. + pub fn clone_url_opts( + src_url: &str, + dst: impl AsRef, + filter: Option<&[String]>, + no_transcripts: bool, ) -> Result { // Before the network or the destination directory: a blank prefix // would be persisted as a sparse line that reloads as a full view. @@ -99,13 +114,14 @@ impl Repo { let mut store = store_arc.lock().unwrap(); // Fresh clone dst has no local refs yet → no haves → full transfer // (of whatever `filter` scopes it to). - transfer_objects( + transfer_objects_opts( &dst_repo.layout, transport.as_ref(), &mut store, &tips, &[], filter, + no_transcripts, )?; // Clone-specific belt-and-suspenders (P22 Task 3): the transfer // above already indexes every signature object it wrote via @@ -351,6 +367,19 @@ impl Repo { /// Fetch objects + branch tips from `remote` into remote-tracking refs /// (`refs/remotes//`). Local branches are left untouched. pub fn fetch(&self, remote: &str) -> Result> { + self.fetch_opts(remote, false) + } + + /// [`Repo::fetch`] with the `--no-transcripts` switch (ADR-0038 + /// addendum, #211): received transcript objects and their signatures are + /// verified and discarded, never stored or indexed. The sender still + /// puts them on the wire (no wire flag), so this saves disk and + /// exposure, not bandwidth. A later plain fetch brings them in. + pub fn fetch_opts( + &self, + remote: &str, + no_transcripts: bool, + ) -> Result> { let cfg = RemoteConfig::load(&self.layout)?; let url = cfg .url(remote) @@ -379,13 +408,14 @@ impl Repo { let mut store = store_arc.lock().unwrap(); // Derive haves from local refs before the mutable borrow for transfer. let haves = local_have_tips(&self.layout, &store)?; - transfer_objects( + transfer_objects_opts( &self.layout, transport.as_ref(), &mut store, &tips, &haves, None, + no_transcripts, )?; } for (branch, tip) in &remote_refs { @@ -398,6 +428,14 @@ impl Repo { /// branch if absent. Errors `NonFastForward` if the remote has commits not /// reachable from the local tip. pub fn push(&self, remote: &str) -> Result { + self.push_opts(remote, false) + } + + /// [`Repo::push`] with the `--no-transcripts` switch (ADR-0038 addendum, + /// #211): indexed transcripts, and signatures over them, are left out of + /// the pack, so the remote receives no transcript object or index entry + /// from this push. This is the one command that saves bandwidth. + pub fn push_opts(&self, remote: &str, no_transcripts: bool) -> Result { let cfg = RemoteConfig::load(&self.layout)?; let url = cfg .url(remote) @@ -485,8 +523,11 @@ impl Repo { // not the snapshot's, so it only surfaces if the transcript // ids are folded into the signature query too (review-caught // alongside the `get_pack` fix — same omission, same shape). - let transcript_ids = - crate::transcripts::indexed_transcript_ids_for(&self.layout, &snaps)?; + let transcript_ids = if no_transcripts { + Vec::new() + } else { + crate::transcripts::indexed_transcript_ids_for(&self.layout, &snaps)? + }; let sig_targets: Vec = snaps.iter().chain(transcript_ids.iter()).copied().collect(); let sig_ids = crate::signatures::indexed_signature_ids_for(&self.layout, &sig_targets)?; @@ -566,13 +607,32 @@ fn transfer_objects( tips: &[ObjectId], haves: &[ObjectId], filter: Option<&[String]>, +) -> Result<()> { + transfer_objects_opts(layout, transport, store, tips, haves, filter, false) +} + +/// [`transfer_objects`] with `no_transcripts`: ingest through +/// [`crate::transport::ingest_pack_file_without_transcripts`], which verifies +/// but does not store transcripts. +fn transfer_objects_opts( + layout: &Layout, + transport: &dyn Transport, + store: &mut Store, + tips: &[ObjectId], + haves: &[ObjectId], + filter: Option<&[String]>, + no_transcripts: bool, ) -> Result<()> { let guard = crate::transport::TempPackGuard::new(layout)?; { let mut f = std::fs::File::create(guard.path())?; transport.get_pack(tips, haves, filter, &mut f)?; } - crate::transport::ingest_pack_file(layout, store, guard.path())?; + if no_transcripts { + crate::transport::ingest_pack_file_without_transcripts(layout, store, guard.path())?; + } else { + crate::transport::ingest_pack_file(layout, store, guard.path())?; + } Ok(()) } @@ -580,7 +640,7 @@ fn transfer_objects( mod tests { use crate::repo::Repo; use crate::signatures::SigStatus; - use crate::sync::transfer_objects; + use crate::sync::{transfer_objects, transfer_objects_opts}; use scl_core::ObjectId; #[test] @@ -869,6 +929,212 @@ mod tests { std::fs::remove_dir_all(&b_root).unwrap(); } + /// `--no-transcripts` fixture (#211): an origin with a signed snapshot + /// carrying a signed transcript. Returns the repo, snapshot, transcript + /// id and the identity that sealed and signed both. + fn origin_with_signed_transcript( + root: &std::path::Path, + ) -> (Repo, ObjectId, ObjectId, scl_crypto::Identity) { + let _ = std::fs::remove_dir_all(root); + std::fs::create_dir_all(root).unwrap(); + let a = Repo::init(root).unwrap(); + std::fs::write(root.join("f1"), b"one").unwrap(); + let snap = a.commit("t", "c1").unwrap(); + let (_s, identity) = scl_crypto::generate_identity_v2(); + a.sign_snapshot(snap, &identity).unwrap(); + let tid = a + .attach_transcript(snap, "claude-code", "s1", b"body", &[identity.enc.public()]) + .unwrap(); + a.sign_transcript(tid, &identity).unwrap(); + (a, snap, tid, identity) + } + + /// Assert `r` holds no trace of transcript `tid` (object, index entry, + /// signature) while snapshot `snap` is fully present: its whole closure + /// resolves and its own signature arrived. + fn assert_no_transcript_but_snapshot_intact(r: &Repo, snap: ObjectId, tid: ObjectId) { + { + let arc = r.store_arc(); + let mut store = arc.lock().unwrap(); + assert!( + !store.contains(&tid), + "transcript object must not be stored" + ); + crate::reachable::reachable_objects(&mut *store, &[snap]) + .expect("snapshot closure transfers and verifies"); + } + assert!(crate::transcripts::load(r.layout()).unwrap().is_empty()); + assert!(r.transcripts_for(&snap).unwrap().is_empty()); + assert!( + r.signatures_for(&tid).unwrap().is_empty(), + "no signature index entry may point at the dropped transcript" + ); + assert_eq!( + r.signatures_for(&snap).unwrap().len(), + 1, + "the snapshot's own signature still arrives" + ); + } + + #[test] + fn clone_no_transcripts_drops_transcript_keeps_snapshot() { + let pid = std::process::id(); + let a_root = std::env::temp_dir().join(format!("scl-notrans-clone-a-{pid}")); + let b_root = std::env::temp_dir().join(format!("scl-notrans-clone-b-{pid}")); + let _ = std::fs::remove_dir_all(&b_root); + let (a, snap, tid, identity) = origin_with_signed_transcript(&a_root); + + let b = Repo::clone_url_opts(&a_root.display().to_string(), &b_root, None, true).unwrap(); + assert_no_transcript_but_snapshot_intact(&b, snap, tid); + + // Per command, not persisted: a later plain fetch brings it in, + // sealed and signed. + b.fetch("origin").unwrap(); + let got = b.transcripts_for(&snap).unwrap(); + assert!(got.iter().any(|(t, _)| *t == tid)); + assert_eq!( + b.open_transcript(&tid, &identity.enc).unwrap().as_slice(), + b"body" + ); + assert_eq!(b.signatures_for(&tid).unwrap().len(), 1); + + drop(a); + drop(b); + std::fs::remove_dir_all(&a_root).unwrap(); + std::fs::remove_dir_all(&b_root).unwrap(); + } + + #[test] + fn fetch_no_transcripts_drops_transcript_keeps_snapshot() { + let pid = std::process::id(); + let a_root = std::env::temp_dir().join(format!("scl-notrans-fetch-a-{pid}")); + let b_root = std::env::temp_dir().join(format!("scl-notrans-fetch-b-{pid}")); + let _ = std::fs::remove_dir_all(&b_root); + let (a, snap, tid, _identity) = origin_with_signed_transcript(&a_root); + // Clone opted out, then fetch opted out. + let b = Repo::clone_url_opts(&a_root.display().to_string(), &b_root, None, true).unwrap(); + std::fs::write(a_root.join("f2"), b"two").unwrap(); + let snap2 = a.commit("t", "c2").unwrap(); + let tid2 = a + .attach_transcript( + snap2, + "claude-code", + "s2", + b"body2", + &[scl_crypto::generate_identity_v2().1.enc.public()], + ) + .unwrap(); + + b.fetch_opts("origin", true).unwrap(); + assert_no_transcript_but_snapshot_intact(&b, snap, tid); + { + let arc = b.store_arc(); + let mut store = arc.lock().unwrap(); + assert!(!store.contains(&tid2)); + // The new snapshot arrived and its closure verifies. + crate::reachable::reachable_objects(&mut *store, &[snap2]).unwrap(); + } + assert!(crate::transcripts::load(b.layout()).unwrap().is_empty()); + + // A plain fetch now brings both transcripts in. + b.fetch("origin").unwrap(); + let idx = crate::transcripts::load(b.layout()).unwrap(); + assert!(idx.contains(&(snap, tid)) && idx.contains(&(snap2, tid2))); + + drop(a); + drop(b); + std::fs::remove_dir_all(&a_root).unwrap(); + std::fs::remove_dir_all(&b_root).unwrap(); + } + + #[test] + fn push_no_transcripts_sends_snapshot_not_transcript() { + let pid = std::process::id(); + let a_root = std::env::temp_dir().join(format!("scl-notrans-push-a-{pid}")); + let b_root = std::env::temp_dir().join(format!("scl-notrans-push-b-{pid}")); + let _ = std::fs::remove_dir_all(&b_root); + std::fs::create_dir_all(&a_root).unwrap(); + let a = Repo::init(&a_root).unwrap(); + std::fs::write(a_root.join("f1"), b"one").unwrap(); + a.commit("t", "c1").unwrap(); + let b = Repo::clone_to(&a_root, &b_root).unwrap(); + // A pushed-into repo must not be held open by its owner (single-writer lock). + drop(a); + + // B commits, signs and attaches a signed transcript, then pushes + // without transcripts. + std::fs::write(b_root.join("f2"), b"two").unwrap(); + let snap = b.commit("t", "c2").unwrap(); + let (_s, identity) = scl_crypto::generate_identity_v2(); + b.sign_snapshot(snap, &identity).unwrap(); + let tid = b + .attach_transcript(snap, "claude-code", "s1", b"body", &[identity.enc.public()]) + .unwrap(); + b.sign_transcript(tid, &identity).unwrap(); + b.push_opts("origin", true).unwrap(); + let a = Repo::open(&a_root).unwrap(); + assert_no_transcript_but_snapshot_intact(&a, snap, tid); + drop(a); + + // The next plain push that moves the branch carries it. + std::fs::write(b_root.join("f3"), b"three").unwrap(); + b.commit("t", "c3").unwrap(); + b.push("origin").unwrap(); + let a = Repo::open(&a_root).unwrap(); + assert!(a + .transcripts_for(&snap) + .unwrap() + .iter() + .any(|(t, _)| *t == tid)); + assert_eq!(a.signatures_for(&tid).unwrap().len(), 1); + + drop(a); + drop(b); + std::fs::remove_dir_all(&a_root).unwrap(); + std::fs::remove_dir_all(&b_root).unwrap(); + } + + #[test] + fn no_transcripts_fetch_over_the_wire_drops_what_the_server_over_sends() { + // The wire server always over-sends indexed transcripts (no flag); + // the receiver must verify and discard them. Mirrors + // `signatures_ride_ssh_transport`. + use crate::stdio_transport::WireClient; + use crate::wire; + + let pid = std::process::id(); + let src_root = std::env::temp_dir().join(format!("scl-notrans-wire-src-{pid}")); + let dst_root = std::env::temp_dir().join(format!("scl-notrans-wire-dst-{pid}")); + let _ = std::fs::remove_dir_all(&dst_root); + let (src, snap, tid, _identity) = origin_with_signed_transcript(&src_root); + + let (client_read, mut server_write) = std::io::pipe().unwrap(); + let (mut server_read, client_write) = std::io::pipe().unwrap(); + let server_root = src_root.clone(); + let server = std::thread::spawn(move || { + wire::serve(&server_root, &mut server_read, &mut server_write) + }); + let client = WireClient::handshake(client_read, client_write).unwrap(); + + let dst = Repo::init(&dst_root).unwrap(); + { + let store_arc = dst.vfs().store(); + let mut store = store_arc.lock().unwrap(); + transfer_objects_opts(&dst.layout, &client, &mut store, &[snap], &[], None, true) + .unwrap(); + } + client.bye().unwrap(); + drop(client); + server.join().unwrap().unwrap(); + + assert_no_transcript_but_snapshot_intact(&dst, snap, tid); + + drop(src); + drop(dst); + std::fs::remove_dir_all(&src_root).unwrap(); + std::fs::remove_dir_all(&dst_root).unwrap(); + } + #[test] fn signatures_ride_ssh_transport() { // The wire-protocol pipe harness `WireClient` <-> `wire::serve` IS diff --git a/crates/repo/src/transport.rs b/crates/repo/src/transport.rs index c2616bc9..389f1807 100644 --- a/crates/repo/src/transport.rs +++ b/crates/repo/src/transport.rs @@ -453,12 +453,39 @@ pub(crate) fn ingest_pack_file_checked( max_records: Option, check: impl FnOnce(&std::collections::BTreeSet) -> Result<()>, ) -> Result> { + ingest_pack_file_impl(layout, store, path, max_records, check, false) +} + +/// [`ingest_pack_file`] for a `--no-transcripts` receiver (ADR-0038 addendum, +/// #211): every record is still hash-verified in pass 1, but pass 2 does not +/// write `Transcript` objects, nor a signature whose target is a transcript +/// dropped from this same pack (it would index against a transcript that is +/// not here). The sender over-sends regardless of what the receiver wants (no +/// wire flag), so this saves disk and exposure, not bandwidth. +pub(crate) fn ingest_pack_file_without_transcripts( + layout: &Layout, + store: &mut Store, + path: &std::path::Path, +) -> Result> { + ingest_pack_file_impl(layout, store, path, None, |_| Ok(()), true) +} + +fn ingest_pack_file_impl( + layout: &Layout, + store: &mut Store, + path: &std::path::Path, + max_records: Option, + check: impl FnOnce(&std::collections::BTreeSet) -> Result<()>, + skip_transcripts: bool, +) -> Result> { + // Transcript ids seen in pass 1; pass 2 uses them to also drop their signatures. + let mut dropped = std::collections::BTreeSet::new(); // Pass 1: verify every record's hash; write nothing. { let f = std::fs::File::open(path)?; let mut seen = std::collections::BTreeSet::new(); let mut records = 0usize; - scl_core::pack::parse_pack_reader(f, |id, _obj| { + scl_core::pack::parse_pack_reader(f, |id, obj| { records += 1; if max_records.is_some_and(|max| records > max) { return Err(scl_core::Error::PackCorrupt(format!( @@ -466,6 +493,9 @@ pub(crate) fn ingest_pack_file_checked( max_records.unwrap_or(0) ))); } + if skip_transcripts && matches!(obj, scl_core::Object::Transcript(_)) { + dropped.insert(id); + } seen.insert(id); Ok(()) })?; @@ -475,6 +505,11 @@ pub(crate) fn ingest_pack_file_checked( let f = std::fs::File::open(path)?; let mut ids = Vec::new(); scl_core::pack::parse_pack_reader(f, |id, obj| { + if dropped.contains(&id) + || matches!(&obj, scl_core::Object::Signature(s) if dropped.contains(&s.snapshot)) + { + return Ok(()); + } let got = store.put(obj)?; // Defense in depth: pass 1 already verified this record's hash; this // guards against a future change that weakens that. diff --git a/docs/adr/0038-agent-session-transcripts.md b/docs/adr/0038-agent-session-transcripts.md index f00424a7..8e30b227 100644 --- a/docs/adr/0038-agent-session-transcripts.md +++ b/docs/adr/0038-agent-session-transcripts.md @@ -99,9 +99,8 @@ pipe-safety discipline). with a wider audience is an explicit grant/rewrap act, not a repo-visibility accident. - New store growth axis: transcripts are KB–MB, not signature-sized. - Over-send-on-transfer is correct but potentially heavy; a - `--no-transcripts` fetch knob is anticipated as a fast-follow if - measurement warrants (logged, never silent). + Over-send-on-transfer is correct but potentially heavy; the + `--no-transcripts` opt-out (see the addendum below) is that knob. - Wraps living inside the object mean recipient cutover (P17 `sc rewrap`) cannot re-wrap in place — it must mint replacement transcript objects and re-point the index. Acceptable for the MVP (transcripts are @@ -148,3 +147,33 @@ pipe-safety discipline). Also does not defend: secrets echoed into a transcript remaining readable to *authorized* transcript recipients (scan-and-warn mitigates, rotation remedies); content quality or truthfulness of the recorded session. + +## Addendum: `--no-transcripts` on fetch, clone and push (2026-10, #211) + +`sc fetch`, `sc clone` and `sc push` accept `--no-transcripts`. Decisions: + +1. **Client-side only, no `PROTOCOL_VERSION` bump.** `GetPack` has no field a + receiver could use to say "no transcripts", and the sender over-sends + indexed transcripts unconditionally. So the opt-out lives where the + client already has control: + - `push`: the client builds the outgoing set, so it leaves out indexed + transcripts and the signatures keyed by them. This saves bandwidth. + - `fetch` / `clone`: the server still sends them. The receiver verifies + every record in pass 1 of `ingest_pack_file` as usual, then pass 2 does + not write `Transcript` objects, nor a signature whose target is a + transcript dropped from the same pack. This saves disk and exposure + (no ciphertext, no index entry), **not** bandwidth. A server-side skip + would need a new `GetPack` field and a version bump; it is a deferred + follow-on in `ROADMAP.md`. +2. **Per command, not persisted.** A clone made with `--no-transcripts` + records nothing; a later plain `sc fetch` brings every indexed transcript + in (the sender's over-send covers snapshots the receiver already has). + A plain `sc push` after a `--no-transcripts` push carries them only once + the branch moves again, because `push` returns early when the remote tip + already equals the local tip (the same limit a retroactive attach has). +3. **Sealing and integrity unchanged.** Bodies stay sealed whether or not they + travel. Snapshots, trees, blobs and the snapshot's own signatures transfer + and verify exactly as before. Index entries are left out with the objects, + so no `.sc/transcripts` or `.sc/signatures` entry points at a transcript + the repo does not hold. Git remotes never carry transcripts, so the flag is + a no-op there. From d13ba337c94a96c4034385a95f30c37f3d826103 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Tue, 20 Oct 2026 09:09:35 +0300 Subject: [PATCH 2/5] test(cli): require signed history and a successful log in --no-transcripts checks (ref #211) --- crates/cli/tests/transcripts.rs | 48 ++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/crates/cli/tests/transcripts.rs b/crates/cli/tests/transcripts.rs index 16dfa81a..83e9cb45 100644 --- a/crates/cli/tests/transcripts.rs +++ b/crates/cli/tests/transcripts.rs @@ -299,11 +299,14 @@ fn origin_with_transcript( std::fs::create_dir_all(&origin).unwrap(); let keys = root.join("keys"); std::fs::create_dir_all(&keys).unwrap(); - let (id, enc_pk, _sig_pk) = keygen(&keys, "alice"); + let (id, enc_pk, sig_pk) = keygen(&keys, "alice"); assert!(sc(&origin, &["init"]).status.success()); std::fs::write( origin.join(".sc/recipients.toml"), - format!("[recipients]\nalice = \"{enc_pk}\"\n"), + format!( + "[recipients]\nalice = \"{enc_pk}\"\n\n[signing]\nalice = \"{sig_pk}\"\n\n\ + [signers]\ntrusted = [\"alice\"]\n" + ), ) .unwrap(); std::fs::write(origin.join("a.txt"), "hello\n").unwrap(); @@ -336,6 +339,16 @@ fn origin_with_transcript( (root, origin, id) } +/// recipients.toml is local config, not cloned: copy it so `sc verify +/// --require` can resolve the trusted signer in `dst`. +fn share_config(origin: &Path, dst: &Path) { + std::fs::copy( + origin.join(".sc/recipients.toml"), + dst.join(".sc/recipients.toml"), + ) + .unwrap(); +} + /// Number of lines in a repo's `.sc/transcripts` index (0 if absent). fn transcript_index_len(repo: &Path) -> usize { std::fs::read_to_string(repo.join(".sc/transcripts")) @@ -351,15 +364,21 @@ fn assert_snapshot_ok_and_no_transcript(repo: &Path, refname: &str, file: &str) "snapshot content transfers: {}", String::from_utf8_lossy(&cat.stderr) ); - let verify = sc(repo, &["verify", refname]); + let verify = sc(repo, &["verify", "--require", refname]); assert!( verify.status.success(), "snapshot signature verifies: {}", String::from_utf8_lossy(&verify.stderr) ); assert_eq!(transcript_index_len(repo), 0, "no transcript index entry"); + let log = sc(repo, &["log"]); assert!( - !stdout(&sc(repo, &["log", refname])).contains("transcript:"), + log.status.success(), + "log: {}", + String::from_utf8_lossy(&log.stderr) + ); + assert!( + !stdout(&log).contains("transcript:"), "log shows no transcript marker" ); } @@ -382,6 +401,7 @@ fn clone_no_transcripts_leaves_transcripts_out_and_plain_fetch_brings_them() { "{}", String::from_utf8_lossy(&out.stderr) ); + share_config(&origin, &dst); assert_snapshot_ok_and_no_transcript(&dst, "main", "a.txt"); // Per command: a later plain fetch brings the sealed transcript in. @@ -404,7 +424,7 @@ fn clone_no_transcripts_leaves_transcripts_out_and_plain_fetch_brings_them() { #[test] fn fetch_no_transcripts_leaves_transcripts_out() { - let (root, origin, _id) = origin_with_transcript("nt-fetch"); + let (root, origin, id) = origin_with_transcript("nt-fetch"); let dst = root.join("clone"); assert!(sc( &root, @@ -417,9 +437,16 @@ fn fetch_no_transcripts_leaves_transcripts_out() { ) .status .success()); + share_config(&origin, &dst); // Origin moves on with a second commit; the clone fetches it opted out. std::fs::write(origin.join("b.txt"), "two\n").unwrap(); assert!(sc(&origin, &["commit", "-m", "c2"]).status.success()); + assert!(sc( + &origin, + &["sign", "main", "--identity", id.to_str().unwrap()] + ) + .status + .success()); let out = sc(&dst, &["fetch", "--no-transcripts"]); assert!( out.status.success(), @@ -446,12 +473,7 @@ fn push_no_transcripts_sends_snapshot_but_not_transcript() { .success()); // The clone commits, signs and attaches a transcript, then pushes opted out. let idp = id.to_str().unwrap(); - // recipients.toml is local config, not cloned. - std::fs::copy( - origin.join(".sc/recipients.toml"), - dst.join(".sc/recipients.toml"), - ) - .unwrap(); + share_config(&origin, &dst); std::fs::write(dst.join("b.txt"), "two\n").unwrap(); assert!(sc(&dst, &["commit", "-m", "c2"]).status.success()); assert!(sc(&dst, &["sign", "main", "--identity", idp]) @@ -481,7 +503,9 @@ fn push_no_transcripts_sends_snapshot_but_not_transcript() { ); // Origin got the new snapshot (verifiable) and no new transcript. assert!(sc(&origin, &["cat", "main:b.txt"]).status.success()); - assert!(sc(&origin, &["verify", "main"]).status.success()); + assert!(sc(&origin, &["verify", "--require", "main"]) + .status + .success()); assert_eq!(transcript_index_len(&origin), before); std::fs::remove_dir_all(&root).unwrap(); } From 95fc116751d7003d2d008afdf77a0428ccc21b4f Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Tue, 20 Oct 2026 09:20:01 +0300 Subject: [PATCH 3/5] docs,test: tighten --no-transcripts wording, name bucket remotes, add sc+http test (ref #211) Hash-checked (not signature-verified), 'not written by this transfer' rather than 'never stored'. Bucket remotes carry no transcripts, so the flag does nothing on fetch/clone there (#229). ADR addendum notes the tombstone interaction (#226). --- .claude/skills/sc-cli-reference/SKILL.md | 5 +- crates/cli/src/main.rs | 25 ++++--- crates/repo/src/http_transport.rs | 84 ++++++++++++++++++++++ crates/repo/src/sync.rs | 17 +++-- crates/repo/src/transport.rs | 3 +- docs/adr/0038-agent-session-transcripts.md | 47 ++++++++---- 6 files changed, 149 insertions(+), 32 deletions(-) diff --git a/.claude/skills/sc-cli-reference/SKILL.md b/.claude/skills/sc-cli-reference/SKILL.md index dcf4caaf..4949f268 100644 --- a/.claude/skills/sc-cli-reference/SKILL.md +++ b/.claude/skills/sc-cli-reference/SKILL.md @@ -221,14 +221,15 @@ cargo run --bin sc -- transcript list [] [--json] # list transcripts (nev cargo run --bin sc -- transcript sign [--identity ] # retroactively sign a tip's # transcript(s) (P30) cargo run --bin sc -- clone|fetch|push --no-transcripts ... # leave transcripts (P30) out of one - # transfer (#211): clone/fetch verify then discard + # transfer (#211): clone/fetch hash-check then discard # received transcripts + their signatures (sender # still sends them, so no bandwidth saved); push # does not send them. Per command, not remembered: # a later plain fetch brings them in; a plain push # carries them only once the branch moves again. # Snapshots transfer and verify as usual; no-op for - # git remotes + # git and bucket (sc+wal://, sc+s3://) remotes + # (push to a bucket still skips the upload) cargo run --bin sc -- ws harvest --transcript [--sign] [--identity ] # attach the # file to each harvested workspace's landed snapshot # (P30; landing status prints before the attach) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 0c43b792..2a65396f 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -317,9 +317,12 @@ enum Cmd { /// process. Requires `--filter`. #[arg(long, requires = "filter")] lazy: bool, - /// Leave transcript objects (P30) out of this transfer: they are - /// verified and discarded, never stored or indexed. Per command, not - /// remembered by the clone. Git remotes carry no transcripts anyway. + /// Leave transcript objects (P30) out of this transfer: the server + /// still sends them, the client hash-checks and discards them, so + /// this transfer writes none and indexes none. Per command, not + /// remembered by the clone; a later plain fetch brings them in. + /// Does nothing for git remotes and bucket remotes (sc+wal://, + /// sc+s3://), which carry no transcripts. #[arg(long)] no_transcripts: bool, }, @@ -398,9 +401,13 @@ enum Cmd { Fetch { #[arg(default_value = "origin")] remote: String, - /// Leave transcript objects (P30) out of this fetch: they are - /// verified and discarded, never stored or indexed. Per command, not - /// remembered; a later plain fetch brings them in. Git remotes carry no transcripts anyway. + /// Leave transcript objects (P30) out of this fetch: the server + /// still sends them, the client hash-checks and discards them, so + /// this fetch writes none and indexes none (a new signature over a + /// transcript you already hold is dropped too). Per command, not + /// remembered; a later plain fetch brings them in. Does nothing for + /// git remotes and bucket remotes (sc+wal://, sc+s3://), which + /// carry no transcripts. #[arg(long)] no_transcripts: bool, }, @@ -412,8 +419,10 @@ enum Cmd { #[arg(long)] include_encrypted: bool, /// Do not send transcript objects (P30) or their signatures. Sealed - /// bodies stay sealed either way; snapshots still transfer. Ignored - /// for git remotes, which never carry transcripts. + /// bodies stay sealed either way; snapshots still transfer. Does + /// nothing for git remotes, which never carry transcripts. A bucket + /// remote (sc+wal://, sc+s3://) is stored but never served them, so + /// there the flag only spares the upload. #[arg(long)] no_transcripts: bool, }, diff --git a/crates/repo/src/http_transport.rs b/crates/repo/src/http_transport.rs index a57cf7d4..53946835 100644 --- a/crates/repo/src/http_transport.rs +++ b/crates/repo/src/http_transport.rs @@ -1772,6 +1772,90 @@ mod tests { let _ = std::fs::remove_dir_all(bare_dir.parent().unwrap()); } + /// `--no-transcripts` (#211) over a real served remote: the server + /// over-sends transcripts on clone/fetch and the client drops them, and a + /// push leaves them out of the upload. Snapshots verify throughout. + #[test] + fn no_transcripts_clone_fetch_push_over_real_http() { + use crate::repo::Repo; + let (_s, identity) = scl_crypto::generate_identity_v2(); + let recipients = [identity.enc.public()]; + let src_root = tmp_repo("notrans-src"); + let (snap1, tid1) = { + let src = Repo::open(&src_root).unwrap(); + std::fs::write(src_root.join("a.txt"), b"one").unwrap(); + let snap = src.commit("t", "c1").unwrap(); + src.sign_snapshot(snap, &identity).unwrap(); + let tid = src + .attach_transcript(snap, "claude-code", "s1", b"body", &recipients) + .unwrap(); + src.sign_transcript(tid, &identity).unwrap(); + (snap, tid) + }; + let port = spawn_real_http_server(src_root.clone()); + let url = format!("sc+http://127.0.0.1:{port}/repo"); + + // No transcript object, index entry or signature for `tid` in `r`. + let absent = |r: &Repo, tid: ObjectId| { + let arc = r.store_arc(); + assert!(!arc.lock().unwrap().contains(&tid)); + assert!(crate::transcripts::load(r.layout()).unwrap().is_empty()); + assert!(r.signatures_for(&tid).unwrap().is_empty()); + }; + + // clone: snapshot and its signature arrive, the transcript does not. + let dst_root = + std::env::temp_dir().join(format!("scl-http-notrans-dst-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dst_root); + let dst = Repo::clone_url_opts(&url, &dst_root, None, true).unwrap(); + assert_eq!(dst.head_tip().unwrap(), Some(snap1)); + assert_eq!(dst.signatures_for(&snap1).unwrap().len(), 1); + absent(&dst, tid1); + + // A second opted-out clone, to fetch with after the push below. + let dst2_root = + std::env::temp_dir().join(format!("scl-http-notrans-dst2-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dst2_root); + let dst2 = Repo::clone_url_opts(&url, &dst2_root, None, true).unwrap(); + absent(&dst2, tid1); + + // push: the snapshot lands on the server, its transcript does not. + std::fs::write(dst_root.join("b.txt"), b"two").unwrap(); + let snap2 = dst.commit("t", "c2").unwrap(); + dst.sign_snapshot(snap2, &identity).unwrap(); + let tid2 = dst + .attach_transcript(snap2, "claude-code", "s2", b"body2", &recipients) + .unwrap(); + dst.push_opts("origin", true).unwrap(); + drop(dst); + { + let src = Repo::open(&src_root).unwrap(); + assert_eq!(src.head_tip().unwrap(), Some(snap2)); + assert_eq!(src.signatures_for(&snap2).unwrap().len(), 1); + let idx = crate::transcripts::load(src.layout()).unwrap(); + assert!(idx.contains(&(snap1, tid1)) && !idx.iter().any(|(_, t)| *t == tid2)); + } + + // fetch: the new snapshot arrives; the server re-sends tid1 and the + // client drops it. + let fetched = dst2.fetch_opts("origin", true).unwrap(); + assert!(fetched.iter().any(|(_, id)| *id == snap2)); + absent(&dst2, tid1); + + // Per command: a plain fetch brings it in. + dst2.fetch("origin").unwrap(); + assert!(dst2 + .transcripts_for(&snap1) + .unwrap() + .iter() + .any(|(t, _)| *t == tid1)); + + drop(dst2); + let _ = std::fs::remove_dir_all(&src_root); + let _ = std::fs::remove_dir_all(&dst_root); + let _ = std::fs::remove_dir_all(&dst2_root); + } + // ── Task 4: loopback classifier + fail-closed bind gate + bearer auth // gate + read-only threading. ── diff --git a/crates/repo/src/sync.rs b/crates/repo/src/sync.rs index b860f368..8b8e17e9 100644 --- a/crates/repo/src/sync.rs +++ b/crates/repo/src/sync.rs @@ -85,8 +85,10 @@ impl Repo { /// [`Repo::clone_url_filtered`] with the `--no-transcripts` switch /// (ADR-0038 addendum, #211). With `no_transcripts`, transcript objects - /// (and signatures over them) in the received pack are verified but not - /// stored, so the clone holds no transcript object and no index entry. + /// (and signatures over them) in the received pack are hash-checked but + /// not written, so this clone holds no transcript object and no index + /// entry. Bucket remotes never serve transcripts, so the flag does + /// nothing there. /// Snapshots, trees and blobs transfer unchanged. Per command, not /// persisted: a later plain `fetch` brings the transcripts in. pub fn clone_url_opts( @@ -371,10 +373,13 @@ impl Repo { } /// [`Repo::fetch`] with the `--no-transcripts` switch (ADR-0038 - /// addendum, #211): received transcript objects and their signatures are - /// verified and discarded, never stored or indexed. The sender still - /// puts them on the wire (no wire flag), so this saves disk and - /// exposure, not bandwidth. A later plain fetch brings them in. + /// addendum, #211): received transcript objects, and signatures over + /// them, are hash-checked and then not written by this fetch. The + /// sender re-sends every indexed transcript each time (they are never + /// subtracted via the have-set), so a transcript you already hold is + /// re-sent and its new signature, if any, is dropped too; the next plain + /// fetch brings both in. No wire flag exists, so this saves disk and + /// exposure, not bandwidth. pub fn fetch_opts( &self, remote: &str, diff --git a/crates/repo/src/transport.rs b/crates/repo/src/transport.rs index 389f1807..33b52172 100644 --- a/crates/repo/src/transport.rs +++ b/crates/repo/src/transport.rs @@ -457,7 +457,8 @@ pub(crate) fn ingest_pack_file_checked( } /// [`ingest_pack_file`] for a `--no-transcripts` receiver (ADR-0038 addendum, -/// #211): every record is still hash-verified in pass 1, but pass 2 does not +/// #211): every record is still hash-checked in pass 1 (not +/// signature-verified), but pass 2 does not /// write `Transcript` objects, nor a signature whose target is a transcript /// dropped from this same pack (it would index against a transcript that is /// not here). The sender over-sends regardless of what the receiver wants (no diff --git a/docs/adr/0038-agent-session-transcripts.md b/docs/adr/0038-agent-session-transcripts.md index 8e30b227..7ae98294 100644 --- a/docs/adr/0038-agent-session-transcripts.md +++ b/docs/adr/0038-agent-session-transcripts.md @@ -158,22 +158,39 @@ pipe-safety discipline). client already has control: - `push`: the client builds the outgoing set, so it leaves out indexed transcripts and the signatures keyed by them. This saves bandwidth. - - `fetch` / `clone`: the server still sends them. The receiver verifies - every record in pass 1 of `ingest_pack_file` as usual, then pass 2 does - not write `Transcript` objects, nor a signature whose target is a - transcript dropped from the same pack. This saves disk and exposure - (no ciphertext, no index entry), **not** bandwidth. A server-side skip - would need a new `GetPack` field and a version bump; it is a deferred - follow-on in `ROADMAP.md`. + - `fetch` / `clone`: the server still sends them. The receiver + hash-checks every record in pass 1 of `ingest_pack_file` as usual (a + hash check, not signature verification), then pass 2 does not write + `Transcript` objects, nor a signature whose target is a transcript + dropped from the same pack. This transfer therefore writes and indexes + no transcript. It saves disk and exposure (no ciphertext, no index + entry), **not** bandwidth. A server-side skip would need a new + `GetPack` field and a version bump; it is a deferred follow-on in + `ROADMAP.md`. 2. **Per command, not persisted.** A clone made with `--no-transcripts` records nothing; a later plain `sc fetch` brings every indexed transcript - in (the sender's over-send covers snapshots the receiver already has). - A plain `sc push` after a `--no-transcripts` push carries them only once - the branch moves again, because `push` returns early when the remote tip - already equals the local tip (the same limit a retroactive attach has). + in (the sender re-sends all of them each time, because they are never + subtracted via the have-set). The same re-send means a `--no-transcripts` + fetch also drops a new signature over a transcript the receiver already + holds; the next plain fetch brings it in. A plain `sc push` after a + `--no-transcripts` push carries them only once the branch moves again, + because `push` returns early when the remote tip already equals the local + tip (the same limit a retroactive attach has). 3. **Sealing and integrity unchanged.** Bodies stay sealed whether or not they travel. Snapshots, trees, blobs and the snapshot's own signatures transfer - and verify exactly as before. Index entries are left out with the objects, - so no `.sc/transcripts` or `.sc/signatures` entry points at a transcript - the repo does not hold. Git remotes never carry transcripts, so the flag is - a no-op there. + and are hash-checked exactly as before. Index entries are left out with the + objects, so no `.sc/transcripts` or `.sc/signatures` entry created by this + transfer points at a transcript the repo does not hold. +4. **Remotes where the flag does nothing.** Git remotes never carry + transcripts. Bucket remotes (`sc+wal://`, `sc+s3://`) do not either: + `BucketTransport::get_pack` walks reachability only, so a fetch or clone + from a bucket delivers no transcripts or transcript signatures whether or + not the flag is given, and a plain fetch does not change that. (A push to a + bucket still honours the flag by not uploading them.) That gap is tracked + in #229. +5. **Interaction with transcript-drop tombstones (PR #226).** A tombstone is + an empty-envelope `Transcript` object, so `--no-transcripts` drops it like + any other transcript: a receiver keeps showing a dropped transcript after a + `--no-transcripts` fetch until a plain fetch brings the tombstone in. + Whether tombstones should be exempt is for #226 to decide; this change + does not special-case them. From 3b810bec187c1afa208ad1205fb01902032f99b0 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Tue, 20 Oct 2026 09:31:30 +0300 Subject: [PATCH 4/5] test,docs: assert http test dirs are removed, clarify bucket push in ADR addendum (ref #211) --- crates/repo/src/http_transport.rs | 7 ++++--- docs/adr/0038-agent-session-transcripts.md | 9 +++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/repo/src/http_transport.rs b/crates/repo/src/http_transport.rs index 53946835..da641a42 100644 --- a/crates/repo/src/http_transport.rs +++ b/crates/repo/src/http_transport.rs @@ -1851,9 +1851,10 @@ mod tests { .any(|(t, _)| *t == tid1)); drop(dst2); - let _ = std::fs::remove_dir_all(&src_root); - let _ = std::fs::remove_dir_all(&dst_root); - let _ = std::fs::remove_dir_all(&dst2_root); + for root in [&src_root, &dst_root, &dst2_root] { + std::fs::remove_dir_all(root).unwrap(); + assert!(!root.exists()); + } } // ── Task 4: loopback classifier + fail-closed bind gate + bearer auth diff --git a/docs/adr/0038-agent-session-transcripts.md b/docs/adr/0038-agent-session-transcripts.md index 7ae98294..7db6347b 100644 --- a/docs/adr/0038-agent-session-transcripts.md +++ b/docs/adr/0038-agent-session-transcripts.md @@ -182,12 +182,13 @@ pipe-safety discipline). objects, so no `.sc/transcripts` or `.sc/signatures` entry created by this transfer points at a transcript the repo does not hold. 4. **Remotes where the flag does nothing.** Git remotes never carry - transcripts. Bucket remotes (`sc+wal://`, `sc+s3://`) do not either: + transcripts. Bucket remotes (`sc+wal://`, `sc+s3://`) never serve them: `BucketTransport::get_pack` walks reachability only, so a fetch or clone from a bucket delivers no transcripts or transcript signatures whether or - not the flag is given, and a plain fetch does not change that. (A push to a - bucket still honours the flag by not uploading them.) That gap is tracked - in #229. + not the flag is given, and a plain fetch does not change that. For `push` + the flag still works: a normal bucket push uploads and stores the + transcripts (they are simply never served back), and `--no-transcripts` + skips that upload. The serving gap is tracked in #229. 5. **Interaction with transcript-drop tombstones (PR #226).** A tombstone is an empty-envelope `Transcript` object, so `--no-transcripts` drops it like any other transcript: a receiver keeps showing a dropped transcript after a From f91abd2e53681eeb054c307013987eb6268436fc Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Tue, 20 Oct 2026 09:44:35 +0300 Subject: [PATCH 5/5] test: assert --no-transcripts test dirs are gone after cleanup (ref #211) --- crates/cli/tests/transcripts.rs | 3 +++ crates/repo/src/sync.rs | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/crates/cli/tests/transcripts.rs b/crates/cli/tests/transcripts.rs index 83e9cb45..04969809 100644 --- a/crates/cli/tests/transcripts.rs +++ b/crates/cli/tests/transcripts.rs @@ -420,6 +420,7 @@ fn clone_no_transcripts_leaves_transcripts_out_and_plain_fetch_brings_them() { assert!(show.status.success()); assert!(stdout(&show).contains("USER: fix")); std::fs::remove_dir_all(&root).unwrap(); + assert!(!root.exists()); } #[test] @@ -459,6 +460,7 @@ fn fetch_no_transcripts_leaves_transcripts_out() { assert!(sc(&dst, &["fetch"]).status.success()); assert_eq!(transcript_index_len(&dst), 1); std::fs::remove_dir_all(&root).unwrap(); + assert!(!root.exists()); } #[test] @@ -508,4 +510,5 @@ fn push_no_transcripts_sends_snapshot_but_not_transcript() { .success()); assert_eq!(transcript_index_len(&origin), before); std::fs::remove_dir_all(&root).unwrap(); + assert!(!root.exists()); } diff --git a/crates/repo/src/sync.rs b/crates/repo/src/sync.rs index 8b8e17e9..2ca3ed29 100644 --- a/crates/repo/src/sync.rs +++ b/crates/repo/src/sync.rs @@ -1006,7 +1006,9 @@ mod tests { drop(a); drop(b); std::fs::remove_dir_all(&a_root).unwrap(); + assert!(!a_root.exists()); std::fs::remove_dir_all(&b_root).unwrap(); + assert!(!b_root.exists()); } #[test] @@ -1049,7 +1051,9 @@ mod tests { drop(a); drop(b); std::fs::remove_dir_all(&a_root).unwrap(); + assert!(!a_root.exists()); std::fs::remove_dir_all(&b_root).unwrap(); + assert!(!b_root.exists()); } #[test] @@ -1096,7 +1100,9 @@ mod tests { drop(a); drop(b); std::fs::remove_dir_all(&a_root).unwrap(); + assert!(!a_root.exists()); std::fs::remove_dir_all(&b_root).unwrap(); + assert!(!b_root.exists()); } #[test] @@ -1137,7 +1143,9 @@ mod tests { drop(src); drop(dst); std::fs::remove_dir_all(&src_root).unwrap(); + assert!(!src_root.exists()); std::fs::remove_dir_all(&dst_root).unwrap(); + assert!(!dst_root.exists()); } #[test]