Review iteration: warn on gitSha read failure, WAL invariant comment, C6.2 wave-3 coordination gate
- backup.ts: log.warn when `git rev-parse HEAD` fails so sandbox/CI runs
with no git show diagnosably instead of silently emitting gitSha:null
(Karpathy review ask).
- backup.ts: expand comment on VACUUM INTO to pin the WAL-mode invariant
— future readers must not "helpfully" add a wal_checkpoint call
(Karpathy review ask).
- C6.2 proposal: add hard coordination gate before wave 3 because
commit 0db6e42 already demonstrated the race hazard when two agents
touch scripts/ / connector-definitions/ in the same window
(Linus review ask).
This commit is contained in:
1 parent
557090a6a8
commit
e530849b0f
2 files changed
+28
-1
No files matched your search
@@ -21,7 +21,11 @@ function readGitSha(): string | null {
|
||||
});
|
||||
const sha = out.toString("utf8").trim();
|
||||
return sha.length === 40 ? sha : null;
|
||||
} catch {
|
||||
} catch (e) {
|
||||
log.warn(
|
||||
"[database/backup] git rev-parse HEAD failed; manifest.gitSha will be null",
|
||||
e instanceof Error ? e.message : String(e),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -89,6 +93,12 @@ export function buildBackupMethods(
|
||||
// while the connection is held open — no WAL checkpoint dance, no
|
||||
// torn writes, works on sqlite3 ≥ 3.27. The destination must not
|
||||
// exist; `mkdirSync` above only created the parent directory.
|
||||
//
|
||||
// Safety invariant under WAL mode: VACUUM INTO opens an implicit
|
||||
// read transaction that sees every committed frame including those
|
||||
// still in profile.sqlite-wal. DO NOT add PRAGMA wal_checkpoint
|
||||
// here — a TRUNCATE checkpoint would fight concurrent writers and
|
||||
// buys nothing for the snapshot; a PASSIVE checkpoint is redundant.
|
||||
const dbTarget = join(targetDir, "profile.sqlite").replace(/'/g, "''");
|
||||
db.exec(`VACUUM INTO '${dbTarget}'`);
|
||||
|
||||
|
||||
Reference in new issue
Block a user