From debb172344c0826a0dca53bd8ec8c4a45925f61c Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Mon, 30 Nov 2026 15:57:08 +0530 Subject: [PATCH 1/6] Fixed grep and adoption reporting budgets pass the settings gate Derive the grep page allowance from the docstring cap and document the deadline for optional Postgres metadata. Signed-off-by: Lareb Zafar --- server/code/app/grep_source.py | 5 ++--- server/code/domain/definition_header.py | 2 +- server/insights/workers/adoption_telemetry.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/server/code/app/grep_source.py b/server/code/app/grep_source.py index 56acd1fb004..ab988188c10 100644 --- a/server/code/app/grep_source.py +++ b/server/code/app/grep_source.py @@ -28,9 +28,8 @@ ContextSource = dict[str, dict[str, str | None]] CompleteContexts = frozenset[tuple[str, int]] GREP_MATCH_TEXT_CHARS = 300 -# Signature and docstring lines one page adds beyond its match windows: four -# definitions at the docstring cap, about eight of typical size. -GREP_HEADER_PAGE_LINES = 48 +# A page budgets four docstrings at the excerpt cap for its added header lines. +GREP_HEADER_PAGE_LINES = 4 * DOCSTRING_MAX_LINES # A shorter run of docstring lines is shown: its mark and the window it splits cost more. _DOCSTRING_CUT_MIN_LINES = 3 diff --git a/server/code/domain/definition_header.py b/server/code/domain/definition_header.py index 1711b078735..1a7b3e9dc1a 100644 --- a/server/code/domain/definition_header.py +++ b/server/code/domain/definition_header.py @@ -9,7 +9,7 @@ PYTHON_SUFFIXES = (".py", ".pyi") # Lines read from a definition's first line to find the end of its docstring. DEFINITION_HEADER_SCAN_LINES = 80 -# Docstring lines an excerpt shows; a longer docstring keeps its first and last lines. +# not a setting: the grep page's header budget is derived from this excerpt size. DOCSTRING_MAX_LINES = 12 _DOCSTRING_TAIL_LINES = 3 _LAYOUT = frozenset({tokenize.NL, tokenize.COMMENT, tokenize.INDENT, tokenize.DEDENT}) diff --git a/server/insights/workers/adoption_telemetry.py b/server/insights/workers/adoption_telemetry.py index 8782f7da39e..e8501539430 100644 --- a/server/insights/workers/adoption_telemetry.py +++ b/server/insights/workers/adoption_telemetry.py @@ -60,7 +60,7 @@ async def _postgres_metadata() -> dict[str, str]: hosting = _postgres_hosting(settings.pg_dsn) if configured == "auto" else configured metadata = {"postgres_hosting": hosting} if hosting else {} try: - # A slow Postgres must not hold up the ClickHouse activity reports. + # not a setting: this optional version lookup gets two seconds of the reporting budget. async with asyncio.timeout(2): version = await pg.fetchval("SHOW server_version") except Exception: # noqa: BLE001 — ClickHouse activity can still be reported without a Postgres version From 05438a4694686be9e621ca76cae379414d3b339f Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Mon, 30 Nov 2026 15:58:32 +0530 Subject: [PATCH 2/6] Reviewed sender fingerprints match the shipped sources The collection primer sends the same scoped request and the SDK change parses response data. Record the current digests after reviewing those paths. Signed-off-by: Lareb Zafar --- tests/unit/session_content_senders.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index 37b67ff9556..b2c753b1adc 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -387,8 +387,8 @@ "integrations/claude-code-plugin/hooks/loom-flush.mjs": "8b48742059e0c7bdc1fe724a78df31f28af646dc9e9325aace7bae3a7d2a86ab", "integrations/claude-code-plugin/hooks/loom-namespace-health.mjs": "5f2bd718a88587c5f66b9823317bc77c18ce6a124f0602368b254d2c8c733ddb", "integrations/claude-code-plugin/hooks/loom-prompt-pack.mjs": "db4ebc48929214e55acbc9a41f6143a97715ea9b1948e429c158fcae110c2ee4", - "integrations/claude-code-plugin/hooks/loom-session-start.mjs": "d492ffd106dde196ce2949fb31b0d1933dff6441e30d91c6191dee03b20dc49b", - "integrations/claude-code-plugin/lib/collections-line.mjs": "d3f112711219cd5ff435b398ef323502ea1f9ac46c02b8b66bc44b3f1ba74a73", + "integrations/claude-code-plugin/hooks/loom-session-start.mjs": "46ad5c59b10d683c7bcc922c57749fdce4c79a4802efedc33269b53ca38fdcdd", + "integrations/claude-code-plugin/lib/collections-line.mjs": "5c8e1eb430708f5039583a0810bfad9768ed554669624e5084aa6330aa70c498", "integrations/claude-code-plugin/lib/first-session.mjs": "e9183d950899f3ef78bdd17ba677d25e9ff5baffddc97ca282fecc5a80a92651", "integrations/claude-code-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/claude-code-plugin/lib/loom-client.mjs": "4002ed3ecd815258eca4904aede0e549579eeb1069ed59ea425ecb252fa59e78", @@ -402,8 +402,8 @@ "integrations/codex-plugin/hooks/loom-flush.mjs": "8b48742059e0c7bdc1fe724a78df31f28af646dc9e9325aace7bae3a7d2a86ab", "integrations/codex-plugin/hooks/loom-namespace-health.mjs": "5f2bd718a88587c5f66b9823317bc77c18ce6a124f0602368b254d2c8c733ddb", "integrations/codex-plugin/hooks/loom-prompt-pack.mjs": "db4ebc48929214e55acbc9a41f6143a97715ea9b1948e429c158fcae110c2ee4", - "integrations/codex-plugin/hooks/loom-session-start.mjs": "d492ffd106dde196ce2949fb31b0d1933dff6441e30d91c6191dee03b20dc49b", - "integrations/codex-plugin/lib/collections-line.mjs": "d3f112711219cd5ff435b398ef323502ea1f9ac46c02b8b66bc44b3f1ba74a73", + "integrations/codex-plugin/hooks/loom-session-start.mjs": "46ad5c59b10d683c7bcc922c57749fdce4c79a4802efedc33269b53ca38fdcdd", + "integrations/codex-plugin/lib/collections-line.mjs": "5c8e1eb430708f5039583a0810bfad9768ed554669624e5084aa6330aa70c498", "integrations/codex-plugin/lib/first-session.mjs": "e9183d950899f3ef78bdd17ba677d25e9ff5baffddc97ca282fecc5a80a92651", "integrations/codex-plugin/lib/flush-job.mjs": "e6c4ae5e42a54cba0e171b727688be621a81245023bf85a8ac093d334bc9bfd5", "integrations/codex-plugin/lib/loom-client.mjs": "4002ed3ecd815258eca4904aede0e549579eeb1069ed59ea425ecb252fa59e78", @@ -422,7 +422,7 @@ "sdk/python/loom/integrations/langgraph.py": "5d68e6ab1645d868477a13b14aa6d734c72f72057464cac9a21aa707add17e7b", "sdk/python/loom/integrations/llamaindex.py": "06eaa071115cad752d27bdc9bf7c4d5b6f5d7d39d9896267fcd459a4e06bf661", "sdk/python/loom/integrations/openai_agents.py": "143fe1df060b96550a33f77fa44416e291c2154552e433f8309275f61c8fca2a", - "sdk/python/loom/memory.py": "9de078f3ad992f7d0d8b0f3b88737393d84564413b336c474580ced0da7f6625", + "sdk/python/loom/memory.py": "0cf1ee9e997a2368f6f2ecbdab50116b6ce0c3469ee875f20fd8b6c295931b82", "sdk/python/loom/run.py": "1d47d5f4d197f78de347d2cf66b9f59f4292846d214f7116c444035971c6ab42", "sdk/python/loom/session.py": "5f0fd61fcfdbf9d60888b111887fca8f32e24eb51ca9ff04a256901657c3202b", "sdk/typescript/src/integrations/claude-memory.ts": "c846f0011d7cf1ba4b30e99fbfd8adb6b29abff56856d0dbe14fba620007f6bc", From f68ee4da53a27ca32377fc64d149fd978ce9ca76 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Sun, 29 Nov 2026 14:21:58 +0530 Subject: [PATCH 3/6] Extraction refusal checks include changed-file data File paths and timestamps come from the caller and can enter the extraction queue. Classify both values as transcript content so intake and erasure use the same refusal checks. Signed-off-by: Lareb Zafar --- server/memory/domain/refusals.py | 5 +++++ tests/unit/test_memory_refusals.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/server/memory/domain/refusals.py b/server/memory/domain/refusals.py index df6ffe59c17..cc170bf21cd 100644 --- a/server/memory/domain/refusals.py +++ b/server/memory/domain/refusals.py @@ -85,6 +85,7 @@ def matches(value: Any, patterns: Iterable[Fingerprint]) -> bool: "messages", "last_messages", "session_values", + "changed_files", "extra_tags", "recalled_keys", "extraction_instructions", @@ -148,6 +149,10 @@ def transcript_content(payload: Mapping[str, Any]) -> list[Any]: result.append(role) for field in ("session_values", "extra_tags", "recalled_keys"): result.extend(payload.get(field) or []) + for changed_file in payload.get("changed_files") or []: + result.extend( + changed_file[field] for field in ("path", "modified_at") if changed_file.get(field) + ) for field in ("extraction_instructions", "observation_date", "memory_key"): if payload.get(field): result.append(payload[field]) diff --git a/tests/unit/test_memory_refusals.py b/tests/unit/test_memory_refusals.py index df201ec8649..6856af5804d 100644 --- a/tests/unit/test_memory_refusals.py +++ b/tests/unit/test_memory_refusals.py @@ -290,6 +290,14 @@ def test_every_extraction_field_has_an_explicit_content_classification(): [ ("extraction_instructions", "retired copper lark"), ("session_values", ["retired copper lark"]), + ( + "changed_files", + [{"path": "retired copper lark", "modified_at": "2025-01-01T12:00:00Z"}], + ), + ( + "changed_files", + [{"path": "source/module.py", "modified_at": "retired copper lark"}], + ), ("extra_tags", ["retired copper lark"]), ("recalled_keys", ["retired copper lark"]), ("record_schema", {"choice": ["retired copper lark"]}), From f28dd5b57e05aa071e590e7c2e242c8f9a0a03e0 Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Mon, 30 Nov 2026 06:10:23 +0530 Subject: [PATCH 4/6] Conflict resolver tests cover assertion order at equal standing Attesting the restored row raises its standing. Attest the successor earlier to preserve the retirement assertion. Keep the lower-standing case as a check that the pair stays in conflict. Signed-off-by: Lareb Zafar --- .../integration/test_conflict_resolver_ch.py | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_conflict_resolver_ch.py b/tests/integration/test_conflict_resolver_ch.py index 8be366cf3c5..ce70f2fbb17 100644 --- a/tests/integration/test_conflict_resolver_ch.py +++ b/tests/integration/test_conflict_resolver_ch.py @@ -3139,10 +3139,14 @@ async def clear(**kw: Any) -> ConflictResult: assert rows["office_location"]["superseded_by"] == rows["office_city"]["id"] -async def test_an_attest_of_a_retired_row_keeps_its_first_assertion(ch, wired, monkeypatch) -> None: - """Paris retired by Rome, Berlin written; a person attests the retired Paris row (a - copy, still retired), then undoes it. Paris was stated before Berlin, and Berlin's - update retires it.""" +@pytest.mark.parametrize( + "attest_successor", [True, False], ids=["equal-standing", "lower-standing"] +) +async def test_an_attest_of_a_retired_row_keeps_its_first_assertion( + ch, wired, monkeypatch, attest_successor: bool +) -> None: + """The restored Paris row predates Berlin even when attested later. Berlin retires + Paris at equal standing and flags it at lower standing.""" from server.memory.api.models_crud import MemoryVerifyInput from server.memory.app import after_write, conflicts from server.memory.app.verify import handle_memory_verify @@ -3162,6 +3166,18 @@ async def clear(**kw: Any) -> ConflictResult: await _set(org, "s3", "office_site", "The office is in Berlin") await after_write.drain() await _place(ch, org, "s3", "office_site", _vec((2140, 0.9), (2142, 0.436)), owed=False) + if attest_successor: + await handle_memory_verify( + MemoryVerifyInput( + org=org, + namespace=NS, + agent="bot", + user_id=USER, + session_id="s3", + memory_key="office_site", + actor="human:alice", + ) + ) await _later() await handle_memory_verify( MemoryVerifyInput( @@ -3181,7 +3197,13 @@ async def clear(**kw: Any) -> ConflictResult: monkeypatch.setitem(_SCRIPT, "office_site", ("update", 0.98)) out = await run_pass() rows = await _rows(ch, org) - assert rows["office_city"]["superseded_by"] == rows["office_site"]["id"], out + paris, berlin = rows["office_city"], rows["office_site"] + if attest_successor: + assert paris["superseded_by"] == berlin["id"], out + else: + assert paris["status"] == berlin["status"] == "conflicted", out + assert paris["superseded_by"] == "" + assert berlin["id"] in {str(peer) for peer in paris["conflict_with"]} async def test_an_undo_whose_insert_answer_was_lost_finishes(ch, wired, monkeypatch) -> None: From 55217733ce7c203160094b57e14e2e4d08784aef Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Mon, 30 Nov 2026 16:13:31 +0530 Subject: [PATCH 5/6] Conflict fixture waits for verification mirrors Finish background embedding copies before marking the test row pending so writes cannot share a replacement version. Signed-off-by: Lareb Zafar --- tests/integration/test_conflict_resolver_ch.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/test_conflict_resolver_ch.py b/tests/integration/test_conflict_resolver_ch.py index ce70f2fbb17..a0c448313bf 100644 --- a/tests/integration/test_conflict_resolver_ch.py +++ b/tests/integration/test_conflict_resolver_ch.py @@ -3193,6 +3193,7 @@ async def clear(**kw: Any) -> ConflictResult: assert (await _rows(ch, org))["office_city"]["status"] == "superseded" winner = (await _rows(ch, org))["office_location"]["id"] assert (await _undo(org, "office_city", winner)).restored + await after_write.drain() await _place(ch, org, "s3", "office_site", _vec((2140, 0.9), (2142, 0.436)), owed=True) monkeypatch.setitem(_SCRIPT, "office_site", ("update", 0.98)) out = await run_pass() From e3e7b87c543eeafc33320dd4a7fce9b4b842fd6e Mon Sep 17 00:00:00 2001 From: Lareb Zafar Date: Mon, 30 Nov 2026 16:16:31 +0530 Subject: [PATCH 6/6] Conflict fixture verifies its mirror writes have finished Fail at the synchronization boundary if the test times out waiting for verification instead of letting pending writes race the fixture. Signed-off-by: Lareb Zafar --- tests/integration/test_conflict_resolver_ch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_conflict_resolver_ch.py b/tests/integration/test_conflict_resolver_ch.py index a0c448313bf..5d81235b56d 100644 --- a/tests/integration/test_conflict_resolver_ch.py +++ b/tests/integration/test_conflict_resolver_ch.py @@ -3193,7 +3193,8 @@ async def clear(**kw: Any) -> ConflictResult: assert (await _rows(ch, org))["office_city"]["status"] == "superseded" winner = (await _rows(ch, org))["office_location"]["id"] assert (await _undo(org, "office_city", winner)).restored - await after_write.drain() + await after_write.drain(timeout_s=60.0) + assert after_write.pending() == 0, "verification mirrors still pending" await _place(ch, org, "s3", "office_site", _vec((2140, 0.9), (2142, 0.436)), owed=True) monkeypatch.setitem(_SCRIPT, "office_site", ("update", 0.98)) out = await run_pass()