Skip to content

feat(readiness): report ready only when migration, policy store and network agree (#224) - #289

Merged
karagozemin merged 15 commits into
Fortexa-stellar:mainfrom
Nuruddeen61:main
Oct 1, 2026
Merged

karagozemin merged 15 commits into
Fortexa-stellar:mainfrom
Nuruddeen61:main

Conversation

@Nuruddeen61

Copy link
Copy Markdown
Contributor

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 passphrase
  • src/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: adds runWithDatabaseNoMigrate() 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 effects
  • Tests: gate (each dependency stubbed) and guard

Notes

  • runWithDatabase() applies pending migrations and getPolicyConfig() bootstraps defaults, so neither can be used to detect a stale or empty store; the readiness checks read state without changing it.
  • Expected passphrase: FORTEXA_EXPECTED_NETWORK_PASSPHRASE if set, otherwise public network in production and testnet elsewhere.
  • In file-store mode (no DATABASE_URL) there is no schema, so the migration check passes.
  • I have not been able to run the test suite locally yet.

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.
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@karagozemin
karagozemin merged commit 203c3d5 into Fortexa-stellar:main Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report ready only when policy storage, database, and network agree

2 participants