fix(learnings): accept type:"investigation" in gstack-learnings-log

The /investigate skill instructed agents to log learnings with type:"investigation",
but bin/gstack-learnings-log:22 rejected anything not in
[pattern, pitfall, preference, architecture, tool, operational]. Every
investigation run exited 1 to stderr and the learning was dropped, silently
to the user.

Fix: add 'investigation' to ALLOWED_TYPES.

Regression test: round-trips a learning with type:"investigation" and asserts
exit 0 + file write; second test reads investigate/SKILL.md.tmpl and asserts
it emits the literal type:"investigation" string, guarding the
template/validator contract at both ends.

Fixes #1423. Reported by diogolealassis.
This commit is contained in:
Garry Tan
2026-05-13 11:21:50 -07:00
parent 386fe518f9
commit f94aef7303
2 changed files with 23 additions and 1 deletions
+21
View File
@@ -102,6 +102,27 @@ describe('gstack-learnings-log', () => {
const lines = fs.readFileSync(f!, 'utf-8').trim().split('\n');
expect(lines.length).toBe(2);
});
// Regression test for #1423: investigate skill emits type:"investigation"
// but ALLOWED_TYPES previously rejected it. Now accepted.
test('accepts type:"investigation" (regression: #1423)', () => {
const input = '{"skill":"investigate","type":"investigation","key":"root-cause","insight":"verified","confidence":9,"source":"observed"}';
const result = runLog(input);
expect(result.exitCode).toBe(0);
const f = findLearningsFile();
expect(f).not.toBeNull();
const parsed = JSON.parse(fs.readFileSync(f!, 'utf-8').trim());
expect(parsed.type).toBe('investigation');
});
// Caller contract: investigate/SKILL.md.tmpl must emit type:"investigation"
// verbatim. Guards against the template drifting to an invalid type and
// silently breaking the log path. See codex review finding for #1423.
test('investigate template emits type:"investigation" verbatim (caller contract)', () => {
const tmpl = fs.readFileSync(path.join(ROOT, 'investigate/SKILL.md.tmpl'), 'utf-8');
// The invocation line must include "type":"investigation" exactly.
expect(tmpl).toContain('"type":"investigation"');
});
});
describe('gstack-learnings-search', () => {