Skip to content

Recover retained source for exact grep results - #1210

Merged
zlareb1 merged 1 commit into
mainfrom
fix/grep-source-line-coverage
Nov 23, 2026
Merged

zlareb1 merged 1 commit into
mainfrom
fix/grep-source-line-coverage

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 23, 2026

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

Exact grep and symbol mentions recover retained source behind class summaries before reporting missing source-line coverage.

Why

A class summary elides method bodies, so it cannot establish physical line numbers. The same index can hold complete raw chunks for that class. Grep discarded the summary and reported incomplete coverage without reading those chunks, prompting clients to retrieve source they already had or could read through Loom.

Recover source under the same tenant, namespace, embedding label and path. Replace a summary only when raw chunks cover its span without gaps or disagreements, including disagreement with source read earlier in the request.

Scope and risk

The shared recovery path serves literal and regex grep, rendered-message scans and symbol mentions. It groups summary fragments by class and uses bounded point reads. Source validation runs off the event loop. Recovery shares the existing scan character bound and any caller-supplied deadline. Missing, conflicting, failed or capped recovery preserves the existing coverage warning.

The risk is incorrect coordinates or extra read work during recovery. Recorded public-source replay against an isolated, migrated datastore retains previous hits and checks every returned line against the source revision. No extractor or stored source is changed.

Compatibility, rollout and rollback

  • Wire: no operations, fields, defaults or signed cursor formats change.
  • Grep pool mapping metadata advances so older cached pages trigger the existing disclosed rerun. Rolling builds can read the pool format and rerun when the mapping differs.
  • Operator steps: none; no migration or re-index.
  • Rollback: revert the read path. Stored source is unchanged and cached pools expire normally.

Tests

  • make format lint typecheck: pass.
  • python -m tests.analyzer.corpus --write: regenerated the SQL shape manifest, including the source-recovery read.
  • Recorded public-source extraction and real datastore qualification verify source coordinates, retained hits and removal of recoverable coverage warnings. No model calls or fabricated vector results are used.
  • Regression cases cover complete, missing, conflicting, changed, failed and capped source reads. Unit regressions are authored; unit and integration suites are not run locally at the requester's direction. CI can run .venv/bin/python -m pytest tests/unit/test_code_grep_container_source.py tests/unit/test_code_grep.py tests/unit/test_code_symbol_uses.py tests/unit/test_code_search_cursor.py and the SQL analyzer checks.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated: Codex wrote the change and checked source recovery, typed SQL, exact source coordinates and static checks.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. Static checks pass; focused tests remain for CI at the requester's direction.
  • Generated SQL shape manifest is regenerated; SDK, configuration and plugin generators report current output.
  • No migrations or plugin changes.
  • No frontend changes.
  • Architecture documentation describes source recovery and its failure behavior.
  • Repository text contains no deployment details.
  • Commits are signed off.

Class summaries omit physical line mappings even when complete raw chunks are retained. Verify those chunks under the same scope before lowering grep coverage, and share the recovery with rendered-message scans and symbol mentions.

Signed-off-by: Lareb Zafar <[email protected]>
@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 23, 2026 1:36am UTC

Request Review

@zlareb1
zlareb1 merged commit 950697d into main Nov 23, 2026
56 of 58 checks passed
@zlareb1
zlareb1 deleted the fix/grep-source-line-coverage branch November 23, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant