Skip to content

Conversation

@aridyckovsky
Copy link
Owner

What

Time-Series Checkpoints: Implement JSON checkpoint system for tracking audit history with automatic thread linking, delta computation, and O(1) access to latest audit via symlink.

New Services: Add Time and ProcessInfo services for testable date/time and environment variable access.

Why

Enable migration progress tracking by preserving audit snapshots instead of overwriting. Each checkpoint:

  • Links to Amp thread via AMP_CURRENT_THREAD_ID
  • Computes deltas between consecutive audits
  • Uses normalized schema (FindingsGroup) for 40-70% size reduction
  • Provides CLI commands for history navigation

Scope

Packages affected:

  • @effect-migrate/core - Checkpoint manager, Time/ProcessInfo services, checkpoint schemas
  • @effect-migrate/cli - Checkpoints command for history navigation

Changeset

  • Changeset added

Changeset summary:

Add time-series checkpoint persistence with automatic thread linking and delta computation. New services: Time and ProcessInfo for testable date/time and environment access. New CLI command: checkpoints for audit history navigation.

Testing

pnpm build:types && pnpm typecheck && pnpm lint && pnpm build && pnpm test

All checks pass:

New tests added:

  • packages/core/test/amp/checkpoint-manager.test.ts (24 tests) - ID generation, manifest management, delta computation
  • packages/core/test/services/Time.test.ts (5 tests) - Time service layer validation
  • packages/core/test/services/ProcessInfo.test.ts (5 tests) - Environment variable access
  • packages/cli/test/commands/checkpoints.test.ts (9 tests) - CLI command validation

Manual testing verified:

  • Multi-session workflow with different thread IDs
  • Symlink creation on Unix (macOS)
  • Delta computation between consecutive audits
  • CLI commands: list, latest, show, diff

Checkpoint Structure

.amp/effect-migrate/
├── index.json                    # Updated with checkpoint info
├── audit.json                    # Symlink to latest checkpoint
├── checkpoints/
│   ├── 2025-11-08T10-00-00Z.json # Timestamped checkpoints
│   ├── 2025-11-08T11-30-00Z.json
│   └── manifest.json             # Navigation index
├── threads.json
├── metrics.json
└── badges.md

Schema Changes

New schemas in @effect-migrate/core/src/schema/amp.ts:

  • AuditCheckpoint - Full audit snapshot with checkpointId
  • CheckpointMetadata - Manifest entry with delta and thread info
  • CheckpointManifest - Complete history index
  • CheckpointSummary - Navigation summary for index.json

Updated schemas:

  • AmpContextIndex - Added latestCheckpoint and checkpoints fields

CLI Commands

# List checkpoint history
pnpm cli checkpoints list

# Show latest checkpoint
pnpm cli checkpoints latest

# Show specific checkpoint
pnpm cli checkpoints show 2025-11-08T10-00-00Z

# Compare two checkpoints
pnpm cli checkpoints diff 2025-11-08T10-00-00Z 2025-11-08T11-30-00Z

Key Features

Automatic Thread Linking:

  • Detects AMP_CURRENT_THREAD_ID environment variable
  • Associates checkpoint with Amp thread
  • Displayed in CLI output and stored in metadata

Delta Computation:

  • Calculates changes in errors/warnings/info between checkpoints
  • Stored in manifest for O(1) access
  • Formatted with +/- indicators in CLI

Efficient Storage:

  • Uses FindingsGroup schema (normalized from PR2)
  • 40-70% size reduction vs. flat format
  • Symlink to latest checkpoint for compatibility

Test Infrastructure:

  • Mock filesystem helpers for isolated testing
  • Deterministic timestamps via Time service layer
  • Environment variable mocking via ProcessInfo service

Checklist

  • Code follows Effect-TS best practices
  • TypeScript strict mode passes
  • All tests pass
  • Linter passes
  • Build succeeds
  • Changeset created
  • Manual multi-session testing completed

Agent Context

Implementation approach:

Time/ProcessInfo services:

  • Created testable abstractions for date/time and environment access
  • Implemented Live and Test layers for each service
  • Enabled deterministic testing via controlled time/env values

Checkpoint manager:

  • Filesystem-safe ID generation (ISO 8601 with hyphens)
  • Thread detection via ProcessInfo service
  • Delta computation from FindingsSummary structs
  • Manifest management with newest-first ordering

CLI integration:

  • Table formatting via cli-table3 for readable output
  • JSON output support via --json flag
  • Error handling for missing checkpoints
  • Symlink validation and fallback

Test infrastructure:

  • Mock filesystem helpers for isolated service testing
  • Snapshot testing for CLI output formatting
  • Cross-platform compatibility (symlink/copy based on OS)

Amp Threads:

Related docs:

  • @docs/agents/plans/pr3-json-checkpoints.md
  • @docs/agents/plans/checkpoint-based-audit-persistence.md
  • @docs/agents/plans/comprehensive-data-architecture.md

Migration Impact

For external consumers: None (pre-1.0, no published versions)

For internal development:

  • Existing .amp/effect-migrate/audit.json preserved via symlink
  • Checkpoints directory created on first audit after PR
  • No breaking changes to audit schema (uses 0.2.0 from PR2)

Commits

7 commits organized in 2 phases:

  1. Services infrastructure (commits 1-2) - Time and ProcessInfo services with test layers
  2. Checkpoint implementation (commits 3-5) - Manager, schemas, CLI command, integration
  3. Test infrastructure (commits 6-7) - Mock helpers, refactoring, documentation

aridyckovsky and others added 11 commits November 8, 2025 17:25
- Add Time service with Clock capture pattern for testable timestamps
- Add ProcessInfo service for Effect-first env/cwd access
- Time.Default captures Clock once at construction to prevent leaking
- Export service helpers (nowMillis, now, nowUtc, checkpointId, formatCheckpointId)
- Schema.decodeUnknownSync pattern for DateTime.Utc creation without casting

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
- Replace direct Clock usage with Time service in context-writer and thread-manager
- Replace process.cwd() with ProcessInfo.cwd in thread command
- Establish ThreadLayer pattern combining NodeContext, ProcessInfo, Time, Clock
- Update CLI entry point with AppLayer providing all required services
- Fix package-meta error handling to use Effect-native string failures
- Update thread tests to use proper layer construction with Clock provision

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
- Add mock-filesystem.ts with makeMockFileSystem, MockPathLayer, MockProcessInfoLayer
- Add helpers.ts with readJson utility for schema-validated test reads
- Refactor context-writer tests to use new test helper infrastructure
- Refactor thread-manager tests with makeThreadTestContext pattern
- Simplify RuleRunner tests using helper utilities
- MockProcessInfoLayer reads actual process.env for dynamic test control

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
- Add checkpoint-manager.ts implementing time-series audit snapshots
- Add CheckpointSummary, CheckpointMetadata, CheckpointManifest schemas
- Add AuditCheckpoint schema for individual checkpoint files
- Implement generateCheckpointId, computeDelta, createCheckpoint, readCheckpoint
- Implement manifest management (readManifest, writeManifest, listCheckpoints)
- Export RuleKindSchema for checkpoint validation
- Update AmpContextIndex schema with checkpoint navigation fields
- Update tsconfig with exactOptionalPropertyTypes workaround comment

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
- Add checkpoints.ts with list, show, latest, diff subcommands
- Implement checkpoint navigation UI with tables and formatted output
- Add delta visualization showing progress trends
- Support JSON output for programmatic access
- Integrate with existing ThreadLayer for service provision

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
- Update pr3-json-checkpoints.md with actual implementation details
- Add Time and ProcessInfo to vscode sortImports ignore list

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
Add detailed plan for automating @SInCE tag management in TSDoc comments:
- Convention: Use @SInCE NEXT placeholder for new exports
- Automation: Script replaces NEXT with actual versions during changeset bumps
- Validation: ESLint rule + CI checks enforce tag presence
- Integration with existing Changesets workflow

Amp-Thread-ID: https://ampcode.com/threads/T-a15b90b3-d708-46f1-a20d-188db13bc420
Co-authored-by: Amp <amp@ampcode.com>
@aridyckovsky aridyckovsky self-assigned this Nov 8, 2025
@aridyckovsky aridyckovsky added pkg:core Issues related to @effect-migrate/core package pkg:cli Issues related to @effect-migrate/cli package type:feature New feature or request type:docs Documentation improvements type:refactor Code refactoring effect-ts Effect-TS patterns and usage services Service layers and dependency injection migration Migration tooling and patterns priority:high High priority amp:audit Audit context and structured violation output changeset:next-minor Changes planned for next minor version pr:breaking-change Contains breaking changes pr:size:large Large PR (> 500 lines) and removed pr:breaking-change Contains breaking changes labels Nov 8, 2025
Generated detailed Amp review covering:
- Architecture and implementation quality analysis
- File-by-file code review with strengths and observations
- Test coverage assessment
- Security and performance considerations
- Pre-merge checklist verification
- Future enhancement suggestions

All checks passing, ready for merge.

Amp-Thread-ID: https://ampcode.com/threads/T-f8c50070-3fad-49b9-8a26-c7ddb08fd6f3
Co-authored-by: Amp <amp@ampcode.com>
@aridyckovsky aridyckovsky merged commit a9b0305 into main Nov 8, 2025
1 check passed
@github-actions github-actions bot mentioned this pull request Nov 8, 2025
@aridyckovsky aridyckovsky deleted the feat/json-checkpoints branch November 8, 2025 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amp:audit Audit context and structured violation output changeset:next-minor Changes planned for next minor version effect-ts Effect-TS patterns and usage migration Migration tooling and patterns pkg:cli Issues related to @effect-migrate/cli package pkg:core Issues related to @effect-migrate/core package pr:size:large Large PR (> 500 lines) priority:high High priority services Service layers and dependency injection type:docs Documentation improvements type:feature New feature or request type:refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants