feat: RFC-20 Phase 3 — GC Integration #30

Merged
xiaonuo merged 1 commits from fix/23-gc-integration into main 2026-05-30 08:30:51 +00:00
Owner

What

Implements garbage collection (GC) integration for the json-cas variable system following RFC-20 Phase 3 specification.

Why

Enables automatic cleanup of unreachable CAS nodes to prevent storage bloat and maintain a minimal working set of required data.

Changes

Core Implementation

  • packages/json-cas/src/gc.ts — Mark-and-sweep GC algorithm
  • packages/json-cas/src/gc.test.ts — Comprehensive test suite (16 scenarios)

Store Interface Extensions

  • Added listAll() and delete() to Store interface
  • Implemented for MemoryStore and FsStore

CLI Integration

  • Added json-cas gc command
  • Outputs JSON: { total, reachable, collected, scanned }

Test Results

All 230 tests pass
Clean build
No lint errors

Ref

Fixes #23

## What Implements garbage collection (GC) integration for the json-cas variable system following RFC-20 Phase 3 specification. ## Why Enables automatic cleanup of unreachable CAS nodes to prevent storage bloat and maintain a minimal working set of required data. ## Changes ### Core Implementation - `packages/json-cas/src/gc.ts` — Mark-and-sweep GC algorithm - `packages/json-cas/src/gc.test.ts` — Comprehensive test suite (16 scenarios) ### Store Interface Extensions - Added `listAll()` and `delete()` to Store interface - Implemented for MemoryStore and FsStore ### CLI Integration - Added `json-cas gc` command - Outputs JSON: { total, reachable, collected, scanned } ## Test Results ✅ All 230 tests pass ✅ Clean build ✅ No lint errors ## Ref Fixes #23
xiaoju added 1 commit 2026-05-30 08:24:40 +00:00
Implements garbage collection (GC) with mark-and-sweep algorithm:
- Mark phase: recursively walks references from all variable values (global, not scoped)
- Sweep phase: deletes unmarked CAS nodes
- Schema preservation: schemas referenced by reachable nodes are preserved
- Bootstrap preservation: self-referencing meta-schema always preserved

New features:
- Core gc() function in packages/json-cas/src/gc.ts with GcStats interface
- Extended Store interface with listAll() and delete() methods
- CLI command: json-cas gc (outputs JSON stats)
- Comprehensive test suite with 16 test scenarios

Implements: #23

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
xiaonuo merged commit cd338822f2 into main 2026-05-30 08:30:51 +00:00
This repo is archived. You cannot comment on pull requests.
No Reviewers
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/json-cas#30