mostlyright-data 0.31.14__tar.gz → 0.31.15__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.
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/.gitignore +3 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/PKG-INFO +1 -2
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/pyproject.toml +2 -9
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/enriching-with-small-models.md +33 -8
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/source-credentials.md +2 -1
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/sources.md +5 -1
- mostlyright_data-0.31.15/src/mostlyright/data_harness/key_seam.py +7 -0
- mostlyright_data-0.31.15/src/mostlyright/data_harness/session_probes.py +324 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/table_manifest.py +0 -371
- mostlyright_data-0.31.15/src/mostlyright/data_harness/thin/__init__.py +34 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/enrichment.py +23 -10
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/probe.py +5 -8
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/research.py +8 -247
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/router.py +1 -33
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/runs.py +2 -6
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/session.py +0 -22
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/transport.py +7 -9
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4.py +1 -2
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_artifacts.py +5 -5
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_datasets.py +4 -6
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_narrative.py +369 -30
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/vocabulary.py +0 -99
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/attendance.py +0 -11
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/clarification.py +3 -3
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/cloud_auth.py +1 -8
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/credentials.py +0 -78
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/login.py +6 -26
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/path_kind.py +14 -37
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/remediation.py +2 -23
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/render.py +5 -91
- mostlyright_data-0.31.14/src/mostlyright/data_harness/formats.py +0 -411
- mostlyright_data-0.31.14/src/mostlyright/data_harness/hosted_crawler_protocol.py +0 -115
- mostlyright_data-0.31.14/src/mostlyright/data_harness/key_seam.py +0 -353
- mostlyright_data-0.31.14/src/mostlyright/data_harness/session_probes.py +0 -722
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/__init__.py +0 -58
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/acquire.py +0 -1146
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/acquire_cancel.py +0 -579
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/approvals.py +0 -931
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/commands.py +0 -428
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/narrative.py +0 -727
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/parity.py +0 -1082
- mostlyright_data-0.31.14/src/mostlyright/data_harness/thin/propose.py +0 -2877
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/README.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/scripts/hatch_build.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/SKILL.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/agents/openai.yaml +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/1-open-the-page-and-the-link-to-it-in-the-first-message.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/2-brief-two-to-four-questions-each-with-a-recommended-answer.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/3-probe-read-a-source-before-committing-to-it.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/4-decide-say-what-you-chose-what-you-refused-and-ask-one-question.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/5-draft-one-recipe-document-one-call.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/6-build-one-run-sized-to-acquire-every-measured-source-whole.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/7-interrogate-ask-the-run-what-it-actually-delivered.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/8-fix-revise-the-document-and-register-it-again.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/9-present-only-what-survived-inspection-with-caveats.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/agent-protocol.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/autonomous-delivery.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/before-the-first-tool-call.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/boundaries.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/cloud-authentication-preflight.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/commands.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/cross-repository-protocol-reference.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/installation-parity.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/live-run.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/making-a-table-incremental.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/narrating-the-run.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/not-hosted-yet.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/one-install.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/patterns.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/prediction-labels.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/preparing-table-search.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/promote.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/readers.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/receipts.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/recipe-test.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/recording-a-stream-venue.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/recovering-an-import-failure.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/reference-pages.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/required-protocol.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/the-one-thing-to-say-about-the-skill-itself.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/transforms.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/user-communication-contract.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/writing-a-decision-record.md +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/scripts/write_research_notebook.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/__init__.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/agent_protocol.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/canonical.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/page_coverage.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/part_check_evidence.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/skill_assets.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/activity.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/backoff.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/categories.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/dataset-categories-v1.json +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/delivery.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/description_shape.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/download.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/fast_features.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/matching_benchmark.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/progress_rate.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/progress_vocabulary.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe_brief.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe_explain.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe_forecast.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe_lint.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/recipe_test.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/refresh_rehearsal.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/release_check.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/run_diagnose.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/run_prefix.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/stream.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/stream_venue.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/studio_capabilities.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/support.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/table_search_contract.json +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/table_view.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/user_agent.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_catalog.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_connected.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_connections.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_dataset_covers.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_handoff.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_matching.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_public.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_query.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_reader.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_runs.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_search.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_search_contract.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_secrets.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_stream.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/thin/v4_tables.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/__init__.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/commands/__init__.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/commands/auth.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/commands/clarify.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/commands/login.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/commands/whoami.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/credential_native.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/credential_store.py +0 -0
- {mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/src/mostlyright/data_harness/ux/plain_file.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mostlyright-data
|
|
3
|
-
Version: 0.31.
|
|
3
|
+
Version: 0.31.15
|
|
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/
|
|
@@ -9,7 +9,6 @@ Provides-Extra: build
|
|
|
9
9
|
Requires-Dist: hatch-vcs==0.5.0; extra == 'build'
|
|
10
10
|
Requires-Dist: hatchling==1.28.0; extra == 'build'
|
|
11
11
|
Requires-Dist: setuptools-scm==10.3.4; extra == 'build'
|
|
12
|
-
Requires-Dist: uv-build==0.11.3; extra == 'build'
|
|
13
12
|
Requires-Dist: vcs-versioning==2.6.0; extra == 'build'
|
|
14
13
|
Description-Content-Type: text/markdown
|
|
15
14
|
|
|
@@ -22,16 +22,13 @@ build = [
|
|
|
22
22
|
"hatch-vcs==0.5.0",
|
|
23
23
|
"hatchling==1.28.0",
|
|
24
24
|
"setuptools-scm==10.3.4",
|
|
25
|
-
"uv-build==0.11.3",
|
|
26
25
|
"vcs-versioning==2.6.0",
|
|
27
26
|
]
|
|
28
27
|
|
|
29
28
|
[dependency-groups]
|
|
30
29
|
dev = [
|
|
31
|
-
"cmarkgfm>=2025.10.22",
|
|
32
30
|
"jsonschema[format]>=4.23,<5",
|
|
33
31
|
"pytest>=8.3",
|
|
34
|
-
"pytest-xdist>=3.6",
|
|
35
32
|
# Test-only, and only for `tests/test_thin_v4_contract.py`'s cross-check of its hand-written
|
|
36
33
|
# OpenAPI scan against a real parser. It never enters the distribution, whose runtime
|
|
37
34
|
# dependency list is empty; the guard it unblocks was unreachable in every configuration
|
|
@@ -60,8 +57,8 @@ cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true
|
|
|
60
57
|
source = "vcs"
|
|
61
58
|
|
|
62
59
|
# Only `v<digits>` tags are releases. A commit after the last one builds as that release's
|
|
63
|
-
# version, as a checkout between releases always has:
|
|
64
|
-
#
|
|
60
|
+
# version, as a checkout between releases always has: the published CLI reports plain X.Y.Z
|
|
61
|
+
# and refuses a local version suffix. A tree without git history builds as 0.0.0.
|
|
65
62
|
[tool.hatch.version.raw-options]
|
|
66
63
|
tag_regex = "^v(?P<version>[0-9]+(?:\\.[0-9]+)*(?:(?:a|b|rc)[0-9]+)?)$"
|
|
67
64
|
version_scheme = "only-version"
|
|
@@ -77,8 +74,6 @@ only-include = [
|
|
|
77
74
|
"src/mostlyright/data_harness/__init__.py",
|
|
78
75
|
"src/mostlyright/data_harness/agent_protocol.py",
|
|
79
76
|
"src/mostlyright/data_harness/canonical.py",
|
|
80
|
-
"src/mostlyright/data_harness/formats.py",
|
|
81
|
-
"src/mostlyright/data_harness/hosted_crawler_protocol.py",
|
|
82
77
|
"src/mostlyright/data_harness/key_seam.py",
|
|
83
78
|
"src/mostlyright/data_harness/page_coverage.py",
|
|
84
79
|
"src/mostlyright/data_harness/part_check_evidence.py",
|
|
@@ -115,8 +110,6 @@ only-include = [
|
|
|
115
110
|
"src/mostlyright/data_harness/__init__.py",
|
|
116
111
|
"src/mostlyright/data_harness/agent_protocol.py",
|
|
117
112
|
"src/mostlyright/data_harness/canonical.py",
|
|
118
|
-
"src/mostlyright/data_harness/formats.py",
|
|
119
|
-
"src/mostlyright/data_harness/hosted_crawler_protocol.py",
|
|
120
113
|
"src/mostlyright/data_harness/key_seam.py",
|
|
121
114
|
"src/mostlyright/data_harness/page_coverage.py",
|
|
122
115
|
"src/mostlyright/data_harness/part_check_evidence.py",
|
|
@@ -12,7 +12,7 @@ whether each is served here, read from Studio's platform credential listing.
|
|
|
12
12
|
|
|
13
13
|
| Task | What it does | Binding |
|
|
14
14
|
| --- | --- | --- |
|
|
15
|
-
| classify | Labels each row from a text column with yes/no or choice questions: a topic, a category, a sentiment, a flag no keyword rule decides. Each answer carries a probability per label. | `classify` (Clef, self-hosted)
|
|
15
|
+
| classify | Labels each row from a text column with yes/no or choice questions: a topic, a category, a sentiment, a flag no keyword rule decides. Each answer carries a probability per label. | `gemini-decisions` (Mostly Right Classify: Gemini Decision 1) first; `classify` (Clef, self-hosted) and `openrouter-decisions` (TypeSafe's Jev) answer the same questions |
|
|
16
16
|
| extract | Pulls named fields (names, amounts, dates, places) out of page or document text into columns. Every value appears verbatim in the input or is dropped. | `extract` (the extraction model, NuExtract-based) |
|
|
17
17
|
| match | Links the same entity across tables or within one. | none yet: `planned` |
|
|
18
18
|
|
|
@@ -20,14 +20,19 @@ Each served binding comes with its route, its pinned `model`, its rate, today's
|
|
|
20
20
|
and a `request_template`. Copy `origin`, `method`, `path_template` and `model` from the listing
|
|
21
21
|
exactly, and write the same origin as the source's `connector.origin` and as the only entry of
|
|
22
22
|
`pages.allowed_origins`. Clef's and the extraction model's origins are this deployment's own
|
|
23
|
-
service addresses, which no one can guess
|
|
24
|
-
|
|
23
|
+
service addresses, which no one can guess, and Mostly Right Classify's is Google's Gemini API.
|
|
24
|
+
The platform credential is chosen by that route and pin, so a guessed origin or a model alias is
|
|
25
|
+
refused at registration with `PLATFORM_CREDENTIAL_UNBOUND`. The person enrols no key.
|
|
25
26
|
The person pays nothing for these calls. They count against the workspace's daily quota, which
|
|
26
|
-
`mr-data recipe forecast` reports. Prefer `
|
|
27
|
-
|
|
27
|
+
`mr-data recipe forecast` reports. Prefer `gemini-decisions` for new work: it answers a row in a
|
|
28
|
+
quarter of a second, has no cold start, and was the most accurate of the three on choice questions.
|
|
29
|
+
Keep `classify` and `openrouter-decisions` for recipes already written against them. Its ceiling is
|
|
30
|
+
Google's token rate, about 140 rows a second with one choice question per row and about 48 with forty
|
|
31
|
+
yes/no questions, so ask few questions per row (see below); a wider recipe is slowed by 429s.
|
|
28
32
|
|
|
29
33
|
Each binding also comes with a `pages_template`: `request_timeout_seconds` 120 and `retries` 3.
|
|
30
|
-
Write both into the collection's `pages`. Clef and the extraction model
|
|
34
|
+
Write both into the collection's `pages`. They exist for Clef and the extraction model and cost
|
|
35
|
+
nothing on `gemini-decisions`. Clef and the extraction model scale to zero when idle,
|
|
31
36
|
and their first instance takes three to five minutes to load. Studio starts loading it when the
|
|
32
37
|
run is admitted, and until the service has answered once it spreads each member's attempts over
|
|
33
38
|
six minutes rather than seconds. The longer timeout and the fourth attempt let the last one land
|
|
@@ -102,11 +107,12 @@ also keep the rows it settled from being sent at all: see [Needs Studio 4.14](#n
|
|
|
102
107
|
A classify source is a [per-row request](sources.md#authoring-a-per-row-request) over the source
|
|
103
108
|
that holds the text. Start from the listing's `request_template` and fill in:
|
|
104
109
|
|
|
105
|
-
- `parameters` and the `{text_column}` placeholder in `state
|
|
110
|
+
- `parameters` and the `{text_column}` placeholder in `state` (`input` on `gemini-decisions`):
|
|
111
|
+
rename both to the upstream
|
|
106
112
|
source's column that holds the text. The template's `text_column` and `id` are placeholders,
|
|
107
113
|
and registration refuses a parameter or carried column the upstream does not have.
|
|
108
114
|
- `questions`: one entry per column you want. A `choice` question names its labels as keys of
|
|
109
|
-
`criteria` (1 to 64); include a "none fits" label so a row is never forced into a wrong one. A
|
|
115
|
+
`criteria` (1 to 64, or 2 to 255 on `gemini-decisions`); include a "none fits" label so a row is never forced into a wrong one. A
|
|
110
116
|
`noul` question answers one statement true or false, and its `criteria` may describe only
|
|
111
117
|
`true` and `false`. A `score` question rates the text on a list of 1 to 64 levels. Keep the
|
|
112
118
|
instructions to one sentence about the text alone. `state` takes at most 65,536 characters.
|
|
@@ -121,6 +127,25 @@ The Reader reads each label's probability by JSON pointer, as the Jev example in
|
|
|
121
127
|
table that publishes a model's label names the model pin in the column description and keeps the
|
|
122
128
|
probability beside the label.
|
|
123
129
|
|
|
130
|
+
### Writing a Mostly Right Classify source
|
|
131
|
+
|
|
132
|
+
`gemini-decisions` takes the same questions with these differences, and its `request_template`
|
|
133
|
+
already has them:
|
|
134
|
+
|
|
135
|
+
- The text goes in `input`, not `state`.
|
|
136
|
+
- Each label in `criteria` takes a string. Write `""` when the label says it all; `null` is refused.
|
|
137
|
+
- Question keys match `[A-Za-z0-9_-]{1,64}`, a choice question takes 2 to 255 labels, and a label has no
|
|
138
|
+
control or zero-width characters. Write a family emoji as its word (`family`), since its
|
|
139
|
+
joiners are refused.
|
|
140
|
+
- It takes `noul`, `choice` and `score` questions; only `choice` has been measured against Clef
|
|
141
|
+
and Jev.
|
|
142
|
+
- The answer carries no `id` and no `model`. Read the probabilities only, or declare `/id` and
|
|
143
|
+
`/model` `required: false`.
|
|
144
|
+
|
|
145
|
+
When a row gets several labels from one list (emoji, tags, genres), ask one `choice` question over
|
|
146
|
+
the whole list and keep the top three by probability, not one yes/no question per label. It costs
|
|
147
|
+
a third of the tokens and picks the same top three.
|
|
148
|
+
|
|
124
149
|
### Writing an extract source
|
|
125
150
|
|
|
126
151
|
An extract source has the same per-row shape with the extraction body
|
|
@@ -39,7 +39,8 @@ A [per-row request](sources.md#authoring-a-per-row-request) presents a key by it
|
|
|
39
39
|
`request.auth` says. A saved connection cannot stand in for it.
|
|
40
40
|
- `platform` presents a key Mostly Right holds, so the user enrols nothing.
|
|
41
41
|
|
|
42
|
-
The platform key serves every binding `mr-data models --json` lists:
|
|
42
|
+
The platform key serves every binding `mr-data models --json` lists: Mostly Right Classify
|
|
43
|
+
(Gemini Decision 1) and Clef for classification,
|
|
43
44
|
the extraction model where it is served, and OpenRouter's decisions endpoint for TypeSafe's Jev
|
|
44
45
|
decision model, pinned to `typesafe/jev-1.13`. Do not ask the user for a key to use any of them. A user who
|
|
45
46
|
prefers their own key enrols it with `mr-data keys set`. The source then states
|
{mostlyright_data-0.31.14 → mostlyright_data-0.31.15}/skills/mr-data-build/references/sources.md
RENAMED
|
@@ -185,6 +185,8 @@ movie in an upstream `movies` source. It uses three labels. Its connector states
|
|
|
185
185
|
`"adapter_id": "public.https.collection@2.0.0"`, `"credential_mode": "platform"`,
|
|
186
186
|
`"origin": "https://openrouter.ai"` and a `json.tabular` Reader pin with `records_pointer` `""`.
|
|
187
187
|
Its `limits.max_requests` is 4000, which reserves four attempts for each of up to 1000 requests.
|
|
188
|
+
The same source on `gemini-decisions` names Gemini's route and pin, puts the text in `input`
|
|
189
|
+
instead of `state`, and writes `""` for each label instead of `null`.
|
|
188
190
|
|
|
189
191
|
```json
|
|
190
192
|
"collection": {
|
|
@@ -265,7 +267,9 @@ deploy.
|
|
|
265
267
|
|
|
266
268
|
The platform credential needs no key from anyone, and any subscribed workspace may use it. Each
|
|
267
269
|
binding is one route and one pinned model, and `mr-data models --json` lists the ones this
|
|
268
|
-
deployment serves:
|
|
270
|
+
deployment serves: Mostly Right Classify for classification (`gemini-decisions`,
|
|
271
|
+
`POST https://generativelanguage.googleapis.com/v1beta/decisions` with `/model` set to
|
|
272
|
+
`gemini-decision-1`), Clef (`classify`), TypeSafe's Jev through OpenRouter
|
|
269
273
|
(`openrouter-decisions`, `POST https://openrouter.ai/api/alpha/decisions` with `/model` set to
|
|
270
274
|
`typesafe/jev-1.13`) and, where it is served, the extraction model (`extract`). Pin the exact
|
|
271
275
|
model the listing names. A floating alias such as `~typesafe/jev-latest` is refused at
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"""The probe vocabulary a research session speaks (ADR 0021).
|
|
2
|
+
|
|
3
|
+
Studio owns the probe *kind* enum and nothing else about a probe. Its contract says so in as many
|
|
4
|
+
words: a probe request and a probe result are "opaque to Studio", size-bounded, digested, and
|
|
5
|
+
stored uninterpreted, "so the harness can add a probe parameter or a result field without a Studio
|
|
6
|
+
contract change". This module is the other half of that arrangement -- the place where the bodies
|
|
7
|
+
under those four kinds are actually specified, so that "opaque to Studio" does not degrade into
|
|
8
|
+
"unspecified anywhere".
|
|
9
|
+
|
|
10
|
+
**Why the kind enum is not restated as a choice.** ``research-session.schema.json`` closes
|
|
11
|
+
``probe_kind`` to four values. Restating them here as a *harness* decision would invite the two
|
|
12
|
+
spellings to drift; :data:`PROBE_KINDS` is therefore the same four, and
|
|
13
|
+
``tests/test_thin_research.py`` asserts it equals the contract's own ``probe_kind`` enum. What
|
|
14
|
+
this repository decides is the body, and only the body.
|
|
15
|
+
|
|
16
|
+
**Why every request names a source.** All four kinds carry ``source_id``, including
|
|
17
|
+
``evaluate_expression``. It costs one field and buys two things. Probe progress can then be emitted
|
|
18
|
+
as the ``source_probe_started`` / ``source_probe_settled`` pair -- which travel as Studio's
|
|
19
|
+
``attempt_progress`` and ``source_probe_completed`` event types, exactly the two the
|
|
20
|
+
research-session design names -- without mislabelling a probe id as a source id. And the session's
|
|
21
|
+
``context.source_ids`` becomes an enforceable allowlist: a probe that names a source the session
|
|
22
|
+
was not opened against is refused before anything is read, which is the whole of a probe's
|
|
23
|
+
authority check.
|
|
24
|
+
|
|
25
|
+
**Why expressions are an AST and never a string.** ``evaluate_expression`` is the one kind a caller
|
|
26
|
+
could reasonably expect to accept a little language. It does not. The request carries a closed,
|
|
27
|
+
bounded, non-recursive-by-construction operator tree; there is no parser, no ``eval``, no
|
|
28
|
+
comprehension over caller text, and no operator whose cost is superlinear in anything the caller
|
|
29
|
+
controls. A probe body arrives from Studio having been stored uninterpreted, which means it arrives
|
|
30
|
+
with exactly as much trust as the client that submitted it -- that is to say, none.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
from __future__ import annotations
|
|
34
|
+
|
|
35
|
+
import math
|
|
36
|
+
from collections.abc import Mapping
|
|
37
|
+
from typing import Any, Final
|
|
38
|
+
|
|
39
|
+
from mostlyright.data_harness.canonical import canonical_json_bytes
|
|
40
|
+
|
|
41
|
+
#: The vocabulary's own version, carried on every result body. It is not Studio's
|
|
42
|
+
#: ``schema_version``: Studio versions the envelope, this versions what the harness puts inside it,
|
|
43
|
+
#: and the point of the arrangement is that this number can move without Studio moving.
|
|
44
|
+
PROBE_SCHEMA_VERSION: Final = "mr-session-probes.v1"
|
|
45
|
+
|
|
46
|
+
#: Studio's closed enum, restated so this module loads without the generated client, and asserted
|
|
47
|
+
#: equal to it by the test suite.
|
|
48
|
+
PROBE_KINDS: Final[tuple[str, ...]] = (
|
|
49
|
+
"source_inspect",
|
|
50
|
+
"sample_rows",
|
|
51
|
+
"profile_columns",
|
|
52
|
+
"evaluate_expression",
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
#: Studio's own bounds on the two opaque bodies, restated because the worker must refuse an
|
|
56
|
+
#: oversized result *before* spending a request on it. Studio enforces these too; a worker that
|
|
57
|
+
#: relied on that alone would learn about the ceiling by being rejected, after the work.
|
|
58
|
+
PROBE_REQUEST_MAX_BYTES: Final = 64 * 1024
|
|
59
|
+
PROBE_RESULT_MAX_BYTES: Final = 256 * 1024
|
|
60
|
+
|
|
61
|
+
#: How many rows any probe may pull back, and how many any probe may look at. The first bounds the
|
|
62
|
+
#: answer, the second bounds the work: a profile over a million rows is not an interactive probe.
|
|
63
|
+
MAX_SAMPLE_ROWS: Final = 200
|
|
64
|
+
MAX_SCAN_ROWS: Final = 50_000
|
|
65
|
+
DEFAULT_SCAN_ROWS: Final = 10_000
|
|
66
|
+
#: A cell is rendered as a short token or a number. A probe answer is a preview, not an export, so
|
|
67
|
+
#: a long string is truncated in the answer rather than the answer being refused.
|
|
68
|
+
MAX_CELL_CHARS: Final = 512
|
|
69
|
+
MAX_PROFILE_COLUMNS: Final = 256
|
|
70
|
+
#: Expression trees are bounded twice: by depth, so nesting cannot be used to build a large tree
|
|
71
|
+
#: from a small body, and by operand count at each node.
|
|
72
|
+
MAX_EXPRESSION_DEPTH: Final = 8
|
|
73
|
+
MAX_EXPRESSION_OPERANDS: Final = 16
|
|
74
|
+
|
|
75
|
+
#: The aggregate an ``evaluate_expression`` probe may compute. Closed, and every member is one
|
|
76
|
+
#: pass over at most ``MAX_SCAN_ROWS`` values.
|
|
77
|
+
AGGREGATES: Final[tuple[str, ...]] = ("count", "sum", "min", "max", "avg")
|
|
78
|
+
|
|
79
|
+
#: The predicate operators a filter may use. Closed, and every member is one comparison between one
|
|
80
|
+
#: cell and one caller literal. Nothing here matches, searches, or concatenates.
|
|
81
|
+
COMPARISONS: Final[tuple[str, ...]] = ("eq", "ne", "lt", "le", "gt", "ge")
|
|
82
|
+
UNARY_TESTS: Final[tuple[str, ...]] = ("is_null", "is_not_null")
|
|
83
|
+
CONNECTIVES: Final[tuple[str, ...]] = ("and", "or", "not")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class ProbeVocabularyError(ValueError):
|
|
87
|
+
"""A probe body that is not in the vocabulary. Carries the code the probe fails with."""
|
|
88
|
+
|
|
89
|
+
def __init__(self, code: str, detail: str) -> None:
|
|
90
|
+
super().__init__(f"{code}: {detail}")
|
|
91
|
+
self.code = code
|
|
92
|
+
self.detail = detail
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# ------------------------------------------------------------------------------------------
|
|
96
|
+
# Runtime validation. Hand written, total, and refusing rather than coercing.
|
|
97
|
+
# ------------------------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _require(condition: bool, code: str, detail: str) -> None:
|
|
101
|
+
if not condition:
|
|
102
|
+
raise ProbeVocabularyError(code, detail)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _object(value: Any, label: str) -> dict[str, Any]:
|
|
106
|
+
_require(
|
|
107
|
+
isinstance(value, dict) and all(isinstance(key, str) for key in value),
|
|
108
|
+
"PROBE_REQUEST_INVALID",
|
|
109
|
+
f"{label} must be an object with string keys",
|
|
110
|
+
)
|
|
111
|
+
return dict(value)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _exact_keys(value: Mapping[str, Any], required: set[str], optional: set[str]) -> None:
|
|
115
|
+
present = set(value)
|
|
116
|
+
missing = sorted(required - present)
|
|
117
|
+
_require(not missing, "PROBE_REQUEST_INVALID", f"missing field(s): {', '.join(missing)}")
|
|
118
|
+
unknown = sorted(present - required - optional)
|
|
119
|
+
_require(not unknown, "PROBE_REQUEST_INVALID", f"unknown field(s): {', '.join(unknown)}")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _uuid_text(value: Any, label: str) -> str:
|
|
123
|
+
_require(isinstance(value, str), "PROBE_REQUEST_INVALID", f"{label} must be a string")
|
|
124
|
+
text = str(value)
|
|
125
|
+
parts = text.split("-")
|
|
126
|
+
shape = [8, 4, 4, 4, 12]
|
|
127
|
+
ok = len(parts) == 5 and all(
|
|
128
|
+
len(part) == width and all(character in "0123456789abcdef" for character in part)
|
|
129
|
+
for part, width in zip(parts, shape, strict=True)
|
|
130
|
+
)
|
|
131
|
+
_require(ok, "PROBE_REQUEST_INVALID", f"{label} must be a lowercase UUID")
|
|
132
|
+
return text
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _bounded_int(value: Any, label: str, *, minimum: int, maximum: int) -> int:
|
|
136
|
+
# `type(...) is int` rather than isinstance: bool is a subclass of int, and a caller that sent
|
|
137
|
+
# `true` for a row limit made a mistake that must surface as one.
|
|
138
|
+
_require(type(value) is int, "PROBE_REQUEST_INVALID", f"{label} must be an integer")
|
|
139
|
+
_require(
|
|
140
|
+
minimum <= value <= maximum,
|
|
141
|
+
"PROBE_REQUEST_INVALID",
|
|
142
|
+
f"{label} must be in [{minimum}, {maximum}]",
|
|
143
|
+
)
|
|
144
|
+
return int(value)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _column_name(value: Any, label: str) -> str:
|
|
148
|
+
_require(
|
|
149
|
+
isinstance(value, str) and 1 <= len(value) <= 256,
|
|
150
|
+
"PROBE_REQUEST_INVALID",
|
|
151
|
+
f"{label} must be a string of 1..256 characters",
|
|
152
|
+
)
|
|
153
|
+
return str(value)
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _column_list(value: Any, label: str) -> tuple[str, ...]:
|
|
157
|
+
_require(isinstance(value, list), "PROBE_REQUEST_INVALID", f"{label} must be an array")
|
|
158
|
+
_require(
|
|
159
|
+
1 <= len(value) <= MAX_PROFILE_COLUMNS,
|
|
160
|
+
"PROBE_REQUEST_INVALID",
|
|
161
|
+
f"{label} must name between 1 and {MAX_PROFILE_COLUMNS} columns",
|
|
162
|
+
)
|
|
163
|
+
names = tuple(_column_name(item, f"{label} entry") for item in value)
|
|
164
|
+
_require(len(set(names)) == len(names), "PROBE_REQUEST_INVALID", f"{label} repeats a column")
|
|
165
|
+
return names
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _scalar(value: Any, label: str) -> Any:
|
|
169
|
+
if value is None or isinstance(value, bool):
|
|
170
|
+
return value
|
|
171
|
+
if isinstance(value, str):
|
|
172
|
+
_require(
|
|
173
|
+
len(value) <= MAX_CELL_CHARS,
|
|
174
|
+
"PROBE_REQUEST_INVALID",
|
|
175
|
+
f"{label} exceeds {MAX_CELL_CHARS} characters",
|
|
176
|
+
)
|
|
177
|
+
return value
|
|
178
|
+
if type(value) in {int, float}:
|
|
179
|
+
_require(
|
|
180
|
+
not isinstance(value, float) or math.isfinite(value),
|
|
181
|
+
"PROBE_REQUEST_INVALID",
|
|
182
|
+
f"{label} must be a finite number",
|
|
183
|
+
)
|
|
184
|
+
return value
|
|
185
|
+
raise ProbeVocabularyError("PROBE_REQUEST_INVALID", f"{label} is not an admitted literal")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _predicate(value: Any, *, depth: int) -> dict[str, Any]:
|
|
189
|
+
_require(
|
|
190
|
+
depth <= MAX_EXPRESSION_DEPTH,
|
|
191
|
+
"PROBE_EXPRESSION_TOO_DEEP",
|
|
192
|
+
f"predicate nests deeper than {MAX_EXPRESSION_DEPTH}",
|
|
193
|
+
)
|
|
194
|
+
node = _object(value, "predicate")
|
|
195
|
+
operator = node.get("op")
|
|
196
|
+
_require(isinstance(operator, str), "PROBE_REQUEST_INVALID", "predicate op must be a string")
|
|
197
|
+
if operator in COMPARISONS:
|
|
198
|
+
_exact_keys(node, {"op", "column", "value"}, set())
|
|
199
|
+
return {
|
|
200
|
+
"op": operator,
|
|
201
|
+
"column": _column_name(node["column"], "predicate column"),
|
|
202
|
+
"value": _scalar(node["value"], "predicate value"),
|
|
203
|
+
}
|
|
204
|
+
if operator in UNARY_TESTS:
|
|
205
|
+
_exact_keys(node, {"op", "column"}, set())
|
|
206
|
+
return {"op": operator, "column": _column_name(node["column"], "predicate column")}
|
|
207
|
+
if operator in {"and", "or"}:
|
|
208
|
+
_exact_keys(node, {"op", "operands"}, set())
|
|
209
|
+
operands = node["operands"]
|
|
210
|
+
_require(
|
|
211
|
+
isinstance(operands, list) and 1 <= len(operands) <= MAX_EXPRESSION_OPERANDS,
|
|
212
|
+
"PROBE_REQUEST_INVALID",
|
|
213
|
+
f"{operator} takes 1..{MAX_EXPRESSION_OPERANDS} operands",
|
|
214
|
+
)
|
|
215
|
+
return {
|
|
216
|
+
"op": operator,
|
|
217
|
+
"operands": [_predicate(item, depth=depth + 1) for item in operands],
|
|
218
|
+
}
|
|
219
|
+
if operator == "not":
|
|
220
|
+
_exact_keys(node, {"op", "operand"}, set())
|
|
221
|
+
return {"op": "not", "operand": _predicate(node["operand"], depth=depth + 1)}
|
|
222
|
+
raise ProbeVocabularyError(
|
|
223
|
+
"PROBE_REQUEST_INVALID", f"predicate op {operator!r} is not admitted"
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def probe_kind(value: Any) -> str:
|
|
228
|
+
"""Admit one Studio probe kind, or refuse with the code the probe fails under."""
|
|
229
|
+
|
|
230
|
+
_require(
|
|
231
|
+
isinstance(value, str) and value in PROBE_KINDS,
|
|
232
|
+
"PROBE_KIND_UNSUPPORTED",
|
|
233
|
+
f"probe kind {value!r} is not in the vocabulary",
|
|
234
|
+
)
|
|
235
|
+
return str(value)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def validate_probe_request(kind: str, request: Any) -> dict[str, Any]:
|
|
239
|
+
"""Admit one probe request body and return it normalized, with defaults filled in.
|
|
240
|
+
|
|
241
|
+
Normalizing here rather than at each use is deliberate: the executor should never see an
|
|
242
|
+
absent ``scan_rows`` and choose a default of its own, because two executors choosing two
|
|
243
|
+
defaults is how a probe stops being reproducible.
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
kind = probe_kind(kind)
|
|
247
|
+
body = _object(request, "probe request")
|
|
248
|
+
encoded = canonical_json_bytes(body)
|
|
249
|
+
_require(
|
|
250
|
+
len(encoded) <= PROBE_REQUEST_MAX_BYTES,
|
|
251
|
+
"PROBE_REQUEST_TOO_LARGE",
|
|
252
|
+
f"probe request is {len(encoded)} canonical bytes, over {PROBE_REQUEST_MAX_BYTES}",
|
|
253
|
+
)
|
|
254
|
+
if kind == "source_inspect":
|
|
255
|
+
_exact_keys(body, {"source_id"}, {"scan_rows"})
|
|
256
|
+
return {
|
|
257
|
+
"source_id": _uuid_text(body["source_id"], "source_id"),
|
|
258
|
+
"scan_rows": _bounded_int(
|
|
259
|
+
body.get("scan_rows", DEFAULT_SCAN_ROWS),
|
|
260
|
+
"scan_rows",
|
|
261
|
+
minimum=1,
|
|
262
|
+
maximum=MAX_SCAN_ROWS,
|
|
263
|
+
),
|
|
264
|
+
}
|
|
265
|
+
if kind == "sample_rows":
|
|
266
|
+
_exact_keys(body, {"source_id", "limit"}, {"offset", "columns"})
|
|
267
|
+
normalized: dict[str, Any] = {
|
|
268
|
+
"source_id": _uuid_text(body["source_id"], "source_id"),
|
|
269
|
+
"limit": _bounded_int(body["limit"], "limit", minimum=1, maximum=MAX_SAMPLE_ROWS),
|
|
270
|
+
"offset": _bounded_int(
|
|
271
|
+
body.get("offset", 0), "offset", minimum=0, maximum=MAX_SCAN_ROWS
|
|
272
|
+
),
|
|
273
|
+
}
|
|
274
|
+
if "columns" in body:
|
|
275
|
+
normalized["columns"] = list(_column_list(body["columns"], "columns"))
|
|
276
|
+
return normalized
|
|
277
|
+
if kind == "profile_columns":
|
|
278
|
+
_exact_keys(body, {"source_id"}, {"scan_rows", "columns"})
|
|
279
|
+
profiled: dict[str, Any] = {
|
|
280
|
+
"source_id": _uuid_text(body["source_id"], "source_id"),
|
|
281
|
+
"scan_rows": _bounded_int(
|
|
282
|
+
body.get("scan_rows", DEFAULT_SCAN_ROWS),
|
|
283
|
+
"scan_rows",
|
|
284
|
+
minimum=1,
|
|
285
|
+
maximum=MAX_SCAN_ROWS,
|
|
286
|
+
),
|
|
287
|
+
}
|
|
288
|
+
if "columns" in body:
|
|
289
|
+
profiled["columns"] = list(_column_list(body["columns"], "columns"))
|
|
290
|
+
return profiled
|
|
291
|
+
_exact_keys(body, {"source_id", "expression"}, {"scan_rows"})
|
|
292
|
+
expression = _object(body["expression"], "expression")
|
|
293
|
+
_exact_keys(expression, {"aggregate"}, {"column", "where"})
|
|
294
|
+
aggregate = expression["aggregate"]
|
|
295
|
+
_require(
|
|
296
|
+
isinstance(aggregate, str) and aggregate in AGGREGATES,
|
|
297
|
+
"PROBE_REQUEST_INVALID",
|
|
298
|
+
f"aggregate {aggregate!r} is not admitted",
|
|
299
|
+
)
|
|
300
|
+
normalized_expression: dict[str, Any] = {"aggregate": str(aggregate)}
|
|
301
|
+
if aggregate == "count":
|
|
302
|
+
# `count` over a column would silently mean one of two different things -- rows, or
|
|
303
|
+
# non-null values in that column -- so it takes no column at all and always means rows.
|
|
304
|
+
_require(
|
|
305
|
+
"column" not in expression,
|
|
306
|
+
"PROBE_REQUEST_INVALID",
|
|
307
|
+
"count takes no column; it counts matched rows",
|
|
308
|
+
)
|
|
309
|
+
else:
|
|
310
|
+
_require(
|
|
311
|
+
"column" in expression,
|
|
312
|
+
"PROBE_REQUEST_INVALID",
|
|
313
|
+
f"{aggregate} requires a column",
|
|
314
|
+
)
|
|
315
|
+
normalized_expression["column"] = _column_name(expression["column"], "expression column")
|
|
316
|
+
if "where" in expression:
|
|
317
|
+
normalized_expression["where"] = _predicate(expression["where"], depth=1)
|
|
318
|
+
return {
|
|
319
|
+
"source_id": _uuid_text(body["source_id"], "source_id"),
|
|
320
|
+
"scan_rows": _bounded_int(
|
|
321
|
+
body.get("scan_rows", DEFAULT_SCAN_ROWS), "scan_rows", minimum=1, maximum=MAX_SCAN_ROWS
|
|
322
|
+
),
|
|
323
|
+
"expression": normalized_expression,
|
|
324
|
+
}
|