Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test: round 100 — findFiles maxAge+recursive interaction, parseSessionMetadata ### truncation, cleanupAliases falsy coercion

Affaan Mustafad2c1281e97a5
diff --git a/tests/lib/session-aliases.test.js b/tests/lib/session-aliases.test.js
index bc7b912b9..fb84b888a 100644
--- a/tests/lib/session-aliases.test.js
+++ b/tests/lib/session-aliases.test.js
@@ -1294,6 +1294,22 @@ function runTests() {
'Alias data should be preserved');
})) passed++; else failed++;
+ // ── Round 100: cleanupAliases callback returning falsy non-boolean 0 ──
+ console.log('\nRound 100: cleanupAliases (callback returns 0 — falsy non-boolean coercion):');
+ if (test('cleanupAliases removes alias when callback returns 0 (falsy coercion: !0 === true)', () => {
+ resetAliases();
+ aliases.setAlias('zero-test', '/sessions/some-session', '2026-01-15');
+ // callback returns 0 (a falsy value) — !0 === true → alias is removed
+ const result = aliases.cleanupAliases(() => 0);
+ assert.strictEqual(result.removed, 1,
+ 'Alias should be removed because !0 === true (JavaScript falsy coercion)');
+ assert.strictEqual(result.success, true,
+ 'Cleanup should succeed');
+ const resolved = aliases.resolveAlias('zero-test');
+ assert.strictEqual(resolved, null,
+ 'Alias should no longer exist after removal');
+ })) passed++; else failed++;
+
// Summary
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
diff --git a/tests/lib/session-manager.test.js b/tests/lib/session-manager.test.js
index a5100a15d..3957f0c26 100644
--- a/tests/lib/session-manager.test.js
+++ b/tests/lib/session-manager.test.js
@@ -1606,6 +1606,28 @@ src/main.ts
'null path should be caught by try/catch and return false');
})) passed++; else failed++;
+ // ── Round 100: parseSessionMetadata with ### inside item text (premature section termination) ──
+ console.log('\nRound 100: parseSessionMetadata (### in item text — lazy regex truncation):');
+ if (test('parseSessionMetadata truncates item text at embedded ### due to lazy regex lookahead', () => {
+ const content = `# Session
+
+### Completed
+- [x] Fix issue ### with parser
+- [x] Normal task
+
+### In Progress
+- [ ] Debug output
+`;
+ const meta = sessionManager.parseSessionMetadata(content);
+ // The lazy regex ([\s\S]*?)(?=###|\n\n|$) terminates at the first ###
+ // So the Completed section captures only "- [x] Fix issue " (before the inner ###)
+ // The second item "- [x] Normal task" is lost because it's after the inner ###
+ assert.strictEqual(meta.completed.length, 1,
+ 'Only 1 item extracted — second item is after the inner ### terminator');
+ assert.strictEqual(meta.completed[0], 'Fix issue',
+ 'Item text truncated at embedded ### (lazy regex stops at first ### match)');
+ })) passed++; else failed++;
+
// Summary
console.log(`\nResults: Passed: ${passed}, Failed: ${failed}`);
process.exit(failed > 0 ? 1 : 0);
diff --git a/tests/lib/utils.test.js b/tests/lib/utils.test.js
index c386406d1..8ac9c532f 100644
--- a/tests/lib/utils.test.js
+++ b/tests/lib/utils.test.js
@@ -1422,6 +1422,38 @@ function runTests() {
}
})) passed++; else failed++;
+ // ── Round 100: findFiles with both maxAge AND recursive (interaction test) ──
+ console.log('\nRound 100: findFiles (maxAge + recursive combined — untested interaction):');
+ if (test('findFiles with maxAge AND recursive filters age across subdirectories', () => {
+ const tmpDir = fs.mkdtempSync(path.join(utils.getTempDir(), 'r100-maxage-recur-'));
+ const subDir = path.join(tmpDir, 'nested');
+ try {
+ fs.mkdirSync(subDir);
+ // Create files: one in root, one in subdirectory
+ const rootFile = path.join(tmpDir, 'root.txt');
+ const nestedFile = path.join(subDir, 'nested.txt');
+ fs.writeFileSync(rootFile, 'root file');
+ fs.writeFileSync(nestedFile, 'nested file');
+
+ // maxAge: 1 with recursive: true — both files are fresh (ageInDays ≈ 0)
+ const results = utils.findFiles(tmpDir, '*.txt', { maxAge: 1, recursive: true });
+ assert.strictEqual(results.length, 2,
+ 'Both root and nested files should match (fresh, maxAge: 1, recursive: true)');
+
+ // maxAge: -1 with recursive: true — no files should match (age always >= 0)
+ const noResults = utils.findFiles(tmpDir, '*.txt', { maxAge: -1, recursive: true });
+ assert.strictEqual(noResults.length, 0,
+ 'maxAge: -1 should exclude all files even in subdirectories');
+
+ // maxAge: 1 with recursive: false — only root file
+ const rootOnly = utils.findFiles(tmpDir, '*.txt', { maxAge: 1, recursive: false });
+ assert.strictEqual(rootOnly.length, 1,
+ 'recursive: false should only find root-level file');
+ } finally {
+ fs.rmSync(tmpDir, { recursive: true, force: true });
+ }
+ })) passed++; else failed++;
+
// Summary
console.log('\n=== Test Results ===');
console.log(`Passed: ${passed}`);