fix(eval-harness): validate replay fixture identity before success

This commit is contained in:
Neo committed 2026-11-16 18:39:51 -05:00
1 parent 8abdf329ec
commit c5ea88624f
2 files changed
+54 -1

No files matched your search

+7 -1
View File
@@ -73,7 +73,13 @@ class FixtureStore {
} catch (_error) {
throw new ReplayError('tool.fixture_corrupt', `fixture ${key.slice(0, 16)} is not valid JSON`, { tool, key });
}
if (record.tool !== tool || record.args_hash !== hashValue(args)) {
if (!record || typeof record !== 'object' || Array.isArray(record)
|| typeof record.tool !== 'string' || !Object.hasOwn(record, 'response')
|| ['key', 'args_hash', 'response_hash'].some(field =>
typeof record[field] !== 'string' || !envelope.HASH_PATTERN.test(record[field]))) {
throw new ReplayError('tool.fixture_corrupt', `fixture ${key.slice(0, 16)} has invalid record fields`, { tool, key });
}
if (record.key !== key || record.tool !== tool || record.args_hash !== hashValue(args)) {
throw new ReplayError('tool.fixture_mismatch', `fixture ${key.slice(0, 16)} was recorded for different arguments`, { tool, key });
}
if (record.response_hash !== hashValue(record.response)) {