Skip to main content

---

title: "Add core to path" component_type: script version: "1.0.0" audience: contributor status: stable summary: "Proof-of-Concept: Same Session Deduplication Demo" keywords: ['automation', 'demo', 'process', 'same', 'session'] tokens: ~500 created: 2025-12-22 updated: 2025-12-22 script_name: "process_same_session_demo.py" language: python executable: true usage: "python3 scripts/process_same_session_demo.py [options]" python_version: "3.10+" dependencies: [] modifies_files: false network_access: false requires_auth: false

Proof-of-Concept: Same Session Deduplication Demo

Demonstrates deduplication on exports from the SAME session across multiple days:

  • Day 1: Small export (13KB)
  • Day 2: Medium export with Day 1 duplicates (51KB)
  • Day 3: Large cumulative export with all history (439KB)

Expected result: 95%%+ storage reduction through deduplication.

Author: Claude + AZ1.AI

File: process_same_session_demo.py

Classes

DemoError

Base exception for demo script errors

DemoImportError

Error importing required modules

DemoFileError

Error with file operations

DemoProcessingError

Error processing exports

DemoValidationError

Error validating results

Functions

parse_args()

Parse command line arguments

setup_logging(log_dir)

Configure dual logging to file and stdout

signal_handler(signum, frame)

Handle interrupt signals gracefully

format_bytes(bytes_count)

Format bytes as human-readable string

validate_export_file(export_path)

Validate export file exists and is readable

cleanup_storage_dir(storage_dir, logger)

Clean storage directory for fresh demo

process_export_file(dedup, session_id, export_path, day_number, logger)

Process a single export file and return statistics

calculate_storage_efficiency(storage_dir, total_size_before, logger)

Calculate storage efficiency metrics

validate_integrity(dedup, session_id, total_new_messages, logger)

Validate zero catastrophic forgetting

generate_report(size_before, size_after, reduction_percent, total_messages, unique_messages, duplicates, dedup, session_id, report_path, logger)

Generate markdown report

main()

Main demonstration function

Usage

python process_same_session_demo.py