You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs: the citation guard cannot see a stale pin, accepts :0, and lets a ../ citation escape the repo #1265
area:docsDocumentation site (docs/, mkdocs.yml) and READMEdocumentationImprovements or additions to documentationrisk:T1Risk tier T1 (tests, examples, changelog.d), set by the controller from the diff
Implementation: AgentDescent (ours) — do not pick up; this is queued behind the #1259 card, not a second slice of it.
tests/test_docs_citations.py (added in #1264, reviewed head 58ab248e980acdd3a8958bd3fea721e541218e41) walks docs/**/*.md and README.md, reads every backticked path:line / path:line-line citation, and requires the cited file to exist and the last cited line to be inside it. Citations into the upstream Elixir/DGM trees are pinned in _EXTERNAL as exact (page, path, first, last) coordinates.
Three gaps, each reachable only by writing a citation we do not have today. They were left out of #1264 deliberately: none of them can fail on the current docs, and pushing a fourth file would have restarted five CI legs for test hygiene.
A pin is never checked for staleness. If a page stops citing a pinned path, or moves the citation to another line, the pin stays and the coordinates it names become permanently allowed. A future citation at exactly those coordinates — the wrong line in a quoted upstream file — would pass silently. Fix: while walking, collect the external citations actually seen and assert _EXTERNAL - seen == set(), naming every stale pin.
:0 passes._CITATION takes (\d+), and end = 0 never exceeds a line count, so agentdescent/cli.py:0 is accepted. Fix: reject first < 1, and reject last < first.
../ escapes REPO_ROOT. The path class allows dots, and the guard tests REPO_ROOT / path, so ../../etc/hostname:1 is read (a line count, never contents) and accepted when the target exists. Fix: reject any citation whose path has a .. segment, or resolve and require the result to stay under REPO_ROOT.
Acceptance: each fix lands with an assertion that fails first on the guard as merged — one entry added to _EXTERNAL whose citation is not in the page (stale pin, must be named), one page citing path:0 (must be named), one page citing a ../ path (must be named); today all three pass, after the change all three fail. python -m pytest tests/test_docs_citations.py -q green; the failure message keeps naming the page, the citation and the file's length; no page prose touched; python -m tools.changelog_fragments check decides whether a fragment is needed.
Fourth gap, added from a security read of the guard at 58ab248e980acdd3a8958bd3fea721e541218e41 — same four lines as gap 3, so it rides with it rather than getting its own card.
target = REPO_ROOT / path (tests/test_docs_citations.py:66) accepts .. segments and absolute paths, and the guard then counts lines on whatever resolves. Today that is cosmetic: _line_count (:52) returns only an integer, the failure message carries page:line -> citation plus that integer (:70) or (file does not exist) (:72), and there is no write, no network and no file content anywhere in the guard.
The sharp edge is a citation whose target is a FIFO or a character device (/dev/zero-style): read_text would block or read without bound, and on CI that is bounded only by the job's timeout-minutes, i.e. it burns a leg rather than failing with a message.
Fix, in the same place as gap 3: reject any citation path with a .. segment or an absolute path, resolve, require stat.S_ISREG on the result, and only then count lines. Acceptance unchanged: an injected citation at such a path is named today and refused after the change.
Fifth point, and it decides what the list actually means: all 11 _EXTERNAL entries are carried from the pages' prose; none was checked against an upstream file. The author never fetched agents/*.ex, runtime/genesis.ex, evolution.py, DGM_outer.py, adapters/git.ex or agent/subagent_processing.ex, so 0 of 11 are confirmed upstream.
That does not make the guard wrong — those citations predate it, and the guard's real value is separating "resolves in this repository" from "asserted to live upstream". But the comment above _EXTERNAL currently reads as if the entries were facts, and a later reader will take them that way. Fix, either: verify the nine distinct coordinates once by hand against the upstream trees and record the sha you read them at, or state in that comment that they are prose-derived and unverified. The second is honest and costs nothing.
Mechanically: 11 entries over 9 distinct (path, first, last) pairs, because runtime/genesis.ex:152 and agents/manager.ex:58 each appear on two pages — worth keeping that shape when the staleness check is added, since collapsing to 9 would lose the per-page fact.
Measured on main 441ac2bd with the guard and the #1264 doc line: the guard walks 151 pages, sees 17 citations, of which 4 resolve in-repo and 13 occurrences (the 9 distinct upstream coordinates, some repeated on a page) are pinned. With #1264's one-line fix applied the guard passes at 0 problems, and main's only offender is exactly that one citation.
Three more from a QA pass that ran the guard on 58ab248e rather than reading it. None is live — measured on docs/ + README.md at that head: 0 backticked :line tokens the pattern misses and 0 reversed ranges — so they ride here rather than in the PR.
A reversed range passes._problems compares only the range's last number (end), so agentdescent/cli.py:999-7 is accepted while its first line is past the end of the file. Fix: also reject start > end and check first against the count.
Extensionless tokens are never read._CITATION requires a dotted extension, so a Makefile:3 or Dockerfile:12 citation is invisible. Fix: loosen the token pattern, or state in the docstring that only dotted paths are covered. Zero instances today, so the documentation option is legitimate.
The walk has a declared edge that a reader will miss. The guard covers docs/**/*.md + README.md; three tracked markdown files outside that carry citations today — CHANGELOG.md (2), the #1259 changelog fragment (1), and examples/genesis/README.md (2, both external agents/manager.ex rows). Fix: either extend _pages() to every tracked *.md, or say explicitly in the docstring which files are out of scope, so "every citation" is not read as the whole repo.
Acceptance for all three is the same shape as the rest of this issue: a failing-first injection per item, then the guard green at python -m pytest tests/test_docs_citations.py -q.
area:docsDocumentation site (docs/, mkdocs.yml) and READMEdocumentationImprovements or additions to documentationrisk:T1Risk tier T1 (tests, examples, changelog.d), set by the controller from the diff
Activity
HugoXK commentedon Nov 24, 2026
Fourth gap, added from a security read of the guard at
58ab248e980acdd3a8958bd3fea721e541218e41— same four lines as gap 3, so it rides with it rather than getting its own card.target = REPO_ROOT / path(tests/test_docs_citations.py:66) accepts..segments and absolute paths, and the guard then counts lines on whatever resolves. Today that is cosmetic:_line_count(:52) returns only an integer, the failure message carriespage:line -> citationplus that integer (:70) or(file does not exist)(:72), and there is no write, no network and no file content anywhere in the guard.The sharp edge is a citation whose target is a FIFO or a character device (
/dev/zero-style):read_textwould block or read without bound, and on CI that is bounded only by the job'stimeout-minutes, i.e. it burns a leg rather than failing with a message.Fix, in the same place as gap 3: reject any citation path with a
..segment or an absolute path, resolve, requirestat.S_ISREGon the result, and only then count lines. Acceptance unchanged: an injected citation at such a path is named today and refused after the change.HugoXK commentedon Nov 24, 2026
Fifth point, and it decides what the list actually means: all 11
_EXTERNALentries are carried from the pages' prose; none was checked against an upstream file. The author never fetchedagents/*.ex,runtime/genesis.ex,evolution.py,DGM_outer.py,adapters/git.exoragent/subagent_processing.ex, so 0 of 11 are confirmed upstream.That does not make the guard wrong — those citations predate it, and the guard's real value is separating "resolves in this repository" from "asserted to live upstream". But the comment above
_EXTERNALcurrently reads as if the entries were facts, and a later reader will take them that way. Fix, either: verify the nine distinct coordinates once by hand against the upstream trees and record the sha you read them at, or state in that comment that they are prose-derived and unverified. The second is honest and costs nothing.Mechanically: 11 entries over 9 distinct
(path, first, last)pairs, becauseruntime/genesis.ex:152andagents/manager.ex:58each appear on two pages — worth keeping that shape when the staleness check is added, since collapsing to 9 would lose the per-page fact.Measured on main
441ac2bdwith the guard and the#1264doc line: the guard walks 151 pages, sees 17 citations, of which 4 resolve in-repo and 13 occurrences (the 9 distinct upstream coordinates, some repeated on a page) are pinned. With#1264's one-line fix applied the guard passes at 0 problems, and main's only offender is exactly that one citation.HugoXK commentedon Nov 24, 2026
Three more from a QA pass that ran the guard on
58ab248erather than reading it. None is live — measured ondocs/+README.mdat that head: 0 backticked:linetokens the pattern misses and 0 reversed ranges — so they ride here rather than in the PR._problemscompares only the range's last number (end), soagentdescent/cli.py:999-7is accepted while its first line is past the end of the file. Fix: also rejectstart > endand checkfirstagainst the count._CITATIONrequires a dotted extension, so aMakefile:3orDockerfile:12citation is invisible. Fix: loosen the token pattern, or state in the docstring that only dotted paths are covered. Zero instances today, so the documentation option is legitimate.docs/**/*.md+README.md; three tracked markdown files outside that carry citations today —CHANGELOG.md(2), the#1259changelog fragment (1), andexamples/genesis/README.md(2, both externalagents/manager.exrows). Fix: either extend_pages()to every tracked*.md, or say explicitly in the docstring which files are out of scope, so "every citation" is not read as the whole repo.Acceptance for all three is the same shape as the rest of this issue: a failing-first injection per item, then the guard green at
python -m pytest tests/test_docs_citations.py -q.test(docs): reject a citation whose path is absolute (#1265)
fix(docs): reject an absolute citation path (#1265)