Skip to content

refactor: domain-model cleanup (glossary, drift-in-DB, rarity cap) - #40

Merged
AABur merged 12 commits into
mainfrom
refactor/domain-model-cleanup
Jul 17, 2026
Merged

refactor: domain-model cleanup (glossary, drift-in-DB, rarity cap)#40
AABur merged 12 commits into
mainfrom
refactor/domain-model-cleanup

Conversation

@AABur

@AABur AABur commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Domain-model cleanup driven by a grilling + domain-modeling session. Introduces CONTEXT.md (the project glossary) and aligns code, behavior, and docs with the sharpened vocabulary. Each decision came from a recorded trade-off with the maintainer.

Glossary (CONTEXT.md)

Collection, Faction vs Nation (internal code vs user-facing layer), Ability, Diff vs Drift, Reserved, Spawnable, Exile, Deck, Quantity, Baseline.

Behavior changes

  • Rename attributesabilities across internal keys, templates, and the diff. The raw JSON export keeps attributes — that key mirrors the API verbatim.
  • Drop deck importdeck add is the single import path (it already does everything import did and more).
  • Fix deck add quantity check — a mismatch is now only flagged when the deck needs more copies than the collection records; --update only raises quantities, never lowers them (matches the docs and the "a deck is evidence of ownership" model).
  • Enforce the rarity cap on every quantity write — moved into the storage layer, so XLSX update and deck add --update now clamp to the per-rarity maximum (as the game does), with a warning. Previously only the web editor capped.
  • Diff report is opt-in — sync no longer auto-writes sync-diff-*.md on apply/reject/--diff-only. The diff is shown on screen; pass --diff-report PATH to also save it.
  • Drift snapshot lives in the DB, not files — a contract-drift halt no longer writes sync-schema-diff-*.md / sync-schema-observed-*.json. The observed shape is stashed in metadata; baseline accept promotes exactly the reviewed shape and clears it. CLI prints the drift; the web modal renders it. Accepting a baseline stays a deliberate CLI step.

Docs

README, CONTRIBUTING, and .gitignore updated in the same branch. "catalog" removed in favor of "Collection" / "card set".

Verification

  • make check green: format + lint + mypy (47 files) + 458 tests (was 451).
  • New behavior exercised end-to-end on live code, not just tests: rarity cap on the XLSX path, full drift cycle (halt → DB stash → baseline accept → clear), sync file behavior, and the web drift modal over HTTP.

Test plan

  • make check
  • rarity cap clamps XLSX update on an Elite card
  • drift halt writes no files, stashes snapshot, baseline accept promotes and clears it
  • sync writes no file by default; --diff-report PATH does
  • web drift modal renders all sections and offers no apply

@AABur
AABur merged commit 17468a1 into main Jul 17, 2026
1 check passed
@AABur
AABur deleted the refactor/domain-model-cleanup branch July 17, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant