Skip to content

Parent merge leaves nested split artifacts in catalog metadata #2136

@Jay2006sawant

Description

@Jay2006sawant

Describe the bug

When merging a parent element, trestle merge successfully writes merged content back into catalog.json, but nested split files/directories are not fully cleaned up.

I verified this locally after full dev setup. After splitting catalog.metadata and then splitting nested metadata.roles.*, running trestle merge -e 'catalog.metadata' leaves stale files under catalog/metadata/ (including deeper roles children), even though catalog.json already contains merged metadata.

This creates an inconsistent workspace state and can confuse follow-up split/merge operations.

To Reproduce

Steps to reproduce the behavior:

  1. Create a fresh workspace and import a model:
    • trestle init
    • trestle import -f tests/data/json/minimal_catalog_with_groups.json -o mycatalog
  2. Go to catalogs/mycatalog and split top-level catalog parts:
    • trestle split -f ./catalog.json -e 'catalog.metadata,catalog.groups,catalog.back-matter'
  3. Go to catalogs/mycatalog/catalog and split metadata:
    • trestle split -f ./metadata.json -e 'metadata.roles,metadata.responsible-parties'
  4. Go to catalogs/mycatalog/catalog/metadata and split roles deeper:
    • trestle split -f ./roles.json -e 'roles.*'
  5. Return to catalogs/mycatalog and merge metadata:
    • trestle merge -e 'catalog.metadata'
  6. Inspect remaining files with ls -R catalog and see stale artifacts still present under catalog/metadata/....

Expected behavior

After trestle merge -e 'catalog.metadata', obsolete nested split artifacts for that subtree should be cleaned up (or at least consistently handled), so the workspace does not retain stale catalog/metadata/... split content after parent merge.

Screenshots / Logs.

Repro output after merge (ls -R catalog):

catalog:
back-matter.json
groups.json
metadata

catalog/metadata:
responsible-parties.json
roles

catalog/metadata/roles:
00000__role.json

Also confirmed catalog.json already contains merged metadata.

Environment

  • OS: Linux 6.8.0-101-generic
  • Python version: 3.10.12 (hatch test environment)
  • Installed packages: local editable install (pip install -e ".[dev]"), make develop, make test passed (1255 passed, 3 skipped)

Are you going to solve this issue?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions