Repository navigation
perf: materialize only the requested recent plugin audit lines - #19498
Conversation
|
Warning Review limit reachedNext included review available in 26 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
recentAuditLinesbackward scan — replaces the fullsplit('\n').filter().slice(-limit)with a reverse walk overlastIndexOf('\n')that stops oncelimitnon-empty lines are collected, falling back verbatim to the old path for non-finite or< 1limits.- Parity regression coverage — a differential oracle plus a 1500-seed randomized corpus (blank, whitespace, CRLF, torn-final-append, non-JSON, multi-byte, escaped-newline shapes) and a split-boundary test pin the new selection to exactly the old one.
I traced the algorithm against the old split/filter/slice behavior and confirmed exact equivalence: the reverse walk emits the same non-empty segments in the same order, the start < end guard correctly skips empty/trailing-newline segments, Math.trunc(limit) matches slice(-limit)'s truncation for fractional limits, and the < 1 / non-finite fallback is the old code verbatim. toReversed() is safe here — the module runs in the Electron main process (Node 20+) and is only type-imported from the Node-18 relay bundle path (plugin-host-methods.ts:6), so the relay toReversed ratchet is unaffected. Tests and oxlint both pass locally.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

ELI5
Orca keeps an audit log of everything a plugin does through the gated host API — one record per line, in a file that can grow to 10 MB before it rotates.
When something asks for "the last 200 entries", the old code chopped the whole file into every single line it contained — potentially tens of thousands of strings — and then threw away all but the last 200.
Now it walks backwards from the end of the file, stopping as soon as it has the 200 lines it was asked for. Nothing else is ever built.
It reads back from real line breaks, so a record can never come back cut in half, and the entries you get are exactly the entries the old code returned — checked against the old code over 7,500 randomly generated log files containing blank lines, half-written final lines, Windows line endings, non-JSON junk and accented text.
What Changed / Why
This PR contains only this focused change and its regression coverage. It targets
mainindependently of the other desktop audit PRs. Measurements describe operation/allocation reductions, not end-to-end latency gains.Linked Issue
User-requested desktop performance audit; no issue supplied.
Visual Proof
N/A — no visual design change. Behavior and performance invariants are checked by automated regression tests.
Testing
pnpm tcpassed on this branch.git diff --cached --checkpassed.ORCA_BACKGROUND_LAUNCH=1. No visible test window was launched.Test files:
src/main/plugins/plugin-audit-log-scaling.test.tsAgent skill upstream boundary
Checklist