Skip to content

fix(storage): preserve tree on invalid or failed moves - #2816

Closed
HandSonic wants to merge 6 commits into
OtterMind:mainfrom
HandSonic:fix/tree-drop-preserve-source
Closed

HandSonic wants to merge 6 commits into
OtterMind:mainfrom
HandSonic:fix/tree-drop-preserve-source

Conversation

@HandSonic

@HandSonic HandSonic commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

N/A - this defect was found during review of local tree storage moves; no public issue currently tracks it.

Summary

  • Keep the stored tree unchanged when a move targets a missing node, itself, or a descendant.
  • Persist a candidate tree before publishing tree moves or tree-node deletions in memory.
  • Preserve normal group and datasource creation through a separate internal insertion path; existing-node moves retain their validation.

This PR is limited to tree operations and their direct creation regression. General record-storage rollback, cross-file transactions, and retry/idempotency changes are excluded.

Affected surfaces

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

Verification

  • Local storage reactor tests and package passed: storage 79, domain-api 27, tools 77; 183 tests total, zero failures/errors/skips.
  • Command: mvn -B -ntp -f chat2db-community-server/pom.xml -pl :chat2db-community-storage -am -Dmaven.test.skip=false -DskipTests=false '-Dsurefire.includes=**/*Test.java' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.failure.ignore=false package. Test JVMs used isolated temporary home and temp directories.
  • Fresh Playwright CLI checks on the simplified build passed: root/nested group creation, refresh, real mouse drag, menu moves with descendants, missing/self/descendant/missing-source no-ops, real tree-directory write denial with unchanged memory and disk, backend restart, delete cancellation with zero writes, and child promotion after deletion.
  • Regression tests also cover all four supported drop positions, ID-only namespace moves preserving children, normal datasource insertion, and tree reload.
  • Simplify tree persistence and insertion branches, remove the artificial delay, and avoid duplicate tree copies for mutations that already own a detached candidate.
  • New-head CI is triggered by this update; its current result is available in PR checks.

Risk and compatibility

  • Public API and tree JSON format remain unchanged. New-node insertion is an internal storage entry point.
  • Normal creation must not be rejected by the existing-source move guard. Regression tests exercise actual LocalWorkspaceStorage callers.
  • Failure preservation applies to the tree's own state/file. Datasource/namespace record files are not part of an atomic transaction with the tree; this PR does not claim to repair their pre-existing cross-file failure behavior.
  • No database-driver, network, credential, runtime-registration or packaging changes.

Reviewer map

  • Reviewer: @openai0229 (default CODEOWNER for community storage).
  • Start here: TreeNodeStorage.updatePosition, createTree / persistTree, then the invalid-target and forced-replacement-failure cases in TreeNodeStorageTest.
  • Failure condition: A missing, self, or descendant target, or an atomic replacement exception, must leave both the in-memory and reloaded tree unchanged; a valid move must still be visible in both.
  • Rollback or disable path: Revert the PR as a whole; there is no runtime flag because this restores storage consistency.

Contributor declaration

  • I linked the Issue that defines this change. (N/A - no public issue exists.)
  • 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: Substantial AI assistance was used for implementation, tests, and adversarial review; the resulting diff and test evidence were manually inspected.

@HandSonic
HandSonic force-pushed the fix/tree-drop-preserve-source branch from 30d7583 to 0aae22f Compare September 3, 2026 18:47
@openai0229 openai0229 closed this Sep 15, 2026
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants