Skip to content

Commit 9b69d9b

Browse files
committed
Record runtime dependency inventory without dev checks
1 parent 72d3fe4 commit 9b69d9b

4 files changed

Lines changed: 42 additions & 7 deletions

File tree

.github/workflows/phase2-packet-capture.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,6 @@ jobs:
211211
phase2-dependencies/protocol-client/client-build-manifest.json
212212
phase2-dependencies/protocol-client/client-files.sha256
213213
phase2-dependencies/protocol-client/node-minecraft-protocol/package-lock.json
214-
phase2-dependencies/protocol-client/node-minecraft-protocol/dependency-tree.json
214+
phase2-dependencies/protocol-client/node-minecraft-protocol/production-lock-inventory.json
215215
if-no-files-found: warn
216216
retention-days: 30

.github/workflows/phase2-runtime-ab.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,6 @@ jobs:
181181
phase2-dependencies/protocol-client/client-build-manifest.json
182182
phase2-dependencies/protocol-client/client-files.sha256
183183
phase2-dependencies/protocol-client/node-minecraft-protocol/package-lock.json
184-
phase2-dependencies/protocol-client/node-minecraft-protocol/dependency-tree.json
184+
phase2-dependencies/protocol-client/node-minecraft-protocol/production-lock-inventory.json
185185
if-no-files-found: warn
186186
retention-days: 30

docs/phase2-performance-validation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ Pktmon 只能证明传输行为,不能证明朝向、高度、遮挡、动画
512512

513513
协议客户端只用于让 Paper/Sparrow 经过真实 tracker、chunk 与 TCP 路径,不渲染画面。准备步骤固定
514514
`node-minecraft-protocol`、wrapper 和协议数据的三个 40 位提交,在无 secret 的只读 job 中禁用 npm
515-
lifecycle scripts,并保存完整 lockfile、依赖树和逐文件 SHA-256。该依赖仍来自尚未合并的上游 PR,
515+
lifecycle scripts,并保存完整 lockfile、由 lockfile 派生的生产依赖清单和逐文件 SHA-256。该依赖仍来自尚未合并的上游 PR,
516516
因此自动结果是性能/协议回归证据,不替代原版客户端、Leaf、Via/代理/Geyser 的真人兼容性勾选。
517517

518518
正式结论必须使用默认 12 runs、120 秒预热、20 秒稳定和 180 秒 clean 采样。4/8 runs 仅用于验证

tools/perf/prepare-phase2-protocol-client.sh

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,52 @@ packageJson.dependencies['minecraft-data'] = 'file:../node-minecraft-data'
7777
fs.writeFileSync('package.json', `${JSON.stringify(packageJson, null, 2)}\n`, 'utf8')
7878
NODE
7979
npm install --omit=dev --ignore-scripts --package-lock=true --no-audit --no-fund
80-
npm ls --omit=dev --all --json > dependency-tree.json
80+
# npm ls recursively validates dependencies declared by the linked data
81+
# source package, including its generator/test toolchain. Those packages are
82+
# intentionally absent from this runtime-only install, so derive a stable
83+
# production inventory from the authoritative lockfile instead.
84+
node <<'NODE'
85+
const fs = require('fs')
86+
const lock = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
87+
if (lock.lockfileVersion !== 3 || lock.packages == null) {
88+
throw new Error(`Unsupported package-lock schema: ${lock.lockfileVersion}`)
89+
}
90+
const compareText = (a, b) => a < b ? -1 : a > b ? 1 : 0
91+
const sortedObject = value => Object.fromEntries(Object.entries(value || {}).sort(([a], [b]) => compareText(a, b)))
92+
const packages = Object.entries(lock.packages)
93+
.filter(([, metadata]) => metadata.dev !== true)
94+
.sort(([a], [b]) => compareText(a, b))
95+
.map(([location, metadata]) => ({
96+
location: location || '.',
97+
name: metadata.name || null,
98+
version: metadata.version || null,
99+
resolved: metadata.resolved || null,
100+
integrity: metadata.integrity || null,
101+
link: metadata.link === true,
102+
optional: metadata.optional === true,
103+
dependencies: sortedObject(metadata.dependencies),
104+
optionalDependencies: sortedObject(metadata.optionalDependencies),
105+
peerDependencies: sortedObject(metadata.peerDependencies)
106+
}))
107+
const inventory = {
108+
schemaVersion: 1,
109+
source: 'package-lock.json production entries',
110+
lockfileVersion: lock.lockfileVersion,
111+
packageCount: packages.length,
112+
packages
113+
}
114+
fs.writeFileSync('production-lock-inventory.json', `${JSON.stringify(inventory, null, 2)}\n`, 'utf8')
115+
NODE
81116
)
82117

83118
mkdir -p "$output_directory"
84119
mv "$nmp_directory" "$output_directory/node-minecraft-protocol"
85120
mv "$wrapper_directory" "$output_directory/node-minecraft-data"
86121

87122
lock_path="$output_directory/node-minecraft-protocol/package-lock.json"
88-
tree_path="$output_directory/node-minecraft-protocol/dependency-tree.json"
123+
inventory_path="$output_directory/node-minecraft-protocol/production-lock-inventory.json"
89124
test -s "$lock_path"
90-
test -s "$tree_path"
125+
test -s "$inventory_path"
91126

92127
sha256_file() {
93128
sha256sum "$1" | awk '{print $1}'
@@ -112,7 +147,7 @@ cat > "$output_directory/client-build-manifest.json" <<EOF
112147
},
113148
"installScriptsEnabled": false,
114149
"packageLockSha256": "$(sha256_file "$lock_path")",
115-
"dependencyTreeSha256": "$(sha256_file "$tree_path")"
150+
"productionLockInventorySha256": "$(sha256_file "$inventory_path")"
116151
}
117152
EOF
118153

0 commit comments

Comments
 (0)