fix: report explicitly disabled summaries as skipped

This commit is contained in:
Tivonsico
2026-10-11 00:36:27 +08:00
parent 71bf78796f
commit 1ad235fdfe
3 changed files with 40 additions and 1 deletions
+4 -1
View File
@@ -112,7 +112,10 @@ function getContextRemainingPct(transcriptPath) {
* Returns the summary string, or null on failure or when recursion guard is active.
*/
function generateSessionSummary(transcriptPath, { onSkip = () => {} } = {}) {
if (process.env.ECC_SKIP_LLM_SUMMARY) return null;
if (process.env.ECC_SKIP_LLM_SUMMARY) {
onSkip('ECC_SKIP_LLM_SUMMARY');
return null;
}
const conversation = extractConversationText(transcriptPath);
if (!conversation) return null;
+21
View File
@@ -266,6 +266,27 @@ function runTests() {
}
}) ? passed++ : failed++);
(test('logs an explicit LLM disable as skipped and persists mechanical resume state', () => {
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-session-skip-'));
try {
const uuid = '12345678-1234-4234-8234-123456789abc';
const transcript = path.join(home, `${uuid}.jsonl`);
const bin = path.join(home, 'empty-bin');
fs.mkdirSync(bin);
fs.writeFileSync(transcript, JSON.stringify({ type: 'user', content: 'Save context with LLM disabled' }) + '\n');
const res = runHook(home, transcript, {
ECC_LLM_SUMMARY_INTERVAL: '1', ECC_SKIP_LLM_SUMMARY: '1',
ECC_LLM_SUMMARY_SUBPROCESS: '', PATH: bin
});
assert.strictEqual(res.status, 0, res.stderr);
assert.match(res.stderr, /LLM summary skipped.*ECC_SKIP_LLM_SUMMARY/);
assert.doesNotMatch(res.stderr, /LLM summary failed/);
assert.match(fs.readFileSync(sessionFileFor(home, uuid), 'utf8'), /Save context with LLM disabled/);
} finally {
fs.rmSync(home, { recursive: true, force: true });
}
}) ? passed++ : failed++);
for (const inherited of ['', String(Date.now() + 300000), '1']) {
(test(`direct legacy runner bounds the deadline ${inherited || '(unset)'}`, () => {
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-runner-budget-'));
+15
View File
@@ -185,6 +185,21 @@ test('returns null when ECC_SKIP_LLM_SUMMARY is set', () => {
else delete process.env.ECC_SKIP_LLM_SUMMARY;
});
test('reports the explicit recursion guard as a deliberate skip', () => {
const orig = process.env.ECC_SKIP_LLM_SUMMARY;
process.env.ECC_SKIP_LLM_SUMMARY = '1';
try {
const skipped = [];
assert.strictEqual(generateSessionSummary('/nonexistent.jsonl', {
onSkip: reason => skipped.push(reason)
}), null);
assert.deepStrictEqual(skipped, ['ECC_SKIP_LLM_SUMMARY']);
} finally {
if (orig !== undefined) process.env.ECC_SKIP_LLM_SUMMARY = orig;
else delete process.env.ECC_SKIP_LLM_SUMMARY;
}
});
test('returns null for missing transcript (no conversation to summarize)', () => {
const orig = process.env.ECC_SKIP_LLM_SUMMARY;
delete process.env.ECC_SKIP_LLM_SUMMARY;