Skip to content

governor/action-mode.ts's dry-run-by-default precedence logic is invisible to Codecov #8345

Description

@JSONbored

Context

packages/loopover-engine/src/governor/action-mode.ts (#2342) resolves the miner's overall
MinerActionMode (paused | dry_run | live), enforcing "dry-run by default" for autonomous miner
writes: resolveMinerActionMode returns paused when the kill-switch is active (regardless of any live-mode
opt-in), live only when BOTH the operator's global env opt-in AND the target repo's own explicit
liveModeOptIn: "live" literal are present, and dry_run for everything else (including any malformed or
partial config). It also exports the deliberately-non-boolean opt-in literal (MINER_LIVE_MODE_OPT_IN), the
strict-equality checkers (isExplicitMinerLiveModeOptIn, isGlobalMinerLiveModeOptIn), and
buildMinerDryRunGovernorLedgerEvent. It is live and consumed today (packages/loopover-miner/lib/attempt-input-builder.ts
and governor/chokepoint.ts), and it already has a full, passing test suite at
packages/loopover-engine/test/action-mode.test.ts (12 scenarios, node --test).

Same failure mode as #6250 (review-enrichment's node:test suite being invisible to Codecov): that engine
package test suite doesn't run under root vitest, which is what Codecov's codecov/patch gate reads.
packages/loopover-engine/src/**/*.ts is already listed in vitest.config.ts's coverage.include, so this
is a per-file gap — no file under root test/** currently exercises resolveMinerActionMode or its sibling
functions directly, so they report as ~0% covered in Codecov despite real, passing tests existing one
directory over. Note this repo already has plenty of precedent for safety-adjacent governor primitives
having real root-level vitest coverage (e.g. test/unit/miner-governor-kill-switch.test.ts,
test/unit/governor-kill-switch-pagerduty.test.ts) — this issue asks for the same shape of coverage for
action-mode.ts specifically, which is currently missing it.

⚠️ Read this before starting. This issue is test-coverage-only. Do NOT modify
packages/loopover-engine/src/governor/action-mode.ts, packages/loopover-engine/src/governor/kill-switch.ts,
or packages/loopover-engine/test/action-mode.test.ts. The only new artifact this issue calls for is one
new root-level vitest file that exercises the EXISTING, unchanged resolution logic. A PR that changes any
governor source file's behavior — including the kill-switch or live-mode opt-in precedence — does not
satisfy this issue and is out of scope for it.

Requirements

  • Create test/unit/miner-governor-action-mode.test.ts using describe/it/expect from vitest, importing
    resolveMinerActionMode, minerActionModeExecutes, isExplicitMinerLiveModeOptIn,
    isGlobalMinerLiveModeOptIn, buildMinerDryRunGovernorLedgerEvent, MINER_LIVE_MODE_OPT_IN, and
    MINER_LIVE_MODE_ENV_VAR from "../../packages/loopover-engine/src/index" — the barrel — matching the
    existing sibling pattern in test/unit/calibration-dashboard.test.ts. Use a fake/stubbed
    MinerKillSwitchScope the same way packages/loopover-engine/test/action-mode.test.ts already does — do
    not import or exercise the real isMinerKillSwitchActive implementation's own IO paths.
  • Cover, at minimum, every scenario already exercised in packages/loopover-engine/test/action-mode.test.ts
    (read it for the exact fixtures/assertions to mirror), including the full 3-step precedence ladder from
    resolveMinerActionMode's own doc comment:
    1. Kill-switch active → paused, even when both live-mode opt-ins are also present.
    2. Kill-switch inactive, global opt-in true AND repo opt-in exactly "live"live.
    3. Every other combination (global opt-in false; global true but repo opt-in absent/malformed/wrong-case/wrong-type
      like true or "Live" or "1") → dry_run.
    • isExplicitMinerLiveModeOptIn: true only for the exact literal "live"; false for true, "Live",
      "1", undefined, null, and other strings.
    • isGlobalMinerLiveModeOptIn: true only when env.LOOPOVER_MINER_LIVE_MODE === "live" exactly.
    • minerActionModeExecutes: true only for "live".
    • buildMinerDryRunGovernorLedgerEvent: correct eventType/decision/reason fields, and the ??
      fallback for an omitted repoFullName.
  • Every ??, ternary, &&, and strict-equality branch in these functions must have both its taken and
    not-taken branch exercised.

Deliverables

  • New file test/unit/miner-governor-action-mode.test.ts (vitest, imports via the engine barrel).
  • No changes to any file under packages/loopover-engine/src/** or packages/loopover-engine/test/**.

Test Coverage Requirements

packages/loopover-engine/src/governor/action-mode.ts is inside coverage.include in vitest.config.ts and
therefore IS subject to the 99% Codecov codecov/patch branch-counted gate — today it reports ~0% because
nothing under root test/** exercises it directly. After this PR, npm run test:coverage (run unsharded
locally) should show packages/loopover-engine/src/governor/action-mode.ts at or near 100% line/branch
coverage, including every arm of the 3-step precedence ladder.

Expected Outcome

governor/action-mode.ts's already-real, already-tested dry-run-by-default precedence logic becomes visible
to Codecov, so a future PR that changes this file is actually gated on real coverage instead of a blind spot
— closing a gap in exactly the kind of module (miner write-execution gating) where an uncaught regression
would matter most.

Links & Resources

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