Skip to content

fix(coverage): resolve UAT wiring from the reservation registry - #2138

Merged
njhensley merged 7 commits into
NVIDIA:mainfrom
Dhirenderchoudhary:fix/1977-coverage-uat-wiring
Aug 13, 2026
Merged

njhensley merged 7 commits into
NVIDIA:mainfrom
Dhirenderchoudhary:fix/1977-coverage-uat-wiring

Conversation

@Dhirenderchoudhary

Copy link
Copy Markdown
Contributor

Summary

The coverage-matrix generator went blind to the nightly UAT lanes after the reservation-registry rewrite, so make coverage-docs silently downgraded every UAT row. Rewires the scanner to read the registry and the per-cloud pipelines directly, and gates matrix freshness at PR time.

Motivation / Context

Regenerating docs/user/coverage-matrix.md on current main drops uat from 6 rows and demotes evidence verify from covered/nightly to not-yet-covered. The committed page was only accurate because nobody regenerated it — #1967 hand-edited it rather than running the generator.

Two independent causes:

  • uatConfigRef matched a literal tests/uat/<cloud>/tests/<name>.yaml in the workflows. None remain — the pipelines build TEST_CONFIG from inputs resolved out of the reservation registry, so wired.intents came back empty.
  • tests/uat/*/run are shims that source tests/uat/lib/phases.sh. Scanning only the shims found no aicr invocations at all. The one row that kept uat (validate) was matching prose inside a comment in aws/run, not a real invocation.

Fixes: #1977
Related: #1967, #1644

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Build/CI/tooling

Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)
  • API server (cmd/aicrd, pkg/server)
  • Recipe engine / data (pkg/recipe)
  • Bundlers (pkg/bundler, pkg/component/*)
  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)
  • Validator (pkg/validator)
  • Core libraries (pkg/errors, pkg/k8s)
  • Docs/examples (docs/, examples/)
  • Other: tools/coverage, .github/workflows/merge-gate.yaml, Makefile

Implementation Notes

Each fact now comes from the artifact that owns it. infra/uat/reservations.yaml (via pkg/uatbroker) answers which lanes and intents the nightly batch dispatches; the per-cloud uat-<cloud>.yaml pipelines answer which runner phases are enabled steps. tests/uat/lib becomes a UAT signal root, gated on there being at least one enrolled lane so an inert library can't read as live coverage.

Both scans fail closed. Returning an empty result on a moved registry or a renamed input is indistinguishable from "nothing is wired" — that's the exact silent downgrade this generator exists to prevent, and the old fail-open behaviour is why this rotted unnoticed.

Journey coverage requires both halves. A reservation enrolled for the intent and its pipeline actually executing the journey's workload phase. This is the one judgment call worth review: once the scanner reads the registry, cuj2-inference-dynamo wants to flip to covered, because inference is enrolled nightly on aws/gcp/azure/gb200. But serve is commented out in all four pipelines (#1644) — the stack is deployed and validated, the journey never runs. Marking it covered would trade this issue's false negative for a false positive and then lock that into the merge gate, so it stays stubbed with a note pointing at the disabled step instead of the current one citing DC3/DC6, both closed.

Decoding the pipelines as YAML rather than grepping is what makes that readable: a commented-out step is absent from the parsed document, where a raw-text scan matches its invocation verbatim.

Version axis is derived from uat-nightly-batch.yaml's previous_n instead of the hardcoded "the live axis today is main" claim, which stopped being true when the multi-version matrix landed.

Freshness gating: coverage-check joins make qualify, and a coverage-freshness/-skip job pair joins the merge gate (mirroring bom-freshness), watching every signal source. The generator reads only in-repo signals — no network, no cluster — so unlike bom-check it's cheap enough to gate directly.

Net effect on the committed matrix: the 6 UAT rows are restored and now reproducible (the CLI-verb table regenerates byte-identical to what was committed), the version-axis paragraph is corrected, and cuj2-inference keeps an accurate note.

Testing

make coverage-docs   # regenerated; byte-stable across consecutive runs
GOFLAGS=-mod=vendor go test ./tools/coverage/... -count=1 -race
GOFLAGS=-mod=vendor go test ./pkg/uatbroker/... ./tools/uat-broker/... ./tests/uat/...
GOFLAGS=-mod=vendor golangci-lint run -c .golangci.yaml ./...
GOFLAGS=-mod=vendor go vet ./...
make lint-yaml check-docs-mdx check-docs-filenames license check-agents-sync
actionlint .github/workflows/merge-gate.yaml

All green. golangci-lint reports 0 issues module-wide.

Coverage delta — tools/coverage: 82.2% → 85.5% (+3.3%).

I mutation-tested the new guards to confirm they aren't vacuous (each mutation reverted after):

Mutation Caught by
Remove the tests/uat/lib scan target (the original bug) TestBuildMatrixStatusFromSignals, TestUATVerbsResolveThroughSharedPhaseLibrary, TestRepoUATLanesAreVisible
Drop the journey-phase gate (intent-only coverage) TestJourneyStepDisabledIsNotCovered
Make the registry load fail-open TestBuildMatrixFailsClosed

TestRepoUATLanesAreVisible runs the real scanner against the real repo as a standing anti-rot guard — if the registry moves or the phase commands migrate out of tests/uat/lib again, it fails there instead of silently downgrading the next regeneration.

Two caveats on the full suite: I could not run make qualify end to end (e2e and scan need Docker + registry access I don't have locally), and full make test has pre-existing failures in pkg/oci (TestHelmV4_2_3ExplicitVersionPull) and tests/releasepolicy (needs GNU timeout, absent on macOS). I confirmed the identical failure set on unmodified origin/main, so neither is from this change. Leaving those to CI.

Risk Assessment

  • Low — Isolated change, well-tested, easy to revert
  • Medium — Touches multiple components or has broader impact
  • High — Breaking change, affects critical paths, or complex rollout

The generator change itself is isolated and revertible, but this adds a new blocking merge-gate job, so a false positive there would block unrelated PRs.

Rollout notes: coverage-freshness only fires on PRs touching the matrix inputs (the doc, tools/coverage, pkg/cli, pkg/uatbroker, infra/uat/reservations.yaml, the uat-*.yaml pipelines, tests/uat, tests/chainsaw, demos, Makefile); everything else hits the -skip companion. The failure message names the fix (make coverage-docs and commit). No migration, no flags, backwards compatible — revert the workflow hunk to disable the gate without touching the generator.

Checklist

  • Tests pass locally (make test with -race) — see the caveat above on two pre-existing env failures
  • Linter passes (make lint)
  • I did not skip/disable tests to make CI green
  • I added/updated tests for new functionality
  • I updated docs if user-facing behavior changed
  • Changes follow existing patterns in the codebase
  • Commits are cryptographically signed (git commit -S)

@Dhirenderchoudhary
Dhirenderchoudhary requested review from a team as code owners August 9, 2026 17:53
@copy-pr-bot

copy-pr-bot Bot commented Aug 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Welcome to AICR, @Dhirenderchoudhary! Thanks for your first pull request.

Before review, please ensure:

  • All commits are signed off per the DCO
  • CI checks pass (tests, lint, security scan)
  • The PR description explains the why behind your changes

A maintainer will review this soon.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The coverage generator now reads UAT enrollment, cloud pipeline phases, shared UAT libraries, and nightly version inputs. It reports distinct stub causes and fails on invalid wiring. Matrix construction returns errors before rendering. Tests add fixture-backed regression coverage. make qualify and the merge gate now run coverage freshness checks for relevant changes.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • NVIDIA/aicr#2148: Updates Makefile qualification workflow documentation related to coverage freshness validation.
  • NVIDIA/aicr#2166: Modifies merge-gate path-filter logic for conditional validation jobs.

Suggested labels: area/tests

Suggested reviewers: mchmarny, almaslennikov

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: resolving UAT wiring through the reservation registry.
Description check ✅ Passed The description directly explains the UAT wiring fix, coverage regeneration, freshness gating, tests, and rollout impact.
Linked Issues check ✅ Passed The changes satisfy issue #1977 by fixing UAT discovery, version-axis handling, fail-closed validation, and coverage freshness gating.
Out of Scope Changes check ✅ Passed The workflow, Makefile, documentation, generator, and tests support the linked issue objectives and do not show unrelated code changes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/user/coverage-matrix.md`:
- Line 18: Update the coverage-matrix rendering for the stub rows: when
noteJourneyStepDisabled applies, display “GPU (H100, real)” and “nightly”; when
noteIntentNotEnrolled applies, retain “GPU (unwired)” and “—”.

In `@tools/coverage/build_test.go`:
- Around line 507-517: Replace the equalStrings helper and its call site with
the standard library slices.Equal function, adding the slices import to
tools/coverage/build_test.go. Remove the now-unused equalStrings function and
preserve the existing comparison behavior.

In `@tools/coverage/scan.go`:
- Around line 64-65: Update the UAT scanning flow around scanVerbs and the
shared tests/uat/lib target so it includes only function bodies for phases
enabled by each enrolled lane’s wiredUAT.lane.phases, rather than all
shared-library commands whenever runners exist. Ensure unknown or invalid phase
configuration fails closed. Add coverage for an enrolled train phase and
disabled serve phase containing a unique CLI verb, verifying only the train verb
is reported.
- Around line 49-68: Update scanVerbs and BuildMatrix to propagate a structured
error when any enrolled runner path or the gated tests/uat/lib target is
missing, rather than relying on walkSignalFiles to skip it. Preserve normal
scanning for existing targets, and ensure callers receive the error so
incomplete coverage cannot produce a successful matrix.

In `@tools/coverage/wiring.go`:
- Line 257: Update the os.Open call in the coverage wiring code so the rationale
is a separate ordinary comment immediately before it, and leave //nolint:gosec
alone on its own line. Preserve the existing suppression and
repository-relative-path rationale while making the directive self-contained.
- Around line 193-199: Update the phase detection around phaseRef and the
wf.Jobs step iteration to ignore shell-commented command lines before matching
runner invocations. Ensure lines whose executable content begins with # do not
populate phases, while valid commands continue to be detected; add a fixture and
assertion confirming a commented runner command produces no UAT coverage, with
ambiguous or disabled signals failing closed.
- Around line 256-268: Update BuildMatrix and readBoundedFile to accept and
propagate a timeout-bounded context using the project’s named timeout default,
and use context-aware I/O for opening and reading files. Before reading,
validate the target is a supported regular file and reject special files or
symlink-resolved unsupported types.
- Around line 181-183: Validate the computed relative workflow path in the
surrounding wiring function before joining it with repoRoot: call
filepath.IsLocal on the native relative path derived from cloud and return the
established structured invalid-request error when validation fails. Keep the
existing readBoundedFile flow unchanged for local paths, and do not replace this
check with substring-based validation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 3436042f-751d-4709-8de8-53d5f56d38ca

📥 Commits

Reviewing files that changed from the base of the PR and between 602c8db and d693818.

📒 Files selected for processing (10)
  • .github/workflows/merge-gate.yaml
  • Makefile
  • docs/user/coverage-matrix.md
  • tools/coverage/build.go
  • tools/coverage/build_test.go
  • tools/coverage/main.go
  • tools/coverage/model.go
  • tools/coverage/render.go
  • tools/coverage/scan.go
  • tools/coverage/wiring.go

Comment thread docs/user/coverage-matrix.md Resolved
Comment thread tools/coverage/build_test.go Resolved
Comment thread tools/coverage/scan.go Resolved
Comment thread tools/coverage/scan.go Resolved
Comment thread tools/coverage/wiring.go Resolved
Comment thread tools/coverage/wiring.go Resolved
Comment thread tools/coverage/wiring.go
Comment on lines +256 to +268
func readBoundedFile(path, rel string) ([]byte, error) {
f, err := os.Open(path) //nolint:gosec // fixed repo-relative path under the repo root
if err != nil {
return nil, errors.Wrap(errors.ErrCodeNotFound, "open "+rel, err)
}
defer func() { _ = f.Close() }()

data, err := io.ReadAll(io.LimitReader(f, maxScanFileBytes+1))
if err != nil {
return nil, errors.Wrap(errors.ErrCodeInternal, "read "+rel, err)
}
if int64(len(data)) > maxScanFileBytes {
return nil, errors.New(errors.ErrCodeInvalidRequest, rel+" exceeds the scan size limit")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Bound read time as well as read size.

io.LimitReader limits bytes only. os.Open or io.ReadAll can block indefinitely on a special file reached through a repository symlink.

Thread a timeout-bounded context from BuildMatrix into file reads. Reject unsupported file types before reading them.

As per coding guidelines, all I/O operations must use a timeout-bounded context and named defaults.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/coverage/wiring.go` around lines 256 - 268, Update BuildMatrix and
readBoundedFile to accept and propagate a timeout-bounded context using the
project’s named timeout default, and use context-aware I/O for opening and
reading files. Before reading, validate the target is a supported regular file
and reject special files or symlink-resolved unsupported types.

Source: Coding guidelines

Comment thread tools/coverage/wiring.go
// against the repo-relative name rel. Bounded rather than os.ReadFile so an
// unexpectedly huge (or symlinked) input cannot balloon the generator.
func readBoundedFile(path, rel string) ([]byte, error) {
f, err := os.Open(path) //nolint:gosec // fixed repo-relative path under the repo root

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Keep the nolint directive self-contained.

Move the rationale to a normal comment before the directive. Keep //nolint:gosec on its own line.

Based on learnings, directive-shaped comments must be self-contained because gofmt can separate continuation text from the directive.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/coverage/wiring.go` at line 257, Update the os.Open call in the
coverage wiring code so the rationale is a separate ordinary comment immediately
before it, and leave //nolint:gosec alone on its own line. Preserve the existing
suppression and repository-relative-path rationale while making the directive
self-contained.

Source: Learnings

@Dhirenderchoudhary
Dhirenderchoudhary force-pushed the fix/1977-coverage-uat-wiring branch from d693818 to d7307ae Compare August 9, 2026 18:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/coverage/build_test.go`:
- Around line 343-346: Update the rowByItem assertion for
"cuj2-inference-dynamo" to retain and validate its ok result before inspecting
r.Harnesses[HarnessUAT]. Fail the test when the row is absent, then preserve the
existing negative UAT-coverage assertion for an existing row.

In `@tools/coverage/wiring.go`:
- Around line 194-211: Update the phaseRef pattern used in the phase scan to
match valid phase tokens containing digits, hyphens, or underscores, while
preserving the existing cloud-specific path and command boundary. Ensure phases
such as “cuj2-serve” are captured so the downstream phases map and runsJourney
logic receive the correct enabled phase.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 42c24872-5347-4823-9002-3b893584da23

📥 Commits

Reviewing files that changed from the base of the PR and between d693818 and d7307ae.

📒 Files selected for processing (4)
  • tools/coverage/build.go
  • tools/coverage/build_test.go
  • tools/coverage/scan.go
  • tools/coverage/wiring.go

Comment thread tools/coverage/build_test.go Resolved
Comment thread tools/coverage/wiring.go Resolved

@njhensley njhensley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — multi-persona + adversarial meta-review

Method: four independent persona reviewers (Correctness · CI/Operability · Domain & Architecture · Test-coverage), then an adversarial senior meta-reviewer that re-derived every finding against the resolved code at 34f506f6.

Legend: 🔴 Blocker · 🟠 Major · 🟡 Minor · 🔵 Nitpick

Overall — Approve with comments

Well-reasoned, well-tested fix for a real silent-downgrade bug (#1977). The old generator regex-scraped uat-*.yaml for literal tests/uat/<cloud>/tests/<name>.yaml config paths that no longer exist after the reservation-registry rewrite, so it saw zero wired lanes and quietly demoted every UAT row. The rewrite sources each fact from the artifact that owns it — which lanes/intents from infra/uat/reservations.yaml (via pkg/uatbroker), which phases from the per-cloud pipelines decoded as YAML — fails closed on unresolvable inputs, and gates freshness in both make qualify and the merge gate.

Verified the honesty contract against the real files: all four pipelines (aws/gcp/azure/kind) enable train and comment out serve, so cuj1→covered and cuj2→stubbed with the accurate journey-step-disabled note. The test suite is strong (86.2%; all three advertised mutations genuinely caught; the fail-closed table's error substrings all match real errors). No blockers, no majors.

Two 🟡 (both latent, not live in the current tree) and three 🔵 are inline / below.

Additional nitpicks (anchor to unchanged lines, so noted here)

  • 🔵 Verb-level UAT coverage doesn't honor disabled phases — tools/coverage/scan.go#L193. scanVerbs reads phases.sh as one blob, so a verb reachable only from a disabled phase function would still be UAT-covered — asymmetric with the phase-gated CUJ rows. Harmless today (phase_serve has no aicr invocation); latent if a serve-only verb is added later.
  • 🔵 looksLikeText branch has 0% coverage — tools/coverage/scan.go#L181. Extensionless text-sniff path is never walked; a one-line extensionless-script fixture under tests/chainsaw/ would close it.
  • 🔵 kind single-GPU nvkind collapses into the coarse "GPU (H100, real)" class — tools/coverage/build.go. The hardware/cadence columns union all lanes, so today enrolling kind flips no verdict; latent overclaim only if a future intent runs only on the kind lane. Not introduced by this PR.

Confirmed non-issues (examined, cleared)

  • Refuted — "axis prose overclaims by ignoring nightly-intent-min-versions": the premise was wrong — v0.18.0 and v0.19.0 are both shipped, so the >= v0.18.0 gate is satisfied by the previous-release cell; and the generator uses NightlyIntentsOrDefault, never EligibleNightlyIntents, so the min-version gate never touches the matrix. Prose is accurate.
  • readBoundedFile bounded-read pattern is correct (LimitReader(f, max+1), >max reject; read-only Close ignored per repo rules).
  • yaml:"on" tag decodes correctly under yaml.v3 (no YAML 1.1 boolean-alias issue).
  • Determinism holds (sorted clouds, membership-only maps). All-opted-out registry → zero lanes with no error is correct-by-design, not fail-open.
  • coverage-freshness/-skip are mutually exclusive over the boolean paths-filter output; the aggregate gate can't deadlock; pinned SHAs; no network/cluster/tool deps ("in-repo signals only" confirmed — no os/exec, net/http, or go build).
  • pkg/uatbroker coupling is the correct dependency direction and eliminates schema drift; the paths-filter watches every signal the generator reads.

Summary

🔴 Blocker 0 · 🟠 Major 0 · 🟡 Minor 2 · 🔵 Nitpick 3 — Approve with comments. Neither 🟡 is live in the current tree; both are cheap hardening opportunities, not merge blockers.

Comment thread tools/coverage/wiring.go Outdated
w.runners = append(w.runners, r)
if len(phases) == 0 {
return nil, errors.New(errors.ErrCodeNotFound,
rel+" declares no enabled UAT runner step, but its cloud is enrolled in the nightly batch")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor — Fail-closed on a fully-commented enrolled pipeline breaks every local make qualify

When an enrolled cloud (non-empty nightly-intents in reservations.yaml) has ALL runner steps commented out in its uat-<cloud>.yaml, scanLanePhases returns this error → BuildMatrix fails → make coverage-check exits 1. Because coverage-check is wired into qualify UNCONDITIONALLY (Makefile:296) — unlike the path-filtered merge-gate job — this breaks every developer's make qualify regardless of what they changed, until the state is reconciled.

Blast radius: The realistic trigger is contrived (the real disabled-serve case keeps train enabled), so this is design tension rather than a bug — but the opt-out that fixes it (nightly-intents: [] on that cloud's reservation) is documented only in reservations.yaml, not at this error site or the Makefile.

Fix: Name the opt-out in the error string (or the coverage-check Makefile comment) so a pipeline maintenance window doesn't turn into a confusing toolchain-wide make qualify failure. Optionally degrade a single otherwise-reachable lane to a stubbed row rather than a hard BuildMatrix error.

Comment thread tools/coverage/wiring.go Outdated
// commented line inside one survives into step.Run and would otherwise
// read as an executed phase.
for _, line := range strings.Split(step.Run, "\n") {
if strings.HasPrefix(strings.TrimSpace(line), "#") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Minor — scanLanePhases only strips full-line comments — a trailing/echo-embedded runner ref is a false phase match

This filter skips a line only when its trimmed prefix is # (full-line comment), then runs phaseRef against the whole surviving line. A trailing inline comment or echo-embedded reference — e.g. echo done # ./tests/uat/aws/run serve "${TEST_CONFIG}" — registers serve as executed (reproduced independently by two reviewers as map[serve:true]), flipping cuj2-inference-dynamo from stubbed to covered and claiming real GPU-nightly coverage that never ran. This is exactly the comment-block false-credit the YAML-decode design exists to prevent — the fix went halfway.

Blast radius: Latent, not live: today's disabled serve steps are full YAML comment blocks (stripped by yaml.Unmarshal before reaching step.Run) and enabled steps are bare invocations, so nothing triggers it in-repo. A future contributor disabling a phase with an inline comment would silently over-report the journey.

Fix: Cut each line at its first unquoted # before matching (or anchor the match to the line's first command token), and add a trailing-comment-only case to TestShellCommentedPhaseIsNotExecuted.

Comment thread tools/coverage/wiring.go Outdated
return VersionAxis{}, errors.New(errors.ErrCodeNotFound,
nightlyBatchRelPath+" declares no "+previousNInput+" input; the version axis cannot be derived")
}
n, err := strconv.Atoi(input.Default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Nitpick — Version axis reads the workflow_dispatch input default, not the cron's || '1' fallback (comment misstates GHA semantics)

scanVersionAxis reads on.workflow_dispatch.inputs.previous_n.default, and the comment above claims the cron uses that default. It does not: on a schedule event the inputs context is empty and workflow_dispatch defaults are NOT applied — which is precisely why uat-nightly-batch.yaml uses a separate literal PREVIOUS_N: ${{ inputs.previous_n || '1' }}. The true scheduled value is the || '1' fallback, not the input default.

Blast radius: Both literals are '1' today so the rendered prose is correct, and the freshness gate reads the same default so CI stays green even under drift — only a human reader is misled if someone bumps one literal and not the other. Cosmetic doc prose.

Fix: Source the axis from the || 'N' fallback the cron actually uses (or assert the two literals agree and fail closed on mismatch), and correct the comment about GitHub schedule/inputs semantics.

Resolve merge-gate.yaml conflict by keeping both coverage-freshness and docs-mdx path filters.

Signed-off-by: Dhirender Choudhary <[email protected]>
Strip trailing shell comments before phase matching, name the
nightly-intents opt-out in the empty-pipeline error, and require the
schedule || 'N' fallback to agree with the dispatch default.

Signed-off-by: Dhirender Choudhary <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@Dhirenderchoudhary

Copy link
Copy Markdown
Contributor Author

@njhensley

Thanks for the thorough review really helpful.

Addressed both yellows and the version-axis nit in e597f0cd:

  • empty enrolled pipeline error now names the nightly-intents: [] opt-out
  • phase scan strips trailing/unquoted # before matching (with a trailing-comment test)
  • version axis requires the schedule || 'N' fallback to agree with the dispatch default

Also merged main and cleared the merge-gate.yaml conflict. Happy to follow up on anything else.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (3)
tools/coverage/wiring.go (2)

188-189: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate the derived workflow path before joining it to repoRoot.

cloud comes from the reservation registry and builds rel. A traversal segment makes filepath.Join resolve outside the repository. Check the native relative path with filepath.IsLocal and return a structured invalid-request error when the check fails.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/coverage/wiring.go` around lines 188 - 189, Validate the derived rel
path immediately after constructing it in the workflow-loading flow, before
joining it with repoRoot. Use filepath.IsLocal on the native relative path and,
when validation fails, return the established structured invalid-request error;
otherwise preserve the existing readBoundedFile call.

320-334: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Bound read time as well as read size.

io.LimitReader caps bytes only. os.Open and io.ReadAll can block on a special file reached through a repository symlink. Pass a timeout-bounded context from BuildMatrix into the file reads, and reject non-regular files before reading.

As per coding guidelines, "All I/O operations need context with timeout".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/coverage/wiring.go` around lines 320 - 334, The readBoundedFile flow
currently limits bytes but not I/O duration and accepts special files. Update
BuildMatrix to create and pass a timeout-bounded context into each file read,
change readBoundedFile to use that context and abort reads when it expires, and
validate the opened path with FileInfo.Mode().IsRegular() before io.ReadAll,
returning an appropriate error for non-regular files.

Source: Coding guidelines

tools/coverage/scan.go (1)

71-72: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Shared-library verbs are still not filtered by enabled phases.

scanTargets adds all of tests/uat/lib when any runner is enrolled. wiredUAT.lanes[].phases is not consulted here, so a CLI verb that only appears in a disabled phase function reads as UAT-covered. scanCUJ applies the phase gate for CUJ rows, but CLI verb rows keep the unfiltered signal.

Scan only the shared function bodies for phases enabled on an enrolled lane. Add a test with an enabled train phase and a disabled serve phase that contains a unique CLI verb.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tools/coverage/scan.go` around lines 71 - 72, Update scanTargets and the
shared-library scanning flow to consult each enrolled lane’s
wiredUAT.lanes[].phases, scanning only function bodies belonging to enabled
phases; prevent CLI verbs defined exclusively in disabled phases from being
reported as UAT-covered. Add coverage for an enabled train phase and disabled
serve phase containing a unique CLI verb, asserting the disabled-phase verb is
excluded.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/merge-gate.yaml:
- Around line 175-200: Add `.github/workflows/merge-gate.yaml` to the `coverage`
filter’s watched paths so changes to the `coverage-freshness` job definition
trigger that gate, matching the existing self-gating behavior of the `deps` and
`docs` filters.

In `@tools/coverage/model.go`:
- Around line 88-92: Update the comment above PreviousReleases to state that
scheduled runs use the literal `${{ inputs.previous_n || 'N' }}` fallback
because the schedule event has no inputs, rather than the workflow input
default. Keep the explanation that zero runs main only and ensure the documented
fallback agrees with scanVersionAxis.

In `@tools/coverage/wiring.go`:
- Around line 238-254: Update stripShellComment so backslash escape handling
applies only inside double quotes or outside quotes, never while inSingle is
true. Preserve skipping the next character for those permitted contexts,
allowing literal backslashes in single-quoted text and escaped # characters
outside quotes to avoid starting a comment.

---

Duplicate comments:
In `@tools/coverage/scan.go`:
- Around line 71-72: Update scanTargets and the shared-library scanning flow to
consult each enrolled lane’s wiredUAT.lanes[].phases, scanning only function
bodies belonging to enabled phases; prevent CLI verbs defined exclusively in
disabled phases from being reported as UAT-covered. Add coverage for an enabled
train phase and disabled serve phase containing a unique CLI verb, asserting the
disabled-phase verb is excluded.

In `@tools/coverage/wiring.go`:
- Around line 188-189: Validate the derived rel path immediately after
constructing it in the workflow-loading flow, before joining it with repoRoot.
Use filepath.IsLocal on the native relative path and, when validation fails,
return the established structured invalid-request error; otherwise preserve the
existing readBoundedFile call.
- Around line 320-334: The readBoundedFile flow currently limits bytes but not
I/O duration and accepts special files. Update BuildMatrix to create and pass a
timeout-bounded context into each file read, change readBoundedFile to use that
context and abort reads when it expires, and validate the opened path with
FileInfo.Mode().IsRegular() before io.ReadAll, returning an appropriate error
for non-regular files.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 7a168e3a-9ac6-498a-95ff-480b1cb8dcda

📥 Commits

Reviewing files that changed from the base of the PR and between 63c79ec and e597f0c.

📒 Files selected for processing (10)
  • .github/workflows/merge-gate.yaml
  • Makefile
  • docs/user/coverage-matrix.md
  • tools/coverage/build.go
  • tools/coverage/build_test.go
  • tools/coverage/main.go
  • tools/coverage/model.go
  • tools/coverage/render.go
  • tools/coverage/scan.go
  • tools/coverage/wiring.go

Comment thread .github/workflows/merge-gate.yaml Resolved
Comment thread tools/coverage/model.go Resolved
Comment thread tools/coverage/wiring.go Resolved
Self-gate coverage-freshness via merge-gate.yaml, align the
PreviousReleases comment with the schedule fallback, tighten
stripShellComment escapes, and reject non-local UAT cloud paths.

Signed-off-by: Dhirender Choudhary <[email protected]>
@njhensley

Copy link
Copy Markdown
Member

@Dhirenderchoudhary, please ensure your commits are signed and verified. Thanks!

@Dhirenderchoudhary

Copy link
Copy Markdown
Contributor Author

@njhensley Verified and signed

@github-actions

Copy link
Copy Markdown
Contributor

@njhensley

Copy link
Copy Markdown
Member

@Dhirenderchoudhary, please address linting issues. Should be good to go after that.

Signed-off-by: Dhirender Choudhary <[email protected]>
@Dhirenderchoudhary
Dhirenderchoudhary force-pushed the fix/1977-coverage-uat-wiring branch from 97e6469 to fc82377 Compare August 13, 2026 16:54
@Dhirenderchoudhary

Copy link
Copy Markdown
Contributor Author

FIxed lint CI failures

@njhensley
njhensley enabled auto-merge (squash) August 13, 2026 17:55

@njhensley njhensley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good on my end — approving! ✅

Everything from the review is now buttoned up:

  • Fail-closed opt-out names nightly-intents: [] in both the error string and the Makefile comment — no more mystery make qualify failures during pipeline maintenance. 👍
  • Comment stripping got a proper quote/backslash-aware stripShellComment with its own TestStripShellComment plus a trailing-comment case in TestShellCommentedPhaseIsNotExecuted. Closes the false-credit gap cleanly.
  • Version axis now reads the real || 'N' schedule fallback and asserts it agrees with the dispatch default (fails closed on drift), with the GHA semantics fixed in the comment and the model.go godoc.
  • gofmt — confirmed fixed in fc82377; lint is clean now.

Re-verified against the real repo: go test ./tools/coverage/... -race passes (including TestRepoUATLanesAreVisible), and coverage-matrix.md regenerates byte-identical and stable across runs. The filepath.IsLocal guard and merge-gate self-gating hunk are both correct too.

Really thorough follow-through on every point — thanks for that. 🚀

@njhensley
njhensley merged commit 0dc556e into NVIDIA:main Aug 13, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/coverage wired-runner scanner blind to UAT lanes after reservation-registry rewrite

2 participants