Aller au contenu
login
arrow_backRetour aux issues
Tracer-Cloud/opensre #5496

One shared JSONL integrity assertion

ecoDébutant good first issue tests

descriptionDescription

## Problem Several concurrency tests check session-file integrity, and each reimplements a weaker version of the same check — usually "the file is non-empty" or "the last line parses". ## Why it matters Every concurrency test in this area needs the same assertion, and the weak versions pass on a file that has lost turns or gained a second header. One shared helper makes the bar the same everywhere and makes it easy to raise. ## Steps 1. Find the existing ad-hoc integrity checks — start with `tests/core/agent_harness/session/test_jsonl_store_lock.py` and `gateway/tests/test_multi_actor_concurrency.py`. 2. Write one helper that asserts, on a session file: - every non-empty line parses as JSON - exactly one record of `type == "session"`, and it is the first line - optionally, that a given set of expected turn markers is present 3. Give it a failure message that shows the offending line number and the first 50 characters of that line. A bare `JSONDecodeError` from inside a helper is worse than the inline check it replaced. 4. Decide deliberately how a **truncated final line** is treated — after a crash mid-write it is expected, elsewhere it is a bug. Make it a parameter with an explicit default, not an accident. 5. Repoint the existing ad-hoc checks at the helper. ## Suggested placement A shared test helper, not a fixture — it takes a path and asserts. Check `tests/core/agent_harness/session/` for an existing helpers module before adding a file. ## Expected result One assertion every concurrency test can call, strong enough to catch a lost turn or a duplicate header. ## Verification ```bash uv run python -m pytest tests/core/agent_harness/session/ \ gateway/tests/test_multi_actor_concurrency.py -q ``` Prove the helper catches each failure it claims to. Build three fixture files by hand — one with a torn line, one with two session headers, one missing a turn — and confirm the helper fails on each with a message naming the problem. Keep those as tests of the helper itself. ## Checklist - [ ] One helper, used by every existing integrity check in this area - [ ] All three failure modes asserted, each with a readable message - [ ] Truncated-final-line handling is an explicit parameter - [ ] The helper has its own tests built from hand-made bad files - [ ] `make lint format typecheck test` ## Out of scope Changing any production writer. ## Claiming this issue Ask in [OpenSRE Discord](https://discord.com/invite/opensre) before you start so a maintainer can assign it. Ask OpenSRE maintainers and write a commit under this issue.
codeOuvre sur GitHub