Skip to content

test: add 40 unit tests for triage classification engine - #259

Open
TerminalGravity wants to merge 4 commits into
mainfrom
test/triage-unit-tests-v2
Open

test: add 40 unit tests for triage classification engine#259
TerminalGravity wants to merge 4 commits into
mainfrom
test/triage-unit-tests-v2

Conversation

@TerminalGravity

Copy link
Copy Markdown
Collaborator

First test file in the repo. Covers all 5 triage levels, config options, priority ordering, and edge cases. All 40 tests pass.

Sets the pattern for testing pure logic modules — no mocks needed since triage is pure functions.

Shows 4 concrete scenarios: vague prompt clarification, multi-step
scoping, correction pattern matching, and cross-service awareness.
Each example includes the prompt, triage classification, and the
actual output users can expect.
The README and examples/README.md referenced examples/.preflight/
but the actual config files didn't exist. Added:

- config.yml — profile, related projects, thresholds, embeddings
- triage.yml — keyword rules and strictness settings
- contracts/api.yml — manual contract definition examples

All files are heavily commented so users can copy them into their
project root and customize without needing to reference the docs.
The tool used run() (which calls execFileSync('git', ...)) for non-git
commands like wc and tail. These would silently fail since 'wc' and 'tail'
were passed as arguments to git, not as separate commands.

Replaced with Node.js APIs:
- countFileLines() using readFileSync for line counting
- getFileSize() using statSync for byte size
- readFileTail() using fs read with offset for large file tailing
- Git calls now use array syntax instead of string with shell redirects

Also removed the now-unused shellEscape helper.
Covers all 5 triage levels (trivial, clear, ambiguous, cross-service, multi-step),
skip/always_check keywords, priority ordering, edge cases, and config options.
First test file in the repo — sets the pattern for testing pure logic modules.

@TerminalGravity TerminalGravity left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look good but CI is red — the lint failure is from pre-existing require() imports in src/tools/token-audit.ts (lines 39-41), not from this PR. We should fix that separately or add an eslint-disable for those lines so test PRs can land. The triage tests themselves look solid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant