Repository navigation
Closed
Labels
enhancementNew feature or request
Milestone
Description
背景
texrun の最初の backend として TeX Live + latexmk を利用する。
互換性を最優先し、一般的な LaTeX 文書や学会テンプレートを既存 TeX 環境と同様にコンパイルできることを目指す。
スコープ
- TeX Live / latexmk は外部依存として利用する
- shell を介さず subprocess を起動する
- 初期 MVP では local installation を前提としてよい
- engine interface 経由で呼び出す
作業内容
-
latexmkexecutable の検出 - workspace を working directory として起動
- non-interactive な compile option を設定(候補は下記)
- stdout / stderr を capture
- exit status を
CompileResultに変換 - PDF artifact を収集
- timeout 時に子プロセスを停止できるようにする
- latexmk は pdflatex / bibtex 等を子プロセスとして起動するため、latexmk 単体ではなく process group 単位で kill する(Unix:
CommandExt::process_group(0)+killpg) - stdout / stderr の読み取りでデッドロックしないよう、pipe は別スレッド等で読み続ける
- latexmk は pdflatex / bibtex 等を子プロセスとして起動するため、latexmk 単体ではなく process group 単位で kill する(Unix:
- executable が存在しない場合を明確な error にする
- engine version / latexmk version を取得できる余地を設ける
- 子プロセスの環境変数を制御する(
TEXINPUTS等の host 由来の変数に意図せず依存しない)
latexmk 引数の候補
latexmk -pdf -norc
-interaction=nonstopmode -halt-on-error -file-line-error
-no-shell-escape
-outdir=<workspace output dir>
<entrypoint>
-norc:latexmkrc(Perl コード)を読み込まない。workspace 内・ユーザー home のどちらの rc も実行させない-no-shell-escape:\write18を明示的に無効化する(TeX Live 既定の restricted shell escape にも依存しない)-file-line-error: Normalize LaTeX diagnostics into structured errors and warnings #7 の file / line 抽出を容易にする- 環境変数
max_print_lineを大きな値にしてログの 79 文字折り返しを抑制する(Normalize LaTeX diagnostics into structured errors and warnings #7 の parse 精度向上) - 環境変数
openout_any=p/openin_any=pで書き込み・読み取りを paranoid に制限できるか検証する(Add execution limits and define the sandbox boundary #9)
pdflatex 以外(xelatex / lualatex)の選択は MVP では option として持たなくてよいが、CompileOptions に追加できる形にしておく。
セキュリティ
引数生成に shell command string を利用しない。
避ける:
sh -c "latexmk ..."
直接 executable と argument array を指定する。
完了条件
- 最小の
article文書から PDF を生成できる - syntax error を含む文書で compile failure を返せる
- latexmk が存在しない環境で明確なエラーになる
- timeout が機能し、timeout 後に latexmk / TeX の子プロセスが残らない
依存
- Define the compile domain model and engine interface #3(engine interface)、Implement isolated compile workspaces #4(workspace)
- timeout / 実行制限のポリシーと文書化は Add execution limits and define the sandbox boundary #9、fixture による E2E は Add integration fixtures for common LaTeX scenarios #10
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
chore(docker): add TeX Live development environment (#17)
feat(core): define compile domain model and engine interface (#20)
nishide-dev commentedon Sep 30, 2026
PR #20(#3)からの申し送り: engine は
compile(&self, ctx: &CompileContext<'_>, req)を実装。最初にreq.validate()を呼ぶ契約、ctx.cancel.is_cancelled()を timeout の try_wait poll ループ内で確認し process group を kill、cancel 時はCompileOutcome::Cancelled。argv に path を渡すときはWorkspacePath::to_cli_arg()(先頭-対策)を使う。docs(security): define the MVP security model and execution limits (#22)
nishide-dev commentedon Sep 30, 2026
PR #22(docs/security.md)再レビューからの #5 向け申し送り:
"を拒否するのは引数受け渡しの正しさのためにも必要$xdvipdfmx,$hilatex,$dvips_landscape,$hnt_previewer,$*_update_command等)もすべて NONE にするKpsewhich command needed but not set upは stderr に出る(bibtex 使用時のみ)-outdirを latexmk は pdflatex に相対パスで渡す(Normalize LaTeX diagnostics into structured errors and warnings #7 の path 正規化に影響).texrun自身は写さないfmt/base/mem、.biber.conf、走査上限 40,000)に合わせるfeat(workspace): add isolated compile workspaces (#21)
feat(diagnostics): parse LaTeX logs into structured diagnostics (#23)
feat(preview): render PDF pages to PNG previews (#31)
feat(process): limit CPU, memory and process count (#45)
chore(ci): generate release notes from conventional commits (#62)