fix(#2638): write sub_repos to canonical planning.sub_repos (#2668)

loadConfig's multiRepo migration and filesystem-sync writers targeted the
top-level parsed.sub_repos, but KNOWN_TOP_LEVEL (the unknown-key validator's
allowlist) only recognizes planning.sub_repos (canonical per #2561). Each
migration/sync therefore persisted a key the next loadConfig call warned was
unknown.

Redirect both writers to parsed.planning.sub_repos, ensuring parsed.planning
is initialized first. Also self-heal legacy/buggy installs by stripping any
stale top-level sub_repos on load, preserving its value as the
planning.sub_repos seed if that slot is empty.

Tests cover: (a) canonical planning.sub_repos emits no warning, (b) multiRepo
migration writes to planning.sub_repos with no top-level residue,
(c) filesystem sync relocates to planning.sub_repos, (d) stale top-level
sub_repos from older buggy installs is stripped on load.

Closes #2638
This commit is contained in:
Tom Boucher
2026-04-24 18:05:33 -04:00
committed by GitHub
parent 259c1d07d3
commit 06463860e4
3 changed files with 165 additions and 7 deletions

View File

@@ -1519,9 +1519,10 @@ describe('loadConfig sub_repos auto-sync', () => {
assert.deepStrictEqual(config.sub_repos, ['backend', 'frontend']);
assert.strictEqual(config.commit_docs, false);
// Verify config was persisted
// Verify config was persisted to the canonical location (planning.sub_repos per #2561/#2638)
const saved = JSON.parse(fs.readFileSync(path.join(projectRoot, '.planning', 'config.json'), 'utf-8'));
assert.deepStrictEqual(saved.sub_repos, ['backend', 'frontend']);
assert.deepStrictEqual(saved.planning?.sub_repos, ['backend', 'frontend']);
assert.strictEqual(saved.sub_repos, undefined, 'top-level sub_repos should not be written (#2638)');
assert.strictEqual(saved.multiRepo, undefined, 'multiRepo should be removed');
});