Repository navigation
fix: enforce TEPP request and search evidence boundaries #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
886d7e6
1a27efe
579bae3
3b57e1c
061e621
eb1fc2a
6c2ef69
4e92ef2
4243b26
553cf49
cc203bd
eddd995
caf86d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,13 @@ | |
| "group", | ||
| "holdings", | ||
| "limited", | ||
| # Fixture descriptors are search vocabulary, not organization identity. | ||
| "fictitious", | ||
| "nonexistent", | ||
| "placeholder", | ||
| "sample", | ||
| "example", | ||
| "demo", | ||
|
devin-ai-integration[bot] marked this conversation as resolved.
Outdated
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: New stopwords make demo/example-named orgs permanently uncorroborated Adding Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| "foundation", | ||
| "the", | ||
| "and", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,12 +8,12 @@ | |
| lineage scores as TEPP's calibrated psychometric measurement (they answer | ||
| different questions -- see docs/lineage-bi-research-notes.md). | ||
|
|
||
| TEPP does not expose a live HTTP endpoint yet (as of this writing it is | ||
| Rust-crate-only; see ``docs/API_CONTRACT.md`` in that repo). This client | ||
| builds and validates the exact wire shape TEPP has published | ||
| (``schemas/analysis_run_request_v1.json``) so wiring in a real transport is | ||
| a one-line change (:meth:`TeppClient.__init__`'s ``transport`` argument) once | ||
| that endpoint exists, instead of a redesign. | ||
| TEPP's current protected main exposes Rust library/domain contracts and an | ||
| accepted target API contract, not a deployed HTTP service (see | ||
| ``docs/API_CONTRACT.md`` in that repo). This client builds and validates the | ||
| exact wire shape TEPP has published | ||
| (``schemas/analysis_run_request_v1.json``), so an executable transport can be | ||
| added through :meth:`TeppClient.__init__` without a consumer redesign. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
@@ -23,14 +23,15 @@ | |
|
|
||
|
|
||
| class TeppNotAvailable(RuntimeError): | ||
| """Raised by the default transport: TEPP has no live REST API yet.""" | ||
| """Raised when no executable TEPP transport is configured.""" | ||
|
|
||
|
|
||
| def _no_transport(request: dict[str, Any]) -> dict[str, Any]: | ||
| """Fail closed while TEPP exposes no executable transport.""" | ||
| raise TeppNotAvailable( | ||
| "TEPP has no live HTTP endpoint yet (Rust-crate-only as of this writing). " | ||
| "Pass a transport= callable to TeppClient once one exists, or consume TEPP " | ||
| "as a Rust crate directly per its own docs/API_CONTRACT.md." | ||
| "No executable TEPP transport is configured. TEPP currently publishes " | ||
| "Rust library/domain contracts and an accepted target API contract; " | ||
| "configure transport= when an executable service is available." | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -50,7 +51,26 @@ class AnalysisRunRequest: | |
| output_profile: str | ||
| contract_version: int = 1 | ||
|
|
||
| def __post_init__(self) -> None: | ||
| """Reject payloads that violate TEPP's v1 schema before transport.""" | ||
| if type(self.contract_version) is not int or self.contract_version != 1: | ||
| raise ValueError("TEPP AnalysisRunRequest requires contract_version=1") | ||
| for field_name in ( | ||
| "idempotency_key", | ||
| "tenant_workspace_id", | ||
| "snapshot_id", | ||
| "knowledge_cutoff", | ||
| "model_contract_version", | ||
| "output_profile", | ||
| ): | ||
| value = getattr(self, field_name) | ||
| if not isinstance(value, str) or not value.strip(): | ||
| raise ValueError( | ||
| f"TEPP AnalysisRunRequest field {field_name} must be non-blank text" | ||
| ) | ||
|
Comment on lines
+55
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: bool rejection for contract_version relies on exact type identity
Was this helpful? React with 👍 or 👎 to provide feedback.
Comment on lines
+55
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📝 Info: Request validation raises ValueError before the fail-closed try block The new Was this helpful? React with 👍 or 👎 to provide feedback. |
||
|
|
||
| def to_json(self) -> dict[str, Any]: | ||
| """Serialize the validated request into TEPP's v1 wire representation.""" | ||
| return { | ||
| "contract_version": self.contract_version, | ||
| "idempotency_key": self.idempotency_key, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.