Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(core): guard doctor on older layouts [A6]

Corey Olsona0a8c69b351d
diff --git a/src/doctor.js b/src/doctor.js
index 4b578afb..b0766bbe 100644
--- a/src/doctor.js
+++ b/src/doctor.js
@@ -19,8 +19,9 @@ export function doctorProblems(file, root, tryGit) {
if (!existsSync(file)) return [finding('BOARD_MISSING', 'board file is missing', 'run pullboard status to create a new board')];
const db = new DatabaseSync(file, { readOnly: true });
try {
+ const schemaProblems = versionProblems(db);
+ if (schemaProblems.length) return schemaProblems;
return [
- ...versionProblems(db),
...triggerProblems(db),
...itemProblems(db),
...pinProblems(db, root, tryGit),
diff --git a/test/doctor.test.js b/test/doctor.test.js
index 56df2c6a..170ec830 100644
--- a/test/doctor.test.js
+++ b/test/doctor.test.js
@@ -17,7 +17,7 @@ after(() => {
/**
* Create a committed repo with a board and isolated git identity for one integrity scenario.
*/
-function boardBox() {
+function boardBox({ initialize = true } = {}) {
const dir = mkdtempSync(join(tmpdir(), 'pullboard-doctor-'));
sandboxes.push(dir);
const root = join(dir, 'repo');
@@ -37,8 +37,10 @@ function boardBox() {
writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ gate: 'true', lanes: {} }, null, 2));
git('add', '-A');
git('commit', '-q', '-m', 'chore: setup');
- assert.equal(run('status').status, 0);
- return { dir, root, env, git, run, dbFile: join(root, '.git', 'pullboard', 'board.sqlite') };
+ const dbFile = join(root, '.git', 'pullboard', 'board.sqlite');
+ if (initialize) assert.equal(run('status').status, 0);
+ else mkdirSync(join(root, '.git', 'pullboard'), { recursive: true });
+ return { dir, root, env, git, run, dbFile };
}
/**
@@ -155,3 +157,16 @@ test('doctor reports older and newer schema versions without migrating either [A
db.close();
}
});
+
+test('doctor reports an older empty SQLite layout without querying current tables [A6]', () => {
+ const box = boardBox({ initialize: false });
+ const db = new DatabaseSync(box.dbFile);
+ db.exec('PRAGMA user_version = 0');
+ db.close();
+ const before = readFileSync(box.dbFile);
+ const result = box.run('doctor');
+ assert.equal(result.status, 1);
+ assert.match(result.stdout, /schema version is 0; this pullboard expects 1; repair: run pullboard status to upgrade this board/);
+ assert.doesNotMatch(result.stderr, /no such table|SQLITE_ERROR|Error:/);
+ assert.deepEqual(readFileSync(box.dbFile), before);
+});