Skip to content

perf(codex): close 84%→95%+ compliance gap (nl|sed, git -C, rg -n) + proxy bypass nudge + discover --codex meter #53

Closed

Description

@thehoff

Measurement-first context

Post-v0.1.8 measurement (2026-05-18 ~19:00 local) on
~/Library/Application Support/rtk/history.db and
~/.claude/plugins/data/codex-openai-codex/state/*/jobs/*.log:

Metric Baseline (pre-v0.1.8) Now Δ
Global savings (24h) 24.8% 70.6% +45.8pp
Codex compliance 80.0% 84.3% +4.3pp

84.3% compliance = 503 wrapped / 597 total commands across 21 recent codex review job logs. 94 raw commands cluster into 3 patterns that AGENTS.md doesn't currently cover.

The 3 gap patterns

  1. nl -ba <path> | sed -n 'A,Bp' — ~35 calls. Codex's "read with line numbers + range" pattern. Composed pipe defeats the contextcrawler prefix rule because codex treats the whole pipe as one shell composition.
  2. git -C <project-dir> ... — ~25 calls. Codex uses -C for cross-directory git ops; treats it as "different" from plain git.
  3. rg -n ... — ~11 calls. Short form not represented in current RIGHT examples.

Scope (single PR, four commits)

1. contextcrawler discover --codex

Add codex log scanner that mirrors the existing Claude discover output: total commands, wrapped %, raw % bucketed by pattern. Reads ~/.claude/plugins/data/codex-openai-codex/state/*/jobs/*.log. Ships the measurement alongside the fix per the project's metrics-before-claims rule.

2. AGENTS.md WRONG/RIGHT additions

Strengthen hooks/codex/rtk-awareness.md with explicit pairs:

  • nl -ba and nl -ba file | sed -n → contextcrawler read -n <path> (or contextcrawler proxy nl -ba ... | contextcrawler proxy sed ... if range matters)
  • git -C <path> <subcmd> → contextcrawler git -C <path> <subcmd>
  • rg -n pattern → contextcrawler rg -n pattern (explicit short-form example)

3. Proxy bypass nudge

When contextcrawler proxy <wrapped-tool> is invoked (sed/nl/grep/awk/rg/find/cat/head/tail/ls/wc — i.e. tools we have a wrapper for), emit a one-line stderr note pointing at the wrapped equivalent. Don't auto-rewrite — measure adoption first, then upgrade to auto-rewrite in a follow-up if the nudge isn't enough.

Background: proxy is now the #1 token leak — 307K input @ 0% savings on 394 calls/24h. The biggest source is codex using proxy sed/proxy nl for the read-with-line-numbers pattern.

4. Pinning regression test

codex_template_contains_gap_patterns — fails if any of the three gap patterns (nl -ba, git -C, rg -n) disappears from the template.

Success criteria (measure before close)

  • cargo test green
  • After PR merges + deploy + 24h of codex use: re-measure compliance via contextcrawler discover --codex and confirm ≥95% (target +10.7pp from current 84.3%)
  • After 24h: re-measure proxy row in dashboard and confirm the absolute token leak shrinks (success even if % stays 0% — the volume is what matters)

Deferred (not in this PR)

  • contextcrawler read --range A,B[;C,D] to fully replace nl|sed composed pipes (codex composes multi-range selectors — non-trivial)
  • Auto-rewrite (vs. nudge-only) for proxy-wraps-wrapped-tool — unlock once nudge adoption is measured

Trace

Activity

  1. added
    enhancement
    on May 18, 2026
  2. added a commit that references this issue on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions