feat(meals): enforce three lower-calorie dinners with media
CI / backend (pytest + alembic) (push) Canceled after 0s
CI / frontend (build) (push) Canceled after 0s

This commit is contained in:
2026-09-01 10:11:36 -07:00
parent 7838c49721
commit 2695ba0232
85 changed files with 8103 additions and 795 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Report or apply deterministic recipe catalog quarantine decisions."""
from __future__ import annotations
import argparse
import json
import os
import sys
_ = sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from app.database import SessionLocal
from app.services.recipe_catalog_audit import audit_recipe_catalog
def main() -> int:
parser = argparse.ArgumentParser(
description="Audit recipe provenance and semantic quality"
)
parser.add_argument(
"--apply",
action="store_true",
help="Persist active/quarantined status and findings atomically",
)
args = parser.parse_args()
db = SessionLocal()
try:
report = audit_recipe_catalog(db, apply=args.apply)
if args.apply:
db.commit()
print(json.dumps(report, indent=2, sort_keys=True))
return 0
except Exception:
db.rollback()
raise
finally:
db.close()
if __name__ == "__main__":
raise SystemExit(main())
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
"""Load the bundled starter recipe catalog as one atomic operation."""
from __future__ import annotations
import argparse
import json
import os
import sys
from typing import Sequence
_ = sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from app.database import SessionLocal
from app.services.starter_recipe_catalog import (
StarterRecipeCatalogError,
load_bundled_starter_catalog,
)
def main(argv: Sequence[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Load the bundled starter recipe catalog")
parser.add_argument(
"--dry-run",
action="store_true",
help="Validate the catalog and report planned inserts or updates without writing",
)
parser.add_argument(
"--update-existing",
action="store_true",
help="Atomically synchronize all existing bundled recipes in place",
)
args = parser.parse_args(argv)
db = SessionLocal()
try:
summary = load_bundled_starter_catalog(
db,
dry_run=args.dry_run,
update_existing=args.update_existing,
)
print(json.dumps(summary, sort_keys=True))
return 0
except StarterRecipeCatalogError as exc:
db.rollback()
print(json.dumps({"dry_run": args.dry_run, "error": str(exc)}, sort_keys=True))
return 1
except Exception:
db.rollback()
raise
finally:
db.close()
if __name__ == "__main__":
raise SystemExit(main())