fix: mark consolidated events even when later sessions error#265
fix: mark consolidated events even when later sessions error#265nvandessel merged 3 commits intomainfrom
Conversation
When runner.Run() returned an error (e.g., one session's LLM call timed out), both cmd_consolidate.go and handler_consolidate.go returned early without calling MarkConsolidated. This left ALL events — including those from successfully-processed sessions — unmarked, causing the pipeline to re-process the same events on every invocation and burning rate limit on redundant work. Now MarkConsolidated runs before the error check, using the SourceEventIDs that the runner already preserves from successful sessions. The mark failure is logged as a warning rather than masking the original pipeline error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #265 +/- ##
=======================================
Coverage 78.77% 78.78%
=======================================
Files 186 186
Lines 18685 18687 +2
=======================================
+ Hits 14720 14723 +3
+ Misses 2742 2741 -1
Partials 1223 1223 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Greptile SummaryThis PR fixes a significant pipeline-efficiency bug: when The fix reorders the Key changes:
Confidence Score: 5/5Safe to merge; the logic change is minimal, well-reasoned, and the prior logger-inconsistency concern was already addressed. All remaining findings are P2 style/test-design observations. The core reordering is correct: runner.Run always returns a non-nil result with SourceEventIDs only from fully-processed sessions, so calling MarkConsolidated before the error check is sound. No production behavior regressions identified. runner_test.go — integration test calls MarkConsolidated under DryRun:true, which is a cosmetic mismatch with the !dryRun guard used by actual callers.
|
| Filename | Overview |
|---|---|
| cmd/floop/cmd_consolidate.go | Reorders MarkConsolidated before the runErr check, adds result != nil guard, and demotes MarkConsolidated failures from hard errors to stderr warnings — correctly preserving progress from successful sessions on partial pipeline failure. |
| internal/mcp/handler_consolidate.go | Same reordering as the CLI handler: MarkConsolidated now runs before runErr is checked, and MarkConsolidated failure is a logged warning rather than a hard error returned to the MCP caller. |
| internal/consolidation/runner_test.go | Adds two new tests covering partial-failure semantics: a unit test verifying SourceEventIDs are populated from the successful session and an integration test using a real SQLite store. Integration test calls MarkConsolidated under DryRun:true, which doesn't match the production !dryRun guard. |
Sequence Diagram
sequenceDiagram
participant Caller as CLI / MCP Handler
participant Runner as consolidation.Runner
participant ES as EventStore
Caller->>Runner: Run(ctx, evts, graphStore, opts)
loop per session
Runner->>Runner: runSession(sess-ok) → SourceEventIDs=[e1,e2]
Runner->>Runner: runSession(sess-fail) → error
Runner-->>Caller: result{SourceEventIDs:[e1,e2]}, runErr
end
Note over Caller,ES: Fixed order (this PR)
alt !dryRun && result != nil && len(SourceEventIDs) > 0
Caller->>ES: MarkConsolidated([e1, e2])
ES-->>Caller: ok (or warn on failure)
end
alt runErr != nil
Caller-->>Caller: return error (e3 remains unconsolidated)
end
Reviews (3): Last reviewed commit: "test: add coverage for mark-consolidated..." | Re-trigger Greptile
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Two new tests: - TestRunner_MarkConsolidatedOnPartialFailure: verifies SourceEventIDs from successful sessions are available for marking when a later session fails (unit test, no I/O) - TestRunner_MarkConsolidatedOnPartialFailure_WithEventStore: end-to-end integration test with real SQLite event store — verifies that events from successful sessions are marked consolidated while events from failed sessions remain unconsolidated Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
runner.Run()returned an error (e.g., one session's LLM call timed out), both CLI and MCP handlers returned early without callingMarkConsolidatedMarkConsolidatedruns before the error check, preserving progress from successful sessionsTest plan
CGO_ENABLED=0 go test ./internal/consolidation/ ./internal/events/ -count=1🤖 Generated with Claude Code