Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
86573ea
The stored-memory read's docstring says the per-call valid_at default…
zlareb1 Nov 28, 2026
785fe7c
namespace.validate reads the names of unlinked memories off the event…
zlareb1 Nov 28, 2026
d9f6163
The code-state probe's comment names what its first statement reads
zlareb1 Nov 28, 2026
db550c6
The link findings say their 2,000-memory limit also applies under keys
zlareb1 Nov 28, 2026
c086f98
The env examples no longer set the ingest poller to its default
zlareb1 Nov 28, 2026
314f750
The file re-hash names the case where a link adopts its last checked …
zlareb1 Nov 28, 2026
b3ec87d
The unread list of via labels is gone
zlareb1 Nov 28, 2026
01584bd
A moved-code note reads its line numbers as integers
zlareb1 Nov 28, 2026
a182ce2
A test pins the note for a definition whose module prefix follows its…
zlareb1 Nov 28, 2026
fbfd6a9
A link-recheck test case says what it asserts
zlareb1 Nov 28, 2026
8a6650b
The comment on the cross-file search states its condition in two lines
zlareb1 Nov 28, 2026
e610388
A range's turnover is remembered per file limit
zlareb1 Nov 28, 2026
00681a2
The turnover docstring names every case that returns None
zlareb1 Nov 28, 2026
0d9d248
The extraction prompt docstring says a coding session takes no flag-g…
zlareb1 Nov 28, 2026
4c5d162
A test pins the pool cut's depth under the lazy-materialization cap
zlareb1 Nov 28, 2026
f536f33
The lessons bullet of the memory concepts page is wrapped like its pa…
zlareb1 Nov 28, 2026
752dec2
The paragraph on following a renamed definition and rolling-upgrade e…
zlareb1 Nov 28, 2026
b157488
The rename-edits paragraph of the memory concepts page is wrapped at …
zlareb1 Nov 28, 2026
28de679
The extraction page gives where a session fact's valid_at comes from,…
zlareb1 Nov 28, 2026
0448ce6
The extraction page sizes the session prompt in characters, as its te…
zlareb1 Nov 28, 2026
b1aabf5
The pending-link check states which writes it counts under their caus…
zlareb1 Nov 28, 2026
5c0d7eb
Merge main: the follow-ups sit on the reworked link recheck and the l…
zlareb1 Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ OPENAI_API_KEY=
# LOOM_CODE_GITHUB_TOKEN=<token> # private clones and PR history; empty = public clones, no PR sync
# The stock single-node stack enables the non-LLM indexing workers so repositories
# added in the dashboard make progress without a second setup step.
# Per-merge fast tier (tree-sitter + embeddings).
LOOM_CODE_INGEST_ENABLED=true
# LOOM_CODE_PR_HISTORY_ENABLED=true # merged-PR sync (needs the GitHub token)
# Re-embed code rows whose embedding failed.
LOOM_CODE_EMBED_RECOVERY_ENABLED=true
Expand Down
1 change: 0 additions & 1 deletion deploy/standalone/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ OPENAI_API_KEY=
# C/C++ compiler indexing needs a project compilation database and scip-clang;
# these are repository build prerequisites, not additional running services.
# LOOM_CODE_REPOS_JSON=[{"org":"dev","namespace":"code-myrepo","repo":"acme/myrepo","git_branch":"main","public":true}]
LOOM_CODE_INGEST_ENABLED=true
LOOM_CODE_EMBED_RECOVERY_ENABLED=true
LOOM_CODE_GRAPH_STATS_ENABLED=true
LOOM_CODE_SCIP_DELTA_ENABLED=true
Expand Down
54 changes: 27 additions & 27 deletions docs/concepts/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,23 +530,22 @@ link comes back only when its own name does. A definition moved to another file
own name with an edit is followed there when its text is close to the one the link last
read. A new definition left where it was stops that search only when it may be the old
one under a new name: an export list or an unrelated function added beside it does not. A
name gone from its file is
looked for in the files changed
since its last check as the mirror holds them, beside the index, so a definition moved by
a commit the index has not taken in whole (past `code_ingest_max_files_per_commit`) is
followed when the link is rechecked. When `memory_code_links_mirror_naming_files` or more
of those files name it, or more than `memory_code_links_mirror_changed_files` changed
under the entry's prefixes, or the diff cannot be read, or the paths are more than git
takes in one command or searches in its time, the mirror adds nothing and the index
decides. When git cannot run the search, or a definition it finds cannot be
fingerprinted, a live link the index's namesakes do not settle is `unresolved`. Files the
ingest would not index (outside the entry's `path_prefixes`, refused by its denylist,
over the byte cap, binary) add no definition; a generated file, which the ingest declares
without searching its text, does. A file the parser fails on keeps its links as they were
until it parses. When the fingerprint rules change, every link is re-hashed from the
commits its hashes were taken at. When its old text is gone from git, a link that matched
it takes the text the next check finds and a changed one stays `changed`; one whose old
text no longer parses keeps its last state, and the worker reports it.
name gone from its file is looked for in the files changed since its last check as the
mirror holds them, beside the index, so a definition moved by a commit the index has not
taken in whole (past `code_ingest_max_files_per_commit`) is followed when the link is
rechecked. When `memory_code_links_mirror_naming_files` or more of those files name it,
or more than `memory_code_links_mirror_changed_files` changed under the entry's prefixes,
or the diff cannot be read, or the paths are more than git takes in one command or
searches in its time, the mirror adds nothing and the index decides. When git cannot run
the search, or a definition it finds cannot be fingerprinted, a live link the index's
namesakes do not settle is `unresolved`. Files the ingest would not index (outside the
entry's `path_prefixes`, refused by its denylist, over the byte cap, binary) add no
definition; a generated file, which the ingest declares without searching its text, does.
A file the parser fails on keeps its links as they were until it parses. When the
fingerprint rules change, every link is re-hashed from the commits its hashes were taken
at. When its old text is gone from git, a link that matched it takes the text the next
check finds and a changed one stays `changed`; one whose old text no longer parses keeps
its last state, and the worker reports it.

After a rename a memory's text still says the old name until it is revised, by the
link pass where the swap is certain ([below](#a-memorys-text-after-a-rename)) or by a
Expand Down Expand Up @@ -643,10 +642,11 @@ The links are read where the code is:
commit that put its code in a changed, unresolved or missing state) when one is known, and
`supersedes_key` when it replaces an older row, and `code_moved` (its links to code in the
file that is now at another path or symbol than it was written against) when there are
any; a row another row read for the answer supersedes is not served. `lessons_left_out` counts the rows the cap, a cut or that rule left
out. A decision or constraint is served whole or left out. The read runs after the answer,
never enters the search memo, and is skipped for `include_lessons: false`, with
`code_result_lessons` off, or for a token narrowed to its own user or session.
any; a row another row read for the answer supersedes is not served. `lessons_left_out`
counts the rows the cap, a cut or that rule left out. A decision or constraint is served
whole or left out. The read runs after the answer, never enters the search memo, and is
skipped for `include_lessons: false`, with `code_result_lessons` off, or for a token
narrowed to its own user or session.
- `code.grep` in matches mode focuses inline lessons on the definitions its
matches name in trunk files. When selecting files to read, grep prefers
files with a current lesson linked to a matched definition at the returned
Expand Down Expand Up @@ -721,9 +721,9 @@ counts the served memories that name code (a backticked or qualified name, a cal
| `code_unlinked_name_unresolved` | lists no `files`, and each name is defined nowhere on trunk or more than once. |
| `code_unlinked_pending` | waits for its link; each sample says what it `waits_for`: `link_pass` (the worker has not read this write), `index` (no index yet, or a file that does not parse) or `trunk` (a qualified name trunk does not define yet). |

The counts are of the 2,000 served memories last written (all under `keys` when given),
and only in an org that indexes a repository; a raw tool observation, which is never
linked, is not counted. How far each repository's links trail its
The counts are of the 2,000 served memories last written (of those under `keys` when
given), and only in an org that indexes a repository; a raw tool observation, which is
never linked, is not counted. How far each repository's links trail its
index is a gauge, and a health warning when it lasts
([monitoring](../operations/monitoring.md#what-to-alert-on)).

Expand Down Expand Up @@ -820,9 +820,9 @@ says. A sentence ends after `.`, `!` or `?` and a space (not after a one-letter
such as `e.g.`), at a blank line and before a list item; a line break alone does not end
one. The words that mark a sentence as
being about the name are English, and `call` or `calls` is not one: it is read as calling
the code. The finding reads the 2,000 memories whose `moved` link was last checked (all
under `keys` when given), in the repositories the caller may read, and no high-sensitivity
memory; a link whose code also changed is listed under `code_links_stale`. Neither the
the code. The finding reads the 2,000 memories whose `moved` link was last checked (of
those under `keys` when given), in the repositories the caller may read, and no
high-sensitivity memory; a link whose code also changed is listed under `code_links_stale`. Neither the
memory's key, tags, `files`, entities and concepts nor a line number written in its text
is edited.

Expand Down
25 changes: 14 additions & 11 deletions docs/features/memory/extraction.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,20 @@ The rules in `server/memory/domain/durable_facts.py` match sentence shape, not t
a release changed is kept; whether its CI was green at the time is dropped.

A plugin's session capture (a `source:` tag) is extracted with a prompt of its own, at
every capture size. It holds no conversation rule or example, and is about 2,700 tokens
where the conversation prompt is 20,000 to 34,000, because most captures hold nothing to
keep and the prompt is then what the call costs. What the user states that holds beyond
the session is kept: a standing rule, a preference, a decision, a fact about their setup.
What the user asks for the task alone is not. Its schema asks for the fields a coding fact
uses and for the end of a state the user bounds (`valid_to`, `foresight`), so a freeze
"until Friday" stops being served after that day. The extractor sets no `valid_at`,
`temporal_confidence`, occurrence record or `question_topic` on a session capture's fact;
the row takes its `valid_at` from the fact's `temporal_anchor` when that is not in the
future, else from the observation date. From the work, only knowledge about the codebase
that a later session in the repository can reuse without reading the code again is kept:
every capture size. It holds no conversation rule or example, and is under 9,000
characters where the conversation prompt is about 57,000 for a short input and 86,000 for
a longer one, because most captures hold nothing to keep and the prompt is then what the
call costs. What the user states that holds beyond the session is kept: a standing rule, a
preference, a decision, a fact about their setup. What the user asks for the task alone is
not. Its schema asks for the fields a coding fact uses and for the end of a state the user
bounds (`valid_to`, `foresight`), so a freeze "until Friday" stops being served after that
day. The prompt asks for no `valid_at`, `temporal_confidence`, occurrence record or
`question_topic` on a session capture's fact. The row takes its `valid_at` from the time
of the latest turn the fact cites, when the capture's messages carry a `timestamp` and the
fact's `temporal_anchor` names no other day or time of day; else from the call's own
`valid_at`; else from the fact's `temporal_anchor` when that is not in the future; else
from the observation date. From the work, only knowledge about the codebase that a later
session in the repository can reuse without reading the code again is kept:

- how a behaviour is reached across definitions or files, as one claim for the whole path;
- a relation between definitions that reading one of them does not show;
Expand Down
22 changes: 6 additions & 16 deletions server/code/domain/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,12 @@ def estimate_unit_tokens(unit: CodeUnit, *, body: str | None = None) -> int:
}
)

# Every served unit says which leg found it. `via` is one of VIA_VALUES: a content leg
# or both, the symbol route, or the other leg that proposed a unit neither content leg
# found. The ranks are 1-based positions inside the leg's pool before fusion (0 = the
# leg did not return this chunk). Computed from the leg results BEFORE the fusion priors
# reorder anything, so they answer "what did each leg say", not "where did it end up".
VIA_VALUES: tuple[str, ...] = (
"lexical",
"vector",
"both",
"symbol",
"definition",
"history",
"card",
"concept",
"hyde",
)
# Every served unit says which leg found it. `via` names a content leg or both
# (`lexical`, `vector`, `both`), the symbol route, or the other leg that proposed a unit
# neither content leg found. The ranks are 1-based positions inside the leg's pool before
# fusion (0 = the leg did not return this chunk). Computed from the leg results BEFORE the
# fusion priors reorder anything, so they answer "what did each leg say", not "where did
# it end up".
_DEFAULT_GRANULARITY = "unit"


Expand Down
10 changes: 6 additions & 4 deletions server/identity/app/namespace_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@

# What every `code_unlinked_*` check reads (`code_unlinked.unlinked`).
_UNLINKED_READ = (
f"Only the {code_unlinked.SCANNED} served memories last written are read (all under "
"`keys` when given), and only in an org that indexes a repository. A raw tool "
f"Only the {code_unlinked.SCANNED} served memories last written are read (of those "
"under `keys` when given), and only in an org that indexes a repository. A raw tool "
"observation is never linked and is not read; a word of the prose counts as a name "
"only beside `files`."
)
Expand Down Expand Up @@ -409,7 +409,7 @@
1,
exceptions=(
f"Only the {code_unlinked.SCANNED} memories whose `moved` link was last checked "
"are read (all under `keys` when given), only in repositories the caller may "
"are read (of those under `keys` when given), only in repositories the caller may "
"read, and no high-sensitivity memory. A link whose code also changed is "
"`code_links_stale`'s."
),
Expand Down Expand Up @@ -448,7 +448,9 @@
exceptions=_UNLINKED_READ,
uncertainty=(
"While the link pass backfills earlier writes, a memory it has not reached is "
"counted here even when nothing of it will resolve."
"counted here even when nothing of it will resolve. A write queued after the "
"pass's position with an earlier write time (an insert in flight, a writer "
"clock behind ClickHouse's) is counted under its cause until the next pass."
),
),
}
Expand Down
7 changes: 4 additions & 3 deletions server/memory/app/code_link_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ async def touched(self, base: str, head: str) -> set[str] | None:
async def turnover(self, base: str, head: str, *, limit: int) -> Turnover | None:
"""The definitions `base..head` brought in and took out of the files it changed,
those the ingest would not index left out, a renamed file read as one. None when
the range cannot be read (a force-push, a diff git fails on), or changed more
than `limit` files under the entry's prefixes: counted in `wide_ranges`, and
the range cannot be read (a force-push, a diff git fails on), when no repository
indexes the namespace, or when the range changed more than `limit` files under
the entry's prefixes: only that last case is counted in `wide_ranges`, and it is
read only where a definition's lines are (`turnover_holding`)."""

async def read() -> Turnover | None:
Expand All @@ -289,7 +290,7 @@ async def read() -> Turnover | None:
return None
return await self._read_turnover(paths[0], base, head, paths[1])

return await self._once(("turnover", base, head), read)
return await self._once(("turnover", base, head, limit), read)

async def turnover_holding(
self, base: str, head: str, lines: Sequence[str], path: str, *, limit: int
Expand Down
6 changes: 3 additions & 3 deletions server/memory/app/code_link_rehash.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ async def cited_at(commit: str, path: str) -> str | None:
first = written or await cited_at(a["baseline_commit"], a["baseline_path"]) or ""
read = await cited_at(a["checked_commit"], link.path)
checked = read or ""
took = not first and link.matched_baseline()
baseline = first or (checked if took else NO_BASELINE)
adopts_checked = not first and link.matched_baseline()
baseline = first or (checked if adopts_checked else NO_BASELINE)
out = {"anchored_hash": written, "body_hash": baseline, "checked_hash": checked}
if took and checked:
if adopts_checked and checked:
# the next re-hash reads the baseline where this one took it
out |= {"baseline_commit": a["checked_commit"], "baseline_path": link.path}
# a file that is gone stays gone; lines that cannot be read show no change
Expand Down
17 changes: 9 additions & 8 deletions server/memory/app/code_unlinked.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from __future__ import annotations

import asyncio
from collections import defaultdict
from collections.abc import Sequence
from typing import Any
Expand Down Expand Up @@ -64,7 +65,9 @@ async def read(cls) -> _Pass:
def has_read(self, org: str, memory: dict[str, Any]) -> bool:
"""The pass read `memory` as it is now: written before the queue position and,
while the backfill runs, at or before the identity it has reached. A version is
the write's wall-clock time in ns."""
the write's wall-clock time in ns, and the position is ClickHouse's time at the
queue insert: a write queued after the position with an earlier version (an
insert in flight, a writer clock behind) reads as read until the next pass."""
if not self.read_to or int(memory["version"]) // 1000 > self.read_to:
return False
ident = (org, *(str(memory[c]) for c in IDENTITY[1:]))
Expand All @@ -79,18 +82,16 @@ async def unlinked(
read), the last written first: each with its memory_key and
memory_id and, under `pending`, what it `waits_for` (`index`: its repository's first
index or a file that does not parse; `trunk`: a qualified name trunk does not define
yet; `link_pass`: the pass to read it). Read of the memories under `keys` when given,
of the `SCANNED` last written otherwise. A memory whose repository the caller may not
yet; `link_pass`: the pass to read it). Read of the `SCANNED` last written, among
those under `keys` when given. A memory whose repository the caller may not
read counts as naming none: its cause must not tell what that repository holds.
Nothing is read, and nothing counted, in an org that indexes no repository."""
out: dict[str, list[dict[str, str]]] = {cause: [] for cause in CAUSES}
if not any(cfg.org == org for cfg in configured_repos()):
return out # the org indexes no repository: no memory of it could be linked
heads = [
h
for h in await store.linkable_of_namespace(org, namespace, keys, limit=SCANNED)
if _names_code(h)
]
linkable = await store.linkable_of_namespace(org, namespace, keys, limit=SCANNED)
# reading names is CPU work: off the loop
heads = await asyncio.to_thread(lambda: [h for h in linkable if _names_code(h)])
if not heads:
return out
named = {h["mid"]: code_namespace_for(org, namespace, list(h.get("tags") or [])) for h in heads}
Expand Down
5 changes: 3 additions & 2 deletions server/memory/app/extract/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def _extraction_base_prompt(
compact: bool, *, agent_learnings: bool = False, coding_session: bool = False
) -> str:
"""The extraction system prompt before the preamble: a coding session's own
prompt at every input size, else the full or the compact examples plus the
flag-gated blocks."""
prompt at every input size, which takes no flag-gated block (`agent_learnings`
is not read for it), else the full or the compact examples plus the flag-gated
blocks."""
if coding_session:
return _CODING_SESSION_SYSTEM_PROMPT
base_prompt = (
Expand Down
7 changes: 4 additions & 3 deletions server/memory/app/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,10 @@ async def _stored_neighbours(state: WorkflowState, facts: list[dict[str, Any]])
earlier session may already have stored of this capture's claims. One `embed_many`
call for the capture, and the reads bounded like the conflict checks of the write
that follows. None for a fact that carries `valid_at`, `valid_to` or `foresight`:
the verifier compares text and sees no validity. None under `append_only`, where
every write is its own event, or under a policy that could not be read. Fail-open:
with none, no fact is dropped as already stored."""
the verifier compares text and sees no validity. The call's own `valid_at` default
is not read: a fact that takes its start from it is still compared. None under
`append_only`, where every write is its own event, or under a policy that could not
be read. Fail-open: with none, no fact is dropped as already stored."""
import server.memory.store as memory_repo
from server.embedding import get_embedder
from server.memory.app.handlers import nearest_existing_rows
Expand Down
Loading
Loading