feat: Structured compaction via unified ledger#2
Merged
Conversation
- Delete handoff-creator.ts and handoff-resumer.ts - Remove handoff imports and exports from agents/index.ts
There was a problem hiding this comment.
2 issues found across 26 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/hooks/auto-clear-ledger.ts">
<violation number="1" location="src/hooks/auto-clear-ledger.ts:108">
P1: File operations are cleared before confirming ledger-creator session was created successfully. If `ledgerSessionID` is undefined (session creation fails), `fileOps` data is lost permanently. Consider moving `getAndClearFileOps` inside the `if (ledgerSessionID)` block, or use `getFileOps` first and only call `clearFileOps` after the ledger-creator successfully processes the data.</violation>
</file>
<file name="tests/hooks/artifact-auto-index-ledger.test.ts">
<violation number="1" location="tests/hooks/artifact-auto-index-ledger.test.ts:4">
P2: Test doesn't validate parsing behavior - it only checks if certain strings exist in the source code. Consider testing the actual parsing function with sample ledger content to verify correct extraction of file operations.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
- Change getAndClearFileOps to getFileOps (read without clearing) - Only call clearFileOps after ledger-creator successfully completes - Export parseLedger for testing - Rewrite artifact-auto-index-ledger test to validate actual parsing - Add edge case tests for ledger parsing
There was a problem hiding this comment.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/hooks/auto-clear-ledger.ts">
<violation number="1" location="src/hooks/auto-clear-ledger.ts:157">
P1: The `clearFileOps` is called even when the ledger-creator polling times out (30 attempts without reaching "idle" status). This contradicts the comment and could cause file operations to be lost if the ledger-creator fails to complete. Consider only clearing when the status successfully reached "idle".</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Track ledgerCompleted flag to distinguish between timeout and success. File ops are preserved if polling times out, preventing data loss.
- Document new ledger format with Progress and File Operations sections - Add File Ops Tracker to hooks table - Add Factory.ai to inspiration section - Explain iterative merging and deterministic file tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Motivation
Based on Factory.ai's structured compaction research, which found that structured summarization with deterministic file tracking retains more useful context than alternatives.
Previously we had three overlapping artifacts:
Now unified into a single improved ledger that serves as both session state and compaction summary.
Changes
Removed: Handoff System
handoff-creator.tsandhandoff-resumer.tsagentsAdded: File Operations Tracker
file-ops-tracker.tshook intercepts read/write/edit tool callsUpdated: Ledger System
New Ledger Format
Testing
Summary by cubic
Unifies session continuity into a single iterative ledger with deterministic file operation tracking, removing the handoff system. This improves compaction quality, simplifies search/indexing, and auto-updates the ledger when context is near full.
New Features
Migration
Written for commit af987ac. Summary will update on new commits.