Add compaction source pruning#24
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e6ad1d1c29
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| let updated = false; | ||
| for (const id of sourceIds) { | ||
| const entry = index.trajectories[id]; |
There was a problem hiding this comment.
Guard missing index maps during source discard
Handle structurally invalid index.json the same way as markTrajectoriesAsCompacted(): in discardSourceTrajectories(), index.trajectories is dereferenced without a guard, so a valid-but-corrupt index (for example { "version": 1 } from manual edits or partial writes in any search path) throws after the compaction artifact has already been written. That turns trail compact --discard-sources into a hard failure and can leave users with partial side effects instead of the intended best-effort cleanup.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in c6ba4cc by validating the parsed index shape before touching index.trajectories, so structurally invalid indexes are skipped during best-effort source discard.
e6ad1d1 to
c6ba4cc
Compare
Summary
trail compact --discard-sourcesto remove source trajectory JSON/Markdown/trace files and prune index entries after compactioncompactWorkflowand SDK auto-compaction optionsVerification
npm run lintnpm run typechecknpm test -- --run