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
4 changes: 2 additions & 2 deletions codexSessionAudit/codex_session_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ def audit_source(path: Path, label: str, result: AuditResult) -> SourceStats:
with handle:
for line in handle:
stats.records += 1
if '"response_item"' not in line and '"session_meta"' not in line:
continue
try:
record = json.loads(line)
except json.JSONDecodeError:
Expand All @@ -227,6 +225,8 @@ def audit_source(path: Path, label: str, result: AuditResult) -> SourceStats:
if not isinstance(record, dict):
stats.malformed_records += 1
continue
if record.get("type") not in {"response_item", "session_meta"}:
continue
update_timestamp(result, record.get("timestamp"))
payload = record.get("payload")
if not isinstance(payload, dict):
Expand Down
11 changes: 11 additions & 0 deletions codexSessionAudit/tests/test_codex_session_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,14 @@ def test_invalid_timestamp_does_not_leak_into_report(tmp_path: Path) -> None:
assert result["summary"]["first_timestamp"] == "2026-10-31T00:00:00Z"
assert result["summary"]["last_timestamp"] == "2026-10-31T00:00:00Z"
assert "sensitive-invalid-timestamp" not in json.dumps(result)


def test_all_jsonl_records_are_validated_before_type_filter(tmp_path: Path) -> None:
session = tmp_path / "sessions" / "one.jsonl"
session.parent.mkdir(parents=True)
other = {"type": "event_msg", "payload": {"type": "message", "role": "user", "text": "response_item"}}
session.write_text("{broken json\n" + json.dumps(other) + "\n", encoding="utf-8")
result = audit_module.audit([tmp_path]).to_dict()
assert result["summary"]["records"] == 2
assert result["summary"]["malformed_records"] == 1
assert result["summary"]["user_messages"] == 0
Loading