From 41232d859a8926143df4bf19b9cfb73e63cf9af0 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:56:51 +0800 Subject: [PATCH 1/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- server/cli/code_maintenance.py | 69 ++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/server/cli/code_maintenance.py b/server/cli/code_maintenance.py index 91d9b7a460d..32fb07057a7 100644 --- a/server/cli/code_maintenance.py +++ b/server/cli/code_maintenance.py @@ -489,6 +489,75 @@ async def _answers_purge(args: argparse.Namespace) -> int: return 0 +_FAKE_DESCRIPTION_PREFIX = "[fake-synthesis:" +_DESCRIBE_RESET_PREVIEW = 10 # matched chunks a dry run prints + + +async def _describe_reset(args: argparse.Namespace) -> int: + """Return live chunks whose description the fake LLM provider wrote to + structural context: the description line leaves `context_text`, the row is + re-embedded, and a later `describe` on a real provider picks it up again. + The description prefix is the only marker: `code_chunks` records no model. + Only the served embedding model's label is reset, so the fresh vector is + that model's; other labels keep their rows.""" + from server.code.domain.extract.context_text import build_context_text, with_description + from server.code.store.index import CodeRepo + from server.core.ch import get_client + from server.embedding.embedder import get_embedder + + await connect_code_plane(get_client(), args) + org, ns = _identity(args) + repo = CodeRepo() + embedder = get_embedder() + rows = await repo._ch.query_all( + """ + SELECT * EXCEPT (embedding) FROM loom.code_chunks FINAL + WHERE org = {org:String} AND namespace = {ns:String} + AND embedding_model = {model:String} + AND context_source = 'llm' + AND startsWith(context_description, {prefix:String}) + AND tombstoned_at IS NULL + """, + {"org": org, "ns": ns, "model": embedder.model_name, "prefix": _FAKE_DESCRIPTION_PREFIX}, + ) + if not rows: + print("no live chunks with a fake description matched") + return 0 + if args.dry_run: + print(f"would reset {len(rows)} chunks to structural context") + for r in rows[:_DESCRIBE_RESET_PREVIEW]: + desc = " ".join(str(r.get("context_description") or "").split())[:100] + print(f" {r.get('path')}#{r.get('scope') or '-'}: {desc}") + if len(rows) > _DESCRIBE_RESET_PREVIEW: + print(f" … and {len(rows) - _DESCRIBE_RESET_PREVIEW} more") + return 0 + reset = 0 + for r in rows: + path = str(r.get("path") or "") + scope = str(r.get("scope") or "") + old_ctx = str(r.get("context_text") or "") + ctx = ( + with_description(old_ctx, scope=scope, description="") + if old_ctx + else build_context_text(path=path, scope=scope, content=str(r.get("content") or "")) + ) + vec = await embedder.embed(ctx) + row = CodeRepo.moved_of( + "code_chunks", + r, + context_description="", + context_source="structural", + context_text=ctx, + embedding=vec, + embedding_dim=len(vec), + ) + await repo.insert_rows("code_chunks", [row]) + reset += 1 + print(f"reset {reset} chunks to structural context") + await _compact_after_bulk(reset, embedder.model_name) + return 0 + + @dataclass class _DescribeRun: """One `loom code describe` run: its bounds, what it did and what it spent.""" From 7a44e828406edb744cc1895910c351237056b870 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:56:53 +0800 Subject: [PATCH 2/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- server/cli/code.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/server/cli/code.py b/server/cli/code.py index dcfb28cd49c..f2cf7912455 100644 --- a/server/cli/code.py +++ b/server/cli/code.py @@ -22,6 +22,7 @@ _coverage_import, _crossref, _describe, + _describe_reset, _export_matrix, _export_pairs, _init, @@ -333,6 +334,19 @@ def _add_answers_purge_parser(csub: argparse._SubParsersAction[argparse.Argument p_purge.set_defaults(func=_cmd_answers_purge) +def _add_describe_reset_parser(csub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None: + """`loom code describe-reset`: clear fake-provider chunk descriptions.""" + p_reset = csub.add_parser( + "describe-reset", + help="Reset live chunks whose description came from the fake LLM provider " + "to structural context. Dry run by default (counts and samples the " + "matches); --apply resets.", + ) + add_apply_flags(p_reset, writes="reset the matched chunks") + _add_common(p_reset) + p_reset.set_defaults(func=_cmd_describe_reset) + + def _add_github_backfill_parsers(csub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None: """`backfill-reviews`, `backfill-assignees`, `backfill-items`: GitHub history fills.""" p_rev = csub.add_parser( @@ -497,6 +511,7 @@ def register_code_cli(sub: argparse._SubParsersAction[argparse.ArgumentParser]) _add_pr_history_parsers(csub) _add_describe_parser(csub) _add_answers_purge_parser(csub) + _add_describe_reset_parser(csub) _add_scip_full_parser(csub) @@ -716,6 +731,10 @@ def _cmd_describe(args: argparse.Namespace) -> int: return _run("describe", _describe(args)) +def _cmd_describe_reset(args: argparse.Namespace) -> int: + return _run("describe-reset", _describe_reset(args)) + + def _cmd_scip_retry(args: argparse.Namespace) -> int: return _run("scip-retry", _scip_retry(args)) From 5ec73c6ca0be1f9d29b7d487a86d026392d4f539 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:56:56 +0800 Subject: [PATCH 3/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- server/code/domain/extract/context_text.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/code/domain/extract/context_text.py b/server/code/domain/extract/context_text.py index 8352f74d6bf..fd7a7f27713 100644 --- a/server/code/domain/extract/context_text.py +++ b/server/code/domain/extract/context_text.py @@ -237,7 +237,8 @@ def build_context_text( def with_description(context_text: str, *, scope: str, description: str) -> str: """`context_text` with `description` set as its description line, every other head line (signature, calls, callers) and the content kept: what - `build_context_text` would have produced with that description.""" + `build_context_text` would have produced with that description. An empty + description removes the line instead of leaving a blank one.""" head, sep, content = context_text.partition("\n---\n") if not sep: return context_text @@ -246,4 +247,6 @@ def with_description(context_text: str, *, scope: str, description: str) -> str: rest = lines[at:] if rest and not rest[0].startswith(("calls: ", "Called by: ")): rest = rest[1:] # the description line already there - return "\n".join([*lines[:at], description.strip(), *rest]) + sep + content + desc = description.strip() + head_lines = [*lines[:at], *rest] if not desc else [*lines[:at], desc, *rest] + return "\n".join(head_lines) + sep + content From 88e85c1da7e911d60cc20c66e1947ecb2722c5b9 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:56:58 +0800 Subject: [PATCH 4/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- tests/unit/test_cli_apply_default.py | 207 +++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) diff --git a/tests/unit/test_cli_apply_default.py b/tests/unit/test_cli_apply_default.py index ebb268a1743..1c9de676f93 100644 --- a/tests/unit/test_cli_apply_default.py +++ b/tests/unit/test_cli_apply_default.py @@ -18,6 +18,7 @@ ["tracker-embed-reset", "--org", "o", "--namespace", "n"], ["code", "compact"], ["code", "answers-purge", "--all"], + ["code", "describe-reset", "--org", "o", "--namespace", "n"], ["integrity-repair"], ["sensitivity-sweep", "--org", "o"], ["demote-activity-narration", "--org", "o", "--namespace", "n"], @@ -110,3 +111,209 @@ def tombstone_of(table: str, r: dict[str, str]) -> dict[str, str]: ) assert asyncio.run(code_maintenance._answers_purge(args)) == 0 assert len(written) == 12 + + +class _DescribeResetEmbedder: + """The fake n-gram embedder's vector math without its customer gate.""" + + def __init__(self) -> None: + from server.embedding.fake import FakeNGramEmbedder + + self._real = FakeNGramEmbedder(dim=8) + + model_name = "fake-ngram-8" + dim = 8 + + async def embed(self, text: str) -> list[float]: + return self._real._embed_raw(text) + + +def _describe_reset_row( + *, + chunk_id: str, + org: str = "o", + namespace: str = "n", + source: str = "llm", + description: str = "[fake-synthesis: fake-echo-1] one line", + tombstoned: bool = False, +) -> dict[str, object]: + """A live `code_chunks` row as ingest wrote it, description included.""" + from datetime import UTC, datetime + + from server.code.domain.extract.context_text import build_context_text + from server.code.store.index.rows import build_row + + content = "void push(Entry e) {}\n" + return build_row( + "code_chunks", + org=org, + namespace=namespace, + embedding_model="fake-ngram-8", + path="src/Queue.cpp", + chunk_id=chunk_id, + scope="DB::Queue::push", + kind="function", + content=content, + context_text=build_context_text( + path="src/Queue.cpp", + scope="DB::Queue::push", + signature="(Entry e)", + description=description, + content=content, + calls=["DB::Queue::flush"], + callers=["DB::Handler::run"], + ), + context_description=description, + context_source=source, + embedding=[0.0] * 8, + embedding_dim=8, + tombstoned_at=datetime(2026, 1, 1, tzinfo=UTC) if tombstoned else None, + ) + + +class _DescribeResetStore: + """Live `code_chunks` rows with the reset's read and write semantics: the + query matches the command's WHERE clause, an insert supersedes the live + row of its key.""" + + def __init__(self, rows: list[dict[str, object]]) -> None: + self.rows = list(rows) + self.written: list[dict[str, object]] = [] + + async def query_all( + self, sql: str, params: dict[str, object] | None = None + ) -> list[dict[str, object]]: + p = params or {} + return [ + r + for r in self.rows + if r.get("org") == p.get("org") + and r.get("namespace") == p.get("ns") + and r.get("embedding_model") == p.get("model") + and r.get("context_source") == "llm" + and str(r.get("context_description") or "").startswith(str(p.get("prefix"))) + and r.get("tombstoned_at") is None + ] + + async def insert_rows(self, table: str, out: list[dict[str, object]]) -> None: + self.written.extend(out) + for row in out: + self.rows = [r for r in self.rows if r["chunk_id"] != row["chunk_id"]] + [row] + + +def _run_describe_reset( + monkeypatch: pytest.MonkeyPatch, store: _DescribeResetStore, argv: list[str] +) -> int: + import asyncio + + from server.cli import code_maintenance + + class _CH: + connected = False + + async def connect(self) -> None: ... + + async def disconnect(self) -> None: ... + + class _Repo: + _ch = store + + insert_rows = store.insert_rows + + @staticmethod + def moved_of( + table: str, live_row: dict[str, object], **updates: object + ) -> dict[str, object]: + from server.code.store.index.base import CodeRepoBase + + return CodeRepoBase.moved_of(table, live_row, **updates) + + monkeypatch.setattr("server.core.ch.get_client", lambda: _CH()) + # An org-declaring run checks its deployment first; this fake ClickHouse records none. + monkeypatch.setattr("server.core.pg_profile.check_configured", AsyncMock(return_value=None)) + monkeypatch.setattr("server.code.store.index.CodeRepo", _Repo) + monkeypatch.setattr("server.embedding.embedder.get_embedder", lambda: _DescribeResetEmbedder()) + args = _parser().parse_args(argv) + return asyncio.run(code_maintenance._describe_reset(args)) + + +def test_describe_reset_dry_run_samples_and_writes_nothing( + monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + store = _DescribeResetStore( + [ + _describe_reset_row(chunk_id=f"c{i}", description=f"[fake-synthesis: fake] q{i}") + for i in range(12) + ] + ) + assert ( + _run_describe_reset( + monkeypatch, store, ["code", "describe-reset", "--org", "o", "--namespace", "n"] + ) + == 0 + ) + out = capsys.readouterr().out + assert "would reset 12 chunks" in out and "q9" in out and "q10" not in out and "2 more" in out + assert store.written == [] + assert ( + _run_describe_reset( + monkeypatch, + store, + ["code", "describe-reset", "--org", "o", "--namespace", "n", "--apply"], + ) + == 0 + ) + assert len(store.written) == 12 + + +def test_describe_reset_apply_resets_only_fake_rows( + monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + from server.code.domain.extract.context_text import build_context_text + from server.embedding.fake import FakeNGramEmbedder + + fake = _describe_reset_row(chunk_id="fake") + real = _describe_reset_row(chunk_id="real", description="Summarises the queue.") + structural = _describe_reset_row(chunk_id="struct", source="structural", description="") + other_ns = _describe_reset_row(chunk_id="other", namespace="other") + tombstoned = _describe_reset_row(chunk_id="dead", tombstoned=True) + store = _DescribeResetStore([fake, real, structural, other_ns, tombstoned]) + assert ( + _run_describe_reset( + monkeypatch, + store, + ["code", "describe-reset", "--org", "o", "--namespace", "n", "--apply"], + ) + == 0 + ) + assert "reset 1 chunks" in capsys.readouterr().out + assert len(store.written) == 1 + (reset,) = store.written + content = "void push(Entry e) {}\n" + expected_text = build_context_text( + path="src/Queue.cpp", + scope="DB::Queue::push", + signature="(Entry e)", + content=content, + calls=["DB::Queue::flush"], + callers=["DB::Handler::run"], + ) + assert reset["context_description"] == "" + assert reset["context_source"] == "structural" + assert reset["context_text"] == expected_text + assert reset["embedding"] == FakeNGramEmbedder(dim=8)._embed_raw(expected_text) + assert reset["embedding_dim"] == 8 + assert reset["chunk_id"] == "fake" and reset["version"] > int(fake["version"] or 0) + assert [r["chunk_id"] for r in store.rows] == ["real", "struct", "other", "dead", "fake"] + assert store.rows[0] is real and store.rows[1] is structural + assert store.rows[2] is other_ns and store.rows[3] is tombstoned + assert ( + _run_describe_reset( + monkeypatch, + store, + ["code", "describe-reset", "--org", "o", "--namespace", "n", "--apply"], + ) + == 0 + ) + assert "no live chunks with a fake description matched" in capsys.readouterr().out + assert len(store.written) == 1 From 9a41949f5e9254f220a6ed729932be535cb5986d Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:57:01 +0800 Subject: [PATCH 5/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- tests/unit/test_context_text_with_description.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/unit/test_context_text_with_description.py b/tests/unit/test_context_text_with_description.py index f3f6af50c11..1a7d77bab2c 100644 --- a/tests/unit/test_context_text_with_description.py +++ b/tests/unit/test_context_text_with_description.py @@ -28,5 +28,10 @@ def test_an_existing_description_is_replaced_not_stacked() -> None: assert got == _text("New.") +def test_an_empty_description_removes_the_description_line() -> None: + assert with_description(_text("Old."), scope="DB::Queue::push", description="") == _text() + assert with_description(_text("Old."), scope="DB::Queue::push", description=" ") == _text() + + def test_a_text_without_the_content_separator_is_left_alone() -> None: assert with_description("no separator", scope="s", description="d") == "no separator" From 6f4f2966a32533670c23c981e970733f99ddece8 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:57:04 +0800 Subject: [PATCH 6/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- tests/unit/snapshots/cli_tree.json | 125 +++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/tests/unit/snapshots/cli_tree.json b/tests/unit/snapshots/cli_tree.json index 4371fc4b760..5c7d39c4b84 100644 --- a/tests/unit/snapshots/cli_tree.json +++ b/tests/unit/snapshots/cli_tree.json @@ -1907,6 +1907,125 @@ } ] }, + "describe-reset": { + "prog": "loom code describe-reset", + "usage": null, + "description": null, + "epilog": null, + "formatter_class": "argparse:HelpFormatter", + "add_help": true, + "allow_abbrev": true, + "defaults": { + "dry_run": true, + "apply_gated": true, + "func": "server.cli.code:_cmd_describe_reset" + }, + "groups": [ + { + "title": "positional arguments", + "description": null, + "dests": [] + }, + { + "title": "options", + "description": null, + "dests": [ + "help", + "dry_run", + "dry_run", + "org", + "namespace" + ] + } + ], + "mutually_exclusive": [ + { + "required": false, + "dests": [ + "dry_run", + "dry_run" + ] + } + ], + "arguments": [ + { + "option_strings": [ + "-h", + "--help" + ], + "dest": "help", + "action": "_HelpAction", + "default": "==SUPPRESS==", + "const": null, + "choices": null, + "nargs": 0, + "type": null, + "required": false, + "help": "show this help message and exit", + "metavar": null + }, + { + "option_strings": [ + "--apply" + ], + "dest": "dry_run", + "action": "_StoreFalseAction", + "default": true, + "const": false, + "choices": null, + "nargs": 0, + "type": null, + "required": false, + "help": "reset the matched chunks (default: dry run)", + "metavar": null + }, + { + "option_strings": [ + "--dry-run" + ], + "dest": "dry_run", + "action": "_StoreTrueAction", + "default": true, + "const": true, + "choices": null, + "nargs": 0, + "type": null, + "required": false, + "help": "report what --apply would write, write nothing (the default)", + "metavar": null + }, + { + "option_strings": [ + "--org" + ], + "dest": "org", + "action": "_StoreAction", + "default": null, + "const": null, + "choices": null, + "nargs": null, + "type": null, + "required": false, + "help": "default: LOOM_CODE_ORG", + "metavar": null + }, + { + "option_strings": [ + "--namespace" + ], + "dest": "namespace", + "action": "_StoreAction", + "default": null, + "const": null, + "choices": null, + "nargs": null, + "type": null, + "required": false, + "help": "default: LOOM_CODE_NAMESPACE", + "metavar": null + } + ] + }, "scip-full": { "prog": "loom code scip-full", "usage": null, @@ -3261,6 +3380,7 @@ "repack": "loom code repack", "describe": "loom code describe", "answers-purge": "loom code answers-purge", + "describe-reset": "loom code describe-reset", "scip-full": "loom code scip-full", "scip-lock-path": "loom code scip-lock-path", "entry-lock": "loom code entry-lock", @@ -3341,6 +3461,11 @@ "help": "Tombstone stored code.ask answers. Dry run by default (counts and samples the matches); --apply tombstones.", "metavar": "answers-purge" }, + { + "dest": "describe-reset", + "help": "Reset live chunks whose description came from the fake LLM provider to structural context. Dry run by default (counts and samples the matches); --apply resets.", + "metavar": "describe-reset" + }, { "dest": "scip-full", "help": "Full compiler-tier re-index by hand (the code_scip_full worker runs it weekly by default: heals the TU-cap degrades of per-merge deltas and any drift). Heavy: ~50 min of scip-clang + apply, on this host rather than in the server.", From 86a232a89e1790c79a548fa624be5b0bfdc9cbce Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:57:07 +0800 Subject: [PATCH 7/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- tests/unit/snapshots/cli_help.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/unit/snapshots/cli_help.json b/tests/unit/snapshots/cli_help.json index 8fe14e3ac51..b1cb005b84d 100644 --- a/tests/unit/snapshots/cli_help.json +++ b/tests/unit/snapshots/cli_help.json @@ -6,8 +6,8 @@ "options: -h, --help show this help message and exit --version show program's version number and exit" ], "loom code": [ - "usage: loom code [-h] {init,backfill,reconcile,compact,reembed,vector-twin,crossref,coverage-import,export-pairs,backfill-prs,repack,describe,answers-purge,scip-full,scip-lock-path,entry-lock,scip-delta,entries,warm,scip-retry,backfill-reviews,backfill-assignees,backfill-items,stats,export-matrix,lint-instructions} ...", - "positional arguments: {init,backfill,reconcile,compact,reembed,vector-twin,crossref,coverage-import,export-pairs,backfill-prs,repack,describe,answers-purge,scip-full,scip-lock-path,entry-lock,scip-delta,entries,warm,scip-retry,backfill-reviews,backfill-assignees,backfill-items,stats,export-matrix,lint-instructions} init Create the bare clone + seed state. backfill Full-tree indexing (resumable). reconcile Content-based staleness check: paths whose chunks predate their last change at the branch head; --heal re-ingests them (watermark untouched). compact OPTIMIZE ... FINAL a code vector table when its physical copies per key reach --min-ratio, and wait for the merge. Dry run by default (measures the ratio); --apply optimizes. reembed Write the namespace's live chunks under a second embedding model's label: in-database, resumable, no checkout. vector-twin Fill a namespace's Matryoshka-prefix twin of the chunk vectors inside ClickHouse: no re-embed, resumable. crossref SQL/shell test -> implementing C++ reference pass (writes code_test_map method=content_reference; idempotent). coverage-import Import the newest per-test line coverage run of the configured source (writes code_test_map method=coverage and code_coverage_files). export-pairs Export (query -> acted-on unit, hard negatives) retrieval pairs from real traffic (trace x outcome join) for embedder/reranker fine-tuning. backfill-prs Merged-PR history from GitHub or a Forgejo host. repack Regenerate context packs for recently merged PRs in the current pack shape. describe LLM contextual one-liners for top-PageRank chunks. answers-purge Tombstone stored code.ask answers. Dry run by default (counts and samples the matches); --apply tombstones. scip-full Full compiler-tier re-index by hand (the code_scip_full worker runs it weekly by default: heals the TU-cap degrades of per-merge deltas and any drift). Heavy: ~50 min of scip-clang + apply, on this host rather than in the server. scip-lock-path Print the entry's compiler-tier lock file on this host. A manual harness run goes under `loom code entry-lock`, which takes this file and the deployment lease; scip-full and scip-delta take both themselves. entry-lock Run a command under the entry's compiler-tier lock (this host's file and the deployment's lease): exit 75 when another pass holds it, 3 when the lease is lost mid-run (the command is stopped). scip-delta One compiler-tier delta pass (same code as the code_scip_delta worker), by hand: git_head vs scip_commit per configured repo, scip-clang over the changed TUs, apply. Prints `RESULT: ...`. entries One line per configured repository: org namespace checkout lock-file (the lock path resolved; a manual run takes it through `loom code entry-lock`). warm Pre-seed the code.ask answer cache from a question list (one question per line, or JSONL with a 'question' field). Each miss pays one synthesis; every future asker fleet-wide gets the cached answer. Safe to re-run: a hit skips synthesis. scip-retry Reset a failed SCIP batch to pending. backfill-reviews Inline review comments for merged PRs already in code_pr_history that have none stored yet (newest first, one GitHub request per PR). backfill-assignees Fill code_pr_history.assignees (who the repo assigned to review) for merged PRs already stored, walking the newest closed PRs 100 per request. backfill-items Fill code_gh_items (issues + PRs, any state) updated since a date, 100 per request, oldest update first; moves gh_items_cursor. stats Watermarks + live row counts. export-matrix Maintenance matrix from merged-PR co-change: 'when this file changes, these usually change too', with evidence, as markdown for an instructions file (AGENTS.md / copilot-instructions.md). lint-instructions Agent-instruction files (CLAUDE.md, AGENTS.md, copilot-instructions, .claude/**.md, skills) whose path or symbol references no longer resolve at the clone's head.", + "usage: loom code [-h] {init,backfill,reconcile,compact,reembed,vector-twin,crossref,coverage-import,export-pairs,backfill-prs,repack,describe,answers-purge,describe-reset,scip-full,scip-lock-path,entry-lock,scip-delta,entries,warm,scip-retry,backfill-reviews,backfill-assignees,backfill-items,stats,export-matrix,lint-instructions} ...", + "positional arguments: {init,backfill,reconcile,compact,reembed,vector-twin,crossref,coverage-import,export-pairs,backfill-prs,repack,describe,answers-purge,describe-reset,scip-full,scip-lock-path,entry-lock,scip-delta,entries,warm,scip-retry,backfill-reviews,backfill-assignees,backfill-items,stats,export-matrix,lint-instructions} init Create the bare clone + seed state. backfill Full-tree indexing (resumable). reconcile Content-based staleness check: paths whose chunks predate their last change at the branch head; --heal re-ingests them (watermark untouched). compact OPTIMIZE ... FINAL a code vector table when its physical copies per key reach --min-ratio, and wait for the merge. Dry run by default (measures the ratio); --apply optimizes. reembed Write the namespace's live chunks under a second embedding model's label: in-database, resumable, no checkout. vector-twin Fill a namespace's Matryoshka-prefix twin of the chunk vectors inside ClickHouse: no re-embed, resumable. crossref SQL/shell test -> implementing C++ reference pass (writes code_test_map method=content_reference; idempotent). coverage-import Import the newest per-test line coverage run of the configured source (writes code_test_map method=coverage and code_coverage_files). export-pairs Export (query -> acted-on unit, hard negatives) retrieval pairs from real traffic (trace x outcome join) for embedder/reranker fine-tuning. backfill-prs Merged-PR history from GitHub or a Forgejo host. repack Regenerate context packs for recently merged PRs in the current pack shape. describe LLM contextual one-liners for top-PageRank chunks. answers-purge Tombstone stored code.ask answers. Dry run by default (counts and samples the matches); --apply tombstones. describe-reset Reset live chunks whose description came from the fake LLM provider to structural context. Dry run by default (counts and samples the matches); --apply resets. scip-full Full compiler-tier re-index by hand (the code_scip_full worker runs it weekly by default: heals the TU-cap degrades of per-merge deltas and any drift). Heavy: ~50 min of scip-clang + apply, on this host rather than in the server. scip-lock-path Print the entry's compiler-tier lock file on this host. A manual harness run goes under `loom code entry-lock`, which takes this file and the deployment lease; scip-full and scip-delta take both themselves. entry-lock Run a command under the entry's compiler-tier lock (this host's file and the deployment's lease): exit 75 when another pass holds it, 3 when the lease is lost mid-run (the command is stopped). scip-delta One compiler-tier delta pass (same code as the code_scip_delta worker), by hand: git_head vs scip_commit per configured repo, scip-clang over the changed TUs, apply. Prints `RESULT: ...`. entries One line per configured repository: org namespace checkout lock-file (the lock path resolved; a manual run takes it through `loom code entry-lock`). warm Pre-seed the code.ask answer cache from a question list (one question per line, or JSONL with a 'question' field). Each miss pays one synthesis; every future asker fleet-wide gets the cached answer. Safe to re-run: a hit skips synthesis. scip-retry Reset a failed SCIP batch to pending. backfill-reviews Inline review comments for merged PRs already in code_pr_history that have none stored yet (newest first, one GitHub request per PR). backfill-assignees Fill code_pr_history.assignees (who the repo assigned to review) for merged PRs already stored, walking the newest closed PRs 100 per request. backfill-items Fill code_gh_items (issues + PRs, any state) updated since a date, 100 per request, oldest update first; moves gh_items_cursor. stats Watermarks + live row counts. export-matrix Maintenance matrix from merged-PR co-change: 'when this file changes, these usually change too', with evidence, as markdown for an instructions file (AGENTS.md / copilot-instructions.md). lint-instructions Agent-instruction files (CLAUDE.md, AGENTS.md, copilot-instructions, .claude/**.md, skills) whose path or symbol references no longer resolve at the clone's head.", "options: -h, --help show this help message and exit" ], "loom code init": [ @@ -62,6 +62,10 @@ "usage: loom code answers-purge [-h] [--llm-model LLM_MODEL] [--all] [--apply | --dry-run] [--org ORG] [--namespace NAMESPACE]", "options: -h, --help show this help message and exit --llm-model LLM_MODEL only entries synthesized by this model (e.g. gpt-6-luna) --all purge every cached answer --apply tombstone the matched answers (default: dry run) --dry-run report what --apply would write, write nothing (the default) --org ORG default: LOOM_CODE_ORG --namespace NAMESPACE default: LOOM_CODE_NAMESPACE" ], + "loom code describe-reset": [ + "usage: loom code describe-reset [-h] [--apply | --dry-run] [--org ORG] [--namespace NAMESPACE]", + "options: -h, --help show this help message and exit --apply reset the matched chunks (default: dry run) --dry-run report what --apply would write, write nothing (the default) --org ORG default: LOOM_CODE_ORG --namespace NAMESPACE default: LOOM_CODE_NAMESPACE" + ], "loom code scip-full": [ "usage: loom code scip-full [-h] [--checkout CHECKOUT] [--jobs JOBS] [--keep-delta KEEP_DELTA] [--apply-delta APPLY_DELTA] [--org ORG] [--namespace NAMESPACE]", "options: -h, --help show this help message and exit --checkout CHECKOUT default: LOOM_CODE_SCIP_CHECKOUT_DIR --jobs JOBS scip-clang -j (0 = nproc/2) --keep-delta KEEP_DELTA copy the harness's delta.json here after indexing (so an interrupted apply can be re-run with --apply-delta instead of paying the ~50 min index again) --apply-delta APPLY_DELTA skip checkout + scip-clang and apply this delta.json (from --keep-delta); scip_commit is set to the delta's commit --org ORG default: LOOM_CODE_ORG --namespace NAMESPACE default: LOOM_CODE_NAMESPACE" From 6910806aab341388494ce2c090a3ed519b039c10 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:57:10 +0800 Subject: [PATCH 8/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- docs/reference/cli.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 816a0920bef..b3c5702a0c3 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -242,6 +242,7 @@ python scripts/codegen/docs_reference.py | `loom code repack` | Regenerate context packs for recently merged PRs in the current pack shape. | `--org`, `--namespace`, `--days`, `--limit`, `--dry-run` | | `loom code describe` | LLM contextual one-liners for top-PageRank chunks. | `--org`, `--namespace`, `--top-pct`, `--limit`, `--max-usd`, `--suffix`, `--concurrency` | | `loom code answers-purge` | Tombstone stored code.ask answers. | `--llm-model`, `--all`, `--apply`, `--dry-run`, `--org`, `--namespace` | +| `loom code describe-reset` | Reset live chunks whose description came from the fake LLM provider to structural context. | `--apply`, `--dry-run`, `--org`, `--namespace` | | `loom code scip-full` | Full compiler-tier re-index by hand (the code_scip_full worker runs it weekly by default: heals the TU-cap degrades of per-merge deltas and any drift). | `--checkout`, `--jobs`, `--keep-delta`, `--apply-delta`, `--org`, `--namespace` | | `loom code scip-lock-path` | Print the entry's compiler-tier lock file on this host. | `--org`, `--namespace` | | `loom code entry-lock` | Run a command under the entry's compiler-tier lock (this host's file and the deployment's lease): exit 75 when another pass holds it, 3 when the lease is lost mid-run (the command is stopped). | `--org`, `--namespace`, `--tier`, `` | From 1c985502c97417973d0299a83667138bc7c28589 Mon Sep 17 00:00:00 2001 From: JELLY Date: Sun, 6 Dec 2026 16:57:13 +0800 Subject: [PATCH 9/9] `loom code describe-reset` returns fake-provider chunk descriptions to structural context Signed-off-by: krison --- docs/operations/code-index-operations.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/operations/code-index-operations.md b/docs/operations/code-index-operations.md index fb5f49aa400..5284808dad8 100644 --- a/docs/operations/code-index-operations.md +++ b/docs/operations/code-index-operations.md @@ -1345,6 +1345,7 @@ copy. | `loom code compact [--table T] [--apply]` | measures, and with `--apply` runs, `OPTIMIZE … FINAL` on a code vector table once its physical copies per key reach `LOOM_CODE_COMPACT_MIN_RATIO` (1.5), and waits for the merge; bulk passes do it themselves after `LOOM_CODE_COMPACT_AFTER_BULK_ROWS` rows ([maintenance](./maintenance.md#compaction-and-optimize)) | | `loom code warm ` | asks each question once to populate shared `code.ask` answers (text lines or JSONL with `question`); a valid answer hit avoids fresh synthesis, but query embedding can still cost | | `loom code answers-purge` | retires stored `code.ask` answers; dry run until `--apply`. Normal reuse already checks the model and prompt, answer-key settings, maximum age and recorded source hashes | +| `loom code describe-reset` | returns live chunks whose description came from the fake LLM provider to structural context and re-embeds them; dry run until `--apply`. A later `describe` on a real provider picks the reset rows up again | | `loom code repack` | rebuilds context packs for recently merged PRs in the current shape | | `loom code crossref` | the SQL/shell test → implementing C++ reference pass (idempotent) | | `loom code coverage-import [--dry-run]` | imports the newest per-test line coverage run of the configured source into the test map ([measured coverage](#measured-coverage)) |