Skip to content

(docs): rank non-ancestor and ambiguous doc stamps as unknown, resolve the repo top level (#1399) - #1400

Merged
devsuitup merged 3 commits into
mainfrom
fix/1399-doc-staleness
Nov 29, 2026
Merged

devsuitup merged 3 commits into
mainfrom
fix/1399-doc-staleness

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Closes #1399

Summary

Follow-up to #1354 / #1398 for scripts/doc-staleness.js:

  • A verified SHA that is not an ancestor of HEAD (stamp on a diverged branch) now ranks unknown sha (git merge-base --is-ancestor: exit 1 means not an ancestor, any other failure throws).
  • A sha git cannot resolve to exactly one commit ranks unknown sha. Measured on git 2.24: an ambiguous short prefix makes rev-parse --verify --quiet <p>^{commit} exit 1 (without --quiet it is 128, "short SHA1 ... is ambiguous"), a tree or blob SHA exits 1. The code also accepts exit 128 when stderr says "ambiguous", for git versions that differ; any other failure still throws.
  • --repo-root inside a subdirectory resolves git rev-parse --show-toplevel and works from there.
  • .ai/contexts/fast-check.md describes the current behaviour: unknown sha cases, top-level resolution, rename and deletion counting, exact exit conditions.

Developer tooling only: no-changelog.

Tests

test/doc-staleness.test.js (10 pass), test/check-docs.test.js (118 pass). New tests, all on real temp repos:

  • non-ancestor stamp -> unknown sha. RED before the fix: expected: 'unknown sha', actual: 'verified'.
  • unresolvable/ambiguous -> unknown sha, other failures throw; uses a real 3-character commit collision plus stubbed git errors (a 7-character collision is impractical). RED before the fix: expected: 'function', actual: 'undefined' (resolveStampCommit did not exist).
  • subdirectory repo root. RED before the fix: the report was [] instead of the top-level report.
  • :(literal) pin: src/a[1].js covered by src/*.js, with src/a1.js modified then deleted after the stamp. Mutation (remove :(literal)): expected: 0, actual: 2; restored, hash verified.
  • rename and deletion pin (passes on the old code, documents it): a rename counts only through the new path, a deleted file counts nothing, and a doc whose only covered file is deleted fails validation.

… the repo top level (#1399)

A stamp that is not an ancestor of HEAD, or that git cannot resolve to exactly one commit, now ranks as unknown sha. --repo-root inside a subdirectory resolves the repository top level. Tests pin literal pathspecs and rename/deletion counting; the fast-check context describes the current behaviour.
@devsuitup devsuitup added the no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived label Nov 29, 2026
@devsuitup
devsuitup merged commit 81f5b24 into main Nov 29, 2026
15 checks passed
@devsuitup
devsuitup deleted the fix/1399-doc-staleness branch November 29, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog The PR changes nothing a user sees; the CHANGELOG.md check is waived

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(docs): doc-staleness edge cases — non-ancestor stamp, ambiguous SHA, subdirectory root

1 participant