8000 fix(xerj code): cite real file lines for prose/Markdown hits (#1892) by xerj-org · Pull Request #1908 · xerj-org/xerj · GitHub
[go: up one dir, main page]

Skip to content

fix(xerj code): cite real file lines for prose/Markdown hits (#1892) - #1908

Merged
xerj-org merged 2 commits into
mainfrom
fix/xcode-prose-lines
Oct 20, 2026
Merged

xerj-org merged 2 commits into
mainfrom
fix/xcode-prose-lines

Conversation

@xerj-org
Copy link
Copy Markdown
Owner

Fixes #1892.

Bug: xerj code cited every Markdown/prose hit as file:1 or file (line unknown). A prose record is one section, and the passage ordinal counts lines of the re-flowed section text, not lines of the file.

Fix (xccode/render.rs, xccode/mod.rs)

  • RenderOpts gains checkout: Option<&Path>. xerj code passes <root>/corpora/<corpus>.
  • citation_in checks in this order:
    1. A stored line on the record still wins.
    2. For a prose section (a section field or an s<N> locator), it finds the passage's first distinctive line (at least 12 non-space characters) in the checkout file and cites that real line. A path with non-normal components (.., absolute) is never opened.
    3. Otherwise it uses the lexical ordinal, as before. Without a checkout, a prose hit stays (line unknown) rather than passing an ordinal off as a line.
  • Limitation: if the same distinctive line appears more than once in a file, the first occurrence is cited.

Tests

  • New prose_section_cites_the_file_line_from_the_checkout, which covers sectioned, single-section and path-escape cases and checks that code is unchanged. xerj-common lib: 259 passed. clippy -D warnings and fmt are clean.
  • End to end with the built binary, against a local index of swift-book + swift-evolution:
    before: ─── swift-evolution/proposals/0235-add-result.md:1  (score 19.26, Apache-2.0)
    after:  ─── swift-evolution/proposals/0235-add-result.md:203  (score 19.26, Apache-2.0)
            ─── swift-book/TSPL.docc/LanguageGuide/Concurrency.md:477  (score 7.69, Apache-2.0)
    
    Line 203 of 0235-add-result.md is the passage's first line (let result: Result<Int, Error> = // ...).

…, text sections)

Prose records store no file line, and their lexical passage ordinal counts
lines of the re-flowed section, not of the file. So every Markdown hit read
`(line unknown)`, or `:1` regardless of where the window was, while the
footer asked agents to cite file:line. For a prose section record the
renderer now looks the passage's first distinctive line up in the corpus
checkout (<root>/corpora/<corpus>/<ax_path>) and cites that line. It never
uses the section-relative ordinal, and never opens a path that would leave
the checkout. Code records keep the ordinal line.

Fixes #1892
@cla-bot cla-bot Bot added the cla-signed label Oct 19, 2026
@xerj-org
xerj-org merged commit 10c0100 into main Oct 20, 2026
24 checks passed
@xerj-org
Copy link
Copy Markdown
Owner Author

Xerj Merger made the fix: xerj code now cites real file lines for Markdown/prose hits instead of file:1 or "line unknown". It finds the passage's first distinctive line in the corpus checkout and cites that line, while a stored line on the record still wins. Build + Test passed on a8025bd. Fixes #1892.

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.

[bug]: xerj code prints "(line unknown)" on every passage while telling the agent to cite file:line

1 participant

0