fix(code-locator): #334 — validate_symbols returns indexed_at_sha for snapshot-drift detection#527
Conversation
… snapshot-drift detection `ValidateSymbolsTool` now reads `head_commit` + `repo_path` from the `index_meta` table at init (populated by `code_locator_runtime.record_index_state` after every rebuild) and exposes them as `indexed_at_sha` / `indexed_at_path` on every `ValidatedSymbol`. Caller-LLMs compare `indexed_at_sha` against `authoritative_sha` before bind to detect the snapshot drift that causes false-positive validate→reject sequences (field bug, Jacob 2026-05). Pure additive metadata — no behavior change to bind, no daemon-side change. Empty string when the index pre-dates ref tracking (legacy build or skipped `record_index_state`); caller treats that as "snapshot unknown." Skill `bicameral-bind` SKILL.md updated per the Tool Changes Require Skill Changes mandate — adds a "Snapshot drift (#334)" section and extends step 3 with the ref-comparison guidance. Three sociable tests (real SymbolDB, real `build_index`, real git subprocess) cover: full-build sha echoes git HEAD; missing-meta legacy path returns ""; init-time caching survives a post-init commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
e2e fail diagnosis: infra, not this PRDownloaded the failing run's transcripts ( The CLI is rejected at auth time before any prompt processing happens — that's why every flow reports Filed as #528 — this affects every PR touching the workflow's path filter (skills/bicameral-, handlers/, ledger/, server.py, contracts.py, pyproject.toml, tests/e2e/) and needs an org-level toggle or workflow-side API-key migration. This PR's actual test surfaceAll 10 non-e2e checks green:
Plus locally: 3 new sociable tests pass, 3 Phase 1 regression tests pass, ruff + format clean. Requesting merge despite the red e2e — the failure is upstream from any code in this PR. Happy to wait if a reviewer prefers to land #528's fix first. 🤖 Generated with Claude Code |
…auth_org_not_allowed 403) The `production` env's CLAUDE_CODE_OAUTH_TOKEN was tied to an org Claude Code subscription that has been disabled, surfacing as oauth_org_not_allowed 403 on every flow before turn 1 and red-gating every PR. Switch the assertions job to the `ci-test` env's ANTHROPIC_API_KEY — `claude -p` honours the key natively, the same env already powers test-mcp-regression.yml + preflight-eval.yml, and CI is now decoupled from subscription policy. The recording job already uses ANTHROPIC_API_KEY for interactive `claude`; this aligns the assertions job with that contract. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
ValidateSymbolsToolnow readshead_commit+repo_pathfrom theindex_metatable at init (populated bycode_locator_runtime.record_index_stateafter every rebuild) and exposes them asindexed_at_sha/indexed_at_pathon everyValidatedSymbol. Caller-LLMs compareindexed_at_shaagainstauthoritative_shabefore bind to detect the snapshot drift that causes false-positivevalidate→rejectsequences.Closes #334 (option C lite — additive metadata) as the immediate, reversible mitigation. Option A (snapshot-pinned validate or ref-in-bind-payload) and #332 (bind ignoring
link_commitHEAD advancement) remain as follow-ups that need Jin's RPC-contract input — see #334 design comment.Why this shape
validate_symbolsreads from the local SQLite symbol index.bindvalidates viagit show {authoritative_sha}:{file_path}+ tree-sitter. These are two data sources at two different refs. When the index is more recent thanauthoritative_sha(the field bug Jacob reported: feature-branch symbol satisfies validate with score 100, then bind hard-rejects), the documented preflight handshake misleads the caller.This PR doesn't fix the underlying disagreement — it makes it visible. Pure additive metadata, no behavior change to bind, no daemon-side change. If empty (
""), the index pre-dates ref tracking (legacy build or skippedrecord_index_state); caller-LLMs treat empty as "snapshot unknown" and apply caution per the updated skill.What changed
code_locator/models.pyValidatedSymbolgainsindexed_at_sha+indexed_at_path(both default"")code_locator/indexing/sqlite_store.pySymbolDB.read_index_meta(key)— handles missing-table case gracefullycode_locator/tools/validate_symbols.pyskills/bicameral-bind/SKILL.mdtests/test_validate_symbols_indexed_at_sha.pybuild_index, real git subprocess)Test plan
pytest tests/test_validate_symbols_indexed_at_sha.py -v— 3 passedrecord_index_statecycle →indexed_at_shaechoes git HEAD""without raisingpytest tests/test_phase1_code_locator.py -v— no regression (3 passed, 1 skipped as before)""ruff check+ruff formatcleanOut of scope (deliberate)
bindis daemon-side as of 2c-7a,validate_symbolsstays MCP-side). Needs Jin's contract decision before implementation.link_commitHEAD advancement) — same root cause, separate scope. Can land as a follow-up.Audit trail
CLAUDE.md→ Tool Changes Require Skill Changes (Mandatory)CLAUDE.md→ Sociable Testing for UX Paths (Mandatory for Handlers + Ledger)🤖 Generated with Claude Code