Repository navigation
code.map invalidates cached maps when the indexed head advances - #1825
Conversation
The handler read the current commit after retrieving cached map text, so an index advance could attach a new commit to an older map. Cache the map text and commit together, key entries by commit, and retry when the index head changes during rendering. After three unstable attempts, return a retryable error without caching the result. Cover warm-cache advances, render-time changes, retry exhaustion and orientation reuse. The HTTP regression checks the map and commit after a completed index advance. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
The map helper returns text with its observed head. Preserve the token-budget assertions after merging the new tests from main. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
The orientation handler reads artifact.text. Keep the empty-search fallback test aligned with that helper contract. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
The focused map, orientation and transport checks passed. The tunable-constants gate fails on the new retry count.
Read the render bound from settings with a default of three and a minimum of one. Cover configured bounds, environment loading and invalid values, and regenerate the configuration contracts. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
zlareb1
left a comment
There was a problem hiding this comment.
The map and orientation paths read code_map_render_attempts from the settings catalog. The 97 focused map, orientation, transport and settings tests pass on the current merge tree.
|
The tunable-constants gate reports the same three search limits when run locally on this merge tree and on clean |
|
The dependency review job stops because GitHub returns a missing head snapshot warning. The same failure reproduces on clean main. I replayed the API responses with the workflow fix; it completes the vulnerability review after verifying the snapshot inputs are unchanged. |
Closes: #1823
Changelog category
Changelog entry
code.maprebuilds cached maps after the indexed head advances and returns the head stored with the map. Rendering retries when it detects a completed index advance.Why
The text cache keys only on org, namespace, module prefix and token budget. Reading
git_headafter retrieving that text pairs an older map with a newer head.Store the rendered text and observed head together, and include the head in the cache key. On a miss, compare the head before and after rendering; discard the result if they differ. When all configured attempts fail, return a retryable overload error without caching the result.
Head validation fixes the stale-cache failure without adding a storage generation or changing the indexing pipeline. Immutable generations would be needed for full snapshot consistency.
Scope and risk
Changes the map cache used by
code.mapand orientation-modecode.context_pack. Cache hits keep the head stored with their text even if the index advances just after lookup; the next request sees the new head.git_headis an indexing watermark. Progressive index writes, summaries and graph statistics can change before or independently of that watermark. This change does not make those reads an atomic snapshot or certify that all map content belongs to one Git commit.The cache keeps its 900-second TTL and 200-entry bound. Retaining entries for different heads can increase eviction churn. A miss adds a head validation query.
code_map_render_attemptsbounds rendering attempts, defaults to 3 and requires a value of at least 1. Larger values can increase latency during repeated index advances.Compatibility, rollout and rollback
commit_shacomes from the cached record.code.mapand orientation-modecode.context_packcan return the existing retryable HTTP 503 overload error when the head changes during every render attempt.LOOM_CODE_MAP_RENDER_ATTEMPTSorcode_map_render_attemptsin the configuration file to change the limit; restart the server to apply it.Tests
make format,make lint,make typecheck.tests/integration/test_code_map_cache.pypassed against a private migrated ClickHouse and source server before the settings follow-up. It was not rerun for this follow-up.The HTTP regression fails on the original implementation because the second response still contains the A summary while reporting head B. It passes with this fix and checks a repeated B request.
Unit regressions cover an empty initial head, warm-cache invalidation, an advance just after cache lookup, advances during rendering, retry exhaustion without caching, recovery and orientation-mode cache sharing. The settings follow-up covers limits of 1, 3 and 5 attempts, environment loading, the default and rejection of zero and negative values.
The token-budget test is adapted to the helper's record return type and head read; its tiny-budget and unlimited-budget assertions are preserved. The task-search fallback test also returns the map record from its stub, preserving its orientation and context assertions.
The remaining failure is
test_no_new_tunable_constant, which reportsPLACES_TOKEN_BUDGET,TOP_SOURCE_MAX_LINESand_QUERY_WORDS_MAXinserver/transport/code_lean.py. The same test fails on isolated upstream main ata5a018489with those three constants; this PR does not change that file._MAP_RENDER_ATTEMPTSis removed and no longer appears in the failure.The full unit suite and remaining integration checks are running in CI. Dependency review failed before completing its scan:
Invalid dependency snapshot warning header. A separate API request reports that no dependency snapshot exists for this head; its decoded warning is plain text, while the unchanged workflow expects JSON. This is not a completed vulnerability scan.AI assistance in the code
AI-generated: GPT wrote most of the diff. Agent checks include the caller paths, failure interleavings, local gates and a real HTTP regression. Maintainer review is pending.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist