-
Notifications
You must be signed in to change notification settings - Fork 3
feat(etl-uvicorn): give plugins request-scoped settings and invocation context #74
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
461be64
feat(etl-uvicorn): install invocation-settings handling (0.1.0)
CyMule 8049666
refactor(etl-uvicorn): own the /invoke transport, not the contract
CyMule 14d63b9
ci: move workflows to the Python 3.11 floor
CyMule b32f096
feat(etl-uvicorn): settings-scoped cache for per-invoke derived state
CyMule 472491c
fix(etl-uvicorn): map context errors through the blame taxonomy
CyMule 3df816d
feat(etl-uvicorn): declare blame in failure responses instead of enco…
CyMule 855881e
feat(etl-uvicorn): own the invocation-context model and the blame sta…
CyMule 8dc9cae
refactor(etl-uvicorn): bind /invoke envelope without body replay (#75)
CyMule 3a809fe
fix(etl-uvicorn): declare user blame on the streaming error path
CyMule d7cea08
fix(etl-uvicorn): match /invoke by the route path under a rooted depl…
CyMule dcabc9b
fix(etl-uvicorn): reject a repeat envelope install with a different b…
CyMule 1e7408a
chore(etl-uvicorn): describe context extraction as a route dependency
CyMule f8b5104
build(etl-uvicorn): pin unpublished invocation-settings source
CyMule a930c88
refactor(etl-uvicorn): simplify invocation failure plumbing
CyMule 1a7d177
refactor(etl-uvicorn): delegate field-atomic settings resolution
CyMule 292b3ed
refactor(etl-uvicorn): simplify settings resolver integration
CyMule 42fdb29
fix(etl-uvicorn): target invocation settings 0.4.0
f88e2b6
docs(invocation-settings): make contract guidance timeless
cc11cfe
build(deps): advance invocation settings pin
3f06700
feat(invocation-settings): require field-set transport
72371c4
feat(etl-uvicorn): resolve boot-or-scoped handlers on the settings cache
e4b4d65
build(deps): advance invocation settings pin
a05ec45
build(deps): advance invocation settings pin
02a6153
fix(etl-uvicorn): tighten context validation, cache expiry, and prech…
3c8495d
feat(etl-uvicorn): align invocation transport with v2 settings
4706959
fix(cache): re-read clock before insert-time sweep; fix stale CLI fla…
e80eb09
fix(etl-uvicorn): address invocation transport review
ee156c6
fix(etl-uvicorn): normalize malformed invoke JSON
8ae8fb4
fix(etl-uvicorn): preserve nested JSON validation
cc1fa56
feat(contracts): generate ratified invocation bindings
069b3a7
chore(deps): consume released invocation settings
18beb28
feat(observability): attach invocation context to request spans
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ on: | |
| - published | ||
|
|
||
| env: | ||
| PYTHON_VERSION: "3.10" | ||
| PYTHON_VERSION: "3.11" | ||
|
|
||
| jobs: | ||
| release: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| #!/usr/bin/env python3 | ||
| """Generate local Python bindings from the ratified invocation schema IDs.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import hashlib | ||
| import json | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| OUTPUT_DIR = ROOT / "unstructured_platform_plugins" / "generated" | ||
| API_ROOT = "repos/Unstructured-IO/schemas-experimental/contents" | ||
|
|
||
| CONTRACTS = { | ||
| "invocation_context_v1.py": { | ||
| "schema": f"{API_ROOT}/schemas/ratified-types/invocation-context/v1.json?ref=main", | ||
| "typeviz": f"{API_ROOT}/web/public/typeviz/invocation-context-v1.json?ref=main", | ||
| "schema_id": "https://schemas.u10d.dev/invocation-context/v1.json", | ||
| "root_type": "InvocationContext", | ||
| }, | ||
| "error_audience_v1.py": { | ||
| "schema": f"{API_ROOT}/schemas/ratified-types/errors/audience/v1.json?ref=main", | ||
| "typeviz": f"{API_ROOT}/web/public/typeviz/errors-audience-v1.json?ref=main", | ||
| "schema_id": "https://schemas.u10d.dev/errors/audience/v1.json", | ||
| "root_type": "ErrorAudience", | ||
| }, | ||
| } | ||
|
|
||
|
|
||
| def _load_json(api_path: str) -> dict[str, Any]: | ||
| completed = subprocess.run( | ||
| ["gh", "api", "-H", "Accept: application/vnd.github.raw+json", api_path], | ||
|
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. P2: When the generator runs without the external GitHub CLI, Prompt for AI agents |
||
| check=True, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| return json.loads(completed.stdout) | ||
|
|
||
|
|
||
| def _python_binding(sidecar: dict[str, Any]) -> str: | ||
| for binding in sidecar["bindings"]: | ||
| if binding["key"] == "python": | ||
| return binding["code"].rstrip() + "\n" | ||
| raise ValueError("typeviz sidecar has no Python binding") | ||
|
|
||
|
|
||
| def _render(spec: dict[str, str]) -> str: | ||
| schema = _load_json(spec["schema"]) | ||
| sidecar = _load_json(spec["typeviz"]) | ||
| if schema["$id"] != spec["schema_id"]: | ||
| raise ValueError(f"unexpected schema id: {schema['$id']}") | ||
| if sidecar["root_type_name"] != spec["root_type"]: | ||
| raise ValueError(f"unexpected root type: {sidecar['root_type_name']}") | ||
|
|
||
| canonical = json.dumps(schema, sort_keys=True, separators=(",", ":")).encode() | ||
| schema_hash = hashlib.sha256(canonical).hexdigest() | ||
| generated = _python_binding(sidecar) | ||
| if spec["root_type"] == "InvocationContext": | ||
| generated = generated.replace( | ||
| "from typing import Any, Literal", "from typing import Literal" | ||
| ) | ||
| else: | ||
| generated = generated.replace("\nfrom pydantic import BaseModel, Field\n", "") | ||
| provenance = ( | ||
| "\n# Generation provenance used by drift tests and reviewers.\n" | ||
| f"SCHEMA_ID = {schema['$id']!r}\n" | ||
| f"SCHEMA_SHA256 = {schema_hash!r}\n" | ||
| ) | ||
| if spec["root_type"] == "InvocationContext": | ||
| policy = schema["x-unstructured-version-policy"] | ||
| provenance += ( | ||
| f"RESERVED_CONTEXT_KEY = {schema['x-unstructured-reserved-key']!r}\n" | ||
| f"SUPPORTED_CONTEXT_VERSIONS = frozenset({policy['supported']!r})\n" | ||
| f"DIMENSION_FIELDS = {tuple(schema['x-unstructured-dimension-fields'])!r}\n" | ||
| ) | ||
| return ( | ||
| "# Generated by scripts/generate_invocation_contracts.py; do not edit by hand.\n" | ||
| "# ruff: noqa: E501\n" | ||
| f"# Source: {spec['schema_id']}\n" | ||
| + generated | ||
| + provenance | ||
| ) | ||
|
|
||
|
|
||
| def main() -> int: | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument("--check", action="store_true") | ||
| args = parser.parse_args() | ||
|
|
||
| OUTPUT_DIR.mkdir(parents=True, exist_ok=True) | ||
| stale: list[str] = [] | ||
| for filename, spec in CONTRACTS.items(): | ||
| output = OUTPUT_DIR / filename | ||
| rendered = _render(spec) | ||
| if args.check: | ||
| if not output.exists() or output.read_text() != rendered: | ||
| stale.append(str(output.relative_to(ROOT))) | ||
| else: | ||
| output.write_text(rendered) | ||
|
|
||
| if stale: | ||
| print("stale generated invocation contracts:", *stale, sep="\n ", file=sys.stderr) | ||
| return 1 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Floor bump for every plugin that consumes this wrapper. Can you confirm no in-tree plugin is still on 3.10? If any is, this pins them out of the settings work entirely rather than just deferring their cutover.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed: every in-tree plugin requires Python 3.12+, so the 3.11 floor excludes none.