Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ai/suppression_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ai/suppression_test.go |
| Original SHA-256 | ea3d71812678bf1785c931a7c127f7935f1de3371ba8045db51c6c7a7dd787af |
| Git blob SHA | f680f1ac9087b8b2d0c9c48ecdaea8c99242e91e |
| Reading-copy SHA-256 | ea3d71812678bf1785c931a7c127f7935f1de3371ba8045db51c6c7a7dd787af |
Every recorded occurrence
These 12 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/ai/suppression_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓205 lines · 7.0 KB
package ai
import (
"testing"
"github.com/shopspring/decimal"
)
func TestSuppressBelowThresholdHidesSmallCells(t *testing.T) {
// Total is 40, above k, so the answer is allowed. The cell under 10 is hidden by primary
// suppression, and because it is the only naturally sub k cell, complementary suppression also hides
// the smallest published cell so the residual cannot be back solved. The largest cell stays published.
cells := []Cell{
{Key: []string{"secret"}, Count: 22},
{Key: []string{"top_secret"}, Count: 12},
{Key: []string{"ts_sci"}, Count: 6},
}
out := Suppress(cells, 10)
if out[0].Suppressed {
t.Fatal("the largest published cell must not be suppressed")
}
if !out[2].Suppressed {
t.Fatal("a cell of 6 (below k=10) must be suppressed")
}
if !out[1].Suppressed {
t.Fatal("the smallest published cell must be hidden by complementary suppression")
}
}
func TestSuppressComplementaryHidesASecondCell(t *testing.T) {
// Exactly one cell is naturally below k. If only it were hidden, it could be recovered as
// total minus the published cells. So a second (the smallest published) cell must also hide.
cells := []Cell{
{Key: []string{"secret"}, Count: 30},
{Key: []string{"top_secret"}, Count: 14},
{Key: []string{"ts_sci"}, Count: 6},
}
out := Suppress(cells, 10)
suppressed := 0
for _, c := range out {
if c.Suppressed {
suppressed++
}
}
if suppressed < 2 {
t.Fatalf("complementary suppression must hide at least 2 cells, got %d", suppressed)
}
// The smallest published cell (top_secret, 14) is the one chosen to also hide, not the larger.
if out[1].Key[0] != "top_secret" || !out[1].Suppressed {
t.Fatal("the smallest published cell must be the complementary suppression")
}
}
func TestSuppressRefusesWhenTotalBelowThreshold(t *testing.T) {
// If the whole matched set is below k, even its existence is sub threshold: hide everything.
cells := []Cell{
{Key: []string{"secret"}, Count: 4},
{Key: []string{"ts_sci"}, Count: 3},
}
out := Suppress(cells, 10)
for _, c := range out {
if !c.Suppressed {
t.Fatal("when the total is below k every cell must be suppressed")
}
}
}
func TestSuppressNoSmallCellsLeavesAllPublished(t *testing.T) {
cells := []Cell{
{Key: []string{"secret"}, Count: 22},
{Key: []string{"top_secret"}, Count: 18},
}
out := Suppress(cells, 10)
for _, c := range out {
if c.Suppressed {
t.Fatal("no cell below k means nothing is suppressed")
}
}
}
func TestSuppressIsDeterministic(t *testing.T) {
cells := []Cell{
{Key: []string{"a"}, Count: 6},
{Key: []string{"b"}, Count: 6},
{Key: []string{"c"}, Count: 28},
}
a := Suppress(append([]Cell(nil), cells...), 10)
b := Suppress(append([]Cell(nil), cells...), 10)
for i := range a {
if a[i].Suppressed != b[i].Suppressed {
t.Fatal("suppression must be deterministic across runs")
}
}
}
func TestSuppressDifferencingTwoQueriesCannotIsolateOne(t *testing.T) {
// The classic differencing attack: a broad query and a narrow query that differ by one person. With
// suppression, the narrow query's small residual cell is hidden, so subtraction cannot isolate the
// individual. This proves the per answer floor blocks the naive single subtraction (the cross query
// budget that blocks the iterated attack is the deferred cross tenant control, documented).
broad := []Cell{{Key: []string{"secret"}, Count: 11}}
narrow := []Cell{{Key: []string{"secret"}, Count: 1}} // the broad set minus ten others, one person
bo := Suppress(broad, 10)
no := Suppress(narrow, 10)
if bo[0].Suppressed {
t.Fatal("a published cell of 11 should remain")
}
if !no[0].Suppressed {
t.Fatal("a residual cell of 1 must be suppressed so subtraction cannot isolate the person")
}
}
func TestSuppressNeverPublishesBelowK(t *testing.T) {
// Property: after Suppress, no published cell has a count below k. Exhaustive over small grids.
k := 10
for total := 0; total <= 60; total++ {
for a := 0; a <= total; a++ {
cells := []Cell{{Key: []string{"a"}, Count: a}, {Key: []string{"b"}, Count: total - a}}
out := Suppress(cells, k)
for _, c := range out {
if !c.Suppressed && c.Count < k {
t.Fatalf("published a cell of %d below k=%d (total=%d)", c.Count, k, total)
}
}
}
}
}
func TestSuppressAtLeastTwoOrZeroHidden(t *testing.T) {
// Property: among MULTIPLE buckets the hidden count is never exactly one (complementary suppression
// invariant). The single bucket refuse case is covered separately in TestSuppressWidthOneAndZero.
k := 10
for total := 0; total <= 60; total++ {
for a := 0; a <= total; a++ {
cells := []Cell{{Key: []string{"a"}, Count: a}, {Key: []string{"b"}, Count: total - a}}
out := Suppress(cells, k)
hidden := 0
for _, c := range out {
if c.Suppressed {
hidden++
}
}
if hidden == 1 {
t.Fatalf("exactly one cell hidden (recoverable) at total=%d a=%d", total, a)
}
}
}
}
func TestSuppressWidthOneAndZero(t *testing.T) {
// Width 0: an empty partition is a no op and never panics.
if out := Suppress([]Cell{}, 10); len(out) != 0 {
t.Fatal("empty input must return empty")
}
// Width 1, below k: the single bucket is refused. One hidden cell is acceptable here because there is
// no sibling and no grand total to subtract against.
one := Suppress([]Cell{{Key: []string{"only"}, Count: 7}}, 10)
if !one[0].Suppressed {
t.Fatal("a lone sub k bucket must be suppressed")
}
// Width 1, at or above k: published.
ok := Suppress([]Cell{{Key: []string{"only"}, Count: 10}}, 10)
if ok[0].Suppressed {
t.Fatal("a lone bucket at k must be published")
}
}
func TestSuppressZeroesValueOnSuppressedCell(t *testing.T) {
// A suppressed cell must not retain its decimal aggregate, and RenderValue must return the sentinel,
// so a small cell median or average can never leak through the Value dimension.
cells := []Cell{
{Key: []string{"secret"}, Count: 30, Value: decimal.RequireFromString("88.5"), HasValue: true},
{Key: []string{"ts_sci"}, Count: 6, Value: decimal.RequireFromString("91.4"), HasValue: true},
}
out := Suppress(cells, 10)
// ts_sci is suppressed (count 6), and complementary suppression also hides secret. Both must have
// their Value cleared and RenderValue must show the sentinel.
for _, c := range out {
if !c.Suppressed {
t.Fatalf("expected both cells suppressed, %v was published", c.Key)
}
if !c.Value.IsZero() || c.HasValue {
t.Fatalf("suppressed cell %v still carries a value", c.Key)
}
if RenderValue(c) != SuppressionSentinel {
t.Fatalf("RenderValue leaked a suppressed aggregate for %v", c.Key)
}
}
}
func TestSuppressClearsStaleFlagsOnReuse(t *testing.T) {
// Reusing a slice must not keep an old suppression decision. First call suppresses, then the same
// backing slice is refilled with all published counts and must come back fully published.
cells := []Cell{{Key: []string{"a"}, Count: 3}, {Key: []string{"b"}, Count: 4}}
Suppress(cells, 10) // total 7 < k, both suppressed
cells[0].Count = 25
cells[1].Count = 25
out := Suppress(cells, 10)
for _, c := range out {
if c.Suppressed {
t.Fatalf("stale suppression flag survived reuse for %v", c.Key)
}
}
}