Files
Agent-Workbench/docs/network-q-evidence/drivers/network-q-index.mjs.txt
T
2026-11-03 23:53:31 +08:00

20 lines
1.6 KiB
Plaintext

import fs from 'node:fs';
import assert from 'node:assert/strict';
import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
const hash = value => createHash('sha256').update(value).digest('hex');
const prefix = 'docs/network-q-evidence/', manifest = JSON.parse(fs.readFileSync(prefix + 'manifest.json'));
const files = [...manifest.entries.map(row => prefix + row.path), prefix + 'manifest.json'].sort();
const indexed = execFileSync('git', ['ls-files','-z','--','docs/network-q-evidence'], { encoding:'utf8', windowsHide:true }).split('\0').filter(Boolean).sort();
assert.deepEqual(indexed, files);
const output = execFileSync('git', ['cat-file','--batch'], { input: files.map(file => ':' + file).join('\n') + '\n', windowsHide:true, maxBuffer:256*1024*1024 });
let cursor = 0, bytes = 0;
for (const file of files) {
const end = output.indexOf(10,cursor), header = output.subarray(cursor,end).toString('ascii');
assert.match(header,/^[a-f0-9]+ blob \d+$/); const size = Number(header.split(' ')[2]);
cursor = end+1; const body = output.subarray(cursor,cursor+size); cursor += size; assert.equal(output[cursor++],10);
const disk = fs.readFileSync(file); assert.equal(body.length,disk.length); assert.equal(hash(body),hash(disk),file); bytes += size;
}
assert.equal(cursor,output.length);
console.log(JSON.stringify({success:true,count:files.length,bytes,manifestSha256:hash(fs.readFileSync(prefix+'manifest.json')),scope:'Every original evidence file and manifest staged in Git, with identical SHA-256 and bytes. No log omissions or line-ending transformation.'}));