Repository navigation
feat(diagnostics): report BibTeX failures - #42
Conversation
## 概要 #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]>
39c5529 to
aaa091b
Compare
nishide-dev
left a comment
There was a problem hiding this comment.
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に出ない
修正案:
- 上の場合は
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) - このとき、「the error may be on the previous line」の注記は付けない
Unbalanced bracesも同様に line を None にし、「detected at line N; an unbalanced{or"earlier in this entry is likely」を付ける- 上の 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 全体で効いていない。
.blg1 つあたり 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]>
|
レビューありがとうございます。追加 commit で対応しました(origin/main に追従済み)。 should-fix
nit
確認
🤖 Generated with Claude Code |
nishide-dev
left a comment
There was a problem hiding this comment.
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@stringbefore it」のような文言にすると、より正確です。
以上で APPROVE とします。
## 概要 `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]>
概要
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:.blgparserBlgParser(新しい moduleblg)を追加しました。別 crate にはせず、同じ crate の module にしました。純粋関数・best-effort という性質が同じで、
sanitize、excerpt の上限、Collector(error 優先の件数上限)をそのまま使えるためです。認識する内容:
.blgI couldn't open database file/style file/auxiliary filemissing_file<msg>---line N of file x.bib(位置が次の行にある形も)、---while reading file、Sorry---bibtex_errorWarning--I didn't find a database entry for "k"undefined_citationWarning--other(There were N error messages)/(That was a fatal error)/ 上の errorbibtex_failedfile:
.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(新しい modulebibtex。process 関連には触れていません):*.blgを読みます(mtime が latexmk の開始以降。\includeやbibunitsなどで複数の aux があっても拾います)。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 にしました。Bibtex errors: See fileがあるのに.blgを読めなかった場合は、bibtex_failedの error を返します。.blgは artifact に含めません(docs/security.md§3.9 の「engine が報告したものだけ収集」の方針)。内容は diagnostics のraw_excerptに入ります。texrun-latex-log/tests/fixtures/logs/bibtex-*.blg(dev コンテナの実ログ。.bibの構文エラー、存在しない.bib、存在しない entry、存在しない.bst、複数.bib)regenerate.shにbibtexmode(pdflatex 1 pass +bibtex main)を追加しました。latexmk は.bibが無いと BibTeX を実行しないので、.blgの fixture にはこの mode を使います。texrun-texlive/tests/fixtures/bibtex/(entrypoint ごとに 1 シナリオ)tests/real_blg.rs)、proptest(panic しない・出力に上限がある)、大きな入力が短時間で終わることrequire_texlive!()方式の scenario testtests/bibtex.rs(構文エラー、存在しない.bib、paranoid mode で開けない.hidden/refs.bib、存在しない entry、存在しない.bst、サブディレクトリの entrypoint と複数.bib、正常な bibliography では何も出ないこと)docs/security.md(.blgを artifact にしないことと、読み込みの上限)確認方法
cargo check --workspace --all-targets --all-features --lockedcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warnings(host とコンテナ)cargo test --workspace --all-features --locked(host)TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --locked(全件 pass)関連 Issue
Closes #27
補足
(the error may be on the previous line)が付きます)。TeX のl.Nと同じ意味なので残しましたが、None にすべきという意見があれば変えます。.bib(\bibliography{xampl}など)も latexmk には「見つからない」扱いになり、BibTeX が実行されません。この PR ではその場合もmissing_fileの warning として報告します(挙動自体は既存のままです)。🤖 Generated with Claude Code