Skip to content

feat(mpc): retain input provenance - #898

Merged
frahlg merged 1 commit into
masterfrom
agent/mpc-input-provenance
Aug 11, 2026
Merged

frahlg merged 1 commit into
masterfrom
agent/mpc-input-provenance

Conversation

@frahlg

@frahlg frahlg commented Aug 11, 2026

Copy link
Copy Markdown
Member

Why

Historical planner diagnostics keep the slot values, but not which price and weather rows Core used. That blocks leak-free replay and makes forecast errors hard to trace.

What changed

  • record each slot's price input source and local availability time
  • record the weather row consulted while Core builds PV input
  • add input_provenance_schema: 1 so current missing data stays distinct from legacy snapshots
  • keep optional row fields absent when unknown
  • preserve the fields through diagnostics, SQLite JSON, primary optimizer results, Go fallback, and restore
  • reject negative and future provenance schemas during restore

The weather fields identify the cached row only. They do not claim full PV-model provenance. The availability times are local fetch or creation times, not provider issue times or model revisions.

No SQL migration or optimizer wire change is needed.

Tests

  • focused provenance tests: 100 repetitions
  • focused race tests: 20 repetitions
  • full go/internal/mpc with and without race detector
  • make verify
  • make verify-all, including Python, Go, Core↔Optimizer contracts, Compose migration, vet, build, and Linux ARM64/AMD64 plus Windows AMD64 cross-builds

Part of #885.

@frahlg
frahlg merged commit c095702 into master Aug 11, 2026
14 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a1c04d38a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1692 to +1693
slot.WeatherRowSource = weatherInput.Source
slot.WeatherRowAvailableAtMs = weatherInput.FetchedAtMs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Persist the weather row timestamp

A normal multi-hour forecast fetch assigns the same provider name and nowMs to every row (go/internal/forecast/forecast.go:351,392-400), so these two values identify only the fetch batch, not the row consulted. Without retaining weatherInput.SlotTsMs—particularly when lookupCloudInput selects a nearest row across a gap—the historical diagnostic cannot distinguish which hourly row produced the input, defeating exact provenance and leak-free replay.

Useful? React with 👍 / 👎.

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