Skip to content

Require policyengine-observability 3.0.6 so records carry the matched route - #1019

Draft
anth-volk wants to merge 2 commits into
mainfrom
sim-observability-3.0.6
Draft

anth-volk wants to merge 2 commits into
mainfrom
sim-observability-3.0.6

Conversation

@anth-volk

Copy link
Copy Markdown
Contributor

Fixes #1018

Same-Repository Draft PR Check

  • This PR is a draft.
  • This PR is from a branch in PolicyEngine/policyengine-sim-api, not a personal fork.

Changelog

  • This PR adds a changelog fragment, changelog.d/<name>.<type>.md, whose type is breaking, added, changed, fixed or removed.

Summary

  • Requires policyengine-observability >=3.0.6,<4 (was >=3.0.4,<4) in libs/policyengine-simulation-observability, projects/policyengine-simulation-entry, projects/policyengine-simulation-executor (both dependency lists) and projects/policyengine-simulation-gateway.
  • Relocks the six projects whose uv.lock holds the package with uv lock --upgrade-package policyengine-observability (uv 0.13.6, the repository's pinned release). Each lock diff changes only that package's version, file hashes and specifier. The two libraries that get it through policyengine-simulation-observability (policyengine-simulation-contract, policyengine-stage12-persistence) change only their lock.
  • Updates docs/engineering/skills/observability.md and type-checking.md to the new floor, and describes which records carry the matched route.

What changes from 3.0.4 to 3.0.6

  • 3.0.5 (Report the matched FastAPI route on records written during an endpoint policyengine-observability#40): the FastAPI middleware gives the runtime a function that reads scope["route"], and the runtime calls it each time it writes a record during the request. Records written while an endpoint runs (record_exception, event, log) now carry the route template, for example /jobs/{job_id}, instead of <unmatched>. Records written before routing (for example from a middleware) and requests that match no route still carry <unmatched>. If the reader raises, the runtime reports a diagnostic and keeps the stored route.
  • 3.0.6: only a newer certifi in the observability repository's own uv.lock. The package's requirements do not change, so it changes nothing in these locks besides the package itself.
  • Neither release reads a new environment variable, adds a public API or changes the scope __exit__ annotations that test_scope_exit_typing.py checks.

Deployment

The gateway's and the executor's Modal images install from these locks with uv_sync(frozen=True), and the entrypoint's Cloud Run image installs from its lock, so the new version reaches all three on the next release. The environment variables the observability runtime reads (OBSERVABILITY_*, OTEL_*, POLICYENGINE_OTEL_*) are the same in 3.0.4 and 3.0.6; this PR changes none of their providers or wiring.

Overlap with the daily dependency update

The open Update dependencies PR (#583) also moves these locks to 3.0.6 among many other upgrades, and fails on other packages. This PR moves only policyengine-observability so the route fix can ship on its own; the next daily run rebuilds #583 from main.

Testing

Red then green: the first commit adds the tests and fails on 3.0.4 with '<unmatched>' != '/jobs/{job_id}'; the second commit makes them pass.

  • projects/policyengine-simulation-gateway: uv run --frozen pytest "tests/test_observability.py::test_exception_recorded_while_a_route_runs_carries_the_matched_route" (new) passes. The test makes GET /jobs/{job_id} fail in the Modal lookup and checks that the exception.recorded record and the request.completed record both carry /jobs/{job_id}.
  • projects/policyengine-simulation-entry: uv run --frozen pytest "tests/test_app.py::test_event_recorded_while_a_route_runs_carries_the_matched_route" (new) passes. It checks the simulation_entry_backend_response event and request.completed for GET /jobs/{job_id}.
  • python -m scripts.rules pyright --sync <package> passes for all six relocked packages.
  • uv lock --check --project <dir> passes for all six.
  • BASE_SHA=origin/main .github/scripts/check-changelog-fragment.sh passes.
  • I did not run the full test suites locally; CI runs them.

🤖 Generated with Claude Code

anth-volk and others added 2 commits November 6, 2026 18:45
policyengine-observability 3.0.4 writes `<unmatched>` as `http.route` on
every record written while a FastAPI endpoint runs, because its middleware
begins the request before FastAPI matches the route. These tests check the
gateway's exception record for `/jobs/{job_id}` and the entrypoint's backend
response event for the same route. They fail until the services lock 3.0.5
or later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3.0.5 reads the matched FastAPI route each time a record is written, so
records written while an endpoint runs carry its route template instead of
`<unmatched>` (PolicyEngine/policyengine-observability#40). 3.0.6 changes
only the certifi version in that repository's own lock.

Raise the floor to 3.0.6 in every pyproject that requires the package, and
relock the six projects that hold it, upgrading only that package. Update the
observability and type-checking guides to the new floor and describe which
records carry the matched route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Records written during a gateway request carry the route <unmatched>

1 participant