Skip to content

fix(logs): exclude same-thread events after scan completion - #607

Open
Drewwb wants to merge 1 commit into
openai:mainfrom
Drewwb:fix/scan-logs-completion-boundary
Open

fix(logs): exclude same-thread events after scan completion#607
Drewwb wants to merge 1 commit into
openai:mainfrom
Drewwb:fix/scan-logs-completion-boundary

Conversation

@Drewwb

@Drewwb Drewwb commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

readScanLogs() uses a saved scan's completedAt timestamp to reject independent worker sessions that start after the scan, but it does not apply that same completion boundary to events inside sessions that were already selected. A post-scan prompt runs on the same Codex thread after complete-scan, so its later events can appear in codex-security scans logs as if they belonged to the completed security scan.

Changes

  • In src/scan-logs.ts, parse the saved scan's completedAt once, then skip any event whose own timestamp parses to a time strictly after that boundary before it is appended. Events without a parseable timestamp (such as session_meta) and every event at or before completedAt are preserved, and a null/undefined/unparseable completedAt disables the filter, so running-scan and legacy behavior is unchanged.
  • Add a regression test in tests-ts/scan-logs.test.ts that puts a during-scan event (12:01) and a same-thread post-completion event (12:03) in the scan's own session with a completedAt of 12:02, and asserts the 12:01 event is kept while the 12:03 event is dropped.

Testing

  • bun test tests-ts/scan-logs.test.ts — 8 pass, 0 fail
  • pnpm run types — clean
  • npx prettier --check src/scan-logs.ts tests-ts/scan-logs.test.ts — clean

Risk and rollout

Low risk. The change only narrows saved-log projection to a scan's recorded lifetime; it never adds events, and events without a timestamp or at/before completedAt are untouched. No public CLI surface, schema, or default changes.

Public disclosure review

  • No customer, partner, prospect, or user identities, data, or identifying details are included.
  • No credentials, personal data, private source, scan findings, or nonpublic links or tickets are included.
  • I reviewed the branch name, title, description, commits, changes, comments, logs, screenshots, attachments, and links for public disclosure.

Fixes #555

readScanLogs() uses a saved scan's completedAt to reject independent
sessions that start after the scan, but once a session was selected it
appended every event without applying the same boundary. A post-scan
prompt runs on the same Codex thread after complete-scan, so its later
events surfaced in `codex-security scans logs` as if they belonged to
the completed scan.

Apply the completion boundary to individual events too: skip any event
whose timestamp parses to a time after completedAt. Events without a
parseable timestamp (such as session_meta) and every event at or before
completedAt are preserved, so ordinary scan activity is unaffected.

Add a regression test covering a same-thread event emitted after the
saved completion time.
@github-actions github-actions Bot added the bug Something isn't working label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saved scan logs include same-thread events emitted after scan completion

1 participant