Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@colony/core': patch
---

Stop attributing the storage-at-rest compression claim to live `savings_report` calls

The `Storage at rest (per observation)` reference row used to map to `['savings_report']`. Live `savings_report` output is structured JSON (~3.5k tokens per call) where the caveman compressor preserves technical tokens byte-for-byte, so the live comparison projected the row's 1k-token baseline against ~3.5k actual tokens and reported negative savings (e.g. `-155%`).

The row stays in the static reference — caveman compression really does shrink prose observations on disk — but it is now a structural claim about the storage layer rather than a per-call cost, so `mcp_operations` is empty. `savings_report` calls now show up under `unmatched_operations` instead of inflating the row.
8 changes: 6 additions & 2 deletions apps/mcp-server/test/task-threads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,9 @@ describe('task_claim_file — protected-branch guard', () => {
arguments: { task_id: thread.task_id, session_id: 'S1', file_path: '/repo/src/index.ts' },
});
expect(res.isError).toBe(true);
const body = JSON.parse((res.content as Array<{ type: string; text: string }>)[0]?.text ?? '{}');
const body = JSON.parse(
(res.content as Array<{ type: string; text: string }>)[0]?.text ?? '{}',
);
expect(body.code).toBe(TASK_THREAD_ERROR_CODES.PROTECTED_BRANCH_CLAIM_REJECTED);
// No claim row written.
expect(guardedStore.storage.getClaim(thread.task_id, '/repo/src/index.ts')).toBeFalsy();
Expand All @@ -1572,7 +1574,9 @@ describe('task_claim_file — protected-branch guard', () => {
arguments: { task_id: thread.task_id, session_id: 'S2', file_path: '/repo/src/index.ts' },
});
expect(res.isError).toBeFalsy();
const body = JSON.parse((res.content as Array<{ type: string; text: string }>)[0]?.text ?? '{}');
const body = JSON.parse(
(res.content as Array<{ type: string; text: string }>)[0]?.text ?? '{}',
);
expect(body.claim_status).toBe('claimed');
});
});
4 changes: 2 additions & 2 deletions packages/core/src/savings-reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ export const SAVINGS_REFERENCE_ROWS: ReadonlyArray<SavingsReferenceRow> = [
1,
1_000,
300,
'caveman compression preserves technical tokens byte-for-byte',
['savings_report'],
'caveman compression keeps prose observations small on disk; this is a structural claim about the storage layer, not the cost of any single MCP call, so no live operation is mapped (savings_report itself emits structured JSON that is mostly preserved-as-is technical tokens, which made it a misleading proxy)',
[],
),
row(
'Plan publication & goal anchoring',
Expand Down
35 changes: 34 additions & 1 deletion packages/core/test/savings-reference.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { describe, expect, it } from 'vitest';
import { savingsLiveComparison, savingsLiveComparisonCost } from '../src/savings-reference.js';
import {
SAVINGS_REFERENCE_ROWS,
savingsLiveComparison,
savingsLiveComparisonCost,
} from '../src/savings-reference.js';

describe('savings reference receipts', () => {
it('estimates USD saved from matched live mcp_metrics costs', () => {
Expand Down Expand Up @@ -49,4 +53,33 @@ describe('savings reference receipts', () => {
saved_cost_usd: 0.097,
});
});

it('does not attribute structured-output savings_report calls to the at-rest compression row', () => {
// Regression: the "Storage at rest (per observation)" row used to map to
// ['savings_report'], which produced negative live savings because
// savings_report emits ~3.5k tokens of structured JSON per call against a
// 1k baseline. The row stays in the static reference (compression is real
// for prose observations) but no live MCP operation should be mapped to
// it.
const storageAtRestRow = SAVINGS_REFERENCE_ROWS.find(
(r) => r.operation === 'Storage at rest (per observation)',
);
expect(storageAtRestRow).toBeDefined();
expect(storageAtRestRow?.mcp_operations).toEqual([]);

const comparison = savingsLiveComparison([
{
operation: 'savings_report',
calls: 2,
total_tokens: 5100,
last_ts: 1,
},
]);
expect(
comparison.rows.find((r) => r.operation === 'Storage at rest (per observation)'),
).toBeUndefined();
expect(
comparison.unmatched_operations.find((u) => u.operation === 'savings_report'),
).toMatchObject({ operation: 'savings_report', calls: 2, colony_tokens: 5100 });
});
});
Loading