Skip to content

feat(diagnostics): report BibTeX failures - #42

Merged
nishide-dev merged 2 commits into
mainfrom
feat/bibtex-diagnostics
Sep 30, 2026
Merged

nishide-dev merged 2 commits into
mainfrom
feat/bibtex-diagnostics

Conversation

@nishide-dev

@nishide-dev nishide-dev commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

概要

BibTeX が失敗しても、これまでの diagnostics は main の .log から出る Citation ... undefined だけで、原因(どの .bib のどの行か、BibTeX が失敗したこと自体)が分かりませんでした。BibTeX の .blg と、latexmk が BibTeX について出すメッセージを parse して、構造化 diagnostics として返すようにします。

変更内容

  • texrun-core: DiagnosticKind::BibtexError(.bib の構文エラー・重複 entry など)と BibtexFailed(BibTeX が失敗した / 実行されなかった)を追加しました。#[non_exhaustive] と #[serde(other)] Other はそのままで、schema_version は据え置きです(値の追加だけなので)。
  • texrun-latex-log: .blg parser BlgParser(新しい module blg)を追加しました。
    • 別 crate にはせず、同じ crate の module にしました。純粋関数・best-effort という性質が同じで、sanitize、excerpt の上限、Collector(error 優先の件数上限)をそのまま使えるためです。

    • 認識する内容:

      .blg kind severity
      I couldn't open database file / style file / auxiliary file missing_file error
      <msg>---line N of file x.bib(位置が次の行にある形も)、---while reading file、Sorry--- bibtex_error error
      Warning--I didn't find a database entry for "k" undefined_citation warning
      その他の Warning-- other warning
      (There were N error messages) / (That was a fatal error) / 上の error bibtex_failed error の後なら info、それ以外は error
    • file: .blg 自身が Database file #n: / The style file: で名前を挙げた .bib / .bst で、かつ caller(BibFiles)が解決できたときだけ付けます。.aux 内の位置(存在しない database / style の場合)には付けません。

    • line: file と一緒にだけ付けます。---line N は BibTeX がエラーを見つけた行(予期しない token の行)です。(Error may have been on previous line) のときは、message に「前の行かもしれない」と書きます。warning の --line N は string name "x" is undefined のときだけ残します。I'm ignoring x's extra "year" field などは、BibTeX がフィールドの先まで先読みしてから出すので、行がずれることを実ログで確認しました。そのため None にしています(feat(diagnostics): parse LaTeX logs into structured diagnostics #23 / feat(diagnostics): locate missing packages and fold fatal errors #40 の「誤った line は None より悪い」)。

    • 計算量: 行数に線形です(各行を 1 回見て、message の後ろは定数行だけ先読み)。database / style 名は 64 個まで覚えます。BibFiles::locate は名前ごとに 1 回です。crate / module の doc に書きました。

  • texrun-texlive(新しい module bibtex。process 関連には触れていません):
    • output dir 以下で、この compile の間に書かれた *.blg を読みます(mtime が latexmk の開始以降。\include や bibunits などで複数の aux があっても拾います)。
    • 上限: 走査は 20,000 entry・深さ 16 までで、symlink はたどりません。読むのは 16 file まで、各 1 MiB(先頭)まで。通常ファイルだけを O_NOFOLLOW | O_NONBLOCK で open し、fstat でも確認します。diagnostics は 1 file あたり 200 個までです。
    • .bib / .bst 名は、<entrypoint dir>/<name> が workspace 内の通常ファイルのときだけ workspace 相対に変換します。latexmk は BibTeX の BIBINPUTS / BSTINPUTS の先頭に entrypoint のディレクトリを置く(実測)ので、そこにあるファイルが BibTeX の読んだものです。installed style や output dir に生成されたファイルは None です。
    • 存在しない .bib: latexmk は BibTeX を実行せず(veto)、exit 0 で終わり、.blg も出ません(実測)。latexmk の出力の Reason: I am configured only to use bibtex/biber if all .bib files exist, but the following didn't: に続く名前から、missing_file の warning を返します。compile 自体は成功扱いのままなので、severity は warning にしました。
    • latexmk の error summary に Bibtex errors: See file があるのに .blg を読めなかった場合は、bibtex_failed の error を返します。
    • .blg は artifact に含めません(docs/security.md §3.9 の「engine が報告したものだけ収集」の方針)。内容は diagnostics の raw_excerpt に入ります。
  • fixture:
    • texrun-latex-log/tests/fixtures/logs/bibtex-*.blg(dev コンテナの実ログ。.bib の構文エラー、存在しない .bib、存在しない entry、存在しない .bst、複数 .bib)
    • regenerate.sh に bibtex mode(pdflatex 1 pass + bibtex main)を追加しました。latexmk は .bib が無いと BibTeX を実行しないので、.blg の fixture にはこの mode を使います。
    • texrun-texlive/tests/fixtures/bibtex/(entrypoint ごとに 1 シナリオ)
  • test:
    • parser: unit test、実ログ test(tests/real_blg.rs)、proptest(panic しない・出力に上限がある)、大きな入力が短時間で終わること
    • engine: unit test(再帰的な探索、stale / symlink / FIFO / 件数・深さ・サイズの上限、workspace 外への symlink、console の parse)と、require_texlive!() 方式の scenario test tests/bibtex.rs(構文エラー、存在しない .bib、paranoid mode で開けない .hidden/refs.bib、存在しない entry、存在しない .bst、サブディレクトリの entrypoint と複数 .bib、正常な bibliography では何も出ないこと)
  • docs: README(BibTeX 関連の kind)、docs/security.md(.blg を artifact にしないことと、読み込みの上限)

確認方法

  • cargo check --workspace --all-targets --all-features --locked
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings(host とコンテナ)
  • cargo test --workspace --all-features --locked(host)
  • dev コンテナで TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked(全件 pass)

関連 Issue

Closes #27

補足

  • 構文エラーの line は、BibTeX が報告した「予期しない token の行」です(例: 行 4 の末尾のカンマ抜けは行 5 と報告され、(the error may be on the previous line) が付きます)。TeX の l.N と同じ意味なので残しましたが、None にすべきという意見があれば変えます。
  • latexmk の console のメッセージ(veto の理由、error summary)は latexmk 4.86 の文言に依存します。文書も console に任意のテキストを出せるので、ここからは file の付かない diagnostic だけを作ります。
  • kpsewhich を無効にしている影響で、texmf 内の .bib(\bibliography{xampl} など)も latexmk には「見つからない」扱いになり、BibTeX が実行されません。この PR ではその場合も missing_file の warning として報告します(挙動自体は既存のままです)。
  • biber / biblatex は対象外です(Issue のスコープどおり)。

🤖 Generated with Claude Code

nishide-dev added a commit that referenced this pull request Sep 30, 2026
## 概要

#39 で `rustix` が texrun-texlive の dev-dependencies に移り、その後 #40 が library
側の `read_source` で `rustix` を使ったため、main の CI(check / clippy / test /
integration)が失敗している。両 PR は個別には green だったが、組み合わせで壊れた。

## 変更内容

- `crates/texrun-texlive/Cargo.toml` の `[dependencies]` に `rustix` を追加
- test 内の未 import の `Command` を完全修飾に

PR #42(#27)の作業中に見つかった修正(commit 71b7991)を、main を早く直すために単独の PR として切り出したもの。

## 確認方法

- [x] `cargo check --workspace --all-targets --all-features --locked`
- [x] `cargo clippy --workspace --all-targets --all-features --locked --
-D warnings`
- [ ] CI

## 補足

今後同様の組み合わせ破損を防ぐため、branch protection で「merge 前に最新 main
への追従」(strict)を有効にするか検討する。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Parse the BibTeX logs (.blg) latexmk's BibTeX runs write into the output
directory, and latexmk's messages about BibTeX, into diagnostics:

- texrun-latex-log: BlgParser for .blg files. Syntax errors and repeated
  entries are bibtex_error with the .bib file and the line BibTeX
  reports (only for databases / styles the log names and the caller
  resolves), unopenable databases / styles are missing_file, missing
  entries undefined_citation warnings, and a bibtex_failed summary
  follows (info after errors, error when none were recognized).
- texrun-texlive: read the .blg files of this compile (bounded walk,
  O_NOFOLLOW | O_NONBLOCK, size / count limits), attribute .bib names to
  the entrypoint directory, and report databases latexmk did not find
  (it then skips BibTeX and exits 0) and BibTeX errors latexmk reports
  without a readable log.
- texrun-core: DiagnosticKind::BibtexError and BibtexFailed.

Closes #27

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nishide-dev
nishide-dev force-pushed the feat/bibtex-diagnostics branch from 39c5529 to aaa091b Compare September 30, 2026 17:46

@nishide-dev nishide-dev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: CHANGES_REQUESTED

PR #42(#27: BibTeX の失敗を構造化 diagnostics として返す)をレビューしました。全体の設計は良いと思います。.blg が database / style として名前を挙げ、entrypoint dir に workspace 内の通常ファイルとしてある場合だけ file を付ける、という絞り方。.aux 内の位置は付けない方針。読み込みの上限(走査の entry 数・深さ、symlink を追わない、O_NOFOLLOW | O_NONBLOCK + fstat、1 MiB × 16 file)。console 由来の diagnostics には file を付けない方針。どれも #23 / #40 のレビュー方針に沿っています。

一方で、構文エラーの line について、実際の誤り箇所から大きくずれるうえに「前の行かもしれない」という注記がさらに誤った行を指すケースを確認しました。これと severity の不整合 1 件を should-fix としています。

確認したこと

  • gh pr checks 42: 全 pass
  • host (macOS): cargo fmt --check / cargo clippy --workspace --all-targets --all-features --locked -D warnings / cargo test --workspace --all-features --locked: 全 pass
  • dev コンテナ: clippy と TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked: 全 pass
  • dev コンテナで、fixture に無いケースを texrun compile --json で試しました(BibTeX 0.99d / latexmk 4.86。結果は下の表)。
ケース 実際の誤り 報告 (file:line) 評価
field 間のカンマ抜け(行末) 3 行目 refs.bib:4 + 「前の行かも」 注記込みで正しい
field 間のカンマ抜け(同じ行の途中) 8 行目 refs.bib:8 正しい
key の後のカンマ抜け 1 行目 refs.bib:2 + 「前の行かも」 注記込みで正しい
@string の閉じ括弧抜け 1 行目 refs.bib:2 + 「前の行かも」 注記込みで正しい
@string の = 抜け 2 行目 refs.bib:2 正しい
entry の閉じ } 忘れ(次の entry との間に空行) 5 行目の後 refs.bib:7 + 「前の行かも」 ずれる。注記は空行(6 行目)を指す
field 値の { の閉じ忘れ 3 行目 refs.bib:8(次の entry の @)+ 「前の行かも」 5 行ずれる
field 値の " の閉じ忘れ 2 行目 refs.bib:6(Unbalanced braces)+ 「前の行かも」 4 行ずれる
最後の entry の閉じ忘れ(EOF) 末尾 refs.bib:6(Illegal end of database file) 許容範囲
重複 entry 8 行目 refs.bib:8 正しい
未定義の @string 名(warning) 14 行目 refs.bib:14 正しい
未知の entry type / 重複 field(warning) - refs.bib、line なし 方針どおり
複数 .bib(サブディレクトリの bib/two.bib を含む) 各行 bib/two.bib:5(注記あり)、three.bib:2 正しい
\include の章から cite(.blg は 1 つ) 5 行目 refs.bib:5 + 未定義 key の warning 正しい
日本語(UTF-8)を含む .bib 4 行目 refs.bib:5 + 「前の行かも」 正しい
workspace 内の独自 .bst の閉じ括弧忘れ 5 行目 mystyle.bst:7 ほか ずれる(N 系、下記)
\bibliographystyle 無し - bibtex_error(I found no \bibstyle command)、file なし 正しい
存在しない .bst - missing_file + bibtex_error、file なし 正しい
\cite 無し(\bibliography だけ) - error の bibtex_error、なのに outcome は succeeded / exit 0 S2
空の .bib に cite - undefined_citation warning(BibTeX 側も) 正しい
同じ文書を 2 回 compile - 2 回とも同じ diagnostics 正しい
entrypoint dir の正しい refs.bib と、文書が output dir に生成した同名の壊れた refs.bib - BibTeX は entrypoint dir 側を読み、diagnostics は出ない 「entrypoint dir が先頭」という前提を確認
biblatex (backend=biber) - 最小構成に biblatex が無いので missing_file(biblatex.sty)で止まる 下記

biber について: dev イメージでは biber まで到達しないので、biber 形式の .blg([n] Module.pm:NNN> ERROR - ...)を BlgParser に直接渡して確認しました(一時的なテストで、コミットはしていません)。diagnostics は 0 件で、誤った file/line は出ません。latexmk の biber ...: ... 行も scan_console の対象外です。対象外として安全に degrade します。

2 回目の compile と mtime: CLI は毎回新しい workspace にコピーし(.texrun/ は除外)、output dir も新しく作るので、CLI 経由では古い .blg を拾う経路はありません。latexmk を同じ output dir で 2 回実行した場合も、.aux が変わると BibTeX は再実行され、.blg の mtime は更新されました。

should-fix

S1. entry / field が閉じていないとき、line が誤り箇所から大きくずれ、「前の行かもしれない」も誤った行を指す

上の表のとおり、BibTeX が報告する行は「予期しない token を見つけた行」です。次の 2 つの場合、BibTeX は誤りの後も数行を読み進めてから token を見つけます。

  • 閉じていない { / " を含む field 値
  • 閉じ } の無い entry

このとき報告される行は、次の entry の @ の行や、たまたま閉じた } の行です。実際の誤り箇所より 4〜5 行後になりました。さらに (Error may have been on previous line) から付けた「the error may be on the previous line」は、空行や無関係な行を指します。

AI はこの diagnostic を見て refs.bib:8 や 7 行目を直しに行きますが、そこには何もありません。PR 本文には「TeX の l.N と同じ意味なので残した」とあります。ただ #23 / #40 では、先読みした位置の line(missing package の \usepackage の次の行、その後の Emergency stop.)を None にしました。このケースは同じ性質です。また、この PR 自身も、先読みしてから出る warning(I'm ignoring ... extra field)の line は None にしています。

.blg だけで判別できます。

  • quote された 2 行( : <before> / : <after>)の <after> が @ で始まる: BibTeX が次の entry / command に到達した。直前の entry が閉じていない
  • message が Unbalanced braces / Illegal end of database file: 開き括弧・引用符がどこから始まったかは .blg に出ない

修正案:

  1. 上の場合は file だけ残して line = None にし、BibTeX が見つけた位置は message に書く。例: BibTeX: I was expecting a ,' or a }' (found the next entry at line 8; the entry before it is probably not closed: a missing }or an unbalanced{/" in one of its fields)
  2. このとき、「the error may be on the previous line」の注記は付けない
  3. Unbalanced braces も同様に line を None にし、「detected at line N; an unbalanced { or " earlier in this entry is likely」を付ける
  4. 上の 3 ケース(entry の閉じ忘れ、field 値の { の閉じ忘れ、" の閉じ忘れ)の実ログ fixture と、line が None になるテストを追加する

field 間のカンマ抜けのように、1 行前が正しい通常のケースはこれまでどおり line を残せます(<after> が field 名で始まるため)。@string{x = "y" の閉じ括弧忘れ(次の行が @string)は、この判定では line が None になります。この場合は 1 行前で正しかったのですが、.blg だけでは閉じていない field 値のケースと区別できません。line が None になるだけで誤った line は出ないので、許容できると思います。

S2. I found no \citation commands が error になり、compile 成功と矛盾する

\bibliography はあるが \cite がまだ無い文書(書き始めの草稿でよくある状態)では、次のようになります。

  • JSON: outcome は succeeded、exit は 0。一方で severity: error の bibtex_error がある
  • human: Compiled main.tex in 116ms (1 error, 1 warning)

latexmk 4.86 の check_bibtex_log は、I found no \citation commands、見つからない aux / database を "weak errors" として warning 扱いにしています(だから exit 0 になります)。AI は error を見て、直す必要の無いものを直そうとするおそれがあります。

修正案: I found no \citation commands---while reading file ... を Severity::Warning にし、これだけの .blg では bibtex_failed を出さない(または info にする)。この状態の実ログ fixture を追加する。

nit

  • N1. 件数の上限が compile 全体で効いていない。 .blg 1 つあたり 200 個 × 16 file(excerpt は各 4 KiB まで)で、main log の分とは別に最大 3,200 個になります。bibtex::diagnostics 全体に上限(例: 合計 200 個、error 優先)を設けると、JSON の大きさの上限が分かりやすくなります。あわせて、16 file の上限に達したときにどれが残るかは read_dir の順序次第です。<stem>.blg は優先して読むとよいと思います。
  • N2. mtime の判定。 since を秒単位に切り捨てているので、同じ workspace を再利用するライブラリ利用者の場合は、直前の compile が同じ秒に書いた .blg を拾えます。また、latexmk が BibTeX を再実行しなかった(up-to-date の)場合は、前回の warning が消えます。CLI では毎回新しい workspace なので実害はありません。ただ、find_blgs の doc に「新しい output dir を前提とする。mtime は保険」と書いておくと意図が伝わります。
  • N3. .hidden/refs.bib のように paranoid mode で開けない場合、I couldn't open database file .hidden/refs.bib だけでは、ファイルがあるのに開けない理由が分かりません。名前にドットで始まる要素や .. が含まれるときは「TeX Live の安全設定で、ドットで始まるディレクトリ・親ディレクトリのファイルは開けない」と message に補足すると、AI が判断しやすくなります(任意)。
  • N4. .bst の構文エラー(関数本体の閉じ括弧忘れ)も、S1 と同じく先読みした位置の行になります(例: 5 行目の誤りが mystyle.bst:7 の read is an unknown function)。独自の .bst はまれなので、S1 の対応範囲外でもかまいません。やるなら .bst の error は line を None にするのが簡単です。
  • N5. docs/security.md に一言あるとよいと思います。文書は output dir に任意のファイルを書けるので、.blg の内容も main の .log と同じく文書が制御できる入力です。file の付与は entrypoint dir に実在する .bib / .bst に限られるので、現状の設計で問題はありません。

テストの質

  • parser: 実ログ fixture、proptest、大きな入力の計算量テスト、locate が名前ごとに 1 回であることのテストがそろっていて良いです。
  • engine: symlink、FIFO、深さ・件数・サイズの上限、workspace 外への symlink を unit test で押さえていて、scenario test も主要ケースを網羅しています。
  • 不足しているのは、S1 の 3 ケース(ずれる line を None にすること)と S2(\cite 無し)の実ログ fixture です。

S1 / S2 が直れば APPROVE できると思います。

Address the review of #42:

- When BibTeX read on past the mistake before noticing (the quoted text
  reaches the next `@` entry, `Unbalanced braces`, `Illegal end of
  database file`, and any error in a `.bst`), keep only the file and say
  in the message where BibTeX noticed and what is likely wrong, without
  the "previous line" note.
- Follow latexmk's weak errors: `I found no \citation commands` is a
  warning, and a log with only weak errors is not a failure.
- Bound the diagnostics of all .blg files of a compile together and
  read `<stem>.blg` first; document that the output directory is
  assumed to be new; explain databases refused by paranoid mode.
- Real BibTeX log fixtures for unclosed entries, braces and quotes and
  for a document without citations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nishide-dev

Copy link
Copy Markdown
Owner Author

レビューありがとうございます。追加 commit で対応しました(origin/main に追従済み)。

should-fix

  • S1: BibTeX が誤り箇所を読み過ぎてから気づいたケースは、file だけ残して line を None にしました。message には、BibTeX が気づいた位置と、原因として考えられることを書きます。「前の行」の注記は付けません。
    • 対象の判定:
      • quote された 2 行目が @ で始まる(次の entry に到達した)
      • Unbalanced braces
      • Illegal end of database file
      • .bst の error すべて(N4)
    • message の例: BibTeX: I was expecting a ,' or a }' (found the next entry at line 8; the entry before it is probably not closed: a missing }or an unbalanced{/" in one of its fields)
    • 実ログ fixture を 3 件追加しました: bibtex-unclosed-entry、bibtex-unclosed-brace、bibtex-unclosed-quote。real_blg.rs で、line が None になり message が上のようになることを確認しています。
    • engine の scenario(unclosed.tex)も追加しました。field 間のカンマ抜けなど、これまでの通常ケースは line を残しています。
    • @string の閉じ括弧忘れは、ご指摘のとおり区別できないので None になります。crate docs に記載しました。
  • S2: latexmk 4.86 の check_bibtex_log と同じ判定にしました。
    • I found no \citation commands は常に warning です。
    • error がすべて weak error(citation 無し、.aux / database が開けない)のときは、failed = false で、bibtex_failed も出しません。
    • database が開けず、さらに I found no database files が出る場合は、latexmk でも失敗扱いなので error のままです。
    • 実ログ fixture bibtex-no-citations と、engine の scenario(outcome は succeeded、error は 0 件)を追加しました。

nit

  • N1: 全 .blg を合わせて最大 200 個にしました。各 .blg の要約と省略の通知は数えません。上限に達したら、残りの .blg を読まなかったことを知らせる note を 1 つ出します。
    • <stem>.blg は走査の前に直接確認して先頭に置くので、16 file の上限に達しても必ず読みます。
  • N2: bibtex module と find_blgs の doc に、output dir は compile ごとに新しい前提で、mtime の判定は保険であることを書きました。docs/security.md にも同じ内容を書いています。
  • N3: 開けないファイル名が絶対パス、..、ドットで始まる要素を含むときは、TeX Live の安全設定で開けないことを message に補足します。
  • N4: S1 と同じ方針で対応しました(.bst の error は file のみ)。
  • N5: docs/security.md に、.blg も文書が制御できる入力であることを書きました。file を付けるのは entrypoint のディレクトリに実在する .bib / .bst だけであることも書いています。

確認

  • host: fmt / check / clippy -D warnings / test(--locked)がすべて pass
  • dev コンテナ: TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 で clippy と全テストが pass
  • CI: 全 job pass

🤖 Generated with Claude Code

@nishide-dev nishide-dev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

指摘対応の commit 04e4eb5 を再レビューしました。前回の S1 / S2 と nit N1〜N5 は、すべて解消されています。前回試したケースを最新 head で再実行し、line が正しかったケースが None に変わっていないことも確認しました。退行は見つかりませんでした。

確認したこと

  • gh pr checks 42: pass(test (linux) / (macos) は確認時点で実行中)
  • host (macOS): cargo fmt --check / cargo clippy --workspace --all-targets --all-features --locked -D warnings / cargo test --workspace --all-features --locked: 全 pass
  • dev コンテナ: clippy と TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked: 全 pass
  • 前回と同じ 18 ケースを、dev コンテナで texrun compile --json により再実行しました。

前回の指摘

S1: 読み進めた後の line(解消)

ケース 前回 今回
entry の閉じ } 忘れ refs.bib:7 + 「前の行かも」 refs.bib、line なし。「found the next entry at line 7; the entry before it is probably not closed ...」
field 値の { の閉じ忘れ refs.bib:8 + 「前の行かも」 refs.bib、line なし。同じ注記
field 値の " の閉じ忘れ refs.bib:6 refs.bib、line なし。「detected at line 6; an unbalanced { or " earlier in this entry is likely」
最後の entry の閉じ忘れ(EOF) refs.bib:6 refs.bib、line なし。「reached the end of the file at line 6; an entry is probably not closed」
独自 .bst の閉じ括弧忘れ(N4) mystyle.bst:7 ほか mystyle.bst、line なし。「detected at line N; the mistake may be earlier in the style」

どのケースでも「the error may be on the previous line」は付かなくなりました。3 ケースの実ログ fixture(bibtex-unclosed-{entry,brace,quote}.blg)と、scenario test も追加されています。

退行の確認(line が正しかったケース)

ケース 今回 前回との比較
field 間のカンマ抜け(行末) refs.bib:4 + 「前の行かも」 同じ
field 間のカンマ抜け(同じ行の途中) refs.bib:8 同じ
key の後のカンマ抜け refs.bib:2 + 「前の行かも」 同じ
複数 .bib(bib/two.bib、three.bib) bib/two.bib:5(注記あり)、three.bib:2 同じ
\include の章から cite refs.bib:5 + 未定義 key の warning 同じ
日本語を含む .bib refs.bib:5 + 「前の行かも」 同じ
@string の = 抜け refs.bib:2 同じ
重複 entry refs.bib:8 同じ
未定義の string 名(warning) refs.bib:14 同じ
@string の閉じ括弧忘れ refs.bib、line なし(1 行前で正しかった) None になった。前回、判別できないので許容とした範囲で、doc にも明記されている

カンマ抜け系で None に変わったものはありません。

S2: I found no \citation commands(解消)

\cite の無い文書では、warning の bibtex_error だけになりました。bibtex_failed は出ず、human 出力も「Compiled ... (1 warning ...)」です。latexmk 4.86 の check_bibtex_log と同じく、weak error だけの .blg は失敗として扱わない判定です。見つからない database に I found no database files が続く場合は、latexmk と同じく error のまま残ります(hidden-database の scenario test)。

nit

  • N1: 全 .blg 合わせて 200 個が上限になりました(diagnostics_are_bounded_for_the_whole_compile)。<stem>.blg は file の上限を超えても先に読まれます(the_main_log_is_read_even_past_the_file_limit)。
  • N2 / N5: 「output dir は compile ごとに新しい前提で、mtime の判定は保険」であることと、.blg を文書が制御できる入力として扱うことが、module doc と docs/security.md に書かれました。
  • N3: paranoid mode で開けない名前(絶対パス、..、ドットで始まる要素)には、理由の補足が付くようになりました。

その他の再確認

  • \bibliographystyle 無し、存在しない .bst、空の .bib、2 回目の compile、entrypoint dir と output dir に同名の .bib がある場合、biblatex (backend=biber): 前回と同じ結果で、問題はありません。
  • 追加されたコード(read_on_note、weak_only の前走査、budget の計算)は、どれも行数に線形で、新たな読み込みもありません。

nit(任意、マージを妨げません)

  • @string の閉じ括弧忘れでも、注記が「the entry before it is probably not closed」になります。@string の command も含むことが分かるように、「the entry or @string before it」のような文言にすると、より正確です。

以上で APPROVE とします。

@nishide-dev
nishide-dev merged commit c6e97db into main Sep 30, 2026
9 checks passed
@nishide-dev
nishide-dev deleted the feat/bibtex-diagnostics branch September 30, 2026 18:13
nishide-dev added a commit that referenced this pull request Oct 6, 2026
## 概要

`v*` の tag を push するだけで、検証 → engine image の公開 → **release notes 付き** の
GitHub release の作成(source tar 添付)まで完了するようにする。release notes は前の版の tag
から今回の tag までの commit(= squash merge した PR タイトル、Conventional Commits)を
git-cliff で分類して生成し、インストール方法・image の tag / digest・`gh attestation
verify`・source tar の説明を定型で付ける。既存 release の notes だけを作り直す workflow
も追加する(v0.1.0 の notes を埋めるのに使う)。

## 変更内容

- `cliff.toml`(新規): git-cliff の設定。type で分類(`feat` → Features / `fix` →
Bug fixes / `perf` → Performance / `docs` → Documentation /
`refactor`・`test`・`build`・`chore` → Other changes)。`chore(deps)` は
Dependencies に「N dependency updates: #a, #b」の 1 行にまとめる(PR 番号はタイトル行の末尾の
`(#N)` だけから取る。番号の無いものは件数にだけ数える)。`!` / `BREAKING CHANGE:` は Breaking
changes にも載せる。Conventional でない commit も Other changes に残す。**すべての行は
commit のタイトル(1 行目 = PR タイトル)だけから作り**、PR 本文や footer の文面は載せない。末尾の `(#N)` を
PR へのリンクにし、`@name` は mention にならないよう code にし、前の版との compare リンクを付ける。
- `.github/scripts/release-notes-test.sh` /
`release-notes-test.expected.md`(新規): 使い捨ての repository に main の squash
merge と同じ形の fixture の commit(PR 本文付き、実際の Dependabot 形式の本文付き(単独・group)、PR
番号の無い `chore(deps)`、日本語の `BREAKING CHANGE:` footer + attribution、GitHub
の Revert、`@name` を含むタイトル)を作り、notes の「What's changed」を期待値と比べる。PR の
`notes` job で毎回実行する。
- `.github/scripts/release-notes.sh`(新規): `release-notes.sh <tag>
[<digest>]` で notes の Markdown を出力する。
- 安定版は前の安定版から(間の prerelease を畳み込む: `--ignore-tags '^v.*-'`)、prerelease
は直前の tag から、最初の版は全履歴。git-cliff の `--context` から対象 tag の release だけを選んで
`--from-context` で描画するので、HEAD が tag より先(main)でも同じ notes になる。
- tag がまだ無い場合は「最後の tag 〜 HEAD」をその版としてプレビューする。digest を省略すると placeholder。
  - tag が HEAD の祖先でない、semver でない、digest の形式が違う、対象の commit が無い、などはエラー。
- `.github/workflows/engine-image.yml`
  - `publish` が `digest` を output する。
- `release` が checkout(`fetch-depth: 0`)→
git-cliff(`taiki-e/install-action` を SHA
pin、`[email protected]`。install-action が checksum を検証)→ notes 生成(job
summary にも出す)→ release の作成(`--notes-file`。版に `-` があれば prerelease
にする既存の扱いを維持)。
- release が既にある場合(手で作った / 再実行)は、notes を生成したもので **上書き** してから asset を
upload する。
- `.github/workflows/release-notes.yml`(新規): notes の生成だけを行う
workflow。image の公開・release の作成はしない。
- `pull_request`(`cliff.toml`・script・この workflow の変更時): fixture の test
の後、PR の head commit(merge ref ではなく。`Merge … into …` の行が入らない)で、最後の tag(現状
v0.1.0、全履歴)の notes と、次の版(patch + 1)としての「最後の tag 以降」の notes を job summary
と artifact `release-notes` に出す。digest は GHCR から引く(未公開の版は placeholder)。
- `workflow_dispatch`(`tag`、`update`): `update=false`(既定)は dry
run。`update=true` は `gh release edit --notes-file` で既存 release の notes
を置き換える(main か tag 上の実行のみ。image が GHCR に無い版は失敗)。
- 権限: 生成する `notes` job は `contents: read`。書き込む `update` job だけが
`contents: write` で、repository の code は実行しない(artifact を受け取って `gh release
edit` するだけ)。
- docs
- `docs/development.md`: release 手順を「tag を push するだけ」に更新し、「release
notes」節(分類の規則、notes の文面は PR タイトルで決まること、ローカルでの生成方法、作り直し方)を追加。
- `CONTRIBUTING.md`: PR タイトルが release notes の 1 行になること、type /
description の書き方の注意、notes の PR check を追記。
- `docs/security.md`(権限の記述)、`docs/engine-image.md`(digest は release
notes に載る)を追随。

## 設計判断

- **git-cliff を採用**(GitHub の自動生成 + `.github/release.yml` ではなく): この repo
は PR にラベルを付けない運用で、GitHub の自動生成はラベルでしか分類できない。git-cliff は commit の type
で分類でき、PR タイトル = commit タイトルの運用にそのまま合う。API を使わず(`--offline`)git
の履歴だけで決まるので、PR 上やローカルでも同じ結果を再現できる。
- **既存 release の notes は上書き**: notes は git の履歴と公開済みの digest
から決定的に作られるので、再実行で上書きしても結果は同じ。手で先に release を作った場合も、生成した notes に揃える(docs
に明記。公開後の手修正は、作り直すと消える)。
- **CHANGELOG.md は置かない**: tag ごとに CHANGELOG 更新の commit / PR
が必要になり、運用が増えるため。GitHub release を changelog とし、必要なら同じ `cliff.toml` から
`git cliff` でいつでも全履歴を出せる。
- **notes の作り直しは別 workflow**: engine-image.yml の `workflow_dispatch` は
image の公開と結び付いているので、notes だけの経路を分けた。image は再公開せず、digest は GHCR
にある既存の版から引く。
- **notes の生成は image の公開後**: digest が要るため `release` job で生成する。設定の誤りは PR
上の `Release notes / notes` で先に検出する。万一 `release` で失敗しても image は公開済みで、`gh
run rerun --failed` でやり直せる(既存の手順どおり)。
- **git-cliff の版**: `2.14.2` を両 workflow で固定(install-action の manifest の
sha256 で検証)。install-action 自体は SHA pin で、Dependabot の対象。

## 確認方法

- [x] `actionlint`(全 workflow)、`shellcheck
.github/scripts/release-notes.sh`
- [x] ローカルで git-cliff 2.14.2(公式 release の tar を sha512 で確認)を使って生成
  - `release-notes.sh v0.1.0 sha256:b611…` → 下記(v0.1.0 までの全履歴、32 commit)
  - `release-notes.sh v0.1.1` → v0.1.0 以降の差分(この PR の commit のみ)のプレビュー
- 使い捨ての clone で `v0.2.0-rc.1` / `v0.2.0-rc.2` / `v0.2.0` を打って確認: rc.2 は
rc.1 からの差分、v0.2.0 は v0.1.0 からの全部(rc の分を畳み込む)。tag が HEAD の祖先でない場合・semver
でない tag・不正な digest はエラーになる
- `release-notes-test.sh`: 期待値どおり(下記)。修正前の `cliff.toml`
に戻して実行すると、Dependabot の行が `3 dependency updates (Dependabot):,,`
に、Breaking changes が日本語の footer + `🤖 Generated with …` に、Revert
の行が本文付きに、`@octocat` が mention になり、test が失敗することを確認した
  - レビュー対応の後も v0.1.0 の notes は変わらない(前回の出力と diff なし)
- [x] `CONTRIBUTING.md` / `docs/development.md`: タイトルだけが載ること、`@name`
を書かないこと、`jq` が要ること、`update` は通常 `--ref main` で実行すること(v0.1.0 の tag の上には
workflow が無い)、fixture の test を追記
- [x] PR 上の `Release notes / notes` が、v0.1.0 と v0.1.1(プレビュー)の notes を
job summary と artifact に出す(GHCR から v0.1.0 の digest を引く)
- `workflow_dispatch` の dry run は、新規 workflow が default branch に入るまで
dispatch できないため、merge 後に `gh workflow run release-notes.yml --ref main
-f tag=v0.1.0` で確認する(PR 上の `pull_request` の実行が同じ生成を行う)
- tag の push・release の作成 / 編集・publish を有効にした実行はしていない
- Rust のコードは変更していない(cargo の品質ゲートは CI で確認)

### 生成例: v0.1.0(digest は GHCR の実際の値)

<details>
<summary>v0.1.0 の notes(全文)</summary>

````markdown
## What's changed

### Features

- **core**: Define compile domain model and engine interface ([#20](#20))
- **workspace**: Add isolated compile workspaces ([#21](#21))
- **diagnostics**: Parse LaTeX logs into structured diagnostics ([#23](#23))
- **texlive**: Add latexmk engine ([#30](#30))
- **preview**: Render PDF pages to PNG previews ([#31](#31))
- **cli**: Add compile command ([#34](#34))
- **workspace**: Exclude nested output directories by path ([#38](#38))
- **diagnostics**: Locate missing packages and fold fatal errors ([#40](#40))
- **diagnostics**: Report BibTeX failures ([#42](#42))
- **process**: Apply resource limits before exec through a gate ([#44](#44))
- **process**: Limit CPU, memory and process count ([#45](#45))
- **sandbox**: Add a container backend for the TeX engine ([#50](#50))
- **sandbox**: Render previews inside the container ([#52](#52))
- **sandbox**: Reclaim containers left by killed runs and report the process limit ([#53](#53))
- **sandbox**: Reclaim leftovers from a previous boot ([#58](#58))

### Bug fixes

- **workspace**: Refine exclusion and collection edge cases ([#29](#29))
- **texlive**: Restore the build after #39 and #40 ([#43](#43))
- **sandbox**: Accept engine images without labels ([#55](#55))
- **sandbox**: Support rootless Podman and refuse rootless Docker ([#57](#57))
- **sandbox**: Detect OOM kills reliably on Docker ([#61](#61))

### Documentation

- Add contribution guidelines and MIT license ([#15](#15))
- Add initial README ([#18](#18))
- **security**: Define the MVP security model and execution limits ([#22](#22))
- Update README to reflect the completed MVP ([#37](#37))
- Rewrite the README ([#59](#59))

### Other changes

- Initialize repository
- Bootstrap Rust workspace and toolchain ([#16](#16))
- **ci**: Add quality gates and dependency checks ([#19](#19))
- **docker**: Add TeX Live development environment ([#17](#17))
- Add TeX Live integration fixtures and CI job ([#33](#33))
- **process**: Extract shared subprocess execution ([#39](#39))
- **ci**: Publish the engine image to GHCR ([#51](#51))

## Install

```bash
cargo install --locked --git https://github.com/nishide-dev/texrun --tag
v0.1.0 texrun
```

See the [README](https://github.com/nishide-dev/texrun/blob/v0.1.0/README.md#installation) for the requirements and
the tools each backend needs.

## Engine image

The container backend (`--backend container`) runs TeX in the engine image
of this version, `ghcr.io/nishide-dev/texrun-engine:0.1.0` (linux/amd64, linux/arm64). texrun
never pulls it; pull it once:

```bash
docker pull ghcr.io/nishide-dev/texrun-engine:0.1.0
```

Published versions are never overwritten. To use exactly this image, pin its
digest:

```bash
docker pull
ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b
texrun compile --backend container --container-image
ghcr.io/nishide-dev/texrun-engine@sha256:b611748f16d50c00982da2e52b51939d50167bebbc22b35ab8741d1c39e00d1b
main.tex
```

The image has an SBOM, SLSA provenance and a signed GitHub artifact
attestation:

```bash
gh attestation verify oci://ghcr.io/nishide-dev/texrun-engine:0.1.0 -R
nishide-dev/texrun
```

## Source of the engine image

`texrun-engine-0.1.0-sources.tar` (below) has the Debian source packages
(`.dsc`, `.orig.tar.*`, `.debian.tar.*`) of every package in the image,
for both platforms, at exactly the installed versions (`packages.txt` and
`SHA256SUMS` inside): the corresponding source of its GPL / AGPL programs.
See [docs/engine-image.md](https://github.com/nishide-dev/texrun/blob/v0.1.0/docs/engine-image.md#licenses).
````

</details>

### 生成例: v0.1.0 以降の main の差分(次の版のプレビュー)

````markdown
## What's changed

### Bug fixes

- **ci**: Build release notes lines from commit titles only

### Other changes

- **ci**: Generate release notes from conventional commits
- **ci**: Write release notes on tag push and add a notes-only workflow

**Full diff**: [v0.1.0...v0.1.1](v0.1.0...v0.1.1)
````

(以下の Install / Engine image / Source は v0.1.0 と同じ形で、digest は
placeholder。squash merge 後は 1 commit になる)

### 生成例: fixture(`release-notes-test.expected.md`)

````markdown
## What's changed

### Breaking changes

- **cli**: Rename --json flag to --format json ([#4](#4))

### Features

- **cli**: Rename --json flag to --format json ([#4](#4))

### Bug fixes

- **diagnostics**: Report the error `@octocat` found ([#7](#7))

### Other changes

- Revert "fix(core): handle empty logs ([#5](#5))" ([#6](#6))

### Dependencies

- 3 dependency updates: [#2](#2), [#3](#3)

**Full diff**: [v0.1.0...v0.2.0](v0.1.0...v0.2.0)
````

## 補足

- merge 後、v0.1.0 の notes を埋めるには: `gh workflow run release-notes.yml
--ref main -f tag=v0.1.0`(dry run、summary で確認)の後に `gh workflow run
release-notes.yml --ref main -f tag=v0.1.0 -f update=true`。
- notes の文面は PR タイトルで決まる。merge 後に誤りに気付いた場合は release を手で編集できるが、作り直すと消える。
- 推奨(任意): `release-notes.yml` の `update` job にも、engine-image.yml と同様に
`environment` を付けることを検討できる(docs/security.md の「release の入口」)。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Report BibTeX failures as structured diagnostics

1 participant