API Stability Matrix

This document enumerates the public API surface of dazzle_filekit that is known to be imported by external callers. Any change to a name or signature in the “Locked” section must be treated as a breaking change and must include a migration commit in the downstream caller(s) listed below.

tests/test_import_stability.py is the automated canary for this document. If you rename or remove a locked symbol, that test will fail.

Last audited: 2026-11-19 (filekit v0.5.3 – locking and portable.current_flavor added below; v0.5.0 – portable and batch_layout added below; no locked symbol renamed or removed since the v0.3.0 audit; one behaviour change, to how copy_tree_preserving_links treats junctions).

v0.3.0 (#15) is a deliberate clean break. Unlike the deprecation-shim migration procedure at the bottom of this doc, 0.3.0 removed/renamed locked symbols without shims and migrated every in-tree consumer in the same cycle. The rubric was coverage-completeness over backward-compatibility. 0.3.0 had not shipped to PyPI when these landed, so no released contract broke mid-stream.

v0.3.0 breaking changes (#15)

Old symbol

Replacement

Migrated consumer(s)

paths.normalize_path(p)

normalize_cross_platform_path(p, resolve=True) (link-following)

dazzlecmd dazzlecmd_lib/core/links/_detect.py

paths.normalize_path_no_resolve(p)

normalize_cross_platform_path(p) (default resolve=False, link-safe)

dazzlecmd dazzlecmd_lib/core/safedel/_classifier.py

paths.get_path_type(p)

paths.classify_fs_object(p) (identical behavior)

(no external caller)

paths.is_unc_path / utils.validation.is_unc_path (divergent copies)

one canonical def delegating to unctools.is_unc_path – //server/share is now True on every platform

(behavior superset; no caller broke)

utils.compat.get_drive_mappings()

unctools.converter.get_mappings() / UNCConverter().get_reverse_mappings() (V9 fold into unctools 0.2.2)

(no caller; never exported)


Locked top-level surface (from dazzle_filekit import ...)

v0.2.3 and earlier (locked since v0.2.3)

Symbol

Callers

normalize_cross_platform_path

claude-session-logger log-command.py, rename_session.py (× all 4 copies). The canonical path normalizer with an optional resolve= keyword arg. 0.3.0: the normalize_path / normalize_path_no_resolve wrappers were removed (clean break) – use resolve=True / the default.

create_symlink

claude-session-logger log-command.py (× all 4 copies)

copy_file

claude-session-logger rename_session.py (× all 4 copies)

resolve_cross_platform_path

dazzlecmd projects/core/fixpath/fixpath.py:197

calculate_file_hash

github-traffic-tracker plan_lib/file_ops.py:26

collect_file_metadata

github-traffic-tracker plan_lib/file_ops.py:26. v0.2.4 note: returned dict is now a strict superset (adds size, ISO timestamps, SDDL ACLs, xattrs).

apply_file_metadata

preservelib workflows. v0.2.4 note: honors the new fields when present. v0.3.0: metadata= param typed as dazzle_lib.FileMetadataDict.

~~normalize_path~~

Removed in 0.3.0 (clean break) -> normalize_cross_platform_path(path, resolve=True). dazzlecmd migrated in-cycle.

is_same_file

README example

find_files

README example

is_unc_path

README example. v0.3.0: platform-independent (//server/share -> True everywhere). Now a thin convenience wrapper delegating to the L0 owner unctools.is_unc_path; may be deprecated in 0.4.0 – prefer unctools.is_unc_path directly.

classify_fs_object

v0.3.0 (renamed from get_path_type): classifies WHAT a filesystem object is.

get_disk_usage, check_disk_space, ensure_disk_space

README example

verify_file_hash, verify_copied_files

README example

configure_logging, enable_verbose_logging

README example

v0.5.3 additions (locking, current_flavor)

An exclusive lock on one dedicated lock file, and the flavor of the running interpreter for callers of the portable key. The first consumer of both is dz relaunch’s store (dazzlecmd).

Symbol

Purpose

locking (submodule)

The lock file

exclusive_lock(path, *, timeout=5.0)

Context manager: hold an exclusive lock on a dedicated lock file (Windows msvcrt.locking, POSIX flock); retries until timeout, then raises

LockTimeoutError

FileOperationError + TimeoutError: the lock stayed held past the deadline

locking.try_lock(fd) / locking.unlock(fd)

One non-blocking attempt / release on an open descriptor

current_flavor() (in portable)

"windows", "wsl" or "posix" for the running interpreter – the one function in portable that inspects the runtime; encode/decode keep flavor/runtime required

v0.5.0 additions (portable, batch_layout, two keywords)

One literal, runtime-neutral way to name an absolute path inside a store, and a planner that lays a batch of paths out so no two share a stored path. Both are pure: no file access, nothing expanded or resolved (0.5.3’s current_flavor is the one exception, and says so). The first consumer is safedel’s trash layout in dazzlecmd-lib.

Symbol

Purpose

portable (submodule)

The portable path key

encode_portable_path(path, *, flavor)

Absolute path -> /-joined key whose first part is the root: a drive letter, UNC/<server>/<share>, or ROOT. flavor ("windows", "wsl", "posix") is required: it says how to read the text

decode_portable_path(key, *, runtime)

Key -> native path for that runtime, or None where the root has no native form there (a drive on plain POSIX)

key_to_relpath(parts_or_key, *, target_flavor)

Join parts into a relative path that cannot climb and can exist on the target

PortablePathError

Raised for a path or key with no portable form (a ValueError)

batch_layout (submodule)

The batch planner

plan_batch(paths, *, flavor, is_link=None, drop_nested=True, target_flavor=None)

One base per root (the items’ common parent) and a /-joined relative path per item; returns a BatchPlan

BatchPlan, BatchItem

The plan (bases, items, warnings, errors, dropped, ok) and one placed item (original, base_index, relpath)

Behaviours that are part of the lock:

  • The same file has one key from Windows and from WSL (C:\x and /mnt/c/x both give C/x); under "posix", /mnt/c/x is an ordinary folder (ROOT/mnt/c/x).

  • Device paths, volume-GUID paths, drive-relative paths, .. above the root, and names that exist only under the \\?\ prefix are refused, never guessed at.

  • plan_batch never returns two items with the same relative path; what it cannot place is an error in the plan, not an exception.

Two keywords added to locked functions, both with defaults that keep the 0.4.x call shape:

  • normalize_cross_platform_path(path, *, resolve=False, expand=True) – expand=False takes the path literally (no whitespace strip, no ~, no environment variables); only its format is normalized.

  • copy_tree_preserving_links(src, dst, *, ..., links="keep") – "keep", "follow" or "skip", for symlinks and junctions alike. Behaviour change: through 0.4.3 a junction inside src was entered and its target copied, despite the name; "keep" now recreates it as a junction. Pass links="follow" for the old result.

v0.4.0 additions (longpath)

Windows MAX_PATH shims via on-demand junctions – the remedy for the condition utils.validation.is_valid_path already detected. Windows-only in effect; a no-op where PATH_MAX is 4096/1024.

Not yet load-bearing. No external caller imports these today, so unlike the rows elsewhere in this document they are not locked by an existing consumer. The intended first consumer is dazzlecmd (dz longpath, plus a fixpath -o branch), which is not built yet. Treat the surface as settled but young: if a signature has to move, now is the cheap moment, and this section should be re-audited once dazzlecmd depends on it.

Symbol

Description

longpath (submodule)

The long-path shim domain module

shim_path(path, root=None, threshold=240)

One-call entry point; returns an openable path and never raises for a path-shaped input (falls back to the original)

needs_shim(path, threshold=DEFAULT_THRESHOLD)

The trigger. False on POSIX, and False for an already-\\?\-prefixed path

plan_shim(path, root=None, threshold=..., id_len=4) -> ShimPlan

Pure decision, no filesystem writes; anchors at the shallowest ancestor that fits

ShimPlan

original / needed / anchor / link / shimmed / reason / warnings, plus .usable and .resolved()

resolve_shim_root(target=None, candidates=None, probe=True)

Shortest writable root, probed at runtime

candidate_roots(target=None)

The ordered candidates, shortest first

budget_for(root, id_len=4)

Longest filename a shim under root can serve

create_shim(plan, max_id_len=16)

Materialise the junction; verifies an existing one points at the requested anchor and lengthens the id on hash collision. Mutates plan.link / plan.shimmed to what was actually used

remove_shim(link)

Remove a shim, target untouched; re-checks junction-ness immediately before os.rmdir

reap_shims(root, max_age_seconds=86400, now=None)

Age-based reaper; considers only junctions

MAX_PATH (260), USABLE_PATH (259), DEFAULT_THRESHOLD (240), NAME_MAX (255), SHIM_DIR_NAME (.dzs)

Constants

Behavioural contracts worth pinning – each has a regression test, and each was a real defect first:

  • shim_path never raises for a path-shaped input. The guard covers OSError, ValueError and ctypes.ArgumentError, because an embedded NUL surfaces as a different type per interpreter: 3.12+ raises ValueError via os.path.isjunction, while 3.9-3.11 raise ctypes.ArgumentError from the DeviceIoControl fallback – which is not a ValueError.

  • create_shim never reports success for a junction pointing at a different anchor. Anchor ids are truncated hashes and do collide.

  • remove_shim / reap_shims never touch a target’s contents, and refuse anything that is not a junction.

v0.3.0 additions (locked as of v0.3.0)

Restored from unctools’ 0.2.0 split (STACK-MAP D7), as the Option D resolver edge.

Symbol

Description

open_file(path, mode='r', encoding=None, *, try_path_variants=False, resolver=None, **kwargs)

Fallback-aware open() (R1 / unctools safe_open)

copy_file/move_file/copy_files_with_path/move_files_with_path – new try_path_variants=/resolver= keyword-only args

Path-variant fallback (R2 / safe_copy/batch_copy); additive, default off

process_files(directory, callback, pattern='*', recursive=True, *, try_path_variants=False, resolver=None)

Flat batch-apply over a glob set (R3 / unctools process_files)

replace_in_file / batch_replace_in_files (also dazzle_filekit.content)

Read-modify-write text replace (R4)

path_exists_case_sensitive / get_case_sensitive_path / fix_path_case (utils.compat)

Case-sensitivity helpers (R6)

Intrinsic link primitives (#15 Phase A):

Symbol

Description

dazzle_filekit.links (submodule) + LinkInfo / analyze_link(link_path)

Intrinsic link analysis (no destination param); LinkInfo.to_dict() -> dazzle_lib.LinkTargetDict

detect_link_type / read_link_target

Link kind (symlink/junction/hardlink/None) + target read (DeviceIoControl for junctions)

create_junction / create_hardlink

PowerShell junction + os.link hardlink

remove_link

Detach a symlink/junction/hardlink without deleting its target (v0.3.2)

paths.compute_relative_path(target, start)

..-traversing relative path (distinct from get_relative_path)

utils.validation.read_junction_target

Junction target via the reparse buffer

Cross-layer schemas consumed (#15 Phase D): collect_file_metadata -> dazzle_lib.FileMetadataDict, collect_timestamp_info -> TimestampsDict, LinkInfo.to_dict -> LinkTargetDict (STACK-MAP D10).

Dependency change (0.3.0): dazzle-lib>=0.2.0 and unctools>=0.2.2 are now required (the PathVariantResolver seam + the V9 drive-map fold); the optional [unctools] extra is removed.

v0.3.3 additions (locked as of v0.3.3)

Declared-platform PATH-environment-value helpers (pathenv module) – homed from dazzlecmd-lib’s self-setup work (dazzlecmd#103). Pure string logic; the platform keyword is "windows" / "posix" / None (host).

Symbol

Description

pathenv (submodule)

The declared-platform PATH-value domain module

PLATFORM_WINDOWS, PLATFORM_POSIX

Platform tokens for the platform= keyword

host_path_platform()

The running host’s PATH dialect

split_path_value(value, platform=None)

Split on the DECLARED platform’s separator (; / :), never os.pathsep

normalize_path_entry(entry, platform=None)

Identity-normalize one entry (quotes, %VAR% via ntpath on any host, separators, trailing, casefold-on-windows)

path_value_contains(value, directory, platform=None)

Normalized membership

append_path_value(value, directory, platform=None)

Pure string append; no-op when present under normalized identity

v0.2.4 additions (locked as of v0.2.4)

Symbol

Description

atomic_write_text(path, content, *, encoding, newline)

Atomic text file write via tmp+rename

atomic_write_json(path, data, *, indent, sort_keys, default, trailing_newline)

Atomic JSON write; default=str handles Path/datetime

copy_tree_preserving_links(src, dst, *, dirs_exist_ok, ignore, ignore_dangling_symlinks, links="keep")

Tree copy in which the caller chooses what happens to symlinks and junctions (keep / follow / skip; see v0.5.0 above)

is_wsl()

WSL detection (Linux-only, False elsewhere)

is_win32_available()

Cached pywin32 availability probe (for rich Windows metadata features)

restore_windows_creation_time(path, created)

NTFS ctime restoration via pywin32 SetFileTime

compare_metadata(md1, md2)

Metadata diff with 2s timestamp tolerance

metadata_to_json(md)

JSON-safe projection of a metadata dict

metadata

Public submodule: from dazzle_filekit import metadata

Rule: Signatures may be enriched with additional keyword-only arguments (def f(existing_arg, *, new_kwarg=default)), but positional parameters and existing keyword names must not be removed or repurposed.


Locked submodule imports

dazzle_filekit.paths

Symbol

Callers

normalize_cross_platform_path

canonical entry point (resolve=True -> link-following; default -> link-safe); re-exported via utils.compat. dazzlecmd migrated to this in 0.3.0.

classify_fs_object

v0.3.0, renamed from get_path_type

compute_relative_path

v0.3.0 (#15 Phase A); distinct from get_relative_path (subpath-only)

normalize_path / normalize_path_no_resolve were removed in 0.3.0 (clean break, no shims) – see the v0.3.0 breaking-changes table near the top.

dazzle_filekit.utils.disk

Symbol

Callers

get_disk_usage

dazzlecmd projects/core/safedel/_volumes.py:29

check_disk_space

dazzlecmd projects/core/safedel/_platform.py:392 (aliased as fk_check)

calculate_total_size

dazzlecmd projects/core/safedel/_platform.py:410

dazzle_filekit.utils.compat

Symbol

Callers

is_windows

dazzlecmd projects/core/safedel/_store.py:60

is_wsl

v0.2.4 addition; platform detection helper

normalize_cross_platform_path

re-exported from paths.py so from dazzle_filekit.utils.compat import normalize_cross_platform_path still works

resolve_cross_platform_path, path_exists_cross_platform

dazzlecmd fixpath

dazzle_filekit.metadata (new in v0.2.4)

Full rich metadata module ported from preservelib. Public submodule: callers can from dazzle_filekit import metadata or from dazzle_filekit.metadata import ....

Symbol

Purpose

collect_file_metadata(path)

Rich capture incl. SDDL + xattrs + ctime

apply_file_metadata(path, md)

Rich apply

restore_windows_creation_time(path, created)

NTFS ctime restore

is_win32_available()

Cached pywin32 probe

compare_metadata(md1, md2)

Diff helper

metadata_to_json(md)

JSON-safe projection

get_metadata_summary(md)

Human-friendly summary

collect_timestamp_info(path)

Timestamp-only capture

apply_timestamp_strategy(path, strategy, ...)

Strategy-based timestamp apply

dazzle_filekit.operations (primitives added in v0.2.4)

Symbol

Purpose

atomic_write_text(path, content, *, encoding, newline)

tmp+rename atomic text write

atomic_write_json(path, data, *, indent, sort_keys, default, trailing_newline)

atomic JSON wrapper

copy_tree_preserving_links(src, dst, *, dirs_exist_ok, ignore, ignore_dangling_symlinks, links="keep")

link-aware tree copy (links= added in v0.5.0)

dazzle_filekit.platform.windows (new capabilities in v0.2.4)

Symbol

Purpose

detect_alternate_streams(path)

NTFS ADS enumeration via ctypes FindFirstStreamW

has_significant_ads(path)

True if any non-ignored stream exists

Module attributes (wildcard imports)

preservelib (three copies: C:\code\preserve\preservelib\, C:\code\dazzlecmd\github\projects\core\safedel\_lib\preservelib\, C:\code\github-traffic-tracker\local\src\ghtraf\lib\preserve_lib\) uses:

from dazzle_filekit import paths, operations, verification

This means the modules themselves (dazzle_filekit.paths, dazzle_filekit.operations, dazzle_filekit.verification) must remain importable and must continue to expose the functions preservelib reaches for. See tests/test_import_stability.py::test_preservelib_module_shapes for the concrete list.


Allowed changes (non-breaking)

  • Adding new functions.

  • Adding new modules.

  • Adding new keyword-only parameters to existing functions.

  • Enriching the behavior of existing functions when the external contract (return type, raised exceptions on the happy path, side effects on the target file) stays compatible.

  • Adding new positional arguments that default to an existing value are not safe if a caller uses keyword-only invocation – prefer keyword- only additions.

Forbidden without a migration plan

  • Renaming any symbol in the Locked tables.

  • Removing any symbol in the Locked tables.

  • Changing a function from a module-level function to a method on a class.

  • Changing the return type in a way that breaks existing callers.

  • Making a previously optional parameter required.

Migration procedure for a locked symbol

If a locked symbol genuinely needs to change:

  1. Add the new function alongside the old one.

  2. Update every downstream caller in the same working-set (grep across C:\code\ to confirm).

  3. Mark the old symbol @deprecated with a one-release grace window.

  4. Ship.

  5. Remove the old symbol in the release after the grace window.

Do not skip steps 2-4 even if you own all the callers – the session-logger incident on 2026-04-10 is the baseline cautionary tale.