feat(identifier): declare helixforge fleet namespace

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
tegwick 2026-08-21 23:57:03 +02:00
parent 3c6887a3e0
commit 956efbb7ae
9 changed files with 2915 additions and 17 deletions

View file

@ -282,7 +282,7 @@ def main(argv: list[str] | None = None) -> int:
p_identifier = sub.add_parser("identifier", help="Deterministic work-record identifiers")
identifier_sub = p_identifier.add_subparsers(dest="identifier_command")
p_id_derive = identifier_sub.add_parser("derive", help="Derive one UUIDv5")
p_id_derive.add_argument("--namespace", required=True)
p_id_derive.add_argument("--namespace", default=None, help="Override declared fleet namespace")
p_id_derive.add_argument("--record-id", required=True)
p_id_preflight = identifier_sub.add_parser("preflight", help="Scan live identifier collisions")
p_id_preflight.add_argument("--root", default=".")
@ -291,9 +291,14 @@ def main(argv: list[str] | None = None) -> int:
help="Emit a non-mutating, per-repository old-to-derived UUID plan",
)
p_id_plan.add_argument("--root", default=".")
p_id_plan.add_argument("--namespace", required=True)
p_id_plan.add_argument("--namespace", default=None, help="Override declared fleet namespace")
p_id_plan.add_argument("--output", default=None, help="Write the provenance mapping as JSON")
p_id_plan.add_argument("--force", action="store_true", help="Replace an existing --output file")
p_id_verify = identifier_sub.add_parser(
"migration-verify",
help="Verify a sealed migration plan against current repository sources",
)
p_id_verify.add_argument("--plan", required=True)
p_sbom = sub.add_parser("sbom", help="Derive SBOM snapshots and licence reports from repository files")
sbom_sub = p_sbom.add_subparsers(dest="sbom_command")
@ -616,27 +621,40 @@ def main(argv: list[str] | None = None) -> int:
return 2
from repo_manager.identifiers import (
derive_work_record_uuid,
load_fleet_namespace,
plan_identifier_migration,
scan_live_identifier_collisions,
verify_identifier_migration_plan,
)
namespace = getattr(args, "namespace", None) or load_fleet_namespace()
if args.identifier_command == "derive":
try:
derived = derive_work_record_uuid(args.namespace, args.record_id)
derived = derive_work_record_uuid(namespace, args.record_id)
except ValueError as exc:
print(json.dumps({"ok": False, "error": str(exc)}, indent=2))
return 1
result = {
"ok": True,
"namespace": args.namespace,
"namespace": namespace,
"record_id": args.record_id,
"uuid": str(derived),
}
elif args.identifier_command == "preflight":
result = scan_live_identifier_collisions(Path(args.root))
elif args.identifier_command == "migration-verify":
try:
plan = json.loads(Path(args.plan).read_text(encoding="utf-8"))
if not isinstance(plan, dict):
raise TypeError("migration plan must be a JSON object")
result = verify_identifier_migration_plan(plan)
except (OSError, TypeError, ValueError, json.JSONDecodeError) as exc:
print(json.dumps({"ok": False, "error": str(exc)}, indent=2))
return 1
else:
try:
result = plan_identifier_migration(Path(args.root), args.namespace)
result = plan_identifier_migration(Path(args.root), namespace)
except ValueError as exc:
print(json.dumps({"ok": False, "error": str(exc)}, indent=2))
return 1