Files
aiturk-hermes-ide/apps/desktop/assets/codex-bridge/test_summary_coverage.py
T
yilsem 1f13b86e5f
Server CI and Windows package / verify (push) Successful in 3m45s
Server CI and Windows package / windows-package (push) Successful in 9m49s
fix(context): preserve summary details and unify IDE release branches
Use the complete target budget, reject omitted concrete references, rebuild deficient checkpoints, and run both branches through Linux CI with an exact-branch parity gate. IDE beta.45, bridge24.
2026-10-20 21:02:45 +03:00

65 lines
3.4 KiB
Python

import copy
import tempfile
import unittest
import compression_settings as cs
import gecis_context as gc
class SummaryCoverage(unittest.TestCase):
def test_long_noise_is_not_misclassified_as_one_giant_identifier(self):
gc.require_summary_coverage('A' * 60000 + 'KARAR-4827' + 'B' * 60000,
'KARAR-4827: original decision preserved.')
def test_partial_decision_ledger_is_rejected_and_full_ledger_is_accepted(self):
records = [f'DEC-{i:04d}: src/feature_{i:04d}/config.json limit_{i:04d}={30000+i} TEST-QA-{i:04d} NO-DELETE-{i:04d}'
for i in range(200)]
source = [{'role': 'user', 'content': '\n'.join(records)}]
with self.assertRaises(gc.TransferError):
gc.require_summary_coverage(source, '\n'.join(records[:95]))
gc.require_summary_coverage(source, '\n'.join(records))
def test_assignment_values_stay_associated_with_their_keys(self):
source = [{'content': 'limit_a=123 limit_b=456 src/a.py DEC-1'}]
self.assertGreater(gc.summary_missing(source, 'limit_a=456 limit_b=123 src/a.py DEC-1'), 0)
gc.require_summary_coverage(source, 'DEC-1: `src/a.py`; limit_a: 123; limit_b: 456')
def test_secret_named_assignments_are_not_required_in_a_summary(self):
gc.require_summary_coverage([{'content': 'api_key=123456 password=7890 otp=1234'}], 'Secrets omitted.')
def test_target_budget_is_not_multiplied_by_compression_level_again(self):
settings = dict(cs.DEFAULTS, keepTurns=1, triggerPercent=60, targetPercent=25, level='fazla')
req = {'input': [{'role': 'user', 'content': 'DEC-1 ' + 'x' * 60000},
{'role': 'user', 'content': 'Keep this recent turn.'}]}
observed = []
def summarize(source, budget):
observed.append(budget)
return 'DEC-1: All accepted decisions, paths, settings and outstanding work are retained. ' * 2
prepared = gc.Preparer().prepare(req, 32768, summarize, settings=settings, automatic=True)
protected, _, recent = gc.split_history(req['input'], 1)
available = gc.input_budget(req, 32768, settings, True) - gc.tokens(dict(req, input=protected + recent)) - 256
self.assertEqual(observed, [available])
self.assertLessEqual(gc.tokens(prepared), 32768 * .25)
def test_incomplete_old_checkpoint_is_rebuilt_without_overwriting_source(self):
settings = dict(cs.DEFAULTS, keepTurns=1)
req = {'input': [{'role': 'user', 'content': 'DEC-1 src/a.py limit_a=123 ' + 'x' * 60000},
{'role': 'user', 'content': 'Latest'}]}
original = copy.deepcopy(req)
with tempfile.TemporaryDirectory() as home:
store = cs.Checkpoints(home)
old = gc.split_history(req['input'], 1)[1]
store.save('scope', old, settings, 'Incomplete old summary without the required details. ' * 3)
calls = []
def summarize(source, budget):
calls.append(1)
return 'DEC-1 src/a.py limit_a=123. Accepted decision and all relevant constraints retained. ' * 2
result = gc.Preparer().prepare(req, 32768, summarize, 'scope', settings=settings, checkpoints=store)
self.assertEqual(calls, [1])
self.assertEqual(req, original)
gc.require_summary_coverage(old, gc.encoded(result))
if __name__ == '__main__':
unittest.main()