test: add 40 unit tests for triage classification engine - #259
Open
TerminalGravity wants to merge 4 commits into
Open
test: add 40 unit tests for triage classification engine#259TerminalGravity wants to merge 4 commits into
TerminalGravity wants to merge 4 commits into
Conversation
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
commented
Mar 16, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.