feat: add research input manifest contract - #271
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c713e1bc00
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "kind": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" }, | ||
| "artifact_uri": { "type": "string", "minLength": 1, "pattern": "^\\S+$" }, | ||
| "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" }, | ||
| "as_of": { "$ref": "#/$defs/date_time" } |
There was a problem hiding this comment.
Encode the manifest cutoff for every input
When an interchange consumer validates only against this schema, an input whose as_of is later than the manifest's as_of is accepted because this property has no cross-field ordering constraint. The Python validator rejects the same payload in _validate_input, so schema-validated research can inadvertently include post-cutoff data and produce look-ahead-biased results; encode this invariant in the published contract as well.
Useful? React with 👍 / 👎.
| "inputs": { | ||
| "type": "array", | ||
| "minItems": 1, | ||
| "items": { "$ref": "#/$defs/input" } |
There was a problem hiding this comment.
Enforce unique input IDs in the schema
When a manifest is validated through the packaged JSON Schema, inputs may contain multiple records with the same input_id—including conflicting URIs or hashes—because the array has no uniqueness-by-ID constraint. validate_research_input_manifest rejects these records, so the two advertised representations of the contract disagree and schema consumers can receive an ambiguous artifact binding; add the corresponding uniqueness invariant to the array.
Useful? React with 👍 / 👎.
| if not isinstance(value, str) or not _RFC3339_DATETIME.fullmatch(value): | ||
| raise ResearchInputManifestValidationError() | ||
| try: | ||
| parsed = datetime.fromisoformat(value.replace("Z", "+00:00")) |
There was a problem hiding this comment.
Preserve sub-microsecond precision in cutoff comparisons
When timestamps contain more than six fractional digits—which the schema and _RFC3339_DATETIME explicitly allow—datetime.fromisoformat truncates the excess precision. For example, a manifest cutoff ending in .0000001Z and an input timestamp ending in .0000002Z both become the same Python datetime, so the future input passes the check at _validate_input; either constrain accepted precision to microseconds or compare without discarding the additional digits.
Useful? React with 👍 / 👎.
Co-Authored-By: Codex <noreply@openai.com>
|
S0 terminal settlement: FAILED_PARKED. Final read-only auditor rechecked head 107f7cc and found material frozen contract/schema/provenance/strict-readback blockers plus unresolved review threads. One authorized consolidated remediation was exhausted; no third patch/review, no successor PR. Durable terminal event: 4bf18939-e665-45e6-bcec-84b8d0beae39 (SHA 5396de848bedf8c9f304e55ff908e9a7bfb1058265666b5282ba93b74460768b). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 107f7cc554
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "created_at": { "$ref": "#/$defs/date_time" }, | ||
| "as_of": { "$ref": "#/$defs/date_time" }, |
There was a problem hiding this comment.
Declare the creation-time ordering in the schema
When a consumer validates only against the published schema, a manifest with created_at earlier than its own as_of cutoff is accepted, even though validate_research_input_manifest rejects it at created_at < manifest_as_of. This leaves schema-based ingestion with a weaker provenance contract than the Python validator; declare the same sibling timestamp-ordering invariant at the schema root.
Useful? React with 👍 / 👎.
| manifest = validate_research_input_manifest(parsed) | ||
| if _canonical_json(manifest) != value: | ||
| raise ResearchInputManifestValidationError() |
There was a problem hiding this comment.
Reject lone surrogates before canonical encoding
When otherwise valid JSON contains an unpaired UTF-16 escape in artifact_uri (for example \ud800), json.loads accepts the resulting string and metadata validation permits it, but _canonical_json(manifest) raises an uncaught UnicodeEncodeError. Callers catching ResearchInputManifestValidationError can therefore crash on malformed manifest bytes instead of receiving the advertised validation failure; reject surrogate code points or translate this encoding failure.
Useful? React with 👍 / 👎.
| "format": "date-time", | ||
| "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,6})?(Z|[+-][0-9]{2}:[0-9]{2})$" |
There was a problem hiding this comment.
Make calendar validation assertive in the schema
When a Draft 2020-12 consumer does not explicitly enable the optional format assertion vocabulary, format: date-time is only an annotation and the accompanying pattern accepts impossible values such as 2026-99-99T99:99:99+99:99. The Python validator rejects those values through datetime.fromisoformat, so schema-only interchange validation can admit manifests that the packaged validator refuses; make date-time validity an asserted part of the schema contract rather than relying on the default format annotation.
Useful? React with 👍 / 👎.
Scope
research_input_manifest.v1JSON Schema and pure in-memory validator.Boundaries
origin/main5a83f508552bb68115123aa378795325094a7b52.Tests-first evidence
ModuleNotFoundError: No module named 'quant_platform_kit.data.research_input'.4 passed.628 passed, 1 skipped, 22 warnings, 3 subtests passed.