Skip to content

feat(backend): main.py mounts routers through the OMI_ROLE role map (B8) - #22470

Merged
Git-on-my-level merged 7 commits into
integration/legacy-retirefrom
lr/07-role-mount
Oct 19, 2026
Merged

Git-on-my-level merged 7 commits into
integration/legacy-retirefrom
lr/07-role-mount

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Lane 7 (legacy-retire swarm), B8 step 2: main.py mounts routers through the OMI_ROLE role map. Targets integration/legacy-retire. Unblocked by #22388 reaching integration (6471cea).

What

  • backend/main.py: the 110-line app.include_router block becomes mount_routers(app, role_from_env(), include_harness=is_chat_first_e2e_harness_runtime()).
  • .github/scripts/check_duplicate_routes.py: resolves role-map mounts for an entrypoint that calls mount_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.
  • Tests:
    • census adds router-import == role-map equality, plus a check that the duplicate-route checker still resolves main's routes;
    • test_api_key_route_contract / test_support_harness assert role-map membership instead of include_router text.
  • Lane 1's mount PR for enrichment / batch_provider_stt becomes two Mount(enrichment, ...) / Mount(batch_provider_stt, ...) rows plus their imports, all in app_roles.py (roles per contract (a)), plus removing them from STUB_ROUTERS_PENDING_MOUNT. main.py is untouched. No include_router lines.

Nothing sets OMI_ROLE yet. B9 (workers on 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

  • INV-DATA-1: matched by path only if the preflight selects it. No routing authority, project or data plane changes; the served route table is identical.

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 import main and 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_roles stays as an unused table).

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Git-on-my-level and others added 3 commits October 19, 2026 16:22
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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T12:42:28.362038Z f87303e New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Git-on-my-level and others added 4 commits October 19, 2026 17:21
…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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 722f3cf into integration/legacy-retire Oct 19, 2026
23 checks passed
@Git-on-my-level
Git-on-my-level deleted the lr/07-role-mount branch October 19, 2026 12:56
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…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]>
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
…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]>
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.

1 participant