Add startup readiness checks and authenticated tenant readiness endpoint#434
Open
Add startup readiness checks and authenticated tenant readiness endpoint#434
Conversation
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.
Motivation
init_database()as the sole readiness signal so startup validates filesystem and tenant DBs in multi-tenant mode.Description
backend/services/startup_health.pythat verifies the workspace root exists and is writable, validates DB open/create for single-tenant or a tenant (or synthetic) path in multi-tenant, and performs required schema/table+column compatibility checks for baseline migrations using_REQUIRED_SCHEMA(e.g.,onboarding_sessions,daily_workflow_plans).init_database()as the primary readiness signal in bothbackend/main.pyandbackend/app.pyby callingrun_startup_health_routine()during application startup and logging errors explicitly, and re-raising to enable fail-fast behavior when configured.GET /health/readiness(in both entrypoints) that returns the latest startup report viaget_startup_status()and a per-tenant auth-context check viareadiness_under_auth_context()which resolves the tenant DB path and attempts a session/query.docs/STARTUP_READINESS_BEHAVIOR.mddescribing single-tenant vs multi-tenant expectations, warning vs failure conditions, and theALWRITY_FAIL_FAST_STARTUP/ production default semantics.Testing
python -m py_compile backend/services/startup_health.py backend/main.py backend/app.pywhich succeeded.run_startup_health_routine()which exercised DB initialization paths and reported afailedstatus in this environment due to the workspace root not existing (this is environment-dependent and expected in a clean test container); the routine logged errors and warnings as designed.run_startup_health_routine().Codex Task