"""Disposable Files/Records fixture. Never Simple or Complex.

Dry-run is the only mode this script performs. It prints the provision and
cleanup steps for AuthV2 Golden Capabilities. It does not install packs, write
D1, or touch the two protected golden projects.

    python -m scripts.golden_capabilities_fixture --project-id <uuid>
"""

from __future__ import annotations

import argparse
import json

PROTECTED_PROJECTS = {
    "d89488a5-506c-43f0-8983-b80cee9bb45c",  # AuthV2 Golden Simple
    "ae2d6e69-338e-48c5-9f75-afc6047ef90f",  # AuthV2 Golden Complex
}

PROVISION_STEPS = (
    "create_disposable_project",
    "install_minimum_records_pack_without_foreign_keys",
    "push_one_storage_bucket",
    "create_member_and_staff_sessions",
)
CLEANUP_STEPS = (
    "delete_uploaded_files",
    "delete_created_records",
    "uninstall_packs",
    "delete_bucket_registration",
    "delete_entity_schema_rows",
    "revoke_sessions",
)


def fixture_plan(project_id: str) -> dict:
    if project_id in PROTECTED_PROJECTS:
        raise ValueError("protected_golden_project")
    return {
        "fixture": "AuthV2 Golden Capabilities",
        "project_id": project_id,
        "mode": "dry_run",
        "provision": list(PROVISION_STEPS),
        "cleanup": list(CLEANUP_STEPS),
        # Operational fixture residue must be zero. Soft-disabled schema
        # registrations are lifecycle metadata and are tracked separately.
        "residual_policy": {
            "active_test_data": 0,
            "enabled_test_resources": 0,
            "accessible_test_files_or_records": 0,
            "retained_lifecycle_metadata": "soft_disabled_schema_registrations",
        },
        "residual_rows_allowed": False,
    }


def main() -> None:
    parser = argparse.ArgumentParser(description="Plan the disposable capabilities fixture. Does not mutate.")
    parser.add_argument("--project-id", required=True)
    args = parser.parse_args()
    print(json.dumps(fixture_plan(args.project_id), indent=2))


if __name__ == "__main__":
    main()
