test: distinguish clean and unsupported inputs
This commit is contained in:
parent
6fe5f90c17
commit
c62318304a
|
|
@ -24,8 +24,10 @@ cluster of closely related phrases from being treated as independent proof.
|
|||
If the resulting evidence sum is `E`, the displayed score is
|
||||
`round(100 × E / (E + 50))`, bounded to `0..=100`. The configured `low`,
|
||||
`medium`, and `high` thresholds name the resulting band. Evidence below `low`
|
||||
is explicitly reported as below threshold. No findings produce score zero and
|
||||
no confidence verdict.
|
||||
is explicitly reported as below threshold. Empty input and text with no
|
||||
findings produce score zero and no confidence verdict. Binary, invalid UTF-8,
|
||||
oversized, and unsupported inputs remain typed input errors; they are never
|
||||
reported as clean analyses.
|
||||
|
||||
Weights and thresholds are review policy, not calibrated probabilities. A
|
||||
score of 75 does not mean a 75% chance that AI wrote the input.
|
||||
|
|
|
|||
|
|
@ -751,4 +751,16 @@ mod tests {
|
|||
assert_eq!(analysis.findings.len(), 3);
|
||||
assert_ne!(analysis.confidence_band, Some(ConfidenceBand::High));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_and_clean_text_have_zero_confidence_and_no_verdict() {
|
||||
let detector = Detector::new(&Config::embedded()).unwrap();
|
||||
|
||||
for source in ["", "A specific, carefully sourced statement."] {
|
||||
let analysis = detector.analyze(source);
|
||||
assert!(analysis.findings.is_empty());
|
||||
assert_eq!(analysis.confidence.score(), 0);
|
||||
assert_eq!(analysis.confidence_band, None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,23 @@ fn invalid_utf8_is_a_per_document_error() {
|
|||
assert!(documents.next().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn binary_content_is_an_input_error_not_a_clean_document() {
|
||||
let directory = tempdir().expect("temp dir");
|
||||
let path = directory.path().join("binary.txt");
|
||||
fs::write(&path, b"clean prefix\0binary suffix").expect("write fixture");
|
||||
|
||||
let mut documents = read(&path, &limits()).expect("open input");
|
||||
let error = documents.next().expect("one result").unwrap_err();
|
||||
|
||||
assert!(matches!(
|
||||
error,
|
||||
InputError::BinaryContent {
|
||||
source_id: SourceId::File(error_path)
|
||||
} if error_path == path
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_path_is_rejected() {
|
||||
let directory = tempdir().expect("temp dir");
|
||||
|
|
|
|||
2
tasks.md
2
tasks.md
|
|
@ -120,7 +120,7 @@ configuration is explainable, and all precedence/validation tests pass.
|
|||
- [x] Design the confidence formula: bounded weighted evidence, per-rule caps,
|
||||
correlated-family damping, normalization to `0..=100`, and configurable
|
||||
low/medium/high thresholds.
|
||||
- [ ] Return zero confidence and no verdict for empty/no-evidence input. Keep
|
||||
- [x] Return zero confidence and no verdict for empty/no-evidence input. Keep
|
||||
unsupported/binary input distinct from a clean analysis.
|
||||
- [ ] Sort findings deterministically and deduplicate identical rule/span pairs.
|
||||
- [ ] Add table-driven unit tests for every shipped rule with positive examples
|
||||
|
|
|
|||
Loading…
Reference in New Issue