Skip to content

[scanner] Gate proposal: auto-re-anchor drifted src/docs line-range citations #14713

Closed

Description

@hivecommons-hive

Class

Line-range citations in src/docs/*.md that point into frequently edited Go files drift every time the cited function moves, turning the required relative links and anchors resolve check red on the default branch and on every open PR until someone hand-edits a number.

Prior instances (same root cause, same site)

  1. docs: fix drifted scale-envelope citation failing link check fleet-wide [scanner] #9389 — scale-envelope.md citation into client.go drifted, fleet-wide red
  2. 📖 docs: refresh scale-envelope client.go citation (v5 docs-citation check red) #11740 — same citation drifted again, v5 red
  3. [shared-ci] relative links and anchors resolve failing across hivecommons/hive #14711 / 📖 docs: re-anchor the RankActionableIssues citation in scale-envelope.md #14712 — same citation drifted a third time after 🐛 dashboard: anchor tracker rows on the open PR when the issue has closed #14657 grew RankActionableIssues

Each one was a one-line docs PR plus a [shared-ci] incident, a stamped comment on every affected PR, and a kick cycle of lost merges.

Missing gate

src/scripts/check-docs-citations.py already parses the backticked symbol anchors next to each citation (RankActionableIssues, AgeMinutes), but --fix only delegates to the older api-reference.md fixer. Proposal: teach --fix to re-anchor any citation whose anchors are found elsewhere in the target file (move/widen the range to the span that contains every anchor), and run it in one of two places:

  • A. In the existing relative links and anchors resolve job: run --fix, and if it produced a diff, fail with the exact sed/patch to apply (the same shape as check-api-reference-citations.sh --fix output). Keeps CI read-only; makes the repair a copy-paste.
  • B. As a post-merge auto-fix workflow on v5 (like cli-pin-bump): run --fix, open a signed docs PR when the default branch drifts, so PRs are never red for a base-branch citation.

Either keeps the check as the verdict; the difference is who types the number.

Decision taken by hive: none yet — this changes what CI is allowed to rewrite, so it is parked for a maintainer accept/decline.

Risk: governance

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Activity

  1. added
    agent/scannerCreated or modified by the scanner agent
    stage/045-needs-decisionIssue parked on a person: needs-human or a maintainer decision is owed before the hive picks it up
    on Oct 27, 2026
  2. hivecommons-hive commented on Oct 27, 2026

    @hivecommons-hive
    ContributorAuthor

    What to reply

    • /hive approve: go with the recommendation
    • /hive decision <your instructions>: go ahead, following your instructions
    • /hive help: show these again

    If what this issue waited on has been done (a merged fix, or an action taken outside this repository), a maintainer can reply /fixed to close it as completed; Hive clears its park labels.

    Only a maintainer with write access can un-park; everything else is ignored. Full command reference: https://github.com/hivecommons/hive/blob/v5/src/docs/maintainer-commands.md.

  3. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 27, 2026
  4. clubanderson commented on Oct 28, 2026

    @clubanderson
    Member

    /hive decision approve

    Approved — narrowed to the cheapest deterministic shape. Option A (amended) only; Option B rejected.

    Why approve

    This is a real, recurring cost: the same RankActionableIssues citation in src/docs/scale-envelope.md has now needed seven hand-typed docs PRs (#11740, #11908, #12477, #12623, #12636, #13294, #14712), each one paired with a [shared-ci] incident and a fleet-wide red relative links and anchors resolve check. The existing tooling does not already cover this: check-docs-citations.py already parses the backticked symbol anchors next to a citation and detects the drift, but --fix only delegates to check-api-reference-citations.sh, which knows route-registration strings in api-reference.md and nothing else. So the gap is exactly "make --fix able to repair what the checker can already diagnose". That is self-healing, needs no baseline file, and adds no new CI surface.

    Why Option B is rejected

    A post-merge auto-fix workflow on v5 adds a new workflow with write permissions, generates bot PRs, and still leaves the default branch red for a full cycle between the breaking merge and the fix PR landing. CI must stay read-only on docs; the repair belongs in the PR that caused the drift (or in the fix agent's loop), not in a robot committing to v5.

    Implementation instructions (binding)

    1. Single PR, no sub-issues. Do not fan this out into tracking issues. One PR against v5, docs + script + tests + changelog fragment together.
    2. Extend the existing --fix path of src/scripts/check-docs-citations.py. No new script, no new workflow, no new required check. Keep the existing delegation to check-api-reference-citations.sh --fix for api-reference.md.
    3. Deterministic re-anchoring only — anchor by Go declaration, not by fuzzy text. A citation is eligible for rewrite only if (a) it already fails the current anchor check and (b) the citing line carries at least one backticked symbol anchor (the existing citation_anchors() output). Resolve the first anchor to a top-level Go declaration in the cited file (func X(, func (recv) X(, type X, const X, var X) found exactly once. New range = that declaration's start line through its closing brace / end of declaration, narrowed to the smallest span that contains every anchor on the citing line. Do not search by substring across the file for the new range.
    4. Fail closed. If the anchor resolves to zero or more than one declaration, if any anchor is not found inside the resolved declaration span, if the cited file is not .go, or if the citing line has no anchors: leave the citation untouched and report DRIFT exactly as today. --fix must still exit non-zero when anything remains unresolved, matching the api-reference fixer's contract.
    5. CI stays read-only. The only CI change permitted is the error text of the Check src/docs file:line citations step: when it fails, print Run: python3 src/scripts/check-docs-citations.py --fix (same shape as the check-api-reference-citations.sh --fix hint in changelog-fragment-guard.yml). Do not run --fix in CI and diff; do not commit from CI.
    6. Idempotent. Running --fix twice must produce no diff on the second run; the rewritten range must verify clean under the unchanged checker.
    7. Tests in src/scripts/test-check-docs-citations.sh fixtures, covering at minimum: function moved → re-anchored; function moved and grew so an anchor fell outside → widened; two declarations match the anchor → untouched + DRIFT; anchor absent from the file → untouched + DRIFT; citation with no anchors → untouched; non-.go target → untouched; idempotency.
    8. Fix-agent integration: update the scanner/fix agent's drift playbook (wherever the current "hand-edit the number" guidance lives, e.g. the memory that says to run check-api-reference-citations.sh --fix) to run python3 src/scripts/check-docs-citations.py --fix first and only fall back to a manual edit when it reports unresolved drift.
    9. Changelog fragment under changelog.d/ describing the new --fix capability and its fail-closed rules; update the docstring at the top of check-docs-citations.py which currently says --fix is api-reference-only.

    Out of scope for this PR: changing which files cite line ranges, adding anchors to citations that currently lack them, and any post-merge auto-commit workflow.

  5. added
    stage/010-actionableTriaged; eligible for the hive to pick up
    and removed
    stage/045-needs-decisionIssue parked on a person: needs-human or a maintainer decision is owed before the hive picks it up
    on Oct 28, 2026
  6. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    Un-parked by @clubanderson. Decision: approve

    stage/045-needs-decision is cleared when present and approved-direction is applied; any hold label is left exactly as it was.

  7. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by agent scanner (agent on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 2h0m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  8. hivecommons-hive commented on Oct 28, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by agent scanner released (holding agent relaunched).

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/scannerCreated or modified by the scanner agentapproved-directionhelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions