Repository navigation
feat(data): freshness SLAs, stale flags in the build and a Worker-side staleness check (#18) - #73
Merged
Merged
Conversation
3 tasks
…hness stamping Resolve conflicts from rebasing #73 onto origin/main (#72 merge). Integrated freshness stamping (annotate) into the build process while preserving USD conversions, per-model estimates, and CSV exports. Added argument validation for --as-of and unknown arguments. Co-authored-by: Colonizer Settlers <331648616+colonizer-settlers@users.noreply.github.com>
ParallelEntrepreneur
force-pushed
the
colonizer/issue-18-246be8a4
branch
from
October 10, 2026 15:38
a1c1d43 to
c2209a5
Compare
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.
What changed
data/rules/freshness.json: the SLA classesvolatile_api(3 days),standard_api(10 days) andsubscription(14 days), plus the rules that pick a row's class. The first matching rule wins, and the row type is checked before volatility, so a subscription withvolatility: highstill gets 14 days. A key left out of a rule matches anything.age= whole UTC days from the date part oflast_verified_atto "today".stale = age > sla_days. A row exactly at its SLA is not stale, and a row verified today or with a future date never is.stale_since= verified date + SLA + 1 day (the first stale day), otherwisenull.tests/vectors/staleness.json: 17 shared vectors:mediumvolatility at 11 days, which must be stale;lowvolatility;last_verified_at;tools/freshness.mjs:classify,stalenessandannotate.annotatecopies the document and addsstale,stale_sinceand, where it applies,stale_fieldsto everyapi_offers[]/subscriptions[]row.stale_fieldsmaps a field to itsstale_since. It lists a field only when itsprovenance.fields.<f>override has afetched_atolder than the row and is itself past the SLA.counts.staleand a top-levelfreshness: { as_of, oldest: [5 rows] }, ordered by oldestlast_verified_atwith ties broken byid.tools/build.mjs(npm run build): readsdata/pricing.json, annotates it as of--as-of YYYY-MM-DD(default: today in UTC) and writesdist/pricing.json(--outoverrides the path; tests use it). Assembling the per-provider shards is still left to Split pricing.json into per-provider and per-vendor files, with a deterministic build back to pricing.json and the CSVs #10.dist/is already gitignored.crates/tokker-api/src/freshness.rs:include_str!and parses it once, so no SLA is hard-coded in Rust.serde/serde_jsonwere added, both from the workspace.schema/pricing.v1.json): additive only. It adds optionalstale,stale_sinceandstale_fieldson both row types and an optional top-levelfreshnessblock, sodist/pricing.jsonvalidates.countsalready accepted extra integer keys, socounts.staleneeded no change.schema_versionindata/pricing.jsongoes to1.1.0, following the additive-minor policy indocs/SCHEMA.md.docs/SCHEMA.mdandtools/README.mdget short notes.How it was verified (before the interrupted edit)
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspaceandRUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspaceall passed.cargo build -p tokker-worker --target wasm32-unknown-unknownpassed.cargo tree -d --depth 0 | grep cratefieldprinted nothing.npm ciandnpm run validatepassed.npm testpassed 22/22: every shared vector, the fourstale_fieldscases, counts/oldest, no mutation of the input, and the annotated real dataset passingvalidateDocuments.npm run buildbuiltdist/pricing.jsonwith 253 stale rows out of 583 as of 2026-10-10. That output passednode tools/validate.mjs dist/pricing.json.tests/vectors/staleness.json, which is how the Worker and the build are kept in agreement.Look at closely
The interrupted edits. These are what the review pass was working on when it stopped:
tools/freshness.mjs: replacingDate.UTCwithsetUTCFullYear, so that years 0000–0099 parse literally the way Rust does.Date.UTCmaps them to 1900–1999, so the two implementations would disagree on those years.tools/build.mjs: printing a clean error and exiting 1 on an impossible--as-ofor a malformedlast_verified_at, instead of a stack trace.crates/tokker-api/src/freshness.rs: a shorter rewrite of the 318-line first version.Check each file is complete. If one isn't, take it from the first implementation and reapply the two fixes.
Size. About 790 lines in total, over the 400-line guideline: 8 modified files (+65/−5) and 6 new files of about 730 lines. The issue asks for two implementations, shared vectors, two test suites and the schema/docs updates.
Stale rows today. Every row has
last_verified_at: 2026-10-05, so the 253 high-volatility API rows are already past their 3-day SLA. The flags are correct; the verify loops just haven't run yet.Closes #18
🤖 Generated by Colonizer in a microVM
Co-Authored-By: Colonizer Settlers 331648616+colonizer-settlers@users.noreply.github.com