runtime-pin-check 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mammost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ The address data used by this package comes from @geothai/core and is licensed
24
+ separately under CC BY 4.0 (see the README, section Attribution).
package/README.md CHANGED
@@ -1,3 +1,452 @@
1
- # Temporary Holding Version
1
+ # runtime-pin-check
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **ไทย** · [English](#english)
4
+
5
+ หาเวอร์ชัน **Node, Python และ Go** ที่ถูกปักไว้ไม่ตรงกันในไฟล์ต่าง ๆ ของ repository เดียว (`.nvmrc`, `package.json`,
6
+ `Dockerfile`, `.python-version`, `pyproject.toml`, `go.mod`, workflow ของ GitHub Actions, `.gitlab-ci.yml`, `mise.toml`,
7
+ `.tool-versions`) บอกทุกจุดพร้อม **ไฟล์:บรรทัด** เทียบด้วย semver จริง แยกผลต่อโปรเจกต์ใน monorepo และมี `--fix` ที่แก้เฉพาะ
8
+ ตัวเลขเวอร์ชัน ไม่แตะไบต์อื่น ไม่ใช้ AI ไม่ต้องใช้เครือข่าย และไม่ต้องมี API key ตอนรัน
9
+
10
+ > ติดตั้ง: `npm install -D runtime-pin-check` หรือรันทันที `npx runtime-pin-check` · GitHub Action ยังไม่ได้ออก release
11
+
12
+ ## ผลลัพธ์จริง
13
+
14
+ `examples/conflict-demo/` มีไฟล์หกไฟล์ที่ปักเวอร์ชันขัดกัน (`.nvmrc` 20, `Dockerfile` `node:18-alpine`, workflow ใช้ 22,
15
+ `package.json` ต้องการ `>=22 <23`, `.python-version` 3.11 แต่ `pyproject.toml` ต้องการ `>=3.12`)
16
+
17
+ ```bash
18
+ npm ci && npm run build
19
+ node dist/cli.js examples/conflict-demo --date 2026-11-25
20
+ ```
21
+
22
+ ```text
23
+ runtime-pin-check: 6 pins in 1 project root, checked on 2026-11-25 (end-of-life data from 2026-11-25)
24
+
25
+ . (repo root)
26
+ error VERSION_CONFLICT node
27
+ node: 3 different versions across 3 files: 22 (.github/workflows/ci.yml:10), 20 (.nvmrc:1), 18 (Dockerfile:1); no version satisfies all of them.
28
+ .github/workflows/ci.yml:10 22
29
+ .nvmrc:1 20
30
+ Dockerfile:1 18-alpine
31
+ error OUTSIDE_RANGE node
32
+ .nvmrc:1 pins node 20, outside the range >=22.0.0 <23.0.0-0 required by package.json:1.
33
+ .nvmrc:1 20
34
+ package.json:1 >=22 <23
35
+ error OUTSIDE_RANGE python
36
+ .python-version:1 pins python 3.11, outside the range >=3.12.0 required by pyproject.toml:4.
37
+ .python-version:1 3.11
38
+ pyproject.toml:4 >=3.12
39
+ error OUTSIDE_RANGE node
40
+ Dockerfile:1 pins node 18, outside the range >=22.0.0 <23.0.0-0 required by package.json:1.
41
+ Dockerfile:1 18-alpine
42
+ package.json:1 >=22 <23
43
+ warning EOL_RUNTIME node
44
+ .nvmrc:1 pins node 20 ("20"): node 20 reached end-of-life on 2026-04-30 (check date 2026-11-25).
45
+ .nvmrc:1 20
46
+ warning EOL_RUNTIME node
47
+ Dockerfile:1 pins node 18 ("18-alpine"): node 18 reached end-of-life on 2025-04-30 (check date 2026-11-25).
48
+ Dockerfile:1 18-alpine
49
+
50
+ 4 errors, 2 warnings, 0 info
51
+ ```
52
+
53
+ ผลข้างบนคือผลจริงทั้งหมดจากคำสั่งนั้น (วางจากการรันจริง) รหัสออกเป็น `1`
54
+ เพราะมี finding ระดับ error ส่วน `examples/clean-demo/` ปักเวอร์ชันตรงกันทุกไฟล์ ได้ "No problems found." และรหัสออก `0`
55
+
56
+ ## ต่างจากเครื่องมืออื่นอย่างไร
57
+
58
+ EOL และ GitHub Action **ไม่ใช่จุดเด่นของเรา** เครื่องมืออื่นทำสองอย่างนี้ให้ Node อยู่แล้ว (ดูตารางด้านล่าง) สิ่งที่เรามีและเครื่องมือที่เรารันเทียบไม่มี:
59
+
60
+ 1. **เทียบข้ามไฟล์ทั้งสามภาษา** (Node, Python, Go) ด้วย semver พร้อม `ไฟล์:บรรทัด` ของทุก source
61
+ 2. **`--fix` ที่ปลอดภัยกับ range และคงไบต์เดิม** เขียนทับเฉพาะ pin ที่เป็นเลขเวอร์ชันตรง ๆ (`22`, `22.11.0`, `node:22-alpine`) ส่วน range
62
+ (`>=22 <23`) ไม่แตะเว้นแต่สั่ง `--fix-ranges` และไม่แตะ lockfile
63
+ 3. **แยกผลต่อโปรเจกต์ (project root) ใน monorepo** ไม่เอาเวอร์ชันของ `packages/a` มาเทียบกับ `packages/b`
64
+
65
+ เทียบกับ **engines-gauge 1.1.0** และ **conflic 1.1.6** ข้อมูลในตารางมาจากการรันจริงบน fixture ของ recon (`docs/recon.md`) และบน repo 40
66
+ ตัวของ corpus (`bench/corpus.md`, ตาราง head-to-head) เท่านั้น เรื่องที่ไม่ได้ตรวจ เขียนว่า "ไม่ได้ตรวจ"
67
+
68
+ | | runtime-pin-check | engines-gauge 1.1.0 | conflic 1.1.6 |
69
+ |---|---|---|---|
70
+ | ภาษาที่เทียบ | Node, Python, Go | Node เท่านั้น | Node, Python, Go |
71
+ | แยกผลต่อโปรเจกต์ใน monorepo | มี | ไม่มี | ไม่มี |
72
+ | `ไฟล์:บรรทัด` ของทุก source | มี | มี | มี |
73
+ | `mise.toml`, `.gitlab-ci.yml` | อ่าน | ไม่อ่านทั้งสอง | ไม่อ่านทั้งสอง |
74
+ | `volta`, `go.mod toolchain`, matrix ของ CI | อ่าน | volta และ matrix อ่าน | ไม่อ่านทั้งสามอย่าง |
75
+ | `ARG NODE_VERSION=24` ใน `FROM` | อ่านค่า | พลาด (เห็นแค่ 22.11.0) | อ่านเป็นข้อความดิบ `node:${NODE_VERSION}-alpine` |
76
+ | `--fix` | แก้ pin ตรง ๆ คงไบต์เดิม | `--save` แก้ช่องเดียว (`engines`) | ในการรันของ recon เสนอแก้ `engines ">=22 <23"` เป็น `"20"` |
77
+ | EOL | มี (offline, Node/Python/Go) | มีสำหรับ Node | ไม่มี |
78
+ | GitHub Action | มี (composite) | มี | ไม่ได้ตรวจ |
79
+ | 40 repo จริง: จำนวน finding | 139 | 29 | 1,397 |
80
+ | ใน 26 จุดขัดกันจริงของเรา เครื่องมือนั้นอ้างไฟล์:บรรทัดเดียวกันกี่จุด | — | 5 | 24 |
81
+
82
+ อ่านตารางนี้อย่างระวัง: (1) "อ้างไฟล์:บรรทัดเดียวกัน" เป็นเกณฑ์หลวม ไม่ได้ตรวจว่า finding ถูกความหมาย (2) **ไม่ได้ติดป้ายความถูกต้องของ finding ของคู่แข่ง**
83
+ จึงไม่มี precision ของเขามาเทียบ (3) conflic จับจุดขัดกันจริงได้มากกว่าเราในเกณฑ์นี้ (24 ต่อ 26) แต่รายงานมากกว่าเราราว 10 เท่า และ 220 จาก 1,397
84
+ อยู่ใต้โฟลเดอร์ test/fixtures/testdata (4) ตลาดนี้แน่นเร็ว: recon พบเครื่องมือใหม่ 7 ตัวใน 6 เดือน ทุกตัวมีดาวไม่เกิน 3 และดาวน์โหลดไม่เกิน 28 ต่อสัปดาห์
85
+
86
+ ## ใช้งาน
87
+
88
+ ยังไม่อยู่บน npm ใช้จากซอร์ส (ต้อง Node 22 ขึ้นไป):
89
+
90
+ ```bash
91
+ npm ci
92
+ npm run build
93
+ node dist/cli.js [dir] [options]
94
+ ```
95
+
96
+ | ตัวเลือก | ความหมาย |
97
+ |---|---|
98
+ | `[dir]` | โฟลเดอร์ที่สแกน (ค่าเริ่มต้น `.`) |
99
+ | `--json` | พิมพ์ผลเป็น JSON (มี `findings`, `summary`, `diagnostics`) |
100
+ | `--runtime node,python,go` | ตรวจเฉพาะบางภาษา |
101
+ | `--fail-on error\|warning\|info` | รหัสออก `1` เมื่อมี finding ระดับนี้ขึ้นไป (ค่าเริ่มต้น `error`) |
102
+ | `--date YYYY-MM-DD` | ตรวจ EOL และ alias `lts/*` ณ วันนั้น (ค่าเริ่มต้น วันนี้ตาม UTC) ใช้ทำผลซ้ำได้ |
103
+ | `--include-fixtures` | สแกนโฟลเดอร์ fixture ด้วย (ปกติข้าม `fixtures/`, `__fixtures__/`, `testdata/`, `test-fixtures/`) |
104
+ | `--exclude <glob>` | ข้ามพาธที่ตรง (ใส่ซ้ำได้ เช่น `examples`, `docs/**`) |
105
+ | `--fix --to <version>` | แก้ pin เป็นเวอร์ชันนี้ (ใช้ร่วมกับ `--runtime <หนึ่งภาษา>`, `--dry-run`, `--fix-ranges`) |
106
+
107
+ รหัสออก: `0` ไม่มี finding ระดับที่สั่ง · `1` มี finding · `2` ใช้คำสั่งผิดหรืออ่านไฟล์ไม่ได้ ใน GitHub Actions (`GITHUB_ACTIONS=true`) จะพิมพ์
108
+ annotation `::error file=…,line=…::` ให้ด้วย
109
+
110
+ สแกน repository ตัวเองต้องตัด `examples/` ออก เพราะมีความขัดแย้งที่ตั้งใจใส่ไว้: `node dist/cli.js . --exclude examples`
111
+
112
+ ### `--fix`
113
+
114
+ ```bash
115
+ node dist/cli.js examples/conflict-demo --fix --to 22 --runtime node --dry-run
116
+ ```
117
+
118
+ ```text
119
+ --- a/.nvmrc
120
+ +++ b/.nvmrc
121
+ @@ -1 +1 @@
122
+ -20
123
+ +22
124
+ --- a/Dockerfile
125
+ +++ b/Dockerfile
126
+ @@ -1,2 +1,2 @@
127
+ -FROM node:18-alpine
128
+ +FROM node:22-alpine
129
+ RUN node -v
130
+ runtime-pin-check --fix --to 22 (dry run: nothing written)
131
+ would change 2 pins in 2 files:
132
+ .nvmrc:1 20 -> 22
133
+ Dockerfile:1 18-alpine -> 22-alpine
134
+ already at 22: 1 pin
135
+ left alone (1); nothing is guessed:
136
+ package.json:1 ">=22 <23" (range): ">=22 <23" is a range; pass --fix-ranges to rewrite it
137
+ ```
138
+
139
+ `--dry-run` พิมพ์ diff แล้วไม่เขียนไฟล์ ถ้าไม่ใส่ จะเขียนจริง เฉพาะบรรทัดที่เปลี่ยน ไบต์อื่นของไฟล์คงเดิม (รวม BOM ถ้ามี) pin ที่โปรแกรมไม่เข้าใจ
140
+ ถูกข้าม พร้อมบอกเหตุผล ไม่เดา
141
+
142
+ ### GitHub Action
143
+
144
+ Action เป็น **composite action**: ตั้ง Node 24 (`actions/setup-node`) แล้วรัน `dist/cli.js` ที่อยู่ในตัว action (ถ้าไม่มี `dist/` เพราะอ้างอิง branch
145
+ จะรัน `npm ci && npm run build` ก่อน) การตั้ง Node 24 เปลี่ยน `node` ของ step ถัดไปใน job ของคุณด้วย CLI ต้องใช้ Node 22 ขึ้นไป
146
+
147
+ ```yaml
148
+ - uses: actions/checkout@v7
149
+ - uses: OWNER/runtime-pin-check@v0 # แทน OWNER และ ref ด้วยที่ตั้งจริงของ repository นี้หลังเผยแพร่
150
+ with:
151
+ path: .
152
+ fail-on: error
153
+ exclude: |
154
+ examples
155
+ docs/**
156
+ ```
157
+
158
+ ตัวอย่างไฟล์เต็มอยู่ที่ `examples/workflows/pin-check.yml`
159
+
160
+ | input | ค่าเริ่มต้น | เทียบกับ CLI |
161
+ |---|---|---|
162
+ | `path` | `.` | `[dir]` |
163
+ | `fail-on` | `error` | `--fail-on` |
164
+ | `runtime` | ว่าง (ทั้งสามภาษา) | `--runtime` |
165
+ | `date` | ว่าง (วันนี้ UTC) | `--date` |
166
+ | `exclude` | ว่าง | `--exclude` หนึ่งบรรทัดต่อหนึ่งพาธ |
167
+ | `include-fixtures` | `false` | `--include-fixtures` |
168
+
169
+ ค่า input ส่งผ่าน environment ไม่ถูกต่อเข้าไปในสคริปต์ รายงานแบบข้อความถูกใส่ใน job summary ด้วย CI ของ repository นี้ทดสอบ Action กับ `examples/clean-demo`
170
+ (ต้องผ่าน) และ `examples/conflict-demo` (ต้องล้ม) และสแกน repository ตัวเอง
171
+
172
+ #### การออก release ของ Action (สำหรับผู้ดูแลโปรเจกต์)
173
+
174
+ `dist/` ไม่ถูก commit บน `main` ถ้าจะให้ผู้ใช้ไม่ต้อง build ตอนรัน ให้ออก release ที่ tree มี `dist/`:
175
+
176
+ ```bash
177
+ git switch -c release/v0.1.0
178
+ npm ci && npm run build
179
+ git add -f dist # dist/ ถูก ignore บน main
180
+ git commit -m "build: dist for v0.1.0"
181
+ git tag v0.1.0
182
+ ```
183
+
184
+ แล้ว push branch และ tag ด้วยตัวเอง ตอนรัน action จะติดตั้ง dependency ของ runtime (`npm ci --omit=dev`, สามแพ็กเกจ) หนึ่งครั้งต่อการรัน
185
+
186
+ ## รหัส finding
187
+
188
+ | รหัส | ระดับ | เมื่อไหร่ |
189
+ |---|---|---|
190
+ | `VERSION_CONFLICT` | error | source ของภาษาเดียวกันในโปรเจกต์เดียวกันไม่มีเวอร์ชันที่ซ้อนทับกัน (รายงานหนึ่งรายการต่อภาษาต่อโปรเจกต์ แสดงทุก source จัดกลุ่มตามค่า) |
191
+ | `OUTSIDE_RANGE` | error | pin ตรง ๆ อยู่นอก range ของอีก source (เช่น `.nvmrc` 18 เทียบ `engines >=20`) |
192
+ | `PRECISION_MISMATCH` | info | เห็นตรงกันแต่เขียนละเอียดไม่เท่ากัน (`22` กับ `22.11.0`) |
193
+ | `EOL_RUNTIME` | warning | ทุกเวอร์ชันที่ source อนุญาตหมดอายุแล้ว ณ วันที่ตรวจ |
194
+ | `EOL_SOON` | info | หมดอายุภายใน 90 วัน |
195
+ | `FLOATING_ALIAS` | info | `latest`, `node`, `stable` ที่เปลี่ยนไปเรื่อย ๆ (ไม่นำไปเทียบ) |
196
+ | `UNPARSEABLE` | info | เจอช่องนั้นแต่ตีความไม่ได้ (เช่น `${VAR}`) พร้อมไฟล์:บรรทัด ไม่ข้ามเงียบและไม่ล้ม |
197
+
198
+ ไฟล์ที่เป็น YAML, TOML หรือ JSON ที่พังจริงจะถูกรายงานเป็น diagnostic ระดับไฟล์ (ใน `--json` และใน report) ไม่ทำให้โปรแกรมล้ม
199
+
200
+ ## อ่านไฟล์อะไร
201
+
202
+ - **Node:** `.nvmrc`, `.node-version`, `package.json` (`engines.node`, `volta.node`, `devEngines.runtime`), `.tool-versions`, `mise.toml`,
203
+ `Dockerfile*` (`FROM node:` รวม multi-stage และ `ARG` ที่ใช้ใน `FROM`), `.github/workflows/*.yml` (`actions/setup-node`, ค่าใน matrix เป็น source แยก),
204
+ `.gitlab-ci.yml` (`image: node:`)
205
+ - **Python:** `.python-version`, `pyproject.toml` (`project.requires-python`, `tool.poetry.dependencies.python`), `.tool-versions`, `mise.toml`,
206
+ `Dockerfile*`, `actions/setup-python`, `runtime.txt` ยังไม่อ่าน `Pipfile`, `setup.py`/`setup.cfg`, `tox.ini` และ action อื่นเช่น `astral-sh/setup-uv`
207
+ - **Go:** `go.mod` (`go` และ `toolchain`), `.tool-versions`, `mise.toml`, `Dockerfile*` (`FROM golang:`), `actions/setup-go` ยังไม่อ่าน `go.work` และ `GOTOOLCHAIN`
208
+ - Docker image: ตีความเป็นภาษาก็ต่อเมื่อเป็น image ทางการและ mirror ที่รู้จัก ถ้าเป็น image อื่นจะไม่เดา
209
+
210
+ ## ผูกไฟล์กับโปรเจกต์อย่างไร (สำคัญใน monorepo)
211
+
212
+ โปรเจกต์ (project root) คือ root ของ repository บวกทุกโฟลเดอร์ที่มี `package.json`, `pyproject.toml` หรือ `go.mod` (ไม่นับ `node_modules`, `.git`, `dist`,
213
+ `build`, `vendor`, `.venv`) กติกาหลัก:
214
+
215
+ - ไฟล์ในโปรเจกต์ผูกกับโปรเจกต์ที่ใกล้ที่สุดที่ครอบมัน
216
+ - ไฟล์ pin ระดับ root (`.nvmrc`, `.node-version`, `.python-version`, `.tool-versions`, `mise.toml`) ใช้กับ root และกับทุกโปรเจกต์ย่อยที่ไม่มีไฟล์ชนิดเดียวกัน
217
+ (ค้นขึ้นไปเหมือนที่ nvm, pyenv, asdf, mise ทำ)
218
+ - step ของ CI ระดับ root และ `Dockerfile` ที่ root: ถ้ามี `working-directory` (ของ step หรือ `defaults.run` ของ job) ผูกกับโปรเจกต์นั้น มิฉะนั้นถ้า root มี manifest ของ
219
+ ภาษานั้นผูกกับ root อย่างเดียว มิฉะนั้นผูกกับโปรเจกต์ที่ step/job ระบุพาธไว้ (`cache-dependency-path`, `node-version-file` ฯลฯ) และถ้าไม่มีเลย
220
+ จะเป็น **UNBOUND** (ไม่ผูกกับโปรเจกต์ใด)
221
+ - source ที่ UNBOUND ยังได้ `EOL_*`, `FLOATING_ALIAS`, `UNPARSEABLE` และถูกนับในสรุปว่า "not tied to a project" แต่ **ไม่เข้า** `VERSION_CONFLICT`,
222
+ `OUTSIDE_RANGE`, `PRECISION_MISMATCH` นี่คือการเลือก "precision ก่อน recall": พลาดความขัดแย้งข้ามโปรเจกต์ยอมรับได้ รายงานความขัดแย้งปลอมไม่ได้
223
+
224
+ ## ความแม่นยำที่วัดได้
225
+
226
+ วัดบน **repository สาธารณะ 40 ตัว** (SHA ตายตัวใน `bench/repos.txt`) ด้วย CLI commit `483d4fb` และ `--date 2026-11-25` ติดป้ายทุก finding ด้วยมือเป็น T (ถูกต้อง),
227
+ TI (ถูกตามข้อเท็จจริงแต่ผู้ดูแลของ repository นั้นน่าจะตั้งใจ เช่น matrix ที่ทดสอบเวอร์ชันต่ำสุด) หรือ F (เท็จ) โดยผู้ติดป้ายคนแรก แล้วผู้ติดป้ายอีกคนติดซ้ำแบบ blind ครบทั้ง 139 รายการ (เห็นตรงกัน 98.6%, kappa 0.954; ผลคือเปลี่ยน 1 รายการจาก T เป็น TI)
228
+
229
+ **strict** นับเฉพาะ T ส่วน **factual** นับ T และ TI รวมกัน (TI เป็นเรื่องจริงที่ไฟล์ขัดกันจริง เพียงแต่ผู้ดูแลของ repository นั้นน่าจะตั้งใจ) เกณฑ์ปล่อยของโปรเจกต์ใช้ factual: ไม่มี F ที่เกิดจากผูกไฟล์ผิดโปรเจกต์ (F-scope)
230
+ หรืออ่านไฟล์ fixture (F-fixture) เลย, factual ≥ 95%, และ F ที่เหลือทุกรายการต้องบอกเป็นข้อจำกัด ตัวเลขทั้งสองแบบแสดงไว้ด้านล่างโดยไม่ปัดขึ้น
231
+
232
+ | | ผล |
233
+ |---|---|
234
+ | finding ทั้งหมด | 139 (T 111 · TI 27 · F 1) |
235
+ | precision แบบเข้ม (strict, นับเฉพาะ T) | **79.9%** (111/139) |
236
+ | precision ตามข้อเท็จจริง (factual, T+TI) | **99.3%** (138/139) |
237
+ | F-scope / F-fixture | 0 / 0 |
238
+ | `OUTSIDE_RANGE` | 4 รายการ: T 2, TI 2, F 0 (strict 50.0%, factual 100%, n = 4) |
239
+ | F ที่เหลือ | 1 (`cypress-io/cypress-docker-images`: Dockerfile แยกตามเวอร์ชันของ Node แต่ละรุ่นยังถูกเทียบกับ pin ที่ root) |
240
+
241
+ ตัวเลขทั้งหมดมาจาก `bench/corpus.md` ส่วน "Rerun @ 483d4fb" ทำซ้ำได้ด้วยคำสั่งในส่วน "Repro" ของไฟล์นั้น (`node bench/corpus.mjs clone|run|report`)
242
+
243
+ ข้อจำกัดที่ต้องรู้ ไม่ปิดบัง:
244
+
245
+ - **strict ต่ำกว่าเป้าเดิม 80% อยู่ 1 รายการ** (79.9%; ต้องมี T อย่างน้อย 112 จาก 139) เกณฑ์ปล่อยถูกปรับให้ใช้ factual precision เพราะ TI เป็นความขัดแย้งจริง
246
+ และการปรับกฎต่อบน 40 repo ชุดเดิมจะทำให้ตัวเลขเข้ากับชุดนี้เกินจริง การอ้าง precision ครั้งต่อไปต้องใช้ชุด repo ใหม่ที่ไม่เคยเห็น
247
+ - **`OUTSIDE_RANGE` มีตัวอย่างน้อย (n = 4)** strict 50.0% เพราะ 2 ใน 4 เป็น TI (เช่น การทดสอบ "ปฏิเสธ runtime ที่ไม่รองรับ" โดยตั้งใจ) ไม่มี finding เท็จ แต่ตัวอย่างน้อยเกินกว่าจะสรุปอะไร
248
+ - **recall ลดลงโดยเจตนา:** เมื่อเทียบกับรอบก่อนใช้กติกาผูกโปรเจกต์ มี finding ที่เคยเป็นของจริง 24 รายการ (T 14 + TI 10 ที่หายเพราะกติกา) ไม่ถูกรายงานอีก source 77 ตัวใน 18 จาก 40 repo เป็น UNBOUND
249
+ ส่วนใหญ่เป็นขั้นตอน CI ที่ root ซึ่งไม่มี manifest และไม่มีพาธบอกว่าเป็นของโปรเจกต์ไหน ตัวอย่างความขัดแย้งจริงที่เราพลาดเพราะเรื่องนี้ เช่น node 18 เทียบ 20 ใน workflow สองไฟล์ที่ root ที่ไม่มี manifest ของ Node
250
+ - **ขีดจำกัดที่ยังมี:** repository ที่มี Dockerfile หนึ่งไฟล์ต่อ runtime หนึ่งรุ่น (เช่น cypress-docker-images) ยังเทียบกับ pin ที่ root และให้ finding เท็จ
251
+ - **job ที่ประกาศ `defaults.run.working-directory` แต่ override บาง step กลับไปที่ root** ถูกผูกกับโฟลเดอร์ default ทั้ง job (ตั้งใจ: นี่คือวิธีที่ monorepo ประกาศว่า job รับใช้โปรเจกต์ไหน)
252
+ - ไม่มี precision ของเครื่องมืออื่นให้เทียบ เพราะไม่ได้ติดป้าย finding ของเขา
253
+ - diagnostic ที่เป็นเท็จ 2 รายการใน 1 จาก 40 repo (YAML หลายเอกสารใต้ `.github/workflows/resources/` ที่ไม่ใช่ workflow) ถูกแก้ใน `f80ed6e` วัดซ้ำบน 40 repo เดิมแล้ว: finding เหมือน `483d4fb` ทุก repo และ diagnostic เหลือ 0
254
+ แต่ยังไม่มี diagnostic จริง (ไฟล์พังจริง) ใน 40 repo นี้ จึงยังไม่มีหลักฐานจาก repo จริงว่า diagnostic จับไฟล์พังได้ (มีเฉพาะ unit test)
255
+ - ไม่มีตัวเลขเวลา (ms) ใน README นี้ เพราะขึ้นกับเครื่อง ทุกตัวเลขในส่วนนี้ซ้ำได้ด้วยคำสั่งที่ระบุ
256
+
257
+ ## ข้อมูล EOL
258
+
259
+ `data/eol.json` เป็น snapshot ของ endoflife.date (MIT) สร้างด้วย `node scripts/update-eol.mjs` ซึ่งเป็นที่เดียว (นอกจากการสำรวจ) ที่ใช้เครือข่าย ตัว CLI และไลบรารีไม่ใช้เครือข่ายเลย
260
+ snapshot เก็บเฉพาะสายรุ่น วันหมดอายุ วัน LTS และรุ่นล่าสุด ไม่เก็บคำอธิบายสินค้า ส่วนชื่อ codename ของ Node LTS (เช่น `lts/iron`) ได้มาจากดัชนีรุ่นของ nodejs.org เฉพาะคู่ "เมเจอร์ → ชื่อ" และถ้าอ่านดัชนีนี้
261
+ ไม่ได้ตอนอัปเดต สคริปต์จะเก็บคู่เดิมไว้และแจ้งเตือน ไม่ล้างทิ้ง
262
+
263
+ workflow `.github/workflows/update-eol.yml` รันทุกวันจันทร์: ดึงข้อมูลใหม่ ถ้าสิ่งที่เกี่ยวกับ EOL เปลี่ยน (สายรุ่น วันหมดอายุ วัน LTS หรือ codename; การเปลี่ยนเฉพาะเลขรุ่นย่อยล่าสุดไม่นับ)
264
+ จะรัน typecheck, test, build แล้วเปิด pull request ให้ตรวจ ต้องเปิดการตั้งค่า "Allow GitHub Actions to create and approve pull requests" ของ repository
265
+
266
+ ## เครดิตและสัญญาอนุญาต
267
+
268
+ โค้ดใช้สัญญาอนุญาต MIT (`LICENSE`) ข้อมูล EOL จาก endoflife.date (MIT, © endoflife.date contributors) และ codename จากดัชนีรุ่นของ Node.js รายละเอียดและข้อความสัญญาอนุญาตอยู่ใน [`NOTICE`](NOTICE)
269
+
270
+ ## พัฒนา
271
+
272
+ ```bash
273
+ npm run typecheck && npm test && npm run build
274
+ ```
275
+
276
+ ---
277
+
278
+ ## English
279
+
280
+ Finds **Node, Python and Go** versions that are pinned inconsistently across one repository's files (`.nvmrc`, `package.json`, `Dockerfile`,
281
+ `.python-version`, `pyproject.toml`, `go.mod`, GitHub Actions workflows, `.gitlab-ci.yml`, `mise.toml`, `.tool-versions`), with **file and line** for every
282
+ pin, real semver comparison, results per project in a monorepo, and a `--fix` that changes only the version digits and no other byte. No AI, no network, no API key at run time.
283
+
284
+ > Install: `npm install -D runtime-pin-check`, or run `npx runtime-pin-check`. The GitHub Action has no release yet.
285
+
286
+ ### What it looks like
287
+
288
+ `examples/conflict-demo/` has files that pin conflicting versions. The Thai section above shows the full output of
289
+
290
+ ```bash
291
+ npm ci && npm run build
292
+ node dist/cli.js examples/conflict-demo --date 2026-11-25
293
+ ```
294
+
295
+ (4 errors, 2 warnings, exit code 1: `VERSION_CONFLICT` across `.github/workflows/ci.yml:10` (22), `.nvmrc:1` (20) and `Dockerfile:1` (18-alpine); `OUTSIDE_RANGE` for `.nvmrc`
296
+ and `Dockerfile` against `package.json` `>=22 <23`, and for `.python-version` 3.11 against `pyproject.toml` `>=3.12`; `EOL_RUNTIME` for node 20 and 18.)
297
+ `examples/clean-demo/` is consistent: "No problems found.", exit code 0.
298
+
299
+ ### How it differs
300
+
301
+ End-of-life checks and a GitHub Action are **not** what sets this apart: other tools already provide both for Node. What this adds, and the tools we ran against lack:
302
+
303
+ 1. **Cross-file comparison for all three runtimes** with semver and `file:line` for every source.
304
+ 2. **A `--fix` that is safe with ranges and byte-preserving**: it rewrites only plain version pins (`22`, `22.11.0`, `node:22-alpine`); ranges (`>=22 <23`) are
305
+ left alone unless you pass `--fix-ranges`; lockfiles are never touched.
306
+ 3. **Per-project-root results in a monorepo**: `packages/a` is never compared with `packages/b`.
307
+
308
+ Compared with **engines-gauge 1.1.0** and **conflic 1.1.6**. Every cell comes from our runs on the recon fixture (`docs/recon.md`) and on the 40-repository corpus
309
+ (`bench/corpus.md`, head-to-head table); what we did not check says "not checked".
310
+
311
+ | | runtime-pin-check | engines-gauge 1.1.0 | conflic 1.1.6 |
312
+ |---|---|---|---|
313
+ | Runtimes compared | Node, Python, Go | Node only | Node, Python, Go |
314
+ | Per-project results in a monorepo | yes | no | no |
315
+ | `file:line` for every source | yes | yes | yes |
316
+ | `mise.toml`, `.gitlab-ci.yml` | read | neither read | neither read |
317
+ | `volta`, `go.mod toolchain`, CI matrix | read | volta and matrix read | none of the three read |
318
+ | `ARG NODE_VERSION=24` used in `FROM` | value resolved | missed (saw only 22.11.0) | raw text `node:${NODE_VERSION}-alpine` |
319
+ | `--fix` | rewrites plain pins, bytes preserved | `--save` edits one field (`engines`) | in the recon run it proposed `engines ">=22 <23"` -> `"20"` |
320
+ | End-of-life | yes (offline; Node, Python, Go) | yes, for Node | no |
321
+ | GitHub Action | yes (composite) | yes | not checked |
322
+ | 40 real repos: findings | 139 | 29 | 1,397 |
323
+ | Of our 26 true drift findings, how many the tool reports at the same file:line | — | 5 | 24 |
324
+
325
+ Read this table with care: (1) "same file:line" is a loose measure, not a check that the finding is right; (2) **we did not label the competitors' findings**, so there is
326
+ no precision for them to compare; (3) conflic reaches more of our true drift on this measure (24 of 26) but reports about ten times as many findings, and 220 of its 1,397 sit under
327
+ test/fixtures/testdata folders; (4) the space is crowded and moving fast: recon found 7 new tools in 6 months, each with at most 3 stars and 28 downloads a week.
328
+
329
+ ### Use
330
+
331
+ Not on npm yet. From source (Node 22 or newer):
332
+
333
+ ```bash
334
+ npm ci
335
+ npm run build
336
+ node dist/cli.js [dir] [options]
337
+ ```
338
+
339
+ Options are listed in the Thai table above and in `--help`: `--json`, `--runtime node,python,go`, `--fail-on error|warning|info` (default `error`), `--date YYYY-MM-DD`,
340
+ `--include-fixtures`, `--exclude <glob>` (repeatable), and `--fix --to <version>` with `--runtime <one>`, `--dry-run`, `--fix-ranges`. Exit codes: `0` nothing at or above `--fail-on`,
341
+ `1` findings, `2` usage or I/O error. With `GITHUB_ACTIONS=true` it also prints `::error file=…,line=…::` annotations. To scan this repository itself leave out the deliberate
342
+ conflicts: `node dist/cli.js . --exclude examples`.
343
+
344
+ `--fix` demo (`--dry-run` prints the diff and writes nothing): the Thai section shows `node dist/cli.js examples/conflict-demo --fix --to 22 --runtime node --dry-run` changing
345
+ `.nvmrc` 20 -> 22 and `Dockerfile` `node:18-alpine` -> `node:22-alpine`, and leaving `package.json`'s `">=22 <23"` alone because it is a range.
346
+
347
+ #### GitHub Action
348
+
349
+ A **composite action**: it sets up Node 24 (`actions/setup-node`) and runs the `dist/cli.js` that ships with the action (on a branch ref without `dist/` it runs `npm ci && npm run build` first).
350
+ Setting up Node 24 changes `node` for the later steps of your job too; the CLI needs Node 22 or newer.
351
+
352
+ ```yaml
353
+ - uses: actions/checkout@v7
354
+ - uses: OWNER/runtime-pin-check@v0 # replace OWNER and the ref with the real location once published
355
+ with:
356
+ path: .
357
+ fail-on: error
358
+ exclude: |
359
+ examples
360
+ docs/**
361
+ ```
362
+
363
+ Inputs: `path` (default `.`), `fail-on` (`error`), `runtime` (empty = all), `date` (empty = today, UTC), `exclude` (one path per line), `include-fixtures` (`false`); each maps to the CLI flag of the same name.
364
+ Inputs travel through the environment, never into the script text. The text report is also added to the job summary. A full sample is in `examples/workflows/pin-check.yml`. This repository's CI runs
365
+ the Action on `examples/clean-demo` (must pass), on `examples/conflict-demo` (must fail), and on the repository itself.
366
+
367
+ **Releasing the Action (for the maintainer).** `dist/` is not committed on `main`. To let users skip the build, release a tree that contains it:
368
+
369
+ ```bash
370
+ git switch -c release/v0.1.0
371
+ npm ci && npm run build
372
+ git add -f dist # dist/ is ignored on main
373
+ git commit -m "build: dist for v0.1.0"
374
+ git tag v0.1.0
375
+ ```
376
+
377
+ then push the branch and the tag yourself. On such a ref the action installs the three runtime dependencies (`npm ci --omit=dev`) once per run.
378
+
379
+ ### Finding codes
380
+
381
+ `VERSION_CONFLICT` (error: sources of one runtime in one project have no common version; one finding per runtime per project listing every source), `OUTSIDE_RANGE` (error: a plain pin outside another source's range),
382
+ `PRECISION_MISMATCH` (info: agree at different precision), `EOL_RUNTIME` (warning: every version a source allows is past end-of-life on the check date), `EOL_SOON` (info: end-of-life within 90 days),
383
+ `FLOATING_ALIAS` (info: `latest`, `node`, `stable`; not compared), `UNPARSEABLE` (info: the field was found but cannot be read, with file and line; never skipped silently, never a crash).
384
+ Broken YAML, TOML or JSON is reported as a file-level diagnostic (in `--json` and in the report), not as a crash.
385
+
386
+ ### What it reads
387
+
388
+ - **Node:** `.nvmrc`, `.node-version`, `package.json` (`engines.node`, `volta.node`, `devEngines.runtime`), `.tool-versions`, `mise.toml`, `Dockerfile*` (`FROM node:`, multi-stage, `ARG` used in `FROM`),
389
+ `.github/workflows/*.yml` (`actions/setup-node`; each matrix value is its own source), `.gitlab-ci.yml` (`image: node:`).
390
+ - **Python:** `.python-version`, `pyproject.toml` (`project.requires-python`, `tool.poetry.dependencies.python`), `.tool-versions`, `mise.toml`, `Dockerfile*`, `actions/setup-python`, `runtime.txt`.
391
+ Not read: `Pipfile`, `setup.py`/`setup.cfg`, `tox.ini`, other actions such as `astral-sh/setup-uv`.
392
+ - **Go:** `go.mod` (`go` and `toolchain`), `.tool-versions`, `mise.toml`, `Dockerfile*` (`FROM golang:`), `actions/setup-go`. Not read: `go.work`, `GOTOOLCHAIN`.
393
+ - Docker images count as a runtime only when they are official images or well-known mirrors; other images are ignored, not guessed.
394
+
395
+ ### How files are tied to projects
396
+
397
+ A project root is the repository root plus every folder with a `package.json`, `pyproject.toml` or `go.mod` (not under `node_modules`, `.git`, `dist`, `build`, `vendor`, `.venv`).
398
+ A file inside a project binds to the nearest enclosing project. Root-level tool pin files (`.nvmrc`, `.node-version`, `.python-version`, `.tool-versions`, `mise.toml`) apply to the root and to every
399
+ sub-project without a file of the same kind (looked up the way nvm, pyenv, asdf and mise do). A root-level CI setup step or root `Dockerfile` binds to the project named by its `working-directory` (the step's or
400
+ the job's `defaults.run`); otherwise to the root if the root has a manifest for that runtime; otherwise to the sub-projects named by a path in the same step or job (`cache-dependency-path`, `node-version-file`, ...);
401
+ and if none of that applies it is **UNBOUND**. UNBOUND sources still get `EOL_*`, `FLOATING_ALIAS` and `UNPARSEABLE` and are listed in the summary as "not tied to a project", but never take part in
402
+ `VERSION_CONFLICT`, `OUTSIDE_RANGE` or `PRECISION_MISMATCH`: precision over recall. Missing a cross-project drift is acceptable; reporting a false one is not.
403
+
404
+ ### Measured precision
405
+
406
+ Measured on **40 public repositories** (pinned SHAs in `bench/repos.txt`) with CLI commit `483d4fb` and `--date 2026-11-25`. Every finding was labelled by hand as T (true), TI (true but probably intentional, e.g. a matrix that tests the lowest version) or
407
+ F (false), by a first labeller; a second labeller then re-labelled all 139 findings blind (98.6% agreement, kappa 0.954; one finding changed from T to TI).
408
+
409
+ **Strict** counts T only; **factual** counts T and TI together (a TI is a real disagreement between files that the repository's maintainers probably intended). The release gate is factual: zero false findings caused by binding a file to the
410
+ wrong project (F-scope) or reading a fixture (F-fixture), factual precision of at least 95%, and every remaining F listed as a known limit. Both figures are shown below, not rounded up.
411
+
412
+ | | Result |
413
+ |---|---|
414
+ | All findings | 139 (T 111 · TI 27 · F 1) |
415
+ | Strict precision (T only) | **79.9%** (111/139) |
416
+ | Factual precision (T + TI) | **99.3%** (138/139) |
417
+ | F-scope / F-fixture | 0 / 0 |
418
+ | `OUTSIDE_RANGE` | 4 findings: T 2, TI 2, F 0 (strict 50.0%, factual 100%, n = 4) |
419
+ | Remaining F | 1 (`cypress-io/cypress-docker-images`: one Dockerfile per Node release line is still compared with the root pin) |
420
+
421
+ All figures come from the "Rerun @ 483d4fb" part of `bench/corpus.md` and can be reproduced with the commands in its "Repro" section (`node bench/corpus.mjs clone|run|report`).
422
+
423
+ Known limits, stated plainly:
424
+
425
+ - **Strict precision is one finding short of the original 80% target** (79.9%; 112 of 139 would be needed). The release gate was revised to factual precision, because a TI is a real conflict and another tuning round on the same 40 repositories
426
+ would overfit the metric to this corpus. A future precision claim needs a fresh corpus of repositories nobody has looked at.
427
+ - **`OUTSIDE_RANGE` has few samples (n = 4).** Strict 50.0% because 2 of the 4 are TI (for example a deliberate "reject an unsupported runtime" test); there is no false finding, but four is too few to conclude anything.
428
+ - **Recall was traded away on purpose.** Compared with the run before the project-binding rules, 24 findings that had been real (14 T and 10 TI lost to the rules) are no longer reported, and 77 sources in 18 of the 40 repositories are UNBOUND,
429
+ mostly root-level CI steps in repositories whose root has no manifest and where nothing names the project. A real conflict we miss because of this: node 18 against 20 in two workflows at the root of a repository with no Node manifest.
430
+ - **A Dockerfile per runtime release** (for example cypress-docker-images) still compares with the root pin and produces a false finding.
431
+ - **A job that declares `defaults.run.working-directory` but overrides one step back to the root** is bound to the default folder for the whole job. This is deliberate: it is how a monorepo says which project a job serves.
432
+ - No precision for other tools: we did not label their findings.
433
+ - Two false diagnostics in 1 of the 40 repositories (multi-document YAML under `.github/workflows/resources/` that is not a workflow) were fixed in `f80ed6e` and re-measured on the same 40 repositories: the findings are identical to `483d4fb` in every repository and the diagnostics dropped to 0. There is still no real diagnostic (a genuinely broken file) among the 40, so no evidence from real repositories that diagnostics catch broken files (unit tests only).
434
+ - This README quotes no timings (milliseconds); they depend on the machine. Every figure here can be reproduced with the stated command.
435
+
436
+ ### End-of-life data
437
+
438
+ `data/eol.json` is a snapshot of endoflife.date (MIT), built by `node scripts/update-eol.mjs`, the only place (besides research) that uses the network; the CLI and the library never do. It keeps release lines, end-of-life dates, LTS dates and
439
+ latest releases, and no product descriptions. Node LTS codenames (`lts/iron`) come from the nodejs.org release index, as major-version-to-name pairs only; if that index cannot be read during an update, the script keeps the previous pairs and warns.
440
+
441
+ `.github/workflows/update-eol.yml` runs every Monday: it fetches new data and, when something relevant to end-of-life changed (a release line, an end-of-life date, an LTS date or a codename; a new latest patch release alone does not count),
442
+ it runs typecheck, tests and build and opens a pull request. The repository setting "Allow GitHub Actions to create and approve pull requests" must be on.
443
+
444
+ ### Credits and license
445
+
446
+ Code: MIT (`LICENSE`). End-of-life data from endoflife.date (MIT, © endoflife.date contributors) and Node.js LTS codenames from the Node.js release index; details and license text in [`NOTICE`](NOTICE).
447
+
448
+ ### Development
449
+
450
+ ```bash
451
+ npm run typecheck && npm test && npm run build
452
+ ```