Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

test(metrics): isolate snapshot read byte accounting

wellkiloe9302928d0b8
diff --git a/tests/hooks/ecc-metrics-bridge.test.js b/tests/hooks/ecc-metrics-bridge.test.js
index c8dafe6dc..baa2cd21a 100644
--- a/tests/hooks/ecc-metrics-bridge.test.js
+++ b/tests/hooks/ecc-metrics-bridge.test.js
@@ -271,8 +271,11 @@ function runTests() {
appendSessionCostRow(metricsDir, 'S1', snapshotRow);
fs.readSync = function measuredRead(descriptor, buffer, offset, length, position) {
- bytesReadFromCostLog += length;
- return originalReadSync.call(this, descriptor, buffer, offset, length, position);
+ const bytesRead = originalReadSync.call(
+ this, descriptor, buffer, offset, length, position
+ );
+ if (Number.isSafeInteger(position)) bytesReadFromCostLog += bytesRead;
+ return bytesRead;
};
const result = readSessionCost('S1');
@@ -329,8 +332,11 @@ function runTests() {
const originalReadSync = fs.readSync;
let bytesReadFromCostLog = 0;
fs.readSync = function measuredRead(descriptor, buffer, offset, length, position) {
- bytesReadFromCostLog += length;
- return originalReadSync.call(this, descriptor, buffer, offset, length, position);
+ const bytesRead = originalReadSync.call(
+ this, descriptor, buffer, offset, length, position
+ );
+ if (Number.isSafeInteger(position)) bytesReadFromCostLog += bytesRead;
+ return bytesRead;
};
try {
assert.deepStrictEqual(readSessionCost('S1'), { totalCost: 1, totalIn: 100, totalOut: 50 });