Skip to content

fix(texlive-tags): declare the two registry-less references - #172

Merged
toshi0806 merged 1 commit into
mainfrom
declare-the-registry-less-tag-references
Sep 4, 2026
Merged

fix(texlive-tags): declare the two registry-less references#172
toshi0806 merged 1 commit into
mainfrom
declare-the-registry-less-tag-references

Conversation

@toshi0806

Copy link
Copy Markdown
Member

Resolves #164

2026e の drift 是正(#161)で、監査が 25 件を報告した一方 grep では 29 箇所ありました。差の 4 件はレジストリ接頭辞を伴わない short-form で、invariants.coverage のとおり既定の検出が届きません。うち 2 件は拾うべきものでした。

拾うべき 2 件

箇所 理由
latex-release-action/Dockerfile:8 1 行目が pin する同じイメージの注記。片方だけ動くと、どのバリアントが使われるかの説明が実態と食い違う
latex-ecosystem/ECOSYSTEM.md:73 既存パターンが拾う 72 行目の次の行。名前とタグがコロンで 1 セルに収まっているかどうかの差だけで、同じ表の半分が監査の外にあった

拾ってはいけない 2 件

CHANGELOG.md は各リリースが何を出したかの記録、ECOSYSTEM.md:330 はバージョニング方式の例示です。

前者には明示的な ignore が必要でした。 short-form パターンが届いてしまうためで、しかも検証中に 2026d(6 行目)だけでなく 2026a(11 行目)もあることが分かりました。後者はイメージ名を伴わないため、どちらのパターンでも自然に除外されます。

実測で検証しました

# latex-release-action に (?<!ghcr\.io/smkwlab/)texlive-ja-textlint:\K[0-9]{4}[a-z]? を適用
Dockerfile:8:2026e        ← 拾いたい
CHANGELOG.md:6:2026d      ← ignore で除外
CHANGELOG.md:11:2026a     ← ignore で除外

# latex-ecosystem、否定後読みなし
ECOSYSTEM.md:73:2026e
docs/MULTI-ORG-DEPLOYMENT.md:170:2026e   ← 既定検出と重複

# 否定後読みあり
ECOSYSTEM.md:73:2026e                     ← 重複なし

否定後読みを入れた理由

#164 に「既定検出と二重に当たると drift 件数が水増しされるはず」と書いた懸念への対応です。hits は既定検出と extra_patterns の結果を単純連結しているので、同じ file:line:tag が 2 回出ると件数が狂います。上の実測どおり、否定後読みで docs/MULTI-ORG-DEPLOYMENT.md:170 が除外され重複しません。

効果の確認方法

現在すべて 2026e に揃っているため、今 audit を走らせても drift 0 件で、この変更の効果は見えません。次のリリース(2026f)で Dockerfile:8ECOSYSTEM.md:73 が drift として報告されるかどうかが実証になります。

The audit reported 25 drifting references for 2026e while grep found 29.
Four sat outside the declaration because they name the image without the
registry prefix, which invariants.coverage says the default detection
does not reach. Two of those four should be caught.

Dockerfile:8 in latex-release-action annotates the same image its first
line pins, so when only one of the pair moves the note stops describing
what the file builds. ECOSYSTEM.md:73 is the row below one the existing
pattern already covers -- the two differ only in whether the name and the
tag share a cell, and half of that table was invisible to the audit.

The other two stay out, and stay out correctly: CHANGELOG.md records what
each release shipped, and ECOSYSTEM.md:330 illustrates the versioning
scheme rather than naming the current release. The first needs an explicit
ignore because the short-form pattern reaches it -- both its 2026d and its
2026a line -- while the second carries no image name and is excluded by
either pattern.

Both patterns use a negative lookbehind so the default detection and these
do not count the same line twice.

Refs #164

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

全体的に変更の意図は明確で、PR 本文の説明も詳細です。以下に気になる点を挙げます。

],
"ignore_note": "どのリリースが何を出したかの記録。2026d と 2026a を名乗る行があるが、現行版に揃えると履歴が壊れる。",
"extra_patterns": [
"(?<!ghcr\\.io/smkwlab/)texlive-ja-textlint:\\K[0-9]{4}[a-z]?"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 [HIGH] extra_patterns の重複リスク

latex-release-actionlatex-ecosystem の両方に同一パターン (?<!ghcr\.io/smkwlab/)texlive-ja-textlint:\K[0-9]{4}[a-z]? が追加されています。

PR 本文では「否定後読みで重複を防ぐ」と説明されていますが、それは同一リポジトリ内での既定検出との重複を防ぐものです。もし将来、両リポジトリが同じファイルを参照するような構成変更があった場合、このパターン自体が複数エントリに存在することで混乱を招く可能性があります。

また、このパターンが latex-release-actionCHANGELOG.md に対しても適用されるかどうか(ignore リストが extra_patterns にも効くか)を、スクリプト側で明示的に保証しているか確認が必要です。もし ignoreextra_patterns に適用されない実装であれば、CHANGELOG.md 内の texlive-ja-textlint:2026d のような行が誤検出される恐れがあります。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

2 点とも確認しました。どちらも据え置きます。

ignoreextra_patterns にも効きます

ご指摘の懸念が一番重要でしたが、audit-texlive-tags.sh の処理順がこうなっています。

ignore=$(printf '%s' "$spec" | jq -r '.ignore // [] | .[]')

hits=$( ... 既定の検出 ... )                    # ① 既定検出を集める

extra=$(printf '%s' "$spec" | jq -r '.extra_patterns // [] | .[]')
while IFS= read -r pattern; do
    found=$( ... grep -oHnP "$pattern" ... )
    [ -n "$found" ] && hits=$(printf '%s\n%s' "$hits" "$found")   # ② extra も同じ hits へ
done <<EOF
$extra
EOF

while IFS= read -r hit; do                       # ③ hits 全体に ignore を適用
    file=${hit%%:*}
    ignored=false
    while IFS= read -r path; do
        [ "$file" = "$path" ] && ignored=true
    done <<EOF
$ignore
EOF
    [ "$ignored" = true ] && continue

既定検出と extra_patterns の結果は同じ hits に集約され、除外はその後に一度だけ適用されます。 実装コメントにも設計意図が明記されています。

除外パスは grep の後で落とす。git ls-files に渡して絞ると、宣言したパスが消えていても気付けない

したがって CHANGELOG.md は、パターンが到達しても後段で確実に落ちます。誤検出は起きません。

同一パターンが 2 エントリにある件

宣言はリポジトリごとに独立して適用されます。スクリプトは各リポジトリを個別に clone し、その作業ディレクトリで git ls-filesgrep を走らせるため、latex-release-action のパターンが latex-ecosystem のファイルに当たることはありません。

「両リポジトリが同じファイルを参照する構成変更」は、この仕組みでは起こりえない形です。パターンが同じ文字列であることは偶然ではなく、同じ書き方(レジストリ接頭辞なしのイメージ参照)を拾いたいという同じ要求から来ています。共通化するとしたら宣言の構造自体を変える話になり、この PR の範囲を超えます。

"ignore": [
"CHANGELOG.md"
],
"ignore_note": "どのリリースが何を出したかの記録。2026d と 2026a を名乗る行があるが、現行版に揃えると履歴が壊れる。",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [MEDIUM] ignore_noteextra_patterns_note はスキーマ上の正式フィールドか確認を

ignore_note および extra_patterns_note はコメント代わりに使われていますが、JSON にはコメント構文がないためこのアプローチ自体は理解できます。ただし、これらのフィールドがスキーマや処理スクリプト側で「未知フィールドとして無視される」ことが保証されているか確認してください。スキーマ検証が厳格(additionalProperties: false 相当)な場合、バリデーションエラーになる可能性があります。

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

スキーマ検証は存在しないので、バリデーションエラーにはなりません。 据え置きます。

audit-texlive-tags.sh が jq で読むフィールドはこれだけです。

.image
.name
.ignore
.extra_patterns
.source_of_truth.repo
.source_of_truth.path

ignore_noteextra_patterns_note は読まれず、単に無視されます。スクリプト内に $schema / ajv / jsonschema 等による検証は一切ありません。

そもそもこの書き方はこのファイルの既存の慣習です。

  • トップレベルの $schema-note — ファイル全体の趣旨を書いている
  • invariants — 5 つの不変条件を散文で書いている
  • latex-ecosystemignore_note / extra_patterns_note — 今回追加したものと同じ形

つまり _note サフィックスは、JSON にコメント構文がないことへの既定の対処としてこのファイルが元から採っている方式で、今回それに倣っただけです。ご指摘のとおり additionalProperties: false のスキーマが後から導入されれば影響しますが、そのときは既存の $schema-noteinvariants も同時に引っかかるので、このファイル全体の設計判断として扱うべき話になります。

@toshi0806

Copy link
Copy Markdown
Member Author

レビュー対応

HIGH 1 件・MEDIUM 1 件、いずれも実装を確認して据え置きました。コード変更はありません。CI は review / review / actionlint とも success です。

HIGH: ignoreextra_patterns に効くか(r3935507045)→ 効きます

この PR の成否を左右する指摘だったので、実装を追いました。

audit-texlive-tags.sh は既定検出と extra_patterns の結果を同一の hits に集約し、その後に一度だけ ignore を適用します。実装コメントにも設計意図が書かれています。

除外パスは grep の後で落とす。git ls-files に渡して絞ると、宣言したパスが消えていても気付けない

したがってパターンが CHANGELOG.md に到達しても後段で落ちます。誤検出は起きません。

なお同一パターンが 2 エントリにある件は、スクリプトが各リポジトリを個別に clone してその作業ディレクトリで grep する構造上、相互に干渉しません。

MEDIUM: _note フィールドがスキーマ違反にならないか(r3935507051)→ 検証機構がありません

jq が読むのは .image / .name / .ignore / .extra_patterns / .source_of_truth.* の 6 つだけで、_note 系は無視されます。スキーマ検証のコードは存在しません。

加えてこの書き方はこのファイルの既存の慣習です(トップレベルの $schema-noteinvariantslatex-ecosystem の既存 _note 群)。将来 additionalProperties: false のスキーマを導入するなら、それらも同時に対象になるため、ファイル全体の設計判断として扱うべき話になります。


全指摘に返信済み・CI green で収束しました。Resolves #164 を含むため、マージ時に #164 が自動クローズされます。

@toshi0806
toshi0806 merged commit 6e23fbb into main Sep 4, 2026
4 checks passed
@toshi0806
toshi0806 deleted the declare-the-registry-less-tag-references branch September 4, 2026 16:18
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.

Two registry-less texlive tag references sit outside the audit's declarations

1 participant