docs(qa): 基线判红归因改判,作废「运行期漂移」初判并补 lessons §5.33
台账 §9.4 初稿把 chromium-mobile 两页 +30/+21px 记为「零源码改动 ⇒ 只能来自
运行期」,参照系用错:旧参照的采集树是 040951c(09-22),当前树含 a366bd1
(09-28 第五轮),参照比树旧了一个修复轮次。
- 实测归因:row-diff.cjs(sharp 逐行比对)定位发散行 y=7440 落在 /products/erp
的 benefits 段;git diff 显示 Q-6 把指标 count-up 从 render 体迁入 useEffect
并加取消 ⇒ 旧参照冻结的是动画中间帧,新参照是稳定终态,属预期改进
- 排除数据侧:prisma/seeds/products.ts 在该窗口零改动
- 三条口径落到 lessons §5.33:归因须对「采集树 vs 当前树」;基线数量须标「例/张」
(本轮 38 张 = 31 例);裸 --update-snapshots 实为 changed 模式,不重写通过项
- §9.5 的 G 项就此关闭,取证脚本随证据目录入库
This commit is contained in:
1 parent
6ba4b70a0c
commit
c66dfcac26
4 files changed
+82
-4
No files matched your search
@@ -0,0 +1,55 @@
|
||||
const { execFileSync } = require('node:child_process');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const sharp = require('sharp');
|
||||
|
||||
const repo = process.cwd();
|
||||
const rel = process.argv[2];
|
||||
const outDir = process.argv[3] || '/tmp/vsdiff';
|
||||
const oldRef = process.argv[4] || '1396666';
|
||||
fs.mkdirSync(outDir, { recursive: true });
|
||||
|
||||
const oldBuf = execFileSync('git', ['show', `${oldRef}:${rel}`], { maxBuffer: 1 << 28 });
|
||||
fs.writeFileSync(path.join(outDir, 'old.png'), oldBuf);
|
||||
const newBuf = fs.readFileSync(path.join(repo, rel));
|
||||
fs.writeFileSync(path.join(outDir, 'new.png'), newBuf);
|
||||
|
||||
async function raw(f) {
|
||||
const img = sharp(f).ensureAlpha();
|
||||
const { data, info } = await img.raw().toBuffer({ resolveWithObject: true });
|
||||
return { data, w: info.width, h: info.height, ch: info.channels };
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const a = await raw(path.join(outDir, 'old.png'));
|
||||
const b = await raw(path.join(outDir, 'new.png'));
|
||||
console.log(`old ${a.w}x${a.h} new ${b.w}x${b.h}`);
|
||||
const w = Math.min(a.w, b.w);
|
||||
const rows = Math.min(a.h, b.h);
|
||||
const firstDiffRows = [];
|
||||
for (let y = 0; y < rows; y++) {
|
||||
let diff = 0;
|
||||
const oa = y * a.w * a.ch, ob = y * b.w * b.ch;
|
||||
for (let x = 0; x < w; x++) {
|
||||
for (let c = 0; c < 3; c++) {
|
||||
const d = Math.abs(a.data[oa + x * a.ch + c] - b.data[ob + x * b.ch + c]);
|
||||
if (d > 24) { diff++; if (diff > 40) break; }
|
||||
}
|
||||
if (diff > 40) break;
|
||||
}
|
||||
if (diff > 40) {
|
||||
firstDiffRows.push(y);
|
||||
if (firstDiffRows.length >= 1 && y - firstDiffRows[0] > 400) break;
|
||||
}
|
||||
}
|
||||
if (!firstDiffRows.length) { console.log('no divergence in shared region'); return; }
|
||||
const start = firstDiffRows[0];
|
||||
let end = start;
|
||||
for (const y of firstDiffRows) end = y;
|
||||
console.log(`first divergent row = ${start}, last in burst = ${end}, burst rows = ${firstDiffRows.length}`);
|
||||
const top = Math.max(0, start - 260);
|
||||
const height = Math.min(b.h - top, 900);
|
||||
await sharp(path.join(outDir, 'new.png')).extract({ left: 0, top, width: b.w, height }).png().toFile(path.join(outDir, 'crop-new.png'));
|
||||
await sharp(path.join(outDir, 'old.png')).extract({ left: 0, top, width: a.w, height: Math.min(a.h - top, 900) }).png().toFile(path.join(outDir, 'crop-old.png'));
|
||||
console.log(`crops written to ${outDir}/crop-{new,old}.png (top=${top}, h=${height})`);
|
||||
})();
|
||||
Reference in new issue
Block a user