Skip to content

[quality] docs/github-app.md Configure table has no contract test against the env the server reads or the chart sets #748

Open

Description

@hivecommons-hive

Finding

Every other operator-facing configuration surface has a test that reads the document against the source it describes: __tests__/configurationDocs.test.ts (docs/configuration.md), __tests__/commands.test.ts (docs/commands.md), __tests__/jobsDocs.test.ts (docs/cron-jobs.md, docs/pr-jobs.md, action.yml jobs), __tests__/docsYamlExamples.test.ts. The "Configure" table in docs/github-app.md (lines 43-59), the one place an operator learns which environment variables the App server takes, which are required and what the defaults are, has none. __tests__/worker/wranglerConfig.test.ts reads the same file but only its Workers setup block.

The table makes 15 claims that src/adapters/app/settings.ts, src/server/node.ts and the chart can each contradict without any test noticing:

  • the variable names (env.PORT, env.PROW_SHUTDOWN_DRAIN_MS, env.PROW_SHUTDOWN_GRACE_MS, env.PROW_CRON_INTERVAL, env.REDIS_URL, env.GITHUB_API_URL, the three required(env, ...) names and the six inputEnv names);
  • which are required (settingsFromEnv throws for exactly three);
  • the defaults (8080, 5000, 25000, lgtm);
  • the "same as <input>" mapping onto action inputs;
  • and the chart's prow-github-app.env block and ConfigMap, which must name only variables the server reads (a mistyped key such as PROW_JOB: renders fine and is silently ignored) and must wire every required one.

Evidence at afe75b9: all 15 claims are currently true (checked by hand and by the test below), so this is drift protection, not a present defect. Unit coverage (npm run test:coverage): 100/99.89/100/100, the two branch misses being the documented v8 await artifacts (approve.ts:516, auth.ts:237), so no line-level gap is involved; this is a test-infrastructure finding for a doc/chart contract, not a coverage-gap.

Recommendation

Add __tests__/githubAppDocs.test.ts, in the style of jobsDocs.test.ts (reading the tree's copies through treeRoot so a Stryker sandbox does not break it), asserting in both directions:

  • one table row per variable the server dereferences, with PROW_REPLICAS (set only by the chart) explained in prose instead
  • yes in Required exactly for the required(env, ...) names
  • every env.X ?? <number> fallback in node.ts and the jobs: 'lgtm' default in settings.ts quoted as the row's default
  • every "same as <input>" row maps to inputEnv and the input exists in action.yml
  • the chart's env block and ConfigMap name only variables the server reads, and wire every required one

Decision taken by hive: one class-level contract test over the whole env surface rather than per-variable pins, matching the pattern the sibling doc tests already use.

Priority

  • Impact: medium (operators configure the server from this table; the chart is generated from the same names)
  • Effort: low (one test file, no src/ change)

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: 840b8f6

Activity

  1. added
    testing
    agent/quality
    on Nov 22, 2026
  2. added
    kind/cleanup
    and removed on Nov 22, 2026
  3. hivecommons-hive commented on Nov 22, 2026

    @hivecommons-hive
    ContributorAuthor

    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 3 closed as completed in the last 14 days) already cite auth.ts, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] Gate proposal: every implemented command must have a bundle scenario (11 of 42 undriven at afe75b9, including /remove-approve and /remove-hold)

    Finding

    __tests__/commands.test.ts already pins two contracts: every command the dispatcher implements has a row in docs/commands.md, and every documented row has a handler. Nothing pins the third leg: that each implemented command is actually driven through dist/index.js by the bundle acceptance harness (__tests__/bundle/).

    At main@afe75b9, taking the same implemented set that commands.test.ts computes (hand-written handlers, the commandAliases table in src/issueComment/handleIssueComment.ts, prefixedLabelCommands and fixedLabelCommands plus their /remove- forms: 42 commands) and searching every __tests__/bundle/*.test.ts for the command as a quoted comment body, 11 are never the body of any bundle scenario:

    • /remove-approve (its own hasCommand('/remove-approve', ...) operand at src/issueComment/approve.ts:46)
    • /remove-hold (its own hasCommand('/remove-hold', ...) operand at src/labels/hold.ts:41)
    • /area, /priority (exclusive: true), /stage, /status
    • /remove-area, /remove-priority, /remove-lifecycle, /remove-stage, /remove-status

    The e2e coverage gate (vitest.e2e-coverage.config.mjs, 99 % lines and branches) cannot see this: /remove-approve and /remove-hold are left-hand operands of || chains whose right-hand operand always runs, so lines and v8 branches read as covered when only /approve cancel and /hold cancel / /unhold are driven. The prefixed commands share one code path with /kind, so they too are line-covered while their data rows (exclusive, registry defaults) are only exercised by unit tests.

    Coverage evidence at afe75b9 (both reproduced locally this kick): unit npm run test:coverage 100 / 99.89 / 100 / 100 (3012 tests, the two branch misses are the documented post-await v8 artefacts at approve.ts:516 and auth.ts:237); e2e npm run test:coverage:e2e 100 / 99.88 / 100 / 100 (581 tests, same two artefacts). Nightly run 44993652121 on the same SHA: every job green. This is therefore not a coverage-gap filing: every line is reached by both suites. It is a measurement blind spot of the e2e gate.

    Why a gate and not another finding

    This is at least the sixth instance of the class "unit-covered command or arm that no bundle scenario drives" this lane has filed in this repository (#251 /hold aliases and /remove success, #295 plain /close and /milestone refusals, the status-event path of tideOnCheckSuite, root-OWNERS authorization in auth.ts, the configured blunderbuss section). #251 named /remove-hold specifically; the PR that closed it (#252) added dispatcherArms.test.ts for the prow-commands input arms and never drove /remove-hold, and nothing since has noticed, which is exactly what a missing gate looks like.

    Proposed gate

    Extend __tests__/commands.test.ts (same file, same implemented set, no new tooling) with a third contract:

    // the commands no bundle scenario drives yet; this list may only shrink
    const undrivenInBundle = new Set([
      '/remove-approve', '/remove-hold',
      '/area', '/priority', '/stage', '/status',
      '/remove-area', '/remove-priority', '/remove-lifecycle', '/remove-stage', '/remove-status',
    ])
    
    it('drives every other implemented command through dist/index.js', () => {
      const bodies = readdirSync(bundleDir).filter(f => f.endsWith('.test.ts'))
        .map(f => read(join(bundleDir, f))).join('\n')
      for (const cmd of implemented) {
        const driven = new RegExp(`['"\`]${cmd}(?:[ '"\`\\\\\\n]|$)`).test(bodies)
        if (undrivenInBundle.has(cmd))
          expect(driven, `${cmd} now has a bundle scenario; remove it from undrivenInBundle`).toBe(false)
        else
          expect(driven, `${cmd} is implemented but no __tests__/bundle scenario drives it`).toBe(true)
      }
    })

    Seeded with today's 11 so it is green on main from the first commit; a new command or alias without a bundle scenario fails build-test, and a scenario that lands for a seeded command fails until the seed entry is removed, so the list only ratchets down. A follow-up PR would then drive /remove-approve and /remove-hold (one scenario each, modelled on holdCancelArms.test.ts and approveReview.test.ts) and delete those two entries; the nine prefixed-command rows can follow at the maintainers' pace or stay seeded if they judge the shared /kind path sufficient.

    Decision taken by hive: the gate lives in the existing commands.test.ts rather than a new file, matches on quoted comment bodies (the form every bundle scenario uses), and is seeded rather than enforced from zero so it lands without any new scenario. Test-only change; no src/ or workflow edit.

    What is being asked

    Accept or decline the gate. If accepted, the lane opens one hold-gated PR with the contract test and the two alias scenarios. If declined, the lane resumes filing the individual gaps above as separate findings.

    Risk: governance

    Priority

    • Impact: medium
    • Effort: low

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: unknown


    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 3 closed as completed in the last 14 days) already cite approve.ts, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] Nightly mutation gate: break 94 admits up to 19 new survivors; check survivors against an explicit allowlist

    Finding

    The scheduled mutation job of .github/workflows/test.yml runs stryker.nightly.config.mjs with thresholds.break: 94. The config comment states the intent: the break is set "just under what main reaches ... so a new behavioural survivor fails the nightly run instead of waiting for someone to run the check by hand".

    The threshold cannot deliver that. At afe75b9 the job (run 45125155064, job mutation) reports 1268 killed, 1 timeout, 60 survived over 1329 mutants, a score of 95.49 %. Every one of those 60 survivors is already triaged as equivalent in the three tables of docs/contributing.md ("Mutation checks"). But 94 % of 1329 allows 79 survivors, so:

    • one new behavioural survivor scores 95.41 % and the job stays green;
    • 19 new survivors pass before the job goes red;
    • the gate cannot tell a triaged-equivalent survivor from a new one, so a surviving mutant only becomes visible when someone reads the clear-text log and compares it against the tables by hand.

    Each file added to mutate (as #721 proposes for lgtmBinding.ts and labels/lgtm.ts) widens that headroom further, because the break is a percentage of a growing total.

    For completeness, the rest of the test evidence at the same revision shows no coverage gap to file: build-test unit coverage (Node 24.22.3) is 100 / 99.89 / 100 / 100 and the e2e-coverage bundle run is 100 / 99.88 / 100 / 100; the two uncovered branch arms in both runs are the documented negative-count await artefacts at approve.ts:516 and auth.ts:237, not code paths.

    Recommendation

    Make the nightly gate exact instead of proportional: fail the run on any survivor that is not on an explicit allowlist, and keep the break score only as a backstop.

    Decision taken by hive: an allowlist checked after stryker run, rather than raising break to just under the current score. A tighter percentage would still admit one survivor whenever the total grows, and would need to move every time a file joins mutate.

    • Add a committed allowlist of reviewed survivors (one file:line per entry, for example reports/mutation/allowed-survivors.txt or a JSON file next to the Stryker configs), seeded from the three tables in docs/contributing.md.
    • Add a small Node script (for example __tests__/mutation/checkSurvivors.mjs) that reads reports/mutation/report.json (the json reporter already writes it), collects mutants with status: "Survived" as file:line, and exits non-zero listing any entry not on the allowlist, and any allowlist entry that no longer survives (so the list cannot rot).
    • Chain it into the existing npm script: "test:mutation:nightly": "stryker run stryker.nightly.config.mjs && node __tests__/mutation/checkSurvivors.mjs". No workflow change is needed; the job already runs that script.
    • Extend __tests__/mutationConfig.test.ts to pin that every allowlist entry is named in a docs/contributing.md table row and vice versa, so the "why" and the gate stay in step.
    • Update the break comment in stryker.nightly.config.mjs to describe it as the backstop it is.

    Sequencing: #721 edits stryker.nightly.config.mjs, __tests__/mutationConfig.test.ts and docs/contributing.md, the same files this change needs. The PR for this issue should be cut after #721 lands (or on top of it) to avoid two held PRs over the same lines.

    Priority

    • Impact: medium (the gate exists and is green, but it does not detect the regression class its own comment says it is there for)
    • Effort: low

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5q9t | SHA: afe75b9

  4. hivecommons-hive commented on Nov 22, 2026

    @hivecommons-hive
    ContributorAuthor

    Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/qualitykind/cleanupstage/040-covered-by-prtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions