Skip to content

Add test coverage for decidePublicSurface's oss_maintainer + not_checked auto-label fallback #8324

Description

@JSONbored

Context

src/signals/settings-preview.ts's decidePublicSurface is documented as "the single source of truth" for what the GitHub App's public surface does for a PR, "shared by the live webhook processor and the maintainer-facing dry-run preview, so the preview can never drift from real behavior." Its willLabel computation (around line 143-146) is:

const willLabel =
  shouldApplyPrLabel(settings, input.minerStatus) ||
  (settings.publicAudienceMode === "oss_maintainer" && input.minerStatus === "not_checked" && settings.autoLabelEnabled && (settings.publicSurface === "comment_and_label" || settings.publicSurface === "label_only"));

The second disjunct is an inline fallback condition that duplicates (and diverges from) the logic already encapsulated in the imported shouldApplyPrLabel function — it exists specifically to handle publicAudienceMode: "oss_maintainer" combined with minerStatus: "not_checked", a real combination that governs whether a webhook run (src/queue/processors.ts) actually applies a label without having completed the official Gittensor miner lookup.

This exact branch has zero test coverage: grep -n "not_checked" test/unit/settings-preview.test.ts returns no matches at all. Given the function's own stated "single source of truth, preview can never drift from real behavior" contract, an untested fallback branch is a real risk — if shouldApplyPrLabel's own logic changes in the future without a matching update here, this inline condition could silently diverge from the imported function's intent with no test catching it.

Requirements

  • Add test coverage in test/unit/settings-preview.test.ts for decidePublicSurface with settings.publicAudienceMode: "oss_maintainer" and input.minerStatus: "not_checked", covering:
    • autoLabelEnabled: true with publicSurface: "comment_and_label"willLabel (and thus the label action) is included.
    • autoLabelEnabled: true with publicSurface: "label_only"willLabel is included.
    • autoLabelEnabled: true with publicSurface: "comment_only"willLabel is NOT included (the disjunct's own publicSurface check must exclude this).
    • autoLabelEnabled: falsewillLabel is NOT included via this fallback (falls back to shouldApplyPrLabel's own result).
  • Do not change decidePublicSurface's behavior as part of this issue — this is a test-coverage gap on existing, currently-uncovered branchy logic, not a behavior change. If while writing the tests a genuine divergence from shouldApplyPrLabel's intent is found, note it in the PR description rather than silently "fixing" it, since intent here needs a maintainer read.

Deliverables

  • New test cases in test/unit/settings-preview.test.ts exercising all four combinations above for the oss_maintainer + not_checked fallback branch of willLabel.

Test Coverage Requirements

This repo's Codecov patch gate requires 99%+ coverage of changed lines and branches — since this issue is pure test addition (no production code changes), the goal is closing the existing branch-coverage gap on decidePublicSurface's willLabel computation, specifically every operand of the && chain in the second disjunct.

Expected Outcome

decidePublicSurface's oss_maintainer + not_checked labeling fallback is exercised by explicit tests for every combination of autoLabelEnabled and publicSurface, closing a real branch-coverage gap on a function whose own doc comment claims it's the authoritative, drift-proof source of truth for this behavior.

Links & Resources

  • src/signals/settings-preview.tsdecidePublicSurface, willLabel computation around line 143-146
  • test/unit/settings-preview.test.ts — existing coverage (533 lines), no not_checked cases today

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions