Skip to content

Integrate dz fixpath for broken dazzlelink recovery #14

@djdarcy

Description

@djdarcy

Integrate dz fixpath for broken dazzlelink recovery

Problem

When a file is renamed or moved within a library, both absolute and relative paths in a dazzlelink become stale. Currently there is no recovery mechanism -- the dazzlelink is simply broken:

$ dazzlelink execute "Taleb - The Black Swan (see Philosophy)"
Error: Target not found via absolute path
Error: Target not found via relative path
Error: All resolution methods failed

Meanwhile, dz fixpath (from DazzleCMD) already has file search, fuzzy matching, and ranking capabilities that could locate the moved file by name.

Proposed solution

Add fixpath as an optional fallback at the end of the execute resolution chain, and a new reconnect command for batch repair.

Execute fallback (step 5, after #13's chain):

1. Try target_path (absolute)
2. Try target_relative (from dazzlelink dir)
3. Try path_representations (UNC, drive)
4. Try dz fixpath --find --fast <filename>     <-- NEW
5. Fail with diagnostic message

New reconnect command:

dazzlelink reconnect "D:\M\Literature\Books"           # scan and fix broken links
dazzlelink reconnect --dry-run "D:\M\Literature\Books"  # report only
dazzlelink reconnect --auto-update "D:\M\Literature"    # fix and update dazzlelink JSON

Implementation approach

Phase 1: fixpath as execute fallback

  • In execute_dazzlelink(): after all stored paths fail, extract filename from target_path
  • Shell out to dz fixpath --find --fast --print <filename> or import as library
  • If found, open the resolved path
  • Optionally prompt user to update the dazzlelink with the new path

Phase 2: reconnect command

  • Scan directory for dazzlelink files
  • For each, run the resolution chain
  • Collect broken links
  • For each broken link, invoke fixpath search
  • Report results; optionally auto-update

Configuration:

  • config.fixpath_enabled: Whether to use fixpath fallback (default: true if dz fixpath available)
  • config.fixpath_search_dirs: Directories to search (default: library root)
  • config.fixpath_auto_update: Whether to auto-update dazzlelinks when fixpath resolves (default: false, prompt)

Design considerations

  • fixpath is an external dependency (DazzleCMD). The integration should be optional -- if dz fixpath isn't installed, the fallback is skipped gracefully.
  • Auto-updating dazzlelinks after fixpath resolution should be opt-in, not default. Moving a file and having all references auto-update is powerful but potentially dangerous.
  • The reconnect command is analogous to dazzlelink check (which reports broken symlinks) but adds the repair capability.

Acceptance criteria

  • execute invokes fixpath as a last-resort fallback when all stored paths fail
  • fixpath integration is optional -- graceful degradation when dz fixpath is not available
  • reconnect command scans a directory for broken dazzlelinks
  • reconnect --dry-run reports broken links without modifying anything
  • reconnect --auto-update fixes broken dazzlelinks by updating stored paths
  • Configuration options for fixpath behavior (enabled, search dirs, auto-update)
  • Test: rename target file, verify fixpath fallback locates it
  • Test: reconnect repairs broken dazzlelinks in batch

Related issues

Analysis

See 2026-03-30__22-32-33__dazzlelink-relative-paths-for-library-crossrefs.md for detailed design analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions