feat(identifier): add reversible file migration
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
887943108e
commit
1d5b60346d
4 changed files with 354 additions and 2 deletions
|
|
@ -300,6 +300,21 @@ def main(argv: list[str] | None = None) -> int:
|
|||
)
|
||||
p_id_verify.add_argument("--plan", required=True)
|
||||
p_id_verify.add_argument("--repo", default=None, help="Verify one repository atomic unit")
|
||||
p_id_files = identifier_sub.add_parser(
|
||||
"migration-files",
|
||||
help="Validate or execute one repository's sealed UUID file rewrite",
|
||||
)
|
||||
p_id_files.add_argument("--plan", required=True)
|
||||
p_id_files.add_argument("--repo", required=True)
|
||||
p_id_files.add_argument("--confirm-plan-sha256", required=True)
|
||||
p_id_files.add_argument(
|
||||
"--direction", choices=["forward", "reverse"], default="forward"
|
||||
)
|
||||
p_id_files.add_argument(
|
||||
"--execute",
|
||||
action="store_true",
|
||||
help="Write files; without this flag only validate and report",
|
||||
)
|
||||
|
||||
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")
|
||||
|
|
@ -623,6 +638,7 @@ def main(argv: list[str] | None = None) -> int:
|
|||
from repo_manager.identifiers import (
|
||||
derive_work_record_uuid,
|
||||
load_fleet_namespace,
|
||||
migrate_repository_identifier_files,
|
||||
plan_identifier_migration,
|
||||
scan_live_identifier_collisions,
|
||||
verify_identifier_migration_plan,
|
||||
|
|
@ -653,6 +669,21 @@ def main(argv: list[str] | None = None) -> int:
|
|||
except (OSError, TypeError, ValueError, json.JSONDecodeError) as exc:
|
||||
print(json.dumps({"ok": False, "error": str(exc)}, indent=2))
|
||||
return 1
|
||||
elif args.identifier_command == "migration-files":
|
||||
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 = migrate_repository_identifier_files(
|
||||
plan,
|
||||
repo_slug=args.repo,
|
||||
confirm_plan_sha256=args.confirm_plan_sha256,
|
||||
direction=args.direction,
|
||||
execute=args.execute,
|
||||
)
|
||||
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), namespace)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue