Modify the Scorer to accept an optional JudgeResult, replacing hardcoded actionability with judge-provided scores and using judge classifications to identify false-positive novel findings that reduce precision, while remaining fully backward-compatible when no judge is provided.
Components
Component
Description
Complexity
Dependencies
Scorer signature change
Change Scorer::score() to accept Option<&JudgeResult> as third parameter, importing JudgeResult and ClassificationVerdict from judge.rs
low
-
Actionability computation
Compute actionability as average of judge's actionability_scores when present and non-empty, falling back to 0.5 otherwise
low
Scorer signature change
Precision with judge classifications
Add compute_precision_with_judge() that counts FPs from must_not_flag hits (always) plus novel findings classified as false_positive by judge (only when judge present). must_not_flag takes precedence over judge.
medium
Scorer signature change
FindingMatcher helpers
Add count_must_not_flag_hits() and identify_novel_findings() to FindingMatcher for decomposing precision calculation
low
-
Backward compatibility
Update all existing T06 tests to pass None as third argument; wrap old compute_precision as convenience delegating to compute_precision_with_judge(..., None)
low
Scorer signature change, Precision with judge classifications
Code Patterns
Actionability from judge with fallback
code
let actionability = match judge_result {
Some(jr) if !jr.actionability_scores.is_empty() => {
let sum: f64 = jr.actionability_scores.iter().map(|s| s.score).sum();
sum / jr.actionability_scores.len() as f64
}
_ => 0.5,
};
Precision with judge false positives
code
let judge_fps = match judge_result {
Some(jr) => {
jr.classifications
.iter()
.filter(|c| {
novel_finding_ids.contains(&c.finding_id)
&& c.verdict == ClassificationVerdict::FalsePositive
})
.count()
}
None => 0,
};
let total_fps = must_not_flag_fps + judge_fps;
let precision = 1.0 - (total_fps as f64 / total);
precision.max(0.0)
#[test]
fn test_example() {
// Arrange - Set up test data and conditions
let input = create_test_input();
// Act - Execute the code under test
let result = function_under_test(input);
// Assert - Verify the results
assert_eq!(result, expected_value);
}
What to Test
Happy path (normal operation)
Edge cases (empty input, boundaries, limits)
Error conditions (invalid input, failures)
Regression tests for fixed bugs
Test Helpers
Create helper functions for common test setup
Use tempdir() for filesystem tests
Use builders for complex test data
Running Tests
bash
cargo test # Run all tests
cargo test <test_name> # Run specific test
cargo test -- --nocapture # Show println! output
SKILL: CLI DESIGN
CLI Design
Follow these conventions for CLI commands and user interaction:
Command Structure
Use clap with derive macros for argument parsing
Organize commands as subcommands where logical
Provide both short and long flags for common options
Include helpful examples in help text
User Feedback
Print progress information during long operations
Use clear, action-oriented language ("Creating...", "Loading...")
Show success/failure status clearly
Provide next steps on completion
Output Formatting
Use consistent indentation for structured output
Add blank lines to separate sections for readability
Keep line length reasonable for terminal display
Use colors sparingly (via console crate) for emphasis
Error Messages
Be specific about what went wrong
Suggest how to fix the problem when possible
Include relevant file paths or values
Exit with non-zero status on error
Confirmation Prompts
Require confirmation for destructive operations
Provide --force flag to skip prompts in scripts
Default to the safer option (usually "no")
Example Pattern
rust
fn cmd_example(project_dir: &Path) -> Result<()> {
println!("Performing operation...");
// Do work
let result = do_work(project_dir)?;
// Report success
println!("Operation complete: {} items processed", result.count);
println!();
println!("Next steps:");
println!(" Run 'forge next-command' to continue");
Ok(())
}
SKILL: TDD WORKFLOW
TDD Workflow
Apply Test-Driven Development when implementing new functionality. Use your judgment
to determine when TDD is appropriate — it's most valuable for business logic,
algorithms, and complex state management.
Verify both instances truly represent the same concept
Extract to a well-named function/constant/type
Update all call sites
Run tests to confirm behavior unchanged
Warning
Premature abstraction is worse than duplication. Only abstract when:
The pattern appears 3+ times, OR
The duplication causes active maintenance burden
SKILL: SECURE CODING
Secure Coding
Follow these secure coding practices for all code in this project.
Input Validation
Validate all external input (user input, API responses, file contents)
Use allowlists over denylists when validating
Sanitize data before use in SQL, shell commands, or HTML output
Validate early, at system boundaries (CLI args, file reads, network responses)
Rust-Specific Security
Minimize unsafe blocks; document safety invariants when used
Use established crypto libraries (ring, rustls) — never roll your own
Validate and canonicalize file paths to prevent directory traversal
Handle symlinks carefully; use canonicalize() before path operations
Prefer OsStr/OsString for paths from external sources
Command Execution
Never interpolate untrusted input into shell commands
Use Command::new().arg() instead of shell string concatenation
Validate command arguments against an allowlist when possible
OWASP Awareness
Injection: Use parameterized queries, avoid string interpolation
Broken Auth: Never hardcode credentials, use secure session management
Sensitive Data: Encrypt at rest and in transit, minimize data collection
Broken Access Control: Verify permissions on every request, deny by default
Logging: Log security events, never log secrets or PII
Secrets Management
Never commit secrets to version control
Use environment variables or secret managers for credentials
Add sensitive file patterns to .gitignore (.env, *.key, credentials.*)
Error Handling
Never expose stack traces or internal details to users
Log detailed errors server-side only
Return generic error messages to external callers
Use .context() to add information without leaking internals
SKILL: CONTEXT7 INTEGRATION
Context7 Integration
Query Context7 for up-to-date library documentation before implementing code that
uses external dependencies. This ensures you use current APIs and best practices.
When to Query Context7
Before first use of an unfamiliar or rapidly-evolving library
When implementing patterns you haven't used recently
When errors suggest API changes or deprecations
When the spec mentions specific library features
When NOT to Query
Standard library features (Rust std, Python built-ins)
Well-known stable APIs you're confident about (serde, clap basics)
Query once per library per phase — avoid redundant queries for the same library
Be specific in queries: "jwt token validation" not just "auth"
If the library isn't found, proceed with general knowledge but note the gap
Limit to 3 Context7 queries per phase to avoid excessive API calls
Handling Missing Libraries
If Context7 doesn't have documentation for a library:
Check the library's README or docs.rs
Proceed with general knowledge
Add extra test coverage for that integration
SKILL: AGENT REVIEW
Agent Review
Before claiming phase completion, spawn an independent review agent to verify
your implementation. This catches issues you may have missed.
When to Trigger Review
After all implementation for the phase is complete
After all tests pass
Before emitting <promise>DONE</promise>
How to Spawn Review Agent
Use the Task tool with these parameters:
subagent_type: "general-purpose"
description: "Review phase N implementation" (replace N with phase number)
prompt: Include the phase context and checklist below
Example prompt to pass to the review agent:
text
Review the code changes for Phase {N} - {phase name}.
Run this command to see what changed:
git diff HEAD~{iterations} --stat
git diff HEAD~{iterations}
Check for:
1. DRY violations - duplicated code that should be extracted
2. Security issues - injection risks, hardcoded secrets, missing validation
3. Test coverage - are edge cases covered, are tests meaningful
4. Code clarity - naming, structure, comments where needed
Report issues as a numbered list with file:line references.
If no issues found, respond with: REVIEW PASSED
Replace {N} with the phase number, {phase name} with the phase name, and
{iterations} with the number of iterations completed in this phase.
Handling Review Results
REVIEW PASSED: Proceed to emit <promise>DONE</promise>
Issues found: Address each issue, re-run tests, then request another review
Max 2 review cycles: If issues persist after 2 reviews, emit <blocker>review-failed</blocker> and describe the unresolved issues
Review Scope
The reviewer checks only the current phase's changes, not the entire codebase.
Use git diff HEAD~N where N is the iteration count to see phase changes.
CRITICAL RULES
Follow the spec requirements exactly
Check existing code before making changes
Run tests/checks to verify your work
Only output JUDGE-SCORER TESTS WRITTEN when the task is FULLY complete and verified
If tests fail, fix them before claiming completion
PROGRESS SIGNALS (Optional)
You can use these tags to communicate your progress:
I'll start by exploring the existing scorer and judge code to understand the current implementation before writing tests.
Assistant
Now let me read the full scorer.rs and judge.rs files to understand the exact types and test patterns.
Assistant
Let me also check the benchmark types to understand the Finding ID situation for novel finding identification.
Assistant
Let me check the module structure for imports.
Assistant
Let me check for callers of Scorer::score() so I know the full impact.
Assistant
Now I'll change the Scorer::score() signature and implement a stub body that defaults to 0.5 actionability (so existing tests pass with None), while not yet using judge data for precision (new tests will fail — TDD red).
Assistant
Now add the helper methods to FindingMatcher.
Assistant
Now update all existing tests to pass None instead of a float. The composite test with 0.7 actionability needs its expected value adjusted since None defaults to 0.5.
Assistant
Now update the composite test that used 0.7 actionability.
Assistant
Now let me read the current state of the test section to find the right insertion point for new tests.
Assistant
Now I'll add the new judge-scorer integration tests after the display test, before the closing } of the test module.
Assistant
Now let's run the tests to verify the TDD state: existing tests should pass, new judge-precision tests should fail.
Assistant
The scorer is in the binary crate. Let me run the correct test target.
Assistant
The import in the test module is wrong — it uses super::judge but it should use the full path since we're inside mod tests which is inside scorer. Let me fix it.
2 failed — the two tests that require judge FP classification of novel findings (test_precision_judge_fp_on_novel_finding_reduces_precision and test_must_not_flag_plus_judge_fp_combined)
These 2 failures are the "red" in TDD — they test the core behavior that compute_precision_with_judge needs to wire in judge classifications for novel findings, which is currently stubbed with let judge_fps = 0.
Assistant
No clippy warnings in scorer.rs. The existing clippy errors are in other modules (lib crate), not related to my changes.
Assistant
The ClassificationVerdict import is unused in the main module (it's only used in tests via the super::super::judge import). Since it will be needed by the implementation in compute_precision_with_judge, I'll keep it but suppress the warning for now. Actually, let me just remove it from the module-level import since the tests import it separately and it'll be added back during implementation.
Assistant
Wait, but ClassificationVerdict was already imported via use super::* in the test module — let me check. The test module does use super::* which imports from the scorer module, not the judge module. So the test make_judge_result helper uses ClassificationVerdict which needs to be imported from the judge module. Let me verify the test module compiles correctly.
Assistant
Clean compilation. Let me do a final run to confirm the test state is correct.
Assistant
TDD red phase is complete. Here's the summary:
Tests written (40 total in scorer::tests):
Category
Tests
Status
Existing T06 tests (updated to None)
20
All pass
count_must_not_flag_hits helper
2
Pass
identify_novel_findings helper
3
Pass
Actionability from judge
4
Pass (implemented)
Precision with judge FP on novel findings
2
FAIL (stub)
Combined must_not_flag + judge FP
1
FAIL (stub)
No judge = novel assumed TP
1
Pass
must_not_flag always FP
1
Pass
Composite with judge
2
Pass
Backward compat (None defaults)
2
Pass
2 failing tests define the behavior that phase 02 (implementation) must satisfy:
test_precision_judge_fp_on_novel_finding_reduces_precision — novel findings classified as FP by judge should reduce precision
test_must_not_flag_plus_judge_fp_combined — must_not_flag FPs + judge FPs on novel findings should both count
Actionability computation: fully implemented (average of judge scores, 0.5 fallback)
FindingMatcher::count_must_not_flag_hits() and identify_novel_findings(): fully implemented
compute_precision_with_judge(): stubbed — only counts must_not_flag hits, judge FP counting is TODO
100%
JUDGE-SCORER TESTS WRITTEN
User
SKILL: AGENT REVIEW
Agent Review
Before claiming phase completion, spawn an independent review agent to verify
your implementation. This catches issues you may have missed.
When to Trigger Review
After all implementation for the phase is complete
After all tests pass
Before emitting <promise>DONE</promise>
How to Spawn Review Agent
Use the Task tool with these parameters:
subagent_type: "general-purpose"
description: "Review phase N implementation" (replace N with phase number)
prompt: Include the phase context and checklist below
Example prompt to pass to the review agent:
text
Review the code changes for Phase {N} - {phase name}.
Run this command to see what changed:
git diff HEAD~{iterations} --stat
git diff HEAD~{iterations}
Check for:
1. DRY violations - duplicated code that should be extracted
2. Security issues - injection risks, hardcoded secrets, missing validation
3. Test coverage - are edge cases covered, are tests meaningful
4. Code clarity - naming, structure, comments where needed
Report issues as a numbered list with file:line references.
If no issues found, respond with: REVIEW PASSED
Replace {N} with the phase number, {phase name} with the phase name, and
{iterations} with the number of iterations completed in this phase.
Handling Review Results
REVIEW PASSED: Proceed to emit <promise>DONE</promise>
Issues found: Address each issue, re-run tests, then request another review
Max 2 review cycles: If issues persist after 2 reviews, emit <blocker>review-failed</blocker> and describe the unresolved issues
Review Scope
The reviewer checks only the current phase's changes, not the entire codebase.
Use git diff HEAD~N where N is the iteration count to see phase changes.
CRITICAL RULES
Follow the spec requirements exactly
Check existing code before making changes
Run tests/checks to verify your work
Only output JUDGE-SCORER TESTS WRITTEN when the task is FULLY complete and verified
If tests fail, fix them before claiming completion
PROGRESS SIGNALS (Optional)
You can use these tags to communicate your progress:
Query Context7 for up-to-date library documentation before implementing code that
uses external dependencies. This ensures you use current APIs and best practices.
When to Query Context7
Before first use of an unfamiliar or rapidly-evolving library
When implementing patterns you haven't used recently
When errors suggest API changes or deprecations
When the spec mentions specific library features
When NOT to Query
Standard library features (Rust std, Python built-ins)
Well-known stable APIs you're confident about (serde, clap basics)
Verify both instances truly represent the same concept
Extract to a well-named function/constant/type
Update all call sites
Run tests to confirm behavior unchanged
Warning
Premature abstraction is worse than duplication. Only abstract when:
The pattern appears 3+ times, OR
The duplication causes active maintenance burden
User
SKILL: TDD WORKFLOW
TDD Workflow
Apply Test-Driven Development when implementing new functionality. Use your judgment
to determine when TDD is appropriate — it's most valuable for business logic,
algorithms, and complex state management.
#[test]
fn test_example() {
// Arrange - Set up test data and conditions
let input = create_test_input();
// Act - Execute the code under test
let result = function_under_test(input);
// Assert - Verify the results
assert_eq!(result, expected_value);
}
What to Test
Happy path (normal operation)
Edge cases (empty input, boundaries, limits)
Error conditions (invalid input, failures)
Regression tests for fixed bugs
Test Helpers
Create helper functions for common test setup
Use tempdir() for filesystem tests
Use builders for complex test data
Running Tests
bash
cargo test # Run all tests
cargo test <test_name> # Run specific test
cargo test -- --nocapture # Show println! output