Skip to content

Stage 12A: Check Auth0 permissions on Simulation Entrypoint routes - #758

Merged
anth-volk merged 12 commits into
mainfrom
feat/stage-12a-entrypoint-permissions
Oct 15, 2026
Merged

anth-volk merged 12 commits into
mainfrom
feat/stage-12a-entrypoint-permissions

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #759

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.

Summary

  • Handlers now receive the caller's identity. Protected routes get the validated CallerIdentity, which used to be parsed and discarded.
  • Auth0 permissions per route:
    • simulation:submit: POST /simulate/economy/comparison and POST /simulate/economy/budget-window.
    • simulation:read: GET /jobs/{job_id} and GET /budget-window-jobs/{batch_job_id}.
    • stage12:operate: both /internal/stage12/* routes.
  • How a permission is matched: exact matches only, from the RBAC permissions claim on any token. The space-delimited scope claim also counts, but only on client-credentials (machine) tokens, identified by gty (a string or a list) or an @clients subject; a gty of any other shape is ignored rather than rejecting the token. Claims are read only by their registered JWT names, so a grant_types or subject claim cannot stand in for gty or sub. Without RBAC, Auth0 copies requested API scopes into a user token's scope, so a user token's scope is ignored. Public routes are unchanged.
  • SIMULATION_ENTRYPOINT_ENFORCE_PERMISSIONS, strictly 0 or 1, defaulting to 0:
    • 0 (log-only): emits simulation_entry_permission_missing with the permission and azp client ID, never tokens, and lets the request through.
    • 1: answers 403.
    • Disabled auth, which is non-production only, is always allowed.
  • Deploy wiring: the deploy script and reusable workflow pass the flag from the GitHub variable SIMULATION_ENTRYPOINT_ENFORCE_PERMISSIONS; unset means 0. The deployed auth tests receive it too.
  • Deployed check: a new authenticated test runs only when enforcement is 1. It confirms the deployed test client, which must not hold stage12:operate, gets 403 from a Stage 12 route.
  • Docs: the README and DEPLOYMENT docs cover the permission table, the modes, the Auth0 prerequisites, and rollout and rollback. Beta never promotes its candidate, so missing API v1 grants can only be seen in prod's log-only events; the rollout steps say so.

Before setting enforcement to 1: on the shared entrypoint API in Auth0, enable RBAC and "Add Permissions in the Access Token". Then grant:

  • simulation:submit and simulation:read to the API v1 client and to the deployed test client (but not stage12:operate to the test client);
  • stage12:operate to the Stage 12 operator client.

Wait one access-token lifetime with no log-only events before flipping, because cached tokens don't carry new grants. The API v1 client uses a single GATEWAY_AUTH_AUDIENCE for both the old gateway and the entrypoint.

Testing

  • uv run pytest tests/ (entry project): 233 passed. Before this change there were 158. The new tests cover:
    • the per-route permission matrix;
    • permissions vs scope claims, including near misses, and scope being ignored on user tokens, including signed user tokens with string, list and malformed gty, and tokens whose grant_types or subject claims try to stand in for gty or sub;
    • log-only vs enforced;
    • disabled auth;
    • public routes staying public;
    • telemetry failure not changing the response.
  • ruff format --check src tests authenticated_tests is clean.
  • ruff check . passes on the whole repository with main's ruff.toml, which now selects the group 1 rule families from Run ruff check in CI with the first group of rule families #765, using CI's pinned ruff 0.15.22.
  • Pyright shows only the 2 errors already on main.
  • After merging main (up to Run ruff check in CI with the first group of rule families #765): the entry project's tests/ has 519 passed (with main's new tests), and the quality guards and python -m scripts.rules guard --base-ref origin/main pass. The three deployment checks for permission enforcement are registered in main's rules registry as sim.deploy.permission-enforcement-wired.
  • Deployed tests were not run.

Related:

🤖 Generated with Claude Code

anth-volk and others added 3 commits October 12, 2026 23:27
Protected handlers now receive the validated CallerIdentity through a
require_permission dependency instead of discarding it. Submission routes
require simulation:submit, polling routes require simulation:read, and the
temporary Stage 12 routes require stage12:operate. A permission may come from
the permissions claim or the space-delimited scope claim.

SIMULATION_ENTRYPOINT_ENFORCE_PERMISSIONS accepts exactly 0 or 1 and defaults
to 0. In log-only mode a missing permission emits
simulation_entry_permission_missing with the permission and the token's azp,
then allows the request. With 1 the request is rejected with 403. Disabled
authentication has no identity to check and stays allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The deployment workflow passes each environment's
SIMULATION_ENTRYPOINT_ENFORCE_PERMISSIONS variable to the entrypoint. An unset
or empty value deploys 0, and any value other than 0 or 1 fails before Cloud
Run changes.

Every authenticated deployment test run receives the same value. When it is
1, a new check confirms that the deployed test client's valid token is
rejected on a stage12:operate route; otherwise the check skips.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe the route permissions, the log-only and enforced modes, the Auth0
RBAC settings and client grants required before enforcement, and the rollout
and rollback steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk and others added 6 commits October 13, 2026 15:45
A route permission now comes from the RBAC permissions claim for every
token, but from the space-delimited scope claim only when the token was
issued to a machine client (gty is client-credentials or the subject ends in
@Clients). Without RBAC on the Auth0 API, a user token's scope carries any
API scope the user's application requested, so it is not proof of a grant.
This matters once a public sign-in application exists in the same tenant.

CallerIdentity now parses gty, and the verified-token tests use a realistic
client-credentials token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CallerIdentity typed gty as a string, so a token whose gty was a list
failed validation and was rejected with 403 even in log-only mode, where
main had ignored the claim. It is now read as a tuple of grant types: a
string or a list of strings, with any other shape ignored. The claim only
decides whether scope counts, so ignoring a malformed value can only narrow
what a token grants.

New tests send signed tokens through JWTDecoder: user tokens with scope but
no permissions are rejected under enforcement whatever their grant type,
list-valued and malformed gty claims still authenticate, and a listed
client-credentials grant still counts scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Beta never promotes its candidate revision, so a beta enforcement value
applies only to the candidate that the deployment tests call, and log-only
events from beta cannot reveal a missing API v1 grant. The rollout steps now
watch prod for those events, note that no deployment test sends API v1's own
token, and name the production-only workflow that can redeploy the
entrypoint for a faster rollback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CallerIdentity allowed population by field name, so a verified token
with no gty but a top-level grant_types claim counted as a
client-credentials token and had its scope trusted, and a subject claim
could stand in for sub (an @Clients subject marks a machine client).
Nothing builds CallerIdentity by field name, so drop populate_by_name:
sub, iss, aud, exp, iat, azp and gty are now read only by those claim
names.

Tests sign tokens that carry grant_types (with a user sub) or subject in
place of the registered claims, and check that neither grants scope
permissions, while a registered @Clients sub still does.

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

# Conflicts:
#	projects/policyengine-simulation-entry/tests/test_deployment_assets.py
Main's rules registry flags guard tests no rule describes. Register the
three Simulation Entrypoint permission-enforcement deployment tests as
sim.deploy.permission-enforcement-wired.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review October 14, 2026 21:29
@anth-volk
anth-volk requested a review from a team as a code owner October 14, 2026 21:29
@anth-volk
anth-volk removed the request for review from a team October 14, 2026 21:29
…oint-permissions

# Conflicts:
#	docs/generated/rules.md
anth-volk and others added 2 commits October 15, 2026 02:02
…oint-permissions

# Conflicts:
#	docs/generated/rules.md
Brings in #765 (ruff check in CI with the first group of rule
families), #809 (policyengine 6.4.1) and #791 (redacted Stage 12
failure cause).

Conflicts:
- auth.py: kept this branch's Callable and Literal imports and sorted
  the stdlib import block the way main's newly enabled I rule expects.
- docs/generated/rules.md: regenerated with python -m scripts.rules
  render from the auto-merged registry, which holds main's enforced
  sim.quality.ruff-lint and this branch's
  sim.deploy.permission-enforcement-wired (34 of 48 rules blocking).

ruff check . passes under main's ruff.toml with ruff 0.15.22, so this
branch's own code needed no further changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk merged commit 660123e into main Oct 15, 2026
13 checks passed
@anth-volk
anth-volk deleted the feat/stage-12a-entrypoint-permissions branch October 15, 2026 17:40
anth-volk added a commit that referenced this pull request Oct 16, 2026
* Annotate policyengine-fastapi for ruff ANN

Add the missing parameter and return annotations. AppExit forwards its
callback arguments as object rather than Any, the JWT decoder's private
validator returns the same dict type its caller declares, and the
metrics middleware types call_next as Starlette's RequestResponseEndpoint.
Ping endpoints already pass response_model explicitly, so their new
return annotations do not change the generated responses.

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

* Annotate the simulation contract library for ruff ANN

Type the SPM resolution and validation entry points, the gateway request
pre-validators (object in, object out) and the Modal Dict store helpers.
The three wrap model serializers in spm.py stay unannotated with a
reasoned noqa: Pydantic turns a serializer's return annotation into the
model's serialization JSON schema, which would rewrite the OpenAPI spec.

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

* Annotate the observability and Stage 12 persistence libraries for ruff ANN

Replace Any with object for values that are only inspected or passed
through, and type the persistence row helpers with SQLAlchemy's
RowMapping, Table and ColumnElement (imported for type checking only).

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

* Annotate the simulation gateway for ruff ANN

Every annotated route passes response_model explicitly, so FastAPI keeps
using it and the OpenAPI golden file is unchanged. _bundle_payload keeps
Any for **dump_kwargs, forwarded unchanged to BaseModel.model_dump, with
a reasoned noqa. Test fixtures outside tests/ are annotated too.

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

* Annotate the simulation entry service for ruff ANN

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

* Annotate the simulation executor for ruff ANN

Type the runtime, output builders, Modal entrypoints, scripts and the test
fixtures that live outside tests/. PolicyEngine, Google Cloud Storage and
observability types are imported for type checking only, country modules
are ModuleType, and duck-typed analysis values that tests replace with
SimpleNamespace are object. _try_compute_output uses a ParamSpec so its
arguments are checked against the wrapped function.

The in-repo src/modal package shadows the Modal library here, so Modal
types stay quoted or behind TYPE_CHECKING. _image_setup.py may not import
anything at module level, so it uses a local TYPE_CHECKING flag. The
RemoteFunction protocol keeps Any (with a reasoned noqa) because it
mirrors modal.Function.remote and spawn, whose payloads vary per function.

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

* Enable ruff group 3 (annotations)

Select ANN. Tests are exempt, alongside the docstring, magic-number and
assert rules a later group will enable. scripts/rules findings are left
for the next sync from policyengine-api.

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

* Annotate the package-update script and the Stage 12 proof fixtures

_json_from_stdin returns object (every caller narrows it), and the proof
fixtures annotate their SQLAlchemy connection and table parameters. The
schema-authority proof reads the fixtures as text, so it is unaffected.

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

* Sync the annotated rules tool from policyengine-api

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

* Register ANN and the test-file ruff exemptions

sim.quality.ruff-lint now includes ANN, and the **/tests/** per-file
ignore list (S101, D1, ANN, PLR2004) is registered as
sim.quality.tests-ruff-exemptions.

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

* Annotate the routing and bundle helpers #743 and #744 added

#743 and #744 landed on main after this stack branched. ANN, which this
PR enables, wants annotations on #744's routing-store, publication-journal
and active-state helpers and on #743's bundle dataset-digest helper. The
Modal store annotations are quoted, as in the gateway, because the
executor tests replace the modal module with a stub.

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

* Annotate the shared object store fake #787 added

#787 landed on main after this stack branched. ANN, which this PR enables,
wants annotations on the in-memory object store it moved into the executor's
fixtures. They match the byte interface of the real ArtifactStore it stands
in for.

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

* Annotate the segmented national child calls #795 added

The respawn helpers take and return the Modal FunctionCall that
Function.spawn returns, rather than Any.

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

* Annotate the permission checks #758 added

#758 landed on main after this stack branched. ANN, which this PR
enables, flags three of its additions:

- CallerAuthorizer.__init__ returns None;
- the gty before-validator takes the raw claim as object, as the
  project's other before-validators do, since it narrows the value with
  isinstance checks;
- the deployed permission-enforcement test returns None.

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

* Annotate the job progress code #781 added

#781 landed on main after this stack branched. ANN, which this PR
enables, flags six of its additions:

- the contract's job progress store returns a modal.Dict, as the
  budget-window stores do;
- the Modal app's reporter factory returns a JobProgressReporter, and
  the stage-duration recorder takes the runtime and that reporter;
- StoredJobProgressReporter.__init__ returns None;
- the calculation-start hook takes the StageReportingSimulation whose
  on_first_ensure it calls.

The new annotation-only imports sit under TYPE_CHECKING.

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

---------

Co-authored-by: Anthony Volk <14987227+anth-volk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 16, 2026
* Document the simulation contract library for ruff D

Validators, state helpers and URI functions get docstrings. Every Pydantic
model and enum whose class docstring would become a JSON-schema description
carries a D101 noqa instead, so the published contract schemas and the
OpenAPI documents built from them stay byte-identical.

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

* Document the FastAPI support library for ruff D

The ping and health models and the /ping/alive route are mounted in the
executor app, so they keep their existing (OpenAPI-visible) docstrings under
noqa. The no-op observability methods keep their explicit return None under
RET501 noqa, and two stray string statements in the GCP module become the
docstrings they were meant to be.

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

* Document the simulation observability library for ruff D

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

* Document the Stage 12 persistence library for ruff D

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

* Document the simulation entrypoint for ruff D

The entry routes are nested in create_app, so their docstrings (the OpenAPI
descriptions) are untouched and the generated spec is unchanged.

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

* Document the simulation gateway for ruff D

The /ping router endpoint keeps its OpenAPI description under a D205 noqa;
the golden OpenAPI test still passes. Two placeholder pass statements in the
test fixtures' mock exception classes go now that the classes have
docstrings (PIE790).

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

* Document the simulation executor for ruff D

Covers the executor package, the Modal apps, fixtures, scripts and test
docstrings. Docstrings are added to several Modal functions; images copy
src/modal into a layer, so this changes those layers like any source edit.
Protocol stubs keep their ... bodies.

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

* Document the integration tests, repo scripts and package markers for ruff D

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

* Document the Stage 12 schema-DDL proof fixtures for ruff D

The schema-authority proof reads the fixtures as text; the new docstrings
avoid DDL phrases, so the bad fixture is still rejected and the good one
accepted.

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

* Enable ruff group 4 (docstrings)

Select pydocstyle (D) and ignore D203 and D213, the incompatible halves of
the D203/D211 and D212/D213 pairs. Tests stay exempt from D1 only.

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

* Drop redundant return None from documented no-op methods

With a docstring as the body, the bare return None lines are redundant;
remove them instead of suppressing RET501.

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

* Document published contract models and routes

Replace the 61 D101 suppressions on contract, ping and health models with
class docstrings written for API consumers, and fix the /ping/alive and
gateway /ping route docstrings instead of suppressing D205. Pydantic and
FastAPI copy these into schema and operation descriptions, so the entry,
gateway and executor OpenAPI documents gain descriptions; paths, operations,
properties, types and required lists are unchanged. The gateway golden spec
is regenerated with generate_openapi.

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

* Use the Public API's docstrings in the shared rules tool

Both repos documented scripts/rules independently for ruff D, so the
copies drifted apart. Take the Public API's wording so the tool stays
byte-identical in both repos; only docstrings differ.

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

* Register D in the ruff-lint rule

sim.quality.ruff-lint now lists D, and the rendered rules page and
AGENTS.md Rules block are regenerated for the new tool hash.

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

* Put the docstrings #767 added in the imperative mood

#767 landed on main after this stack branched. D401, which this PR
enables, wants each docstring's summary line in the imperative mood.

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

* Put the docstrings #743 and #744 added in the D style

#743 and #744 landed on main after this stack branched. D, which this PR
enables, flags their new code: blank lines after docstrings (D202), a
two-line summary (D205, D209), summaries that are not in the imperative
mood (D401), an escaped backslash in the sentinel's module docstring
(D301), and three public functions without docstrings (D103).

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

* Put the docstrings #789 added in the D style

#789 landed on main after this stack branched. D, which this PR enables,
flags blank lines after its new docstrings (D202) and the undocumented
__call__ of its ConnectionOpener protocol (D102).

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

* Document the shared object store fake #787 added

#787 landed on main after this stack branched. D, which this PR enables,
flags the undocumented __init__ (D107), upload_bytes and read_bytes (D102)
of the in-memory object store it moved into the executor's fixtures.

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

* Put the docstrings #795 added in the D style

D, which this PR enables, flags the undocumented group_label property
(D102), the budget check's run-on summary (D205, D209) and two test
helpers' summaries that are not in the imperative mood (D401).

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

* Put the docstrings #791 added in the D style

#791 landed on main after this stack branched. D, which this PR enables,
flags blank lines after five of its new docstrings (D202) and the
undocumented __init__ (D107) and stage method (D102) of its StageProgress
tracker.

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

* Put the docstrings #758 added in the D style

#758 landed on main after this stack branched. D, which this PR enables,
flags its permission checks and deployed permission test:

- CallerAuthorizer's initializer and authorize now say what enforcement
  does with a caller that lacks a permission, and that the missing
  permission is always recorded;
- the permission_enforcement fixture says when it skips and when it
  raises, and the enforced-permission deployment test says what it
  checks;
- the blank lines after the docstrings of is_client_credentials,
  granted_permissions, the gty validator and the Cloud Run
  deployment-environment test helper go.

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

* Put the docstrings #781 added in the D style

#781 landed on main after this stack branched. D, which this PR enables,
flags its job progress code:

- the JobProgressReporter protocol and each of its methods say which
  stage boundary the runtime reports; the null reporter's methods say
  what they discard, with the docstring as the body;
- StoredJobProgressReporter's initializer, record, start, set_execution,
  enter, start_segments, segment_completed and attempts say how the
  record changes, including when a call changes nothing;
- the contract's job progress store functions say what they read and
  write, and StageReportingSimulation and its ensure say when the
  callback runs;
- the floor and maximum helpers, the Modal reporter factory, the
  published-record helper and the gateway's stage-field helper are in
  the imperative mood, and blank lines after docstrings go.

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

---------

Co-authored-by: Anthony Volk <14987227+anth-volk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 16, 2026
* Fix ruff TRY, EM and BLE findings in the FastAPI library

Exception messages move into a msg variable before the raise (EM), with
the text unchanged. The JWT decoder re-raises with a bare raise (TRY201).
Its two JWKS lookup error logs stay traceback-free under a TRY400 noqa,
because callers control the token and a traceback per bad token would let
them flood the logs. The token decode and the GCP project-id probe keep
except Exception under a BLE001 noqa: any decode failure must become a 403,
and any probe failure falls back to GOOGLE_CLOUD_PROJECT.

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

* Fix ruff TRY and EM findings in the simulation contract library

Exception messages move into a msg variable before the raise (EM), with
the text unchanged; Pydantic validators keep raising ValueError, so
callers still get the same ValidationError. resolve_spm_selection and
validate_spm_result move their try bodies into private helpers so no raise
sits inside the try (TRY301, TRY300); the same ValueErrors still become
the same SPMInputError, chained from the original.

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

* Fix ruff TRY, EM and BLE findings in the simulation observability library

Exception messages move into a msg variable before the raise (EM), with
the text unchanged. log_and_redact_exception's fallback log calls
logger.exception with the same explicit exc_info, so its output is
unchanged (TRY400). Its telemetry catch-all keeps except Exception under a
BLE001 noqa, because the helper must never raise.

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

* Fix ruff EM findings in the Stage 12 persistence library

Exception messages move into a msg variable before the raise, with the
text unchanged.

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

* Fix ruff TRY, EM and BLE findings in the simulation entrypoint

Exception messages move into a msg variable before the raise (EM), with
the text unchanged. forward() returns the proxied response from an else
block (TRY300). The four Stage 12 diagnostic error logs stay
traceback-free under a TRY400 noqa: three record only the error type, so a
traceback could carry request or calculation data, and the dispatch
timeout is fully described by its timeout. The Stage 12 context capture
keeps its telemetry catch-all under a BLE001 noqa.

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

* Fix ruff TRY, EM and BLE findings in the simulation gateway

Exception messages move into a msg variable before the raise (EM), with
the text unchanged. The auth misconfiguration log keeps its message and
gains a traceback through exc_info=True (TRY400). _runtime keeps
RuntimeError and _resolve_policyengine_route keeps ValueError under a
TRY004 noqa, because handlers and callers depend on those types. The
job-status and budget-window handlers keep their catch-alls under a
BLE001 noqa: call.get re-raises whatever the worker raised, and every
failure must become a failed-job response or fall back to the seed state.
The auth-bypass event keeps its catch-all too. The golden OpenAPI spec is
unchanged.

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

* Fix ruff TRY, EM and BLE findings in the simulation executor

Exception messages move into a msg variable before the raise (EM), with
the text unchanged. Raises inside try bodies move into private helpers
(_parse_policy_period_dates, _certified_us_spm_capability,
_require_artifact_digest, _require_local_authority_column), so the same
exceptions reach the same handlers (TRY301, TRY300); dump_package_version
narrows its try to the file read.

qualify_stage12_parity, a local operator CLI that nothing calls or
catches, now raises TypeError for a JSON value that is not an object. The
other TRY004 sites keep their types under a noqa: they cross a Modal
boundary, are documented or asserted by tests, or are recorded by type
name in telemetry and Stage 12 error summaries. The Stage 12 comparison
failure log stays traceback-free under a TRY400 noqa. Worker, cleanup and
telemetry catch-alls keep except Exception under a BLE001 noqa.

The Modal images copy src/modal and policyengine_simulation_executor, so
their layers change like any source edit; src/modal/app.py gains no
future import.

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

* Fix ruff EM findings in the integration tests and repo scripts

Exception messages move into a msg variable before the raise, with the
text unchanged.

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

* Enable ruff group 5 (exceptions and messages)

Select flake8-blind-except (BLE), flake8-errmsg (EM) and tryceratops
(TRY). The preceding commits fix every finding; deliberate catch-alls,
kept exception types and traceback-free error logs carry an inline noqa
with the reason. Tests get no exemption.

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

* Give every BLE001 suppression an inline reason

Enabling BLE activated suppressions that were written before the rule
was on. Seven had no reason, or kept it only in a comment above; they now
carry it inline, and the "- reason" ones use the "  # reason" form.

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

* Name hoisted SPM error codes error_code, not msg

The EM fix moves an exception's first literal argument into a variable
called msg. SPMInputError's first argument is an error code, followed by
the message, so those 20 variables are renamed error_code. The gateway
file also moves its BLE001 suppression reason to the "  # reason" form.

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

* Register TRY, EM and BLE in the ruff-lint rule

sim.quality.ruff-lint now lists the group 5 families, and the rendered
rules page and AGENTS.md Rules block are regenerated.

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

* Name hoisted parity mismatch codes error_code, not msg

ParityMismatch takes a code and a schema path, not a message, so the 26
variables the EM fix named msg are renamed error_code.

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

* Fix the group 5 changelog line's YAML and wording

The colon after "(TRY, EM, BLE)" made YAML read the item as a mapping
rather than a string. The line also said error types were unchanged,
but two type checks in qualify_stage12_parity.py now raise TypeError.

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

* Build the exception messages #743 and #744 added before raising

#743 and #744 landed on main after this stack branched. EM and TRY003,
which this PR enables, flag 34 raises in their sentinel, routing and
package-update code that pass a literal message. Each message now moves
into a msg variable before the raise, with the text unchanged.

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

* Build the exception messages #789's tests raise before raising

PR enables, flag five raises in its new Stage 12 tests that pass a literal
message; each message now moves into a msg variable first. TRY301 flags
the raise inside the pooling test's transaction, which moves into a small
helper so the same RuntimeError still ends that transaction.

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

* Build the exception messages #795 added before raising

#795 landed on main after this stack branched. EM and TRY003, which this
PR enables, flag its two new RuntimeError raises (a child that timed out
and a spent parent budget) and the cancel failure its test fake raises;
each message now moves into a msg variable first, with the text
unchanged. BLE001 flags _cancel_call, which now holds the best-effort
cancel loop this PR suppressed; it keeps that suppression with its
reason inline.

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

* Build the exception messages #791's tests raise before raising

#791 landed on main after this stack branched. EM and TRY003, which this
PR enables, flag ten raises in its new Stage 12 failure-cause and runtime
tests that pass a literal message; each message now moves into a msg
variable first, with the text unchanged. TRY301 flags the raise inside
the try of the _raised helper, which now captures the raised error, with
its traceback, through pytest.raises; that also drops the helper's blind
except and its BLE001 suppression.

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

* Write the BLE001 suppressions #791 added with an inline reason

#791 landed on main after this stack branched. Its two new blind-except
suppressions in the Stage 12 failure-cause module gave their reasons in
the "- reason" form; like every other BLE001 suppression in this PR,
they now use the "  # reason" form, with the reasons unchanged.

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

* Build the exception messages #758 added before raising

#758 landed on main after this stack branched. EM and TRY003, which this
PR enables, flag four raises with a literal message: the deployed
permission_enforcement fixture's RuntimeError and three stand-ins in its
permission tests. Each message now moves into a msg variable first, with
the text unchanged.

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

* Write the BLE001 suppression #758 added with an inline reason

#758 landed on main after this stack branched. The blind except around
its simulation_entry_permission_missing event gave its reason in the
"- reason" form; like every other BLE001 suppression in this PR, it now
uses the "  # reason" form, with the reason unchanged.

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

* Build the exception messages #781 added before raising

#781 landed on main after this stack branched. EM and TRY003, which this
PR enables, flag nine raises with a literal message: the contract's
segment-count validator and eight stand-ins in its executor and gateway
job progress tests. Each message now moves into a msg variable first,
with the text unchanged.

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

* Write the BLE001 suppressions #781 added with an inline reason

#781 landed on main after this stack branched. Its five new blind-except
suppressions, in the Modal app's reporter and stage-duration helpers, the
stored reporter's read and write, and the gateway's stage-field read,
gave their reasons in the "- reason" form; like every other BLE001
suppression in this PR, they now use the "  # reason" form, with the
reasons unchanged.

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

---------

Co-authored-by: Anthony Volk <14987227+anth-volk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 16, 2026
…Z, ERA, TD, FIX, EXE) (#785)

* Fix ruff LOG and G findings

Pass logging arguments instead of f-strings (G004); each message renders
to the same text. Name the economy-comparison router's logger after its
module rather than its file path (LOG002). Log the gateway's auth
misconfiguration with logger.exception and a fixed message (G201): the
traceback already ends with the exception and its message, which the old
call also repeated in the message.

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

* Keep naive policy dates explicit for ruff DTZ

policyengine.py parses policy period keys with strptime and no zone, so
its ParameterValue dates are naive, and the executor's period parsing and
the tests that compare against those dates must stay naive too. Mark each
kept naive datetime with a reasoned DTZ suppression, and route the policy
tests' expected dates through one helper.

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

* Replace asserts outside tests for ruff S101

The deployed-service test suite in authenticated_tests is a pytest suite
that the tests glob misses, so give it the same test exemptions.

Elsewhere, drop the asserts that only narrowed types: the SPM selection
check now returns the hash and scenario it has already proved present,
and the qualification runner closes over a non-optional runtime. The
gateway image smoke raises RuntimeError when its report is incomplete, as
the executor's static-file smoke does, and the fake model output raises
AssertionError explicitly when the adapter asks for a mode other than
JSON.

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

* Keep command-line output for ruff T20

Every print the rule finds belongs to a command-line script or a Modal
local entrypoint, whose stdout is its output, so keep each print. Files
with one to three prints mark each with a reasoned suppression; the
routing-state publisher and the policyengine package updater send their
output through one small helper that holds the only print.

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

* Route test subprocess calls through helpers for ruff S603 and S607

Each test module that runs repository scripts now does so through one
helper that holds the only subprocess call, with reasoned suppressions:
the scripts are repository-owned, their arguments are built by the tests,
and bash and uv come from PATH as they do in the workflows. Resolving the
executables in Python instead could pick a different binary, because
subprocess searches the child's PATH, and some tests run scripts with an
empty environment.

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

* Fix the remaining ruff S findings

Build the GCP metadata request inline from its constant http URL, with
the same Metadata-Flavor header, so S310 can see the scheme. Keep every
other finding with a reasoned suppression:

- S105/S106: fake tokens in tests (one module constant per test module
  where a value repeats), and names or fingerprints that only look like
  secrets.
- S108: the executor's fixed data directories inside the Modal container,
  and a lookup path the tests' fakes only pass along.
- S110: add S110 to the existing reasoned BLE001 suppressions.
- S102: the image tests execute repository-owned app source as Modal's
  /root/app.py.
- S301: the SPM tests round-trip errors they built or raised.
- S310: the Hub API request URL is built from the HF_ENDPOINT base and
  quoted path parts.

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

* Enable ruff group 6 (security, logging and debugging leftovers)

Select DTZ, ERA, EXE, FIX, G, LOG, S, T20 and TD. The earlier commits on
this branch fixed or suppressed, with a reason, every finding outside the
shared scripts/rules tool.

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

* Register group 6 and the deployed-test ruff exemption

sim.quality.ruff-lint now lists DTZ, ERA, EXE, FIX, G, LOG, S, T20 and
TD. The authenticated_tests exemption gets its own rule, since a ruff
per-file-ignore rule names one pattern.

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

* Sync the rules tool from the Public API's group 6

The shared scripts/rules tool takes the Public API's group 6 fixes:
explicit checks instead of asserts, and reasoned suppressions for its
git and shellcheck subprocess calls, prints and calendar dates. The
rendered rules page picks up the tool's new hash.

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

* Fix the ruff group 6 findings in the code #743 and #744 added

#743 and #744 landed on main after this stack branched. Group 6, which
this PR enables, flags their new code; each fix follows this PR's
conventions:

- T201: the routing publisher's new commands report through its _report
  helper, the package updater's dispatch check through _write_result, and
  the sentinel CLI gets one _report helper that holds its only print.
- S603/S607: the deployment-asset tests route #744's new bash calls
  through _run_bash, which now takes cwd; the rollback tests and the
  package-update helper tests get one helper each that holds the only
  subprocess call, with reasoned suppressions.
- S310: the sentinel's HTTP helper opens the deployed entrypoint or the
  test auth issuer URL that the workflow passes; reasoned suppressions.
- S106: a fake bearer token in the sentinel tests.

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

* Add S110 to the cancel suppression #795 added

#795 landed on main after this stack branched. S110, which this PR
enables, flags the try-except-pass in its _cancel_call, which now holds
the best-effort cancel loop this PR suppressed; like the other reasoned
BLE001 suppressions, it gains S110.

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

* Fix the ruff group 6 findings in the code #791 added

#791 landed on main after this stack branched. S105, which this PR
enables, flags two values that only look like secrets, and each keeps a
reasoned suppression: the redaction pattern for secret-looking key names
in the Stage 12 failure-cause module, and the fake database password its
tests check redaction removes.

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

* Fix the ruff group 6 findings in the code #758 added

#758 landed on main after this stack branched. S603, which this PR
enables, flags the two new deployment tests that run the Cloud Run deploy
script directly to check permission enforcement defaults and rejections.
They carry the same reasoned suppression as the existing direct run of
that script.

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

* Fix the ruff group 6 findings in the code #781 added

#781 landed on main after this stack branched. Group 6, which this PR
enables, flags two of its additions:

- S110: the Modal app's stage-duration telemetry swallows a failed
  set_context, so its suppression adds S110 beside BLE001, as the call
  attributes helper above it does;
- DTZ001: the contract test that the job record rejects a naive time
  builds that naive time on purpose, so it carries a reasoned
  suppression.

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

* Allow file-level ruff exceptions only in tests, CI/CD and command-line scripts

A ruff per-file-ignores entry switches rules off for whole files. That is
now acceptable where it's the norm: tests, CI/CD scripts under .github,
and command-line scripts (under a scripts directory, or modules run
through if __name__ == "__main__"). Everywhere else a kept finding still
needs an inline suppression with its reason.

The rules guard already requires a per-file-ignore rule for every entry.
It now also expands each entry's pattern the way ruff does (globset
syntax, and a slash-less pattern also matches file names) and fails when
the pattern covers any other file, is negated, or matches nothing.
scripts/rules/file_exceptions.py holds the definitions, and the registry
doc describes the policy.

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

* Move group 6's test, CI and script suppressions to file-level exceptions

Tests, CI/CD scripts and command-line scripts now take their deliberate
group 6 exceptions as registered per-file-ignores, each code chosen from
the suppressions those files already carried:

- tests and the deployed-service tests: S102, S105, S106, S108, S301,
  S603, S607, DTZ001 and DTZ007, added to their existing exemptions;
- .github: T201;
- scripts directories: DTZ011, S603, S607 and T201;
- programs under src (the Modal deployment utilities, and the OpenAPI
  and Stage 12 infrastructure commands): S310 and T201.

That removes 75 inline codes from 44 files. Application code keeps its
inline suppressions and reasons. Comments only: no code changes.

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

---------

Co-authored-by: Anthony Volk <14987227+anth-volk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 16, 2026
…#799)

* Exempt tests from SLF001, INP001 and PLC0415

Tests deliberately reach into private members, pytest test directories
aren't packages, and tests often import inside a test after patching the
environment. Application code still gets every rule.

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

* Drop response_model arguments that repeat the return type (ruff FAST001)

FastAPI takes the response model from the return annotation when
response_model is omitted, so the generated OpenAPI documents are unchanged.

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

* Fix ruff naming and builtin-shadowing findings (N, A, PLC0414, SLF001)

- Alias the shared exit registry as app_exit where it is imported, and keep
  the policyengine_fastapi.exit.exit name that projects import.
- Use snake_case for the OpenTelemetry provider and log-handler locals.
- Add the Error suffix to exceptions that never leave their project:
  BackendUnavailableError, BackendTimeoutError,
  TemporaryStage12UnsupportedRequestError and ParityMismatchError.
  TemporaryStage12DispatchFailed keeps its name, which the entry app logs
  as error_type.
- Keep the camelCase budget-window fields, which are published JSON, the
  explicit re-exports in stage12_execution, and the two deliberate private
  accesses, each with a reason.

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

* Resolve ruff INP001 per directory

Declare the script directories (.github/scripts, scripts and the executor's
scripts) and the rules proof fixtures as namespace packages in ruff.toml.
Ruff's full output, with every rule selected, is otherwise unchanged by the
setting.

The executor's src/modal/utils scripts keep an inline suppression instead:
declaring that directory, or adding an __init__.py, makes ruff treat it as
part of a first-party "modal" package and regroup its Modal SDK imports.
An __init__.py would also change the src.modal source baked into the Modal
images.

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

* Keep deliberate deferred imports in the shared library and CI script (ruff PLC0415)

Each deferred import keeps an inline reason: the GCP exporters, logging
instrumentation and metadata probe load only when used, and only the
bundle-versions command runs where policyengine is installed.

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

* Import the Stage 12 backend at the top of the entry app (ruff PLC0415)

app.py already imports stage12_backend at module level for its exception
types, so binding Stage12ComparisonBackend there too loads nothing new.

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

* Resolve ruff PLC0415 in the gateway

Bind SPMSelection in endpoints.py's existing policyengine_simulation_contract.spm
import. Keep the Modal function body's imports, which build the web app in
its container, and the smoke app's in-image imports, each with a reason.

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

* Resolve ruff PLC0415 in the executor

Move only imports that load nothing new and that no test patches:
pathlib and importlib, the policyengine_simulation_contract helpers, names
from a module the file already imports at the top, and RegionGroupStrategy,
which policyengine.core already loads.

Every other deferred import keeps an inline reason: Modal function bodies and
the image-build and smoke functions, lazily loaded policyengine models and
heavy libraries, call-time resolution that the tests' patch seams rely on,
and import cycles in the runtime.

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

* Wrap long lines in the shared libraries (ruff E501)

Split long messages and the GCP log format with implicit string
concatenation, so every string is unchanged, and rewrap two docstrings that
no published schema uses.

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

* Wrap long generated-client calls in the integration tests (ruff E501)

Bind the long generated endpoint functions to shorter local names before
calling them.

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

* Wrap long lines in the entry project (ruff E501)

Split long strings with implicit concatenation, so every value is unchanged.
The fake curl and gcloud scripts keep their single-line printf output with a
suppression on the string.

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

* Wrap long lines in the executor (ruff E501)

Split long messages and test strings with implicit concatenation, so every
value is unchanged, and shorten docstrings that no published schema uses.
The fake gh script keeps its single-line JSON output with a suppression on
the string.

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

* Wrap long lines in the gateway (ruff E501)

Split the Modal app's FastAPI description with implicit concatenation, so
the published text is unchanged, and shorten four test names.

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

* Wrap the Stage 12 DDL proof fixtures' docstrings (ruff E501)

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

* Enable ruff group 7 (structure and imports)

Select A, E, FAST, INP, N, PLC and SLF. Every finding outside the shared
scripts/rules tool is fixed or carries an inline reason; the rules tool's
findings are fixed upstream and synced separately.

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

* Register group 7 in the ruff-lint rule

sim.quality.ruff-lint now lists A, E, FAST, INP, N, PLC and SLF.

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

* Sync the rules tool from the Public API's group 7

The shared scripts/rules tool takes the Public API's group 7 fixes:
wrapped long lines, BaseUnavailableError, and assert_violation in its
tests. The rendered rules page picks up the tool's new hash.

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

* Fix the ruff group 7 findings in the code #743 and #744 added

#743 and #744 landed on main after this stack branched. Group 7, which
this PR enables, flags their new code; each fix follows this PR's
conventions:

- E501: wrap the long strings in their routing, sentinel, gateway and
  test code; every message and expected value reads the same.
- N818: RoutingConflict never leaves the executor, so it becomes
  RoutingConflictError, as this PR renames the other in-project errors.
- INP001: the sentinel script in src/modal/utils keeps the inline reason
  the other scripts there carry.
- PLC0415: the sentinel's deferred contract and runtime imports and the
  package updater's optional receipt import keep inline reasons.

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

* Keep the long Stage 12 test name #789 added under E501

#789 landed on main after this stack branched. E501, which this PR
enables, flags the signature line of its lost-commit coordinator test,
whose name cannot be wrapped; the line keeps a reasoned suppression
rather than a shorter, vaguer name.

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

* Fix the ruff group 7 findings in the code #791 added

#791 landed on main after this stack branched. E501, which this PR
enables, flags three long string literals in its Stage 12 failure-cause
tests; each is wrapped by implicit concatenation, with its value
unchanged. N818 flags Stage12FailureCause, whose name telemetry records
as the error type of every recorded cause, so it keeps its name under a
reasoned suppression, like TemporaryStage12DispatchFailed.

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

* Fix the ruff group 7 findings in the code #758 added

#758 landed on main after this stack branched. FAST002, which this PR
enables, flags the six entry routes that take the caller's identity as
a "caller: CallerIdentity | None = Depends(...)" parameter. FastAPI's
Annotated form can't be used: this module postpones annotations, and
FastAPI resolves them against the module's globals, where the per-app
permission dependency doesn't exist. No handler reads the parameter.

Each route now declares its permission dependency in the decorator's
dependencies, as the gateway's routes declare require_auth and as these
routes declared authentication before #758. FastAPI still runs the same
dependency before the body is read, so each route checks the same
permission, logs or rejects a missing one the same way, and the OpenAPI
document is unchanged. The CallerIdentity import is no longer used.

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

* Fix the ruff group 7 findings in the code #781 added

#781 landed on main after this stack branched. PLC0415, which this PR
enables, flags four of its deferred imports. As for the executor's other
deferred imports, only an import that loads nothing new and that no test
patches moves to the top:

- the Modal app's NULL_JOB_PROGRESS and StoredJobProgressReporter, whose
  module the app's top-level imports already load, move to the top;
- the job_progress_state store functions stay deferred, resolved per
  call so the tests can patch job_progress_state;
- StageReportingSimulation stays deferred in _build_simulation, resolved
  per call like its neighbours so the tests can patch it;
- the bundle-metadata builder's JOB_PROGRESS_CAPABILITY_VERSION stays
  deferred: the contract package, and pydantic with it, loads only when
  bundle metadata is built.

Each kept import carries its reason inline.

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

* List the lazily loaded packages for ruff instead of suppressing each import

Fourteen heavy or optional packages and modules are only ever imported
inside the function that needs them: the policyengine bundle, countries,
provenance and tax-benefit-model modules, policyengine_us, spm_calculator,
h5py, google.cloud, three OpenTelemetry exporters and instrumentations,
pythonjsonlogger, and the executor's spm and baseline_artifacts modules.
No application module imports any of them at module level.

ruff.toml now lists them in banned-module-level-imports and selects
TID253, so importing one at module level fails (TYPE_CHECKING imports are
still fine), and PLC0415 accepts their in-function imports without a
suppression. That removes 51 PLC0415 suppressions. Tests may still import
them at module level (TID253 joins the test exemptions).

Packages that some application module does import at module level
(pandas, microdf, huggingface_hub, policyengine.core and others) aren't
listed, so their deferred imports keep their reasons.

The nine Modal utility programs, run with python -m from a directory that
isn't a package, take INP001 in their existing file-level entry instead
of one suppression each.

Comments and configuration only: no code changes.

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

---------

Co-authored-by: Anthony Volk <14987227+anth-volk@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Stage 12A: Check Auth0 permissions on Simulation Entrypoint routes

1 participant