fix(install): recheck file ownership after the manifest scan

This commit is contained in:
Agent Workbench Dev
2026-11-04 19:40:33 +08:00
parent 13c8fc2d79
commit 1037031e82
5 changed files with 33 additions and 5 deletions
+6
View File
@@ -31,3 +31,9 @@ W六请求71044 tokens、0提案0交付是事实;末轮新增468字符、还
### 升级兼容补漏
安装关联首轮13项11通过、2失败:upgrade-running的历史兼容清单截至1.25.0,编译宿主真实报告1.25.1后被拒,并非数据或Key问题。已补1.25.1并让当前APP_VERSION始终参与受支持列表,保留未知/未来版本拒绝;新增版本守卫,实际独立进程连续两次升级和0.1.0迁移3/3通过。首失败install-related.tap与复验upgrade-compat.tap均保留。没有操作正式宿主。
### 安装阶段
目录枚举时对每个普通文件补treeFile,重新检查实际路径、常规类型及nlink,避免全清单扫描后新增硬链接漏验;目录仍走祖先检查。独立反例加入不属于最终宿主身份集合的可选文件,full-manifest已完成后在inventory开始新增外部别名,准确拒绝;移除别名后原身份/字节保持。安装12/12通过。
只读对同一10971文件不可变发行做ABBA对照,旧校验8450/8150ms,新校验11083/9961ms,四次宿主身份exact。新增文件复核有约2–3秒成本,保持单次realpath算法,不回到逐文件重复祖先遍历。该数值是整个validateInstalledVersion的本轮观察,不能冒充新的正式升级耗时。原记录在.qa/reliability-1.25.2/install.tap及install-benchmark.json。
+1
View File
@@ -7,6 +7,7 @@
- 当前阶段:预留来源顺序修复;后续安装变化核验、混合进展及吞吐、发行验收、新真实实验,各阶段验证/回顾/本地提交。
- 预留阶段:v3原消费前缀+原账本顺序,v1/v2保持历史算法;输入异常不丢输出最大值。专项13/13、上下文/预算/引擎24/24通过,原R保持72571及原暂停。已补阶段回顾,按范围本地提交。一次读取不存在src/core/state路径的rg失败,改读真实src/server/store.mjs。
- 安装关联首轮13项11通过2失败,确认升级兼容列表漏1.25.1;补历史版本并动态包含当前APP_VERSION,守卫及独立真实宿主升级3/3通过,首失败保留,先单独提交该修复。没有正式操作。
- 安装文件变化复核12/12通过;10971文件只读ABBA全校验8.15–8.45s→9.96–11.08s、四次身份exact,记录新增检查的真实成本。已补阶段回顾并独立本地提交。
## 1.25接续
+5 -3
View File
@@ -7,7 +7,7 @@ import { isDeepStrictEqual } from 'node:util';
import { HostController } from './host-controller.mjs';
import { inspectHostInstallation } from './app-installation.mjs';
import { observeWindowsProcess, protectUserDirectory, binaryIdentity } from './process-identity.mjs';
import { ownedChild, readState, writeState, samePath, assertLocalTree } from './file-state.mjs';
import { ownedChild, treeFile, readState, writeState, samePath, assertLocalTree } from './file-state.mjs';
import { upgradeRunning } from '../../../scripts/upgrade-running.mjs';
import { canonicalHost, hostError } from '../../shared/contracts/desktop-host.mjs';
import { InstallationProgress } from './installation-progress.mjs';
@@ -21,10 +21,12 @@ export function validateInstalledVersion(directory, { onProgress = null } = {})
if (installation.kind !== 'portable') throw fail('安装候选需要完整便携发行清单。');
const manifest = readState(path.join(installation.root, 'MANIFEST.json'), 16 * 1024 * 1024), actual = [];
const walk = relative => { for (const entry of fs.readdirSync(path.join(installation.root, relative), { withFileTypes: true })) {
// Directories keep the full ancestor check; files are reached only through
// those checked directories, and their bytes were verified by the manifest scan.
// Recheck file ownership after the hash scan: an optional shipped file may
// have acquired another link in the meantime. Keep the single-realpath
// file check rather than walking every ancestor again for every file.
const next = path.posix.join(relative, entry.name);
if (entry.isDirectory()) { ownedChild(installation.root, next); walk(next); } else if (entry.isFile()) {
treeFile(installation.root, next);
actual.push(next); onProgress?.({ scope: 'directory-inventory', root: installation.root, completedFiles: actual.length, totalFiles: manifest.files.length + 1, completedBytes: null, totalBytes: null, currentPath: next });
} else throw fail('安装候选含有链接或非常规文件。');
} }; walk('');
+2 -2
View File
@@ -5,8 +5,8 @@
用户在独立复核后授权全量修复、开发、验证与本地提交。基线532b9d60干净;采用planning-with-files,先解决已复现问题,再新冻真实样本。正式PID/Provider/Key保持,不委派、不推送、不续跑旧样本。原失败和未知不改成通过。
1. [complete] 预留v3绑定原账本消费前缀,拒绝重排/重复/跨Task;保留v1/v2算法和原封存核验,输入异常不再丢弃已报告输出上界。专项13/13、上下文/预算/引擎相关24/24通过。
2. [in_progress] 恢复全清单扫描后普通文件的归属/硬链接变化核验,保持单次realpath提速;补时间边界回归与性能证据。
3. [pending] 修复混合进展读取停止,保留真正重复/相同检查/相同提案的有界停止;核对实际请求中读页与检查事实并提高可用分页吞吐。
2. [complete] inventory恢复每文件treeFile检查,扫描后新增硬链接被拒,原身份/字节一致;12/12安装通过,关联11项通过与升级3/3复验。10971文件只读ABBA全校验旧8.15–8.45s、新9.96–11.08s,未恢复逐文件祖先遍历。
3. [in_progress] 修复混合进展读取停止,保留真正重复/相同检查/相同提案的有界停止;核对实际请求中读页与检查事实并提高可用分页吞吐。
4. [pending] 完整相关/全量/构建与实际界面、不可变发行及隔离安装验收;保留状态升级1.25.2,阶段回顾和本地提交。
5. [pending] 新冻结单次诊断/身份预检/有界Node;通过后才React/Python及Purge AB/BA,分别报告失败、成本和因果边界,不循环重试求通过。
+19
View File
@@ -49,6 +49,25 @@ test('installation requires separate absolute program/data directories and a can
assert.throws(() => new InstallationManager({ installRoot: 'relative', dataRoot: f.data }));
const m = manager(f, root); m.candidateRoot = f.projectRoot; assert.throws(() => m.candidate());
});
test('inventory rejects a new hardlink on an optional file after its full-manifest scan and accepts the untouched candidate after removal', t => {
const f = fixture(t), root = candidate(f), relative = 'zz-optional-data.txt', original = Buffer.from('owned optional release data');
const file = path.join(root, relative), alias = path.join(f.root, 'outside-optional-alias.txt');
fs.writeFileSync(file, original);
const manifestFile = path.join(root, 'MANIFEST.json'), manifest = JSON.parse(fs.readFileSync(manifestFile, 'utf8'));
manifest.files.push({ path: relative, bytes: original.length, sha256: hash(original) });
fs.writeFileSync(manifestFile, JSON.stringify(manifest));
const before = validateInstalledVersion(root); let linked = false, fullScanFinished = false;
assert.throws(() => validateInstalledVersion(root, { onProgress(progress) {
if (progress.scope === 'full-manifest' && progress.completedFiles === progress.totalFiles) fullScanFinished = true;
if (progress.scope === 'directory-inventory' && !linked) {
assert.equal(fullScanFinished, true); fs.linkSync(file, alias); linked = true;
}
} }), /多个路径/);
assert.equal(linked, true); assert.equal(fs.lstatSync(file).nlink, 2);
assert.deepEqual(fs.readFileSync(file), original); assert.deepEqual(fs.readFileSync(alias), original);
fs.unlinkSync(alias); assert.deepEqual(validateInstalledVersion(root), before);
});
test('staging retains the original data and pointer without querying or restarting a host', async t => {
const f = fixture(t), root = candidate(f), m = manager(f, root), before = snapshotPersistentData(f.data);
m.host = () => { throw Error('Staging must not contact the host'); };