Repository navigation
feat(backend): main.py mounts routers through the OMI_ROLE role map (B8) - #22470
Conversation
main.py's 110-line include block becomes one mount_routers(app, role, globals()) call; app_roles.ROUTER_MOUNTS is the route table (same order, default role all, so behaviour-neutral). Router imports stay static for the image closure and import-time checks. An unknown OMI_ROLE fails startup. check_duplicate_routes.py resolves role-map mounts so it does not silently pass on an empty main app (it still reports the one load-bearing duplicate). The census test adds router-import == role-map equality; the api-key and support harness tests assert role-map membership instead of include_router text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n main.py) Mount rows hold router modules directly, so app_roles imports every router once (static, same order, after main.py's env/credential setup) and main.py imports only the mount entrypoint plus messaging. Typecheck: 0 errors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y (fast-unit guard) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…cturally main.py mounts through the B8 role map, so client_telemetry and memory_product registration is asserted as an AST Mount(...) row in app_roles.py (an import would load every router, too slow for the fast-unit guard). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… m5 fast-unit CPU limit test_product_memory_router.py::test_product_search_endpoint_keeps_expired_unadjudicated_short_term_and_excludes_archive is unchanged by this branch. On m5 it measured 0.37-0.47s CPU against the 0.30s fast-unit fail limit (load average 35-50), including 0.37s for the unchanged integration version of the file, so it sits at the limit rather than having regressed. The local pre-push gate selects the file only because the router registration test in it moved to the B8 role map. CI still runs the test; the allowlist is the documented exception mechanism (approved by the lead). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lr/07-role-mount # Conflicts: # backend/tests/fast_unit_duration_allowlist.txt
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f87303ed67
ℹ️ 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".
| assert "app.include_router(client_telemetry.router)" in text | ||
| # main.py mounts through the B8 role map; read its ROUTER_MOUNTS rows structurally (AST, not an | ||
| # import: importing app_roles loads every router, too slow for a fast unit test). | ||
| import ast |
There was a problem hiding this comment.
Move the new imports to module scope
Move this ast import, along with the newly added function-local imports in test_product_memory_router.py and test_app_roles_route_census.py, to the tops of their modules. The backend import contract explicitly forbids imports inside functions, so these additions violate the repository convention even though the imported modules are standard-library modules.
AGENTS.md reference: backend/AGENTS.md:L161-L163
Useful? React with 👍 / 👎.
…e map; run store conformance (#22498) On top of lane 7's role map (#22470), main.py is unchanged: - app_roles.py: Mount(enrichment) and Mount(batch_provider_stt) on API_WORKERS (contract (a) phase 1: the consumer routes mount on every serving role; lane 9's C4 sweep needs the API role too). - test_app_roles_route_census.py: nothing is pending mount any more. - route_policy_manifest.yaml: reviewed policy for /v2/enrichment/run and /v2/batch-pipeline/provider-stt/run (service_oidc Cloud Tasks targets, like recover-quarantine). - run-emulator-proofs.sh: lane 12's job-store conformance suite (sim + emulator legs). Supersedes #22463 (main.py-shaped mount). Verified: test_app_roles_route_census + test_enrichment_route + test_batch_provider_stt 102 passed; check_duplicate_routes ok (891); check_route_policy_baseline current. Co-authored-by: Claude Opus 5.5 <[email protected]>
…tore; jsonb codec (#22488) * feat(jobstore): A0/A1 Postgres doc-mode Store, migrations, three-backend Store conformance Adds database/jobstore (connection pool capped at 4, expand-only versioned migrations with checksum + advisory lock, PostgresStore over the batch Store protocol, SERIALIZABLE with bounded retry), testing/store_fixtures.py (the store_backend fixture over sim, Firestore emulator and Postgres, local PG16 on a private unix socket) and tests/integration/test_store_conformance.py. Postgres in CI needs an unnamed .github change (S6), so the postgres parameter skips in GitHub CI and is proven locally. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(jobstore): wire package imports so the dead-code ratchet sees the modules reachable Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(jobstore): public transaction helpers, typed fixture cleanup Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * test(pipeline-sim): SimStore matches FirestoreStore on ready_predecessor, validation, conversation writes and projection scan Closes the four gaps the Store conformance suite had strict-xfailed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(jobstore): Postgres Outbox (contract b) and outbox conformance suite on sim, Postgres and emulator The outbox owns wake creation (defer, not-due claim_key -> DEFERRED), wake(row_id, wake_token) is idempotent, wake_pending (migration 0003) makes a failed task create sweep-retryable. The emulator leg skips until lane 9's Firestore outbox is wired into build_outbox_backend. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(jobstore): rename sweep work list (deferred-work marker lint) Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(jobstore): psycopg is not in the lockfile yet; scope the pyright ignore to its imports Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * chore(jobstore): keep the psycopg pyright ignores on the import line Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(jobstore): emulator leg of the outbox suite, IAM-auth private-IP connector and operator entry Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * test(jobstore): OMI_TEST_POSTGRES_IAM runs the conformance suite against Cloud SQL with IAM auth Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * test(jobstore): hermetic guard allows the metadata server and the PG endpoint only under OMI_TEST_POSTGRES_IAM Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(jobstore): A1 gate, the pipeline goldens are byte-identical on PostgresStore; jsonb codec for datetime and bytes PgSimStore runs the simulator through the real PostgresStore. The first run found that batch documents carry datetime values jsonb could not store; the codec tags and restores datetime and bytes. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * feat(backend): main.py mounts routers through the OMI_ROLE role map (B8) (#22470) * feat(backend): main.py mounts routers through the OMI_ROLE role map (B8) main.py's 110-line include block becomes one mount_routers(app, role, globals()) call; app_roles.ROUTER_MOUNTS is the route table (same order, default role all, so behaviour-neutral). Router imports stay static for the image closure and import-time checks. An unknown OMI_ROLE fails startup. check_duplicate_routes.py resolves role-map mounts so it does not silently pass on an empty main app (it still reports the one load-bearing duplicate). The census test adds router-import == role-map equality; the api-key and support harness tests assert role-map membership instead of include_router text. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(backend): the role map owns the router imports (pyright-clean main.py) Mount rows hold router modules directly, so app_roles imports every router once (static, same order, after main.py's env/credential setup) and main.py imports only the mount entrypoint plus messaging. Typecheck: 0 errors. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): role-map membership checks read app_roles.py statically (fast-unit guard) Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): router registration tests read ROUTER_MOUNTS rows structurally main.py mounts through the B8 role map, so client_telemetry and memory_product registration is asserted as an AST Mount(...) row in app_roles.py (an import would load every router, too slow for the fast-unit guard). Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(backend): allowlist the product-search endpoint test against the m5 fast-unit CPU limit test_product_memory_router.py::test_product_search_endpoint_keeps_expired_unadjudicated_short_term_and_excludes_archive is unchanged by this branch. On m5 it measured 0.37-0.47s CPU against the 0.30s fast-unit fail limit (load average 35-50), including 0.37s for the unchanged integration version of the file, so it sits at the limit rather than having regressed. The local pre-push gate selects the file only because the router registration test in it moved to the B8 role map. CI still runs the test; the allowlist is the documented exception mechanism (approved by the lead). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> * chore(jobstore): drop the iam_connector the integration merge duplicated; Pool alone applies the jsonb codec Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Lane 7 (legacy-retire swarm), B8 step 2: main.py mounts routers through the
OMI_ROLErole map. Targetsintegration/legacy-retire. Unblocked by #22388 reaching integration (6471cea).What
backend/main.py: the 110-lineapp.include_routerblock becomesmount_routers(app, role_from_env(), include_harness=is_chat_first_e2e_harness_runtime()).app_roles.ROUTER_MOUNTS(from feat(deploy): lane 7 slice 1: ops file + config-train (B4), prod-train lock (B5), worker digest promotion, OMI_ROLE map (B8) #22430) is the route table: same order, and the default roleallmounts every router, so this is behaviour-neutral.Mountrows hold the router modules, andapp_rolesowns the static router imports. main.py imports it at the position its own router imports had, after env and credential setup, so import order is unchanged.runtime_image_contracts.py check: pass) and pyright (0 errors) still see every router.OMI_ROLEfails startup..github/scripts/check_duplicate_routes.py: resolves role-map mounts for an entrypoint that callsmount_routers. Without this it would silently pass on an empty main app. Still 889 (app, method, path) combinations, and it still reports the one load-bearing duplicate.test_api_key_route_contract/test_support_harnessassert role-map membership instead ofinclude_routertext.enrichment/batch_provider_sttbecomes twoMount(enrichment, ...)/Mount(batch_provider_stt, ...)rows plus their imports, all inapp_roles.py(roles per contract (a)), plus removing them fromSTUB_ROUTERS_PENDING_MOUNT. main.py is untouched. Noinclude_routerlines.Nothing sets
OMI_ROLEyet. B9 (workerson backend-integration) is rehearsed on staging first, gated on a route census.Failure-Class: none
(This PR's commit is a feat; the local preflight measures from main, so it also sees integration's fix commits, which carry their own declarations.)
Product invariants affected
Verification
pytest test_app_roles_route_census test_api_key_route_contract test_support_harness test_parakeet_endpoints test_stale_processing_periodic_scheduling: 146 passed, 2 skipped. Two of these importmainand build the real app.check_duplicate_routes.py: 889 combinations, the known duplicate still reported.test_check_duplicate_routes.py: OK.Rollback
Revert this PR (restores the include block;
app_rolesstays as an unused table).🤖 Generated with Claude Code