Skip to content

Commit 755cfb4

Browse files
fix: auto-migrate legacy audit configuration to token-safe defaults
1 parent f709ee4 commit 755cfb4

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

global-template/docgen/lib/pipeline.mjs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ export async function model(root, { skipIndex = false } = {}) {
1818
export const plan = base.plan;
1919
export const generate = base.generate;
2020

21+
function ensureAuditDefaults(root) {
22+
const paths = projectPaths(root);
23+
const config = loadConfig(root);
24+
config.audit ??= {};
25+
let changed = false;
26+
if (!['off', 'advisory', 'blocking'].includes(String(config.audit.llmMode ?? '').toLowerCase())) {
27+
config.audit.llmMode = 'off';
28+
changed = true;
29+
}
30+
if (config.audit.requiredSectionsAsWarnings === undefined) {
31+
config.audit.requiredSectionsAsWarnings = true;
32+
changed = true;
33+
}
34+
if (changed) {
35+
writeJson(paths.config, config);
36+
console.log('[docgen] audit CONFIG MIGRATION | llmMode=off | requiredSectionsAsWarnings=true');
37+
}
38+
return config;
39+
}
40+
2141
async function finishDeterministicOnlyAudit(root) {
2242
const paths = projectPaths(root);
2343
const quality = readJson(path.join(paths.audit, 'deterministic.json'));
@@ -34,7 +54,7 @@ async function finishDeterministicOnlyAudit(root) {
3454
}
3555

3656
export async function audit(root) {
37-
const config = loadConfig(root);
57+
const config = ensureAuditDefaults(root);
3858
const llmMode = auditLlmMode(config);
3959
try {
4060
return await guardedAudit(root, llmMode === 'off' ? finishDeterministicOnlyAudit : base.audit);

0 commit comments

Comments
 (0)