fix: orphan accepted commit marker self-healing — auto-clear stale marker when no recoverable graph source exists

- Add maybeResolveOrphanAcceptedCommitMarker() for conservative orphan detection:
  - Chat-state sidecar rescue first (preserves marker, keeps mismatch diagnostic)
  - Only clears marker when ALL local sources confirmed absent
  - Guards: shadow-available, migration-failed, chat-switched all block clearing
- Enhance clearCurrentChatCommitMarker() with resetAcceptedRevision option
  - Resets lastAcceptedRevision and acceptedStorageTier when marker is orphan
- Integrate orphan resolution into loadGraphFromIndexedDb() empty+mismatch branch
- Update onDeleteCurrentIdbController/onDeleteAllIdbController to resetAcceptedRevision
- Update graph-persistence regressions:
  - Orphan marker scenario now auto-heals to EMPTY_CONFIRMED (was: permanently BLOCKED)
  - Add chat-state rescue guard test: sidecar data prevents marker clearing
This commit is contained in:
Youzini-afk
2026-04-12 20:35:29 +08:00
parent 648a7a1741
commit 5bd29c99d5
3 changed files with 257 additions and 3 deletions

View File

@@ -1196,6 +1196,7 @@ export async function onDeleteCurrentIdbController(runtime) {
runtime.clearCurrentChatCommitMarker?.({
reason: "manual-delete-current-idb",
immediate: true,
resetAcceptedRevision: true,
});
runtime.syncGraphLoadFromLiveContext?.({
source: "manual-delete-current-idb",
@@ -1252,6 +1253,7 @@ export async function onDeleteAllIdbController(runtime) {
runtime.clearCurrentChatCommitMarker?.({
reason: "manual-delete-all-idb",
immediate: true,
resetAcceptedRevision: true,
});
runtime.syncGraphLoadFromLiveContext?.({
source: "manual-delete-all-idb",