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
11 changes: 10 additions & 1 deletion packages/gittensory-miner/lib/replay-task-generation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ export type ReplayScoringKey = {
groundTruth: unknown;
};

// generateReplayScoringKey never lints/scrubs frozen context (it doesn't touch context text at all), so
// unlike ReplayTaskRejected it can only ever reject on selection -- narrower than reusing ReplayTaskRejected,
// which would advertise an "unscrubbable_forward_reference" branch this function can never actually produce.
export type ReplayScoringKeyRejected = {
eligible: false;
rejected: "selection";
reasons: string[];
};

export function detectForwardReferences(
text: unknown,
context: ForwardRefContext | null | undefined,
Expand Down Expand Up @@ -114,4 +123,4 @@ export function generateReplayTask(
export function generateReplayScoringKey(
candidate: FreezePointCandidate | null | undefined,
options: ReplayTaskOptions | null | undefined,
): ReplayScoringKey | ReplayTaskRejected;
): ReplayScoringKey | ReplayScoringKeyRejected;
22 changes: 22 additions & 0 deletions test/unit/miner-replay-task-generation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,27 @@ describe("gittensory-miner leakage-safe replay task generation (#3011)", () => {
reasons: ["insufficient_prior_history", "insufficient_revealed_history"],
});
});

// REGRESSION: pins the intentional eligibility asymmetry documented on generateReplayScoringKey itself --
// it never lints/scrubs frozen context, so a candidate generateReplayTask rejects for an unscrubbable
// forward reference still yields a scoring key here. A caller must not assume the two are a matched pair
// without checking generateReplayTask's own result (see the same candidate's rejection above).
it("still returns a scoring key for a candidate whose frozen context generateReplayTask rejects as unscrubbable", () => {
const candidate = { ...eligible, frozenContextTexts: ["the tally hit 250 last month"] };

const replayTask = generateReplayTask(candidate, CONTEXT, options);
expect(replayTask).toEqual({
eligible: false,
rejected: "unscrubbable_forward_reference",
residual: [{ kind: "bare-issue-number", value: 250 }],
});

const scoringKey = generateReplayScoringKey(candidate, options);
expect(scoringKey).toEqual({
eligible: true,
commitCount: 10,
groundTruth: { merged: true, approach: "refactor" },
});
});
});
});
Loading