Harden Pi compaction, turn lifecycle, and session durability - #24
Merged
Conversation
There was a problem hiding this comment.
Caution
The context-overflow compact-and-retry and the transient-provider retry are both broken in production: the failed assistant attempt can never be isolated because transaction markers sit on the branch tail. See the inline comment for the exact mechanism and a fix.
Reviewed changes
- Crash-recoverable Pi journals — transaction envelopes, torn-final-line repair, corrupt-journal quarantine, exact-owner deletion, and startup orphan reconciliation.
- Pi provenance + renderer privacy — canonical provider protocol persisted under
ChatMessage.piand stripped bychatForRendererbefore any renderer-facing return. - Compaction hardening — pre-prompt pressure checks, adaptive thresholds, bounded map-reduce, and structural summary validation.
- Turn lifecycle + retry — sequential foreground tools, crash-recovery turn envelope, exact terminal projection reconciliation, and abortable retry backoff.
- Schedule + usage —
AbortSignalforwarding through schedule mutations with restore semantics, pluscompaction-source usage accounting andcacheWrite1hretention.
DeepSeek Pro | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Unwrapped journal transactions for retries —
abandonRetryableAssistantnow scans backward pastAIDEN_PI_TRANSACTION/AIDEN_CHAT_MESSAGE_MARKERmarkers to isolate the failed assistant attempt, then rolls back the entire committed envelope (via the begin marker'sparentId), restoring the context-overflow compact-and-retry and transient-provider retry paths that the transaction wrapping had silently broken. - Reproduced the production append path in tests — the overflow and transient-provider tests now append the failed assistant through
appendPiMessagesand assert the branch is left free of transaction markers and the failederrormessage after rollback.
DeepSeek Pro | 𝕏
…ss-hardening # Conflicts: # package.json
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
Validation
Review process
Three independent fresh-context reviewers audited compaction correctness, durability/privacy, and completeness. Their validated findings were fixed in the final three commits.