-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnoxfile.py
More file actions
executable file
·695 lines (568 loc) · 25.5 KB
/
noxfile.py
File metadata and controls
executable file
·695 lines (568 loc) · 25.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
"""Streamlined Nox configuration for Rxiv-Maker testing."""
import nox
# Removed container cleanup utilities as engines are deprecated
# Configure nox to use uv as the default backend for faster environment creation
nox.options.default_venv_backend = "uv"
# Enable environment reuse to reduce disk usage and improve performance
nox.options.reuse_existing_virtualenvs = True
# Set default sessions for local development workflow
nox.options.sessions = ["lint", "test(test_type='full')"]
# Configuration constants
PYTHON_VERSIONS = ["3.11", "3.12", "3.13"]
# Common dependencies
TEST_DEPS = [
"pytest>=7.4.0",
"pytest-cov>=4.0",
"pytest-timeout>=2.4.0",
"pytest-xdist>=3.8.0",
"pytest-asyncio>=0.21.0",
]
LINT_DEPS = ["ruff>=0.8.0", "mypy>=1.0.0"]
DOC_DEPS = ["lazydocs>=0.4.8"]
SECURITY_DEPS = ["bandit>=1.7.5", "safety>=2.3.5", "pip-audit>=2.6.1"]
def install_project_deps(session):
"""Install project and test dependencies efficiently using uv."""
session.run("uv", "pip", "install", "-e", ".", external=True)
session.run("uv", "pip", "install", *TEST_DEPS, external=True)
# Core Development Sessions
@nox.session(python="3.11", reuse_venv=True)
def lint(session):
"""Run comprehensive linting checks."""
session.run("uv", "pip", "install", *LINT_DEPS, external=True)
session.run("ruff", "check", "src/", "tests/")
session.run("ruff", "format", "--check", "src/", "tests/")
@nox.session(python="3.11", reuse_venv=True)
def format(session):
"""Format code with ruff (auto-fix)."""
session.run("uv", "pip", "install", "ruff>=0.8.0", external=True)
session.run("ruff", "format", "src/", "tests/")
session.run("ruff", "check", "--fix", "src/", "tests/")
@nox.session(python="3.11", reuse_venv=True)
@nox.parametrize("test_type", ["unit", "integration", "fast", "full", "smoke"])
def test(session, test_type):
"""Unified test session with different execution modes.
Usage:
nox -s test-unit # Unit tests only (fastest, <1 min)
nox -s test-integration # Integration tests only (<5 min)
nox -s test-fast # Fast tests only (<2 min)
nox -s test-full # Full test suite (<10 min)
nox -s test-smoke # Smoke tests only (ultra-fast, <30s)
nox -s test # Default to full test suite
"""
install_project_deps(session)
if test_type == "unit":
# Unit tests only - fastest feedback
session.run(
"pytest",
"tests/unit/",
"--maxfail=3",
"--tb=short",
"-x", # Stop on first failure for fast feedback
*session.posargs,
)
elif test_type == "integration":
# Integration tests only - moderate feedback
session.run(
"pytest",
"tests/integration/",
"--maxfail=5",
"--tb=short",
*session.posargs,
)
elif test_type == "fast":
# Quick development feedback - fast tests only
session.run(
"pytest",
"tests/unit/",
"-m",
"unit and not ci_exclude",
"--maxfail=3",
"--tb=short",
"-x", # Stop on first failure for fast feedback
*session.posargs,
)
elif test_type == "smoke":
# Ultra-fast smoke tests - quickest validation (<30s)
session.run(
"pytest",
"tests/smoke/",
"-m",
"smoke",
"--maxfail=1",
"--tb=short",
"-x", # Stop on first failure for immediate feedback
"--disable-warnings", # Reduce noise for quick feedback
*session.posargs,
)
elif test_type == "full":
# Primary test session matching CI behavior with coverage enforcement
session.run(
"pytest",
"tests/unit/",
"tests/integration/",
"tests/cli/",
"-m",
"not slow and not ci_exclude and not system",
"--cov=src",
"--cov-report=term-missing:skip-covered",
"--cov-fail-under=40", # Enforce minimum 40% coverage (realistic for complex codebase)
"--maxfail=5",
*session.posargs,
)
@nox.session(venv_backend="none", reuse_venv=True)
def test_ci_exact(session):
"""Test with exact CI environment settings to forecast failures locally.
This session replicates the exact GitHub Actions CI environment:
- Same environment variables
- Same test command and flags
- Same Python version (3.11)
- Same package versions
- Same PATH limitations (no 'python' executable, only 'python3')
Use this to debug CI failures before pushing.
"""
# Set the same environment variables as CI
session.env["FORCE_COLOR"] = "1"
session.env["UV_SYSTEM_PYTHON"] = "1"
session.env["PYTHONIOENCODING"] = "utf-8"
session.env["LC_ALL"] = "C.UTF-8"
session.env["LANG"] = "C.UTF-8"
# Use current environment (assumes you're in the project venv)
import sys
if not sys.executable.endswith(".venv/bin/python"):
session.log("Warning: Not running in project virtual environment")
session.log(f"Current Python: {sys.executable}")
session.log("Run: source .venv/bin/activate")
# Mimic CI PATH restrictions - remove 'python' executable access
import os
from pathlib import Path
current_path = os.environ.get("PATH", "")
path_dirs = current_path.split(os.pathsep)
filtered_path_dirs = []
for path_dir in path_dirs:
# Temporarily rename 'python' executables to reproduce CI conditions
path_obj = Path(path_dir)
python_exec = path_obj / "python"
if python_exec.exists() and not python_exec.is_symlink():
# Create a backup and remove from PATH visibility
backup_name = path_obj / "python.ci_hidden"
if not backup_name.exists():
try:
python_exec.rename(backup_name)
session.log(f"Temporarily hidden: {python_exec}")
except Exception as e:
session.log(f"Cannot hide {python_exec}: {e}")
filtered_path_dirs.append(path_dir)
# Update PATH for this session
session.env["PATH"] = os.pathsep.join(filtered_path_dirs)
try:
# Run exact same command as CI with same flags
session.run(
"pytest",
"tests/unit/",
"-m",
"unit and not ci_exclude",
"--maxfail=3",
"--tb=short",
"-x", # Stop on first failure like CI
*session.posargs,
)
finally:
# Restore any hidden executables
for path_dir in path_dirs:
path_obj = Path(path_dir)
backup_name = path_obj / "python.ci_hidden"
python_exec = path_obj / "python"
if backup_name.exists() and not python_exec.exists():
try:
backup_name.rename(python_exec)
session.log(f"Restored: {python_exec}")
except Exception as e:
session.log(f"Cannot restore {python_exec}: {e}")
@nox.session(python="3.11", reuse_venv=True)
def test_system(session):
"""Run system tests - comprehensive end-to-end testing (manual trigger only)."""
install_project_deps(session)
session.run(
"pytest",
"tests/system/",
"-m",
"system",
"--tb=long",
"--maxfail=3",
"-v",
*session.posargs,
)
@nox.session(python="3.11", reuse_venv=True)
def build(session):
"""Package building and validation."""
session.run(
"uv",
"pip",
"install",
"build>=1.0.0",
"twine>=4.0.0",
"hatchling",
external=True,
)
# Clean previous builds
session.run("rm", "-rf", "dist/", "build/", external=True)
# Build package (--no-isolation avoids pip issues in CI isolated venvs)
session.run("python", "-m", "build", "--no-isolation")
# Validate package
session.run("twine", "check", "dist/*")
# Test installation
session.run("bash", "-c", "uv pip install dist/*.whl", external=True)
session.run("rxiv", "--help")
@nox.session(python="3.11", reuse_venv=False)
def test_cli_e2e(session):
"""Exhaustive CLI end-to-end testing with package build and isolated environment.
This session:
1. Builds the rxiv-maker package from source
2. Creates a clean isolated environment
3. Installs the built package (not development mode)
4. Runs comprehensive CLI tests in a temporary directory different from development
5. Tests all major CLI commands and workflows
6. Validates style file resolution in installed package context
"""
import os
import shutil
import tempfile
from pathlib import Path
session.log("🔧 Setting up package build environment...")
# Install build dependencies
session.run("uv", "pip", "install", "build>=1.0.0", "pytest>=7.4.0", "pytest-timeout>=2.4.0", external=True)
# Clean and build package
session.log("🏗️ Building rxiv-maker package...")
session.run("rm", "-rf", "dist/", "build/", external=True)
session.run("python", "-m", "build")
# Get the built wheel file
import glob
wheel_files = glob.glob("dist/*.whl")
if not wheel_files:
session.error("No wheel file found in dist/")
wheel_file = wheel_files[0]
session.log(f"📦 Built package: {wheel_file}")
# Install the package (not in development mode)
session.log("📥 Installing built package in isolated environment...")
session.run("uv", "pip", "install", wheel_file, external=True)
# Verify installation
session.run("rxiv", "--version")
session.run("rxiv", "--help")
# Create temporary test directory (different from development directory)
with tempfile.TemporaryDirectory(prefix="rxiv_cli_test_") as temp_dir:
temp_path = Path(temp_dir)
session.log(f"🧪 Running CLI tests in isolated directory: {temp_path}")
# Copy test manuscript to temp directory
example_source = Path("EXAMPLE_MANUSCRIPT")
if example_source.exists():
example_dest = temp_path / "test_manuscript"
shutil.copytree(example_source, example_dest)
session.log(f"📄 Copied test manuscript to: {example_dest}")
else:
# Create minimal test manuscript if EXAMPLE_MANUSCRIPT doesn't exist
example_dest = temp_path / "test_manuscript"
example_dest.mkdir()
# Create minimal test files
(example_dest / "manuscript.tex").write_text(r"""
\documentclass{article}
\usepackage{rxiv_maker_style}
\title{Test Manuscript}
\author{Test Author}
\begin{document}
\maketitle
\section{Introduction}
This is a test manuscript for CLI testing.
\cite{testref}
\bibliography{references}
\end{document}
""")
(example_dest / "references.bib").write_text(r"""
@article{testref,
title={Test Reference},
author={Test Author},
journal={Test Journal},
year={2024}
}
""")
session.log(f"📝 Created minimal test manuscript at: {example_dest}")
# Change to temp directory for all tests
original_cwd = os.getcwd()
os.chdir(temp_path)
try:
session.log("🚀 Running exhaustive CLI tests...")
# Test 1: Basic help and version commands
session.log("✅ Testing basic CLI commands...")
session.run("rxiv", "--help")
session.run("rxiv", "--version")
session.run("rxiv", "pdf", "--help")
session.run("rxiv", "clean", "--help")
# Test 2: Clean command
session.log("✅ Testing clean command...")
session.run("rxiv", "clean", str(example_dest))
# Test 3: PDF generation with style file resolution validation
session.log("✅ Testing PDF generation with style file resolution...")
try:
# This tests the critical style file path resolution fix
session.run("rxiv", "pdf", str(example_dest), "--skip-validation")
session.log("🎉 PDF generation successful - style files resolved correctly!")
except Exception as e:
session.log(f"⚠️ PDF generation test result: {e}")
# Don't fail the session for PDF generation issues as LaTeX might not be available
session.log("📝 Note: PDF generation failure may be due to missing LaTeX installation")
# Test 4: Test with different verbosity levels
session.log("✅ Testing verbosity levels...")
session.run("rxiv", "--verbose", "clean", str(example_dest))
# Test 5: Test error handling with invalid paths
session.log("✅ Testing error handling...")
try:
session.run("rxiv", "pdf", "/nonexistent/path")
session.error("Expected error for nonexistent path")
except Exception:
session.log("✅ Error handling working correctly for invalid paths")
# Test 6: Validate package structure and style file accessibility
session.log("✅ Testing package structure and style file detection...")
session.run(
"python",
"-c",
"""
import rxiv_maker
from rxiv_maker.engines.operations.build_manager import BuildManager
import tempfile
import os
# Test style file detection in installed package context
with tempfile.TemporaryDirectory() as temp_dir:
build_manager = BuildManager(temp_dir)
# This tests the enhanced style file detection logic
style_dir = build_manager.style_dir
if style_dir and os.path.exists(style_dir):
print(f'✅ Style directory found: {style_dir}')
# Check for required style files
cls_file = os.path.join(style_dir, 'rxiv_maker_style.cls')
bst_file = os.path.join(style_dir, 'rxiv_maker_style.bst')
if os.path.exists(cls_file):
print(f'✅ Style class file found: {cls_file}')
else:
print(f'❌ Style class file missing: {cls_file}')
if os.path.exists(bst_file):
print(f'✅ Style bibliography file found: {bst_file}')
else:
print(f'❌ Style bibliography file missing: {bst_file}')
else:
print(f'❌ Style directory not found or inaccessible: {style_dir}')
raise Exception('Style file detection failed in installed package')
print('🎉 All style file detection tests passed!')
""",
)
# Test 7: Test CLI with local engine
session.log("✅ Testing local engine support...")
# Test with RXIV_ENGINE environment variable
import os
original_engine = os.environ.get("RXIV_ENGINE")
try:
os.environ["RXIV_ENGINE"] = "LOCAL"
session.run("rxiv", "clean", str(example_dest))
session.log("✅ Local engine working correctly")
except Exception as e:
session.log(f"⚠️ Local engine test: {e}")
finally:
if original_engine:
os.environ["RXIV_ENGINE"] = original_engine
elif "RXIV_ENGINE" in os.environ:
del os.environ["RXIV_ENGINE"]
# Test 8: Battle testing - comprehensive CLI validation
session.log("🔥 Running battle testing suite...")
# Test 8.1: Validate command with various flags
session.log("✅ Testing validate command...")
session.run("rxiv", "validate", "--help")
try:
session.run("rxiv", "validate", str(example_dest))
session.log("✅ Basic validation successful")
except Exception as e:
session.log(f"⚠️ Basic validation: {e}")
try:
session.run("rxiv", "validate", str(example_dest), "--detailed")
session.log("✅ Detailed validation successful")
except Exception as e:
session.log(f"⚠️ Detailed validation: {e}")
try:
session.run("rxiv", "validate", str(example_dest), "--no-doi")
session.log("✅ No-DOI validation successful")
except Exception as e:
session.log(f"⚠️ No-DOI validation: {e}")
# Test 8.2: Figures command
session.log("✅ Testing figures command...")
session.run("rxiv", "figures", "--help")
try:
session.run("rxiv", "figures", str(example_dest))
session.log("✅ Figures generation successful")
except Exception as e:
session.log(f"⚠️ Figures generation: {e}")
try:
session.run("rxiv", "figures", str(example_dest), "--force")
session.log("✅ Force figures generation successful")
except Exception as e:
session.log(f"⚠️ Force figures generation: {e}")
# Test 8.3: Clean command variations
session.log("✅ Testing clean command variations...")
session.run("rxiv", "clean", "--help")
clean_options = ["--temp-only", "--cache-only", "--figures-only", "--output-only"]
for option in clean_options:
try:
session.run("rxiv", "clean", str(example_dest), option)
session.log(f"✅ Clean {option} successful")
except Exception as e:
session.log(f"⚠️ Clean {option}: {e}")
# Test 8.4: Configuration commands
session.log("✅ Testing configuration commands...")
session.run("rxiv", "config", "--help")
try:
session.run("rxiv", "config", "show")
session.log("✅ Config show successful")
except Exception as e:
session.log(f"⚠️ Config show: {e}")
# Test 8.5: Bibliography commands
session.log("✅ Testing bibliography commands...")
session.run("rxiv", "bibliography", "--help")
session.run("rxiv", "bibliography", "add", "--help")
session.run("rxiv", "bibliography", "fix", "--help")
# Test 8.6: Check installation command
session.log("✅ Testing check-installation command...")
try:
session.run("rxiv", "check-installation")
session.log("✅ Check installation successful")
except Exception as e:
session.log(f"⚠️ Check installation: {e}")
# Test 8.7: Init command for new manuscripts
session.log("✅ Testing init command...")
session.run("rxiv", "init", "--help")
test_init_path = temp_path / "test_init_manuscript"
try:
session.run("rxiv", "init", str(test_init_path), "--template", "basic", "--no-interactive")
session.log("✅ Init basic template successful")
# Validate init creates proper structure
if (test_init_path / "00_CONFIG.yml").exists():
session.log("✅ Config file created by init")
if (test_init_path / "01_MAIN.md").exists():
session.log("✅ Main file created by init")
if (test_init_path / "03_REFERENCES.bib").exists():
session.log("✅ References file created by init")
except Exception as e:
session.log(f"⚠️ Init command: {e}")
# Test 8.8: PDF generation with various flags
session.log("✅ Testing PDF generation with various flags...")
try:
session.run("rxiv", "pdf", str(example_dest), "--skip-validation")
session.log("✅ PDF with skip-validation successful")
except Exception as e:
session.log(f"⚠️ PDF skip-validation: {e}")
try:
session.run("rxiv", "pdf", str(example_dest), "--force-figures", "--skip-validation")
session.log("✅ PDF with force-figures successful")
except Exception as e:
session.log(f"⚠️ PDF force-figures: {e}")
# Test 8.9: Test manuscript creation and full workflow (battle test scenario)
session.log("✅ Testing full manuscript workflow...")
workflow_test_path = temp_path / "workflow_test"
try:
# Create new manuscript using template
session.run("rxiv", "init", str(workflow_test_path), "--template", "research", "--no-interactive")
# Generate figures for the new manuscript
session.run("rxiv", "figures", str(workflow_test_path))
# Validate the new manuscript (skip DOI to avoid network issues)
session.run("rxiv", "validate", str(workflow_test_path), "--no-doi")
# Try to generate PDF (this tests the path bug fix we implemented)
session.run("rxiv", "pdf", str(workflow_test_path), "--skip-validation")
session.log("✅ Full workflow test successful - path bug fix verified!")
except Exception as e:
session.log(f"⚠️ Full workflow test: {e}")
# Test 8.10: Version command variations
session.log("✅ Testing version command...")
session.run("rxiv", "version")
try:
session.run("rxiv", "version", "--detailed")
session.log("✅ Detailed version successful")
except Exception as e:
session.log(f"⚠️ Detailed version: {e}")
session.log("🎉 All CLI battle testing completed successfully!")
session.log(f"📊 Test environment: {temp_path}")
session.log("✅ Package installation and CLI functionality verified in isolated environment")
session.log("🔥 Battle testing suite passed - all major CLI features validated!")
finally:
# Restore original working directory
os.chdir(original_cwd)
# Matrix/Specialized Sessions
@nox.session(python="3.11", reuse_venv=True)
def pdf(session):
"""Test PDF generation with local environment."""
install_project_deps(session)
# Test rxiv CLI PDF generation
session.run("rxiv", "pdf", "EXAMPLE_MANUSCRIPT")
# Test make command PDF generation
session.run("make", "pdf", external=True)
# Validate outputs exist (PDF is generated in EXAMPLE_MANUSCRIPT/output/)
session.run("ls", "-la", "EXAMPLE_MANUSCRIPT/output/", external=True)
@nox.session(python=PYTHON_VERSIONS, reuse_venv=False)
def test_cross(session):
"""Cross-version testing for releases (all Python versions)."""
install_project_deps(session)
session.run(
"pytest",
"tests/unit/",
"tests/integration/",
"-m",
"not slow",
"--maxfail=3",
*session.posargs,
)
@nox.session(python="3.11", reuse_venv=True)
def security(session):
"""Run comprehensive security checks with automated vulnerability detection."""
session.run("uv", "pip", "install", *SECURITY_DEPS, external=True)
# Security vulnerability scanning with enhanced configuration
session.log("Running pip-audit for known vulnerabilities...")
session.run("pip-audit", "--format", "json", "--output", "pip-audit-report.json", success_codes=[0, 1])
session.log("Running safety scan for known vulnerabilities...")
# Use --output json for non-interactive output, continue on failure to not block CI
session.run("safety", "scan", "--output", "json", success_codes=[0, 1, 2])
# Static security analysis
session.log("Running bandit for static security analysis...")
session.run("bandit", "-r", "src/", "-f", "json", "-o", "bandit-report.json", success_codes=[0, 1])
session.log("Security scanning completed - check report files for details")
@nox.session(python="3.11", reuse_venv=True)
def docs(session):
"""Generate comprehensive API documentation with validation."""
session.run("uv", "pip", "install", *DOC_DEPS, external=True)
install_project_deps(session)
session.log("Cleaning existing documentation...")
session.run("rm", "-rf", "docs/api/", external=True)
session.run("mkdir", "-p", "docs/api/", external=True)
session.log("Generating API documentation...")
# Generate comprehensive docs with better configuration
session.run(
"lazydocs",
"src/rxiv_maker/",
"--output-path",
"docs/api/",
"--overview-file",
"README.md",
"--src-base-url",
"https://github.com/HenriquesLab/rxiv-maker/blob/main/",
success_codes=[0, 1],
) # Continue on warning/non-critical errors
session.log("Documentation generation completed - check docs/api/ directory")
# Utility Sessions
@nox.session(python=False)
def clean(session):
"""Clean up nox environments and containers to free disk space."""
session.run("rm", "-rf", ".nox/", external=True)
session.log("Nox environments removed.")
# Container cleanup functionality has been removed as engines are deprecated
@nox.session(python=False)
def clean_all(session):
"""Clean all nox environments and perform aggressive container cleanup."""
session.run("rm", "-rf", ".nox/", external=True)
session.log("All nox environments cleaned.")
# Container cleanup functionality has been removed as engines are deprecated
# ======================================================================
# 🧹 ENHANCED CLEANUP SESSIONS (Space Optimization)
# ======================================================================