:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay-recorder-v4): move images into sealed packs (#117975)
Nicholas Waltz38111e13f340
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 57ce90bb9004..eed5f9ac1588 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -11060,6 +11060,7 @@ dependencies = ["aws-sdk-kms","aws-sdk-s3","axum 0.7.9",+ "base64 0.22.1","brotlic","bytes","chrono",diff --git a/rust/ai-research/replay-recorder-v4/Cargo.toml b/rust/ai-research/replay-recorder-v4/Cargo.tomlindex a59f22d31e90..93c953a66601 100644--- a/rust/ai-research/replay-recorder-v4/Cargo.toml+++ b/rust/ai-research/replay-recorder-v4/Cargo.toml@@ -40,6 +40,7 @@ tracing = { workspace = true }tracing-subscriber = { workspace = true }[dev-dependencies]+base64 = { workspace = true }bytes = { workspace = true }serde_json = { workspace = true }tokio = { workspace = true, features = ["test-util"] }diff --git a/rust/ai-research/replay-recorder-v4/src/config.rs b/rust/ai-research/replay-recorder-v4/src/config.rsindex ade7a7309a23..39b6efc0510b 100644--- a/rust/ai-research/replay-recorder-v4/src/config.rs+++ b/rust/ai-research/replay-recorder-v4/src/config.rs@@ -53,6 +53,9 @@ pub struct Config {#[envconfig(from = "AI_RESEARCH_V4_RRWEB_BUCKET", default = "")]pub rrweb_bucket: String,+ #[envconfig(from = "AI_RESEARCH_V4_IMAGES_BUCKET", default = "")]+ pub images_bucket: String,+#[envconfig(default = "9104")]pub metrics_port: u16,}diff --git a/rust/ai-research/replay-recorder-v4/src/consumer.rs b/rust/ai-research/replay-recorder-v4/src/consumer.rsindex dde0f8fe8935..999bb1991c83 100644--- a/rust/ai-research/replay-recorder-v4/src/consumer.rs+++ b/rust/ai-research/replay-recorder-v4/src/consumer.rs@@ -15,14 +15,14 @@ use rdkafka::{ClientConfig, ClientContext, Offset, TopicPartitionList};use chrono::Utc;use replay_core_v4::keys::batch::{KeyStore, SessionId};use replay_core_v4::keys::kms::AwsKms;-use replay_core_v4::keys::rows::write_day;+use replay_core_v4::keys::rows::{key_month, write_day};use replay_core_v4::keys::table::{AwsKeyTable, CachedKeyTable};use crate::batch::{Batch, Block, Inspectors, SessionKey};use crate::process::{admit, read, sampled};use crate::store::BlobStore;use crate::teams::TeamCache;-use crate::write::{write_blocks, WriteError};+use crate::write::{prepare, write_blocks, write_images, WriteError};/// Records the partitions each rebalance takes away, so the loop can drop what it buffered for them.pub struct RebalanceContext {@@ -125,6 +125,7 @@ pub struct Writer {pub keys: KeyStore<CachedKeyTable<AwsKeyTable>, AwsKms>,pub store: Arc<dyn BlobStore>,pub rrweb_bucket: String,+ pub images_bucket: String,}#[derive(Debug, thiserror::Error)]@@ -178,8 +179,8 @@ pub async fn run(inspectors.drop_partitions(&revoked);}if batch.should_flush(settings.flush_interval, settings.flush_max_bytes) {- let (blocks, offsets) = inspectors.inspect(std::mem::take(&mut batch));- if let Err(error) = flush(&blocks, writer.as_ref()).await {+ let (mut blocks, offsets) = inspectors.inspect(std::mem::take(&mut batch));+ if let Err(error) = flush(&mut blocks, writer.as_ref()).await {// Nothing of this flush is committed, so a restart reads it again from the last commit.tracing::error!(%error, "flush failed");handle.signal_failure(format!("flush failed: {error}"));@@ -230,9 +231,9 @@ fn handle_message(}/// Stores a flush's blocks, or only reports them when the recorder runs dry.-async fn flush(blocks: &[Block], writer: Option<&Writer>) -> Result<(), FlushError> {+async fn flush(blocks: &mut [Block], writer: Option<&Writer>) -> Result<(), FlushError> {counter!("ai_research_v4_recorder_blocks_total").increment(blocks.len() as u64);- for block in blocks {+ for block in blocks.iter() {counter!("ai_research_v4_recorder_block_events_total").increment(block.stats.event_count);if block.stats.cold_start {counter!("ai_research_v4_recorder_cold_start_blocks_total").increment(1);@@ -243,6 +244,8 @@ async fn flush(blocks: &[Block], writer: Option<&Writer>) -> Result<(), FlushErr}let Some(writer) = writer else { return Ok(()) };let now = Utc::now();+ let day = write_day(now);+ let month = key_month(&day);let sessions: Vec<SessionId> = blocks.iter().map(|b| SessionId {@@ -251,14 +254,26 @@ async fn flush(blocks: &[Block], writer: Option<&Writer>) -> Result<(), FlushErr}).collect();// Keys are stored before anything is sealed with them, as in v3.- let keys = writer- .keys- .keys_for_flush(&sessions, &write_day(now))- .await?;+ let keys = writer.keys.keys_for_flush(&sessions, &day).await?;counter!("ai_research_v4_recorder_dropped_sessions_total").increment(keys.dropped.len() as u64);- let written = write_blocks(- blocks,+ let prepared = prepare(blocks, &keys, month);+ let rows = write_images(+ &prepared.images,&keys,+ &day,+ month,+ &writer.images_bucket,+ &writer.rrweb_bucket,+ writer.store.as_ref(),+ now,+ )+ .await?;+ counter!("ai_research_v4_recorder_stored_images_total").increment(rows.len() as u64);+ // What sealing images under session keys would store, to compare with the frames above.+ counter!("ai_research_v4_recorder_session_keyed_image_frames_total")+ .increment(prepared.session_frames);+ let written = write_blocks(+ &prepared.blocks,&writer.rrweb_bucket,writer.store.as_ref(),now,diff --git a/rust/ai-research/replay-recorder-v4/src/main.rs b/rust/ai-research/replay-recorder-v4/src/main.rsindex 6f5e44652486..4358f918b1b4 100644--- a/rust/ai-research/replay-recorder-v4/src/main.rs+++ b/rust/ai-research/replay-recorder-v4/src/main.rs@@ -143,6 +143,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {keys: KeyStore::new(table, kms),store: Arc::new(S3Store::new(aws_sdk_s3::Client::new(&aws))),rrweb_bucket: config.rrweb_bucket.clone(),+ images_bucket: config.images_bucket.clone(),})} else {tracing::info!("writes are off: the recorder stores nothing");diff --git a/rust/ai-research/replay-recorder-v4/src/write.rs b/rust/ai-research/replay-recorder-v4/src/write.rsindex 37b97e0b7d76..f60ce6a7453b 100644--- a/rust/ai-research/replay-recorder-v4/src/write.rs+++ b/rust/ai-research/replay-recorder-v4/src/write.rs@@ -1,15 +1,23 @@-//! Writes a flush: keys first, then one object of sealed session blocks.+//! Writes a flush: image packs and their index first, then one object of sealed session blocks.+//!+//! The order matters for a crash between writes. A pack without its blocks is unreferenced, which is harmless. A block+//! whose images were never stored would hold references that resolve to nothing.+use std::collections::{BTreeMap, HashSet};use std::io::Write;use chrono::{DateTime, Utc};use rand::Rng;use replay_core_v4::bytescan::write_json_string;use replay_core_v4::envelope::{seal_frame, Codec, Context, Version};-use replay_core_v4::keys::batch::{FlushKeys, SessionId};+use replay_core_v4::keys::batch::{FlushKeys, SessionId, SessionKey as Key};use replay_core_v4::keys::rows::write_day;+use replay_core_v4::scan::cv::extract_event_images;+use replay_core_v4::scan::images::{Image, ImageLimits, ImageSink};+use replay_core_v4::seal::image_content_key;use crate::batch::{Block, SessionKey};+use crate::index::{image_index, write_parquet, ImageIndexRow, IndexError};use crate::store::{BlobStore, StoreError};/// Brotli settings for blocks, the same as the v3 lane, which uses the same C encoder. The lane keeps blocks for months@@ -21,7 +29,9 @@ const BLOCK_BROTLI_WINDOW_BITS: u8 = 22;pub enum WriteError {#[error(transparent)]Store(#[from] StoreError),- #[error("sealing a block failed: {0}")]+ #[error(transparent)]+ Index(#[from] IndexError),+ #[error("sealing failed: {0}")]Seal(String),}@@ -36,25 +46,11 @@ pub struct Written {pub byte_end: u64,}-/// The block in the main lane's format: one `["window_id",event]` line per event.-pub fn block_lines(block: &Block) -> Vec<u8> {- let mut lines =- Vec::with_capacity(block.stats.byte_size as usize + block.stats.event_count as usize * 16);- for message in &block.messages {- let mut window = Vec::new();- write_json_string(- message.window_id.as_deref().unwrap_or_default(),- &mut window,- );- for event in &message.events {- lines.push(b'[');- lines.extend_from_slice(&window);- lines.push(b',');- lines.extend_from_slice(&message.inner[event.span.0..event.span.1]);- lines.extend_from_slice(b"]\n");- }- }- lines+/// A session's block, ready to seal: its key, and its lines with the images moved out.+pub struct PreparedBlock {+ pub session: SessionKey,+ pub key: Key,+ pub lines: Vec<u8>,}fn block_encoder() -> Result<brotlic::BrotliEncoder, WriteError> {@@ -66,19 +62,174 @@ fn block_encoder() -> Result<brotlic::BrotliEncoder, WriteError> {.map_err(seal_error)}-pub fn object_key(write_day: &str, at: DateTime<Utc>) -> String {+pub struct Prepared {+ pub blocks: Vec<PreparedBlock>,+ /// The flush's new images by team, each stored once.+ pub images: BTreeMap<i64, Vec<Image>>,+ /// The frames the packs would hold if each session sealed its images under its own key: one per distinct+ /// (session, reference) pair, where `images` holds one per reference.+ pub session_frames: u64,+}++fn unique_suffix(at: DateTime<Utc>) -> String {format!(- "blocks/dt={write_day}/{}-{:016x}",+ "{}-{:016x}",at.timestamp_millis(),rand::thread_rng().gen::<u64>())}-/// Seals each block under its session key into one object. Blocks whose session has no key, because a deletion-/// tombstoned it, are left out.-pub async fn write_blocks(- blocks: &[Block],+pub fn object_key(write_day: &str, at: DateTime<Utc>) -> String {+ format!("blocks/dt={write_day}/{}", unique_suffix(at))+}++/// Moves each kept session's images out and builds its lines in the main lane's format: one `["window_id",event]`+/// line per event. Fills the image and written size columns of each block's stats. Every image goes into this+/// flush's packs, even one an earlier flush stored: a pack expires by its own write time, so it must be no older than+/// the blocks that reference it.+pub fn prepare(blocks: &mut [Block], keys: &FlushKeys, key_month: &str) -> Prepared {+ let mut prepared = Prepared {+ blocks: Vec::new(),+ images: BTreeMap::new(),+ session_frames: 0,+ };+ // A reference names its team, so it names one frame of the flush.+ let mut seen: HashSet<String> = HashSet::new();+ let mut seen_in_session: HashSet<(String, String)> = HashSet::new();+ for block in blocks.iter_mut() {+ let id = SessionId {+ team_id: block.session.team_id,+ session_id: block.session.session_id.clone(),+ };+ let (Some(key), Some(team_key)) = (+ keys.sessions.get(&id),+ keys.team_months.get(&block.session.team_id),+ ) else {+ continue;+ };+ let content_key = image_content_key(team_key);+ let images = prepared.images.entry(block.session.team_id).or_default();+ let mut lines = Vec::with_capacity(+ block.stats.byte_size as usize + block.stats.event_count as usize * 16,+ );+ for message in &block.messages {+ let mut window = Vec::new();+ write_json_string(+ message.window_id.as_deref().unwrap_or_default(),+ &mut window,+ );+ let mut sink = ImageSink::new(+ &content_key,+ block.session.team_id,+ key_month,+ ImageLimits::default(),+ );+ for event in &message.events {+ let extracted = extract_event_images(&message.inner, event, &mut sink);+ let line_start = lines.len();+ lines.push(b'[');+ lines.extend_from_slice(&window);+ lines.push(b',');+ lines.extend_from_slice(+ extracted+ .as_deref()+ .unwrap_or(&message.inner[event.span.0..event.span.1]),+ );+ lines.extend_from_slice(b"]\n");+ let line = (lines.len() - line_start) as u64;+ block.stats.written_jsonl_bytes += line;+ block.stats.max_written_event_bytes = block.stats.max_written_event_bytes.max(line);+ }+ block.stats.images_extracted += sink.images.len() as u32;+ block.stats.image_bytes += sink+ .images+ .iter()+ .map(|i| i.bytes.len() as u64)+ .sum::<u64>();+ block.stats.images_inline += sink.left_inline;+ for image in sink.images {+ if seen_in_session.insert((id.session_id.clone(), image.reference.clone())) {+ prepared.session_frames += 1;+ }+ if seen.insert(image.reference.clone()) {+ images.push(image);+ }+ }+ }+ prepared.blocks.push(PreparedBlock {+ session: block.session.clone(),+ key: key.clone(),+ lines,+ });+ }+ prepared.images.retain(|_, images| !images.is_empty());+ prepared+}++/// Seals each team's images under its team month key into one pack, then writes the image index for the flush.+#[allow(clippy::too_many_arguments)]+pub async fn write_images(+ images: &BTreeMap<i64, Vec<Image>>,keys: &FlushKeys,+ write_day: &str,+ key_month: &str,+ images_bucket: &str,+ rrweb_bucket: &str,+ store: &dyn BlobStore,+ at: DateTime<Utc>,+) -> Result<Vec<ImageIndexRow>, WriteError> {+ let mut rows = Vec::new();+ for (&team_id, team_images) in images {+ let Some(team_key) = keys.team_months.get(&team_id) else {+ continue;+ };+ let pack_key = format!(+ "images/packs/dt={write_day}/{team_id}/{}",+ unique_suffix(at)+ );+ let mut pack = Vec::new();+ for image in team_images {+ let context = Context {+ team_id,+ key_month: Some(key_month.to_owned()),+ kind: "image".to_owned(),+ codec: Some(Codec::None),+ reference: Some(image.reference.clone()),+ ..Context::default()+ };+ let frame = seal_frame(team_key, Version::V4, &context, &image.bytes)+ .map_err(|e| WriteError::Seal(e.to_string()))?;+ let byte_start = pack.len() as u64;+ pack.extend_from_slice(&frame);+ rows.push(ImageIndexRow {+ team_id,+ key_month: key_month.to_owned(),+ image_ref: image.reference.clone(),+ pack_s3_key: pack_key.clone(),+ byte_start,+ byte_end: pack.len() as u64 - 1,+ mime: image.mime.to_owned(),+ byte_size: image.bytes.len() as u64,+ });+ }+ store.put_new(images_bucket, &pack_key, pack).await?;+ }+ if !rows.is_empty() {+ let index_key = format!("index/images/dt={write_day}/{}.parquet", unique_suffix(at));+ store+ .put_new(+ rrweb_bucket,+ &index_key,+ write_parquet(&image_index(&rows)?)?,+ )+ .await?;+ }+ Ok(rows)+}++/// Seals each prepared block under its session key into one object.+pub async fn write_blocks(+ blocks: &[PreparedBlock],bucket: &str,store: &dyn BlobStore,at: DateTime<Utc>,@@ -87,16 +238,9 @@ pub async fn write_blocks(let mut object = Vec::new();let mut written = Vec::new();for block in blocks {- let id = SessionId {- team_id: block.session.team_id,- session_id: block.session.session_id.clone(),- };- let Some(session_key) = keys.sessions.get(&id) else {- continue;- };let mut encoder = brotlic::CompressorWriter::with_encoder(block_encoder()?, Vec::new());encoder- .write_all(&block_lines(block))+ .write_all(&block.lines).map_err(|e| WriteError::Seal(e.to_string()))?;let compressed = encoder.into_inner()@@ -104,18 +248,18 @@ pub async fn write_blocks(let context = Context {team_id: block.session.team_id,session_id: Some(block.session.session_id.clone()),- key_month: Some(session_key.key_month.clone()),+ key_month: Some(block.key.key_month.clone()),kind: "rrweb".to_owned(),codec: Some(Codec::Brotli),..Context::default()};- let frame = seal_frame(&session_key.key, Version::V4, &context, &compressed)+ let frame = seal_frame(&block.key.key, Version::V4, &context, &compressed).map_err(|e| WriteError::Seal(e.to_string()))?;let byte_start = object.len() as u64;object.extend_from_slice(&frame);written.push(Written {session: block.session.clone(),- key_month: session_key.key_month.clone(),+ key_month: block.key.key_month.clone(),object_key: object_key.clone(),byte_start,byte_end: object.len() as u64 - 1,@@ -134,9 +278,10 @@ mod tests {use std::sync::Mutex;use async_trait::async_trait;+ use base64::engine::general_purpose::STANDARD;+ use base64::Engine;use replay_core_v4::envelope::open_frame;use replay_core_v4::inspect::stats::BlockStats;- use replay_core_v4::keys::batch::SessionKey as Key;use replay_core_v4::scan::message::read_message;use serde_json::{json, Value};@@ -147,6 +292,12 @@ mod tests {objects: Mutex<HashMap<(String, String), Vec<u8>>>,}+ impl MemoryStore {+ fn get(&self, bucket: &str, key: &str) -> Vec<u8> {+ self.objects.lock().unwrap()[&(bucket.to_owned(), key.to_owned())].clone()+ }+ }+fn decompress(compressed: &[u8]) -> io::Result<Vec<u8>> {let mut plain = Vec::new();brotlic::DecompressorReader::new(compressed).read_to_end(&mut plain)?;@@ -166,7 +317,7 @@ mod tests {}fn block(session: &str, events: Value) -> Block {- let inner = json!({"event": "$snapshot_items", "properties": {"$session_id": session, "$window_id": "w\"1", "$snapshot_items": events}});+ let inner = json!({"event": "$snapshot_items", "properties": {"$session_id": session, "$window_id": "w1", "$snapshot_items": events}});let message = read_message(json!({"distinct_id": "d", "data": inner.to_string()}).to_string()@@ -184,13 +335,24 @@ mod tests {}}+ /// The length of each line, its line break included.+ fn lines_of(lines: &[u8]) -> impl Iterator<Item = u64> + '_ {+ lines+ .split_inclusive(|&b| b == b'\n')+ .map(|line| line.len() as u64)+ }++ fn uri(bytes: &[u8]) -> String {+ format!("data:image/png;base64,{}", STANDARD.encode(bytes))+ }+#[tokio::test]- async fn seals_each_kept_session_into_one_object_by_byte_range() {- let events = json!([{"type": 4, "timestamp": 1, "data": {"href": "https://example.com"}}, {"type": 3, "timestamp": 2, "data": {"source": 1}}]);- let blocks = [- block("kept", events.clone()),- block("tombstoned", events.clone()),- ];+ async fn stores_images_once_and_blocks_that_point_at_them() {+ let events = json!([+ {"type": 2, "timestamp": 1, "data": {"node": {"attributes": {"src": uri(b"new"), "srcset": format!("{} 2x", uri(b"new"))}}}},+ {"type": 3, "timestamp": 2, "data": {"source": 0, "adds": [{"parentId": 1, "node": {"attributes": {"src": uri(b"old")}}}]}},+ ]);+ let mut blocks = vec![block("kept", events.clone()), block("tombstoned", events)];let mut keys = FlushKeys::default();keys.sessions.insert(SessionId {@@ -202,14 +364,73 @@ mod tests {key_month: "2026-09".to_owned(),},);+ keys.team_months.insert(7, [6; 32]);+ let old_ref = replay_core_v4::refs::image_ref(+ 7,+ "2026-10",+ &replay_core_v4::refs::reference_hash(&image_content_key(&[6; 32]), b"old"),+ );+ let prepared = prepare(&mut blocks, &keys, "2026-10");++ // The same image in two sessions of the team is one frame and one index row.+ let same = json!([{"type": 2, "timestamp": 1, "data": {"node": {"attributes": {"src": uri(b"shared")}}}}]);+ let mut two = vec![block("kept", same.clone()), block("other", same)];+ let mut both = FlushKeys::default();+ both.team_months.insert(7, [6; 32]);+ for (session, key) in [("kept", [5; 32]), ("other", [4; 32])] {+ both.sessions.insert(+ SessionId {+ team_id: 7,+ session_id: session.to_owned(),+ },+ Key {+ key,+ key_month: "2026-10".to_owned(),+ },+ );+ }+ // A key per session would need a frame in each.+ let shared = prepare(&mut two, &both, "2026-10");+ assert_eq!((shared.images[&7].len(), shared.session_frames), (1, 2));+let store = MemoryStore::default();let at = DateTime::parse_from_rfc3339("2026-10-15T12:00:00Z").unwrap().with_timezone(&Utc);-- let written = write_blocks(&blocks, &keys, "rrweb-v4", &store, at)+ let rows = write_images(+ &prepared.images,+ &keys,+ "2026-10-15",+ "2026-10",+ "images-v4",+ "rrweb-v4",+ &store,+ at,+ )+ .await+ .unwrap();+ let written = write_blocks(&prepared.blocks, "rrweb-v4", &store, at).await.unwrap();++ // The pack holds both images, also the one an earlier flush stored.+ assert_eq!(rows.len(), 2);+ assert!(rows.iter().any(|row| row.image_ref == old_ref));+ assert_eq!(+ (+ blocks[0].stats.images_extracted,+ blocks[0].stats.images_inline+ ),+ (2, 0)+ );+ let longest = lines_of(&prepared.blocks[0].lines).max().unwrap();+ assert_eq!(+ (+ blocks[0].stats.written_jsonl_bytes,+ blocks[0].stats.max_written_event_bytes+ ),+ (prepared.blocks[0].lines.len() as u64, longest)+ );assert_eq!(written.iter()@@ -217,14 +438,10 @@ mod tests {.collect::<Vec<_>>(),vec!["kept"]);- let block = &written[0];- assert!(block.object_key.starts_with("blocks/dt=2026-10-15/"));- assert_eq!(block.key_month, "2026-09");- let object = store.objects.lock().unwrap()- [&("rrweb-v4".to_owned(), block.object_key.clone())]- .clone();- let frame = &object[block.byte_start as usize..=block.byte_end as usize];+ let block = &written[0];+ let frame = &store.get("rrweb-v4", &block.object_key)+ [block.byte_start as usize..=block.byte_end as usize];let context = Context {team_id: 7,session_id: Some("kept".to_owned()),@@ -233,25 +450,44 @@ mod tests {codec: Some(Codec::Brotli),..Context::default()};- let lines =- decompress(&open_frame(&[5; 32], Version::V4, &context, frame).unwrap()).unwrap();- let lines: Vec<Value> = String::from_utf8(lines)- .unwrap()- .lines()- .map(|l| serde_json::from_str(l).unwrap())- .collect();- let expected: Vec<Value> = events- .as_array()- .unwrap()- .iter()- .map(|e| json!(["w\"1", e]))- .collect();- assert_eq!(lines, expected);-- let nothing = write_blocks(&blocks[1..], &keys, "rrweb-v4", &store, at)- .await+ let lines = String::from_utf8(+ decompress(&open_frame(&[5; 32], Version::V4, &context, frame).unwrap()).unwrap(),+ )+ .unwrap();+ let first: Value = serde_json::from_str(lines.lines().next().unwrap()).unwrap();+ let reference = first[1]["data"]["node"]["attributes"]["src"]+ .as_str().unwrap();- assert!(nothing.is_empty());- assert_eq!(store.objects.lock().unwrap().len(), 1);+ assert_eq!(reference, rows[0].image_ref);+ assert!(lines.contains(&old_ref) && !lines.contains("base64"));++ // The reference resolves through the index to the image's bytes in the pack.+ let row = &rows[0];+ let pack = store.get("images-v4", &row.pack_s3_key);+ let image_context = Context {+ team_id: 7,+ key_month: Some("2026-10".to_owned()),+ kind: "image".to_owned(),+ codec: Some(Codec::None),+ reference: Some(row.image_ref.clone()),+ ..Context::default()+ };+ let sealed = &pack[row.byte_start as usize..=row.byte_end as usize];+ assert_eq!(+ open_frame(&[6; 32], Version::V4, &image_context, sealed).unwrap(),+ b"new"+ );+ // The team month key seals images, as the fetcher's, so the session key does not open them.+ assert!(open_frame(&[5; 32], Version::V4, &image_context, sealed).is_err());+ assert_eq!(+ store+ .objects+ .lock()+ .unwrap()+ .keys()+ .filter(|(_, key)| key.starts_with("index/images/dt=2026-10-15/"))+ .count(),+ 1+ );}}