Wait for readiness before bootstrap app jobs - #266
Conversation
Co-authored-by: Möbius Agent <mobius-agent@users.noreply.github.com>
hamzamerzic
left a comment
There was a problem hiding this comment.
The readiness boundary is the right fix, but the bootstrap gate currently never activates. In install_from_manifest, source is overwritten with Path(app.source_dir) immediately before wait_for_ready = source == "bootstrap", so the comparison is always false and bootstrap jobs still launch without --wait-for-ready. Please preserve the install-source value before converting the app path (or give the two concepts distinct names), and add an install-path test that proves a bootstrap invocation calls launch_app_job(..., wait_for_ready=True) while an interactive install remains false.
|
Reviewed and superseded by the corrected readiness implementation in #283, now merged to main through #304. The original install-source PATH assignment was overwritten before the gate could activate; the integrated version preserves the intended readiness behavior without that defect. Thanks, Ricardo. |
Why this is useful
Bootstrap installs run while FastAPI is still completing startup, but the app-job runner needs the backend to mint its scoped credential and provide its job context. A first initialization job could therefore exit before the backend was ready, leaving an app empty until its next scheduled run.
Approach
/api/readycontract only when an initialization job was launched by bootstrapWhy this approach
This uses the platform's existing readiness boundary and fixes the specific ordering dependency where it occurs. It avoids making app installation depend on a guessed delay and keeps normal jobs fast.
Alternatives considered
Testing
python3 -m py_compile backend/app/app_jobs.py backend/app/install.py backend/scripts/app-job-runner.pypytest -q tests/test_app_jobs.py -k 'not job_context and not job_token'pytest -q tests/test_bootstrap.py