fix: bound Windows Git metadata paths before workspace creation

This commit is contained in:
Agent Workbench Dev
2026-10-30 00:13:52 +08:00
parent bb48f69f25
commit 4c8321a2ee
29 changed files with 224 additions and 55 deletions
+2 -1
View File
@@ -9,5 +9,6 @@ const manager = new WorkspaceManager(store, { initialize: false, faultInjector:
} });
const record = store.owned('workspace', workspaceId, sessionId);
await (await manager.start(store.session(sessionId), record.id, record.fingerprint)).promise;
process.stderr.write('Workspace did not reach crash cut: ' + cut + ' / ' + record.status + ' / ' + record.summary + '\n');
process.stderr.write('Workspace did not reach crash cut: ' + cut + ' / ' + record.status + ' / ' + record.summary
+ '\nGit result: ' + JSON.stringify(record.gitResult ?? null) + '\nObservation: ' + JSON.stringify(record.observation?.problems ?? []) + '\n');
await manager.stopAll(); store.close(); process.exit(74);
+36
View File
@@ -81,6 +81,42 @@ test('workspace preparation refuses known shared-repository activity and preserv
assert.equal(f.store.core.workspace.size, 1);
});
function deepSource(f, bytes) {
const prefix = path.join(f.root, '深', 'repo', '.git');
const padding = Math.max(0, bytes - Buffer.byteLength(prefix, 'utf8'));
const root = path.join(f.root, '深' + 'p'.repeat(padding), 'repo');
assert.ok(path.resolve(root).startsWith(path.resolve(f.root) + path.sep));
fs.mkdirSync(root, { recursive: true });
fs.copyFileSync(path.join(f.projectRoot, 'README.md'), path.join(root, 'README.md'));
f.projectRoot = root; f.project = f.store.addProject(root); f.session = f.store.createSession(f.project.id);
createDeliveryProject(f);
}
test('compact checkout identities create in deep Unicode source directories while retaining the human branch name', async t => {
const f = fixture(t); deepSource(f, 142);
const before = captureWorkspaceSource(f), manager = new WorkspaceManager(f.store);
const label = 'x'.repeat(64), record = await manager.prepare(f.session, label);
assert.equal(path.basename(record.root), 'w-' + record.id);
assert.ok(record.branch.startsWith('workbench/' + 'x'.repeat(32) + '-'));
await (await manager.start(f.session, record.id, record.fingerprint)).promise;
assert.equal(record.status, 'ready', record.summary);
assertWorkspaceSource(assert, f, before, record.branch);
});
test('Windows Git metadata path limits reject creation before publishing a branch or changing source bytes', async t => {
const f = fixture(t); deepSource(f, 168);
const before = captureWorkspaceSource(f), manager = new WorkspaceManager(f.store);
if (process.platform === 'win32') {
await assert.rejects(manager.prepare(f.session, 'deep metadata'), /Git管理目录过长/);
assert.equal(f.store.core.workspace.size, 0);
assertWorkspaceSource(assert, f, before, 'not-created');
} else {
const record = await manager.prepare(f.session, 'deep metadata');
assert.equal(record.creationAttempted, false);
assertWorkspaceSource(assert, f, before, record.branch);
}
});
test('a pending source snapshot participates in shutdown and completes before storage can close', async t => {
const f = fixture(t); createDeliveryProject(f, { ownerChanges: false });
const runtime = new Runtime(f.store, new Provider()), manager = runtime.workspaceManager();