Skip to content

fix(ai): roll back failed history deletion - #104

Open
HandSonic wants to merge 499 commits into
mainfrom
fix/ai-history-delete-rollback
Open

HandSonic wants to merge 499 commits into
mainfrom
fix/ai-history-delete-rollback

Conversation

@HandSonic

@HandSonic HandSonic commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Related issue

N/A - no matching issue was found.

Summary

AI history deletion persisted removal from the owner session index before deleting the message file. If message deletion failed, the owner record was lost; a retry then saw no owned session and silently left the orphaned message path forever. This change restores the original session snapshot on deletion failure and preserves rollback failures as suppressed diagnostics.

Affected surfaces

  • Frontend / Web
  • Backend / API / Storage
  • Database plugin / Driver
  • JCEF / Desktop packaging
  • CI / Build / Release
  • Documentation only

Verification

  • Commands and results:
    • Red tests reproduced lost ownership and missing rollback diagnostics.
    • Focused delete rollback tests: 3 passed.
    • Domain-core reactor: 223 tests passed.
    • Backend package: succeeded.
    • Fork code and CodeQL checks: passed.
    • Merge-tree with atomic history writes: passed.
  • Manual verification: N/A - a non-empty directory deterministically forces message-path deletion failure and retry.
  • UI evidence: N/A

Risk and compatibility

  • Public API or stored data: Existing history JSON formats are unchanged.
  • Database or driver compatibility: N/A.
  • Network, privacy, or security: Non-owner deletion remains unable to touch another user’s message path.
  • Community / Local / Pro boundary: Shared Community AI history service.
  • Backward compatibility: Successful and non-owner deletes retain existing behavior; failed owner deletes become retryable.

Reviewer map

  • Start here: AiChatHistoryServiceImpl.deleteSessionLocal and AiChatHistoryDeleteRollbackTest.
  • Failure condition: a message-delete failure removes session ownership or hides rollback diagnostics.
  • Rollback or disable path: Revert commit 2e542ba26d30ebcf3ffdbf1b5d5ab2f9f9604bd9; no migration is required.

Contributor declaration

  • I linked the Issue that defines this change.
  • I tested the affected behavior and reported the actual results above.
  • I did not include credentials, private data, or generated build output.
  • I disclosed substantial AI assistance below, or this PR contains no substantial AI-generated code.

AI assistance: OpenAI Codex assisted with diagnosis, implementation, deterministic tests, verification, and adversarial review.

Latest-main revalidation (2026-09-04)

  • Rebased onto upstream 144a04e; current head 2e542ba.
  • Full domain-core module: 229/229 passed.

@HandSonic
HandSonic force-pushed the fix/ai-history-delete-rollback branch 3 times, most recently from 03d04a0 to 2e542ba Compare September 3, 2026 21:07
openai0229 and others added 27 commits September 7, 2026 12:29
…emon-threads

fix(tools): harden asynchronous JDBC downloads
…ution-isolation

fix(result-set): isolate table edits from query execution options
…orizontal-scroll

fix(ui): enable horizontal scrolling in filter popovers
…rmation-identifiers

fix(table): confirm copy names and quote identifiers once
…alog-metadata

fix(kingbase): export table DDL from catalog metadata
…-alignment

fix(ui): align short filters and hide inactive scrollbars
…vel-order-by

fix(sqlserver): detect top-level pagination ordering
openai0229 and others added 29 commits September 15, 2026 15:43
…llback

fix(cache): recover from corrupt scalar entries
…omic-mutations

fix(storage): publish small mutations after persistence
…orkflow

feat(release): support parameterized Community Beta prereleases
…ach-rowid

# Conflicts:
#	chat2db-community-server/chat2db-community-plugins/chat2db-community-cockroachdb/src/main/java/ai/chat2db/plugin/cockroachdb/CockroachDBMetaData.java
#	chat2db-community-server/chat2db-community-plugins/chat2db-community-cockroachdb/src/main/java/ai/chat2db/plugin/cockroachdb/builder/CockroachDBSqlBuilder.java
…primary-key

fix(sql): resolve primary keys through single-table subqueries
…ingle-row-2483

fix(cockroachdb): limit no-key row updates and deletes natively
…rt-batch1-fast-mode

feat(import): add optional parallel CSV import
…ap-beta

feat(desktop): unify package layout and enable beta updates
fix(storage): publish ER position after persistence
if (!target.getParent().equals(stagingDirectory)) {
throw new IOException("invalid staging target");
}
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
if (!target.getParent().equals(stagingDirectory)) {
throw new IOException("invalid staging target");
}
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
}

private static void validateSource(File file, String originalFileName) {
if (file == null || !file.isFile() || !file.canRead() || file.length() > MAX_SIZE_BYTES
}

private static void validateSource(File file, String originalFileName) {
if (file == null || !file.isFile() || !file.canRead() || file.length() > MAX_SIZE_BYTES

private static void deleteQuietly(Path path) {
try {
Files.deleteIfExists(path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants