feat(chassis): SDK-native chassis behind L9_CHASSIS + W4-04 audit pool wiring - #150
Open
cryptoxdog wants to merge 2 commits into
Open
feat(chassis): SDK-native chassis behind L9_CHASSIS + W4-04 audit pool wiring#150cryptoxdog wants to merge 2 commits into
cryptoxdog wants to merge 2 commits into
Conversation
… pool Two changes that cannot be split: the SDK chassis consumes the same engine.handlers surface and the same GraphLifecycle that W4-04 modifies. SDK-native chassis (dormant by default) - chassis/entrypoint.py: single uvicorn target dispatching on L9_CHASSIS (legacy -> chassis_app.create_app, sdk -> node_app.create_app). Every launch site (Makefile, Dockerfile.prod, scripts/entrypoint.sh, compose) now points here, so switching chassis is config, not a command change. - chassis/node_app.py: builds the app via constellation-node-sdk create_node_app. SdkLifecycleAdapter bridges engine.boot.GraphLifecycle (legacy LifecycleHook) onto the SDK's unrelated LifecycleHook ABC, which leaves engine/boot.py free of SDK imports during dual-run. - chassis/handler_registration.py: registers ACTION_HANDLERS with the SDK registry, wrapping each with the PacketEnvelope audit side effect that chassis/actions.py applies on the legacy path. - engine/handlers.py now exports ACTION_HANDLERS as the single action registry; chassis/actions.py consumes it instead of a hand-maintained dict, so the two chassis cannot drift. test_chassis_parity.py locks that. W4-04 Postgres audit pool - The ComplianceEngine consumer side is already on main; this adds the missing wiring. GraphLifecycle.startup creates an asyncpg pool when POSTGRES_DSN is set and passes it through init_dependencies to EngineState.db_pool; shutdown closes it. Soft dependency: an unset or unreachable DSN leaves db_pool None and logs a warning rather than blocking startup, matching the existing Neo4j degrade path. - docker-compose gains a postgres service seeded from packet_store.sql. Chassis consolidation - Deletes chassis/app.py and chassis/auth/app.py, which duplicated chassis/chassis_app.py. All imports and launch sites repointed. Settings - Under pytest, env_file is None so a developer's local .env cannot leak opt-in flags into the suite. Verified: 1667 passed / 15 skipped / 56 xfailed, ruff clean, contract scanner clean. mypy reports one pre-existing syntax error on main. L9_META headers are left at main's schema v1 so this does not collide with the schema v2 stamp in #147. Co-authored-by: Cursor <[email protected]>
|
❌ PR Too Large 📋 Best Practices for Large Changes
🚫 This PR is blocked until reviewable size limits are met. |
3 tasks
ACTION_HANDLERS is now the single action->handler map for both chassis; CONTRACT-02 and the compliance workflow comment still described the pre-rename chassis/app.py layout.
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v7 | ||
| uses: actions/setup-python@v5 |
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.




Why one PR
These two bodies of work share
engine/handlers.pyandengine/boot.py. The SDK chassis wraps the sameGraphLifecyclethat W4-04 modifies, and both depend on the newACTION_HANDLERSregistry. Splitting them would mean shipping a broken intermediate state or resolving the same conflict twice.1. SDK-native chassis — dormant by default
L9_CHASSIS=legacy(the default) preserves today's behavior exactly.L9_CHASSIS=sdkselects the new path.chassis/entrypoint.pyL9_CHASSISchassis/node_app.pyconstellation-node-sdkcreate_node_appchassis/handler_registration.pyACTION_HANDLERSwith the SDK registry + packet audit wrapperSdkLifecycleAdapterbridgesengine.boot.GraphLifecycle(which subclasses the legacyLifecycleHook) onto the SDK's unrelatedLifecycleHookABC. Keeping the adapter inchassis/meansengine/boot.pystays free of SDK imports while both chassis run in parallel.Every launch site now points at
chassis.entrypoint:create_app— Makefile,Dockerfile.prod,scripts/entrypoint.sh,docker-compose.yml— so switching chassis is a config change, not a command change.Single action registry
engine/handlers.pynow exportsACTION_HANDLERS.chassis/actions.pyconsumes it instead of maintaining its own dict, so the legacy and SDK chassis cannot expose different action sets.tests/contracts/test_chassis_parity.pyfails if a future edit reintroduces a hand-maintained list in either one.2. W4-04 Postgres audit pool
The
ComplianceEngineconsumer side is already onmain; only the wiring was missing.GraphLifecycle.startup()creates anasyncpgpool whenPOSTGRES_DSNis set and passes it throughinit_dependencies()toEngineState.db_pool.shutdown()closes it.This is a soft dependency: an unset or unreachable DSN leaves
db_poolasNoneand logs a warning rather than blocking startup — the same graceful-degrade pattern as the existing Neo4j connection.EngineState.health_check()reportsdb_pool_present.docker-compose.ymlgains apostgres:16-alpineservice seeded fromengine/packet/packet_store.sql.3. Chassis consolidation
Deletes
chassis/app.py(371 lines) andchassis/auth/app.py(208 lines), which duplicatedchassis/chassis_app.py. All imports and launch sites repointed. This clears thechassis/auth/app.pyitem inmemory-bank/tech-debt.md.4. Hermetic settings under pytest
engine/config/settings.pysetsenv_file=Nonewhenpytestis insys.modules, so a developer's local.envcannot leak opt-in feature flags into the test suite.Verification
mypy engine/reports one error (engine/inference_rule_registry.py:462syntax) that reproduces on cleanorigin/main— pre-existing, not introduced here.Deliberately out of scope
main's schema v1 so this does not collide with the schema v2 stamp in feat(meta): config-driven L9_META pipeline, schema v2, full-repo stamp #147.chassis/app.py(docs/contracts/api/openapi.yaml,DEPENDENCY_INJECTION.md,config/env-contract.yaml) are owned by docs(contracts): align the YAML registry and the prose docs into one registry #146 — left untouched to avoid conflicts.tools/l9_meta_injector.pystill lists the two deleted files in its registry; feat(meta): config-driven L9_META pipeline, schema v2, full-repo stamp #147 replaces that module wholesale.gitinstall fromfix/docker-git-deps-and-proprietary-licenseare not included.Made with Cursor