Skip to content

Route imported special folders under the import's top collection; show multi-parent collections under the most specific parent - #3813

Merged
mstomar125 merged 3 commits into
mainfrom
issue-3812-import-routing-prefix
Oct 14, 2026
Merged

mstomar125 merged 3 commits into
mainfrom
issue-3812-import-routing-prefix

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Closes #3812. Follow-up to #1703 / #1705.

Problem

nodespace import dir <parent> --auto-collection-routing where <parent> holds one docs folder (docs-sync-smoke/{architecture,archived,decisions,...}) produced two trees: Archived and ADR (and Lessons) were routed to fixed top-level names, dropping the directories above them, while every other directory kept its full prefix (Docs Sync Smoke:Architecture). Reproduced on a built CLI/daemon with the 36-file sample structure: Archived -> (no parent), ADR -> (no parent).

Separately, the collections tree showed a multi-parent collection under its first parent in unspecified order. In a Sync workspace every collection is also filed under the workspace-wide default collection, so a collection could appear under that container instead of its real parent.

Change

  • derive_collection_metadata: the special folders keep the directories above them (docs-sync-smoke/archived/x.md -> Docs Sync Smoke:Archived, ...:ADR, ...:Lessons) and match by whole path segment. Precedence is unchanged (archived > decisions/adr > lessons). A prefix that cannot be a collection path (blank name, : in a name, deeper than the depth limit) falls back to the bare name, as before. A top-level decisions/ is now ADR, like a nested one (it used to become Decisions).
  • buildCollectionsTree: a collection with several parents is shown under the most specific one (candidates that are an ancestor of another candidate are dropped; the first of the rest wins, so behavior with unrelated parents is unchanged).

Not changed, on purpose

The importer is NOT stamped as a member of the imported collections. Core has no membership/access semantics (ADR-081/083), and in Sync a registered person member_of a collection restricts it (ADR-037), so stamping would make a team's imported docs private to the importer. Hiding the default container in the sidebar is the Sync extension's collectionTreeRoots contribution (ADR-082), a Sync-app follow-up.

Tests

  • Rust (daemon lib): routing table tests (prefixed, base-level, invalid prefixes, precedence) and an end-to-end batch import asserting every routed collection hangs under the single top collection. Mutation-checked: dropping the prefix fails 2 of the 3.
  • Vitest: buildCollectionsTree display-parent tests (both parent orders, three parents, unrelated parents, cycle). Mutation-checked: first-parent selection fails 2.
  • Manual: built CLI/daemon, isolated home, 36-file sample tree: before, Archived/ADR had no parent; after, all 9 routed collections hang under Docs Sync Smoke.

The Sync app ships a pinned core rev, so a pin bump is needed there to pick this up.

🤖 Generated with Claude Code

mstomar125 and others added 3 commits October 14, 2026 12:21
…t multi-parent collections under the most specific parent

derive_collection_metadata sent archived/, decisions/|adr/ and lessons/ to fixed
top-level collection names and dropped the directories above them, while every
other directory was joined from all its segments, so one import produced two
trees (Archived and ADR outside the import's top collection). The special folders
now keep the leading directories and match by whole path segment (a top-level
decisions/ is ADR like a nested one).

The collections tree showed a multi-parent collection under its first parent,
in unspecified order; it now picks the most specific parent (one nested below
another candidate), so a workspace-wide container that also holds every
collection does not hide the real nesting.

Refs #3812

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the issue-3812-import-routing-prefix branch from c013a70 to 9ea7458 Compare October 14, 2026 10:21
@mstomar125
mstomar125 merged commit b008c34 into main Oct 14, 2026
@mstomar125
mstomar125 deleted the issue-3812-import-routing-prefix branch October 14, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant