Skip to content

fix(elixir): auto-merge lock file maintenance, and narrow its window - #166

Merged
toshi0806 merged 1 commit into
mainfrom
fix-elixir-lockfile-automerge
Sep 2, 2026
Merged

fix(elixir): auto-merge lock file maintenance, and narrow its window#166
toshi0806 merged 1 commit into
mainfrom
fix-elixir-lockfile-automerge

Conversation

@toshi0806

Copy link
Copy Markdown
Member

#165 が Elixir 系 8 PR のうち 4 本(elixir dependencies)を止めていた原因を扱うのに対し、こちらは残る 4 本(lock file maintenance)です。原因が別なので分けています。

症状

止まっている 8 本の PR 本文を読み比べると、はっきり分かれます。

#23 (elixir dependencies):    🚦 Automerge: Enabled.
#24 (lock file maintenance):  🚦 Automerge: Disabled by config.

後者は設定どおりの挙動で、branch protection を入れても動きません。

原因

{"matchManagers": ["mix"], "matchDatasources": ["hex"],
 "matchUpdateTypes": ["minor", "patch", "digest", "lockFileMaintenance"], "automerge": true}

lock file refresh は datasource を持たないため、matchDatasources がこの rule から締め出しています。 matchUpdateTypeslockFileMaintenance と書いてあるのに一度も効いていない、自己矛盾した状態でした。

npm.json の同等ルールには matchDatasources がなく、だから latex 系では同じ週に lockfile PR が自動マージされています。

対応

matchDatasources を外すのではなく、rule を分けました。あの絞り込みは git 依存を自動マージの対象から外す意図があるはずで、それを壊さずに lockFileMaintenance だけを通すためです。

-      "matchUpdateTypes": ["minor", "patch", "digest", "lockFileMaintenance"],
+      "matchUpdateTypes": ["minor", "patch", "digest"],
       "groupName": "elixir dependencies",
       "automerge": true
+    },
+    {
+      "matchManagers": ["mix"],
+      "matchUpdateTypes": ["lockFileMaintenance"],
+      "automerge": true

効かない記述を元の rule に残すと、読んだ人が「lockFileMaintenance も automerge される」と誤解するので削っています。matchManagersnpm.json と揃えました。

窓も同時に狭めます

 "lockFileMaintenance": {
   "enabled": true,
-  "schedule": ["on sunday and monday"]
+  "schedule": ["before 5am on sunday"]
 }

automerge を有効にするだけだと、#157 で観測したループが Elixir 系でも始まります。 lock file maintenance は job が汲み尽くせる「項目」ではなく「コミットされた lockfile と registry の差」なので、マージすると数時間で差が復活し、2 日窓の中の次の job がまた PR を作ります。latex 系では 08-27〜08-29 の窓で 7 本作られ、うち 1 本は前の PR のマージ 36 秒後でした。

Elixir 系で今それが起きていないのは、automerge が動いていないからにすぎません。 この PR で automerge を通す以上、窓の修正とセットにする必要があります。#158latex.json に施したのと同じ形(1 日・夜明け前、Renovate デフォルトの形を曜日だけ動かす)です。5 時間は Mend の job 間隔 4 時間より広いので、窓が 2 つの job の間に落ちる失敗には戻りません。

影響範囲

elixir#v1 を extend する 9 リポジトリすべてに届きます。DNS 系 5 リポジトリ(automerge が正常動作中)も対象なので、あちらの lock file maintenance も日曜早朝の 1 窓に変わります。mudan-dns セッションには別途共有します。

順序

#165(branch protection)とは独立ですが、#165 を先にマージするのが自然です。protection が入るまでは elixir dependencies 側が動かないので、この PR だけ入れても lockfile の 4 本しか流れません。

A lock file refresh carries no datasource, so matchDatasources on the
rule above -- which is deliberate, keeping git dependencies out of the
auto-merged lane -- never let lockFileMaintenance match it. Naming
lockFileMaintenance in that rule's matchUpdateTypes did nothing, and the
mix lock refreshes have sat unmerged since 2026-08-30 while the npm ones,
whose rule carries no datasource filter, merged the same week. Give it
its own rule rather than widening the existing one.

Narrow the window to one day for the reason recorded in #157 and applied
to latex.json in #158: lock file maintenance is not an item a job can
exhaust but the difference between the committed lock file and the
registry, so merging it restores that difference within hours and the
next job inside a two-day window has something to create again. That did
not surface here only because nothing was merging. Five hours still
exceeds the four-hour job interval, so the window cannot fall between two
jobs.

Refs #157

@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.

全体的に、問題の原因分析・修正方針・副作用への対処がすべて整合しており、変更内容は適切です。以下に気になった点を1点挙げます。

Comment thread elixir.json
"description": "Auto-merge lock file maintenance too. It cannot ride on the rule above: a lock file refresh carries no datasource, so matchDatasources there -- which is deliberate, keeping git dependencies out of the auto-merged lane -- excludes it. Naming lockFileMaintenance in that rule's matchUpdateTypes therefore did nothing, and the mix lock refreshes sat unmerged from 2026-08-30 while the npm ones, whose rule has no datasource filter, merged the same week.",
"matchManagers": ["mix"],
"matchUpdateTypes": ["lockFileMaintenance"],
"automerge": true

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] 新しいルールに matchDatasources が存在しないことは意図的(lockFileMaintenance はデータソースを持たないため)ですが、matchPackagePatternsmatchDepTypes などの追加フィルタも一切ないため、mix マネージャーが管理するすべてのリポジトリの lockFileMaintenance PR が無条件に automerge されます。

PR 本文では「git 依存を自動マージ対象から外す意図」に言及していますが、lockFileMaintenance の場合は git 依存のバージョン固定も lock ファイルに含まれます。git 依存が含まれるリポジトリで lock ファイルが更新された場合、その変更も自動マージされることになります。

意図的にそれを許容するのであれば、description にその旨を明記しておくと、将来の読者が誤解しにくくなります。

@toshi0806

Copy link
Copy Markdown
Member Author

DNS 系からの実測データ

elixir#v1 を extend する DNS 系 5 リポジトリを担当している側から実測が届いたので、影響範囲の裏付けとして記録します。この変更は DNS 系にとっても改善でした。

1. 窓を狭めても不利益がない

2 日窓の状態で、過去に作られた lockfile PR は 8/16 の 1 回だけです。

tenbin_dns    #135 created=08-16T17:51 merged=08-17T01:53 +1/-1
tdig          #90  created=08-16T16:29 merged=08-17T01:55 +2/-2
tenbin_cache  #132 created=08-16T16:39 merged=08-17T01:53 +1/-1
elixir_dnstap #41  created=08-16T18:08 merged=08-17T01:55 +0/-0

Elixir 側は依存本数が少なく transitive の入れ替わりもほとんどないため、週 1 本で困る事情はないとのことです。npm 系(textlint 9 パッケージ+その transitive)とは規模が違います。

2. DNS 系でも automerge は効いていませんでした

上の merge 時刻がそれを示しています。4 リポジトリのマージが 01:53:32 / 01:53:37 / 01:55:22 / 01:55:26 と 2 分間に集中している一方、作成からは 8〜9 時間空いています。

Renovate の job による自動マージなら各リポジトリの job タイミングに散るはずで、この集中は人が続けて操作した形です。 Automerge: Disabled by config. が DNS 系でも同じように出ていたことになります。

つまりこの PR は、Elixir 系 4 ツールの停止を解くだけでなく、DNS 系で毎回発生していた手動マージも不要にします

3. 差分ゼロの PR が実在しました

elixir_dnstap#41+0/-0 を確認したところ、API の集計値ではなく実際に変更ファイルが 0 件でした。

$ gh api /repos/smkwlab/elixir_dnstap/pulls/41/files
(空)

lockfile に差がない状態でも lock file maintenance の PR が作られたことになります。#157 に書いた「マージすると差が復活し、窓の中の次の job がまた作る」の裏返しで、差がなくても作るなら窓を狭める理由がもう一つ増えます。

ただし作成の 8 時間後にマージされているので、作成時点では差があり、その間に別経路で同じ状態になった可能性も残ります。断定はできません。 窓を狭める判断はこれに依存しないので、深追いはしていません。

@toshi0806
toshi0806 merged commit 5f6ffc5 into main Sep 2, 2026
2 checks passed
toshi0806 added a commit that referenced this pull request Sep 4, 2026
The window moved in #166 and again here, and neither change left a trace
in this file: description[3] explains the two-day top-level window and
says nothing about the one lockFileMaintenance carries. Reading elixir.json
alone gave no reason for `after 6am and before 12pm on sunday`.

Split across two entries -- why it is narrower than the window above, and
why it sits in daylight -- rather than one, which would have run half
again as long as anything else here.

Refs #157
toshi0806 added a commit that referenced this pull request Sep 4, 2026
* fix: move the lock file maintenance windows into daylight

The five-hour window from midnight caught nothing. On 2026-09-04
texlive-ja-textlint's jobs completed at 07:57, 11:57, 14:57, 17:57 and
21:57 in Tokyo, and the one before 07:57 was the previous day: the
interval is three to four hours through the day but stretches overnight,
so a window running 00:00-05:00 sits in the gap. The update spent the
whole of Friday under Awaiting Schedule and no pull request was created.

#158 justified five hours by comparing it against a four-hour interval
read off the documentation. The average was right and the placement was
not, and an average cannot tell you whether a particular five hours is
reachable.

Six hours from 6am takes in two jobs, which is what one refresh needs:
the first creates the pull request, the second merges it once the checks
are green. The third -- the job that would start the cycle again, which
is what #157 set out to stop -- falls outside.

elixir.json carried the same midnight window and gets the same move. Its
next window is 2026-09-06, so this needs to be distributed today to be
worth anything.

Refs #157

* docs(elixir): record why the lock file window sits where it does

The window moved in #166 and again here, and neither change left a trace
in this file: description[3] explains the two-day top-level window and
says nothing about the one lockFileMaintenance carries. Reading elixir.json
alone gave no reason for `after 6am and before 12pm on sunday`.

Split across two entries -- why it is narrower than the window above, and
why it sits in daylight -- rather than one, which would have run half
again as long as anything else here.

Refs #157
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.

1 participant