Summary
engram projects prune reports a success count that includes projects it failed to prune. In the same output it prints three FOREIGN KEY constraint failed errors and then claims all nine projects were pruned. Six were.
The underlying data stayed consistent — no observations were lost and PRAGMA integrity_check / PRAGMA foreign_key_check are clean — so this is a reporting defect, not corruption. But the summary line is the only thing a caller sees, and it asserts an outcome that did not happen.
Steps to Reproduce
- Have a store with several zero-observation projects, at least one of which has sessions referenced by another table.
- Run
engram projects prune.
- Answer
all at the selection prompt.
Actual Behavior
Error pruning "<project-a>": prune sessions: constraint failed: FOREIGN KEY constraint failed (787)
Error pruning "<project-b>": prune sessions: constraint failed: FOREIGN KEY constraint failed (787)
Error pruning "<project-c>": prune sessions: constraint failed: FOREIGN KEY constraint failed (787)
Pruned 9 project(s): 1911 sessions, 489 prompts removed.
Nine were listed, three errored, and the summary says nine were pruned.
Verified against the store before and after:
|
before |
after |
delta |
| sessions |
3,626 |
1,715 |
−1,911 |
| user_prompts |
7,253 |
6,764 |
−489 |
| observations |
6,549 |
6,549 |
0 |
The session and prompt deltas match the summary exactly, so those two numbers are truthful. The project count is not — the three failed projects still exist, each still holding one session:
<project-a>: 1 session
<project-b>: 1 session
<project-c>: 1 session
Store integrity after the run:
PRAGMA foreign_key_check → 0 rows
PRAGMA integrity_check → ok
Expected Behavior
Either of these would be correct; the first seems closer to the intent of the command:
- Report only what succeeded:
Pruned 6 project(s), 3 failed: 1911 sessions, 489 prompts removed, with a non-zero exit code.
- Or treat the batch as atomic and roll back on any failure.
What should not happen is a count that sums attempts while errors for the failures are printed directly above it. A caller scripting around this command, or a user skimming the last line, would conclude the store is clean when three projects remain.
Note on the constraint itself
The failures look legitimate — those sessions are referenced elsewhere, so the delete is correctly refused. The defect here is only that the refusal is not reflected in the summary. Whether zero-observation projects whose sessions are still referenced should be prunable at all is a separate design question, and if the answer is no, listing them as prune candidates in the first place is arguably the earlier bug.
Environment
engram v1.20.0+patch.busytimeout
- Linux x86_64, Arch
- SQLite store in WAL mode, ~6.5k observations across 39 projects at the time of the run
Summary
engram projects prunereports a success count that includes projects it failed to prune. In the same output it prints threeFOREIGN KEY constraint failederrors and then claims all nine projects were pruned. Six were.The underlying data stayed consistent — no observations were lost and
PRAGMA integrity_check/PRAGMA foreign_key_checkare clean — so this is a reporting defect, not corruption. But the summary line is the only thing a caller sees, and it asserts an outcome that did not happen.Steps to Reproduce
engram projects prune.allat the selection prompt.Actual Behavior
Nine were listed, three errored, and the summary says nine were pruned.
Verified against the store before and after:
The session and prompt deltas match the summary exactly, so those two numbers are truthful. The project count is not — the three failed projects still exist, each still holding one session:
Store integrity after the run:
Expected Behavior
Either of these would be correct; the first seems closer to the intent of the command:
Pruned 6 project(s), 3 failed: 1911 sessions, 489 prompts removed, with a non-zero exit code.What should not happen is a count that sums attempts while errors for the failures are printed directly above it. A caller scripting around this command, or a user skimming the last line, would conclude the store is clean when three projects remain.
Note on the constraint itself
The failures look legitimate — those sessions are referenced elsewhere, so the delete is correctly refused. The defect here is only that the refusal is not reflected in the summary. Whether zero-observation projects whose sessions are still referenced should be prunable at all is a separate design question, and if the answer is no, listing them as prune candidates in the first place is arguably the earlier bug.
Environment
engramv1.20.0+patch.busytimeout