fix(integration-ever-works): a docs root move cut short before any root was recorded gathers the whole tree

Merged
EV
7d ago
+21-5

Fixes the Greptile finding deferred on the develop โ†’ stage cascade #11096 (thread): Root move stops page sync.

Problem

placeTree() (docs/ever-works-docs.store.ts) counted the unfinished move target (DOCS_TREE_MOVING_TO) as a source folder only when a root had been recorded (DOCS_TREE_ROOT_ID). A mapping placed before that setting existed (OQ5, #11115) has no recorded root on its first move. Scenario:

  1. The tree sits under the sync's own "Ever Works" folder A. The admin sets root B. The move writes MOVING_TO = B, moves Organization/, and stops before Works/.
  2. The admin sets root C. The next pass took only A as a source. It moved Works/ to C, recorded C and cleared the target.
  3. Organization/ stayed at B, so its pages counted as outside the synced tree and lost their pairings.

Fix

DOCS_TREE_MOVING_TO is written only by a move, so the sync owns it. It now counts as a source with or without a recorded root. Nothing else changes: an admin's own move still stays, a folder the sync cannot tell was a root still never moves, and the root is still recorded only once a tree folder sits under it. The doc comment is updated to match.

Additive only: no setting, column or migration changes.

Tests

docs/ever-works-docs.db.spec.ts (SQLite), new case in the OQ5 block. It removes the recorded root, simulates the A โ†’ B move cut short after Organization/, then sets C. Expected: both folders under C, DOCS_TREE_ROOT_ID = C, target cleared.

It fails on develop (Organization/ still under B) and passes with the fix. Locally (Node 26, --experimental-vm-modules): docs 68/68 (3 suites).

๐Ÿค– Generated with Claude Code


Summary by cubic

Fixes the Ever Works docs sync losing tree folders when a root move is cut short before a root was recorded. placeTree() only counted the unfinished move target (DOCS_TREE_MOVING_TO) as a source when a root had been recorded, so on a first move, a folder left at the target never moved again and lost its page pairings.

  • DOCS_TREE_MOVING_TO now counts as a source with or without a recorded root; nothing else changes.
  • Additive only: no setting, column, or migration changes.
  • Adds a SQLite test case reproducing the cut-short move followed by a new root.