Skip to content

loom code describe-reset returns fake-provider chunk descriptions to structural context - #2373

Open
chenxiaokeng666-prog wants to merge 9 commits into
ClickHouse:mainfrom
chenxiaokeng666-prog:fix/describe-reset-1557
Open

chenxiaokeng666-prog wants to merge 9 commits into
ClickHouse:mainfrom
chenxiaokeng666-prog:fix/describe-reset-1557

Conversation

@chenxiaokeng666-prog

@chenxiaokeng666-prog chenxiaokeng666-prog commented Dec 6, 2026 •

Copy link
Copy Markdown

Closes: #1557
Related: #1679

Changelog category (leave one):

  • New Feature

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):

loom code describe-reset returns chunks whose description came from the fake LLM provider to structural context and re-embeds them; dry run by default, --apply resets.

Why

With llm.provider set to fake, ingest stored the fake client's echo text as chunk descriptions with context_source='llm', and there was no in-place way to clear them: a re-index keeps described rows unchanged, and the only route was removing the repository and re-adding it. The reset command gives operators the in-place recovery the issue asks for, following the maintainer's decision on #1557.

Scope and risk

Touches the new describe-reset CLI command, its parser, the with_description blank-line fix, unit tests, CLI snapshots, the CLI reference and one operations-table row. Deliberately left alone: part 1 of #1557 (the ingest skip and the loom code describe refusal, PR #1679), the provider-change case, and any code.index_status field. No wire op is added or changed; this is a CLI command only. The reset is scoped to the served embedding model's label, so rows under other labels keep their fake descriptions. Serial per-row embed and insert, mirroring _describe; on a namespace with tens of thousands of fake rows this runs one embed call per row. context_text.py is a chunk-stage extractor module, so this fix moves the chunk stamp: the worker re-heals the chunk stage in every indexed repository. The heal is cheap by design — content-addressed rows are kept, never re-embedded.

Compatibility, rollout and rollback

  • Wire: none — no op or field added, changed or removed; no changed default.
  • Operator steps: run loom code describe-reset --org <org> --namespace <ns> to preview the count and a sample, then add --apply to reset. A later loom code describe on a real provider picks the reset rows up again.
  • Rollback: reverting leaves reset rows in structural context with their fresh vectors; re-running loom code describe on a real provider restores descriptions. No migration, no generated-file residue beyond the snapshots in this PR.

Tests

  • pytest tests/unit/test_cli_apply_default.py tests/unit/test_context_text_with_description.py tests/unit/test_cli_surface_snapshot.py tests/unit/test_docs_reference.py tests/unit/test_public_copy.py tests/unit/test_doc_links.py — 343 passed.
  • pytest tests/unit/test_cli_apply_default.py tests/unit/test_context_text_with_description.py — 20 passed, including the 3 new tests.
  • Negative control: with the three source files reverted, exactly the 3 new tests fail (2 describe-reset, 1 empty-description); fix restored, all green.
  • ruff check and ruff format --check on all changed Python files — pass. mypy on the 3 changed source files — no issues. scripts/codegen/docs_reference.py --check — pass.
  • pytest tests/unit/test_code_extractor_stamp.py — 21 passed, 1 failed: test_only_the_stage_grammars_are_stamped fails because the tree-sitter packages are not installed in the local venv (grammar_versions() returns empty); pre-existing environmental failure, unrelated to this change.
  • Behaviour against a live ClickHouse stack was not verified — unit tests only, using the repo's test doubles.

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

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Note

Medium Risk
--apply mutates live code-index embeddings in ClickHouse for matched chunks; scope is limited to fake-prefix LLM descriptions and one embedding model label, but a mistaken run still rewrites search vectors until reversed via describe or re-index.

Overview
Adds loom code describe-reset so operators can undo chunk descriptions written by the fake LLM provider during dev indexing. The command finds live code_chunks rows where context_source is llm and context_description starts with [fake-synthesis:, scoped to the served embedding model; by default it dry-runs with counts and samples, and with --apply it strips the description, sets context_source to structural, rebuilds context_text, re-embeds, and supersedes the rows (then triggers the usual post-bulk compact). A later loom code describe on a real provider can describe those chunks again.

with_description now drops the description line when the description is empty/whitespace instead of leaving a blank line—needed for clean structural context on reset.

Docs and CLI reference tables document the command; unit tests cover dry-run vs apply gating and selective reset behavior.

Reviewed by Cursor Bugbot for commit 1c98550. Bugbot is set up for automated code reviews on this repo. Configure here.

…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
…o structural context

Signed-off-by: krison <chenxiaokeng666@gmail.com>
@vercel

vercel Bot commented Dec 6, 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 Dec 6, 2026 8:59am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 8:59am UTC

Request Review

@cla-assistant

cla-assistant Bot commented Dec 6, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@zlareb1 zlareb1 self-assigned this Dec 6, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reset can overwrite a newer chunk tombstone. The inline finding gives the write sequence to cover in a regression test.

else build_context_text(path=path, scope=scope, content=str(r.get("content") or ""))
)
vec = await embedder.embed(ctx)
row = CodeRepo.moved_of(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — describe-reset --apply can make a removed chunk searchable again. If ingestion tombstones a chunk after the reset reads it and while the embedding call is in flight, moved_of gives the saved live row a version newer than the tombstone. FINAL then returns the reset row with tombstoned_at = NULL. Coordinate the reset write with ingestion so it cannot publish a stale row. Add a regression test that tombstones the selected chunk during embedding and verifies it stays absent.

This branch has not been deployed

No deployments
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.

Ingest stores the fake LLM's echo as chunk descriptions when llm.provider is fake, and no op clears them

2 participants