-
Notifications
You must be signed in to change notification settings - Fork 0
Add atomic release readiness contract #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
98ee0aa
Add atomic release readiness contract
mira-2026 5594198
Address release readiness review findings
mira-2026 eda80c0
Bind readiness to the active release
mira-2026 6b975a7
Complete release integrity review fixes
mira-2026 e8453ca
Bind release manifests to built artifacts
mira-2026 23169b4
Fix release readiness review findings
mira-2026 b378ed0
Clarify fresh-host build directories
mira-2026 d33a8bb
Verify worker release before database startup
mira-2026 f0a1c00
Harden atomic release startup validation
mira-2026 719c2fb
Preserve deploy cutover safety
mira-2026 7b67ee1
Coalesce concurrent backend startup
mira-2026 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ lerna-debug.log* | |
|
|
||
| node_modules | ||
| dist | ||
| release-manifest.json | ||
| backend/data/ | ||
| data/ | ||
| .test-openclaw/ | ||
|
|
||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { databaseMigrations } from "./databaseMigrations/index.ts"; | ||
|
|
||
| const CURRENT_DATABASE_SCHEMA_VERSION = databaseMigrations.at(-1)?.version ?? 0; | ||
|
|
||
| /** | ||
| * Keep this range explicit. An expand migration may widen the maximum before | ||
| * the migration ships; a contract migration must narrow it only after the | ||
| * previous release has left the rollback window. | ||
| */ | ||
| export const DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY = Object.freeze({ | ||
| maximum: 6, | ||
| minimum: 6, | ||
| target: CURRENT_DATABASE_SCHEMA_VERSION, | ||
| }); | ||
|
|
||
| interface DatabaseSchemaCompatibility { | ||
| maximum: number; | ||
| minimum: number; | ||
| } | ||
|
|
||
| if ( | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.target < | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.minimum || | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.target > | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.maximum | ||
| ) { | ||
| throw new Error( | ||
| "Dashboard database schema target is outside the declared release compatibility range" | ||
| ); | ||
| } | ||
|
|
||
| export function isDatabaseSchemaCompatible( | ||
| version: number, | ||
| compatibility: DatabaseSchemaCompatibility = DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY | ||
| ): boolean { | ||
| return ( | ||
| Number.isSafeInteger(version) && | ||
| version >= compatibility.minimum && | ||
| version <= compatibility.maximum | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| import { getProcessReleaseRoot } from "./releaseManifest.ts"; | ||
|
|
||
| export function resolveFrontendPath(): string { | ||
| return ( | ||
| process.env.MIRA_DASHBOARD_FRONTEND_PATH || | ||
| path.join(getProcessReleaseRoot(), "dist") | ||
| ); | ||
| } | ||
|
|
||
| export function isFrontendIndexReady(): boolean { | ||
| try { | ||
| const indexStat = fs.statSync(path.join(resolveFrontendPath(), "index.html")); | ||
| return indexStat.isFile(); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import { database } from "./database.ts"; | ||
| import { validateDatabaseMigrationHistory } from "./databaseMigrationRunner.ts"; | ||
| import { | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY, | ||
| isDatabaseSchemaCompatible, | ||
| } from "./databaseSchemaCompatibility.ts"; | ||
| import { isFrontendIndexReady } from "./frontendAssets.ts"; | ||
| import gateway from "./gateway.ts"; | ||
| import { | ||
| getRuntimeReleaseIdentity, | ||
| type RuntimeReleaseIdentity, | ||
| } from "./releaseManifest.ts"; | ||
| import { getJobExecutionSummary } from "./services/jobExecutionQueue.ts"; | ||
|
|
||
| interface DatabaseReadiness { | ||
| currentSchemaVersion?: number; | ||
| maximumCompatibleSchemaVersion: number; | ||
| minimumCompatibleSchemaVersion: number; | ||
| ready: boolean; | ||
| targetSchemaVersion: number; | ||
| } | ||
|
|
||
| export interface ReadinessSignals { | ||
| database: DatabaseReadiness; | ||
| frontendReady: boolean; | ||
| gatewayConnected: boolean; | ||
| release: RuntimeReleaseIdentity; | ||
| sessionCount: number; | ||
| workerReady: boolean; | ||
| } | ||
|
|
||
| export interface DashboardReadinessSnapshot { | ||
| checks: { | ||
| database: DatabaseReadiness; | ||
| frontend: { ready: boolean }; | ||
| release: { | ||
| backendCommit: string; | ||
| frontendCommit: string; | ||
| issue?: RuntimeReleaseIdentity["issue"]; | ||
| manifestFormatVersion?: number; | ||
| ready: boolean; | ||
| source: RuntimeReleaseIdentity["source"]; | ||
| }; | ||
| worker: { ready: boolean }; | ||
| }; | ||
| dependencies: { | ||
| gatewayConnected: boolean; | ||
| }; | ||
| status: "isReady" | "notReady"; | ||
| } | ||
|
|
||
| function databaseReadiness(): DatabaseReadiness { | ||
| try { | ||
| database.query("SELECT 1").get(); | ||
| const currentSchemaVersion = validateDatabaseMigrationHistory(database); | ||
| return { | ||
| currentSchemaVersion, | ||
| maximumCompatibleSchemaVersion: | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.maximum, | ||
| minimumCompatibleSchemaVersion: | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.minimum, | ||
| ready: isDatabaseSchemaCompatible(currentSchemaVersion), | ||
| targetSchemaVersion: DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.target, | ||
| }; | ||
| } catch { | ||
| return { | ||
| maximumCompatibleSchemaVersion: | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.maximum, | ||
| minimumCompatibleSchemaVersion: | ||
| DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.minimum, | ||
| ready: false, | ||
| targetSchemaVersion: DASHBOARD_DATABASE_SCHEMA_COMPATIBILITY.target, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| function isWorkerReady(): boolean { | ||
| try { | ||
| return getJobExecutionSummary().workerOnline; | ||
|
mira-2026 marked this conversation as resolved.
|
||
| } catch (error) { | ||
| console.warn("[Health] Failed to read job worker telemetry:", error); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| export async function collectReadinessSignals(): Promise<ReadinessSignals> { | ||
| return { | ||
| database: databaseReadiness(), | ||
| frontendReady: isFrontendIndexReady(), | ||
| gatewayConnected: gateway.isConnected(), | ||
| release: await getRuntimeReleaseIdentity(), | ||
| sessionCount: gateway.getSessions().length, | ||
| workerReady: isWorkerReady(), | ||
| }; | ||
| } | ||
|
|
||
| export function evaluateReadiness(signals: ReadinessSignals): DashboardReadinessSnapshot { | ||
| const ready = | ||
| signals.database.ready && | ||
| signals.frontendReady && | ||
| signals.release.ready && | ||
| signals.workerReady; | ||
| return { | ||
| checks: { | ||
| database: signals.database, | ||
| frontend: { ready: signals.frontendReady }, | ||
| release: { | ||
| backendCommit: signals.release.backendCommit, | ||
| frontendCommit: signals.release.frontendCommit, | ||
| ...(signals.release.issue && { issue: signals.release.issue }), | ||
| ...(signals.release.manifestFormatVersion !== undefined && { | ||
| manifestFormatVersion: signals.release.manifestFormatVersion, | ||
| }), | ||
| ready: signals.release.ready, | ||
| source: signals.release.source, | ||
| }, | ||
| worker: { ready: signals.workerReady }, | ||
| }, | ||
| dependencies: { | ||
| // Gateway availability is diagnostic. A Gateway outage cannot be | ||
| // repaired by rolling Dashboard code back. | ||
| gatewayConnected: signals.gatewayConnected, | ||
| }, | ||
| status: ready ? "isReady" : "notReady", | ||
| }; | ||
| } | ||
|
|
||
| export function livenessSnapshot() { | ||
| return { | ||
| status: "isOk" as const, | ||
| uptimeSeconds: Math.floor(process.uptime()), | ||
| }; | ||
| } | ||
|
|
||
| export async function readinessSnapshot(): Promise<DashboardReadinessSnapshot> { | ||
| return evaluateReadiness(await collectReadinessSignals()); | ||
| } | ||
|
|
||
| export async function diagnosticsSnapshot() { | ||
| const signals = await collectReadinessSignals(); | ||
| return { | ||
| ...evaluateReadiness(signals), | ||
| releaseDetails: signals.release, | ||
| sessionCount: signals.sessionCount, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.