230dc05287
CI / detect-changes (push) Successful in 8s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / build-sha-integrity (push) Successful in 6s
CI / sbom-scan (push) Has been skipped
CI / validate-canonical-controls (push) Successful in 6s
CI / go-lint (push) Has been skipped
CI / loc-budget (push) Successful in 19s
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / nodejs-build (push) Successful in 3m1s
CI / test-go (push) Successful in 59s
CI / iace-gt-coverage (push) Successful in 22s
CI / test-python-backend (push) Has been skipped
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package ucca
|
|
|
|
import "testing"
|
|
|
|
// A superseded alt-source must rank below the same result when it is NOT
|
|
// superseded (the eu-v1 norm), but only demoted — the penalty is finite, so it
|
|
// stays in the pool and remains findable for history/transition questions.
|
|
func TestAuthorityScore_SupersededIsDemotedNotRemoved(t *testing.T) {
|
|
fresh := LegalSearchResult{
|
|
Score: 0.65, SourceClass: "binding_law", AuthorityWeight: 100,
|
|
Jurisdiction: "EU", RegulationShort: "CRA", Article: "13",
|
|
}
|
|
old := fresh
|
|
old.Superseded = true
|
|
|
|
sFresh := authorityScore("CRA Sicherheitsupdates Hersteller", fresh, "", false)
|
|
sOld := authorityScore("CRA Sicherheitsupdates Hersteller", old, "", false)
|
|
|
|
if sOld >= sFresh {
|
|
t.Errorf("superseded must score lower: fresh=%.3f superseded=%.3f", sFresh, sOld)
|
|
}
|
|
gap := sFresh - sOld
|
|
if gap < supersededPenalty-0.001 || gap > supersededPenalty+0.001 {
|
|
t.Errorf("demotion should equal supersededPenalty (%.2f), got %.3f", supersededPenalty, gap)
|
|
}
|
|
// Still a positive, finite score → present in the pool, not hidden.
|
|
if sOld <= -1 {
|
|
t.Errorf("superseded score collapsed (%.3f) — must remain findable", sOld)
|
|
}
|
|
}
|