Repository navigation
Conversation
…aximal stable prefix The find stage fans out one call per taxonomy dimension (8 lenses per diff batch). The taxonomy value sat mid-block-order, so any prompt-cache breakpoint before it could only share the ~2,100-token instructions+skill block across the batch. Diff, summaries, policy, and every instruction are byte-identical across lenses; only the taxonomy value differs. Move the taxonomy value to the END of the block order. A breakpoint before it now shares the maximum prefix (~3,266 tokens for a typical find call) across the batch's 8 lenses - find input saving rises from ~48% to ~62% - but only IF a breakpoint mechanism exists and the relay honors prompt caching, which it does not today. This is forward-structure: it changes what is cacheable, not what is cached. All prompt content is byte-identical, only the order of one block changed. The schema-repair nonce keeps its anti-replay property: it is appended AFTER the base prompt, outside the cacheable prefix, so two identical consecutive failures still cannot replay a cached answer. The reorder does not move it. Verified: 228 tests, 220 pass, 7 skip (baseline 227 + the new prefix-stability guard; the single fail under full-suite concurrency is the known diff-input FIFO flake, 8/0 in isolation). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: w13-cache-followthrough
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📝 WalkthroughWalkthrough本次变更调整 ChangesFind 提示词稳定性
Estimated code review effort: 1(简单)| ~5 分钟 Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/find-prefix-stability.test.mjs`:
- Around line 26-36: Update the prompt loop in the find-prefix stability test to
retain each prompt’s expected taxonomy dimension and assert that the final block
contains that dimension’s serialized id, not just the “Assigned taxonomy
dimension:” label. Preserve the existing final-block and ordering assertions for
every prompt.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a6b05fc5-3f9d-41f3-913c-0b765dc16f57
📒 Files selected for processing (2)
src/claude-runner.mjstest/find-prefix-stability.test.mjs
| for (const prompt of prompts) { | ||
| const blocks = prompt.split('\n\n'); | ||
| const lastBlock = blocks[blocks.length - 1]; | ||
| assert.ok( | ||
| lastBlock.startsWith('Assigned taxonomy dimension:'), | ||
| 'the taxonomy value must be the final block of the find prompt so the diff/summaries/policy stay in the stable prefix', | ||
| ); | ||
| assert.ok( | ||
| prompt.indexOf('Immutable pull-request diff batch:') < prompt.indexOf('Assigned taxonomy dimension:'), | ||
| 'the diff must precede the taxonomy value so the diff is inside the cross-lens stable prefix', | ||
| ); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
验证最终 block 中的 taxonomy id。
当前断言只检查最后一个 block 以 Assigned taxonomy dimension: 开头。如果实现保留标签但丢失或错误序列化 security/correctness,测试仍会通过。请保留每个 prompt 对应的 dimension,并断言最终 block 包含该 dimension 的 id。
建议补丁
- const prompts = ['security', 'correctness'].map((dimension) =>
- stagePrompt({ ...shared, taxonomy: { id: dimension } }, context),
- );
+ const prompts = ['security', 'correctness'].map((dimension) => ({
+ dimension,
+ prompt: stagePrompt({ ...shared, taxonomy: { id: dimension } }, context),
+ }));
- for (const prompt of prompts) {
+ for (const { dimension, prompt } of prompts) {
const blocks = prompt.split('\n\n');
const lastBlock = blocks[blocks.length - 1];
assert.ok(
lastBlock.startsWith('Assigned taxonomy dimension:'),
'the taxonomy value must be the final block of the find prompt so the diff/summaries/policy stay in the stable prefix',
);
+ assert.ok(
+ lastBlock.includes(dimension),
+ 'the final block must contain the assigned taxonomy id',
+ );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/find-prefix-stability.test.mjs` around lines 26 - 36, Update the prompt
loop in the find-prefix stability test to retain each prompt’s expected taxonomy
dimension and assert that the final block contains that dimension’s serialized
id, not just the “Assigned taxonomy dimension:” label. Preserve the existing
final-block and ordering assertions for every prompt.
Summary
Engine half of the CACHE-ENGINE-SIDE ownership verdict. AxonHub is the larger and gating half (its probe sent an explicit
cache_controlbreakpoint on 3,326 tokens, well over the 1,024 minimum, and gotcache_creation=0— the gateway creates no entries even when asked); the engine half done here is the concrete "variable sitting in the cacheable prefix" fix, as forward-structure readiness.Assigned taxonomy dimension:value from block 10/12 to the last block. Diff, summaries, policy, and every instruction are byte-identical across a batch's 8 lenses; only the taxonomy value differs. With the variable value last, a breakpoint placed before it can share the maximum prefix across lenses instead of only the ~2,100-token instructions+skill block.schemaFeedbackPromptthat asserted the upstream prefix cache "still covers" the expensive part — the relay currently creates no prompt-cache entries even when explicitly asked, so the append-only shape is forward-structure, not a live guarantee.test/find-prefix-stability.test.mjslocks the order: taxonomy value must be the final block, diff must precede it, and everything before the taxonomy value must be byte-identical across lenses.Quantified conditional saving
--clearenv+ strict ALLOWED_ENV, no request body) and the relay does not create cache entries. This PR only changes what would be cacheable, never what is cached.No stale-context risk
Nothing is cached by this change. When/if caching exists, a hit on the stable prefix requires a byte-identical prefix — same review, same diff/summaries/policy — which is exactly what the other lenses of the same batch send. A different PR's diff is a different prefix → cache miss. Stale reuse is structurally impossible.
Nonce anti-replay preserved
schemaFeedbackPromptappendsRepair attempt nonce: <uuid>after the base prompt, outside the cacheable prefix, so two identical consecutive failures still cannot replay a cached identical answer. The reorder does not move it; the property is unchanged.Test plan
node --test test/: 228 tests / 220 pass / 7 skip (baseline 227 + new guard; the single fail is the known diff-input FIFO ETIMEDOUT flake, 8/0 in isolation).🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Claude-Session: w13-cache-followthrough
Summary by CodeRabbit
改进
测试