mostlyright-data 0.31.34__tar.gz → 0.31.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/PKG-INFO +1 -1
  2. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/SKILL.md +1 -0
  3. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/predicting-with-tabular-models.md +39 -4
  4. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/sources.md +71 -0
  5. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe.py +3 -2
  6. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe_explain.py +34 -5
  7. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe_forecast.py +39 -0
  8. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe_lint.py +240 -9
  9. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/studio_capabilities.py +10 -3
  10. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/table_search_contract.json +1 -1
  11. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4.py +2 -2
  12. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_connected.py +0 -1
  13. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_tables.py +37 -1
  14. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/.gitignore +0 -0
  15. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/README.md +0 -0
  16. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/pyproject.toml +0 -0
  17. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/scripts/hatch_build.py +0 -0
  18. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/agents/openai.yaml +0 -0
  19. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/1-open-the-page-and-the-link-to-it-in-the-first-message.md +0 -0
  20. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/2-brief-two-to-four-questions-each-with-a-recommended-answer.md +0 -0
  21. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/3-probe-read-a-source-before-committing-to-it.md +0 -0
  22. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/4-decide-say-what-you-chose-what-you-refused-and-ask-one-question.md +0 -0
  23. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/5-draft-one-recipe-document-one-call.md +0 -0
  24. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/6-build-one-run-sized-to-acquire-every-measured-source-whole.md +0 -0
  25. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/7-interrogate-ask-the-run-what-it-actually-delivered.md +0 -0
  26. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/8-fix-revise-the-document-and-register-it-again.md +0 -0
  27. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/9-present-only-what-survived-inspection-with-caveats.md +0 -0
  28. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/agent-protocol.md +0 -0
  29. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/autonomous-delivery.md +0 -0
  30. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/before-the-first-tool-call.md +0 -0
  31. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/boundaries.md +0 -0
  32. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/cloud-authentication-preflight.md +0 -0
  33. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/commands.md +0 -0
  34. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/enriching-with-small-models.md +0 -0
  35. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/live-run.md +0 -0
  36. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/making-a-table-incremental.md +0 -0
  37. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/narrating-the-run.md +0 -0
  38. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/not-hosted-yet.md +0 -0
  39. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/one-install.md +0 -0
  40. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/patterns.md +0 -0
  41. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/prediction-labels.md +0 -0
  42. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/preparing-table-search.md +0 -0
  43. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/promote.md +0 -0
  44. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/readers.md +0 -0
  45. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/receipts.md +0 -0
  46. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/recipe-test.md +0 -0
  47. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/recording-a-stream-venue.md +0 -0
  48. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/recovering-an-import-failure.md +0 -0
  49. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/reference-pages.md +0 -0
  50. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/required-protocol.md +0 -0
  51. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/satellite-signals.md +0 -0
  52. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/source-credentials.md +0 -0
  53. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/the-one-thing-to-say-about-the-skill-itself.md +0 -0
  54. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/transforms.md +0 -0
  55. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/user-communication-contract.md +0 -0
  56. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/references/writing-a-decision-record.md +0 -0
  57. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/skills/mr-data-build/scripts/write_research_notebook.py +0 -0
  58. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/__init__.py +0 -0
  59. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/agent_protocol.py +0 -0
  60. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/canonical.py +0 -0
  61. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/key_seam.py +0 -0
  62. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/page_coverage.py +0 -0
  63. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/part_check_evidence.py +0 -0
  64. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/session_probes.py +0 -0
  65. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/skill_assets.py +0 -0
  66. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/table_manifest.py +0 -0
  67. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/__init__.py +0 -0
  68. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/activity.py +0 -0
  69. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/backoff.py +0 -0
  70. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/categories.py +0 -0
  71. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/dataset-categories-v1.json +0 -0
  72. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/dataset_layout.py +0 -0
  73. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/delivery.py +0 -0
  74. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/description_shape.py +0 -0
  75. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/download.py +0 -0
  76. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/enrichment.py +0 -0
  77. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/fast_features.py +0 -0
  78. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/matching_benchmark.py +0 -0
  79. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/probe.py +0 -0
  80. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/progress_rate.py +0 -0
  81. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/progress_vocabulary.py +0 -0
  82. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe_brief.py +0 -0
  83. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/recipe_test.py +0 -0
  84. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/refresh_rehearsal.py +0 -0
  85. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/release_check.py +0 -0
  86. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/research.py +0 -0
  87. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/router.py +0 -0
  88. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/run_diagnose.py +0 -0
  89. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/run_prefix.py +0 -0
  90. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/runs.py +0 -0
  91. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/session.py +0 -0
  92. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/stream.py +0 -0
  93. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/stream_venue.py +0 -0
  94. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/support.py +0 -0
  95. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/table_view.py +0 -0
  96. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/transport.py +0 -0
  97. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/user_agent.py +0 -0
  98. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_artifacts.py +0 -0
  99. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_catalog.py +0 -0
  100. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_connections.py +0 -0
  101. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_dataset_covers.py +0 -0
  102. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_datasets.py +0 -0
  103. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_handoff.py +0 -0
  104. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_matching.py +0 -0
  105. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_narrative.py +0 -0
  106. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_public.py +0 -0
  107. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_query.py +0 -0
  108. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_reader.py +0 -0
  109. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_runs.py +0 -0
  110. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_search.py +0 -0
  111. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_search_contract.py +0 -0
  112. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_secrets.py +0 -0
  113. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/v4_stream.py +0 -0
  114. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/thin/vocabulary.py +0 -0
  115. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/__init__.py +0 -0
  116. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/attendance.py +0 -0
  117. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/clarification.py +0 -0
  118. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/cloud_auth.py +0 -0
  119. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/commands/__init__.py +0 -0
  120. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/commands/auth.py +0 -0
  121. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/commands/clarify.py +0 -0
  122. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/commands/login.py +0 -0
  123. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/commands/whoami.py +0 -0
  124. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/credential_native.py +0 -0
  125. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/credential_store.py +0 -0
  126. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/credentials.py +0 -0
  127. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/login.py +0 -0
  128. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/path_kind.py +0 -0
  129. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/plain_file.py +0 -0
  130. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/remediation.py +0 -0
  131. {mostlyright_data-0.31.34 → mostlyright_data-0.31.35}/src/mostlyright/data_harness/ux/render.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mostlyright-data
3
- Version: 0.31.34
3
+ Version: 0.31.35
4
4
  Summary: Mostly Right hosted CLI for reviewed datasets
5
5
  Project-URL: Homepage, https://mostlyright.md/
6
6
  Project-URL: Documentation, https://mostlyright.md/docs/guides/cli/
@@ -69,6 +69,7 @@ the source shape that fits.
69
69
  | Bulk dump beside a windowed source | `reference` | `recheck_seconds` | [reference](references/patterns.md#bulk-dump-beside-a-windowed-source) |
70
70
  | Live `wss://` feed | a recorded stream | see [Streams](references/recording-a-stream-venue.md) | none |
71
71
  | A join of tables this workspace already built, rebuilt when one promotes | `table.version@1.0.0` sources with `refresh: upstream_promoted` and `rebuild` (server 4.38) | one shared `data_classification`, `debounce_seconds` | [table sources](references/sources.md#reading-another-table-of-this-workspace) |
72
+ | A daily history of another table's rows, such as what each prediction said | one `table.version@1.0.0` source with a daily `window.snapshot` and `refresh: upstream_promoted`, no `rebuild` (server 4.70) | `max_partitions`, `max_source_bytes` for the whole horizon | [daily history](references/sources.md#keeping-a-daily-history-of-another-table) |
72
73
 
73
74
  [Patterns](references/patterns.md) has one complete recipe per row, with the pace set.
74
75
  [Sources](references/sources.md#pace-and-width) has the pace rules and the limits of parallel
@@ -295,6 +295,42 @@ ratio of thousands. In the transform, multiply the prediction and each quantile
295
295
  back into the target's unit. Backtest the ratio model against the provider's forecast itself as
296
296
  one more baseline.
297
297
 
298
+ ### Keep what each prediction said
299
+
300
+ Every rebuild replaces the predictions, so the prediction table cannot say later what it
301
+ predicted for an hour. On server 4.70 a second table can.
302
+
303
+ #### Needs server 4.70
304
+
305
+ Check first: run `mr-data recipe explain RECIPE.json --json` and read `table_source_snapshot` and `snapshot_refresh` in `studio_capabilities`. When `table_source_snapshot` is false, `mr-data recipe` refuses the recipe before registering it ("not available on this server yet"): tell the person the server does not keep such a history yet, and register nothing. When `snapshot_refresh` is false, the recipe registers with `SNAPSHOT_WILL_NOT_REFRESH_YET`, and each build keeps the one day it read: tell the person no history builds up until the server turns snapshot refresh on.
306
+
307
+ The second table's table source captures the prediction table's predicted rows once a UTC day
308
+ and keeps every day it captured. Build it in this shape:
309
+
310
+ - **Capture only.** The log has one source: a table source that reads the prediction table with
311
+ a daily `window.snapshot` and a `row_filter` that keeps the predicted rows, such as
312
+ `row_kind = 'predicted'` ([keeping a daily history of another table](sources.md#keeping-a-daily-history-of-another-table)).
313
+ Its transform casts each column and adds the capture day, which is the snapshot column. It
314
+ joins nothing and scores nothing.
315
+ - **No `rebuild`.** A rebuild would replace every captured day with one, so the server refuses
316
+ `rebuild` beside a snapshot table source. Declare `refresh: {trigger: upstream_promoted,
317
+ debounce_seconds: 900}` alone: each promotion of the prediction table starts a refresh that
318
+ appends that day's capture. The server starts at most one capture a UTC day, and a second
319
+ capture of the same day replaces it.
320
+ - **A daily cadence as the backstop.** Promote the log with `mr-data promote TABLE_ID --cadence
321
+ "every 1d" --why "captures the prediction table once a day"`. The trigger runs only after a
322
+ cadence is set, and the cadence captures a day even when the prediction table did not promote.
323
+ - **Score in a separate table.** To compare the logged predictions with the measured values,
324
+ build a third table that reads the log and the measured table as whole table sources, with
325
+ `rebuild` and `refresh: upstream_promoted`. Do not add a whole table source to the log itself:
326
+ a refresh would have to read it whole, so it blocks the log's refresh (`SOURCE_READS_WHOLE`),
327
+ and the `rebuild` that would answer it is refused beside the snapshot.
328
+
329
+ `mr-data table show TABLE_ID` states how many days the log holds and how many remain before its
330
+ ceilings, from the server's forecast. Size `window.snapshot.max_partitions` and
331
+ `limits.max_source_bytes` for the whole horizon before you register: both are fixed once the
332
+ recipe is registered.
333
+
298
334
  ### A predict table over fixed inputs
299
335
 
300
336
  When no input will change again, such as a file read once or an upstream table that never
@@ -533,10 +569,9 @@ A person can ask for the predictions in the same table as their data. Build it t
533
569
  table holds rows ahead, and tell the person how often they arrive.
534
570
  - **Say that predictions change.** Every rebuild replaces every prediction, so a past row's
535
571
  value can change when the model sees more data, and the table keeps no record of what it said
536
- before. Say so in the description. Keeping what was predicted at the time needs a second
537
- table whose table source reads this one with a daily snapshot, which comes with Studio
538
- contract 4.70.0 and is not served yet. Tell the person
539
- and ask; never overwrite past predictions without telling them. A rebuild from unchanged inputs
572
+ before. Say so in the description. To keep what was predicted at the time, build a
573
+ prediction log ([keep what each prediction said](#keep-what-each-prediction-said)). Tell the
574
+ person and ask; never overwrite past predictions without telling them. A rebuild from unchanged inputs
540
575
  gives the same values to a relative 1e-5 (1e-6 near zero), not the same bytes, so an unchanged request can still
541
576
  seal a new version.
542
577
 
@@ -545,3 +545,74 @@ Three rules cost a round trip when they are missed:
545
545
 
546
546
  The full member list is in `docs/RECIPE-DOCUMENT.md`, "Needs server 4.38".
547
547
 
548
+ ### Keeping a daily history of another table
549
+
550
+ A table built from table sources is rebuilt from them, so it cannot keep a row its upstream
551
+ dropped or replaced. Server 4.70 can capture the upstream once a day instead.
552
+
553
+ #### Needs server 4.70
554
+
555
+ Check first: run `mr-data recipe explain RECIPE.json --json` and read `table_source_snapshot` and `snapshot_refresh` in `studio_capabilities`. When `table_source_snapshot` is false, `mr-data recipe` refuses the recipe before registering it ("not available on this server yet"): tell the person the server does not keep such a history yet, and register nothing. When `snapshot_refresh` is false, the recipe registers with `SNAPSHOT_WILL_NOT_REFRESH_YET`, and each build keeps the one day it read: tell the person no history builds up until the server turns snapshot refresh on.
556
+
557
+ The source reads the upstream's latest promoted version, keeps the rows its
558
+ `row_filter` admits, stamps them with the UTC day it read them, and merges that day onto the
559
+ table's history:
560
+
561
+ ```json
562
+ {
563
+ "name": "captures",
564
+ "source_class": "mostlyright_table",
565
+ "data_classification": "public",
566
+ "locator": {
567
+ "kind": "table",
568
+ "display_locator": "table:UPSTREAM_TABLE_ID@latest_promoted",
569
+ "table": {"table_id": "UPSTREAM_TABLE_ID", "version": "latest_promoted"}
570
+ },
571
+ "rights_claim": {"claimed_basis": "permission_asserted", "claim_evidence_digest": "sha256:EVIDENCE_SHA256",
572
+ "claim_note": "A table this workspace built and promoted."},
573
+ "connector": {
574
+ "adapter_id": "table.version@1.0.0",
575
+ "credential_mode": "none",
576
+ "parameters": [
577
+ {"name": "reader.family_id", "value": "parquet.tabular"},
578
+ {"name": "reader.family_version", "value": "1.0.0"},
579
+ {"name": "reader.decode_options", "value": "{}"}
580
+ ]
581
+ },
582
+ "limits": {"max_source_bytes": 536870912, "max_requests": 1},
583
+ "row_filter": "row_kind = 'predicted'",
584
+ "window": {
585
+ "start_at": "2026-11-20T00:00:00Z",
586
+ "granularity": "day",
587
+ "timezone": "UTC",
588
+ "lookback_seconds": 0,
589
+ "max_span_seconds": 86400,
590
+ "snapshot": {"column": "captured_on", "max_partitions": 1200},
591
+ "merge": {
592
+ "materialization": "partition_replace",
593
+ "partition": {"column": "captured_on", "key": "iso_date_value"},
594
+ "row_identity": ["captured_on", "balancing_authority", "hour_utc"]
595
+ }
596
+ }
597
+ }
598
+ ```
599
+
600
+ - The window is a daily `window.snapshot` and nothing else: `granularity: day`,
601
+ `lookback_seconds: 0`, `max_span_seconds: 86400`, and a merge partitioned on the snapshot column
602
+ with key `iso_date_value`. `row_identity` names the snapshot column and the columns that make a
603
+ captured row unique. A request window or an hourly snapshot is refused on a table source.
604
+ - `row_filter` is optional: one DuckDB boolean expression over the upstream's columns, each read
605
+ as text. Leave it out to keep every row. An unknown column fails the run `ROW_FILTER_INVALID`
606
+ before any part of the upstream is read, and a capture that keeps no row fails `SNAPSHOT_RELATION_EMPTY` and
607
+ erases nothing.
608
+ - `limits.max_source_bytes` bounds what the table keeps, not what it reads: each day's filtered
609
+ rows and, up to 4 GiB, the whole history. The read of the upstream is held to 4 GiB. Size it at
610
+ the bytes one day keeps times the days to keep, with headroom, and `max_partitions` at the days
611
+ to keep. Both are fixed once the recipe is registered.
612
+ - Declare `refresh: {trigger: upstream_promoted, debounce_seconds: 900}` and no `rebuild`: a
613
+ rebuild beside a snapshot is refused, since it would replace every day held with one. Each
614
+ promotion starts a refresh that appends the day. The server captures at most once a UTC day, and
615
+ a later capture of the same day replaces it. Promote with `--cadence "every 1d"` so a day is
616
+ captured even when the upstream does not promote.
617
+ - Keep the capture table to this one source. A whole table source beside it blocks every refresh
618
+ (`SOURCE_READS_WHOLE`). Join or score the history in another table that reads this one.
@@ -1449,7 +1449,8 @@ def register(
1449
1449
  """``mr-data recipe FILE``: register one document and print what the server derived from it.
1450
1450
 
1451
1451
  Existing documents are linted before a credential is resolved. A document using keyless
1452
- grammar (``keyless_window`` or ``keyless_post``) asks what Studio serves before local lint,
1452
+ grammar (``keyless_window`` or ``keyless_post``) or a snapshot table source
1453
+ (``table_source_snapshot``) asks what Studio serves before local lint,
1453
1454
  because an older schema may reject the grammar before reporting capabilities. The brief and
1454
1455
  delegation gates follow, and registration is last.
1455
1456
  """
@@ -1460,7 +1461,7 @@ def register(
1460
1461
  v4.recipe_registration_body(document, "00000000-0000-0000-0000-000000000000")
1461
1462
  # New grammar must be refused as unserved before local lint can diagnose its shape.
1462
1463
  keyless = any(
1463
- capability in recipe_explain.KEYLESS_CAPABILITIES
1464
+ capability in recipe_explain.SCHEMA_GATED_CAPABILITIES
1464
1465
  for _, capability in recipe_explain.gated_grammar(document)
1465
1466
  )
1466
1467
  selected = client
@@ -38,11 +38,15 @@ from mostlyright.data_harness.thin import THIN_SCHEMA_PREFIX, numbered
38
38
  from mostlyright.data_harness.thin.recipe_lint import (
39
39
  KEYLESS_API_ADAPTER_ID,
40
40
  ROW_REQUEST_ADAPTER_ID,
41
+ TABLE_SOURCE_ADAPTER_ID,
41
42
  is_table_source,
42
43
  lint_document,
43
44
  lint_refusal,
44
45
  )
45
- from mostlyright.data_harness.thin.studio_capabilities import KEYLESS_CAPABILITIES, KEYLESS_POST
46
+ from mostlyright.data_harness.thin.studio_capabilities import (
47
+ KEYLESS_POST,
48
+ SCHEMA_GATED_CAPABILITIES,
49
+ )
46
50
  from mostlyright.data_harness.thin.transport import ThinLaneError
47
51
  from mostlyright.data_harness.thin.v4 import (
48
52
  EXPLAIN_AND_FORECAST_REQUEST_VERSION,
@@ -141,6 +145,7 @@ CAPABILITY_NAMES: tuple[str, ...] = (
141
145
  "row_request_batch",
142
146
  "keyless_window",
143
147
  "keyless_post",
148
+ "table_source_snapshot",
144
149
  )
145
150
 
146
151
  #: What a Studio that answers 404 or 405 from the explanation routes serves.
@@ -1343,7 +1348,7 @@ def explain_document_at_studio(
1343
1348
  keyless = [
1344
1349
  (pointer, capability)
1345
1350
  for pointer, capability in gated_grammar(document)
1346
- if capability in KEYLESS_CAPABILITIES
1351
+ if capability in SCHEMA_GATED_CAPABILITIES
1347
1352
  ]
1348
1353
  if keyless and getattr(refusal, "http_status", None) == 422:
1349
1354
  _raise_local_fault(document, lint=lint, cause=refusal)
@@ -1382,6 +1387,12 @@ def not_served_detail(missing: Sequence[tuple[str, str]], why: str, *, known: bo
1382
1387
  "Wait for the server deployment that enables hourly snapshot captures; do not "
1383
1388
  "silently change the requested capture interval."
1384
1389
  )
1390
+ if any(capability == "table_source_snapshot" for _, capability in missing):
1391
+ return (
1392
+ f"not available on this server yet: {listed}. {why}. Nothing was registered. "
1393
+ "Wait for the server deployment that captures snapshot table sources (contract "
1394
+ "4.70.0); without its window the table source would be read whole and keep no history."
1395
+ )
1385
1396
  post = any(capability == KEYLESS_POST for _, capability in missing)
1386
1397
  others = any(capability != KEYLESS_POST for _, capability in missing)
1387
1398
  if post and others and known:
@@ -1435,7 +1446,10 @@ def gated_grammar(document: Mapping[str, Any]) -> list[tuple[str, str]]:
1435
1446
  grammar. ``batch`` on a per-row request (4.15.0). The public generic API, no-auth kind,
1436
1447
  millisecond endpoints and slice/pacing members (4.26.0) each need ``keyless_window``. A POST
1437
1448
  that presents no credential (4.49.0) needs ``keyless_post``: a ``public.https.api@1.0.0``
1438
- request, or a per-row request under ``credential_mode: none``. Its pointer is the method.
1449
+ request, or a per-row request under ``credential_mode: none``. Its pointer is the method. A
1450
+ ``table.version@1.0.0`` source that states a ``window`` or a ``row_filter`` (4.70.0) needs
1451
+ ``table_source_snapshot``, as Studio's capabilities say: a client that reads false registers
1452
+ no snapshot on a table source.
1439
1453
  """
1440
1454
 
1441
1455
  gated: list[tuple[str, str]] = []
@@ -1463,6 +1477,13 @@ def gated_grammar(document: Mapping[str, Any]) -> list[tuple[str, str]]:
1463
1477
  if keyless_api and isinstance(request, Mapping) and request.get("method") == "POST":
1464
1478
  gated.append((f"{prefix}/connector/generic_api/request/method", "keyless_post"))
1465
1479
  window = source.get("window")
1480
+ if (
1481
+ isinstance(connector, Mapping)
1482
+ and connector.get("adapter_id") == TABLE_SOURCE_ADAPTER_ID
1483
+ ):
1484
+ for member in ("window", "row_filter"):
1485
+ if member in source:
1486
+ gated.append((f"{prefix}/{member}", "table_source_snapshot"))
1466
1487
  if isinstance(window, Mapping) and window.get("granularity") == "hour":
1467
1488
  gated.append((f"{prefix}/window/granularity", "hourly_snapshot_refresh"))
1468
1489
  merge = window.get("merge") if isinstance(window, Mapping) else None
@@ -1659,7 +1680,7 @@ def explain(args: argparse.Namespace, *, client: StudioV4Client | None = None) -
1659
1680
  document = recipe_module.read_document(Path(target))
1660
1681
  selected = client or recipe_module._client(args)
1661
1682
  keyless = any(
1662
- capability in KEYLESS_CAPABILITIES for _, capability in gated_grammar(document)
1683
+ capability in SCHEMA_GATED_CAPABILITIES for _, capability in gated_grammar(document)
1663
1684
  )
1664
1685
  if keyless:
1665
1686
  answer = explain_document_at_studio(selected, document)
@@ -1742,6 +1763,14 @@ def explain(args: argparse.Namespace, *, client: StudioV4Client | None = None) -
1742
1763
  held = rebuild_budget_warning(document)
1743
1764
  if held is not None:
1744
1765
  receipt["warnings"] = numbered("warning", [held])
1766
+ if subject["kind"] == "table" and snapshot_sources(document):
1767
+ # What the registered table holds, as Studio's forecast serves it: the explanation states
1768
+ # whether a refresh may append a day, and this how many days are already held.
1769
+ from mostlyright.data_harness.thin.recipe_forecast import held_snapshot_history
1770
+
1771
+ history = held_snapshot_history(selected, subject["recipe_id"], subject["recipe_digest"])
1772
+ if history is not None:
1773
+ receipt["snapshot_history"] = history
1745
1774
  blocking_codes = _codes(findings, blocking=True)
1746
1775
  receipt.update(
1747
1776
  status="recipe_refresh_ready" if receipt["refresh_ready"] else "recipe_refresh_blocked",
@@ -1781,11 +1810,11 @@ __all__ = [
1781
1810
  "EXPLAIN_REFRESH_PATH",
1782
1811
  "EXPLAIN_SCHEMA",
1783
1812
  "GRAMMAR_NOT_SERVED_CODE",
1784
- "KEYLESS_CAPABILITIES",
1785
1813
  "MIRRORED_RULE_CODES",
1786
1814
  "NO_CAPABILITIES",
1787
1815
  "ROUTES_REQUEST_VERSION",
1788
1816
  "RULE_CODES",
1817
+ "SCHEMA_GATED_CAPABILITIES",
1789
1818
  "SNAPSHOT_WILL_NOT_REFRESH_YET",
1790
1819
  "TABLE_REFRESH_EXPLANATION_PATH",
1791
1820
  "MirrorFinding",
@@ -733,6 +733,44 @@ def forecast_at_studio(
733
733
  return answer
734
734
 
735
735
 
736
+ def held_snapshot_history(
737
+ client: StudioV4Client, recipe_id: Any, recipe_digest: Any
738
+ ) -> list[dict[str, Any]] | None:
739
+ """Each snapshot source's held history as Studio's forecast serves it, or ``None``.
740
+
741
+ ``snapshot_history`` (server 4.14.0) is the one place Studio states what a snapshot table
742
+ holds: days held, merged bytes and days remaining against the declared ceilings, read off its
743
+ history run. A snapshot table source (4.70.0) is a snapshot there too. Nothing is computed
744
+ here beyond the sentence: every number is the server's, and a member it sends null stays
745
+ null. ``None`` when there is no recipe to ask about, the route is not served or the read is
746
+ refused, since this is a line beside another answer and never the reason that answer fails.
747
+ """
748
+
749
+ if not isinstance(recipe_id, str) or not isinstance(recipe_digest, str):
750
+ return None
751
+ try:
752
+ answer = forecast_at_studio(
753
+ client,
754
+ identifier(recipe_id, "recipe identifier"),
755
+ recipe_digest=bare_digest(recipe_digest, "recipe digest"),
756
+ mode="refresh",
757
+ )
758
+ except ThinLaneError:
759
+ return None
760
+ if answer is None:
761
+ return None
762
+ held = [
763
+ {
764
+ "source_name": item.get("source_name"),
765
+ **dict(item["snapshot_history"]),
766
+ "said": _snapshot_line(item),
767
+ }
768
+ for item in answer["sources"]
769
+ if isinstance(item.get("snapshot_history"), Mapping)
770
+ ]
771
+ return held or None
772
+
773
+
736
774
  def forecast(args: argparse.Namespace, *, client: StudioV4Client | None = None) -> dict[str, Any]:
737
775
  """``mr-data recipe forecast RECIPE_ID --digest D [--mode full|refresh]``.
738
776
 
@@ -860,6 +898,7 @@ __all__ = [
860
898
  "forecast_at_studio",
861
899
  "forecast_exit_code",
862
900
  "forecast_lines",
901
+ "held_snapshot_history",
863
902
  "last_run",
864
903
  "platform_policy",
865
904
  "request_ceiling",
@@ -244,6 +244,7 @@ def lint_document(document: Mapping[str, Any]) -> list[Finding]:
244
244
  findings.extend(_predict_sources(document.get("sources")))
245
245
  findings.extend(_refresh_trigger(document))
246
246
  findings.extend(_row_filters(document.get("sources")))
247
+ findings.extend(_table_source_row_filters(document.get("sources")))
247
248
  findings.extend(_row_request_credentials(document.get("sources")))
248
249
  findings.extend(_keyless_api_requests(document.get("sources")))
249
250
  findings.extend(_row_request_templates(document.get("sources")))
@@ -556,11 +557,11 @@ TABLE_LOCATOR_KIND = "table"
556
557
  #: ``#/$defs/table_source_locator/properties/version``: the one selector v1 admits.
557
558
  TABLE_SOURCE_VERSIONS: frozenset[str] = frozenset({"latest_promoted"})
558
559
 
559
- #: Members a table source never carries: it is read whole, presents no credential and names no
560
- #: origin, so the schema refuses each of these beside it.
560
+ #: Members a table source never carries: it reads sealed parts, presents no credential and names
561
+ #: no origin, so the schema refuses each of these beside it. A ``window`` is admitted since server
562
+ #: 4.70.0, as a daily ``window.snapshot`` alone (:func:`_table_source_window`).
561
563
  TABLE_SOURCE_FORBIDDEN: tuple[str, ...] = (
562
564
  "credential",
563
- "window",
564
565
  "collection",
565
566
  "closed",
566
567
  "reference",
@@ -579,6 +580,22 @@ MAX_REFRESH_DEBOUNCE_SECONDS = 86_400
579
580
  _UUID = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$")
580
581
 
581
582
 
583
+ def is_snapshot_table_source(source: Any) -> bool:
584
+ """Studio's ``rebuild_strategy.is_snapshot_table_source`` (server 4.70.0).
585
+
586
+ A ``table.version@1.0.0`` source that states a window, read without a shape check: the one
587
+ window such a source may state is a daily ``window.snapshot``, and Studio treats a stored
588
+ document stating any window on one as holding history.
589
+ """
590
+
591
+ return (
592
+ isinstance(source, Mapping)
593
+ and isinstance(source.get("connector"), Mapping)
594
+ and source["connector"].get("adapter_id") == TABLE_SOURCE_ADAPTER_ID
595
+ and isinstance(source.get("window"), Mapping)
596
+ )
597
+
598
+
582
599
  def is_table_source(source: Any) -> bool:
583
600
  """Whether a source is a Mostly Right table source by any of the three marks the schema reads.
584
601
 
@@ -711,10 +728,107 @@ def _table_sources(sources: Any) -> list[Finding]:
711
728
  Finding(
712
729
  DOCUMENT_INVALID,
713
730
  f"{pointer}/{member}",
714
- "is not stated on a table source, which is read whole and presents no "
715
- "credential",
731
+ "is not stated on a table source, which reads sealed parts and presents "
732
+ "no credential",
716
733
  )
717
734
  )
735
+ findings.extend(_table_source_window(source, pointer))
736
+ return findings
737
+
738
+
739
+ def _table_source_window(source: Mapping[str, Any], pointer: str) -> list[Finding]:
740
+ """The one window a table source states: a daily ``window.snapshot`` (server 4.70.0).
741
+
742
+ Each acquisition captures the pinned upstream version's rows its ``row_filter`` keeps,
743
+ stamps them with the UTC day of the receipt and merges that day onto the table's history.
744
+ A request window, an hourly snapshot or anything else is refused, and the source is bound
745
+ ``text``, since the captures merge as text. The snapshot's own members (its column, span,
746
+ lookback and merge) are left to the schema's ``window_snapshot``, as on any snapshot source.
747
+ """
748
+
749
+ if "window" not in source:
750
+ return []
751
+ window = source.get("window")
752
+ findings: list[Finding] = []
753
+ if not isinstance(window, Mapping) or "snapshot" not in window:
754
+ findings.append(
755
+ Finding(
756
+ DOCUMENT_INVALID,
757
+ f"{pointer}/window",
758
+ "states no snapshot, and a table source reads a pinned version whole, so the one "
759
+ "window it states is a daily window.snapshot",
760
+ )
761
+ )
762
+ elif window.get("granularity") != "day":
763
+ findings.append(
764
+ Finding(
765
+ DOCUMENT_INVALID,
766
+ f"{pointer}/window/granularity",
767
+ "must be 'day': a table source's snapshot captures once a UTC day",
768
+ )
769
+ )
770
+ if "binding" in source and source.get("binding") != "text":
771
+ findings.append(
772
+ Finding(
773
+ DOCUMENT_INVALID,
774
+ f"{pointer}/binding",
775
+ "must be 'text': a snapshot table source merges its captures as text",
776
+ )
777
+ )
778
+ return findings
779
+
780
+
781
+ def _table_source_row_filters(sources: Any) -> list[Finding]:
782
+ """A source's own ``row_filter`` (server 4.70.0): on a snapshot table source alone.
783
+
784
+ It chooses which rows of the pinned upstream version one capture keeps, so the schema admits
785
+ it only on a ``table.version@1.0.0`` source beside its ``window``, and holds it to 1 to 8,192
786
+ characters with no NUL. Whether it binds against the upstream's columns is the worker's
787
+ question before any part moves (``ROW_FILTER_INVALID``): this lane holds no SQL engine.
788
+ """
789
+
790
+ findings: list[Finding] = []
791
+ for index, source in enumerate(sources if isinstance(sources, list) else ()):
792
+ if not isinstance(source, Mapping) or "row_filter" not in source:
793
+ continue
794
+ pointer = f"/sources/{index}"
795
+ connector = source.get("connector")
796
+ if not (
797
+ isinstance(connector, Mapping)
798
+ and connector.get("adapter_id") == TABLE_SOURCE_ADAPTER_ID
799
+ ):
800
+ findings.append(
801
+ Finding(
802
+ DOCUMENT_INVALID,
803
+ f"{pointer}/connector/adapter_id",
804
+ f"must be {TABLE_SOURCE_ADAPTER_ID!r} beside a source row_filter, which only "
805
+ "a snapshot table source states; a per-row collection's filter is "
806
+ "collection.discovery.row_filter",
807
+ )
808
+ )
809
+ elif "window" not in source:
810
+ findings.append(
811
+ Finding(
812
+ DOCUMENT_INVALID,
813
+ f"{pointer}/window",
814
+ "is absent beside row_filter: the filter chooses the rows a daily "
815
+ "window.snapshot captures, so a table source states it only with one",
816
+ )
817
+ )
818
+ expression = source["row_filter"]
819
+ if (
820
+ not isinstance(expression, str)
821
+ or not 1 <= len(expression) <= MAX_ROW_FILTER_CHARACTERS
822
+ or "\x00" in expression
823
+ ):
824
+ findings.append(
825
+ Finding(
826
+ DOCUMENT_INVALID,
827
+ f"{pointer}/row_filter",
828
+ "is one boolean expression of 1 to "
829
+ f"{MAX_ROW_FILTER_CHARACTERS:,} characters with no NUL, written as a string",
830
+ )
831
+ )
718
832
  return findings
719
833
 
720
834
 
@@ -1043,7 +1157,10 @@ def _refresh_trigger(document: Mapping[str, Any]) -> list[Finding]:
1043
1157
 
1044
1158
  The trigger asks Studio to rebuild this table when an upstream table it reads promotes a new
1045
1159
  version, so the schema requires ``rebuild`` beside it (the rebuild is what answers the request,
1046
- under its own interval and byte bounds) and at least one ``table.version@1.0.0`` source.
1160
+ under its own interval and byte bounds) and at least one ``table.version@1.0.0`` source. Since
1161
+ server 4.70.0 a recipe with a snapshot table source needs no ``rebuild``: its request is
1162
+ answered by the day-append refresh that captures the newest promoted version, and a rebuild
1163
+ beside one is refused (:func:`_rebuild_coherence`).
1047
1164
  """
1048
1165
 
1049
1166
  if "refresh" not in document:
@@ -1077,16 +1194,20 @@ def _refresh_trigger(document: Mapping[str, Any]) -> list[Finding]:
1077
1194
  "is not a member of refresh",
1078
1195
  )
1079
1196
  )
1080
- if "rebuild" not in document:
1197
+ sources = document.get("sources")
1198
+ if "rebuild" not in document and not any(
1199
+ is_snapshot_table_source(source)
1200
+ for source in (sources if isinstance(sources, list) else ())
1201
+ ):
1081
1202
  findings.append(
1082
1203
  Finding(
1083
1204
  DOCUMENT_INVALID,
1084
1205
  "/rebuild",
1085
1206
  "is absent, and refresh requires it: the declared whole-table rebuild is what "
1086
- "answers an upstream promotion",
1207
+ "answers an upstream promotion, unless a table source states a daily "
1208
+ "window.snapshot, whose day-append refresh answers it",
1087
1209
  )
1088
1210
  )
1089
- sources = document.get("sources")
1090
1211
  if not any(
1091
1212
  isinstance(source, Mapping)
1092
1213
  and isinstance(source.get("connector"), Mapping)
@@ -1573,6 +1694,7 @@ def _coherence(document: Mapping[str, Any], *, declared: Sequence[str]) -> list[
1573
1694
  findings.extend(_table_partition_coherence(document, known=known))
1574
1695
  findings.extend(_reference_coherence(document.get("sources")))
1575
1696
  findings.extend(_rebuild_coherence(document))
1697
+ findings.extend(_snapshot_table_source_coherence(document))
1576
1698
  findings.extend(_classification_coherence(document.get("sources")))
1577
1699
  return findings
1578
1700
 
@@ -2156,6 +2278,115 @@ def _rebuild_coherence(document: Mapping[str, Any]) -> list[Finding]:
2156
2278
  ]
2157
2279
 
2158
2280
 
2281
+ #: The Python engine's ceilings past which only the native engine builds a recipe
2282
+ #: (Studio's ``keel_engine.PYTHON_MAX_SEALED_ROWS``, ``PYTHON_ROW_REQUEST_MAX_PAGES`` and
2283
+ #: ``ROW_REQUEST_PAGE_MEMBERS``, and ``refresh_plan.PYTHON_RECOMPUTE_MAX_BYTES``).
2284
+ PYTHON_MAX_SEALED_ROWS = 10_000_000
2285
+ PYTHON_ROW_REQUEST_MAX_PAGES = 4_000_000
2286
+ ROW_REQUEST_PAGE_MEMBERS: tuple[str, ...] = (
2287
+ "max_pages",
2288
+ "max_fetches_per_run",
2289
+ "max_unavailable_members",
2290
+ )
2291
+ PYTHON_RECOMPUTE_MAX_BYTES = 4 * 1024**3
2292
+
2293
+
2294
+ def _native_only_declaration(document: Mapping[str, Any]) -> str | None:
2295
+ """Studio's ``keel_engine.python_refused_declaration``: the first declaration only the native
2296
+ engine builds, or ``None``.
2297
+
2298
+ In Studio's order: a predict source; a per-row origin pacing outside the Python coordinator's
2299
+ subset (a keyless ``source_rows`` discovery with a request); a ``row_expectation`` count past
2300
+ the Python engine's sealed rows; a collection page budget past its four million; and a
2301
+ ``multi_source_recompute`` budget past its 4 GiB.
2302
+ """
2303
+
2304
+ sources = document.get("sources")
2305
+ sources = sources if isinstance(sources, list) else []
2306
+ for index, source in enumerate(sources):
2307
+ if isinstance(source, Mapping) and "predict" in source:
2308
+ return f"/sources/{index}/predict"
2309
+ for index, source in enumerate(sources):
2310
+ collection = source.get("collection") if isinstance(source, Mapping) else None
2311
+ pages = collection.get("pages") if isinstance(collection, Mapping) else None
2312
+ if not isinstance(pages, Mapping) or "origin_pacing" not in pages:
2313
+ continue
2314
+ discovery = collection.get("discovery")
2315
+ connector = source.get("connector")
2316
+ if not (
2317
+ isinstance(connector, Mapping)
2318
+ and connector.get("credential_mode") == "none"
2319
+ and isinstance(discovery, Mapping)
2320
+ and discovery.get("kind") == "source_rows"
2321
+ and isinstance(discovery.get("request"), Mapping)
2322
+ ):
2323
+ return f"/sources/{index}/collection/pages/origin_pacing"
2324
+ checks = document.get("checks")
2325
+ for index, check in enumerate(checks if isinstance(checks, list) else ()):
2326
+ if not isinstance(check, Mapping) or check.get("kind") != "row_expectation":
2327
+ continue
2328
+ for member in ("min_rows", "max_rows"):
2329
+ count = check.get(member)
2330
+ if type(count) is int and count > PYTHON_MAX_SEALED_ROWS:
2331
+ return f"/checks/{index}/{member}"
2332
+ for index, source in enumerate(sources):
2333
+ collection = source.get("collection") if isinstance(source, Mapping) else None
2334
+ pages = collection.get("pages") if isinstance(collection, Mapping) else None
2335
+ if not isinstance(pages, Mapping):
2336
+ continue
2337
+ for member in ROW_REQUEST_PAGE_MEMBERS:
2338
+ count = pages.get(member)
2339
+ if type(count) is int and count > PYTHON_ROW_REQUEST_MAX_PAGES:
2340
+ return f"/sources/{index}/collection/pages/{member}"
2341
+ recompute = document.get("multi_source_recompute")
2342
+ if isinstance(recompute, Mapping):
2343
+ for member in ("full_output_max_bytes", "total_retained_max_bytes"):
2344
+ value = recompute.get(member)
2345
+ if type(value) is int and value > PYTHON_RECOMPUTE_MAX_BYTES:
2346
+ return f"/multi_source_recompute/{member}"
2347
+ return None
2348
+
2349
+
2350
+ def _snapshot_table_source_coherence(document: Mapping[str, Any]) -> list[Finding]:
2351
+ """The registration route's walk over snapshot table sources (server 4.70.0), restated.
2352
+
2353
+ Studio's ``recipes._snapshot_table_source_details``: a source ``row_filter`` that is only
2354
+ whitespace is no expression, and a snapshot table source is captured by the Python worker,
2355
+ so a recipe only the native engine builds (:func:`_native_only_declaration`) cannot carry
2356
+ one. Whether the deployment's engine advertises the capture at all is Studio's to answer
2357
+ (``features.table_source_snapshot``); nothing here can see the deployment.
2358
+ """
2359
+
2360
+ sources = document.get("sources")
2361
+ sources = sources if isinstance(sources, list) else []
2362
+ findings: list[Finding] = []
2363
+ for index, source in enumerate(sources):
2364
+ expression = source.get("row_filter") if isinstance(source, Mapping) else None
2365
+ if isinstance(expression, str) and expression and not expression.strip():
2366
+ findings.append(
2367
+ Finding(
2368
+ DOCUMENT_INCOHERENT,
2369
+ f"/sources/{index}/row_filter",
2370
+ "is only whitespace; row_filter is one boolean expression over the upstream "
2371
+ "version's columns",
2372
+ )
2373
+ )
2374
+ captured = [index for index, source in enumerate(sources) if is_snapshot_table_source(source)]
2375
+ refused = _native_only_declaration(document) if captured else None
2376
+ if refused is not None:
2377
+ findings.extend(
2378
+ Finding(
2379
+ DOCUMENT_INCOHERENT,
2380
+ f"/sources/{index}/window",
2381
+ f"is a snapshot table source, which the Python worker captures, and {refused} is "
2382
+ "built only by the native engine; register the capture as a table of its own "
2383
+ "that this table reads",
2384
+ )
2385
+ for index in captured
2386
+ )
2387
+ return findings
2388
+
2389
+
2159
2390
  def snapshot_horizon_notes(document: Mapping[str, Any]) -> list[str]:
2160
2391
  """One sentence per snapshot window naming its declared horizon: advice, never a finding.
2161
2392