probe-contracts 0.1.0__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 (67) hide show
  1. probe_contracts-0.1.0/.gitignore +57 -0
  2. probe_contracts-0.1.0/DESIGN.md +67 -0
  3. probe_contracts-0.1.0/LICENSE +190 -0
  4. probe_contracts-0.1.0/PKG-INFO +29 -0
  5. probe_contracts-0.1.0/README.md +16 -0
  6. probe_contracts-0.1.0/probe_contracts/__init__.py +51 -0
  7. probe_contracts-0.1.0/probe_contracts/agent_surface/DESIGN.md +104 -0
  8. probe_contracts-0.1.0/probe_contracts/agent_surface/__init__.py +1 -0
  9. probe_contracts-0.1.0/probe_contracts/agent_surface/agent_surface.py +360 -0
  10. probe_contracts-0.1.0/probe_contracts/analytics/__init__.py +5 -0
  11. probe_contracts-0.1.0/probe_contracts/analytics/analytics.py +116 -0
  12. probe_contracts-0.1.0/probe_contracts/analytics/events.json +1019 -0
  13. probe_contracts-0.1.0/probe_contracts/client_messages/__init__.py +23 -0
  14. probe_contracts-0.1.0/probe_contracts/client_messages/client_messages.py +92 -0
  15. probe_contracts-0.1.0/probe_contracts/codegen/__init__.py +5 -0
  16. probe_contracts-0.1.0/probe_contracts/codegen/__main__.py +6 -0
  17. probe_contracts-0.1.0/probe_contracts/codegen/client_messages.py +125 -0
  18. probe_contracts-0.1.0/probe_contracts/codegen/codegen.py +95 -0
  19. probe_contracts-0.1.0/probe_contracts/codegen/events.py +108 -0
  20. probe_contracts-0.1.0/probe_contracts/codegen/field_types.py +82 -0
  21. probe_contracts-0.1.0/probe_contracts/codegen/python.py +96 -0
  22. probe_contracts-0.1.0/probe_contracts/codegen/transcript_switch.py +38 -0
  23. probe_contracts-0.1.0/probe_contracts/codegen/typescript.py +76 -0
  24. probe_contracts-0.1.0/probe_contracts/compat.py +18 -0
  25. probe_contracts-0.1.0/probe_contracts/harness/__init__.py +1 -0
  26. probe_contracts-0.1.0/probe_contracts/harness/harness.py +533 -0
  27. probe_contracts-0.1.0/probe_contracts/harness/harnesses.json +314 -0
  28. probe_contracts-0.1.0/probe_contracts/knowledge/DESIGN.md +76 -0
  29. probe_contracts-0.1.0/probe_contracts/knowledge/__init__.py +18 -0
  30. probe_contracts-0.1.0/probe_contracts/knowledge/knowledge.py +134 -0
  31. probe_contracts-0.1.0/probe_contracts/knowledge/limits.py +174 -0
  32. probe_contracts-0.1.0/probe_contracts/notes/DESIGN.md +77 -0
  33. probe_contracts-0.1.0/probe_contracts/notes/__init__.py +1 -0
  34. probe_contracts-0.1.0/probe_contracts/notes/notes.py +59 -0
  35. probe_contracts-0.1.0/probe_contracts/overview_csp/__init__.py +5 -0
  36. probe_contracts-0.1.0/probe_contracts/overview_csp/allowlist.json +15 -0
  37. probe_contracts-0.1.0/probe_contracts/overview_csp/overview_csp.py +17 -0
  38. probe_contracts-0.1.0/probe_contracts/probe_contracts.py +75 -0
  39. probe_contracts-0.1.0/probe_contracts/records/DESIGN.md +42 -0
  40. probe_contracts-0.1.0/probe_contracts/records/__init__.py +29 -0
  41. probe_contracts-0.1.0/probe_contracts/records/artifact.py +81 -0
  42. probe_contracts-0.1.0/probe_contracts/records/experiment.py +34 -0
  43. probe_contracts-0.1.0/probe_contracts/records/lineage.py +71 -0
  44. probe_contracts-0.1.0/probe_contracts/records/metric_point.py +31 -0
  45. probe_contracts-0.1.0/probe_contracts/records/project.py +68 -0
  46. probe_contracts-0.1.0/probe_contracts/records/records.py +50 -0
  47. probe_contracts-0.1.0/probe_contracts/records/run.py +75 -0
  48. probe_contracts-0.1.0/probe_contracts/records/span.py +38 -0
  49. probe_contracts-0.1.0/probe_contracts/scrubber/__init__.py +1 -0
  50. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/__init__.py +151 -0
  51. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/credential_scan.py +433 -0
  52. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/decoding.py +152 -0
  53. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/events.py +272 -0
  54. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/quick.py +147 -0
  55. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/rules.py +138 -0
  56. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/shapes.py +251 -0
  57. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/values.py +354 -0
  58. probe_contracts-0.1.0/probe_contracts/scrubber/credential_scan/windows.py +119 -0
  59. probe_contracts-0.1.0/probe_contracts/scrubber/redaction.py +813 -0
  60. probe_contracts-0.1.0/probe_contracts/scrubber/scrubber.py +1087 -0
  61. probe_contracts-0.1.0/probe_contracts/scrubber/secrets.py +7 -0
  62. probe_contracts-0.1.0/probe_contracts/transcript_switch/__init__.py +5 -0
  63. probe_contracts-0.1.0/probe_contracts/transcript_switch/transcript_switch.py +26 -0
  64. probe_contracts-0.1.0/probe_contracts/transcripts/__init__.py +1 -0
  65. probe_contracts-0.1.0/probe_contracts/transcripts/atif_fragment.py +546 -0
  66. probe_contracts-0.1.0/probe_contracts/transcripts/transcripts.py +395 -0
  67. probe_contracts-0.1.0/pyproject.toml +37 -0
@@ -0,0 +1,57 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ # No trailing slash: a worktree's .venv is often a SYMLINK to a shared venv,
5
+ # and `.venv/` matches only directories (one was committed in #3276).
6
+ .venv
7
+ venv/
8
+ *.egg-info/
9
+ .pytest_cache/
10
+ .ruff_cache/
11
+ .mypy_cache/
12
+
13
+ # Env / secrets
14
+ .env
15
+ .env.*
16
+ !.env.example
17
+ .secrets/*
18
+ !.secrets/research.env.example
19
+ !.secrets/engine.env.example
20
+
21
+ # Node / Next.js
22
+ node_modules
23
+ dashboard/.next/
24
+ dashboard/out/
25
+ dashboard/.vercel/
26
+ *.tsbuildinfo
27
+
28
+ # Session planning scratch (not product)
29
+ tasks/
30
+
31
+ # OS
32
+ .DS_Store
33
+ .gstack/
34
+
35
+ # The tap plugin is stdlib-only and ships via the marketplace, not as a
36
+ # resolved package. `uv run --with pytest` writes a lockfile here that reflects
37
+ # test tooling, not the plugin's dependencies.
38
+ agent/plugins/probe-research-tap/uv.lock
39
+
40
+ # Scratch dir for the coverage-dataset capture (authored tasks, trial trees).
41
+ .work/
42
+
43
+ # Summary bench: NOTHING under fixtures/ or results/ is ever committed.
44
+ # Fixtures are raw production table slices -- customer data -- and live in
45
+ # the governed bench bucket, fetched by pointer (see
46
+ # scripts/benches/summary_bench/README.md). Reports rendered over them inherit the
47
+ # same tier. Only the harness code and the fixture POINTER manifests belong
48
+ # in git.
49
+ scripts/benches/summary_bench/results/
50
+ scripts/benches/summary_bench/fixtures/
51
+ # Hints bench: prompts, engine answers and labels are customer data and live
52
+ # in a scratchpad (scripts/benches/hints_bench/RECIPE.md); never a .jsonl in the repo.
53
+ scripts/benches/hints_bench/**/*.jsonl
54
+ .venv-agent/
55
+
56
+ # Reproducible onboarding bundle built from dashboard/onboarding-tutorial.
57
+ dashboard/public/onboarding-tutorial-assets/
@@ -0,0 +1,67 @@
1
+ # probe-contracts: design
2
+
3
+ ## Why a package
4
+
5
+ Before it, each shared thing had a source and generated or hand-kept copies pinned by parity
6
+ tests: the credential scrubber (3 server copies plus the engine's), the harness registry
7
+ (8 places), the agent view vocabulary, the supersede parser, the overview CSP allowlist, and
8
+ the run/project/artifact vocabularies the dashboard re-spelled in `constants.ts`. This
9
+ package is the one place each of them is defined; consumers import it, and a consumer that
10
+ cannot import a package (a stdlib-only hook, the tap, the dashboard) gets a generated copy
11
+ with a `--check`.
12
+
13
+ ## Records and projections (plan O5)
14
+
15
+ One record per concept. A record never goes on the wire: every request and response is a
16
+ named projection (`Record.project(*names, **overrides)`) that copies the named fields, in
17
+ order, into a plain model the server subclasses under its wire name. So:
18
+
19
+ - the frozen ingest `RunOut` keeps exactly its field set while `Run` grows;
20
+ - the projection carries no docstring, config or validator of its own, so a wire shape's
21
+ OpenAPI schema is byte-identical to the hand-written class it replaced;
22
+ - PATCH bodies stay plain models: `model_fields_set` still tells "sent" from "left out".
23
+
24
+ Field docs live as comments, not `Field(description=...)`: a description would change
25
+ every projection's OpenAPI schema.
26
+
27
+ ## Vendoring
28
+
29
+ Imports inside the package are relative, so the CLI wheel can carry it under any parent
30
+ (`probe/_vendor/probe_contracts`). The scrubber's caches key on `__name__.startswith("probe.")`:
31
+ top-level `probe_contracts` (the server) keeps them off, a copy under `probe.` would turn
32
+ them on, as the SDK's own copy does today.
33
+
34
+ The front door is lazy (`__getattr__`): importing a stdlib-only part must not load pydantic.
35
+
36
+ ## The knowledge engine (engine step 3)
37
+
38
+ `transcripts/` (the session renderer and the per-event ATIF fragment builder) and `knowledge/`
39
+ (the graph vocabulary research-os writes into the engine, and the gatherer deadlines its client
40
+ timeouts sit above) moved here from prbe-knowledge, so each is defined once. The engine is
41
+ private and cannot install this folder, so it carries a copy: `vendor/probe_contracts/` plus
42
+ `vendor/CONTRACTS_REF` (the research-os commit and every file's sha256), written by
43
+ `scripts/codegen/sync_engine_contracts.py --knowledge-root <engine>` and checked by the engine's parity
44
+ test. Change these files here, then re-vendor the engine and the tap
45
+ (`agent/tools/sync/sync_atif_fragment.py`) together: the engine rebuilds every fragment a client
46
+ sends and compares. Once probe-contracts is on PyPI the engine pins it like any dependency.
47
+
48
+ ## The analytics event catalog (plan X11)
49
+
50
+ `analytics/events.json` names every product event any Probe runtime sends, once: its enum key,
51
+ its wire name, who sends it (`server`, `agent`, `plugin`, `dashboard`) and one line of why.
52
+ `python -m probe_contracts.codegen` draws each runtime's `Event` from it (server
53
+ `app/external/analytics/generated/`, agent `probe/analytics/generated/`, `@probe/analytics`
54
+ `src/generated/`), and `--check` (test_contracts_codegen.py) fails on a stale copy. JSON, not
55
+ Python, so any runtime can read it and nothing imports it at run time.
56
+
57
+ - A NAME is unique in the whole catalog and never changes: PostHog insights, dashboards and the
58
+ Slack destinations key on it. The safety net pins every runtime's names from the code
59
+ (`tests/safety_net/analytics/`), so the catalog itself cannot drift them silently.
60
+ - A KEY is unique per runtime only: the server's `onboarding.completed` and the browser's
61
+ `onboarding_completed` are both `ONBOARDING_COMPLETED` in their own enum, and renaming either
62
+ would rewrite call sites for nothing.
63
+ - The plugin hooks are stdlib scripts loaded by path, so they keep their own constants;
64
+ `tests/unit/external/test_contracts_analytics.py` pins them to the catalog.
65
+ - Domain lifecycle events are not here: they are `EventType` (`app/shared/event_log.py`), the
66
+ tenant `events` table's vocabulary, which `record_event` forwards. The test above refuses a
67
+ catalog name that is also an `EventType`.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 prbe.ai
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.5
2
+ Name: probe-contracts
3
+ Version: 0.1.0
4
+ Summary: Probe Research's shared contracts: domain records, their generated client views, and the vocabularies every surface reads.
5
+ Author-email: Probe <team@prbe.ai>
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: pydantic>=2.9
12
+ Description-Content-Type: text/markdown
13
+
14
+ # probe-contracts
15
+
16
+ What Probe Research's server, SDK/CLI and dashboard must agree on, defined once:
17
+
18
+ - `probe_contracts.records`: the shared domain concepts as classes (`Run`, `Experiment`,
19
+ `Project`, `Artifact`, `MetricPoint`, `Span`) and the vocabularies their fields use.
20
+ Wire shapes are named projections of a record (`Run.project(...)`), never the record itself.
21
+ - `probe_contracts.analytics`: the one product-analytics event catalog (`events.json`) and its
22
+ checked loader (`EventCatalog`).
23
+ - `probe_contracts.codegen`: draws every client view of the records and each runtime's `Event`
24
+ enum (`python -m probe_contracts.codegen [--check]`).
25
+ - `probe_contracts.transcripts` and `probe_contracts.knowledge`: what the CLI's tap, this server and
26
+ the knowledge engine must build and name the same way (ATIF fragments, graph vocabulary).
27
+
28
+ Licensed Apache-2.0. The research-os server installs it from this folder; the
29
+ `probe-research` wheel vendors it at build time until it is published on PyPI.
@@ -0,0 +1,16 @@
1
+ # probe-contracts
2
+
3
+ What Probe Research's server, SDK/CLI and dashboard must agree on, defined once:
4
+
5
+ - `probe_contracts.records`: the shared domain concepts as classes (`Run`, `Experiment`,
6
+ `Project`, `Artifact`, `MetricPoint`, `Span`) and the vocabularies their fields use.
7
+ Wire shapes are named projections of a record (`Run.project(...)`), never the record itself.
8
+ - `probe_contracts.analytics`: the one product-analytics event catalog (`events.json`) and its
9
+ checked loader (`EventCatalog`).
10
+ - `probe_contracts.codegen`: draws every client view of the records and each runtime's `Event`
11
+ enum (`python -m probe_contracts.codegen [--check]`).
12
+ - `probe_contracts.transcripts` and `probe_contracts.knowledge`: what the CLI's tap, this server and
13
+ the knowledge engine must build and name the same way (ATIF fragments, graph vocabulary).
14
+
15
+ Licensed Apache-2.0. The research-os server installs it from this folder; the
16
+ `probe-research` wheel vendors it at build time until it is published on PyPI.
@@ -0,0 +1,51 @@
1
+ """probe-contracts: what the server, the SDK/CLI and the dashboard must agree on, defined once.
2
+
3
+ The front door is lazy: `import probe_contracts.scrubber` must not pay for
4
+ pydantic and every record class. `from probe_contracts import Run` loads them.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import importlib
10
+ from typing import Any
11
+
12
+ _RECORDS = (
13
+ "AnchorLevel",
14
+ "Artifact",
15
+ "ArtifactStatus",
16
+ "Experiment",
17
+ "LineageEntityType",
18
+ "LineageRelation",
19
+ "MetricNonFinite",
20
+ "MetricPoint",
21
+ "ParentRelation",
22
+ "Project",
23
+ "ProjectKind",
24
+ "Record",
25
+ "Run",
26
+ "RunCounts",
27
+ "RunStatus",
28
+ "Span",
29
+ )
30
+
31
+ _CLIENT_MESSAGES = (
32
+ "Action",
33
+ "Audience",
34
+ "ClientMessage",
35
+ "ClientMessageList",
36
+ "ClientRefusalBody",
37
+ "MessageCode",
38
+ "Severity",
39
+ )
40
+
41
+ __all__ = [*_RECORDS, *_CLIENT_MESSAGES, "CONTRACTS", "Contracts"]
42
+
43
+
44
+ def __getattr__(name: str) -> Any:
45
+ if name in _RECORDS:
46
+ return getattr(importlib.import_module(".records", __name__), name)
47
+ if name in _CLIENT_MESSAGES:
48
+ return getattr(importlib.import_module(".client_messages", __name__), name)
49
+ if name in ("CONTRACTS", "Contracts"):
50
+ return getattr(importlib.import_module(".probe_contracts", __name__), name)
51
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,104 @@
1
+ # contracts/probe_contracts/agent_surface: the view vocabulary both agent surfaces speak
2
+
3
+ ## Why one vocabulary, in a module that imports nothing (`agent_surface.py`)
4
+
5
+ Probe has two agent surfaces over the same research record: the MCP server
6
+ (`agent/src/probe/mcp/`), which external coding agents and the dashboard assistant both read
7
+ through, and the page-generation agent (`app/generation/agent/`). Both answer the same question
8
+ ("open this run and show me its trajectory"). If they answer to different words, a researcher who
9
+ learns one surface has learned nothing about the other, and a fix to one silently diverges from
10
+ the other. The MCP already fixed a lineage bug by making that view return ancestry and edges; a
11
+ second, independent matrix would re-break it.
12
+
13
+ So the vocabulary lives here with no dependencies: the backend reads it directly, and it is
14
+ generated into the agent package (`agent/tools/codegen/gen_views.py`, `make gen-views`). That is the
15
+ direction `agent/schema/openapi.json` already flows: the agent pulls from the backend, the backend
16
+ never writes into the agent.
17
+
18
+ Coverage may differ, spelling may not. `VIEW_MATRIX` is the union of what the surfaces offer,
19
+ because they genuinely differ. Each surface declares the subset it serves and a test holds it to
20
+ that. Neither may invent a second word for a read the other already named.
21
+
22
+ ## trial (`ViewKind.TRIAL`, 0135)
23
+
24
+ A rollout as an entity, not a span. It is reached by its rollout span id, which is both the URL
25
+ identity the dashboard uses and the durable metric-point -> rollout -> manifest join, so an agent
26
+ handed a trial link opens the same record a person is looking at. It carries an authored title,
27
+ description and notes, which is what makes it an entity rather than a filter on a run's spans: a
28
+ caveat written on one rollout is invisible from the run that contains 500.
29
+
30
+ `View.TRIALS` lists them under a run, named like `GROUPS` on an experiment: a trial only ever
31
+ exists under one run, so enumerating them is a view on the container, not a listing with a
32
+ mandatory parent. Before it, a run's trials were reachable only by reading every span the run
33
+ logged and filtering for `rollout`, which returns the span, not the authored Trial, so it cannot
34
+ see a title, a description or a note.
35
+
36
+ ## trial views (the `ViewKind.TRIAL` row of `VIEW_MATRIX`)
37
+
38
+ A trial is not a notes carrier, the only research entity that is not: a rollout ran once and is
39
+ immutable afterwards, so `description` holds what a later reader needs, and a notes document
40
+ beside it is one more place to look. So it gets identity plus the one read that is its own.
41
+
42
+ `trajectory` is not reachable by narrowing the run's: the rollout's descendants are a subtree,
43
+ and the spans route filters by direct `parent_span_id` only, so an agent asking a run for "the
44
+ spans of trial X" gets one level and reads it as the whole rollout.
45
+
46
+ No `artifacts` and no `diff`, both on purpose:
47
+
48
+ - Run artifacts carry a `span_id`, but the list route has no `span_id` filter, so the view could
49
+ only narrow a bounded page client-side and would report "no artifacts" for a trial whose
50
+ manifest sat past the cap.
51
+ - `diff` stays on the run because the sandbox-state route is keyed by the provider's trial name,
52
+ which a researcher-customized `Trial.name` no longer matches; pointing it at a trial id would
53
+ 404 exactly on the trials someone had bothered to rename.
54
+
55
+ ## Other kinds and views
56
+
57
+ - `ViewKind.PAPER` (0152): a kind, not a filter on the project's `papers` view, so "open this
58
+ paper" is a read of a thing, not a narrowing of a list.
59
+ - `ViewKind.TEAM_NOTE`: MCP-only as a readable entity. The assistant is handed this document in
60
+ its system prompt every turn (`render_team_note`), so a read tool for it would be a second copy
61
+ of something already in context, and its cap is exactly the assistant's whole tool-result
62
+ budget.
63
+ - `View.LINEAGE`: both relations, not one or the other (see `_view_run_lineage` in the MCP). The
64
+ ancestry walk alone answered "no lineage" for a run that had plainly consumed a dataset and
65
+ produced three artifacts, which an agent reads as fact. On an artifact (0255) it is the
66
+ file-side half of "what produced this number".
67
+ - `View.VIEWS`: the assistant could create a saved metric view and, before this, not list one
68
+ back, so a view it saved last week was unfindable by the agent that saved it.
69
+ - `View.CONTENT`: the artifact-content lane (1.36) as a view rather than a generation-only
70
+ expansion. Publish means publish, so an unpublished artifact refuses this view rather than
71
+ returning bytes.
72
+ - `View.SUMMARY_HISTORY`: the page's history was a dashboard-only surface, and a recorder that
73
+ rewrites the summary needs to see what it is replacing and what a person last wrote.
74
+ - `View.PICKS` (#3624): the current pick rode the branches header alone, so pick churn (who
75
+ overwrote whose pick, and how often) was unreadable by agents.
76
+
77
+ ## VIEW_PURPOSE
78
+
79
+ One agent-facing line per view, for the error a wrong view raises: it lists the kind's views with
80
+ what each returns. `available_views` on a response stays a bare list (see `_views_offered` in the
81
+ agent's MCP service for why).
82
+
83
+ Separate from the `#:` comments on `View`, deliberately. Those are for whoever maintains the file
84
+ and say why a view exists, which incident shaped it, what it used to do wrong. The purpose lines
85
+ say what an agent gets if it asks, in one line, and nothing else: a maintainer's note shipped into
86
+ a tool response is context spent on history the caller cannot act on.
87
+
88
+ Kept beside `VIEW_MATRIX` rather than in the MCP package for the same reason as the matrix: two
89
+ agent surfaces answer with the same words, and a second copy of the vocabulary goes stale. A view
90
+ absent here still works; the list surfaces print its name bare, as they all did before this
91
+ existed (`tests/unit/core/test_agent_view_vocabulary_is_generated.py` still requires a line for every
92
+ view).
93
+
94
+ ## GENERATION_VIEWS
95
+
96
+ The subset the generation surface serves, declared rather than discovered. It is a third surface,
97
+ and the one that cannot afford a silent miss: an unserved (kind, view) that falls through to a
98
+ card returns a confident answer to a different question, and the summary says it checked
99
+ something it never read. So the pairs are enumerated, a structural test holds the dispatcher to
100
+ exactly this table, and anything outside it refuses by naming what is valid.
101
+
102
+ It is narrower than `VIEW_MATRIX` where a read has no in-process reader yet (`reproduce`,
103
+ `events`, `diff`, `views`, `handoff`, `code`, `readme`). Those are gaps to close, not words to
104
+ invent: the spelling is already agreed.
@@ -0,0 +1 @@
1
+ """The view vocabulary both agent surfaces speak (`agent_surface.py`)."""