Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/signals/slop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,12 @@
}

function ensurePublicSafeText(text: string, fallback: string): string {
return isFocusManifestPublicSafe(text) ? text : fallback;

Check notice on line 436 in src/signals/slop.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
}

// Documented thresholds (#565): the deterministic slopRisk (0-100) maps to fixed bands — clean = 0,
// low = 1-24, elevated = 25-59, high = 60-100. Strong signals weigh 30 (any two reach `high`); weak/
// traceability signals weigh 15. Identical metadata always yields an identical band (see golden fixtures).
function slopBandFor(slopRisk: number): SlopBand {
if (slopRisk <= 0) return "clean";
if (slopRisk < 25) return "low";
Expand Down
45 changes: 45 additions & 0 deletions test/unit/slop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
buildMissingTestEvidenceFinding,
buildNoLinkedIssueRationaleFinding,
buildNonSubstantivePaddingFinding,
buildSlopAssessment,

Check notice on line 10 in test/unit/slop.test.ts

View check run for this annotation

Deleted GitHub App / Gittensory Context

Issue discovery is disabled for this repo

This repo is configured for direct contribution review rather than issue-discovery flow.
buildTrivialWhitespaceChurnFinding,
buildUnfilledIssueTemplateFinding,
type SlopAssessmentInput,
type SlopBand,
ISSUE_SLOP_WEIGHTS,
SLOP_RUBRIC_MARKDOWN,
SLOP_WEIGHTS,
Expand Down Expand Up @@ -405,3 +407,46 @@
expect(JSON.stringify(result)).not.toMatch(FORBIDDEN);
});
});

describe("slop golden fixtures & determinism (#565)", () => {
const goldenFixtures: Array<{ name: string; input: SlopAssessmentInput; slopRisk: number; band: SlopBand; codes: string[] }> = [
{ name: "clean — no metadata", input: {}, slopRisk: 0, band: "clean", codes: [] },
{ name: "low — generic commit subject", input: { commitMessages: ["wip"] }, slopRisk: 15, band: "low", codes: ["low_quality_commit_message"] },
{ name: "low — no linked issue and no rationale", input: { hasLinkedIssue: false }, slopRisk: 15, band: "low", codes: ["no_linked_issue_without_rationale"] },
{
name: "elevated — code change without test evidence",
input: { changedFiles: [{ path: "src/svc.ts", additions: 12, deletions: 3 }], description: "Add retry logic to the sync client." },
slopRisk: 30,
band: "elevated",
codes: ["missing_test_evidence"],
},
{
name: "elevated — untested code change inside a duplicate cluster",
input: { changedFiles: [{ path: "src/svc.ts", additions: 12, deletions: 3 }], description: "Add retry logic to the sync client.", inDuplicateCluster: true },
slopRisk: 45,
band: "elevated",
codes: ["duplicate_cluster_membership", "missing_test_evidence"],
},
{
name: "high — whitespace churn, untested code, and empty description",
input: { changedFiles: [{ path: "src/x.ts", additions: 2, deletions: 1 }, { path: "src/state.snap", additions: 60, deletions: 40 }], description: "" },
slopRisk: 75,
band: "high",
codes: ["empty_pr_description", "missing_test_evidence", "trivial_whitespace_churn"],
},
];

it.each(goldenFixtures)("scores the $name fixture to its documented band", (fixture) => {
const result = buildSlopAssessment(fixture.input);
expect(result.slopRisk).toBe(fixture.slopRisk);
expect(result.band).toBe(fixture.band);
expect(result.findings.map((finding) => finding.code).sort()).toEqual(fixture.codes);
expect(JSON.stringify(result)).not.toMatch(FORBIDDEN_PUBLIC_TERMS);
});

it("returns identical slopRisk and findings for identical metadata (determinism)", () => {
for (const fixture of goldenFixtures) {
expect(buildSlopAssessment(fixture.input)).toEqual(buildSlopAssessment(fixture.input));
}
});
});
Loading