Repository navigation
feat(workspace): exclude nested output directories by path - #38
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Add WorkspaceConfig::excluded_paths: root-relative paths that are never copied into the workspace, reported as ExclusionReason::ExcludedPath. Each component is matched on the folded name (NFKC + lowercase) and checked again on the workspace filesystem, like excluded names and the output directory, so case and normalization variants are left out too. Ancestors and siblings of an excluded path are not affected. The CLI now excludes the output directory at any depth inside the project (by its canonical spelling), unless it contains the entrypoint, and drops the output_inside_project warning. Closes #36 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: CHANGES_REQUESTED
6b0fab7 をレビューしました。workspace 側の実装(出力先の判定を「root 相対パスのルール」に一般化したこと、Level に depth と paths を持たせて持ち回すこと、lexical な判定と FS の別名チェックの結果を合わせて辿ること)はきれいで、除外判定そのものに誤りや既存水準からの後退は見つかりませんでした。ただ、CLI の「出力先が entrypoint を含む場合は除外しない」の判定に、entrypoint が symlink の場合の漏れがあり、main より悪くなるケースがあるので should-fix 1 件で CHANGES_REQUESTED にします。修正は小さいです。
実行結果
- host(macOS / APFS):
cargo check --workspace --all-targets --all-features --locked/cargo fmt --all -- --check/cargo clippy ... -D warnings/cargo test --workspace --all-features --lockedすべて成功(355 passed。TeX Live / preview tool を使う test は SKIPPED) - dev container(Linux): 同じゲートと
TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedがすべて成功(355 passed、SKIPPED なし) - CI: 全 job pass
確認したこと(問題なし)
実際に fake latexmk で texrun compile を実行し、PR と main の binary を比べました。
- 大文字小文字・全角・NFC/NFD:
-o BUILD/PDF(ディスク上はbuild/pdf)、ディスク上 NFD のディレクトリに NFC の綴りで-oを指定した場合とも、canonical な綴りでexcluded_pathとして除外される。workspace 側の unit / integration test も folding と FS 別名チェックの両方を押さえている - 祖先・兄弟・前方一致:
build/pdfを除外したとき、build/pdf2/・build/pdfx(ファイル)・build/figs/・x/build/pdf/はコピーされる。WorkspacePath::starts_withも component 単位なので CLI 側の判定も前方一致で誤らない - symlink: 除外パス以下を指す symlink(直接、祖先ディレクトリへの symlink を経由、綴りの違い)はすべて
symlink_to_excluded。祖先ディレクトリ自体への symlink はコピーされるが、workspace 内では除外パスが存在しないので問題なし - 複数ルールの合流(出力先
build/outと除外build/pdf)、祖先の位置の非ディレクトリ、出力先ルールの「祖先の位置の非ディレクトリも除外」の維持を確認 - fd ベースの走査: 判定は名前と
Levelの持ち回しだけで、openat/statatの流れと作成後の (dev, ino) 照合は変わっていない。race 耐性の後退はない - 既存の除外の退行なし:
.git・latexmkrc・*.fmt・root 直下のtarget・任意の深さのtexrun-outが従来どおりの reason で除外される - CLI:
-o .、--root . -o src src/doc.tex、--root . -o SRC SRC/doc.tex(APFS)、-o srcで entrypoint がsrc/deep/doc.texの場合はどれも除外されず exit 0。project 内 symlink 経由の-oは従来どおりunsafe_output_path
should-fix
S1. entrypoint が symlink で、その実体が出力先の中にあると exit 2 になる
output_path_to_exclude は input.entrypoint()(symlink の名前のまま)で「出力先が entrypoint を含むか」を判定しています。一方で workspace 側は symlink の target も除外判定にかけるので、たとえば root に main.tex -> a/b/real.tex があり -o a/b とすると、a/b が除外に加わり、main.tex が symlink_to_excluded になって entrypoint_excluded(exit 2)で止まります。main ではこの深さの出力先は除外されないので、warning 付きで exit 0 でした(手元で両方の binary で確認)。PR の補足にある「document 自体が workspace に入らなくなるので除外しない」という方針にも反します。エラーメッセージ(entrypoint `main.tex` is excluded from the workspace)からは原因が出力先だと分かりにくい点も気になります。
修正案:
output_path_to_excludeで、input.entrypoint()に加えて entrypoint の実体(fs::canonicalize(root.join(entrypoint.as_path()))を root でstrip_prefixしたもの。check_entrypointで root の配下にあることは確認済み)も見て、どちらかが出力先の配下なら除外しない。ProjectInputに解決済みの相対パスを持たせる形でもよいですtests/cli.rsに「entrypoint が出力先の中のファイルへの symlink でも 2 回目の run が exit 0 になる」test を追加する
nit(任意対応)
- N1. test コマンドの統一漏れ:
compose.yaml4 行目のコメントとcrates/texrun-texlive/tests/common/mod.rs7 行目の doc comment がcargo test --workspaceのままです - N2. 出力先が entrypoint を含むため除外しなかった場合、前回の出力が次回もコピーされることを利用者は知る手段がありません。warning にしない方針には賛成ですが、
severity: infoの note(あるいは--jsonの report のどこか)に残すと、入力上限に当たったときの原因が追いやすくなります。README の「unless it contains the entrypoint」の後に「その場合は前回の出力もコピーされる」「出力先にある他の source も workspace に入らない」と一言あるとよいです - N3.
notes[].kindからoutput_inside_projectを削除していますが、README では stable code として載せていたものです。まだ release 前なので問題ないと思いますが、PR 本文の変更内容に「note kind の削除」と明記しておくと後で追いやすいです
テストは祖先・兄弟・pdf2・別の場所の同名パス・綴りの違い・symlink・entrypoint まで揃っていて質は高いです。S1 の回帰テストを追加すれば APPROVE できます。
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The output directory was only compared with the entrypoint as given. If the entrypoint is a symlink whose target is inside the output directory, excluding that directory dropped the document (entrypoint_excluded). Compare with the resolved path as well, and add an info note (output_contains_entrypoint) when the output directory cannot be left out, so that earlier outputs being copied again is visible. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
83fcf2b を再レビューしました。前回の should-fix S1 と nit N1〜N3 はすべて解消されています。退行も見つかりませんでした。
実行結果
- host(macOS / APFS):
cargo check --workspace --all-targets --all-features --locked/cargo fmt --all -- --check/cargo clippy ... -D warnings/cargo test --workspace --all-features --lockedすべて成功(356 passed。TeX Live / preview tool を使う test は SKIPPED) - dev container(Linux): 同じゲートと
TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedがすべて成功(356 passed、SKIPPED なし)。ただし 1 回目は、この PR が触れていないtexrun-previewのtools_run_with_resource_limits_on_linuxが 1 件失敗しました(下の「範囲外」を参照)。再実行すると、その test の単独実行 3 回と全件実行はすべて成功しました - CI: 全 job pass
前回の指摘の確認
- S1: 前回と同じ構成(entrypoint が出力先の中のファイルへの symlink)を PR と main の binary で再実行しました。PR では 2 回とも exit 0 で、出力先は除外されず、info の
output_contains_entrypointが出ます(main はoutput_inside_projectwarning 付きで exit 0)。entrypoint_excludedにはなりません。ほかに、ディレクトリの symlink を経由する entrypoint、symlink の連鎖、APFS で大文字小文字の違う綴りの entrypoint、-o .も確認し、いずれも exit 0 で note が出ます。fs::canonicalizeで解決するので中間の symlink も扱えており、output_exclusionの unit test(a/bbとa)と CLI の回帰テストもあります - N1:
compose.yamlとcrates/texrun-texlive/tests/common/mod.rsを更新済み。git grepで--all-featuresの付いていないcargo test --workspaceは残っていません - N2: info の note が JSON と human 表示(
note:)の両方に出ます。README の workspace の説明とnotes[].kindの一覧、Note::kindの doc、README を確認する unit test も更新されています。まだ無い出力先には note が出ず、「未存在の出力先は除外に加えない」という方針とも一致します - N3: PR 本文に note kind の削除が明記されています
退行がないことの確認
- entrypoint を含まない深い出力先(
-o out/pdf)は、2 回目の run で従来どおりexcluded_pathとして除外され、note は出ません - workspace crate は前回のレビュー以降変わっていないので、前回確認した除外判定(綴りの違い、祖先・兄弟・前方一致、symlink、fd ベースの走査)はそのままです
範囲外(参考)
crates/texrun-preview/tests/degraded.rsのtools_run_with_resource_limits_on_linuxが、dev container で 1 回だけ失敗しました(記録された limits がすべて unlimited)。再現はしていません。この PR では preview crate を変更していないので、この PR の判定には含めません。再発するようなら別 issue で調べるのがよいと思います
APPROVE です。
## 概要 latexmk(`texrun-texlive`)と preview tool(`texrun-preview`)で重複していた「外部プログラムの制限付き実行」を、新しい共通 crate `crates/texrun-process` にまとめました。両 crate はこの crate を使うように置き換えています。後続の #25(CPU / メモリ / プロセス数)と #26(container sandbox)は、この crate を拡張して実装できるようにしてあります。 ## 変更内容 - **新 crate `texrun-process`**(Unix のみ。`unsafe_code = "forbid"` はそのまま) - `EnvAllowlist` / `sanitize_path`: `env_clear()` の後に設定する変数の allowlist。`PATH` からは空の entry と相対 entry を除く - `Spec`: program・args・env・cwd・stdout / stderr の扱い(`Capture::Keep(n)` / `Discard`)・`Rlimits`・`StartMode` をまとめたもの - `StartMode::Immediate`(spawn 直後に limit を設定する)と `StartMode::StdinGate { token }`(limit を設定してから stdin に開始の合図を書く) - `Rlimits` / `Resource`: `FileSize` / `Core` / `AddressSpace` / `Cpu` / `Processes`。Linux では `prlimit(2)` で設定し、値は texrun 自身の hard limit との小さい方にする。`ESRCH` は無視する - `Cwd::Path` / `Cwd::Dir { fd, path }`: `Dir` の場合、Linux では子プロセスが `/proc/self/fd/N` 経由で fd 自体に `chdir` する。`/proc` が無い環境では、path が同じ dev / inode を指すことを確認してから使う - `run` / `run_with(launcher, …)`: `process_group(0)` で起動する。1 つの poll ループで、leader の終了(`waitid` の `WNOWAIT`)・cancel・timeout / deadline・呼び出し側の check hook(間隔を指定できる)を確認する。終了時は、leader を zombie のまま `killpg(SIGKILL)` してから reap する。`Drop` guard があるので、error や panic のときも同じ順序になる。`EINTR` は retry する。stdout / stderr は上限まで保持し、pipe は最後まで読む - 拡張点として `Launcher` trait を用意した。メソッドは `command`・`apply_rlimits`・`on_spawn`・`on_kill`。既定の実装は `HostLauncher` - #26: container runtime の起動に変換する。rlimit は runtime 側に渡せる - #25: spawn 直後に cgroup へ attach し、kill のときに cgroup 全体を止める。`RLIMIT_CPU` / `RLIMIT_NPROC` は `Resource` に定義済みで、値を決めるのは #25 - **texlive**: `process.rs` は、engine 固有の部分(`Limits`、output dir のサイズ確認、rc の stdin gate の合図 `START_TOKEN`)だけになった。`child_env` は `EnvAllowlist` を返す。`CapturedOutput` は共通 crate の型を re-export している(公開 API は同じ) - **preview** - `process.rs` は、tool 固有の部分(env・`RLIMIT_AS` / `RLIMIT_FSIZE` の値・描画中の画像のサイズ監視)だけになった - #32 コメントの対応: - scratch dir(`.texrun-preview-*`、0700)と `home/`・`work/` を、fd から `mkdirat` / `openat(O_NOFOLLOW)` で作るようにした。後片付けも fd から `unlinkat` で行い、symlink は辿らない - tool の cwd は `work/` の fd にした。画像のサイズ監視も `fstatat` にした - `PdfInfo::pages` の rustdoc に、`UserUnit` のあるページでは backend によって値が異なること(MuPDF は係数を反映し、Poppler は反映しない)を書いた - 変更前の preview は、`try_wait` で leader を reap してから `killpg` していた。今回 texlive と同じ「kill してから reap」の順序に揃えた - **テストの集約**: `crates/texrun-process/tests/supervise.rs` に、TeX を使わない fake script のテストを置いた(Linux では 15 件)。対象は次のとおり - timeout、deadline、cancel、check hook による停止と group kill - 正常終了後に残った子孫の kill - check hook が panic した場合の guard による kill と reap - leader が reap 済みであること(zombie が残らない) - 出力の上限、env の allowlist、stdin gate、fd の cwd - rlimit(gate 経由の設定値、hard limit との min、`RLIMIT_FSIZE` で書き込みが止まること) - **docs/security.md**: §3.6 を共通 crate の説明に書き換えた。§3.2 / §3.4 に共通 crate の担当範囲を追記し、§2 の検証表に共通 crate のテストを追加した ### 定数の判断(統一した) | 項目 | 変更前 | 変更後 | 理由 | | --- | --- | --- | --- | | poll 間隔 | texlive 20 ms / preview 10 ms | **10 ms**(`POLL_INTERVAL`)で統一 | `waitid` は軽い。preview は短い tool を最大数百回起動するので、1 回ごとの待ち時間を短い方に揃えた。重い check(output dir の集計)は hook ごとに間隔を指定する(texlive は従来どおり 500 ms、preview の `fstatat` は毎回) | | reader の grace | texlive 2 s / preview 500 ms | **500 ms**(`READER_GRACE`)で統一 | group を kill した後の pipe はすぐ EOF になる。待つのは group から抜けたプロセスが pipe を開いている場合だけで、そのとき出力は捨ててよい | | rlimit の設定タイミング | texlive は stdin gate、preview は spawn 直後 | 呼び出し側が `StartMode` で選ぶ | 合図を待てるかどうかは program による(latexmk は rc で待てるが、tool は待てない) | 呼び出し側から指定できるようにはしませんでした。指定できるようにする理由が今は無く、値が食い違う原因を減らすためです。 ### レビュー対応(2 commit 目) - **S1(`StartMode::Immediate` の race)**: - 保証範囲を、`StartMode::Immediate`・`TOOL_ADDRESS_SPACE` の rustdoc と security.md §3.2 に書いた。 - 設定までの gap は時間では抑えられない - gap の間の確保・書き込みは戻らない - gap の間に起動した子孫には制限がかからない - leader 自身には、いずれ設定される - `Immediate` は、子を起動しない単一プロセス向けの best effort な層であることも明記した。 - `Launcher::on_spawn` の rustdoc に、#25 の cgroup attach にも同じ gap があることを書いた。 - exec の前に limit を設定する gate(texrun 自身の helper subcommand が token を待ち、`setrlimit` してから exec する)は #41 で実装する。この PR では doc に記載するだけにした。 - テスト: - preview の `tools_run_with_resource_limits_on_linux` は、leader 自身の `/proc/$$/limits` を retry 付き(上限 5 s)で読む形にした。 - `texrun-process` に `linux::rlimits_reach_an_immediate_leader` を追加した。 - dev コンテナで CPU を過負荷にした状態で 40 回ずつ(計 80 回)実行し、失敗は 0 回だった。 - **nit 1(Launcher の hook)**: - `on_kill(pid)` に leader の pid を渡すようにした。 - reap 後の hook `on_reaped(pid)` を追加した。 - hook は `Drop` からも呼ばれるので、panic してはならないことを rustdoc に書いた。 - security.md §3.6 は「拡張する(hook の形は #25 / #26 で見直す)」に弱めた。 - **nit 2(token の大きさ)**: `StartMode::MAX_TOKEN_LEN = 512`(POSIX の最小 `PIPE_BUF`)を定義した。これを超える token は、spawn の前に `RunError::InvalidSpec` で拒否する。 - **nit 3(macOS で rlimit を黙って skip しない)**: - `Finished::rlimits_applied` に、limit を適用したかどうかを記録する。 - `Spec::require_rlimits` を指定すると、適用できない環境では spawn の前に `RunError::Unsupported` を返す。 - latexmk の stdin gate は `require_rlimits` を指定する。preview は best effort のまま。 - **nit 4**: `Resource::Cpu` の rustdoc に、`SIGXCPU` の既定動作は core dump なので `Core` = 0 と組み合わせることを書いた。 - **nit 5(テストの強さ)**: - fd の cwd のテストを OS 別に分けた。Linux は `Ok(moved)` だけ、それ以外は `Err` だけを受け入れる。 - hard limit の cap のテストは、テストの中で自分の `RLIMIT_CORE` の hard limit を有限の値(1 MiB 以下)に下げてから検証するようにした。 - 記録用の launcher を書き、次のテストを追加した: hook の順序、`on_spawn` の失敗で kill・reap されること、`apply_rlimits() == false` で prlimit されないこと、`rlimits_applied`、`Unsupported`(macOS)、token の上限。 - **nit 6**: preview で `RunError::Spawn` の場合は `source` だけを使うようにし、program 名が 2 回出ないようにした。 - **nit 7**: scratch dir は、すでに開いてある output root の fd(`try_clone`)から作るようにした。 - **nit 8**: `/proc/self/fd/N` は `N >= 3` の場合だけ使う。そうでなければ、path を確認する方式に fallback する。 - origin/main(#38 を含む)に rebase した。 ## 確認方法 - [x] `cargo check --workspace --all-targets --all-features --locked` - [x] `cargo fmt --all -- --check` - [x] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`(macOS、および Linux のコンテナ) - [x] `cargo test --workspace --all-features --locked`(macOS) - [x] `cargo deny --locked check` - [x] `docker-compose run --rm -e TEXRUN_REQUIRE_TEXLIVE=1 -e TEXRUN_REQUIRE_PREVIEW_TOOLS=1 dev cargo test --workspace --all-features --locked`: 全て pass、ignored は 0 件(rebase 後の 2 commit 目で再確認。supervise は Linux で 22 件) ## 関連 Issue Closes #32 ## 補足 - `/proc` が無い環境(macOS)では、fd の cwd は「path を確認してから使う」方式になる。この確認と子プロセスの `chdir` の間は atomic ではない(security.md §3.2 に記載)。`HOME` は環境変数なので path で渡す。ここは tool の cache の置き場で、texrun は中身を読まない - #35 / #36 が変更する crate(`texrun-latex-log`、`texrun-workspace`、`apps/texrun`)には手を入れていません 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
## 概要 `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]>
概要
texrun-workspaceに root 相対パスでの除外(WorkspaceConfig::excluded_paths)を追加し、CLI は project 内の出力先を深さによらず次回の workspace から除外するようにしました。-o build/pdfのような深い出力先の中身が次の run でコピーされ、入力上限を無駄に消費する問題(#36、PR #34 の nit)を解消します。あわせて、ローカル品質ゲートの test コマンドを CI / README と揃えました。変更内容
texrun-workspaceWorkspaceConfig::excluded_paths: Vec<WorkspacePath>(既定は空)とwith_excluded_pathsを追加ExclusionReason::ExcludedPathを追加し、除外したパスをMaterializeReportに記録(ディレクトリは 1 件として記録し、中身は列挙しない)Level::out_idx)を、「root 相対パスのルール」の一般化に置き換えた。出力先がルール 0、excluded_pathsがその後に続く。fd ベースの走査の中で、各ディレクトリで「どのルールのパス上にいるか」を持ち回して判定するBuild/PDFや NFD / 全角の綴りも除外される。1 つのディレクトリが複数のルールのパス上にある場合(例: 出力先build/outと除外build/pdfのbuild)も、lexical と FS の両方の結果を合わせて辿るexcludes_path)にも適用: 除外パス以下を指す symlink はSymlinkToExcluded、除外パス以下の entrypoint はEntrypointExcludedapps/texrun。出力先の扱いのみ変更)output::walkで解決した canonical な path(ディスク上の綴り)が project root の配下なら、その root 相対パスをexcluded_pathsに加える。これまでのchild_of(root 直下だけをexcluded_root_namesで除外)は廃止した-o .や--root . -o src src/doc.tex)は除外しない(下の補足を参照)。entrypoint を指定したときの path に加えて、canonicalize した実体の root 相対パスでも判定する(entrypoint が出力先の中のファイルへの symlink の場合、レビュー S1)notes[].kind = output_contains_entrypoint。human 表示ではnote:)を出すoutput_inside_projectを削除した(README で stable code として載せていたもの。release 前のため互換性の配慮はしていない)。あわせてoutput::is_nested_inも削除した。JSON のworkspace.excluded[].reasonにexcluded_pathが出るnotes[].kindの一覧)と、README の一覧を確認する unit test を更新compose.yamlのコメント・crates/texrun-texlive/tests/common/mod.rsの doc comment の test コマンドをcargo test --workspace --all-featuresにし、README / CI と揃えたexcluded_pathsを追記excludes_path、folding を切った状態での FS 別名チェック(BUILD/PDF)a/b/c/pdf)だけが除外され、祖先・兄弟・prefix の似た兄弟(pdf2)・別の場所の同名パスはコピーされる。大文字小文字 / 全角 / NFC⇔NFD の違いでも除外される。symlink と entrypoint にも適用される-o build/pdf/outの 2 回目の run でexcluded_pathが report に出て、warning が出ず、kept workspace で祖先・兄弟だけがコピーされていることを確認。entrypoint を含む出力先は除外されずoutput_contains_entrypointnote が出ること、entrypoint が出力先の中への symlink でも 2 回目の run が exit 0 になること(S1 の回帰テスト。修正を外すと失敗することを確認済み)確認方法
cargo check --workspace --all-targets --all-features --lockedcargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --locked(host の macOS / APFS。TeX Live を使う test は skip)TEXRUN_REQUIRE_TEXLIVE=1 TEXRUN_REQUIRE_PREVIEW_TOOLS=1 cargo test --workspace --all-features --lockedで全件成功cargo denyは CI に任せています関連 Issue
Closes #36
Refs #4, #6, #34
補足
--root . -o src src/doc.tex)ならentrypoint_excluded(exit 2)になり、2 段以上下なら warning を出して続行していました。今回は深さによらず「除外せずに続行する」に揃えています。この場合、前回の出力は次回もコピーされます(-o .と同じで、出力を source と同じ場所に置くのは利用者の選択、という扱いです)。warning ではなく info の note(output_contains_entrypoint)で知らせますchild_ofは存在しない出力先も root 直下なら除外していましたが、walkの結果(canonical な綴り)だけを使う形にしましたcompile.rsのworkspace_config周り、output.rsのis_nested_in削除、report.rsの reason 名と note の doc、cli.rsの help)だけです。Extract shared subprocess execution into a common crate #32 / Improve missing-package line and fatal-error counting in log diagnostics #35 の作業範囲には触れていません🤖 Generated with Claude Code