Repository navigation
feat(prices): a price source contract, and Scryfall's prices through it (#364) - #413
Merged
Merged
Conversation
…rices (#364) Draft v1.0.2 after two Mode A review rounds (Fable 5.2). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
) hosted_paid_allowed? is true for Scryfall (2026-11-13); #362 stays open. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Two plan review rounds (Fable 5.2), all findings applied. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
T1.1: The guard, the fake source and the registry Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
T1.2: Series, Quote, Malformed and the errors Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
T1.3: verify! Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…its file (#364) T2.1: The declaration and the day Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…le (#364) T2.2: Reading prices as quotes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
#364) T2.3: The catalog's file, the twin, streaming and a timing Failing-first does not apply (plan exception): these examples check behaviour T2.2 already implements. Mutation proof, each run with only its named example (-e), then restored (git diff clean): 1. `date = reported_on(path)` -> `date = Date.new(2026, 11, 13)` Examples: "refuses a file with no date before it yields anything" and "takes each quote's day from the file's name". Failed: expected [Thu, 12 Nov 2026], got [Fri, 13 Nov 2026]; and "expected IntegrityError but nothing was raised" (yielded not empty). 2. `gzip.each_line` -> `gzip.read.each_line` Example: "reads the file as a stream". Failed: expected ["first"], got [] (yielded stays empty). 3. `external_key: id` -> `external_key: id.upcase` in each_price_record Example: "reads the file the catalog reads". Failed: expected ["card-1", "card-2"], got ["CARD-1", "CARD-2"]. 4. `return unless card["lang"] == "en"` after the Hash guard Example: "yields a non-English printing". Failed: expected [["nonfoil", "EUR", 50]], got []; records.size expected 3, got 2. Timing (SCANNER_TIMING=1, "reads 50,000 cards"): price quotes: 300000 quotes from 50,000 cards in 1.2 s Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
T3.1: PriceSeries Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
T3.2: PriceSource, and PricesRecord's comment Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…364) T4.1: The area doc. Scope, glossary, invariants (the contract's comment, absence, no network, date and cents rules, twins, sync rows, models, the hosted flag), named constants (SERIES_BY_KEY, PRICE, FILE_STAMP, CURRENCY, KEY), decisions not in an ADR and sources, each with its spec 085 decision, ruling or issue. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nd of the read (#364) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s fields (#364) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ED (#364) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ontract and the area doc (#364) A refresh that deletes a price on its absence must not delete one the source failed to parse. Maintainer request at the digest. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One memory (mutation proof in place of failing-first) and three lessons (absent is not unreadable, no contract member named name, a flag's polarity from its false). Approved at the digest. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The prices area doc carries the contract, the models, the sync and the constants; its log, the area map and the specs index say so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Conflicts in CLAUDE.md (the prices sentence kept on top of main's current paragraph) and docs/specs/README.md (rows 083 and 085 kept with main's 084 and 087). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
One conflict, the specs index: row 085 kept beside main's retired 087 row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
plainprogrammer
marked this pull request as ready for review
November 13, 2026 21:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #364
What this adds
A collectible's extension now supplies market prices through a documented contract, and Scryfall supplies them for Magic cards (spec 085,
prices.md).Prices::Sources(app/models/prices/sources.rb): a source states its key, title, attribution, whether a hosted instance with paid plans may show it, and its series, and yieldsQuotes (the source's id for the printing, finish, currency, kind, whole cents, the day reported) orMalformeds from#each_quote(path, languages:). Its comment is the one place the contract is written.Prices.sourcesis the registry, asCatalog.sourcesis for the catalog.MTG::Scryfall::PriceQuotes. It streams the bulk file the catalog refresh reads and yields a quote forusd,usd_foil,usd_etched,eur,eur_foilandeur_etched(research 083 found no etched EUR today; it is read anyway).tixis not stored. Prices become cents from their digits, never a float. The day reported comes from the file's name. It stores what the file carries, including the EUR a non-English printing copies from its English twin (ruling 41); the twin rule is a display rule for A card's market price on its page and in the collection #369.Malformedcarries the price's series, so Prices refresh once a day, and each change is recorded once #365's refresh can tell a price it failed to parse from one the file left empty, and must not delete the former. The reason is in the contract's comment and inprices.md.PriceSource.sync!andPriceSeries.ensure!from the source's own declaration: idempotent, race-safe through the unique indexes, never deleted, no migration seed.spec/price_source_core_spec.rb) keeps the core files free of any collectible name.Scope
No refresh, no download of the file, no model for current prices, price changes or runs (#365, #366), no page or twin lookup (#369), no migration, and no change to
db/prices_structure.sql.Rulings and review
hosted_paid_allowed?istruefor Scryfall (the maintainer, 2026-11-13, on rulings 27, 37 and 38). The value is written in one place (MTG::Scryfall::PriceQuotes.hosted_paid_allowed?) with its own example. Issue Ask Scryfall in writing about recording prices and showing their history #362 (the written question to Scryfall) is still open and its answer may change it. Nothing reads the flag yet: the refusal the design describes needs a setting for the kind of instance, which hosted mode (Hosted mode: one operator setting #392) adds.verification.md). Its one minor finding (a line with invalid UTF-8 would stop the whole read) is fixed test-first.14a321b9's body. It was accepted at Gate B, under the maintainer's delegation.Owed to the maintainer
hosted_paid_allowed?.Verification
Pushed
23a32348; the pre-push hook ran the fullbin/ciand passed. The suite has 4829 examples (bin/rspec --dry-run); this feature adds 47 across its six spec files (3, 14, 18, 4, 6 and 2) (the timing example,:timing, is excluded by default, andSCANNER_TIMING=1measured 300,000 quotes from 50,000 cards in 1.2 s).bin/ci checks(RuboCop, YARD, the comment ratchet, Brakeman, audits) passes.🤖 Generated with Claude Code