You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Logging enhancements: rotation, stats, and documentation #28
Valid CSV with runId, startTime, duration, issues, passed, failed
Unit Test
AC-6
Document logging system in docs/logging.md
Complete usage guide with examples
Manual Review
AC-7
Document JSON log schema for external tooling
Schema reference matching implementation
Manual Review
AC-8
Provide working jq examples
Commands execute successfully on real logs
Manual Test
Verification Criteria Details
AC-1/AC-2 - Log Rotation:
Given: Log directory exceeds size (>10MB) OR count (>100 files) threshold
When: New run completes OR `sequant logs --rotate` is called
Then: Oldest logs deleted until under threshold (with 10% buffer)
AC-3 - Manual Rotation:
Given: Log directory exists
When: `sequant logs --rotate [--dry-run]`
Then: Reports files deleted and space reclaimed (or would-be deleted in dry-run)
AC-4 - Stats Command:
Given: Multiple run logs exist in .sequant/logs/
When: `sequant stats` is run
Then: Shows:
- Total runs analyzed
- Success/failure rate (%)
- Average phase durations
- Most common failure points (phase + error pattern)
Given: Log directory exceeds size (>10MB) OR count (>100 files) threshold
When: LogWriter.finalize() completes OR `sequant logs --rotate` is called
Then: Oldest logs deleted until under threshold (with 10% buffer)
AC-3 - Manual Rotation:
Given: Log directory exists
When: `sequant logs --rotate [--dry-run]`
Then: Reports files deleted and space reclaimed (or would-be in dry-run)
AC-4 - Stats Command:
Given: Multiple run logs exist in .sequant/logs/
When: `sequant stats` is run
Then: Shows:
- Total runs analyzed
- Success/failure rate (%)
- Average phase durations (by phase type)
- Most common failure points (phase + error pattern)
AC-5 - CSV Export:
Given: Run logs exist
When: `sequant stats --csv`
Then: Valid CSV with headers: runId,startTime,duration,issues,passed,failed,phases
AC-8 - jq Examples:
# List failed runs
jq 'select(.summary.failed > 0)' .sequant/logs/*.json
# Average duration
jq -s 'map(.summary.totalDurationSeconds) | add / length' .sequant/logs/*.json
# Common errors by phase
jq '.issues[].phases[] | select(.error) | {phase, error}' .sequant/logs/*.json
Implementation Plan
Phase 1: Log Rotation (AC-1, AC-2, AC-3)
Step
File
Description
1A
src/lib/settings.ts
Add rotation: { enabled, maxSizeMB, maxFiles } to RunSettings
1B
src/lib/workflow/log-rotation.ts
Create rotation module with getLogStats(), rotateIfNeeded()
1C
src/lib/workflow/log-writer.ts
Integrate rotateIfNeeded() into finalize()
1D
src/commands/logs.ts
Add --rotate and --dry-run flags
1E
src/lib/workflow/log-rotation.test.ts
Unit tests for rotation logic
Phase 2: Stats Command (AC-4, AC-5)
Step
File
Description
2A
src/commands/stats.ts
Create stats command with aggregate calculations
2B
bin/cli.ts
Register sequant stats command
2C
src/commands/stats.test.ts
Unit tests for stats calculations
Phase 3: Documentation (AC-6, AC-7, AC-8)
Step
File
Description
3A
docs/logging.md
System overview, configuration, rotation policy
3B
docs/logging.md
JSON schema reference
3C
docs/logging.md
jq examples section
Design Decisions
Decision
Choice
Rationale
Rotation strategy
Delete oldest (not compress)
Simpler; compression deferred per issue
Rotation buffer
Stop at 90% of threshold
Prevents immediate re-rotation
Stats location
Separate sequant stats command
Cleaner UX vs logs --stats
Auto-rotation
Enabled by default
Prevents unbounded log growth
File age determination
File mtime (not filename parsing)
More reliable
Assumptions to Validate
Total size calculated from file stats (not directory size)
Only run-*.json files counted for rotation
CSV properly escapes special characters
Schema version documented (currently version: 1)
Recommended Workflow
Phases:exec → qa Quality Loop: disabled Reasoning: CLI feature with clear AC. Unit tests provide primary verification. No browser testing needed.
Effort Breakdown
Log Rotation: ~40% (new module + integration + tests)
Activity
admarble commentedon Jan 9, 2026
Implementation Plan for #28
Acceptance Criteria
.sequant/logs/exceeds 10MB--rotateCLI flag for manual rotationsequant statscommand with aggregate analysisdocs/logging.mdVerification Criteria
AC-1/AC-2 - Log Rotation:
--rotateis calledAC-4 - Stats Command:
sequant statsis runAC-5 - CSV Export:
sequant stats --csvAC-8 - jq Examples:
Implementation Phases
Phase 1: Log Rotation
src/lib/workflow/log-rotation.tswith rotation logicsrc/lib/settings.tsLogWriter.finalize()--rotateflag tosequant logscommandPhase 2: Stats Command
src/commands/stats.tswith aggregate calculationssequant statsinbin/cli.ts--csvflagPhase 3: Documentation
docs/logging.mdwith system overviewSettings Schema Addition
{ "run": { "rotation": { "enabled": true, "maxSizeMB": 10, "maxFiles": 100 } } }Design Decisions
sequant statscommandlogs --statsEffort Breakdown
Recommended Workflow
Phases:
exec→qaQuality Loop: disabled
Reasoning: CLI feature with clear AC. No browser testing needed.
admarble commentedon Jan 9, 2026
Spec Review: Verification Criteria & Implementation Plan
Acceptance Criteria with Verification
.sequant/logs/exceeds 10MB--rotateCLI flag for manual rotationsequant statscommand with aggregate analysisdocs/logging.mdVerification Criteria Details
AC-1/AC-2 - Log Rotation:
AC-3 - Manual Rotation:
AC-4 - Stats Command:
AC-5 - CSV Export:
AC-8 - jq Examples:
Implementation Plan
Phase 1: Log Rotation (AC-1, AC-2, AC-3)
Add
RotationSettingstosrc/lib/settings.ts:Create
src/lib/workflow/log-rotation.ts:getLogStats()- size/count analysisrotateIfNeeded()- threshold check + rotationIntegrate into
LogWriter.finalize()- auto-rotate after writeAdd
--rotateflag tosequant logscommand with--dry-runsupportUnit tests:
src/lib/workflow/log-rotation.test.tsPhase 2: Stats Command (AC-4, AC-5)
Create
src/commands/stats.ts:--csvflagRegister in
bin/cli.tswith options:--csv,--path,--jsonUnit tests:
src/commands/stats.test.tsPhase 3: Documentation (AC-6, AC-7, AC-8)
docs/logging.md:Design Decisions
sequant statscommandlogs --statsOpen Questions
Time filtering for stats - Defer
--since/--last-n-daysto future?Compression - Implement as alternative to deletion?
Recommended Workflow
Phases:
exec→qaQuality Loop: disabled
Reasoning: CLI feature with clear AC. Unit tests provide primary verification. No browser testing needed.
Effort Breakdown
admarble commentedon Jan 10, 2026
Spec Review: Enhanced Verification Criteria & Implementation Plan
Acceptance Criteria with Verification
.sequant/logs/exceeds 10MB--rotateCLI flag for manual rotation--dry-runsupportsequant statscommand with aggregate analysisdocs/logging.mdVerification Criteria Details
AC-1/AC-2 - Log Rotation:
AC-3 - Manual Rotation:
AC-4 - Stats Command:
AC-5 - CSV Export:
AC-8 - jq Examples:
Implementation Plan
Phase 1: Log Rotation (AC-1, AC-2, AC-3)
src/lib/settings.tsrotation: { enabled, maxSizeMB, maxFiles }to RunSettingssrc/lib/workflow/log-rotation.tsgetLogStats(),rotateIfNeeded()src/lib/workflow/log-writer.tsrotateIfNeeded()intofinalize()src/commands/logs.ts--rotateand--dry-runflagssrc/lib/workflow/log-rotation.test.tsPhase 2: Stats Command (AC-4, AC-5)
src/commands/stats.tsbin/cli.tssequant statscommandsrc/commands/stats.test.tsPhase 3: Documentation (AC-6, AC-7, AC-8)
docs/logging.mddocs/logging.mddocs/logging.mdDesign Decisions
sequant statscommandlogs --statsAssumptions to Validate
run-*.jsonfiles counted for rotationRecommended Workflow
Phases:
exec→qaQuality Loop: disabled
Reasoning: CLI feature with clear AC. Unit tests provide primary verification. No browser testing needed.
Effort Breakdown
🤖 Generated with Claude Code via
/spec 28feat(#28): Add log rotation, stats command, and logging documentation
admarble commentedon Jan 10, 2026
Implementation Progress Update
AC Coverage
.sequant/logs/exceeds 10MB--rotateCLI flag for manual rotationsequant statscommand with aggregate analysisdocs/logging.mdKey Files Changed
New Files:
src/lib/workflow/log-rotation.ts- Log rotation logic with size/count thresholdssrc/lib/workflow/log-rotation.test.ts- 16 unit tests for rotationsrc/commands/stats.ts- Stats command with aggregate analysissrc/commands/stats.test.ts- 9 unit tests for statsdocs/logging.md- Comprehensive documentationModified Files:
bin/cli.ts- Register stats commandsrc/commands/logs.ts- Add --rotate and --dry-run flagssrc/lib/settings.ts- Add RotationSettings interfacesrc/lib/workflow/log-writer.ts- Integrate auto-rotationTest Results
PR Status
Created: #53
Implementation Notes
LogWriter.finalize()--json), and CSV (--csv) formats🤖 Generated with Claude Code via
/exec 28admarble commentedon Jan 10, 2026
QA Review for Issue #28
AC Coverage
.sequant/logs/exceeds 10MBgetFilesToDelete()checksexceedsSizeThresholdand deletes oldest files until ≤9MB (90% buffer).exceedsCountThresholdtriggers rotation to 90 files. Unit tests verify behavior.--rotateCLI flag for manual rotationlogs.tsimplementshandleRotation()with--rotateand--dry-runflags.sequant statscommand with aggregate analysis--csvoutputs valid CSV with required headers.docs/logging.mdCoverage: 8/8 AC items fully met
Quality Metrics
any)Code Review Summary
Strengths:
log-rotation.tsfor rotation,stats.tsfor statisticsIssues: None identified
Verdict: READY_FOR_MERGE ✅
All 8 AC fully met with comprehensive test coverage. Implementation is clean, well-documented, and follows project patterns.
🤖 Generated with Claude Code via
/qa 28feat(#28): Add log rotation, stats command, and logging documentation (…
chore: release v1.2.7 - logging enhancements, MCP documentation
feat(#28): Add log rotation, stats command, and logging documentation