feat(FN-5188): complete Step 2 — persist bootstrappedAt

Fusion-Task-Id: FN-5188
Fusion-Task-Lineage: 6d238ff1-2d69-44e7-8694-ec19e412f8ef
This commit is contained in:
Fusion (runfusion.ai)
2026-05-19 12:27:09 -07:00
committed by gsxdsm
parent 1565b6dc52
commit 2c75ac6227
3 changed files with 31 additions and 0 deletions

View File

@@ -310,6 +310,21 @@ describe("Database", () => {
expect(ts).toBeLessThanOrEqual(Date.now());
});
it("seeds bootstrappedAt and preserves it across reopen", () => {
const bootstrappedAt = db.getBootstrappedAt();
expect(bootstrappedAt).toBeTypeOf("number");
expect(bootstrappedAt).toBeGreaterThan(0);
expect(bootstrappedAt).toBeLessThanOrEqual(Date.now());
const reopened = new Database(tempDir);
reopened.init();
try {
expect(reopened.getBootstrappedAt()).toBe(bootstrappedAt);
} finally {
reopened.close();
}
});
it("seeds config row with all required fields", () => {
const row = db.prepare("SELECT * FROM config WHERE id = 1").get() as any;
expect(row).toBeDefined();

View File

@@ -1520,6 +1520,9 @@ export class Database {
this.db.exec(
`INSERT OR IGNORE INTO __meta (key, value) VALUES ('lastModified', '${Date.now()}')`,
);
this.db.exec(
`INSERT OR IGNORE INTO __meta (key, value) VALUES ('bootstrappedAt', '${Date.now()}')`,
);
// Run schema migrations
this.migrate();
@@ -3847,6 +3850,15 @@ export class Database {
);
}
getBootstrappedAt(): number | null {
const value = this.getMetaValue("bootstrappedAt");
if (!value) {
return null;
}
const parsed = parseInt(value, 10);
return Number.isFinite(parsed) ? parsed : null;
}
/**
* Get the schema version number.
*/

View File

@@ -8805,6 +8805,10 @@ ${stepsSection}`;
return this.db;
}
getBootstrappedAt(): number | null {
return this.db.getBootstrappedAt();
}
async getSecretsStore(): Promise<SecretsStore> {
if (this.secretsStore) {
return this.secretsStore;