perf(codex_runner): compile session-id regex once at module load #10
Reference in New Issue
Block a user
Delete Branch "fix/compile-session-regex-once"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
_extract_session_idcompiled there.compilepattern on every codex turn. For a busy daemon this is unnecessary CPU overhead.Fix
Move the compiled pattern to module level (
_SESSION_ID_RE) so it is built once at import time.Checklist
e917f05a88tofa25d003c6Five-axis review for PR #10.
Correctness: APPROVED. _extract_session_id still uses the same case-insensitive UUID-matching pattern and returns the same capture group, but the compiled regex is now reused from module scope instead of rebuilt on every call.
Robustness: behavior for missing stderr matches remains unchanged. Import-time compilation is deterministic and will fail early if the pattern is ever invalid.
Security: no new inputs, auth paths, subprocess invocation changes, or secret handling. The regex continues to parse stderr text only.
Performance: positive change. Reusing _SESSION_ID_RE removes repeated regex compilation from each codex turn.
Readability: the module-level constant has a clear name and the extractor is shorter while preserving the original comments and intent.
CI/status checked on
fa25d00: statuses are accessible and both Python 3.11 and 3.12 test jobs are green.Peer 2nd-review per CTO carve-out. 5-axis lens clean; deferring to Code Reviewer (2) review_id=5598. BP unblock for merge.