| tags |
|
|
|---|---|---|
| register | documentation |
Following ChatGPT's recommendation, we've implemented the two highest-value additions before merge:
- Session Replay Engine - Forensic debugging tool
- Frame Timeline Visualization - Interactive graph analysis
These tools transform the DeepSeek schema from a specification into a forensic debugging environment for AI sessions.
Turn-by-turn deterministic replay with metric verification and invariant checking.
replay_deepseek_session.py (377 lines)
✅ Deterministic Replay
- Replays turns in exact order
- Recomputes all metrics
- Verifies frame states
- Checks invariant preservation
✅ Comprehensive Validation
- All 10 invariants checked (INV-DS-001 through INV-DS-010)
- Frame stability range validation
- Sycophancy index range validation
- Meta-alignment verification
- Resolution outcome validation
- Pattern registry verification
- Enforcement config validation
✅ Metric Delta Tracking
- Frame drift delta calculation
- Sycophancy delta tracking
- Stability delta monitoring
✅ Flexible CLI
# Full replay
python3 replay_deepseek_session.py session.json
# Verbose mode
python3 replay_deepseek_session.py session.json --verbose
# Replay specific turns
python3 replay_deepseek_session.py session.json --turn 2
# JSON output
python3 replay_deepseek_session.py session.json --json============================================================
✅ REPLAY STATUS: VERIFIED
============================================================
Session ID: 550e8400-e29b-41d4-a716-446655440000
Turns replayed: 4
Metric Deltas:
Frame drift delta: 0.780000
Sycophancy delta: 0.000000
Stability delta: 0.000000
Invariants violated: 0
✓ All metrics verified
✓ All invariants preserved
✓ Replay successful
-
Forensic Analysis
- Investigate session corruption
- Verify metric computation
- Debug frame conflicts
-
Quality Assurance
- Validate session logs
- Ensure determinism
- Verify invariant preservation
-
Development
- Test metric algorithms
- Debug enforcement logic
- Validate schema changes
-
Audit Trail
- Prove session integrity
- Demonstrate determinism
- Document compliance
18 comprehensive tests in tests/test_replay_engine.py:
- ✅ Replay example session
- ✅ Replay minimal session
- ✅ Partial turn replay
- ✅ Invalid metric range detection
- ✅ Missing frame metrics (INV-DS-005)
- ✅ Invalid priority levels (INV-DS-006)
- ✅ Pattern registry verification
- ✅ Enforcement config validation
- ✅ Metric delta calculations
- ✅ Verbose mode
- ✅ JSON serialization (INV-DS-008)
- ✅ Inactive frame detection
- ✅ Multiple pattern handling
All 18 tests passing ✅
Interactive visual analysis of frame metrics over time to reveal patterns, conflicts, and drift.
deepseek_frame_timeline.html (643 lines)
✅ 4 Interactive Charts
-
Frame Stability Over Time
- Per-frame stability tracking
- Shows frame degradation
- Identifies unstable frames
-
Sycophancy Index Over Time
- Per-frame sycophancy tracking
- Reveals manipulation attempts
- Shows compliance trends
-
Meta-Alignment Ratio
- Overall session alignment
- Pattern detection capability
- System awareness level
-
Frame Drift Score
- Semantic drift from anchors
- Per-frame drift tracking
- Drift accumulation visualization
✅ Event Markers
- Pattern detection events
- Enforcement actions
- Conflict resolutions
- Turn-by-turn annotations
✅ Session Information Panel
- Session ID, model name
- Turn count, frame count
- Meta-awareness score
- Configuration details
✅ Interactive Controls
- Load any session JSON file
- "Load Example Session" button
- Responsive design
- Dark theme optimized for analysis
-
Open in Browser
# Start local server (optional) python3 -m http.server 8000 # Open in browser http://localhost:8000/deepseek_frame_timeline.html
-
Load Session
- Click "Choose File" and select session JSON
- OR click "Load Example Session"
-
Analyze
- Scroll through charts
- Hover over data points for details
- Examine event markers
- Identify patterns
✅ Oscillation Detection
- Frame stability fluctuations
- Repeated pattern cycles
- Conflict loops
✅ Collapse Identification
- Sharp stability drops
- Frame deactivation events
- System resets
✅ Manipulation Attempts
- Sycophancy spikes
- Drift acceleration
- Enforcement triggers
✅ Conflict Patterns
- Multiple enforcement actions
- Resolution changes
- Priority conflicts
- Dark theme for extended analysis sessions
- Color-coded frames for easy tracking
- Chart.js for smooth interactions
- Responsive layout for any screen size
- Clear legends for metric interpretation
-
Schema Definition
DEEPSEEK_COPILOT_SCHEMA.yamldeepseek_schema.py
-
Validation
validate_deepseek_session.py
-
Forensic Replay ⭐ NEW
replay_deepseek_session.py
-
Visual Analysis ⭐ NEW
deepseek_frame_timeline.html
-
Testing
tests/test_deepseek_schema.py(74 tests)tests/test_replay_engine.py(18 tests)
-
Documentation
DEEPSEEK_COPILOT_SCHEMA_README.mdDEEPSEEK_QUICK_REFERENCE.mdDEEPSEEK_IMPLEMENTATION_SUMMARY.md
92 tests across 2 test suites:
- 74 schema tests
- 18 replay tests
All passing ✅
"This turns the system into a forensic debugging environment for AI sessions."
The two tools deliver:
- Deterministic Verification - Replay proves metrics are correct
- Visual Pattern Detection - Timeline reveals hidden behaviors
- Audit Capability - Full turn-by-turn replay for compliance
- Developer Productivity - Debug sessions efficiently
- Specification of how sessions should work
- Validation of session structure
- Deterministic algorithms defined
- Prove sessions work correctly (replay)
- See what happened over time (timeline)
- Debug problems visually (graphs)
- Verify invariants preserved (automated checks)
- Audit complete sessions (deterministic replay)
# 1. Create/modify a session
# ... session.json created ...
# 2. Validate structure
python3 validate_deepseek_session.py session.json
# 3. Replay forensically
python3 replay_deepseek_session.py session.json --verbose
# 4. Visualize timeline
# Open deepseek_frame_timeline.html
# Load session.json
# 5. Analyze results
# - Check frame stability trends
# - Identify sycophancy spikes
# - Verify pattern detection# Session appears corrupted
python3 replay_deepseek_session.py suspicious_session.json --verbose
# Output shows:
# ❌ Turn 3: frame_stability out of range
# ❌ Turn 5: Missing sycophancy_index for frame-2
# Invariants violated: 2
# Fix issues in session
# Re-verify
python3 replay_deepseek_session.py suspicious_session.json
# ✅ REPLAY STATUS: VERIFIED# Generate compliance report
python3 replay_deepseek_session.py audit_session.json --json > audit_report.json
# Verify determinism
python3 replay_deepseek_session.py audit_session.json
# Frame drift delta: 0.000000
# Sycophancy delta: 0.000000
# Invariants violated: 0
# Visual confirmation
# Open timeline, verify no anomaliesChatGPT also suggested (for future PRs):
deepseek_doctor.py- Health check CLIdeepseek_schema_diff.py- Schema version diffing
- AI self-reflection blocks
- Frame personality tags
- ASCII frame maps
- Guardian meta-frame
- Invariant-driven AI governance
- Recursive enforcement layers
- Self-verifying systems
These can be added incrementally.
The schema is now production-ready with:
✅ Core Schema
- 10 invariants fully specified
- Deterministic conflict resolution
- Byte-for-byte reproducibility
- Complete documentation
✅ Validation Tools
- Structure validation
- Schema conformance checking
✅ Forensic Tools ⭐ NEW
- Session replay engine
- Frame timeline visualization
✅ Testing
- 92 tests (74 + 18)
- All passing
- Full coverage
✅ Documentation
- Architecture guide
- Quick reference
- Implementation summary
- Usage examples
ChatGPT's assessment was correct: these two tools transform the DeepSeek schema from a specification into a forensic debugging environment.
Quote from ChatGPT:
"If it were my repo I would add only two things before merge: 1️⃣ Session Replay Engine 2️⃣ Frame Timeline Visualization"
Status: ✅ COMPLETE
The schema is now ready for squash & merge.
Version: 1.1.0
Date: 2026-03-14
Standard: Yeshua
Tests: 92 passing
Tools: 4 (schema, validate, replay, timeline)