{"record":{"id":"e0cbce18b1182e2e","repo":"JuliusBrussee/caveman","slug":"label-pricing-changed-without-a-new-verified-at","errorCode":null,"errorMessage":"{label}: pricing changed without a new verified_at snapshot version (checked catalog/{verified}.yaml)","messagePattern":"(.+?): pricing changed without a new verified_at snapshot version \\(checked catalog/(.+?)\\.yaml\\)","errorType":"validation","errorClass":"CatalogError","httpStatus":null,"severity":"error","filePath":"shared/provider-catalog/validate_catalog.py","lineNumber":234,"sourceCode":"    for index, row in enumerate(current):\n        label = f\"current.yaml row {index + 1}\"\n        identity = validate_row(row, label, check_time)\n        if identity in seen:\n            raise CatalogError(f\"{label}: duplicate identity {'/'.join(identity)}\")\n        seen.add(identity)\n\n        verified = parsed_time(row[\"verified_at\"], label).date().isoformat()\n        snapshot = snapshots.setdefault(\n            verified,\n            load_yaml(CATALOG_DIR / f\"{verified}.yaml\"),\n        )\n        identity = pricing_identity(row)\n        matched = next(\n            (snap_row for snap_row in snapshot if pricing_identity(snap_row) == identity),\n            None,\n        )\n        if matched is None:\n            raise CatalogError(\n                f\"{label}: pricing changed without a new verified_at snapshot version (checked catalog/{verified}.yaml)\"\n            )\n        # sources is excluded from pricing_identity so a capability citation can\n        # be added without minting a new price-dated snapshot, but a PRICING\n        # citation must never be silently swapped or dropped while verified_at\n        # stays put. Mirrors the Go isSubset check in catalog_test.go.\n        snapshot_sources = set(matched.get(\"sources\") or [])\n        if not snapshot_sources.issubset(set(row[\"sources\"])):\n            raise CatalogError(\n                f\"{label}: dropped or replaced a source from its immutable snapshot \"\n                f\"catalog/{verified}.yaml without a new verified_at \"\n                f\"(snapshot had {sorted(snapshot_sources)}, current has {sorted(row['sources'])})\"\n            )\n\n\ndef main() -> int:\n    try:\n        validate_catalog()","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/provider-catalog/validate_catalog.py#L216-L252","documentation":"Each catalog row is date-stamped by verified_at and must exactly match its immutable price snapshot file catalog/{verified}.yaml. The validator looks up a row in the snapshot with the same pricing_identity; if no snapshot row matches, it means pricing fields changed without minting a new snapshot for the new verified_at date, breaking the price-auditability invariant.","triggerScenarios":"Running validate_catalog after editing a pricing field of a row in current.yaml while leaving verified_at unchanged; the pricing_identity of the current row matches no row in catalog/{verified}.yaml, so the raise fires naming the snapshot file that was checked.","commonSituations":"Hand-editing a price in current.yaml without regenerating the dated snapshot; a sync tool bumped prices but failed to bump verified_at; someone backdated verified_at to reuse an old snapshot file; a merge combined a price change from one branch with the old verified_at from another.","solutions":["Bump the row's verified_at to today's date and generate a new catalog/{date}.yaml snapshot reflecting the new pricing","Regenerate the snapshot via the sync tooling so pricing_identity matches","If the price change was unintentional, revert the pricing fields to match the existing snapshot","Verify the new snapshot file exists in CATALOG_DIR with the exact verified date as filename"],"exampleFix":"# before (current.yaml)\nverified_at: 2026-09-01\nmonthly_input: 2.50   # changed, snapshot still says 2.25\n# after\nverified_at: 2026-09-20\nmonthly_input: 2.50\n# plus a new catalog/2026-09-20.yaml snapshot containing the new price","handlingStrategy":"validation","validationCode":"import yaml, datetime\n\ndef pricing_fields_match(current_row, snapshot_rows):\n    key = lambda r: (r[\"provider\"], r[\"model\"], r[\"unit\"], r[\"monthly_input\"], r[\"monthly_output\"])\n    return any(key(s) == key(current_row) for s in snapshot_rows)\n\n# before validating: bump verified_at and ensure catalog/{date}.yaml exists\n# row[\"verified_at\"] = datetime.date.today().isoformat()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always bump verified_at and mint a new dated snapshot whenever any pricing field changes","Never hand-edit prices in current.yaml alone; regenerate snapshots via the sync tool","Diff current.yaml against catalog/{verified_at}.yaml as part of your PR checklist","Remember snapshot files are immutable — create a new one, never edit the old"],"tags":["validation","catalog","snapshot-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}