Repository navigation
feat(readiness): report ready only when migration, policy store and network agree (#224) - #289
Merged
Merged
Conversation
This file implements a unified readiness gate that checks the status of various dependencies to determine if the system is ready. It includes types for readiness checks, results, and dependencies, along with functions to perform the checks and format the results.
This file contains functions to check the readiness of the policy store and retrieve configured passphrases based on environment variables.
Add missing newline at the end of the file
Implement readinessBlockResponse to manage readiness checks for routes with side effects.
|
@Nuruddeen61 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #224
Summary
Health now returns ready only when the database migration, the policy store and the Stellar network passphrase all agree. Decision and payment routes use the same gate before any side effect.
Changes
src/lib/readiness/gate.ts:checkReadiness()runs migration, policy_store and network checks together with injected dependencies; returns only check names and pass/fail (no secrets or account ids)src/lib/readiness/checks.ts: real adapters. Read-only migration and policy store checks (no migrations applied, no default policy bootstrap), expected vs configured passphrasesrc/lib/readiness/guard.ts: shared 503 guard for routes with side effects (enforced in production, like the existing readiness check)src/lib/storage/db.ts: addsrunWithDatabaseNoMigrate()so readiness does not heal a stale schema/api/health: 200 when ready, 503 naming the failing check/api/decision,/api/stellar/pay,/api/stellar/build-payment,/api/stellar/submit-signed: call the guard before side effectsNotes
runWithDatabase()applies pending migrations andgetPolicyConfig()bootstraps defaults, so neither can be used to detect a stale or empty store; the readiness checks read state without changing it.FORTEXA_EXPECTED_NETWORK_PASSPHRASEif set, otherwise public network in production and testnet elsewhere.DATABASE_URL) there is no schema, so the migration check passes.