Skip to content

[quality] remarkRewriteLinks .mdx stripping branches unit-covered but not exercised end-to-end #440

Done

Description

@hivecommons-hive

Finding

lib/remarkRewriteLinks/index.ts's rewriteHref() has two .mdx-specific
stripping branches:

  • the cross-plugin isCrossPage path (p.toLowerCase().endsWith('.mdx'))
  • the site-absolute SITE_ABSOLUTE_MD_RE path
    (original.toLowerCase().endsWith('.mdx'))

Both are 100% unit-covered in isolation
(lib/remarkRewriteLinks/index.test.mts: 'maps (../)+docs/.../foo.mdx to
/docs/.../foo/' and 'strips .mdx from site-absolute /docs/.../foo.mdx'; unit
run npm run test:unit / npm run test:coverage, c8 100/100/100/100 on
this file as of commit 4a3c592). No suite in e2e/linkRewrite.test.mjs
exercised them against a real Docusaurus build, because every file under
docs/ and analyses/ in this repo is .md, not .mdx. A regression
confined to the .mdx branch (e.g. an endsWith check that silently fell
through and mis-sliced the extension) would pass every existing unit and e2e
test while still shipping broken .mdx link rewriting in a real build.

Recommendation

Add a describe block to e2e/linkRewrite.test.mjs that writes temporary
.mdx fixtures into the real content tree (one exercising the cross-plugin
branch, one the site-absolute branch), runs docusaurus build, asserts the
rewritten hrefs in the output HTML, then deletes the fixtures in an
after() hook so no content change survives the test run.

Priority

  • Evidence: unit-covered (lib/remarkRewriteLinks/index.test.mts, 100% branch
    coverage on this file), not end-to-end-covered (no .mdx fixture existed in
    e2e/linkRewrite.test.mjs or the real docs/analyses content as of commit
    4a3c592)
  • Priority: 2 (medium) - unit-covered, not end-to-end-covered
  • Impact: low-medium (narrow, Docusaurus-adjacent regression surface)
  • Effort: low (one new describe block, no application code changes)

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 4a3c592

Activity

  1. added
    testing
    agent/quality
    on Nov 21, 2026
  2. 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 e2e/linkRewrite.test.mjs, 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: e2e build coverage instrumentation

    Finding

    Over the last several sweeps, "add an e2e test exercising branch X in the
    real Docusaurus build" has been filed and landed as an individual PR more
    than a dozen times, each closing a one-off issue that someone had to spot
    by manually re-reading lib/remarkRewriteLinks/index.ts,
    docusaurus.config.ts, lib/getBuildContext.ts, lib/getCurrentBranch.ts,
    and lib/getGitHubRepoUrl.ts line by line and asking "does any e2e build
    actually reach this branch unit tests already cover?":

    Per the quality-agent policy, three or more instances of the same
    recommendation class mean the missing gate should be put to a decision
    instead of a fifteenth individual finding. The underlying gap is that this
    repository has no automated way to tell which unit-covered branches are
    not yet exercised by the real docusaurus build the e2e suite runs - it
    is found by hand every time, and nothing stops the backlog from growing
    again at the same rate.

    Recommendation

    Instrument the e2e build subprocess with V8 coverage and merge it with the
    existing c8 unit-coverage data, so "unit-covered but not end-to-end
    covered" becomes a report instead of a manual review:

    1. In e2e/linkRewrite.test.mjs, pass NODE_V8_COVERAGE=a scratch directory in the
      execFileSync env when invoking npx docusaurus build, writing raw V8
      coverage for the build subprocess to a scratch directory (or extend
      scripts/coverage-summary.mjs's input handling to accept a second
      source).
    2. After the e2e run, use c8's existing merge support (c8 report --temp-directory that directory combined with the unit run's
      --temp-directory, or c8 merge) to produce one combined
      lines/branches/functions report spanning both suites.
    3. Add an npm run test:coverage:e2e (or extend test:coverage) script
      that fails or warns when a branch is covered by unit tests but absent
      from the merged e2e profile, giving the same signal [quality] remarkRewriteLinks .mdx stripping branches unit-covered but not exercised end-to-end #440/test: cover .mdx link rewriting in the real e2e build #441/test: cover git branch/remote fallback in the real e2e build #444 etc.
      found by hand.

    Steps 1-3 are local npm scripts and test-harness code only - no
    .github/workflows/ changes - so they are within this lane's tier and
    land the same way #420 (the sibling mutation-testing proposal) describes
    for its non-CI steps. Wiring the new script into CI is blocked on the same
    workflows permission as #415/#416/#417 and would be a follow-up once a
    maintainer or ISSUES_PRS_MERGE-tier agent can touch that path.

    Decision needed

    Should this repository adopt automated e2e-coverage merging (V8 coverage
    instrumentation of the e2e build subprocess, merged with the unit c8
    profile) instead of continuing to find "unit-covered, not e2e-covered"
    branches one at a time by manual review? This adds new test-harness
    machinery and changes how coverage gaps are discovered project-wide, so it
    is left to a maintainer rather than decided unilaterally.

    Risk: governance

    Priority

    • Impact: medium (closes the discovery gap that has produced over a dozen
      near-identical individual issues/PRs; does not change runtime behavior)
    • Effort: medium (new instrumentation + merge step in the test harness;
      CI wiring is a separate, blocked follow-up)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | 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 e2e/linkRewrite.test.mjs, 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] getGitHubRepoUrl.ts SSH-remote-URL branch unit-covered but no e2e build exercises it

    Finding

    lib/getGitHubRepoUrl.ts's SSH-remote-URL regex branch (/^git@github\.com:([^/]+\/[^/]+?)(?:\.git)?$/ in normalizeGitHubUrl) is 100% unit-covered in isolation (lib/getGitHubRepoUrl.test.mts), but no e2e build ever sets REPOSITORY_URL to an SSH-form remote. e2e/linkRewrite.test.mjs's deploy-preview suite only ever pins an HTTPS-form REPOSITORY_URL (https://github.com/example-org/example-repo) or clears it entirely to exercise the git-remote fallback (this checkout's own origin is HTTPS, so the fallback path never reaches the SSH branch either). A regression confined to the SSH regex, or to which branch wins when both patterns could match, would pass every existing suite.

    Evidence:

    • Unit: npm run test:coverage reports 100/100/100/100 (lines/branches/functions/statements) across all files, including getGitHubRepoUrl.ts.
    • E2E: node --test 'e2e/**/*.test.mjs' (3 suites, all passing) never sets an SSH-form REPOSITORY_URL. Verified by temporarily nulling the SSH regex match in normalizeGitHubUrl and re-running a build-backed test with an SSH REPOSITORY_URL - it failed as expected, confirming the branch is reachable and currently unguarded end-to-end.

    Recommendation

    Add an e2e suite that builds with REPOSITORY_URL set to an SSH-form value (e.g. git@github.com:example-org/example-repo.git) and asserts the rewritten .csv asset link uses the normalized https://github.com/... form.

    Priority

    • Impact: low (no reliability gap today - the branch is unit-tested; this closes an end-to-end blind spot)
    • Effort: low (one new e2e test, no production code change)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 4a3c592


    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 e2e/linkRewrite.test.mjs, 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] getBuildContext.ts repo/main fallback branches uncovered by e2e

    Finding

    lib/getBuildContext.ts's getCurrentBranch() || 'main' and
    getGitHubRepoUrl() || repo fallback branches (hit only when both
    helpers return undefined during a deploy-preview build) are 100%
    unit-covered in isolation (lib/getBuildContext.test.mts), but before
    this finding no suite in e2e/linkRewrite.test.mjs exercised them
    against a real docusaurus build. Every existing deploy-preview e2e
    case either sets GITHUB_REF_NAME/REPOSITORY_URL directly, or
    clears them but still runs inside this checkout's real git repo, so
    getCurrentBranch()/getGitHubRepoUrl() always return a truthy
    value and the || fallbacks in getBuildContext.ts never run.

    Unit evidence: npm run test:coverage reports 100/100/100/100 for
    getBuildContext.ts (revision b0fe1e8).
    End-to-end evidence (pre-fix): npx c8 --include 'lib/getBuildContext.ts' node --test 'e2e/**/*.test.mjs'
    against revision b0fe1e8 reported 100% stmts/funcs/lines but only
    69.23% branch coverage, with lines 14/16/19/25 (the buildEnv default,
    the isDeployPreview short-circuit, and both || fallbacks) flagged
    uncovered.

    Recommendation

    Add an e2e case that runs a deploy-preview build with every git-fallback
    env var cleared (HEAD/BRANCH/GITHUB_HEAD_REF/GITHUB_REF_NAME/REPOSITORY_URL)
    and GIT_DIR/GIT_WORK_TREE pointed at a nonexistent path so the
    real git branch --show-current/git remote get-url origin calls
    fail safely (without touching this checkout's actual .git), then
    assert the rewritten asset link falls back to the hard-coded repo
    constant and main branch.

    Priority

    • Impact: medium (unit-covered but not end-to-end; a regression in the
      fallback wiring would pass every existing suite)
    • Effort: low (one new e2e describe block in the existing file)

    Filed by quality agent (hold-gated mode)


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

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/qualitytesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions