Maintainability: production safety gate, API response models, security rationale, PR template#12
Open
amar-python wants to merge 1 commit into
Open
Conversation
…ity rationale, PR template
- config.py: add ALLOW_SCHEMA_AUTO_CREATE flag with a fail-fast validator
that refuses to start when APP_ENV=production and auto-create is enabled;
main.py gates Base.metadata.create_all behind the flag
- Add Pydantic response_model to all remaining endpoints: /, /api/health,
/api/dashboard, /api/migrations/{id}/execute, /api/migrations/{id}/evaluate,
/api/reports/{id}/generate (also stops leaking the internal report path)
- New schemas: RootResponse, HealthResponse; remove unused import in reports route
- docs/security/Rationale.md: document all nosec/noqa suppressions with
technical justification + template for future entries
- .github/pull_request_template.md: checklist incl. Tests Added and
Verified Workflow Paths
- tests: backend/tests/test_config_safety.py (7 tests) covering the
production safety gate
2 tasks
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.
Summary
Third of three code-quality PRs (see #10 CI stability, #11 data integrity). This one focuses on maintainability and operational safety.
7. Production safety gate
backend/config.py: newALLOW_SCHEMA_AUTO_CREATEflag (defaulttruefor dev) with a pydanticmodel_validatorthat fails startup whenAPP_ENV=productionand the flag is enabled — production schema changes must go through explicit migrations, nevercreate_all. Gate is case/whitespace-insensitive.backend/main.py:Base.metadata.create_allon startup is now gated behind the flag.backend/tests/test_config_safety.py(7 tests) — production+enabled raises, production+disabled OK, dev/staging unaffected, env-var coercion honoured.8. Pydantic
response_modelon all remaining endpoints/→ newRootResponse;/api/health→ newHealthResponse/api/dashboard→ existingDashboardStats/api/migrations/{id}/execute→MigrationExecuteResponse;/{id}/evaluate→EvaluationResponse/api/reports/{id}/generate→ReportResponse— this also stops leaking the server filesystempathto clients (frontend only consumesdownload_url; verified via smoke test).execution_serviceimport in the reports route (flake8 F401).9.
docs/security/Rationale.mdDocuments every
# nosec/# noqasuppression with the rule suppressed, technical justification, and accepted residual risk:backend/database/connection.py:54(noqa: BLE001— health check must never raise)backend/migration/evals/runner.py:309(nosec B608— table name from hardcoded_DEV_SEED_TABLESallowlist)backend/migration/evals/runner.py:642(noqa: BLE001— eval loop isolation)Includes a mandatory template for future suppressions.
10.
.github/pull_request_template.mdChecklist-driven PR template including Tests Added and Verified Workflow Paths sections, plus safety/security and API/data checks. Note: it references
tools/verify_workflow_paths.py(added in #10) and theRunStatuslifecycle (added in #11) — merge those first for the links to resolve.Verification
pytest backend/tests/→ 45 passed (38 baseline + 7 new)TestClient:/,/api/health,/api/dashboard,/api/reports/{id}/generateall 200 with the declared shapes; report response contains nopathkey.Checklist
test_config_safety.py; full suite greendocs/security/Rationale.md