CANP-WP-0003: name the default registry default

Section 20.1 takes a registry's name from its directory basename, so the
reference tool's default store at ~/.canned-prompts/registry was named
`registry` — giving `registry:practice/thing` as a qualified reference.

The workplan had recorded this as reading poorly in one output line. It was
understated: the name reaches qualified references, the on-disk catalog layout
(catalog/registry/...), and index.yaml rows (registry: registry). Once packages
are installed and inclusions recorded, changing it becomes a migration rather
than an edit.

Renaming the directory to ~/.canned-prompts/default fixes it with no special
case in code, nothing written into the user's store, and no second naming
mechanism competing with section 20.1's manifest.

check_legacy_registry refuses to silently create a fresh empty store beside a
populated ~/.canned-prompts/registry — that failure would have been worse than
the wart being fixed. It names the exact mv, and the --registry flag for
keeping the old store. The check fires only for the default path; an explicit
--registry is never second-guessed.

Tests 95 -> 99.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bjefh8NUiEiahN4JLwoSKM

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 388925@bnt-lap001
Assistant-Session: 3507023f-e0fd-4a1e-9d90-a0d4217d1502
This commit is contained in:
tegwick 2026-09-06 19:32:30 +02:00
parent 03826eac4f
commit e1889b41a1
5 changed files with 87 additions and 7 deletions

View file

@ -55,9 +55,30 @@ def default_catalog() -> Path:
def default_registry() -> Path:
# Named "default" rather than "registry" because § 20.1 takes a registry's
# name from its directory basename, and that name reaches qualified
# references, catalog paths and index rows.
return home_dir() / "default"
def legacy_registry() -> Path:
return home_dir() / "registry"
def check_legacy_registry(registry: Path) -> None:
"""Refuse to silently start a fresh default store beside a populated one."""
if registry.resolve() != default_registry().resolve():
return
if registry.exists() or not legacy_registry().is_dir():
return
raise CannedPromptError(
f"the default registry moved from {legacy_registry()} to {registry}, so "
f"a registry's basename names it (§ 20.1) rather than reading as "
f"'registry:'. Move it:\n mv {legacy_registry()} {registry}\n"
f"or keep using the old one explicitly with --registry {legacy_registry()}"
)
def read_manifest(package_dir: Path) -> dict[str, Any]:
manifest_path = package_dir / "prompt.yaml"
if not manifest_path.is_file():
@ -858,6 +879,7 @@ def cmd_publish(args: argparse.Namespace) -> None:
src = Path(args.path)
manifest = validate_package(src)
registry = Path(args.registry).expanduser()
check_legacy_registry(registry)
name = registry_name(registry) if registry.is_dir() else None
policy, claim = namespace_policy(registry, manifest["id"]) if registry.is_dir() else ("open", None)
@ -879,6 +901,7 @@ def cmd_publish(args: argparse.Namespace) -> None:
def cmd_install(args: argparse.Namespace) -> None:
registry = Path(args.registry).expanduser()
check_legacy_registry(registry)
catalog = Path(args.catalog).expanduser()
name = registry_name(registry)