From 79d54bbfe2c60f172acde3171446c5aee98b734c Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:02:27 +0530 Subject: [PATCH 001/117] docs: plan use guidance for retrieved knowledge Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- plan.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 plan.md diff --git a/plan.md b/plan.md new file mode 100644 index 00000000000..b6d67cec934 --- /dev/null +++ b/plan.md @@ -0,0 +1,12 @@ +# Retrieved knowledge use guidance + +Give agents a deterministic next step for each maintained item they can read. The projection runs after authorization, on the served revision. Ranking, publication and procedure matching keep their existing rules. + +1. Define the pure domain projection and typed output. Keep source class, lifecycle, review requirement, content-bound attestation, source and code freshness, and disputes separately inspectable. Prefer inspect_only, clarify_dispute, recheck_source, obtain_review, validate_lead for unavailable required evidence, then follow_if_applicable for eligible current human review. Other leads remain usable with validation. Emit all applicable reasons in stable order. +2. Wire memory.search first, including first-page tiers and parked pages. Use exact identities and revisions from the active authority. Withhold inaccessible or erased artifacts. Treat missing optional evidence as unknown. Keep computed guidance out of shared caches. +3. Once the contract is fixed, propagate through unified search, authorized document reads, memory.for_file and code lessons. Preserve structured guidance in HTTP, SDK and MCP output, including compact representations. +4. Carry guidance for the actually served citations through context assembly, startup, decisions, procedures and stacks. Preserve source publication and budget boundaries. +5. Show the server decision and reasons in dashboard search. Document precedence, unknown states, and host policy responsibilities. Regenerate SDKs, operation references and reach inventory. +6. Verify the decision table, revision and scope parity, access revocation, edits, erasure, pagination, rendering and client compatibility. Use isolated dependencies and a private database for live checks. + +Sol workers implement and verify the memory read path, file and document adapters, context and clients in dependency order. Keep public issue and pull request actions separate from local implementation. From 180ecb64a703df00932ba5fddf8ddac73161efd6 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:02:27 +0530 Subject: [PATCH 002/117] feat: return revision-bound use guidance on knowledge reads Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- .../features/memory/history-and-provenance.md | 29 + .../memory/procedures-and-learnings.md | 2 + docs/features/memory/search-and-ask.md | 2 + docs/features/unified-search.md | 2 + docs/reference/operations/code.md | 18 +- docs/reference/operations/context.md | 1 + docs/reference/operations/search.md | 4 +- scripts/codegen/sdk_py_gen.py | 6 +- scripts/codegen/sdk_rust_gen.py | 6 +- sdk/python/loom/memory.py | 3 + sdk/python/loom/ops.py | 117 +- sdk/python/loom/tools.py | 1 + sdk/rust/src/wire_models.rs | 10400 ++++++++-------- sdk/rust/tests/registry_contracts.rs | 5 + sdk/typescript/src/generated/ops.ts | 82 +- .../src/memory-tool-receipts.test.ts | 9 + sdk/typescript/src/tools.ts | 1 + server/code/api/models_common.py | 5 +- server/code/app/result_lessons.py | 3 +- server/code/app/symbol/symbol.py | 5 +- server/code/domain/lesson.py | 22 + server/code/domain/units.py | 3 +- server/knowledge/api/models_knowledge.py | 2 + server/knowledge/app/document_reads.py | 16 + server/knowledge/app/knowledge_search.py | 6 + server/memory/api/models_context.py | 12 + server/memory/api/models_for_file.py | 2 + server/memory/api/models_lifecycle.py | 2 + server/memory/api/models_loom_search.py | 33 +- server/memory/api/models_procedure.py | 3 + server/memory/api/models_search.py | 5 + server/memory/app/ask/reader_render.py | 5 +- server/memory/app/code_link_reads.py | 54 + server/memory/app/code_plane_reads.py | 24 +- server/memory/app/context_pack.py | 66 +- server/memory/app/for_file.py | 94 +- server/memory/app/path_lessons.py | 2 + server/memory/app/procedure.py | 13 + server/memory/app/search/guidance.py | 231 + server/memory/app/search/output.py | 37 +- server/memory/app/search_pages.py | 12 +- server/memory/app/stack.py | 49 +- server/memory/app/use_guidance.py | 57 + server/memory/domain/context_layout.py | 40 +- server/memory/domain/evidence_pack.py | 7 + server/memory/domain/use_guidance.py | 186 + server/memory/store/code_plane_reads.py | 21 +- server/memory/store/pg_memory.py | 21 + server/memory/store/reads.py | 44 + server/memory/store/shared.py | 26 +- server/transport/lean_results.py | 8 +- server/transport/mcp_tools.py | 27 +- tests/integration/test_code_result_lessons.py | 6 +- .../test_retrieved_use_guidance.py | 49 + tests/unit/test_context_pack_decisions.py | 36 + tests/unit/test_context_pack_served_rows.py | 6 + tests/unit/test_loom_search_repo_decisions.py | 65 + tests/unit/test_mcp_lean_results.py | 50 +- tests/unit/test_memory_code_plane_reads.py | 60 +- tests/unit/test_memory_for_file.py | 30 +- tests/unit/test_pg_authority.py | 45 +- tests/unit/test_procedure_ops.py | 4 + tests/unit/test_rust_search_contract.py | 7 + tests/unit/test_sdk_memory_tool_receipts.py | 7 + tests/unit/test_sdk_py_generated.py | 10 + tests/unit/test_sdk_ts_generated.py | 11 + tests/unit/test_search_pages.py | 17 +- tests/unit/test_search_shared_definitions.py | 14 +- tests/unit/test_search_use_guidance.py | 215 + tests/unit/test_source_checked_pack.py | 18 +- tests/unit/test_term_leg.py | 9 +- tests/unit/test_use_guidance.py | 92 + tests/unit/test_use_guidance_sources.py | 36 + 73 files changed, 7383 insertions(+), 5235 deletions(-) create mode 100644 server/code/domain/lesson.py create mode 100644 server/memory/app/search/guidance.py create mode 100644 server/memory/app/use_guidance.py create mode 100644 server/memory/domain/use_guidance.py create mode 100644 tests/integration/test_retrieved_use_guidance.py create mode 100644 tests/unit/test_search_use_guidance.py create mode 100644 tests/unit/test_use_guidance.py create mode 100644 tests/unit/test_use_guidance_sources.py diff --git a/docs/features/memory/history-and-provenance.md b/docs/features/memory/history-and-provenance.md index 2d66661f153..893110ba196 100644 --- a/docs/features/memory/history-and-provenance.md +++ b/docs/features/memory/history-and-provenance.md @@ -10,6 +10,35 @@ person can attest that a row is true. How the version mirror works is in ## Operations +### Using retrieved guidance + +On a maintained result, `use_guidance.next_step` tells the reader what it can do with +the served revision. `reasons` lists every applicable reason in precedence order. +Inspect `source_class`, `lifecycle`, `review`, `freshness.source`, `freshness.code` +and `dispute` for the underlying facts. The first applicable rule selects the step. + +| Evidence | Next step | +| --- | --- | +| Diagnostic-only lifecycle, including a quarantined procedure | `inspect_only` | +| Visible unresolved dispute | `clarify_dispute` | +| Changed or missing source, or changed, unresolved or missing code | `recheck_source` | +| Pending review or an attestation covering different content | `obtain_review` | +| Unavailable required evidence, or a candidate procedure | `validate_lead` | +| Eligible current content with a matching human attestation and applicable freshness checks satisfied | `follow_if_applicable` | +| Other served claims, including authored claims without review and process-verified claims | `validate_lead` | + +A person or process attests to a content hash. A missing hash gives `unknown`; +a successful read showing no verifier gives `none`. Freshness measures the source +or code the claim describes. A fresh link alone leaves an unreviewed claim a lead. +A reported conflict calls for investigation. When dispute evidence is unavailable, +`dispute` is `unknown`. Optional unknown dispute coverage appears in the reasons. + +Hosts can validate leads against other sources and follow applicable instructions +under their own policy. They choose the answer's audience before retrieval and enforce +the permitted actions. Guidance adds no model call and changes neither publication nor +procedure matching. Older servers and results without a maintained revision may omit +the field. + | Operation | Role | Answers | | -------------------- | ------ | --------------------------------------------------------------------------------------------------------- | | `memory.history` | viewer | Every version of a key, newest first, including tombstoned and redacted versions. | diff --git a/docs/features/memory/procedures-and-learnings.md b/docs/features/memory/procedures-and-learnings.md index dbf7de5e65c..e25bc39b92e 100644 --- a/docs/features/memory/procedures-and-learnings.md +++ b/docs/features/memory/procedures-and-learnings.md @@ -297,3 +297,5 @@ admins, including their queue counts and lineage. Approving one publishes its co value, including supporting SQL, to namespace readers. See [definition drafts](../../architecture/definition-drafts.md) for source setup, review conflicts and interrupted promotion. + +See [Using retrieved guidance](history-and-provenance.md#using-retrieved-guidance) for the next step on a maintained result. diff --git a/docs/features/memory/search-and-ask.md b/docs/features/memory/search-and-ask.md index 2db519dea91..a8fdc8c2760 100644 --- a/docs/features/memory/search-and-ask.md +++ b/docs/features/memory/search-and-ask.md @@ -364,3 +364,5 @@ Per namespace, `namespace.register` sets `retrieval_defaults` (`search_mode`, `t - [Writing memory](./writing.md) - [Runs](../runs.md): reporting which memories a task relied on. - [Performance tuning](../../guides/performance-tuning.md) + +See [Using retrieved guidance](history-and-provenance.md#using-retrieved-guidance) for the next step on a maintained result. diff --git a/docs/features/unified-search.md b/docs/features/unified-search.md index 88a161356bb..c52b089786b 100644 --- a/docs/features/unified-search.md +++ b/docs/features/unified-search.md @@ -279,3 +279,5 @@ The SDK's `Session.offload` / `Session.fetch` wrap the pair for one session. - [Retrieval and ranking](../concepts/retrieval-and-ranking.md): why a hit ranks where it does. - [MCP reference](../reference/mcp.md): toolsets, identity defaults and the code-scope header. - [Tracker](./tracker/overview.md): the duplicate check behind the tracker leg. + +See [Using retrieved guidance](memory/history-and-provenance.md#using-retrieved-guidance) for the next step on a maintained result. diff --git a/docs/reference/operations/code.md b/docs/reference/operations/code.md index 2c2a8c8f046..5fe77b318c8 100644 --- a/docs/reference/operations/code.md +++ b/docs/reference/operations/code.md @@ -291,7 +291,7 @@ What does this symbol call — forward call edges (depth<=3), tier-marked like c | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `edges` | `list[CodeEdgeWire]` | The call-graph edges found, hop by hop; the far end (`from_*` for callers, `to_*` for callees) is the answer. | | `seed_symbols` | `list[str]` | Qualified names of the definitions the walk started from; empty when refused as ambiguous. | @@ -345,7 +345,7 @@ Find callers before editing shared code. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `edges` | `list[CodeEdgeWire]` | The call-graph edges found, hop by hop; the far end (`from_*` for callers, `to_*` for callees) is the answer. | | `seed_symbols` | `list[str]` | Qualified names of the definitions the walk started from; empty when refused as ambiguous. | @@ -390,7 +390,7 @@ Briefing at the START of a task, instead of exploring file by file. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `context` | `str` | The pack as Markdown text; for `unavailable`, a short note saying the PR has no pack yet. | | `tokens_used` | `int` | Estimated tokens of `context`. | @@ -639,7 +639,7 @@ Batched `path:line` -> enclosing function. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `results` | `list[dict[str, Any]]` | one entry per input location, input order preserved: {path, line, symbol, symbol_id, qualified_name, signature, tier, kind, start_line, end_line} kind is "function" / "method" / "fixture" for a line inside a function body; "class"… | | `resolved` | `int` | Locations that landed inside a function, type, or document section. | @@ -786,7 +786,7 @@ Literal or regex search of indexed source with enclosing symbols and coverage. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | File lessons omitted by symbol focus, a token budget, truncation or supersession. | | `matches` | `list[dict[str, Any]]` | {path, line, text, scope, scope_start_line, scope_end_line} per matching LINE, path/line ordered except when prioritize_patterns gives different literals first-page slots. scope_* is the span of the enclosing unit named by `scope` (0/0… | | `related` | `RelatedGrepEvidence \| None` | Related source for a qualified argument or member, separate from literal matches. | @@ -879,7 +879,7 @@ Symbol-shaped (name/symbol_id) or diff-shaped (files/diff) blast radius. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `impacted_symbols` | `list[dict[str, Any]]` | Each row {qualified_name, path, hop, tier}; a row whose function is a registration function (`REGISTER_FUNCTION(X)`, `registerStorageFoo`) carries `via: "registration"` — the seed is reached through a registry; the key is absent otherwise. | | `impacted_tests` | `list[dict[str, Any]]` | Tests the test map ties to the seed and impacted paths: {test_path, src_path, confidence}. | @@ -1056,7 +1056,7 @@ Tell loom what you did with a code answer, by its trace_run_id: 'used_in_answer' | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `path` | `str` | The repo-relative path read, normalised from the request. | | `entries` | `list[dict[str, Any]]` | source order: {kind, qualified_name, signature, start_line, end_line, tier} | @@ -1156,7 +1156,7 @@ Read inclusive, one-based indexed lines. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | How many rows about those files the lessons' token cap or a cut left out, with the rows another row read for the answer supersedes. | | `results` | `list[CodeReadRange]` | | | `as_of` | `dict[str, Any]` | | @@ -1563,7 +1563,7 @@ Find implementations by question, behavior or identifier using `query`. | Output field | Type | Meaning | | --- | --- | --- | -| `lessons` | `list[dict[str, Any]]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | +| `lessons` | `list[CodeLesson]` | The memories about the answer's top files, best first, capped at `code_result_lessons_tokens`; each row {path, memory_key, namespace, excerpt, code_state}, with `changed_since` and `supersedes_key` when they apply. | | `lessons_left_out` | `int` | File lessons omitted by symbol focus, a token budget, truncation or supersession. | | `results` | `list[CodeUnit]` | The ranked units served on this page, cut to top_k and the token budget; empty on an abstain with no pool or a not-covered path. | | `route` | `str` | symbol_exact \| hybrid \| symbol_miss_hybrid | diff --git a/docs/reference/operations/context.md b/docs/reference/operations/context.md index ad586ba915c..59a39e70759 100644 --- a/docs/reference/operations/context.md +++ b/docs/reference/operations/context.md @@ -109,6 +109,7 @@ Retrieve task context by passing the task as `query`. | `rendered` | `str` | The pack as one text: each non-empty section in a `` tag, in block order, cut to `token_budget`. | | `sections` | `dict[str, str]` | Each section's body by name, in block order; sections that rendered nothing are absent. | | `blocks` | `list[ContextBlock]` | One entry per non-empty section: label, body, token estimate, citations, source count, and `priority` (its position in block order). | +| `use_guidance` | `list[ContextUseGuidance]` | Guidance for the cited items retained in the rendered pack. | | `section_meta` | `dict[str, dict[str, Any]]` | Per-section details by name: source count, citations, whether it was cut, its size, its token budget and fill ratio (above 1.0 means it was cut). | | `section_count` | `int` | How many sections rendered something. | | `truncated` | `bool` | True when any section, or the whole pack, was cut to its budget. | diff --git a/docs/reference/operations/search.md b/docs/reference/operations/search.md index 01c039e5d2c..cba349025e4 100644 --- a/docs/reference/operations/search.md +++ b/docs/reference/operations/search.md @@ -33,8 +33,8 @@ Search every plane of the caller's Loom content in one call. | --- | --- | --- | | `tracker` | `dict[str, Any] \| None` | Cited issue/PR matches, or a duplicate-check verdict for a scoped defect report even with no matches; absent for empty general search or an unavailable, failed or timed-out tracker leg. | | `live` | `LiveSearchResults \| None` | Ephemeral connected-source hits; absent unless the optional live leg answered. | -| `memory` | `dict[str, Any]` | The `memory.search` result plus the scoped repository's decisions, rendered as a reader block, without the hits the calibration flagged below its threshold (unless every hit is flagged). | -| `knowledge` | `dict[str, Any]` | The `knowledge.search` result plus the scoped repository's documents, hits below the knowledge similarity floor dropped. | +| `memory` | `SearchSection` | The `memory.search` result plus the scoped repository's decisions, rendered as a reader block, without the hits the calibration flagged below its threshold (unless every hit is flagged). | +| `knowledge` | `SearchSection` | The `knowledge.search` result plus the scoped repository's documents, hits below the knowledge similarity floor dropped. | | `profile` | `dict[str, Any]` | Profile sections whose label or text matches the query words, then by meaning. | | `conversations` | `dict[str, Any]` | The `conversation.search` hits under `results`. | | `withheld` | `dict[str, Any] \| None` | Counts of hits held back per section by the answer-first rules, with `reason`; absent when nothing was withheld or `explain` is set. | diff --git a/scripts/codegen/sdk_py_gen.py b/scripts/codegen/sdk_py_gen.py index 57af0d61709..ef09f216e37 100644 --- a/scripts/codegen/sdk_py_gen.py +++ b/scripts/codegen/sdk_py_gen.py @@ -113,8 +113,10 @@ def _typed_dict( ) -> str: props = schema.get("properties") or {} required = set(schema.get("required") or []) - optional - if not props: - addl = schema.get("additionalProperties") + addl = schema.get("additionalProperties") + # An explicit unconstrained extra-key schema is a dictionary. Python's + # supported TypedDict cannot allow unlisted keys in typed access. + if not props or addl == {}: inner = self.render(addl) if isinstance(addl, dict) else "Any" return f"{name} = dict[str, {inner}]" if any(not k.isidentifier() or keyword.iskeyword(k) for k in props): diff --git a/scripts/codegen/sdk_rust_gen.py b/scripts/codegen/sdk_rust_gen.py index f3f9b23bb85..a3b111c9b65 100644 --- a/scripts/codegen/sdk_rust_gen.py +++ b/scripts/codegen/sdk_rust_gen.py @@ -292,10 +292,14 @@ def wire_type(self, schema: dict[str, Any], hint: str) -> str: if not ref.startswith("#/$defs/") or ref[8:] not in self.defs: raise ValueError(f"{hint}: unresolved ref {ref}") key = ref[8:] + definition = self.defs[key] + if definition.get("additionalProperties") == {} and not definition.get("required"): + # Keep sparse, open sections accessible by key and preserve every wire field. + return "std::collections::HashMap" name = self.ref_names.get(key, type_name(key)) if name in self.active: raise ValueError(f"{hint}: recursive ref {ref}") - self.model(name, self.defs[key], request=self.request) + self.model(name, definition, request=self.request) return name base, nullable = split_nullable(schema) if nullable and base != schema: diff --git a/sdk/python/loom/memory.py b/sdk/python/loom/memory.py index 816de7822a1..a55d7863d5c 100644 --- a/sdk/python/loom/memory.py +++ b/sdk/python/loom/memory.py @@ -30,6 +30,7 @@ if TYPE_CHECKING: from loom.agent import Agent + from loom.ops import UseGuidance # Free-form string. The default taxonomy is episodic/semantic/procedural/ # preference, but namespaces with a registered tag_registry accept any name. @@ -454,6 +455,7 @@ class MemorySearchHit: source_class: str = "" source_resource_id: str = "" verified: bool = False + use_guidance: UseGuidance | None = field(default=None, kw_only=True) # The identity axes the row was written under, when the server read them. agent: str = field(default="", kw_only=True) user_id: str = "" @@ -647,6 +649,7 @@ def _parse_search_hit(r: dict[str, Any]) -> MemorySearchHit: source_class=str(r.get("source_class") or ""), source_resource_id=str(r.get("source_resource_id") or ""), verified=bool(r.get("verified") or False), + use_guidance=r.get("use_guidance"), agent=str(r.get("agent") or ""), user_id=str(r.get("user_id") or ""), session_id=str(r.get("session_id") or ""), diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 4e3de3dcbd8..93f428fc6ac 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -5999,7 +5999,7 @@ class CodeCallersBody(TypedDict, total=False): class CodeCallersOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] edges: Required[list["CodeEdgeWire"]] seed_symbols: Required[list[str]] @@ -6023,6 +6023,85 @@ class CodeCallersOutput(TypedDict, total=False): trace_run_id: NotRequired[str] +class CodeLesson(TypedDict, total=False): + memory_key: NotRequired[str] + namespace: NotRequired[str] + excerpt: NotRequired[str] + code_state: NotRequired[str] + path: NotRequired[str] + changed_since: NotRequired[str] + supersedes_key: NotRequired[str] + suggestion: NotRequired[str] + owner_symbol: NotRequired[str] + use_guidance: NotRequired["UseGuidance"] + + +class UseGuidance(TypedDict, total=False): + next_step: Required[ + Literal[ + "inspect_only", + "clarify_dispute", + "recheck_source", + "obtain_review", + "validate_lead", + "follow_if_applicable", + ] + ] + reasons: Required[ + list[ + Literal[ + "diagnostic_only", + "dispute_unresolved", + "source_recheck_needed", + "code_recheck_needed", + "review_pending", + "review_hash_mismatch", + "required_evidence_unknown", + "procedure_candidate", + "human_review_current", + "process_review_current", + "no_attestation", + "review_unknown", + "source_asserted", + "source_unchanged", + "code_unchanged", + "freshness_unknown", + "dispute_unknown", + ] + ] + ] + source_class: Required[ + Literal["asserted", "extracted", "observed", "derived", "imported", "external", "unknown"] + ] + lifecycle: Required["GuidanceLifecycle"] + review: Required[Literal["human", "process", "stale", "none", "unknown"]] + freshness: Required["GuidanceFreshness"] + dispute: Required[Literal["unresolved", "none", "unknown"]] + + +class GuidanceLifecycle(TypedDict, total=False): + status: Required[str] + procedure_status: Required[ + Literal[ + "candidate", + "exercised", + "authored", + "quarantined", + "template", + "not_applicable", + "unknown", + ] + ] + review_requirement: Required[Literal["pending", "none", "unknown"]] + + +class GuidanceFreshness(TypedDict, total=False): + source: Required[Literal["unchanged", "changed", "missing", "not_applicable", "unknown"]] + code: Required[ + Literal["fresh", "moved", "changed", "unresolved", "missing", "not_applicable", "unknown"] + ] + + class CodeEdgeWire(TypedDict, total=False): edge_kind: Required[str] from_symbol: Required[str] @@ -6104,7 +6183,7 @@ class CodeContextPackBody(TypedDict, total=False): class CodeContextPackOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] context: Required[str] tokens_used: Required[int] @@ -6467,7 +6546,7 @@ class CodeUnit(TypedDict, total=False): score: NotRequired[float] recent_prs: NotRequired[list[dict[str, Any]]] examples: NotRequired[list[dict[str, Any]]] - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_unread: NotRequired[bool] churn: NotRequired[int] amp: NotRequired[int] @@ -6530,7 +6609,7 @@ class CodeEnclosingBody(TypedDict, total=False): class CodeEnclosingOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] results: Required[list[dict[str, Any]]] resolved: Required[int] @@ -6729,7 +6808,7 @@ class CodeGrepBody(TypedDict, total=False): class CodeGrepOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] matches: Required[list[dict[str, Any]]] related: NotRequired[Optional["RelatedGrepEvidence"]] @@ -6874,7 +6953,7 @@ class CodeImpactBody(TypedDict, total=False): class CodeImpactOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] impacted_symbols: Required[list[dict[str, Any]]] impacted_tests: Required[list[dict[str, Any]]] @@ -7141,7 +7220,7 @@ class CodeOutlineBody(TypedDict, total=False): class CodeOutlineOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] path: Required[str] entries: Required[list[dict[str, Any]]] @@ -7280,7 +7359,7 @@ class CodeReadBody(TypedDict, total=False): class CodeReadOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] results: Required[list["CodeReadRange"]] as_of: Required[dict[str, Any]] @@ -7888,7 +7967,7 @@ class CodeSearchBody(TypedDict, total=False): class CodeSearchOutput(TypedDict, total=False): - lessons: NotRequired[list[dict[str, Any]]] + lessons: NotRequired[list["CodeLesson"]] lessons_left_out: NotRequired[int] results: Required[list["CodeUnit"]] route: Required[str] @@ -8840,6 +8919,7 @@ class ContextPackOutput(TypedDict, total=False): rendered: Required[str] sections: Required[dict[str, str]] blocks: NotRequired[list["ContextBlock"]] + use_guidance: NotRequired[list["ContextUseGuidance"]] section_meta: NotRequired[dict[str, dict[str, Any]]] section_count: Required[int] truncated: NotRequired[bool] @@ -8865,6 +8945,13 @@ class ContextBlock(TypedDict, total=False): source_count: NotRequired[int] +class ContextUseGuidance(TypedDict, total=False): + section: Required[str] + citation: Required[str] + item_index: Required[int] + use_guidance: Required["UseGuidance"] + + class ConversationAppendInput(TypedDict, total=False): org: Required[str] namespace: Required[str] @@ -11871,6 +11958,7 @@ class KnowledgeSearchOutput(TypedDict, total=False): class SearchHit(TypedDict, total=False): + use_guidance: NotRequired[Optional["UseGuidance"]] source_uri: Required[str] chunk_idx: Required[int] content: Required[str] @@ -13026,6 +13114,7 @@ class MemorySearchHit(TypedDict, total=False): source_resource_id: NotRequired[str] source_class: NotRequired[str] verified: NotRequired[bool] + use_guidance: NotRequired[Optional["UseGuidance"]] explanation: NotRequired[str] session_id: NotRequired[str] speaker: NotRequired[str] @@ -14140,6 +14229,7 @@ class MemoryForFileHit(TypedDict, total=False): code_state: NotRequired[ Union[Literal["fresh", "moved", "changed", "unresolved", "missing"], Literal[""]] ] + use_guidance: NotRequired[Optional["UseGuidance"]] class MemoryGetInput(TypedDict, total=False): @@ -16431,6 +16521,7 @@ class MemoryStackOutput(TypedDict, total=False): class StackEntry(TypedDict, total=False): + use_guidance: NotRequired[Optional["UseGuidance"]] section: Required[Literal["profile", "pinned", "recent_recall", "procedure", "knowledge"]] memory_key: NotRequired[str] memory_type: NotRequired[str] @@ -18828,6 +18919,7 @@ class ProcedureMatchOutput(TypedDict, total=False): class ProcedureMatch(TypedDict, total=False): + use_guidance: NotRequired[Optional["UseGuidance"]] name: Required[str] situation: Required[str] steps: Required[list[str]] @@ -19449,8 +19541,8 @@ class SearchQueryOutput(TypedDict, total=False): tracker: NotRequired[Optional[dict[str, Any]]] live: NotRequired[Optional["LiveSearchResults"]] - memory: NotRequired[dict[str, Any]] - knowledge: NotRequired[dict[str, Any]] + memory: NotRequired["SearchSection"] + knowledge: NotRequired["SearchSection"] profile: NotRequired[dict[str, Any]] conversations: NotRequired[dict[str, Any]] withheld: NotRequired[Optional[dict[str, Any]]] @@ -19475,6 +19567,9 @@ class LiveSearchHit(TypedDict, total=False): live: NotRequired[Literal[True]] +SearchSection = dict[str, Any] + + class SessionBriefDeleteInput(TypedDict, total=False): org: Required[str] namespace: Required[str] diff --git a/sdk/python/loom/tools.py b/sdk/python/loom/tools.py index da22f2eaae3..00e8d94f55b 100644 --- a/sdk/python/loom/tools.py +++ b/sdk/python/loom/tools.py @@ -63,6 +63,7 @@ "source_class", "source_resource_id", "verified", + "use_guidance", "valid_at", "created_at", "below_threshold", diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index d1619b6758c..d161d96397e 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -1984,6 +1984,207 @@ pub struct ContextBlock { pub source_count: Integer, } +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum UseGuidanceNextStep { + #[serde(rename = "inspect_only")] + InspectOnly, + #[serde(rename = "clarify_dispute")] + ClarifyDispute, + #[serde(rename = "recheck_source")] + RecheckSource, + #[serde(rename = "obtain_review")] + ObtainReview, + #[serde(rename = "validate_lead")] + ValidateLead, + #[serde(rename = "follow_if_applicable")] + FollowIfApplicable, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum UseGuidanceReasonsItem { + #[serde(rename = "diagnostic_only")] + DiagnosticOnly, + #[serde(rename = "dispute_unresolved")] + DisputeUnresolved, + #[serde(rename = "source_recheck_needed")] + SourceRecheckNeeded, + #[serde(rename = "code_recheck_needed")] + CodeRecheckNeeded, + #[serde(rename = "review_pending")] + ReviewPending, + #[serde(rename = "review_hash_mismatch")] + ReviewHashMismatch, + #[serde(rename = "required_evidence_unknown")] + RequiredEvidenceUnknown, + #[serde(rename = "procedure_candidate")] + ProcedureCandidate, + #[serde(rename = "human_review_current")] + HumanReviewCurrent, + #[serde(rename = "process_review_current")] + ProcessReviewCurrent, + #[serde(rename = "no_attestation")] + NoAttestation, + #[serde(rename = "review_unknown")] + ReviewUnknown, + #[serde(rename = "source_asserted")] + SourceAsserted, + #[serde(rename = "source_unchanged")] + SourceUnchanged, + #[serde(rename = "code_unchanged")] + CodeUnchanged, + #[serde(rename = "freshness_unknown")] + FreshnessUnknown, + #[serde(rename = "dispute_unknown")] + DisputeUnknown, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum UseGuidanceSourceClass { + #[serde(rename = "asserted")] + Asserted, + #[serde(rename = "extracted")] + Extracted, + #[serde(rename = "observed")] + Observed, + #[serde(rename = "derived")] + Derived, + #[serde(rename = "imported")] + Imported, + #[serde(rename = "external")] + External, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GuidanceLifecycleProcedureStatus { + #[serde(rename = "candidate")] + Candidate, + #[serde(rename = "exercised")] + Exercised, + #[serde(rename = "authored")] + Authored, + #[serde(rename = "quarantined")] + Quarantined, + #[serde(rename = "template")] + Template, + #[serde(rename = "not_applicable")] + NotApplicable, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GuidanceLifecycleReviewRequirement { + #[serde(rename = "pending")] + Pending, + #[serde(rename = "none")] + None, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GuidanceLifecycle { + pub status: String, + pub procedure_status: GuidanceLifecycleProcedureStatus, + pub review_requirement: GuidanceLifecycleReviewRequirement, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum UseGuidanceReview { + #[serde(rename = "human")] + Human, + #[serde(rename = "process")] + Process, + #[serde(rename = "stale")] + Stale, + #[serde(rename = "none")] + None, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GuidanceFreshnessSource { + #[serde(rename = "unchanged")] + Unchanged, + #[serde(rename = "changed")] + Changed, + #[serde(rename = "missing")] + Missing, + #[serde(rename = "not_applicable")] + NotApplicable, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum GuidanceFreshnessCode { + #[serde(rename = "fresh")] + Fresh, + #[serde(rename = "moved")] + Moved, + #[serde(rename = "changed")] + Changed, + #[serde(rename = "unresolved")] + Unresolved, + #[serde(rename = "missing")] + Missing, + #[serde(rename = "not_applicable")] + NotApplicable, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct GuidanceFreshness { + pub source: GuidanceFreshnessSource, + pub code: GuidanceFreshnessCode, +} + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[non_exhaustive] +pub enum UseGuidanceDispute { + #[serde(rename = "unresolved")] + Unresolved, + #[serde(rename = "none")] + None, + #[serde(rename = "unknown")] + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct UseGuidance { + pub next_step: UseGuidanceNextStep, + pub reasons: Vec, + pub source_class: UseGuidanceSourceClass, + pub lifecycle: GuidanceLifecycle, + pub review: UseGuidanceReview, + pub freshness: GuidanceFreshness, + pub dispute: UseGuidanceDispute, +} + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct ContextUseGuidance { + pub section: String, + pub citation: String, + pub item_index: Integer, + pub use_guidance: UseGuidance, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ContextPackOutput { @@ -1992,26 +2193,28 @@ pub struct ContextPackOutput { #[serde(default = "default_4")] pub blocks: Vec, #[serde(default = "default_5")] + pub use_guidance: Vec, + #[serde(default = "default_6")] pub section_meta: std::collections::HashMap>, pub section_count: Integer, - #[serde(default = "default_6")] + #[serde(default = "default_7")] pub truncated: bool, pub token_budget: Integer, - #[serde(default = "default_7")] - pub mode: String, #[serde(default = "default_8")] - pub tokens_estimate: Integer, + pub mode: String, #[serde(default = "default_9")] - pub fill_ratio: f64, + pub tokens_estimate: Integer, #[serde(default = "default_10")] - pub stable_sections: Vec, + pub fill_ratio: f64, #[serde(default = "default_11")] - pub stable_prefix_chars: Integer, + pub stable_sections: Vec, #[serde(default = "default_12")] - pub stable_hash: String, + pub stable_prefix_chars: Integer, #[serde(default = "default_13")] - pub procedure_keys: Vec, + pub stable_hash: String, #[serde(default = "default_14")] + pub procedure_keys: Vec, + #[serde(default = "default_15")] pub procedure_keys_withheld: Vec, } @@ -2358,9 +2561,9 @@ pub struct KnowledgeAddOutput { pub chunks_created: Integer, pub embedding_model: String, pub embedding_dim: Integer, - #[serde(default = "default_15")] - pub namespace: String, #[serde(default = "default_16")] + pub namespace: String, + #[serde(default = "default_17")] pub source_uri: String, } @@ -2531,27 +2734,27 @@ impl KnowledgeAddInput { pub struct KnowledgeGetOutput { pub found: bool, pub source_uri: String, - #[serde(default = "default_17")] - pub title: Option, #[serde(default = "default_18")] - pub content: Option, + pub title: Option, #[serde(default = "default_19")] - pub tags: Option>, + pub content: Option, #[serde(default = "default_20")] - pub metadata: Option>, + pub tags: Option>, #[serde(default = "default_21")] - pub ingested_at: Option, + pub metadata: Option>, #[serde(default = "default_22")] - pub superseded: Option, + pub ingested_at: Option, #[serde(default = "default_23")] - pub doc_id: Option, + pub superseded: Option, #[serde(default = "default_24")] - pub revision: Option, + pub doc_id: Option, #[serde(default = "default_25")] - pub format: Option, + pub revision: Option, #[serde(default = "default_26")] - pub parser: Option, + pub format: Option, #[serde(default = "default_27")] + pub parser: Option, + #[serde(default = "default_28")] pub coverage: Option>, } @@ -2611,53 +2814,55 @@ impl KnowledgeGetInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSearchHit { + #[serde(default = "default_29")] + pub use_guidance: Option, pub source_uri: String, pub chunk_idx: Integer, pub content: String, pub tags: Vec, pub distance: f64, pub similarity: f64, - #[serde(default = "default_28")] + #[serde(default = "default_30")] pub namespace: String, - #[serde(default = "default_29")] + #[serde(default = "default_31")] pub ingested_at: Option, - #[serde(default = "default_30")] + #[serde(default = "default_32")] pub section_path: Vec, - #[serde(default = "default_31")] + #[serde(default = "default_33")] pub section: String, - #[serde(default = "default_32")] + #[serde(default = "default_34")] pub lexical_score: f64, - #[serde(default = "default_33")] + #[serde(default = "default_35")] pub score: f64, - #[serde(default = "default_34")] + #[serde(default = "default_36")] pub source: String, - #[serde(default = "default_35")] + #[serde(default = "default_37")] pub span: String, - #[serde(default = "default_36")] + #[serde(default = "default_38")] pub span_start: Integer, - #[serde(default = "default_37")] + #[serde(default = "default_39")] pub span_end: Integer, - #[serde(default = "default_38")] + #[serde(default = "default_40")] pub span_similarity: f64, - #[serde(default = "default_39")] + #[serde(default = "default_41")] pub siblings_folded: Integer, - #[serde(default = "default_40")] + #[serde(default = "default_42")] pub agent: String, - #[serde(default = "default_41")] + #[serde(default = "default_43")] pub session_id: String, - #[serde(default = "default_42")] + #[serde(default = "default_44")] pub source_class: String, - #[serde(default = "default_43")] + #[serde(default = "default_45")] pub revision: Integer, - #[serde(default = "default_44")] + #[serde(default = "default_46")] pub format: String, - #[serde(default = "default_45")] + #[serde(default = "default_47")] pub block_type: String, - #[serde(default = "default_46")] + #[serde(default = "default_48")] pub locator: Option>, - #[serde(default = "default_47")] + #[serde(default = "default_49")] pub keys_matched: Vec, - #[serde(default = "default_48")] + #[serde(default = "default_50")] pub noise: bool, } @@ -2665,12 +2870,12 @@ pub struct KnowledgeSearchHit { #[non_exhaustive] pub struct KnowledgeSearchOutput { pub results: Vec, - #[serde(default = "default_49")] + #[serde(default = "default_51")] pub reranked_by: String, pub embedding_model: String, - #[serde(default = "default_50")] + #[serde(default = "default_52")] pub namespaces_skipped: Vec, - #[serde(default = "default_51")] + #[serde(default = "default_53")] pub stale_dropped: Integer, } @@ -2913,11 +3118,11 @@ impl KnowledgeSearchInput { pub struct MemoryDeleteOutput { pub tombstoned: bool, pub version: u64, - #[serde(default = "default_52")] + #[serde(default = "default_54")] pub found: bool, - #[serde(default = "default_53")] + #[serde(default = "default_55")] pub dependents_tombstoned: Integer, - #[serde(default = "default_54")] + #[serde(default = "default_56")] pub dependents_downgraded: Integer, } @@ -3027,12 +3232,12 @@ pub enum CodeLinkState { pub struct CodeLink { pub code_namespace: String, pub path: String, - #[serde(default = "default_55")] + #[serde(default = "default_57")] pub symbol: String, pub state: CodeLinkState, - #[serde(default = "default_56")] + #[serde(default = "default_58")] pub changed_since: String, - #[serde(default = "default_57")] + #[serde(default = "default_59")] pub suggestion: String, } @@ -3041,7 +3246,7 @@ pub struct CodeLink { pub struct RecallByAgent { pub agent: String, pub count: Integer, - #[serde(default = "default_58")] + #[serde(default = "default_60")] pub last_at: Option, } @@ -3501,83 +3706,85 @@ pub struct MemorySearchHit { pub content_excerpt: String, pub distance: f64, pub similarity: f64, - #[serde(default = "default_59")] + #[serde(default = "default_61")] pub below_threshold: Option, - #[serde(default = "default_60")] + #[serde(default = "default_62")] pub governed: Option, - #[serde(default = "default_61")] + #[serde(default = "default_63")] pub tags: Option>, - #[serde(default = "default_62")] + #[serde(default = "default_64")] pub reinforcement_count: Option, - #[serde(default = "default_63")] + #[serde(default = "default_65")] pub used_count: Option, - #[serde(default = "default_64")] + #[serde(default = "default_66")] pub used_cited_count: Option, - #[serde(default = "default_65")] + #[serde(default = "default_67")] pub harm_count: Option, - #[serde(default = "default_66")] + #[serde(default = "default_68")] pub evidence_count: Option, - #[serde(default = "default_67")] + #[serde(default = "default_69")] pub acted_count: Option, - #[serde(default = "default_68")] + #[serde(default = "default_70")] pub pinned: Option, - #[serde(default = "default_69")] + #[serde(default = "default_71")] pub rank_score: f64, - #[serde(default = "default_70")] + #[serde(default = "default_72")] pub temporal_anchor: String, - #[serde(default = "default_71")] + #[serde(default = "default_73")] pub temporal_confidence: f64, - #[serde(default = "default_72")] + #[serde(default = "default_74")] pub valid_at: String, - #[serde(default = "default_73")] + #[serde(default = "default_75")] pub via_path: Vec, - #[serde(default = "default_74")] + #[serde(default = "default_76")] pub entities: Vec, - #[serde(default = "default_75")] + #[serde(default = "default_77")] pub agent: String, - #[serde(default = "default_76")] + #[serde(default = "default_78")] pub user_id: String, - #[serde(default = "default_77")] + #[serde(default = "default_79")] pub source: String, - #[serde(default = "default_78")] + #[serde(default = "default_80")] pub parent_memory_key: String, - #[serde(default = "default_79")] + #[serde(default = "default_81")] pub status: String, - #[serde(default = "default_80")] + #[serde(default = "default_82")] pub superseded_by: Option, - #[serde(default = "default_81")] + #[serde(default = "default_83")] pub superseded_at: Option, - #[serde(default = "default_82")] + #[serde(default = "default_84")] pub version: u64, - #[serde(default = "default_83")] + #[serde(default = "default_85")] pub created_at: String, - #[serde(default = "default_84")] + #[serde(default = "default_86")] pub namespace: String, - #[serde(default = "default_85")] + #[serde(default = "default_87")] pub code_state: String, - #[serde(default = "default_86")] + #[serde(default = "default_88")] pub body_truncated: bool, - #[serde(default = "default_87")] + #[serde(default = "default_89")] pub next: String, - #[serde(default = "default_88")] + #[serde(default = "default_90")] pub source_resource_id: String, - #[serde(default = "default_89")] + #[serde(default = "default_91")] pub source_class: String, - #[serde(default = "default_90")] + #[serde(default = "default_92")] pub verified: bool, - #[serde(default = "default_91")] + #[serde(default = "default_93")] + pub use_guidance: Option, + #[serde(default = "default_94")] pub explanation: String, - #[serde(default = "default_92")] + #[serde(default = "default_95")] pub session_id: String, - #[serde(default = "default_93")] + #[serde(default = "default_96")] pub speaker: String, - #[serde(default = "default_94")] + #[serde(default = "default_97")] pub about_other: bool, - #[serde(default = "default_95")] + #[serde(default = "default_98")] pub derived_from: Vec, - #[serde(default = "default_96")] + #[serde(default = "default_99")] pub score_components: std::collections::HashMap, - #[serde(default = "default_97")] + #[serde(default = "default_100")] pub resolved_from: Option, } @@ -3585,88 +3792,88 @@ pub struct MemorySearchHit { #[non_exhaustive] pub struct MemorySearchOutput { pub results: Vec, - #[serde(default = "default_98")] + #[serde(default = "default_101")] pub reader_block: String, - #[serde(default = "default_99")] + #[serde(default = "default_102")] pub reader_instructions: String, - #[serde(default = "default_100")] + #[serde(default = "default_103")] pub bodies_returned: Integer, - #[serde(default = "default_101")] + #[serde(default = "default_104")] pub bodies_elided: Integer, - #[serde(default = "default_102")] + #[serde(default = "default_105")] pub tokens_returned: Integer, - #[serde(default = "default_103")] + #[serde(default = "default_106")] pub namespaces_searched: Vec, - #[serde(default = "default_104")] + #[serde(default = "default_107")] pub namespaces_skipped: Vec, - #[serde(default = "default_105")] + #[serde(default = "default_108")] pub candidates_total: u64, - #[serde(default = "default_106")] + #[serde(default = "default_109")] pub stale_dropped: Integer, - #[serde(default = "default_107")] + #[serde(default = "default_110")] pub next_page: String, - #[serde(default = "default_108")] + #[serde(default = "default_111")] pub page_offset: Integer, - #[serde(default = "default_109")] + #[serde(default = "default_112")] pub chunk_share: f64, pub embedding_model: String, - #[serde(default = "default_110")] + #[serde(default = "default_113")] pub next: String, - #[serde(default = "default_111")] + #[serde(default = "default_114")] pub scratchpad: String, - #[serde(default = "default_112")] + #[serde(default = "default_115")] pub scratchpad_blocks: Integer, - #[serde(default = "default_113")] + #[serde(default = "default_116")] pub reinforcement: Option, - #[serde(default = "default_114")] + #[serde(default = "default_117")] pub graph_seeds: Integer, - #[serde(default = "default_115")] + #[serde(default = "default_118")] pub graph_neighbors_added: Integer, - #[serde(default = "default_116")] + #[serde(default = "default_119")] pub triples_extracted_from_query: Integer, - #[serde(default = "default_117")] + #[serde(default = "default_120")] pub triples_matched: Integer, - #[serde(default = "default_118")] + #[serde(default = "default_121")] pub set_expansion_phrases: Integer, - #[serde(default = "default_119")] + #[serde(default = "default_122")] pub top_k_ceiling: Integer, - #[serde(default = "default_120")] + #[serde(default = "default_123")] pub abstain: bool, - #[serde(default = "default_121")] + #[serde(default = "default_124")] pub abstain_reason: String, - #[serde(default = "default_122")] + #[serde(default = "default_125")] pub abstain_code: String, - #[serde(default = "default_123")] + #[serde(default = "default_126")] pub degraded: Vec, - #[serde(default = "default_124")] + #[serde(default = "default_127")] pub recipe: String, - #[serde(default = "default_125")] + #[serde(default = "default_128")] pub score_explanation: String, - #[serde(default = "default_126")] + #[serde(default = "default_129")] pub retrieval_confidence: f64, - #[serde(default = "default_127")] + #[serde(default = "default_130")] pub retrieval_risk: String, - #[serde(default = "default_128")] + #[serde(default = "default_131")] pub term_leg: String, - #[serde(default = "default_129")] + #[serde(default = "default_132")] pub route_agreement: f64, - #[serde(default = "default_130")] + #[serde(default = "default_133")] pub calibration_explanation: String, - #[serde(default = "default_131")] + #[serde(default = "default_134")] pub fallback_rounds_used: Integer, - #[serde(default = "default_132")] + #[serde(default = "default_135")] pub fallback_budget_exhausted: bool, - #[serde(default = "default_133")] + #[serde(default = "default_136")] pub fallback_elapsed_ms: Integer, - #[serde(default = "default_134")] + #[serde(default = "default_137")] pub retrieval_plan: String, - #[serde(default = "default_135")] + #[serde(default = "default_138")] pub retrieval_cost_estimate: std::collections::HashMap, - #[serde(default = "default_136")] + #[serde(default = "default_139")] pub retrieval_work: std::collections::HashMap, - #[serde(default = "default_137")] + #[serde(default = "default_140")] pub pending_extraction: u64, - #[serde(default = "default_138")] + #[serde(default = "default_141")] pub derived_aggregate: Option>, } @@ -4782,15 +4989,15 @@ impl MemorySearchInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySetPeer { - #[serde(default = "default_150")] + #[serde(default = "default_153")] pub memory_id: String, - #[serde(default = "default_151")] + #[serde(default = "default_154")] pub memory_key: String, - #[serde(default = "default_152")] + #[serde(default = "default_155")] pub excerpt: String, - #[serde(default = "default_153")] + #[serde(default = "default_156")] pub valid_at: Option, - #[serde(default = "default_154")] + #[serde(default = "default_157")] pub similarity: f64, } @@ -4798,39 +5005,39 @@ pub struct MemorySetPeer { #[non_exhaustive] pub struct MemorySetOutput { pub version: u64, - #[serde(default = "default_139")] + #[serde(default = "default_142")] pub pinned: bool, - #[serde(default = "default_140")] + #[serde(default = "default_143")] pub memory_id: String, - #[serde(default = "default_141")] + #[serde(default = "default_144")] pub content_sha256: String, - #[serde(default = "default_142")] + #[serde(default = "default_145")] pub status: String, - #[serde(default = "default_143")] + #[serde(default = "default_146")] pub duplicate_of: String, - #[serde(default = "default_144")] + #[serde(default = "default_147")] pub namespace: String, - #[serde(default = "default_145")] + #[serde(default = "default_148")] pub memory_key: String, - #[serde(default = "default_146")] + #[serde(default = "default_149")] pub merged_into_key: String, - #[serde(default = "default_147")] + #[serde(default = "default_150")] pub degraded: Vec, - #[serde(default = "default_148")] + #[serde(default = "default_151")] pub retyped_from: String, - #[serde(default = "default_149")] + #[serde(default = "default_152")] pub conflict_verdict: String, - #[serde(default = "default_155")] + #[serde(default = "default_158")] pub peers: Vec, - #[serde(default = "default_156")] + #[serde(default = "default_159")] pub next: String, - #[serde(default = "default_157")] + #[serde(default = "default_160")] pub noop: bool, - #[serde(default = "default_158")] + #[serde(default = "default_161")] pub dry_run: bool, - #[serde(default = "default_159")] + #[serde(default = "default_162")] pub advisories: Vec, - #[serde(default = "default_160")] + #[serde(default = "default_163")] pub chunks_written: Integer, } @@ -5238,24 +5445,24 @@ pub struct OpCapability { pub budget_p99_ms: Integer, pub idempotent: bool, pub audit: bool, - #[serde(default = "default_163")] + #[serde(default = "default_166")] pub request_fields: Vec, - #[serde(default = "default_164")] + #[serde(default = "default_167")] pub response_fields: Vec, - #[serde(default = "default_165")] + #[serde(default = "default_168")] pub toolsets: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct OpsCapabilitiesOutput { - #[serde(default = "default_161")] + #[serde(default = "default_164")] pub build_commit: String, - #[serde(default = "default_162")] + #[serde(default = "default_165")] pub schema_version: String, - #[serde(default = "default_166")] + #[serde(default = "default_169")] pub ops: Vec, - #[serde(default = "default_167")] + #[serde(default = "default_170")] pub consumer_field: String, } @@ -5320,11 +5527,11 @@ pub enum OpsHealthCheckStatus { pub struct OpsHealthCheck { pub name: String, pub status: OpsHealthCheckStatus, - #[serde(default = "default_168")] + #[serde(default = "default_171")] pub detail: String, - #[serde(default = "default_169")] + #[serde(default = "default_172")] pub data: std::collections::HashMap, - #[serde(default = "default_170")] + #[serde(default = "default_173")] pub repair: String, } @@ -5343,7 +5550,7 @@ pub enum OpsHealthOutputOverall { #[non_exhaustive] pub struct OpsHealthOutput { pub checks: Vec, - #[serde(default = "default_171")] + #[serde(default = "default_174")] pub worker_status: std::collections::HashMap>, pub overall: OpsHealthOutputOverall, } @@ -5403,9 +5610,9 @@ pub struct UserNamespaceGrant { pub namespace: String, pub role: String, pub is_owner: bool, - #[serde(default = "default_172")] + #[serde(default = "default_175")] pub granted_at: Option, - #[serde(default = "default_173")] + #[serde(default = "default_176")] pub pending_role: Option, } @@ -5416,9 +5623,9 @@ pub struct UserSummary { pub contact_email: String, pub grants: Vec, pub is_platform_admin: bool, - #[serde(default = "default_174")] + #[serde(default = "default_177")] pub last_active: Option, - #[serde(default = "default_175")] + #[serde(default = "default_178")] pub has_password_auth: bool, } @@ -5427,9 +5634,9 @@ pub struct UserSummary { pub struct AdminUsersOutput { pub users: Vec, pub total: Integer, - #[serde(default = "default_176")] + #[serde(default = "default_179")] pub total_pending_elevations: Integer, - #[serde(default = "default_177")] + #[serde(default = "default_180")] pub total_active_last_7d: Integer, pub platform_admins_configured: Vec, } @@ -5514,7 +5721,7 @@ pub struct ConnectedAgent { pub ops: Integer, pub namespaces_touched: Integer, pub primary_namespace: String, - #[serde(default = "default_178")] + #[serde(default = "default_181")] pub cost_usd: f64, } @@ -5523,7 +5730,7 @@ pub struct ConnectedAgent { pub struct AgentsConnectedOutput { pub rows: Vec, pub window_hours: Integer, - #[serde(default = "default_179")] + #[serde(default = "default_182")] pub new_count: Option, } @@ -5618,32 +5825,32 @@ pub enum AssistantCitationKind { pub struct AssistantCitation { pub kind: AssistantCitationKind, pub text: String, - #[serde(default = "default_184")] + #[serde(default = "default_187")] pub verified: bool, - #[serde(default = "default_185")] + #[serde(default = "default_188")] pub reason: String, - #[serde(rename = "ref", default = "default_186")] + #[serde(rename = "ref", default = "default_189")] pub r#ref: String, - #[serde(default = "default_187")] + #[serde(default = "default_190")] pub anchor: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct AssistantAskOutput { - #[serde(default = "default_180")] + #[serde(default = "default_183")] pub mirrored: bool, - #[serde(default = "default_181")] + #[serde(default = "default_184")] pub answer: String, - #[serde(default = "default_182")] + #[serde(default = "default_185")] pub run_id: String, - #[serde(default = "default_183")] + #[serde(default = "default_186")] pub model: String, - #[serde(default = "default_188")] + #[serde(default = "default_191")] pub citations: Vec, - #[serde(default = "default_189")] + #[serde(default = "default_192")] pub support: String, - #[serde(default = "default_190")] + #[serde(default = "default_193")] pub unknown_names: Vec, } @@ -5781,7 +5988,7 @@ pub struct AuditListRow { #[non_exhaustive] pub struct AuditListOutput { pub rows: Vec, - #[serde(default = "default_191")] + #[serde(default = "default_194")] pub next_cursor: Option, } @@ -5910,11 +6117,11 @@ impl AuditListInput { pub struct BlacklistAddOutput { pub pattern_id: String, pub created_at: String, - #[serde(default = "default_192")] + #[serde(default = "default_195")] pub swept: Integer, - #[serde(default = "default_193")] + #[serde(default = "default_196")] pub swept_truncated: bool, - #[serde(default = "default_194")] + #[serde(default = "default_197")] pub sweep_error: String, } @@ -6067,7 +6274,7 @@ pub struct BlacklistRow { pub reason: String, pub created_by: String, pub hit_count: Integer, - #[serde(default = "default_195")] + #[serde(default = "default_198")] pub last_hit_at: Option, pub created_at: String, } @@ -6164,7 +6371,7 @@ impl BlacklistListInput { #[non_exhaustive] pub struct BlacklistRemoveOutput { pub removed: bool, - #[serde(default = "default_196")] + #[serde(default = "default_199")] pub removed_at: Option, } @@ -6228,7 +6435,7 @@ pub struct BlacklistSweepOutput { pub matched: Integer, pub tombstoned: Integer, pub truncated: bool, - #[serde(default = "default_197")] + #[serde(default = "default_200")] pub error: String, } @@ -6278,7 +6485,7 @@ impl BlacklistSweepInput { #[non_exhaustive] pub struct CalibrationGetOutput { pub source: String, - #[serde(default = "default_198")] + #[serde(default = "default_201")] pub embedder_model: String, pub noise_floor: f64, pub rerank_skip_above: f64, @@ -6287,21 +6494,21 @@ pub struct CalibrationGetOutput { pub abstain_threshold: f64, pub conflict_threshold: f64, pub duplicate_threshold: f64, - #[serde(default = "default_199")] + #[serde(default = "default_202")] pub similar_p10: f64, - #[serde(default = "default_200")] + #[serde(default = "default_203")] pub similar_p25: f64, - #[serde(default = "default_201")] + #[serde(default = "default_204")] pub similar_p50: f64, - #[serde(default = "default_202")] + #[serde(default = "default_205")] pub similar_p75: f64, - #[serde(default = "default_203")] + #[serde(default = "default_206")] pub distractor_p50: f64, - #[serde(default = "default_204")] + #[serde(default = "default_207")] pub distractor_p90: f64, - #[serde(default = "default_205")] + #[serde(default = "default_208")] pub similar_pairs_n: Integer, - #[serde(default = "default_206")] + #[serde(default = "default_209")] pub distractor_pairs_n: Integer, } @@ -6377,40 +6584,40 @@ pub enum CodeAskOutputSource { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeAskOutput { - #[serde(default = "default_207")] + #[serde(default = "default_210")] pub answer: String, - #[serde(default = "default_208")] + #[serde(default = "default_211")] pub partial: bool, - #[serde(default = "default_209")] + #[serde(default = "default_212")] pub partial_reason: String, - #[serde(default = "default_210")] + #[serde(default = "default_213")] pub note: String, - #[serde(default = "default_211")] + #[serde(default = "default_214")] pub coverage: CodeAskOutputCoverage, - #[serde(default = "default_212")] + #[serde(default = "default_215")] pub citations: Vec>, pub source: CodeAskOutputSource, - #[serde(default = "default_213")] + #[serde(default = "default_216")] pub cache_similarity: f64, - #[serde(default = "default_214")] + #[serde(default = "default_217")] pub cache: String, - #[serde(default = "default_215")] + #[serde(default = "default_218")] pub cache_saved_ms: Integer, - #[serde(default = "default_216")] + #[serde(default = "default_219")] pub cache_saved_usd: f64, - #[serde(default = "default_217")] + #[serde(default = "default_220")] pub abstain: bool, - #[serde(default = "default_218")] + #[serde(default = "default_221")] pub abstain_reason: String, - #[serde(default = "default_219")] + #[serde(default = "default_222")] pub retrieval_confidence: f64, - #[serde(default = "default_220")] + #[serde(default = "default_223")] pub tokens_returned: Integer, - #[serde(default = "default_221")] + #[serde(default = "default_224")] pub context_tokens: Integer, - #[serde(default = "default_222")] + #[serde(default = "default_225")] pub trace_run_id: String, - #[serde(default = "default_223")] + #[serde(default = "default_226")] pub as_of: std::collections::HashMap, } @@ -6540,37 +6747,37 @@ impl CodeAskInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeBackportGapOutput { - #[serde(default = "default_224")] + #[serde(default = "default_227")] pub skipped_branches: Vec>, - #[serde(default = "default_225")] + #[serde(default = "default_228")] pub verdict: String, - #[serde(default = "default_226")] + #[serde(default = "default_229")] pub causes: Vec, - #[serde(default = "default_227")] + #[serde(default = "default_230")] pub fix: std::collections::HashMap, - #[serde(default = "default_228")] + #[serde(default = "default_231")] pub issue: std::collections::HashMap, - #[serde(default = "default_229")] + #[serde(default = "default_232")] pub fixes: Vec>, - #[serde(default = "default_230")] + #[serde(default = "default_233")] pub symbols: Vec, - #[serde(default = "default_231")] + #[serde(default = "default_234")] pub files: Vec, - #[serde(default = "default_232")] + #[serde(default = "default_235")] pub branches: Vec>, - #[serde(default = "default_233")] + #[serde(default = "default_236")] pub summary: std::collections::HashMap>, - #[serde(default = "default_234")] + #[serde(default = "default_237")] pub fix_candidate: Option>, - #[serde(default = "default_235")] + #[serde(default = "default_238")] pub tracker_namespace: String, - #[serde(default = "default_236")] + #[serde(default = "default_239")] pub tracker_unavailable: bool, - #[serde(default = "default_237")] + #[serde(default = "default_240")] pub ms: Integer, - #[serde(default = "default_238")] + #[serde(default = "default_241")] pub stage_ms: std::collections::HashMap, - #[serde(default = "default_239")] + #[serde(default = "default_242")] pub trace_run_id: String, } @@ -6721,32 +6928,32 @@ impl CodeBackportGapInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeBackportGapsOutput { - #[serde(default = "default_240")] + #[serde(default = "default_243")] pub skipped_branches: Vec>, - #[serde(default = "default_241")] + #[serde(default = "default_244")] pub branch: String, - #[serde(default = "default_242")] + #[serde(default = "default_245")] pub branch_namespace: String, - #[serde(default = "default_243")] + #[serde(default = "default_246")] pub branches: Vec, - #[serde(default = "default_244")] + #[serde(default = "default_247")] pub rows: Vec>, - #[serde(default = "default_245")] + #[serde(default = "default_248")] pub counts: std::collections::HashMap, - #[serde(default = "default_246")] + #[serde(default = "default_249")] pub counts_by_branch: std::collections::HashMap>, - #[serde(default = "default_247")] + #[serde(default = "default_250")] pub fixes: Integer, - #[serde(default = "default_248")] + #[serde(default = "default_251")] pub wanted_only: bool, - #[serde(default = "default_249")] + #[serde(default = "default_252")] pub since: String, - #[serde(default = "default_250")] + #[serde(default = "default_253")] pub computed: std::collections::HashMap, - #[serde(default = "default_251")] + #[serde(default = "default_254")] pub stale: bool, - #[serde(default = "default_252")] + #[serde(default = "default_255")] pub ms: Integer, } @@ -6875,75 +7082,75 @@ impl CodeBackportGapsInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeBisectCandidatesOutput { - #[serde(default = "default_253")] + #[serde(default = "default_256")] pub verdict: String, - #[serde(default = "default_254")] + #[serde(default = "default_257")] pub candidates_from: String, - #[serde(default = "default_255")] + #[serde(default = "default_258")] pub causes: Vec, - #[serde(default = "default_256")] + #[serde(default = "default_259")] pub epistemic: String, - #[serde(default = "default_257")] + #[serde(default = "default_260")] pub candidates: Vec>, - #[serde(default = "default_258")] + #[serde(default = "default_261")] pub marks: std::collections::HashMap, - #[serde(default = "default_259")] + #[serde(default = "default_262")] pub named_by_graph: Vec, - #[serde(default = "default_260")] + #[serde(default = "default_263")] pub fix_blame: std::collections::HashMap, - #[serde(default = "default_261")] + #[serde(default = "default_264")] pub fusion: std::collections::HashMap, - #[serde(default = "default_262")] + #[serde(default = "default_265")] pub patterns: Vec, - #[serde(default = "default_263")] + #[serde(default = "default_266")] pub pattern_weights: std::collections::HashMap, - #[serde(default = "default_264")] + #[serde(default = "default_267")] pub scope: String, - #[serde(default = "default_265")] + #[serde(default = "default_268")] pub widened_by: Vec, - #[serde(default = "default_266")] + #[serde(default = "default_269")] pub dupcheck_fix: std::collections::HashMap, - #[serde(default = "default_267")] + #[serde(default = "default_270")] pub component: String, - #[serde(default = "default_268")] + #[serde(default = "default_271")] pub component_dirs: Vec, - #[serde(default = "default_269")] + #[serde(default = "default_272")] pub dropped_after_report: Integer, - #[serde(default = "default_270")] + #[serde(default = "default_273")] pub versions_searched: Vec, - #[serde(default = "default_271")] + #[serde(default = "default_274")] pub bad_version: String, - #[serde(default = "default_272")] + #[serde(default = "default_275")] pub good_version: String, - #[serde(default = "default_273")] + #[serde(default = "default_276")] pub window: String, - #[serde(default = "default_274")] + #[serde(default = "default_277")] pub hub_paths_dropped: Vec, - #[serde(default = "default_275")] + #[serde(default = "default_278")] pub resolved: Vec>, - #[serde(default = "default_276")] + #[serde(default = "default_279")] pub paths: Vec, - #[serde(default = "default_277")] + #[serde(default = "default_280")] pub frames: Vec, - #[serde(default = "default_278")] + #[serde(default = "default_281")] pub issue: std::collections::HashMap, - #[serde(default = "default_279")] + #[serde(default = "default_282")] pub introduced_commit: String, - #[serde(default = "default_280")] + #[serde(default = "default_283")] pub fix_candidate: Option>, - #[serde(default = "default_281")] + #[serde(default = "default_284")] pub tracker_namespace: String, - #[serde(default = "default_282")] + #[serde(default = "default_285")] pub tracker_unavailable: bool, - #[serde(default = "default_283")] + #[serde(default = "default_286")] pub trace_run_id: String, - #[serde(default = "default_284")] + #[serde(default = "default_287")] pub partial: bool, - #[serde(default = "default_285")] + #[serde(default = "default_288")] pub partial_reason: String, - #[serde(default = "default_286")] + #[serde(default = "default_289")] pub before: String, - #[serde(default = "default_287")] + #[serde(default = "default_290")] pub after: String, } @@ -7239,43 +7446,43 @@ pub enum CodeBlameRangeOutputStage { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeBlameRangeOutput { - #[serde(default = "default_288")] + #[serde(default = "default_291")] pub verdict: String, - #[serde(default = "default_289")] + #[serde(default = "default_292")] pub causes: Vec, - #[serde(default = "default_290")] + #[serde(default = "default_293")] pub epistemic: String, - #[serde(default = "default_291")] + #[serde(default = "default_294")] pub stage: CodeBlameRangeOutputStage, - #[serde(default = "default_292")] + #[serde(default = "default_295")] pub note: String, - #[serde(default = "default_293")] + #[serde(default = "default_296")] pub path: String, - #[serde(default = "default_294")] + #[serde(default = "default_297")] pub path_indexed: bool, - #[serde(default = "default_295")] + #[serde(default = "default_298")] pub range: std::collections::HashMap, - #[serde(default = "default_296")] + #[serde(default = "default_299")] pub window: std::collections::HashMap, - #[serde(default = "default_297")] + #[serde(default = "default_300")] pub candidates: Vec>, - #[serde(default = "default_298")] + #[serde(default = "default_301")] pub last_touched: Vec>, - #[serde(default = "default_299")] + #[serde(default = "default_302")] pub symbol: std::collections::HashMap, - #[serde(default = "default_300")] + #[serde(default = "default_303")] pub latest_pr: Integer, - #[serde(default = "default_301")] + #[serde(default = "default_304")] pub lines: std::collections::HashMap, - #[serde(default = "default_302")] + #[serde(default = "default_305")] pub legs: std::collections::HashMap, - #[serde(default = "default_303")] + #[serde(default = "default_306")] pub first_release_basis: String, - #[serde(default = "default_304")] + #[serde(default = "default_307")] pub tracker_namespace: String, - #[serde(default = "default_305")] + #[serde(default = "default_308")] pub tracker_unavailable: bool, - #[serde(default = "default_306")] + #[serde(default = "default_309")] pub trace_run_id: String, } @@ -7547,6 +7754,31 @@ impl CodeCalibrateInput { } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +#[non_exhaustive] +pub struct CodeLesson { + #[serde(default)] + pub memory_key: Option, + #[serde(default)] + pub namespace: Option, + #[serde(default)] + pub excerpt: Option, + #[serde(default)] + pub code_state: Option, + #[serde(default)] + pub path: Option, + #[serde(default)] + pub changed_since: Option, + #[serde(default)] + pub supersedes_key: Option, + #[serde(default)] + pub suggestion: Option, + #[serde(default)] + pub owner_symbol: Option, + #[serde(default)] + pub use_guidance: Option, +} + #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeEdgeWire { @@ -7559,9 +7791,9 @@ pub struct CodeEdgeWire { pub line: Integer, pub tier: String, pub confidence: f64, - #[serde(default = "default_309")] + #[serde(default = "default_312")] pub via_override: String, - #[serde(default = "default_310")] + #[serde(default = "default_313")] pub via: String, } @@ -7570,14 +7802,14 @@ pub struct CodeEdgeWire { pub struct CodeCandidateSiteWire { pub path: String, pub line: Integer, - #[serde(default = "default_333")] + #[serde(default = "default_336")] pub caller: String, - #[serde(default = "default_334")] + #[serde(default = "default_337")] pub callee_text: String, pub reason: String, pub confidence: f64, pub disposition: String, - #[serde(default = "default_335")] + #[serde(default = "default_338")] pub candidates: Integer, } @@ -7594,68 +7826,68 @@ pub struct CodeCandidateGroupWire { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCandidateSitesWire { - #[serde(default = "default_327")] + #[serde(default = "default_330")] pub epistemic: String, - #[serde(default = "default_328")] + #[serde(default = "default_331")] pub total: Integer, - #[serde(default = "default_329")] + #[serde(default = "default_332")] pub returned: Integer, - #[serde(default = "default_330")] + #[serde(default = "default_333")] pub truncated: bool, - #[serde(default = "default_331")] + #[serde(default = "default_334")] pub read_capped: bool, - #[serde(default = "default_332")] + #[serde(default = "default_335")] pub by_reason: std::collections::HashMap, - #[serde(default = "default_336")] + #[serde(default = "default_339")] pub groups: Vec, - #[serde(default = "default_337")] + #[serde(default = "default_340")] pub note: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCallersOutput { - #[serde(default = "default_307")] - pub lessons: Vec>, - #[serde(default = "default_308")] + #[serde(default = "default_310")] + pub lessons: Vec, + #[serde(default = "default_311")] pub lessons_left_out: Integer, pub edges: Vec, pub seed_symbols: Vec, - #[serde(default = "default_311")] + #[serde(default = "default_314")] pub overlay: bool, - #[serde(default = "default_312")] + #[serde(default = "default_315")] pub overlay_head_sha: String, - #[serde(default = "default_313")] + #[serde(default = "default_316")] pub overlay_added: Integer, - #[serde(default = "default_314")] + #[serde(default = "default_317")] pub overlay_note: String, - #[serde(default = "default_315")] + #[serde(default = "default_318")] pub resolved_by: String, - #[serde(default = "default_316")] + #[serde(default = "default_319")] pub ambiguous: bool, - #[serde(default = "default_317")] + #[serde(default = "default_320")] pub candidates: Vec, - #[serde(default = "default_318")] + #[serde(default = "default_321")] pub dispatch_seeds: Vec>, - #[serde(default = "default_319")] + #[serde(default = "default_322")] pub note: String, - #[serde(default = "default_320")] + #[serde(default = "default_323")] pub truncated: bool, - #[serde(default = "default_321")] + #[serde(default = "default_324")] pub counts_floor: bool, - #[serde(default = "default_322")] + #[serde(default = "default_325")] pub unresolved_calls: Integer, - #[serde(default = "default_323")] + #[serde(default = "default_326")] pub ambiguous_calls: Integer, - #[serde(default = "default_324")] + #[serde(default = "default_327")] pub epistemic: String, - #[serde(default = "default_325")] + #[serde(default = "default_328")] pub causes: Vec, - #[serde(default = "default_326")] + #[serde(default = "default_329")] pub by_hop_counts: std::collections::HashMap, - #[serde(default = "default_338")] + #[serde(default = "default_341")] pub candidate_sites: Option, - #[serde(default = "default_339")] + #[serde(default = "default_342")] pub trace_run_id: String, } @@ -8183,18 +8415,18 @@ pub enum CodeContextPackOutputSource { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeContextPackOutput { - #[serde(default = "default_340")] - pub lessons: Vec>, - #[serde(default = "default_341")] + #[serde(default = "default_343")] + pub lessons: Vec, + #[serde(default = "default_344")] pub lessons_left_out: Integer, pub context: String, pub tokens_used: Integer, pub source: CodeContextPackOutputSource, - #[serde(default = "default_342")] + #[serde(default = "default_345")] pub truncated: bool, - #[serde(default = "default_343")] + #[serde(default = "default_346")] pub merge_commit_sha: String, - #[serde(default = "default_344")] + #[serde(default = "default_347")] pub trace_run_id: String, } @@ -8368,17 +8600,17 @@ impl CodeContextPackInput { #[non_exhaustive] pub struct CodeContextPackRow { pub pr_number: Integer, - #[serde(default = "default_345")] + #[serde(default = "default_348")] pub merge_commit_sha: String, - #[serde(default = "default_346")] + #[serde(default = "default_349")] pub pack_tokens: Integer, - #[serde(default = "default_347")] + #[serde(default = "default_350")] pub created_at: String, - #[serde(default = "default_348")] + #[serde(default = "default_351")] pub title: String, - #[serde(default = "default_349")] + #[serde(default = "default_352")] pub author: String, - #[serde(default = "default_350")] + #[serde(default = "default_353")] pub merged_at: String, } @@ -8386,7 +8618,7 @@ pub struct CodeContextPackRow { #[non_exhaustive] pub struct CodeContextPacksOutput { pub rows: Vec, - #[serde(default = "default_351")] + #[serde(default = "default_354")] pub total: Integer, } @@ -8504,41 +8736,41 @@ impl CodeContextPacksInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeConventionsOutput { - #[serde(default = "default_352")] + #[serde(default = "default_355")] pub pr_number: Integer, - #[serde(default = "default_353")] + #[serde(default = "default_356")] pub source: String, - #[serde(default = "default_354")] + #[serde(default = "default_357")] pub title: String, - #[serde(default = "default_355")] + #[serde(default = "default_358")] pub labels: Vec, - #[serde(default = "default_356")] + #[serde(default = "default_359")] pub category: String, - #[serde(default = "default_357")] + #[serde(default = "default_360")] pub category_source: String, - #[serde(default = "default_358")] + #[serde(default = "default_361")] pub merged_at: String, - #[serde(default = "default_359")] + #[serde(default = "default_362")] pub merge_commit_sha: String, - #[serde(default = "default_360")] + #[serde(default = "default_363")] pub head_sha: String, - #[serde(default = "default_361")] + #[serde(default = "default_364")] pub files_total: Integer, - #[serde(default = "default_362")] + #[serde(default = "default_365")] pub files_in_diff: Integer, - #[serde(default = "default_363")] + #[serde(default = "default_366")] pub diff_bytes: Integer, - #[serde(default = "default_364")] + #[serde(default = "default_367")] pub diff_truncated: bool, - #[serde(default = "default_365")] + #[serde(default = "default_368")] pub rules: Vec>, - #[serde(default = "default_366")] + #[serde(default = "default_369")] pub summary: std::collections::HashMap, - #[serde(default = "default_367")] + #[serde(default = "default_370")] pub control: std::collections::HashMap, - #[serde(default = "default_368")] + #[serde(default = "default_371")] pub notes: Vec, - #[serde(default = "default_369")] + #[serde(default = "default_372")] pub trace_run_id: String, } @@ -8679,29 +8911,29 @@ impl CodeConventionsInput { #[non_exhaustive] pub struct CodeLanguageCoverage { pub lang: String, - #[serde(default = "default_371")] + #[serde(default = "default_374")] pub files: Integer, - #[serde(default = "default_372")] + #[serde(default = "default_375")] pub files_errored: Integer, - #[serde(default = "default_373")] + #[serde(default = "default_376")] pub files_first_at: String, - #[serde(default = "default_374")] + #[serde(default = "default_377")] pub files_last_at: String, - #[serde(default = "default_375")] + #[serde(default = "default_378")] pub chunks: Integer, - #[serde(default = "default_376")] + #[serde(default = "default_379")] pub chunks_embedded: Integer, - #[serde(default = "default_377")] + #[serde(default = "default_380")] pub chunks_described: Integer, - #[serde(default = "default_378")] + #[serde(default = "default_381")] pub chunks_last_at: String, - #[serde(default = "default_379")] + #[serde(default = "default_382")] pub symbols_treesitter: Integer, - #[serde(default = "default_380")] + #[serde(default = "default_383")] pub symbols_treesitter_last_at: String, - #[serde(default = "default_381")] + #[serde(default = "default_384")] pub symbols_scip: Integer, - #[serde(default = "default_382")] + #[serde(default = "default_385")] pub symbols_scip_last_at: String, } @@ -8709,32 +8941,32 @@ pub struct CodeLanguageCoverage { #[non_exhaustive] pub struct CodeTierCoverage { pub tier: String, - #[serde(default = "default_383")] + #[serde(default = "default_386")] pub edges: Integer, - #[serde(default = "default_384")] + #[serde(default = "default_387")] pub edges_last_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCoverageGaps { - #[serde(default = "default_385")] + #[serde(default = "default_388")] pub functions_scanned: Integer, - #[serde(default = "default_386")] + #[serde(default = "default_389")] pub functions_uncalled: Integer, - #[serde(default = "default_387")] + #[serde(default = "default_390")] pub uncalled_share: f64, - #[serde(default = "default_388")] + #[serde(default = "default_391")] pub source_files: Integer, - #[serde(default = "default_389")] + #[serde(default = "default_392")] pub source_files_untested: Integer, - #[serde(default = "default_390")] + #[serde(default = "default_393")] pub untested_share: f64, - #[serde(default = "default_391")] + #[serde(default = "default_394")] pub code_files: Integer, - #[serde(default = "default_392")] + #[serde(default = "default_395")] pub code_files_no_symbols: Integer, - #[serde(default = "default_393")] + #[serde(default = "default_396")] pub no_symbols_share: f64, } @@ -8743,25 +8975,25 @@ pub struct CodeCoverageGaps { pub struct CodeCoverageOutput { pub org: String, pub namespace: String, - #[serde(default = "default_370")] + #[serde(default = "default_373")] pub as_of_commit: String, pub languages: Vec, pub tiers: Vec, - #[serde(default = "default_394")] + #[serde(default = "default_397")] pub gaps: Option, - #[serde(default = "default_395")] + #[serde(default = "default_398")] pub pr_history_from: String, - #[serde(default = "default_396")] + #[serde(default = "default_399")] pub pr_history_to: String, - #[serde(default = "default_397")] + #[serde(default = "default_400")] pub pr_history_last_fetch_at: String, - #[serde(default = "default_398")] + #[serde(default = "default_401")] pub pr_history_enabled: bool, - #[serde(default = "default_399")] + #[serde(default = "default_402")] pub pr_history_auth: String, - #[serde(default = "default_400")] + #[serde(default = "default_403")] pub context_packs_last_at: String, - #[serde(default = "default_401")] + #[serde(default = "default_404")] pub summaries_last_at: String, } @@ -8931,44 +9163,44 @@ impl CodeCoverageUnwatchInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCommitTierCoverage { - #[serde(default = "default_408")] + #[serde(default = "default_411")] pub producer: String, - #[serde(default = "default_409")] + #[serde(default = "default_412")] pub label: String, - #[serde(default = "default_410")] + #[serde(default = "default_413")] pub watermark_key: String, - #[serde(default = "default_411")] + #[serde(default = "default_414")] pub watermark: String, - #[serde(default = "default_412")] + #[serde(default = "default_415")] pub covered: Option, - #[serde(default = "default_413")] + #[serde(default = "default_416")] pub commits_since: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCommitCoverage { - #[serde(default = "default_405")] + #[serde(default = "default_408")] pub commit: String, - #[serde(default = "default_406")] + #[serde(default = "default_409")] pub in_mirror: bool, - #[serde(default = "default_407")] + #[serde(default = "default_410")] pub fast: Option, - #[serde(default = "default_414")] + #[serde(default = "default_417")] pub tiers: Vec, - #[serde(default = "default_415")] + #[serde(default = "default_418")] pub ready: bool, - #[serde(default = "default_416")] + #[serde(default = "default_419")] pub waiting_on: Vec, - #[serde(default = "default_417")] + #[serde(default = "default_420")] pub commits_since: Integer, - #[serde(default = "default_418")] + #[serde(default = "default_421")] pub paths_changed_since: Vec, - #[serde(default = "default_419")] + #[serde(default = "default_422")] pub paths_changed_count: Integer, - #[serde(default = "default_420")] + #[serde(default = "default_423")] pub paths_truncated: bool, - #[serde(default = "default_421")] + #[serde(default = "default_424")] pub paths_changed_overlap: Vec, } @@ -8979,14 +9211,14 @@ pub struct CodeCoverageWatchOutput { pub namespace: String, pub commit: String, pub inbox: String, - #[serde(default = "default_402")] + #[serde(default = "default_405")] pub ready: bool, - #[serde(default = "default_403")] + #[serde(default = "default_406")] pub emitted: bool, - #[serde(default = "default_404")] + #[serde(default = "default_407")] pub delivered_at: Option, pub event_id: String, - #[serde(default = "default_422")] + #[serde(default = "default_425")] pub commit_coverage: Option, } @@ -9070,31 +9302,31 @@ impl CodeCoverageWatchInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeCoverageClaimOutput { - #[serde(default = "default_423")] + #[serde(default = "default_426")] pub subject: String, - #[serde(default = "default_424")] + #[serde(default = "default_427")] pub subject_kind: String, - #[serde(default = "default_425")] + #[serde(default = "default_428")] pub verdict: String, - #[serde(default = "default_426")] + #[serde(default = "default_429")] pub tests: Vec>, - #[serde(default = "default_427")] + #[serde(default = "default_430")] pub tests_total: Integer, - #[serde(default = "default_428")] + #[serde(default = "default_431")] pub src_paths: Vec, - #[serde(default = "default_429")] + #[serde(default = "default_432")] pub epistemic: String, - #[serde(default = "default_430")] + #[serde(default = "default_433")] pub strongest_tier: String, - #[serde(default = "default_431")] + #[serde(default = "default_434")] pub search_terms: std::collections::HashMap, - #[serde(default = "default_432")] + #[serde(default = "default_435")] pub resolved_by: String, - #[serde(default = "default_433")] + #[serde(default = "default_436")] pub control: std::collections::HashMap, - #[serde(default = "default_434")] + #[serde(default = "default_437")] pub measured: std::collections::HashMap, - #[serde(default = "default_435")] + #[serde(default = "default_438")] pub trace_run_id: String, } @@ -9223,62 +9455,62 @@ impl CodeCoverageClaimInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeUnit { - #[serde(default = "default_436")] + #[serde(default = "default_439")] pub unit_id: String, pub path: String, - #[serde(default = "default_437")] + #[serde(default = "default_440")] pub start_line: Integer, - #[serde(default = "default_438")] + #[serde(default = "default_441")] pub end_line: Integer, - #[serde(default = "default_439")] + #[serde(default = "default_442")] pub symbol: String, - #[serde(default = "default_440")] + #[serde(default = "default_443")] pub kind: String, - #[serde(default = "default_441")] + #[serde(default = "default_444")] pub signature: String, - #[serde(default = "default_442")] + #[serde(default = "default_445")] pub body: String, - #[serde(default = "default_443")] + #[serde(default = "default_446")] pub elided: bool, - #[serde(default = "default_444")] + #[serde(default = "default_447")] pub body_hash: String, - #[serde(default = "default_445")] + #[serde(default = "default_448")] pub description: String, - #[serde(default = "default_446")] + #[serde(default = "default_449")] pub tier: String, - #[serde(default = "default_447")] + #[serde(default = "default_450")] pub score: f64, - #[serde(default = "default_448")] + #[serde(default = "default_451")] pub recent_prs: Vec>, - #[serde(default = "default_449")] + #[serde(default = "default_452")] pub examples: Vec>, - #[serde(default = "default_450")] - pub lessons: Vec>, - #[serde(default = "default_451")] + #[serde(default = "default_453")] + pub lessons: Vec, + #[serde(default = "default_454")] pub lessons_unread: bool, - #[serde(default = "default_452")] + #[serde(default = "default_455")] pub churn: Integer, - #[serde(default = "default_453")] + #[serde(default = "default_456")] pub amp: Integer, - #[serde(default = "default_454")] + #[serde(default = "default_457")] pub tested: bool, - #[serde(default = "default_455")] + #[serde(default = "default_458")] pub callees: Vec>, - #[serde(default = "default_456")] + #[serde(default = "default_459")] pub granularity: String, - #[serde(default = "default_457")] + #[serde(default = "default_460")] pub next: String, - #[serde(default = "default_458")] + #[serde(default = "default_461")] pub outline: Vec>, - #[serde(default = "default_459")] + #[serde(default = "default_462")] pub fan_in: Integer, - #[serde(default = "default_460")] + #[serde(default = "default_463")] pub via: String, - #[serde(default = "default_461")] + #[serde(default = "default_464")] pub lexical_rank: Integer, - #[serde(default = "default_462")] + #[serde(default = "default_465")] pub vector_rank: Integer, - #[serde(default = "default_463")] + #[serde(default = "default_466")] pub namespace: String, } @@ -9325,19 +9557,19 @@ pub enum CodeEditContextTargetStatus { pub struct CodeEditContextTarget { pub name: String, pub status: CodeEditContextTargetStatus, - #[serde(default = "default_481")] + #[serde(default = "default_484")] pub definition_indices: Vec, - #[serde(default = "default_482")] + #[serde(default = "default_485")] pub candidates: Vec>, - #[serde(default = "default_483")] + #[serde(default = "default_486")] pub resolved_by: String, - #[serde(default = "default_484")] + #[serde(default = "default_487")] pub presence: Vec>, - #[serde(default = "default_485")] + #[serde(default = "default_488")] pub hierarchy: std::collections::HashMap>>, - #[serde(default = "default_486")] + #[serde(default = "default_489")] pub documented_in: Vec>, - #[serde(default = "default_487")] + #[serde(default = "default_490")] pub trace_run_id: String, } @@ -9345,41 +9577,41 @@ pub struct CodeEditContextTarget { #[non_exhaustive] pub struct CodeSymbolOutput { pub definitions: Vec, - #[serde(default = "default_464")] + #[serde(default = "default_467")] pub lessons_left_out: Integer, - #[serde(default = "default_465")] + #[serde(default = "default_468")] pub ambiguous: bool, - #[serde(default = "default_466")] + #[serde(default = "default_469")] pub hierarchy: std::collections::HashMap>>, - #[serde(default = "default_467")] + #[serde(default = "default_470")] pub candidates: Vec>, - #[serde(default = "default_468")] + #[serde(default = "default_471")] pub tokens_returned: Integer, - #[serde(default = "default_469")] + #[serde(default = "default_472")] pub trace_run_id: String, - #[serde(default = "default_470")] + #[serde(default = "default_473")] pub uses: CodeSymbolOutputUses, - #[serde(default = "default_471")] + #[serde(default = "default_474")] pub uses_truncated: bool, - #[serde(default = "default_472")] + #[serde(default = "default_475")] pub uses_tokens: Integer, - #[serde(default = "default_473")] + #[serde(default = "default_476")] pub picked_by: String, - #[serde(default = "default_474")] + #[serde(default = "default_477")] pub resolved_by: String, - #[serde(default = "default_475")] + #[serde(default = "default_478")] pub documented_in: Vec>, - #[serde(default = "default_476")] + #[serde(default = "default_479")] pub neighbours: Vec>, - #[serde(default = "default_477")] + #[serde(default = "default_480")] pub anchors: Integer, - #[serde(default = "default_478")] + #[serde(default = "default_481")] pub neighbour_tokens: Integer, - #[serde(default = "default_479")] + #[serde(default = "default_482")] pub presence: Vec>, - #[serde(default = "default_480")] + #[serde(default = "default_483")] pub summary: std::collections::HashMap>, - #[serde(default = "default_488")] + #[serde(default = "default_491")] pub edit_targets: Vec, } @@ -9522,30 +9754,30 @@ impl CodeEditContextInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeEnclosingOutput { - #[serde(default = "default_489")] - pub lessons: Vec>, - #[serde(default = "default_490")] + #[serde(default = "default_492")] + pub lessons: Vec, + #[serde(default = "default_493")] pub lessons_left_out: Integer, pub results: Vec>, pub resolved: Integer, pub paths_indexed: Integer, pub paths_total: Integer, pub took_ms: Integer, - #[serde(default = "default_491")] + #[serde(default = "default_494")] pub as_of: std::collections::HashMap, - #[serde(default = "default_492")] + #[serde(default = "default_495")] pub bodies_returned: Integer, - #[serde(default = "default_493")] + #[serde(default = "default_496")] pub bodies_elided: Integer, - #[serde(default = "default_494")] + #[serde(default = "default_497")] pub tokens_returned: Integer, - #[serde(default = "default_495")] + #[serde(default = "default_498")] pub neighbours: Vec>, - #[serde(default = "default_496")] + #[serde(default = "default_499")] pub anchors: Integer, - #[serde(default = "default_497")] + #[serde(default = "default_500")] pub anchors_capped: bool, - #[serde(default = "default_498")] + #[serde(default = "default_501")] pub neighbour_tokens: Integer, } @@ -9701,7 +9933,7 @@ impl CodeEnclosingInput { #[non_exhaustive] pub struct CodeExamplesOutput { pub examples: Vec>, - #[serde(default = "default_499")] + #[serde(default = "default_502")] pub trace_run_id: String, } @@ -9819,19 +10051,19 @@ impl CodeExamplesInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeFilesOutput { - #[serde(default = "default_500")] + #[serde(default = "default_503")] pub files: Vec>, - #[serde(default = "default_501")] + #[serde(default = "default_504")] pub total: Integer, - #[serde(default = "default_502")] + #[serde(default = "default_505")] pub truncated: bool, - #[serde(default = "default_503")] + #[serde(default = "default_506")] pub as_of: std::collections::HashMap, - #[serde(default = "default_504")] + #[serde(default = "default_507")] pub not_covered: bool, - #[serde(default = "default_505")] + #[serde(default = "default_508")] pub note: String, - #[serde(default = "default_506")] + #[serde(default = "default_509")] pub trace_run_id: String, } @@ -9960,51 +10192,51 @@ impl CodeFilesInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeFirstBuildOutput { - #[serde(default = "default_507")] + #[serde(default = "default_510")] pub verdict: String, - #[serde(default = "default_508")] + #[serde(default = "default_511")] pub causes: Vec, - #[serde(default = "default_509")] + #[serde(default = "default_512")] pub epistemic: String, - #[serde(default = "default_510")] + #[serde(default = "default_513")] pub sha: String, - #[serde(default = "default_511")] + #[serde(default = "default_514")] pub pr_number: Integer, - #[serde(default = "default_512")] + #[serde(default = "default_515")] pub merged_at: String, - #[serde(default = "default_513")] + #[serde(default = "default_516")] pub commit_time: String, - #[serde(default = "default_514")] + #[serde(default = "default_517")] pub ledger_known: bool, - #[serde(default = "default_515")] + #[serde(default = "default_518")] pub mirror_known: bool, - #[serde(default = "default_516")] + #[serde(default = "default_519")] pub first_build: std::collections::HashMap, - #[serde(default = "default_517")] + #[serde(default = "default_520")] pub lag_hours: Option, - #[serde(default = "default_518")] + #[serde(default = "default_521")] pub later_builds: Integer, - #[serde(default = "default_519")] + #[serde(default = "default_522")] pub window_hours: Integer, - #[serde(default = "default_520")] + #[serde(default = "default_523")] pub candidates_checked: Integer, - #[serde(default = "default_521")] + #[serde(default = "default_524")] pub candidates_total: Integer, - #[serde(default = "default_522")] + #[serde(default = "default_525")] pub own_builds: Vec>, - #[serde(default = "default_523")] + #[serde(default = "default_526")] pub containing_branches: Vec, - #[serde(default = "default_524")] + #[serde(default = "default_527")] pub containing_namespaces: Vec, - #[serde(default = "default_525")] + #[serde(default = "default_528")] pub nearest_namespace: String, - #[serde(default = "default_526")] + #[serde(default = "default_529")] pub note: String, - #[serde(default = "default_527")] + #[serde(default = "default_530")] pub tracker_namespace: String, - #[serde(default = "default_528")] + #[serde(default = "default_531")] pub tracker_unavailable: bool, - #[serde(default = "default_529")] + #[serde(default = "default_532")] pub trace_run_id: String, } @@ -10123,19 +10355,19 @@ pub struct GrepDependency { pub struct RelatedGrepEvidence { pub pattern: String, pub matches: Vec>, - #[serde(default = "default_532")] + #[serde(default = "default_535")] pub contexts: Vec>, - #[serde(default = "default_533")] + #[serde(default = "default_536")] pub contexts_partial: bool, - #[serde(default = "default_534")] + #[serde(default = "default_537")] pub definitions: Vec>, - #[serde(default = "default_535")] + #[serde(default = "default_538")] pub definitions_partial: bool, - #[serde(default = "default_536")] + #[serde(default = "default_539")] pub definitions_note: String, - #[serde(default = "default_537")] + #[serde(default = "default_540")] pub truncated: bool, - #[serde(default = "default_538")] + #[serde(default = "default_541")] pub dependencies: Vec, } @@ -10151,69 +10383,69 @@ pub enum CodeGrepOutputFallback { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeGrepOutput { - #[serde(default = "default_530")] - pub lessons: Vec>, - #[serde(default = "default_531")] + #[serde(default = "default_533")] + pub lessons: Vec, + #[serde(default = "default_534")] pub lessons_left_out: Integer, pub matches: Vec>, - #[serde(default = "default_539")] + #[serde(default = "default_542")] pub related: Option, - #[serde(default = "default_540")] + #[serde(default = "default_543")] pub contexts: Vec>, - #[serde(default = "default_541")] + #[serde(default = "default_544")] pub contexts_partial: bool, - #[serde(default = "default_542")] + #[serde(default = "default_545")] pub definitions: Vec>, - #[serde(default = "default_543")] + #[serde(default = "default_546")] pub definitions_partial: bool, - #[serde(default = "default_544")] + #[serde(default = "default_547")] pub definitions_note: String, - #[serde(default = "default_545")] + #[serde(default = "default_548")] pub next_cursor: String, - #[serde(default = "default_546")] + #[serde(default = "default_549")] pub has_more: bool, - #[serde(default = "default_547")] + #[serde(default = "default_550")] pub files: Vec>, - #[serde(default = "default_548")] + #[serde(default = "default_551")] pub files_total: Integer, pub chunks_matched: Integer, - #[serde(default = "default_549")] + #[serde(default = "default_552")] pub truncated: bool, - #[serde(default = "default_550")] + #[serde(default = "default_553")] pub coverage_floor: bool, - #[serde(default = "default_551")] + #[serde(default = "default_554")] pub as_of: std::collections::HashMap, - #[serde(default = "default_552")] + #[serde(default = "default_555")] pub not_covered: bool, - #[serde(default = "default_553")] + #[serde(default = "default_556")] pub neighbours: Vec>, - #[serde(default = "default_554")] + #[serde(default = "default_557")] pub anchors: Integer, - #[serde(default = "default_555")] + #[serde(default = "default_558")] pub anchors_capped: bool, - #[serde(default = "default_556")] + #[serde(default = "default_559")] pub neighbour_tokens: Integer, - #[serde(default = "default_557")] + #[serde(default = "default_560")] pub note: String, - #[serde(default = "default_558")] + #[serde(default = "default_561")] pub verdict: String, - #[serde(default = "default_559")] + #[serde(default = "default_562")] pub template: String, - #[serde(default = "default_560")] + #[serde(default = "default_563")] pub error_code: String, - #[serde(default = "default_561")] + #[serde(default = "default_564")] pub coverage: f64, - #[serde(default = "default_562")] + #[serde(default = "default_565")] pub presence: Vec>, - #[serde(default = "default_563")] + #[serde(default = "default_566")] pub summary: std::collections::HashMap>, - #[serde(default = "default_564")] + #[serde(default = "default_567")] pub trace_run_id: String, - #[serde(default = "default_565")] + #[serde(default = "default_568")] pub partial: bool, - #[serde(default = "default_566")] + #[serde(default = "default_569")] pub partial_reason: String, - #[serde(default = "default_567")] + #[serde(default = "default_570")] pub fallback: CodeGrepOutputFallback, } @@ -10594,9 +10826,9 @@ impl CodeGrepInput { pub struct CodeHistoryOutput { pub prs: Vec>, pub paths: Vec, - #[serde(default = "default_568")] + #[serde(default = "default_571")] pub items: Vec>, - #[serde(default = "default_569")] + #[serde(default = "default_572")] pub trace_run_id: String, } @@ -10747,52 +10979,52 @@ impl CodeHistoryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeImpactOutput { - #[serde(default = "default_570")] - pub lessons: Vec>, - #[serde(default = "default_571")] + #[serde(default = "default_573")] + pub lessons: Vec, + #[serde(default = "default_574")] pub lessons_left_out: Integer, pub impacted_symbols: Vec>, pub impacted_tests: Vec>, pub co_change_files: Vec>, - #[serde(default = "default_572")] + #[serde(default = "default_575")] pub blast_radius_score: f64, - #[serde(default = "default_573")] + #[serde(default = "default_576")] pub touched_symbols: Vec>, - #[serde(default = "default_574")] + #[serde(default = "default_577")] pub co_change_missing: Vec>, - #[serde(default = "default_575")] + #[serde(default = "default_578")] pub owners: Vec>, - #[serde(default = "default_576")] + #[serde(default = "default_579")] pub reverts: Vec>, - #[serde(default = "default_577")] + #[serde(default = "default_580")] pub counts_floor: bool, - #[serde(default = "default_578")] + #[serde(default = "default_581")] pub unresolved_calls: Integer, - #[serde(default = "default_579")] + #[serde(default = "default_582")] pub ambiguous_calls: Integer, - #[serde(default = "default_580")] + #[serde(default = "default_583")] pub epistemic: String, - #[serde(default = "default_581")] + #[serde(default = "default_584")] pub causes: Vec, - #[serde(default = "default_582")] + #[serde(default = "default_585")] pub by_hop_counts: std::collections::HashMap, - #[serde(default = "default_583")] + #[serde(default = "default_586")] pub truncated: bool, - #[serde(default = "default_584")] + #[serde(default = "default_587")] pub resolved_by: String, - #[serde(default = "default_585")] + #[serde(default = "default_588")] pub verdict: String, - #[serde(default = "default_586")] + #[serde(default = "default_589")] pub paths_seen: Vec>, - #[serde(default = "default_587")] + #[serde(default = "default_590")] pub overlay: bool, - #[serde(default = "default_588")] + #[serde(default = "default_591")] pub overlay_head_sha: String, - #[serde(default = "default_589")] + #[serde(default = "default_592")] pub overlay_added: Integer, - #[serde(default = "default_590")] + #[serde(default = "default_593")] pub overlay_note: String, - #[serde(default = "default_591")] + #[serde(default = "default_594")] pub trace_run_id: String, } @@ -11060,12 +11292,12 @@ impl CodeImpactInput { #[non_exhaustive] pub struct CodeIndexErrorRow { pub path: String, - #[serde(default = "default_592")] + #[serde(default = "default_595")] pub lang: String, pub error: String, - #[serde(default = "default_593")] + #[serde(default = "default_596")] pub indexed_commit: String, - #[serde(default = "default_594")] + #[serde(default = "default_597")] pub at: String, } @@ -11073,7 +11305,7 @@ pub struct CodeIndexErrorRow { #[non_exhaustive] pub struct CodeIndexErrorsOutput { pub rows: Vec, - #[serde(default = "default_595")] + #[serde(default = "default_598")] pub total: Integer, } @@ -11173,17 +11405,17 @@ pub struct CodeCompilerTier { pub tool: String, pub label: String, pub watermark_key: String, - #[serde(default = "default_605")] + #[serde(default = "default_608")] pub commit: String, - #[serde(default = "default_606")] + #[serde(default = "default_609")] pub lag: Integer, - #[serde(default = "default_607")] + #[serde(default = "default_610")] pub updated_at: String, - #[serde(default = "default_608")] + #[serde(default = "default_611")] pub primary: bool, - #[serde(default = "default_609")] + #[serde(default = "default_612")] pub workers: Vec, - #[serde(default = "default_610")] + #[serde(default = "default_613")] pub note: String, } @@ -11191,42 +11423,42 @@ pub struct CodeCompilerTier { #[non_exhaustive] pub struct CodeTierHealth { pub tier: String, - #[serde(default = "default_612")] + #[serde(default = "default_615")] pub state: String, - #[serde(default = "default_613")] + #[serde(default = "default_616")] pub kind: String, - #[serde(default = "default_614")] + #[serde(default = "default_617")] pub error: String, - #[serde(default = "default_615")] + #[serde(default = "default_618")] pub fix: String, - #[serde(default = "default_616")] + #[serde(default = "default_619")] pub failing_since: String, - #[serde(default = "default_617")] + #[serde(default = "default_620")] pub last_failed_at: String, - #[serde(default = "default_618")] + #[serde(default = "default_621")] pub failed_passes: Integer, - #[serde(default = "default_619")] + #[serde(default = "default_622")] pub last_ok_at: String, - #[serde(default = "default_620")] + #[serde(default = "default_623")] pub lag_commits: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeWorkerStatus { - #[serde(default = "default_636")] + #[serde(default = "default_639")] pub enabled: bool, - #[serde(default = "default_637")] + #[serde(default = "default_640")] pub interval_seconds: Integer, - #[serde(default = "default_638")] + #[serde(default = "default_641")] pub last_run_at: String, - #[serde(default = "default_639")] + #[serde(default = "default_642")] pub last_duration_ms: Integer, - #[serde(default = "default_640")] + #[serde(default = "default_643")] pub consecutive_failures: Integer, - #[serde(default = "default_641")] + #[serde(default = "default_644")] pub total_runs: Integer, - #[serde(default = "default_642")] + #[serde(default = "default_645")] pub last_error: String, } @@ -11235,84 +11467,84 @@ pub struct CodeWorkerStatus { pub struct CodeIndexStatusOutput { pub repo: String, pub branch: String, - #[serde(default = "default_596")] + #[serde(default = "default_599")] pub org: String, pub namespace: String, - #[serde(default = "default_597")] + #[serde(default = "default_600")] pub provider: String, - #[serde(default = "default_598")] + #[serde(default = "default_601")] pub profile: String, - #[serde(default = "default_599")] + #[serde(default = "default_602")] pub compiler_candidates: Vec, - #[serde(default = "default_600")] + #[serde(default = "default_603")] pub quality_warnings: Vec, - #[serde(default = "default_601")] + #[serde(default = "default_604")] pub git_head: String, - #[serde(default = "default_602")] + #[serde(default = "default_605")] pub scip_commit: String, - #[serde(default = "default_603")] + #[serde(default = "default_606")] pub scip_commit_py: String, - #[serde(default = "default_604")] + #[serde(default = "default_607")] pub scip_producer: String, - #[serde(default = "default_611")] + #[serde(default = "default_614")] pub compiler_tiers: Vec, - #[serde(default = "default_621")] + #[serde(default = "default_624")] pub tier_health: Vec, - #[serde(default = "default_622")] + #[serde(default = "default_625")] pub pr_cursor: String, - #[serde(default = "default_623")] + #[serde(default = "default_626")] pub commit_coverage: Option, - #[serde(default = "default_624")] + #[serde(default = "default_627")] pub clone_head: String, - #[serde(default = "default_625")] + #[serde(default = "default_628")] pub clone_fetched_at: String, - #[serde(default = "default_626")] + #[serde(default = "default_629")] pub fetch_overdue: bool, - #[serde(default = "default_627")] + #[serde(default = "default_630")] pub fast_tier_lag: Integer, - #[serde(default = "default_628")] + #[serde(default = "default_631")] pub scip_lag: Integer, - #[serde(default = "default_629")] + #[serde(default = "default_632")] pub scip_py_lag: Integer, - #[serde(default = "default_630")] + #[serde(default = "default_633")] pub last_refresh_at: String, - #[serde(default = "default_631")] + #[serde(default = "default_634")] pub last_refresh_detail: String, - #[serde(default = "default_632")] + #[serde(default = "default_635")] pub org_readable: bool, - #[serde(default = "default_633")] + #[serde(default = "default_636")] pub path_prefixes: Vec, - #[serde(default = "default_634")] + #[serde(default = "default_637")] pub counts: std::collections::HashMap, - #[serde(default = "default_635")] + #[serde(default = "default_638")] pub state: std::collections::HashMap>, - #[serde(default = "default_643")] + #[serde(default = "default_646")] pub workers: std::collections::HashMap, - #[serde(default = "default_644")] + #[serde(default = "default_647")] pub build_commit: String, - #[serde(default = "default_645")] + #[serde(default = "default_648")] pub ops: Vec, - #[serde(default = "default_646")] + #[serde(default = "default_649")] pub request_fields: std::collections::HashMap>, - #[serde(default = "default_647")] + #[serde(default = "default_650")] pub op_maturity: std::collections::HashMap, - #[serde(default = "default_648")] + #[serde(default = "default_651")] pub op_reach: std::collections::HashMap>, - #[serde(default = "default_649")] + #[serde(default = "default_652")] pub op_toolsets: std::collections::HashMap>, - #[serde(default = "default_650")] + #[serde(default = "default_653")] pub symbol_stats_rows: Integer, - #[serde(default = "default_651")] + #[serde(default = "default_654")] pub symbol_stats_at: String, - #[serde(default = "default_652")] + #[serde(default = "default_655")] pub unit_risk_rows: Integer, - #[serde(default = "default_653")] + #[serde(default = "default_656")] pub unit_risk_at: String, - #[serde(default = "default_654")] + #[serde(default = "default_657")] pub chunks_total: Integer, - #[serde(default = "default_655")] + #[serde(default = "default_658")] pub chunks_embedded: Integer, - #[serde(default = "default_656")] + #[serde(default = "default_659")] pub embedding_coverage: f64, } @@ -11436,9 +11668,9 @@ impl CodeIndexStatusInput { pub struct CodeMapOutput { pub map: String, pub tokens_used: Integer, - #[serde(default = "default_657")] + #[serde(default = "default_660")] pub commit_sha: String, - #[serde(default = "default_658")] + #[serde(default = "default_661")] pub trace_run_id: String, } @@ -11709,32 +11941,32 @@ impl CodeOutcomeInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeOutlineOutput { - #[serde(default = "default_659")] - pub lessons: Vec>, - #[serde(default = "default_660")] + #[serde(default = "default_662")] + pub lessons: Vec, + #[serde(default = "default_663")] pub lessons_left_out: Integer, pub path: String, pub entries: Vec>, pub total: Integer, pub returned: Integer, pub elided: Integer, - #[serde(default = "default_661")] + #[serde(default = "default_664")] pub next: String, - #[serde(default = "default_662")] + #[serde(default = "default_665")] pub indexed: bool, - #[serde(default = "default_663")] + #[serde(default = "default_666")] pub verdict: String, - #[serde(default = "default_664")] + #[serde(default = "default_667")] pub tokens_returned: Integer, - #[serde(default = "default_665")] + #[serde(default = "default_668")] pub took_ms: Integer, - #[serde(default = "default_666")] + #[serde(default = "default_669")] pub head: String, - #[serde(default = "default_667")] + #[serde(default = "default_670")] pub head_truncated: bool, - #[serde(default = "default_668")] + #[serde(default = "default_671")] pub as_of: std::collections::HashMap, - #[serde(default = "default_669")] + #[serde(default = "default_672")] pub trace_run_id: String, } @@ -11886,19 +12118,19 @@ pub enum CodePathGuardsOutputEpistemic { #[non_exhaustive] pub struct CodePathGuardsOutput { pub verdict: CodePathGuardsOutputVerdict, - #[serde(default = "default_670")] + #[serde(default = "default_673")] pub causes: Vec, - #[serde(default = "default_671")] + #[serde(default = "default_674")] pub epistemic: CodePathGuardsOutputEpistemic, - #[serde(default = "default_672")] + #[serde(default = "default_675")] pub explanation: String, - #[serde(default = "default_673")] + #[serde(default = "default_676")] pub hops: Vec>, - #[serde(default = "default_674")] + #[serde(default = "default_677")] pub named_at: Vec, - #[serde(default = "default_675")] + #[serde(default = "default_678")] pub visited_symbols: Integer, - #[serde(default = "default_676")] + #[serde(default = "default_679")] pub trace_run_id: String, } @@ -12004,21 +12236,21 @@ impl CodePathGuardsInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodePrCheckOutput { - #[serde(default = "default_677")] + #[serde(default = "default_680")] pub verdict: String, - #[serde(default = "default_678")] + #[serde(default = "default_681")] pub items: Vec>, - #[serde(default = "default_679")] + #[serde(default = "default_682")] pub undecided: bool, - #[serde(default = "default_680")] + #[serde(default = "default_683")] pub epistemic: String, - #[serde(default = "default_681")] + #[serde(default = "default_684")] pub thresholds: std::collections::HashMap, - #[serde(default = "default_682")] + #[serde(default = "default_685")] pub legs: std::collections::HashMap, - #[serde(default = "default_683")] + #[serde(default = "default_686")] pub draft: std::collections::HashMap, - #[serde(default = "default_684")] + #[serde(default = "default_687")] pub trace_run_id: String, } @@ -12207,18 +12439,18 @@ pub struct CodeReadRange { pub start_line: Integer, pub end_line: Integer, pub status: CodeReadRangeStatus, - #[serde(default = "default_687")] + #[serde(default = "default_690")] pub indexed_commit: String, - #[serde(default = "default_688")] + #[serde(default = "default_691")] pub windows: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeReadOutput { - #[serde(default = "default_685")] - pub lessons: Vec>, - #[serde(default = "default_686")] + #[serde(default = "default_688")] + pub lessons: Vec, + #[serde(default = "default_689")] pub lessons_left_out: Integer, pub results: Vec, pub as_of: std::collections::HashMap, @@ -12459,15 +12691,15 @@ impl CodeReadInput { #[non_exhaustive] pub struct CodeRecentCommitRow { pub commit: String, - #[serde(default = "default_689")] + #[serde(default = "default_692")] pub subject: String, - #[serde(default = "default_690")] + #[serde(default = "default_693")] pub committed_at: String, - #[serde(default = "default_691")] + #[serde(default = "default_694")] pub ingested_at: String, - #[serde(default = "default_692")] + #[serde(default = "default_695")] pub files: Integer, - #[serde(default = "default_693")] + #[serde(default = "default_696")] pub pr_number: Integer, } @@ -12570,11 +12802,11 @@ impl CodeRecentCommitsInput { #[non_exhaustive] pub struct CodeRefreshOutput { pub triggered: bool, - #[serde(default = "default_694")] + #[serde(default = "default_697")] pub already_running: bool, - #[serde(default = "default_695")] + #[serde(default = "default_698")] pub head_before: String, - #[serde(default = "default_696")] + #[serde(default = "default_699")] pub head_after: String, } @@ -12777,22 +13009,22 @@ pub struct CodeRepoAddOutput { pub org: String, pub namespace: String, pub repo: String, - #[serde(default = "default_697")] + #[serde(default = "default_700")] pub remote: String, - #[serde(default = "default_698")] + #[serde(default = "default_701")] pub provider: String, pub branch: String, pub join_policy: String, pub classification: String, - #[serde(default = "default_699")] + #[serde(default = "default_702")] pub index_stage: String, - #[serde(default = "default_700")] + #[serde(default = "default_703")] pub my_role: String, - #[serde(default = "default_701")] + #[serde(default = "default_704")] pub remote_head: String, - #[serde(default = "default_702")] + #[serde(default = "default_705")] pub also: Vec>, - #[serde(default = "default_703")] + #[serde(default = "default_706")] pub skipped: Vec>, } @@ -13020,29 +13252,29 @@ impl CodeRepoAddBranchInput { pub struct CodeRepoRemoteBranchesOutput { pub org: String, pub repo: String, - #[serde(default = "default_704")] + #[serde(default = "default_707")] pub remote: String, - #[serde(default = "default_705")] + #[serde(default = "default_708")] pub provider: String, - #[serde(default = "default_706")] + #[serde(default = "default_709")] pub warnings: Vec, - #[serde(default = "default_707")] + #[serde(default = "default_710")] pub default_branch: String, - #[serde(default = "default_708")] + #[serde(default = "default_711")] pub branches: Vec>, - #[serde(default = "default_709")] + #[serde(default = "default_712")] pub suggested: Vec, - #[serde(default = "default_710")] + #[serde(default = "default_713")] pub indexed: Vec>, - #[serde(default = "default_711")] + #[serde(default = "default_714")] pub cap: Integer, - #[serde(default = "default_712")] + #[serde(default = "default_715")] pub total: Integer, - #[serde(default = "default_713")] + #[serde(default = "default_716")] pub matched: Integer, - #[serde(default = "default_714")] + #[serde(default = "default_717")] pub truncated: bool, - #[serde(default = "default_715")] + #[serde(default = "default_718")] pub query: String, } @@ -13133,11 +13365,11 @@ pub struct CodeRepoRemoveOutput { pub registry_deactivated: bool, pub directory_deactivated: bool, pub purged_tables: Integer, - #[serde(default = "default_716")] + #[serde(default = "default_719")] pub erasure_id: String, - #[serde(default = "default_717")] + #[serde(default = "default_720")] pub mirror_removed: bool, - #[serde(default = "default_718")] + #[serde(default = "default_721")] pub sources_deactivated: Vec, } @@ -13271,14 +13503,14 @@ impl CodeRepoSetAccessInput { pub struct CodeRepoSetSourceOutput { pub org: String, pub namespace: String, - #[serde(default = "default_719")] + #[serde(default = "default_722")] pub tracker_namespaces: Vec, - #[serde(default = "default_720")] + #[serde(default = "default_723")] pub previous_tracker_namespaces: Vec, pub effective_within_s: Integer, - #[serde(default = "default_721")] + #[serde(default = "default_724")] pub not_covering: Vec, - #[serde(default = "default_722")] + #[serde(default = "default_725")] pub warning: String, } @@ -13687,43 +13919,43 @@ pub enum CodeReviewBriefOutputLedger { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeReviewBriefOutput { - #[serde(default = "default_723")] + #[serde(default = "default_726")] pub pr_number: Integer, - #[serde(default = "default_724")] + #[serde(default = "default_727")] pub merge_sha: String, - #[serde(default = "default_725")] + #[serde(default = "default_728")] pub source: CodeReviewBriefOutputSource, - #[serde(default = "default_726")] + #[serde(default = "default_729")] pub ledger: CodeReviewBriefOutputLedger, - #[serde(default = "default_727")] + #[serde(default = "default_730")] pub stored: bool, - #[serde(default = "default_728")] + #[serde(default = "default_731")] pub provenance: std::collections::HashMap, - #[serde(default = "default_729")] + #[serde(default = "default_732")] pub overlay: bool, - #[serde(default = "default_730")] + #[serde(default = "default_733")] pub overlay_head_sha: String, - #[serde(default = "default_731")] + #[serde(default = "default_734")] pub overlay_added: Integer, - #[serde(default = "default_732")] + #[serde(default = "default_735")] pub overlay_note: String, - #[serde(default = "default_733")] + #[serde(default = "default_736")] pub tier: String, - #[serde(default = "default_734")] + #[serde(default = "default_737")] pub built_at: String, - #[serde(default = "default_735")] + #[serde(default = "default_738")] pub indexed_commit: String, - #[serde(default = "default_736")] + #[serde(default = "default_739")] pub build_ms: Integer, - #[serde(default = "default_737")] + #[serde(default = "default_740")] pub tokens_used: Integer, - #[serde(default = "default_738")] + #[serde(default = "default_741")] pub token_budget: Integer, - #[serde(default = "default_739")] + #[serde(default = "default_742")] pub decisions: std::collections::HashMap, - #[serde(default = "default_740")] + #[serde(default = "default_743")] pub sections: std::collections::HashMap>, - #[serde(default = "default_741")] + #[serde(default = "default_744")] pub trace_run_id: String, } @@ -14108,11 +14340,11 @@ pub struct CodeScipStatusOutput { pub status: String, pub parts_received: Integer, pub total_parts: Integer, - #[serde(default = "default_742")] + #[serde(default = "default_745")] pub error: String, - #[serde(default = "default_743")] + #[serde(default = "default_746")] pub commit_sha: String, - #[serde(default = "default_744")] + #[serde(default = "default_747")] pub applied_at: String, } @@ -14258,61 +14490,61 @@ pub enum CodeSearchOutputEpistemic { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeSearchOutput { - #[serde(default = "default_745")] - pub lessons: Vec>, - #[serde(default = "default_746")] + #[serde(default = "default_748")] + pub lessons: Vec, + #[serde(default = "default_749")] pub lessons_left_out: Integer, pub results: Vec, pub route: String, - #[serde(default = "default_747")] + #[serde(default = "default_750")] pub next_cursor: String, - #[serde(default = "default_748")] + #[serde(default = "default_751")] pub has_more: bool, - #[serde(default = "default_749")] + #[serde(default = "default_752")] pub history: std::collections::HashMap, - #[serde(default = "default_750")] + #[serde(default = "default_753")] pub abstain: bool, - #[serde(default = "default_751")] + #[serde(default = "default_754")] pub abstain_code: CodeSearchOutputAbstainCode, - #[serde(default = "default_752")] + #[serde(default = "default_755")] pub abstain_reason: String, - #[serde(default = "default_753")] + #[serde(default = "default_756")] pub retrieval_risk: CodeSearchOutputRetrievalRisk, - #[serde(default = "default_754")] + #[serde(default = "default_757")] pub retrieval_confidence: f64, - #[serde(default = "default_755")] + #[serde(default = "default_758")] pub route_agreement: f64, - #[serde(default = "default_756")] + #[serde(default = "default_759")] pub calibration_explanation: String, - #[serde(default = "default_757")] + #[serde(default = "default_760")] pub tokens_returned: Integer, - #[serde(default = "default_758")] + #[serde(default = "default_761")] pub constrained: bool, - #[serde(default = "default_759")] + #[serde(default = "default_762")] pub matched_files: Integer, - #[serde(default = "default_760")] + #[serde(default = "default_763")] pub as_of: std::collections::HashMap, - #[serde(default = "default_761")] + #[serde(default = "default_764")] pub score_explanation: String, - #[serde(default = "default_762")] + #[serde(default = "default_765")] pub retrieval_work: std::collections::HashMap, - #[serde(default = "default_763")] + #[serde(default = "default_766")] pub trace_run_id: String, - #[serde(default = "default_764")] + #[serde(default = "default_767")] pub top_similarity: f64, - #[serde(default = "default_765")] + #[serde(default = "default_768")] pub tracked: std::collections::HashMap, - #[serde(default = "default_766")] + #[serde(default = "default_769")] pub fanout: std::collections::HashMap, - #[serde(default = "default_767")] + #[serde(default = "default_770")] pub note: String, - #[serde(default = "default_768")] + #[serde(default = "default_771")] pub legs_timed_out: Vec, - #[serde(default = "default_769")] + #[serde(default = "default_772")] pub epistemic: CodeSearchOutputEpistemic, - #[serde(default = "default_770")] + #[serde(default = "default_773")] pub partial: bool, - #[serde(default = "default_771")] + #[serde(default = "default_774")] pub partial_reason: String, } @@ -14817,23 +15049,23 @@ impl CodeSearchInput { #[non_exhaustive] pub struct CodeSettingFactsOutput { pub name: String, - #[serde(default = "default_772")] + #[serde(default = "default_775")] pub verdict: String, - #[serde(default = "default_773")] + #[serde(default = "default_776")] pub causes: Vec, - #[serde(default = "default_774")] + #[serde(default = "default_777")] pub declaration: std::collections::HashMap, - #[serde(default = "default_775")] + #[serde(default = "default_778")] pub tier: String, - #[serde(default = "default_776")] + #[serde(default = "default_779")] pub history: Vec>, - #[serde(default = "default_777")] + #[serde(default = "default_780")] pub randomized_in_ci: std::collections::HashMap, - #[serde(default = "default_778")] + #[serde(default = "default_781")] pub tests_total: Integer, - #[serde(default = "default_779")] + #[serde(default = "default_782")] pub control: std::collections::HashMap, - #[serde(default = "default_780")] + #[serde(default = "default_783")] pub trace_run_id: String, } @@ -15255,31 +15487,31 @@ impl CodeSymbolInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeSymbolHistoryOutput { - #[serde(default = "default_781")] + #[serde(default = "default_784")] pub verdict: String, - #[serde(default = "default_782")] + #[serde(default = "default_785")] pub causes: Vec, - #[serde(default = "default_783")] + #[serde(default = "default_786")] pub epistemic: String, - #[serde(default = "default_784")] + #[serde(default = "default_787")] pub symbol: std::collections::HashMap, - #[serde(default = "default_785")] + #[serde(default = "default_788")] pub ambiguous: bool, - #[serde(default = "default_786")] + #[serde(default = "default_789")] pub candidates: Vec, - #[serde(default = "default_787")] + #[serde(default = "default_790")] pub prs: Vec>, - #[serde(default = "default_788")] + #[serde(default = "default_791")] pub review_comments: Vec>, - #[serde(default = "default_789")] + #[serde(default = "default_792")] pub open_issues_naming: Vec>, - #[serde(default = "default_790")] + #[serde(default = "default_793")] pub summary: std::collections::HashMap, - #[serde(default = "default_791")] + #[serde(default = "default_794")] pub tracker_namespace: String, - #[serde(default = "default_792")] + #[serde(default = "default_795")] pub tracker_unavailable: bool, - #[serde(default = "default_793")] + #[serde(default = "default_796")] pub trace_run_id: String, } @@ -15397,33 +15629,33 @@ impl CodeSymbolHistoryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeTestGateOutput { - #[serde(default = "default_794")] + #[serde(default = "default_797")] pub tests: Vec>, - #[serde(default = "default_795")] + #[serde(default = "default_798")] pub untested: Vec>, - #[serde(default = "default_796")] + #[serde(default = "default_799")] pub changed_files: Vec, - #[serde(default = "default_797")] + #[serde(default = "default_800")] pub touched_symbols: Vec>, - #[serde(default = "default_798")] + #[serde(default = "default_801")] pub obligations: bool, - #[serde(default = "default_799")] + #[serde(default = "default_802")] pub tests_total: Integer, - #[serde(default = "default_800")] + #[serde(default = "default_803")] pub untested_total: Integer, - #[serde(default = "default_801")] + #[serde(default = "default_804")] pub tests_capped: bool, - #[serde(default = "default_802")] + #[serde(default = "default_805")] pub untested_capped: bool, - #[serde(default = "default_803")] + #[serde(default = "default_806")] pub counts_floor: bool, - #[serde(default = "default_804")] + #[serde(default = "default_807")] pub epistemic: String, - #[serde(default = "default_805")] + #[serde(default = "default_808")] pub causes: Vec, - #[serde(default = "default_806")] + #[serde(default = "default_809")] pub by_hop_counts: std::collections::HashMap, - #[serde(default = "default_807")] + #[serde(default = "default_810")] pub trace_run_id: String, } @@ -15552,21 +15784,21 @@ impl CodeTestGateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeTestHomeOutput { - #[serde(default = "default_808")] + #[serde(default = "default_811")] pub verdict: String, - #[serde(default = "default_809")] + #[serde(default = "default_812")] pub home: String, - #[serde(default = "default_810")] + #[serde(default = "default_813")] pub candidates: Vec>, - #[serde(default = "default_811")] + #[serde(default = "default_814")] pub parts: Vec, - #[serde(default = "default_812")] + #[serde(default = "default_815")] pub src_paths: Vec, - #[serde(default = "default_813")] + #[serde(default = "default_816")] pub next_free_stateless_number: Integer, - #[serde(default = "default_814")] + #[serde(default = "default_817")] pub control: std::collections::HashMap, - #[serde(default = "default_815")] + #[serde(default = "default_818")] pub trace_run_id: String, } @@ -15706,27 +15938,27 @@ impl CodeTestHomeInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeTestsForOutput { - #[serde(default = "default_816")] + #[serde(default = "default_819")] pub tests: Vec>, - #[serde(default = "default_817")] + #[serde(default = "default_820")] pub total: Integer, - #[serde(default = "default_818")] + #[serde(default = "default_821")] pub truncated: bool, - #[serde(default = "default_819")] + #[serde(default = "default_822")] pub facets: Vec>, - #[serde(default = "default_820")] + #[serde(default = "default_823")] pub verdict: String, - #[serde(default = "default_821")] + #[serde(default = "default_824")] pub abstain: bool, - #[serde(default = "default_822")] + #[serde(default = "default_825")] pub uncovered_kinds: Vec, - #[serde(default = "default_823")] + #[serde(default = "default_826")] pub as_of: std::collections::HashMap, - #[serde(default = "default_824")] + #[serde(default = "default_827")] pub tokens_returned: Integer, - #[serde(default = "default_825")] + #[serde(default = "default_828")] pub took_ms: Integer, - #[serde(default = "default_826")] + #[serde(default = "default_829")] pub trace_run_id: String, } @@ -15832,9 +16064,9 @@ impl CodeTestsForInput { pub struct CodeTraceOutput { pub frames: Vec>, pub definitions: Vec, - #[serde(default = "default_827")] + #[serde(default = "default_830")] pub tokens_returned: Integer, - #[serde(default = "default_828")] + #[serde(default = "default_831")] pub trace_run_id: String, } @@ -15950,16 +16182,16 @@ pub enum CodeVerifyOutputVerdict { #[non_exhaustive] pub struct CodeVerifyOutput { pub verdict: CodeVerifyOutputVerdict, - #[serde(default = "default_829")] + #[serde(default = "default_832")] pub reason: String, pub explanation: String, - #[serde(default = "default_830")] + #[serde(default = "default_833")] pub evidence: Vec>, - #[serde(default = "default_831")] + #[serde(default = "default_834")] pub floors: std::collections::HashMap, - #[serde(default = "default_832")] + #[serde(default = "default_835")] pub index_verdict: String, - #[serde(default = "default_833")] + #[serde(default = "default_836")] pub trace_run_id: String, } @@ -16081,29 +16313,29 @@ impl CodeVerifyInput { #[non_exhaustive] pub struct CodeVerifyCitationsOutput { pub verdict: String, - #[serde(default = "default_834")] + #[serde(default = "default_837")] pub counts: std::collections::HashMap, - #[serde(default = "default_835")] + #[serde(default = "default_838")] pub citations: Vec>, - #[serde(default = "default_836")] + #[serde(default = "default_839")] pub skipped: Vec>, - #[serde(default = "default_837")] + #[serde(default = "default_840")] pub truncated: bool, - #[serde(default = "default_838")] + #[serde(default = "default_841")] pub epistemic: std::collections::HashMap, - #[serde(default = "default_839")] + #[serde(default = "default_842")] pub at_commit: std::collections::HashMap, - #[serde(default = "default_840")] + #[serde(default = "default_843")] pub pr_diff: std::collections::HashMap, - #[serde(default = "default_841")] + #[serde(default = "default_844")] pub namespaces: Vec, - #[serde(default = "default_842")] + #[serde(default = "default_845")] pub took_ms: Integer, - #[serde(default = "default_843")] + #[serde(default = "default_846")] pub as_of: std::collections::HashMap, - #[serde(default = "default_844")] + #[serde(default = "default_847")] pub note: String, - #[serde(default = "default_845")] + #[serde(default = "default_848")] pub trace_run_id: String, } @@ -16276,7 +16508,7 @@ pub struct CollectionCreateOutput { pub namespace: String, pub parent: String, pub created: bool, - #[serde(default = "default_846")] + #[serde(default = "default_849")] pub title: String, } @@ -16374,9 +16606,9 @@ impl CollectionCreateInput { pub struct CollectionDeleteOutput { pub namespace: String, pub deleted: bool, - #[serde(default = "default_847")] + #[serde(default = "default_850")] pub erasure_id: String, - #[serde(default = "default_848")] + #[serde(default = "default_851")] pub erasure_status: String, } @@ -16418,11 +16650,11 @@ pub struct CollectionEntry { pub parent: String, pub personal: bool, pub role: String, - #[serde(default = "default_849")] + #[serde(default = "default_852")] pub description: String, - #[serde(default = "default_850")] + #[serde(default = "default_853")] pub title: String, - #[serde(default = "default_851")] + #[serde(default = "default_854")] pub document_count: Option, } @@ -16430,7 +16662,7 @@ pub struct CollectionEntry { #[non_exhaustive] pub struct CollectionListOutput { pub collections: Vec, - #[serde(default = "default_852")] + #[serde(default = "default_855")] pub next_cursor: Option, } @@ -16772,11 +17004,11 @@ pub struct ConflictRow { #[non_exhaustive] pub struct ConflictsListOutput { pub rows: Vec, - #[serde(default = "default_853")] + #[serde(default = "default_856")] pub next_before_version: Option, - #[serde(default = "default_854")] + #[serde(default = "default_857")] pub total: Option, - #[serde(default = "default_855")] + #[serde(default = "default_858")] pub keys: Option>, } @@ -16928,7 +17160,7 @@ pub struct ConflictRevisionSuggestion { pub target_local_id: Integer, pub peer_local_ids: Vec, pub rationale: String, - #[serde(default = "default_857")] + #[serde(default = "default_860")] pub apply_operation: String, } @@ -16936,11 +17168,11 @@ pub struct ConflictRevisionSuggestion { #[non_exhaustive] pub struct ConflictsProposeRevisionOutput { pub found: bool, - #[serde(default = "default_856")] + #[serde(default = "default_859")] pub memories: Vec, - #[serde(default = "default_858")] + #[serde(default = "default_861")] pub suggestions: Vec, - #[serde(default = "default_859")] + #[serde(default = "default_862")] pub note: String, } @@ -17020,9 +17252,9 @@ pub struct ConflictsResolveOutput { pub resolved: bool, pub decision: ConflictsResolveOutputDecision, pub affected_memory_ids: Vec, - #[serde(default = "default_860")] + #[serde(default = "default_863")] pub resolved_at: Option, - #[serde(default = "default_861")] + #[serde(default = "default_864")] pub total: Option, } @@ -17179,9 +17411,9 @@ pub enum ConnectionEntryKind { pub struct ConnectionEntry { pub kind: ConnectionEntryKind, pub connected: bool, - #[serde(default = "default_862")] + #[serde(default = "default_865")] pub account_email: Option, - #[serde(default = "default_863")] + #[serde(default = "default_866")] pub scopes: Vec, pub connect_url: String, } @@ -17356,23 +17588,23 @@ impl ConsolidationsListInput { pub struct ContextFetchOutput { pub found: bool, pub blob_key: String, - #[serde(default = "default_864")] + #[serde(default = "default_867")] pub content: String, - #[serde(default = "default_865")] + #[serde(default = "default_868")] pub content_type: String, - #[serde(default = "default_866")] + #[serde(default = "default_869")] pub summary: String, - #[serde(default = "default_867")] + #[serde(default = "default_870")] pub total_chars: Integer, - #[serde(default = "default_868")] + #[serde(default = "default_871")] pub total_lines: Integer, - #[serde(default = "default_869")] + #[serde(default = "default_872")] pub offset: Integer, - #[serde(default = "default_870")] + #[serde(default = "default_873")] pub next_offset: Integer, - #[serde(default = "default_871")] + #[serde(default = "default_874")] pub matched_lines: Integer, - #[serde(default = "default_872")] + #[serde(default = "default_875")] pub expires_at: Option, } @@ -17666,9 +17898,9 @@ pub enum ConversationAppendOutputReason { pub struct ConversationAppendOutput { pub msg_id: String, pub ts: String, - #[serde(default = "default_873")] + #[serde(default = "default_876")] pub stored: bool, - #[serde(default = "default_874")] + #[serde(default = "default_877")] pub reason: ConversationAppendOutputReason, } @@ -17817,13 +18049,13 @@ impl ConversationAppendInput { pub struct ConversationCompactOutput { pub compacted: bool, pub messages_summarized: Integer, - #[serde(default = "default_875")] + #[serde(default = "default_878")] pub summary_msg_id: String, - #[serde(default = "default_876")] + #[serde(default = "default_879")] pub tokens_in: Integer, - #[serde(default = "default_877")] + #[serde(default = "default_880")] pub tokens_out: Integer, - #[serde(default = "default_878")] + #[serde(default = "default_881")] pub reason: String, } @@ -18087,7 +18319,7 @@ pub enum ConversationEntryRole { #[non_exhaustive] pub struct ConversationEntry { pub msg_id: String, - #[serde(default = "default_887")] + #[serde(default = "default_890")] pub agent: String, pub role: ConversationEntryRole, pub content: String, @@ -18104,25 +18336,25 @@ pub struct ConversationEntry { pub struct ConversationGetOutput { pub found: bool, pub thread_id: String, - #[serde(default = "default_879")] + #[serde(default = "default_882")] pub title: String, - #[serde(default = "default_880")] + #[serde(default = "default_883")] pub metadata: std::collections::HashMap, - #[serde(default = "default_881")] + #[serde(default = "default_884")] pub run_id: String, - #[serde(default = "default_882")] + #[serde(default = "default_885")] pub user_id: String, - #[serde(default = "default_883")] + #[serde(default = "default_886")] pub agent: String, - #[serde(default = "default_884")] + #[serde(default = "default_887")] pub created_at: Option, - #[serde(default = "default_885")] + #[serde(default = "default_888")] pub updated_at: Option, - #[serde(default = "default_886")] + #[serde(default = "default_889")] pub msg_count: Integer, - #[serde(default = "default_888")] + #[serde(default = "default_891")] pub messages: Vec, - #[serde(default = "default_889")] + #[serde(default = "default_892")] pub next_cursor: Option, } @@ -18236,7 +18468,7 @@ impl ConversationGetInput { #[non_exhaustive] pub struct ConversationListOutput { pub rows: Vec, - #[serde(default = "default_890")] + #[serde(default = "default_893")] pub next_cursor: Option, } @@ -18382,7 +18614,7 @@ pub struct SavedMessageHit { #[non_exhaustive] pub struct ConversationListSavedMessagesOutput { pub rows: Vec, - #[serde(default = "default_891")] + #[serde(default = "default_894")] pub next_cursor: Option, } @@ -18522,7 +18754,7 @@ pub struct ConversationSaveMessageOutput { pub conversation_id: String, pub message_id: String, pub indexed: bool, - #[serde(default = "default_892")] + #[serde(default = "default_895")] pub reason: ConversationSaveMessageOutputReason, pub ts: String, } @@ -18695,7 +18927,7 @@ pub struct ConversationHit { pub role: ConversationHitRole, pub content_excerpt: String, pub ts: String, - #[serde(default = "default_893")] + #[serde(default = "default_896")] pub namespace: String, } @@ -18703,7 +18935,7 @@ pub struct ConversationHit { #[non_exhaustive] pub struct ConversationSearchOutput { pub hits: Vec, - #[serde(default = "default_894")] + #[serde(default = "default_897")] pub namespaces_skipped: Vec, } @@ -19236,7 +19468,7 @@ pub struct ConversationUnsaveMessageOutput { pub conversation_id: String, pub message_id: String, pub found: bool, - #[serde(default = "default_895")] + #[serde(default = "default_898")] pub removed: bool, pub ts: String, } @@ -19309,7 +19541,7 @@ impl ConversationUnsaveMessageInput { pub struct ConversationUpdateOutput { pub updated: bool, pub thread_id: String, - #[serde(default = "default_896")] + #[serde(default = "default_899")] pub updated_at: Option, } @@ -19414,17 +19646,17 @@ impl ConversationUpdateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CostAgentSummaryRow { - #[serde(default = "default_897")] + #[serde(default = "default_900")] pub namespace: Option, - #[serde(default = "default_898")] + #[serde(default = "default_901")] pub agent: Option, - #[serde(default = "default_899")] + #[serde(default = "default_902")] pub day: Option, - #[serde(default = "default_900")] + #[serde(default = "default_903")] pub model: Option, - #[serde(default = "default_901")] + #[serde(default = "default_904")] pub consumer: Option, - #[serde(default = "default_902")] + #[serde(default = "default_905")] pub session_id: Option, pub turns: Integer, pub sessions: Integer, @@ -19573,18 +19805,18 @@ pub enum BudgetStatusOutputCapSource { #[non_exhaustive] pub struct BudgetStatusOutput { pub namespace: String, - #[serde(default = "default_903")] + #[serde(default = "default_906")] pub user_id: Option, #[serde(deserialize_with = "required_nullable")] pub spent_24h_usd: Option, pub cap_usd: f64, pub cap_source: BudgetStatusOutputCapSource, pub over_cap: bool, - #[serde(default = "default_904")] + #[serde(default = "default_907")] pub namespace_over_cap: Option, - #[serde(default = "default_905")] + #[serde(default = "default_908")] pub pct_of_cap: Option, - #[serde(default = "default_906")] + #[serde(default = "default_909")] pub namespaces_with_spend: Integer, } @@ -19657,11 +19889,11 @@ impl BudgetStatusInput { pub struct CostRecordTurnsOutput { pub recorded: Integer, pub priced: Integer, - #[serde(default = "default_907")] + #[serde(default = "default_910")] pub unpriced_models: Vec, - #[serde(default = "default_908")] + #[serde(default = "default_911")] pub cost_usd: f64, - #[serde(default = "default_909")] + #[serde(default = "default_912")] pub turns_dated_ahead: Integer, } @@ -19832,25 +20064,25 @@ impl CostRecordTurnsInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CostSummaryRow { - #[serde(default = "default_910")] + #[serde(default = "default_913")] pub namespace: Option, - #[serde(default = "default_911")] + #[serde(default = "default_914")] pub agent: Option, - #[serde(default = "default_912")] + #[serde(default = "default_915")] pub day: Option, - #[serde(default = "default_913")] + #[serde(default = "default_916")] pub operation: Option, - #[serde(default = "default_914")] + #[serde(default = "default_917")] pub memory_key: Option, - #[serde(default = "default_915")] + #[serde(default = "default_918")] pub user_id: Option, - #[serde(default = "default_916")] + #[serde(default = "default_919")] pub model: Option, - #[serde(default = "default_917")] + #[serde(default = "default_920")] pub traffic_class: Option, - #[serde(default = "default_918")] + #[serde(default = "default_921")] pub instance_label: Option, - #[serde(default = "default_919")] + #[serde(default = "default_922")] pub build_commit: Option, pub ops: Integer, pub errors: Integer, @@ -19860,9 +20092,9 @@ pub struct CostSummaryRow { pub latency_p50_ms: f64, pub latency_p95_ms: f64, pub latency_p99_ms: f64, - #[serde(default = "default_920")] + #[serde(default = "default_923")] pub cache_hits: Integer, - #[serde(default = "default_921")] + #[serde(default = "default_924")] pub cache_saved_usd: f64, } @@ -19873,9 +20105,9 @@ pub struct CostSummaryOutput { pub total_ops: Integer, pub total_errors: Integer, pub total_cost_usd: f64, - #[serde(default = "default_922")] + #[serde(default = "default_925")] pub cache_hits: Integer, - #[serde(default = "default_923")] + #[serde(default = "default_926")] pub cache_saved_usd: f64, } @@ -20062,31 +20294,31 @@ pub enum DecisionRowStage { #[non_exhaustive] pub struct DecisionRow { pub memory_key: String, - #[serde(default = "default_924")] + #[serde(default = "default_927")] pub category: String, - #[serde(default = "default_925")] + #[serde(default = "default_928")] pub scenario: String, - #[serde(default = "default_926")] + #[serde(default = "default_929")] pub reasoning: String, - #[serde(default = "default_927")] + #[serde(default = "default_930")] pub outcome: String, - #[serde(default = "default_928")] + #[serde(default = "default_931")] pub alternatives: Vec, - #[serde(default = "default_929")] + #[serde(default = "default_932")] pub confidence: Option, - #[serde(default = "default_930")] + #[serde(default = "default_933")] pub decision_maker: String, - #[serde(default = "default_931")] + #[serde(default = "default_934")] pub run_id: String, - #[serde(default = "default_932")] + #[serde(default = "default_935")] pub realized_outcome: String, - #[serde(default = "default_933")] + #[serde(default = "default_936")] pub success: Option, - #[serde(default = "default_934")] + #[serde(default = "default_937")] pub made_at: String, - #[serde(default = "default_935")] + #[serde(default = "default_938")] pub stage: DecisionRowStage, - #[serde(default = "default_936")] + #[serde(default = "default_939")] pub similarity: f64, } @@ -20098,7 +20330,7 @@ pub struct ChainNodeRow { pub relation: String, pub direction: String, pub via: String, - #[serde(default = "default_938")] + #[serde(default = "default_941")] pub decision: Option, } @@ -20106,7 +20338,7 @@ pub struct ChainNodeRow { #[non_exhaustive] pub struct DecisionChainOutput { pub seed: String, - #[serde(default = "default_937")] + #[serde(default = "default_940")] pub seed_decision: Option, pub nodes: Vec, } @@ -20191,7 +20423,7 @@ impl DecisionChainInput { pub struct DecisionOutcomeOutput { pub memory_key: String, pub updated: bool, - #[serde(default = "default_939")] + #[serde(default = "default_942")] pub memories_credited: Integer, } @@ -20269,7 +20501,7 @@ impl DecisionOutcomeInput { #[non_exhaustive] pub struct DecisionPrecedentsOutput { pub precedents: Vec, - #[serde(default = "default_940")] + #[serde(default = "default_943")] pub embedding_model: String, } @@ -20364,11 +20596,11 @@ impl DecisionPrecedentsInput { pub struct DecisionRecordOutput { pub memory_key: String, pub record_id: String, - #[serde(default = "default_941")] + #[serde(default = "default_944")] pub superseded_prior: bool, - #[serde(default = "default_942")] + #[serde(default = "default_945")] pub edges_written: Integer, - #[serde(default = "default_943")] + #[serde(default = "default_946")] pub next: String, } @@ -20644,7 +20876,7 @@ pub enum ErasureExportOutputScopeType { pub struct ErasureExportSection { pub rows: Vec>, pub count: Integer, - #[serde(default = "default_944")] + #[serde(default = "default_947")] pub truncated: bool, } @@ -20757,17 +20989,17 @@ pub struct ErasureListRow { pub requester: String, pub status: ErasureListRowStatus, pub requested_at: String, - #[serde(default = "default_945")] + #[serde(default = "default_948")] pub completed_at: Option, - #[serde(default = "default_946")] + #[serde(default = "default_949")] pub failure_reason: String, - #[serde(default = "default_947")] + #[serde(default = "default_950")] pub steps_completed_count: Integer, - #[serde(default = "default_948")] + #[serde(default = "default_951")] pub reversals_count: Integer, - #[serde(default = "default_949")] + #[serde(default = "default_952")] pub residue_count: Integer, - #[serde(default = "default_950")] + #[serde(default = "default_953")] pub verified_at: Option, } @@ -20864,7 +21096,7 @@ pub enum ErasureRequestOutputStatus { pub struct ErasureStepResult { pub step: String, pub rows_affected: Integer, - #[serde(default = "default_951")] + #[serde(default = "default_954")] pub notes: String, } @@ -20875,21 +21107,21 @@ pub struct ErasureRequestOutput { pub status: ErasureRequestOutputStatus, pub steps: Vec, pub requested_at: String, - #[serde(default = "default_952")] + #[serde(default = "default_955")] pub completed_at: Option, - #[serde(default = "default_953")] + #[serde(default = "default_956")] pub residue_count: Integer, - #[serde(default = "default_954")] + #[serde(default = "default_957")] pub residue: std::collections::HashMap, - #[serde(default = "default_955")] + #[serde(default = "default_958")] pub verified_at: Option, - #[serde(default = "default_956")] + #[serde(default = "default_959")] pub census: Option>, - #[serde(default = "default_957")] + #[serde(default = "default_960")] pub purge: bool, - #[serde(default = "default_958")] + #[serde(default = "default_961")] pub failure_reason: String, - #[serde(default = "default_959")] + #[serde(default = "default_962")] pub steps_completed: Vec, } @@ -21001,33 +21233,33 @@ pub enum ErasureStatusOutputStatus { pub struct ErasureStatusOutput { pub found: bool, pub erasure_id: String, - #[serde(default = "default_960")] + #[serde(default = "default_963")] pub org: Option, - #[serde(default = "default_961")] + #[serde(default = "default_964")] pub scope_type: Option, - #[serde(default = "default_962")] + #[serde(default = "default_965")] pub scope_value: Option, - #[serde(default = "default_963")] + #[serde(default = "default_966")] pub requester: Option, - #[serde(default = "default_964")] + #[serde(default = "default_967")] pub status: Option, - #[serde(default = "default_965")] + #[serde(default = "default_968")] pub current_step: Option, - #[serde(default = "default_966")] + #[serde(default = "default_969")] pub requested_at: Option, - #[serde(default = "default_967")] + #[serde(default = "default_970")] pub completed_at: Option, - #[serde(default = "default_968")] + #[serde(default = "default_971")] pub failure_reason: Option, - #[serde(default = "default_969")] + #[serde(default = "default_972")] pub residue_count: Integer, - #[serde(default = "default_970")] + #[serde(default = "default_973")] pub residue: std::collections::HashMap, - #[serde(default = "default_971")] + #[serde(default = "default_974")] pub verified_at: Option, - #[serde(default = "default_972")] + #[serde(default = "default_975")] pub census: Option>, - #[serde(default = "default_973")] + #[serde(default = "default_976")] pub purge: bool, } @@ -21064,9 +21296,9 @@ pub enum ExtractionPolicyOutputScope { #[non_exhaustive] pub struct NamespacePolicy { pub namespace: String, - #[serde(default = "default_979")] + #[serde(default = "default_982")] pub updated_by: String, - #[serde(default = "default_980")] + #[serde(default = "default_983")] pub updated_at: Option, } @@ -21075,17 +21307,17 @@ pub struct NamespacePolicy { pub struct ExtractionPolicyOutput { pub org: String, pub scope: ExtractionPolicyOutputScope, - #[serde(default = "default_974")] + #[serde(default = "default_977")] pub namespace: String, - #[serde(default = "default_975")] + #[serde(default = "default_978")] pub policy: String, - #[serde(default = "default_976")] + #[serde(default = "default_979")] pub updated_by: String, - #[serde(default = "default_977")] + #[serde(default = "default_980")] pub updated_at: Option, - #[serde(default = "default_978")] - pub effective: String, #[serde(default = "default_981")] + pub effective: String, + #[serde(default = "default_984")] pub namespace_policies: Vec, } @@ -21319,13 +21551,13 @@ pub struct FactRow { pub object: String, pub co_occur: Integer, pub last_seen: String, - #[serde(default = "default_982")] + #[serde(default = "default_985")] pub provenance: String, - #[serde(default = "default_983")] + #[serde(default = "default_986")] pub source_keys: Vec, - #[serde(default = "default_984")] + #[serde(default = "default_987")] pub sources: Vec, - #[serde(default = "default_985")] + #[serde(default = "default_988")] pub stale: bool, } @@ -21333,7 +21565,7 @@ pub struct FactRow { #[non_exhaustive] pub struct FactsListOutput { pub rows: Vec, - #[serde(default = "default_986")] + #[serde(default = "default_989")] pub truncated: bool, } @@ -21552,14 +21784,14 @@ impl FactsListInput { pub struct PathEdge { pub entity_a: String, pub entity_b: String, - #[serde(default = "default_987")] + #[serde(default = "default_990")] pub relation: String, - #[serde(default = "default_988")] + #[serde(default = "default_991")] pub direction: String, pub co_occur: Integer, - #[serde(default = "default_989")] + #[serde(default = "default_992")] pub valid_from: Option, - #[serde(default = "default_990")] + #[serde(default = "default_993")] pub valid_to: Option, } @@ -21790,23 +22022,23 @@ pub struct TraversalNode { pub hop: Integer, pub cumulative_weight: f64, pub via_co_occur: Integer, - #[serde(default = "default_992")] + #[serde(default = "default_995")] pub hub: bool, - #[serde(default = "default_993")] + #[serde(default = "default_996")] pub degree: Integer, - #[serde(default = "default_994")] + #[serde(default = "default_997")] pub via_relation: String, - #[serde(default = "default_995")] + #[serde(default = "default_998")] pub via_direction: String, - #[serde(default = "default_996")] + #[serde(default = "default_999")] pub via_provenance: String, - #[serde(default = "default_997")] + #[serde(default = "default_1000")] pub valid_from: String, - #[serde(default = "default_998")] + #[serde(default = "default_1001")] pub valid_to: String, - #[serde(default = "default_999")] + #[serde(default = "default_1002")] pub community_id: Option, - #[serde(default = "default_1000")] + #[serde(default = "default_1003")] pub path: Vec, } @@ -21814,12 +22046,12 @@ pub struct TraversalNode { #[non_exhaustive] pub struct FactsTraverseOutput { pub seed: String, - #[serde(default = "default_991")] + #[serde(default = "default_994")] pub seed_community_id: Option, pub nodes: Vec, - #[serde(default = "default_1001")] + #[serde(default = "default_1004")] pub truncated: bool, - #[serde(default = "default_1002")] + #[serde(default = "default_1005")] pub hubs: Vec, } @@ -22028,7 +22260,7 @@ pub struct GrantsApproveOutput { pub subject: String, pub namespace: String, pub decision: GrantsApproveOutputDecision, - #[serde(default = "default_1003")] + #[serde(default = "default_1006")] pub role: Option, pub decided_at: String, } @@ -22307,9 +22539,9 @@ pub struct GrantEntry { #[non_exhaustive] pub struct GrantsListOutput { pub rows: Vec, - #[serde(default = "default_1004")] + #[serde(default = "default_1007")] pub next_cursor: Option, - #[serde(default = "default_1005")] + #[serde(default = "default_1008")] pub truncated: bool, } @@ -22425,12 +22657,12 @@ pub enum PendingForMeEntryRequestedRole { #[non_exhaustive] pub struct PendingForMeEntry { pub namespace: String, - #[serde(default = "default_1006")] + #[serde(default = "default_1009")] pub kind: String, pub subject: String, pub current_role: PendingForMeEntryCurrentRole, pub requested_role: PendingForMeEntryRequestedRole, - #[serde(default = "default_1007")] + #[serde(default = "default_1010")] pub pending_since: Option, } @@ -22489,7 +22721,7 @@ impl GrantsPendingForMeInput { #[non_exhaustive] pub struct GrantsRevokeOutput { pub revoked: bool, - #[serde(default = "default_1008")] + #[serde(default = "default_1011")] pub revoked_at: Option, } @@ -22619,7 +22851,7 @@ impl GrantsShareAgentInput { #[non_exhaustive] pub struct GrantsUnshareAgentOutput { pub revoked: bool, - #[serde(default = "default_1009")] + #[serde(default = "default_1012")] pub revoked_at: Option, } @@ -22679,7 +22911,7 @@ pub enum HelpGetOutputAudience { pub struct HelpOutlineEntry { pub section: String, pub anchor: String, - #[serde(default = "default_1017")] + #[serde(default = "default_1020")] pub heading: String, } @@ -22689,21 +22921,21 @@ pub struct HelpGetOutput { pub available: bool, pub found: bool, pub path: String, - #[serde(default = "default_1010")] + #[serde(default = "default_1013")] pub title: String, - #[serde(default = "default_1011")] + #[serde(default = "default_1014")] pub section: String, - #[serde(default = "default_1012")] + #[serde(default = "default_1015")] pub anchor: String, - #[serde(default = "default_1013")] + #[serde(default = "default_1016")] pub audience: HelpGetOutputAudience, - #[serde(default = "default_1014")] + #[serde(default = "default_1017")] pub text: String, - #[serde(default = "default_1015")] + #[serde(default = "default_1018")] pub truncated: bool, - #[serde(default = "default_1016")] + #[serde(default = "default_1019")] pub next_offset: Integer, - #[serde(default = "default_1018")] + #[serde(default = "default_1021")] pub sections: Vec, } @@ -22848,21 +23080,21 @@ pub struct InboxPayload { pub inbox: String, pub owner_agent: String, pub owner_namespace: String, - #[serde(default = "default_1019")] + #[serde(default = "default_1022")] pub description: String, - #[serde(default = "default_1020")] + #[serde(default = "default_1023")] pub posters: Vec, - #[serde(default = "default_1021")] + #[serde(default = "default_1024")] pub accept_disclosure: Vec, pub default_lease_seconds: Integer, pub max_attempts: Integer, pub max_defers: Integer, pub triage_escalate_after_seconds: Integer, - #[serde(default = "default_1022")] + #[serde(default = "default_1025")] pub webhook_url: String, - #[serde(default = "default_1023")] + #[serde(default = "default_1026")] pub created_by: String, - #[serde(default = "default_1024")] + #[serde(default = "default_1027")] pub owner_subject: String, pub created_at: String, pub updated_at: String, @@ -22972,9 +23204,9 @@ pub struct PolicyPayload { pub poster: String, pub kind: String, pub mode: PolicyPayloadMode, - #[serde(default = "default_1025")] + #[serde(default = "default_1028")] pub require_evidence: Vec, - #[serde(default = "default_1026")] + #[serde(default = "default_1029")] pub set_by: String, pub set_at: String, pub version: Integer, @@ -23044,7 +23276,7 @@ impl InboxPolicyListInput { pub struct InboxPolicySetOutput { #[serde(deserialize_with = "required_nullable")] pub policy: Option, - #[serde(default = "default_1027")] + #[serde(default = "default_1030")] pub removed: bool, } @@ -23173,15 +23405,15 @@ pub struct Principal { pub subject: String, pub label: String, pub kind: PrincipalKind, - #[serde(default = "default_1028")] + #[serde(default = "default_1031")] pub namespaces: Vec, - #[serde(default = "default_1029")] + #[serde(default = "default_1032")] pub roles: Vec, - #[serde(default = "default_1030")] + #[serde(default = "default_1033")] pub last_seen: Option, - #[serde(default = "default_1031")] + #[serde(default = "default_1034")] pub can_already_post: bool, - #[serde(default = "default_1032")] + #[serde(default = "default_1035")] pub listed: bool, } @@ -23543,15 +23775,15 @@ pub struct AnalysisColumn { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct InsightsQueryOutput { - #[serde(default = "default_1033")] + #[serde(default = "default_1036")] pub columns: Vec, - #[serde(default = "default_1034")] + #[serde(default = "default_1037")] pub rows: Vec>, - #[serde(default = "default_1035")] + #[serde(default = "default_1038")] pub row_count: Integer, - #[serde(default = "default_1036")] + #[serde(default = "default_1039")] pub truncated: bool, - #[serde(default = "default_1037")] + #[serde(default = "default_1040")] pub sql_digest: String, } @@ -23850,32 +24082,32 @@ pub struct DatasetOut { pub dataset_id: String, pub source_uri: String, pub name: String, - #[serde(default = "default_1038")] + #[serde(default = "default_1041")] pub sheet: String, - #[serde(default = "default_1039")] + #[serde(default = "default_1042")] pub row_start: Integer, - #[serde(default = "default_1040")] + #[serde(default = "default_1043")] pub row_end: Integer, pub revision: Integer, pub snapshot_id: String, pub schema_state: String, pub columns: Vec, - #[serde(default = "default_1041")] + #[serde(default = "default_1044")] pub clarifications: Vec, pub row_count: Integer, - #[serde(default = "default_1042")] + #[serde(default = "default_1045")] pub rejected_rows: Integer, - #[serde(default = "default_1043")] + #[serde(default = "default_1046")] pub rejected: Vec, - #[serde(default = "default_1044")] + #[serde(default = "default_1047")] pub complete: bool, - #[serde(default = "default_1045")] + #[serde(default = "default_1048")] pub approved_by: String, - #[serde(default = "default_1046")] + #[serde(default = "default_1049")] pub approved_at: Option, - #[serde(default = "default_1047")] + #[serde(default = "default_1050")] pub created_at: Option, - #[serde(default = "default_1048")] + #[serde(default = "default_1051")] pub rows: Vec>, } @@ -23883,9 +24115,9 @@ pub struct DatasetOut { #[non_exhaustive] pub struct KnowledgeDatasetApproveOutput { pub found: bool, - #[serde(default = "default_1049")] + #[serde(default = "default_1052")] pub dataset: Option, - #[serde(default = "default_1050")] + #[serde(default = "default_1053")] pub retyped: bool, } @@ -23979,9 +24211,9 @@ impl KnowledgeDatasetApproveInput { #[non_exhaustive] pub struct KnowledgeDatasetGetOutput { pub found: bool, - #[serde(default = "default_1051")] + #[serde(default = "default_1054")] pub revision: Integer, - #[serde(default = "default_1052")] + #[serde(default = "default_1055")] pub datasets: Vec, } @@ -24054,7 +24286,7 @@ impl KnowledgeDatasetGetInput { pub struct KnowledgeDocCluster { pub content_sha256: String, pub doc_count: Integer, - #[serde(default = "default_1053")] + #[serde(default = "default_1056")] pub docs: Vec>, } @@ -24064,16 +24296,16 @@ pub struct KnowledgeChunkCluster { pub content_sha256: String, pub chunk_count: Integer, pub uri_count: Integer, - #[serde(default = "default_1055")] + #[serde(default = "default_1058")] pub samples: Vec>, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeDedupListOutput { - #[serde(default = "default_1054")] + #[serde(default = "default_1057")] pub doc_clusters: Vec, - #[serde(default = "default_1056")] + #[serde(default = "default_1059")] pub chunk_clusters: Vec, } @@ -24150,7 +24382,7 @@ pub struct KnowledgeDedupResolveOutput { pub canonical_uri: String, pub duplicate_uri: String, pub decision: String, - #[serde(default = "default_1057")] + #[serde(default = "default_1060")] pub superseded_uri: String, } @@ -24269,24 +24501,24 @@ impl KnowledgeDeleteInput { #[non_exhaustive] pub struct KnowledgeFormat { pub format: String, - #[serde(default = "default_1058")] + #[serde(default = "default_1061")] pub extensions: Vec, - #[serde(default = "default_1059")] + #[serde(default = "default_1062")] pub media_types: Vec, - #[serde(default = "default_1060")] + #[serde(default = "default_1063")] pub available: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeFormatsOutput { - #[serde(default = "default_1061")] + #[serde(default = "default_1064")] pub formats: Vec, - #[serde(default = "default_1062")] + #[serde(default = "default_1065")] pub max_upload_bytes: Integer, - #[serde(default = "default_1063")] + #[serde(default = "default_1066")] pub refused_extensions: Vec, - #[serde(default = "default_1064")] + #[serde(default = "default_1067")] pub default_format: String, } @@ -24388,7 +24620,7 @@ impl KnowledgeGapsDraftInput { pub struct KnowledgeGap { pub gap_id: String, pub head: String, - #[serde(default = "default_1065")] + #[serde(default = "default_1068")] pub samples: Vec, pub askers: Integer, pub asks: Integer, @@ -24398,13 +24630,13 @@ pub struct KnowledgeGap { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeGapsListOutput { - #[serde(default = "default_1066")] + #[serde(default = "default_1069")] pub gaps: Vec, - #[serde(default = "default_1067")] + #[serde(default = "default_1070")] pub built_at: Option, - #[serde(default = "default_1068")] + #[serde(default = "default_1071")] pub capturing: Option, - #[serde(default = "default_1069")] + #[serde(default = "default_1072")] pub enabled: bool, } @@ -24470,7 +24702,7 @@ pub struct KnowledgeIngestOutput { pub ingestion_id: String, pub state: String, pub source_uri: String, - #[serde(default = "default_1070")] + #[serde(default = "default_1073")] pub namespace: String, } @@ -24689,9 +24921,9 @@ impl KnowledgeIngestInput { #[non_exhaustive] pub struct KnowledgeIngestCancelOutput { pub found: bool, - #[serde(default = "default_1071")] + #[serde(default = "default_1074")] pub state: String, - #[serde(default = "default_1072")] + #[serde(default = "default_1075")] pub cancelled: bool, } @@ -24742,39 +24974,39 @@ impl KnowledgeIngestCancelInput { pub struct KnowledgeIngestStatusOutput { pub found: bool, pub ingestion_id: String, - #[serde(default = "default_1073")] + #[serde(default = "default_1076")] pub source_uri: String, - #[serde(default = "default_1074")] + #[serde(default = "default_1077")] pub state: String, - #[serde(default = "default_1075")] + #[serde(default = "default_1078")] pub stage: String, - #[serde(default = "default_1076")] + #[serde(default = "default_1079")] pub attempts: Integer, - #[serde(default = "default_1077")] + #[serde(default = "default_1080")] pub error_code: String, - #[serde(default = "default_1078")] + #[serde(default = "default_1081")] pub error_message: String, - #[serde(default = "default_1079")] + #[serde(default = "default_1082")] pub format: String, - #[serde(default = "default_1080")] + #[serde(default = "default_1083")] pub coverage: Option>, - #[serde(default = "default_1081")] + #[serde(default = "default_1084")] pub warnings: Vec, - #[serde(default = "default_1082")] + #[serde(default = "default_1085")] pub chunks: Integer, - #[serde(default = "default_1083")] + #[serde(default = "default_1086")] pub revision: Integer, - #[serde(default = "default_1084")] + #[serde(default = "default_1087")] pub expected_revision: Option, - #[serde(default = "default_1085")] + #[serde(default = "default_1088")] pub filename: String, - #[serde(default = "default_1086")] + #[serde(default = "default_1089")] pub retrieval: String, - #[serde(default = "default_1087")] + #[serde(default = "default_1090")] pub cancel_requested: bool, - #[serde(default = "default_1088")] + #[serde(default = "default_1091")] pub created_at: Option, - #[serde(default = "default_1089")] + #[serde(default = "default_1092")] pub updated_at: Option, } @@ -24831,21 +25063,21 @@ pub struct DocumentCount { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct DocumentTotals { - #[serde(default = "default_1090")] + #[serde(default = "default_1093")] pub live: Option, - #[serde(default = "default_1091")] + #[serde(default = "default_1094")] pub deleted: Option, - #[serde(default = "default_1092")] + #[serde(default = "default_1095")] pub newest_ingested_at: Option, - #[serde(default = "default_1093")] + #[serde(default = "default_1096")] pub by_format: Vec, - #[serde(default = "default_1094")] + #[serde(default = "default_1097")] pub by_source_scheme: Vec, - #[serde(default = "default_1095")] + #[serde(default = "default_1098")] pub earlier_revisions: Option, - #[serde(default = "default_1096")] + #[serde(default = "default_1099")] pub unnumbered: Option, - #[serde(default = "default_1097")] + #[serde(default = "default_1100")] pub retired_versions: Option, } @@ -24860,15 +25092,15 @@ pub struct ChunkModelCount { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ChunkTotals { - #[serde(default = "default_1098")] + #[serde(default = "default_1101")] pub embedder_model: String, - #[serde(default = "default_1099")] + #[serde(default = "default_1102")] pub live: Option, - #[serde(default = "default_1100")] + #[serde(default = "default_1103")] pub searchable: Option, - #[serde(default = "default_1101")] + #[serde(default = "default_1104")] pub unembedded: Option, - #[serde(default = "default_1102")] + #[serde(default = "default_1105")] pub by_model: Vec, } @@ -24893,9 +25125,9 @@ pub struct DocumentDecisions { #[non_exhaustive] pub struct DecisionTotals { pub definition: String, - #[serde(default = "default_1103")] + #[serde(default = "default_1106")] pub refs: Vec, - #[serde(default = "default_1104")] + #[serde(default = "default_1107")] pub all_documents: Option, } @@ -24910,7 +25142,7 @@ pub struct DocumentChunks { pub min_chars: Integer, pub median_chars: Integer, pub max_chars: Integer, - #[serde(default = "default_1107")] + #[serde(default = "default_1110")] pub models: Vec, } @@ -24960,11 +25192,11 @@ pub struct IngestJob { pub failure_class: IngestJobFailureClass, pub queued_at: String, pub updated_at: String, - #[serde(default = "default_1112")] + #[serde(default = "default_1115")] pub ended_at: Option, - #[serde(default = "default_1113")] + #[serde(default = "default_1116")] pub next_attempt_at: Option, - #[serde(default = "default_1114")] + #[serde(default = "default_1117")] pub stalled: bool, } @@ -24974,11 +25206,11 @@ pub struct SourceJobs { pub source_uri: String, pub jobs: Integer, pub open_jobs: Integer, - #[serde(default = "default_1111")] + #[serde(default = "default_1114")] pub open_ingestion_id: String, pub latest: IngestJob, pub current: IngestJob, - #[serde(default = "default_1115")] + #[serde(default = "default_1118")] pub replaced: bool, } @@ -24991,18 +25223,18 @@ pub struct InspectDocument { pub source_scheme: String, pub version: Integer, pub revision: Integer, - #[serde(default = "default_1105")] + #[serde(default = "default_1108")] pub ingestion_id: String, pub ingested_at: String, - #[serde(default = "default_1106")] + #[serde(default = "default_1109")] pub retired_versions: Option, - #[serde(default = "default_1108")] + #[serde(default = "default_1111")] pub chunks: Option, - #[serde(default = "default_1109")] + #[serde(default = "default_1112")] pub decisions: Option, - #[serde(default = "default_1110")] + #[serde(default = "default_1113")] pub extraction: Option, - #[serde(default = "default_1116")] + #[serde(default = "default_1119")] pub jobs: Option, } @@ -25047,40 +25279,40 @@ pub struct DocumentFinding { pub kind: DocumentFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1119")] + #[serde(default = "default_1122")] pub window_seconds: Option, - #[serde(default = "default_1120")] + #[serde(default = "default_1123")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1121")] + #[serde(default = "default_1124")] pub evidence: Vec, - #[serde(default = "default_1122")] + #[serde(default = "default_1125")] pub exceptions: String, - #[serde(default = "default_1123")] + #[serde(default = "default_1126")] pub uncertainty: String, pub code: String, pub severity: DocumentFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1124")] + #[serde(default = "default_1127")] pub samples: Vec, - #[serde(default = "default_1125")] + #[serde(default = "default_1128")] pub ingested: Integer, - #[serde(default = "default_1126")] + #[serde(default = "default_1129")] pub ingested_samples: Vec, pub detail: String, pub remedy: String, - #[serde(default = "default_1127")] + #[serde(default = "default_1130")] pub refs: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ReportCoverage { - #[serde(default = "default_1129")] + #[serde(default = "default_1132")] pub rules_run: Vec, - #[serde(default = "default_1130")] + #[serde(default = "default_1133")] pub rules_skipped: Vec, pub complete: bool, } @@ -25088,43 +25320,43 @@ pub struct ReportCoverage { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct IngestionTotals { - #[serde(default = "default_1131")] + #[serde(default = "default_1134")] pub sources: Option, - #[serde(default = "default_1132")] + #[serde(default = "default_1135")] pub without_document: Option, - #[serde(default = "default_1133")] + #[serde(default = "default_1136")] pub replaced: Option, - #[serde(default = "default_1134")] + #[serde(default = "default_1137")] pub pending: Option, - #[serde(default = "default_1135")] + #[serde(default = "default_1138")] pub processing: Option, - #[serde(default = "default_1136")] + #[serde(default = "default_1139")] pub stalled: Option, - #[serde(default = "default_1137")] + #[serde(default = "default_1140")] pub ready: Option, - #[serde(default = "default_1138")] + #[serde(default = "default_1141")] pub partial: Option, - #[serde(default = "default_1139")] + #[serde(default = "default_1142")] pub failed: Option, - #[serde(default = "default_1140")] + #[serde(default = "default_1143")] pub cancelled: Option, - #[serde(default = "default_1141")] + #[serde(default = "default_1144")] pub oldest_open_queued_at: Option, pub worker_enabled: bool, - #[serde(default = "default_1142")] + #[serde(default = "default_1145")] pub extractor_configured: Option, - #[serde(default = "default_1143")] + #[serde(default = "default_1146")] pub without_document_listed: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ExtractionTotals { - #[serde(default = "default_1144")] + #[serde(default = "default_1147")] pub documents: Option, - #[serde(default = "default_1145")] + #[serde(default = "default_1148")] pub incomplete: Option, - #[serde(default = "default_1146")] + #[serde(default = "default_1149")] pub lost: Vec, } @@ -25154,31 +25386,31 @@ pub struct IngestFinding { pub kind: IngestFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1147")] + #[serde(default = "default_1150")] pub window_seconds: Option, - #[serde(default = "default_1148")] + #[serde(default = "default_1151")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1149")] + #[serde(default = "default_1152")] pub evidence: Vec, - #[serde(default = "default_1150")] + #[serde(default = "default_1153")] pub exceptions: String, - #[serde(default = "default_1151")] + #[serde(default = "default_1154")] pub uncertainty: String, pub code: String, pub severity: IngestFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1152")] + #[serde(default = "default_1155")] pub samples: Vec, - #[serde(default = "default_1153")] + #[serde(default = "default_1156")] pub ingestion_ids: Vec, - #[serde(default = "default_1154")] + #[serde(default = "default_1157")] pub without_document: Integer, pub detail: String, pub remedy: String, - #[serde(default = "default_1155")] + #[serde(default = "default_1158")] pub refs: Vec, } @@ -25205,20 +25437,20 @@ pub struct KnowledgeInspectOutput { pub documents: DocumentTotals, pub chunks: ChunkTotals, pub decisions: DecisionTotals, - #[serde(default = "default_1117")] + #[serde(default = "default_1120")] pub listed: Vec, - #[serde(default = "default_1118")] + #[serde(default = "default_1121")] pub listed_complete: bool, - #[serde(default = "default_1128")] + #[serde(default = "default_1131")] pub findings: Vec, pub coverage: ReportCoverage, pub ingestions: IngestionTotals, pub extraction: ExtractionTotals, - #[serde(default = "default_1156")] + #[serde(default = "default_1159")] pub ingest_findings: Vec, - #[serde(default = "default_1157")] + #[serde(default = "default_1160")] pub memory_findings: Vec, - #[serde(default = "default_1158")] + #[serde(default = "default_1161")] pub skipped: Vec, } @@ -25365,7 +25597,7 @@ pub struct KnowledgeListEntry { #[non_exhaustive] pub struct KnowledgeListOutput { pub rows: Vec, - #[serde(default = "default_1159")] + #[serde(default = "default_1162")] pub next_cursor: Option, } @@ -25531,9 +25763,9 @@ pub enum KnowledgeMoveResultReason { #[non_exhaustive] pub struct KnowledgeMoveResult { pub source_uri: String, - #[serde(default = "default_1161")] + #[serde(default = "default_1164")] pub moved: bool, - #[serde(default = "default_1162")] + #[serde(default = "default_1165")] pub reason: KnowledgeMoveResultReason, } @@ -25541,9 +25773,9 @@ pub struct KnowledgeMoveResult { #[non_exhaustive] pub struct KnowledgeMoveOutput { pub found: bool, - #[serde(default = "default_1160")] - pub to_namespace: String, #[serde(default = "default_1163")] + pub to_namespace: String, + #[serde(default = "default_1166")] pub results: Vec, } @@ -25609,17 +25841,17 @@ pub struct OutlineEntry { pub struct KnowledgeOutlineOutput { pub found: bool, pub source_uri: String, - #[serde(default = "default_1164")] + #[serde(default = "default_1167")] pub title: String, - #[serde(default = "default_1165")] + #[serde(default = "default_1168")] pub structured: bool, - #[serde(default = "default_1166")] + #[serde(default = "default_1169")] pub chunk_count: Integer, - #[serde(default = "default_1167")] + #[serde(default = "default_1170")] pub sections: Vec, - #[serde(default = "default_1168")] + #[serde(default = "default_1171")] pub section_content: Option, - #[serde(default = "default_1169")] + #[serde(default = "default_1172")] pub section_chunk_idxs: Vec, } @@ -25726,12 +25958,12 @@ pub struct QueryReceipt { pub struct KnowledgeQueryOutput { pub columns: Vec, pub rows: Vec>, - #[serde(default = "default_1170")] + #[serde(default = "default_1173")] pub row_ids: Vec>, - #[serde(default = "default_1171")] + #[serde(default = "default_1174")] pub truncated: bool, pub complete: bool, - #[serde(default = "default_1172")] + #[serde(default = "default_1175")] pub incomplete: Vec, pub receipt: QueryReceipt, } @@ -26404,9 +26636,9 @@ pub struct QueryHistoryListOutputQueryHistorySource { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct QueryHistoryListOutput { - #[serde(default = "default_1173")] + #[serde(default = "default_1176")] pub enabled: bool, - #[serde(default = "default_1174")] + #[serde(default = "default_1177")] pub sources: Vec, } @@ -26537,7 +26769,7 @@ impl QueryHistoryRemoveInput { #[non_exhaustive] pub struct KnowledgeReadsOutput { pub window_days: Integer, - #[serde(default = "default_1175")] + #[serde(default = "default_1178")] pub reads: Vec>, } @@ -26640,15 +26872,15 @@ pub enum KnowledgeRestoreOutputOriginal { #[non_exhaustive] pub struct KnowledgeRestoreOutput { pub restored: bool, - #[serde(default = "default_1176")] + #[serde(default = "default_1179")] pub reason: KnowledgeRestoreOutputReason, - #[serde(default = "default_1177")] + #[serde(default = "default_1180")] pub doc_id: String, - #[serde(default = "default_1178")] + #[serde(default = "default_1181")] pub revision: Option, - #[serde(default = "default_1179")] + #[serde(default = "default_1182")] pub chunks_restored: Integer, - #[serde(default = "default_1180")] + #[serde(default = "default_1183")] pub original: KnowledgeRestoreOutputOriginal, } @@ -26712,15 +26944,15 @@ impl KnowledgeRestoreInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceProbe { - #[serde(default = "default_1184")] + #[serde(default = "default_1187")] pub documents: Integer, - #[serde(default = "default_1185")] + #[serde(default = "default_1188")] pub more: bool, - #[serde(default = "default_1186")] + #[serde(default = "default_1189")] pub sample: Vec, - #[serde(default = "default_1187")] + #[serde(default = "default_1190")] pub checked: Integer, - #[serde(default = "default_1188")] + #[serde(default = "default_1191")] pub sampled: bool, } @@ -26730,15 +26962,15 @@ pub struct KnowledgeSourceAddOutput { pub name: String, pub kind: String, pub namespace: String, - #[serde(default = "default_1181")] + #[serde(default = "default_1184")] pub items: Vec>, - #[serde(default = "default_1182")] + #[serde(default = "default_1185")] pub include: Vec, - #[serde(default = "default_1183")] + #[serde(default = "default_1186")] pub config: std::collections::HashMap, - #[serde(default = "default_1189")] + #[serde(default = "default_1192")] pub probe: KnowledgeSourceProbe, - #[serde(default = "default_1190")] + #[serde(default = "default_1193")] pub dry_run: bool, } @@ -26895,21 +27127,21 @@ impl KnowledgeSourceAddInput { #[non_exhaustive] pub struct KnowledgeSourceCheckOutput { pub name: String, - #[serde(default = "default_1191")] + #[serde(default = "default_1194")] pub reachable: bool, - #[serde(default = "default_1192")] + #[serde(default = "default_1195")] pub documents: Integer, - #[serde(default = "default_1193")] + #[serde(default = "default_1196")] pub more: bool, - #[serde(default = "default_1194")] + #[serde(default = "default_1197")] pub sample: Vec, - #[serde(default = "default_1195")] + #[serde(default = "default_1198")] pub checked: Integer, - #[serde(default = "default_1196")] + #[serde(default = "default_1199")] pub sampled: bool, - #[serde(default = "default_1197")] + #[serde(default = "default_1200")] pub summary: String, - #[serde(default = "default_1198")] + #[serde(default = "default_1201")] pub checked_at: String, } @@ -26958,37 +27190,37 @@ impl KnowledgeSourceCheckInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceSync { - #[serde(default = "default_1207")] + #[serde(default = "default_1210")] pub requested_at: String, - #[serde(default = "default_1208")] + #[serde(default = "default_1211")] pub last_synced_at: String, - #[serde(default = "default_1209")] + #[serde(default = "default_1212")] pub status: String, - #[serde(default = "default_1210")] + #[serde(default = "default_1213")] pub documents_seen: Integer, - #[serde(default = "default_1211")] + #[serde(default = "default_1214")] pub changed: Integer, - #[serde(default = "default_1212")] + #[serde(default = "default_1215")] pub removed: Integer, - #[serde(default = "default_1213")] + #[serde(default = "default_1216")] pub unconverted: Integer, - #[serde(default = "default_1214")] + #[serde(default = "default_1217")] pub unconverted_reasons: std::collections::HashMap, - #[serde(default = "default_1215")] + #[serde(default = "default_1218")] pub skipped: Integer, - #[serde(default = "default_1216")] + #[serde(default = "default_1219")] pub error: String, - #[serde(default = "default_1217")] + #[serde(default = "default_1220")] pub pending_extract: Integer, - #[serde(default = "default_1218")] + #[serde(default = "default_1221")] pub last_extracted_at: String, - #[serde(default = "default_1219")] + #[serde(default = "default_1222")] pub extracted: Integer, - #[serde(default = "default_1220")] + #[serde(default = "default_1223")] pub flagged_pinned: Integer, - #[serde(default = "default_1221")] + #[serde(default = "default_1224")] pub unextracted: Integer, - #[serde(default = "default_1222")] + #[serde(default = "default_1225")] pub extract_error: String, } @@ -26996,11 +27228,11 @@ pub struct KnowledgeSourceSync { #[non_exhaustive] pub struct KnowledgeSourceDocument { pub source_uri: String, - #[serde(default = "default_1224")] + #[serde(default = "default_1227")] pub title: String, - #[serde(default = "default_1225")] + #[serde(default = "default_1228")] pub source_revision: String, - #[serde(default = "default_1226")] + #[serde(default = "default_1229")] pub ingested_at: String, } @@ -27009,25 +27241,25 @@ pub struct KnowledgeSourceDocument { pub struct KnowledgeSourceInspectOutput { pub name: String, pub kind: String, - #[serde(default = "default_1199")] + #[serde(default = "default_1202")] pub credential_mode: String, - #[serde(default = "default_1200")] + #[serde(default = "default_1203")] pub access: String, - #[serde(default = "default_1201")] + #[serde(default = "default_1204")] pub owner_subject: String, - #[serde(default = "default_1202")] + #[serde(default = "default_1205")] pub items: Vec>, - #[serde(default = "default_1203")] + #[serde(default = "default_1206")] pub include: Vec, - #[serde(default = "default_1204")] + #[serde(default = "default_1207")] pub config: std::collections::HashMap, - #[serde(default = "default_1205")] + #[serde(default = "default_1208")] pub created_by: String, - #[serde(default = "default_1206")] + #[serde(default = "default_1209")] pub created_at: String, - #[serde(default = "default_1223")] + #[serde(default = "default_1226")] pub sync: KnowledgeSourceSync, - #[serde(default = "default_1227")] + #[serde(default = "default_1230")] pub documents: Vec, } @@ -27080,34 +27312,34 @@ impl KnowledgeSourceInspectInput { pub struct KnowledgeSourceEntry { pub name: String, pub kind: String, - #[serde(default = "default_1228")] + #[serde(default = "default_1231")] pub credential_mode: String, - #[serde(default = "default_1229")] + #[serde(default = "default_1232")] pub access: String, - #[serde(default = "default_1230")] + #[serde(default = "default_1233")] pub owner_subject: String, - #[serde(default = "default_1231")] + #[serde(default = "default_1234")] pub items: Vec>, - #[serde(default = "default_1232")] + #[serde(default = "default_1235")] pub include: Vec, - #[serde(default = "default_1233")] + #[serde(default = "default_1236")] pub config: std::collections::HashMap, - #[serde(default = "default_1234")] + #[serde(default = "default_1237")] pub created_by: String, - #[serde(default = "default_1235")] + #[serde(default = "default_1238")] pub created_at: String, - #[serde(default = "default_1236")] + #[serde(default = "default_1239")] pub sync: KnowledgeSourceSync, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceListOutput { - #[serde(default = "default_1237")] + #[serde(default = "default_1240")] pub sources: Vec, - #[serde(default = "default_1238")] + #[serde(default = "default_1241")] pub enabled: bool, - #[serde(default = "default_1239")] + #[serde(default = "default_1242")] pub accepts_sources: bool, } @@ -27160,18 +27392,18 @@ impl KnowledgeSourceListInput { #[non_exhaustive] pub struct KnowledgeSourceParsedLink { pub link: String, - #[serde(default = "default_1240")] + #[serde(default = "default_1243")] pub kind: String, - #[serde(default = "default_1241")] + #[serde(default = "default_1244")] pub item: std::collections::HashMap, - #[serde(default = "default_1242")] + #[serde(default = "default_1245")] pub unreadable: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct KnowledgeSourceParseLinksOutput { - #[serde(default = "default_1243")] + #[serde(default = "default_1246")] pub links: Vec, } @@ -27222,25 +27454,25 @@ impl KnowledgeSourceParseLinksInput { #[derive(Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct PushStatusOutput { - #[serde(default = "default_1244")] + #[serde(default = "default_1247")] pub enabled: bool, - #[serde(default = "default_1245")] + #[serde(default = "default_1248")] pub status: String, - #[serde(default = "default_1246")] + #[serde(default = "default_1249")] pub provider: String, - #[serde(default = "default_1247")] + #[serde(default = "default_1250")] pub generation: String, - #[serde(default = "default_1248")] + #[serde(default = "default_1251")] pub callback_url: String, - #[serde(default = "default_1249")] + #[serde(default = "default_1252")] pub provider_id: String, - #[serde(default = "default_1250")] + #[serde(default = "default_1253")] pub challenge_fingerprint: String, - #[serde(default = "default_1251")] + #[serde(default = "default_1254")] pub verification_token: String, - #[serde(default = "default_1252")] + #[serde(default = "default_1255")] pub channels: Integer, - #[serde(default = "default_1253")] + #[serde(default = "default_1256")] pub expires_at: f64, } impl std::fmt::Debug for PushStatusOutput { @@ -27485,7 +27717,7 @@ impl PushStatusInput { #[non_exhaustive] pub struct KnowledgeSourceRemoveOutput { pub name: String, - #[serde(default = "default_1254")] + #[serde(default = "default_1257")] pub documents_pending: Integer, } @@ -27548,9 +27780,9 @@ impl KnowledgeSourceRemoveInput { #[non_exhaustive] pub struct KnowledgeSourceRotateOutput { pub name: String, - #[serde(default = "default_1255")] + #[serde(default = "default_1258")] pub probe: KnowledgeSourceProbe, - #[serde(default = "default_1256")] + #[serde(default = "default_1259")] pub rotated_at: String, } @@ -27602,7 +27834,7 @@ impl KnowledgeSourceRotateInput { #[non_exhaustive] pub struct KnowledgeSourceSyncNowOutput { pub name: String, - #[serde(default = "default_1257")] + #[serde(default = "default_1260")] pub enabled: bool, } @@ -27665,17 +27897,17 @@ impl KnowledgeSourceSyncNowInput { #[non_exhaustive] pub struct KnowledgeSourceUpdateOutput { pub name: String, - #[serde(default = "default_1258")] + #[serde(default = "default_1261")] pub items: Vec>, - #[serde(default = "default_1259")] + #[serde(default = "default_1262")] pub include: Vec, - #[serde(default = "default_1260")] + #[serde(default = "default_1263")] pub config: std::collections::HashMap, - #[serde(default = "default_1261")] + #[serde(default = "default_1264")] pub added: Vec>, - #[serde(default = "default_1262")] + #[serde(default = "default_1265")] pub removed: Vec>, - #[serde(default = "default_1263")] + #[serde(default = "default_1266")] pub probe: KnowledgeSourceProbe, } @@ -27791,9 +28023,9 @@ impl KnowledgeSourceUpdateInput { pub struct CitedChunk { pub source_uri: String, pub chunk_idx: Integer, - #[serde(default = "default_1265")] + #[serde(default = "default_1268")] pub revision: Integer, - #[serde(default = "default_1266")] + #[serde(default = "default_1269")] pub locator: Option>, } @@ -27802,12 +28034,12 @@ pub struct CitedChunk { pub struct SynthesizeCalculation { pub columns: Vec, pub rows: Vec>, - #[serde(default = "default_1273")] + #[serde(default = "default_1276")] pub row_ids: Vec>, - #[serde(default = "default_1274")] + #[serde(default = "default_1277")] pub truncated: bool, pub complete: bool, - #[serde(default = "default_1275")] + #[serde(default = "default_1278")] pub incomplete: Vec, pub receipt: QueryReceipt, pub citation: String, @@ -27821,23 +28053,23 @@ pub struct KnowledgeSynthesizeOutput { pub chunks_read: Integer, pub documents: Integer, pub reduce_rounds: Integer, - #[serde(default = "default_1264")] - pub citations: Vec, #[serde(default = "default_1267")] + pub citations: Vec, + #[serde(default = "default_1270")] pub cited_chunks: Vec, - #[serde(default = "default_1268")] + #[serde(default = "default_1271")] pub unsupported_citations: Vec, - #[serde(default = "default_1269")] + #[serde(default = "default_1272")] pub truncated: bool, - #[serde(default = "default_1270")] + #[serde(default = "default_1273")] pub abstain: bool, - #[serde(default = "default_1271")] + #[serde(default = "default_1274")] pub abstain_reason: String, - #[serde(default = "default_1272")] + #[serde(default = "default_1275")] pub clarification: String, - #[serde(default = "default_1276")] + #[serde(default = "default_1279")] pub calculations: Vec, - #[serde(default = "default_1277")] + #[serde(default = "default_1280")] pub model: String, } @@ -27953,13 +28185,13 @@ impl KnowledgeSynthesizeInput { #[non_exhaustive] pub struct KnowledgeUpdateMetadataOutput { pub updated: bool, - #[serde(default = "default_1278")] + #[serde(default = "default_1281")] pub title: String, - #[serde(default = "default_1279")] + #[serde(default = "default_1282")] pub description: String, - #[serde(default = "default_1280")] + #[serde(default = "default_1283")] pub tags: Vec, - #[serde(default = "default_1281")] + #[serde(default = "default_1284")] pub chunks_reindexed: Integer, } @@ -28071,13 +28303,13 @@ pub struct KnowledgeUpsertOutput { pub chunks_superseded: Integer, pub embedding_model: String, pub embedding_dim: Integer, - #[serde(default = "default_1282")] + #[serde(default = "default_1285")] pub duplicate_of_uri: String, - #[serde(default = "default_1283")] + #[serde(default = "default_1286")] pub duplicate_chunk_count: Integer, - #[serde(default = "default_1284")] + #[serde(default = "default_1287")] pub namespace: String, - #[serde(default = "default_1285")] + #[serde(default = "default_1288")] pub source_uri: String, } @@ -28262,26 +28494,26 @@ pub struct LearningEntry { pub memory_type: String, pub proposed_value: Value, pub supporter_count: Integer, - #[serde(default = "default_1286")] + #[serde(default = "default_1289")] pub supporter_sessions: Integer, - #[serde(default = "default_1287")] + #[serde(default = "default_1290")] pub supporter_writers: Integer, pub confidence_avg: f64, pub supporters: Vec, pub rationale: String, - #[serde(default = "default_1288")] + #[serde(default = "default_1291")] pub source_kind: String, - #[serde(default = "default_1289")] + #[serde(default = "default_1292")] pub source_resource_id: String, - #[serde(default = "default_1290")] + #[serde(default = "default_1293")] pub agent: String, pub status: LearningEntryStatus, pub proposed_at: String, - #[serde(default = "default_1291")] + #[serde(default = "default_1294")] pub decided_at: Option, - #[serde(default = "default_1292")] + #[serde(default = "default_1295")] pub decided_by: String, - #[serde(default = "default_1293")] + #[serde(default = "default_1296")] pub decision_reason: String, } @@ -28484,11 +28716,11 @@ pub enum LearningsReviewOutputNewStatus { pub struct LearningsReviewOutput { pub candidate_id: String, pub new_status: LearningsReviewOutputNewStatus, - #[serde(default = "default_1294")] + #[serde(default = "default_1297")] pub promoted_to_shared: bool, - #[serde(default = "default_1295")] + #[serde(default = "default_1298")] pub promoted_to_knowledge: bool, - #[serde(default = "default_1296")] + #[serde(default = "default_1299")] pub knowledge_source_uri: String, pub decided_at: String, } @@ -28692,7 +28924,7 @@ impl MemoryAgentsListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct AggregateRow { - #[serde(default = "default_1297")] + #[serde(default = "default_1300")] pub group: std::collections::HashMap, pub metric: f64, } @@ -28700,9 +28932,9 @@ pub struct AggregateRow { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAggregateOutput { - #[serde(default = "default_1298")] + #[serde(default = "default_1301")] pub rows: Vec, - #[serde(default = "default_1299")] + #[serde(default = "default_1302")] pub sql_executed: String, } @@ -28870,15 +29102,15 @@ impl MemoryAggregateInput { pub struct BulkSetResult { pub memory_key: String, pub version: Integer, - #[serde(default = "default_1300")] + #[serde(default = "default_1303")] pub memory_id: String, - #[serde(default = "default_1301")] + #[serde(default = "default_1304")] pub conflict_verdict: String, - #[serde(default = "default_1302")] + #[serde(default = "default_1305")] pub peers: Vec, - #[serde(default = "default_1303")] + #[serde(default = "default_1306")] pub next: String, - #[serde(default = "default_1304")] + #[serde(default = "default_1307")] pub pinned_blocker_id: String, } @@ -28886,29 +29118,29 @@ pub struct BulkSetResult { #[non_exhaustive] pub struct MemoryBulkSetOutput { pub written: Vec, - #[serde(default = "default_1305")] + #[serde(default = "default_1308")] pub skipped_pinned: Vec, - #[serde(default = "default_1306")] + #[serde(default = "default_1309")] pub skipped_locked: Vec, - #[serde(default = "default_1307")] + #[serde(default = "default_1310")] pub skipped_blacklisted: Vec, - #[serde(default = "default_1308")] + #[serde(default = "default_1311")] pub merged: Vec, - #[serde(default = "default_1309")] + #[serde(default = "default_1312")] pub value_updates_linked: Integer, - #[serde(default = "default_1310")] + #[serde(default = "default_1313")] pub rejected_pinned: Vec, - #[serde(default = "default_1311")] + #[serde(default = "default_1314")] pub duplicates: Vec, - #[serde(default = "default_1312")] + #[serde(default = "default_1315")] pub conflicted: Vec, - #[serde(default = "default_1313")] + #[serde(default = "default_1316")] pub unchecked: Integer, - #[serde(default = "default_1314")] + #[serde(default = "default_1317")] pub retyped: Vec, - #[serde(default = "default_1315")] + #[serde(default = "default_1318")] pub identity_duplicates: std::collections::HashMap, - #[serde(default = "default_1316")] + #[serde(default = "default_1319")] pub stage_ms: std::collections::HashMap, } @@ -29058,18 +29290,18 @@ pub enum ApplyRowStatus { #[non_exhaustive] pub struct ApplyRow { pub memory_key: String, - #[serde(default = "default_1324")] + #[serde(default = "default_1327")] pub memory_id: String, - #[serde(default = "default_1325")] + #[serde(default = "default_1328")] pub agent: String, - #[serde(default = "default_1326")] + #[serde(default = "default_1329")] pub user_id: String, - #[serde(default = "default_1327")] + #[serde(default = "default_1330")] pub session_id: String, pub status: ApplyRowStatus, - #[serde(default = "default_1328")] + #[serde(default = "default_1331")] pub version: Option, - #[serde(default = "default_1329")] + #[serde(default = "default_1332")] pub detail: String, } @@ -29079,21 +29311,21 @@ pub struct MemoryApplyOutput { pub action: String, pub dry_run: bool, pub target: String, - #[serde(default = "default_1317")] + #[serde(default = "default_1320")] pub matched: Integer, - #[serde(default = "default_1318")] + #[serde(default = "default_1321")] pub applied: Integer, - #[serde(default = "default_1319")] + #[serde(default = "default_1322")] pub would_apply: Integer, - #[serde(default = "default_1320")] + #[serde(default = "default_1323")] pub refused: Integer, - #[serde(default = "default_1321")] + #[serde(default = "default_1324")] pub noop: Integer, - #[serde(default = "default_1322")] + #[serde(default = "default_1325")] pub failed: Integer, - #[serde(default = "default_1323")] + #[serde(default = "default_1326")] pub truncated: bool, - #[serde(default = "default_1330")] + #[serde(default = "default_1333")] pub rows: Vec, } @@ -29827,137 +30059,137 @@ pub enum MemoryAskOutputDeepFirst { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAskOutput { - #[serde(default = "default_1331")] + #[serde(default = "default_1334")] pub answer: String, - #[serde(default = "default_1332")] + #[serde(default = "default_1335")] pub source: MemoryAskOutputSource, - #[serde(default = "default_1333")] + #[serde(default = "default_1336")] pub abstain: bool, - #[serde(default = "default_1334")] + #[serde(default = "default_1337")] pub abstain_reason: String, - #[serde(default = "default_1335")] + #[serde(default = "default_1338")] pub memory_keys: Vec, - #[serde(default = "default_1336")] + #[serde(default = "default_1339")] pub results: Vec, - #[serde(default = "default_1337")] + #[serde(default = "default_1340")] pub cited_sessions: Vec, - #[serde(default = "default_1338")] + #[serde(default = "default_1341")] pub next: String, - #[serde(default = "default_1339")] + #[serde(default = "default_1342")] pub synth_model: String, - #[serde(default = "default_1340")] + #[serde(default = "default_1343")] pub route_tier: MemoryAskOutputRouteTier, - #[serde(default = "default_1341")] + #[serde(default = "default_1344")] pub route_reason: String, - #[serde(default = "default_1342")] + #[serde(default = "default_1345")] pub llm_cache_hits: Integer, - #[serde(default = "default_1343")] + #[serde(default = "default_1346")] pub llm_cache_misses: Integer, - #[serde(default = "default_1344")] + #[serde(default = "default_1347")] pub llm_cache: bool, - #[serde(default = "default_1345")] + #[serde(default = "default_1348")] pub llm_cache_saved_usd: f64, - #[serde(default = "default_1346")] + #[serde(default = "default_1349")] pub temporal_consistency: Option, - #[serde(default = "default_1347")] + #[serde(default = "default_1350")] pub citation_concentration: Option, - #[serde(default = "default_1348")] + #[serde(default = "default_1351")] pub escalated: bool, - #[serde(default = "default_1349")] + #[serde(default = "default_1352")] pub gate_mode: String, - #[serde(default = "default_1350")] + #[serde(default = "default_1353")] pub gate_kept: Integer, - #[serde(default = "default_1351")] + #[serde(default = "default_1354")] pub gate_dropped: Integer, - #[serde(default = "default_1352")] + #[serde(default = "default_1355")] pub pending_extraction: Integer, - #[serde(default = "default_1353")] + #[serde(default = "default_1356")] pub pending_evidence: Integer, - #[serde(default = "default_1354")] + #[serde(default = "default_1357")] pub retrieval_query: String, - #[serde(default = "default_1355")] + #[serde(default = "default_1358")] pub facets: Vec, - #[serde(default = "default_1356")] + #[serde(default = "default_1359")] pub facet_memories_added: Integer, - #[serde(default = "default_1357")] + #[serde(default = "default_1360")] pub consistency: MemoryAskOutputConsistency, - #[serde(default = "default_1358")] + #[serde(default = "default_1361")] pub consistency_score: f64, - #[serde(default = "default_1359")] + #[serde(default = "default_1362")] pub consistency_note: String, - #[serde(default = "default_1360")] + #[serde(default = "default_1363")] pub identifier_chase_hops: Integer, - #[serde(default = "default_1361")] + #[serde(default = "default_1364")] pub identifier_chase_added: Integer, - #[serde(default = "default_1362")] + #[serde(default = "default_1365")] pub premise_conflict: String, - #[serde(default = "default_1363")] + #[serde(default = "default_1366")] pub premise_note: String, - #[serde(default = "default_1364")] + #[serde(default = "default_1367")] pub premise_verdict: String, - #[serde(default = "default_1365")] + #[serde(default = "default_1368")] pub attribution_note: String, - #[serde(default = "default_1366")] + #[serde(default = "default_1369")] pub depth: MemoryAskOutputDepth, - #[serde(default = "default_1367")] + #[serde(default = "default_1370")] pub deep_fired: bool, - #[serde(default = "default_1368")] + #[serde(default = "default_1371")] pub decomposed: Vec, - #[serde(default = "default_1369")] + #[serde(default = "default_1372")] pub decomposed_parts: Integer, - #[serde(default = "default_1370")] + #[serde(default = "default_1373")] pub superseded_dropped: Integer, - #[serde(default = "default_1371")] + #[serde(default = "default_1374")] pub stale_sentences_masked: Integer, - #[serde(default = "default_1372")] + #[serde(default = "default_1375")] pub entity_followed: Vec, - #[serde(default = "default_1373")] + #[serde(default = "default_1376")] pub when_evidence_turns: Integer, - #[serde(default = "default_1374")] + #[serde(default = "default_1377")] pub decompose_failed: Integer, - #[serde(default = "default_1375")] + #[serde(default = "default_1378")] pub pool_k: Integer, - #[serde(default = "default_1376")] + #[serde(default = "default_1379")] pub grounding: MemoryAskOutputGrounding, - #[serde(default = "default_1377")] + #[serde(default = "default_1380")] pub deep_reason: String, - #[serde(default = "default_1378")] + #[serde(default = "default_1381")] pub deep_keys: Vec, - #[serde(default = "default_1379")] + #[serde(default = "default_1382")] pub deep_chars: Integer, - #[serde(default = "default_1380")] + #[serde(default = "default_1383")] pub code_hits: Integer, - #[serde(default = "default_1381")] + #[serde(default = "default_1384")] pub pool_facts: Integer, - #[serde(default = "default_1382")] + #[serde(default = "default_1385")] pub pool_chunks: Integer, - #[serde(default = "default_1383")] + #[serde(default = "default_1386")] pub prompt_blocks: std::collections::HashMap, - #[serde(default = "default_1384")] + #[serde(default = "default_1387")] pub deep_selector: MemoryAskOutputDeepSelector, - #[serde(default = "default_1385")] + #[serde(default = "default_1388")] pub deep_first: MemoryAskOutputDeepFirst, - #[serde(default = "default_1386")] + #[serde(default = "default_1389")] pub synth_calls: Integer, - #[serde(default = "default_1387")] + #[serde(default = "default_1390")] pub synth_input_tokens: Integer, - #[serde(default = "default_1388")] + #[serde(default = "default_1391")] pub synth_cached_input_tokens: Integer, - #[serde(default = "default_1389")] + #[serde(default = "default_1392")] pub synth_cache_write_tokens: Integer, - #[serde(default = "default_1390")] + #[serde(default = "default_1393")] pub synth_cost_usd: f64, - #[serde(default = "default_1391")] + #[serde(default = "default_1394")] pub context_tokens_est: Integer, - #[serde(default = "default_1392")] + #[serde(default = "default_1395")] pub context_trimmed: Integer, - #[serde(default = "default_1393")] + #[serde(default = "default_1396")] pub summary_hits: Integer, - #[serde(default = "default_1394")] + #[serde(default = "default_1397")] pub knowledge_hits: Integer, - #[serde(default = "default_1395")] + #[serde(default = "default_1398")] pub timeline_rows: Integer, - #[serde(default = "default_1396")] + #[serde(default = "default_1399")] pub count_recomputed: bool, } @@ -30912,36 +31144,36 @@ pub struct MemoryAutoRetirement { pub reason: String, pub memory_id: String, pub memory_key: String, - #[serde(default = "default_1397")] + #[serde(default = "default_1400")] pub agent: String, - #[serde(default = "default_1398")] + #[serde(default = "default_1401")] pub user_id: String, - #[serde(default = "default_1399")] + #[serde(default = "default_1402")] pub session_id: String, - #[serde(default = "default_1400")] + #[serde(default = "default_1403")] pub superseded_by: String, - #[serde(default = "default_1401")] + #[serde(default = "default_1404")] pub superseded_by_key: String, - #[serde(default = "default_1402")] + #[serde(default = "default_1405")] pub label: String, - #[serde(default = "default_1403")] + #[serde(default = "default_1406")] pub unconfirmed: bool, - #[serde(default = "default_1404")] + #[serde(default = "default_1407")] pub judge_verdict: String, - #[serde(default = "default_1405")] + #[serde(default = "default_1408")] pub judge_confidence: Option, - #[serde(default = "default_1406")] + #[serde(default = "default_1409")] pub judge_model: String, - #[serde(default = "default_1407")] + #[serde(default = "default_1410")] pub judge_prompt_version: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryAutoRetirementsOutput { - #[serde(default = "default_1408")] + #[serde(default = "default_1411")] pub rows: Vec, - #[serde(default = "default_1409")] + #[serde(default = "default_1412")] pub next_cursor: Option, } @@ -31035,9 +31267,9 @@ impl MemoryAutoRetirementsInput { #[non_exhaustive] pub struct BacklinkVersion { pub version: Integer, - #[serde(default = "default_1411")] + #[serde(default = "default_1414")] pub status: String, - #[serde(default = "default_1412")] + #[serde(default = "default_1415")] pub created_at: String, } @@ -31045,7 +31277,7 @@ pub struct BacklinkVersion { #[non_exhaustive] pub struct BacklinkDigest { pub session_id: String, - #[serde(default = "default_1414")] + #[serde(default = "default_1417")] pub date: String, } @@ -31053,9 +31285,9 @@ pub struct BacklinkDigest { #[non_exhaustive] pub struct BacklinkEdge { pub memory_key: String, - #[serde(default = "default_1416")] + #[serde(default = "default_1419")] pub relation: String, - #[serde(default = "default_1417")] + #[serde(default = "default_1420")] pub created_at: String, } @@ -31063,7 +31295,7 @@ pub struct BacklinkEdge { #[non_exhaustive] pub struct BacklinkRelated { pub memory_key: String, - #[serde(default = "default_1421")] + #[serde(default = "default_1424")] pub shared_entities: Vec, } @@ -31071,19 +31303,19 @@ pub struct BacklinkRelated { #[non_exhaustive] pub struct MemoryBacklinksOutput { pub memory_key: String, - #[serde(default = "default_1410")] - pub found: bool, #[serde(default = "default_1413")] + pub found: bool, + #[serde(default = "default_1416")] pub versions: Vec, - #[serde(default = "default_1415")] - pub digests: Vec, #[serde(default = "default_1418")] + pub digests: Vec, + #[serde(default = "default_1421")] pub links_in: Vec, - #[serde(default = "default_1419")] + #[serde(default = "default_1422")] pub links_out: Vec, - #[serde(default = "default_1420")] + #[serde(default = "default_1423")] pub evidence_count: Integer, - #[serde(default = "default_1422")] + #[serde(default = "default_1425")] pub related: Vec, } @@ -31188,36 +31420,36 @@ impl MemoryBacklinksInput { #[non_exhaustive] pub struct BriefEvidence { pub memory_key: String, - #[serde(default = "default_1427")] + #[serde(default = "default_1430")] pub source: String, - #[serde(default = "default_1428")] + #[serde(default = "default_1431")] pub source_class: String, - #[serde(default = "default_1429")] + #[serde(default = "default_1432")] pub verified: bool, - #[serde(default = "default_1430")] + #[serde(default = "default_1433")] pub when: String, - #[serde(default = "default_1431")] + #[serde(default = "default_1434")] pub session_id: String, - #[serde(default = "default_1432")] + #[serde(default = "default_1435")] pub excerpt: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryBriefOutput { - #[serde(default = "default_1423")] + #[serde(default = "default_1426")] pub query: String, - #[serde(default = "default_1424")] + #[serde(default = "default_1427")] pub answer: String, - #[serde(default = "default_1425")] + #[serde(default = "default_1428")] pub abstained: bool, - #[serde(default = "default_1426")] + #[serde(default = "default_1429")] pub grounding: String, - #[serde(default = "default_1433")] + #[serde(default = "default_1436")] pub evidence: Vec, - #[serde(default = "default_1434")] + #[serde(default = "default_1437")] pub unknowns: Vec, - #[serde(default = "default_1435")] + #[serde(default = "default_1438")] pub next_reads: Vec, } @@ -31631,9 +31863,9 @@ pub struct MemoryBulkGetOutputMemoryGetOutput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryBulkGetOutput { - #[serde(default = "default_1436")] + #[serde(default = "default_1439")] pub results: std::collections::HashMap, - #[serde(default = "default_1437")] + #[serde(default = "default_1440")] pub missing: Vec, } @@ -32146,7 +32378,7 @@ pub struct MemoryClearOutput { pub cleared_at: String, pub rows_affected: std::collections::HashMap, pub total: Integer, - #[serde(default = "default_1438")] + #[serde(default = "default_1441")] pub locked_skipped: Integer, } @@ -32234,21 +32466,21 @@ pub struct MemoryConsolidateResult { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryConsolidateOutput { - #[serde(default = "default_1439")] + #[serde(default = "default_1442")] pub consolidated: Vec, - #[serde(default = "default_1440")] + #[serde(default = "default_1443")] pub examined: Integer, - #[serde(default = "default_1441")] + #[serde(default = "default_1444")] pub clusters_found: Integer, - #[serde(default = "default_1442")] + #[serde(default = "default_1445")] pub clusters_failed: Integer, - #[serde(default = "default_1443")] + #[serde(default = "default_1446")] pub clusters_refused_lossy: Integer, - #[serde(default = "default_1444")] + #[serde(default = "default_1447")] pub skipped_in_flight: Integer, - #[serde(default = "default_1445")] + #[serde(default = "default_1448")] pub tokens_in: Integer, - #[serde(default = "default_1446")] + #[serde(default = "default_1449")] pub tokens_out: Integer, } @@ -32389,7 +32621,7 @@ impl MemoryConsolidateInput { #[non_exhaustive] pub struct MemoryCopyToOutput { pub copied: bool, - #[serde(default = "default_1447")] + #[serde(default = "default_1450")] pub target_memory_id: String, pub target_namespace: String, pub target_key: String, @@ -32500,11 +32732,11 @@ impl MemoryCopyToInput { #[non_exhaustive] pub struct MemoryCrossPromoteOutput { pub promoted: bool, - #[serde(default = "default_1448")] + #[serde(default = "default_1451")] pub target_memory_id: String, pub target_namespace: String, pub target_key: String, - #[serde(default = "default_1449")] + #[serde(default = "default_1452")] pub cross_promoted_from_memory_id: String, } @@ -32587,23 +32819,23 @@ pub struct DedupCollapsePair { #[non_exhaustive] pub struct MemoryDedupCollapseOutput { pub namespace: String, - #[serde(default = "default_1450")] + #[serde(default = "default_1453")] pub prefix: String, - #[serde(default = "default_1451")] + #[serde(default = "default_1454")] pub dry_run: bool, - #[serde(default = "default_1452")] + #[serde(default = "default_1455")] pub pairs: Integer, - #[serde(default = "default_1453")] + #[serde(default = "default_1456")] pub canonical_live: Integer, - #[serde(default = "default_1454")] + #[serde(default = "default_1457")] pub orphans: Integer, - #[serde(default = "default_1455")] + #[serde(default = "default_1458")] pub mirror_stale: Integer, - #[serde(default = "default_1456")] + #[serde(default = "default_1459")] pub restamped: Integer, - #[serde(default = "default_1457")] + #[serde(default = "default_1460")] pub truncated: bool, - #[serde(default = "default_1458")] + #[serde(default = "default_1461")] pub sample: Vec, } @@ -32702,7 +32934,7 @@ pub struct DedupDuplicate { pub memory_id: String, pub memory_key: String, pub agent: String, - #[serde(default = "default_1461")] + #[serde(default = "default_1464")] pub created_at: Option, } @@ -32710,12 +32942,12 @@ pub struct DedupDuplicate { #[non_exhaustive] pub struct DedupCluster { pub canonical_id: String, - #[serde(default = "default_1459")] + #[serde(default = "default_1462")] pub canonical_key: String, - #[serde(default = "default_1460")] + #[serde(default = "default_1463")] pub canonical_agent: String, pub dup_count: Integer, - #[serde(default = "default_1462")] + #[serde(default = "default_1465")] pub duplicates: Vec, } @@ -32787,11 +33019,11 @@ pub struct MemoryDedupResolveOutput { pub canonical_key: String, pub duplicate_key: String, pub decision: String, - #[serde(default = "default_1463")] + #[serde(default = "default_1466")] pub canonical_tombstoned: bool, - #[serde(default = "default_1464")] + #[serde(default = "default_1467")] pub duplicate_tombstoned: bool, - #[serde(default = "default_1465")] + #[serde(default = "default_1468")] pub ignored_args: Vec, } @@ -32929,17 +33161,17 @@ pub struct LostName { pub struct DefinitionEntry { pub memory_key: String, pub promoted_at: String, - #[serde(default = "default_1466")] + #[serde(default = "default_1469")] pub capped: bool, - #[serde(default = "default_1467")] + #[serde(default = "default_1470")] pub term: Option, - #[serde(default = "default_1468")] + #[serde(default = "default_1471")] pub aliases: Vec, - #[serde(default = "default_1469")] + #[serde(default = "default_1472")] pub verdict: Option, - #[serde(default = "default_1470")] + #[serde(default = "default_1473")] pub lapse_reason: Option, - #[serde(default = "default_1471")] + #[serde(default = "default_1474")] pub lost: Vec, } @@ -33000,15 +33232,15 @@ impl MemoryDefinitionsListInput { #[non_exhaustive] pub struct MemoryDeleteVersionOutput { pub tombstoned: bool, - #[serde(default = "default_1472")] + #[serde(default = "default_1475")] pub version: Integer, - #[serde(default = "default_1473")] + #[serde(default = "default_1476")] pub found: bool, - #[serde(default = "default_1474")] + #[serde(default = "default_1477")] pub reason: String, - #[serde(default = "default_1475")] + #[serde(default = "default_1478")] pub dependents_tombstoned: Integer, - #[serde(default = "default_1476")] + #[serde(default = "default_1479")] pub dependents_downgraded: Integer, } @@ -33135,21 +33367,21 @@ pub struct DemonstrationRow { pub struct MemoryDemonstrateOutput { pub query: String, pub demonstrations: Vec, - #[serde(default = "default_1477")] + #[serde(default = "default_1480")] pub votes: std::collections::HashMap, - #[serde(default = "default_1478")] + #[serde(default = "default_1481")] pub predicted_label: String, - #[serde(default = "default_1479")] + #[serde(default = "default_1482")] pub margin: f64, - #[serde(default = "default_1480")] + #[serde(default = "default_1483")] pub abstain: bool, - #[serde(default = "default_1481")] + #[serde(default = "default_1484")] pub abstain_reason: String, - #[serde(default = "default_1482")] + #[serde(default = "default_1485")] pub few_shot_block: String, - #[serde(default = "default_1483")] + #[serde(default = "default_1486")] pub examined: Integer, - #[serde(default = "default_1484")] + #[serde(default = "default_1487")] pub labelled: Integer, } @@ -33289,7 +33521,7 @@ impl MemoryDemonstrateInput { pub struct MemoryDemoteOutput { pub demoted: bool, pub was_reversible: bool, - #[serde(default = "default_1485")] + #[serde(default = "default_1488")] pub tombstoned_at: Option, } @@ -33351,15 +33583,15 @@ impl MemoryDemoteInput { pub struct DigestRow { pub session_id: String, pub summary_text: String, - #[serde(default = "default_1486")] + #[serde(default = "default_1489")] pub key_facts: Vec, - #[serde(default = "default_1487")] + #[serde(default = "default_1490")] pub derived_from: Vec, - #[serde(default = "default_1488")] + #[serde(default = "default_1491")] pub valid_at: Option, - #[serde(default = "default_1489")] + #[serde(default = "default_1492")] pub created_at: Option, - #[serde(default = "default_1490")] + #[serde(default = "default_1493")] pub version: Integer, } @@ -33367,7 +33599,7 @@ pub struct DigestRow { #[non_exhaustive] pub struct MemoryDigestsOutput { pub rows: Vec, - #[serde(default = "default_1491")] + #[serde(default = "default_1494")] pub truncated: bool, } @@ -33492,17 +33724,17 @@ pub struct MemoryEvidenceItem { pub evidence_id: String, pub support_type: String, pub scope: MemoryEvidenceItemScope, - #[serde(default = "default_1495")] + #[serde(default = "default_1498")] pub role: String, - #[serde(default = "default_1496")] + #[serde(default = "default_1499")] pub observed_at: Option, - #[serde(default = "default_1497")] + #[serde(default = "default_1500")] pub content: String, - #[serde(default = "default_1498")] + #[serde(default = "default_1501")] pub char_start: Integer, - #[serde(default = "default_1499")] + #[serde(default = "default_1502")] pub char_end: Integer, - #[serde(default = "default_1500")] + #[serde(default = "default_1503")] pub span: String, } @@ -33510,23 +33742,23 @@ pub struct MemoryEvidenceItem { #[non_exhaustive] pub struct MemoryEvidenceOutput { pub found: bool, - #[serde(default = "default_1492")] + #[serde(default = "default_1495")] pub memory_key: String, - #[serde(default = "default_1493")] + #[serde(default = "default_1496")] pub memory_id: String, - #[serde(default = "default_1494")] + #[serde(default = "default_1497")] pub value: String, - #[serde(default = "default_1501")] + #[serde(default = "default_1504")] pub items: Vec, - #[serde(default = "default_1502")] + #[serde(default = "default_1505")] pub truncated: bool, - #[serde(default = "default_1503")] + #[serde(default = "default_1506")] pub cited: Integer, - #[serde(default = "default_1504")] + #[serde(default = "default_1507")] pub lexical: Integer, - #[serde(default = "default_1505")] + #[serde(default = "default_1508")] pub window: Integer, - #[serde(default = "default_1506")] + #[serde(default = "default_1509")] pub derived: Integer, } @@ -33631,26 +33863,26 @@ impl MemoryEvidenceInput { #[non_exhaustive] pub struct EvidenceChunk { pub session_id: String, - #[serde(default = "default_1507")] + #[serde(default = "default_1510")] pub chunk_index: Integer, pub content: String, - #[serde(default = "default_1508")] + #[serde(default = "default_1511")] pub content_sha256: String, - #[serde(default = "default_1509")] + #[serde(default = "default_1512")] pub agent: String, - #[serde(default = "default_1510")] + #[serde(default = "default_1513")] pub user_id: String, - #[serde(default = "default_1511")] + #[serde(default = "default_1514")] pub parent_memory_key: String, - #[serde(default = "default_1512")] + #[serde(default = "default_1515")] pub memory_keys: Vec, - #[serde(default = "default_1513")] + #[serde(default = "default_1516")] pub line_start: Integer, - #[serde(default = "default_1514")] + #[serde(default = "default_1517")] pub line_end: Integer, - #[serde(default = "default_1515")] + #[serde(default = "default_1518")] pub created_at: String, - #[serde(default = "default_1516")] + #[serde(default = "default_1519")] pub source_url: String, } @@ -33659,17 +33891,17 @@ pub struct EvidenceChunk { pub struct EvidenceDigest { pub session_id: String, pub summary_text: String, - #[serde(default = "default_1518")] + #[serde(default = "default_1521")] pub agent: String, - #[serde(default = "default_1519")] + #[serde(default = "default_1522")] pub user_id: String, - #[serde(default = "default_1520")] + #[serde(default = "default_1523")] pub key_facts: Vec, - #[serde(default = "default_1521")] + #[serde(default = "default_1524")] pub derived_from: Vec, - #[serde(default = "default_1522")] + #[serde(default = "default_1525")] pub valid_at: String, - #[serde(default = "default_1523")] + #[serde(default = "default_1526")] pub created_at: String, } @@ -33679,28 +33911,28 @@ pub struct EvidenceEdge { pub from_key: String, pub to_key: String, pub relation: String, - #[serde(default = "default_1525")] + #[serde(default = "default_1528")] pub confidence: f64, - #[serde(default = "default_1526")] + #[serde(default = "default_1529")] pub explanation: String, - #[serde(default = "default_1527")] + #[serde(default = "default_1530")] pub created_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExportEvidenceOutput { - #[serde(default = "default_1517")] + #[serde(default = "default_1520")] pub chunks: Vec, - #[serde(default = "default_1524")] + #[serde(default = "default_1527")] pub digests: Vec, - #[serde(default = "default_1528")] + #[serde(default = "default_1531")] pub edges: Vec, - #[serde(default = "default_1529")] + #[serde(default = "default_1532")] pub has_more: bool, - #[serde(default = "default_1530")] + #[serde(default = "default_1533")] pub next_cursor: String, - #[serde(default = "default_1531")] + #[serde(default = "default_1534")] pub held_high: Integer, } @@ -33893,15 +34125,15 @@ impl ExposureSummaryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionRetryMineOutput { - #[serde(default = "default_1532")] + #[serde(default = "default_1535")] pub requeued: Vec, - #[serde(default = "default_1533")] + #[serde(default = "default_1536")] pub not_failed: Vec, - #[serde(default = "default_1534")] + #[serde(default = "default_1537")] pub model_calls_off: Vec, - #[serde(default = "default_1535")] + #[serde(default = "default_1538")] pub expired: Vec, - #[serde(default = "default_1536")] + #[serde(default = "default_1539")] pub unknown: Vec, } @@ -33962,20 +34194,20 @@ pub struct ExtractionQueueRow { pub content_chars: Integer, pub written: Integer, pub last_error: String, - #[serde(default = "default_1537")] + #[serde(default = "default_1540")] pub enqueued_at: Option, - #[serde(default = "default_1538")] + #[serde(default = "default_1541")] pub updated_at: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionStatusOutput { - #[serde(default = "default_1539")] + #[serde(default = "default_1542")] pub batches: Vec, - #[serde(default = "default_1540")] + #[serde(default = "default_1543")] pub pending: Integer, - #[serde(default = "default_1541")] + #[serde(default = "default_1544")] pub failed: Integer, } @@ -34123,13 +34355,13 @@ impl MemoryExtractionStatusInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryExtractionStatusMineOutput { - #[serde(default = "default_1542")] + #[serde(default = "default_1545")] pub batches: Vec, - #[serde(default = "default_1543")] + #[serde(default = "default_1546")] pub unknown: Vec, - #[serde(default = "default_1544")] + #[serde(default = "default_1547")] pub pending: Integer, - #[serde(default = "default_1545")] + #[serde(default = "default_1548")] pub failed: Integer, } @@ -34250,38 +34482,40 @@ pub struct MemoryForFileHit { pub memory_key: String, pub memory_type: String, pub value: String, - #[serde(default = "default_1546")] + #[serde(default = "default_1549")] pub value_truncated: bool, - #[serde(default = "default_1547")] + #[serde(default = "default_1550")] pub tags: Vec, - #[serde(default = "default_1548")] + #[serde(default = "default_1551")] pub confidence: f64, - #[serde(default = "default_1549")] + #[serde(default = "default_1552")] pub pinned: bool, - #[serde(default = "default_1550")] + #[serde(default = "default_1553")] pub status: String, - #[serde(default = "default_1551")] + #[serde(default = "default_1554")] pub agent: String, - #[serde(default = "default_1552")] + #[serde(default = "default_1555")] pub updated_at: Option, - #[serde(default = "default_1553")] + #[serde(default = "default_1556")] pub namespace: String, - #[serde(default = "default_1554")] + #[serde(default = "default_1557")] pub actor: String, - #[serde(default = "default_1555")] + #[serde(default = "default_1558")] pub supersedes_key: String, - #[serde(default = "default_1556")] + #[serde(default = "default_1559")] pub supersedes: String, - #[serde(default = "default_1557")] + #[serde(default = "default_1560")] pub supersedes_kind: MemoryForFileHitSupersedesKind, - #[serde(default = "default_1558")] + #[serde(default = "default_1561")] pub matched_files: Vec, - #[serde(default = "default_1559")] + #[serde(default = "default_1562")] pub source_resource_id: String, - #[serde(default = "default_1560")] + #[serde(default = "default_1563")] pub verification: MemoryForFileHitVerification, - #[serde(default = "default_1561")] + #[serde(default = "default_1564")] pub code_state: MemoryForFileHitCodeState, + #[serde(default = "default_1565")] + pub use_guidance: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -34290,11 +34524,11 @@ pub struct MemoryForFileOutput { pub path: String, pub total: Integer, pub hits: Vec, - #[serde(default = "default_1562")] + #[serde(default = "default_1566")] pub rendered: String, - #[serde(default = "default_1563")] + #[serde(default = "default_1567")] pub tokens_estimate: Integer, - #[serde(default = "default_1564")] + #[serde(default = "default_1568")] pub truncated: bool, } @@ -34402,61 +34636,61 @@ impl MemoryForFileInput { #[non_exhaustive] pub struct MemoryGetByIdOutput { pub found: bool, - #[serde(default = "default_1565")] + #[serde(default = "default_1569")] pub memory_id: String, - #[serde(default = "default_1566")] + #[serde(default = "default_1570")] pub namespace: String, - #[serde(default = "default_1567")] + #[serde(default = "default_1571")] pub agent: String, - #[serde(default = "default_1568")] + #[serde(default = "default_1572")] pub user_id: String, - #[serde(default = "default_1569")] + #[serde(default = "default_1573")] pub session_id: String, - #[serde(default = "default_1570")] + #[serde(default = "default_1574")] pub memory_key: String, - #[serde(default = "default_1571")] + #[serde(default = "default_1575")] pub memory_type: Option, - #[serde(default = "default_1572")] + #[serde(default = "default_1576")] pub value: Value, - #[serde(default = "default_1573")] + #[serde(default = "default_1577")] pub confidence: Option, - #[serde(default = "default_1574")] + #[serde(default = "default_1578")] pub version: Option, - #[serde(default = "default_1575")] + #[serde(default = "default_1579")] pub created_at: Option, - #[serde(default = "default_1576")] + #[serde(default = "default_1580")] pub expires_at: Option, - #[serde(default = "default_1577")] + #[serde(default = "default_1581")] pub valid_at: Option, - #[serde(default = "default_1578")] + #[serde(default = "default_1582")] pub valid_to: Option, - #[serde(default = "default_1579")] + #[serde(default = "default_1583")] pub pinned: bool, - #[serde(default = "default_1580")] + #[serde(default = "default_1584")] pub content_sha256: String, - #[serde(default = "default_1581")] + #[serde(default = "default_1585")] pub verified_by: String, - #[serde(default = "default_1582")] + #[serde(default = "default_1586")] pub verified_at: Option, - #[serde(default = "default_1583")] + #[serde(default = "default_1587")] pub verification: String, - #[serde(default = "default_1584")] + #[serde(default = "default_1588")] pub sensitivity: String, - #[serde(default = "default_1585")] + #[serde(default = "default_1589")] pub actor: String, - #[serde(default = "default_1586")] + #[serde(default = "default_1590")] pub source_class: String, - #[serde(default = "default_1587")] + #[serde(default = "default_1591")] pub lock_mode: String, - #[serde(default = "default_1588")] + #[serde(default = "default_1592")] pub lock_reason: String, - #[serde(default = "default_1589")] + #[serde(default = "default_1593")] pub lock_until: Option, - #[serde(default = "default_1590")] + #[serde(default = "default_1594")] pub locked_by: String, - #[serde(default = "default_1591")] + #[serde(default = "default_1595")] pub on_expire: String, - #[serde(default = "default_1592")] + #[serde(default = "default_1596")] pub expire_reason: String, } @@ -34532,41 +34766,41 @@ pub struct MemoryHealthTopRow { pub memory_type: String, pub recall_count: Integer, pub used_count: Integer, - #[serde(default = "default_1595")] + #[serde(default = "default_1599")] pub harm_count: Integer, - #[serde(default = "default_1596")] + #[serde(default = "default_1600")] pub last_recalled_at: Option, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryHealthStaleness { - #[serde(default = "default_1598")] + #[serde(default = "default_1602")] pub by_age: std::collections::HashMap, - #[serde(default = "default_1599")] + #[serde(default = "default_1603")] pub with_validity_end: Integer, - #[serde(default = "default_1600")] + #[serde(default = "default_1604")] pub with_validity_end_share: f64, - #[serde(default = "default_1601")] + #[serde(default = "default_1605")] pub with_expiry: Integer, - #[serde(default = "default_1602")] + #[serde(default = "default_1606")] pub expiring_7d: Integer, - #[serde(default = "default_1603")] + #[serde(default = "default_1607")] pub pinned: Integer, - #[serde(default = "default_1604")] + #[serde(default = "default_1608")] pub days_since_reinforced_p50: Integer, - #[serde(default = "default_1605")] + #[serde(default = "default_1609")] pub days_since_reinforced_p90: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryHealthFootprint { - #[serde(default = "default_1607")] + #[serde(default = "default_1611")] pub value_chars: Integer, - #[serde(default = "default_1608")] + #[serde(default = "default_1612")] pub value_tokens_est: Integer, - #[serde(default = "default_1609")] + #[serde(default = "default_1613")] pub tokens_per_row_est: f64, } @@ -34576,19 +34810,19 @@ pub struct MemoryHealthOutput { pub live: Integer, pub recalled_ever: Integer, pub used_ever: Integer, - #[serde(default = "default_1593")] + #[serde(default = "default_1597")] pub harmed_ever: Integer, pub silent: Integer, pub silent_older: Integer, pub silent_share: f64, pub silent_after_days: Integer, - #[serde(default = "default_1594")] + #[serde(default = "default_1598")] pub by_type: Vec, - #[serde(default = "default_1597")] + #[serde(default = "default_1601")] pub top_recalled: Vec, - #[serde(default = "default_1606")] - pub staleness: MemoryHealthStaleness, #[serde(default = "default_1610")] + pub staleness: MemoryHealthStaleness, + #[serde(default = "default_1614")] pub footprint: MemoryHealthFootprint, } @@ -34708,51 +34942,51 @@ impl MemoryHealthInput { pub struct MemoryHistoryRow { pub memory_id: String, pub version: Integer, - #[serde(default = "default_1611")] + #[serde(default = "default_1615")] pub version_text: String, - #[serde(default = "default_1612")] + #[serde(default = "default_1616")] pub value: Value, pub confidence: f64, - #[serde(default = "default_1613")] + #[serde(default = "default_1617")] pub source_trace: String, - #[serde(default = "default_1614")] + #[serde(default = "default_1618")] pub pinned: bool, pub created_at: String, - #[serde(default = "default_1615")] + #[serde(default = "default_1619")] pub expires_at: Option, - #[serde(default = "default_1616")] + #[serde(default = "default_1620")] pub tombstoned_at: Option, - #[serde(default = "default_1617")] + #[serde(default = "default_1621")] pub redacted_at: Option, - #[serde(default = "default_1618")] + #[serde(default = "default_1622")] pub redaction_reason: String, - #[serde(default = "default_1619")] + #[serde(default = "default_1623")] pub content_sha256: String, - #[serde(default = "default_1620")] + #[serde(default = "default_1624")] pub actor: String, - #[serde(default = "default_1621")] + #[serde(default = "default_1625")] pub source_class: String, - #[serde(default = "default_1622")] + #[serde(default = "default_1626")] pub agent: String, - #[serde(default = "default_1623")] + #[serde(default = "default_1627")] pub written_at: Option, - #[serde(default = "default_1624")] + #[serde(default = "default_1628")] pub status: String, - #[serde(default = "default_1625")] + #[serde(default = "default_1629")] pub conflict_with: Vec, - #[serde(default = "default_1626")] + #[serde(default = "default_1630")] pub tags: Vec, - #[serde(default = "default_1627")] + #[serde(default = "default_1631")] pub verified_at: Option, - #[serde(default = "default_1628")] + #[serde(default = "default_1632")] pub verified_by: String, - #[serde(default = "default_1629")] + #[serde(default = "default_1633")] pub verified_sha256: String, - #[serde(default = "default_1630")] + #[serde(default = "default_1634")] pub lock_mode: String, - #[serde(default = "default_1631")] + #[serde(default = "default_1635")] pub lock_reason: String, - #[serde(default = "default_1632")] + #[serde(default = "default_1636")] pub lock_until: Option, } @@ -34862,13 +35096,13 @@ impl MemoryHistoryInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryImportTotals { - #[serde(default = "default_1633")] + #[serde(default = "default_1637")] pub written: Integer, - #[serde(default = "default_1634")] + #[serde(default = "default_1638")] pub held: Integer, - #[serde(default = "default_1635")] + #[serde(default = "default_1639")] pub skipped: Integer, - #[serde(default = "default_1636")] + #[serde(default = "default_1640")] pub refused: Integer, } @@ -34951,11 +35185,11 @@ pub struct MemoryImportResult { pub index: Integer, pub key: String, pub outcome: MemoryImportResultOutcome, - #[serde(default = "default_1637")] + #[serde(default = "default_1641")] pub reason: MemoryImportResultReason, - #[serde(default = "default_1638")] + #[serde(default = "default_1642")] pub held_by: String, - #[serde(default = "default_1639")] + #[serde(default = "default_1643")] pub note: MemoryImportResultNote, } @@ -34964,7 +35198,7 @@ pub struct MemoryImportResult { pub struct MemoryImportOutput { pub totals: MemoryImportTotals, pub results: Vec, - #[serde(default = "default_1640")] + #[serde(default = "default_1644")] pub dry_run: bool, } @@ -35157,9 +35391,9 @@ pub struct MemoryImportCuratedRow { pub section_heading: String, pub bytes_written: Integer, pub verdict: String, - #[serde(default = "default_1641")] + #[serde(default = "default_1645")] pub rejection_reason: String, - #[serde(default = "default_1642")] + #[serde(default = "default_1646")] pub pinned_blocker_id: Option, } @@ -35251,21 +35485,21 @@ impl MemoryImportCuratedInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryImportEvidenceOutput { - #[serde(default = "default_1643")] + #[serde(default = "default_1647")] pub chunks_written: Integer, - #[serde(default = "default_1644")] + #[serde(default = "default_1648")] pub links_written: Integer, - #[serde(default = "default_1645")] + #[serde(default = "default_1649")] pub digests_written: Integer, - #[serde(default = "default_1646")] + #[serde(default = "default_1650")] pub embedding_model: String, - #[serde(default = "default_1647")] + #[serde(default = "default_1651")] pub embedding_dim: Integer, - #[serde(default = "default_1648")] + #[serde(default = "default_1652")] pub edited: Vec, - #[serde(default = "default_1649")] + #[serde(default = "default_1653")] pub skipped: Integer, - #[serde(default = "default_1650")] + #[serde(default = "default_1654")] pub unchecked: Integer, } @@ -35602,7 +35836,7 @@ pub struct InspectRow { pub memory_key: String, pub memory_id: String, pub version: Integer, - #[serde(default = "default_1660")] + #[serde(default = "default_1664")] pub content_sha256: String, pub memory_type: String, pub status: String, @@ -35613,9 +35847,9 @@ pub struct InspectRow { pub actor: String, pub updated_at: String, pub sensitivity: String, - #[serde(default = "default_1661")] + #[serde(default = "default_1665")] pub versions: Integer, - #[serde(default = "default_1662")] + #[serde(default = "default_1666")] pub excerpt: String, } @@ -35623,27 +35857,27 @@ pub struct InspectRow { #[non_exhaustive] pub struct InspectView { pub definition: String, - #[serde(default = "default_1651")] + #[serde(default = "default_1655")] pub refs: Vec, - #[serde(default = "default_1652")] + #[serde(default = "default_1656")] pub live_rows: Integer, - #[serde(default = "default_1653")] + #[serde(default = "default_1657")] pub by_type: Vec, - #[serde(default = "default_1654")] + #[serde(default = "default_1658")] pub by_status: Vec, - #[serde(default = "default_1655")] + #[serde(default = "default_1659")] pub by_source_class: Vec, - #[serde(default = "default_1656")] + #[serde(default = "default_1660")] pub top_tags: Vec, - #[serde(default = "default_1657")] + #[serde(default = "default_1661")] pub categories: Vec, - #[serde(default = "default_1658")] + #[serde(default = "default_1662")] pub first_updated_at: Option, - #[serde(default = "default_1659")] - pub last_updated_at: Option, #[serde(default = "default_1663")] + pub last_updated_at: Option, + #[serde(default = "default_1667")] pub newest: Vec, - #[serde(default = "default_1664")] + #[serde(default = "default_1668")] pub complete: bool, } @@ -35659,32 +35893,32 @@ pub struct InspectCall { #[non_exhaustive] pub struct InspectActivity { pub window_seconds: Integer, - #[serde(default = "default_1665")] + #[serde(default = "default_1669")] pub calls: Vec, - #[serde(default = "default_1666")] + #[serde(default = "default_1670")] pub first_at: Option, - #[serde(default = "default_1667")] + #[serde(default = "default_1671")] pub last_at: Option, - #[serde(default = "default_1668")] + #[serde(default = "default_1672")] pub gap: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct InspectSettings { - #[serde(default = "default_1669")] + #[serde(default = "default_1673")] pub guide_revision: Integer, - #[serde(default = "default_1670")] + #[serde(default = "default_1674")] pub guide_summary: String, - #[serde(default = "default_1671")] + #[serde(default = "default_1675")] pub categories_registered: Integer, - #[serde(default = "default_1672")] + #[serde(default = "default_1676")] pub extraction_policy: Option, - #[serde(default = "default_1673")] + #[serde(default = "default_1677")] pub extraction_policy_unavailable: String, - #[serde(default = "default_1674")] + #[serde(default = "default_1678")] pub extraction_instructions: String, - #[serde(default = "default_1675")] + #[serde(default = "default_1679")] pub extraction_instructions_refs: Vec, } @@ -35700,7 +35934,7 @@ pub struct MemoryInspectOutput { pub others: InspectView, pub activity: InspectActivity, pub settings: InspectSettings, - #[serde(default = "default_1676")] + #[serde(default = "default_1680")] pub skipped: Vec, } @@ -35794,7 +36028,7 @@ pub struct MemoryKeyRef { #[non_exhaustive] pub struct MemoryKeysOutput { pub keys: Vec, - #[serde(default = "default_1677")] + #[serde(default = "default_1681")] pub truncated: bool, } @@ -35897,9 +36131,9 @@ pub struct LineageCandidate { pub decided_at: String, pub decided_by: String, pub match_confidence: LineageCandidateMatchConfidence, - #[serde(default = "default_1686")] + #[serde(default = "default_1690")] pub seeded_from_thread_id: String, - #[serde(default = "default_1687")] + #[serde(default = "default_1691")] pub seeded_from_msg_id: String, } @@ -35917,25 +36151,25 @@ pub struct LineageAuditEvent { pub struct MemoryLineageOutput { pub found: bool, pub memory_key: String, - #[serde(default = "default_1678")] + #[serde(default = "default_1682")] pub promotion_event: String, - #[serde(default = "default_1679")] + #[serde(default = "default_1683")] pub promoted_by: String, - #[serde(default = "default_1680")] + #[serde(default = "default_1684")] pub promoted_at: Option, - #[serde(default = "default_1681")] + #[serde(default = "default_1685")] pub rationale: String, - #[serde(default = "default_1682")] + #[serde(default = "default_1686")] pub source_trace: String, - #[serde(default = "default_1683")] + #[serde(default = "default_1687")] pub source_resource_id: String, - #[serde(default = "default_1684")] + #[serde(default = "default_1688")] pub mechanism: MemoryLineageOutputMechanism, - #[serde(default = "default_1685")] + #[serde(default = "default_1689")] pub supporters: Vec, - #[serde(default = "default_1688")] + #[serde(default = "default_1692")] pub candidate: Option, - #[serde(default = "default_1689")] + #[serde(default = "default_1693")] pub audit_chain: Vec, } @@ -36064,11 +36298,11 @@ pub struct MemoryLinkOutput { pub from_key: String, pub to_key: String, pub relation: String, - #[serde(default = "default_1690")] + #[serde(default = "default_1694")] pub confidence: f64, - #[serde(default = "default_1691")] + #[serde(default = "default_1695")] pub conflict_opened: bool, - #[serde(default = "default_1692")] + #[serde(default = "default_1696")] pub relation_defaulted: bool, } @@ -36382,17 +36616,17 @@ pub struct MemoryListEntry { pub struct MemoryListOutput { pub entries: Vec, pub truncated: bool, - #[serde(default = "default_1693")] + #[serde(default = "default_1697")] pub total: Integer, - #[serde(default = "default_1694")] + #[serde(default = "default_1698")] pub today: Integer, - #[serde(default = "default_1695")] + #[serde(default = "default_1699")] pub namespace_version: String, - #[serde(default = "default_1696")] + #[serde(default = "default_1700")] pub unchanged: bool, - #[serde(default = "default_1697")] + #[serde(default = "default_1701")] pub hidden: Integer, - #[serde(default = "default_1698")] + #[serde(default = "default_1702")] pub hidden_hint: String, } @@ -36778,19 +37012,19 @@ impl MemoryListInput { #[non_exhaustive] pub struct MemoryLockOutput { pub locked: bool, - #[serde(default = "default_1699")] + #[serde(default = "default_1703")] pub reason: String, - #[serde(default = "default_1700")] + #[serde(default = "default_1704")] pub memory_id: String, - #[serde(default = "default_1701")] + #[serde(default = "default_1705")] pub version: Option, - #[serde(default = "default_1702")] + #[serde(default = "default_1706")] pub lock_mode: String, - #[serde(default = "default_1703")] + #[serde(default = "default_1707")] pub lock_until: Option, - #[serde(default = "default_1704")] + #[serde(default = "default_1708")] pub locked_by: String, - #[serde(default = "default_1705")] + #[serde(default = "default_1709")] pub previous_mode: String, } @@ -36949,21 +37183,21 @@ pub struct MemoryMoveOutput { pub from_key: String, pub to_key: String, pub redirected: bool, - #[serde(default = "default_1706")] + #[serde(default = "default_1710")] pub memory_id: String, - #[serde(default = "default_1707")] + #[serde(default = "default_1711")] pub version: Integer, - #[serde(default = "default_1708")] + #[serde(default = "default_1712")] pub content_sha256: String, - #[serde(default = "default_1709")] + #[serde(default = "default_1713")] pub advisories: Vec, - #[serde(default = "default_1710")] + #[serde(default = "default_1714")] pub dry_run: bool, - #[serde(default = "default_1711")] + #[serde(default = "default_1715")] pub memory_type: String, - #[serde(default = "default_1712")] + #[serde(default = "default_1716")] pub value_preview: String, - #[serde(default = "default_1713")] + #[serde(default = "default_1717")] pub sensitivity: String, } @@ -37175,7 +37409,7 @@ impl MemoryMoveInput { pub struct MemoryOutcomeOutput { pub recorded: bool, pub evidence_count_after: Integer, - #[serde(default = "default_1714")] + #[serde(default = "default_1718")] pub quarantined: bool, } @@ -37418,13 +37652,13 @@ impl MemoryOutcomeRunInput { #[non_exhaustive] pub struct OutlineSession { pub session_id: String, - #[serde(default = "default_1716")] + #[serde(default = "default_1720")] pub date: String, - #[serde(default = "default_1717")] + #[serde(default = "default_1721")] pub headline: String, - #[serde(default = "default_1718")] + #[serde(default = "default_1722")] pub key_facts: Integer, - #[serde(default = "default_1719")] + #[serde(default = "default_1723")] pub rows: Integer, } @@ -37432,7 +37666,7 @@ pub struct OutlineSession { #[non_exhaustive] pub struct OutlineHub { pub entity: String, - #[serde(default = "default_1722")] + #[serde(default = "default_1726")] pub degree: Integer, } @@ -37440,28 +37674,28 @@ pub struct OutlineHub { #[non_exhaustive] pub struct OutlineCommunity { pub community_id: Integer, - #[serde(default = "default_1724")] + #[serde(default = "default_1728")] pub label: String, - #[serde(default = "default_1725")] + #[serde(default = "default_1729")] pub size: Integer, - #[serde(default = "default_1726")] + #[serde(default = "default_1730")] pub computed_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryOutlineOutput { - #[serde(default = "default_1715")] + #[serde(default = "default_1719")] pub rows_by_type: std::collections::HashMap, - #[serde(default = "default_1720")] + #[serde(default = "default_1724")] pub sessions: Vec, - #[serde(default = "default_1721")] + #[serde(default = "default_1725")] pub sessions_total: Integer, - #[serde(default = "default_1723")] - pub hubs: Vec, #[serde(default = "default_1727")] + pub hubs: Vec, + #[serde(default = "default_1731")] pub communities: Vec, - #[serde(default = "default_1728")] + #[serde(default = "default_1732")] pub profile_chars: Integer, } @@ -37613,7 +37847,7 @@ pub struct OwnerUsageRow { pub recalls: Integer, pub used: Integer, pub harm: Integer, - #[serde(default = "default_1729")] + #[serde(default = "default_1733")] pub last_recalled: Option, } @@ -38100,7 +38334,7 @@ pub struct MemoryPromoteOutput { pub shared_memory_key: String, pub promotion_event: String, pub reversible_until: String, - #[serde(default = "default_1730")] + #[serde(default = "default_1734")] pub ignored_args: Vec, } @@ -38269,18 +38503,18 @@ impl MemoryPromoteInput { pub struct MemoryProposalDecision { pub memory_key: String, pub decided: bool, - #[serde(default = "default_1732")] + #[serde(default = "default_1736")] pub status: String, - #[serde(default = "default_1733")] + #[serde(default = "default_1737")] pub reason: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalDecideOutput { - #[serde(default = "default_1731")] + #[serde(default = "default_1735")] pub decided: Integer, - #[serde(default = "default_1734")] + #[serde(default = "default_1738")] pub results: Vec, } @@ -38381,33 +38615,33 @@ pub enum MemoryProposalReady { pub struct MemoryProposal { pub memory_key: String, pub memory_id: String, - #[serde(default = "default_1735")] + #[serde(default = "default_1739")] pub content_sha256: String, - #[serde(default = "default_1736")] + #[serde(default = "default_1740")] pub agent: String, - #[serde(default = "default_1737")] + #[serde(default = "default_1741")] pub memory_type: String, - #[serde(default = "default_1738")] + #[serde(default = "default_1742")] pub value_preview: String, - #[serde(default = "default_1739")] + #[serde(default = "default_1743")] pub sensitivity: String, - #[serde(default = "default_1740")] + #[serde(default = "default_1744")] pub tags: Vec, - #[serde(default = "default_1741")] + #[serde(default = "default_1745")] pub created_at: String, - #[serde(default = "default_1742")] + #[serde(default = "default_1746")] pub graded_passes: Integer, - #[serde(default = "default_1743")] + #[serde(default = "default_1747")] pub graded_fails: Integer, - #[serde(default = "default_1744")] + #[serde(default = "default_1748")] pub last_graded_at: String, - #[serde(default = "default_1745")] + #[serde(default = "default_1749")] pub used_count: Integer, - #[serde(default = "default_1746")] + #[serde(default = "default_1750")] pub harm_count: Integer, - #[serde(default = "default_1747")] + #[serde(default = "default_1751")] pub ready: MemoryProposalReady, - #[serde(default = "default_1748")] + #[serde(default = "default_1752")] pub conflict_with: Vec, } @@ -38423,24 +38657,24 @@ pub enum ProposalPolicyMode { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProposalPolicy { - #[serde(default = "default_1751")] + #[serde(default = "default_1755")] pub mode: ProposalPolicyMode, - #[serde(default = "default_1752")] + #[serde(default = "default_1756")] pub min_passes: Integer, - #[serde(default = "default_1753")] + #[serde(default = "default_1757")] pub max_fails: Integer, - #[serde(default = "default_1754")] + #[serde(default = "default_1758")] pub reject_after_fails: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalsOutput { - #[serde(default = "default_1749")] + #[serde(default = "default_1753")] pub proposals: Vec, - #[serde(default = "default_1750")] + #[serde(default = "default_1754")] pub total: Integer, - #[serde(default = "default_1755")] + #[serde(default = "default_1759")] pub policy: ProposalPolicy, } @@ -38547,19 +38781,19 @@ impl MemoryProposalsInput { pub struct MemoryProvenanceLink { pub direction: String, pub memory_key: String, - #[serde(default = "default_1769")] + #[serde(default = "default_1773")] pub relation: String, - #[serde(default = "default_1770")] + #[serde(default = "default_1774")] pub label: String, - #[serde(default = "default_1771")] + #[serde(default = "default_1775")] pub explanation: String, - #[serde(default = "default_1772")] + #[serde(default = "default_1776")] pub evidence: Vec, - #[serde(default = "default_1773")] + #[serde(default = "default_1777")] pub confidence: f64, - #[serde(default = "default_1774")] + #[serde(default = "default_1778")] pub author: String, - #[serde(default = "default_1775")] + #[serde(default = "default_1779")] pub run_id: String, } @@ -38567,33 +38801,33 @@ pub struct MemoryProvenanceLink { #[non_exhaustive] pub struct MemoryProvenanceOutput { pub found: bool, - #[serde(default = "default_1756")] + #[serde(default = "default_1760")] pub source_trace: String, - #[serde(default = "default_1757")] + #[serde(default = "default_1761")] pub source_kind: String, - #[serde(default = "default_1758")] + #[serde(default = "default_1762")] pub actor: String, - #[serde(default = "default_1759")] + #[serde(default = "default_1763")] pub source_class: String, - #[serde(default = "default_1760")] + #[serde(default = "default_1764")] pub source_label: String, - #[serde(default = "default_1761")] + #[serde(default = "default_1765")] pub thread_id: String, - #[serde(default = "default_1762")] + #[serde(default = "default_1766")] pub thread_exists: bool, - #[serde(default = "default_1763")] + #[serde(default = "default_1767")] pub thread_title: String, - #[serde(default = "default_1764")] + #[serde(default = "default_1768")] pub agent: String, - #[serde(default = "default_1765")] + #[serde(default = "default_1769")] pub session_id: String, - #[serde(default = "default_1766")] + #[serde(default = "default_1770")] pub run_id: String, - #[serde(default = "default_1767")] + #[serde(default = "default_1771")] pub written_at: String, - #[serde(default = "default_1768")] + #[serde(default = "default_1772")] pub source_resource_id: String, - #[serde(default = "default_1776")] + #[serde(default = "default_1780")] pub links: Vec, } @@ -38688,17 +38922,17 @@ impl MemoryProvenanceInput { pub struct RecallTurn { pub evidence_id: String, pub session_id: String, - #[serde(default = "default_1777")] + #[serde(default = "default_1781")] pub role: String, - #[serde(default = "default_1778")] + #[serde(default = "default_1782")] pub actor: String, - #[serde(default = "default_1779")] + #[serde(default = "default_1783")] pub observed_at: String, - #[serde(default = "default_1780")] + #[serde(default = "default_1784")] pub content: String, - #[serde(default = "default_1781")] + #[serde(default = "default_1785")] pub truncated: bool, - #[serde(default = "default_1782")] + #[serde(default = "default_1786")] pub matched_tokens: Integer, } @@ -38715,21 +38949,21 @@ pub enum MemoryRecallOutputOrder { #[non_exhaustive] pub struct MemoryRecallOutput { pub turns: Vec, - #[serde(default = "default_1783")] + #[serde(default = "default_1787")] pub total_matched: Integer, - #[serde(default = "default_1784")] + #[serde(default = "default_1788")] pub returned: Integer, - #[serde(default = "default_1785")] + #[serde(default = "default_1789")] pub has_more: bool, - #[serde(default = "default_1786")] + #[serde(default = "default_1790")] pub next_cursor: String, - #[serde(default = "default_1787")] + #[serde(default = "default_1791")] pub next_offset: Integer, - #[serde(default = "default_1788")] + #[serde(default = "default_1792")] pub order: MemoryRecallOutputOrder, - #[serde(default = "default_1789")] + #[serde(default = "default_1793")] pub query_tokens: Vec, - #[serde(default = "default_1790")] + #[serde(default = "default_1794")] pub tokens_returned: Integer, } @@ -39011,19 +39245,19 @@ pub struct MemoryRecordConflictRow { pub schema_name: String, pub memory_key: String, pub field_name: String, - #[serde(default = "default_1791")] + #[serde(default = "default_1795")] pub prior_value: Value, - #[serde(default = "default_1792")] + #[serde(default = "default_1796")] pub incoming_value: Value, pub prior_record_id: String, pub incoming_record_id: String, - #[serde(default = "default_1793")] + #[serde(default = "default_1797")] pub prior_memory_id: String, - #[serde(default = "default_1794")] + #[serde(default = "default_1798")] pub incoming_memory_id: String, - #[serde(default = "default_1795")] + #[serde(default = "default_1799")] pub detected_at: Option, - #[serde(default = "default_1796")] + #[serde(default = "default_1800")] pub resolved_at: Option, } @@ -39031,7 +39265,7 @@ pub struct MemoryRecordConflictRow { #[non_exhaustive] pub struct MemoryRecordConflictsOutput { pub rows: Vec, - #[serde(default = "default_1797")] + #[serde(default = "default_1801")] pub truncated: bool, } @@ -39141,19 +39375,19 @@ pub enum MemoryRecordRowStatus { #[non_exhaustive] pub struct MemoryRecordRow { pub record_id: String, - #[serde(default = "default_1798")] + #[serde(default = "default_1802")] pub memory_key: String, - #[serde(default = "default_1799")] + #[serde(default = "default_1803")] pub memory_id: String, - #[serde(default = "default_1800")] + #[serde(default = "default_1804")] pub record: std::collections::HashMap, - #[serde(default = "default_1801")] + #[serde(default = "default_1805")] pub field_states: std::collections::HashMap, - #[serde(default = "default_1802")] + #[serde(default = "default_1806")] pub status: MemoryRecordRowStatus, - #[serde(default = "default_1803")] + #[serde(default = "default_1807")] pub valid_at: Option, - #[serde(default = "default_1804")] + #[serde(default = "default_1808")] pub valid_to: Option, } @@ -39220,7 +39454,7 @@ impl MemoryRecordHistoryInput { #[non_exhaustive] pub struct MemoryRecordQueryOutput { pub rows: Vec, - #[serde(default = "default_1805")] + #[serde(default = "default_1809")] pub truncated: bool, } @@ -39444,15 +39678,15 @@ pub enum MemoryRecordWriteOutputKeySource { pub struct MemoryRecordWriteOutput { pub record_id: String, pub field_count: Integer, - #[serde(default = "default_1806")] + #[serde(default = "default_1810")] pub memory_key: String, - #[serde(default = "default_1807")] + #[serde(default = "default_1811")] pub key_source: MemoryRecordWriteOutputKeySource, - #[serde(default = "default_1808")] + #[serde(default = "default_1812")] pub fold: std::collections::HashMap, - #[serde(default = "default_1809")] + #[serde(default = "default_1813")] pub superseded_record_id: String, - #[serde(default = "default_1810")] + #[serde(default = "default_1814")] pub conflicts: Integer, } @@ -39695,13 +39929,13 @@ impl MemoryRecordWriteInput { #[non_exhaustive] pub struct MemoryRedactOutput { pub redacted: bool, - #[serde(default = "default_1811")] + #[serde(default = "default_1815")] pub refused_head: bool, - #[serde(default = "default_1812")] + #[serde(default = "default_1816")] pub redacted_at: Option, - #[serde(default = "default_1813")] + #[serde(default = "default_1817")] pub cache_rows_deleted: Integer, - #[serde(default = "default_1814")] + #[serde(default = "default_1818")] pub precedent_rows_deleted: Integer, } @@ -39861,7 +40095,7 @@ impl MemoryReindexInput { #[non_exhaustive] pub struct MemoryRejectOutput { pub rejected: bool, - #[serde(default = "default_1815")] + #[serde(default = "default_1819")] pub rejected_at: Option, } @@ -39977,7 +40211,7 @@ pub struct MemoryRelatedHit { pub struct MemoryRelatedOutput { pub results: Vec, pub source_entities: Vec, - #[serde(default = "default_1816")] + #[serde(default = "default_1820")] pub reason: String, } @@ -40092,13 +40326,13 @@ impl MemoryRelatedInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryResolveOrphanDuplicatesOutput { - #[serde(default = "default_1817")] + #[serde(default = "default_1821")] pub candidates: Integer, - #[serde(default = "default_1818")] + #[serde(default = "default_1822")] pub reactivated: Integer, - #[serde(default = "default_1819")] + #[serde(default = "default_1823")] pub dry_run: bool, - #[serde(default = "default_1820")] + #[serde(default = "default_1824")] pub memory_ids: Vec, } @@ -40175,15 +40409,15 @@ impl MemoryResolveOrphanDuplicatesInput { #[non_exhaustive] pub struct MemoryRestoreOutput { pub restored: bool, - #[serde(default = "default_1821")] + #[serde(default = "default_1825")] pub memory_id: Option, - #[serde(default = "default_1822")] + #[serde(default = "default_1826")] pub version: Option, - #[serde(default = "default_1823")] + #[serde(default = "default_1827")] pub expired: bool, - #[serde(default = "default_1824")] + #[serde(default = "default_1828")] pub redacted: bool, - #[serde(default = "default_1825")] + #[serde(default = "default_1829")] pub from_status: String, } @@ -40303,13 +40537,13 @@ pub struct SearchTraceHit { pub content_excerpt: String, pub distance: f64, pub similarity: f64, - #[serde(default = "default_1826")] + #[serde(default = "default_1830")] pub entity_boost: f64, pub rank_score: f64, pub rank: Integer, - #[serde(default = "default_1827")] + #[serde(default = "default_1831")] pub source: String, - #[serde(default = "default_1828")] + #[serde(default = "default_1832")] pub parent_memory_key: String, } @@ -40319,11 +40553,11 @@ pub struct MemorySearchTraceOutput { pub results: Vec, pub embedding_model: String, pub entity_filter: Vec, - #[serde(default = "default_1829")] + #[serde(default = "default_1833")] pub query_spellings: std::collections::HashMap, - #[serde(default = "default_1830")] + #[serde(default = "default_1834")] pub query_spellings_skipped: bool, - #[serde(default = "default_1831")] + #[serde(default = "default_1835")] pub stale_dropped: Integer, } @@ -41504,7 +41738,7 @@ pub struct SearchTraceLogRow { pub embedding_model: String, pub latency_ms: Integer, pub run_id: String, - #[serde(default = "default_1832")] + #[serde(default = "default_1836")] pub operation: String, } @@ -41613,71 +41847,71 @@ pub struct RefusedFact { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySetFromMessagesOutput { - #[serde(default = "default_1833")] + #[serde(default = "default_1837")] pub written: Vec, - #[serde(default = "default_1834")] + #[serde(default = "default_1838")] pub refused: Vec, - #[serde(default = "default_1835")] + #[serde(default = "default_1839")] pub tokens_in: Integer, - #[serde(default = "default_1836")] + #[serde(default = "default_1840")] pub tokens_out: Integer, - #[serde(default = "default_1837")] + #[serde(default = "default_1841")] pub llm_provider: String, - #[serde(default = "default_1838")] + #[serde(default = "default_1842")] pub llm_model: String, - #[serde(default = "default_1839")] + #[serde(default = "default_1843")] pub segments: Integer, - #[serde(default = "default_1840")] + #[serde(default = "default_1844")] pub foresight: Integer, - #[serde(default = "default_1841")] + #[serde(default = "default_1845")] pub forgotten: Integer, - #[serde(default = "default_1842")] + #[serde(default = "default_1846")] pub forgotten_keys: Vec, - #[serde(default = "default_1843")] + #[serde(default = "default_1847")] pub forget_requests: Integer, - #[serde(default = "default_1844")] + #[serde(default = "default_1848")] pub about_other: Integer, - #[serde(default = "default_1845")] + #[serde(default = "default_1849")] pub premise_facts: Integer, - #[serde(default = "default_1846")] + #[serde(default = "default_1850")] pub learning_candidates: Integer, - #[serde(default = "default_1847")] + #[serde(default = "default_1851")] pub ignored_args: Vec, - #[serde(default = "default_1848")] + #[serde(default = "default_1852")] pub segmenter: String, - #[serde(default = "default_1849")] + #[serde(default = "default_1853")] pub cached_tokens_in: Integer, - #[serde(default = "default_1850")] + #[serde(default = "default_1854")] pub ontology_warnings: Vec, - #[serde(default = "default_1851")] + #[serde(default = "default_1855")] pub evidence_ids: Vec, - #[serde(default = "default_1852")] + #[serde(default = "default_1856")] pub belief_source_links: Integer, - #[serde(default = "default_1853")] + #[serde(default = "default_1857")] pub pipeline_errors: Vec, - #[serde(default = "default_1854")] + #[serde(default = "default_1858")] pub value_updates_linked: Integer, - #[serde(default = "default_1855")] + #[serde(default = "default_1859")] pub stubbed_fields: Vec, - #[serde(default = "default_1856")] + #[serde(default = "default_1860")] pub degraded: Vec, - #[serde(default = "default_1857")] + #[serde(default = "default_1861")] pub deferred: bool, - #[serde(default = "default_1858")] + #[serde(default = "default_1862")] pub queue_id: String, - #[serde(default = "default_1859")] + #[serde(default = "default_1863")] pub deferred_by: String, - #[serde(default = "default_1860")] + #[serde(default = "default_1864")] pub stage_ms: std::collections::HashMap, - #[serde(default = "default_1861")] + #[serde(default = "default_1865")] pub observation_date_source: String, - #[serde(default = "default_1862")] + #[serde(default = "default_1866")] pub under_operator_policy: bool, - #[serde(default = "default_1863")] + #[serde(default = "default_1867")] pub extract_prompt_keys: Vec, - #[serde(default = "default_1864")] + #[serde(default = "default_1868")] pub llm_cache_hits: Integer, - #[serde(default = "default_1865")] + #[serde(default = "default_1869")] pub llm_cache_misses: Integer, } @@ -42090,23 +42324,25 @@ pub enum StackEntrySection { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct StackEntry { + #[serde(default = "default_1870")] + pub use_guidance: Option, pub section: StackEntrySection, - #[serde(default = "default_1866")] + #[serde(default = "default_1871")] pub memory_key: String, - #[serde(default = "default_1867")] + #[serde(default = "default_1872")] pub memory_type: String, - #[serde(default = "default_1868")] + #[serde(default = "default_1873")] pub value: String, pub tokens: Integer, - #[serde(default = "default_1869")] + #[serde(default = "default_1874")] pub pinned: bool, - #[serde(default = "default_1870")] + #[serde(default = "default_1875")] pub recall_count: Integer, - #[serde(default = "default_1871")] + #[serde(default = "default_1876")] pub last_recalled_at: Option, - #[serde(default = "default_1872")] + #[serde(default = "default_1877")] pub actor: String, - #[serde(default = "default_1873")] + #[serde(default = "default_1878")] pub namespace: String, } @@ -42291,14 +42527,14 @@ impl MemoryStackInput { pub struct MemoryStatus { pub memory_id: String, pub status: String, - #[serde(default = "default_1874")] + #[serde(default = "default_1879")] pub superseded_by: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryStatusesOutput { - #[serde(default = "default_1875")] + #[serde(default = "default_1880")] pub rows: Vec, } @@ -42347,23 +42583,23 @@ impl MemoryStatusesInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySweepExpiredOutput { - #[serde(default = "default_1876")] + #[serde(default = "default_1881")] pub scanned: Integer, - #[serde(default = "default_1877")] + #[serde(default = "default_1882")] pub tombstoned: Integer, - #[serde(default = "default_1878")] + #[serde(default = "default_1883")] pub demoted: Integer, - #[serde(default = "default_1879")] + #[serde(default = "default_1884")] pub anonymized: Integer, - #[serde(default = "default_1880")] + #[serde(default = "default_1885")] pub locked_skipped: Integer, - #[serde(default = "default_1881")] + #[serde(default = "default_1886")] pub moved_skipped: Integer, - #[serde(default = "default_1882")] + #[serde(default = "default_1887")] pub dry_run: bool, - #[serde(default = "default_1883")] + #[serde(default = "default_1888")] pub sample: Vec>, - #[serde(default = "default_1884")] + #[serde(default = "default_1889")] pub failures: Vec, } @@ -42440,10 +42676,10 @@ pub struct MemoryTimelineEntry { pub memory_key: String, pub memory_type: String, pub content_excerpt: String, - #[serde(default = "default_1885")] + #[serde(default = "default_1890")] pub valid_at: Option, pub created_at: String, - #[serde(default = "default_1886")] + #[serde(default = "default_1891")] pub namespace: String, } @@ -42451,7 +42687,7 @@ pub struct MemoryTimelineEntry { #[non_exhaustive] pub struct MemoryTimelineOutput { pub events: Vec, - #[serde(default = "default_1887")] + #[serde(default = "default_1892")] pub total_matching: Integer, } @@ -42643,9 +42879,9 @@ impl MemoryTimelineInput { pub struct MemoryTouchResult { pub memory_key: String, pub touched: bool, - #[serde(default = "default_1890")] + #[serde(default = "default_1895")] pub version: Option, - #[serde(default = "default_1891")] + #[serde(default = "default_1896")] pub expires_at: Option, } @@ -42653,13 +42889,13 @@ pub struct MemoryTouchResult { #[non_exhaustive] pub struct MemoryTouchOutput { pub touched: bool, - #[serde(default = "default_1888")] + #[serde(default = "default_1893")] pub version: Option, - #[serde(default = "default_1889")] + #[serde(default = "default_1894")] pub expires_at: Option, - #[serde(default = "default_1892")] + #[serde(default = "default_1897")] pub results: Vec, - #[serde(default = "default_1893")] + #[serde(default = "default_1898")] pub touched_count: Integer, } @@ -42839,15 +43075,15 @@ impl MemoryTouchInput { #[non_exhaustive] pub struct MemoryUnlockOutput { pub unlocked: bool, - #[serde(default = "default_1894")] + #[serde(default = "default_1899")] pub reason: String, - #[serde(default = "default_1895")] + #[serde(default = "default_1900")] pub memory_id: String, - #[serde(default = "default_1896")] + #[serde(default = "default_1901")] pub version: Option, - #[serde(default = "default_1897")] + #[serde(default = "default_1902")] pub previous_mode: String, - #[serde(default = "default_1898")] + #[serde(default = "default_1903")] pub unlocked_by: String, } @@ -42952,11 +43188,11 @@ impl MemoryUnlockInput { #[non_exhaustive] pub struct MemoryUnpinOutput { pub unpinned: bool, - #[serde(default = "default_1899")] + #[serde(default = "default_1904")] pub reason: String, - #[serde(default = "default_1900")] + #[serde(default = "default_1905")] pub memory_id: String, - #[serde(default = "default_1901")] + #[serde(default = "default_1906")] pub version: Option, } @@ -43050,15 +43286,15 @@ impl MemoryUnpinInput { #[non_exhaustive] pub struct MemoryUpdateCandidate { pub memory_id: String, - #[serde(default = "default_1907")] + #[serde(default = "default_1912")] pub agent: String, - #[serde(default = "default_1908")] + #[serde(default = "default_1913")] pub user_id: String, - #[serde(default = "default_1909")] + #[serde(default = "default_1914")] pub session_id: String, - #[serde(default = "default_1910")] + #[serde(default = "default_1915")] pub version: Integer, - #[serde(default = "default_1911")] + #[serde(default = "default_1916")] pub status: String, } @@ -43066,23 +43302,23 @@ pub struct MemoryUpdateCandidate { #[non_exhaustive] pub struct MemoryUpdateOutput { pub updated: bool, - #[serde(default = "default_1902")] + #[serde(default = "default_1907")] pub memory_id: String, - #[serde(default = "default_1903")] + #[serde(default = "default_1908")] pub memory_key: String, - #[serde(default = "default_1904")] + #[serde(default = "default_1909")] pub new_version: Integer, - #[serde(default = "default_1905")] + #[serde(default = "default_1910")] pub content_sha256: String, - #[serde(default = "default_1906")] + #[serde(default = "default_1911")] pub reason: String, - #[serde(default = "default_1912")] + #[serde(default = "default_1917")] pub candidates: Vec, - #[serde(default = "default_1913")] + #[serde(default = "default_1918")] pub conflict_verdict: String, - #[serde(default = "default_1914")] + #[serde(default = "default_1919")] pub conflict_peers: Integer, - #[serde(default = "default_1915")] + #[serde(default = "default_1920")] pub duplicate_of: String, } @@ -43291,15 +43527,15 @@ impl MemoryUpdateInput { #[non_exhaustive] pub struct MemoryUpdateByIdOutput { pub updated: bool, - #[serde(default = "default_1916")] + #[serde(default = "default_1921")] pub new_version: Integer, - #[serde(default = "default_1917")] + #[serde(default = "default_1922")] pub content_sha256: String, - #[serde(default = "default_1918")] + #[serde(default = "default_1923")] pub conflict_verdict: String, - #[serde(default = "default_1919")] + #[serde(default = "default_1924")] pub conflict_peers: Integer, - #[serde(default = "default_1920")] + #[serde(default = "default_1925")] pub duplicate_of: String, } @@ -43427,23 +43663,23 @@ impl MemoryUpdateByIdInput { #[non_exhaustive] pub struct MemoryVerifyOutput { pub found: bool, - #[serde(default = "default_1921")] + #[serde(default = "default_1926")] pub changed: bool, - #[serde(default = "default_1922")] + #[serde(default = "default_1927")] pub memory_id: String, - #[serde(default = "default_1923")] + #[serde(default = "default_1928")] pub memory_key: String, - #[serde(default = "default_1924")] + #[serde(default = "default_1929")] pub namespace: String, - #[serde(default = "default_1925")] + #[serde(default = "default_1930")] pub verified_by: String, - #[serde(default = "default_1926")] + #[serde(default = "default_1931")] pub verified_at: Option, - #[serde(default = "default_1927")] + #[serde(default = "default_1932")] pub verification: String, - #[serde(default = "default_1928")] + #[serde(default = "default_1933")] pub version: Integer, - #[serde(default = "default_1929")] + #[serde(default = "default_1934")] pub content_sha256: String, } @@ -43648,13 +43884,13 @@ pub struct SchemaFieldOutput { #[serde(rename = "type")] pub r#type: String, pub required: bool, - #[serde(default = "default_1932")] + #[serde(default = "default_1937")] pub identity: bool, - #[serde(default = "default_1933")] + #[serde(default = "default_1938")] pub enum_values: Vec, - #[serde(default = "default_1934")] + #[serde(default = "default_1939")] pub constraints: std::collections::HashMap, - #[serde(default = "default_1935")] + #[serde(default = "default_1940")] pub description: String, } @@ -43663,11 +43899,11 @@ pub struct SchemaFieldOutput { pub struct MemorySchemaSummary { pub schema_id: String, pub name: String, - #[serde(default = "default_1930")] + #[serde(default = "default_1935")] pub description: String, - #[serde(default = "default_1931")] - pub status: String, #[serde(default = "default_1936")] + pub status: String, + #[serde(default = "default_1941")] pub fields: Vec, } @@ -44082,13 +44318,13 @@ impl MemorySchemaRegisterInput { #[non_exhaustive] pub struct MentorPlane { pub plane: String, - #[serde(default = "default_1938")] + #[serde(default = "default_1943")] pub calls: Integer, - #[serde(default = "default_1939")] + #[serde(default = "default_1944")] pub available: Option, - #[serde(default = "default_1940")] + #[serde(default = "default_1945")] pub when: String, - #[serde(default = "default_1941")] + #[serde(default = "default_1946")] pub mentored: bool, } @@ -44098,11 +44334,11 @@ pub struct MentorHint { pub code: String, pub severity: String, pub text: String, - #[serde(default = "default_1943")] + #[serde(default = "default_1948")] pub ops: Vec, - #[serde(default = "default_1944")] + #[serde(default = "default_1949")] pub evidence: std::collections::HashMap, - #[serde(default = "default_1945")] + #[serde(default = "default_1950")] pub plane: Option, } @@ -44110,9 +44346,9 @@ pub struct MentorHint { #[non_exhaustive] pub struct MentorAdoption { pub code: String, - #[serde(default = "default_1947")] + #[serde(default = "default_1952")] pub shown_sessions: Integer, - #[serde(default = "default_1948")] + #[serde(default = "default_1953")] pub followed_sessions: Integer, } @@ -44148,7 +44384,7 @@ pub enum UsageRungSource { #[non_exhaustive] pub struct UsageRung { pub rung: UsageRungRung, - #[serde(default = "default_1950")] + #[serde(default = "default_1955")] pub count: Option, pub source: UsageRungSource, pub meaning: String, @@ -44163,27 +44399,27 @@ pub struct MentorBriefOutput { pub window_seconds: Integer, pub computed_at: String, pub sessions: Integer, - #[serde(default = "default_1937")] - pub usage: std::collections::HashMap, #[serde(default = "default_1942")] + pub usage: std::collections::HashMap, + #[serde(default = "default_1947")] pub planes: Vec, - #[serde(default = "default_1946")] + #[serde(default = "default_1951")] pub hints: Vec, - #[serde(default = "default_1949")] + #[serde(default = "default_1954")] pub adoption: Vec, - #[serde(default = "default_1951")] + #[serde(default = "default_1956")] pub usage_evidence: Vec, - #[serde(default = "default_1952")] + #[serde(default = "default_1957")] pub ledger_from: Option, - #[serde(default = "default_1953")] + #[serde(default = "default_1958")] pub ledger_retention_days: Option, - #[serde(default = "default_1954")] + #[serde(default = "default_1959")] pub agents: Vec, - #[serde(default = "default_1955")] + #[serde(default = "default_1960")] pub agent_defaulted: bool, - #[serde(default = "default_1956")] + #[serde(default = "default_1961")] pub skipped: Vec, - #[serde(default = "default_1957")] + #[serde(default = "default_1962")] pub healthy: bool, } @@ -44332,33 +44568,33 @@ impl MentorGuideInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct NamespaceAuditSummary { - #[serde(default = "default_1958")] + #[serde(default = "default_1963")] pub live_rows: Integer, - #[serde(default = "default_1959")] + #[serde(default = "default_1964")] pub live_bytes: Integer, - #[serde(default = "default_1960")] + #[serde(default = "default_1965")] pub excerpt_bytes: Integer, - #[serde(default = "default_1961")] + #[serde(default = "default_1966")] pub version_rows: Integer, - #[serde(default = "default_1962")] + #[serde(default = "default_1967")] pub version_bytes: Integer, - #[serde(default = "default_1963")] + #[serde(default = "default_1968")] pub unembedded_rows: Integer, - #[serde(default = "default_1964")] + #[serde(default = "default_1969")] pub gets: Integer, - #[serde(default = "default_1965")] + #[serde(default = "default_1970")] pub searches: Integer, - #[serde(default = "default_1966")] + #[serde(default = "default_1971")] pub sets: Integer, - #[serde(default = "default_1967")] + #[serde(default = "default_1972")] pub get_search_ratio: f64, - #[serde(default = "default_1968")] + #[serde(default = "default_1973")] pub inspector_calls: Integer, - #[serde(default = "default_1969")] + #[serde(default = "default_1974")] pub typed_gets: Integer, - #[serde(default = "default_1970")] + #[serde(default = "default_1975")] pub written_in_window: Integer, - #[serde(default = "default_1971")] + #[serde(default = "default_1976")] pub ledger_calls: Integer, } @@ -44390,25 +44626,25 @@ pub struct NamespaceAuditFinding { pub kind: NamespaceAuditFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1972")] + #[serde(default = "default_1977")] pub window_seconds: Option, - #[serde(default = "default_1973")] + #[serde(default = "default_1978")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1974")] + #[serde(default = "default_1979")] pub evidence: Vec, - #[serde(default = "default_1975")] + #[serde(default = "default_1980")] pub exceptions: String, - #[serde(default = "default_1976")] + #[serde(default = "default_1981")] pub uncertainty: String, pub code: String, pub severity: NamespaceAuditFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1977")] + #[serde(default = "default_1982")] pub bytes: Integer, - #[serde(default = "default_1978")] + #[serde(default = "default_1983")] pub samples: Vec>, pub detail: String, pub remedy: String, @@ -44423,7 +44659,7 @@ pub struct NamespaceAuditOutput { pub window_seconds: Integer, pub summary: NamespaceAuditSummary, pub findings: Vec, - #[serde(default = "default_1979")] + #[serde(default = "default_1984")] pub skipped: Vec, pub coverage: ReportCoverage, pub healthy: bool, @@ -44514,29 +44750,29 @@ pub enum BrowseEntryMyStatus { #[non_exhaustive] pub struct BrowseEntry { pub namespace: String, - #[serde(default = "default_1980")] + #[serde(default = "default_1985")] pub kind: String, pub description: String, pub owner_email: String, pub member_count: Integer, - #[serde(default = "default_1981")] + #[serde(default = "default_1986")] pub requires_approval: bool, pub created_at: String, - #[serde(default = "default_1982")] + #[serde(default = "default_1987")] pub join_policy: String, - #[serde(default = "default_1983")] + #[serde(default = "default_1988")] pub visibility: String, - #[serde(default = "default_1984")] + #[serde(default = "default_1989")] pub my_status: BrowseEntryMyStatus, - #[serde(default = "default_1985")] + #[serde(default = "default_1990")] pub my_role: String, - #[serde(default = "default_1986")] + #[serde(default = "default_1991")] pub repo: String, - #[serde(default = "default_1987")] + #[serde(default = "default_1992")] pub branch: String, - #[serde(default = "default_1988")] + #[serde(default = "default_1993")] pub guide_revision: Integer, - #[serde(default = "default_1989")] + #[serde(default = "default_1994")] pub guide_summary: String, } @@ -44640,9 +44876,9 @@ pub enum NamespaceCancelRequestOutputClearedRole { pub struct NamespaceCancelRequestOutput { pub cancelled: bool, pub namespace: String, - #[serde(default = "default_1990")] + #[serde(default = "default_1995")] pub cleared_role: Option, - #[serde(default = "default_1991")] + #[serde(default = "default_1996")] pub cancelled_at: Option, } @@ -44714,7 +44950,7 @@ pub struct NamespaceDeleteOutput { pub deleted: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_1992")] + #[serde(default = "default_1997")] pub sources_retired: Vec, } @@ -44783,67 +45019,67 @@ pub enum NamespaceGetOutputClassification { pub struct NamespaceGetOutput { pub found: bool, pub namespace: String, - #[serde(default = "default_1993")] + #[serde(default = "default_1998")] pub kind: Option, - #[serde(default = "default_1994")] + #[serde(default = "default_1999")] pub owner_email: Option, - #[serde(default = "default_1995")] + #[serde(default = "default_2000")] pub description: Option, - #[serde(default = "default_1996")] + #[serde(default = "default_2001")] pub tags: Option>, - #[serde(default = "default_1997")] + #[serde(default = "default_2002")] pub active: Option, - #[serde(default = "default_1998")] + #[serde(default = "default_2003")] pub conversation_logging_enabled: Option, - #[serde(default = "default_1999")] + #[serde(default = "default_2004")] pub capture_generation_io: Option, - #[serde(default = "default_2000")] + #[serde(default = "default_2005")] pub coverage_sweep: Option, - #[serde(default = "default_2001")] + #[serde(default = "default_2006")] pub consolidation_enabled: Option, - #[serde(default = "default_2002")] + #[serde(default = "default_2007")] pub daily_cost_cap_usd: Option, - #[serde(default = "default_2003")] + #[serde(default = "default_2008")] pub daily_user_cost_cap_usd: Option, - #[serde(default = "default_2004")] + #[serde(default = "default_2009")] pub budget_alert_inbox: Option, - #[serde(default = "default_2005")] + #[serde(default = "default_2010")] pub conflict_threshold: Option, - #[serde(default = "default_2006")] + #[serde(default = "default_2011")] pub retention_days: Option, - #[serde(default = "default_2007")] + #[serde(default = "default_2012")] pub warm_days: Option, - #[serde(default = "default_2008")] + #[serde(default = "default_2013")] pub visibility: Option, - #[serde(default = "default_2009")] + #[serde(default = "default_2014")] pub requires_approval: Option, - #[serde(default = "default_2010")] + #[serde(default = "default_2015")] pub join_policy: Option, - #[serde(default = "default_2011")] + #[serde(default = "default_2016")] pub effective_join_policy: Option, - #[serde(default = "default_2012")] + #[serde(default = "default_2017")] pub retrieval_defaults: Option>, - #[serde(default = "default_2013")] + #[serde(default = "default_2018")] pub rerank_endpoint: Option, - #[serde(default = "default_2014")] + #[serde(default = "default_2019")] pub classify_endpoint: Option, - #[serde(default = "default_2015")] + #[serde(default = "default_2020")] pub default_conflict_policy: Option, - #[serde(default = "default_2016")] + #[serde(default = "default_2021")] pub proposal_policy: Option, - #[serde(default = "default_2017")] + #[serde(default = "default_2022")] pub code_change_policy: Option, - #[serde(default = "default_2018")] + #[serde(default = "default_2023")] pub tag_registry: Option>>, - #[serde(default = "default_2019")] + #[serde(default = "default_2024")] pub classification: Option, - #[serde(default = "default_2020")] + #[serde(default = "default_2025")] pub guide_revision: Option, - #[serde(default = "default_2021")] + #[serde(default = "default_2026")] pub guide_summary: Option, - #[serde(default = "default_2022")] + #[serde(default = "default_2027")] pub created_at: Option, - #[serde(default = "default_2023")] + #[serde(default = "default_2028")] pub updated_at: Option, } @@ -44896,17 +45132,17 @@ impl NamespaceGetInput { #[non_exhaustive] pub struct NamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2024")] + #[serde(default = "default_2029")] pub revision: Integer, - #[serde(default = "default_2025")] + #[serde(default = "default_2030")] pub content: String, - #[serde(default = "default_2026")] + #[serde(default = "default_2031")] pub summary: String, - #[serde(default = "default_2027")] + #[serde(default = "default_2032")] pub note: String, - #[serde(default = "default_2028")] + #[serde(default = "default_2033")] pub updated_by: String, - #[serde(default = "default_2029")] + #[serde(default = "default_2034")] pub updated_at: Option, } @@ -45043,17 +45279,17 @@ impl NamespaceGuideHistoryInput { #[non_exhaustive] pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2031")] + #[serde(default = "default_2036")] pub revision: Integer, - #[serde(default = "default_2032")] + #[serde(default = "default_2037")] pub content: String, - #[serde(default = "default_2033")] + #[serde(default = "default_2038")] pub summary: String, - #[serde(default = "default_2034")] + #[serde(default = "default_2039")] pub note: String, - #[serde(default = "default_2035")] + #[serde(default = "default_2040")] pub updated_by: String, - #[serde(default = "default_2036")] + #[serde(default = "default_2041")] pub updated_at: Option, } @@ -45061,10 +45297,10 @@ pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { #[non_exhaustive] pub struct NamespaceGuideSetOutput { pub written: bool, - #[serde(default = "default_2030")] + #[serde(default = "default_2035")] pub conflict: bool, pub revision: Integer, - #[serde(default = "default_2037")] + #[serde(default = "default_2042")] pub current: Option, } @@ -45185,7 +45421,7 @@ pub struct InventorySection { #[serde(deserialize_with = "required_nullable")] pub latest_at: Option, pub complete: bool, - #[serde(default = "default_2038")] + #[serde(default = "default_2043")] pub reason: String, } @@ -45215,10 +45451,10 @@ pub struct InventoryPopulation { pub population: InventoryPopulationPopulation, #[serde(deserialize_with = "required_nullable")] pub total: Option, - #[serde(default = "default_2039")] + #[serde(default = "default_2044")] pub top: Vec, pub complete: bool, - #[serde(default = "default_2040")] + #[serde(default = "default_2045")] pub reason: String, } @@ -45384,11 +45620,11 @@ pub struct NamespaceJoinOutput { pub joined: bool, pub namespace: String, pub role: NamespaceJoinOutputRole, - #[serde(default = "default_2041")] + #[serde(default = "default_2046")] pub status: String, - #[serde(default = "default_2042")] + #[serde(default = "default_2047")] pub requested_role: Option, - #[serde(default = "default_2043")] + #[serde(default = "default_2048")] pub pending_admins: Vec, pub joined_at: String, } @@ -45480,7 +45716,7 @@ impl NamespaceJoinInput { pub struct NamespaceLeaveOutput { pub left: bool, pub namespace: String, - #[serde(default = "default_2044")] + #[serde(default = "default_2049")] pub left_at: Option, } @@ -45557,27 +45793,27 @@ pub enum NamespaceEntryVisibility { #[non_exhaustive] pub struct NamespaceEntry { pub namespace: String, - #[serde(default = "default_2045")] + #[serde(default = "default_2050")] pub kind: String, pub owner_email: String, pub description: String, pub tags: Vec, pub active: bool, - #[serde(default = "default_2046")] + #[serde(default = "default_2051")] pub consolidation_enabled: bool, - #[serde(default = "default_2047")] + #[serde(default = "default_2052")] pub daily_cost_cap_usd: f64, - #[serde(default = "default_2048")] + #[serde(default = "default_2053")] pub daily_user_cost_cap_usd: f64, - #[serde(default = "default_2049")] + #[serde(default = "default_2054")] pub budget_alert_inbox: String, - #[serde(default = "default_2050")] + #[serde(default = "default_2055")] pub conflict_threshold: Option, - #[serde(default = "default_2051")] + #[serde(default = "default_2056")] pub retention_days: Integer, - #[serde(default = "default_2052")] + #[serde(default = "default_2057")] pub warm_days: Integer, - #[serde(default = "default_2053")] + #[serde(default = "default_2058")] pub visibility: NamespaceEntryVisibility, pub created_at: String, pub updated_at: String, @@ -45732,27 +45968,27 @@ pub enum MineEntryVisibility { pub struct MineEntry { pub namespace: String, pub role: String, - #[serde(default = "default_2054")] + #[serde(default = "default_2059")] pub status: String, - #[serde(default = "default_2055")] + #[serde(default = "default_2060")] pub pending_role: Option, - #[serde(default = "default_2056")] + #[serde(default = "default_2061")] pub pending_since: Option, - #[serde(default = "default_2057")] + #[serde(default = "default_2062")] pub pending_admins: Vec, - #[serde(default = "default_2058")] + #[serde(default = "default_2063")] pub visibility: MineEntryVisibility, - #[serde(default = "default_2059")] + #[serde(default = "default_2064")] pub kind: String, - #[serde(default = "default_2060")] + #[serde(default = "default_2065")] pub title: String, - #[serde(default = "default_2061")] + #[serde(default = "default_2066")] pub description: String, - #[serde(default = "default_2062")] + #[serde(default = "default_2067")] pub joined_at: Option, - #[serde(default = "default_2063")] + #[serde(default = "default_2068")] pub is_new: bool, - #[serde(default = "default_2064")] + #[serde(default = "default_2069")] pub inherited: bool, } @@ -45818,7 +46054,7 @@ pub struct OntologyEntry { pub name: String, pub status: String, pub description: String, - #[serde(default = "default_2065")] + #[serde(default = "default_2070")] pub cardinality: String, pub created_by: String, pub updated_at: String, @@ -46011,7 +46247,7 @@ pub struct NamespaceRegisterOutput { pub registered: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_2066")] + #[serde(default = "default_2071")] pub visibility: NamespaceRegisterOutputVisibility, } @@ -47091,7 +47327,7 @@ impl NamespaceRegisterOntologyInput { #[non_exhaustive] pub struct NamespaceRestoreOutput { pub restored: bool, - #[serde(default = "default_2067")] + #[serde(default = "default_2072")] pub publication_pending: bool, pub target_namespace: String, pub snapshot_id: String, @@ -47978,15 +48214,15 @@ pub struct NamespaceRollbackOutput { pub version_at: Integer, pub reinstate: Integer, pub remove: Integer, - #[serde(default = "default_2068")] + #[serde(default = "default_2073")] pub skipped_no_head: Integer, - #[serde(default = "default_2069")] + #[serde(default = "default_2074")] pub skipped_already_gone: Integer, - #[serde(default = "default_2070")] + #[serde(default = "default_2075")] pub truncated: bool, - #[serde(default = "default_2071")] + #[serde(default = "default_2076")] pub sample: Vec>, - #[serde(default = "default_2072")] + #[serde(default = "default_2077")] pub applied_at: Option, } @@ -48165,101 +48401,101 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub confidence: f64, pub source_trace: String, pub pinned: bool, - #[serde(default = "default_2073")] + #[serde(default = "default_2078")] pub expires_at: Option, - #[serde(default = "default_2074")] + #[serde(default = "default_2079")] pub entities: Vec, - #[serde(default = "default_2075")] + #[serde(default = "default_2080")] pub version: Integer, - #[serde(default = "default_2076")] + #[serde(default = "default_2081")] pub content_sha256: String, - #[serde(default = "default_2077")] + #[serde(default = "default_2082")] pub actor: String, - #[serde(default = "default_2078")] + #[serde(default = "default_2083")] pub source_class: String, - #[serde(default = "default_2079")] + #[serde(default = "default_2084")] pub source_resource_id: String, - #[serde(default = "default_2080")] + #[serde(default = "default_2085")] pub verified_by: String, - #[serde(default = "default_2081")] + #[serde(default = "default_2086")] pub verified_at: Option, - #[serde(default = "default_2082")] + #[serde(default = "default_2087")] pub verified_sha256: String, - #[serde(default = "default_2083")] + #[serde(default = "default_2088")] pub grounding: String, - #[serde(default = "default_2084")] + #[serde(default = "default_2089")] pub evidence: String, - #[serde(default = "default_2085")] + #[serde(default = "default_2090")] pub tags: Vec, - #[serde(default = "default_2086")] + #[serde(default = "default_2091")] pub valid_at: Option, - #[serde(default = "default_2087")] + #[serde(default = "default_2092")] pub valid_to: Option, - #[serde(default = "default_2088")] + #[serde(default = "default_2093")] pub created_at: Option, - #[serde(default = "default_2089")] + #[serde(default = "default_2094")] pub updated_at: Option, - #[serde(default = "default_2090")] + #[serde(default = "default_2095")] pub value_json: String, - #[serde(default = "default_2091")] + #[serde(default = "default_2096")] pub status: NamespaceSnapshotOutputSnapshotMemoryRowStatus, - #[serde(default = "default_2092")] + #[serde(default = "default_2097")] pub requires_review: Option, - #[serde(default = "default_2093")] + #[serde(default = "default_2098")] pub conflict_with: Vec, - #[serde(default = "default_2094")] + #[serde(default = "default_2099")] pub duplicate_of: String, - #[serde(default = "default_2095")] + #[serde(default = "default_2100")] pub evidence_count: Integer, - #[serde(default = "default_2096")] + #[serde(default = "default_2101")] pub recall_count: Integer, - #[serde(default = "default_2097")] + #[serde(default = "default_2102")] pub last_recalled_at: Option, - #[serde(default = "default_2098")] + #[serde(default = "default_2103")] pub cross_promoted_from_memory_id: String, - #[serde(default = "default_2099")] + #[serde(default = "default_2104")] pub cross_promoted_from_namespace: String, - #[serde(default = "default_2100")] + #[serde(default = "default_2105")] pub superseded_by: String, - #[serde(default = "default_2101")] + #[serde(default = "default_2106")] pub rejection_reason: String, - #[serde(default = "default_2102")] + #[serde(default = "default_2107")] pub temporal_anchor: Option, - #[serde(default = "default_2103")] + #[serde(default = "default_2108")] pub temporal_confidence: f64, - #[serde(default = "default_2104")] + #[serde(default = "default_2109")] pub invalid_at: Option, - #[serde(default = "default_2105")] + #[serde(default = "default_2110")] pub char_limit: Option, - #[serde(default = "default_2106")] + #[serde(default = "default_2111")] pub reinforcement_count: Integer, - #[serde(default = "default_2107")] + #[serde(default = "default_2112")] pub last_reinforced_at: Option, - #[serde(default = "default_2108")] + #[serde(default = "default_2113")] pub mentioned_at: Option, - #[serde(default = "default_2109")] + #[serde(default = "default_2114")] pub sensitivity: String, - #[serde(default = "default_2110")] + #[serde(default = "default_2115")] pub redacted_at: Option, - #[serde(default = "default_2111")] + #[serde(default = "default_2116")] pub redaction_reason: String, - #[serde(default = "default_2112")] + #[serde(default = "default_2117")] pub lock_mode: String, - #[serde(default = "default_2113")] + #[serde(default = "default_2118")] pub lock_reason: String, - #[serde(default = "default_2114")] + #[serde(default = "default_2119")] pub lock_until: Option, - #[serde(default = "default_2115")] + #[serde(default = "default_2120")] pub locked_by: String, - #[serde(default = "default_2116")] + #[serde(default = "default_2121")] pub locked_at: Option, - #[serde(default = "default_2117")] + #[serde(default = "default_2122")] pub on_expire: String, - #[serde(default = "default_2118")] + #[serde(default = "default_2123")] pub expire_reason: String, - #[serde(default = "default_2119")] + #[serde(default = "default_2124")] pub files: Vec, - #[serde(default = "default_2120")] + #[serde(default = "default_2125")] pub concepts: Vec, } @@ -48268,11 +48504,11 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub struct NamespaceSnapshotOutputSnapshotTypeRow { pub memory_type: String, pub retention_days: Integer, - #[serde(default = "default_2121")] + #[serde(default = "default_2126")] pub dedup_threshold: Option, - #[serde(default = "default_2122")] + #[serde(default = "default_2127")] pub hot_quota: Integer, - #[serde(default = "default_2123")] + #[serde(default = "default_2128")] pub conflict_policy: String, } @@ -48487,7 +48723,7 @@ pub struct TaxonomyCommunity { pub community_id: Integer, pub label: String, pub size: Integer, - #[serde(default = "default_2124")] + #[serde(default = "default_2129")] pub top_entities: Vec, } @@ -48498,9 +48734,9 @@ pub struct NamespaceTaxonomyOutput { pub entities: Vec, pub memory_count: Integer, pub memory_types: Vec, - #[serde(default = "default_2125")] + #[serde(default = "default_2130")] pub communities: Vec, - #[serde(default = "default_2126")] + #[serde(default = "default_2131")] pub communities_computed_at: String, } @@ -48600,15 +48836,15 @@ pub enum TuneProposalTarget { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TuneEvidence { - #[serde(default = "default_2128")] + #[serde(default = "default_2133")] pub finding_codes: Vec, - #[serde(default = "default_2129")] + #[serde(default = "default_2134")] pub supporting_count: Integer, - #[serde(default = "default_2130")] + #[serde(default = "default_2135")] pub supporting: Vec, - #[serde(default = "default_2131")] + #[serde(default = "default_2136")] pub counter_count: Option, - #[serde(default = "default_2132")] + #[serde(default = "default_2137")] pub documents: Vec, } @@ -48634,10 +48870,10 @@ pub enum TuneApplyVia { #[non_exhaustive] pub struct TuneApply { pub op: String, - #[serde(default = "default_2136")] + #[serde(default = "default_2141")] pub via: TuneApplyVia, pub args: std::collections::HashMap, - #[serde(default = "default_2137")] + #[serde(default = "default_2142")] pub args_complete: bool, pub required_role: String, pub guard: String, @@ -48656,7 +48892,7 @@ pub struct ChunkStats { pub sections: Integer, pub sections_cut: Integer, pub max_input_tokens: Integer, - #[serde(default = "default_2139")] + #[serde(default = "default_2144")] pub over_input_limit: Option, } @@ -48676,25 +48912,25 @@ pub struct TuneProposal { pub title: String, pub rationale: String, pub current: String, - #[serde(default = "default_2127")] + #[serde(default = "default_2132")] pub current_revision: Option, pub proposed: String, pub evidence: TuneEvidence, - #[serde(default = "default_2133")] + #[serde(default = "default_2138")] pub affected_agents: Vec, - #[serde(default = "default_2134")] + #[serde(default = "default_2139")] pub affected_agents_total: Option, - #[serde(default = "default_2135")] + #[serde(default = "default_2140")] pub effect: TuneProposalEffect, pub historical: String, pub apply: TuneApply, - #[serde(default = "default_2138")] + #[serde(default = "default_2143")] pub apply_also: Vec, - #[serde(default = "default_2140")] + #[serde(default = "default_2145")] pub preview: Option, - #[serde(default = "default_2141")] + #[serde(default = "default_2146")] pub limits: String, - #[serde(default = "default_2142")] + #[serde(default = "default_2147")] pub refs: Vec, } @@ -48702,13 +48938,13 @@ pub struct TuneProposal { #[non_exhaustive] pub struct ChunkingSample { pub cap: Integer, - #[serde(default = "default_2148")] + #[serde(default = "default_2153")] pub population: Option, pub documents: Integer, pub unread: Integer, pub load_cap: Integer, pub embedder_model: String, - #[serde(default = "default_2149")] + #[serde(default = "default_2154")] pub input_token_limit: Option, pub current: ChunkStats, } @@ -48719,21 +48955,21 @@ pub struct NamespaceTuneOutput { pub org: String, pub namespace: String, pub computed_at: String, - #[serde(default = "default_2143")] + #[serde(default = "default_2148")] pub proposals: Vec, - #[serde(default = "default_2144")] + #[serde(default = "default_2149")] pub guide_revision: Option, - #[serde(default = "default_2145")] + #[serde(default = "default_2150")] pub categories_registered: Option, - #[serde(default = "default_2146")] + #[serde(default = "default_2151")] pub extraction_policy: Option, - #[serde(default = "default_2147")] + #[serde(default = "default_2152")] pub extraction_policy_unavailable: String, - #[serde(default = "default_2150")] + #[serde(default = "default_2155")] pub chunking: Option, - #[serde(default = "default_2151")] + #[serde(default = "default_2156")] pub skipped: Vec, - #[serde(default = "default_2152")] + #[serde(default = "default_2157")] pub model_used: bool, } @@ -48854,22 +49090,22 @@ pub struct NamespaceValidateFinding { pub kind: NamespaceValidateFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_2153")] + #[serde(default = "default_2158")] pub window_seconds: Option, - #[serde(default = "default_2154")] + #[serde(default = "default_2159")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_2155")] + #[serde(default = "default_2160")] pub evidence: Vec, - #[serde(default = "default_2156")] + #[serde(default = "default_2161")] pub exceptions: String, - #[serde(default = "default_2157")] + #[serde(default = "default_2162")] pub uncertainty: String, pub check: String, pub severity: NamespaceValidateFindingSeverity, pub count: Integer, - #[serde(default = "default_2158")] + #[serde(default = "default_2163")] pub samples: Vec>, pub detail: String, } @@ -48884,9 +49120,9 @@ pub struct NamespaceValidateOutput { pub warnings: Integer, pub infos: Integer, pub findings: Vec, - #[serde(default = "default_2159")] + #[serde(default = "default_2164")] pub skipped: Vec, - #[serde(default = "default_2160")] + #[serde(default = "default_2165")] pub keys_scoped: Integer, pub coverage: ReportCoverage, pub checked_at: String, @@ -49006,9 +49242,9 @@ impl NamespaceValidateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ObserveCrystallizeOutput { - #[serde(default = "default_2161")] + #[serde(default = "default_2166")] pub enqueued: Integer, - #[serde(default = "default_2162")] + #[serde(default = "default_2167")] pub session_id: String, } @@ -49105,23 +49341,23 @@ impl ObserveCrystallizeInput { #[non_exhaustive] pub struct ObserveRecordOutput { pub memory_key: String, - #[serde(default = "default_2163")] + #[serde(default = "default_2168")] pub memory_id: String, - #[serde(default = "default_2164")] + #[serde(default = "default_2169")] pub kind: String, - #[serde(default = "default_2165")] + #[serde(default = "default_2170")] pub tags: Vec, - #[serde(default = "default_2166")] + #[serde(default = "default_2171")] pub file_paths: Vec, - #[serde(default = "default_2167")] + #[serde(default = "default_2172")] pub content_sha256: String, - #[serde(default = "default_2168")] + #[serde(default = "default_2173")] pub tool_name: String, - #[serde(default = "default_2169")] + #[serde(default = "default_2174")] pub has_error: bool, - #[serde(default = "default_2170")] + #[serde(default = "default_2175")] pub narrative_chars: Integer, - #[serde(default = "default_2171")] + #[serde(default = "default_2176")] pub skipped_reason: String, } @@ -49320,26 +49556,26 @@ pub struct ProjectionFailureRow { pub failure_id: String, pub org: String, pub namespace: String, - #[serde(default = "default_2172")] + #[serde(default = "default_2177")] pub agent: String, pub projection: String, - #[serde(default = "default_2173")] + #[serde(default = "default_2178")] pub source_operation: String, - #[serde(default = "default_2174")] + #[serde(default = "default_2179")] pub source_resource_id: String, - #[serde(default = "default_2175")] + #[serde(default = "default_2180")] pub memory_keys: Vec, - #[serde(default = "default_2176")] + #[serde(default = "default_2181")] pub error_type: String, - #[serde(default = "default_2177")] + #[serde(default = "default_2182")] pub error_message: String, - #[serde(default = "default_2178")] + #[serde(default = "default_2183")] pub payload: std::collections::HashMap, - #[serde(default = "default_2179")] + #[serde(default = "default_2184")] pub status: String, - #[serde(default = "default_2180")] + #[serde(default = "default_2185")] pub created_at: Option, - #[serde(default = "default_2181")] + #[serde(default = "default_2186")] pub resolved_at: Option, } @@ -49493,22 +49729,22 @@ pub struct ProjectionFailureRetryRow { pub projection: String, pub retried: bool, pub resolved: bool, - #[serde(default = "default_2182")] + #[serde(default = "default_2187")] pub abandoned: bool, - #[serde(default = "default_2183")] + #[serde(default = "default_2188")] pub reason: String, - #[serde(default = "default_2184")] + #[serde(default = "default_2189")] pub error: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProjectionFailureRetryOutput { - #[serde(default = "default_2185")] + #[serde(default = "default_2190")] pub results: Vec, pub retried: Integer, pub resolved: Integer, - #[serde(default = "default_2186")] + #[serde(default = "default_2191")] pub abandoned: Integer, } @@ -49590,15 +49826,15 @@ impl ProjectionFailureRetryInput { pub struct OrgModelCallsOutput { pub org: String, pub enabled: bool, - #[serde(default = "default_2187")] + #[serde(default = "default_2192")] pub reason: String, - #[serde(default = "default_2188")] + #[serde(default = "default_2193")] pub updated_by: String, - #[serde(default = "default_2189")] + #[serde(default = "default_2194")] pub updated_at: Option, - #[serde(default = "default_2190")] + #[serde(default = "default_2195")] pub locked: bool, - #[serde(default = "default_2191")] + #[serde(default = "default_2196")] pub locked_by: String, } @@ -49937,7 +50173,7 @@ impl PolicyDecisionsInput { #[non_exhaustive] pub struct PolicyDeleteOutput { pub removed: bool, - #[serde(default = "default_2192")] + #[serde(default = "default_2197")] pub widening: bool, } @@ -50003,12 +50239,12 @@ pub struct PolicyRuleOut { pub condition: std::collections::HashMap, pub description: String, pub enabled: bool, - #[serde(default = "default_2193")] + #[serde(default = "default_2198")] pub mode: String, pub created_by: String, - #[serde(default = "default_2194")] + #[serde(default = "default_2199")] pub created_at: Option, - #[serde(default = "default_2195")] + #[serde(default = "default_2200")] pub updated_at: Option, } @@ -50080,9 +50316,9 @@ impl PolicyListInput { pub struct PolicySetOutput { pub rule: PolicyRuleOut, pub leaf_count: Integer, - #[serde(default = "default_2196")] + #[serde(default = "default_2201")] pub widening: bool, - #[serde(default = "default_2197")] + #[serde(default = "default_2202")] pub change: Vec, } @@ -50352,37 +50588,37 @@ pub struct ProcedureEvolveOutput { pub revision: Integer, pub changed: bool, pub template: bool, - #[serde(default = "default_2198")] + #[serde(default = "default_2203")] pub folded_runs: Integer, - #[serde(default = "default_2199")] + #[serde(default = "default_2204")] pub gate: ProcedureEvolveOutputGate, - #[serde(default = "default_2200")] + #[serde(default = "default_2205")] pub gate_mode: String, - #[serde(default = "default_2201")] + #[serde(default = "default_2206")] pub gate_llr: f64, - #[serde(default = "default_2202")] + #[serde(default = "default_2207")] pub gate_before: std::collections::HashMap, - #[serde(default = "default_2203")] + #[serde(default = "default_2208")] pub gate_after: std::collections::HashMap, - #[serde(default = "default_2204")] + #[serde(default = "default_2209")] pub gate_cost_before: std::collections::HashMap, - #[serde(default = "default_2205")] + #[serde(default = "default_2210")] pub gate_cost_after: std::collections::HashMap, - #[serde(default = "default_2206")] + #[serde(default = "default_2211")] pub gate_reason: String, - #[serde(default = "default_2207")] + #[serde(default = "default_2212")] pub dead_end_steps: Vec, - #[serde(default = "default_2208")] + #[serde(default = "default_2213")] pub fail_prone_steps: Vec, - #[serde(default = "default_2209")] + #[serde(default = "default_2214")] pub fail_prone_transitions: Vec, - #[serde(default = "default_2210")] + #[serde(default = "default_2215")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2211")] + #[serde(default = "default_2216")] pub strikes: Integer, - #[serde(default = "default_2212")] + #[serde(default = "default_2217")] pub quarantined: bool, - #[serde(default = "default_2213")] + #[serde(default = "default_2218")] pub retention: std::collections::HashMap, } @@ -50605,9 +50841,9 @@ pub struct ProcedureForkOutput { pub memory_key: String, pub version: Integer, pub name: String, - #[serde(default = "default_2214")] + #[serde(default = "default_2219")] pub steps: Vec, - #[serde(default = "default_2215")] + #[serde(default = "default_2220")] pub forked_from: std::collections::HashMap, } @@ -50867,32 +51103,32 @@ pub enum ProcedureLocateOutputStatus { #[non_exhaustive] pub struct ProcedureLocateOutput { pub memory_key: String, - #[serde(default = "default_2216")] + #[serde(default = "default_2221")] pub name: String, - #[serde(default = "default_2217")] + #[serde(default = "default_2222")] pub status: ProcedureLocateOutputStatus, pub matched: bool, - #[serde(default = "default_2218")] + #[serde(default = "default_2223")] pub active: Option>, - #[serde(default = "default_2219")] + #[serde(default = "default_2224")] pub hops: Vec>>, - #[serde(default = "default_2220")] + #[serde(default = "default_2225")] pub entry_nodes: Vec, - #[serde(default = "default_2221")] + #[serde(default = "default_2226")] pub dominant_next: Vec, - #[serde(default = "default_2222")] + #[serde(default = "default_2227")] pub revisits: std::collections::HashMap, - #[serde(default = "default_2223")] + #[serde(default = "default_2228")] pub looping: bool, - #[serde(default = "default_2224")] + #[serde(default = "default_2229")] pub exits: Vec, - #[serde(default = "default_2225")] + #[serde(default = "default_2230")] pub failure_notes: Vec>, - #[serde(default = "default_2226")] + #[serde(default = "default_2231")] pub rendered: String, - #[serde(default = "default_2227")] + #[serde(default = "default_2232")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2228")] + #[serde(default = "default_2233")] pub for_agent: std::collections::HashMap, } @@ -51044,46 +51280,48 @@ pub enum ProcedureMatchStatus { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProcedureMatch { + #[serde(default = "default_2234")] + pub use_guidance: Option, pub name: String, pub situation: String, pub steps: Vec, - #[serde(default = "default_2229")] + #[serde(default = "default_2235")] pub tags: Vec, - #[serde(default = "default_2230")] + #[serde(default = "default_2236")] pub metadata: std::collections::HashMap, pub similarity: f64, pub memory_key: String, pub namespace: String, - #[serde(default = "default_2231")] + #[serde(default = "default_2237")] pub graph: Option>, - #[serde(default = "default_2232")] + #[serde(default = "default_2238")] pub template: bool, - #[serde(default = "default_2233")] + #[serde(default = "default_2239")] pub run_stats: std::collections::HashMap, - #[serde(default = "default_2234")] + #[serde(default = "default_2240")] pub status: ProcedureMatchStatus, - #[serde(default = "default_2235")] + #[serde(default = "default_2241")] pub quarantined: Option>, - #[serde(default = "default_2236")] + #[serde(default = "default_2242")] pub fail_prone_steps: Vec, - #[serde(default = "default_2237")] + #[serde(default = "default_2243")] pub revision: Integer, - #[serde(default = "default_2238")] + #[serde(default = "default_2244")] pub rejected_revisions: Vec>, - #[serde(default = "default_2239")] + #[serde(default = "default_2245")] pub tool_overlap: f64, - #[serde(default = "default_2240")] + #[serde(default = "default_2246")] pub score: f64, - #[serde(default = "default_2241")] + #[serde(default = "default_2247")] pub utility: f64, - #[serde(default = "default_2242")] + #[serde(default = "default_2248")] pub goal_similarity: Option, - #[serde(default = "default_2243")] + #[serde(default = "default_2249")] pub for_agent: std::collections::HashMap, - #[serde(default = "default_2244")] + #[serde(default = "default_2250")] pub run_stats_by_agent: std::collections::HashMap>, - #[serde(default = "default_2245")] + #[serde(default = "default_2251")] pub actor: String, } @@ -51091,11 +51329,11 @@ pub struct ProcedureMatch { #[non_exhaustive] pub struct ProcedureMatchOutput { pub matches: Vec, - #[serde(default = "default_2246")] + #[serde(default = "default_2252")] pub matched: Integer, - #[serde(default = "default_2247")] + #[serde(default = "default_2253")] pub procedure_key: String, - #[serde(default = "default_2248")] + #[serde(default = "default_2254")] pub score: f64, } @@ -51476,7 +51714,7 @@ pub struct ProcedureReviseOutput { pub revision: Integer, pub prior_revision: Integer, pub digest: String, - #[serde(default = "default_2249")] + #[serde(default = "default_2255")] pub steps: Vec, } @@ -51588,14 +51826,14 @@ pub struct ProfileActivityEntry { pub agent: String, pub last_activated_at: String, pub event_count: Integer, - #[serde(default = "default_2250")] + #[serde(default = "default_2256")] pub operations: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProfileActivityOutput { - #[serde(default = "default_2251")] + #[serde(default = "default_2257")] pub entries: Vec, } @@ -51703,17 +51941,17 @@ impl ProfileActivityInput { #[non_exhaustive] pub struct ProfileMutationOutput { pub version: Integer, - #[serde(default = "default_2252")] + #[serde(default = "default_2258")] pub memory_id: String, - #[serde(default = "default_2253")] + #[serde(default = "default_2259")] pub content_sha256: String, - #[serde(default = "default_2254")] + #[serde(default = "default_2260")] pub namespace: String, - #[serde(default = "default_2255")] + #[serde(default = "default_2261")] pub label: String, - #[serde(default = "default_2256")] + #[serde(default = "default_2262")] pub char_limit: Option, - #[serde(default = "default_2257")] + #[serde(default = "default_2263")] pub value_length: Integer, } @@ -51822,7 +52060,7 @@ pub struct ProfileRenderOutput { pub rendered: String, pub section_count: Integer, pub total_chars: Integer, - #[serde(default = "default_2258")] + #[serde(default = "default_2264")] pub labels: Vec, } @@ -52207,17 +52445,17 @@ pub enum ProfileStructuredOutputStatus { #[non_exhaustive] pub struct ProfileStructuredOutput { pub status: ProfileStructuredOutputStatus, - #[serde(default = "default_2259")] + #[serde(default = "default_2265")] pub profile: std::collections::HashMap, - #[serde(default = "default_2260")] + #[serde(default = "default_2266")] pub built_at: Option, - #[serde(default = "default_2261")] + #[serde(default = "default_2267")] pub memory_id: String, - #[serde(default = "default_2262")] + #[serde(default = "default_2268")] pub version: Integer, - #[serde(default = "default_2263")] + #[serde(default = "default_2269")] pub version_text: String, - #[serde(default = "default_2264")] + #[serde(default = "default_2270")] pub schema_sha256: String, } @@ -52334,13 +52572,13 @@ impl ProfileStructuredInput { #[non_exhaustive] pub struct ProfileSchemaOutput { pub found: bool, - #[serde(default = "default_2265")] + #[serde(default = "default_2271")] pub json_schema: std::collections::HashMap, - #[serde(default = "default_2266")] + #[serde(default = "default_2272")] pub schema_sha256: String, - #[serde(default = "default_2267")] + #[serde(default = "default_2273")] pub updated_by: String, - #[serde(default = "default_2268")] + #[serde(default = "default_2274")] pub updated_at: Option, } @@ -52493,10 +52731,10 @@ pub enum RunBeginOutputStatus { #[non_exhaustive] pub struct RunBeginOutput { pub run_id: String, - #[serde(default = "default_2269")] + #[serde(default = "default_2275")] pub status: RunBeginOutputStatus, pub started_at: String, - #[serde(default = "default_2270")] + #[serde(default = "default_2276")] pub next: String, } @@ -52704,29 +52942,29 @@ pub struct RunCompleteOutput { pub run_id: String, pub status: RunCompleteOutputStatus, pub duration_ms: Integer, - #[serde(default = "default_2271")] + #[serde(default = "default_2277")] pub used_applied: Integer, - #[serde(default = "default_2272")] + #[serde(default = "default_2278")] pub evidence_applied: Integer, - #[serde(default = "default_2273")] + #[serde(default = "default_2279")] pub harm_applied: Integer, - #[serde(default = "default_2274")] + #[serde(default = "default_2280")] pub memories_written: Vec, - #[serde(default = "default_2275")] + #[serde(default = "default_2281")] pub recalled: Integer, - #[serde(default = "default_2276")] + #[serde(default = "default_2282")] pub observations: Integer, - #[serde(default = "default_2277")] + #[serde(default = "default_2283")] pub procedure_runs_recorded: Integer, - #[serde(default = "default_2278")] + #[serde(default = "default_2284")] pub reflection_key: String, - #[serde(default = "default_2279")] + #[serde(default = "default_2285")] pub retain: String, - #[serde(default = "default_2280")] + #[serde(default = "default_2286")] pub retained: Integer, - #[serde(default = "default_2281")] + #[serde(default = "default_2287")] pub demoted: Integer, - #[serde(default = "default_2282")] + #[serde(default = "default_2288")] pub expiring: Integer, } @@ -53247,25 +53485,25 @@ pub enum RunGetOutputOverBudgetItem { #[non_exhaustive] pub struct RunGetOutput { pub found: bool, - #[serde(default = "default_2283")] + #[serde(default = "default_2289")] pub run: Option, - #[serde(default = "default_2284")] + #[serde(default = "default_2290")] pub recalled: Integer, - #[serde(default = "default_2285")] + #[serde(default = "default_2291")] pub recalled_keys: Vec, - #[serde(default = "default_2286")] + #[serde(default = "default_2292")] pub memories_written: Vec, - #[serde(default = "default_2287")] + #[serde(default = "default_2293")] pub observations: Integer, - #[serde(default = "default_2288")] + #[serde(default = "default_2294")] pub turns: Integer, - #[serde(default = "default_2289")] + #[serde(default = "default_2295")] pub unpriced_turns: Integer, - #[serde(default = "default_2290")] + #[serde(default = "default_2296")] pub cost_usd: f64, - #[serde(default = "default_2291")] + #[serde(default = "default_2297")] pub elapsed_seconds: Integer, - #[serde(default = "default_2292")] + #[serde(default = "default_2298")] pub over_budget: Vec, } @@ -53332,17 +53570,17 @@ pub struct RunGradeProposal { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct RunGradeOutput { - #[serde(default = "default_2293")] + #[serde(default = "default_2299")] pub graded: Integer, - #[serde(default = "default_2294")] + #[serde(default = "default_2300")] pub run_ids: Vec, - #[serde(default = "default_2295")] + #[serde(default = "default_2301")] pub skipped_active: Integer, - #[serde(default = "default_2296")] + #[serde(default = "default_2302")] pub unchanged: Integer, - #[serde(default = "default_2297")] + #[serde(default = "default_2303")] pub memories_counted: Integer, - #[serde(default = "default_2298")] + #[serde(default = "default_2304")] pub proposals_decided: Vec, } @@ -53457,7 +53695,7 @@ impl RunGradeInput { #[non_exhaustive] pub struct RunListOutput { pub runs: Vec, - #[serde(default = "default_2299")] + #[serde(default = "default_2305")] pub total: Option, } @@ -53734,39 +53972,39 @@ pub struct LiveSearchHit { pub title: String, pub url: String, pub provider: LiveSearchHitProvider, - #[serde(default = "default_2302")] + #[serde(default = "default_2308")] pub content: String, - #[serde(default = "default_2303")] + #[serde(default = "default_2309")] pub live: LiveSearchHitLive, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct LiveSearchResults { - #[serde(default = "default_2301")] + #[serde(default = "default_2307")] pub live: LiveSearchResultsLive, - #[serde(default = "default_2304")] + #[serde(default = "default_2310")] pub results: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SearchOutput { - #[serde(default = "default_2300")] + #[serde(default = "default_2306")] pub tracker: Option>, - #[serde(default = "default_2305")] + #[serde(default = "default_2311")] pub live: Option, - #[serde(default = "default_2306")] + #[serde(default = "default_2312")] pub memory: std::collections::HashMap, - #[serde(default = "default_2307")] + #[serde(default = "default_2313")] pub knowledge: std::collections::HashMap, - #[serde(default = "default_2308")] + #[serde(default = "default_2314")] pub profile: std::collections::HashMap, - #[serde(default = "default_2309")] + #[serde(default = "default_2315")] pub conversations: std::collections::HashMap, - #[serde(default = "default_2310")] + #[serde(default = "default_2316")] pub withheld: Option>, - #[serde(default = "default_2311")] + #[serde(default = "default_2317")] pub namespaces_skipped: Vec, } @@ -53959,7 +54197,7 @@ impl SearchInput { pub struct SessionBriefDeleteOutput { pub deleted: bool, pub brief_key: String, - #[serde(default = "default_2312")] + #[serde(default = "default_2318")] pub revision: Integer, } @@ -54052,67 +54290,67 @@ impl SessionBriefDeleteInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDecision { - #[serde(default = "default_2321")] + #[serde(default = "default_2327")] pub what: String, - #[serde(default = "default_2322")] + #[serde(default = "default_2328")] pub why: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDeadEnd { - #[serde(default = "default_2324")] + #[serde(default = "default_2330")] pub tried: String, - #[serde(default = "default_2325")] + #[serde(default = "default_2331")] pub why_not: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDone { - #[serde(default = "default_2327")] + #[serde(default = "default_2333")] pub what: String, - #[serde(rename = "ref", default = "default_2328")] + #[serde(rename = "ref", default = "default_2334")] pub r#ref: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefFile { - #[serde(default = "default_2332")] + #[serde(default = "default_2338")] pub path: String, - #[serde(default = "default_2333")] + #[serde(default = "default_2339")] pub role: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefSections { - #[serde(default = "default_2318")] + #[serde(default = "default_2324")] pub goal: String, - #[serde(default = "default_2319")] + #[serde(default = "default_2325")] pub status: String, - #[serde(default = "default_2320")] + #[serde(default = "default_2326")] pub verification: String, - #[serde(default = "default_2323")] + #[serde(default = "default_2329")] pub decisions: Vec, - #[serde(default = "default_2326")] + #[serde(default = "default_2332")] pub dead_ends: Vec, - #[serde(default = "default_2329")] + #[serde(default = "default_2335")] pub done: Vec, - #[serde(default = "default_2330")] + #[serde(default = "default_2336")] pub open_questions: Vec, - #[serde(default = "default_2331")] + #[serde(default = "default_2337")] pub next_steps: Vec, - #[serde(default = "default_2334")] + #[serde(default = "default_2340")] pub files: Vec, - #[serde(default = "default_2335")] + #[serde(default = "default_2341")] pub constraints: Vec, - #[serde(default = "default_2336")] + #[serde(default = "default_2342")] pub pointers: Vec, - #[serde(default = "default_2337")] + #[serde(default = "default_2343")] pub client_summary: String, - #[serde(default = "default_2338")] + #[serde(default = "default_2344")] pub client_summary_at: String, } @@ -54120,45 +54358,45 @@ pub struct BriefSections { #[non_exhaustive] pub struct SessionBriefGetOutput { pub found: bool, - #[serde(default = "default_2313")] + #[serde(default = "default_2319")] pub brief_key: String, - #[serde(default = "default_2314")] + #[serde(default = "default_2320")] pub revision: Integer, - #[serde(default = "default_2315")] + #[serde(default = "default_2321")] pub snapshot_id: String, - #[serde(default = "default_2316")] + #[serde(default = "default_2322")] pub snapshot_key: String, - #[serde(default = "default_2317")] + #[serde(default = "default_2323")] pub rendered: String, - #[serde(default = "default_2339")] + #[serde(default = "default_2345")] pub sections: Option, - #[serde(default = "default_2340")] + #[serde(default = "default_2346")] pub project: String, - #[serde(default = "default_2341")] + #[serde(default = "default_2347")] pub branch: String, - #[serde(default = "default_2342")] + #[serde(default = "default_2348")] pub head_sha: String, - #[serde(default = "default_2343")] + #[serde(default = "default_2349")] pub author: String, - #[serde(default = "default_2344")] + #[serde(default = "default_2350")] pub trigger: String, - #[serde(default = "default_2345")] + #[serde(default = "default_2351")] pub actor: String, - #[serde(default = "default_2346")] + #[serde(default = "default_2352")] pub source_sessions: Vec, - #[serde(default = "default_2347")] + #[serde(default = "default_2353")] pub updated_at: Option, - #[serde(default = "default_2348")] + #[serde(default = "default_2354")] pub age_seconds: Integer, - #[serde(default = "default_2349")] + #[serde(default = "default_2355")] pub revisions: Integer, - #[serde(default = "default_2350")] + #[serde(default = "default_2356")] pub events_total: Integer, - #[serde(default = "default_2351")] + #[serde(default = "default_2357")] pub source_chars: Integer, - #[serde(default = "default_2352")] + #[serde(default = "default_2358")] pub brief_chars: Integer, - #[serde(default = "default_2353")] + #[serde(default = "default_2359")] pub deleted: bool, } @@ -54333,34 +54571,34 @@ impl SessionBriefGetInput { pub struct SessionBriefSummary { pub brief_key: String, pub revision: Integer, - #[serde(default = "default_2354")] + #[serde(default = "default_2360")] pub project: String, - #[serde(default = "default_2355")] + #[serde(default = "default_2361")] pub branch: String, - #[serde(default = "default_2356")] + #[serde(default = "default_2362")] pub agent: String, - #[serde(default = "default_2357")] + #[serde(default = "default_2363")] pub goal: String, - #[serde(default = "default_2358")] + #[serde(default = "default_2364")] pub status: String, - #[serde(default = "default_2359")] + #[serde(default = "default_2365")] pub author: String, - #[serde(default = "default_2360")] + #[serde(default = "default_2366")] pub actor: String, - #[serde(default = "default_2361")] + #[serde(default = "default_2367")] pub updated_at: Option, - #[serde(default = "default_2362")] + #[serde(default = "default_2368")] pub age_seconds: Integer, - #[serde(default = "default_2363")] + #[serde(default = "default_2369")] pub brief_chars: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefListOutput { - #[serde(default = "default_2364")] + #[serde(default = "default_2370")] pub briefs: Vec, - #[serde(default = "default_2365")] + #[serde(default = "default_2371")] pub rendered: String, } @@ -54500,25 +54738,25 @@ impl SessionBriefListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefStats { - #[serde(default = "default_2369")] + #[serde(default = "default_2375")] pub events_in: Integer, - #[serde(default = "default_2370")] + #[serde(default = "default_2376")] pub windows: Integer, - #[serde(default = "default_2371")] + #[serde(default = "default_2377")] pub events_total: Integer, - #[serde(default = "default_2372")] + #[serde(default = "default_2378")] pub source_chars: Integer, - #[serde(default = "default_2373")] + #[serde(default = "default_2379")] pub brief_chars: Integer, - #[serde(default = "default_2374")] + #[serde(default = "default_2380")] pub compression_ratio: f64, - #[serde(default = "default_2375")] + #[serde(default = "default_2381")] pub dropped_ungrounded: Integer, - #[serde(default = "default_2376")] + #[serde(default = "default_2382")] pub tokens_in: Integer, - #[serde(default = "default_2377")] + #[serde(default = "default_2383")] pub tokens_out: Integer, - #[serde(default = "default_2378")] + #[serde(default = "default_2384")] pub llm_model: String, } @@ -54528,13 +54766,13 @@ pub struct SessionBriefSaveOutput { pub brief_key: String, pub revision: Integer, pub changed: bool, - #[serde(default = "default_2366")] + #[serde(default = "default_2372")] pub author: String, - #[serde(default = "default_2367")] + #[serde(default = "default_2373")] pub reason: String, - #[serde(default = "default_2368")] + #[serde(default = "default_2374")] pub rendered: String, - #[serde(default = "default_2379")] + #[serde(default = "default_2385")] pub stats: SessionBriefStats, } @@ -55279,39 +55517,39 @@ pub struct TaskPayload { pub priority: Integer, pub disclosure: TaskPayloadDisclosure, pub status: TaskPayloadStatus, - #[serde(default = "default_2380")] + #[serde(default = "default_2386")] pub reason: String, - #[serde(default = "default_2381")] + #[serde(default = "default_2387")] pub blocked_on: String, - #[serde(default = "default_2382")] + #[serde(default = "default_2388")] pub not_before: Option, - #[serde(default = "default_2383")] + #[serde(default = "default_2389")] pub resume_at: Option, - #[serde(default = "default_2384")] + #[serde(default = "default_2390")] pub deadline: Option, - #[serde(default = "default_2385")] + #[serde(default = "default_2391")] pub defer_count: Integer, pub title: String, - #[serde(default = "default_2386")] + #[serde(default = "default_2392")] pub brief: std::collections::HashMap, pub from_agent: String, - #[serde(default = "default_2387")] + #[serde(default = "default_2393")] pub from_subject: String, - #[serde(default = "default_2388")] + #[serde(default = "default_2394")] pub origin: String, - #[serde(default = "default_2389")] + #[serde(default = "default_2395")] pub parent_task_id: Option, - #[serde(default = "default_2390")] + #[serde(default = "default_2396")] pub owner: String, - #[serde(default = "default_2391")] + #[serde(default = "default_2397")] pub attempt: Integer, - #[serde(default = "default_2392")] + #[serde(default = "default_2398")] pub fence: Integer, - #[serde(default = "default_2393")] + #[serde(default = "default_2399")] pub lease_until: Option, - #[serde(default = "default_2394")] + #[serde(default = "default_2400")] pub outcome: std::collections::HashMap, - #[serde(default = "default_2395")] + #[serde(default = "default_2401")] pub last_actor: String, pub created_at: String, pub updated_at: String, @@ -55322,7 +55560,7 @@ pub struct TaskPayload { #[non_exhaustive] pub struct TaskOutput { pub task: TaskPayload, - #[serde(default = "default_2396")] + #[serde(default = "default_2402")] pub seq: Integer, } @@ -55723,10 +55961,10 @@ impl TaskCompleteInput { pub struct InboxCount { pub inbox: String, pub status: String, - #[serde(default = "default_2397")] + #[serde(default = "default_2403")] pub blocked_on: String, pub n: Integer, - #[serde(default = "default_2398")] + #[serde(default = "default_2404")] pub oldest: Option, } @@ -55813,7 +56051,7 @@ pub struct TaskCreateOutput { pub task: TaskPayload, pub created: bool, pub seq: Integer, - #[serde(default = "default_2399")] + #[serde(default = "default_2405")] pub next: String, } @@ -56152,7 +56390,7 @@ impl TaskFailInput { #[non_exhaustive] pub struct TaskGetOutput { pub found: bool, - #[serde(default = "default_2400")] + #[serde(default = "default_2406")] pub task: Option, } @@ -56286,23 +56524,23 @@ pub struct TaskEventPayload { pub task_id: String, pub inbox: String, pub event: String, - #[serde(default = "default_2401")] + #[serde(default = "default_2407")] pub from_status: String, - #[serde(default = "default_2402")] + #[serde(default = "default_2408")] pub to_status: String, - #[serde(default = "default_2403")] + #[serde(default = "default_2409")] pub actor: String, - #[serde(default = "default_2404")] + #[serde(default = "default_2410")] pub agent: String, - #[serde(default = "default_2405")] + #[serde(default = "default_2411")] pub fence: Integer, - #[serde(default = "default_2406")] + #[serde(default = "default_2412")] pub version: Integer, - #[serde(default = "default_2407")] + #[serde(default = "default_2413")] pub reason: String, - #[serde(default = "default_2408")] + #[serde(default = "default_2414")] pub patch: std::collections::HashMap, - #[serde(default = "default_2409")] + #[serde(default = "default_2415")] pub note: String, pub ts: String, } @@ -56642,7 +56880,7 @@ pub struct TaskPullOutput { pub tasks: Vec, pub waited_ms: Integer, pub backend: String, - #[serde(default = "default_2410")] + #[serde(default = "default_2416")] pub note: String, } @@ -57038,7 +57276,7 @@ impl TaskUnblockInput { pub struct TaskUpdateOutput { pub task: TaskPayload, pub seq: Integer, - #[serde(default = "default_2411")] + #[serde(default = "default_2417")] pub conflict: bool, } @@ -57401,19 +57639,19 @@ impl TaskReasonInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerAnswerOutput { - #[serde(default = "default_2412")] + #[serde(default = "default_2418")] pub intent: String, - #[serde(default = "default_2413")] + #[serde(default = "default_2419")] pub anchors: std::collections::HashMap, - #[serde(default = "default_2414")] + #[serde(default = "default_2420")] pub sections: Vec>, - #[serde(default = "default_2415")] + #[serde(default = "default_2421")] pub searched: Vec, - #[serde(default = "default_2416")] + #[serde(default = "default_2422")] pub lines: Vec, - #[serde(default = "default_2417")] + #[serde(default = "default_2423")] pub restricted: bool, - #[serde(default = "default_2418")] + #[serde(default = "default_2424")] pub verdict: String, } @@ -57509,17 +57747,17 @@ impl TrackerAnswerInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerBindingOutput { - #[serde(default = "default_2419")] + #[serde(default = "default_2425")] pub tracker_namespace: String, - #[serde(default = "default_2420")] + #[serde(default = "default_2426")] pub tracker_namespaces: Vec, - #[serde(default = "default_2421")] + #[serde(default = "default_2427")] pub restricted: bool, - #[serde(default = "default_2422")] + #[serde(default = "default_2428")] pub kind: String, - #[serde(default = "default_2423")] + #[serde(default = "default_2429")] pub authorized: bool, - #[serde(default = "default_2424")] + #[serde(default = "default_2430")] pub templates: Vec, } @@ -57572,13 +57810,13 @@ impl TrackerBindingInput { #[non_exhaustive] pub struct TrackerComponentOutput { pub component: String, - #[serde(default = "default_2425")] + #[serde(default = "default_2431")] pub risk: std::collections::HashMap, - #[serde(default = "default_2426")] + #[serde(default = "default_2432")] pub open_issues: Vec>, - #[serde(default = "default_2427")] + #[serde(default = "default_2433")] pub known: bool, - #[serde(default = "default_2428")] + #[serde(default = "default_2434")] pub tracker_unavailable: bool, } @@ -57639,9 +57877,9 @@ impl TrackerComponentInput { #[non_exhaustive] pub struct TrackerContractOutput { pub database: String, - #[serde(default = "default_2429")] + #[serde(default = "default_2435")] pub tables: Vec>, - #[serde(default = "default_2430")] + #[serde(default = "default_2436")] pub templates: std::collections::HashMap, } @@ -57694,66 +57932,66 @@ impl TrackerContractInput { #[non_exhaustive] pub struct TrackerLegStatus { pub name: String, - #[serde(default = "default_2441")] + #[serde(default = "default_2447")] pub status: String, - #[serde(default = "default_2442")] + #[serde(default = "default_2448")] pub reason: String, - #[serde(default = "default_2443")] + #[serde(default = "default_2449")] pub message: String, - #[serde(default = "default_2444")] + #[serde(default = "default_2450")] pub retried: bool, - #[serde(default = "default_2445")] + #[serde(default = "default_2451")] pub ms: Integer, - #[serde(default = "default_2446")] + #[serde(default = "default_2452")] pub cause: String, - #[serde(default = "default_2447")] + #[serde(default = "default_2453")] pub namespace: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerDuplicateCheckOutput { - #[serde(default = "default_2431")] + #[serde(default = "default_2437")] pub verdict: String, - #[serde(default = "default_2432")] + #[serde(default = "default_2438")] pub items: Vec>, - #[serde(default = "default_2433")] + #[serde(default = "default_2439")] pub undecided: bool, - #[serde(default = "default_2434")] + #[serde(default = "default_2440")] pub epistemic: String, - #[serde(default = "default_2435")] + #[serde(default = "default_2441")] pub thresholds: std::collections::HashMap, - #[serde(default = "default_2436")] + #[serde(default = "default_2442")] pub judge: std::collections::HashMap, - #[serde(default = "default_2437")] + #[serde(default = "default_2443")] pub fit_at: String, - #[serde(default = "default_2438")] + #[serde(default = "default_2444")] pub fit: std::collections::HashMap, - #[serde(default = "default_2439")] + #[serde(default = "default_2445")] pub query: std::collections::HashMap, - #[serde(default = "default_2440")] + #[serde(default = "default_2446")] pub legs: std::collections::HashMap, - #[serde(default = "default_2448")] + #[serde(default = "default_2454")] pub leg_status: Vec, - #[serde(default = "default_2449")] + #[serde(default = "default_2455")] pub tracker_unavailable: bool, - #[serde(default = "default_2450")] + #[serde(default = "default_2456")] pub namespaces: Vec, - #[serde(default = "default_2451")] + #[serde(default = "default_2457")] pub by_namespace: std::collections::HashMap>, - #[serde(default = "default_2452")] + #[serde(default = "default_2458")] pub closest: Vec>, - #[serde(default = "default_2453")] + #[serde(default = "default_2459")] pub needs: Vec>, - #[serde(default = "default_2454")] + #[serde(default = "default_2460")] pub closest_note: String, - #[serde(default = "default_2455")] + #[serde(default = "default_2461")] pub nearest: Vec>, - #[serde(default = "default_2456")] + #[serde(default = "default_2462")] pub rerank: std::collections::HashMap, - #[serde(default = "default_2457")] + #[serde(default = "default_2463")] pub answer: String, - #[serde(default = "default_2458")] + #[serde(default = "default_2464")] pub related_prs: Vec>, } @@ -57960,17 +58198,17 @@ impl TrackerDuplicateCheckInput { #[non_exhaustive] pub struct TrackerFlakyOutput { pub test_name: String, - #[serde(default = "default_2459")] + #[serde(default = "default_2465")] pub known_flaky: bool, - #[serde(default = "default_2460")] + #[serde(default = "default_2466")] pub open_issues: Integer, - #[serde(default = "default_2461")] + #[serde(default = "default_2467")] pub issues: Vec>, - #[serde(default = "default_2462")] + #[serde(default = "default_2468")] pub verdict: String, - #[serde(default = "default_2463")] + #[serde(default = "default_2469")] pub tracker_unavailable: bool, - #[serde(default = "default_2464")] + #[serde(default = "default_2470")] pub signal: Option>, } @@ -58053,9 +58291,9 @@ impl TrackerFlakyInput { #[non_exhaustive] pub struct TrackerItemOutput { pub items: Vec>, - #[serde(default = "default_2465")] + #[serde(default = "default_2471")] pub unknown: Vec, - #[serde(default = "default_2466")] + #[serde(default = "default_2472")] pub tracker_unavailable: bool, } @@ -58104,19 +58342,19 @@ impl TrackerItemInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerLinksOutput { - #[serde(default = "default_2467")] + #[serde(default = "default_2473")] pub subject: std::collections::HashMap, - #[serde(default = "default_2468")] + #[serde(default = "default_2474")] pub verdict: String, - #[serde(default = "default_2469")] + #[serde(default = "default_2475")] pub items: Vec>, - #[serde(default = "default_2470")] + #[serde(default = "default_2476")] pub epistemic: String, - #[serde(default = "default_2471")] + #[serde(default = "default_2477")] pub record: std::collections::HashMap, - #[serde(default = "default_2472")] + #[serde(default = "default_2478")] pub computed_at: String, - #[serde(default = "default_2473")] + #[serde(default = "default_2479")] pub tracker_unavailable: bool, } @@ -58214,11 +58452,11 @@ impl TrackerLinksInput { pub struct TrackerReleaseOutput { pub version: String, pub blockers: Vec>, - #[serde(default = "default_2474")] + #[serde(default = "default_2480")] pub active_blockers: Integer, - #[serde(default = "default_2475")] + #[serde(default = "default_2481")] pub health: std::collections::HashMap, - #[serde(default = "default_2476")] + #[serde(default = "default_2482")] pub tracker_unavailable: bool, } @@ -58267,17 +58505,17 @@ impl TrackerReleaseInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSimilarOutput { - #[serde(default = "default_2477")] + #[serde(default = "default_2483")] pub items: Vec>, - #[serde(default = "default_2478")] + #[serde(default = "default_2484")] pub query: std::collections::HashMap, - #[serde(default = "default_2479")] + #[serde(default = "default_2485")] pub legs: std::collections::HashMap, - #[serde(default = "default_2480")] + #[serde(default = "default_2486")] pub epistemic: String, - #[serde(default = "default_2481")] + #[serde(default = "default_2487")] pub tracker_unavailable: bool, - #[serde(default = "default_2482")] + #[serde(default = "default_2488")] pub namespaces: Vec, } @@ -58398,19 +58636,19 @@ pub struct TrackerSourceAddOutput { pub name: String, pub host: String, pub database: String, - #[serde(default = "default_2483")] + #[serde(default = "default_2489")] pub namespaces: Vec>, - #[serde(default = "default_2484")] + #[serde(default = "default_2490")] pub contract: std::collections::HashMap, - #[serde(default = "default_2485")] + #[serde(default = "default_2491")] pub roles: Vec, - #[serde(default = "default_2486")] + #[serde(default = "default_2492")] pub my_role: String, - #[serde(default = "default_2487")] + #[serde(default = "default_2493")] pub dry_run: bool, - #[serde(default = "default_2488")] + #[serde(default = "default_2494")] pub written: bool, - #[serde(default = "default_2489")] + #[serde(default = "default_2495")] pub view_templates: std::collections::HashMap, } @@ -58573,13 +58811,13 @@ impl TrackerSourceAddInput { #[non_exhaustive] pub struct TrackerSourceCheckOutput { pub name: String, - #[serde(default = "default_2490")] + #[serde(default = "default_2496")] pub database: String, - #[serde(default = "default_2491")] + #[serde(default = "default_2497")] pub reachable: bool, - #[serde(default = "default_2492")] + #[serde(default = "default_2498")] pub contract: std::collections::HashMap, - #[serde(default = "default_2493")] + #[serde(default = "default_2499")] pub view_templates: std::collections::HashMap, } @@ -58619,11 +58857,11 @@ impl TrackerSourceCheckInput { pub struct TrackerSourceInspectOutput { pub host: String, pub database: String, - #[serde(default = "default_2494")] + #[serde(default = "default_2500")] pub tables: Vec>, - #[serde(default = "default_2495")] + #[serde(default = "default_2501")] pub roles: Vec, - #[serde(default = "default_2496")] + #[serde(default = "default_2502")] pub proposal: std::collections::HashMap, } @@ -58752,9 +58990,9 @@ impl TrackerSourceInspectInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSourceListOutput { - #[serde(default = "default_2497")] + #[serde(default = "default_2503")] pub sources: Vec>, - #[serde(default = "default_2498")] + #[serde(default = "default_2504")] pub self_service: bool, } @@ -58807,9 +59045,9 @@ impl TrackerSourceListInput { #[non_exhaustive] pub struct TrackerSourceRemoveOutput { pub name: String, - #[serde(default = "default_2499")] + #[serde(default = "default_2505")] pub deactivated: bool, - #[serde(default = "default_2500")] + #[serde(default = "default_2506")] pub namespaces_retired: Vec, } @@ -58850,9 +59088,9 @@ impl TrackerSourceRemoveInput { #[non_exhaustive] pub struct TrackerSourceRotateOutput { pub name: String, - #[serde(default = "default_2501")] + #[serde(default = "default_2507")] pub contract: std::collections::HashMap, - #[serde(default = "default_2502")] + #[serde(default = "default_2508")] pub rotated_at: String, } @@ -58899,11 +59137,11 @@ impl TrackerSourceRotateInput { #[non_exhaustive] pub struct TrackerSourceSetMappingOutput { pub name: String, - #[serde(default = "default_2503")] + #[serde(default = "default_2509")] pub contract: std::collections::HashMap, - #[serde(default = "default_2504")] + #[serde(default = "default_2510")] pub dry_run: bool, - #[serde(default = "default_2505")] + #[serde(default = "default_2511")] pub written: bool, } @@ -58970,45 +59208,45 @@ impl TrackerSourceSetMappingInput { #[non_exhaustive] pub struct TrackerTestSignalOutput { pub test_name: String, - #[serde(default = "default_2506")] + #[serde(default = "default_2512")] pub verdict: String, - #[serde(default = "default_2507")] + #[serde(default = "default_2513")] pub why: Vec, - #[serde(default = "default_2508")] + #[serde(default = "default_2514")] pub lower_bound: f64, - #[serde(default = "default_2509")] + #[serde(default = "default_2515")] pub window_days: Integer, - #[serde(default = "default_2510")] + #[serde(default = "default_2516")] pub since: String, - #[serde(default = "default_2511")] + #[serde(default = "default_2517")] pub features: std::collections::HashMap, - #[serde(default = "default_2512")] + #[serde(default = "default_2518")] pub infra: std::collections::HashMap, - #[serde(default = "default_2513")] + #[serde(default = "default_2519")] pub churn: std::collections::HashMap, - #[serde(default = "default_2514")] + #[serde(default = "default_2520")] pub thresholds: std::collections::HashMap, - #[serde(default = "default_2515")] + #[serde(default = "default_2521")] pub source: String, - #[serde(default = "default_2516")] + #[serde(default = "default_2522")] pub timings_ms: std::collections::HashMap, - #[serde(default = "default_2517")] + #[serde(default = "default_2523")] pub tracker_unavailable: bool, - #[serde(default = "default_2518")] + #[serde(default = "default_2524")] pub rollup: std::collections::HashMap, - #[serde(default = "default_2519")] + #[serde(default = "default_2525")] pub streak: std::collections::HashMap, - #[serde(default = "default_2520")] + #[serde(default = "default_2526")] pub smells: std::collections::HashMap, - #[serde(default = "default_2521")] + #[serde(default = "default_2527")] pub prior: std::collections::HashMap, - #[serde(default = "default_2522")] + #[serde(default = "default_2528")] pub unavailable_reason: String, - #[serde(default = "default_2523")] + #[serde(default = "default_2529")] pub candidates: Vec>, - #[serde(default = "default_2524")] + #[serde(default = "default_2530")] pub candidate_matches: Integer, - #[serde(default = "default_2525")] + #[serde(default = "default_2531")] pub resolved_from: String, } @@ -59112,9 +59350,9 @@ impl TrackerTestSignalInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct UiVitalsOutput { - #[serde(default = "default_2526")] + #[serde(default = "default_2532")] pub recorded: bool, - #[serde(default = "default_2527")] + #[serde(default = "default_2533")] pub route: String, } @@ -59298,7 +59536,7 @@ pub struct WebhookDelivery { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookDeliveriesOutput { - #[serde(default = "default_2528")] + #[serde(default = "default_2534")] pub deliveries: Vec, } @@ -59420,14 +59658,14 @@ pub struct WebhookInfo { pub secret_ref: String, pub events: Vec, pub created_at: String, - #[serde(default = "default_2529")] + #[serde(default = "default_2535")] pub secret_present: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookListOutput { - #[serde(default = "default_2530")] + #[serde(default = "default_2536")] pub webhooks: Vec, } @@ -59609,7 +59847,7 @@ pub struct WorkingMemoryMutationOutput { pub version: Integer, pub char_limit: Integer, pub value_length: Integer, - #[serde(default = "default_2531")] + #[serde(default = "default_2537")] pub fill_ratio: f64, } @@ -59833,15 +60071,15 @@ impl WorkingMemoryDeleteInput { pub struct WorkingMemoryGetOutput { pub found: bool, pub block_key: String, - #[serde(default = "default_2532")] + #[serde(default = "default_2538")] pub content: String, - #[serde(default = "default_2533")] + #[serde(default = "default_2539")] pub char_limit: Integer, - #[serde(default = "default_2534")] + #[serde(default = "default_2540")] pub version: Integer, - #[serde(default = "default_2535")] + #[serde(default = "default_2541")] pub updated_at: Option, - #[serde(default = "default_2536")] + #[serde(default = "default_2542")] pub fill_ratio: f64, } @@ -59952,7 +60190,7 @@ pub struct WorkingMemoryBlock { pub content: String, pub char_limit: Integer, pub version: Integer, - #[serde(default = "default_2537")] + #[serde(default = "default_2543")] pub updated_at: Option, } @@ -59960,7 +60198,7 @@ pub struct WorkingMemoryBlock { #[non_exhaustive] pub struct WorkingMemoryRenderOutput { pub rendered: String, - #[serde(default = "default_2538")] + #[serde(default = "default_2544")] pub blocks: Vec, pub block_count: Integer, pub total_chars: Integer, @@ -60342,181 +60580,181 @@ fn default_3() -> Integer { fn default_4() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_5() -> std::collections::HashMap> { +fn default_5() -> Vec { + serde_json::from_str("[]").expect("schema default") +} +fn default_6() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_6() -> bool { +fn default_7() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_7() -> String { +fn default_8() -> String { serde_json::from_str("\"task\"").expect("schema default") } -fn default_8() -> Integer { +fn default_9() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_9() -> f64 { +fn default_10() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_10() -> Vec { +fn default_11() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_11() -> Integer { +fn default_12() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_12() -> String { +fn default_13() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_13() -> Vec { - serde_json::from_str("[]").expect("schema default") -} fn default_14() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_15() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_15() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_16() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_17() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_17() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_18() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_19() -> Option> { +fn default_19() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_20() -> Option> { +fn default_20() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_21() -> Option { +fn default_21() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_22() -> Option { +fn default_22() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_23() -> Option { +fn default_23() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_24() -> Option { +fn default_24() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_25() -> Option { +fn default_25() -> Option { serde_json::from_str("null").expect("schema default") } fn default_26() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_27() -> Option> { +fn default_27() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_28() -> String { +fn default_28() -> Option> { + serde_json::from_str("null").expect("schema default") +} +fn default_29() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_30() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_29() -> Option { +fn default_31() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_30() -> Vec { +fn default_32() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_31() -> String { +fn default_33() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_32() -> f64 { +fn default_34() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_33() -> f64 { +fn default_35() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_34() -> String { +fn default_36() -> String { serde_json::from_str("\"knowledge\"").expect("schema default") } -fn default_35() -> String { +fn default_37() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_36() -> Integer { +fn default_38() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_37() -> Integer { +fn default_39() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_38() -> f64 { +fn default_40() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_39() -> Integer { +fn default_41() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_40() -> String { +fn default_42() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_41() -> String { +fn default_43() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_42() -> String { +fn default_44() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_43() -> Integer { +fn default_45() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_44() -> String { +fn default_46() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_45() -> String { +fn default_47() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_46() -> Option> { +fn default_48() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_47() -> Vec { +fn default_49() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_48() -> bool { +fn default_50() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_49() -> String { +fn default_51() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_50() -> Vec { +fn default_52() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_51() -> Integer { +fn default_53() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_52() -> bool { +fn default_54() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_53() -> Integer { +fn default_55() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_54() -> Integer { +fn default_56() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_55() -> String { +fn default_57() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_56() -> String { +fn default_58() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_57() -> String { +fn default_59() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_58() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_59() -> Option { +fn default_60() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_60() -> Option { +fn default_61() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_61() -> Option> { +fn default_62() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_62() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_63() -> Option { +fn default_63() -> Option> { serde_json::from_str("null").expect("schema default") } fn default_64() -> Option { @@ -60531,14 +60769,14 @@ fn default_66() -> Option { fn default_67() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_68() -> Option { +fn default_68() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_69() -> f64 { - serde_json::from_str("0.0").expect("schema default") +fn default_69() -> Option { + serde_json::from_str("null").expect("schema default") } -fn default_70() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_70() -> Option { + serde_json::from_str("null").expect("schema default") } fn default_71() -> f64 { serde_json::from_str("0.0").expect("schema default") @@ -60546,216 +60784,216 @@ fn default_71() -> f64 { fn default_72() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_73() -> Vec { +fn default_73() -> f64 { + serde_json::from_str("0.0").expect("schema default") +} +fn default_74() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_75() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_74() -> Vec { +fn default_76() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_75() -> String { +fn default_77() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_76() -> String { +fn default_78() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_77() -> String { +fn default_79() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_78() -> String { +fn default_80() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_79() -> String { +fn default_81() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_80() -> Option { +fn default_82() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_81() -> Option { +fn default_83() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_82() -> u64 { +fn default_84() -> u64 { serde_json::from_str("0").expect("schema default") } -fn default_83() -> String { +fn default_85() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_84() -> String { +fn default_86() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_85() -> String { +fn default_87() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_86() -> bool { +fn default_88() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_87() -> String { +fn default_89() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_88() -> String { +fn default_90() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_89() -> String { +fn default_91() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_90() -> bool { +fn default_92() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_91() -> String { +fn default_93() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_94() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_92() -> String { +fn default_95() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_93() -> String { +fn default_96() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_94() -> bool { +fn default_97() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_95() -> Vec { +fn default_98() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_96() -> std::collections::HashMap { +fn default_99() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_97() -> Option { +fn default_100() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_98() -> String { +fn default_101() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_99() -> String { +fn default_102() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_100() -> Integer { +fn default_103() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_101() -> Integer { +fn default_104() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_102() -> Integer { +fn default_105() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_103() -> Vec { +fn default_106() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_104() -> Vec { +fn default_107() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_105() -> u64 { +fn default_108() -> u64 { serde_json::from_str("0").expect("schema default") } -fn default_106() -> Integer { +fn default_109() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_107() -> String { +fn default_110() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_108() -> Integer { +fn default_111() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_109() -> f64 { +fn default_112() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_110() -> String { +fn default_113() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_111() -> String { +fn default_114() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_112() -> Integer { +fn default_115() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_113() -> Option { +fn default_116() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_114() -> Integer { +fn default_117() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_115() -> Integer { +fn default_118() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_116() -> Integer { +fn default_119() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_117() -> Integer { +fn default_120() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_118() -> Integer { +fn default_121() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_119() -> Integer { +fn default_122() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_120() -> bool { +fn default_123() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_121() -> String { +fn default_124() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_122() -> String { +fn default_125() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_123() -> Vec { +fn default_126() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_124() -> String { +fn default_127() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_125() -> String { +fn default_128() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_126() -> f64 { +fn default_129() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_127() -> String { +fn default_130() -> String { serde_json::from_str("\"abstain\"").expect("schema default") } -fn default_128() -> String { +fn default_131() -> String { serde_json::from_str("\"off\"").expect("schema default") } -fn default_129() -> f64 { +fn default_132() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_130() -> String { +fn default_133() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_131() -> Integer { +fn default_134() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_132() -> bool { +fn default_135() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_133() -> Integer { +fn default_136() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_134() -> String { +fn default_137() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_135() -> std::collections::HashMap { +fn default_138() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_136() -> std::collections::HashMap { +fn default_139() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_137() -> u64 { +fn default_140() -> u64 { serde_json::from_str("0").expect("schema default") } -fn default_138() -> Option> { +fn default_141() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_139() -> bool { +fn default_142() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_140() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_141() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_142() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_143() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -60768,8 +61006,8 @@ fn default_145() -> String { fn default_146() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_147() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_147() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_148() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -60777,8 +61015,8 @@ fn default_148() -> String { fn default_149() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_150() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_150() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_151() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -60786,710 +61024,710 @@ fn default_151() -> String { fn default_152() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_153() -> Option { +fn default_153() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_154() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_155() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_156() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_154() -> f64 { +fn default_157() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_155() -> Vec { +fn default_158() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_156() -> String { +fn default_159() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_157() -> bool { +fn default_160() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_158() -> bool { +fn default_161() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_159() -> Vec { +fn default_162() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_160() -> Integer { +fn default_163() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_161() -> String { +fn default_164() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_162() -> String { +fn default_165() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_163() -> Vec { +fn default_166() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_164() -> Vec { +fn default_167() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_165() -> Vec { +fn default_168() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_166() -> Vec { +fn default_169() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_167() -> String { +fn default_170() -> String { serde_json::from_str("\"consumer\"").expect("schema default") } -fn default_168() -> String { +fn default_171() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_169() -> std::collections::HashMap { +fn default_172() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_170() -> String { +fn default_173() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_171() -> std::collections::HashMap> { +fn default_174() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_172() -> Option { +fn default_175() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_173() -> Option { +fn default_176() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_174() -> Option { +fn default_177() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_175() -> bool { +fn default_178() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_176() -> Integer { +fn default_179() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_177() -> Integer { +fn default_180() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_178() -> f64 { +fn default_181() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_179() -> Option { +fn default_182() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_180() -> bool { +fn default_183() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_181() -> String { +fn default_184() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_182() -> String { +fn default_185() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_183() -> String { +fn default_186() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_184() -> bool { +fn default_187() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_185() -> String { +fn default_188() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_186() -> String { +fn default_189() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_187() -> String { +fn default_190() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_188() -> Vec { +fn default_191() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_189() -> String { +fn default_192() -> String { serde_json::from_str("\"unchecked\"").expect("schema default") } -fn default_190() -> Vec { +fn default_193() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_191() -> Option { +fn default_194() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_192() -> Integer { +fn default_195() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_193() -> bool { +fn default_196() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_194() -> String { +fn default_197() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_195() -> Option { +fn default_198() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_196() -> Option { +fn default_199() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_197() -> String { +fn default_200() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_198() -> String { +fn default_201() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_199() -> f64 { +fn default_202() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_200() -> f64 { +fn default_203() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_201() -> f64 { +fn default_204() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_202() -> f64 { +fn default_205() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_203() -> f64 { +fn default_206() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_204() -> f64 { +fn default_207() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_205() -> Integer { +fn default_208() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_206() -> Integer { +fn default_209() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_207() -> String { +fn default_210() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_208() -> bool { +fn default_211() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_209() -> String { +fn default_212() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_210() -> String { +fn default_213() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_211() -> CodeAskOutputCoverage { +fn default_214() -> CodeAskOutputCoverage { serde_json::from_str("\"\"").expect("schema default") } -fn default_212() -> Vec> { +fn default_215() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_213() -> f64 { +fn default_216() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_214() -> String { +fn default_217() -> String { serde_json::from_str("\"miss\"").expect("schema default") } -fn default_215() -> Integer { +fn default_218() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_216() -> f64 { +fn default_219() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_217() -> bool { +fn default_220() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_218() -> String { +fn default_221() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_219() -> f64 { +fn default_222() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_220() -> Integer { +fn default_223() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_221() -> Integer { +fn default_224() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_222() -> String { +fn default_225() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_223() -> std::collections::HashMap { +fn default_226() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_224() -> Vec> { +fn default_227() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_225() -> String { +fn default_228() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_226() -> Vec { +fn default_229() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_227() -> std::collections::HashMap { +fn default_230() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_228() -> std::collections::HashMap { +fn default_231() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_229() -> Vec> { +fn default_232() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_230() -> Vec { +fn default_233() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_231() -> Vec { +fn default_234() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_232() -> Vec> { +fn default_235() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_233() -> std::collections::HashMap> { +fn default_236() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_234() -> Option> { +fn default_237() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_235() -> String { +fn default_238() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_236() -> bool { +fn default_239() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_237() -> Integer { +fn default_240() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_238() -> std::collections::HashMap { +fn default_241() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_239() -> String { +fn default_242() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_240() -> Vec> { +fn default_243() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_241() -> String { +fn default_244() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_242() -> String { +fn default_245() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_243() -> Vec { +fn default_246() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_244() -> Vec> { +fn default_247() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_245() -> std::collections::HashMap { +fn default_248() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_246() -> std::collections::HashMap> { +fn default_249() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_247() -> Integer { +fn default_250() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_248() -> bool { +fn default_251() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_249() -> String { +fn default_252() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_250() -> std::collections::HashMap { +fn default_253() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_251() -> bool { +fn default_254() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_252() -> Integer { +fn default_255() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_253() -> String { +fn default_256() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_254() -> String { +fn default_257() -> String { serde_json::from_str("\"tracker\"").expect("schema default") } -fn default_255() -> Vec { +fn default_258() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_256() -> String { +fn default_259() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_257() -> Vec> { +fn default_260() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_258() -> std::collections::HashMap { +fn default_261() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_259() -> Vec { +fn default_262() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_260() -> std::collections::HashMap { +fn default_263() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_261() -> std::collections::HashMap { +fn default_264() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_262() -> Vec { +fn default_265() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_263() -> std::collections::HashMap { +fn default_266() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_264() -> String { +fn default_267() -> String { serde_json::from_str("\"file\"").expect("schema default") } -fn default_265() -> Vec { +fn default_268() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_266() -> std::collections::HashMap { +fn default_269() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_267() -> String { +fn default_270() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_268() -> Vec { +fn default_271() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_269() -> Integer { +fn default_272() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_270() -> Vec { +fn default_273() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_271() -> String { +fn default_274() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_272() -> String { +fn default_275() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_273() -> String { +fn default_276() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_274() -> Vec { +fn default_277() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_275() -> Vec> { +fn default_278() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_276() -> Vec { +fn default_279() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_277() -> Vec { +fn default_280() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_278() -> std::collections::HashMap { +fn default_281() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_279() -> String { +fn default_282() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_280() -> Option> { +fn default_283() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_281() -> String { +fn default_284() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_282() -> bool { +fn default_285() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_283() -> String { +fn default_286() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_284() -> bool { +fn default_287() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_285() -> String { +fn default_288() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_286() -> String { +fn default_289() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_287() -> String { +fn default_290() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_288() -> String { +fn default_291() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_289() -> Vec { +fn default_292() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_290() -> String { +fn default_293() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_291() -> CodeBlameRangeOutputStage { +fn default_294() -> CodeBlameRangeOutputStage { serde_json::from_str("\"last_touched\"").expect("schema default") } -fn default_292() -> String { +fn default_295() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_293() -> String { +fn default_296() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_294() -> bool { +fn default_297() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_295() -> std::collections::HashMap { +fn default_298() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_296() -> std::collections::HashMap { +fn default_299() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_297() -> Vec> { +fn default_300() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_298() -> Vec> { +fn default_301() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_299() -> std::collections::HashMap { +fn default_302() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_300() -> Integer { +fn default_303() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_301() -> std::collections::HashMap { +fn default_304() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_302() -> std::collections::HashMap { +fn default_305() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_303() -> String { +fn default_306() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_304() -> String { +fn default_307() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_305() -> bool { +fn default_308() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_306() -> String { +fn default_309() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_307() -> Vec> { +fn default_310() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_308() -> Integer { +fn default_311() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_309() -> String { +fn default_312() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_310() -> String { +fn default_313() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_311() -> bool { +fn default_314() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_312() -> String { +fn default_315() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_313() -> Integer { +fn default_316() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_314() -> String { +fn default_317() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_315() -> String { +fn default_318() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_316() -> bool { +fn default_319() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_317() -> Vec { +fn default_320() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_318() -> Vec> { +fn default_321() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_319() -> String { +fn default_322() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_320() -> bool { +fn default_323() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_321() -> bool { +fn default_324() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_322() -> Integer { +fn default_325() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_323() -> Integer { +fn default_326() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_324() -> String { +fn default_327() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_325() -> Vec { +fn default_328() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_326() -> std::collections::HashMap { +fn default_329() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_327() -> String { +fn default_330() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_328() -> Integer { +fn default_331() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_329() -> Integer { +fn default_332() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_330() -> bool { +fn default_333() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_331() -> bool { +fn default_334() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_332() -> std::collections::HashMap { +fn default_335() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_333() -> String { +fn default_336() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_334() -> String { +fn default_337() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_335() -> Integer { +fn default_338() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_336() -> Vec { +fn default_339() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_337() -> String { +fn default_340() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_338() -> Option { +fn default_341() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_339() -> String { +fn default_342() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_340() -> Vec> { +fn default_343() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_341() -> Integer { +fn default_344() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_342() -> bool { +fn default_345() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_343() -> String { +fn default_346() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_344() -> String { +fn default_347() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_345() -> String { +fn default_348() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_346() -> Integer { +fn default_349() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_347() -> String { +fn default_350() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_348() -> String { +fn default_351() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_349() -> String { +fn default_352() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_350() -> String { +fn default_353() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_351() -> Integer { +fn default_354() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_352() -> Integer { +fn default_355() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_353() -> String { +fn default_356() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_354() -> String { +fn default_357() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_355() -> Vec { +fn default_358() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_356() -> String { +fn default_359() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_357() -> String { +fn default_360() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_358() -> String { +fn default_361() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_359() -> String { +fn default_362() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_360() -> String { +fn default_363() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_361() -> Integer { +fn default_364() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_362() -> Integer { +fn default_365() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_363() -> Integer { +fn default_366() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_364() -> bool { +fn default_367() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_365() -> Vec> { +fn default_368() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_366() -> std::collections::HashMap { +fn default_369() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_367() -> std::collections::HashMap { +fn default_370() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_368() -> Vec { +fn default_371() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_369() -> String { +fn default_372() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_370() -> String { +fn default_373() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_371() -> Integer { +fn default_374() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_372() -> Integer { +fn default_375() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_373() -> String { +fn default_376() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_374() -> String { +fn default_377() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_375() -> Integer { - serde_json::from_str("0").expect("schema default") -} -fn default_376() -> Integer { +fn default_378() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_377() -> Integer { +fn default_379() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_378() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_379() -> Integer { +fn default_380() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_380() -> String { +fn default_381() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_381() -> Integer { +fn default_382() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_382() -> String { +fn default_383() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_383() -> Integer { +fn default_384() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_384() -> String { +fn default_385() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_385() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_386() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_387() -> f64 { - serde_json::from_str("0.0").expect("schema default") +fn default_387() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_388() -> Integer { serde_json::from_str("0").expect("schema default") @@ -61509,1523 +61747,1523 @@ fn default_392() -> Integer { fn default_393() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_394() -> Option { +fn default_394() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_395() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_396() -> f64 { + serde_json::from_str("0.0").expect("schema default") +} +fn default_397() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_395() -> String { +fn default_398() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_396() -> String { +fn default_399() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_397() -> String { +fn default_400() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_398() -> bool { +fn default_401() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_399() -> String { +fn default_402() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_400() -> String { +fn default_403() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_401() -> String { +fn default_404() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_402() -> bool { +fn default_405() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_403() -> bool { +fn default_406() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_404() -> Option { +fn default_407() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_405() -> String { +fn default_408() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_406() -> bool { +fn default_409() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_407() -> Option { +fn default_410() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_408() -> String { +fn default_411() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_409() -> String { +fn default_412() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_410() -> String { +fn default_413() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_411() -> String { +fn default_414() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_412() -> Option { +fn default_415() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_413() -> Integer { +fn default_416() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_414() -> Vec { +fn default_417() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_415() -> bool { +fn default_418() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_416() -> Vec { +fn default_419() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_417() -> Integer { +fn default_420() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_418() -> Vec { +fn default_421() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_419() -> Integer { +fn default_422() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_420() -> bool { +fn default_423() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_421() -> Vec { +fn default_424() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_422() -> Option { +fn default_425() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_423() -> String { +fn default_426() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_424() -> String { +fn default_427() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_425() -> String { +fn default_428() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_426() -> Vec> { +fn default_429() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_427() -> Integer { +fn default_430() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_428() -> Vec { +fn default_431() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_429() -> String { +fn default_432() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_430() -> String { +fn default_433() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_431() -> std::collections::HashMap { +fn default_434() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_432() -> String { +fn default_435() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_433() -> std::collections::HashMap { +fn default_436() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_434() -> std::collections::HashMap { +fn default_437() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_435() -> String { +fn default_438() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_436() -> String { +fn default_439() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_437() -> Integer { +fn default_440() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_438() -> Integer { +fn default_441() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_439() -> String { +fn default_442() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_440() -> String { +fn default_443() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_441() -> String { +fn default_444() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_442() -> String { +fn default_445() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_443() -> bool { +fn default_446() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_444() -> String { +fn default_447() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_445() -> String { +fn default_448() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_446() -> String { +fn default_449() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_447() -> f64 { +fn default_450() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_448() -> Vec> { +fn default_451() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_449() -> Vec> { +fn default_452() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_450() -> Vec> { +fn default_453() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_451() -> bool { +fn default_454() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_452() -> Integer { +fn default_455() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_453() -> Integer { +fn default_456() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_454() -> bool { +fn default_457() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_455() -> Vec> { +fn default_458() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_456() -> String { +fn default_459() -> String { serde_json::from_str("\"unit\"").expect("schema default") } -fn default_457() -> String { +fn default_460() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_458() -> Vec> { +fn default_461() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_459() -> Integer { +fn default_462() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_460() -> String { +fn default_463() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_461() -> Integer { +fn default_464() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_462() -> Integer { +fn default_465() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_463() -> String { +fn default_466() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_464() -> Integer { +fn default_467() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_465() -> bool { +fn default_468() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_466() -> std::collections::HashMap>> +fn default_469() -> std::collections::HashMap>> { serde_json::from_str("{}").expect("schema default") } -fn default_467() -> Vec> { +fn default_470() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_468() -> Integer { +fn default_471() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_469() -> String { +fn default_472() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_470() -> CodeSymbolOutputUses { +fn default_473() -> CodeSymbolOutputUses { serde_json::from_str("[]").expect("schema default") } -fn default_471() -> bool { +fn default_474() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_472() -> Integer { +fn default_475() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_473() -> String { +fn default_476() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_474() -> String { +fn default_477() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_475() -> Vec> { +fn default_478() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_476() -> Vec> { +fn default_479() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_477() -> Integer { +fn default_480() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_478() -> Integer { +fn default_481() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_479() -> Vec> { +fn default_482() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_480() -> std::collections::HashMap> { +fn default_483() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_481() -> Vec { +fn default_484() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_482() -> Vec> { +fn default_485() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_483() -> String { +fn default_486() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_484() -> Vec> { +fn default_487() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_485() -> std::collections::HashMap>> +fn default_488() -> std::collections::HashMap>> { serde_json::from_str("{}").expect("schema default") } -fn default_486() -> Vec> { +fn default_489() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_487() -> String { +fn default_490() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_488() -> Vec { +fn default_491() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_489() -> Vec> { +fn default_492() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_490() -> Integer { +fn default_493() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_491() -> std::collections::HashMap { +fn default_494() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_492() -> Integer { +fn default_495() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_493() -> Integer { +fn default_496() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_494() -> Integer { +fn default_497() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_495() -> Vec> { +fn default_498() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_496() -> Integer { +fn default_499() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_497() -> bool { +fn default_500() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_498() -> Integer { +fn default_501() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_499() -> String { +fn default_502() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_500() -> Vec> { +fn default_503() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_501() -> Integer { +fn default_504() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_502() -> bool { +fn default_505() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_503() -> std::collections::HashMap { +fn default_506() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_504() -> bool { +fn default_507() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_505() -> String { +fn default_508() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_506() -> String { +fn default_509() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_507() -> String { +fn default_510() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_508() -> Vec { +fn default_511() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_509() -> String { +fn default_512() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_510() -> String { +fn default_513() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_511() -> Integer { +fn default_514() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_512() -> String { +fn default_515() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_513() -> String { +fn default_516() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_514() -> bool { +fn default_517() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_515() -> bool { +fn default_518() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_516() -> std::collections::HashMap { +fn default_519() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_517() -> Option { +fn default_520() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_518() -> Integer { +fn default_521() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_519() -> Integer { +fn default_522() -> Integer { serde_json::from_str("72").expect("schema default") } -fn default_520() -> Integer { +fn default_523() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_521() -> Integer { +fn default_524() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_522() -> Vec> { +fn default_525() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_523() -> Vec { +fn default_526() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_524() -> Vec { +fn default_527() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_525() -> String { +fn default_528() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_526() -> String { +fn default_529() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_527() -> String { +fn default_530() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_528() -> bool { +fn default_531() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_529() -> String { +fn default_532() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_530() -> Vec> { +fn default_533() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_531() -> Integer { +fn default_534() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_532() -> Vec> { +fn default_535() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_533() -> bool { +fn default_536() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_534() -> Vec> { +fn default_537() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_535() -> bool { +fn default_538() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_536() -> String { +fn default_539() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_537() -> bool { +fn default_540() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_538() -> Vec { +fn default_541() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_539() -> Option { +fn default_542() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_540() -> Vec> { +fn default_543() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_541() -> bool { +fn default_544() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_542() -> Vec> { +fn default_545() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_543() -> bool { +fn default_546() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_544() -> String { +fn default_547() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_545() -> String { +fn default_548() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_546() -> bool { +fn default_549() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_547() -> Vec> { +fn default_550() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_548() -> Integer { +fn default_551() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_549() -> bool { +fn default_552() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_550() -> bool { +fn default_553() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_551() -> std::collections::HashMap { +fn default_554() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_552() -> bool { +fn default_555() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_553() -> Vec> { +fn default_556() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_554() -> Integer { +fn default_557() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_555() -> bool { +fn default_558() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_556() -> Integer { +fn default_559() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_557() -> String { +fn default_560() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_558() -> String { +fn default_561() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_559() -> String { +fn default_562() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_560() -> String { +fn default_563() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_561() -> f64 { +fn default_564() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_562() -> Vec> { +fn default_565() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_563() -> std::collections::HashMap> { +fn default_566() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_564() -> String { +fn default_567() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_565() -> bool { +fn default_568() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_566() -> String { +fn default_569() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_567() -> CodeGrepOutputFallback { +fn default_570() -> CodeGrepOutputFallback { serde_json::from_str("\"\"").expect("schema default") } -fn default_568() -> Vec> { +fn default_571() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_569() -> String { +fn default_572() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_570() -> Vec> { +fn default_573() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_571() -> Integer { +fn default_574() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_572() -> f64 { +fn default_575() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_573() -> Vec> { +fn default_576() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_574() -> Vec> { +fn default_577() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_575() -> Vec> { +fn default_578() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_576() -> Vec> { +fn default_579() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_577() -> bool { +fn default_580() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_578() -> Integer { +fn default_581() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_579() -> Integer { +fn default_582() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_580() -> String { +fn default_583() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_581() -> Vec { +fn default_584() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_582() -> std::collections::HashMap { +fn default_585() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_583() -> bool { +fn default_586() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_584() -> String { +fn default_587() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_585() -> String { +fn default_588() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_586() -> Vec> { +fn default_589() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_587() -> bool { +fn default_590() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_588() -> String { +fn default_591() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_589() -> Integer { +fn default_592() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_590() -> String { +fn default_593() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_591() -> String { +fn default_594() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_592() -> String { +fn default_595() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_593() -> String { +fn default_596() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_594() -> String { +fn default_597() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_595() -> Integer { +fn default_598() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_596() -> String { +fn default_599() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_597() -> String { +fn default_600() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_598() -> String { +fn default_601() -> String { serde_json::from_str("\"generic\"").expect("schema default") } -fn default_599() -> Vec { +fn default_602() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_600() -> Vec { +fn default_603() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_601() -> String { +fn default_604() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_602() -> String { +fn default_605() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_603() -> String { +fn default_606() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_604() -> String { +fn default_607() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_605() -> String { +fn default_608() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_606() -> Integer { +fn default_609() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_607() -> String { +fn default_610() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_608() -> bool { +fn default_611() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_609() -> Vec { +fn default_612() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_610() -> String { +fn default_613() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_611() -> Vec { +fn default_614() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_612() -> String { +fn default_615() -> String { serde_json::from_str("\"ok\"").expect("schema default") } -fn default_613() -> String { +fn default_616() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_614() -> String { +fn default_617() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_615() -> String { +fn default_618() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_616() -> String { +fn default_619() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_617() -> String { +fn default_620() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_618() -> Integer { +fn default_621() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_619() -> String { +fn default_622() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_620() -> Integer { +fn default_623() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_621() -> Vec { +fn default_624() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_622() -> String { +fn default_625() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_623() -> Option { +fn default_626() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_624() -> String { +fn default_627() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_625() -> String { +fn default_628() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_626() -> bool { +fn default_629() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_627() -> Integer { +fn default_630() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_628() -> Integer { +fn default_631() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_629() -> Integer { +fn default_632() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_630() -> String { +fn default_633() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_631() -> String { +fn default_634() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_632() -> bool { +fn default_635() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_633() -> Vec { +fn default_636() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_634() -> std::collections::HashMap { +fn default_637() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_635() -> std::collections::HashMap> { +fn default_638() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_636() -> bool { +fn default_639() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_637() -> Integer { +fn default_640() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_638() -> String { +fn default_641() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_639() -> Integer { +fn default_642() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_640() -> Integer { +fn default_643() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_641() -> Integer { +fn default_644() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_642() -> String { +fn default_645() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_643() -> std::collections::HashMap { +fn default_646() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_644() -> String { +fn default_647() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_645() -> Vec { +fn default_648() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_646() -> std::collections::HashMap> { +fn default_649() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_647() -> std::collections::HashMap { +fn default_650() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_648() -> std::collections::HashMap> { +fn default_651() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_649() -> std::collections::HashMap> { +fn default_652() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_650() -> Integer { +fn default_653() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_651() -> String { +fn default_654() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_652() -> Integer { +fn default_655() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_653() -> String { +fn default_656() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_654() -> Integer { +fn default_657() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_655() -> Integer { +fn default_658() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_656() -> f64 { +fn default_659() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_657() -> String { +fn default_660() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_658() -> String { +fn default_661() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_659() -> Vec> { +fn default_662() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_660() -> Integer { +fn default_663() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_661() -> String { +fn default_664() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_662() -> bool { +fn default_665() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_663() -> String { +fn default_666() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_664() -> Integer { +fn default_667() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_665() -> Integer { +fn default_668() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_666() -> String { +fn default_669() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_667() -> bool { +fn default_670() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_668() -> std::collections::HashMap { +fn default_671() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_669() -> String { +fn default_672() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_670() -> Vec { +fn default_673() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_671() -> CodePathGuardsOutputEpistemic { +fn default_674() -> CodePathGuardsOutputEpistemic { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_672() -> String { +fn default_675() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_673() -> Vec> { +fn default_676() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_674() -> Vec { +fn default_677() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_675() -> Integer { +fn default_678() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_676() -> String { +fn default_679() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_677() -> String { +fn default_680() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_678() -> Vec> { +fn default_681() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_679() -> bool { +fn default_682() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_680() -> String { +fn default_683() -> String { serde_json::from_str("\"heuristic\"").expect("schema default") } -fn default_681() -> std::collections::HashMap { +fn default_684() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_682() -> std::collections::HashMap { +fn default_685() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_683() -> std::collections::HashMap { +fn default_686() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_684() -> String { +fn default_687() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_685() -> Vec> { +fn default_688() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_686() -> Integer { +fn default_689() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_687() -> String { +fn default_690() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_688() -> Vec { +fn default_691() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_689() -> String { +fn default_692() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_690() -> String { +fn default_693() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_691() -> String { +fn default_694() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_692() -> Integer { +fn default_695() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_693() -> Integer { +fn default_696() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_694() -> bool { +fn default_697() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_695() -> String { +fn default_698() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_696() -> String { +fn default_699() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_697() -> String { +fn default_700() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_698() -> String { +fn default_701() -> String { serde_json::from_str("\"git\"").expect("schema default") } -fn default_699() -> String { +fn default_702() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_700() -> String { +fn default_703() -> String { serde_json::from_str("\"admin\"").expect("schema default") } -fn default_701() -> String { +fn default_704() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_702() -> Vec> { +fn default_705() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_703() -> Vec> { +fn default_706() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_704() -> String { +fn default_707() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_705() -> String { +fn default_708() -> String { serde_json::from_str("\"git\"").expect("schema default") } -fn default_706() -> Vec { +fn default_709() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_707() -> String { +fn default_710() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_708() -> Vec> { +fn default_711() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_709() -> Vec { +fn default_712() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_710() -> Vec> { +fn default_713() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_711() -> Integer { +fn default_714() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_712() -> Integer { +fn default_715() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_713() -> Integer { +fn default_716() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_714() -> bool { +fn default_717() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_715() -> String { +fn default_718() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_716() -> String { +fn default_719() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_717() -> bool { +fn default_720() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_718() -> Vec { +fn default_721() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_719() -> Vec { +fn default_722() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_720() -> Vec { +fn default_723() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_721() -> Vec { +fn default_724() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_722() -> String { +fn default_725() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_723() -> Integer { +fn default_726() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_724() -> String { +fn default_727() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_725() -> CodeReviewBriefOutputSource { +fn default_728() -> CodeReviewBriefOutputSource { serde_json::from_str("\"missing\"").expect("schema default") } -fn default_726() -> CodeReviewBriefOutputLedger { +fn default_729() -> CodeReviewBriefOutputLedger { serde_json::from_str("\"\"").expect("schema default") } -fn default_727() -> bool { +fn default_730() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_728() -> std::collections::HashMap { +fn default_731() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_729() -> bool { +fn default_732() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_730() -> String { +fn default_733() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_731() -> Integer { +fn default_734() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_732() -> String { +fn default_735() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_733() -> String { +fn default_736() -> String { serde_json::from_str("\"standard\"").expect("schema default") } -fn default_734() -> String { +fn default_737() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_735() -> String { +fn default_738() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_736() -> Integer { +fn default_739() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_737() -> Integer { +fn default_740() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_738() -> Integer { +fn default_741() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_739() -> std::collections::HashMap { +fn default_742() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_740() -> std::collections::HashMap> { +fn default_743() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_741() -> String { +fn default_744() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_742() -> String { +fn default_745() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_743() -> String { +fn default_746() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_744() -> String { +fn default_747() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_745() -> Vec> { +fn default_748() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_746() -> Integer { +fn default_749() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_747() -> String { +fn default_750() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_748() -> bool { +fn default_751() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_749() -> std::collections::HashMap { +fn default_752() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_750() -> bool { +fn default_753() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_751() -> CodeSearchOutputAbstainCode { +fn default_754() -> CodeSearchOutputAbstainCode { serde_json::from_str("\"\"").expect("schema default") } -fn default_752() -> String { +fn default_755() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_753() -> CodeSearchOutputRetrievalRisk { +fn default_756() -> CodeSearchOutputRetrievalRisk { serde_json::from_str("\"low\"").expect("schema default") } -fn default_754() -> f64 { +fn default_757() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_755() -> f64 { +fn default_758() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_756() -> String { +fn default_759() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_757() -> Integer { +fn default_760() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_758() -> bool { +fn default_761() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_759() -> Integer { +fn default_762() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_760() -> std::collections::HashMap { +fn default_763() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_761() -> String { +fn default_764() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_762() -> std::collections::HashMap { +fn default_765() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_763() -> String { +fn default_766() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_764() -> f64 { +fn default_767() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_765() -> std::collections::HashMap { +fn default_768() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_766() -> std::collections::HashMap { +fn default_769() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_767() -> String { +fn default_770() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_768() -> Vec { +fn default_771() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_769() -> CodeSearchOutputEpistemic { +fn default_772() -> CodeSearchOutputEpistemic { serde_json::from_str("\"\"").expect("schema default") } -fn default_770() -> bool { +fn default_773() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_771() -> String { +fn default_774() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_772() -> String { +fn default_775() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_773() -> Vec { +fn default_776() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_774() -> std::collections::HashMap { +fn default_777() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_775() -> String { +fn default_778() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_776() -> Vec> { +fn default_779() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_777() -> std::collections::HashMap { +fn default_780() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_778() -> Integer { +fn default_781() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_779() -> std::collections::HashMap { +fn default_782() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_780() -> String { +fn default_783() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_781() -> String { +fn default_784() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_782() -> Vec { +fn default_785() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_783() -> String { +fn default_786() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_784() -> std::collections::HashMap { +fn default_787() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_785() -> bool { +fn default_788() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_786() -> Vec { +fn default_789() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_787() -> Vec> { +fn default_790() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_788() -> Vec> { +fn default_791() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_789() -> Vec> { +fn default_792() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_790() -> std::collections::HashMap { +fn default_793() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_791() -> String { +fn default_794() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_792() -> bool { +fn default_795() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_793() -> String { +fn default_796() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_794() -> Vec> { +fn default_797() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_795() -> Vec> { +fn default_798() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_796() -> Vec { +fn default_799() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_797() -> Vec> { +fn default_800() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_798() -> bool { +fn default_801() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_799() -> Integer { +fn default_802() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_800() -> Integer { +fn default_803() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_801() -> bool { +fn default_804() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_802() -> bool { +fn default_805() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_803() -> bool { +fn default_806() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_804() -> String { +fn default_807() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_805() -> Vec { +fn default_808() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_806() -> std::collections::HashMap { +fn default_809() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_807() -> String { +fn default_810() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_808() -> String { +fn default_811() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_809() -> String { +fn default_812() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_810() -> Vec> { +fn default_813() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_811() -> Vec { +fn default_814() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_812() -> Vec { +fn default_815() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_813() -> Integer { +fn default_816() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_814() -> std::collections::HashMap { +fn default_817() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_815() -> String { +fn default_818() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_816() -> Vec> { +fn default_819() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_817() -> Integer { +fn default_820() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_818() -> bool { +fn default_821() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_819() -> Vec> { +fn default_822() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_820() -> String { +fn default_823() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_821() -> bool { +fn default_824() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_822() -> Vec { +fn default_825() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_823() -> std::collections::HashMap { +fn default_826() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_824() -> Integer { +fn default_827() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_825() -> Integer { +fn default_828() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_826() -> String { +fn default_829() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_827() -> Integer { +fn default_830() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_828() -> String { +fn default_831() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_829() -> String { +fn default_832() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_830() -> Vec> { +fn default_833() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_831() -> std::collections::HashMap { +fn default_834() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_832() -> String { +fn default_835() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_833() -> String { +fn default_836() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_834() -> std::collections::HashMap { +fn default_837() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_835() -> Vec> { +fn default_838() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_836() -> Vec> { +fn default_839() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_837() -> bool { +fn default_840() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_838() -> std::collections::HashMap { +fn default_841() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_839() -> std::collections::HashMap { +fn default_842() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_840() -> std::collections::HashMap { +fn default_843() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_841() -> Vec { +fn default_844() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_842() -> Integer { +fn default_845() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_843() -> std::collections::HashMap { +fn default_846() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_844() -> String { +fn default_847() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_845() -> String { +fn default_848() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_846() -> String { +fn default_849() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_847() -> String { +fn default_850() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_848() -> String { +fn default_851() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_849() -> String { +fn default_852() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_850() -> String { +fn default_853() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_851() -> Option { +fn default_854() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_852() -> Option { +fn default_855() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_853() -> Option { +fn default_856() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_854() -> Option { +fn default_857() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_855() -> Option> { +fn default_858() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_856() -> Vec { +fn default_859() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_857() -> String { +fn default_860() -> String { serde_json::from_str("\"conflicts.resolve\"").expect("schema default") } -fn default_858() -> Vec { +fn default_861() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_859() -> String { +fn default_862() -> String { serde_json::from_str("\"No changes were applied.\"").expect("schema default") } -fn default_860() -> Option { +fn default_863() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_861() -> Option { +fn default_864() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_862() -> Option { +fn default_865() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_863() -> Vec { +fn default_866() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_864() -> String { +fn default_867() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_865() -> String { +fn default_868() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_866() -> String { +fn default_869() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_867() -> Integer { +fn default_870() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_868() -> Integer { +fn default_871() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_869() -> Integer { +fn default_872() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_870() -> Integer { +fn default_873() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_871() -> Integer { +fn default_874() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_872() -> Option { +fn default_875() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_873() -> bool { +fn default_876() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_874() -> ConversationAppendOutputReason { +fn default_877() -> ConversationAppendOutputReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_875() -> String { +fn default_878() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_876() -> Integer { +fn default_879() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_877() -> Integer { +fn default_880() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_878() -> String { +fn default_881() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_879() -> String { +fn default_882() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_880() -> std::collections::HashMap { +fn default_883() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_881() -> String { +fn default_884() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_882() -> String { +fn default_885() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_883() -> String { +fn default_886() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_884() -> Option { +fn default_887() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_885() -> Option { +fn default_888() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_886() -> Integer { +fn default_889() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_887() -> String { +fn default_890() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_888() -> Vec { +fn default_891() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_889() -> Option { +fn default_892() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_890() -> Option { +fn default_893() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_891() -> Option { +fn default_894() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_892() -> ConversationSaveMessageOutputReason { +fn default_895() -> ConversationSaveMessageOutputReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_893() -> String { +fn default_896() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_894() -> Vec { +fn default_897() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_895() -> bool { +fn default_898() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_896() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_897() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_898() -> Option { - serde_json::from_str("null").expect("schema default") -} fn default_899() -> Option { serde_json::from_str("null").expect("schema default") } @@ -63041,32 +63279,32 @@ fn default_902() -> Option { fn default_903() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_904() -> Option { +fn default_904() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_905() -> Option { +fn default_905() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_906() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_906() -> Option { + serde_json::from_str("null").expect("schema default") } -fn default_907() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_907() -> Option { + serde_json::from_str("null").expect("schema default") } -fn default_908() -> f64 { - serde_json::from_str("0.0").expect("schema default") +fn default_908() -> Option { + serde_json::from_str("null").expect("schema default") } fn default_909() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_910() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_910() -> Vec { + serde_json::from_str("[]").expect("schema default") } -fn default_911() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_911() -> f64 { + serde_json::from_str("0.0").expect("schema default") } -fn default_912() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_912() -> Integer { + serde_json::from_str("0").expect("schema default") } fn default_913() -> Option { serde_json::from_str("null").expect("schema default") @@ -63089,648 +63327,648 @@ fn default_918() -> Option { fn default_919() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_920() -> Integer { +fn default_920() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_921() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_922() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_923() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_921() -> f64 { +fn default_924() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_922() -> Integer { +fn default_925() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_923() -> f64 { +fn default_926() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_924() -> String { +fn default_927() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_925() -> String { +fn default_928() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_926() -> String { +fn default_929() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_927() -> String { +fn default_930() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_928() -> Vec { +fn default_931() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_929() -> Option { +fn default_932() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_930() -> String { +fn default_933() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_931() -> String { +fn default_934() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_932() -> String { +fn default_935() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_933() -> Option { +fn default_936() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_934() -> String { +fn default_937() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_935() -> DecisionRowStage { +fn default_938() -> DecisionRowStage { serde_json::from_str("\"decided\"").expect("schema default") } -fn default_936() -> f64 { +fn default_939() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_937() -> Option { +fn default_940() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_938() -> Option { +fn default_941() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_939() -> Integer { +fn default_942() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_940() -> String { +fn default_943() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_941() -> bool { +fn default_944() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_942() -> Integer { +fn default_945() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_943() -> String { +fn default_946() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_944() -> bool { +fn default_947() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_945() -> Option { +fn default_948() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_946() -> String { +fn default_949() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_947() -> Integer { +fn default_950() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_948() -> Integer { +fn default_951() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_949() -> Integer { +fn default_952() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_950() -> Option { +fn default_953() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_951() -> String { +fn default_954() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_952() -> Option { +fn default_955() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_953() -> Integer { +fn default_956() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_954() -> std::collections::HashMap { +fn default_957() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_955() -> Option { +fn default_958() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_956() -> Option> { +fn default_959() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_957() -> bool { +fn default_960() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_958() -> String { +fn default_961() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_959() -> Vec { +fn default_962() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_960() -> Option { +fn default_963() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_961() -> Option { +fn default_964() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_962() -> Option { +fn default_965() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_963() -> Option { +fn default_966() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_964() -> Option { +fn default_967() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_965() -> Option { +fn default_968() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_966() -> Option { +fn default_969() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_967() -> Option { +fn default_970() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_968() -> Option { +fn default_971() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_969() -> Integer { +fn default_972() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_970() -> std::collections::HashMap { +fn default_973() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_971() -> Option { +fn default_974() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_972() -> Option> { +fn default_975() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_973() -> bool { +fn default_976() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_974() -> String { +fn default_977() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_975() -> String { +fn default_978() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_976() -> String { +fn default_979() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_977() -> Option { +fn default_980() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_978() -> String { +fn default_981() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_979() -> String { +fn default_982() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_980() -> Option { +fn default_983() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_981() -> Vec { +fn default_984() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_982() -> String { +fn default_985() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_983() -> Vec { +fn default_986() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_984() -> Vec { +fn default_987() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_985() -> bool { +fn default_988() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_986() -> bool { +fn default_989() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_987() -> String { +fn default_990() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_988() -> String { +fn default_991() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_989() -> Option { +fn default_992() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_990() -> Option { +fn default_993() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_991() -> Option { +fn default_994() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_992() -> bool { +fn default_995() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_993() -> Integer { +fn default_996() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_994() -> String { +fn default_997() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_995() -> String { +fn default_998() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_996() -> String { +fn default_999() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_997() -> String { +fn default_1000() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_998() -> String { +fn default_1001() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_999() -> Option { +fn default_1002() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1000() -> Vec { +fn default_1003() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1001() -> bool { +fn default_1004() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1002() -> Vec { +fn default_1005() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1003() -> Option { +fn default_1006() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1004() -> Option { +fn default_1007() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1005() -> bool { +fn default_1008() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1006() -> String { +fn default_1009() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_1007() -> Option { +fn default_1010() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1008() -> Option { +fn default_1011() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1009() -> Option { +fn default_1012() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1010() -> String { +fn default_1013() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1011() -> String { +fn default_1014() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1012() -> String { +fn default_1015() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1013() -> HelpGetOutputAudience { +fn default_1016() -> HelpGetOutputAudience { serde_json::from_str("\"user\"").expect("schema default") } -fn default_1014() -> String { +fn default_1017() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1015() -> bool { +fn default_1018() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1016() -> Integer { +fn default_1019() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1017() -> String { +fn default_1020() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1018() -> Vec { +fn default_1021() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1019() -> String { +fn default_1022() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1020() -> Vec { +fn default_1023() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1021() -> Vec { +fn default_1024() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1022() -> String { +fn default_1025() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1023() -> String { +fn default_1026() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1024() -> String { +fn default_1027() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1025() -> Vec { +fn default_1028() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1026() -> String { +fn default_1029() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1027() -> bool { +fn default_1030() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1028() -> Vec { +fn default_1031() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1029() -> Vec { +fn default_1032() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1030() -> Option { +fn default_1033() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1031() -> bool { +fn default_1034() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1032() -> bool { +fn default_1035() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1033() -> Vec { +fn default_1036() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1034() -> Vec> { +fn default_1037() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1035() -> Integer { +fn default_1038() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1036() -> bool { +fn default_1039() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1037() -> String { +fn default_1040() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1038() -> String { +fn default_1041() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1039() -> Integer { +fn default_1042() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1040() -> Integer { +fn default_1043() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1041() -> Vec { +fn default_1044() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1042() -> Integer { +fn default_1045() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1043() -> Vec { +fn default_1046() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1044() -> bool { +fn default_1047() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1045() -> String { +fn default_1048() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1046() -> Option { +fn default_1049() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1047() -> Option { +fn default_1050() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1048() -> Vec> { +fn default_1051() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1049() -> Option { +fn default_1052() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1050() -> bool { +fn default_1053() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1051() -> Integer { +fn default_1054() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1052() -> Vec { +fn default_1055() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1053() -> Vec> { +fn default_1056() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1054() -> Vec { +fn default_1057() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1055() -> Vec> { +fn default_1058() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1056() -> Vec { +fn default_1059() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1057() -> String { +fn default_1060() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1058() -> Vec { +fn default_1061() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1059() -> Vec { +fn default_1062() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1060() -> Option { +fn default_1063() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1061() -> Vec { +fn default_1064() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1062() -> Integer { +fn default_1065() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1063() -> Vec { +fn default_1066() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1064() -> String { +fn default_1067() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1065() -> Vec { +fn default_1068() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1066() -> Vec { +fn default_1069() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1067() -> Option { +fn default_1070() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1068() -> Option { +fn default_1071() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1069() -> bool { +fn default_1072() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1070() -> String { +fn default_1073() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1071() -> String { +fn default_1074() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1072() -> bool { +fn default_1075() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1073() -> String { +fn default_1076() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1074() -> String { +fn default_1077() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1075() -> String { +fn default_1078() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1076() -> Integer { +fn default_1079() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1077() -> String { +fn default_1080() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1078() -> String { +fn default_1081() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1079() -> String { +fn default_1082() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1080() -> Option> { +fn default_1083() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_1081() -> Vec { +fn default_1084() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1082() -> Integer { +fn default_1085() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1083() -> Integer { +fn default_1086() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1084() -> Option { +fn default_1087() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1085() -> String { +fn default_1088() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1086() -> String { +fn default_1089() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1087() -> bool { +fn default_1090() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1088() -> Option { +fn default_1091() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1089() -> Option { +fn default_1092() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1090() -> Option { +fn default_1093() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1091() -> Option { +fn default_1094() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1092() -> Option { +fn default_1095() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1093() -> Vec { +fn default_1096() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1094() -> Vec { +fn default_1097() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1095() -> Option { +fn default_1098() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1096() -> Option { +fn default_1099() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1097() -> Option { +fn default_1100() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1098() -> String { +fn default_1101() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1099() -> Option { +fn default_1102() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1100() -> Option { +fn default_1103() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1101() -> Option { +fn default_1104() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1102() -> Vec { +fn default_1105() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1103() -> Vec { +fn default_1106() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1104() -> Option { +fn default_1107() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1105() -> String { +fn default_1108() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1106() -> Option { +fn default_1109() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1107() -> Vec { +fn default_1110() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1108() -> Option { +fn default_1111() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1109() -> Option { +fn default_1112() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1110() -> Option { +fn default_1113() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1111() -> String { +fn default_1114() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1112() -> Option { +fn default_1115() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1113() -> Option { +fn default_1116() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1114() -> bool { +fn default_1117() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1115() -> bool { +fn default_1118() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1116() -> Option { +fn default_1119() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1117() -> Vec { +fn default_1120() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1118() -> bool { +fn default_1121() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1119() -> Option { +fn default_1122() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1120() -> Option { +fn default_1123() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1121() -> Vec { +fn default_1124() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1122() -> String { +fn default_1125() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1123() -> String { +fn default_1126() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1124() -> Vec { +fn default_1127() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1125() -> Integer { +fn default_1128() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1126() -> Vec { +fn default_1129() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1127() -> Vec { +fn default_1130() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1128() -> Vec { +fn default_1131() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1129() -> Vec { +fn default_1132() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1130() -> Vec { +fn default_1133() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1131() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_1132() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_1133() -> Option { - serde_json::from_str("null").expect("schema default") -} fn default_1134() -> Option { serde_json::from_str("null").expect("schema default") } @@ -63752,22 +63990,22 @@ fn default_1139() -> Option { fn default_1140() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1141() -> Option { +fn default_1141() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1142() -> Option { +fn default_1142() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1143() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_1143() -> Option { + serde_json::from_str("null").expect("schema default") } -fn default_1144() -> Option { +fn default_1144() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1145() -> Option { +fn default_1145() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1146() -> Vec { +fn default_1146() -> Vec { serde_json::from_str("[]").expect("schema default") } fn default_1147() -> Option { @@ -63776,1861 +64014,1861 @@ fn default_1147() -> Option { fn default_1148() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1149() -> Vec { +fn default_1149() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1150() -> String { +fn default_1150() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1151() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1152() -> Vec { + serde_json::from_str("[]").expect("schema default") +} +fn default_1153() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1151() -> String { +fn default_1154() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1152() -> Vec { +fn default_1155() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1153() -> Vec { +fn default_1156() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1154() -> Integer { +fn default_1157() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1155() -> Vec { +fn default_1158() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1156() -> Vec { +fn default_1159() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1157() -> Vec { +fn default_1160() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1158() -> Vec { +fn default_1161() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1159() -> Option { +fn default_1162() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1160() -> String { +fn default_1163() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1161() -> bool { +fn default_1164() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1162() -> KnowledgeMoveResultReason { +fn default_1165() -> KnowledgeMoveResultReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1163() -> Vec { +fn default_1166() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1164() -> String { +fn default_1167() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1165() -> bool { +fn default_1168() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1166() -> Integer { +fn default_1169() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1167() -> Vec { +fn default_1170() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1168() -> Option { +fn default_1171() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1169() -> Vec { +fn default_1172() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1170() -> Vec> { +fn default_1173() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1171() -> bool { +fn default_1174() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1172() -> Vec { +fn default_1175() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1173() -> bool { +fn default_1176() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1174() -> Vec { +fn default_1177() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1175() -> Vec> { +fn default_1178() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1176() -> KnowledgeRestoreOutputReason { +fn default_1179() -> KnowledgeRestoreOutputReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1177() -> String { +fn default_1180() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1178() -> Option { +fn default_1181() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1179() -> Integer { +fn default_1182() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1180() -> KnowledgeRestoreOutputOriginal { +fn default_1183() -> KnowledgeRestoreOutputOriginal { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1181() -> Vec> { +fn default_1184() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1182() -> Vec { +fn default_1185() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1183() -> std::collections::HashMap { +fn default_1186() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1184() -> Integer { +fn default_1187() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1185() -> bool { +fn default_1188() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1186() -> Vec { +fn default_1189() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1187() -> Integer { +fn default_1190() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1188() -> bool { +fn default_1191() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1189() -> KnowledgeSourceProbe { +fn default_1192() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1190() -> bool { +fn default_1193() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1191() -> bool { +fn default_1194() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1192() -> Integer { +fn default_1195() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1193() -> bool { +fn default_1196() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1194() -> Vec { +fn default_1197() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1195() -> Integer { +fn default_1198() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1196() -> bool { +fn default_1199() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1197() -> String { +fn default_1200() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1198() -> String { +fn default_1201() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1199() -> String { +fn default_1202() -> String { serde_json::from_str("\"shared\"").expect("schema default") } -fn default_1200() -> String { +fn default_1203() -> String { serde_json::from_str("\"namespace\"").expect("schema default") } -fn default_1201() -> String { +fn default_1204() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1202() -> Vec> { +fn default_1205() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1203() -> Vec { +fn default_1206() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1204() -> std::collections::HashMap { +fn default_1207() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1205() -> String { +fn default_1208() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1206() -> String { +fn default_1209() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1207() -> String { +fn default_1210() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1208() -> String { +fn default_1211() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1209() -> String { +fn default_1212() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1210() -> Integer { +fn default_1213() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1211() -> Integer { +fn default_1214() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1212() -> Integer { +fn default_1215() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1213() -> Integer { +fn default_1216() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1214() -> std::collections::HashMap { +fn default_1217() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1215() -> Integer { +fn default_1218() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1216() -> String { +fn default_1219() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1217() -> Integer { +fn default_1220() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1218() -> String { +fn default_1221() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1219() -> Integer { +fn default_1222() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1220() -> Integer { +fn default_1223() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1221() -> Integer { +fn default_1224() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1222() -> String { +fn default_1225() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1223() -> KnowledgeSourceSync { +fn default_1226() -> KnowledgeSourceSync { serde_json::from_str("{\"requested_at\":\"\",\"last_synced_at\":\"\",\"status\":\"\",\"documents_seen\":0,\"changed\":0,\"removed\":0,\"unconverted\":0,\"unconverted_reasons\":{},\"skipped\":0,\"error\":\"\",\"pending_extract\":0,\"last_extracted_at\":\"\",\"extracted\":0,\"flagged_pinned\":0,\"unextracted\":0,\"extract_error\":\"\"}").expect("schema default") } -fn default_1224() -> String { +fn default_1227() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1225() -> String { +fn default_1228() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1226() -> String { +fn default_1229() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1227() -> Vec { +fn default_1230() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1228() -> String { +fn default_1231() -> String { serde_json::from_str("\"shared\"").expect("schema default") } -fn default_1229() -> String { +fn default_1232() -> String { serde_json::from_str("\"namespace\"").expect("schema default") } -fn default_1230() -> String { +fn default_1233() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1231() -> Vec> { +fn default_1234() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1232() -> Vec { +fn default_1235() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1233() -> std::collections::HashMap { +fn default_1236() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1234() -> String { +fn default_1237() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1235() -> String { +fn default_1238() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1236() -> KnowledgeSourceSync { +fn default_1239() -> KnowledgeSourceSync { serde_json::from_str("{\"requested_at\":\"\",\"last_synced_at\":\"\",\"status\":\"\",\"documents_seen\":0,\"changed\":0,\"removed\":0,\"unconverted\":0,\"unconverted_reasons\":{},\"skipped\":0,\"error\":\"\",\"pending_extract\":0,\"last_extracted_at\":\"\",\"extracted\":0,\"flagged_pinned\":0,\"unextracted\":0,\"extract_error\":\"\"}").expect("schema default") } -fn default_1237() -> Vec { +fn default_1240() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1238() -> bool { +fn default_1241() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1239() -> bool { +fn default_1242() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1240() -> String { +fn default_1243() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1241() -> std::collections::HashMap { +fn default_1244() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1242() -> String { +fn default_1245() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1243() -> Vec { +fn default_1246() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1244() -> bool { +fn default_1247() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1245() -> String { +fn default_1248() -> String { serde_json::from_str("\"disabled\"").expect("schema default") } -fn default_1246() -> String { +fn default_1249() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1247() -> String { +fn default_1250() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1248() -> String { +fn default_1251() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1249() -> String { +fn default_1252() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1250() -> String { +fn default_1253() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1251() -> String { +fn default_1254() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1252() -> Integer { +fn default_1255() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1253() -> f64 { +fn default_1256() -> f64 { serde_json::from_str("0").expect("schema default") } -fn default_1254() -> Integer { +fn default_1257() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1255() -> KnowledgeSourceProbe { +fn default_1258() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1256() -> String { +fn default_1259() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1257() -> bool { +fn default_1260() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1258() -> Vec> { +fn default_1261() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1259() -> Vec { +fn default_1262() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1260() -> std::collections::HashMap { +fn default_1263() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1261() -> Vec> { +fn default_1264() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1262() -> Vec> { +fn default_1265() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1263() -> KnowledgeSourceProbe { +fn default_1266() -> KnowledgeSourceProbe { serde_json::from_str( "{\"documents\":0,\"more\":false,\"sample\":[],\"checked\":0,\"sampled\":false}", ) .expect("schema default") } -fn default_1264() -> Vec { +fn default_1267() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1265() -> Integer { +fn default_1268() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1266() -> Option> { +fn default_1269() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_1267() -> Vec { +fn default_1270() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1268() -> Vec { +fn default_1271() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1269() -> bool { +fn default_1272() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1270() -> bool { +fn default_1273() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1271() -> String { +fn default_1274() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1272() -> String { +fn default_1275() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1273() -> Vec> { +fn default_1276() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1274() -> bool { +fn default_1277() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1275() -> Vec { +fn default_1278() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1276() -> Vec { +fn default_1279() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1277() -> String { +fn default_1280() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1278() -> String { +fn default_1281() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1279() -> String { +fn default_1282() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1280() -> Vec { +fn default_1283() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1281() -> Integer { +fn default_1284() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1282() -> String { +fn default_1285() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1283() -> Integer { +fn default_1286() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1284() -> String { +fn default_1287() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1285() -> String { +fn default_1288() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1286() -> Integer { +fn default_1289() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1287() -> Integer { +fn default_1290() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1288() -> String { +fn default_1291() -> String { serde_json::from_str("\"memory_supporters\"").expect("schema default") } -fn default_1289() -> String { +fn default_1292() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1290() -> String { +fn default_1293() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1291() -> Option { +fn default_1294() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1292() -> String { +fn default_1295() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1293() -> String { +fn default_1296() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1294() -> bool { +fn default_1297() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1295() -> bool { +fn default_1298() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1296() -> String { +fn default_1299() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1297() -> std::collections::HashMap { +fn default_1300() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1298() -> Vec { +fn default_1301() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1299() -> String { +fn default_1302() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1300() -> String { +fn default_1303() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1301() -> String { +fn default_1304() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1302() -> Vec { +fn default_1305() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1303() -> String { +fn default_1306() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1304() -> String { +fn default_1307() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1305() -> Vec { +fn default_1308() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1306() -> Vec { +fn default_1309() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1307() -> Vec { +fn default_1310() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1308() -> Vec { +fn default_1311() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1309() -> Integer { +fn default_1312() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1310() -> Vec { +fn default_1313() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1311() -> Vec { +fn default_1314() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1312() -> Vec { +fn default_1315() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1313() -> Integer { +fn default_1316() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1314() -> Vec { +fn default_1317() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1315() -> std::collections::HashMap { +fn default_1318() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1316() -> std::collections::HashMap { +fn default_1319() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1317() -> Integer { +fn default_1320() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1318() -> Integer { +fn default_1321() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1319() -> Integer { +fn default_1322() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1320() -> Integer { +fn default_1323() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1321() -> Integer { +fn default_1324() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1322() -> Integer { +fn default_1325() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1323() -> bool { +fn default_1326() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1324() -> String { +fn default_1327() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1325() -> String { +fn default_1328() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1326() -> String { +fn default_1329() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1327() -> String { +fn default_1330() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1328() -> Option { +fn default_1331() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1329() -> String { +fn default_1332() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1330() -> Vec { +fn default_1333() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1331() -> String { +fn default_1334() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1332() -> MemoryAskOutputSource { +fn default_1335() -> MemoryAskOutputSource { serde_json::from_str("\"synthesized\"").expect("schema default") } -fn default_1333() -> bool { +fn default_1336() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1334() -> String { +fn default_1337() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1335() -> Vec { +fn default_1338() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1336() -> Vec { +fn default_1339() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1337() -> Vec { +fn default_1340() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1338() -> String { +fn default_1341() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1339() -> String { +fn default_1342() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1340() -> MemoryAskOutputRouteTier { +fn default_1343() -> MemoryAskOutputRouteTier { serde_json::from_str("\"\"").expect("schema default") } -fn default_1341() -> String { +fn default_1344() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1342() -> Integer { +fn default_1345() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1343() -> Integer { +fn default_1346() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1344() -> bool { +fn default_1347() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1345() -> f64 { +fn default_1348() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1346() -> Option { +fn default_1349() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1347() -> Option { +fn default_1350() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1348() -> bool { +fn default_1351() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1349() -> String { +fn default_1352() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1350() -> Integer { +fn default_1353() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1351() -> Integer { +fn default_1354() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1352() -> Integer { +fn default_1355() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1353() -> Integer { +fn default_1356() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1354() -> String { +fn default_1357() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1355() -> Vec { +fn default_1358() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1356() -> Integer { +fn default_1359() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1357() -> MemoryAskOutputConsistency { +fn default_1360() -> MemoryAskOutputConsistency { serde_json::from_str("\"\"").expect("schema default") } -fn default_1358() -> f64 { +fn default_1361() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1359() -> String { +fn default_1362() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1360() -> Integer { +fn default_1363() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1361() -> Integer { +fn default_1364() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1362() -> String { +fn default_1365() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1363() -> String { +fn default_1366() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1364() -> String { +fn default_1367() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1365() -> String { +fn default_1368() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1366() -> MemoryAskOutputDepth { +fn default_1369() -> MemoryAskOutputDepth { serde_json::from_str("\"\"").expect("schema default") } -fn default_1367() -> bool { +fn default_1370() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1368() -> Vec { +fn default_1371() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1369() -> Integer { +fn default_1372() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1370() -> Integer { +fn default_1373() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1371() -> Integer { +fn default_1374() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1372() -> Vec { +fn default_1375() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1373() -> Integer { +fn default_1376() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1374() -> Integer { +fn default_1377() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1375() -> Integer { +fn default_1378() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1376() -> MemoryAskOutputGrounding { +fn default_1379() -> MemoryAskOutputGrounding { serde_json::from_str("\"\"").expect("schema default") } -fn default_1377() -> String { +fn default_1380() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1378() -> Vec { +fn default_1381() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1379() -> Integer { +fn default_1382() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1380() -> Integer { +fn default_1383() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1381() -> Integer { +fn default_1384() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1382() -> Integer { +fn default_1385() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1383() -> std::collections::HashMap { +fn default_1386() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1384() -> MemoryAskOutputDeepSelector { +fn default_1387() -> MemoryAskOutputDeepSelector { serde_json::from_str("\"\"").expect("schema default") } -fn default_1385() -> MemoryAskOutputDeepFirst { +fn default_1388() -> MemoryAskOutputDeepFirst { serde_json::from_str("\"\"").expect("schema default") } -fn default_1386() -> Integer { +fn default_1389() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1387() -> Integer { +fn default_1390() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1388() -> Integer { +fn default_1391() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1389() -> Integer { +fn default_1392() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1390() -> f64 { +fn default_1393() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1391() -> Integer { +fn default_1394() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1392() -> Integer { +fn default_1395() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1393() -> Integer { +fn default_1396() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1394() -> Integer { +fn default_1397() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1395() -> Integer { +fn default_1398() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1396() -> bool { +fn default_1399() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1397() -> String { +fn default_1400() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1398() -> String { +fn default_1401() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1399() -> String { +fn default_1402() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1400() -> String { +fn default_1403() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1401() -> String { +fn default_1404() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1402() -> String { +fn default_1405() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1403() -> bool { +fn default_1406() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1404() -> String { +fn default_1407() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1405() -> Option { +fn default_1408() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1406() -> String { +fn default_1409() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1407() -> String { +fn default_1410() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1408() -> Vec { +fn default_1411() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1409() -> Option { +fn default_1412() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1410() -> bool { +fn default_1413() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1411() -> String { +fn default_1414() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1412() -> String { +fn default_1415() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1413() -> Vec { +fn default_1416() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1414() -> String { +fn default_1417() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1415() -> Vec { +fn default_1418() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1416() -> String { +fn default_1419() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1417() -> String { +fn default_1420() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1418() -> Vec { +fn default_1421() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1419() -> Vec { +fn default_1422() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1420() -> Integer { +fn default_1423() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1421() -> Vec { +fn default_1424() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1422() -> Vec { +fn default_1425() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1423() -> String { +fn default_1426() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1424() -> String { +fn default_1427() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1425() -> bool { +fn default_1428() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1426() -> String { +fn default_1429() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1427() -> String { +fn default_1430() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_1428() -> String { +fn default_1431() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1429() -> bool { +fn default_1432() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1430() -> String { +fn default_1433() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1431() -> String { +fn default_1434() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1432() -> String { +fn default_1435() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1433() -> Vec { +fn default_1436() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1434() -> Vec { +fn default_1437() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1435() -> Vec { +fn default_1438() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1436() -> std::collections::HashMap { +fn default_1439() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1437() -> Vec { +fn default_1440() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1438() -> Integer { +fn default_1441() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1439() -> Vec { +fn default_1442() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1440() -> Integer { +fn default_1443() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1441() -> Integer { +fn default_1444() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1442() -> Integer { +fn default_1445() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1443() -> Integer { +fn default_1446() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1444() -> Integer { +fn default_1447() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1445() -> Integer { +fn default_1448() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1446() -> Integer { +fn default_1449() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1447() -> String { +fn default_1450() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1448() -> String { +fn default_1451() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1449() -> String { +fn default_1452() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1450() -> String { +fn default_1453() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1451() -> bool { +fn default_1454() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1452() -> Integer { +fn default_1455() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1453() -> Integer { +fn default_1456() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1454() -> Integer { +fn default_1457() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1455() -> Integer { +fn default_1458() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1456() -> Integer { +fn default_1459() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1457() -> bool { +fn default_1460() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1458() -> Vec { +fn default_1461() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1459() -> String { +fn default_1462() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1460() -> String { +fn default_1463() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1461() -> Option { +fn default_1464() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1462() -> Vec { +fn default_1465() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1463() -> bool { +fn default_1466() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1464() -> bool { +fn default_1467() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1465() -> Vec { +fn default_1468() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1466() -> bool { +fn default_1469() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1467() -> Option { +fn default_1470() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1468() -> Vec { +fn default_1471() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1469() -> Option { +fn default_1472() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1470() -> Option { +fn default_1473() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1471() -> Vec { +fn default_1474() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1472() -> Integer { +fn default_1475() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1473() -> bool { +fn default_1476() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1474() -> String { +fn default_1477() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1475() -> Integer { +fn default_1478() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1476() -> Integer { +fn default_1479() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1477() -> std::collections::HashMap { +fn default_1480() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1478() -> String { +fn default_1481() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1479() -> f64 { +fn default_1482() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1480() -> bool { +fn default_1483() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1481() -> String { +fn default_1484() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1482() -> String { +fn default_1485() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1483() -> Integer { +fn default_1486() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1484() -> Integer { +fn default_1487() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1485() -> Option { +fn default_1488() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1486() -> Vec { +fn default_1489() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1487() -> Vec { +fn default_1490() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1488() -> Option { +fn default_1491() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1489() -> Option { +fn default_1492() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1490() -> Integer { +fn default_1493() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1491() -> bool { +fn default_1494() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1492() -> String { +fn default_1495() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1493() -> String { +fn default_1496() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1494() -> String { +fn default_1497() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1495() -> String { +fn default_1498() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1496() -> Option { +fn default_1499() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1497() -> String { +fn default_1500() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1498() -> Integer { +fn default_1501() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1499() -> Integer { +fn default_1502() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1500() -> String { +fn default_1503() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1501() -> Vec { +fn default_1504() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1502() -> bool { +fn default_1505() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1503() -> Integer { +fn default_1506() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1504() -> Integer { +fn default_1507() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1505() -> Integer { +fn default_1508() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1506() -> Integer { +fn default_1509() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1507() -> Integer { +fn default_1510() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1508() -> String { +fn default_1511() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1509() -> String { +fn default_1512() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1510() -> String { +fn default_1513() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1511() -> String { +fn default_1514() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1512() -> Vec { +fn default_1515() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1513() -> Integer { +fn default_1516() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1514() -> Integer { +fn default_1517() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1515() -> String { +fn default_1518() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1516() -> String { +fn default_1519() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1517() -> Vec { +fn default_1520() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1518() -> String { +fn default_1521() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1519() -> String { +fn default_1522() -> String { serde_json::from_str("\"-\"").expect("schema default") } -fn default_1520() -> Vec { +fn default_1523() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1521() -> Vec { +fn default_1524() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1522() -> String { +fn default_1525() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1523() -> String { +fn default_1526() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1524() -> Vec { +fn default_1527() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1525() -> f64 { +fn default_1528() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1526() -> String { +fn default_1529() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1527() -> String { +fn default_1530() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1528() -> Vec { +fn default_1531() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1529() -> bool { +fn default_1532() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1530() -> String { +fn default_1533() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1531() -> Integer { +fn default_1534() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1532() -> Vec { +fn default_1535() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1533() -> Vec { +fn default_1536() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1534() -> Vec { +fn default_1537() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1535() -> Vec { +fn default_1538() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1536() -> Vec { +fn default_1539() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1537() -> Option { +fn default_1540() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1538() -> Option { +fn default_1541() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1539() -> Vec { +fn default_1542() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1540() -> Integer { +fn default_1543() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1541() -> Integer { +fn default_1544() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1542() -> Vec { +fn default_1545() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1543() -> Vec { +fn default_1546() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1544() -> Integer { +fn default_1547() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1545() -> Integer { +fn default_1548() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1546() -> bool { +fn default_1549() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1547() -> Vec { +fn default_1550() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1548() -> f64 { +fn default_1551() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1549() -> bool { +fn default_1552() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1550() -> String { +fn default_1553() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1551() -> String { +fn default_1554() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1552() -> Option { +fn default_1555() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1553() -> String { +fn default_1556() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1554() -> String { +fn default_1557() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1555() -> String { +fn default_1558() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1556() -> String { +fn default_1559() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1557() -> MemoryForFileHitSupersedesKind { +fn default_1560() -> MemoryForFileHitSupersedesKind { serde_json::from_str("\"\"").expect("schema default") } -fn default_1558() -> Vec { +fn default_1561() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1559() -> String { +fn default_1562() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1560() -> MemoryForFileHitVerification { +fn default_1563() -> MemoryForFileHitVerification { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1561() -> MemoryForFileHitCodeState { +fn default_1564() -> MemoryForFileHitCodeState { serde_json::from_str("\"\"").expect("schema default") } -fn default_1562() -> String { +fn default_1565() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1566() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1563() -> Integer { +fn default_1567() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1564() -> bool { +fn default_1568() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1565() -> String { +fn default_1569() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1566() -> String { +fn default_1570() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1567() -> String { +fn default_1571() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1568() -> String { +fn default_1572() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1569() -> String { +fn default_1573() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1570() -> String { +fn default_1574() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1571() -> Option { +fn default_1575() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1572() -> Value { +fn default_1576() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1573() -> Option { +fn default_1577() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1574() -> Option { +fn default_1578() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1575() -> Option { +fn default_1579() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1576() -> Option { +fn default_1580() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1577() -> Option { +fn default_1581() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1578() -> Option { +fn default_1582() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1579() -> bool { +fn default_1583() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1580() -> String { +fn default_1584() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1581() -> String { +fn default_1585() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1582() -> Option { +fn default_1586() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1583() -> String { +fn default_1587() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1584() -> String { +fn default_1588() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1585() -> String { +fn default_1589() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1586() -> String { +fn default_1590() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1587() -> String { +fn default_1591() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1588() -> String { +fn default_1592() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1589() -> Option { +fn default_1593() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1590() -> String { +fn default_1594() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1591() -> String { +fn default_1595() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1592() -> String { +fn default_1596() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1593() -> Integer { +fn default_1597() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1594() -> Vec { +fn default_1598() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1595() -> Integer { +fn default_1599() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1596() -> Option { +fn default_1600() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1597() -> Vec { +fn default_1601() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1598() -> std::collections::HashMap { +fn default_1602() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1599() -> Integer { +fn default_1603() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1600() -> f64 { +fn default_1604() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1601() -> Integer { +fn default_1605() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1602() -> Integer { +fn default_1606() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1603() -> Integer { +fn default_1607() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1604() -> Integer { +fn default_1608() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1605() -> Integer { +fn default_1609() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1606() -> MemoryHealthStaleness { +fn default_1610() -> MemoryHealthStaleness { serde_json::from_str("{\"by_age\":{},\"with_validity_end\":0,\"with_validity_end_share\":0.0,\"with_expiry\":0,\"expiring_7d\":0,\"pinned\":0,\"days_since_reinforced_p50\":0,\"days_since_reinforced_p90\":0}").expect("schema default") } -fn default_1607() -> Integer { +fn default_1611() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1608() -> Integer { +fn default_1612() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1609() -> f64 { +fn default_1613() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1610() -> MemoryHealthFootprint { +fn default_1614() -> MemoryHealthFootprint { serde_json::from_str("{\"value_chars\":0,\"value_tokens_est\":0,\"tokens_per_row_est\":0.0}") .expect("schema default") } -fn default_1611() -> String { +fn default_1615() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1612() -> Value { +fn default_1616() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1613() -> String { +fn default_1617() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1614() -> bool { +fn default_1618() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1615() -> Option { +fn default_1619() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1616() -> Option { +fn default_1620() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1617() -> Option { +fn default_1621() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1618() -> String { +fn default_1622() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1619() -> String { +fn default_1623() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1620() -> String { +fn default_1624() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1621() -> String { +fn default_1625() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1622() -> String { +fn default_1626() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1623() -> Option { +fn default_1627() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1624() -> String { +fn default_1628() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1625() -> Vec { +fn default_1629() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1626() -> Vec { +fn default_1630() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1627() -> Option { +fn default_1631() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1628() -> String { +fn default_1632() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1629() -> String { +fn default_1633() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1630() -> String { +fn default_1634() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1631() -> String { +fn default_1635() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1632() -> Option { +fn default_1636() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1633() -> Integer { +fn default_1637() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1634() -> Integer { +fn default_1638() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1635() -> Integer { +fn default_1639() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1636() -> Integer { +fn default_1640() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1637() -> MemoryImportResultReason { +fn default_1641() -> MemoryImportResultReason { serde_json::from_str("\"\"").expect("schema default") } -fn default_1638() -> String { +fn default_1642() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1639() -> MemoryImportResultNote { +fn default_1643() -> MemoryImportResultNote { serde_json::from_str("\"\"").expect("schema default") } -fn default_1640() -> bool { +fn default_1644() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1641() -> String { +fn default_1645() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1642() -> Option { +fn default_1646() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1643() -> Integer { +fn default_1647() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1644() -> Integer { +fn default_1648() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1645() -> Integer { +fn default_1649() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1646() -> String { +fn default_1650() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1647() -> Integer { +fn default_1651() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1648() -> Vec { +fn default_1652() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1649() -> Integer { +fn default_1653() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1650() -> Integer { +fn default_1654() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1651() -> Vec { +fn default_1655() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1652() -> Integer { +fn default_1656() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1653() -> Vec { +fn default_1657() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1654() -> Vec { +fn default_1658() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1655() -> Vec { +fn default_1659() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1656() -> Vec { +fn default_1660() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1657() -> Vec { +fn default_1661() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1658() -> Option { +fn default_1662() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1659() -> Option { +fn default_1663() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1660() -> String { +fn default_1664() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1661() -> Integer { +fn default_1665() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1662() -> String { +fn default_1666() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1663() -> Vec { +fn default_1667() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1664() -> bool { +fn default_1668() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1665() -> Vec { +fn default_1669() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1666() -> Option { +fn default_1670() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1667() -> Option { +fn default_1671() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1668() -> String { +fn default_1672() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1669() -> Integer { +fn default_1673() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1670() -> String { +fn default_1674() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1671() -> Integer { +fn default_1675() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1672() -> Option { +fn default_1676() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1673() -> String { +fn default_1677() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1674() -> String { +fn default_1678() -> String { serde_json::from_str("\"Each request that extracts memories from messages may send extraction instructions; no user, agent or session setting stores them.\"").expect("schema default") } -fn default_1675() -> Vec { +fn default_1679() -> Vec { serde_json::from_str("[\"memory.set_from_messages\",\"extraction_instructions\"]") .expect("schema default") } -fn default_1676() -> Vec { +fn default_1680() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1677() -> bool { +fn default_1681() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1678() -> String { +fn default_1682() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1679() -> String { +fn default_1683() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1680() -> Option { +fn default_1684() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1681() -> String { +fn default_1685() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1682() -> String { +fn default_1686() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1683() -> String { +fn default_1687() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1684() -> MemoryLineageOutputMechanism { +fn default_1688() -> MemoryLineageOutputMechanism { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_1685() -> Vec { +fn default_1689() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1686() -> String { +fn default_1690() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1687() -> String { +fn default_1691() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1688() -> Option { +fn default_1692() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1689() -> Vec { +fn default_1693() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1690() -> f64 { +fn default_1694() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1691() -> bool { +fn default_1695() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1692() -> bool { +fn default_1696() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1693() -> Integer { +fn default_1697() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1694() -> Integer { +fn default_1698() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1695() -> String { +fn default_1699() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1696() -> bool { +fn default_1700() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1697() -> Integer { +fn default_1701() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1698() -> String { +fn default_1702() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1699() -> String { +fn default_1703() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1700() -> String { +fn default_1704() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1701() -> Option { +fn default_1705() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1702() -> String { +fn default_1706() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1703() -> Option { +fn default_1707() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1704() -> String { +fn default_1708() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1705() -> String { +fn default_1709() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1706() -> String { +fn default_1710() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1707() -> Integer { +fn default_1711() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1708() -> String { +fn default_1712() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1709() -> Vec { +fn default_1713() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1710() -> bool { +fn default_1714() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1711() -> String { +fn default_1715() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1712() -> String { +fn default_1716() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1713() -> String { +fn default_1717() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1714() -> bool { +fn default_1718() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1715() -> std::collections::HashMap { +fn default_1719() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1716() -> String { +fn default_1720() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1717() -> String { +fn default_1721() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1718() -> Integer { +fn default_1722() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1719() -> Integer { +fn default_1723() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1720() -> Vec { +fn default_1724() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1721() -> Integer { +fn default_1725() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1722() -> Integer { +fn default_1726() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1723() -> Vec { +fn default_1727() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1724() -> String { +fn default_1728() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1725() -> Integer { +fn default_1729() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1726() -> String { +fn default_1730() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1727() -> Vec { +fn default_1731() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1728() -> Integer { +fn default_1732() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1729() -> Option { +fn default_1733() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1730() -> Vec { +fn default_1734() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1731() -> Integer { +fn default_1735() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1732() -> String { +fn default_1736() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1733() -> String { +fn default_1737() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1734() -> Vec { +fn default_1738() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1735() -> String { +fn default_1739() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1736() -> String { +fn default_1740() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1737() -> String { +fn default_1741() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1738() -> String { +fn default_1742() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1739() -> String { +fn default_1743() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1740() -> Vec { +fn default_1744() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1741() -> String { +fn default_1745() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1742() -> Integer { +fn default_1746() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1743() -> Integer { +fn default_1747() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1744() -> String { +fn default_1748() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1745() -> Integer { +fn default_1749() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1746() -> Integer { +fn default_1750() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1747() -> MemoryProposalReady { +fn default_1751() -> MemoryProposalReady { serde_json::from_str("\"\"").expect("schema default") } -fn default_1748() -> Vec { +fn default_1752() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1749() -> Vec { +fn default_1753() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1750() -> Integer { +fn default_1754() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1751() -> ProposalPolicyMode { +fn default_1755() -> ProposalPolicyMode { serde_json::from_str("\"manual\"").expect("schema default") } -fn default_1752() -> Integer { +fn default_1756() -> Integer { serde_json::from_str("2").expect("schema default") } -fn default_1753() -> Integer { +fn default_1757() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1754() -> Integer { +fn default_1758() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1755() -> ProposalPolicy { +fn default_1759() -> ProposalPolicy { serde_json::from_str( "{\"mode\":\"manual\",\"min_passes\":2,\"max_fails\":0,\"reject_after_fails\":0}", ) .expect("schema default") } -fn default_1756() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_1757() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_1758() -> String { - serde_json::from_str("\"\"").expect("schema default") -} -fn default_1759() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1760() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1761() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1762() -> bool { - serde_json::from_str("false").expect("schema default") +fn default_1762() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_1763() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -65641,8 +65879,8 @@ fn default_1764() -> String { fn default_1765() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1766() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_1766() -> bool { + serde_json::from_str("false").expect("schema default") } fn default_1767() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -65659,11 +65897,11 @@ fn default_1770() -> String { fn default_1771() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1772() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_1772() -> String { + serde_json::from_str("\"\"").expect("schema default") } -fn default_1773() -> f64 { - serde_json::from_str("1.0").expect("schema default") +fn default_1773() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_1774() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -65671,11 +65909,11 @@ fn default_1774() -> String { fn default_1775() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1776() -> Vec { +fn default_1776() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1777() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_1777() -> f64 { + serde_json::from_str("1.0").expect("schema default") } fn default_1778() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -65683,2280 +65921,2298 @@ fn default_1778() -> String { fn default_1779() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1780() -> String { +fn default_1780() -> Vec { + serde_json::from_str("[]").expect("schema default") +} +fn default_1781() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1782() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1781() -> bool { +fn default_1783() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1784() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1785() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1782() -> Integer { +fn default_1786() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1783() -> Integer { +fn default_1787() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1784() -> Integer { +fn default_1788() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1785() -> bool { +fn default_1789() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1786() -> String { +fn default_1790() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1787() -> Integer { +fn default_1791() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_1788() -> MemoryRecallOutputOrder { +fn default_1792() -> MemoryRecallOutputOrder { serde_json::from_str("\"recent\"").expect("schema default") } -fn default_1789() -> Vec { +fn default_1793() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1790() -> Integer { +fn default_1794() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1791() -> Value { +fn default_1795() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1792() -> Value { +fn default_1796() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1793() -> String { +fn default_1797() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1794() -> String { +fn default_1798() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1795() -> Option { +fn default_1799() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1796() -> Option { +fn default_1800() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1797() -> bool { +fn default_1801() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1798() -> String { +fn default_1802() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1799() -> String { +fn default_1803() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1800() -> std::collections::HashMap { +fn default_1804() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1801() -> std::collections::HashMap { +fn default_1805() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1802() -> MemoryRecordRowStatus { +fn default_1806() -> MemoryRecordRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1803() -> Option { +fn default_1807() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1804() -> Option { +fn default_1808() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1805() -> bool { +fn default_1809() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1806() -> String { +fn default_1810() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1807() -> MemoryRecordWriteOutputKeySource { +fn default_1811() -> MemoryRecordWriteOutputKeySource { serde_json::from_str("\"anonymous\"").expect("schema default") } -fn default_1808() -> std::collections::HashMap { +fn default_1812() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1809() -> String { +fn default_1813() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1810() -> Integer { +fn default_1814() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1811() -> bool { +fn default_1815() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1812() -> Option { +fn default_1816() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1813() -> Integer { +fn default_1817() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1814() -> Integer { +fn default_1818() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1815() -> Option { +fn default_1819() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1816() -> String { +fn default_1820() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1817() -> Integer { +fn default_1821() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1818() -> Integer { +fn default_1822() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1819() -> bool { +fn default_1823() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1820() -> Vec { +fn default_1824() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1821() -> Option { +fn default_1825() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1822() -> Option { +fn default_1826() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1823() -> bool { +fn default_1827() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1824() -> bool { +fn default_1828() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1825() -> String { +fn default_1829() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1826() -> f64 { +fn default_1830() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1827() -> String { +fn default_1831() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_1828() -> String { +fn default_1832() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1829() -> std::collections::HashMap { +fn default_1833() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1830() -> bool { +fn default_1834() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1831() -> Integer { +fn default_1835() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1832() -> String { +fn default_1836() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1833() -> Vec { +fn default_1837() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1834() -> Vec { +fn default_1838() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1835() -> Integer { +fn default_1839() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1836() -> Integer { +fn default_1840() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1837() -> String { +fn default_1841() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1838() -> String { +fn default_1842() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1839() -> Integer { +fn default_1843() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_1840() -> Integer { +fn default_1844() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1841() -> Integer { +fn default_1845() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1842() -> Vec { +fn default_1846() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1843() -> Integer { +fn default_1847() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1844() -> Integer { +fn default_1848() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1845() -> Integer { +fn default_1849() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1846() -> Integer { +fn default_1850() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1847() -> Vec { +fn default_1851() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1848() -> String { +fn default_1852() -> String { serde_json::from_str("\"whole\"").expect("schema default") } -fn default_1849() -> Integer { +fn default_1853() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1850() -> Vec { +fn default_1854() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1851() -> Vec { +fn default_1855() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1852() -> Integer { +fn default_1856() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1853() -> Vec { +fn default_1857() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1854() -> Integer { +fn default_1858() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1855() -> Vec { +fn default_1859() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1856() -> Vec { +fn default_1860() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1857() -> bool { +fn default_1861() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1858() -> String { +fn default_1862() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1859() -> String { +fn default_1863() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1860() -> std::collections::HashMap { +fn default_1864() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1861() -> String { +fn default_1865() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1862() -> bool { +fn default_1866() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1863() -> Vec { +fn default_1867() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1864() -> Integer { +fn default_1868() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1865() -> Integer { +fn default_1869() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1866() -> String { +fn default_1870() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1871() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1867() -> String { +fn default_1872() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1868() -> String { +fn default_1873() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1869() -> bool { +fn default_1874() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1870() -> Integer { +fn default_1875() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1871() -> Option { +fn default_1876() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1872() -> String { +fn default_1877() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1873() -> String { +fn default_1878() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1874() -> String { +fn default_1879() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1875() -> Vec { +fn default_1880() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1876() -> Integer { +fn default_1881() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1877() -> Integer { +fn default_1882() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1878() -> Integer { +fn default_1883() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1879() -> Integer { +fn default_1884() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1880() -> Integer { +fn default_1885() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1881() -> Integer { +fn default_1886() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1882() -> bool { +fn default_1887() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1883() -> Vec> { +fn default_1888() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1884() -> Vec { +fn default_1889() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1885() -> Option { +fn default_1890() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1886() -> String { +fn default_1891() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1887() -> Integer { +fn default_1892() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1888() -> Option { +fn default_1893() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1889() -> Option { +fn default_1894() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1890() -> Option { +fn default_1895() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1891() -> Option { +fn default_1896() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1892() -> Vec { +fn default_1897() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1893() -> Integer { +fn default_1898() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1894() -> String { +fn default_1899() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1895() -> String { +fn default_1900() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1896() -> Option { +fn default_1901() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1897() -> String { +fn default_1902() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1898() -> String { +fn default_1903() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1899() -> String { +fn default_1904() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1900() -> String { +fn default_1905() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1901() -> Option { +fn default_1906() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1902() -> String { +fn default_1907() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1903() -> String { +fn default_1908() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1904() -> Integer { +fn default_1909() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1905() -> String { +fn default_1910() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1906() -> String { +fn default_1911() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1907() -> String { +fn default_1912() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1908() -> String { +fn default_1913() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1909() -> String { +fn default_1914() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1910() -> Integer { +fn default_1915() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1911() -> String { +fn default_1916() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1912() -> Vec { +fn default_1917() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1913() -> String { +fn default_1918() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1914() -> Integer { +fn default_1919() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1915() -> String { +fn default_1920() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1916() -> Integer { +fn default_1921() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1917() -> String { +fn default_1922() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1918() -> String { +fn default_1923() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1919() -> Integer { +fn default_1924() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1920() -> String { +fn default_1925() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1921() -> bool { +fn default_1926() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1922() -> String { +fn default_1927() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1923() -> String { +fn default_1928() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1924() -> String { +fn default_1929() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1925() -> String { +fn default_1930() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1926() -> Option { +fn default_1931() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1927() -> String { +fn default_1932() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1928() -> Integer { +fn default_1933() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1929() -> String { +fn default_1934() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1930() -> String { +fn default_1935() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1931() -> String { +fn default_1936() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1932() -> bool { +fn default_1937() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1933() -> Vec { +fn default_1938() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1934() -> std::collections::HashMap { +fn default_1939() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1935() -> String { +fn default_1940() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1936() -> Vec { +fn default_1941() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1937() -> std::collections::HashMap { +fn default_1942() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1938() -> Integer { +fn default_1943() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1939() -> Option { +fn default_1944() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1940() -> String { +fn default_1945() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1941() -> bool { +fn default_1946() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1942() -> Vec { +fn default_1947() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1943() -> Vec { +fn default_1948() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1944() -> std::collections::HashMap { +fn default_1949() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1945() -> Option { +fn default_1950() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1946() -> Vec { +fn default_1951() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1947() -> Integer { +fn default_1952() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1948() -> Integer { +fn default_1953() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1949() -> Vec { +fn default_1954() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1950() -> Option { +fn default_1955() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1951() -> Vec { +fn default_1956() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1952() -> Option { +fn default_1957() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1953() -> Option { +fn default_1958() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1954() -> Vec { +fn default_1959() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1955() -> bool { +fn default_1960() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1956() -> Vec { +fn default_1961() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1957() -> bool { +fn default_1962() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1958() -> Integer { +fn default_1963() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1959() -> Integer { +fn default_1964() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1960() -> Integer { +fn default_1965() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1961() -> Integer { +fn default_1966() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1962() -> Integer { +fn default_1967() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1963() -> Integer { +fn default_1968() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1964() -> Integer { +fn default_1969() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1965() -> Integer { +fn default_1970() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1966() -> Integer { +fn default_1971() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1967() -> f64 { +fn default_1972() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1968() -> Integer { +fn default_1973() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1969() -> Integer { +fn default_1974() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1970() -> Integer { +fn default_1975() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1971() -> Integer { +fn default_1976() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1972() -> Option { +fn default_1977() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1973() -> Option { +fn default_1978() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1974() -> Vec { +fn default_1979() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1975() -> String { +fn default_1980() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1976() -> String { +fn default_1981() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1977() -> Integer { +fn default_1982() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1978() -> Vec> { +fn default_1983() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1979() -> Vec { +fn default_1984() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1980() -> String { +fn default_1985() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_1981() -> bool { +fn default_1986() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1982() -> String { +fn default_1987() -> String { serde_json::from_str("\"approval\"").expect("schema default") } -fn default_1983() -> String { +fn default_1988() -> String { serde_json::from_str("\"public\"").expect("schema default") } -fn default_1984() -> BrowseEntryMyStatus { +fn default_1989() -> BrowseEntryMyStatus { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1985() -> String { +fn default_1990() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1986() -> String { +fn default_1991() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1987() -> String { +fn default_1992() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1988() -> Integer { +fn default_1993() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1989() -> String { +fn default_1994() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1990() -> Option { +fn default_1995() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1991() -> Option { +fn default_1996() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1992() -> Vec { +fn default_1997() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1993() -> Option { +fn default_1998() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1994() -> Option { +fn default_1999() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1995() -> Option { +fn default_2000() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1996() -> Option> { +fn default_2001() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_1997() -> Option { +fn default_2002() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1998() -> Option { +fn default_2003() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1999() -> Option { +fn default_2004() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2000() -> Option { +fn default_2005() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2001() -> Option { +fn default_2006() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2002() -> Option { +fn default_2007() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2003() -> Option { +fn default_2008() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2004() -> Option { +fn default_2009() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2005() -> Option { +fn default_2010() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2006() -> Option { +fn default_2011() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2007() -> Option { +fn default_2012() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2008() -> Option { +fn default_2013() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2009() -> Option { +fn default_2014() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2010() -> Option { +fn default_2015() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2011() -> Option { +fn default_2016() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2012() -> Option> { +fn default_2017() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2013() -> Option { +fn default_2018() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2014() -> Option { +fn default_2019() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2015() -> Option { +fn default_2020() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2016() -> Option { +fn default_2021() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2017() -> Option { +fn default_2022() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2018() -> Option>> { +fn default_2023() -> Option>> { serde_json::from_str("null").expect("schema default") } -fn default_2019() -> Option { +fn default_2024() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2020() -> Option { +fn default_2025() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2021() -> Option { +fn default_2026() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2022() -> Option { +fn default_2027() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2023() -> Option { +fn default_2028() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2024() -> Integer { +fn default_2029() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2025() -> String { +fn default_2030() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2026() -> String { +fn default_2031() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2027() -> String { +fn default_2032() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2028() -> String { +fn default_2033() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2029() -> Option { +fn default_2034() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2030() -> bool { +fn default_2035() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2031() -> Integer { +fn default_2036() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2032() -> String { +fn default_2037() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2033() -> String { +fn default_2038() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2034() -> String { +fn default_2039() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2035() -> String { +fn default_2040() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2036() -> Option { +fn default_2041() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2037() -> Option { +fn default_2042() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2038() -> String { +fn default_2043() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2039() -> Vec { +fn default_2044() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2040() -> String { +fn default_2045() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2041() -> String { +fn default_2046() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2042() -> Option { +fn default_2047() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2043() -> Vec { +fn default_2048() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2044() -> Option { +fn default_2049() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2045() -> String { +fn default_2050() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2046() -> bool { +fn default_2051() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2047() -> f64 { +fn default_2052() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2048() -> f64 { +fn default_2053() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2049() -> String { +fn default_2054() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2050() -> Option { +fn default_2055() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2051() -> Integer { +fn default_2056() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2052() -> Integer { +fn default_2057() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2053() -> NamespaceEntryVisibility { +fn default_2058() -> NamespaceEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2054() -> String { +fn default_2059() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2055() -> Option { +fn default_2060() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2056() -> Option { +fn default_2061() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2057() -> Vec { +fn default_2062() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2058() -> MineEntryVisibility { +fn default_2063() -> MineEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2059() -> String { +fn default_2064() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2060() -> String { +fn default_2065() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2061() -> String { +fn default_2066() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2062() -> Option { +fn default_2067() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2063() -> bool { +fn default_2068() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2064() -> bool { +fn default_2069() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2065() -> String { +fn default_2070() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2066() -> NamespaceRegisterOutputVisibility { +fn default_2071() -> NamespaceRegisterOutputVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2067() -> bool { +fn default_2072() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2068() -> Integer { +fn default_2073() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2069() -> Integer { +fn default_2074() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2070() -> bool { +fn default_2075() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2071() -> Vec> { +fn default_2076() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2072() -> Option { +fn default_2077() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2073() -> Option { +fn default_2078() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2074() -> Vec { +fn default_2079() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2075() -> Integer { +fn default_2080() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2076() -> String { +fn default_2081() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2077() -> String { +fn default_2082() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2078() -> String { +fn default_2083() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2079() -> String { +fn default_2084() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2080() -> String { +fn default_2085() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2081() -> Option { +fn default_2086() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2082() -> String { +fn default_2087() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2083() -> String { +fn default_2088() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2084() -> String { +fn default_2089() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2085() -> Vec { +fn default_2090() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2086() -> Option { +fn default_2091() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2087() -> Option { +fn default_2092() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2088() -> Option { +fn default_2093() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2089() -> Option { +fn default_2094() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2090() -> String { +fn default_2095() -> String { serde_json::from_str("\"{}\"").expect("schema default") } -fn default_2091() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { +fn default_2096() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2092() -> Option { +fn default_2097() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2093() -> Vec { +fn default_2098() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2094() -> String { +fn default_2099() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2095() -> Integer { +fn default_2100() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2096() -> Integer { +fn default_2101() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2097() -> Option { +fn default_2102() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2098() -> String { +fn default_2103() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2099() -> String { +fn default_2104() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2100() -> String { +fn default_2105() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2101() -> String { +fn default_2106() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2102() -> Option { +fn default_2107() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2103() -> f64 { +fn default_2108() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2104() -> Option { +fn default_2109() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2105() -> Option { +fn default_2110() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2106() -> Integer { +fn default_2111() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2107() -> Option { +fn default_2112() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2108() -> Option { +fn default_2113() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2109() -> String { +fn default_2114() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2110() -> Option { +fn default_2115() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2111() -> String { +fn default_2116() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2112() -> String { +fn default_2117() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2113() -> String { +fn default_2118() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2114() -> Option { +fn default_2119() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2115() -> String { +fn default_2120() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2116() -> Option { +fn default_2121() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2117() -> String { +fn default_2122() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2118() -> String { +fn default_2123() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2119() -> Vec { +fn default_2124() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2120() -> Vec { +fn default_2125() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2121() -> Option { +fn default_2126() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2122() -> Integer { +fn default_2127() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2123() -> String { +fn default_2128() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2124() -> Vec { +fn default_2129() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2125() -> Vec { +fn default_2130() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2126() -> String { +fn default_2131() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2127() -> Option { +fn default_2132() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2128() -> Vec { +fn default_2133() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2129() -> Integer { +fn default_2134() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2130() -> Vec { +fn default_2135() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2131() -> Option { +fn default_2136() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2132() -> Vec { +fn default_2137() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2133() -> Vec { +fn default_2138() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2134() -> Option { +fn default_2139() -> Option { serde_json::from_str("0").expect("schema default") } -fn default_2135() -> TuneProposalEffect { +fn default_2140() -> TuneProposalEffect { serde_json::from_str("\"future\"").expect("schema default") } -fn default_2136() -> TuneApplyVia { +fn default_2141() -> TuneApplyVia { serde_json::from_str("\"op\"").expect("schema default") } -fn default_2137() -> bool { +fn default_2142() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2138() -> Vec { +fn default_2143() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2139() -> Option { +fn default_2144() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2140() -> Option { +fn default_2145() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2141() -> String { +fn default_2146() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2142() -> Vec { +fn default_2147() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2143() -> Vec { +fn default_2148() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2144() -> Option { +fn default_2149() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2145() -> Option { +fn default_2150() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2146() -> Option { +fn default_2151() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2147() -> String { +fn default_2152() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2148() -> Option { +fn default_2153() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2149() -> Option { +fn default_2154() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2150() -> Option { +fn default_2155() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2151() -> Vec { +fn default_2156() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2152() -> bool { +fn default_2157() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2153() -> Option { +fn default_2158() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2154() -> Option { +fn default_2159() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2155() -> Vec { +fn default_2160() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2156() -> String { +fn default_2161() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2157() -> String { +fn default_2162() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2158() -> Vec> { +fn default_2163() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2159() -> Vec { +fn default_2164() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2160() -> Integer { +fn default_2165() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2161() -> Integer { +fn default_2166() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2162() -> String { +fn default_2167() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2163() -> String { +fn default_2168() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2164() -> String { +fn default_2169() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2165() -> Vec { +fn default_2170() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2166() -> Vec { +fn default_2171() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2167() -> String { +fn default_2172() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2168() -> String { +fn default_2173() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2169() -> bool { +fn default_2174() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2170() -> Integer { +fn default_2175() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2171() -> String { +fn default_2176() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2172() -> String { +fn default_2177() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2173() -> String { +fn default_2178() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2174() -> String { +fn default_2179() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2175() -> Vec { +fn default_2180() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2176() -> String { +fn default_2181() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2177() -> String { +fn default_2182() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2178() -> std::collections::HashMap { +fn default_2183() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2179() -> String { +fn default_2184() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2180() -> Option { +fn default_2185() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2181() -> Option { +fn default_2186() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2182() -> bool { +fn default_2187() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2183() -> String { +fn default_2188() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2184() -> String { +fn default_2189() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2185() -> Vec { +fn default_2190() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2186() -> Integer { +fn default_2191() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2187() -> String { +fn default_2192() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2188() -> String { +fn default_2193() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2189() -> Option { +fn default_2194() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2190() -> bool { +fn default_2195() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2191() -> String { +fn default_2196() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2192() -> bool { +fn default_2197() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2193() -> String { +fn default_2198() -> String { serde_json::from_str("\"inherit\"").expect("schema default") } -fn default_2194() -> Option { +fn default_2199() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2195() -> Option { +fn default_2200() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2196() -> bool { +fn default_2201() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2197() -> Vec { +fn default_2202() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2198() -> Integer { +fn default_2203() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2199() -> ProcedureEvolveOutputGate { +fn default_2204() -> ProcedureEvolveOutputGate { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2200() -> String { +fn default_2205() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2201() -> f64 { +fn default_2206() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2202() -> std::collections::HashMap { +fn default_2207() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2203() -> std::collections::HashMap { +fn default_2208() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2204() -> std::collections::HashMap { +fn default_2209() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2205() -> std::collections::HashMap { +fn default_2210() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2206() -> String { +fn default_2211() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2207() -> Vec { +fn default_2212() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2208() -> Vec { +fn default_2213() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2209() -> Vec { +fn default_2214() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2210() -> std::collections::HashMap { +fn default_2215() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2211() -> Integer { +fn default_2216() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2212() -> bool { +fn default_2217() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2213() -> std::collections::HashMap { +fn default_2218() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2214() -> Vec { +fn default_2219() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2215() -> std::collections::HashMap { +fn default_2220() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2216() -> String { +fn default_2221() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2217() -> ProcedureLocateOutputStatus { +fn default_2222() -> ProcedureLocateOutputStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2218() -> Option> { +fn default_2223() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2219() -> Vec>> { +fn default_2224() -> Vec>> { serde_json::from_str("[]").expect("schema default") } -fn default_2220() -> Vec { +fn default_2225() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2221() -> Vec { +fn default_2226() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2222() -> std::collections::HashMap { +fn default_2227() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2223() -> bool { +fn default_2228() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2224() -> Vec { +fn default_2229() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2225() -> Vec> { +fn default_2230() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2226() -> String { +fn default_2231() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2227() -> std::collections::HashMap { +fn default_2232() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2228() -> std::collections::HashMap { +fn default_2233() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2229() -> Vec { +fn default_2234() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_2235() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2230() -> std::collections::HashMap { +fn default_2236() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2231() -> Option> { +fn default_2237() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2232() -> bool { +fn default_2238() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2233() -> std::collections::HashMap { +fn default_2239() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2234() -> ProcedureMatchStatus { +fn default_2240() -> ProcedureMatchStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2235() -> Option> { +fn default_2241() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2236() -> Vec { +fn default_2242() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2237() -> Integer { +fn default_2243() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2238() -> Vec> { +fn default_2244() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2239() -> f64 { +fn default_2245() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2240() -> f64 { +fn default_2246() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2241() -> f64 { +fn default_2247() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2242() -> Option { +fn default_2248() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2243() -> std::collections::HashMap { +fn default_2249() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2244() -> std::collections::HashMap> { +fn default_2250() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2245() -> String { +fn default_2251() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2246() -> Integer { +fn default_2252() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2247() -> String { +fn default_2253() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2248() -> f64 { +fn default_2254() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2249() -> Vec { +fn default_2255() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2250() -> Vec { +fn default_2256() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2251() -> Vec { +fn default_2257() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2252() -> String { +fn default_2258() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2253() -> String { +fn default_2259() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2254() -> String { +fn default_2260() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2255() -> String { +fn default_2261() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2256() -> Option { +fn default_2262() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2257() -> Integer { +fn default_2263() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2258() -> Vec { +fn default_2264() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2259() -> std::collections::HashMap { +fn default_2265() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2260() -> Option { +fn default_2266() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2261() -> String { +fn default_2267() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2262() -> Integer { +fn default_2268() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2263() -> String { +fn default_2269() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2264() -> String { +fn default_2270() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2265() -> std::collections::HashMap { +fn default_2271() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2266() -> String { +fn default_2272() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2267() -> String { +fn default_2273() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2268() -> Option { +fn default_2274() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2269() -> RunBeginOutputStatus { +fn default_2275() -> RunBeginOutputStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2270() -> String { +fn default_2276() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2271() -> Integer { +fn default_2277() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2272() -> Integer { +fn default_2278() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2273() -> Integer { +fn default_2279() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2274() -> Vec { +fn default_2280() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2275() -> Integer { +fn default_2281() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2276() -> Integer { +fn default_2282() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2277() -> Integer { +fn default_2283() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2278() -> String { +fn default_2284() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2279() -> String { +fn default_2285() -> String { serde_json::from_str("\"keep\"").expect("schema default") } -fn default_2280() -> Integer { +fn default_2286() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2281() -> Integer { +fn default_2287() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2282() -> Integer { +fn default_2288() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2283() -> Option { +fn default_2289() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2284() -> Integer { +fn default_2290() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2285() -> Vec { +fn default_2291() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2286() -> Vec { +fn default_2292() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2287() -> Integer { +fn default_2293() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2288() -> Integer { +fn default_2294() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2289() -> Integer { +fn default_2295() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2290() -> f64 { +fn default_2296() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2291() -> Integer { +fn default_2297() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2292() -> Vec { +fn default_2298() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2293() -> Integer { +fn default_2299() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2294() -> Vec { +fn default_2300() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2295() -> Integer { +fn default_2301() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2296() -> Integer { +fn default_2302() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2297() -> Integer { +fn default_2303() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2298() -> Vec { +fn default_2304() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2299() -> Option { +fn default_2305() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2300() -> Option> { +fn default_2306() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2301() -> LiveSearchResultsLive { +fn default_2307() -> LiveSearchResultsLive { serde_json::from_str("true").expect("schema default") } -fn default_2302() -> String { +fn default_2308() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2303() -> LiveSearchHitLive { +fn default_2309() -> LiveSearchHitLive { serde_json::from_str("true").expect("schema default") } -fn default_2304() -> Vec { +fn default_2310() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2305() -> Option { +fn default_2311() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2306() -> std::collections::HashMap { +fn default_2312() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2307() -> std::collections::HashMap { +fn default_2313() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2308() -> std::collections::HashMap { +fn default_2314() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2309() -> std::collections::HashMap { +fn default_2315() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2310() -> Option> { +fn default_2316() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2311() -> Vec { +fn default_2317() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2312() -> Integer { +fn default_2318() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2313() -> String { +fn default_2319() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2314() -> Integer { +fn default_2320() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2315() -> String { +fn default_2321() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2316() -> String { +fn default_2322() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2317() -> String { +fn default_2323() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2318() -> String { +fn default_2324() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2319() -> String { +fn default_2325() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2320() -> String { +fn default_2326() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2321() -> String { +fn default_2327() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2322() -> String { +fn default_2328() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2323() -> Vec { +fn default_2329() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2324() -> String { +fn default_2330() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2325() -> String { +fn default_2331() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2326() -> Vec { +fn default_2332() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2327() -> String { +fn default_2333() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2328() -> String { +fn default_2334() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2329() -> Vec { +fn default_2335() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2330() -> Vec { +fn default_2336() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2331() -> Vec { +fn default_2337() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2332() -> String { +fn default_2338() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2333() -> String { +fn default_2339() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2334() -> Vec { +fn default_2340() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2335() -> Vec { +fn default_2341() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2336() -> Vec { +fn default_2342() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2337() -> String { +fn default_2343() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2338() -> String { +fn default_2344() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2339() -> Option { +fn default_2345() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2340() -> String { +fn default_2346() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2341() -> String { +fn default_2347() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2342() -> String { +fn default_2348() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2343() -> String { +fn default_2349() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2344() -> String { +fn default_2350() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2345() -> String { +fn default_2351() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2346() -> Vec { +fn default_2352() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2347() -> Option { +fn default_2353() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2348() -> Integer { +fn default_2354() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2349() -> Integer { +fn default_2355() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2350() -> Integer { +fn default_2356() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2351() -> Integer { +fn default_2357() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2352() -> Integer { +fn default_2358() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2353() -> bool { +fn default_2359() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2354() -> String { +fn default_2360() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2355() -> String { +fn default_2361() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2356() -> String { +fn default_2362() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2357() -> String { +fn default_2363() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2358() -> String { +fn default_2364() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2359() -> String { +fn default_2365() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2360() -> String { +fn default_2366() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2361() -> Option { +fn default_2367() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2362() -> Integer { +fn default_2368() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2363() -> Integer { +fn default_2369() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2364() -> Vec { +fn default_2370() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2365() -> String { +fn default_2371() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2366() -> String { +fn default_2372() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2367() -> String { +fn default_2373() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2368() -> String { +fn default_2374() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2369() -> Integer { +fn default_2375() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2370() -> Integer { +fn default_2376() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2371() -> Integer { +fn default_2377() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2372() -> Integer { +fn default_2378() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2373() -> Integer { +fn default_2379() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2374() -> f64 { +fn default_2380() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2375() -> Integer { +fn default_2381() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2376() -> Integer { +fn default_2382() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2377() -> Integer { +fn default_2383() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2378() -> String { +fn default_2384() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2379() -> SessionBriefStats { +fn default_2385() -> SessionBriefStats { serde_json::from_str("{\"events_in\":0,\"windows\":0,\"events_total\":0,\"source_chars\":0,\"brief_chars\":0,\"compression_ratio\":0.0,\"dropped_ungrounded\":0,\"tokens_in\":0,\"tokens_out\":0,\"llm_model\":\"\"}").expect("schema default") } -fn default_2380() -> String { +fn default_2386() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2381() -> String { +fn default_2387() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2382() -> Option { +fn default_2388() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2383() -> Option { +fn default_2389() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2384() -> Option { +fn default_2390() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2385() -> Integer { +fn default_2391() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2386() -> std::collections::HashMap { +fn default_2392() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2387() -> String { +fn default_2393() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2388() -> String { +fn default_2394() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2389() -> Option { +fn default_2395() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2390() -> String { +fn default_2396() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2391() -> Integer { +fn default_2397() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2392() -> Integer { +fn default_2398() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2393() -> Option { +fn default_2399() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2394() -> std::collections::HashMap { +fn default_2400() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2395() -> String { +fn default_2401() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2396() -> Integer { +fn default_2402() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2397() -> String { +fn default_2403() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2398() -> Option { +fn default_2404() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2399() -> String { +fn default_2405() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2400() -> Option { +fn default_2406() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2401() -> String { +fn default_2407() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2402() -> String { +fn default_2408() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2403() -> String { +fn default_2409() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2404() -> String { +fn default_2410() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2405() -> Integer { +fn default_2411() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2406() -> Integer { +fn default_2412() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2407() -> String { +fn default_2413() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2408() -> std::collections::HashMap { +fn default_2414() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2409() -> String { +fn default_2415() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2410() -> String { +fn default_2416() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2411() -> bool { +fn default_2417() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2412() -> String { +fn default_2418() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2413() -> std::collections::HashMap { +fn default_2419() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2414() -> Vec> { +fn default_2420() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2415() -> Vec { +fn default_2421() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2416() -> Vec { +fn default_2422() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2417() -> bool { +fn default_2423() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2418() -> String { +fn default_2424() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_2419() -> String { +fn default_2425() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2420() -> Vec { +fn default_2426() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2421() -> bool { +fn default_2427() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2422() -> String { +fn default_2428() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2423() -> bool { +fn default_2429() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2424() -> Vec { +fn default_2430() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2425() -> std::collections::HashMap { +fn default_2431() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2426() -> Vec> { +fn default_2432() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2427() -> bool { +fn default_2433() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2428() -> bool { +fn default_2434() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2429() -> Vec> { +fn default_2435() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2430() -> std::collections::HashMap { +fn default_2436() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2431() -> String { +fn default_2437() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2432() -> Vec> { +fn default_2438() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2433() -> bool { +fn default_2439() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2434() -> String { +fn default_2440() -> String { serde_json::from_str("\"calibrated\"").expect("schema default") } -fn default_2435() -> std::collections::HashMap { +fn default_2441() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2436() -> std::collections::HashMap { +fn default_2442() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2437() -> String { +fn default_2443() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2438() -> std::collections::HashMap { +fn default_2444() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2439() -> std::collections::HashMap { +fn default_2445() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2440() -> std::collections::HashMap { +fn default_2446() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2441() -> String { +fn default_2447() -> String { serde_json::from_str("\"ok\"").expect("schema default") } -fn default_2442() -> String { +fn default_2448() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2443() -> String { +fn default_2449() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2444() -> bool { +fn default_2450() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2445() -> Integer { +fn default_2451() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2446() -> String { +fn default_2452() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2447() -> String { +fn default_2453() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2448() -> Vec { +fn default_2454() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2449() -> bool { +fn default_2455() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2450() -> Vec { +fn default_2456() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2451() -> std::collections::HashMap> { +fn default_2457() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2452() -> Vec> { +fn default_2458() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2453() -> Vec> { +fn default_2459() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2454() -> String { +fn default_2460() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2455() -> Vec> { +fn default_2461() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2456() -> std::collections::HashMap { +fn default_2462() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2457() -> String { +fn default_2463() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2458() -> Vec> { +fn default_2464() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2459() -> bool { +fn default_2465() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2460() -> Integer { +fn default_2466() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2461() -> Vec> { +fn default_2467() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2462() -> String { +fn default_2468() -> String { serde_json::from_str("\"no_flaky_signal\"").expect("schema default") } -fn default_2463() -> bool { +fn default_2469() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2464() -> Option> { +fn default_2470() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2465() -> Vec { +fn default_2471() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2466() -> bool { +fn default_2472() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2467() -> std::collections::HashMap { +fn default_2473() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2468() -> String { +fn default_2474() -> String { serde_json::from_str("\"not_computed\"").expect("schema default") } -fn default_2469() -> Vec> { +fn default_2475() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2470() -> String { +fn default_2476() -> String { serde_json::from_str("\"candidate\"").expect("schema default") } -fn default_2471() -> std::collections::HashMap { +fn default_2477() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2472() -> String { +fn default_2478() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2473() -> bool { +fn default_2479() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2474() -> Integer { +fn default_2480() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2475() -> std::collections::HashMap { +fn default_2481() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2476() -> bool { +fn default_2482() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2477() -> Vec> { +fn default_2483() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2478() -> std::collections::HashMap { +fn default_2484() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2479() -> std::collections::HashMap { +fn default_2485() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2480() -> String { +fn default_2486() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_2481() -> bool { +fn default_2487() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2482() -> Vec { +fn default_2488() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2483() -> Vec> { +fn default_2489() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2484() -> std::collections::HashMap { +fn default_2490() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2485() -> Vec { +fn default_2491() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2486() -> String { +fn default_2492() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2487() -> bool { +fn default_2493() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2488() -> bool { +fn default_2494() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2489() -> std::collections::HashMap { +fn default_2495() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2490() -> String { +fn default_2496() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2491() -> bool { +fn default_2497() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2492() -> std::collections::HashMap { +fn default_2498() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2493() -> std::collections::HashMap { +fn default_2499() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2494() -> Vec> { +fn default_2500() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2495() -> Vec { +fn default_2501() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2496() -> std::collections::HashMap { +fn default_2502() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2497() -> Vec> { +fn default_2503() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2498() -> bool { +fn default_2504() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2499() -> bool { +fn default_2505() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2500() -> Vec { +fn default_2506() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2501() -> std::collections::HashMap { +fn default_2507() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2502() -> String { +fn default_2508() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2503() -> std::collections::HashMap { +fn default_2509() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2504() -> bool { +fn default_2510() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2505() -> bool { +fn default_2511() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2506() -> String { +fn default_2512() -> String { serde_json::from_str("\"no_signal\"").expect("schema default") } -fn default_2507() -> Vec { +fn default_2513() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2508() -> f64 { +fn default_2514() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2509() -> Integer { +fn default_2515() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2510() -> String { +fn default_2516() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2511() -> std::collections::HashMap { +fn default_2517() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2512() -> std::collections::HashMap { +fn default_2518() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2513() -> std::collections::HashMap { +fn default_2519() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2514() -> std::collections::HashMap { +fn default_2520() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2515() -> String { +fn default_2521() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2516() -> std::collections::HashMap { +fn default_2522() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2517() -> bool { +fn default_2523() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2518() -> std::collections::HashMap { +fn default_2524() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2519() -> std::collections::HashMap { +fn default_2525() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2520() -> std::collections::HashMap { +fn default_2526() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2521() -> std::collections::HashMap { +fn default_2527() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2522() -> String { +fn default_2528() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2523() -> Vec> { +fn default_2529() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2524() -> Integer { +fn default_2530() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2525() -> String { +fn default_2531() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2526() -> bool { +fn default_2532() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2527() -> String { +fn default_2533() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2528() -> Vec { +fn default_2534() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2529() -> bool { +fn default_2535() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2530() -> Vec { +fn default_2536() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2531() -> f64 { +fn default_2537() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2532() -> String { +fn default_2538() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2533() -> Integer { +fn default_2539() -> Integer { serde_json::from_str("4096").expect("schema default") } -fn default_2534() -> Integer { +fn default_2540() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2535() -> Option { +fn default_2541() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2536() -> f64 { +fn default_2542() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2537() -> Option { +fn default_2543() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2538() -> Vec { +fn default_2544() -> Vec { serde_json::from_str("[]").expect("schema default") } diff --git a/sdk/rust/tests/registry_contracts.rs b/sdk/rust/tests/registry_contracts.rs index acea2407303..fe3993655df 100644 --- a/sdk/rust/tests/registry_contracts.rs +++ b/sdk/rust/tests/registry_contracts.rs @@ -4971,6 +4971,11 @@ fn context_pack() { serde_json::from_str::("[]").unwrap(), "context.pack:blocks" ); + assert_eq!( + encoded["use_guidance"], + serde_json::from_str::("[]").unwrap(), + "context.pack:use_guidance" + ); assert_eq!( encoded["section_meta"], serde_json::from_str::("{}").unwrap(), diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index b18d149a263..47520e96273 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -457,6 +457,40 @@ export interface CodeCallersInput { edge_kinds?: string[]; } +export interface CodeLesson { + memory_key?: string; + namespace?: string; + excerpt?: string; + code_state?: string; + path?: string; + changed_since?: string; + supersedes_key?: string; + suggestion?: string; + owner_symbol?: string; + use_guidance?: UseGuidance; +} + +export interface UseGuidance { + next_step: "inspect_only" | "clarify_dispute" | "recheck_source" | "obtain_review" | "validate_lead" | "follow_if_applicable"; + reasons: Array<"diagnostic_only" | "dispute_unresolved" | "source_recheck_needed" | "code_recheck_needed" | "review_pending" | "review_hash_mismatch" | "required_evidence_unknown" | "procedure_candidate" | "human_review_current" | "process_review_current" | "no_attestation" | "review_unknown" | "source_asserted" | "source_unchanged" | "code_unchanged" | "freshness_unknown" | "dispute_unknown">; + source_class: "asserted" | "extracted" | "observed" | "derived" | "imported" | "external" | "unknown"; + lifecycle: GuidanceLifecycle; + review: "human" | "process" | "stale" | "none" | "unknown"; + freshness: GuidanceFreshness; + dispute: "unresolved" | "none" | "unknown"; +} + +export interface GuidanceLifecycle { + status: string; + procedure_status: "candidate" | "exercised" | "authored" | "quarantined" | "template" | "not_applicable" | "unknown"; + review_requirement: "pending" | "none" | "unknown"; +} + +export interface GuidanceFreshness { + source: "unchanged" | "changed" | "missing" | "not_applicable" | "unknown"; + code: "fresh" | "moved" | "changed" | "unresolved" | "missing" | "not_applicable" | "unknown"; +} + export interface CodeEdgeWire { edge_kind: string; from_symbol: string; @@ -502,7 +536,7 @@ export interface CodeCandidateSiteWire { } export interface CodeCallersOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; edges: CodeEdgeWire[]; seed_symbols: string[]; @@ -541,7 +575,7 @@ export interface CodeContextPackInput { } export interface CodeContextPackOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; context: string; tokens_used: number; @@ -792,7 +826,7 @@ export interface CodeUnit { score?: number; recent_prs?: Array>; examples?: Array>; - lessons?: Array>; + lessons?: CodeLesson[]; lessons_unread?: boolean; churn?: number; amp?: number; @@ -863,7 +897,7 @@ export interface CodeEnclosingInput { } export interface CodeEnclosingOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; results: Array>; resolved: number; @@ -1016,7 +1050,7 @@ export interface GrepDependency { } export interface CodeGrepOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; matches: Array>; related?: RelatedGrepEvidence | null; @@ -1098,7 +1132,7 @@ export interface CodeImpactInput { } export interface CodeImpactOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; impacted_symbols: Array>; impacted_tests: Array>; @@ -1292,7 +1326,7 @@ export interface CodeOutlineInput { } export interface CodeOutlineOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; path: string; entries: Array>; @@ -1395,7 +1429,7 @@ export interface CodeReadWindow { } export interface CodeReadOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; results: CodeReadRange[]; as_of: Record; @@ -1761,7 +1795,7 @@ export interface CodeSearchInput { } export interface CodeSearchOutput { - lessons?: Array>; + lessons?: CodeLesson[]; lessons_left_out?: number; results: CodeUnit[]; route: string; @@ -2369,10 +2403,20 @@ export interface ContextBlock { source_count?: number; } +export interface ContextUseGuidance { + section: string; + citation: string; + /** Zero-based item index within the rendered section. */ + item_index: number; + use_guidance: UseGuidance; +} + export interface ContextPackOutput { rendered: string; sections: Record; blocks?: ContextBlock[]; + /** Guidance for the cited items retained in the rendered pack. */ + use_guidance?: ContextUseGuidance[]; section_meta?: Record>; section_count: number; truncated?: boolean; @@ -4379,6 +4423,7 @@ export interface KnowledgeSearchInput { } export interface SearchHit { + use_guidance?: UseGuidance | null; source_uri: string; chunk_idx: number; content: string; @@ -5155,6 +5200,7 @@ export interface MemorySearchHit { source_resource_id?: string; source_class?: string; verified?: boolean; + use_guidance?: UseGuidance | null; explanation?: string; session_id?: string; speaker?: string; @@ -5985,6 +6031,7 @@ export interface MemoryForFileHit { source_resource_id?: string; verification?: "human" | "process" | "stale" | "none"; code_state?: "fresh" | "moved" | "changed" | "unresolved" | "missing" | ""; + use_guidance?: UseGuidance | null; } export interface MemoryForFileOutput { @@ -7469,6 +7516,7 @@ export interface MemoryStackInput { } export interface StackEntry { + use_guidance?: UseGuidance | null; section: "profile" | "pinned" | "recent_recall" | "procedure" | "knowledge"; memory_key?: string; memory_type?: string; @@ -9137,6 +9185,7 @@ export interface ProcedureMatchInput { } export interface ProcedureMatch { + use_guidance?: UseGuidance | null; name: string; situation: string; steps: string[]; @@ -9539,11 +9588,22 @@ export interface LiveSearchHit { live?: true; } +export interface SearchSection { + results?: SearchSectionHit[]; + error?: string; + [key: string]: unknown; +} + +export interface SearchSectionHit { + use_guidance?: UseGuidance | null; + [key: string]: unknown; +} + export interface SearchQueryOutput { tracker?: Record | null; live?: LiveSearchResults | null; - memory?: Record; - knowledge?: Record; + memory?: SearchSection; + knowledge?: SearchSection; profile?: Record; conversations?: Record; withheld?: Record | null; diff --git a/sdk/typescript/src/memory-tool-receipts.test.ts b/sdk/typescript/src/memory-tool-receipts.test.ts index dc34c02b169..f98b546bce2 100644 --- a/sdk/typescript/src/memory-tool-receipts.test.ts +++ b/sdk/typescript/src/memory-tool-receipts.test.ts @@ -87,6 +87,15 @@ describe("memory tool evidence", () => { async (code_state) => { const metadata = { code_state, + use_guidance: { + next_step: "clarify_dispute", + reasons: ["dispute_unresolved", "review_unknown"], + source_class: "external", + lifecycle: { status: "conflicted", procedure_status: "not_applicable", review_requirement: "unknown" }, + review: "unknown", + freshness: { code: code_state, source: "unknown" }, + dispute: "unresolved", + }, status: "conflicted", source_class: "external", source_resource_id: "src/reader.py", diff --git a/sdk/typescript/src/tools.ts b/sdk/typescript/src/tools.ts index e4a28f64c65..56cab97a05b 100644 --- a/sdk/typescript/src/tools.ts +++ b/sdk/typescript/src/tools.ts @@ -54,6 +54,7 @@ const RECALL_HIT_FIELDS = [ "source_class", "source_resource_id", "verified", + "use_guidance", "valid_at", "created_at", "below_threshold", diff --git a/server/code/api/models_common.py b/server/code/api/models_common.py index 3d0ff929cba..8896bfa5df3 100644 --- a/server/code/api/models_common.py +++ b/server/code/api/models_common.py @@ -1,7 +1,5 @@ """What every code.* input shares: the identity block, the `namespaces` list rule, and the serializer helpers that keep a disclosure off the wire until it fired. - -A leaf: it imports nothing from the package. """ from __future__ import annotations @@ -17,6 +15,7 @@ model_validator, ) +from server.code.domain.lesson import CodeLesson from server.core.naming import present from server.operations.base import MCP_HIDDEN @@ -76,7 +75,7 @@ def _drop_empty(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]: # written against; '' for a row that names the file only. `changed_since` is the commit # that put its code in a `changed`, `unresolved` or `missing` state, when known; # `supersedes_key` the key of the older row it replaces. - lessons: list[dict[str, Any]] = Field(default_factory=list) + lessons: list[CodeLesson] = Field(default_factory=list) # How many rows about those files the lessons' token cap or a cut left out, with # the rows another row read for the answer supersedes. lessons_left_out: int = 0 diff --git a/server/code/app/result_lessons.py b/server/code/app/result_lessons.py index 655679d0854..36adc5ac981 100644 --- a/server/code/app/result_lessons.py +++ b/server/code/app/result_lessons.py @@ -29,6 +29,7 @@ from server.code.app.spans import code_span, span_attrs from server.code.domain import deadline as code_deadline from server.code.domain.anchor import local_name +from server.code.domain.lesson import code_lessons from server.core.ch import caller_shaped from server.identity.app import request_scope from server.memory.app import code_plane_reads, path_lessons @@ -189,7 +190,7 @@ async def __call__(self, input: Any) -> Any: matched_symbols=symbols, source=source, ) - out.lessons, out.lessons_left_out = found.rows, found.left_out + out.lessons, out.lessons_left_out = code_lessons.validate_python(found.rows), found.left_out return out diff --git a/server/code/app/symbol/symbol.py b/server/code/app/symbol/symbol.py index a64a7a2ea28..0942b5348de 100644 --- a/server/code/app/symbol/symbol.py +++ b/server/code/app/symbol/symbol.py @@ -52,6 +52,7 @@ symbol_body, ) from server.code.app.symbol.uses import _mention_leg, _symbol_uses +from server.code.domain.lesson import code_lessons from server.code.store.index import CodeRepo from server.core.errors import ValidationError from server.identity.app.request_scope import request_narrowed @@ -496,7 +497,9 @@ def _apply_enrichment(units: list[Any], enrichment: dict[str, Any]) -> None: if not units or not enrichment: return for field, value in enrichment.items(): - setattr(units[0], field, value) + setattr( + units[0], field, code_lessons.validate_python(value) if field == "lessons" else value + ) def _budget_definitions(units: list[Any], token_budget: int) -> tuple[list[Any], int, int]: diff --git a/server/code/domain/lesson.py b/server/code/domain/lesson.py new file mode 100644 index 00000000000..918729e59f2 --- /dev/null +++ b/server/code/domain/lesson.py @@ -0,0 +1,22 @@ +"""A memory excerpt attached to a code result or symbol definition.""" + +from pydantic import TypeAdapter +from typing_extensions import TypedDict + +from server.memory.domain.use_guidance import UseGuidance + + +class CodeLesson(TypedDict, total=False): + memory_key: str + namespace: str + excerpt: str + code_state: str + path: str + changed_since: str + supersedes_key: str + suggestion: str + owner_symbol: str + use_guidance: UseGuidance + + +code_lessons = TypeAdapter(list[CodeLesson]) diff --git a/server/code/domain/units.py b/server/code/domain/units.py index 0eeef2332d0..5290c58f091 100644 --- a/server/code/domain/units.py +++ b/server/code/domain/units.py @@ -20,6 +20,7 @@ from pydantic import BaseModel, Field, SerializerFunctionWrapHandler, model_serializer +from server.code.domain.lesson import CodeLesson from server.code.domain.symbol_body import retained_source_lines from server.code.domain.symbol_documentation import symbol_description_preview @@ -154,7 +155,7 @@ def _compact(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]: # enrichment blocks (code.symbol fills these; empty lists otherwise) recent_prs: list[dict[str, Any]] = Field(default_factory=list) examples: list[dict[str, Any]] = Field(default_factory=list) - lessons: list[dict[str, Any]] = Field(default_factory=list) + lessons: list[CodeLesson] = Field(default_factory=list) # True when `lessons` was asked for but its read failed or ran past # `code_enrich_timeout_s`: the symbol may have lessons this answer does not carry. lessons_unread: bool = False diff --git a/server/knowledge/api/models_knowledge.py b/server/knowledge/api/models_knowledge.py index bf7e3a76a44..f0996f3d1ec 100644 --- a/server/knowledge/api/models_knowledge.py +++ b/server/knowledge/api/models_knowledge.py @@ -22,6 +22,7 @@ from server.knowledge.domain.datasets import DatasetType from server.knowledge.domain.documents import MAX_SEARCH_TOP_K from server.memory.domain.rerank_names import RerankName +from server.memory.domain.use_guidance import UseGuidance from server.operations.base import MCP_HIDDEN from server.operations.read_projection import ProjectedRow @@ -118,6 +119,7 @@ class KnowledgeUpsertOutput(BaseModel): class _SearchHit(BaseModel): + use_guidance: UseGuidance | None = None source_uri: str chunk_idx: int content: str diff --git a/server/knowledge/app/document_reads.py b/server/knowledge/app/document_reads.py index f4d0649361c..3605252ae42 100644 --- a/server/knowledge/app/document_reads.py +++ b/server/knowledge/app/document_reads.py @@ -70,6 +70,22 @@ async def document_counts(org: str, namespaces: list[str]) -> dict[str, int]: # ============================================================ +async def ordinary_source_uris(org: str, namespace: str, uris: set[str]) -> set[str]: + """Currently live ordinary sources in a namespace already authorized by the caller.""" + from server.core.ch import sequential_reads + from server.knowledge.store.documents import get_many_by_uris + + with sequential_reads(): + rows = await get_many_by_uris(org, namespace, sorted(uris)) + return { + row.source_uri + for row in rows + if not row.access_json + and not any(tag.startswith("source-id:") for tag in row.tags) + and row.blob_erased_at is None + } + + @dataclass(frozen=True) class ListRequest: input: KnowledgeListInput diff --git a/server/knowledge/app/knowledge_search.py b/server/knowledge/app/knowledge_search.py index 6d40df5db0c..7b2c46f885e 100644 --- a/server/knowledge/app/knowledge_search.py +++ b/server/knowledge/app/knowledge_search.py @@ -30,6 +30,7 @@ from server.knowledge.app.source_search_proofs import SearchProofs from server.knowledge.domain.chunking import embedding_text from server.memory.app.log_once import LogOnce +from server.memory.domain.use_guidance import guidance_for_row from server.settings import settings log = logging.getLogger(__name__) @@ -94,6 +95,11 @@ async def _render( await _narrow_spans(self.embedder, self.query_vec, top, proofs=proofs) if proofs is not None: await proofs.check() + for hit in top: + # Publication checks establish access to this revision, independent of factual review. + hit.use_guidance = guidance_for_row( + {"source_class": hit.source_class}, code_state="not_applicable" + ) if _missed(self.input, top, skipped=bool(self.skipped), dropped=bool(dropped)): gaps_app.record_miss( op="knowledge.search", diff --git a/server/memory/api/models_context.py b/server/memory/api/models_context.py index 6ead2aa889b..16d8532fa58 100644 --- a/server/memory/api/models_context.py +++ b/server/memory/api/models_context.py @@ -14,6 +14,7 @@ from server.core.naming import SENTINEL from server.memory.api.models_common import _Identity +from server.memory.domain.use_guidance import UseGuidance from server.operations.base import MCP_HIDDEN @@ -119,6 +120,13 @@ class ContextBlock(BaseModel): source_count: int = 0 +class ContextUseGuidance(BaseModel): + section: str + citation: str + item_index: int = Field(description="Zero-based item index within the rendered section.") + use_guidance: UseGuidance + + class ContextPackOutput(BaseModel): # The (namespace, memory_key) of each stored row whose item line `rendered` still # holds, which the op records as served to the agent. Private, never on the wire. @@ -132,6 +140,10 @@ class ContextPackOutput(BaseModel): # One entry per non-empty section: label, body, token estimate, citations, # source count, and `priority` (its position in block order). blocks: list[ContextBlock] = Field(default_factory=list) + use_guidance: list[ContextUseGuidance] = Field( + default_factory=list, + description="Guidance for the cited items retained in the rendered pack.", + ) # Per-section details by name: source count, citations, whether it was cut, its # size, its token budget and fill ratio (above 1.0 means it was cut). section_meta: dict[str, dict[str, Any]] = Field(default_factory=dict) diff --git a/server/memory/api/models_for_file.py b/server/memory/api/models_for_file.py index e5910b6bcf2..fc972341b29 100644 --- a/server/memory/api/models_for_file.py +++ b/server/memory/api/models_for_file.py @@ -33,6 +33,7 @@ from server.memory.domain.code_change import CodeState from server.memory.domain.trust import VerificationState +from server.memory.domain.use_guidance import UseGuidance class MemoryForFileInput(BaseModel): @@ -100,6 +101,7 @@ class _MemoryForFileHit(BaseModel): # file in `files`): `fresh`, `moved`, `changed` (that code changed since the row was # written), `unresolved` (renamed or removed and not followed) or `missing` (gone). code_state: CodeState | Literal[""] = "" + use_guidance: UseGuidance | None = None class MemoryForFileOutput(BaseModel): diff --git a/server/memory/api/models_lifecycle.py b/server/memory/api/models_lifecycle.py index 5c8dcff429b..c1e42b65874 100644 --- a/server/memory/api/models_lifecycle.py +++ b/server/memory/api/models_lifecycle.py @@ -12,6 +12,7 @@ from server.memory.api.models_common import _Identity from server.memory.domain.definition_check import LapseReason +from server.memory.domain.use_guidance import UseGuidance # ============================================================ # memory.promote / memory.demote — shared memory plane @@ -393,6 +394,7 @@ class MemoryStackInput(_Identity): class _StackEntry(BaseModel): + use_guidance: UseGuidance | None = None section: Literal["profile", "pinned", "recent_recall", "procedure", "knowledge"] memory_key: str = "" memory_type: str = "" diff --git a/server/memory/api/models_loom_search.py b/server/memory/api/models_loom_search.py index 6ea13deecd9..57a12bebd0b 100644 --- a/server/memory/api/models_loom_search.py +++ b/server/memory/api/models_loom_search.py @@ -9,7 +9,7 @@ from __future__ import annotations -from typing import Any, Literal +from typing import Annotated, Any, Literal from pydantic import ( BaseModel, @@ -17,8 +17,14 @@ Field, SerializerFunctionWrapHandler, StrictBool, + ValidatorFunctionWrapHandler, + WrapValidator, model_serializer, + with_config, ) +from typing_extensions import TypedDict + +from server.memory.domain.use_guidance import UseGuidance class SearchInput(BaseModel): @@ -82,6 +88,27 @@ class LiveSearchResults(BaseModel): results: list[LiveSearchHit] = Field(default_factory=list, max_length=10) +def _preserve_section_order(value: Any, handler: ValidatorFunctionWrapHandler) -> dict[str, Any]: + parsed: dict[str, Any] = handler(value) + # Match the assembled response's wire order after validating newly typed fields. + return {key: parsed[key] for key in value if key in parsed} + + +@with_config(ConfigDict(extra="allow", json_schema_extra={"additionalProperties": {}})) +class SearchSectionHit(TypedDict, total=False): + """A plane's hit with guidance for the maintained revision it serves.""" + + use_guidance: UseGuidance | None + + +@with_config(ConfigDict(extra="allow", json_schema_extra={"additionalProperties": {}})) +class SearchSection(TypedDict, total=False): + """A sparse plane result including its own fields, hits and leg errors.""" + + results: list[Annotated[SearchSectionHit, WrapValidator(_preserve_section_order)]] + error: str + + class SearchOutput(BaseModel): """The sections, each `{"results": [...], ...}` as its plane's search returns it, or `{"error": ..., "results": []}` when that leg failed. @@ -106,10 +133,10 @@ def _drop_absent_sections(self, handler: SerializerFunctionWrapHandler) -> dict[ # The `memory.search` result plus the scoped repository's decisions, rendered as a # reader block, without the hits the calibration flagged below its threshold # (unless every hit is flagged). - memory: dict[str, Any] = Field(default_factory=dict) + memory: Annotated[SearchSection, WrapValidator(_preserve_section_order)] = {} # The `knowledge.search` result plus the scoped repository's documents, hits below # the knowledge similarity floor dropped. - knowledge: dict[str, Any] = Field(default_factory=dict) + knowledge: Annotated[SearchSection, WrapValidator(_preserve_section_order)] = {} # Profile sections whose label or text matches the query words, then by meaning. profile: dict[str, Any] = Field(default_factory=dict) # The `conversation.search` hits under `results`. diff --git a/server/memory/api/models_procedure.py b/server/memory/api/models_procedure.py index c8bbf35484d..f7a2e1dc3bb 100644 --- a/server/memory/api/models_procedure.py +++ b/server/memory/api/models_procedure.py @@ -13,6 +13,8 @@ from pydantic import BaseModel, Field +from server.memory.domain.use_guidance import UseGuidance + class ProcedureAddInput(BaseModel): org: str @@ -99,6 +101,7 @@ class ProcedureMatchInput(BaseModel): class _ProcedureMatch(BaseModel): + use_guidance: UseGuidance | None = None name: str situation: str # the stored situation that matched steps: list[str] diff --git a/server/memory/api/models_search.py b/server/memory/api/models_search.py index b538268694a..5636b02a23b 100644 --- a/server/memory/api/models_search.py +++ b/server/memory/api/models_search.py @@ -17,6 +17,7 @@ from server.memory.domain.code_change import CodeState from server.memory.domain.rerank_names import RerankName from server.memory.domain.search_types import ChunkRef +from server.memory.domain.use_guidance import UseGuidance from server.operations.base import MCP_HIDDEN # ============================================================ @@ -489,6 +490,8 @@ def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, data: dict[str, Any] = handler(self) if self.tags is None: data.pop("tags", None) + if self.use_guidance is None: + data.pop("use_guidance", None) # Same rule for the reliance counters (`include_usage`). for name in _USAGE_FIELDS: if getattr(self, name, None) is None: @@ -658,6 +661,8 @@ def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, # Provenance: how the content entered memory and whether # an attestation is live — so a caller can filter on trust post-hoc. verified: bool = False + # Use guidance for maintained memory, derived from evidence for the served revision. + use_guidance: UseGuidance | None = None # Compact agent-facing provenance so a hit can be cited without search_trace. explanation: str = "" # Provenance: the `session_id` the memory was written under; "" when the diff --git a/server/memory/app/ask/reader_render.py b/server/memory/app/ask/reader_render.py index ed534ed4f9f..4decd50652f 100644 --- a/server/memory/app/ask/reader_render.py +++ b/server/memory/app/ask/reader_render.py @@ -77,7 +77,10 @@ def render_reader_block(hits: list[Any], question: str = "", *, label_namespace: if label_namespace and _get(h, "namespace") == label_namespace: mtype = f"{mtype}, {label_namespace}" text = str(_get(h, "content_excerpt") or "")[:_EXCERPT_CHARS] - parts.append(f"[{_date_of(h)}] [{key}] ({mtype}) {text}{_restatement_note(h, keys)}") + guidance = _get(h, "use_guidance") + step = _get(guidance, "next_step") if guidance else "" + note = f" [use: {step}]" if step else "" + parts.append(f"[{_date_of(h)}] [{key}] ({mtype}) {text}{_restatement_note(h, keys)}{note}") return "\n\n".join(parts) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 41c21c18b5a..93948ea5dfb 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -14,8 +14,10 @@ from server.code.app import memory_links as code from server.code.domain.index.remote import repo_tag from server.code.domain.index.repos import configured_repos +from server.core.hashing import hash_text from server.memory.api.models_crud import CodeLink from server.memory.domain import code_change +from server.memory.domain.redaction_lineage import is_content_hash from server.memory.store import code_links as store from server.memory.store.code_links import LinkRow from server.settings import settings @@ -127,6 +129,58 @@ async def readable_namespaces(org: str, namespaces: set[str]) -> set[str]: return {ns for ns, ok in zip(names, allowed, strict=True) if ok} +def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: + """Current links only. An observed problem outweighs incomplete coverage.""" + visible = [a for a in links if a["code_namespace"] in readable] + state = code_change.worst([a["state"] for a in visible]) + if state in code_change.DEMOTED: + return state + if not settings.memory_code_links_enabled or len(visible) != len(links): + return "unknown" + if not visible or any(not a["complete"] or a["state"] == "pending" for a in visible): + return "unknown" + return state or "unknown" + + +async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: + """Classify every readable link made from the evidence in the served memory revision.""" + states = ["unknown"] * len(rows) + candidates: dict[int, tuple[str, str, str, str]] = {} + for index, row in enumerate(rows): + if not {"namespace", "tags", "files", "user_id"} <= row.keys(): + continue + ns = str(row["namespace"]) + tags = [str(tag) for tag in row["tags"] or ()] + cns = code_namespace_for(org, ns, tags) + if not cns: + if not any(tag.startswith("repo:") for tag in tags): + states[index] = "not_applicable" + continue + sha = hash_text(row.get("content_sha256")) + if row.get("memory_id") and is_content_hash(sha): + files = [str(path) for path in row["files"] or ()] + inputs = inputs_hash(sha, files, cns, str(row["user_id"])) + candidates[index] = (str(row["memory_id"]), ns, cns, inputs) + if not candidates: + return states + try: + readable = await readable_namespaces(org, {cns for _, _, cns, _ in candidates.values()}) + mids = sorted({mid for mid, _, cns, _ in candidates.values() if cns in readable}) + if not mids: + return states + links = await store.for_memories(org, mids) + except Exception as error: # noqa: BLE001 — unavailable links leave guidance uncertain + log.debug("Guidance code links unavailable: %s", type(error).__name__) + return states + by_revision: dict[tuple[str, str, str, str], list[LinkRow]] = defaultdict(list) + for link in links: + key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) + by_revision[key].append(link) + for index, key in candidates.items(): + states[index] = guidance_link_state(by_revision.get(key, ()), readable) + return states + + # ---- reads ---------------------------------------------------------------------------- diff --git a/server/memory/app/code_plane_reads.py b/server/memory/app/code_plane_reads.py index d65ec3335b8..de87230b92c 100644 --- a/server/memory/app/code_plane_reads.py +++ b/server/memory/app/code_plane_reads.py @@ -13,6 +13,7 @@ from server.code.domain.anchor import Definition, bare_name, local_name from server.code.domain.declaration import fingerprint_version from server.code.domain.extract import bounded_parse +from server.core.hashing import hash_text from server.identity.domain.read_scope import ReadFilters from server.memory.domain.code_change import worst from server.memory.domain.decision_schema import CONSTRAINT_TAG @@ -79,11 +80,14 @@ async def lessons_for_symbol( each with the state of the symbol's code on the branch read (trunk's state where the branch's files cannot be read here).""" from server.code.app import memory_links as code - from server.memory.app.code_link_reads import current_links + from server.memory.app.code_link_reads import current_links, inputs_now, readable_namespaces + from server.memory.app.for_file import current_file_rows, guided_file_rows if not namespaces: return [] trunk = code.trunk_namespace(org, code_namespace) or code_namespace + if not await readable_namespaces(org, {trunk}): + return [] stored, head = await asyncio.gather( links_store.for_paths( org, [trunk], list(paths), include_former=True, namespaces=list(namespaces) @@ -117,15 +121,22 @@ async def lessons_for_symbol( limit=limit, changed=[mid for mid, state in states.items() if state == "changed"], ) + served = await current_file_rows(org, served) rows = {str(r["mid"]): r for r in served} - out: dict[str, tuple[tuple[Any, ...], dict[str, Any]]] = {} + out: dict[str, tuple[tuple[Any, ...], dict[str, Any], dict[str, Any]]] = {} + local_code_changes: set[str] = set() for a, state, suggestion in matched: row = rows.get(a["memory_id"]) if row is None or row["mid"] in out: continue + if inputs_now(org, row | {"sha": hash_text(row["content_sha256"])}) != a["inputs_hash"]: + continue + if state == "changed": + local_code_changes.add(a["memory_id"]) rank = (state == "changed", not row.get("pinned"), -float(row.get("confidence") or 0)) out[row["mid"]] = ( rank, + row, { "memory_key": str(row["memory_key"]), "namespace": str(row["namespace"]), @@ -135,8 +146,13 @@ async def lessons_for_symbol( "suggestion": suggestion, }, ) - ranked = [lesson for _, lesson in sorted(out.values(), key=lambda x: x[0])][:limit] - return fit_symbol_lessons(ranked) + ranked = sorted(out.values(), key=lambda x: x[0])[:limit] + await guided_file_rows( + org, [row for _, row, _ in ranked], local_code_changes=local_code_changes + ) + return fit_symbol_lessons( + [lesson | {"use_guidance": row["use_guidance"].model_dump()} for _, row, lesson in ranked] + ) def fit_symbol_lessons(rows: list[dict[str, Any]]) -> list[dict[str, Any]]: diff --git a/server/memory/app/context_pack.py b/server/memory/app/context_pack.py index dc6b8744f9a..f6935ec6b86 100644 --- a/server/memory/app/context_pack.py +++ b/server/memory/app/context_pack.py @@ -21,12 +21,18 @@ from server.core.naming import SENTINEL as _WM_SENTINEL from server.core.naming import named from server.identity.app.request_scope import request_scope -from server.memory.api.models_context import ContextBlock, ContextPackInput, ContextPackOutput +from server.memory.api.models_context import ( + ContextBlock, + ContextPackInput, + ContextPackOutput, + ContextUseGuidance, +) from server.memory.api.models_lifecycle import MemoryStackInput from server.memory.api.models_procedure import ProcedureMatchInput from server.memory.api.models_profile import ProfileRenderInput from server.memory.api.models_search import MemorySearchInput from server.memory.api.models_working_memory import WorkingMemoryRenderInput +from server.memory.app.stack import recall_guidance_for_rows from server.memory.domain import code_change from server.memory.domain.context_layout import ( _BLOCK_LABELS, @@ -46,12 +52,15 @@ escape_data, label_part, one_item, + served_item_counts, served_rows, ) -from server.memory.domain.decision_statement import states_reason +from server.memory.domain.decision_statement import memory_value, states_reason from server.memory.domain.evidence_pack import EvidenceItem, pack_evidence from server.memory.domain.memory_types import excluded_from_unfiltered_search from server.memory.domain.search_types import SHARED_AGENT, hit_row, hit_row_key, names_row +from server.memory.domain.trust import row_content_sha256 +from server.memory.domain.use_guidance import UseGuidance if TYPE_CHECKING: from server.knowledge.api.models_knowledge import _SearchHit @@ -203,6 +212,7 @@ class _PackState: # order; None for an item that is no stored row. The rows whose line the rendered pack # still holds are what the op records as served (`served_rows`). item_rows: dict[str, list[tuple[str, str] | None]] = field(default_factory=dict) + item_guidance: dict[str, list[ContextUseGuidance | None]] = field(default_factory=dict) def put( self, @@ -213,12 +223,24 @@ def put( source_count: int = 0, extra_meta: dict[str, Any] | None = None, rows: list[tuple[str, str] | None] | None = None, + guidance: list[UseGuidance | None] | None = None, ) -> None: input = self.input default_section_tokens = self.default_section_tokens if not body: return self.item_rows[name] = list(rows or []) + if guidance is not None: + self.item_guidance[name] = [ + ContextUseGuidance( + section=name, citation=citation, item_index=index, use_guidance=item + ) + if item is not None + else None + for index, (citation, item) in enumerate( + zip(citations or [], guidance, strict=True) + ) + ] if name in RECALLED_SECTIONS: body = escape_data(body) trimmed, was_truncated = _trim( @@ -297,12 +319,14 @@ def _put_memory_stack(st: _PackState, out: MemoryStackOutput) -> None: citations: list[str] = [] rows: list[tuple[str, str] | None] = [] layers: list[str] = [] + guidance: list[UseGuidance | None] = [] for entry in out.entries: layer = entry.section if layer not in layers: layers.append(layer) cite = f"stack:{layer}/{entry.memory_key or entry.memory_type}" citations.append(cite) + guidance.append(getattr(entry, "use_guidance", None)) stored = layer in STACK_ROW_LAYERS and entry.memory_key rows.append((entry.namespace or input.namespace, entry.memory_key) if stored else None) author = author_label([entry.actor]) if layer in STACK_ROW_LAYERS else "" @@ -313,6 +337,7 @@ def _put_memory_stack(st: _PackState, out: MemoryStackOutput) -> None: "\n".join(lines), citations=citations, rows=rows, + guidance=guidance, source_count=len(out.entries), extra_meta={ "stack_layers": layers, @@ -414,6 +439,13 @@ def _vtext(v: Any) -> str: if not rows: return + guidance_rows = [ + dict(row.model_dump(), content_sha256=row_content_sha256(row)) + if hasattr(row, "model_dump") + else {} + for row in rows + ] + guidance = await recall_guidance_for_rows(input.org, guidance_rows) evidence = [ EvidenceItem( citation=f"memory:{input.namespace}/{r.memory_key}", @@ -430,8 +462,9 @@ def _vtext(v: Any) -> str: ), conflict=(r.status == "conflicted"), author=author_label([getattr(r, "actor", "")]), + use_guidance=use_guidance, ) - for r in rows + for r, use_guidance in zip(rows, guidance, strict=True) ] packed = pack_evidence( evidence, @@ -447,6 +480,7 @@ def _vtext(v: Any) -> str: packed.rendered, citations=packed.citations, rows=[(input.namespace, row_of[c]) for c in packed.citations], + guidance=[packed.use_guidance.get(c) for c in packed.citations], source_count=packed.source_count, extra_meta={ "recall_mode": "startup_pins_recency", @@ -543,10 +577,15 @@ async def _pack_decisions_from_hits( for h in decision_hits: ns = getattr(h, "namespace", "") or input.namespace rec = records.get(str(h.memory_key)) or {} - scenario = ( - str(rec.get("scenario") or "").strip() - or str(getattr(h, "content_excerpt", "") or "").strip() - ) + excerpt = str(getattr(h, "content_excerpt", "") or "").strip() + # Structured records are read by key. A guided line may use their + # rendering only when it describes the selected hit's statement. + if getattr(h, "use_guidance", None) is not None and ( + ns != input.namespace + or (rec and memory_value(rec, proposed=rec.get("stage") == "proposed") != excerpt) + ): + rec = {} + scenario = str(rec.get("scenario") or "").strip() or excerpt outcome = str(rec.get("outcome") or "").strip() realized = str(rec.get("realized_outcome") or "").strip() reasoning = str(rec.get("reasoning") or "").strip() @@ -572,6 +611,7 @@ async def _pack_decisions_from_hits( # An abstaining search's rows are no answer: the answer marks them so, and a # client drops them (the prompt-recall hook does), so none counts as served. rows=None if abstained else [hit_row(h, input.namespace) for h in decision_hits], + guidance=[getattr(h, "use_guidance", None) for h in decision_hits], source_count=len(decision_hits), ) @@ -671,6 +711,7 @@ async def _pack_memories(st: _PackState) -> None: author=_hit_author(actors, input, h), derived_from=tuple(getattr(h, "derived_from", None) or ()), code_state=code_change.label(*_code_state_and_commit(h)), + use_guidance=getattr(h, "use_guidance", None), ) ) packed = pack_evidence( @@ -689,6 +730,7 @@ async def _pack_memories(st: _PackState) -> None: citations=packed.citations, # see _pack_decisions_from_hits: an abstaining search shows no answer rows=None if out.abstain else [row_of[c] for c in packed.citations], + guidance=[packed.use_guidance.get(c) for c in packed.citations], source_count=packed.source_count, extra_meta={ "evidence_groups": packed.groups, @@ -760,6 +802,7 @@ async def _pack_procedures(st: _PackState) -> None: "\n".join(lines), citations=citations, rows=[(str(m.namespace or input.namespace), str(m.memory_key)) for m in matches], + guidance=[getattr(m, "use_guidance", None) for m in matches], source_count=len(matches), extra_meta=explore_meta or None, ) @@ -791,6 +834,7 @@ def _put_knowledge(st: _PackState, results: list[_SearchHit]) -> None: source="knowledge", group=h.source_uri, score=float(getattr(h, "score", 0.0) or 0.0), + use_guidance=getattr(h, "use_guidance", None), ) for h in results ] @@ -806,6 +850,7 @@ def _put_knowledge(st: _PackState, results: list[_SearchHit]) -> None: "knowledge", packed.rendered, citations=packed.citations, + guidance=[packed.use_guidance.get(c) for c in packed.citations], source_count=packed.source_count, extra_meta={ "evidence_groups": packed.groups, @@ -975,6 +1020,7 @@ def _clone_pack(prefix: _PackState) -> _PackState: shown_procedures=list(prefix.shown_procedures), withheld_procedures=list(prefix.withheld_procedures), item_rows={name: list(rows) for name, rows in prefix.item_rows.items()}, + item_guidance={name: list(items) for name, items in prefix.item_guidance.items()}, ) @@ -1027,6 +1073,12 @@ def _render_checked_pack( rendered=rendered, sections=sections, blocks=blocks, + use_guidance=[ + item + for name, lines in served_item_counts(rendered, [name for name, _ in present]).items() + for item in st.item_guidance.get(name, [])[:lines] + if item is not None + ], section_meta=section_meta, section_count=len([v for v in sections.values() if v]), truncated=truncated, diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index 6bfabac5757..b2f1601b708 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -10,26 +10,31 @@ from typing import TYPE_CHECKING, Any from server.code.app.common import repo_relative +from server.core import pg from server.core.ch import get_client -from server.core.datetimes import naive_utc_now +from server.core.datetimes import naive_utc_now, parse_iso_dt +from server.core.hashing import hash_text from server.core.repo_base import query_all_sliced from server.memory.api.models_for_file import ( MemoryForFileInput, MemoryForFileOutput, _MemoryForFileHit, ) +from server.memory.app.code_link_reads import guidance_code_states +from server.memory.app.use_guidance import guidance_source_states from server.memory.domain import code_change from server.memory.domain.decision_schema import ( CONSTRAINT_TAG, DECISION_TAG, FAILURE_TAG, SCHEMA_NAME, - SOURCE_CHANGED_TAG, is_decision, is_whole_row, ) from server.memory.domain.memory_types import KEY_IDENTIFIED_TYPES from server.memory.domain.trust import row_verification +from server.memory.domain.use_guidance import guidance_for_row +from server.memory.store import reads as memory_reads from server.memory.store.sql import FILE_LISTING_VISIBLE from server.settings import settings @@ -70,7 +75,8 @@ memory_key, memory_type, if({{full_values:UInt8}}, value, substring(value, 1, {_READ_BYTES})) AS value, tags, confidence, pinned, CAST(status AS String) AS status_text, agent, updated_at, actor, - memory_id, conflict_with, source_resource_id, + memory_id, user_id, session_id, version, files, conflict_with, + source_resource_id, source_trace, source_class, requires_review, verified_by, verified_sha256, content_sha256, if({{include_source_links:UInt8}}, files, []) AS source_files, if({{include_source_links:UInt8}}, user_id, '') AS source_user_id, @@ -189,13 +195,14 @@ def _body(hit: dict[str, Any], *, decision: bool, whole: bool = True) -> str: def _status_notes(hit: dict[str, Any], *, decision: bool) -> str: - """`(pinned)` for a pinned row, `(source changed)` for a decision tagged - `source-changed`, `(outcome: failed)` for a decision whose recorded outcome failed, + """`(pinned)` for a pinned row, `(source changed)` for a decision with a readable + changed source, `(outcome: failed)` for a decision whose recorded outcome failed, and a note when its linked code changed or went. An extracted decision nobody pinned is the normal case and carries no pin mark.""" tags = hit.get("tags") or [] out = " (pinned)" if hit.get("pinned") else "" - if decision and SOURCE_CHANGED_TAG in tags: + freshness = (hit.get("use_guidance") or {}).get("freshness", {}) + if decision and freshness.get("source") == "changed": out += " (source changed)" if decision and FAILURE_TAG in tags: out += " (outcome: failed)" @@ -203,6 +210,11 @@ def _status_notes(hit: dict[str, Any], *, decision: bool) -> str: return out + code_change.note(state, commit) +def _use_note(hit: dict[str, Any]) -> str: + guidance = hit.get("use_guidance") + return f" [use: {guidance['next_step']}]" if guidance else "" + + def _marker(hit: dict[str, Any], *, show_decision: bool) -> str: """` [constraint, decision]`: the row's kinds. `decision` is added only when `show_decision`; a team line leaves it out because its head says `Decision`.""" @@ -226,7 +238,10 @@ def _team_line(hit: dict[str, Any], now: datetime, *, decision: bool) -> str: label = "Decision" if decision else "Team rule" head = f"{label} ({who})" if who else label marks = _marker(hit, show_decision=False) + _status_notes(hit, decision=decision) - return f"- {head}{marks}: {_body(hit, decision=decision)} [id: {hit['memory_key']}]" + return ( + f"- {head}{marks}: {_body(hit, decision=decision)}" + f" [id: {hit['memory_key']}]{_use_note(hit)}" + ) def _removal_footer(hits: list[dict[str, Any]], home: str) -> str: @@ -286,7 +301,7 @@ def _row_line(h: dict[str, Any], now: datetime, home: str, *, whole: bool = True if _is_team(h, home): return _team_line(h, now, decision=decision) marks = _marker(h, show_decision=decision) + _status_notes(h, decision=decision) - return f"- {h['memory_key']}{marks}: {_body(h, decision=decision, whole=whole)}" + return f"- {h['memory_key']}{marks}: {_body(h, decision=decision, whole=whole)}{_use_note(h)}" def listing_line(hit: dict[str, Any]) -> str: @@ -582,13 +597,13 @@ async def _linked( try: trunks = [t for ns in input.extra_namespaces if (t := trunk_namespace(input.org, ns))] trunks = trunks or [t for t in [namespace_for_tags(input.org, input.tags)] if t] - if not trunks: + seen = await readable_namespaces(input.org, set(trunks)) if trunks else set() + if not seen: return {} links = await code_links.for_paths( - input.org, trunks, [path], namespaces=nss, states=list(code_change.STATE_RANK) + input.org, sorted(seen), [path], namespaces=nss, states=list(code_change.STATE_RANK) ) links = await current_links(input.org, links) - seen = await readable_namespaces(input.org, {a["code_namespace"] for a in links}) except Exception as e: # noqa: BLE001 — the links are additive; the files match stands log.debug("memory.for_file: code links skipped: %s", e) return None @@ -659,7 +674,7 @@ async def _merged_rows( ) skipped = linked.result() is None # read by the own read above if not extras: - return _supersede_order(own), skipped + return _supersede_order(await current_file_rows(input.org, own)), skipped got = await asyncio.gather( *( _rows_for( @@ -692,7 +707,8 @@ async def _merged_rows( if k not in seen: seen.add(k) merged.append(r) - return _supersede_order(merged[: int(input.top_k)]), skipped + current = await current_file_rows(input.org, merged[: int(input.top_k)]) + return _supersede_order(current), skipped def _hit(r: dict[str, Any], input: MemoryForFileInput) -> _MemoryForFileHit: @@ -716,7 +732,57 @@ def _hit(r: dict[str, Any], input: MemoryForFileInput) -> _MemoryForFileHit: source_resource_id=str(r.get("source_resource_id") or ""), verification=row_verification(r), code_state=r.get("code_state", ""), + use_guidance=r["use_guidance"], + ) + + +async def current_file_rows(org: str, rows: list[dict[str, Any]]) -> list[dict[str, Any]]: + """Postgres owns visibility and metadata when enabled.""" + if not rows or not pg.enabled(): + return rows + keys = [ + (org, r["namespace"], r["agent"], r["user_id"], r["session_id"], r["memory_key"]) + for r in rows + ] + heads = await memory_reads.guidance_heads(keys) + now = naive_utc_now() + kept = [] + for row, key in zip(rows, keys, strict=True): + head = heads.get(key) + if ( + head + and int(head.get("version") or 0) == int(row["version"]) + and str(head.get("memory_id")) == str(row["memory_id"]) + and hash_text(head.get("content_sha256")) == hash_text(row.get("content_sha256")) + and head.get("status") in ("active", "conflicted") + and head.get("sensitivity") != "high" + and head.get("tombstoned_at") is None + and head.get("redacted_at") is None + and all( + head.get(column) is None + or ((end := parse_iso_dt(head[column])) is not None and end > now) + for column in ("expires_at", "valid_to") + ) + ): + kept.append(row | head | {"status_text": head["status"]}) + return kept + + +async def guided_file_rows( + org: str, rows: list[dict[str, Any]], *, local_code_changes: set[str] | None = None +) -> None: + """Project guidance from visible memory revisions, independently of their path links.""" + code_states, source_states = await asyncio.gather( + guidance_code_states(org, rows), guidance_source_states(org, rows) ) + for row, state, source_state in zip(rows, code_states, source_states, strict=True): + if ( + local_code_changes + and str(row["memory_id"]) in local_code_changes + and state not in code_change.DEMOTED + ): + state = "changed" + row["use_guidance"] = guidance_for_row(row, code_state=state, source_state=source_state) async def listing_rows( @@ -739,6 +805,7 @@ async def listing_rows( full_values=True, include_source_links=include_source_links, ) + await guided_file_rows(input.org, rows) return [ _with_ids(_hit(r, input), r) | {"code_symbols": r.get("code_symbols", [])} @@ -763,6 +830,7 @@ async def handle_memory_for_file(input: MemoryForFileInput) -> MemoryForFileOutp path = repo_relative(input.path) base = path.rsplit("/", 1)[-1] rows, _skipped = await _merged_rows(input, path, base) + await guided_file_rows(input.org, rows) hits: list[_MemoryForFileHit] = [] to_render: list[dict[str, Any]] = [] diff --git a/server/memory/app/path_lessons.py b/server/memory/app/path_lessons.py index 204ea39a60f..d0d2f534402 100644 --- a/server/memory/app/path_lessons.py +++ b/server/memory/app/path_lessons.py @@ -81,6 +81,8 @@ def _lesson(hit: dict[str, Any], path: str) -> dict[str, Any] | None: lesson["changed_since"] = str(hit["code_changed_since"]) if hit.get("supersedes_key"): lesson["supersedes_key"] = str(hit["supersedes_key"]) + if hit.get("use_guidance"): + lesson["use_guidance"] = hit["use_guidance"] return lesson diff --git a/server/memory/app/procedure.py b/server/memory/app/procedure.py index 428b7071689..902413bd7bc 100644 --- a/server/memory/app/procedure.py +++ b/server/memory/app/procedure.py @@ -32,9 +32,11 @@ _ProcedureSummary, ) from server.memory.api.models_search import MemorySearchInput +from server.memory.app.stack import recall_guidance_for_rows from server.memory.domain.procedure_evidence import two_axis_score from server.memory.domain.procedure_graph import utility_from_stats from server.memory.domain.sensitivity import ATTRIBUTE_TAG_PREFIX, SENSITIVITY_TAG_PREFIX +from server.memory.domain.trust import row_content_sha256 log = logging.getLogger(__name__) _REJECTED_PUBLIC_KEYS = ("revision", "digest", "reason", "before", "after", "steps") @@ -259,6 +261,7 @@ async def handle_procedure_match(input: ProcedureMatchInput) -> ProcedureMatchOu rows_by_key = await _procedure_rows(input, keys_by_ns) matches: list[_ProcedureMatch] = [] + guidance_rows: list[dict[str, Any]] = [] for hit in hits: row = rows_by_key.get((hit.namespace or input.namespace, hit.memory_key)) value = row.value if row is not None else {} @@ -341,6 +344,16 @@ async def handle_procedure_match(input: ProcedureMatchInput) -> ProcedureMatchOu ], ) ) + guidance_rows.append( + dict(row.model_dump(), content_sha256=row_content_sha256(row)) + if hasattr(row, "model_dump") + else {} + ) + guidance = await recall_guidance_for_rows( + input.org, guidance_rows, procedure_statuses=[match.status for match in matches] + ) + for match, use_guidance in zip(matches, guidance, strict=True): + match.use_guidance = use_guidance # Fused score within a tier (situation×goal axes + tool overlap boost + # weighted ledger utility; equals similarity when no goal and no # recent_tools were given and the utility weight is 0); candidates diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py new file mode 100644 index 00000000000..2fb8c491522 --- /dev/null +++ b/server/memory/app/search/guidance.py @@ -0,0 +1,231 @@ +"""Read current evidence for the exact fact revisions served by memory.search.""" + +from __future__ import annotations + +import asyncio +import logging +from collections.abc import Coroutine +from datetime import datetime +from typing import Any + +from server.core.datetimes import naive_utc_now, parse_iso_dt +from server.identity.app.request_scope import request_scope +from server.identity.domain.read_scope import row_in_read_scope +from server.memory.api.models_search import MemorySearchInput, _MemorySearchHit +from server.memory.app.code_link_reads import guidance_code_states +from server.memory.app.search.pg_validation import doc_key, doc_version +from server.memory.app.use_guidance import guidance_source_states +from server.memory.domain.code_change import worst +from server.memory.domain.search_types import SHARED_AGENT, is_shared_row +from server.memory.domain.temporal_sql import served_statuses +from server.memory.domain.use_guidance import guidance_for_row +from server.memory.store.reads import guidance_heads +from server.memory.store.rows import IdentityKey +from server.memory.store.shared import guidance_heads as shared_guidance_heads +from server.observability import degradations + +log = logging.getLogger(__name__) + + +def _fact_row(hit: _MemorySearchHit) -> bool: + return hit.source in ("fact", "anchor") + + +def _status_kept( + status: str, hit: _MemorySearchHit, input: MemorySearchInput, *, parked: bool +) -> bool: + if parked and hit.status and hit.status == status: + # Paging retains the original call's explicit diagnostic inclusion. + return status in served_statuses( + include_duplicates=True, include_superseded=True, include_proposed=True + ) + return status in served_statuses( + include_duplicates=input.include_duplicates, + include_superseded=input.include_superseded, + include_proposed=input.include_proposed, + ) + + +def _current(row: dict[str, Any], now: datetime) -> bool: + if row.get("tombstoned_at") is not None or row.get("sensitivity") == "high": + return False + for field in ("expires_at", "valid_to"): + if (value := row.get(field)) is not None: + until = parse_iso_dt(value) + if until is None or until <= now: + return False + return True + + +def hit_in_read_scope(identity: tuple[str, ...] | list[str] | None) -> bool: + scope = request_scope() + if not scope.narrowed: + return True + if identity is None or len(identity) != 3: + return False + agent, user_id, session_id = identity + return agent == SHARED_AGENT or row_in_read_scope(scope, user_id, session_id) + + +async def _read_heads[K]( + query: Coroutine[Any, Any, dict[K, dict[str, Any]]], *, timeout_s: float, parked: bool +) -> dict[K, dict[str, Any]] | None: + try: + return await asyncio.wait_for(query, timeout_s) + except Exception as exc: # noqa: BLE001 ? unavailable evidence confers no approval + log.debug("Search guidance heads unavailable: %s", type(exc).__name__) + if parked: + degradations.note("memory", "parked page verification unavailable", health=False) + return None + + +def _memory_evidence( + input: MemorySearchInput, + hits: list[_MemorySearchHit], + keys: dict[int, IdentityKey], + rows: dict[IdentityKey, dict[str, Any]] | None, + *, + replay: bool, + parked: bool, +) -> tuple[set[int], dict[int, dict[str, Any]]]: + denied: set[int] = set() + now = naive_utc_now() + evidence: dict[int, dict[str, Any]] = {} + if rows is None: + return denied, evidence + for i, key in keys.items(): + row = rows.get(key) + hit = hits[i] + if ( + row is None + or not _current(row, now) + or row.get("redacted_at") is not None + or ( + not replay + and not _status_kept(str(row.get("status") or ""), hit, input, parked=parked) + ) + ): + denied.add(i) + continue + if int(row.get("version") or 0) == doc_version(hit): + evidence[i] = dict(row, namespace=key[1], user_id=key[3]) + + return denied, evidence + + +def _shared_evidence( + hits: list[_MemorySearchHit], + keys: dict[int, tuple[str, str]], + rows: dict[tuple[str, str], dict[str, Any]] | None, +) -> tuple[set[int], dict[int, dict[str, Any]]]: + denied: set[int] = set() + evidence: dict[int, dict[str, Any]] = {} + if rows is None: + return denied, evidence + for i, key in keys.items(): + row = rows.get(key) + if row is None or row.get("tombstoned_at") is not None or row.get("superseded_by"): + denied.add(i) + elif int(row.get("version") or 0) == doc_version(hits[i]): + evidence[i] = {"status": "active"} + return denied, evidence + + +async def _evidence_states( + query: Coroutine[Any, Any, list[str]], + evidence: dict[int, dict[str, Any]], + timeout_s: float, + kind: str, +) -> dict[int, str]: + try: + states = await asyncio.wait_for(query, timeout_s) + return dict(zip(evidence, states, strict=True)) + except Exception as exc: # noqa: BLE001 ? missing evidence is reported as unknown + log.debug("Search guidance %s state unavailable: %s", kind, type(exc).__name__) + return {} + + +async def attach_search_guidance( + input: MemorySearchInput, + hits: list[_MemorySearchHit], + *, + parked: bool = False, + replay: bool = False, + timeout_s: float = 0.2, +) -> list[_MemorySearchHit]: + """Project authorization-scoped evidence for the served window. + + Parked fact bodies are retained only when the current head still serves that revision. + A historical read never inherits live review. + The caller has already checked namespace membership and governed definitions. + """ + denied = { + i + for i, hit in enumerate(hits) + if (parked or hit._row_identity is not None) and not hit_in_read_scope(hit._row_identity) + } + keys: dict[int, IdentityKey] = { + i: (input.org, *doc_key(hit, input.namespace)) + for i, hit in enumerate(hits) + if _fact_row(hit) + and not is_shared_row(hit) + and hit._row_identity is not None + and doc_version(hit) > 0 + and i not in denied + } + shared_keys = { + i: (hit.namespace or input.namespace, hit.memory_key) + for i, hit in enumerate(hits) + if _fact_row(hit) and is_shared_row(hit) and not hit.governed and doc_version(hit) > 0 + } + rows: dict[IdentityKey, dict[str, Any]] | None = None + shared: dict[tuple[str, str], dict[str, Any]] | None = None + if (not replay or parked) and (keys or shared_keys): + rows, shared = await asyncio.gather( + _read_heads( + guidance_heads(list(set(keys.values()))), timeout_s=timeout_s, parked=parked + ), + _read_heads( + shared_guidance_heads(input.org, list(set(shared_keys.values()))), + timeout_s=timeout_s, + parked=parked, + ), + ) + denied_memory, evidence = _memory_evidence( + input, hits, keys, rows, replay=replay, parked=parked + ) + denied_shared, shared_evidence = _shared_evidence(hits, shared_keys, shared) + denied |= denied_memory | denied_shared + evidence.update(shared_evidence) + authorized = evidence.keys() + usable = {} if replay else {i: row for i, row in evidence.items() if not hits[i]._chunk_typed} + code_states: dict[int, str] = {} + source_states: dict[int, str] = {} + if usable: + eligible = list(usable.values()) + code_states, source_states = await asyncio.gather( + _evidence_states(guidance_code_states(input.org, eligible), usable, timeout_s, "code"), + _evidence_states( + guidance_source_states(input.org, eligible), usable, timeout_s, "source" + ), + ) + + kept = [] + for i, hit in enumerate(hits): + if i in denied or (parked and _fact_row(hit) and not hit.governed and i not in authorized): + continue + if _fact_row(hit): + row = usable.get(i, {"status": hit.status, "source_class": hit.source_class}) + hit.use_guidance = guidance_for_row( + row, + code_state=code_states.get(i, "unknown"), + source_state=source_states.get(i, "unknown"), + procedure_status=( + "unknown" if hit.memory_type == "procedural" else "not_applicable" + ), + ) + if parked: + # Link state can change while the served memory revision stays the same. + hit.code_state = worst([hit.use_guidance.freshness.code]) + kept.append(hit) + return kept diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index 1bde824a2d7..eca271f709b 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -15,6 +15,7 @@ from server.memory.app.search import pg_validation, term_leg from server.memory.app.search.context import SearchContext from server.memory.app.search.evidence import _decorate_hits +from server.memory.app.search.guidance import attach_search_guidance, hit_in_read_scope from server.memory.app.search.knobs import _ground_relative_excerpts_enabled from server.memory.app.search.payload import ( _apply_bodies, @@ -90,12 +91,18 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: readable = await _readable_namespaces(input.org, input.namespace, payload) hits, nxt, stale_dropped = await _parked_slice(input, payload, offset, readable) # Hits from a namespace the caller lost are neither served nor counted; the - # count is over the whole parked list, the same on every page while the - # caller's readable namespaces do not change. - withheld = sum(1 for h in payload.get("hits") or [] if h.get("namespace", "") not in readable) + # first page was never parked. If scope narrowed, only the visible tail can + # be counted. + parked_rows = payload.get("hits") or [] + withheld = sum( + 1 + for row in parked_rows + if row.get("namespace", "") not in readable + or not hit_in_read_scope(row.get("row_identity")) + ) # Rows the authority no longer serves stay in it, counted per page in `stale_dropped`; # a shared definition withheld since the first page stays in it too, counted nowhere. - total = max(0, int(payload.get("candidates_total") or 0) - withheld) + total = len(parked_rows) - withheld if withheld else int(payload.get("candidates_total") or 0) # A parked page was serialised without tags unless the first call asked; fill on this # call's own switch. await _fill_hit_tags(hits, input) @@ -184,8 +191,8 @@ async def _parked_slice( """Up to `top_k` readable, still-served hits from `offset`; the next offset (-1 at the end) and how many were stale. Checked in two windows at most: `top_k` readable rows, then, when the page is still short, `_REFILL_PER_MISSING_HIT` for each hit missing. - A replay page skips the authority's check; the shared-definition check runs on every - page.""" + A replay page does not adopt the current head's guidance. On every page the + current checks can withhold inaccessible content.""" from server.memory.app import search_pages as _pages rows = list(payload.get("hits") or []) @@ -200,7 +207,7 @@ async def _parked_slice( window: list[tuple[int, _MemorySearchHit]] = [] while j < len(rows) and len(window) < size: hit = _pages.unparked(rows[j]) if rows[j].get("namespace", "") in readable else None - if hit is not None: + if hit is not None and hit_in_read_scope(hit._row_identity): window.append((j, hit)) j += 1 window_hits = [h for _, h in window] @@ -216,13 +223,26 @@ async def _parked_slice( whole=input.bodies in ("unit", "source"), ), ) + current = await attach_search_guidance( + input, + [ + h + for h, stale_hit, withheld_hit in zip( + refreshed, stale, definitions_withheld, strict=True + ) + if h is not None and not stale_hit and not withheld_hit + ], + parked=True, + replay=bool(payload.get("replay")), + ) + current_ids = {id(h) for h in current} for (at, _), is_stale, is_withheld, hit in zip( window, stale, definitions_withheld, refreshed, strict=True ): if len(hits) == top_k: j = at # the first row of the next page break - if is_stale: + if is_stale or (not is_withheld and hit is not None and id(hit) not in current_ids): dropped += 1 elif not is_withheld and hit is not None: hits.append(hit) @@ -292,6 +312,7 @@ async def _shape_final_hits( code_change.spend_marks(final_hits) else: final_hits = move_stale(final_hits, input) + final_hits = await attach_search_guidance(input, final_hits, replay=input.as_of is not None) _unit_bodies = await _expand_unit_bodies( final_hits, input, prefer_entities=list(ctx.effective_entity_filter) ) diff --git a/server/memory/app/search_pages.py b/server/memory/app/search_pages.py index cb0dac6f0a1..270e12eee7b 100644 --- a/server/memory/app/search_pages.py +++ b/server/memory/app/search_pages.py @@ -62,16 +62,13 @@ def split_tail(pool: list[Any], final: list[Any]) -> tuple[int, list[Any]]: def _parked(hit: Any) -> dict[str, Any]: """A hit as a page stores it, with what a later page's checks read, off the wire: the - row's identity, which tells a shared definition, and under the Postgres authority what - its check reads (`row_chunk`, `row_version`, `chunk_typed`).""" + row's identity and revision, plus Postgres chunk validation fields.""" if not hasattr(hit, "model_dump"): - return dict(hit) - out: dict[str, Any] = hit.model_dump() + return {key: value for key, value in dict(hit).items() if key != "use_guidance"} + out: dict[str, Any] = hit.model_dump(exclude={"use_guidance"}) if getattr(hit, "_row_identity", None) is not None: out["row_identity"] = list(hit._row_identity) - if not pg.enabled(): - return out - if getattr(hit, "_row_chunk", None) is not None: + if pg.enabled() and getattr(hit, "_row_chunk", None) is not None: out["row_chunk"] = list(hit._row_chunk) if getattr(hit, "_row_version", 0): out["row_version"] = int(hit._row_version) @@ -86,6 +83,7 @@ def unparked(row: dict[str, Any]) -> _MemorySearchHit | None: from server.memory.api.models_search import _MemorySearchHit r = dict(row) + r.pop("use_guidance", None) identity, chunk = r.pop("row_identity", None), r.pop("row_chunk", None) row_version = int(r.pop("row_version", 0) or 0) chunk_typed = bool(r.pop("chunk_typed", False)) diff --git a/server/memory/app/stack.py b/server/memory/app/stack.py index b780d62599d..ef73e3c6e7b 100644 --- a/server/memory/app/stack.py +++ b/server/memory/app/stack.py @@ -3,6 +3,7 @@ from __future__ import annotations +import asyncio import json import logging from contextlib import nullcontext @@ -16,7 +17,10 @@ from server.knowledge.app.source_access import ReadPlan from server.knowledge.app.source_search_proofs import SearchProofs from server.memory.api.models_lifecycle import MemoryStackInput, MemoryStackOutput, _StackEntry +from server.memory.app.code_link_reads import guidance_code_states from server.memory.app.stack_knowledge import StackKnowledge +from server.memory.app.use_guidance import guidance_source_states +from server.memory.domain.use_guidance import UseGuidance, guidance_for_row log = logging.getLogger(__name__) @@ -42,6 +46,29 @@ def _est_tokens(s: str) -> int: return max(1, len(s) // 4) +async def recall_guidance_for_rows( + org: str, rows: list[dict[str, Any]], *, procedure_statuses: list[str] | None = None +) -> list[UseGuidance]: + """Project guidance from the authorized revisions whose bodies supply recall.""" + code_states, source_states = await asyncio.gather( + guidance_code_states(org, rows), guidance_source_states(org, rows) + ) + statuses = ( + procedure_statuses + if procedure_statuses is not None + else [ + "unknown" if row.get("memory_type") == "procedural" else "not_applicable" + for row in rows + ] + ) + return [ + guidance_for_row(row, code_state=code, source_state=source, procedure_status=status) + for row, code, source, status in zip( + rows, code_states, source_states, statuses, strict=True + ) + ] + + @dataclass class _StackFill: """The bundle as it fills: entries, tokens used against the budget, and @@ -118,7 +145,10 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N scope = scope_and(request_scope(), params) pinned_rows = await ch.query_all( f""" - SELECT memory_key, memory_type, value, recall_count, last_recalled_at, actor + SELECT memory_key, memory_type, value, recall_count, last_recalled_at, actor, + status, source_class, requires_review, verified_by, verified_sha256, + content_sha256, source_resource_id, source_trace, conflict_with, + memory_id, namespace, tags, files, user_id FROM loom.memory FINAL WHERE org = {{org:String}} AND namespace = {{ns:String}} @@ -136,7 +166,8 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N """, params=params, ) - for r in pinned_rows: + guidance = await recall_guidance_for_rows(input.org, pinned_rows) + for r, use_guidance in zip(pinned_rows, guidance, strict=True): val = _value_str(r.get("value")) cost = _est_tokens(val) if not fill.fits(cost): @@ -152,6 +183,7 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N recall_count=int(r.get("recall_count") or 0), last_recalled_at=r.get("last_recalled_at"), actor=str(r.get("actor") or ""), + use_guidance=use_guidance, ) ) @@ -180,7 +212,10 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s recent_rows = await ch.query_all( f""" SELECT memory_key, memory_type, value, recall_count, - evidence_count, last_recalled_at, actor + evidence_count, last_recalled_at, actor, + status, source_class, requires_review, verified_by, verified_sha256, + content_sha256, source_resource_id, source_trace, conflict_with, + memory_id, namespace, tags, files, user_id FROM loom.memory FINAL WHERE org = {{org:String}} AND namespace = {{ns:String}} @@ -202,7 +237,8 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s params=params, ) most_recent_excerpt = "" - for r in recent_rows: + guidance = await recall_guidance_for_rows(input.org, recent_rows) + for r, use_guidance in zip(recent_rows, guidance, strict=True): if r["memory_key"] in pinned_keys: continue val = _value_str(r.get("value")) @@ -221,6 +257,7 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s recall_count=int(r.get("recall_count") or 0), last_recalled_at=r.get("last_recalled_at"), actor=str(r.get("actor") or ""), + use_guidance=use_guidance, ) ) return most_recent_excerpt @@ -263,6 +300,7 @@ async def _stack_procedures(input: MemoryStackInput, fill: _StackFill) -> None: actor=m.actor, # a procedure can be matched in another of the caller's namespaces namespace=m.namespace if m.namespace != input.namespace else "", + use_guidance=getattr(m, "use_guidance", None), ) ) except Exception as e: # noqa: BLE001 — a failed procedure section must not fail the stack @@ -285,6 +323,9 @@ def _render(fill: _StackFill, hits: list[Any]) -> MemoryStackOutput: memory_type="knowledge", value=value, tokens=cost, + use_guidance=guidance_for_row( + {"source_class": getattr(hit, "source_class", "")}, code_state="not_applicable" + ), ) ) return MemoryStackOutput( diff --git a/server/memory/app/use_guidance.py b/server/memory/app/use_guidance.py new file mode 100644 index 00000000000..53e87f1b3ee --- /dev/null +++ b/server/memory/app/use_guidance.py @@ -0,0 +1,57 @@ +"""Authorize the supporting source before explaining a source-dependent memory claim.""" + +from __future__ import annotations + +import asyncio +import logging +from collections import defaultdict +from collections.abc import Mapping, Sequence +from typing import Any + +from server.auth.authz import row_in_scope +from server.identity.app.request_scope import request_narrowed +from server.knowledge.app.document_reads import ordinary_source_uris +from server.memory.domain.decision_schema import SOURCE_CHANGED_TAG + +log = logging.getLogger(__name__) + + +def _changed_document(row: Mapping[str, Any]) -> tuple[str, str] | None: + if SOURCE_CHANGED_TAG not in (row.get("tags") or ()): + return None + resource = row.get("source_resource_id") + if not isinstance(resource, str) or not resource.startswith("knowledge:"): + return None + namespace, _, citation = resource.removeprefix("knowledge:").partition("/") + # A '#' inside a URI or heading makes this citation ambiguous without another read. + if not namespace or citation.count("#") != 1: + return None + uri, _, _section = citation.partition("#") + return (namespace, uri) if uri else None + + +async def _readable_documents(org: str, namespace: str, uris: set[str]) -> set[tuple[str, str]]: + """A current ordinary document must exist in a namespace the caller may read.""" + try: + if not await row_in_scope(org, namespace, hides_answer=False): + return set() + return {(namespace, uri) for uri in await ordinary_source_uris(org, namespace, uris)} + except Exception as exc: # noqa: BLE001 — optional source evidence cannot fail a memory read + log.debug("Guidance source read unavailable: %s", type(exc).__name__) + return set() + + +async def guidance_source_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: + """The recorded change marker applies only to a currently readable source.""" + references = [_changed_document(row) for row in rows] + by_ns: dict[str, set[str]] = defaultdict(set) + if not request_narrowed(): + for ref in references: + if ref: + by_ns[ref[0]].add(ref[1]) + visible: set[tuple[str, str]] = set() + if by_ns: + reads = (_readable_documents(org, ns, uris) for ns, uris in by_ns.items()) + for checked in await asyncio.gather(*reads): + visible.update(checked) + return ["changed" if ref and ref in visible else "unknown" for ref in references] diff --git a/server/memory/domain/context_layout.py b/server/memory/domain/context_layout.py index a2dc9e0ac44..97ab723bfde 100644 --- a/server/memory/domain/context_layout.py +++ b/server/memory/domain/context_layout.py @@ -270,20 +270,13 @@ def _own_bookmark(block: Any, mine: str) -> bool: STACK_ROW_LAYERS = frozenset({"pinned", "recent_recall", "procedure"}) -def served_rows( - rendered: str, - section_names: list[str], - item_rows: dict[str, list[tuple[str, str] | None]], -) -> list[tuple[str, str]]: - """The stored rows the rendered pack shows. `rendered` is the answer every caller - gets (MCP's lean pack carries it alone); `sections` and `blocks` keep lines the pack's - own budget cut, so a row counts only where `rendered` holds it. What a client then - discards is its own; a section the answer marks as no answer records no rows (see - `_pack_memories`). Each section's item lines start with `- ` (`one_item` indents a - continuation), in the order of its `item_rows`; a trim keeps a prefix, so the first n - rows of a section whose n item lines `rendered` still holds were shown, a cut one - included. `section_names` are the present sections in pack order.""" - shown: list[tuple[str, str]] = [] +def served_item_counts(rendered: str, section_names: list[str]) -> dict[str, int]: + """Count the rendered item lines that survived each section and pack budget. + + Items are one '- ' bullet each, followed by optional continuation lines. + Trimming preserves a prefix and can leave part of its last item. + """ + counts: dict[str, int] = {} cursor = 0 for name in section_names: start = rendered.find(f"<{name}>\n", cursor) @@ -292,7 +285,20 @@ def served_rows( start += len(name) + 3 end = rendered.find(f"\n", start) end = len(rendered) if end < 0 else end - lines = sum(1 for line in rendered[start:end].split("\n") if line.startswith("- ")) - shown += [row for row in item_rows.get(name, [])[:lines] if row] + counts[name] = sum(1 for line in rendered[start:end].split("\n") if line.startswith("- ")) cursor = end - return shown + return counts + + +def served_rows( + rendered: str, + section_names: list[str], + item_rows: dict[str, list[tuple[str, str] | None]], +) -> list[tuple[str, str]]: + """The stored rows retained by the rendered pack's token budget.""" + return [ + row + for name, lines in served_item_counts(rendered, section_names).items() + for row in item_rows.get(name, [])[:lines] + if row + ] diff --git a/server/memory/domain/evidence_pack.py b/server/memory/domain/evidence_pack.py index 845d540b08e..7f9859e15d1 100644 --- a/server/memory/domain/evidence_pack.py +++ b/server/memory/domain/evidence_pack.py @@ -10,6 +10,7 @@ from dataclasses import dataclass, field from server.memory.domain.context_layout import label_part, one_item +from server.memory.domain.use_guidance import UseGuidance @dataclass(frozen=True) @@ -30,6 +31,7 @@ class EvidenceItem: # linked code changed, was not found again or went (` code_state=…` on the line); # "" otherwise. code_state: str = "" + use_guidance: UseGuidance | None = None @dataclass(frozen=True) @@ -39,6 +41,7 @@ class PackedEvidence: source_count: int truncated: bool groups: list[str] = field(default_factory=list) + use_guidance: dict[str, UseGuidance] = field(default_factory=dict) def _trim(text: str, char_budget: int) -> tuple[str, bool]: @@ -100,6 +103,7 @@ def pack_evidence( lines: list[str] = [] citations: list[str] = [] groups: list[str] = [] + use_guidance: dict[str, UseGuidance] = {} truncated = False for item in ordered: group = item.group or item.source or "fact" @@ -114,6 +118,8 @@ def pack_evidence( break lines.append(line) citations.append(item.citation) + if item.use_guidance is not None: + use_guidance[item.citation] = item.use_guidance if group not in groups: groups.append(group) @@ -124,4 +130,5 @@ def pack_evidence( source_count=len(citations), truncated=truncated or trim_truncated, groups=groups, + use_guidance=use_guidance, ) diff --git a/server/memory/domain/use_guidance.py b/server/memory/domain/use_guidance.py new file mode 100644 index 00000000000..12be5597407 --- /dev/null +++ b/server/memory/domain/use_guidance.py @@ -0,0 +1,186 @@ +"""How an agent may use one authorized revision, given only the evidence it can read.""" + +from __future__ import annotations + +from collections.abc import Mapping +from typing import Any, Literal, cast, get_args + +from pydantic import BaseModel + +from server.core.hashing import hash_text +from server.memory.domain import proposal_review, trust +from server.memory.domain.provenance import SOURCE_CLASSES +from server.memory.domain.redaction_lineage import is_content_hash + +NextStep = Literal[ + "inspect_only", + "clarify_dispute", + "recheck_source", + "obtain_review", + "validate_lead", + "follow_if_applicable", +] +Reason = Literal[ + "diagnostic_only", + "dispute_unresolved", + "source_recheck_needed", + "code_recheck_needed", + "review_pending", + "review_hash_mismatch", + "required_evidence_unknown", + "procedure_candidate", + "human_review_current", + "process_review_current", + "no_attestation", + "review_unknown", + "source_asserted", + "source_unchanged", + "code_unchanged", + "freshness_unknown", + "dispute_unknown", +] +Review = Literal["human", "process", "stale", "none", "unknown"] +Source = Literal["asserted", "extracted", "observed", "derived", "imported", "external", "unknown"] +SourceState = Literal["unchanged", "changed", "missing", "not_applicable", "unknown"] +CodeState = Literal[ + "fresh", "moved", "changed", "unresolved", "missing", "not_applicable", "unknown" +] +Dispute = Literal["unresolved", "none", "unknown"] +ProcedureState = Literal[ + "candidate", "exercised", "authored", "quarantined", "template", "not_applicable", "unknown" +] + + +class GuidanceLifecycle(BaseModel): + status: str + procedure_status: ProcedureState + review_requirement: Literal["pending", "none", "unknown"] + + +class GuidanceFreshness(BaseModel): + source: SourceState + code: CodeState + + +class UseGuidance(BaseModel): + next_step: NextStep + reasons: list[Reason] + source_class: Source + lifecycle: GuidanceLifecycle + review: Review + freshness: GuidanceFreshness + dispute: Dispute + + +def _review(row: Mapping[str, Any]) -> Review: + if "verified_by" not in row or row["verified_by"] is None: + return "unknown" + if not row["verified_by"]: + return "none" + actor = str(row["verified_by"]) + if not trust.is_valid_actor(actor): + return "unknown" + stored = row.get("value") + whole = isinstance(stored, str) and not row.get("value_truncated") + current = trust.live_sha256(row.get("content_sha256"), stored if whole else None) + attested = hash_text(row.get("verified_sha256")) + if not is_content_hash(current) or not is_content_hash(attested): + return "unknown" + return trust.verification_state(actor, attested, current) + + +def guidance_for_row( + row: Mapping[str, Any], + *, + code_state: str = "unknown", + source_state: str = "unknown", + procedure_status: str = "not_applicable", + dispute: str = "unknown", +) -> UseGuidance: + """Project facts selected for the served revision. A missing column has unknown coverage.""" + status = str(row.get("status") or row.get("status_text") or "unknown") + origin = row.get("source_class") + source = cast(Source, origin if origin in SOURCE_CLASSES else "unknown") + proc = cast( + ProcedureState, + procedure_status if procedure_status in get_args(ProcedureState) else "unknown", + ) + lifecycle = GuidanceLifecycle( + status=status, + procedure_status=proc, + review_requirement=( + "pending" + if proposal_review.pending_review(dict(row, status=status)) + else "none" + if row.get("requires_review") is not None + else "unknown" + ), + ) + if ( + source_state == "unknown" + and source == "asserted" + and row.get("source_trace") == "" + and row.get("source_resource_id") == "" + ): + source_state = "not_applicable" + freshness = GuidanceFreshness( + source=cast( + SourceState, source_state if source_state in get_args(SourceState) else "unknown" + ), + code=cast(CodeState, code_state if code_state in get_args(CodeState) else "unknown"), + ) + dispute_state = cast(Dispute, dispute if dispute in get_args(Dispute) else "unknown") + if status == "conflicted": + dispute_state = "unresolved" + review = _review(row) + rules: list[tuple[bool, NextStep, Reason]] = [ + ( + status in {"rejected", "withdrawn", "superseded", "duplicate", "retired"} + or proc == "quarantined", + "inspect_only", + "diagnostic_only", + ), + (dispute_state == "unresolved", "clarify_dispute", "dispute_unresolved"), + (freshness.source in {"changed", "missing"}, "recheck_source", "source_recheck_needed"), + ( + freshness.code in {"changed", "unresolved", "missing"}, + "recheck_source", + "code_recheck_needed", + ), + (lifecycle.review_requirement == "pending", "obtain_review", "review_pending"), + (review == "stale", "obtain_review", "review_hash_mismatch"), + ( + status != "active" + or lifecycle.review_requirement == "unknown" + or proc == "unknown" + or "unknown" in (freshness.code, freshness.source), + "validate_lead", + "required_evidence_unknown", + ), + (proc == "candidate", "validate_lead", "procedure_candidate"), + (review == "human", "follow_if_applicable", "human_review_current"), + (review == "process", "validate_lead", "process_review_current"), + (review == "none", "validate_lead", "no_attestation"), + (review == "unknown", "validate_lead", "review_unknown"), + ] + matched = [(step, reason) for applies, step, reason in rules if applies] + reasons = [reason for _, reason in matched] + if source == "asserted": + reasons.append("source_asserted") + if freshness.source == "unchanged": + reasons.append("source_unchanged") + if freshness.code in {"fresh", "moved"}: + reasons.append("code_unchanged") + if "unknown" in (freshness.code, freshness.source): + reasons.append("freshness_unknown") + if dispute_state == "unknown": + reasons.append("dispute_unknown") + return UseGuidance( + next_step=matched[0][0], + reasons=reasons, + source_class=source, + review=review, + lifecycle=lifecycle, + freshness=freshness, + dispute=dispute_state, + ) diff --git a/server/memory/store/code_plane_reads.py b/server/memory/store/code_plane_reads.py index 238b247c6f7..498a65734dd 100644 --- a/server/memory/store/code_plane_reads.py +++ b/server/memory/store/code_plane_reads.py @@ -10,6 +10,7 @@ from server.core.repo_base import _CHClient, _default_client, query_all_sliced from server.identity.domain.read_scope import ReadFilters, scope_and from server.memory.store.code_links import LinkedMemory +from server.memory.store.sql import FILE_LISTING_VISIBLE async def served_excerpts( @@ -32,18 +33,20 @@ async def served_excerpts( return [] return await query_all_sliced( ch or _default_client(), - """ - SELECT toString(memory_id) AS mid, memory_key, namespace, + f""" + SELECT toString(memory_id) AS mid, memory_id, memory_key, namespace, + agent, user_id, session_id, memory_type, version, tags, files, if(startsWith(value, '"'), JSONExtractString(value), value) AS excerpt, - pinned, confidence + pinned, confidence, conflict_with, CAST(status AS String) AS status_text, + source_trace, source_class, source_resource_id, requires_review, + verified_by, verified_sha256, content_sha256 FROM loom.memory FINAL - WHERE org = {org:String} AND namespace IN {nss:Array(String)} + WHERE org = {{org:String}} AND namespace IN {{nss:Array(String)}} AND (namespace, agent, user_id, session_id, memory_key, memory_id) - IN {memories:Array(Tuple(String, String, String, String, String, UUID))} - AND tombstoned_at IS NULL AND status IN ('active', 'conflicted') - AND (expires_at IS NULL OR expires_at > now()) AND sensitivity != 'high' - ORDER BY memory_id IN {changed:Array(UUID)}, pinned DESC, confidence DESC - LIMIT {limit:UInt32} + IN {{memories:Array(Tuple(String, String, String, String, String, UUID))}} + AND ({FILE_LISTING_VISIBLE}) AND status IN ('active', 'conflicted') + ORDER BY memory_id IN {{changed:Array(UUID)}}, pinned DESC, confidence DESC + LIMIT {{limit:UInt32}} """, { "org": org, diff --git a/server/memory/store/pg_memory.py b/server/memory/store/pg_memory.py index 5af3de3a3bc..b921291bdb8 100644 --- a/server/memory/store/pg_memory.py +++ b/server/memory/store/pg_memory.py @@ -1654,6 +1654,27 @@ async def heads_by_keys( return {identity_key(r["row"]): decode_row(r["row"]) for r in rows} +async def guidance_heads( + keys: Sequence[IdentityKey], columns: tuple[str, ...] +) -> dict[IdentityKey, dict[str, Any]]: + """Small current-head projections for authorized exact identities.""" + keys = [k for k in keys if not pg.unstorable(k)] + if not keys: + return {} + rows = await pg.fetch( + f""" + SELECT c.org, c.namespace, c.agent, c.user_id, c.session_id, c.memory_key, + (SELECT jsonb_object_agg(k, c.row->k) FROM unnest($7::text[]) AS f(k) + WHERE c.row ? k) AS evidence + {_EXACT_KEYS} + """, + *_key_arrays(keys), + list(columns), + ) + decoded = ((identity_key(r), decode_row(r["evidence"] or {})) for r in rows) + return {key: {c: row[c] for c in columns if c in row} for key, row in decoded} + + async def heads_on_connection( conn: Any, keys: Sequence[IdentityKey], diff --git a/server/memory/store/reads.py b/server/memory/store/reads.py index afffb05462d..230c3ab461d 100644 --- a/server/memory/store/reads.py +++ b/server/memory/store/reads.py @@ -422,6 +422,50 @@ async def memory_rows_by_identity_keys( return {identity_key(r): _hydrate(r) for r in rows} +_GUIDANCE_COLUMNS = ( + "memory_id", + "version", + "source_class", + "status", + "requires_review", + "content_sha256", + "verified_by", + "verified_at", + "verified_sha256", + "sensitivity", + "tombstoned_at", + "redacted_at", + "expires_at", + "valid_to", + "tags", + "files", + "source_resource_id", + "source_trace", +) + + +async def guidance_heads(keys: Sequence[IdentityKey]) -> dict[IdentityKey, dict[str, Any]]: + """Current guidance metadata, without loading the value or source text.""" + if not keys: + return {} + if pg.enabled(): + return await pg_memory.guidance_heads(keys, _GUIDANCE_COLUMNS) + columns = ", ".join(_GUIDANCE_COLUMNS) + rows = await query_all_sliced( + _default_client(), + f""" + SELECT org, namespace, agent, user_id, session_id, memory_key, {columns} + FROM loom.memory FINAL + PREWHERE (org, namespace, agent, user_id, session_id, memory_key) + IN {{keys:{_IDENTITY_KEY_TUPLE}}} + {_SEQUENTIAL if read_your_writes_enabled() else ""} + """, + {"keys": sorted(set(keys))}, + "keys", + ) + return {identity_key(r): r for r in rows} + + async def clickhouse_head_versions( keys: Sequence[IdentityKey], *, ch: _CHClient | None = None ) -> dict[IdentityKey, int]: diff --git a/server/memory/store/shared.py b/server/memory/store/shared.py index d70c4bcdf24..1d6d03bc106 100644 --- a/server/memory/store/shared.py +++ b/server/memory/store/shared.py @@ -13,15 +13,16 @@ from __future__ import annotations import json +from collections.abc import Sequence from datetime import datetime from typing import Any -from server.core.repo_base import _CHClient, _default_client +from server.core.repo_base import _CHClient, _default_client, query_all_sliced from server.core.rmt_carry import register from server.memory.domain.definitions import DEFINITION_KEY_PREFIX from server.memory.domain.memory_types import DEFINITION from server.memory.domain.search_types import SHARED_AGENT -from server.memory.store.sql import _SEQUENTIAL +from server.memory.store.sql import _SEQUENTIAL, read_your_writes_enabled # Every persisted column of loom.shared, in DDL order. `ch.insert` takes its # column list from the row, and FINAL serves the DDL default of a column the @@ -195,6 +196,27 @@ async def repair_shared_embeddings( return written +async def guidance_heads( + org: str, keys: Sequence[tuple[str, str]] +) -> dict[tuple[str, str], dict[str, Any]]: + """Current lifecycle of shared rows named by the authorized search window.""" + if not keys: + return {} + rows = await query_all_sliced( + _default_client(), + f""" + SELECT namespace, memory_key, version, superseded_by, tombstoned_at + FROM loom.shared FINAL + PREWHERE org = {{org:String}} + AND (namespace, memory_key) IN {{keys:Array(Tuple(String, String))}} + {_SEQUENTIAL if read_your_writes_enabled() else ""} + """, + {"org": org, "keys": sorted(set(keys))}, + "keys", + ) + return {(str(r["namespace"]), str(r["memory_key"])): r for r in rows} + + async def fetch_shared( org: str, namespace: str, diff --git a/server/transport/lean_results.py b/server/transport/lean_results.py index 0a011bee6a7..f22f113cbf0 100644 --- a/server/transport/lean_results.py +++ b/server/transport/lean_results.py @@ -140,14 +140,14 @@ def _explained(arguments: dict[str, Any] | None) -> bool: # breakpoints acts on, and that harness calls /v1/context.pack (the plugin # hooks do). Untrimmed, a pack of tokens_estimate ~1,000 costs ~3,600 # response tokens over MCP. -PACK_KEEP: tuple[str, ...] = ("rendered", "truncated") +PACK_KEEP: tuple[str, ...] = ("rendered", "truncated", "use_guidance") def lean_pack(payload: Any) -> Any: """The MCP shape of a context.pack: the rendered bundle once, the - citations of its blocks (deduplicated, in pack order), `truncated` when - set, and the memory section's abstain / retrieval_risk verdict — the - one piece of section accounting a reader acts on.""" + citations of its blocks (deduplicated, in pack order), guidance for + rendered items, `truncated` when set, and the memory section's abstain / retrieval_risk verdict. + """ if not isinstance(payload, dict) or "rendered" not in payload: return payload out: dict[str, Any] = {k: payload[k] for k in PACK_KEEP if payload.get(k)} diff --git a/server/transport/mcp_tools.py b/server/transport/mcp_tools.py index 7455ae57214..a84ed4be319 100644 --- a/server/transport/mcp_tools.py +++ b/server/transport/mcp_tools.py @@ -15,7 +15,7 @@ from contextlib import contextmanager from typing import Any, get_args -from server.memory.api.models_loom_search import SearchInput +from server.memory.api.models_loom_search import SearchInput, SearchOutput from server.memory.app.loom_search.answer_first import withheld_note from server.memory.app.loom_search.tracker_leg import tracker_text_lines from server.operations.base import Operation @@ -130,6 +130,9 @@ def _synthetic_tool_descriptors( def _synthetic_tool_descriptors_core() -> list[dict[str, Any]]: + search_schema = _shape_schema(model_schema(SearchOutput)) + # MCP omits the optional live section until connected sources answer. + search_schema["properties"]["live"] = {"type": "object"} return [ dict(LOOM_OP_DESCRIPTOR), { @@ -234,18 +237,7 @@ def _synthetic_tool_descriptors_core() -> list[dict[str, Any]]: }, "required": ["query"], }, - # Must declare every section structuredContent returns — strict - # client validators reject keys absent from the declared schema. - "outputSchema": { - "type": "object", - "properties": { - "memory": {"type": "object"}, - "knowledge": {"type": "object"}, - "profile": {"type": "object"}, - "conversations": {"type": "object"}, - "live": {"type": "object"}, - }, - }, + "outputSchema": search_schema, "annotations": { "readOnlyHint": True, "destructiveHint": False, @@ -730,6 +722,11 @@ def _instructions_due(session_id: str, *, now: float | None = None) -> bool: return True +def _next_step(hit: dict[str, Any]) -> str: + guidance = hit.get("use_guidance") + return str(guidance.get("next_step") or "") if isinstance(guidance, dict) else "" + + def _memory_section_lines( memory: dict[str, Any], mem_hits: list[dict[str, Any]], @@ -782,6 +779,7 @@ def _memory_section_lines( why = why_note(h) if explain else (h.get("explanation") or "").replace("\n", " ").strip() out.append( f" - [{h.get('memory_key')}] (ns={ns_label}) {excerpt[:200]}" + + (f" [use: {step}]" if (step := _next_step(h)) else "") + ((f" [why: {why}]" if explain else f" ({why})") if why else "") ) return out @@ -841,7 +839,8 @@ def search_answer( for h in know_hits[:top_k]: uri = h.get("source_uri") or "-" excerpt = " ".join((h.get("content") or "").split())[:200] if show_body else "" - lines.append(f" - [{uri}] {excerpt}".rstrip()) + guidance = f" [use: {step}]" if (step := _next_step(h)) else "" + lines.append(f" - [{uri}] {excerpt}".rstrip() + guidance) if conv_hits: lines.append("\nConversation hits:") for h in conv_hits[:top_k]: diff --git a/tests/integration/test_code_result_lessons.py b/tests/integration/test_code_result_lessons.py index 81ca1db6440..bf5306abd9f 100644 --- a/tests/integration/test_code_result_lessons.py +++ b/tests/integration/test_code_result_lessons.py @@ -261,7 +261,11 @@ async def test_lessons_match_the_result_file_by_path( keys = {r["memory_key"] for r in rows} assert keys == {"notes/exact", "notes/bare", "design/memo", "notes/long"}, rows by_key = {r["memory_key"]: r for r in rows} - assert by_key["notes/exact"] == { + exact = by_key["notes/exact"] + guidance = exact["use_guidance"] + assert guidance["next_step"] == "validate_lead" + assert guidance["freshness"]["code"] == "not_applicable" + assert {key: value for key, value in exact.items() if key != "use_guidance"} == { "path": PATH, "memory_key": "notes/exact", "namespace": "dev", diff --git a/tests/integration/test_retrieved_use_guidance.py b/tests/integration/test_retrieved_use_guidance.py new file mode 100644 index 00000000000..c9e4c880daa --- /dev/null +++ b/tests/integration/test_retrieved_use_guidance.py @@ -0,0 +1,49 @@ +"""One memory revision has the same guidance in search and file recall.""" + +from __future__ import annotations + +import asyncio + +import pytest + +from tests.integration._resources import unique_org + + +@pytest.mark.asyncio +async def test_search_and_file_follow_reviewed_content(control_plane_url, mint_test_token): + from loom import Agent + + org = unique_org("retrieved-guidance") + ns = "decisions" + token = mint_test_token(org=org, namespaces=[ns], roles=["writer"]) + key = "refresh_catalog_index" + path = "catalog/refresh.py" + async with Agent( + org=org, namespace=ns, agent="writer", base_url=control_plane_url, api_key=token + ) as agent: + written = await agent.memory.set( + key, "Refresh the catalog index after imports.", files=[path] + ) + + async def check(review: str, step: str) -> None: + for _ in range(25): + file = await agent.call("memory.for_file", {"path": path}) + search = await agent.memory.search( + key, recipe="fast", auto_touch=False, namespace_scope="this" + ) + file_hits = [hit for hit in file["hits"] if hit["memory_key"] == key] + found = [hit for hit in search if hit.memory_key == key] + if file_hits and found and found[0].use_guidance: + guidance = found[0].use_guidance + if guidance["review"] == review: + assert guidance["next_step"] == step + assert guidance == file_hits[0]["use_guidance"] + return + await asyncio.sleep(0.2) + pytest.fail(f"{key} did not reach {review} on both read paths") + + await check("none", "validate_lead") + await agent.memory.verify(memory_id=written["memory_id"]) + await check("process", "validate_lead") + await agent.memory.update_by_id(written["memory_id"], "Refresh the catalog before imports.") + await check("stale", "obtain_review") diff --git a/tests/unit/test_context_pack_decisions.py b/tests/unit/test_context_pack_decisions.py index edda2ff8e73..efa469a1df7 100644 --- a/tests/unit/test_context_pack_decisions.py +++ b/tests/unit/test_context_pack_decisions.py @@ -306,3 +306,39 @@ def test_every_governed_definition_leads_the_memories_block( block = out.sections["memories"] positions = [block.index(f"term {i}") for i in range(4)] assert positions == sorted(positions) and positions[-1] < block.index("a resource row") + + +@pytest.mark.parametrize("matches", [True, False]) +def test_guided_decision_uses_the_served_statement( + monkeypatch: pytest.MonkeyPatch, matches: bool +) -> None: + from server.memory.domain.decision_statement import memory_value + from server.memory.domain.use_guidance import guidance_for_row + + _dead_other_sections(monkeypatch) + record = {"scenario": "pick a store", "outcome": "use SQLite", "stage": "decided"} + selected = record if matches else {**record, "outcome": "use ClickHouse"} + guidance = guidance_for_row({"status": "conflicted"}) + hit = NS( + **{ + **vars(_DECISION), + "content_excerpt": memory_value(selected), + "use_guidance": guidance, + } + ) + monkeypatch.setattr("server.memory.app.search.handle_memory_search", _search_stub([hit])) + + async def records(ch: Any, org: str, ns: str, keys: list[str]) -> dict[str, Any]: + return {"d1": record} + + monkeypatch.setattr("server.memory.app.decision._decision_records", records) + out = asyncio.run( + handle_context_pack(ContextPackInput(org="o", namespace="ns", agent="a", query="store")) + ) + + assert selected["outcome"] in out.sections["decisions"] + assert ("use SQLite" in out.sections["decisions"]) is matches + assert ("decided:" in out.sections["decisions"]) is matches + (item,) = out.use_guidance + assert item.citation == "decision:ns/d1" + assert item.use_guidance == guidance diff --git a/tests/unit/test_context_pack_served_rows.py b/tests/unit/test_context_pack_served_rows.py index c3d096ed662..ffd593399e6 100644 --- a/tests/unit/test_context_pack_served_rows.py +++ b/tests/unit/test_context_pack_served_rows.py @@ -13,6 +13,7 @@ from server.memory.api.models_context import ContextPackInput from server.memory.app.context_pack import handle_context_pack from server.memory.domain.context_layout import served_rows +from server.memory.domain.use_guidance import guidance_for_row from tests.unit.checked_pack_fakes import install_pack_stack, install_pack_target @@ -67,6 +68,8 @@ def test_a_stack_section_cut_to_its_budget_records_the_rows_it_kept( monkeypatch: pytest.MonkeyPatch, ) -> None: entries = [_entry("profile", "role", 20)] + [_entry("pinned", f"p{i}", 150) for i in range(6)] + for i, entry in enumerate(entries[1:]): + entry.use_guidance = guidance_for_row({"status": "conflicted" if i % 2 else "active"}) _stub_all_but_the_stack(monkeypatch, entries) out = asyncio.run( handle_context_pack( @@ -88,6 +91,9 @@ def test_a_stack_section_cut_to_its_budget_records_the_rows_it_kept( # every recorded row's line is in what the agent got; the profile line is no row assert all(f"[pinned/{k} by=" in shown for k in kept) assert f"[pinned/p{len(kept)} by=" not in shown + assert [(item.citation, item.item_index, item.use_guidance) for item in out.use_guidance] == [ + (f"stack:pinned/{key}", i + 1, entries[i + 1].use_guidance) for i, key in enumerate(kept) + ] def test_a_chunk_the_pack_serves_records_its_parent_fact(monkeypatch: pytest.MonkeyPatch) -> None: diff --git a/tests/unit/test_loom_search_repo_decisions.py b/tests/unit/test_loom_search_repo_decisions.py index fb73d001301..18e9ba99877 100644 --- a/tests/unit/test_loom_search_repo_decisions.py +++ b/tests/unit/test_loom_search_repo_decisions.py @@ -634,6 +634,71 @@ async def aggregate(ctx: Any) -> dict[str, Any]: assert settled.legs == ["memory"] +@pytest.mark.asyncio +async def test_merged_repository_decision_keeps_exact_authorized_guidance( + search_env, + monkeypatch, +) -> None: + from dataclasses import replace + + from server.memory.app.search import guidance, handle_memory_search + + visible = replace( + _svc_hit("decision:evict", sim=0.9, mtype="decision"), + identity=("a", "alice", "s1"), + version=42, + ) + hidden = replace( + _svc_hit("decision:private", sim=0.8, mtype="decision"), + identity=("a", "bob", "s1"), + version=43, + ) + search_env.hits_by_ns[TRUNK] = [visible, hidden] + key = (ORG, TRUNK, "a", "alice", "s1", visible.memory_key) + seen: list[tuple[str, ...]] = [] + + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + seen.extend(keys) + return { + key: { + "version": 42, + "status": "active", + "source_class": "asserted", + "verified_by": "human:reviewer", + "verified_sha256": "a" * 64, + "content_sha256": "a" * 64, + } + } + + monkeypatch.setattr(guidance, "guidance_heads", heads) + inp = BASE.model_copy(update={"render": "", "tags": [], "namespace_scope": "this"}) + set_current_auth( + AuthInfo( + subject="sa:bot", + org=ORG, + namespaces=("me", TRUNK), + roles=(), + is_service_account=True, + read_user_id="alice", + ) + ) + try: + direct = await handle_memory_search( + inp.model_copy(update={"namespace": TRUNK, "memory_type": "decision"}) + ) + merged = await repo_decisions.memory_with_repo_decisions(inp, repo_namespace=TRUNK) + payload = await _assemble(monkeypatch, merged, explain=True) + finally: + set_current_auth(None) + + (direct_hit,) = direct.results + assert direct_hit.use_guidance is not None and direct_hit.use_guidance.review == "human" + (row,) = payload["memory"]["results"] + assert row["memory_key"] == visible.memory_key + assert row.get("use_guidance") == direct_hit.use_guidance.model_dump() + assert seen == [key, key] + + @pytest.mark.asyncio async def test_an_empty_repository_is_searched_once(search_env, monkeypatch) -> None: """The merged pass runs no read-your-writes re-read: an empty trunk is diff --git a/tests/unit/test_mcp_lean_results.py b/tests/unit/test_mcp_lean_results.py index cf51eb4cfa7..9702dd09eea 100644 --- a/tests/unit/test_mcp_lean_results.py +++ b/tests/unit/test_mcp_lean_results.py @@ -7,8 +7,16 @@ import json import re +from server.memory.api.models_loom_search import SearchOutput +from server.memory.domain.use_guidance import guidance_for_row from server.transport import mcp_call, mcp_outcome, mcp_tools -from server.transport.lean_results import DIAGNOSTIC_KEYS, lean, lean_result +from server.transport.lean_results import ( + DIAGNOSTIC_KEYS, + lean, + lean_pack, + lean_result, + lean_search_result, +) # A representative loom_search payload, cut down: two fact hits, one episodic chunk, the reader paragraph, the # retrieval accounting. The answer is one word. @@ -273,3 +281,43 @@ def test_loom_search_hits_drop_the_metadata_the_model_never_acts_on() -> None: h2 = lean_search_result(p, {}, "alice")["memory"]["results"][0] assert h2["namespace"] == "core-tracker" and "created_at" not in h2 and h2["valid_at"] assert lean_search_result(PAYLOAD, {"explain": True}, "alice") is PAYLOAD + + +def test_lean_mcp_preserves_the_exact_guidance_of_each_served_item() -> None: + memory = guidance_for_row({"status": "conflicted"}).model_dump() + document = guidance_for_row( + {"source_class": "external"}, code_state="not_applicable" + ).model_dump() + payload = { + "memory": {"results": [{"memory_key": "one", "use_guidance": memory}]}, + "knowledge": { + "results": [{"source_uri": "doc", "content": "claim", "use_guidance": document}] + }, + } + full = SearchOutput.model_validate( + {**payload, "profile": {"error": "unavailable"}} + ).model_dump() + assert full["memory"] == payload["memory"] + assert full["knowledge"] == payload["knowledge"] + assert full["profile"] == {"error": "unavailable"} + assert SearchOutput(memory={"error": "unavailable", "results": []}).model_dump()["memory"] == { + "error": "unavailable", + "results": [], + } + lean_search = lean_search_result(full, {"bodies": "none"}) + assert lean_search["memory"]["results"][0]["use_guidance"] == memory + assert lean_search["knowledge"]["results"][0]["use_guidance"] == document + context = lean_pack( + { + "rendered": "claim", + "use_guidance": [ + { + "section": "knowledge", + "citation": "doc", + "item_index": 0, + "use_guidance": document, + } + ], + } + ) + assert context["use_guidance"][0]["use_guidance"] == document diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 9b37277c31a..4e27dd1b21d 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -160,8 +160,13 @@ def test_code_search_runs_as_the_pinned_user_whatever_the_body_says() -> None: def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", **kw: Any) -> dict: + from server.memory.app.code_link_reads import inputs_hash + return LINK_COLS | { "memory_id": mid, + "namespace": "agent-a", + "code_namespace": "code-a", + "inputs_hash": inputs_hash("a" * 64, [], "code-a", "user"), "qualified_name": qn, "path": kw.get("path", "src/a.py"), "former": kw.get("former", []), @@ -175,6 +180,11 @@ def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", ** def _excerpt(mid: str, key: str, *, pinned: int = 0) -> dict: return { "mid": mid, + "memory_id": mid, + "content_sha256": b"a" * 64, + "user_id": "user", + "files": [], + "tags": [], "memory_key": key, "namespace": "agent-a", "excerpt": key, @@ -238,7 +248,12 @@ async def current(org, rows): monkeypatch.setattr(memory_links, "indexed_head", head) monkeypatch.setattr(memory_links, "parsed", parsed) monkeypatch.setattr(memory_links, "mirror_here", mirror_here) + + async def for_memories(org, ids): + return [link for link in links if link["memory_id"] in ids] + monkeypatch.setattr(memory_links, "trunk_namespace", lambda org, n: "code-a") + monkeypatch.setattr(code_links, "for_memories", for_memories) monkeypatch.setattr(store, "served_excerpts", served) monkeypatch.setattr("server.memory.app.code_link_reads.current_links", current) return await code_plane_reads.lessons_for_symbol( @@ -256,11 +271,43 @@ async def test_symbol_lessons_keep_whole_values_and_honor_an_opt_in_budget(monke whole = await _lessons(monkeypatch, links, excerpts, definitions) assert whole[0]["excerpt"] == value assert len(whole) == 2 - monkeypatch.setattr(settings, "code_result_lessons_tokens", 80) + assert whole[1]["use_guidance"]["next_step"] == "validate_lead" + monkeypatch.setattr(settings, "code_result_lessons_tokens", 180) bounded = await _lessons(monkeypatch, links, excerpts, definitions) assert [row["memory_key"] for row in bounded] == ["short"] +@pytest.mark.asyncio +async def test_code_guidance_reads_only_authorized_repository_bindings(monkeypatch) -> None: + from server.memory.app import code_link_reads + + allowed = _excerpt("m1", "allowed") | {"namespace": "code-a"} + hidden = _excerpt("m2", "hidden") | {"namespace": "code-hidden"} + unresolved = _excerpt("m3", "unresolved") | {"namespace": "unbound", "tags": ["repo:abc"]} + unbound = _excerpt("m4", "unbound") | {"namespace": "unbound"} + visible = _link("m1", state="changed") | {"namespace": "code-a"} + stale = _link("m1", state="missing") | {"namespace": "code-a", "inputs_hash": "old"} + + async def readable(org, namespaces): + assert namespaces == {"code-a", "code-hidden"} + return {"code-a"} + + async def links(org, ids): + assert ids == ["m1"] + return [visible, stale] + + monkeypatch.setattr( + code_link_reads, + "code_namespace_for", + lambda org, ns, tags: ns if ns.startswith("code-") else "", + ) + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", links) + assert await code_link_reads.guidance_code_states( + "o", [allowed, hidden, unresolved, unbound] + ) == ["changed", "unknown", "unknown", "not_applicable"] + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] @@ -289,6 +336,17 @@ async def test_a_lesson_reads_changed_where_the_definition_differs_from_the_link branch = [("src/a.py", "src.a::Reader::read", "h0")] out = await _lessons(monkeypatch, links, excerpts, branch, ns="code-a-26-8") assert {o["memory_key"]: o["code_state"] for o in out} == {"k1": "changed", "k2": "fresh"} + assert out[0]["use_guidance"]["freshness"]["code"] == "changed" + assert out[1]["use_guidance"]["freshness"]["code"] == "changed" + assert out[1]["use_guidance"]["next_step"] == "recheck_source" + + +@pytest.mark.asyncio +async def test_symbol_lesson_ignores_a_link_for_a_different_value(monkeypatch) -> None: + links = [_link("m1")] + excerpts = [_excerpt("m1", "k1") | {"content_sha256": b"b" * 64}] + definitions = [("src/a.py", "src.a::Reader::read", "h1")] + assert await _lessons(monkeypatch, links, excerpts, definitions) == [] @pytest.mark.asyncio diff --git a/tests/unit/test_memory_for_file.py b/tests/unit/test_memory_for_file.py index 94efce86067..644b388d6a2 100644 --- a/tests/unit/test_memory_for_file.py +++ b/tests/unit/test_memory_for_file.py @@ -413,7 +413,7 @@ async def test_an_escaped_constraint_under_the_ceiling_prints_whole( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.truncated is False - assert out.rendered.splitlines()[1] == f"- rules/zh [constraint]: {text}" + assert out.rendered.splitlines()[1] == f"- rules/zh [constraint]: {text} [use: validate_lead]" @pytest.mark.asyncio @@ -432,7 +432,9 @@ async def test_an_emoji_constraint_under_the_ceiling_prints_whole( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.truncated is False - assert out.rendered.splitlines()[1] == f"- rules/emoji [constraint]: {text}" + assert ( + out.rendered.splitlines()[1] == f"- rules/emoji [constraint]: {text} [use: validate_lead]" + ) def test_a_more_line_from_a_left_out_constraint_fits_the_budget( @@ -742,7 +744,7 @@ async def test_the_source_is_read_into_the_hit_and_the_block( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.rendered.splitlines()[1] == ( - f"- design/spill [decision] (pinned): Decided X because Y. — source: {_SOURCE}" + f"- design/spill [decision] (pinned): Decided X because Y. — source: {_SOURCE} [use: validate_lead]" ) assert out.hits[0].source_resource_id == _SOURCE @@ -979,27 +981,36 @@ def test_a_cut_object_value_prints_as_stored() -> None: def test_a_decision_whose_source_changed_says_so_pinned_or_not() -> None: tags = ["decision", "source-changed"] - pinned = _lines([_decision("design/p", tags=tags)])[1] + evidence = {"use_guidance": {"freshness": {"source": "changed"}, "next_step": "recheck_source"}} + pinned = _lines([_decision("design/p", tags=tags) | evidence])[1] assert pinned.startswith("- Decision (by alice, 3 days ago) (pinned) (source changed): ") - own = _lines([_decision("design/u", tags=tags, pinned=False, namespace="me")])[1] + own = _lines([_decision("design/u", tags=tags, pinned=False, namespace="me") | evidence])[1] assert own.startswith("- design/u [decision] (source changed): ") # A fact carrying the tag is no decision: nothing is added. fact = _row("fact", json.dumps("A plain fact."), tags=["source-changed"], namespace="me") - assert "(source changed" not in _lines([fact])[1] + assert "(source changed" not in _lines([fact | evidence])[1] @pytest.mark.asyncio -async def test_the_served_block_marks_a_decision_whose_source_changed( - monkeypatch: pytest.MonkeyPatch, +@pytest.mark.parametrize("source_state", ["changed", "unknown"]) +async def test_the_served_block_marks_only_a_checked_source_change( + monkeypatch: pytest.MonkeyPatch, source_state: str ) -> None: rows = [ _decision("extracted", "Decided spill.", pinned=False, tags=["decision", "source-changed"]) ] + + async def states(org, selected): + assert len(selected) == 1 and selected[0]["memory_key"] == "extracted" + return [source_state] + + monkeypatch.setattr(mff, "guidance_source_states", states) monkeypatch.setattr(mff, "get_client", lambda: _CH(rows)) out = await mff.handle_memory_for_file( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp", token_budget=300) ) - assert "- extracted [decision] (source changed): Decided spill." in out.rendered + assert ("(source changed)" in out.rendered) is (source_state == "changed") + assert out.hits[0].use_guidance.freshness.source == source_state def test_an_attested_decision_whose_source_changed_reads_source_changed() -> None: @@ -1007,6 +1018,7 @@ def test_an_attested_decision_whose_source_changed_reads_source_changed() -> Non hit = _decision( "design/a", pinned=False, tags=["decision", "source-changed"], verification="human" ) + hit["use_guidance"] = {"freshness": {"source": "changed"}, "next_step": "recheck_source"} line = _lines([hit])[1] assert line.startswith("- Decision (by alice, 3 days ago) (source changed): ") diff --git a/tests/unit/test_pg_authority.py b/tests/unit/test_pg_authority.py index 28b1555e40a..c544a727afa 100644 --- a/tests/unit/test_pg_authority.py +++ b/tests/unit/test_pg_authority.py @@ -1818,22 +1818,35 @@ def _page_input(top_k: int) -> Any: return MemorySearchInput(org="o", namespace="n", query="q", top_k=top_k) +@pytest.fixture +def current_parked_heads(monkeypatch: pytest.MonkeyPatch) -> None: + from server.memory.app.search import guidance + + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + return {key: {"version": 42 if key[-1] == "k1" else 5, "status": "active"} for key in keys} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + + @pytest.mark.asyncio -async def test_a_parked_page_keeps_each_hits_identity(monkeypatch: pytest.MonkeyPatch) -> None: +async def test_a_parked_page_keeps_each_hits_identity( + monkeypatch: pytest.MonkeyPatch, current_parked_heads: None +) -> None: from server.core import pg from server.memory.app.search.output import _parked_slice with monkeypatch.context() as m: # parked under the Postgres authority m.setattr(pg, "enabled", lambda: True) - payload = _parked_page([_hit("k1"), _hit("k2", user=None)]) + payload = _parked_page([_hit("k1", version=42), _hit("k2", user=None)]) hits, nxt, _ = await _parked_slice(_page_input(2), payload, 0, {"n"}) - assert [h._row_identity for h in hits] == [("a", "u", "s"), None] + assert [h._row_identity for h in hits] == [("a", "u", "s")] assert nxt == -1 @pytest.mark.asyncio async def test_a_parked_page_reads_on_past_stale_rows_and_resumes_after_the_last_served( monkeypatch: pytest.MonkeyPatch, + current_parked_heads: None, ) -> None: from server.memory.app.search import pg_validation from server.memory.app.search.output import _parked_slice @@ -1851,7 +1864,9 @@ async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: @pytest.mark.asyncio -async def test_an_as_of_replays_pages_are_served_unchecked(monkeypatch: pytest.MonkeyPatch) -> None: +async def test_an_as_of_replay_page_does_not_inherit_current_guidance( + monkeypatch: pytest.MonkeyPatch, current_parked_heads: None +) -> None: from server.memory.api.models_search import MemorySearchInput from server.memory.app import search_pages from server.memory.app.search import output, pg_validation @@ -1876,6 +1891,9 @@ async def _load(*a: Any, **kw: Any) -> dict[str, Any]: ) out = await output._serve_parked_page(page) assert [h.memory_key for h in out.results] == ["a", "b"] and out.stale_dropped == 0 + assert all( + h.use_guidance is not None and h.use_guidance.review == "unknown" for h in out.results + ) @pytest.mark.parametrize("namespace", ["*", ""]) @@ -1890,13 +1908,14 @@ async def test_a_namespace_named_like_a_policy_scope_is_refused(namespace: str) await pg_memory.commit_versions([row], [{}]) -def test_a_page_parked_under_clickhouse_carries_no_postgres_fields() -> None: +def test_a_page_parked_under_clickhouse_carries_revision_without_chunk_identity() -> None: from server.memory.app.search_pages import _parked hit = _hit("k1") hit._row_version, hit._row_chunk = 42, ("a", "u", 3, "sha") parked = _parked(hit) - assert not {"row_chunk", "row_version"} & set(parked) + assert "row_chunk" not in parked + assert parked["row_version"] == 42 # The row's identity is kept: a later page tells a shared definition by it. assert "row_identity" in parked @@ -1904,6 +1923,7 @@ def test_a_page_parked_under_clickhouse_carries_no_postgres_fields() -> None: @pytest.mark.asyncio async def test_a_parked_page_keeps_each_hits_chunk_and_version( monkeypatch: pytest.MonkeyPatch, + current_parked_heads: None, ) -> None: from server.core import pg from server.memory.app.search.output import _parked_slice @@ -2380,9 +2400,11 @@ async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: @pytest.mark.asyncio -async def test_a_parked_page_under_clickhouse_resumes_past_the_rows_a_caller_lost() -> None: - """Without the Postgres authority nothing is checked; a full page followed by rows of a - namespace the caller lost hands the next page the first of them.""" +async def test_a_parked_page_under_clickhouse_resumes_past_the_rows_a_caller_lost( + current_parked_heads: None, +) -> None: + """A full page followed by rows of a namespace the caller lost hands the next page + the first of them.""" from server.memory.app.search.output import _parked_slice lost = _hit("lost") @@ -2992,7 +3014,9 @@ async def _start() -> None: @pytest.mark.asyncio -async def test_a_parked_page_checks_at_most_two_windows(monkeypatch: pytest.MonkeyPatch) -> None: +async def test_a_parked_page_checks_at_most_two_windows( + monkeypatch: pytest.MonkeyPatch, current_parked_heads: None +) -> None: """A tail mostly stale is not read a window at a time: the first window, then four rows for each hit still missing, in one check; a page still short hands on the rest.""" from server.memory.app.search import pg_validation @@ -3018,6 +3042,7 @@ async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: @pytest.mark.asyncio async def test_an_empty_parked_page_with_more_behind_it_does_not_abstain( monkeypatch: pytest.MonkeyPatch, + current_parked_heads: None, ) -> None: from server.memory.api.models_search import MemorySearchInput from server.memory.app import search_pages diff --git a/tests/unit/test_procedure_ops.py b/tests/unit/test_procedure_ops.py index 4984b8e13c6..1edb91cb5a9 100644 --- a/tests/unit/test_procedure_ops.py +++ b/tests/unit/test_procedure_ops.py @@ -89,6 +89,10 @@ def test_match_labels_status_and_lists_candidates_last(monkeypatch: pytest.Monke ) assert [m.memory_key for m in out.matches] == ["p:auth", "p:run", "p:tpl", "p:mined"] assert [m.status for m in out.matches] == ["authored", "exercised", "template", "candidate"] + assert [ + match["use_guidance"]["lifecycle"]["procedure_status"] + for match in out.model_dump()["matches"] + ] == ["authored", "exercised", "template", "candidate"] out = asyncio.run( handle_procedure_match( diff --git a/tests/unit/test_rust_search_contract.py b/tests/unit/test_rust_search_contract.py index a12aeaa8b9f..b2bd9c5aa38 100644 --- a/tests/unit/test_rust_search_contract.py +++ b/tests/unit/test_rust_search_contract.py @@ -41,3 +41,10 @@ def test_selected_contracts_and_default_fixtures_are_generated_without_a_toolcha assert "pub flag: Option" in fixture assert 'serde_json::from_str("false")' in fixture assert "DefaultsLabel::Empty" in fixture + + +def test_unified_search_sections_keep_rust_map_access(monkeypatch) -> None: + monkeypatch.setattr(gen, "rustfmt", lambda text: text) + source = gen.build(("search.query",)) + for section in ("memory", "knowledge"): + assert f"pub {section}: std::collections::HashMap" in source diff --git a/tests/unit/test_sdk_memory_tool_receipts.py b/tests/unit/test_sdk_memory_tool_receipts.py index 04aa36a19e9..0b8daed4b1f 100644 --- a/tests/unit/test_sdk_memory_tool_receipts.py +++ b/tests/unit/test_sdk_memory_tool_receipts.py @@ -12,6 +12,7 @@ from server.memory.api.models_crud import MemorySetOutput from server.memory.api.models_search import MemorySearchOutput, _MemorySearchHit +from server.memory.domain.use_guidance import guidance_for_row def _agent(reply: dict[str, Any]) -> tuple[Agent, list[dict[str, Any]]]: @@ -75,6 +76,7 @@ async def test_remember_preserves_the_wire_receipt(receipt: dict[str, Any], stor @pytest.mark.parametrize("state", ["fresh", "changed", "unresolved", "missing"]) async def test_recall_keeps_code_state_and_provenance(state: str) -> None: + guidance = guidance_for_row({"status": "conflicted"}, code_state=state) hit = _MemorySearchHit( memory_key="claim", memory_type="semantic", @@ -82,6 +84,7 @@ async def test_recall_keeps_code_state_and_provenance(state: str) -> None: similarity=0.9, distance=0.1, code_state=state, + use_guidance=guidance, status="conflicted", source_class="external", source_resource_id="src/reader.py", @@ -95,6 +98,10 @@ async def test_recall_keeps_code_state_and_provenance(state: str) -> None: try: out = json.loads(await agent.tools().execute("loom_recall", {"query": "reader"})) assert out["abstain"] is False + assert out["memories"][0]["use_guidance"] == guidance.model_dump() + from loom.memory import _parse_search_hit + + assert _parse_search_hit(reply["results"][0]).use_guidance == guidance.model_dump() for field in ( "code_state", "status", diff --git a/tests/unit/test_sdk_py_generated.py b/tests/unit/test_sdk_py_generated.py index 1e2dd85dcfe..3a4884054f5 100644 --- a/tests/unit/test_sdk_py_generated.py +++ b/tests/unit/test_sdk_py_generated.py @@ -87,3 +87,13 @@ def name(op_name: str, suffix: str, model: type) -> str: assert spec.output == name(op.name, "Output", op.output_model), op.name text = (ROOT / "sdk" / "python" / "loom" / "ops.py").read_text() assert "MemoryGetOutput2" not in text and "MemoryPinInput" not in text + + +def test_unified_search_sections_keep_python_dict_access() -> None: + from typing import Any, get_type_hints + + from loom import ops + + hints = get_type_hints(ops.SearchQueryOutput) + assert hints["memory"] == dict[str, Any] + assert hints["knowledge"] == dict[str, Any] diff --git a/tests/unit/test_sdk_ts_generated.py b/tests/unit/test_sdk_ts_generated.py index fa7cb1b9926..091a0ab2ab3 100644 --- a/tests/unit/test_sdk_ts_generated.py +++ b/tests/unit/test_sdk_ts_generated.py @@ -46,3 +46,14 @@ def test_type_names_follow_the_model_not_the_op_order() -> None: declared = re.findall(r"^export (?:interface|type) (\w+)", text, re.M) assert len(declared) == len(set(declared)) assert not [n for n in declared if re.fullmatch(r"\w+\d", n) and n[:-1] in declared] + + +def test_unified_search_results_have_typed_guidance_and_open_fields() -> None: + from server.memory.api.models_loom_search import SearchOutput + + emitter = sdk_ts_gen.Emitter() + emitter.declare("SearchQueryOutput", SearchOutput.model_json_schema()) + assert "results?: SearchSectionHit[];" in emitter.decls["SearchSection"] + assert "use_guidance?: UseGuidance | null;" in emitter.decls["SearchSectionHit"] + for name in ("SearchSection", "SearchSectionHit"): + assert "[key: string]: unknown;" in emitter.decls[name] diff --git a/tests/unit/test_search_pages.py b/tests/unit/test_search_pages.py index db0ce127a4b..ddf9ec7caeb 100644 --- a/tests/unit/test_search_pages.py +++ b/tests/unit/test_search_pages.py @@ -9,11 +9,13 @@ from server.memory.api.models_search import _MemorySearchHit from server.memory.app import search_pages as sp +from server.memory.app.search import guidance +from server.memory.store.rows import IdentityKey from tests.unit._memory_search_pkg import patch_handler_name def _hit(key: str, rank: float, ns: str = "ns", session: str = "") -> _MemorySearchHit: - return _MemorySearchHit( + hit = _MemorySearchHit( memory_key=key, memory_type="semantic", content_excerpt=f"about {key}", @@ -22,7 +24,18 @@ def _hit(key: str, rank: float, ns: str = "ns", session: str = "") -> _MemorySea rank_score=rank, namespace=ns, session_id=session, + version=7, ) + hit._row_identity = ("writer", "user", session or "-") + return hit + + +@pytest.fixture(autouse=True) +def _current_heads(monkeypatch: pytest.MonkeyPatch) -> None: + async def heads(keys: list[IdentityKey]) -> dict[IdentityKey, dict[str, Any]]: + return {key: {"version": 7, "status": "active"} for key in keys} + + monkeypatch.setattr(guidance, "guidance_heads", heads) def _encode(top_k: int, candidates_total: int, tail: list[_MemorySearchHit], **lists: Any) -> str: @@ -196,7 +209,7 @@ async def test_serve_parked_page_slices_and_hands_back_the_next_handle(monkeypat assert out.next_page == sp.make_handle(key, 2) and out.abstain is False # Every page says what the first call read and what the cap left out. assert out.namespaces_searched == ["n", "work"] and out.namespaces_skipped == ["home"] - # No retrieval ran: the only statement was the blob read. + # The blob reader does no new retrieval. Guidance reads the exact authorized heads. assert len(ch.queries) == 1 and ch.inserts == [] out2 = await h.handle_memory_search(inp.model_copy(update={"page": out.next_page})) diff --git a/tests/unit/test_search_shared_definitions.py b/tests/unit/test_search_shared_definitions.py index b4ac41ece44..eb3901e4f20 100644 --- a/tests/unit/test_search_shared_definitions.py +++ b/tests/unit/test_search_shared_definitions.py @@ -14,9 +14,10 @@ from server.memory import store as memory_repo from server.memory.api.models_search import MemorySearchInput, _MemorySearchHit from server.memory.app import search_pages -from server.memory.app.search import handler, output, pg_validation +from server.memory.app.search import guidance, handler, output, pg_validation from server.memory.app.search.shared_definitions import without_withheld_definitions from server.memory.store import MemoryRow +from server.memory.store.rows import IdentityKey from server.observability import degradations @@ -52,7 +53,12 @@ async def _fresh(_org: str, _ns: str, hits: list[Any]) -> list[bool]: def _parked(key: str, agent: str) -> dict[str, Any]: """A hit as a parked page stores it.""" hit = _MemorySearchHit( - memory_key=key, memory_type="definition", content_excerpt="x", distance=0.1, similarity=0.9 + memory_key=key, + memory_type="definition", + content_excerpt="x", + distance=0.1, + similarity=0.9, + version=1, ) hit._row_identity = (agent, "-", "-") return search_pages._parked(hit) @@ -71,6 +77,10 @@ async def heads(identity: Any, keys: list[str], **kw: Any) -> list[Any]: held = state["heads"].get(identity.namespace, {}) return [held[k] for k in keys if k in held] + async def guidance_heads(keys: list[IdentityKey]) -> dict[IdentityKey, dict[str, Any]]: + return {key: {"version": 1, "status": "active"} for key in keys} + + monkeypatch.setattr(guidance, "guidance_heads", guidance_heads) monkeypatch.setattr(memory_repo, "get_many_by_keys", heads) return state diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py new file mode 100644 index 00000000000..a48c48e89fc --- /dev/null +++ b/tests/unit/test_search_use_guidance.py @@ -0,0 +1,215 @@ +"""Guidance for search results is bound to the authorized served head.""" + +from __future__ import annotations + +from typing import Any + +import pytest + +from server.identity.domain.read_scope import ReadFilters +from server.memory.api.models_search import MemorySearchInput, _MemorySearchHit +from server.memory.app import search_pages +from server.memory.app.search import guidance +from server.memory.store import pg_memory, reads +from server.memory.store.rows import IDENTITY_COLUMNS + +_INPUT = MemorySearchInput(org="o", namespace="n", query="deploy") +_KEY = ("o", "n", "a", "u", "s", "notes/deploy") + + +def _hit(*, version: int = 42, user: str = "u") -> _MemorySearchHit: + hit = _MemorySearchHit( + memory_key=_KEY[-1], + memory_type="semantic", + content_excerpt="a deployed excerpt", + distance=0, + similarity=1, + version=version, + ) + hit._row_identity = ("a", user, "s") + return hit + + +def _head(**fields: Any) -> dict[str, Any]: + return { + "version": 42, + "status": "active", + "source_class": "asserted", + "source_trace": "", + "source_resource_id": "", + "requires_review": 0, + "verified_by": "human:reviewer", + "verified_sha256": "a" * 64, + "content_sha256": "a" * 64, + "tags": [], + "files": [], + **fields, + } + + +@pytest.mark.asyncio +async def test_search_and_page_project_same_exact_authorized_revision( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + assert keys == [_KEY] + return {_KEY: _head()} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + assert await guidance.attach_search_guidance(_INPUT, [hit]) == [hit] + assert hit.use_guidance is not None and hit.use_guidance.review == "human" + parked = search_pages._parked(hit) + assert "use_guidance" not in parked + parked["use_guidance"] = hit.use_guidance.model_dump() + round_trip = search_pages.unparked(parked) + assert round_trip is not None and round_trip.use_guidance is None + assert await guidance.attach_search_guidance(_INPUT, [round_trip], parked=True) == [round_trip] + assert round_trip.use_guidance == hit.use_guidance + + +@pytest.mark.asyncio +@pytest.mark.parametrize("state", ["changed", "unknown"]) +async def test_parked_hit_refreshes_cached_code_state( + monkeypatch: pytest.MonkeyPatch, state: str +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + assert keys == [_KEY] + return {_KEY: _head()} + + async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: + return [state] + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "guidance_code_states", code_states) + hit = _hit() + hit.code_state = "fresh" + parked = search_pages.unparked(search_pages._parked(hit)) + assert parked is not None + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] + assert parked.use_guidance is not None and parked.use_guidance.freshness.code == state + assert parked.code_state == ("changed" if state == "changed" else "") + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + "head", + [ + None, + _head(version=43), + _head(tombstoned_at="now"), + _head(redacted_at="now"), + _head(sensitivity="high"), + _head(status="rejected"), + ], +) +async def test_parked_hit_cannot_keep_guidance_after_edit_or_erasure( + monkeypatch: pytest.MonkeyPatch, + head: dict[str, Any] | None, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + assert keys == [_KEY] + return {} if head is None else {_KEY: head} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + fresh = await guidance.attach_search_guidance(_INPUT, [hit]) + if head is not None and head.get("version") == 43: + assert fresh == [hit] + assert hit.use_guidance is not None and hit.use_guidance.review == "unknown" + else: + assert fresh == [] + assert await guidance.attach_search_guidance(_INPUT, [hit], parked=True) == [] + + +@pytest.mark.asyncio +async def test_narrower_page_scope_never_reads_or_serves_another_users_evidence( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + assert keys == [_KEY] + return {_KEY: _head()} + + monkeypatch.setattr(guidance, "request_scope", lambda: ReadFilters("own_user", "u", None)) + monkeypatch.setattr(guidance, "guidance_heads", heads) + mine, other = _hit(), _hit(user="other") + assert await guidance.attach_search_guidance(_INPUT, [mine, other], parked=True) == [mine] + assert other.use_guidance is None + + +@pytest.mark.asyncio +async def test_unavailable_current_evidence_cannot_reuse_a_parked_approval( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + raise OSError("store unreachable") + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + assert await guidance.attach_search_guidance(_INPUT, [hit]) == [hit] + assert hit.use_guidance is not None and hit.use_guidance.review == "unknown" + assert await guidance.attach_search_guidance(_INPUT, [hit], parked=True) == [] + + +@pytest.mark.asyncio +async def test_replay_keeps_only_an_authorized_exact_parked_revision( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + return {_KEY: _head()} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + current, historical = _hit(), _hit(version=41) + assert await guidance.attach_search_guidance( + _INPUT, [current, historical], parked=True, replay=True + ) == [current] + assert current.use_guidance is not None and current.use_guidance.review == "unknown" + + +@pytest.mark.asyncio +async def test_postgres_guidance_projection_decodes_sparse_defaults( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def fetch(query: str, *params: Any) -> list[dict[str, Any]]: + assert params[:6] == tuple([part] for part in _KEY) + assert "value" not in params[6] + return [ + { + **dict(zip(IDENTITY_COLUMNS, _KEY, strict=True)), + "evidence": {"version": 42, "source_class": "asserted", "requires_review": 0}, + } + ] + + monkeypatch.setattr(pg_memory.pg, "enabled", lambda: True) + monkeypatch.setattr(pg_memory.pg, "fetch", fetch) + heads = await reads.guidance_heads([_KEY]) + assert heads[_KEY]["status"] == "active" + assert heads[_KEY]["verified_by"] == "" + assert heads[_KEY]["source_trace"] == "" + assert heads[_KEY]["tags"] == [] + assert "value" not in heads[_KEY] + + +@pytest.mark.asyncio +async def test_source_lookup_failure_keeps_authorized_code_evidence( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + return {_KEY: _head(source_class="external", source_resource_id="doc")} + + async def source_states(org: str, rows: list[dict[str, Any]]) -> list[str]: + assert org == "o" and len(rows) == 1 + raise TimeoutError + + async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: + return ["changed"] + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "guidance_source_states", source_states) + monkeypatch.setattr(guidance, "guidance_code_states", code_states) + hit = _hit() + assert await guidance.attach_search_guidance(_INPUT, [hit]) == [hit] + assert hit.use_guidance is not None + assert hit.use_guidance.freshness.source == "unknown" + assert hit.use_guidance.freshness.code == "changed" + assert hit.use_guidance.next_step == "recheck_source" diff --git a/tests/unit/test_source_checked_pack.py b/tests/unit/test_source_checked_pack.py index 5b11af35da1..9f8000d3587 100644 --- a/tests/unit/test_source_checked_pack.py +++ b/tests/unit/test_source_checked_pack.py @@ -22,6 +22,7 @@ from server.memory.api.models_lifecycle import _StackEntry from server.memory.app import context_pack, stack, stack_knowledge from server.memory.domain.context_layout import _DEFAULT_SECTION_TOKENS +from server.memory.domain.use_guidance import guidance_for_row from server.settings import settings @@ -112,6 +113,10 @@ def passage(name): tags=[], distance=0.1, similarity=0.9, + use_guidance=guidance_for_row( + {"source_class": "imported" if name.startswith("private") else "asserted"}, + code_state="not_applicable", + ), ) class Renderer: @@ -172,8 +177,11 @@ def build(*, private=True, large=False): "private-stack" * (50 if large and private else 1) if private else "ordinary-stack", [], 0.1, + source_class="imported" if private else "asserted", + ) + ordinary = ChunkHit( + "docs", "ordinary-stack", 0, "ordinary-stack", [], 0.2, source_class="asserted" ) - ordinary = ChunkHit("docs", "ordinary-stack", 0, "ordinary-stack", [], 0.2) knowledge = stack_knowledge.StackKnowledge( [mixed], [ordinary], SearchProofs(plan, "fake", (items["stack"],)) if private else None ) @@ -188,11 +196,19 @@ async def test_loss_of_either_pool_rebuilds_the_entire_ordinary_pack(world, pool checked = world.build() mixed = await checked.current() assert "private-direct" in mixed.rendered and "private-stack" in mixed.rendered + assert [item.use_guidance.source_class for item in mixed.use_guidance] == [ + "imported", + "imported", + ] world.state.revoked.add(pool) actual = await checked.current() expected = await world.build(private=False).current() assert actual.model_dump() == expected.model_dump() assert actual._served_rows == expected._served_rows + assert [item.use_guidance.source_class for item in actual.use_guidance] == [ + "asserted", + "asserted", + ] assert checked.lost and checked.fresh() assert world.state.renders == ["ordinary-direct"] assert (await checked.current()).model_dump() == expected.model_dump() diff --git a/tests/unit/test_term_leg.py b/tests/unit/test_term_leg.py index 24a73776148..087dfe7ef1a 100644 --- a/tests/unit/test_term_leg.py +++ b/tests/unit/test_term_leg.py @@ -892,13 +892,14 @@ async def test_parked_oversized_source_is_not_hydrated_by_the_shared_label_check governed_first: bool, ) -> None: from server.memory.app import definitions, search_pages - from server.memory.app.search import output + from server.memory.app.search import guidance, output from server.memory.store import reads store["rows"] = [_row("definition/arr", "ARR")] leg = await term_leg._read("o", "n", "what is ARR", set(), None, "m") ordinary = _hit("definition/ordinary", 0.5) ordinary.namespace = "n" + ordinary.version = 1 ordinary._row_identity = ("_shared", "-", "-") tail = [leg.hits[0], ordinary] if governed_first else [ordinary, leg.hits[0]] page = json.loads( @@ -942,6 +943,12 @@ async def heads(identity: Any, keys: list[str], **kwargs: Any) -> dict[str, Any] async def fresh(*args: Any) -> list[bool]: return [False] * len(args[-1]) + async def shared_heads( + org: str, keys: list[tuple[str, str]] + ) -> dict[tuple[str, str], dict[str, Any]]: + return {key: {"version": 1} for key in keys} + + monkeypatch.setattr(guidance, "shared_guidance_heads", shared_heads) monkeypatch.setattr(reads.pg, "enabled", lambda: True) monkeypatch.setattr(reads.pg_memory, "heads_for_identity", heads) monkeypatch.setattr(reads, "_hydrate", hydrate) diff --git a/tests/unit/test_use_guidance.py b/tests/unit/test_use_guidance.py new file mode 100644 index 00000000000..5380d075c0c --- /dev/null +++ b/tests/unit/test_use_guidance.py @@ -0,0 +1,92 @@ +"""The permitted next step for one revision with the evidence the reader can inspect.""" + +from typing import Any + +import pytest + +from server.core.hashing import sha256_value +from server.memory.domain.use_guidance import guidance_for_row + +SHA = sha256_value("read the index") +ROW = {"status": "active", "source_class": "asserted", "requires_review": False, "verified_by": ""} +REVIEW = {"verified_by": "human:reviewer", "verified_sha256": SHA, "content_sha256": SHA} + + +@pytest.mark.parametrize( + ("facts", "code", "dispute", "step", "reason"), + [ + ({}, "fresh", "none", "validate_lead", "no_attestation"), + ( + REVIEW | {"verified_by": "process:validator"}, + "fresh", + "none", + "validate_lead", + "process_review_current", + ), + (REVIEW, "fresh", "unknown", "follow_if_applicable", "human_review_current"), + ( + REVIEW | {"content_sha256": "f" * 64}, + "fresh", + "none", + "obtain_review", + "review_hash_mismatch", + ), + (REVIEW, "changed", "unresolved", "clarify_dispute", "dispute_unresolved"), + (REVIEW, "changed", "none", "recheck_source", "code_recheck_needed"), + (REVIEW, "unknown", "none", "validate_lead", "required_evidence_unknown"), + ( + REVIEW | {"status": "rejected"}, + "changed", + "unresolved", + "inspect_only", + "diagnostic_only", + ), + (REVIEW | {"requires_review": True}, "fresh", "none", "obtain_review", "review_pending"), + ], +) +def test_guidance(facts: dict[str, Any], code: str, dispute: str, step: str, reason: str) -> None: + row = {**ROW, **facts} + opts = dict(source_state="unchanged", code_state=code, dispute=dispute) + result = guidance_for_row(row, **opts) + assert result.next_step == step + assert result.reasons[0] == reason + assert result == guidance_for_row( + row | {"pinned": True, "verified": True, "recall_count": 999, "similarity": 1}, **opts + ) + + +def test_unknown_is_distinct_from_checked_absence_and_changed_bytes() -> None: + assert guidance_for_row({}).review == "unknown" + assert guidance_for_row(ROW).review == "none" + row = ROW | REVIEW | {"content_sha256": "", "value": '"read the index"'} + assert guidance_for_row(row).review == "human" + assert guidance_for_row(row | {"value_truncated": True}).review == "unknown" + assert ( + guidance_for_row(row | {"content_sha256": SHA.encode(), "value_truncated": True}).review + == "human" + ) + assert guidance_for_row(row | {"verified_sha256": "broken"}).review == "unknown" + + +def test_accumulates_independent_reasons_in_precedence_order() -> None: + row = ROW | REVIEW | {"tags": ["source-changed"], "requires_review": True} + result = guidance_for_row( + row, source_state="changed", code_state="changed", dispute="unresolved" + ) + assert result.reasons == [ + "dispute_unresolved", + "source_recheck_needed", + "code_recheck_needed", + "review_pending", + "human_review_current", + "source_asserted", + ] + + +def test_procedure_and_allegation_do_not_change_publication() -> None: + opts = dict(source_state="not_applicable", code_state="not_applicable") + for status, step in [("quarantined", "inspect_only"), ("candidate", "validate_lead")]: + assert guidance_for_row(ROW | REVIEW, procedure_status=status, **opts).next_step == step + result = guidance_for_row(ROW | {"status": "conflicted"}, **opts) + assert result.next_step == "clarify_dispute" + assert result.lifecycle.status == "conflicted" diff --git a/tests/unit/test_use_guidance_sources.py b/tests/unit/test_use_guidance_sources.py new file mode 100644 index 00000000000..cc74c35af22 --- /dev/null +++ b/tests/unit/test_use_guidance_sources.py @@ -0,0 +1,36 @@ +from types import SimpleNamespace +from unittest.mock import AsyncMock + +import pytest + +from server.knowledge.store import documents +from server.memory.app import use_guidance as source + + +@pytest.mark.asyncio +async def test_changed_source_requires_current_access_and_unambiguous_identity(monkeypatch): + docs = AsyncMock( + return_value=[ + SimpleNamespace(source_uri="public", access_json="", tags=[], blob_erased_at=None), + SimpleNamespace(source_uri="mirror", access_json="{}", tags=[], blob_erased_at=None), + ] + ) + gate = AsyncMock(side_effect=lambda org, ns, **kw: ns == "team") + monkeypatch.setattr(documents, "get_many_by_uris", docs) + monkeypatch.setattr(source, "row_in_scope", gate) + monkeypatch.setattr(source, "request_narrowed", lambda: False) + rows = [ + {"tags": ["source-changed"], "source_resource_id": "knowledge:" + cite} + for cite in ["team/public#intro", "hidden/doc#intro", "team/mirror#part", "team/a#b#part"] + ] + assert await source.guidance_source_states("org", rows) == [ + "changed", + "unknown", + "unknown", + "unknown", + ] + docs.assert_awaited_once_with("org", "team", ["mirror", "public"]) + docs.reset_mock() + monkeypatch.setattr(source, "request_narrowed", lambda: True) + assert await source.guidance_source_states("org", rows) == ["unknown"] * len(rows) + docs.assert_not_awaited() From f9112db31bf128bda33c1372ddab7fa3abbdb8cb Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:02:28 +0530 Subject: [PATCH 003/117] feat: show suggested use on dashboard search results Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/api/search.ts | 1 + frontend/src/components/GuidanceLabel.tsx | 14 ++++++++++++++ frontend/src/components/HeaderSearch.tsx | 2 ++ frontend/src/components/SearchWhy.test.tsx | 8 ++++++++ frontend/src/components/SearchWhy.tsx | 2 ++ frontend/src/views/RecallLab.tsx | 10 +++++++--- 6 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 frontend/src/components/GuidanceLabel.tsx diff --git a/frontend/src/api/search.ts b/frontend/src/api/search.ts index d82a7dc65bc..c5ee8016392 100644 --- a/frontend/src/api/search.ts +++ b/frontend/src/api/search.ts @@ -7,6 +7,7 @@ import type { Identity, RequestOpts, SearchScope } from "../api"; // ===== memory.search ===== export interface SearchHit { + use_guidance?: { next_step: string; reasons: string[] } | null; memory_key: string; memory_type: string; content_excerpt: string; diff --git a/frontend/src/components/GuidanceLabel.tsx b/frontend/src/components/GuidanceLabel.tsx new file mode 100644 index 00000000000..5fc41148889 --- /dev/null +++ b/frontend/src/components/GuidanceLabel.tsx @@ -0,0 +1,14 @@ +import type { SearchHit } from "../api"; + +export function GuidanceLabel({ hit, reasons = false }: { hit: SearchHit; reasons?: boolean }) { + const guidance = hit.use_guidance; + if (!guidance) return null; + return ( + + Suggested use: {guidance.next_step.replaceAll("_", " ")} + {reasons && guidance.reasons.length > 0 && ( + {guidance.reasons.map((reason) => reason.replaceAll("_", " ")).join(", ")} + )} + + ); +} diff --git a/frontend/src/components/HeaderSearch.tsx b/frontend/src/components/HeaderSearch.tsx index ccf4c206315..966345722e1 100644 --- a/frontend/src/components/HeaderSearch.tsx +++ b/frontend/src/components/HeaderSearch.tsx @@ -5,6 +5,7 @@ import { Button } from "@clickhouse/click-ui/Button"; import { Icon, type IconName } from "@clickhouse/click-ui/Icon"; import { Popover } from "@clickhouse/click-ui/Popover"; import { SearchField } from "@clickhouse/click-ui/SearchField"; +import { GuidanceLabel } from "./GuidanceLabel"; import { listMemories, browseNamespaces, @@ -782,6 +783,7 @@ export function HeaderSearch({ {e.agent ? `${displayAgent(e.agent)} · ` : ""} {e.content_excerpt || "(empty)"} + ); })} diff --git a/frontend/src/components/SearchWhy.test.tsx b/frontend/src/components/SearchWhy.test.tsx index dd4bb3d4c1b..6ef280cccf0 100644 --- a/frontend/src/components/SearchWhy.test.tsx +++ b/frontend/src/components/SearchWhy.test.tsx @@ -28,6 +28,14 @@ const open = async () => { describe("SearchWhy", () => { afterEach(cleanup); + it("shows the server's suggested action and reasons for the returned hit", async () => { + const guidance = { next_step: "recheck_source", reasons: ["code_recheck_needed", "human_review_current"] }; + render(); + const why = await open(); + expect(why).toHaveTextContent("Suggested use: recheck source"); + expect(why).toHaveTextContent("code recheck needed, human review current"); + }); + it("is one button until opened; the popover shows rank, similarity, score and the terms by magnitude", async () => { const { container } = render( +

#{rank} {similarity !== null && similarity {similarity}} diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 03a6f977ebd..78e5d4ca2c6 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -6,6 +6,7 @@ import { SearchField } from "@clickhouse/click-ui/SearchField"; import { Select } from "@clickhouse/click-ui/Select"; import { Table, type TableRowType } from "@clickhouse/click-ui/Table"; import { Tabs } from "@clickhouse/click-ui/Tabs"; +import { GuidanceLabel } from "../components/GuidanceLabel"; import { listMemories, searchMemory, listSearchTraceLog, type SearchHit, type SearchTraceLogRow } from "../api"; import { useStore, useIdentity } from "../lib/state"; import { PageContainer } from "../layout/PageContainer"; @@ -332,9 +333,12 @@ function scoreRow(row: RecallRow, i: number, top: number, open: (key: string) => { className: CARD_WIDE, label: ( - - {row.text} - + <> + + {row.text} + + {hit && } + ), }, { className: CARD, label: {hit ? hit.similarity.toFixed(3) : "—"} }, From e78e001df3a784cbe4fb09125d0c360d587c2b9c Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:22:29 +0530 Subject: [PATCH 004/117] fix: bind retrieval guidance to the content served Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/api/models_search.py | 1 + server/memory/app/for_file.py | 23 +++++++-- server/memory/app/search/guidance.py | 20 +++++++- server/memory/app/search/output.py | 5 +- server/memory/app/search/payload.py | 8 +++ server/memory/app/search_pages.py | 4 ++ server/memory/app/stack.py | 7 ++- server/memory/app/verify.py | 27 +++++----- tests/unit/test_memory_for_file.py | 13 +++++ tests/unit/test_memory_verify.py | 49 ++++++++++++++++--- tests/unit/test_search_use_guidance.py | 43 ++++++++++++++++ tests/unit/test_source_checked_pack.py | 33 +++++++++++++ .../test_unit_bodies_follow_hit_session.py | 31 ++++++++++++ 13 files changed, 237 insertions(+), 27 deletions(-) diff --git a/server/memory/api/models_search.py b/server/memory/api/models_search.py index 5636b02a23b..174e6b4a16e 100644 --- a/server/memory/api/models_search.py +++ b/server/memory/api/models_search.py @@ -542,6 +542,7 @@ def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, _row_version: int = 0 # A chunk made into its row's hit shows the chunk's type, not the row's. _chunk_typed: bool = False + _guidance_content_sha256: str = "" # The hit's code links in repositories the caller may read, as the search's code # annotation read them; None = not read (memory.ask reads them itself then). _code_links: list[dict[str, Any]] | None = None diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index b2f1601b708..a2c759dbedc 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -7,19 +7,20 @@ import logging from collections import defaultdict from datetime import UTC, datetime -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING, Any, Literal from server.code.app.common import repo_relative from server.core import pg from server.core.ch import get_client from server.core.datetimes import naive_utc_now, parse_iso_dt -from server.core.hashing import hash_text +from server.core.hashing import hash_text, served_row_value from server.core.repo_base import query_all_sliced from server.memory.api.models_for_file import ( MemoryForFileInput, MemoryForFileOutput, _MemoryForFileHit, ) +from server.memory.api.models_procedure import ProcedureStatus from server.memory.app.code_link_reads import guidance_code_states from server.memory.app.use_guidance import guidance_source_states from server.memory.domain import code_change @@ -768,6 +769,17 @@ async def current_file_rows(org: str, rows: list[dict[str, Any]]) -> list[dict[s return kept +def _file_procedure_status( + row: dict[str, Any], +) -> ProcedureStatus | Literal["unknown", "not_applicable"]: + from server.memory.app.procedure import _procedure_status + + if row.get("memory_type") != "procedural": + return "not_applicable" + value = served_row_value(row) if not row.get("value_truncated") else None + return _procedure_status(value) if isinstance(value, dict) else "unknown" + + async def guided_file_rows( org: str, rows: list[dict[str, Any]], *, local_code_changes: set[str] | None = None ) -> None: @@ -782,7 +794,12 @@ async def guided_file_rows( and state not in code_change.DEMOTED ): state = "changed" - row["use_guidance"] = guidance_for_row(row, code_state=state, source_state=source_state) + row["use_guidance"] = guidance_for_row( + row, + code_state=state, + source_state=source_state, + procedure_status=_file_procedure_status(row), + ) async def listing_rows( diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 2fb8c491522..d2fa36fdfbe 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -9,6 +9,7 @@ from typing import Any from server.core.datetimes import naive_utc_now, parse_iso_dt +from server.core.hashing import hash_text from server.identity.app.request_scope import request_scope from server.identity.domain.read_scope import row_in_read_scope from server.memory.api.models_search import MemorySearchInput, _MemorySearchHit @@ -16,6 +17,7 @@ from server.memory.app.search.pg_validation import doc_key, doc_version from server.memory.app.use_guidance import guidance_source_states from server.memory.domain.code_change import worst +from server.memory.domain.redaction_lineage import is_content_hash from server.memory.domain.search_types import SHARED_AGENT, is_shared_row from server.memory.domain.temporal_sql import served_statuses from server.memory.domain.use_guidance import guidance_for_row @@ -108,7 +110,13 @@ def _memory_evidence( denied.add(i) continue if int(row.get("version") or 0) == doc_version(hit): + digest = hash_text(row.get("content_sha256")) + if hit._guidance_content_sha256 and digest != hit._guidance_content_sha256: + denied.add(i) + continue evidence[i] = dict(row, namespace=key[1], user_id=key[3]) + if not parked and hit._row_chunk is None and is_content_hash(digest): + hit._guidance_content_sha256 = digest return denied, evidence @@ -152,6 +160,7 @@ async def attach_search_guidance( parked: bool = False, replay: bool = False, timeout_s: float = 0.2, + snapshot_only: bool = False, ) -> list[_MemorySearchHit]: """Project authorization-scoped evidence for the served window. @@ -198,7 +207,16 @@ async def attach_search_guidance( denied |= denied_memory | denied_shared evidence.update(shared_evidence) authorized = evidence.keys() - usable = {} if replay else {i: row for i, row in evidence.items() if not hits[i]._chunk_typed} + if snapshot_only: + return [hit for i, hit in enumerate(hits) if i not in denied] + usable = { + i: row + for i, row in evidence.items() + if not replay + and not hits[i]._chunk_typed + and hits[i]._row_chunk is None + and (not parked or hits[i]._guidance_content_sha256) + } code_states: dict[int, str] = {} source_states: dict[int, str] = {} if usable: diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index eca271f709b..fbfc5d7c836 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -451,11 +451,14 @@ async def _finish_search_output( from server.memory.app import search_pages as _pages from server.settings import settings as _pg_settings + tail = await attach_search_guidance( + input, ctx.page_tail, replay=input.as_of is not None, snapshot_only=True + ) _content = _pages.encode_page( query=input.query, top_k=int(input.top_k), candidates_total=_output.candidates_total, - tail=ctx.page_tail, + tail=tail, namespaces_searched=_output.namespaces_searched, namespaces_skipped=_output.namespaces_skipped, replay=input.as_of is not None, diff --git a/server/memory/app/search/payload.py b/server/memory/app/search/payload.py index 1b790b6f438..22a64855c05 100644 --- a/server/memory/app/search/payload.py +++ b/server/memory/app/search/payload.py @@ -280,6 +280,7 @@ async def _expand_unit_bodies( tokens_returned).""" if (getattr(input, "bodies", "full") or "full") not in ("unit", "source") or not hits: return (0, 0, 0) + from server.core.hashing import served_content_sha256 from server.memory.store import Identity, get_many_by_keys budget = int(getattr(input, "body_budget_tokens", 4000) or 4000) @@ -386,6 +387,11 @@ def _body_row(h: Any) -> Any: cost = max(1, len(text) // 4) if spent + cost <= budget: try: + if getattr(h, "use_guidance", None) is not None and ( + body_row.version != h.version + or served_content_sha256(v) != h._guidance_content_sha256 + ): + h.use_guidance = None h.content_excerpt = text h.body_truncated = False except Exception: # noqa: BLE001 @@ -543,6 +549,8 @@ async def _expand_source_bodies( h.content_excerpt = text h.body_truncated = False h.score_components = {**(getattr(h, "score_components", {}) or {}), "source_body": 1.0} + if getattr(h, "use_guidance", None) is not None: + h.use_guidance = None except Exception: # noqa: BLE001 continue served.add(eid) diff --git a/server/memory/app/search_pages.py b/server/memory/app/search_pages.py index 270e12eee7b..343df4f14f8 100644 --- a/server/memory/app/search_pages.py +++ b/server/memory/app/search_pages.py @@ -72,6 +72,8 @@ def _parked(hit: Any) -> dict[str, Any]: out["row_chunk"] = list(hit._row_chunk) if getattr(hit, "_row_version", 0): out["row_version"] = int(hit._row_version) + if hit._guidance_content_sha256: + out["guidance_content_sha256"] = hit._guidance_content_sha256 if getattr(hit, "_chunk_typed", False): out["chunk_typed"] = True return out @@ -87,6 +89,7 @@ def unparked(row: dict[str, Any]) -> _MemorySearchHit | None: identity, chunk = r.pop("row_identity", None), r.pop("row_chunk", None) row_version = int(r.pop("row_version", 0) or 0) chunk_typed = bool(r.pop("chunk_typed", False)) + digest = str(r.pop("guidance_content_sha256", "") or "") try: hit = _MemorySearchHit.model_validate(r) except Exception: # noqa: BLE001 — a row this build cannot read is skipped @@ -97,6 +100,7 @@ def unparked(row: dict[str, Any]) -> _MemorySearchHit | None: hit._row_chunk = tuple(chunk) hit._row_version = row_version hit._chunk_typed = chunk_typed + hit._guidance_content_sha256 = digest return hit diff --git a/server/memory/app/stack.py b/server/memory/app/stack.py index ef73e3c6e7b..c469021724a 100644 --- a/server/memory/app/stack.py +++ b/server/memory/app/stack.py @@ -18,6 +18,7 @@ from server.knowledge.app.source_search_proofs import SearchProofs from server.memory.api.models_lifecycle import MemoryStackInput, MemoryStackOutput, _StackEntry from server.memory.app.code_link_reads import guidance_code_states +from server.memory.app.for_file import current_file_rows from server.memory.app.stack_knowledge import StackKnowledge from server.memory.app.use_guidance import guidance_source_states from server.memory.domain.use_guidance import UseGuidance, guidance_for_row @@ -148,7 +149,7 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N SELECT memory_key, memory_type, value, recall_count, last_recalled_at, actor, status, source_class, requires_review, verified_by, verified_sha256, content_sha256, source_resource_id, source_trace, conflict_with, - memory_id, namespace, tags, files, user_id + memory_id, namespace, tags, files, user_id, agent, session_id, version FROM loom.memory FINAL WHERE org = {{org:String}} AND namespace = {{ns:String}} @@ -166,6 +167,7 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N """, params=params, ) + pinned_rows = await current_file_rows(input.org, pinned_rows) guidance = await recall_guidance_for_rows(input.org, pinned_rows) for r, use_guidance in zip(pinned_rows, guidance, strict=True): val = _value_str(r.get("value")) @@ -215,7 +217,7 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s evidence_count, last_recalled_at, actor, status, source_class, requires_review, verified_by, verified_sha256, content_sha256, source_resource_id, source_trace, conflict_with, - memory_id, namespace, tags, files, user_id + memory_id, namespace, tags, files, user_id, agent, session_id, version FROM loom.memory FINAL WHERE org = {{org:String}} AND namespace = {{ns:String}} @@ -237,6 +239,7 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s params=params, ) most_recent_excerpt = "" + recent_rows = await current_file_rows(input.org, recent_rows) guidance = await recall_guidance_for_rows(input.org, recent_rows) for r, use_guidance in zip(recent_rows, guidance, strict=True): if r["memory_key"] in pinned_keys: diff --git a/server/memory/app/verify.py b/server/memory/app/verify.py index 021e2977f03..f63832709e3 100644 --- a/server/memory/app/verify.py +++ b/server/memory/app/verify.py @@ -40,7 +40,7 @@ from server.identity.domain.read_scope import WHOLE_NAMESPACE from server.memory.api.models_crud import MemoryVerifyInput, MemoryVerifyOutput from server.memory.domain import trust -from server.memory.store.rows import version_over +from server.memory.store.rows import identity_key, version_over from server.operations.base import Role if TYPE_CHECKING: @@ -185,7 +185,7 @@ async def handle_memory_verify(input: MemoryVerifyInput) -> MemoryVerifyOutput: # embeddings mirror (a FINAL read of the row's vector plus a second committed insert, # best-effort by contract) runs after this answer on the request's loop, and the next # embedding write covers a loss. Three chained round trips (~11 s p50) become one. - _schedule_mirror(row, verified=not input.revoke) + _schedule_mirror(row, verified=not input.revoke, version=version, content_sha256=sha) after = trust.verification_state(actor, verified_sha, sha) log.info( @@ -211,16 +211,21 @@ async def handle_memory_verify(input: MemoryVerifyInput) -> MemoryVerifyOutput: ) -def _schedule_mirror(row: MemoryRow, *, verified: bool) -> None: +def _schedule_mirror(row: MemoryRow, *, verified: bool, version: int, content_sha256: str) -> None: """Run the embeddings mirror after the response (drained at shutdown).""" from server.memory.app import after_write after_write.schedule( - _mirror_verified_to_embeddings(row, verified=verified), name="memory.verify.mirror" + _mirror_verified_to_embeddings( + row, verified=verified, version=version, content_sha256=content_sha256 + ), + name="memory.verify.mirror", ) -async def _mirror_verified_to_embeddings(row: MemoryRow, *, verified: bool) -> None: +async def _mirror_verified_to_embeddings( + row: MemoryRow, *, verified: bool, version: int, content_sha256: str +) -> None: """Re-emit the key's live embedding rows with `verified` set so trust-aware ranking sees the attestation: every column and the stored vectors carried (no re-embed). Best-effort: the attestation on loom.memory is the source of truth; a miss here @@ -231,15 +236,11 @@ async def _mirror_verified_to_embeddings(row: MemoryRow, *, verified: bool) -> N if not is_embedded(row.memory_type, row.sensitivity): # a 'high' head keeps no vector return try: - await memory_repo.reemit_embedding_rows_for_key( - row.org, - row.namespace, - row.agent, - row.user_id, - row.session_id, - row.memory_key, + key = identity_key(row) + await memory_repo.reemit_embedding_rows_for_keys( + [(key, {"verified": 1 if verified else 0, "version": version})], ch=get_client(), - verified=1 if verified else 0, + of_content={key: content_sha256}, ) except Exception as e: # noqa: BLE001 — the ranking mirror is best-effort log.warning("memory.verify: embedding mirror failed (non-fatal): %s", e) diff --git a/tests/unit/test_memory_for_file.py b/tests/unit/test_memory_for_file.py index 644b388d6a2..d1a81793de6 100644 --- a/tests/unit/test_memory_for_file.py +++ b/tests/unit/test_memory_for_file.py @@ -1055,3 +1055,16 @@ async def _merged(*_a: Any, **_k: Any) -> tuple[list[dict[str, Any]], bool]: assert rows[0]["code_changed_since"] == "ab" * 20 out = await mff.handle_memory_for_file(request) assert "commit abababababab" in out.rendered + + +@pytest.mark.asyncio +async def test_file_guidance_marks_quarantined_procedure_inspect_only(): + row = { + "memory_type": "procedural", + "status": "active", + "value": '{"quarantined": {}}', + "tags": [], + "files": [], + } + await mff.guided_file_rows("o", [row]) + assert row["use_guidance"].next_step == "inspect_only" diff --git a/tests/unit/test_memory_verify.py b/tests/unit/test_memory_verify.py index ef13ff4bf10..7b580a04414 100644 --- a/tests/unit/test_memory_verify.py +++ b/tests/unit/test_memory_verify.py @@ -411,12 +411,14 @@ async def test_verify_answers_before_the_embeddings_mirror_runs( set_current_auth(_token("alice")) started = asyncio.Event() release = asyncio.Event() - mirrored: list[tuple[str, bool]] = [] + mirrored: list[tuple[str, bool, int, str]] = [] - async def slow_mirror(r: MemoryRow, *, verified: bool) -> None: + async def slow_mirror( + r: MemoryRow, *, verified: bool, version: int, content_sha256: str + ) -> None: started.set() await release.wait() - mirrored.append((r.memory_key, verified)) + mirrored.append((r.memory_key, verified, version, content_sha256)) monkeypatch.setattr(mv, "_mirror_verified_to_embeddings", slow_mirror) out = await mv.handle_memory_verify( @@ -430,7 +432,7 @@ async def slow_mirror(r: MemoryRow, *, verified: bool) -> None: assert mirrored == [] # …and has not finished: the answer did not wait for it release.set() await after_write.drain() - assert mirrored == [("deploy_window", True)] + assert mirrored == [("deploy_window", True, out.version, out.content_sha256)] @pytest.mark.asyncio @@ -439,7 +441,7 @@ async def test_a_failing_mirror_never_fails_the_verify(monkeypatch: pytest.Monke ch = _wire(monkeypatch, row) set_current_auth(_token("alice")) - async def boom(r: MemoryRow, *, verified: bool) -> None: + async def boom(r: MemoryRow, *, verified: bool, version: int, content_sha256: str) -> None: raise RuntimeError("embeddings unavailable") monkeypatch.setattr(mv, "_mirror_verified_to_embeddings", boom) @@ -494,10 +496,43 @@ async def insert(self, table: str, rows: list[dict[str, Any]], **_: Any) -> None inserted.extend(rows) monkeypatch.setattr(mv, "get_client", lambda: _CH()) - await mv._mirror_verified_to_embeddings(row, verified=True) + await mv._mirror_verified_to_embeddings( + row, verified=True, version=123, content_sha256=_sha(row.value) + ) assert [(r["scope"], r["embedding_model"]) for r in inserted] == [ ("private", "m1"), ("private", "m2"), ] - assert all(r["verified"] == 1 and r["version"] > 7 for r in inserted) + assert all(r["verified"] == 1 and r["version"] == 123 for r in inserted) assert all(r["mentioned_at"] == datetime(2026, 1, 3) for r in inserted) + + +async def test_verify_mirror_does_not_attest_concurrently_edited_embedding( + monkeypatch: pytest.MonkeyPatch, +) -> None: + from server.memory.store import EMBEDDING_PERSISTED_COLS + + row = _row() + stored = { + **EMBEDDING_PERSISTED_COLS, + **{ + name: getattr(row, name) + for name in ("org", "namespace", "agent", "user_id", "session_id", "memory_key") + }, + "content_sha256": _sha("concurrent edit"), + "version": 101, + } + inserted: list[Any] = [] + + class CH: + async def query_all(self, sql: str, **kwargs: Any) -> list[dict[str, Any]]: + return [stored] + + async def insert(self, table: str, rows: list[dict[str, Any]], **kwargs: Any) -> None: + inserted.extend(rows) + + monkeypatch.setattr(mv, "get_client", lambda: CH()) + await mv._mirror_verified_to_embeddings( + row, verified=True, version=123, content_sha256=_sha(row.value) + ) + assert inserted == [] diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index a48c48e89fc..645a521b393 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -84,6 +84,7 @@ async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: monkeypatch.setattr(guidance, "guidance_code_states", code_states) hit = _hit() hit.code_state = "fresh" + await guidance.attach_search_guidance(_INPUT, [hit], snapshot_only=True) parked = search_pages.unparked(search_pages._parked(hit)) assert parked is not None assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] @@ -213,3 +214,45 @@ async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: assert hit.use_guidance.freshness.source == "unknown" assert hit.use_guidance.freshness.code == "changed" assert hit.use_guidance.next_step == "recheck_source" + + +async def test_parked_hit_rejects_replacement_with_same_version(monkeypatch): + head = _head() + + async def heads(keys): + return {_KEY: head} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + await guidance.attach_search_guidance(_INPUT, [hit], snapshot_only=True) + parked = search_pages.unparked(search_pages._parked(hit)) + assert parked is not None + head.update(content_sha256="b" * 64, verified_sha256="b" * 64) + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [] + + +async def test_previous_build_cursor_cannot_give_folded_passage_parent_approval(monkeypatch): + async def heads(keys): + return {_KEY: _head()} + + async def states(org, rows): + return ["not_applicable"] * len(rows) + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "guidance_code_states", states) + monkeypatch.setattr(guidance, "guidance_source_states", states) + parent = _hit() + await guidance.attach_search_guidance(_INPUT, [parent]) + assert parent.use_guidance is not None + assert parent.use_guidance.next_step == "follow_if_applicable" + + # The old ClickHouse cursor retained the identity and version but omitted chunk identity. + cursor = _hit().model_dump() + cursor.update(content_excerpt="folded passage", row_identity=["a", "u", "s"]) + hit = search_pages.unparked(cursor) + assert hit is not None + assert await guidance.attach_search_guidance(_INPUT, [hit], parked=True) == [hit] + assert hit.content_excerpt == "folded passage" + assert hit.use_guidance is not None + assert hit.use_guidance.review == "unknown" + assert hit.use_guidance.next_step == "validate_lead" diff --git a/tests/unit/test_source_checked_pack.py b/tests/unit/test_source_checked_pack.py index 9f8000d3587..e5c7fc0165d 100644 --- a/tests/unit/test_source_checked_pack.py +++ b/tests/unit/test_source_checked_pack.py @@ -349,3 +349,36 @@ async def send(message): with pytest.raises(request_tail.RequiredTailError): await request_tail.RequestTailMiddleware(app)({"type": "http"}, None, send) assert sent == [] and world.state.renders == [] + + +@pytest.mark.asyncio +@pytest.mark.parametrize("section", ["pinned", "recent"]) +async def test_stack_excludes_mirror_rows_without_matching_postgres_heads(monkeypatch, section): + from server.memory.api.models_lifecycle import MemoryStackInput + from server.memory.app import for_file + + row = { + "namespace": "n", + "agent": "a", + "user_id": "-", + "session_id": "-", + "memory_key": "k", + "memory_id": "memory", + "version": 10, + "value": '"stale text"', + } + + class Mirror: + async def query_all(self, sql, **kwargs): + return [row] + + async def heads(keys): + assert keys == [("o", "n", "a", "-", "-", "k")] + return {keys[0]: {"version": 11}} + + monkeypatch.setattr(for_file.pg, "enabled", lambda: True) + monkeypatch.setattr(for_file.memory_reads, "guidance_heads", heads) + fill = stack._StackFill(budget=100) + reader = stack._stack_pinned if section == "pinned" else stack._stack_recent + await reader(Mirror(), MemoryStackInput(org="o", namespace="n", agent="a"), fill) + assert fill.entries == [] diff --git a/tests/unit/test_unit_bodies_follow_hit_session.py b/tests/unit/test_unit_bodies_follow_hit_session.py index 692c44895f5..70b62ddbd15 100644 --- a/tests/unit/test_unit_bodies_follow_hit_session.py +++ b/tests/unit/test_unit_bodies_follow_hit_session.py @@ -9,8 +9,10 @@ import pytest import server.memory.store as repo +from server.core.hashing import served_content_sha256 from server.memory.api.models_search import _MemorySearchHit from server.memory.app.search.payload import _expand_unit_bodies +from server.memory.domain.use_guidance import guidance_for_row CLIP = "x" * 1200 @@ -167,3 +169,32 @@ async def fake_get_many(identity, keys, **_): h.source = "record" await _expand_unit_bodies([h], _input(session_id="s1")) assert sessions == ["s1"] and h.content_excerpt == "the fact" + + +@pytest.mark.asyncio +@pytest.mark.parametrize("body", ["reviewed text", "replacement text"]) +async def test_unit_body_keeps_approval_only_for_reviewed_content(monkeypatch, body): + hit = _hit("k", excerpt="reviewed text") + hit.version = 42 + digest = served_content_sha256("reviewed text") + hit._guidance_content_sha256 = digest + hit.use_guidance = guidance_for_row( + { + "status": "active", + "requires_review": False, + "verified_by": "human:reviewer", + "content_sha256": digest, + "verified_sha256": digest, + }, + source_state="not_applicable", + code_state="not_applicable", + ) + assert hit.use_guidance.next_step == "follow_if_applicable" + + async def fake_get_many(identity, keys, **kwargs): + return [SimpleNamespace(memory_key="k", value=body, version=42)] + + monkeypatch.setattr(repo, "get_many_by_keys", fake_get_many) + await _expand_unit_bodies([hit], _input()) + assert hit.content_excerpt == body + assert (hit.use_guidance is not None) == (body == "reviewed text") From c38e7b2856114ed3227e8dd27af30cbb467c0649 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 11:40:55 +0530 Subject: [PATCH 005/117] fix: honor procedure status and preserve authorized search totals Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/for_file.py | 20 ++++---------------- server/memory/app/search/guidance.py | 4 +++- server/memory/app/search/output.py | 7 +++---- server/memory/app/search_pages.py | 7 +++++++ server/memory/app/stack.py | 7 ++----- server/memory/app/use_guidance.py | 18 ++++++++++++++++-- tests/unit/test_search_pages.py | 13 +++++++++++-- tests/unit/test_source_checked_pack.py | 11 +++++++++++ tests/unit/test_use_guidance_sources.py | 9 ++++++++- 9 files changed, 65 insertions(+), 31 deletions(-) diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index a2c759dbedc..1756883d4c2 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -7,22 +7,21 @@ import logging from collections import defaultdict from datetime import UTC, datetime -from typing import TYPE_CHECKING, Any, Literal +from typing import TYPE_CHECKING, Any from server.code.app.common import repo_relative from server.core import pg from server.core.ch import get_client from server.core.datetimes import naive_utc_now, parse_iso_dt -from server.core.hashing import hash_text, served_row_value +from server.core.hashing import hash_text from server.core.repo_base import query_all_sliced from server.memory.api.models_for_file import ( MemoryForFileInput, MemoryForFileOutput, _MemoryForFileHit, ) -from server.memory.api.models_procedure import ProcedureStatus from server.memory.app.code_link_reads import guidance_code_states -from server.memory.app.use_guidance import guidance_source_states +from server.memory.app.use_guidance import guidance_source_states, procedure_status_for_row from server.memory.domain import code_change from server.memory.domain.decision_schema import ( CONSTRAINT_TAG, @@ -769,17 +768,6 @@ async def current_file_rows(org: str, rows: list[dict[str, Any]]) -> list[dict[s return kept -def _file_procedure_status( - row: dict[str, Any], -) -> ProcedureStatus | Literal["unknown", "not_applicable"]: - from server.memory.app.procedure import _procedure_status - - if row.get("memory_type") != "procedural": - return "not_applicable" - value = served_row_value(row) if not row.get("value_truncated") else None - return _procedure_status(value) if isinstance(value, dict) else "unknown" - - async def guided_file_rows( org: str, rows: list[dict[str, Any]], *, local_code_changes: set[str] | None = None ) -> None: @@ -798,7 +786,7 @@ async def guided_file_rows( row, code_state=state, source_state=source_state, - procedure_status=_file_procedure_status(row), + procedure_status=procedure_status_for_row(row), ) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index d2fa36fdfbe..1bb41d92cdd 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -135,7 +135,9 @@ def _shared_evidence( if row is None or row.get("tombstoned_at") is not None or row.get("superseded_by"): denied.add(i) elif int(row.get("version") or 0) == doc_version(hits[i]): - evidence[i] = {"status": "active"} + # A promoted row has its own lifecycle. Its private contributors' review + # does not attest the shared copy and may not be readable here. + evidence[i] = {"status": "active", "source_class": hits[i].source_class} return denied, evidence diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index fbfc5d7c836..db38db9dd45 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -90,10 +90,8 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: return empty readable = await _readable_namespaces(input.org, input.namespace, payload) hits, nxt, stale_dropped = await _parked_slice(input, payload, offset, readable) - # Hits from a namespace the caller lost are neither served nor counted; the - # first page was never parked. If scope narrowed, only the visible tail can - # be counted. - parked_rows = payload.get("hits") or [] + # Count authorized first-page hits as well as the tail when access changed. + parked_rows = (payload.get("first_page_scope") or []) + (payload.get("hits") or []) withheld = sum( 1 for row in parked_rows @@ -459,6 +457,7 @@ async def _finish_search_output( top_k=int(input.top_k), candidates_total=_output.candidates_total, tail=tail, + first_page=_output.results, namespaces_searched=_output.namespaces_searched, namespaces_skipped=_output.namespaces_skipped, replay=input.as_of is not None, diff --git a/server/memory/app/search_pages.py b/server/memory/app/search_pages.py index 343df4f14f8..b37007b1613 100644 --- a/server/memory/app/search_pages.py +++ b/server/memory/app/search_pages.py @@ -26,6 +26,7 @@ import hashlib import json +from collections.abc import Sequence from datetime import timedelta from typing import TYPE_CHECKING, Any @@ -113,6 +114,7 @@ def encode_page( namespaces_searched: list[str], namespaces_skipped: list[str], replay: bool = False, + first_page: Sequence[Any] = (), ) -> str: """`replay`: the search was an `as_of` replay, whose pages the Postgres authority does not check (`pg_validation`).""" @@ -126,6 +128,11 @@ def encode_page( "namespaces_skipped": namespaces_skipped, "hits": hits, } + if first_page: + # Scope metadata lets later pages count the original hits without keeping their text. + page["first_page_scope"] = [ + {"namespace": hit.namespace, "row_identity": hit._row_identity} for hit in first_page + ] if replay: page["replay"] = True return json.dumps( diff --git a/server/memory/app/stack.py b/server/memory/app/stack.py index c469021724a..ab3b33bf304 100644 --- a/server/memory/app/stack.py +++ b/server/memory/app/stack.py @@ -20,7 +20,7 @@ from server.memory.app.code_link_reads import guidance_code_states from server.memory.app.for_file import current_file_rows from server.memory.app.stack_knowledge import StackKnowledge -from server.memory.app.use_guidance import guidance_source_states +from server.memory.app.use_guidance import guidance_source_states, procedure_status_for_row from server.memory.domain.use_guidance import UseGuidance, guidance_for_row log = logging.getLogger(__name__) @@ -57,10 +57,7 @@ async def recall_guidance_for_rows( statuses = ( procedure_statuses if procedure_statuses is not None - else [ - "unknown" if row.get("memory_type") == "procedural" else "not_applicable" - for row in rows - ] + else [procedure_status_for_row(row) for row in rows] ) return [ guidance_for_row(row, code_state=code, source_state=source, procedure_status=status) diff --git a/server/memory/app/use_guidance.py b/server/memory/app/use_guidance.py index 53e87f1b3ee..0338a2c879e 100644 --- a/server/memory/app/use_guidance.py +++ b/server/memory/app/use_guidance.py @@ -6,11 +6,13 @@ import logging from collections import defaultdict from collections.abc import Mapping, Sequence -from typing import Any +from typing import Any, Literal from server.auth.authz import row_in_scope +from server.core.hashing import served_row_value from server.identity.app.request_scope import request_narrowed from server.knowledge.app.document_reads import ordinary_source_uris +from server.memory.api.models_procedure import ProcedureStatus from server.memory.domain.decision_schema import SOURCE_CHANGED_TAG log = logging.getLogger(__name__) @@ -24,7 +26,7 @@ def _changed_document(row: Mapping[str, Any]) -> tuple[str, str] | None: return None namespace, _, citation = resource.removeprefix("knowledge:").partition("/") # A '#' inside a URI or heading makes this citation ambiguous without another read. - if not namespace or citation.count("#") != 1: + if not namespace or citation.count("#") > 1: return None uri, _, _section = citation.partition("#") return (namespace, uri) if uri else None @@ -54,4 +56,16 @@ async def guidance_source_states(org: str, rows: Sequence[Mapping[str, Any]]) -> reads = (_readable_documents(org, ns, uris) for ns, uris in by_ns.items()) for checked in await asyncio.gather(*reads): visible.update(checked) + # Readability confirms a change marker may be shown. It does not prove a revision matches. return ["changed" if ref and ref in visible else "unknown" for ref in references] + + +def procedure_status_for_row( + row: dict[str, Any], +) -> ProcedureStatus | Literal["unknown", "not_applicable"]: + from server.memory.app.procedure import _procedure_status + + if row.get("memory_type") != "procedural": + return "not_applicable" + value = served_row_value(row) if not row.get("value_truncated") else None + return _procedure_status(value) if isinstance(value, dict) else "unknown" diff --git a/tests/unit/test_search_pages.py b/tests/unit/test_search_pages.py index ddf9ec7caeb..2386d73c1ba 100644 --- a/tests/unit/test_search_pages.py +++ b/tests/unit/test_search_pages.py @@ -255,7 +255,16 @@ async def test_a_parked_page_drops_hits_the_caller_can_no_longer_read(monkeypatc tail = [_hit("b", 0.8, ns="n"), _hit("c", 0.7, ns="team"), _hit("d", 0.6, ns="home")] content = _encode( - 3, 3, tail, namespaces_searched=["n", "team", "home"], namespaces_skipped=["team", "far"] + 3, + 6, + tail, + first_page=[ + _hit("first", 1, ns="n"), + _hit("revoked", 1, ns="team"), + _hit("home", 1, ns="home"), + ], + namespaces_searched=["n", "team", "home"], + namespaces_skipped=["team", "far"], ) key = sp.page_blob_key(content) patch_handler_name(monkeypatch, "get_client", lambda: _CH(content)) @@ -265,7 +274,7 @@ async def test_a_parked_page_drops_hits_the_caller_can_no_longer_read(monkeypatc ) out = await h.handle_memory_search(page) assert [(r.memory_key, r.namespace) for r in out.results] == [("b", "n"), ("d", "home")] - assert out.candidates_total == 2 + assert out.candidates_total == 4 assert out.namespaces_searched == ["n", "home"] assert out.namespaces_skipped == [], "neither a lost namespace nor one never readable" assert reads == ["o"], "one read of the caller's namespaces per page, however many" diff --git a/tests/unit/test_source_checked_pack.py b/tests/unit/test_source_checked_pack.py index e5c7fc0165d..9d243fad8a9 100644 --- a/tests/unit/test_source_checked_pack.py +++ b/tests/unit/test_source_checked_pack.py @@ -382,3 +382,14 @@ async def heads(keys): reader = stack._stack_pinned if section == "pinned" else stack._stack_recent await reader(Mirror(), MemoryStackInput(org="o", namespace="n", agent="a"), fill) assert fill.entries == [] + + +@pytest.mark.asyncio +async def test_stack_guidance_recognizes_quarantined_and_candidate_procedures(): + rows = [ + {"memory_type": "procedural", "status": "active", "value": '{"quarantined": {}}'}, + {"memory_type": "procedural", "status": "active", "value": '{"tags": ["mined"]}'}, + ] + guidance = await stack.recall_guidance_for_rows("o", rows) + assert [item.lifecycle.procedure_status for item in guidance] == ["quarantined", "candidate"] + assert [item.next_step for item in guidance] == ["inspect_only", "validate_lead"] diff --git a/tests/unit/test_use_guidance_sources.py b/tests/unit/test_use_guidance_sources.py index cc74c35af22..346da820c8a 100644 --- a/tests/unit/test_use_guidance_sources.py +++ b/tests/unit/test_use_guidance_sources.py @@ -21,13 +21,20 @@ async def test_changed_source_requires_current_access_and_unambiguous_identity(m monkeypatch.setattr(source, "request_narrowed", lambda: False) rows = [ {"tags": ["source-changed"], "source_resource_id": "knowledge:" + cite} - for cite in ["team/public#intro", "hidden/doc#intro", "team/mirror#part", "team/a#b#part"] + for cite in [ + "team/public#intro", + "hidden/doc#intro", + "team/mirror#part", + "team/a#b#part", + "team/public", + ] ] assert await source.guidance_source_states("org", rows) == [ "changed", "unknown", "unknown", "unknown", + "changed", ] docs.assert_awaited_once_with("org", "team", ["mirror", "public"]) docs.reset_mock() From b97a8b21cdfd247c5cbc735b612b6328e1de49c4 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 12:55:46 +0530 Subject: [PATCH 006/117] fix: preserve historical paging and bind retrieval guidance to served content Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/components/SearchWhy.test.tsx | 1 + frontend/src/components/SearchWhy.tsx | 7 ++- scripts/codegen/sdk_rust_gen.py | 6 ++ sdk/python/loom/memory.py | 3 +- sdk/rust/src/wire_models.rs | 61 ++++++------------- sdk/rust/tests/models.rs | 17 ++++++ server/memory/app/code_link_reads.py | 7 ++- server/memory/app/for_file.py | 12 +--- server/memory/app/handlers.py | 9 +-- server/memory/app/path_lessons.py | 13 +++- server/memory/app/search/guidance.py | 48 +++++++++++++-- server/memory/app/use_guidance.py | 7 ++- server/memory/store/history.py | 17 ++++-- server/memory/store/pg_memory.py | 2 +- .../test_retrieved_use_guidance.py | 2 + tests/unit/test_memory_code_plane_reads.py | 12 ++++ tests/unit/test_memory_for_file.py | 8 +-- tests/unit/test_memory_touch_expiry.py | 11 ++-- tests/unit/test_sdk_model_memory_metadata.py | 9 +++ tests/unit/test_search_use_guidance.py | 50 ++++++++++++--- tests/unit/test_use_guidance_sources.py | 5 ++ 21 files changed, 212 insertions(+), 95 deletions(-) diff --git a/frontend/src/components/SearchWhy.test.tsx b/frontend/src/components/SearchWhy.test.tsx index 6ef280cccf0..3e27a1ef316 100644 --- a/frontend/src/components/SearchWhy.test.tsx +++ b/frontend/src/components/SearchWhy.test.tsx @@ -32,6 +32,7 @@ describe("SearchWhy", () => { const guidance = { next_step: "recheck_source", reasons: ["code_recheck_needed", "human_review_current"] }; render(); const why = await open(); + expect(why).toHaveTextContent("Matched text: the user prefers oat milk"); expect(why).toHaveTextContent("Suggested use: recheck source"); expect(why).toHaveTextContent("code recheck needed, human review current"); }); diff --git a/frontend/src/components/SearchWhy.tsx b/frontend/src/components/SearchWhy.tsx index 70dbf4f652c..402f8f55ba8 100644 --- a/frontend/src/components/SearchWhy.tsx +++ b/frontend/src/components/SearchWhy.tsx @@ -72,7 +72,12 @@ function Ranked({ hit, rank }: { hit: SearchHit; rank: number }) { .trim(); return ( <> - + {hit.use_guidance && ( + <> +

Matched text: {hit.content_excerpt}

+ + + )}

#{rank} {similarity !== null && similarity {similarity}} diff --git a/scripts/codegen/sdk_rust_gen.py b/scripts/codegen/sdk_rust_gen.py index a3b111c9b65..e6b5d423edf 100644 --- a/scripts/codegen/sdk_rust_gen.py +++ b/scripts/codegen/sdk_rust_gen.py @@ -752,6 +752,12 @@ def build(selected: tuple[str, ...] | None = None) -> str: for request, model in [(False, op.output_model), (True, op.input_model)]: schema = schema_for(model, request=request) em.defs = schema.get("$defs", {}) + if not request: + for definition in (schema, *em.defs.values()): + lessons = definition.get("properties", {}).get("lessons", {}) + if lessons.get("items", {}).get("$ref") == "#/$defs/CodeLesson": + # Preserve existing Rust map access to code lesson fields. + lessons["items"] = {"type": "object", "additionalProperties": True} root = operation_type(op, request=request) em.ref_names = {} for ref, definition in em.defs.items(): diff --git a/sdk/python/loom/memory.py b/sdk/python/loom/memory.py index a55d7863d5c..5bfabb278af 100644 --- a/sdk/python/loom/memory.py +++ b/sdk/python/loom/memory.py @@ -28,9 +28,10 @@ from datetime import datetime from typing import TYPE_CHECKING, Any, Literal, TypeVar +from loom.ops import UseGuidance + if TYPE_CHECKING: from loom.agent import Agent - from loom.ops import UseGuidance # Free-form string. The default taxonomy is episodic/semantic/procedural/ # preference, but namespaces with a registered tag_registry accept any name. diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index 0cbe59354eb..c762955c117 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -7754,31 +7754,6 @@ impl CodeCalibrateInput { } } -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -#[non_exhaustive] -pub struct CodeLesson { - #[serde(default)] - pub memory_key: Option, - #[serde(default)] - pub namespace: Option, - #[serde(default)] - pub excerpt: Option, - #[serde(default)] - pub code_state: Option, - #[serde(default)] - pub path: Option, - #[serde(default)] - pub changed_since: Option, - #[serde(default)] - pub supersedes_key: Option, - #[serde(default)] - pub suggestion: Option, - #[serde(default)] - pub owner_symbol: Option, - #[serde(default)] - pub use_guidance: Option, -} - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct CodeEdgeWire { @@ -7848,7 +7823,7 @@ pub struct CodeCandidateSitesWire { #[non_exhaustive] pub struct CodeCallersOutput { #[serde(default = "default_310")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_311")] pub lessons_left_out: Integer, pub edges: Vec, @@ -8416,7 +8391,7 @@ pub enum CodeContextPackOutputSource { #[non_exhaustive] pub struct CodeContextPackOutput { #[serde(default = "default_343")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_344")] pub lessons_left_out: Integer, pub context: String, @@ -9485,7 +9460,7 @@ pub struct CodeUnit { #[serde(default = "default_452")] pub examples: Vec>, #[serde(default = "default_453")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_454")] pub lessons_unread: bool, #[serde(default = "default_455")] @@ -9777,7 +9752,7 @@ impl CodeEditContextInput { #[non_exhaustive] pub struct CodeEnclosingOutput { #[serde(default = "default_493")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_494")] pub lessons_left_out: Integer, pub results: Vec>, @@ -10406,7 +10381,7 @@ pub enum CodeGrepOutputFallback { #[non_exhaustive] pub struct CodeGrepOutput { #[serde(default = "default_534")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_535")] pub lessons_left_out: Integer, pub matches: Vec>, @@ -11002,7 +10977,7 @@ impl CodeHistoryInput { #[non_exhaustive] pub struct CodeImpactOutput { #[serde(default = "default_574")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_575")] pub lessons_left_out: Integer, pub impacted_symbols: Vec>, @@ -11964,7 +11939,7 @@ impl CodeOutcomeInput { #[non_exhaustive] pub struct CodeOutlineOutput { #[serde(default = "default_663")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_664")] pub lessons_left_out: Integer, pub path: String, @@ -12471,7 +12446,7 @@ pub struct CodeReadRange { #[non_exhaustive] pub struct CodeReadOutput { #[serde(default = "default_689")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_690")] pub lessons_left_out: Integer, pub results: Vec, @@ -14513,7 +14488,7 @@ pub enum CodeSearchOutputEpistemic { #[non_exhaustive] pub struct CodeSearchOutput { #[serde(default = "default_749")] - pub lessons: Vec, + pub lessons: Vec>, #[serde(default = "default_750")] pub lessons_left_out: Integer, pub results: Vec, @@ -61517,7 +61492,7 @@ fn default_308() -> bool { fn default_309() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_310() -> Vec { +fn default_310() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_311() -> Integer { @@ -61616,7 +61591,7 @@ fn default_341() -> Option { fn default_342() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_343() -> Vec { +fn default_343() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_344() -> Integer { @@ -61946,7 +61921,7 @@ fn default_451() -> Vec> { fn default_452() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_453() -> Vec { +fn default_453() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_454() -> bool { @@ -62068,7 +62043,7 @@ fn default_491() -> Vec { fn default_492() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_493() -> Vec { +fn default_493() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_494() -> Integer { @@ -62191,7 +62166,7 @@ fn default_532() -> bool { fn default_533() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_534() -> Vec { +fn default_534() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_535() -> Integer { @@ -62311,7 +62286,7 @@ fn default_572() -> Vec> { fn default_573() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_574() -> Vec { +fn default_574() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_575() -> Integer { @@ -62578,7 +62553,7 @@ fn default_661() -> String { fn default_662() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_663() -> Vec { +fn default_663() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_664() -> Integer { @@ -62656,7 +62631,7 @@ fn default_687() -> std::collections::HashMap { fn default_688() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_689() -> Vec { +fn default_689() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_690() -> Integer { @@ -62836,7 +62811,7 @@ fn default_747() -> String { fn default_748() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_749() -> Vec { +fn default_749() -> Vec> { serde_json::from_str("[]").expect("schema default") } fn default_750() -> Integer { diff --git a/sdk/rust/tests/models.rs b/sdk/rust/tests/models.rs index aa6d7955c02..217de11ec50 100644 --- a/sdk/rust/tests/models.rs +++ b/sdk/rust/tests/models.rs @@ -315,3 +315,20 @@ fn optional_search_disclosures_distinguish_absence_from_false_and_zero() { .unwrap(); assert_eq!(search.reinforcement, None); } + +#[test] +fn code_lessons_preserve_map_field_access() { + use clickhouse_loom::CodeCallersOutput; + + let response: CodeCallersOutput = serde_json::from_value(json!({ + "edges": [], + "seed_symbols": [], + "lessons": [{"memory_key": "note", "use_guidance": {"next_step": "validate_lead"}}] + })) + .unwrap(); + assert_eq!(response.lessons[0].get("memory_key"), Some(&json!("note"))); + assert_eq!( + response.lessons[0]["use_guidance"]["next_step"], + "validate_lead" + ); +} diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 93948ea5dfb..02b1c0ded41 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -13,7 +13,7 @@ from server.code.app import memory_links as code from server.code.domain.index.remote import repo_tag -from server.code.domain.index.repos import configured_repos +from server.code.domain.index.repos import RegistryUnread, configured_repos from server.core.hashing import hash_text from server.memory.api.models_crud import CodeLink from server.memory.domain import code_change @@ -151,7 +151,10 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l continue ns = str(row["namespace"]) tags = [str(tag) for tag in row["tags"] or ()] - cns = code_namespace_for(org, ns, tags) + try: + cns = code_namespace_for(org, ns, tags) + except RegistryUnread: + continue if not cns: if not any(tag.startswith("repo:") for tag in tags): states[index] = "not_applicable" diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index 1756883d4c2..1cdafba23ce 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -210,11 +210,6 @@ def _status_notes(hit: dict[str, Any], *, decision: bool) -> str: return out + code_change.note(state, commit) -def _use_note(hit: dict[str, Any]) -> str: - guidance = hit.get("use_guidance") - return f" [use: {guidance['next_step']}]" if guidance else "" - - def _marker(hit: dict[str, Any], *, show_decision: bool) -> str: """` [constraint, decision]`: the row's kinds. `decision` is added only when `show_decision`; a team line leaves it out because its head says `Decision`.""" @@ -238,10 +233,7 @@ def _team_line(hit: dict[str, Any], now: datetime, *, decision: bool) -> str: label = "Decision" if decision else "Team rule" head = f"{label} ({who})" if who else label marks = _marker(hit, show_decision=False) + _status_notes(hit, decision=decision) - return ( - f"- {head}{marks}: {_body(hit, decision=decision)}" - f" [id: {hit['memory_key']}]{_use_note(hit)}" - ) + return f"- {head}{marks}: {_body(hit, decision=decision)} [id: {hit['memory_key']}]" def _removal_footer(hits: list[dict[str, Any]], home: str) -> str: @@ -301,7 +293,7 @@ def _row_line(h: dict[str, Any], now: datetime, home: str, *, whole: bool = True if _is_team(h, home): return _team_line(h, now, decision=decision) marks = _marker(h, show_decision=decision) + _status_notes(h, decision=decision) - return f"- {h['memory_key']}{marks}: {_body(h, decision=decision, whole=whole)}{_use_note(h)}" + return f"- {h['memory_key']}{marks}: {_body(h, decision=decision, whole=whole)}" def listing_line(hit: dict[str, Any]) -> str: diff --git a/server/memory/app/handlers.py b/server/memory/app/handlers.py index 7124edf9281..8195fcce3f9 100644 --- a/server/memory/app/handlers.py +++ b/server/memory/app/handlers.py @@ -1431,7 +1431,7 @@ async def handle_memory_touch(input: MemoryTouchInput) -> MemoryTouchOutput: mirror = [ ( (r.org, r.namespace, r.agent, r.user_id, r.session_id, r.memory_key), - {"expires_at": naive_expiry}, + {"expires_at": naive_expiry, "version": versions[r.memory_key]}, ) for r in (by_key[k] for k in versions) # a 'high' head keeps no vector: never copy one forward under it @@ -1439,11 +1439,8 @@ async def handle_memory_touch(input: MemoryTouchInput) -> MemoryTouchOutput: ] if mirror: try: - if input.memory_keys: - await memory_repo.reemit_embedding_rows_for_keys(mirror, ch=ch) - else: # one key: the keyed read the single-key path always ran - (o, n, a, u, s_, k), ov = mirror[0] - await memory_repo.reemit_embedding_rows_for_key(o, n, a, u, s_, k, ch=ch, **ov) + hashes = {key: served_content_sha256(by_key[key[-1]].value) for key, _ in mirror} + await memory_repo.reemit_embedding_rows_for_keys(mirror, ch=ch, of_content=hashes) except Exception as e: # noqa: BLE001 — expiry mirror is best-effort; memory rows already updated log.warning("memory_embeddings expiry mirror failed (non-fatal): %s", e) diff --git a/server/memory/app/path_lessons.py b/server/memory/app/path_lessons.py index d0d2f534402..67d6beb63d3 100644 --- a/server/memory/app/path_lessons.py +++ b/server/memory/app/path_lessons.py @@ -81,11 +81,20 @@ def _lesson(hit: dict[str, Any], path: str) -> dict[str, Any] | None: lesson["changed_since"] = str(hit["code_changed_since"]) if hit.get("supersedes_key"): lesson["supersedes_key"] = str(hit["supersedes_key"]) - if hit.get("use_guidance"): - lesson["use_guidance"] = hit["use_guidance"] + guidance = hit.get("use_guidance") + if guidance and _guidance_matches_code(guidance, lesson["code_state"]): + lesson["use_guidance"] = guidance return lesson +def _guidance_matches_code(guidance: Any, code_state: str) -> bool: + if code_state not in code_change.DEMOTED: + return True + freshness = guidance.get("freshness", {}) if isinstance(guidance, dict) else guidance.freshness + state = freshness.get("code") if isinstance(freshness, dict) else freshness.code + return state == code_state + + class Lessons(NamedTuple): """The rows served and how many file lessons were left out (memory.for_file lists them).""" diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 1bb41d92cdd..5dc3c85a6b6 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -21,6 +21,7 @@ from server.memory.domain.search_types import SHARED_AGENT, is_shared_row from server.memory.domain.temporal_sql import served_statuses from server.memory.domain.use_guidance import guidance_for_row +from server.memory.store.history import find_history_target from server.memory.store.reads import guidance_heads from server.memory.store.rows import IdentityKey from server.memory.store.shared import guidance_heads as shared_guidance_heads @@ -48,9 +49,11 @@ def _status_kept( ) -def _current(row: dict[str, Any], now: datetime) -> bool: +def _current(row: dict[str, Any], now: datetime, *, replay: bool = False) -> bool: if row.get("tombstoned_at") is not None or row.get("sensitivity") == "high": return False + if replay: + return True for field in ("expires_at", "valid_to"): if (value := row.get(field)) is not None: until = parse_iso_dt(value) @@ -100,7 +103,7 @@ def _memory_evidence( hit = hits[i] if ( row is None - or not _current(row, now) + or not _current(row, now, replay=replay) or row.get("redacted_at") is not None or ( not replay @@ -109,8 +112,13 @@ def _memory_evidence( ): denied.add(i) continue - if int(row.get("version") or 0) == doc_version(hit): - digest = hash_text(row.get("content_sha256")) + digest = hash_text(row.get("content_sha256")) + if int(row.get("version") or 0) == doc_version(hit) or ( + parked + and not replay + and is_content_hash(digest) + and digest == hit._guidance_content_sha256 + ): if hit._guidance_content_sha256 and digest != hit._guidance_content_sha256: denied.add(i) continue @@ -121,6 +129,30 @@ def _memory_evidence( return denied, evidence +async def _replay_evidence( + keys: dict[int, IdentityKey], + rows: dict[IdentityKey, dict[str, Any]], + hits: list[_MemorySearchHit], +) -> dict[int, dict[str, Any]]: + async def readable(i: int, key: IdentityKey) -> bool: + target = await find_history_target( + key[0], str(rows[key]["memory_id"]), doc_version(hits[i]) + ) + if target is None or target.redacted_at is not None: + return False + return ( + target.org, + target.namespace, + target.agent, + target.user_id, + target.session_id, + target.memory_key, + ) == key + + allowed = await asyncio.gather(*(readable(i, key) for i, key in keys.items())) + return {i: rows[key] for (i, key), keep in zip(keys.items(), allowed, strict=True) if keep} + + def _shared_evidence( hits: list[_MemorySearchHit], keys: dict[int, tuple[str, str]], @@ -205,6 +237,14 @@ async def attach_search_guidance( denied_memory, evidence = _memory_evidence( input, hits, keys, rows, replay=replay, parked=parked ) + if parked and replay and rows is not None: + replay_keys = {i: key for i, key in keys.items() if i not in denied_memory} + evidence = ( + await _read_heads( + _replay_evidence(replay_keys, rows, hits), timeout_s=timeout_s, parked=True + ) + or {} + ) denied_shared, shared_evidence = _shared_evidence(hits, shared_keys, shared) denied |= denied_memory | denied_shared evidence.update(shared_evidence) diff --git a/server/memory/app/use_guidance.py b/server/memory/app/use_guidance.py index 0338a2c879e..6d229ca3eb3 100644 --- a/server/memory/app/use_guidance.py +++ b/server/memory/app/use_guidance.py @@ -68,4 +68,9 @@ def procedure_status_for_row( if row.get("memory_type") != "procedural": return "not_applicable" value = served_row_value(row) if not row.get("value_truncated") else None - return _procedure_status(value) if isinstance(value, dict) else "unknown" + if not isinstance(value, dict): + return "unknown" + try: + return _procedure_status(value) + except (AttributeError, TypeError, ValueError, OverflowError): + return "unknown" diff --git a/server/memory/store/history.py b/server/memory/store/history.py index 91367a39b86..916f61b8be1 100644 --- a/server/memory/store/history.py +++ b/server/memory/store/history.py @@ -10,6 +10,7 @@ from typing import Any from server.core import pg +from server.core.ch import sequential_reads from server.core.repo_base import _CHClient, _default_client, query_all_sliced from server.identity.domain.read_scope import ReadFilters, scope_and from server.memory.store import pg_memory @@ -99,6 +100,7 @@ class HistoryTarget: memory_id: str content_sha256: str # the hash of the version's text, which its search rows carry too tags: tuple[str, ...] = () + redacted_at: str | None = None @classmethod def from_row(cls, r: Mapping[str, Any]) -> HistoryTarget: @@ -113,6 +115,7 @@ def from_row(cls, r: Mapping[str, Any]) -> HistoryTarget: version=int(r.get("version") or 0), content_sha256=str(r.get("content_sha256") or ""), tags=tuple(r.get("tags") or ()), + redacted_at=str(r["redacted_at"]) if r.get("redacted_at") else None, ) @@ -245,22 +248,24 @@ async def find_history_target( ch = ch or _default_client() cols = ( "org, memory_id, namespace, agent, user_id, session_id, memory_key, version, " - "toStringCutToZero(content_sha256) AS content_sha256, tags" + "toStringCutToZero(content_sha256) AS content_sha256, tags, redacted_at" ) at = "org = {org:String} AND memory_id = {mid:UUID} AND version = {v:UInt64}" - r = await ch.query_one( - f""" + with sequential_reads(): + r = await ch.query_one( + f""" SELECT org, toString(memory_id) AS memory_id, namespace, agent, user_id, session_id, - memory_key, version, content_sha256, tags + memory_key, version, content_sha256, tags, redacted_at FROM ( SELECT {cols} FROM loom.memory_versions WHERE {at} UNION ALL SELECT {cols} FROM loom.memory WHERE {at} ) + ORDER BY isNotNull(redacted_at) DESC LIMIT 1 """, - params={"org": org, "mid": memory_id, "v": version}, - ) + params={"org": org, "mid": memory_id, "v": version}, + ) return None if r is None else HistoryTarget.from_row(r) diff --git a/server/memory/store/pg_memory.py b/server/memory/store/pg_memory.py index b921291bdb8..3a71c034bb4 100644 --- a/server/memory/store/pg_memory.py +++ b/server/memory/store/pg_memory.py @@ -1832,7 +1832,7 @@ async def history_target(org: str, memory_id: str, version: int) -> dict[str, An r = await pg.fetchrow( f"SELECT org, memory_id::text AS memory_id, namespace, {_meta('agent')} AS agent, " f"user_id, {_meta('session_id')} AS session_id, {_meta('memory_key')} AS memory_key, " - "version, content_sha256, row->'tags' AS tags " + "version, content_sha256, redacted_at, row->'tags' AS tags " "FROM loom.memory_revisions WHERE org = $1 AND memory_id = $2 AND version = $3 LIMIT 1", org, mid, diff --git a/tests/integration/test_retrieved_use_guidance.py b/tests/integration/test_retrieved_use_guidance.py index c9e4c880daa..4f23a621cc6 100644 --- a/tests/integration/test_retrieved_use_guidance.py +++ b/tests/integration/test_retrieved_use_guidance.py @@ -45,5 +45,7 @@ async def check(review: str, step: str) -> None: await check("none", "validate_lead") await agent.memory.verify(memory_id=written["memory_id"]) await check("process", "validate_lead") + await agent.memory.touch(key, ttl_seconds=3600) + await check("process", "validate_lead") await agent.memory.update_by_id(written["memory_id"], "Refresh the catalog before imports.") await check("stale", "obtain_review") diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 4e27dd1b21d..1a20567e9e1 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -621,3 +621,15 @@ def test_symbol_request_budget_preserves_source_before_whole_lessons() -> None: assert unit.lessons == [lesson, short] unlimited, _, left_out = _budget_definitions([unit], 0) assert unlimited[0].lessons == [lesson, short] and left_out == 0 + + +async def test_unloaded_code_registry_keeps_recall_guidance_unknown(monkeypatch): + from server.code.domain.index.repos import RegistryUnread + from server.memory.app import code_link_reads + + def unavailable(*args): + raise RegistryUnread("registry unavailable") + + monkeypatch.setattr(code_link_reads, "code_namespace_for", unavailable) + row = _excerpt("m1", "readable memory") | {"namespace": "code-a"} + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] diff --git a/tests/unit/test_memory_for_file.py b/tests/unit/test_memory_for_file.py index d1a81793de6..fb41211b333 100644 --- a/tests/unit/test_memory_for_file.py +++ b/tests/unit/test_memory_for_file.py @@ -413,7 +413,7 @@ async def test_an_escaped_constraint_under_the_ceiling_prints_whole( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.truncated is False - assert out.rendered.splitlines()[1] == f"- rules/zh [constraint]: {text} [use: validate_lead]" + assert out.rendered.splitlines()[1] == f"- rules/zh [constraint]: {text}" @pytest.mark.asyncio @@ -432,9 +432,7 @@ async def test_an_emoji_constraint_under_the_ceiling_prints_whole( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.truncated is False - assert ( - out.rendered.splitlines()[1] == f"- rules/emoji [constraint]: {text} [use: validate_lead]" - ) + assert out.rendered.splitlines()[1] == f"- rules/emoji [constraint]: {text}" def test_a_more_line_from_a_left_out_constraint_fits_the_budget( @@ -744,7 +742,7 @@ async def test_the_source_is_read_into_the_hit_and_the_block( MemoryForFileInput(org="o", namespace="ns", path="src/a.cpp") ) assert out.rendered.splitlines()[1] == ( - f"- design/spill [decision] (pinned): Decided X because Y. — source: {_SOURCE} [use: validate_lead]" + f"- design/spill [decision] (pinned): Decided X because Y. — source: {_SOURCE}" ) assert out.hits[0].source_resource_id == _SOURCE diff --git a/tests/unit/test_memory_touch_expiry.py b/tests/unit/test_memory_touch_expiry.py index 81c8bcc4c16..cadaa6e406a 100644 --- a/tests/unit/test_memory_touch_expiry.py +++ b/tests/unit/test_memory_touch_expiry.py @@ -58,8 +58,9 @@ async def _get_one(ident: Any, key: str, **kw: Any) -> Any: calls["one"].append(key) return rows.get(key) - async def _reemit_many(items: list[Any], *, ch: Any = None, batch: int = 500) -> int: + async def _reemit_many(items: list[Any], *, ch: Any = None, of_content: Any = None) -> int: calls["reemit_many"].append(items) + calls["content_hashes"] = of_content return len(items) async def _reemit_one(*args: Any, ch: Any = None, **ov: Any) -> int: @@ -87,8 +88,9 @@ async def test_clear_expiry_on_one_key(stubs: dict[str, Any]) -> None: ((table, rows),) = stubs["ch"].inserts assert table == "loom.memory" and rows[0]["expires_at"] is None assert rows[0]["entities"] == ["mergetree"] and rows[0]["reinforcement_count"] == 4 - ((args, ov),) = stubs["calls"]["reemit_one"] - assert args[-1] == "a" and ov == {"expires_at": None} + ([(key, ov)],) = stubs["calls"]["reemit_many"] + assert key[-1] == "a" and ov == {"expires_at": None, "version": out.version} + assert stubs["calls"]["content_hashes"][key] @pytest.mark.asyncio @@ -113,7 +115,8 @@ async def test_many_keys_are_one_read_one_insert_one_reemit(stubs: dict[str, Any ) (items,) = stubs["calls"]["reemit_many"] assert [k[-1] for k, _ in items] == ["a", "b"] and all( - ov == {"expires_at": None} for _, ov in items + ov == {"expires_at": None, "version": res.version} + for (_, ov), res in zip(items, out.results[:2], strict=True) ) assert stubs["calls"]["reemit_one"] == [] diff --git a/tests/unit/test_sdk_model_memory_metadata.py b/tests/unit/test_sdk_model_memory_metadata.py index f52959c51b8..8d787a979be 100644 --- a/tests/unit/test_sdk_model_memory_metadata.py +++ b/tests/unit/test_sdk_model_memory_metadata.py @@ -151,3 +151,12 @@ async def test_key_correction_cannot_widen_an_unnamed_user_scope(user_id: str | assert calls == [] finally: await agent.close() + + +def test_memory_search_hit_guidance_type_is_resolvable(): + from typing import get_type_hints + + from loom.memory import MemorySearchHit + from loom.ops import UseGuidance + + assert get_type_hints(MemorySearchHit)["use_guidance"] == UseGuidance | None diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index 645a521b393..eebd746c982 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -153,18 +153,34 @@ async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, @pytest.mark.asyncio -async def test_replay_keeps_only_an_authorized_exact_parked_revision( - monkeypatch: pytest.MonkeyPatch, -) -> None: - async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: - return {_KEY: _head()} +async def test_replay_keeps_edited_history_and_withholds_a_redacted_version(monkeypatch): + from server.memory.store.history import HistoryTarget + + async def heads(keys): + return {_KEY: _head(memory_id="m")} + + async def history(org, memory_id, version): + assert memory_id == "m" + return HistoryTarget( + org=org, + namespace="n", + agent="a", + user_id="u", + session_id="s", + memory_key=_KEY[-1], + version=version, + memory_id=memory_id, + content_sha256="a" * 64, + redacted_at="now" if version == 40 else None, + ) monkeypatch.setattr(guidance, "guidance_heads", heads) - current, historical = _hit(), _hit(version=41) + monkeypatch.setattr(guidance, "find_history_target", history) + current, historical, redacted = _hit(), _hit(version=41), _hit(version=40) assert await guidance.attach_search_guidance( - _INPUT, [current, historical], parked=True, replay=True - ) == [current] - assert current.use_guidance is not None and current.use_guidance.review == "unknown" + _INPUT, [current, historical, redacted], parked=True, replay=True + ) == [current, historical] + assert historical.use_guidance is not None and historical.use_guidance.review == "unknown" @pytest.mark.asyncio @@ -256,3 +272,19 @@ async def states(org, rows): assert hit.use_guidance is not None assert hit.use_guidance.review == "unknown" assert hit.use_guidance.next_step == "validate_lead" + + +async def test_parked_hit_keeps_review_when_a_metadata_write_advances_the_version(monkeypatch): + head = _head() + + async def heads(keys): + return {_KEY: head} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + await guidance.attach_search_guidance(_INPUT, [hit], snapshot_only=True) + parked = search_pages.unparked(search_pages._parked(hit)) + assert parked is not None + head["version"] += 2 + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] + assert parked.use_guidance is not None and parked.use_guidance.review == "human" diff --git a/tests/unit/test_use_guidance_sources.py b/tests/unit/test_use_guidance_sources.py index 346da820c8a..cdc1ad78032 100644 --- a/tests/unit/test_use_guidance_sources.py +++ b/tests/unit/test_use_guidance_sources.py @@ -41,3 +41,8 @@ async def test_changed_source_requires_current_access_and_unambiguous_identity(m monkeypatch.setattr(source, "request_narrowed", lambda: True) assert await source.guidance_source_states("org", rows) == ["unknown"] * len(rows) docs.assert_not_awaited() + + +def test_noncanonical_procedure_keeps_unknown_status(): + row = {"memory_type": "procedural", "value": '{"run_stats": "invalid"}'} + assert source.procedure_status_for_row(row) == "unknown" From 89afa781ba5c1175af19b630406fe594ec7c9e98 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:56:48 +0530 Subject: [PATCH 007/117] fix: preserve narrowed search pages and mirror TTL by stored digest Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/handlers.py | 5 ++- server/memory/app/search/guidance.py | 16 ++++++-- server/memory/app/search/output.py | 21 ++++++++++- server/memory/app/search_pages.py | 10 ++++- tests/unit/test_memory_touch_expiry.py | 7 +++- tests/unit/test_pg_authority.py | 51 ++++++++++++++++++++++---- tests/unit/test_search_pages.py | 42 +++++++++++++++++++++ 7 files changed, 135 insertions(+), 17 deletions(-) diff --git a/server/memory/app/handlers.py b/server/memory/app/handlers.py index 8195fcce3f9..41acc2dc784 100644 --- a/server/memory/app/handlers.py +++ b/server/memory/app/handlers.py @@ -52,6 +52,7 @@ from server.memory.domain import lock as _lock from server.memory.domain import trust as _trust from server.memory.domain.delete_marks import delete_version_trace +from server.memory.domain.redaction_lineage import is_content_hash from server.memory.domain.served import served_totals from server.memory.domain.webhook_events import memory_change from server.memory.store import key_write_lock @@ -1435,11 +1436,11 @@ async def handle_memory_touch(input: MemoryTouchInput) -> MemoryTouchOutput: ) for r in (by_key[k] for k in versions) # a 'high' head keeps no vector: never copy one forward under it - if is_embedded(r.memory_type, r.sensitivity) + if is_embedded(r.memory_type, r.sensitivity) and is_content_hash(r.content_sha256) ] if mirror: try: - hashes = {key: served_content_sha256(by_key[key[-1]].value) for key, _ in mirror} + hashes = {key: by_key[key[-1]].content_sha256 for key, _ in mirror} await memory_repo.reemit_embedding_rows_for_keys(mirror, ch=ch, of_content=hashes) except Exception as e: # noqa: BLE001 — expiry mirror is best-effort; memory rows already updated log.warning("memory_embeddings expiry mirror failed (non-fatal): %s", e) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 77e874dc7a3..9c7694e24b1 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -61,11 +61,17 @@ def _current(row: dict[str, Any], now: datetime, *, replay: bool = False) -> boo return True -def hit_in_read_scope(identity: tuple[str, ...] | list[str] | None) -> bool: +def hit_in_read_scope( + identity: tuple[str, ...] | list[str] | None, + *, + allow_unidentified: bool = False, +) -> bool: scope = request_scope() if not scope.narrowed: return True - if identity is None or len(identity) != 3: + if identity is None: + return allow_unidentified + if len(identity) != 3: return False agent, user_id, session_id = identity return agent == SHARED_AGENT or row_in_read_scope(scope, user_id, session_id) @@ -195,6 +201,7 @@ async def attach_search_guidance( replay: bool = False, timeout_s: float = 0.2, snapshot_only: bool = False, + same_parked_scope: bool = False, ) -> list[_MemorySearchHit]: """Project authorization-scoped evidence for the served window. @@ -205,7 +212,10 @@ async def attach_search_guidance( denied = { i for i, hit in enumerate(hits) - if (parked or hit._row_identity is not None) and not hit_in_read_scope(hit._row_identity) + if (parked or hit._row_identity is not None) + and not hit_in_read_scope( + hit._row_identity, allow_unidentified=same_parked_scope and not _fact_row(hit) + ) } keys: dict[int, IdentityKey] = { i: (input.org, *doc_key(hit, input.namespace)) diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index db38db9dd45..8d1349706a7 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -11,6 +11,8 @@ from server.core.ch import get_client, sequential_reads from server.embedding import get_embedder +from server.identity.app.request_scope import request_scope +from server.identity.domain.read_scope import READ_SCOPE_KEY, stored_read_scope from server.memory.api.models_search import MemorySearchInput, MemorySearchOutput, _MemorySearchHit from server.memory.app.search import pg_validation, term_leg from server.memory.app.search.context import SearchContext @@ -92,11 +94,15 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: hits, nxt, stale_dropped = await _parked_slice(input, payload, offset, readable) # Count authorized first-page hits as well as the tail when access changed. parked_rows = (payload.get("first_page_scope") or []) + (payload.get("hits") or []) + same_scope = _same_parked_scope(payload) withheld = sum( 1 for row in parked_rows if row.get("namespace", "") not in readable - or not hit_in_read_scope(row.get("row_identity")) + or not hit_in_read_scope( + row.get("row_identity"), + allow_unidentified=same_scope and row.get("source") not in (None, "fact", "anchor"), + ) ) # Rows the authority no longer serves stay in it, counted per page in `stale_dropped`; # a shared definition withheld since the first page stays in it too, counted nowhere. @@ -183,6 +189,12 @@ async def _parked_shared_flags( return [flags.get(i, False) for i in range(len(hits))] +def _same_parked_scope(payload: dict[str, Any]) -> bool: + # Identity-less results cannot be re-scoped row by row. Only a page created + # under these same predicates can supply one to a narrowed caller. + return payload.get(READ_SCOPE_KEY) == stored_read_scope(request_scope()) + + async def _parked_slice( input: MemorySearchInput, payload: dict[str, Any], offset: int, readable: set[str] ) -> tuple[list[_MemorySearchHit], int, int]: @@ -198,6 +210,7 @@ async def _parked_slice( hits: list[_MemorySearchHit] = [] dropped = 0 j = offset + same_scope = _same_parked_scope(payload) for refill in (False, True): if len(hits) == top_k or j >= len(rows): break @@ -205,7 +218,10 @@ async def _parked_slice( window: list[tuple[int, _MemorySearchHit]] = [] while j < len(rows) and len(window) < size: hit = _pages.unparked(rows[j]) if rows[j].get("namespace", "") in readable else None - if hit is not None and hit_in_read_scope(hit._row_identity): + if hit is not None and hit_in_read_scope( + hit._row_identity, + allow_unidentified=same_scope and hit.source not in ("fact", "anchor"), + ): window.append((j, hit)) j += 1 window_hits = [h for _, h in window] @@ -231,6 +247,7 @@ async def _parked_slice( if h is not None and not stale_hit and not withheld_hit ], parked=True, + same_parked_scope=same_scope, replay=bool(payload.get("replay")), ) current_ids = {id(h) for h in current} diff --git a/server/memory/app/search_pages.py b/server/memory/app/search_pages.py index b37007b1613..2fe088e0e32 100644 --- a/server/memory/app/search_pages.py +++ b/server/memory/app/search_pages.py @@ -32,6 +32,8 @@ from server.core import pg from server.core.datetimes import naive_utc_now +from server.identity.app.request_scope import request_scope +from server.identity.domain.read_scope import READ_SCOPE_KEY, stored_read_scope from server.memory.domain.search_types import RowKey, hit_row_key from server.settings import settings @@ -127,11 +129,17 @@ def encode_page( "namespaces_searched": namespaces_searched, "namespaces_skipped": namespaces_skipped, "hits": hits, + READ_SCOPE_KEY: stored_read_scope(request_scope()), } if first_page: # Scope metadata lets later pages count the original hits without keeping their text. page["first_page_scope"] = [ - {"namespace": hit.namespace, "row_identity": hit._row_identity} for hit in first_page + { + "namespace": hit.namespace, + "row_identity": hit._row_identity, + "source": hit.source, + } + for hit in first_page ] if replay: page["replay"] = True diff --git a/tests/unit/test_memory_touch_expiry.py b/tests/unit/test_memory_touch_expiry.py index cadaa6e406a..c7b1e10db89 100644 --- a/tests/unit/test_memory_touch_expiry.py +++ b/tests/unit/test_memory_touch_expiry.py @@ -45,7 +45,10 @@ def _row(key: str, **kw: Any) -> Any: def stubs(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]: ch = _CH() calls: dict[str, Any] = {"many": [], "one": [], "reemit_many": [], "reemit_one": []} - rows = {k: _row(k, entities=["mergetree"], reinforcement_count=4) for k in ("a", "b")} + rows = { + k: _row(k, entities=["mergetree"], reinforcement_count=4, content_sha256=k * 64) + for k in ("a", "b") + } ch.heads = {identity_key(row): row for row in rows.values()} async def _get_many( @@ -90,7 +93,7 @@ async def test_clear_expiry_on_one_key(stubs: dict[str, Any]) -> None: assert rows[0]["entities"] == ["mergetree"] and rows[0]["reinforcement_count"] == 4 ([(key, ov)],) = stubs["calls"]["reemit_many"] assert key[-1] == "a" and ov == {"expires_at": None, "version": out.version} - assert stubs["calls"]["content_hashes"][key] + assert stubs["calls"]["content_hashes"][key] == "a" * 64 @pytest.mark.asyncio diff --git a/tests/unit/test_pg_authority.py b/tests/unit/test_pg_authority.py index 352b3ba51a4..c74d2f14d64 100644 --- a/tests/unit/test_pg_authority.py +++ b/tests/unit/test_pg_authority.py @@ -1864,22 +1864,57 @@ async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: @pytest.mark.asyncio -async def test_an_as_of_replay_page_does_not_inherit_current_guidance( - monkeypatch: pytest.MonkeyPatch, current_parked_heads: None +async def test_an_as_of_replay_page_returns_since_edited_hits_without_live_guidance( + monkeypatch: pytest.MonkeyPatch, ) -> None: from server.memory.api.models_search import MemorySearchInput from server.memory.app import search_pages - from server.memory.app.search import output, pg_validation + from server.memory.app.search import guidance, output, pg_validation + from server.memory.store.history import HistoryTarget + + edited = _hit("edited", version=5) + edited.content_excerpt = "historical text from the search cut" + current = _hit("unchanged", version=5) + payload = _parked_page( + [edited, current], replay=True, first_page=[_hit("first"), _hit("second")] + ) async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: - raise AssertionError("a replay's page is not checked") + raise AssertionError("replay does not run live version validation") - monkeypatch.setattr(pg_validation, "stale_flags", _flags) - payload = _parked_page([_hit("a"), _hit("b")], replay=True) + async def heads(keys): + return { + key: { + "version": 8 if key[-1] == "edited" else 5, + "status": "active", + "memory_id": key[-1], + "verified_by": "human:reviewer", + "content_sha256": "a" * 64, + "verified_sha256": "a" * 64, + } + for key in keys + } + + async def history(org, memory_id, version): + assert (org, memory_id, version) == ("o", "edited", 5) + return HistoryTarget( + org=org, + namespace="n", + agent="a", + user_id="u", + session_id="s", + memory_key="edited", + version=version, + memory_id=memory_id, + content_sha256="b" * 64, + ) async def _load(*a: Any, **kw: Any) -> dict[str, Any]: return payload + monkeypatch.setattr(pg_validation, "stale_flags", _flags) + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "find_history_target", history) monkeypatch.setattr(search_pages, "load_page", _load) monkeypatch.setattr(output, "get_client", lambda: None) page = MemorySearchInput( @@ -1890,7 +1925,9 @@ async def _load(*a: Any, **kw: Any) -> dict[str, Any]: page=search_pages.make_handle("page/" + "b" * 16, 0), ) out = await output._serve_parked_page(page) - assert [h.memory_key for h in out.results] == ["a", "b"] and out.stale_dropped == 0 + assert [h.memory_key for h in out.results] == ["edited", "unchanged"] + assert out.results[0].content_excerpt == "historical text from the search cut" + assert out.stale_dropped == 0 assert all( h.use_guidance is not None and h.use_guidance.review == "unknown" for h in out.results ) diff --git a/tests/unit/test_search_pages.py b/tests/unit/test_search_pages.py index 2386d73c1ba..123111f9eba 100644 --- a/tests/unit/test_search_pages.py +++ b/tests/unit/test_search_pages.py @@ -349,3 +349,45 @@ async def _down(org: str, *_: object) -> fanout.Fanout: ) out = await h.handle_memory_search(page) assert [r.memory_key for r in out.results] == ["b"] + + +@pytest.mark.asyncio +@pytest.mark.parametrize("stored_user", ["user", "other", None]) +async def test_narrowed_continuation_keeps_chunks_only_under_the_original_scope( + monkeypatch, stored_user +): + from server.identity.domain.read_scope import READ_SCOPE_KEY, ReadFilters + from server.memory.api.models_search import MemorySearchInput + from server.memory.app import search as h + from server.memory.app.search import output + + chunk = _hit("chunk", 0.9, ns="n") + chunk.source = "chunk" + chunk._row_identity = None + fact = _hit("fact", 0.8, ns="n") + unbound_fact = _hit("unbound", 0.7, ns="n") + unbound_fact._row_identity = None + scope = ReadFilters("own_user", "user", None) + monkeypatch.setattr(output, "request_scope", lambda: scope) + monkeypatch.setattr(guidance, "request_scope", lambda: scope) + if stored_user is not None: + monkeypatch.setattr(sp, "request_scope", lambda: ReadFilters("own_user", stored_user, None)) + payload = json.loads(_encode(3, 3, [chunk, fact, unbound_fact])) + if stored_user is None: + payload.pop(READ_SCOPE_KEY) + content = json.dumps(payload) + _callers_namespaces(monkeypatch, ["n"]) + patch_handler_name(monkeypatch, "get_client", lambda: _CH(content)) + result = await h.handle_memory_search( + MemorySearchInput( + org="o", + namespace="n", + query="q", + top_k=3, + page=sp.make_handle(sp.page_blob_key(content), 0), + ) + ) + + expected = ["chunk", "fact"] if stored_user == "user" else ["fact"] + assert [hit.memory_key for hit in result.results] == expected + assert result.candidates_total == len(expected) From 7448894e71e12dc9ee8c717c04743638b448e569 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 19:04:59 +0530 Subject: [PATCH 008/117] fix: enforce historical expiry and preserve hashless TTL updates Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/handlers.py | 16 ++- server/memory/app/search/guidance.py | 4 + server/memory/store/history.py | 6 +- server/memory/store/pg_memory.py | 3 +- tests/analyzer/shapes.txt | 4 +- tests/integration/test_vector_retire_race.py | 104 ++++++++++++++++--- tests/unit/session_content_senders.json | 2 +- tests/unit/test_mcp_initialize_surface.py | 7 +- tests/unit/test_memory_touch_expiry.py | 21 +++- tests/unit/test_pg_authority.py | 23 +++- tests/unit/test_request_sli.py | 4 +- 11 files changed, 161 insertions(+), 33 deletions(-) diff --git a/server/memory/app/handlers.py b/server/memory/app/handlers.py index 41acc2dc784..f31a8d148ee 100644 --- a/server/memory/app/handlers.py +++ b/server/memory/app/handlers.py @@ -1432,15 +1432,25 @@ async def handle_memory_touch(input: MemoryTouchInput) -> MemoryTouchOutput: mirror = [ ( (r.org, r.namespace, r.agent, r.user_id, r.session_id, r.memory_key), - {"expires_at": naive_expiry, "version": versions[r.memory_key]}, + { + "expires_at": naive_expiry, + **( + {"version": versions[r.memory_key]} + if is_content_hash(r.content_sha256) + else {} + ), + }, ) for r in (by_key[k] for k in versions) # a 'high' head keeps no vector: never copy one forward under it - if is_embedded(r.memory_type, r.sensitivity) and is_content_hash(r.content_sha256) + if is_embedded(r.memory_type, r.sensitivity) ] if mirror: try: - hashes = {key: by_key[key[-1]].content_sha256 for key, _ in mirror} + # Without a hash, update expiry at the vector's next version only. + hashes = { + key: by_key[key[-1]].content_sha256 for key, ov in mirror if "version" in ov + } await memory_repo.reemit_embedding_rows_for_keys(mirror, ch=ch, of_content=hashes) except Exception as e: # noqa: BLE001 — expiry mirror is best-effort; memory rows already updated log.warning("memory_embeddings expiry mirror failed (non-fatal): %s", e) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 9c7694e24b1..52cc2eee5f4 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -146,6 +146,10 @@ async def readable(i: int, key: IdentityKey) -> bool: ) if target is None or target.redacted_at is not None: return False + if target.expires_at is not None: + expiry = parse_iso_dt(target.expires_at) + if expiry is None or expiry <= naive_utc_now(): + return False return ( target.org, target.namespace, diff --git a/server/memory/store/history.py b/server/memory/store/history.py index 916f61b8be1..b9b83b6309d 100644 --- a/server/memory/store/history.py +++ b/server/memory/store/history.py @@ -101,6 +101,7 @@ class HistoryTarget: content_sha256: str # the hash of the version's text, which its search rows carry too tags: tuple[str, ...] = () redacted_at: str | None = None + expires_at: str | None = None @classmethod def from_row(cls, r: Mapping[str, Any]) -> HistoryTarget: @@ -116,6 +117,7 @@ def from_row(cls, r: Mapping[str, Any]) -> HistoryTarget: content_sha256=str(r.get("content_sha256") or ""), tags=tuple(r.get("tags") or ()), redacted_at=str(r["redacted_at"]) if r.get("redacted_at") else None, + expires_at=str(r["expires_at"]) if r.get("expires_at") is not None else None, ) @@ -248,14 +250,14 @@ async def find_history_target( ch = ch or _default_client() cols = ( "org, memory_id, namespace, agent, user_id, session_id, memory_key, version, " - "toStringCutToZero(content_sha256) AS content_sha256, tags, redacted_at" + "toStringCutToZero(content_sha256) AS content_sha256, tags, redacted_at, expires_at" ) at = "org = {org:String} AND memory_id = {mid:UUID} AND version = {v:UInt64}" with sequential_reads(): r = await ch.query_one( f""" SELECT org, toString(memory_id) AS memory_id, namespace, agent, user_id, session_id, - memory_key, version, content_sha256, tags, redacted_at + memory_key, version, content_sha256, tags, redacted_at, expires_at FROM ( SELECT {cols} FROM loom.memory_versions WHERE {at} UNION ALL diff --git a/server/memory/store/pg_memory.py b/server/memory/store/pg_memory.py index 59da621d0c7..a218c110220 100644 --- a/server/memory/store/pg_memory.py +++ b/server/memory/store/pg_memory.py @@ -1832,7 +1832,8 @@ async def history_target(org: str, memory_id: str, version: int) -> dict[str, An r = await pg.fetchrow( f"SELECT org, memory_id::text AS memory_id, namespace, {_meta('agent')} AS agent, " f"user_id, {_meta('session_id')} AS session_id, {_meta('memory_key')} AS memory_key, " - f"version, content_sha256, {_meta('redacted_at')} AS redacted_at, row->'tags' AS tags " + f"version, content_sha256, {_meta('redacted_at')} AS redacted_at, " + "row->>'expires_at' AS expires_at, row->'tags' AS tags " "FROM loom.memory_revisions WHERE org = $1 AND memory_id = $2 AND version = $3 LIMIT 1", org, mid, diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 7242a246abb..fbf8504cfe7 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -566,7 +566,6 @@ 4241145d08fa SELECT callee_name, disposition, count() AS n FROM loom.code_call_sites_unresolved FINAL WHERE org = {org:String} AND namespace = {ns:String} AND callee_name IN {names:Array(String)} AND tombstoned_at 424eb9b98496 ALTER TABLE loom.knowledge_ingestions DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync 425e85d1e2ab SELECT org, namespace, agent, user_id, session_id, run_id, goal, user_request, expected_outcome, environment, model, consumer, status, started_at, completed_at, duration_ms, final_response, confidence -4262da811353 SELECT memory_key, memory_type, if({full_values:UInt8}, value, substring(value, ?, if((memory_type = ? OR hasAny(tags, [?, ?])), {whole_bytes:UInt32}, ?))) AS value, tags, confidence, pinned, CAST(sta 426ca1677676 SELECT DISTINCT candidate_id FROM loom.learnings_queue WHERE org = {org:String} AND source_kind = ? AND proposed_value != ? AND candidate_id NOT IN (SELECT candidate_id FROM loom.learnings_supporters 42714bf1b036 SELECT scope_path AS path, summary, pagerank, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.code_summaries FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embeddin 429f25bee1e2 SELECT count() AS n FROM loom.search_misses WHERE org = {org:String} AND namespace = {ns:String} AND ? @@ -733,6 +732,7 @@ 569c9b218f83 ALTER TABLE loom.conflict_allowlist DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = 56a045b3692e SELECT kind, number, source_id, component, is_open, created_at, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.qa_item_embeddings FINAL WHERE org = {org:String} AND namespace = {n 56ab4d25e910 DELETE FROM loom.memory_embeddings WHERE org={org:String} AND namespace={namespace:String} AND agent={agent:String} AND user_id={user_id:String} AND session_id={session_id:String} AND scope={scope:Str +56e519d25919 SELECT memory_key, memory_type, if({full_values:UInt8}, value, substring(value, ?, if((memory_type = ? OR hasAny(tags, [?, ?])), {whole_bytes:UInt32}, ?))) AS value, tags, confidence, pinned, CAST(sta 56f4c4320d80 SELECT f AS path, uniqExact(pr_number) AS prs FROM loom.code_pr_history FINAL ARRAY JOIN files AS f WHERE org = {org:String} AND namespace = {ns:String} AND merged_at > now() - INTERVAL {days:UInt32} 56f6ba832916 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, toString(valid_at) AS valid_at, version FROM loom.memory_embeddings FINAL WHERE org = { 56f6eca8bb7f SELECT count() AS n FROM loom.session_briefs WHERE org = {org:String} AND user_id = {uid:String} @@ -2105,6 +2105,7 @@ e8aec6fb1cfa SELECT if(format != ?, toString(format), if(JSONExtractString(metad e8d8f30521ad SELECT f AS path, argMin(pr_number, merged_at) AS first_pr, min(merged_at) AS first_merged_at FROM loom.code_pr_history FINAL ARRAY JOIN files AS f WHERE org = {org:String} AND namespace = {ns:String} e8dbbea8dde5 SELECT org, code_namespace, path, qualified_name, namespace, memory_id FROM loom.memory_code_links ORDER BY org, code_namespace, path, qualified_name, namespace, memory_id LIMIT {lim:UInt32} e8ee753a0792 SELECT DISTINCT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory WHERE tombstoned_at IS NULL AND sensitivity = ? AND (expires_at IS NULL OR expires_at > now()) AND (match(value, +e909916f6a2b SELECT org, toString(memory_id) AS memory_id, namespace, agent, user_id, session_id, memory_key, version, content_sha256, tags, redacted_at, expires_at FROM ( SELECT org, memory_id, namespace, agent, e95e0aaed16c SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- Multi-vector axis: min(value_dist, key_dist). CH?t g e9b0e6383969 ALTER TABLE loom.knowledge_source_listings DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_ e9bc797f59c7 SELECT org, namespace, agent, user_id, session_id, memory_key, argMax(status, version) AS status, argMax(duplicate_of, version) AS duplicate_of, argMax(tombstoned_at IS NULL, version) AS live, argMax( @@ -2162,7 +2163,6 @@ f0269d04cc56 SELECT count() AS n FROM loom.memory_projection_failures WHERE org f06c74498575 SELECT tag, count() AS rows FROM (SELECT arrayJoin(tags) AS tag FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND user_id != {id:String} AND use f072c6c29b23 SELECT memory_type, toString(status) AS status, source_class, count() AS rows, min(updated_at) AS first_at, max(updated_at) AS last_at FROM loom.memory FINAL WHERE org = {org:String} AND namespace = { f08249ee1acf SELECT kind, name, status, description, cardinality, created_by, updated_at FROM loom.namespace_ontology FINAL WHERE org = {org:String} AND namespace = {ns:String} AND kind = {kind:String} AND status -f0c46bd2964b SELECT org, toString(memory_id) AS memory_id, namespace, agent, user_id, session_id, memory_key, version, content_sha256, tags FROM ( SELECT org, memory_id, namespace, agent, user_id, session_id, memo f0d1a655888a SELECT c.session_id AS session_id, c.chunk_index AS chunk_index, c.parent_memory_key AS parent_memory_key, cosineDistance(c.embedding, {q:Array(Float32)}) AS distance FROM loom.memory_chunks AS c WHER f0e13f039554 ALTER TABLE loom.knowledge_source_listings DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? f0f965973223 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, -- Multi-vector axis: min(value_dist, key_dist). CH?t g diff --git a/tests/integration/test_vector_retire_race.py b/tests/integration/test_vector_retire_race.py index 291594413cd..89ada36cd6b 100644 --- a/tests/integration/test_vector_retire_race.py +++ b/tests/integration/test_vector_retire_race.py @@ -1436,6 +1436,71 @@ async def copies() -> None: ) +async def test_hashless_touch_restores_vector_search_eligibility(ch: Any, monkeypatch: Any): + from server.memory import store as M + from server.memory.api.models_crud import MemoryTouchInput + from server.memory.app import handlers + + ns = f"itest-{uuid.uuid4().hex[:12]}" + value = "The deploy uses blue" + version = M.next_version() + row = _memory_row(ns, version, value, "") | {"content_sha256": ""} + vector = M.build_embedding_row( + org=ORG, + namespace=ns, + agent=AGENT, + user_id=USER, + session_id=SESSION, + memory_key=KEY, + memory_type="semantic", + scope="private", + content_excerpt=value, + content_sha256="", + embedding_model="fake", + embedding_dim=_DIM, + embedding=_wide([0.1, 0.2, 0.3]), + version=version, + created_at=datetime.now(UTC).replace(tzinfo=None), + expires_at=datetime(2001, 1, 1), + ) + params = {"o": ORG, "n": ns, "k": KEY} + + async def eligible(): + return await ch.query_all( + "SELECT content_excerpt, version, expires_at FROM loom.memory_embeddings FINAL " + "WHERE org = {o:String} AND namespace = {n:String} AND memory_key = {k:String} " + "AND tombstoned_at IS NULL AND (expires_at IS NULL OR expires_at > now())", + params=params, + ) + + monkeypatch.setattr(handlers, "get_client", lambda: ch) + try: + await M.insert_memory_versions([row], ch=ch) + await M.insert_embedding_rows([vector], ch=ch) + assert await eligible() == [] + result = await handlers.handle_memory_touch( + MemoryTouchInput( + org=ORG, + namespace=ns, + agent=AGENT, + user_id=USER, + session_id=SESSION, + memory_key=KEY, + clear_expiry=True, + ) + ) + assert result.touched and result.expires_at is None + (hit,) = await eligible() + assert hit["content_excerpt"] == value and hit["expires_at"] is None + assert hit["version"] == version + 1 and hit["version"] != result.version + finally: + for table in ("memory", "memory_embeddings"): + await ch.execute( + f"DELETE FROM loom.{table} WHERE org = {{o:String}} AND namespace = {{n:String}}", + params={"o": ORG, "n": ns}, + ) + + async def test_copies_that_read_the_head_before_the_high_write_retire_themselves( ch: Any, monkeypatch: Any ) -> None: @@ -1453,31 +1518,38 @@ async def test_copies_that_read_the_head_before_the_high_write_retire_themselves key = f"r41_{uuid.uuid4().hex[:6]}" ident = {"org": ORG, "namespace": ns, "agent": AGENT, "memory_key": key} secret = "sk-proj-" + uuid.uuid4().hex + uuid.uuid4().hex[:8] - await _memory_only_row(ch, ns, key, "OLDVALUE the deploy uses blue") + # Hashless touches use the embedding's own next version; exercise that path. + row = _memory_row(ns, M.next_version(), "OLDVALUE the deploy uses blue", "") + await M.insert_memory_versions([row | {"memory_key": key, "content_sha256": ""}], ch=ch) + + from server.memory.store import embeddings - orig = M.reemit_embedding_rows_for_key + reemit = M.reemit_embedding_rows_for_keys + read = embeddings._live_rows_for_keys entered = {"A": asyncio.Event(), "B": asyncio.Event()} go_a, go_b_read, b_read_done, go_b_insert = (asyncio.Event() for _ in range(4)) calls: list[str] = [] + second_touch: asyncio.Task[Any] | None = None - async def wrapped(o, n, a, u, s, k, *, ch=None, **ov): # type: ignore[no-untyped-def] + async def wrapped(items, **kwargs): # type: ignore[no-untyped-def] + nonlocal second_touch who = "A" if not calls else "B" calls.append(who) + if who == "B": + second_touch = asyncio.current_task() entered[who].set() - if who == "A": - await go_a.wait() - return await orig(o, n, a, u, s, k, ch=ch, **ov) - await go_b_read.wait() - rows = await M.live_embedding_rows_for_key( - ch, org=o, namespace=n, agent=a, user_id=u, session_id=s, memory_key=k - ) - b_read_done.set() - await go_b_insert.wait() - from server.memory.store.embeddings import reemit_rows - - return await reemit_rows(rows, ov, ch=ch) + await (go_a if who == "A" else go_b_read).wait() + return await reemit(items, **kwargs) + + async def paused_read(*args, **kwargs): # type: ignore[no-untyped-def] + rows = await read(*args, **kwargs) + if asyncio.current_task() is second_touch and not b_read_done.is_set(): + b_read_done.set() + await go_b_insert.wait() + return rows - monkeypatch.setattr(M, "reemit_embedding_rows_for_key", wrapped) + monkeypatch.setattr(M, "reemit_embedding_rows_for_keys", wrapped) + monkeypatch.setattr(embeddings, "_live_rows_for_keys", paused_read) monkeypatch.setattr(handlers, "get_client", lambda: ch) tasks: list[asyncio.Task[Any]] = [] diff --git a/tests/unit/session_content_senders.json b/tests/unit/session_content_senders.json index a6eb8a23503..27fc1136575 100644 --- a/tests/unit/session_content_senders.json +++ b/tests/unit/session_content_senders.json @@ -406,7 +406,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": "ce7a8616b3d079d7c5241d932f04d85b5c6da6f4843d68d3938e52a3ddb6e8ee", + "sdk/python/loom/memory.py": "654cf81e0f5399b9239ff13dfd25b91161c1855bbfa30333cae5f1f257a71451", "sdk/python/loom/run.py": "1d47d5f4d197f78de347d2cf66b9f59f4292846d214f7116c444035971c6ab42", "sdk/python/loom/session.py": "5f0fd61fcfdbf9d60888b111887fca8f32e24eb51ca9ff04a256901657c3202b", "sdk/typescript/src/integrations/claude-memory.ts": "c846f0011d7cf1ba4b30e99fbfd8adb6b29abff56856d0dbe14fba620007f6bc", diff --git a/tests/unit/test_mcp_initialize_surface.py b/tests/unit/test_mcp_initialize_surface.py index 9c370a74f7b..1bbf61bd437 100644 --- a/tests/unit/test_mcp_initialize_surface.py +++ b/tests/unit/test_mcp_initialize_surface.py @@ -342,7 +342,12 @@ def test_loom_search_output_schema_declares_all_returned_sections() -> None: schema = loom_search["outputSchema"] sections = {"memory", "knowledge", "profile", "conversations"} # Strict clients must also accept the optional connected-source section. - assert set(schema["properties"]) == sections | {"live"} + assert set(schema["properties"]) == sections | { + "live", + "tracker", + "withheld", + "namespaces_skipped", + } assert schema["properties"]["live"]["type"] == "object" assert "live" not in schema.get("required", []) diff --git a/tests/unit/test_memory_touch_expiry.py b/tests/unit/test_memory_touch_expiry.py index c7b1e10db89..e03faa514f9 100644 --- a/tests/unit/test_memory_touch_expiry.py +++ b/tests/unit/test_memory_touch_expiry.py @@ -46,8 +46,13 @@ def stubs(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]: ch = _CH() calls: dict[str, Any] = {"many": [], "one": [], "reemit_many": [], "reemit_one": []} rows = { - k: _row(k, entities=["mergetree"], reinforcement_count=4, content_sha256=k * 64) - for k in ("a", "b") + k: _row( + k, + entities=["mergetree"], + reinforcement_count=4, + content_sha256=k * 64 if k != "c" else "", + ) + for k in ("a", "b", "c") } ch.heads = {identity_key(row): row for row in rows.values()} @@ -205,3 +210,15 @@ async def test_the_heads_a_touch_writes_from_are_whole_rows() -> None: ch = _SQLCapture() await mr.get_many_by_keys(ident, ["k"], ch=ch, scope=WHOLE_NAMESPACE) # type: ignore[arg-type] assert "last_reinforced_at" not in ch.sql[1].split("FROM loom.memory", 1)[0] + + +@pytest.mark.asyncio +async def test_hashless_touch_updates_embedding_expiry_without_pinning_its_version(stubs): + out = await mem_handlers.handle_memory_touch( + MemoryTouchInput(org="o", namespace="n", agent="a", memory_key="c", clear_expiry=True) + ) + assert out.touched and out.expires_at is None + ([(key, overrides)],) = stubs["calls"]["reemit_many"] + assert key[-1] == "c" + assert overrides == {"expires_at": None} + assert stubs["calls"]["content_hashes"] == {} diff --git a/tests/unit/test_pg_authority.py b/tests/unit/test_pg_authority.py index c74d2f14d64..3ffdf49f661 100644 --- a/tests/unit/test_pg_authority.py +++ b/tests/unit/test_pg_authority.py @@ -1864,8 +1864,10 @@ async def _flags(org: str, namespace: str, hits: list[Any]) -> list[bool]: @pytest.mark.asyncio +@pytest.mark.parametrize("historical_expiry", ["2000-01-01T00:00:00", "2098-01-01T00:00:00"]) async def test_an_as_of_replay_page_returns_since_edited_hits_without_live_guidance( monkeypatch: pytest.MonkeyPatch, + historical_expiry: str, ) -> None: from server.memory.api.models_search import MemorySearchInput from server.memory.app import search_pages @@ -1887,6 +1889,7 @@ async def heads(keys): key: { "version": 8 if key[-1] == "edited" else 5, "status": "active", + "expires_at": "2099-01-01T00:00:00", "memory_id": key[-1], "verified_by": "human:reviewer", "content_sha256": "a" * 64, @@ -1907,6 +1910,7 @@ async def history(org, memory_id, version): version=version, memory_id=memory_id, content_sha256="b" * 64, + expires_at=historical_expiry, ) async def _load(*a: Any, **kw: Any) -> dict[str, Any]: @@ -1925,9 +1929,13 @@ async def _load(*a: Any, **kw: Any) -> dict[str, Any]: page=search_pages.make_handle("page/" + "b" * 16, 0), ) out = await output._serve_parked_page(page) - assert [h.memory_key for h in out.results] == ["edited", "unchanged"] - assert out.results[0].content_excerpt == "historical text from the search cut" - assert out.stale_dropped == 0 + expired = historical_expiry.startswith("2000") + assert [h.memory_key for h in out.results] == ( + ["unchanged"] if expired else ["edited", "unchanged"] + ) + if not expired: + assert out.results[0].content_excerpt == "historical text from the search cut" + assert out.stale_dropped == int(expired) assert all( h.use_guidance is not None and h.use_guidance.review == "unknown" for h in out.results ) @@ -3285,12 +3293,19 @@ async def test_a_redaction_finds_a_version_clickhouse_does_not_hold_yet( async def _fetchrow(sql: str, *args: Any) -> dict[str, Any]: asked.append(args) assert "coalesce(redacted_at, row->>'redacted_at') AS redacted_at" in sql - return {**head, "content_sha256": "", "redacted_at": "2026-01-01T00:00:00"} + assert "row->>'expires_at' AS expires_at" in sql + return { + **head, + "content_sha256": "", + "redacted_at": "2026-01-01T00:00:00", + "expires_at": "2026-02-01T00:00:00", + } monkeypatch.setattr(pg, "fetchrow", _fetchrow) target = await history.find_history_target("o", mid, 7, ch=object()) assert target is not None and (target.namespace, target.version) == ("n", 7) assert target.redacted_at == "2026-01-01T00:00:00" + assert target.expires_at == "2026-02-01T00:00:00" assert asked == [("o", uuid.UUID(mid), 7)] diff --git a/tests/unit/test_request_sli.py b/tests/unit/test_request_sli.py index f0a4573e5ae..f3a38d6960b 100644 --- a/tests/unit/test_request_sli.py +++ b/tests/unit/test_request_sli.py @@ -1226,7 +1226,7 @@ def test_only_answers_whole_without_the_namespace_leave_an_unverified_refusal_un for kw in call.keywords: if kw.arg != "hides_answer": continue - rel = str(path.relative_to(REPO_ROOT)) + rel = path.relative_to(REPO_ROOT).as_posix() if isinstance(kw.value, ast.Name) and kw.value.id == "hides_answer": continue # a gate passing its caller's choice through if not isinstance(kw.value, ast.Constant): @@ -1240,6 +1240,8 @@ def test_only_answers_whole_without_the_namespace_leave_an_unverified_refusal_un ("server/code/app/answers_cache.py", "reuse_allowed", never), ("server/code/app/search_fanout.py", "readable_subset", never), ("server/memory/app/code_link_reads.py", "readable_namespaces", never), + # The memory is readable without guidance about its supporting source. + ("server/memory/app/use_guidance.py", "_readable_documents", never), ("server/memory/app/code_grounding.py", "_authorized_code_target", never), ("server/code/app/repo_scope.py", "readable_repo_namespace", never), # The wording of a refusal another check decided. From 3588b51158167275d702d9ad2e5bfc60382e2a8d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:31:55 +0530 Subject: [PATCH 009/117] Recalibrate search after guidance removes hits A head recheck can remove evidence after the verdict is computed. Recompute confidence and abstention from retained hits. Verify that a single-key touch reads live embeddings with the full identity in the batch query. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/search/handler.py | 19 +++++++++-- server/memory/app/search/output.py | 10 +++--- .../unit/test_memory_search_handler_gates.py | 30 +++++++++++++++++ tests/unit/test_memory_write_path_mirror.py | 33 ++++++++++++++----- 4 files changed, 78 insertions(+), 14 deletions(-) diff --git a/server/memory/app/search/handler.py b/server/memory/app/search/handler.py index 5458e5887b4..48deb516c7c 100644 --- a/server/memory/app/search/handler.py +++ b/server/memory/app/search/handler.py @@ -344,11 +344,26 @@ async def handle_memory_search(input: MemorySearchInput) -> MemorySearchOutput: ctx, run, final_hits ) + verdict_hits = final_hits final_hits, calibration, abstain_verdict = await _verdict( - ctx, run, final_hits, evidence_support_count + ctx, run, verdict_hits, evidence_support_count ) - final_hits, _unit_bodies, _namespaces_searched = await _shape_final_hits(ctx, final_hits) + final_hits, _unit_bodies, _namespaces_searched, guidance_dropped = await _shape_final_hits( + ctx, final_hits + ) + if guidance_dropped: + retained = {id(hit) for hit in final_hits} + ctx.actual_work.pop("below_threshold_hits", None) + # Preserve the verdict's original rank order and exclude late tier rows. + # The pooled support count can include evidence for removed rows. + calibration, abstain_verdict = _calibrate_final_hits( + ctx, run, [hit for hit in verdict_hits if id(hit) in retained], 0 + ) + governed_count = sum(1 for hit in final_hits if hit.governed) + ctx.actual_work["term_leg_served"] = governed_count + if governed_count: + abstain_verdict = (False, "", "") _output = _build_search_output( ctx, run, diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index 8d1349706a7..55c11bb9e4b 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -303,11 +303,11 @@ def move_stale(hits: list[Any], input: Any) -> list[Any]: async def _shape_final_hits( ctx: SearchContext, final_hits: list[_MemorySearchHit] -) -> tuple[list[_MemorySearchHit], tuple[int, int, int], list[str]]: +) -> tuple[list[_MemorySearchHit], tuple[int, int, int], list[str], bool]: """Phase 22: shape the served hits — decorate, prepend recent/anchor rows, body floor, move down those whose code changed, unit and source bodies, relative-date wording, foreign namespace marks, grounded excerpts, optional fields. Returns the - hits, the unit-body counts and the namespaces searched.""" + hits, the unit-body counts, the namespaces searched and whether guidance removed rows.""" input = ctx.input namespaces = ctx.namespaces actual_work = ctx.actual_work @@ -327,7 +327,9 @@ async def _shape_final_hits( code_change.spend_marks(final_hits) else: final_hits = move_stale(final_hits, input) - final_hits = await attach_search_guidance(input, final_hits, replay=input.as_of is not None) + guided_hits = await attach_search_guidance(input, final_hits, replay=input.as_of is not None) + guidance_dropped = len(guided_hits) < len(final_hits) + final_hits = guided_hits _unit_bodies = await _expand_unit_bodies( final_hits, input, prefer_entities=list(ctx.effective_entity_filter) ) @@ -363,7 +365,7 @@ async def _shape_final_hits( actual_work["relative_excerpts_grounded"] = ground_hits(final_hits) actual_work.update(await _fill_optional_hit_fields(final_hits, input, _namespaces_searched)) - return final_hits, _unit_bodies, _namespaces_searched + return final_hits, _unit_bodies, _namespaces_searched, guidance_dropped def _build_search_output( diff --git a/tests/unit/test_memory_search_handler_gates.py b/tests/unit/test_memory_search_handler_gates.py index ea5b6a46e6e..b5620fabedf 100644 --- a/tests/unit/test_memory_search_handler_gates.py +++ b/tests/unit/test_memory_search_handler_gates.py @@ -2,6 +2,7 @@ from __future__ import annotations +from dataclasses import replace from datetime import datetime from types import SimpleNamespace from typing import Any @@ -159,6 +160,35 @@ async def test_fast_budget_spends_no_llm_call(search_env) -> None: assert out.retrieval_work["llm_calls_total"] == 0 +@pytest.mark.parametrize( + "unavailable_head", [{"tombstoned_at": "now"}, {"expires_at": "2000-01-01"}] +) +async def test_verdict_abstains_when_guidance_drops_the_last_hit( + search_env, monkeypatch: pytest.MonkeyPatch, unavailable_head: dict[str, str] +) -> None: + from server.memory.app.search import guidance + + hit = replace(_svc_hit("blue", sim=0.95), identity=("a", "-", "-"), version=42) + search_env.hits = [hit] + head: dict[str, Any] = {"version": hit.version, "status": "active"} + + async def heads(keys): + assert keys == [("o", "ns", "a", "-", "-", "blue")] + return {keys[0]: head} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "naive_utc_now", lambda: datetime(2000, 1, 2)) + live = await _run(search_env) + assert [row.memory_key for row in live.results] == ["blue"] + assert not live.abstain and live.retrieval_confidence > 0 + + head.update(unavailable_head) + unavailable = await _run(search_env) + assert unavailable.results == [] + assert unavailable.abstain and unavailable.abstain_code == "no_match" + assert unavailable.retrieval_confidence == 0.0 and unavailable.retrieval_risk == "abstain" + + async def test_weak_top_hit_makes_no_hyde_call(search_env) -> None: # A weak top hit on the default path makes no HyDE call: the read path # stays LLM-free. diff --git a/tests/unit/test_memory_write_path_mirror.py b/tests/unit/test_memory_write_path_mirror.py index f5fceadcd73..ca3f30555d3 100644 --- a/tests/unit/test_memory_write_path_mirror.py +++ b/tests/unit/test_memory_write_path_mirror.py @@ -77,7 +77,7 @@ def __init__( self.fail_inserts_into = fail_inserts_into self.insert_calls: list[tuple[str, list[dict[str, Any]], dict[str, Any]]] = [] self.execute_calls: list[tuple[str, dict[str, Any]]] = [] - self.query_all_sqls: list[str] = [] + self.query_all_calls: list[tuple[str, dict[str, Any]]] = [] async def query_one( self, sql: str, params: dict[str, Any] | None = None @@ -87,7 +87,7 @@ async def query_one( async def query_all( self, sql: str, params: dict[str, Any] | None = None ) -> list[dict[str, Any]]: - self.query_all_sqls.append(sql) + self.query_all_calls.append((sql, params or {})) if ( "FROM loom.memory FINAL" in sql and "PREWHERE (org, namespace, agent, user_id, session_id, memory_key)" in sql @@ -232,7 +232,7 @@ async def _get_by_key(*_: Any, **__: Any) -> MemoryRow: assert row["source_class"] == "extracted" assert row["valid_to"] == _NOW assert row["verified"] == 0 - emb_sql = next(s for s in ch.query_all_sqls if "loom.memory_embeddings" in s) + emb_sql = next(sql for sql, _ in ch.query_all_calls if "loom.memory_embeddings" in sql) assert "argMaxIf(memory_key_embedding" in emb_sql assert "argMax(content_excerpt, version)" in emb_sql @@ -301,7 +301,8 @@ async def test_touch_mirrors_expiry_onto_embeddings( live embedding rows — every persisted column and both vectors carried, `expires_at` set, a fresh version — never a lightweight UPDATE (its patch part would switch the fact leg's codes-first read off).""" - ch = _StubCH(query_all_routes=[("FROM loom.memory_embeddings", [dict(_EMB_TABLE_ROW)])]) + identity = {"user_id": "user-1", "session_id": "session-1"} + ch = _StubCH(query_all_routes=[("FROM loom.memory_embeddings", [_EMB_TABLE_ROW | identity])]) monkeypatch.setattr(mem_handlers, "get_client", lambda: ch) monkeypatch.setattr(_stack_mod, "get_client", lambda: ch) monkeypatch.setattr(_restore_mod, "get_client", lambda: ch) @@ -309,7 +310,7 @@ async def test_touch_mirrors_expiry_onto_embeddings( monkeypatch.setattr("server.memory.app.update.get_client", mem_handlers.get_client) async def _get_by_key(*_: Any, **__: Any) -> MemoryRow: - return _mk_row() + return _mk_row(**identity) monkeypatch.setattr("server.memory.store.get_by_key", _get_by_key) @@ -320,6 +321,7 @@ async def _get_by_key(*_: Any, **__: Any) -> MemoryRow: agent="cursor", memory_key="user_dog_name", ttl_seconds=7200, + **identity, ) ) assert out.touched is True @@ -335,9 +337,24 @@ async def _get_by_key(*_: Any, **__: Any) -> MemoryRow: assert row["memory_key_embedding"] == _EMB_TABLE_ROW["memory_key_embedding"] assert row["content_excerpt"] == _EMB_TABLE_ROW["content_excerpt"] assert row["version"] > 0 - # the read is one keyed FINAL statement over the full identity - read_sql = next(s for s in ch.query_all_sqls if "loom.memory_embeddings" in s) - assert "FINAL" in read_sql and "memory_key = {k:String}" in read_sql + ((read_sql, params),) = [ + (sql, params) for sql, params in ch.query_all_calls if "FROM loom.memory_embeddings" in sql + ] + assert "FROM loom.memory_embeddings FINAL" in read_sql + assert ( + "PREWHERE (org, namespace, agent, user_id, session_id, memory_key) IN arrayZip( " + "{o:Array(String)}, {n:Array(String)}, {a:Array(String)}, " + "{u:Array(String)}, {s:Array(String)}, {k:Array(String)})" + ) in " ".join(read_sql.split()) + assert "WHERE tombstoned_at IS NULL" in read_sql + assert params == { + "o": ["test"], + "n": ["personal"], + "a": ["cursor"], + "u": ["user-1"], + "s": ["session-1"], + "k": ["user_dog_name"], + } @pytest.mark.asyncio From 49ed545a3c9d19cab65ef39dfe63b0e25700c087 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:37:09 +0530 Subject: [PATCH 010/117] Keep belief support for retained search hits Recount support for the surviving evidence when the verdict pool shrinks. Keep the same fallback when the support lookup fails. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/search/computed.py | 6 +---- server/memory/app/search/evidence_support.py | 27 ++++++++++++------- server/memory/app/search/handler.py | 14 +++------- server/memory/app/search/verdict.py | 22 +++++++++++++++ .../unit/test_memory_search_handler_gates.py | 25 +++++++++++++++++ 5 files changed, 68 insertions(+), 26 deletions(-) diff --git a/server/memory/app/search/computed.py b/server/memory/app/search/computed.py index ae888cc8b28..945172dbc40 100644 --- a/server/memory/app/search/computed.py +++ b/server/memory/app/search/computed.py @@ -268,10 +268,6 @@ async def _floor_and_computed_evidence( namespace=input.namespace, ), ) - evidence_support_count = 0 - try: - evidence_support_count = await _evidence_support_count(input, final_hits) - except Exception as e: # noqa: BLE001 - log.warning("evidence support lookup failed (non-fatal): %s", e) + evidence_support_count = await _evidence_support_count(input, final_hits) _clock.mark("evidence_support") return final_hits, derived_aggregate, evidence_support_count diff --git a/server/memory/app/search/evidence_support.py b/server/memory/app/search/evidence_support.py index 89d2158c21d..c062ee74d25 100644 --- a/server/memory/app/search/evidence_support.py +++ b/server/memory/app/search/evidence_support.py @@ -2,11 +2,14 @@ from __future__ import annotations +import logging from typing import Any from server.core.ch import get_client from server.memory.api.models_search import MemorySearchInput +log = logging.getLogger(__package__) + async def _evidence_support_count(input: MemorySearchInput, hits: list[Any]) -> int: if not hits: @@ -16,9 +19,10 @@ async def _evidence_support_count(input: MemorySearchInput, hits: list[Any]) -> ns_keys.setdefault(h.namespace or input.namespace, []).append(h.memory_key) from server.observability.otel import traced - with traced("ch.query.memory_belief_sources", op="evidence_support", keys=len(hits)): - rows = await get_client().query_all( - """ + try: + with traced("ch.query.memory_belief_sources", op="evidence_support", keys=len(hits)): + rows = await get_client().query_all( + """ SELECT count() AS n FROM ( SELECT memory_key, evidence_id, argMax(tombstoned_at, created_at) AS tomb_latest @@ -30,10 +34,13 @@ async def _evidence_support_count(input: MemorySearchInput, hits: list[Any]) -> HAVING tomb_latest IS NULL ) """, - params={ - "org": input.org, - "namespaces": list(ns_keys.keys()), - "keys": [k for keys in ns_keys.values() for k in keys], - }, - ) - return int(rows[0]["n"]) if rows else 0 + params={ + "org": input.org, + "namespaces": list(ns_keys.keys()), + "keys": [k for keys in ns_keys.values() for k in keys], + }, + ) + return int(rows[0]["n"]) if rows else 0 + except Exception as e: # noqa: BLE001 — missing belief support must not fail search + log.warning("evidence support lookup failed (non-fatal): %s", e) + return 0 diff --git a/server/memory/app/search/handler.py b/server/memory/app/search/handler.py index 48deb516c7c..ef715264938 100644 --- a/server/memory/app/search/handler.py +++ b/server/memory/app/search/handler.py @@ -69,7 +69,7 @@ _start_actual_work, ) from server.memory.app.search.vector_legs import _run_vector_legs -from server.memory.app.search.verdict import _calibrate_final_hits +from server.memory.app.search.verdict import _calibrate_final_hits, _verdict_after_guidance async def _run_retrieval_stages( @@ -353,17 +353,9 @@ async def handle_memory_search(input: MemorySearchInput) -> MemorySearchOutput: ctx, final_hits ) if guidance_dropped: - retained = {id(hit) for hit in final_hits} - ctx.actual_work.pop("below_threshold_hits", None) - # Preserve the verdict's original rank order and exclude late tier rows. - # The pooled support count can include evidence for removed rows. - calibration, abstain_verdict = _calibrate_final_hits( - ctx, run, [hit for hit in verdict_hits if id(hit) in retained], 0 + calibration, abstain_verdict = await _verdict_after_guidance( + ctx, run, verdict_hits, final_hits, evidence_support_count ) - governed_count = sum(1 for hit in final_hits if hit.governed) - ctx.actual_work["term_leg_served"] = governed_count - if governed_count: - abstain_verdict = (False, "", "") _output = _build_search_output( ctx, run, diff --git a/server/memory/app/search/verdict.py b/server/memory/app/search/verdict.py index 2fac208b10d..e62803a760e 100644 --- a/server/memory/app/search/verdict.py +++ b/server/memory/app/search/verdict.py @@ -7,6 +7,7 @@ from server.memory.api.models_search import _MemorySearchHit from server.memory.app.search.context import SearchContext +from server.memory.app.search.evidence_support import _evidence_support_count from server.memory.app.search.scope import _SearchRun from server.memory.domain.search_types import TIER_COMPONENTS @@ -205,3 +206,24 @@ def _calibrate_final_hits( work=actual_work, ) return calibration, (abstain, abstain_code, abstain_reason) + + +async def _verdict_after_guidance( + ctx: SearchContext, + run: _SearchRun, + verdict_hits: list[_MemorySearchHit], + final_hits: list[_MemorySearchHit], + evidence_support_count: int, +) -> tuple[RetrievalCalibration, tuple[bool, str, str]]: + # Preserve the verdict's original rank order and exclude late tier rows. + served_ids = {id(hit) for hit in final_hits} + retained = [hit for hit in verdict_hits if id(hit) in served_ids] + if evidence_support_count and len(retained) < len(verdict_hits): + evidence_support_count = await _evidence_support_count(ctx.input, retained) + ctx.actual_work.pop("below_threshold_hits", None) + calibration, abstain_verdict = _calibrate_final_hits(ctx, run, retained, evidence_support_count) + governed_count = sum(1 for hit in final_hits if hit.governed) + ctx.actual_work["term_leg_served"] = governed_count + if governed_count: + abstain_verdict = (False, "", "") + return calibration, abstain_verdict diff --git a/tests/unit/test_memory_search_handler_gates.py b/tests/unit/test_memory_search_handler_gates.py index b5620fabedf..7c201e3e6c9 100644 --- a/tests/unit/test_memory_search_handler_gates.py +++ b/tests/unit/test_memory_search_handler_gates.py @@ -189,6 +189,31 @@ async def heads(keys): assert unavailable.retrieval_confidence == 0.0 and unavailable.retrieval_risk == "abstain" +async def test_verdict_keeps_belief_support_for_a_retained_hit(search_env, monkeypatch) -> None: + from server.memory.app.search import evidence_support, guidance + + retained = _svc_hit("retained", sim=0.75) + removed = replace(_svc_hit("removed", sim=0.95), identity=("a", "-", "-"), version=42) + + async def heads(keys): + return {keys[0]: {"version": 42, "tombstoned_at": "now"}} + + async def support(sql, params): + return [{"n": int("retained" in params["keys"])}] + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(evidence_support, "get_client", lambda: SimpleNamespace(query_all=support)) + search_env.hits = [retained] + baseline = await _run(search_env) + search_env.hits = [removed, retained] + result = await _run(search_env) + + assert [row.memory_key for row in result.results] == ["retained"] + assert result.retrieval_confidence == baseline.retrieval_confidence + assert "evidence_support=1" in baseline.calibration_explanation + assert result.calibration_explanation == baseline.calibration_explanation + + async def test_weak_top_hit_makes_no_hyde_call(search_env) -> None: # A weak top hit on the default path makes no HyDE call: the read path # stays LLM-free. From 3f324c9cb04c90d9639a987d90eef11b3f3df842 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 20:40:13 +0530 Subject: [PATCH 011/117] Count belief support for exact search keys Bind namespace and memory key as a pair so a dropped hit cannot contribute support through two surviving hits in different namespaces. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/search/evidence_support.py | 26 +++---------------- server/memory/store/reads.py | 20 ++++++++++++++ .../unit/test_memory_search_handler_gates.py | 23 +++++++++++++++- 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/server/memory/app/search/evidence_support.py b/server/memory/app/search/evidence_support.py index c062ee74d25..64b350423c1 100644 --- a/server/memory/app/search/evidence_support.py +++ b/server/memory/app/search/evidence_support.py @@ -7,6 +7,7 @@ from server.core.ch import get_client from server.memory.api.models_search import MemorySearchInput +from server.memory.store.reads import count_belief_support log = logging.getLogger(__package__) @@ -14,33 +15,12 @@ async def _evidence_support_count(input: MemorySearchInput, hits: list[Any]) -> int: if not hits: return 0 - ns_keys: dict[str, list[str]] = {} - for h in hits: - ns_keys.setdefault(h.namespace or input.namespace, []).append(h.memory_key) + keys = [(hit.namespace or input.namespace, hit.memory_key) for hit in hits] from server.observability.otel import traced try: with traced("ch.query.memory_belief_sources", op="evidence_support", keys=len(hits)): - rows = await get_client().query_all( - """ - SELECT count() AS n - FROM ( - SELECT memory_key, evidence_id, argMax(tombstoned_at, created_at) AS tomb_latest - FROM loom.memory_belief_sources - WHERE org = {org:String} - AND namespace IN {namespaces:Array(String)} - AND memory_key IN {keys:Array(String)} - GROUP BY memory_key, evidence_id - HAVING tomb_latest IS NULL - ) - """, - params={ - "org": input.org, - "namespaces": list(ns_keys.keys()), - "keys": [k for keys in ns_keys.values() for k in keys], - }, - ) - return int(rows[0]["n"]) if rows else 0 + return await count_belief_support(get_client(), input.org, keys) except Exception as e: # noqa: BLE001 — missing belief support must not fail search log.warning("evidence support lookup failed (non-fatal): %s", e) return 0 diff --git a/server/memory/store/reads.py b/server/memory/store/reads.py index 230c3ab461d..16de11d9be1 100644 --- a/server/memory/store/reads.py +++ b/server/memory/store/reads.py @@ -444,6 +444,26 @@ async def memory_rows_by_identity_keys( ) +async def count_belief_support(ch: _CHClient, org: str, keys: list[tuple[str, str]]) -> int: + """Count live belief sources for the given namespace and memory key pairs.""" + rows = await ch.query_all( + """ + SELECT count() AS n + FROM ( + SELECT namespace, memory_key, evidence_id, + argMax(tombstoned_at, created_at) AS tomb_latest + FROM loom.memory_belief_sources + WHERE org = {org:String} + AND (namespace, memory_key) IN {keys:Array(Tuple(String, String))} + GROUP BY namespace, memory_key, evidence_id + HAVING tomb_latest IS NULL + ) + """, + params={"org": org, "keys": keys}, + ) + return int(rows[0]["n"]) if rows else 0 + + async def guidance_heads(keys: Sequence[IdentityKey]) -> dict[IdentityKey, dict[str, Any]]: """Current guidance metadata, without loading the value or source text.""" if not keys: diff --git a/tests/unit/test_memory_search_handler_gates.py b/tests/unit/test_memory_search_handler_gates.py index 7c201e3e6c9..4265802252e 100644 --- a/tests/unit/test_memory_search_handler_gates.py +++ b/tests/unit/test_memory_search_handler_gates.py @@ -199,7 +199,7 @@ async def heads(keys): return {keys[0]: {"version": 42, "tombstoned_at": "now"}} async def support(sql, params): - return [{"n": int("retained" in params["keys"])}] + return [{"n": int(("ns", "retained") in params["keys"])}] monkeypatch.setattr(guidance, "guidance_heads", heads) monkeypatch.setattr(evidence_support, "get_client", lambda: SimpleNamespace(query_all=support)) @@ -214,6 +214,27 @@ async def support(sql, params): assert result.calibration_explanation == baseline.calibration_explanation +async def test_belief_support_binds_exact_namespace_and_key_pairs(monkeypatch) -> None: + from server.memory.app.search import evidence_support + + queries = [] + + async def support(sql, params): + queries.append((" ".join(sql.split()), params)) + return [{"n": 0}] + + monkeypatch.setattr(evidence_support, "get_client", lambda: SimpleNamespace(query_all=support)) + hits = [ + SimpleNamespace(namespace="a", memory_key="x"), + SimpleNamespace(namespace="b", memory_key="y"), + ] + assert await evidence_support._evidence_support_count(_input(), hits) == 0 + [(sql, params)] = queries + assert "(namespace, memory_key) IN {keys:Array(Tuple(String, String))}" in sql + assert "GROUP BY namespace, memory_key, evidence_id" in sql + assert params == {"org": "o", "keys": [("a", "x"), ("b", "y")]} + + async def test_weak_top_hit_makes_no_hyde_call(search_env) -> None: # A weak top hit on the default path makes no HyDE call: the read path # stays LLM-free. From e9899c120d5b1aa221baea116ced84e3e1138451 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:56:19 +0530 Subject: [PATCH 012/117] Preserve guidance and lesson fields on retrieval Carry authoritative expiry through verification, keep guidance on matching tier bodies, and preserve structured decisions and linked symbols in serialized results. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- .../features/memory/history-and-provenance.md | 16 ++++----- sdk/python/loom/ops.py | 1 + sdk/typescript/src/generated/ops.ts | 1 + server/code/app/symbol/edit_lessons.py | 14 +++++--- server/code/domain/lesson.py | 1 + server/memory/app/context_pack.py | 12 +++++-- server/memory/app/for_file.py | 3 +- server/memory/app/search/payload.py | 3 +- server/memory/app/search/verdict.py | 7 +++- server/memory/app/use_guidance.py | 5 ++- server/memory/app/verify.py | 11 ++++++- server/memory/store/code_plane_reads.py | 4 +-- server/memory/store/sql.py | 5 +++ tests/analyzer/shapes.txt | 2 +- tests/unit/test_code_edit_caller_lessons.py | 31 ++++++++++------- .../unit/test_code_symbol_concurrent_reads.py | 11 ++++--- tests/unit/test_context_pack_decisions.py | 15 +++++++-- tests/unit/test_memory_for_file.py | 16 +++++++-- .../unit/test_memory_search_handler_gates.py | 33 +++++++++++++++++++ tests/unit/test_memory_verify.py | 23 +++++++++++-- .../test_unit_bodies_follow_hit_session.py | 9 +++-- 21 files changed, 175 insertions(+), 48 deletions(-) diff --git a/docs/features/memory/history-and-provenance.md b/docs/features/memory/history-and-provenance.md index 068c5f83520..b23f35fff55 100644 --- a/docs/features/memory/history-and-provenance.md +++ b/docs/features/memory/history-and-provenance.md @@ -23,15 +23,15 @@ the served revision. `reasons` lists every applicable reason in precedence order Inspect `source_class`, `lifecycle`, `review`, `freshness.source`, `freshness.code` and `dispute` for the underlying facts. The first applicable rule selects the step. -| Evidence | Next step | -| --- | --- | -| Diagnostic-only lifecycle, including a quarantined procedure | `inspect_only` | -| Visible unresolved dispute | `clarify_dispute` | -| Changed or missing source, or changed, unresolved or missing code | `recheck_source` | -| Pending review or an attestation covering different content | `obtain_review` | -| Unavailable required evidence, or a candidate procedure | `validate_lead` | +| Evidence | Next step | +| ---------------------------------------------------------------------------------------------------- | ---------------------- | +| Diagnostic-only lifecycle, including a quarantined procedure | `inspect_only` | +| Visible unresolved dispute | `clarify_dispute` | +| Changed or missing source, or changed, unresolved or missing code | `recheck_source` | +| Pending review or an attestation covering different content | `obtain_review` | +| Unavailable required evidence, or a candidate procedure | `validate_lead` | | Eligible current content with a matching human attestation and applicable freshness checks satisfied | `follow_if_applicable` | -| Other served claims, including authored claims without review and process-verified claims | `validate_lead` | +| Other served claims, including authored claims without review and process-verified claims | `validate_lead` | A person or process attests to a content hash. A missing hash gives `unknown`; a successful read showing no verifier gives `none`. Freshness measures the source diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index e573cbc3144..3e6b567bbb3 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -6033,6 +6033,7 @@ class CodeLesson(TypedDict, total=False): supersedes_key: NotRequired[str] suggestion: NotRequired[str] owner_symbol: NotRequired[str] + linked_symbols: NotRequired[list[str]] use_guidance: NotRequired["UseGuidance"] diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index 972d27f6ecd..6c72b035c60 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -467,6 +467,7 @@ export interface CodeLesson { supersedes_key?: string; suggestion?: string; owner_symbol?: string; + linked_symbols?: string[]; use_guidance?: UseGuidance; } diff --git a/server/code/app/symbol/edit_lessons.py b/server/code/app/symbol/edit_lessons.py index 75b6a3db266..d85f4ed1d49 100644 --- a/server/code/app/symbol/edit_lessons.py +++ b/server/code/app/symbol/edit_lessons.py @@ -4,10 +4,12 @@ import asyncio import time +from collections.abc import Mapping from typing import TYPE_CHECKING, Any from server.code.app import enrich from server.code.app.spans import code_span, span_attrs +from server.code.domain.lesson import code_lessons from server.identity.app.request_scope import request_narrowed from server.memory.app.code_plane_reads import fit_symbol_lessons from server.settings import settings @@ -30,7 +32,7 @@ def _verified_callers(definitions: list[CodeUnit]) -> dict[tuple[str, str, str], return callers -def _key(note: dict[str, Any]) -> tuple[str, str, str]: +def _key(note: Mapping[str, Any]) -> tuple[str, str, str]: return note["namespace"], note["memory_key"], note["excerpt"] @@ -45,11 +47,13 @@ def _attach( for note in notes if note.get("code_state") == "fresh" and _key(note) not in seen } - fitted = fit_symbol_lessons([*unit.lessons, *proposals.values()]) - primary = len(unit.lessons) - if fitted[:primary] != unit.lessons: + # Budget the wire form so typed guidance and the retrieved rows use the same encoding. + primary_rows: list[dict[str, Any]] = code_lessons.dump_python(unit.lessons, mode="json") + fitted = fit_symbol_lessons([*primary_rows, *proposals.values()]) + primary = len(primary_rows) + if fitted[:primary] != primary_rows: return 0 - kept = fitted[primary:] + kept = code_lessons.validate_python(fitted[primary:]) unit.lessons.extend(kept) seen.update(map(_key, kept)) return len(kept) diff --git a/server/code/domain/lesson.py b/server/code/domain/lesson.py index 918729e59f2..949dfc9dd82 100644 --- a/server/code/domain/lesson.py +++ b/server/code/domain/lesson.py @@ -16,6 +16,7 @@ class CodeLesson(TypedDict, total=False): supersedes_key: str suggestion: str owner_symbol: str + linked_symbols: list[str] use_guidance: UseGuidance diff --git a/server/memory/app/context_pack.py b/server/memory/app/context_pack.py index f6935ec6b86..782aa508971 100644 --- a/server/memory/app/context_pack.py +++ b/server/memory/app/context_pack.py @@ -18,6 +18,7 @@ from server.core.background import gather_or_cancel from server.core.diagnostics import private_work +from server.core.hashing import served_content_sha256 from server.core.naming import SENTINEL as _WM_SENTINEL from server.core.naming import named from server.identity.app.request_scope import request_scope @@ -578,11 +579,16 @@ async def _pack_decisions_from_hits( ns = getattr(h, "namespace", "") or input.namespace rec = records.get(str(h.memory_key)) or {} excerpt = str(getattr(h, "content_excerpt", "") or "").strip() - # Structured records are read by key. A guided line may use their - # rendering only when it describes the selected hit's statement. + # The record is read by key, so its full statement must match the guided revision. if getattr(h, "use_guidance", None) is not None and ( ns != input.namespace - or (rec and memory_value(rec, proposed=rec.get("stage") == "proposed") != excerpt) + or ( + rec + and served_content_sha256( + memory_value(rec, proposed=rec.get("stage") == "proposed") + ) + != getattr(h, "_guidance_content_sha256", "") + ) ): rec = {} scenario = str(rec.get("scenario") or "").strip() or excerpt diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index 1cdafba23ce..61fed2f7d1c 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -35,7 +35,7 @@ from server.memory.domain.trust import row_verification from server.memory.domain.use_guidance import guidance_for_row from server.memory.store import reads as memory_reads -from server.memory.store.sql import FILE_LISTING_VISIBLE +from server.memory.store.sql import FILE_LISTING_VISIBLE, PROCEDURE_GUIDANCE_VALUE from server.settings import settings if TYPE_CHECKING: @@ -74,6 +74,7 @@ SELECT memory_key, memory_type, if({{full_values:UInt8}}, value, substring(value, 1, {_READ_BYTES})) AS value, + {PROCEDURE_GUIDANCE_VALUE}, tags, confidence, pinned, CAST(status AS String) AS status_text, agent, updated_at, actor, memory_id, user_id, session_id, version, files, conflict_with, source_resource_id, source_trace, source_class, requires_review, diff --git a/server/memory/app/search/payload.py b/server/memory/app/search/payload.py index 22a64855c05..4084a66b71b 100644 --- a/server/memory/app/search/payload.py +++ b/server/memory/app/search/payload.py @@ -10,6 +10,7 @@ from server.core.ch import get_client from server.identity.app.request_scope import request_scope +from server.memory.app.search.pg_validation import doc_version from server.memory.app.search.request import apply_explain_default from server.memory.app.search.tiers import _reader_user_id from server.memory.app.search_tag_filter import read_row_tags as _read_row_tags @@ -388,7 +389,7 @@ def _body_row(h: Any) -> Any: if spent + cost <= budget: try: if getattr(h, "use_guidance", None) is not None and ( - body_row.version != h.version + body_row.version != doc_version(h) or served_content_sha256(v) != h._guidance_content_sha256 ): h.use_guidance = None diff --git a/server/memory/app/search/verdict.py b/server/memory/app/search/verdict.py index e62803a760e..9cd1cf34623 100644 --- a/server/memory/app/search/verdict.py +++ b/server/memory/app/search/verdict.py @@ -3,6 +3,7 @@ from __future__ import annotations +from dataclasses import replace from typing import TYPE_CHECKING, Any from server.memory.api.models_search import _MemorySearchHit @@ -215,15 +216,19 @@ async def _verdict_after_guidance( final_hits: list[_MemorySearchHit], evidence_support_count: int, ) -> tuple[RetrievalCalibration, tuple[bool, str, str]]: - # Preserve the verdict's original rank order and exclude late tier rows. + # Prefer the original relevance order when it still has a served hit. served_ids = {id(hit) for hit in final_hits} retained = [hit for hit in verdict_hits if id(hit) in served_ids] if evidence_support_count and len(retained) < len(verdict_hits): evidence_support_count = await _evidence_support_count(ctx.input, retained) + if not retained: + retained = [hit for hit in final_hits if not hit.governed] ctx.actual_work.pop("below_threshold_hits", None) calibration, abstain_verdict = _calibrate_final_hits(ctx, run, retained, evidence_support_count) governed_count = sum(1 for hit in final_hits if hit.governed) ctx.actual_work["term_leg_served"] = governed_count if governed_count: abstain_verdict = (False, "", "") + if not retained: + calibration = replace(calibration, explanation="only governed definitions survived") return calibration, abstain_verdict diff --git a/server/memory/app/use_guidance.py b/server/memory/app/use_guidance.py index 6d229ca3eb3..a13d2bdb256 100644 --- a/server/memory/app/use_guidance.py +++ b/server/memory/app/use_guidance.py @@ -67,7 +67,10 @@ def procedure_status_for_row( if row.get("memory_type") != "procedural": return "not_applicable" - value = served_row_value(row) if not row.get("value_truncated") else None + if "procedure_value" in row: + value = served_row_value({"value": row["procedure_value"]}) + else: + value = served_row_value(row) if not row.get("value_truncated") else None if not isinstance(value, dict): return "unknown" try: diff --git a/server/memory/app/verify.py b/server/memory/app/verify.py index f63832709e3..20a1c5a23cd 100644 --- a/server/memory/app/verify.py +++ b/server/memory/app/verify.py @@ -238,7 +238,16 @@ async def _mirror_verified_to_embeddings( try: key = identity_key(row) await memory_repo.reemit_embedding_rows_for_keys( - [(key, {"verified": 1 if verified else 0, "version": version})], + [ + ( + key, + { + "verified": 1 if verified else 0, + "version": version, + "expires_at": row.expires_at, + }, + ) + ], ch=get_client(), of_content={key: content_sha256}, ) diff --git a/server/memory/store/code_plane_reads.py b/server/memory/store/code_plane_reads.py index 498a65734dd..2bddf2c93ea 100644 --- a/server/memory/store/code_plane_reads.py +++ b/server/memory/store/code_plane_reads.py @@ -10,7 +10,7 @@ from server.core.repo_base import _CHClient, _default_client, query_all_sliced from server.identity.domain.read_scope import ReadFilters, scope_and from server.memory.store.code_links import LinkedMemory -from server.memory.store.sql import FILE_LISTING_VISIBLE +from server.memory.store.sql import FILE_LISTING_VISIBLE, PROCEDURE_GUIDANCE_VALUE async def served_excerpts( @@ -39,7 +39,7 @@ async def served_excerpts( if(startsWith(value, '"'), JSONExtractString(value), value) AS excerpt, pinned, confidence, conflict_with, CAST(status AS String) AS status_text, source_trace, source_class, source_resource_id, requires_review, - verified_by, verified_sha256, content_sha256 + verified_by, verified_sha256, content_sha256, {PROCEDURE_GUIDANCE_VALUE} FROM loom.memory FINAL WHERE org = {{org:String}} AND namespace IN {{nss:Array(String)}} AND (namespace, agent, user_id, session_id, memory_key, memory_id) diff --git a/server/memory/store/sql.py b/server/memory/store/sql.py index 0f2e8aab0eb..eda1d2ee69a 100644 --- a/server/memory/store/sql.py +++ b/server/memory/store/sql.py @@ -10,6 +10,11 @@ # The value memory.get serves: the native JSON column when populated, else the stored text. SERVED_VALUE = "if(length(toString(value_json)) > 2, toString(value_json), value)" +PROCEDURE_GUIDANCE_VALUE = ( + "if(memory_type = 'procedural', " + "if(length(toString(value_json)) > 2, toString(value_json), memory.value), '') " + "AS procedure_value" +) # A high row is reachable by key, never pushed into a code or edit prompt. FILE_LISTING_VISIBLE = """ diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index fbf8504cfe7..4dd6fed33e1 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -732,7 +732,6 @@ 569c9b218f83 ALTER TABLE loom.conflict_allowlist DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = 56a045b3692e SELECT kind, number, source_id, component, is_open, created_at, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.qa_item_embeddings FINAL WHERE org = {org:String} AND namespace = {n 56ab4d25e910 DELETE FROM loom.memory_embeddings WHERE org={org:String} AND namespace={namespace:String} AND agent={agent:String} AND user_id={user_id:String} AND session_id={session_id:String} AND scope={scope:Str -56e519d25919 SELECT memory_key, memory_type, if({full_values:UInt8}, value, substring(value, ?, if((memory_type = ? OR hasAny(tags, [?, ?])), {whole_bytes:UInt32}, ?))) AS value, tags, confidence, pinned, CAST(sta 56f4c4320d80 SELECT f AS path, uniqExact(pr_number) AS prs FROM loom.code_pr_history FINAL ARRAY JOIN files AS f WHERE org = {org:String} AND namespace = {ns:String} AND merged_at > now() - INTERVAL {days:UInt32} 56f6ba832916 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, toString(valid_at) AS valid_at, version FROM loom.memory_embeddings FINAL WHERE org = { 56f6eca8bb7f SELECT count() AS n FROM loom.session_briefs WHERE org = {org:String} AND user_id = {uid:String} @@ -1651,6 +1650,7 @@ b98c5b9096ba SELECT count() AS n FROM loom.session_summaries FINAL WHERE org = { b99ba261d940 SELECT pr_number, merge_sha, payload, sections, built_at, indexed_commit, tokens, build_ms FROM loom.code_review_briefs FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS b9bc47ece20e SELECT count() AS n FROM loom.entity_triple_rows WHERE org = {org:String} AND namespace = {ns:String} AND ? b9f6cfd45b7f SELECT count() AS n FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND agent = {agent:String} AND thread_id = {tid:String} AND tombstoned_at IS NOT NULL +ba15dc7bc56c SELECT memory_key, memory_type, if({full_values:UInt8}, value, substring(value, ?, if((memory_type = ? OR hasAny(tags, [?, ?])), {whole_bytes:UInt32}, ?))) AS value, if(memory_type = ?, if(length(toSt ba2554cad547 SELECT source_uri, count() AS n FROM loom.chunks WHERE org = {org:String} AND namespace = {ns:String} AND source_uri IN {uris:Array(String)} AND doc_superseded_at IS NULL AND (org, namespace, embeddin ba2843155ed7 SELECT queue_id, agent, user_id, session_id, status, version, enqueued_at < now64(?) - toIntervalDay(?) AS past_last_day FROM loom.memory_extraction_queue FINAL PREWHERE org = {org:String} AND namespa ba28d3f48cd1 SELECT ts, org, namespace, agent, user_id, session_id, operation, request_id, mode, decision, enforced, determining_rules, errors, detail, latency_ms FROM loom.policy_decisions WHERE org = {org:String diff --git a/tests/unit/test_code_edit_caller_lessons.py b/tests/unit/test_code_edit_caller_lessons.py index fcda33edba1..ede8a55ebca 100644 --- a/tests/unit/test_code_edit_caller_lessons.py +++ b/tests/unit/test_code_edit_caller_lessons.py @@ -6,15 +6,17 @@ import pytest -from server.code.api.models_symbol import CodeEditContextInput +from server.code.api.models_symbol import CodeEditContextInput, CodeSymbolOutput from server.code.app import enrich, memory_links from server.code.app.symbol import edit_lessons from server.code.domain.anchor import Definition from server.code.domain.units import CodeUnit from server.memory.app import code_link_reads, code_plane_reads +from server.memory.domain.use_guidance import guidance_for_row from server.settings import settings REVISION = "a" * 40 +CONTENT_SHA = "b" * 64 NOTE = {"memory_key": "mounting", "namespace": "history", "excerpt": "Mounts can repeat."} FRESH = {**NOTE, "code_state": "fresh"} @@ -41,17 +43,19 @@ async def test_verified_callers_share_lesson_scope_and_keep_one_copy(monkeypatch originals = [u.model_dump()["examples"] for u in definitions] primary = {**FRESH, "memory_key": "direct"} different = {**primary, "excerpt": "Mounts need distinct endpoint names."} - definitions[2].lessons = [primary] + guidance = guidance_for_row({"status": "active"}) + serialized_guidance = guidance.model_dump(mode="json") + definitions[2].lessons = [{**primary, "use_guidance": guidance}] read = AsyncMock( return_value=[ - FRESH, + {**FRESH, "use_guidance": serialized_guidance}, primary, different, {**NOTE, "memory_key": "old", "code_state": "changed"}, ] ) monkeypatch.setattr(enrich, "lessons_for_symbol", read) - monkeypatch.setattr(settings, "code_result_lessons_tokens", 0) + monkeypatch.setattr(settings, "code_result_lessons_tokens", 1000) request = CodeEditContextInput(lesson_namespaces=["history"]) await edit_lessons.attach_verified_caller_lessons( @@ -68,13 +72,14 @@ async def test_verified_callers_share_lesson_scope_and_keep_one_copy(monkeypatch assert kwargs["extra_namespaces"] == ["history"] assert kwargs["paths"] == ["web/app.py"] assert 0 < kwargs["seconds"] <= settings.code_enrich_timeout_s - assert [d.lessons for d in definitions] == [ + response = CodeSymbolOutput(definitions=definitions).model_dump(mode="json") + assert [d.get("lessons", []) for d in response["definitions"]] == [ [ - {**FRESH, "linked_symbols": ["App.mount"]}, + {**FRESH, "linked_symbols": ["App.mount"], "use_guidance": serialized_guidance}, {**different, "linked_symbols": ["App.mount"]}, ], [], - [primary], + [{**primary, "use_guidance": serialized_guidance}], ] assert [u.examples for u in definitions] == originals @@ -150,6 +155,7 @@ async def test_verified_lesson_only_ranks_fresh_rows(monkeypatch): "qualified_name": "App.mount", "state": state, "changed_since": "b" * 40, + "inputs_hash": code_link_reads.inputs_hash(CONTENT_SHA, [], "repo", "-"), } for key, state in enumerate(states) ] @@ -168,7 +174,10 @@ async def test_verified_lesson_only_ranks_fresh_rows(monkeypatch): async def excerpts(_org, _namespaces, memories, *, limit, changed): matching = sorted(memories, key=lambda identity: identity[-1] in changed) - return [{**by_id[mid], "mid": mid, "excerpt": mid} for *_, mid in matching[:limit]] + return [ + {**by_id[mid], "mid": mid, "excerpt": mid, "content_sha256": CONTENT_SHA} + for *_, mid in matching[:limit] + ] monkeypatch.setattr(code_plane_reads.reads, "served_excerpts", excerpts) monkeypatch.setattr(settings, "code_result_lessons_tokens", 0) @@ -219,6 +228,7 @@ async def test_verified_caller_requires_matching_fingerprint( "fingerprint_version": "older" if legacy else code_plane_reads.fingerprint_version(), "changed_since": REVISION, "suggestion": "", + "inputs_hash": code_link_reads.inputs_hash(CONTENT_SHA, [], "repo", "-"), } definition = Definition(path, symbol, "mount", body_hash=recovered) monkeypatch.setattr(code_plane_reads.links_store, "for_paths", AsyncMock(return_value=[link])) @@ -228,9 +238,8 @@ async def test_verified_caller_requires_matching_fingerprint( monkeypatch.setattr( code_plane_reads, "_definitions_at", AsyncMock(return_value={(path, symbol): definition}) ) - monkeypatch.setattr( - code_plane_reads.reads, "served_excerpts", AsyncMock(return_value=[{**NOTE, "mid": "one"}]) - ) + row = {**NOTE, "mid": "one", "memory_id": "one", "user_id": "-", "content_sha256": CONTENT_SHA} + monkeypatch.setattr(code_plane_reads.reads, "served_excerpts", AsyncMock(return_value=[row])) monkeypatch.setattr(settings, "code_result_lessons_tokens", 0) scope = {"qualified_name": symbol, "paths": [path], "namespaces": ["history"]} diff --git a/tests/unit/test_code_symbol_concurrent_reads.py b/tests/unit/test_code_symbol_concurrent_reads.py index 40738251904..14043706852 100644 --- a/tests/unit/test_code_symbol_concurrent_reads.py +++ b/tests/unit/test_code_symbol_concurrent_reads.py @@ -282,9 +282,10 @@ async def read(*a, **kw): def test_a_member_whose_lessons_went_unread_keeps_the_others_and_flags_it(): - from server.code.api.models_symbol import CodeSymbolInput + from server.code.api.models_symbol import CodeSymbolInput, CodeSymbolOutput from server.code.app import enrich as code_enrich from server.code.app.symbol import symbol as h + from server.code.domain.units import CodeUnit async def lessons_for_symbol(org, ns, *, symbol_name, paths, extra_namespaces): return None if symbol_name == "A::y" else [dict(LESSON[0])] @@ -296,6 +297,8 @@ async def lessons_for_symbol(org, ns, *, symbol_name, paths, extra_namespaces): plain = CodeSymbolInput(name="A", include_history=False, include_examples=False) with patch.object(code_enrich, "lessons_for_symbol", new=lessons_for_symbol): out = asyncio.run(h._enrichment(None, "o", "n", plain, head, matched_members=True)) - # the member that was read still serves its lesson; the other may have had some - assert [lesson["linked_symbols"] for lesson in out["lessons"]] == [["A::x"]] - assert out["lessons_unread"] is True + response = CodeSymbolOutput(definitions=[CodeUnit(path="a.py", symbol="A")]) + h._apply_enrichment(response.definitions, out) + definition = response.model_dump(mode="json")["definitions"][0] + assert [lesson["linked_symbols"] for lesson in definition["lessons"]] == [["A::x"]] + assert definition["lessons_unread"] is True diff --git a/tests/unit/test_context_pack_decisions.py b/tests/unit/test_context_pack_decisions.py index efa469a1df7..0fd530c00d3 100644 --- a/tests/unit/test_context_pack_decisions.py +++ b/tests/unit/test_context_pack_decisions.py @@ -312,17 +312,25 @@ def test_every_governed_definition_leads_the_memories_block( def test_guided_decision_uses_the_served_statement( monkeypatch: pytest.MonkeyPatch, matches: bool ) -> None: + from server.core.hashing import served_content_sha256 from server.memory.domain.decision_statement import memory_value from server.memory.domain.use_guidance import guidance_for_row _dead_other_sections(monkeypatch) - record = {"scenario": "pick a store", "outcome": "use SQLite", "stage": "decided"} + record = { + "scenario": "pick a store", + "outcome": "use SQLite", + "stage": "decided", + "reasoning": "keep setup local", + "realized_outcome": "the store opened", + } selected = record if matches else {**record, "outcome": "use ClickHouse"} guidance = guidance_for_row({"status": "conflicted"}) hit = NS( **{ **vars(_DECISION), - "content_excerpt": memory_value(selected), + "content_excerpt": selected["scenario"] if matches else memory_value(selected), + "_guidance_content_sha256": served_content_sha256(memory_value(selected)), "use_guidance": guidance, } ) @@ -339,6 +347,9 @@ async def records(ch: Any, org: str, ns: str, keys: list[str]) -> dict[str, Any] assert selected["outcome"] in out.sections["decisions"] assert ("use SQLite" in out.sections["decisions"]) is matches assert ("decided:" in out.sections["decisions"]) is matches + if matches: + assert "because keep setup local" in out.sections["decisions"] + assert "realized: the store opened" in out.sections["decisions"] (item,) = out.use_guidance assert item.citation == "decision:ns/d1" assert item.use_guidance == guidance diff --git a/tests/unit/test_memory_for_file.py b/tests/unit/test_memory_for_file.py index fb41211b333..5a63e733dfd 100644 --- a/tests/unit/test_memory_for_file.py +++ b/tests/unit/test_memory_for_file.py @@ -1056,13 +1056,25 @@ async def _merged(*_a: Any, **_k: Any) -> tuple[list[dict[str, Any]], bool]: @pytest.mark.asyncio -async def test_file_guidance_marks_quarantined_procedure_inspect_only(): +@pytest.mark.parametrize( + "display", + [ + {"value": '{"quarantined": {}}'}, + {"excerpt": '{"description": "preview', "procedure_value": '{"quarantined": {}}'}, + { + "value": '{"description": "preview', + "value_truncated": True, + "procedure_value": '{"quarantined": {}}', + }, + ], +) +async def test_file_guidance_marks_quarantined_procedure_inspect_only(display): row = { "memory_type": "procedural", "status": "active", - "value": '{"quarantined": {}}', "tags": [], "files": [], + **display, } await mff.guided_file_rows("o", [row]) assert row["use_guidance"].next_step == "inspect_only" diff --git a/tests/unit/test_memory_search_handler_gates.py b/tests/unit/test_memory_search_handler_gates.py index 4265802252e..066839fe86c 100644 --- a/tests/unit/test_memory_search_handler_gates.py +++ b/tests/unit/test_memory_search_handler_gates.py @@ -235,6 +235,39 @@ async def support(sql, params): assert params == {"org": "o", "keys": [("a", "x"), ("b", "y")]} +@pytest.mark.parametrize("governed", [False, True]) +async def test_verdict_describes_survivors_outside_the_original_verdict_pool(governed): + from server.memory.api.models_search import _MemorySearchHit + from server.memory.app.search.verdict import _verdict_after_guidance + + dropped = _MemorySearchHit( + memory_key="dropped", + memory_type="semantic", + content_excerpt="old", + distance=0.1, + similarity=0.9, + ) + survivor = _MemorySearchHit( + memory_key="survivor", + memory_type="definition" if governed else "semantic", + content_excerpt="current", + distance=1.0 if governed else 0.25, + similarity=0.0 if governed else 0.75, + governed=governed, + ) + ctx = SimpleNamespace(input=_input(), actual_work={}, query_triples=[]) + run = SimpleNamespace(ns_calibration=None, graph_seeds=0, graph_neighbors=0, triples_matched=0) + calibration, verdict = await _verdict_after_guidance(ctx, run, [dropped], [survivor], 0) + + assert verdict == (False, "", "") + if governed: + assert calibration.confidence == 0.0 + assert calibration.explanation == "only governed definitions survived" + else: + assert calibration.confidence > 0.0 + assert "top_similarity=0.75" in calibration.explanation + + async def test_weak_top_hit_makes_no_hyde_call(search_env) -> None: # A weak top hit on the default path makes no HyDE call: the read path # stays LLM-free. diff --git a/tests/unit/test_memory_verify.py b/tests/unit/test_memory_verify.py index 7b580a04414..090dca42cd5 100644 --- a/tests/unit/test_memory_verify.py +++ b/tests/unit/test_memory_verify.py @@ -457,9 +457,15 @@ async def test_the_mirror_re_emits_every_live_row_of_the_key( ) -> None: """One private row per embedding model is re-emitted whole with `verified` set, keeping the columns the verify input never carried (reinforcement, mention times).""" - from server.memory.store import EMBEDDING_PERSISTED_COLS, build_memory_version_row + from server.memory.store import ( + EMBEDDING_PERSISTED_COLS, + build_memory_version_row, + reemit_embedding_rows_for_keys, + ) + from server.memory.store.rows import identity_key - row = _row() + expiry = _NOW + timedelta(hours=2) + row = _row(expires_at=expiry) stored = [ { **{c: v for c, v in EMBEDDING_PERSISTED_COLS.items()}, @@ -476,6 +482,7 @@ async def test_the_mirror_re_emits_every_live_row_of_the_key( "embedding": [0.5, 0.5], "last_reinforced_at": datetime(2026, 1, 2), "mentioned_at": datetime(2026, 1, 3), + "expires_at": _NOW, "version": 7, } for scope, model in (("private", "m1"), ("private", "m2")) @@ -494,16 +501,26 @@ async def query_all(self, sql: str, params: dict[str, Any] | None = None) -> Any async def insert(self, table: str, rows: list[dict[str, Any]], **_: Any) -> None: assert table == "loom.memory_embeddings" inserted.extend(rows) + stored[:] = rows - monkeypatch.setattr(mv, "get_client", lambda: _CH()) + ch = _CH() + monkeypatch.setattr(mv, "get_client", lambda: ch) await mv._mirror_verified_to_embeddings( row, verified=True, version=123, content_sha256=_sha(row.value) ) + # Touch committed before verification, but its older mirror resumes afterward. + key = identity_key(row) + await reemit_embedding_rows_for_keys( + [(key, {"expires_at": expiry, "version": 122})], + ch=ch, + of_content={key: _sha(row.value)}, + ) assert [(r["scope"], r["embedding_model"]) for r in inserted] == [ ("private", "m1"), ("private", "m2"), ] assert all(r["verified"] == 1 and r["version"] == 123 for r in inserted) + assert all(r["expires_at"] == expiry for r in inserted) assert all(r["mentioned_at"] == datetime(2026, 1, 3) for r in inserted) diff --git a/tests/unit/test_unit_bodies_follow_hit_session.py b/tests/unit/test_unit_bodies_follow_hit_session.py index 70b62ddbd15..40d463739da 100644 --- a/tests/unit/test_unit_bodies_follow_hit_session.py +++ b/tests/unit/test_unit_bodies_follow_hit_session.py @@ -173,9 +173,14 @@ async def fake_get_many(identity, keys, **_): @pytest.mark.asyncio @pytest.mark.parametrize("body", ["reviewed text", "replacement text"]) -async def test_unit_body_keeps_approval_only_for_reviewed_content(monkeypatch, body): +@pytest.mark.parametrize("tier", [False, True]) +async def test_unit_body_keeps_approval_only_for_reviewed_content(monkeypatch, body, tier): hit = _hit("k", excerpt="reviewed text") - hit.version = 42 + if tier: + hit._row_version = 42 + hit.score_components["recent_first"] = 1.0 + else: + hit.version = 42 digest = served_content_sha256("reviewed text") hit._guidance_content_sha256 = digest hit.use_guidance = guidance_for_row( From 69ef6bc2282f713f4bc805f0fb2ac13914734d91 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Thu, 26 Nov 2026 23:59:12 +0530 Subject: [PATCH 013/117] Keep complete decision statements without a digest Match the full served text when a guided hit has no content digest. A clipped excerpt still needs a matching hash before structured fields are attached. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/app/context_pack.py | 19 +++++++------------ tests/unit/test_context_pack_decisions.py | 14 ++++++++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/server/memory/app/context_pack.py b/server/memory/app/context_pack.py index 782aa508971..e05ec3fc8f9 100644 --- a/server/memory/app/context_pack.py +++ b/server/memory/app/context_pack.py @@ -579,18 +579,13 @@ async def _pack_decisions_from_hits( ns = getattr(h, "namespace", "") or input.namespace rec = records.get(str(h.memory_key)) or {} excerpt = str(getattr(h, "content_excerpt", "") or "").strip() - # The record is read by key, so its full statement must match the guided revision. - if getattr(h, "use_guidance", None) is not None and ( - ns != input.namespace - or ( - rec - and served_content_sha256( - memory_value(rec, proposed=rec.get("stage") == "proposed") - ) - != getattr(h, "_guidance_content_sha256", "") - ) - ): - rec = {} + if rec and getattr(h, "use_guidance", None) is not None: + # The record is read by key, so bind its statement to the guided revision. + statement = memory_value(rec, proposed=rec.get("stage") == "proposed") + digest = getattr(h, "_guidance_content_sha256", "") + matches = served_content_sha256(statement) == digest if digest else statement == excerpt + if ns != input.namespace or not matches: + rec = {} scenario = str(rec.get("scenario") or "").strip() or excerpt outcome = str(rec.get("outcome") or "").strip() realized = str(rec.get("realized_outcome") or "").strip() diff --git a/tests/unit/test_context_pack_decisions.py b/tests/unit/test_context_pack_decisions.py index 0fd530c00d3..1a9e1276fe7 100644 --- a/tests/unit/test_context_pack_decisions.py +++ b/tests/unit/test_context_pack_decisions.py @@ -308,9 +308,11 @@ def test_every_governed_definition_leads_the_memories_block( assert positions == sorted(positions) and positions[-1] < block.index("a resource row") -@pytest.mark.parametrize("matches", [True, False]) +@pytest.mark.parametrize( + ("matches", "digest_available"), [(True, True), (False, True), (True, False)] +) def test_guided_decision_uses_the_served_statement( - monkeypatch: pytest.MonkeyPatch, matches: bool + monkeypatch: pytest.MonkeyPatch, matches: bool, digest_available: bool ) -> None: from server.core.hashing import served_content_sha256 from server.memory.domain.decision_statement import memory_value @@ -329,8 +331,12 @@ def test_guided_decision_uses_the_served_statement( hit = NS( **{ **vars(_DECISION), - "content_excerpt": selected["scenario"] if matches else memory_value(selected), - "_guidance_content_sha256": served_content_sha256(memory_value(selected)), + "content_excerpt": ( + selected["scenario"] if matches and digest_available else memory_value(selected) + ), + "_guidance_content_sha256": ( + served_content_sha256(memory_value(selected)) if digest_available else "" + ), "use_guidance": guidance, } ) From 43a91ac49bd4a47f26ba84e2a4f95dc0919a9c9a Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:08:07 +0530 Subject: [PATCH 014/117] Keep retrieval guidance tied to the served row Bind review to matching content across metadata writes. Project source and procedure evidence for recall and keep Recall Lab results tied to their writer. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/App.tsx | 5 +- frontend/src/api/search.ts | 2 + .../MemoryInspector.lifecycle.test.tsx | 21 + frontend/src/components/MemoryInspector.tsx | 42 +- frontend/src/lib/place.test.ts | 10 +- frontend/src/lib/place.ts | 19 +- frontend/src/lib/state.ts | 29 +- .../views/RecallLab.memoriesOrder.test.tsx | 5 + frontend/src/views/RecallLab.table.test.tsx | 80 ++- frontend/src/views/RecallLab.tsx | 63 ++- server/knowledge/app/document_reads.py | 11 +- server/knowledge/store/documents.py | 65 ++- server/knowledge/store/pg_documents.py | 19 +- server/memory/api/models_search.py | 9 +- server/memory/app/for_file.py | 4 +- server/memory/app/retrieval/fact_sql.py | 1 + server/memory/app/retrieval/pool.py | 2 + server/memory/app/retrieval/search.py | 1 + server/memory/app/retrieval/side_legs.py | 4 + server/memory/app/search/anchor_pool.py | 1 + server/memory/app/search/digest_descent.py | 1 + server/memory/app/search/guidance.py | 20 +- server/memory/app/search/key_match.py | 1 + server/memory/app/search/payload.py | 4 +- server/memory/app/search/sql.py | 4 +- server/memory/app/search/vector_legs.py | 2 + server/memory/app/use_guidance.py | 8 +- server/memory/domain/search_types.py | 1 + server/memory/store/code_plane_reads.py | 4 +- server/memory/store/embeddings.py | 2 +- server/memory/store/pg_memory.py | 34 +- server/memory/store/reads.py | 7 +- server/memory/store/sql.py | 27 +- tests/analyzer/cases/legs.py | 2 + tests/analyzer/cases/planes.py | 1 + tests/analyzer/shapes.txt | 472 +++++++++--------- .../test_retrieved_use_guidance.py | 35 +- tests/integration/test_vector_retire_race.py | 4 +- tests/unit/test_documents_repo.py | 63 ++- tests/unit/test_embedding_reemit.py | 11 +- tests/unit/test_memory_for_file.py | 4 +- tests/unit/test_search_use_guidance.py | 61 ++- tests/unit/test_use_guidance_sources.py | 10 +- 43 files changed, 810 insertions(+), 361 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f72cb6ce7cf..c3fe75b9d8a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -207,6 +207,7 @@ export default function App() { const inspectedKey = useStore((s) => s.inspectedMemoryKey); const inspectedAgent = useStore((s) => s.inspectedAgent); const inspectedOwner = useStore((s) => s.inspectedOwner); + const inspectedScope = useStore((s) => s.inspectedScope); // Override agent with the writer's identity (captured when the list-view // card was clicked) so strict-tuple memory.get doesn't 404 on cross-agent // rows. Memoised: a fresh object every render would replay the inspector's seven reads @@ -216,12 +217,13 @@ export default function App() { identity ? { ...identity, + namespace: inspectedScope?.namespace ?? identity.namespace, ...(inspectedAgent ? { agent: inspectedAgent } : {}), // A row filed under a user or session is read under them, or memory.get misses it. ...(inspectedOwner ?? {}), } : null, - [identity, inspectedAgent, inspectedOwner], + [identity, inspectedAgent, inspectedOwner, inspectedScope], ); const inspect = useStore((s) => s.inspect); const setAuthed = useStore((s) => s.setAuthed); @@ -675,6 +677,7 @@ export default function App() { inspect(null)} onChanged={() => useStore.getState().bumpMemoriesVersion()} diff --git a/frontend/src/api/search.ts b/frontend/src/api/search.ts index c5ee8016392..7b1145ea43c 100644 --- a/frontend/src/api/search.ts +++ b/frontend/src/api/search.ts @@ -25,6 +25,8 @@ export interface SearchHit { created_at?: string; /** Writer identity; "" when the leg did not read it. */ agent?: string; + user_id?: string; + session_id?: string; /** Server provenance note for the hit ("fact hit from namespace x; * similarity=0.62; ..."). Rides at k ≤ 15 by default and at any k under * `explain: true`. */ diff --git a/frontend/src/components/MemoryInspector.lifecycle.test.tsx b/frontend/src/components/MemoryInspector.lifecycle.test.tsx index a21cadbfb80..56405470522 100644 --- a/frontend/src/components/MemoryInspector.lifecycle.test.tsx +++ b/frontend/src/components/MemoryInspector.lifecycle.test.tsx @@ -125,6 +125,27 @@ afterEach(() => { }); describe("MemoryInspector lifecycle actions", () => { + it.each([{ agent: "other-agent" }, { user_id: "other-user" }, { session_id: "-" }])( + "hides a namesake returned by a writer-checked lookup (%j)", + async (otherWriter) => { + vi.mocked(api.getMemory).mockResolvedValue({ ...LIVE, ...otherWriter }); + render( + {}} onChanged={() => {}} />, + ); + expect(await screen.findByText(/Memory not found/)).toBeInTheDocument(); + expect(screen.queryByText("oat milk, no sugar")).toBeNull(); + expect(api.getMemory).toHaveBeenCalledWith(row, "coffee_pref", { include_recall_breakdown: true }); + }, + ); + + it("shows the selected row when the lookup returns its writer", async () => { + vi.mocked(api.getMemory).mockResolvedValue(LIVE); + render( + {}} onChanged={() => {}} />, + ); + expect(await screen.findByText("oat milk, no sugar")).toBeInTheDocument(); + }); + it("shows a viewer each lifecycle action unavailable, with the role it needs, and sends nothing", async () => { await open("viewer"); const list = await menu(); diff --git a/frontend/src/components/MemoryInspector.tsx b/frontend/src/components/MemoryInspector.tsx index 093b677e67f..3732e26cb64 100644 --- a/frontend/src/components/MemoryInspector.tsx +++ b/frontend/src/components/MemoryInspector.tsx @@ -144,6 +144,7 @@ function SectionEmpty({ children }: { children: React.ReactNode }) { interface InspectorProps { identity: Identity; + verifyWriter?: boolean; memoryKey: string; onClose: () => void; onChanged: () => void; @@ -170,6 +171,7 @@ interface InspectorProps { export function MemoryInspector({ identity, + verifyWriter, memoryKey, onClose, onChanged, @@ -246,14 +248,40 @@ export function MemoryInspector({ // Set by "Ask about this", which closes the drawer for the assistant panel's field. const leaving = useRef(false); const inspect = useStore((s) => s.inspect); - const openMemory = onInspectMemory ?? inspect; + const openMemory = onInspectMemory ?? ((key: string) => inspect(key, { namespace: identity.namespace })); // A rename's destination is this row moved: it opens under the writer identity this one // was read as. A redirect's target may be another writer's (a deduplicated row's // canonical), as may related rows, mentions and provenance links: those open as before. const followMoved = onInspectMemory ?? ((key: string) => - inspect(key, { agent: identity.agent, userId: identity.user_id, sessionId: identity.session_id })); + inspect(key, { + agent: identity.agent, + userId: identity.user_id, + sessionId: identity.session_id, + namespace: identity.namespace, + exact: verifyWriter, + })); + const readMemory = useCallback(async (): Promise => { + const row = await getMemory(identity, memoryKey, { include_recall_breakdown: true }); + // A key lookup can fall back to a namesake if the selected writer's row disappeared. + if ( + verifyWriter && + row.found && + (row.agent !== identity.agent || row.user_id !== identity.user_id || row.session_id !== identity.session_id) + ) { + return { + found: false, + value: null, + memory_type: null, + confidence: null, + version: null, + pinned: false, + created_at: null, + }; + } + return row; + }, [identity, memoryKey, verifyWriter]); const searchByTag = useStore((s) => s.searchByTag); const openConversationThread = useStore((s) => s.openConversationThread); // A dialog over the drawer owns the keys and the outside clicks while it is open. @@ -340,7 +368,7 @@ export function MemoryInspector({ // A read for a key the drawer has moved off must not land: its value under the new // key would be what Edit, Pin and Verify then write back. let live = true; - getMemory(identity, memoryKey, { include_recall_breakdown: true }) + readMemory() .then((res) => { if (!live) return; detailOf.current = inspection.current; @@ -361,7 +389,7 @@ export function MemoryInspector({ inspection.current += 1; shown.current = null; }; - }, [identity, memoryKey]); + }, [identity, memoryKey, readMemory]); const loadHistory = (key: string) => memoryHistory(identity, key, 8).then((r) => r.rows || []); useEffect(() => { @@ -629,7 +657,7 @@ export function MemoryInspector({ onChanged(); if (!showing()) return; try { - const row = await getMemory(identity, memoryKey, { include_recall_breakdown: true }); + const row = await readMemory(); if (!showing()) return; setDetail(row); // A row the write took away leaves no form open behind "not found". @@ -857,7 +885,7 @@ export function MemoryInspector({ // restore, so read it again. if (r.restored && showing()) { const now = inspection.current; - getMemory(identity, memoryKey, { include_recall_breakdown: true }) + readMemory() .then((fresh) => { if (inspection.current === now) setDetail(fresh); }) @@ -870,7 +898,7 @@ export function MemoryInspector({ // Nothing to restore means the row changed since it was read: show it as it is now. toast(r.restored ? "Restored" : "Nothing to restore", r.restored ? "ok" : "info"); try { - const fresh = await getMemory(identity, memoryKey, { include_recall_breakdown: true }); + const fresh = await readMemory(); if (!stale()) setDetail(fresh); } catch (e) { if (!stale()) toastError("Reload failed", e, { read: true }); diff --git a/frontend/src/lib/place.test.ts b/frontend/src/lib/place.test.ts index f39a7b04bab..2b32054998c 100644 --- a/frontend/src/lib/place.test.ts +++ b/frontend/src/lib/place.test.ts @@ -33,9 +33,15 @@ describe("rememberPlace / readPlace", () => { }); }); - it("keeps the user and session an inspected row is filed under", () => { - rememberPlace({ key: "a", agent: "bot", owner: { user_id: "ada", session_id: "-" } }); + it("keeps the complete identity and lookup mode of an inspected row", () => { + rememberPlace({ + key: "a", + agent: "bot", + owner: { user_id: "ada", session_id: "-" }, + scope: { namespace: "shared", exact: true }, + }); expect(readPlace(history.state)?.inspectedOwner).toEqual({ user_id: "ada", session_id: "-" }); + expect(readPlace(history.state)?.inspectedScope).toEqual({ namespace: "shared", exact: true }); rememberPlace({ key: "a", agent: "bot" }); expect(readPlace(history.state)?.inspectedOwner).toBeNull(); }); diff --git a/frontend/src/lib/place.ts b/frontend/src/lib/place.ts index 34173e91982..ccf3d2d2239 100644 --- a/frontend/src/lib/place.ts +++ b/frontend/src/lib/place.ts @@ -19,6 +19,11 @@ export interface InspectedOwner { session_id: string; } +export interface InspectedScope { + namespace?: string; + exact: boolean; +} + export interface Place { scrollTop: number; /** The `data-focus-key` of the element that had focus; null when nothing keyed did. */ @@ -28,6 +33,7 @@ export interface Place { inspectedAgent: string; /** The user and session it was read under; null for the caller's own. */ inspectedOwner: InspectedOwner | null; + inspectedScope?: InspectedScope | null; } /** How long a restore waits for the page to draw what it restores (a lazy chunk, a list @@ -57,7 +63,7 @@ function mainElement(): HTMLElement | null { * Back should focus when the focused one is not it (a popover link that opened the jump, * where Back should land on the chip that opened the popover). */ export function rememberPlace( - inspected: { key: string | null; agent: string; owner?: InspectedOwner | null }, + inspected: { key: string | null; agent: string; owner?: InspectedOwner | null; scope?: InspectedScope | null }, focusKey?: string | null, ): void { if (typeof window === "undefined") return; @@ -69,6 +75,7 @@ export function rememberPlace( inspected: inspected.key, inspectedAgent: inspected.agent, inspectedOwner: inspected.owner ?? null, + ...(inspected.scope ? { inspectedScope: inspected.scope } : {}), }; patchEntry({ loomPlace: place }); } @@ -79,15 +86,25 @@ export function readPlace(state: unknown): Place | null { const p = (state as Record).loomPlace; if (!p || typeof p !== "object") return null; const r = p as Record; + const scope = inspectionScope(r.inspectedScope); return { scrollTop: typeof r.scrollTop === "number" ? r.scrollTop : 0, focusKey: typeof r.focusKey === "string" ? r.focusKey : null, inspected: typeof r.inspected === "string" ? r.inspected : null, inspectedAgent: typeof r.inspectedAgent === "string" ? r.inspectedAgent : "", inspectedOwner: owner(r.inspectedOwner), + ...(scope ? { inspectedScope: scope } : {}), }; } +function inspectionScope(v: unknown): InspectedScope | null { + if (!v || typeof v !== "object") return null; + const scope = v as Record; + return typeof scope.exact === "boolean" + ? { namespace: typeof scope.namespace === "string" ? scope.namespace : undefined, exact: scope.exact } + : null; +} + function owner(v: unknown): InspectedOwner | null { if (!v || typeof v !== "object") return null; const o = v as Record; diff --git a/frontend/src/lib/state.ts b/frontend/src/lib/state.ts index c004bcee449..a39df4f388f 100644 --- a/frontend/src/lib/state.ts +++ b/frontend/src/lib/state.ts @@ -4,7 +4,7 @@ import { hasToken, isAuthDisabled, isProxyMode } from "../api"; import { sameIdentity } from "./boot"; import { NAMESPACE_NAME, isCollectionName } from "./namespace"; import { HANDOFF_QUERY_KEYS, readSessionHandoff, type SessionHandoffRef } from "./sessionHandoff"; -import { patchEntry, readPlace, rememberPlace, type InspectedOwner, type Place } from "./place"; +import { patchEntry, readPlace, rememberPlace, type InspectedOwner, type InspectedScope, type Place } from "./place"; export type View = | "memories" @@ -210,7 +210,10 @@ function pushView(v: View, opts: NavOptions = {}, remember = true): void { // under the sheet, which remembered its place when the sheet opened. const replace = sheetEntry(); if (!replace) - rememberPlace({ key: s.inspectedMemoryKey, agent: s.inspectedAgent, owner: s.inspectedOwner }, opts.focusKey); + rememberPlace( + { key: s.inspectedMemoryKey, agent: s.inspectedAgent, owner: s.inspectedOwner, scope: s.inspectedScope }, + opts.focusKey, + ); // A navigation's entry is made in the current namespace. const namespace = s.identity?.namespace ?? null; const state = { @@ -303,7 +306,9 @@ function stampFor(namespace: string | null): Record { return { loomNamespace: namespace, loomInspect: null, - ...(place ? { loomPlace: { ...place, inspected: null, inspectedAgent: "", inspectedOwner: null } } : {}), + ...(place + ? { loomPlace: { ...place, inspected: null, inspectedAgent: "", inspectedOwner: null, inspectedScope: null } } + : {}), }; } @@ -322,6 +327,7 @@ function openedByUrl(v: View): Partial { inspectedMemoryKey: memory, inspectedAgent: memory ? linkedAgent(memory) : "", inspectedOwner: null, + inspectedScope: null, ...(doc ? { pendingDocSourceUri: doc } : {}), ...(thread ? { pendingConversationThread: { threadId: thread } } : {}), }; @@ -392,6 +398,7 @@ interface AppState { // The user and session the inspected row is filed under, when the view that opened it // names them (the Assistant's inspected and cited rows); null reads the caller's own. inspectedOwner: InspectedOwner | null; + inspectedScope: InspectedScope | null; // Tag-chip navigation target; Recent.tsx filters by it. memoryTagFilter: string | null; // Header-search document target; Documents.tsx opens its preview dialog. @@ -434,7 +441,10 @@ interface AppState { /** The sidebar's latest badge answer for the current namespace, which it writes; the * phone's More sheet reads it too. */ adminBadges: AdminBadges | null; - inspect: (memoryKey: string | null, opts?: { agent?: string; userId?: string; sessionId?: string }) => void; + inspect: ( + memoryKey: string | null, + opts?: { agent?: string; userId?: string; sessionId?: string; namespace?: string; exact?: boolean }, + ) => void; toggleSidebar: () => void; sidebarCollapsed: boolean; /** Navigate to Memories filtered by tag. */ @@ -495,6 +505,7 @@ export const useStore = create((set, get) => ({ inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null, + inspectedScope: null, memoryTagFilter: null, pendingDocSourceUri: null, pendingConversationThread: null, @@ -524,6 +535,7 @@ export const useStore = create((set, get) => ({ deniedNamespace: null, linkOpened: null, inspectedMemoryKey: null, + inspectedScope: null, pendingConversationThread: null, sessionHandoff: null, pendingDocSourceUri: null, @@ -550,6 +562,7 @@ export const useStore = create((set, get) => ({ set((s) => ({ view, inspectedMemoryKey: null, + inspectedScope: null, navSeq: s.navSeq + 1, sessionHandoff: linkedSessionHandoff(view), navNote: opts.note ?? null, @@ -564,7 +577,9 @@ export const useStore = create((set, get) => ({ set({ view, sessionHandoff: here ? linkedSessionHandoff(view) : null, - ...(here ? openedByUrl(view) : { inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null }), + ...(here + ? openedByUrl(view) + : { inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null, inspectedScope: null }), }); }, arriveFromHistory: (view, place) => { @@ -580,6 +595,7 @@ export const useStore = create((set, get) => ({ inspectedMemoryKey: inspected ?? opened.inspectedMemoryKey ?? null, inspectedAgent: inspected ? (place?.inspectedAgent ?? "") : (opened.inspectedAgent ?? ""), inspectedOwner: inspected ? (place?.inspectedOwner ?? null) : null, + inspectedScope: inspected ? (place?.inspectedScope ?? null) : null, }); addressPageNamespace(); }, @@ -594,7 +610,8 @@ export const useStore = create((set, get) => ({ const agent = opts?.agent || ""; const owner = opts?.userId || opts?.sessionId ? { user_id: opts.userId || "-", session_id: opts.sessionId || "-" } : null; - set({ inspectedMemoryKey, inspectedAgent: agent, inspectedOwner: owner }); + const scope = opts?.namespace || opts?.exact ? { namespace: opts.namespace, exact: !!opts.exact } : null; + set({ inspectedMemoryKey, inspectedAgent: agent, inspectedOwner: owner, inspectedScope: scope }); // On Memories the open memory is the page's URL (`?memory=`), with the agent it was // read as in the entry's state for a reload. if (get().view === "memories") { diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index 6c83e9c2bb2..cd84da05dd9 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -21,6 +21,8 @@ const entry = (memory_key: string): MemoryListEntry => ({ pinned: false, tags: [], agent: "claude-desktop", + user_id: "-", + session_id: "-", value: `value of ${memory_key}`, }); @@ -32,6 +34,9 @@ const hit = (memory_key: string, rank_score: number): SearchHit => ({ similarity: 0.6, rank_score, confidence: 1, + agent: "claude-desktop", + user_id: "-", + session_id: "-", score_components: { semantic: 0.6 }, }); diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index f2391d721ef..a02077d45e2 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -141,7 +141,10 @@ describe("Recall Lab: the scores table", () => { }); it("opens the memory drawer from a row, by click or from its key button", async () => { - searchMemory.mockResolvedValue({ results: [hit("deploy_note", 0.9)], embedding_model: "m" }); + searchMemory.mockResolvedValue({ + results: [hit("deploy_note", 0.9, { agent: "writer", user_id: "-", session_id: "-" })], + embedding_model: "m", + }); render(); const table = await score(); fireEvent.click(within(table).getByText("excerpt of deploy_note")); @@ -151,6 +154,34 @@ describe("Recall Lab: the scores table", () => { expect(useStore.getState().inspectedMemoryKey).toBe("deploy_note"); }); + it("opens the selected namesake using its complete identity", async () => { + searchMemory.mockResolvedValue({ + results: [ + hit("deploy_note", 0.9, { namespace: "ns", agent: "writer", user_id: "-", session_id: "-" }), + hit("deploy_note", 0.8, { namespace: "other", agent: "writer", user_id: "u", session_id: "s" }), + hit("deploy_note", 0.7, { namespace: "ns", agent: "writer", content_excerpt: "identity incomplete" }), + ], + }); + render(); + const table = await score(); + const [local, other, incomplete] = within(table).getAllByRole("button", { name: "deploy_note" }); + expect(incomplete).toBeDisabled(); + fireEvent.click(within(table).getByText("identity incomplete")); + expect(useStore.getState().inspectedMemoryKey).toBeNull(); + fireEvent.click(other); + expect(useStore.getState()).toMatchObject({ + inspectedMemoryKey: "deploy_note", + inspectedAgent: "writer", + inspectedOwner: { user_id: "u", session_id: "s" }, + inspectedScope: { namespace: "other", exact: true }, + }); + fireEvent.click(local); + expect(useStore.getState()).toMatchObject({ + inspectedOwner: { user_id: "-", session_id: "-" }, + inspectedScope: { namespace: "ns", exact: true }, + }); + }); + it("marks a keyword row and gives it dashes where nothing ranked it", async () => { listMemories.mockResolvedValue({ entries: [entry("deploy_kw")], total: 1, today: 0, truncated: false }); searchMemory.mockResolvedValue({ results: [], embedding_model: "m" }); @@ -163,6 +194,53 @@ describe("Recall Lab: the scores table", () => { expect(row.getAllByText("—")).toHaveLength(3); }); + it("keeps guidance with the matching writer and session when keys are shared", async () => { + listMemories.mockResolvedValue({ + entries: [{ ...entry("deploy_note"), user_id: "user", session_id: "one" }], + total: 1, + today: 0, + truncated: false, + }); + searchMemory.mockResolvedValue({ + results: [ + hit("deploy_note", 0.9, { + agent: "claude-code", + user_id: "user", + session_id: "one", + content_excerpt: "matching revision", + use_guidance: { next_step: "inspect_only", reasons: [] }, + }), + hit("deploy_note", 0.8, { + agent: "claude-code", + user_id: "user", + session_id: "two", + content_excerpt: "other session", + use_guidance: { next_step: "validate_lead", reasons: [] }, + }), + hit("deploy_note", 0.7, { + agent: "other-agent", + user_id: "user", + session_id: "one", + content_excerpt: "other writer", + use_guidance: { next_step: "follow_if_applicable", reasons: [] }, + }), + ], + embedding_model: "m", + }); + render(); + const rows = within(await score()) + .getAllByRole("row") + .slice(1) + .map((row) => within(row)); + expect(rows).toHaveLength(3); + expect(rows[0].getByText("keyword match")).toBeInTheDocument(); + expect(rows[0].getByText("matching revision")).toBeInTheDocument(); + expect(rows[0].getByText("Suggested use: inspect only")).toBeInTheDocument(); + expect(rows[1].queryByText("keyword match")).toBeNull(); + expect(rows[1].getByText("Suggested use: validate lead")).toBeInTheDocument(); + expect(rows[2].getByText("Suggested use: follow if applicable")).toBeInTheDocument(); + }); + it("puts the row count and the embedder at the end of the toolbar", async () => { searchMemory.mockResolvedValue({ results: [hit("a1", 0.9), hit("a2", 0.5)], diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 78e5d4ca2c6..eeb974cdf54 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -264,13 +264,29 @@ function RecallHistory() { /** One row of the Memories list's search order: a keyword match, a ranked hit, or both. */ interface RecallRow { + id: string; key: string; text: string; memoryType: string; keyword: boolean; + writer: Pick; hit?: SearchHit; } +function hasWriter(row: RecallRow["writer"]): boolean { + return Boolean(row.agent && row.agent !== "*" && row.user_id && row.session_id); +} + +function recallRowId( + namespace: string, + row: Pick, + unidentified: string, +): string { + return hasWriter(row) + ? JSON.stringify([row.namespace || namespace, row.agent, row.user_id, row.session_id, row.memory_key]) + : unidentified; +} + // The entity boost has its own column; the other terms that moved a hit sit under its score. const ENTITY = "entity"; @@ -295,17 +311,17 @@ const ASK_HEADERS = [ /** One scored row: the key opens the memory (a button, so the keyboard reaches it), the * score draws Click UI's table bar against the top ranked hit, and the last cell asks the * assistant about the result (its click, even an unavailable one, opens nothing). */ -function scoreRow(row: RecallRow, i: number, top: number, open: (key: string) => void, query: string): TableRowType { +function scoreRow(row: RecallRow, i: number, top: number, open: (row: RecallRow) => void, query: string): TableRowType { const hit = row.hit; const terms = whyTerms(hit?.score_components); const entity = terms.find((t) => t.label === ENTITY); const width = hit && top > 0 ? Math.max(0, Math.min(100, (hit.rank_score / top) * 100)) : 0; return { - id: row.key, + id: row.id, onClick: (e) => { - if (!e.defaultPrevented) open(row.key); + if (!e.defaultPrevented) open(row); }, - className: "cursor-pointer", + className: hasWriter(row.writer) ? "cursor-pointer" : undefined, items: [ { className: CARD, label: {i + 1} }, { @@ -314,9 +330,10 @@ function scoreRow(row: RecallRow, i: number, top: number, open: (key: string) =>

); })} diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 27a5acbd046..1133c9c4d16 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -3,12 +3,38 @@ // holds the query (memory.list `contains`, newest first), then the ranked hits they do // not already hold. +import { SENTINEL_AGENTS } from "./format"; + /** Keyword matches a search shows ahead of the ranked hits (a viewer's list page is 100). */ export const KEYWORD_PAGE = 100; +/** Whether a row names its writer in full: a server that predates the fields, a shared row + * (`_shared`, `*`) and a chunk without them do not. */ +export function namesWriter(r: { agent?: string; user_id?: string; session_id?: string }): boolean { + return Boolean(r.agent && !SENTINEL_AGENTS.has(r.agent) && r.agent !== "_shared" && r.user_id && r.session_id); +} + +/** A row's own id: `(namespace, agent, user, session, key)`, which is what two rows of one + * key differ by; `[key]` alone when the row does not name its writer. The two shapes differ + * in length, so a key cannot make one pass for the other. */ +export function rowIdentity( + namespace: string, + r: { memory_key: string; agent?: string; user_id?: string; session_id?: string; namespace?: string }, +): string { + return JSON.stringify( + namesWriter(r) ? [r.namespace || namespace, r.agent, r.user_id, r.session_id, r.memory_key] : [r.memory_key], + ); +} + +/** Every id a row answers to: its own and its key's. A hit that names no writer is the key + * alone (the old match, which keeps every row of the key); a hit that names one matches + * only the row it names. */ +export function rowIds(namespace: string, r: Parameters[1]): string[] { + return [rowIdentity(namespace, r), JSON.stringify([r.memory_key])]; +} + export function keywordThenRanked(keywordKeys: string[], rankedKeys: string[]): string[] { - const keyword = new Set(keywordKeys); - return [...keywordKeys, ...rankedKeys.filter((k) => !keyword.has(k))]; + return [...new Set([...keywordKeys, ...rankedKeys])]; } /** A parsed search: the text the server is asked, and the tag and agent filters. */ diff --git a/frontend/src/lib/place.test.ts b/frontend/src/lib/place.test.ts index 2b32054998c..cf340df4b04 100644 --- a/frontend/src/lib/place.test.ts +++ b/frontend/src/lib/place.test.ts @@ -30,6 +30,7 @@ describe("rememberPlace / readPlace", () => { inspected: "a", inspectedAgent: "bot", inspectedOwner: null, + inspectedScope: null, }); }); diff --git a/frontend/src/lib/place.ts b/frontend/src/lib/place.ts index ccf3d2d2239..5b8da5eb75e 100644 --- a/frontend/src/lib/place.ts +++ b/frontend/src/lib/place.ts @@ -75,7 +75,7 @@ export function rememberPlace( inspected: inspected.key, inspectedAgent: inspected.agent, inspectedOwner: inspected.owner ?? null, - ...(inspected.scope ? { inspectedScope: inspected.scope } : {}), + inspectedScope: inspected.scope ?? null, }; patchEntry({ loomPlace: place }); } @@ -86,31 +86,41 @@ export function readPlace(state: unknown): Place | null { const p = (state as Record).loomPlace; if (!p || typeof p !== "object") return null; const r = p as Record; - const scope = inspectionScope(r.inspectedScope); return { scrollTop: typeof r.scrollTop === "number" ? r.scrollTop : 0, - focusKey: typeof r.focusKey === "string" ? r.focusKey : null, - inspected: typeof r.inspected === "string" ? r.inspected : null, - inspectedAgent: typeof r.inspectedAgent === "string" ? r.inspectedAgent : "", + focusKey: text(r.focusKey) ?? null, + inspected: text(r.inspected) ?? null, + inspectedAgent: text(r.inspectedAgent) ?? "", inspectedOwner: owner(r.inspectedOwner), - ...(scope ? { inspectedScope: scope } : {}), + inspectedScope: inspectionScope(r.inspectedScope), }; } +const text = (v: unknown) => (typeof v === "string" ? v : undefined); + function inspectionScope(v: unknown): InspectedScope | null { - if (!v || typeof v !== "object") return null; - const scope = v as Record; - return typeof scope.exact === "boolean" - ? { namespace: typeof scope.namespace === "string" ? scope.namespace : undefined, exact: scope.exact } - : null; + const o = (v ?? {}) as Partial; + return typeof o.exact === "boolean" ? { namespace: text(o.namespace), exact: o.exact } : null; } function owner(v: unknown): InspectedOwner | null { - if (!v || typeof v !== "object") return null; - const o = v as Record; - return typeof o.user_id === "string" && typeof o.session_id === "string" - ? { user_id: o.user_id, session_id: o.session_id } - : null; + const o = (v ?? {}) as Partial; + const user_id = text(o.user_id); + const session_id = text(o.session_id); + return user_id !== undefined && session_id !== undefined ? { user_id, session_id } : null; +} + +/** How the entry's `?memory=` link was opened: the writer agent, user and session and the + * namespace it was read in, as `inspect` stamped them. An entry that remembers none of it + * (an older one, or a bare link) opens the key under every agent, as before. */ +export function readInspect(key: string): Pick { + const r = (stateRecord().loomInspect ?? {}) as Record; + const mine = r.key === key; + return { + inspectedAgent: (mine && text(r.agent)) || "*", + inspectedOwner: mine ? owner(r.owner) : null, + inspectedScope: mine ? inspectionScope(r.scope) : null, + }; } /** The label of the entry the current one was reached from ("memory api/rate-limit"), set diff --git a/frontend/src/lib/state.namespace.test.ts b/frontend/src/lib/state.namespace.test.ts index 13ae7bb7660..09d5824e089 100644 --- a/frontend/src/lib/state.namespace.test.ts +++ b/frontend/src/lib/state.namespace.test.ts @@ -21,6 +21,7 @@ function at(url: string, state: unknown = null): void { history.replaceState(state, "", url); } const address = () => location.pathname + location.search; +const patchState = (state: unknown) => history.replaceState(state, "", location.href); /** Back one entry, then what App's popstate handler does for a view change. */ async function back(view: Parameters["arriveFromHistory"]>[0]) { @@ -206,6 +207,32 @@ describe("an entry Back reaches from another namespace", () => { expect(useStore.getState()).toMatchObject({ inspectedMemoryKey: "team-key", inspectedAgent: "bot" }); }); + it("a row opened as one session's reopens as that row after a reload; a bare link opens its key", async () => { + useStore.getState().navigate("recall"); + useStore.getState().setIdentity(team); + await back("memories"); + useStore + .getState() + .inspect("team-key", { agent: "bot", userId: "ada", sessionId: "two", namespace: "team", exact: true }); + const reload = () => { + useStore.setState({ identity: null, inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null }); + useStore.getState().bootIdentity(team); + useStore.getState().bootView("memories"); + return useStore.getState(); + }; + expect(reload()).toMatchObject({ + inspectedMemoryKey: "team-key", + inspectedAgent: "bot", + inspectedOwner: { user_id: "ada", session_id: "two" }, + inspectedScope: { namespace: "team", exact: true }, + }); + // An entry stamped before the owner was kept, and a link with no state at all. + patchState({ loomNamespace: "team", loomInspect: { key: "team-key", agent: "bot" } }); + expect(reload()).toMatchObject({ inspectedAgent: "bot", inspectedOwner: null, inspectedScope: null }); + history.replaceState(null, "", "/memories?namespace=team&memory=team-key"); + expect(reload()).toMatchObject({ inspectedAgent: "*", inspectedOwner: null, inspectedScope: null }); + }); + it("after the account loses that namespace, a reload opens nothing under the no-access page", async () => { useStore.getState().navigate("recall"); useStore.getState().setIdentity(team); diff --git a/frontend/src/lib/state.ts b/frontend/src/lib/state.ts index a39df4f388f..3ff3f796aaa 100644 --- a/frontend/src/lib/state.ts +++ b/frontend/src/lib/state.ts @@ -4,7 +4,15 @@ import { hasToken, isAuthDisabled, isProxyMode } from "../api"; import { sameIdentity } from "./boot"; import { NAMESPACE_NAME, isCollectionName } from "./namespace"; import { HANDOFF_QUERY_KEYS, readSessionHandoff, type SessionHandoffRef } from "./sessionHandoff"; -import { patchEntry, readPlace, rememberPlace, type InspectedOwner, type InspectedScope, type Place } from "./place"; +import { + patchEntry, + readInspect, + readPlace, + rememberPlace, + type InspectedOwner, + type InspectedScope, + type Place, +} from "./place"; export type View = | "memories" @@ -247,18 +255,6 @@ export function setViewParam(key: string, value: string | null, state: Record).loomInspect : null; - if (remembered && typeof remembered === "object") { - const r = remembered as Record; - if (r.key === key && typeof r.agent === "string") return r.agent; - } - return "*"; -} - // The URL keys that name an object of one namespace: a switch drops them. const SWITCH_CLEARS = ["memory", "thread", "doc", "task", ...HANDOFF_QUERY_KEYS]; // A collection is the org's, not a namespace's: an entry made in another namespace keeps it, @@ -306,9 +302,7 @@ function stampFor(namespace: string | null): Record { return { loomNamespace: namespace, loomInspect: null, - ...(place - ? { loomPlace: { ...place, inspected: null, inspectedAgent: "", inspectedOwner: null, inspectedScope: null } } - : {}), + ...(place ? { loomPlace: { ...place, inspected: null, inspectedAgent: "", inspectedOwner: null } } : {}), }; } @@ -325,9 +319,7 @@ function openedByUrl(v: View): Partial { const thread = v === "sessions" ? urlParam("thread") : null; return { inspectedMemoryKey: memory, - inspectedAgent: memory ? linkedAgent(memory) : "", - inspectedOwner: null, - inspectedScope: null, + ...(memory ? readInspect(memory) : { inspectedAgent: "", inspectedOwner: null, inspectedScope: null }), ...(doc ? { pendingDocSourceUri: doc } : {}), ...(thread ? { pendingConversationThread: { threadId: thread } } : {}), }; @@ -535,7 +527,6 @@ export const useStore = create((set, get) => ({ deniedNamespace: null, linkOpened: null, inspectedMemoryKey: null, - inspectedScope: null, pendingConversationThread: null, sessionHandoff: null, pendingDocSourceUri: null, @@ -562,7 +553,6 @@ export const useStore = create((set, get) => ({ set((s) => ({ view, inspectedMemoryKey: null, - inspectedScope: null, navSeq: s.navSeq + 1, sessionHandoff: linkedSessionHandoff(view), navNote: opts.note ?? null, @@ -577,9 +567,7 @@ export const useStore = create((set, get) => ({ set({ view, sessionHandoff: here ? linkedSessionHandoff(view) : null, - ...(here - ? openedByUrl(view) - : { inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null, inspectedScope: null }), + ...(here ? openedByUrl(view) : { inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null }), }); }, arriveFromHistory: (view, place) => { @@ -612,11 +600,11 @@ export const useStore = create((set, get) => ({ opts?.userId || opts?.sessionId ? { user_id: opts.userId || "-", session_id: opts.sessionId || "-" } : null; const scope = opts?.namespace || opts?.exact ? { namespace: opts.namespace, exact: !!opts.exact } : null; set({ inspectedMemoryKey, inspectedAgent: agent, inspectedOwner: owner, inspectedScope: scope }); - // On Memories the open memory is the page's URL (`?memory=`), with the agent it was - // read as in the entry's state for a reload. + // On Memories the open memory is the page's URL (`?memory=`), with the agent, user and + // session it was read as and its namespace in the entry's state for a reload. if (get().view === "memories") { setViewParam("memory", inspectedMemoryKey, { - loomInspect: inspectedMemoryKey ? { key: inspectedMemoryKey, agent } : null, + loomInspect: inspectedMemoryKey ? { key: inspectedMemoryKey, agent, owner, scope } : null, }); } }, diff --git a/frontend/src/views/Recent.lists.test.tsx b/frontend/src/views/Recent.lists.test.tsx index 2ed6b0c7562..8514e13b3f8 100644 --- a/frontend/src/views/Recent.lists.test.tsx +++ b/frontend/src/views/Recent.lists.test.tsx @@ -18,11 +18,14 @@ const entry = (memory_key: string, over: Partial = {}): MemoryL memory_type: "semantic", confidence: 1, version: 1, + version_text: "1", created_at: "2026-09-18T09:00:00Z", expires_at: null, pinned: false, tags: [], agent: "claude-desktop", + user_id: "alice", + session_id: "s1", value: `value of ${memory_key}`, ...over, }); @@ -41,13 +44,14 @@ vi.mock("../api", async (importOriginal) => { listMemories: vi.fn(), getMemory: vi.fn(), pinMemory: vi.fn(async () => ({ version: 2, pinned: true })), + deleteMemoryVersion: vi.fn(async () => ({ tombstoned: false })), bulkGetMemories: vi.fn(async () => ({ results: {}, missing: [] })), conflictKeys: vi.fn(async (): Promise => ["c/conflicted"]), listMine: vi.fn(async () => []), isAuthDisabled: () => false, }; }); -import { conflictKeys, getMemory, listMemories, pinMemory } from "../api"; +import { conflictKeys, deleteMemoryVersion, getMemory, listMemories, pinMemory } from "../api"; const owner: WhoAmI = { authenticated: true, @@ -455,11 +459,14 @@ describe("Memories list chrome", () => { memory_type: "semantic", confidence: 0.8, version: 1, + version_text: "1", pinned: false, created_at: "2026-09-18T09:00:00Z", tags: ["infra"], source_trace: "conversation:t1", agent: "claude-desktop", + user_id: "alice", + session_id: "s1", }; vi.mocked(getMemory).mockResolvedValue(detail); vi.mocked(listMemories).mockResolvedValue({ @@ -480,14 +487,111 @@ describe("Memories list chrome", () => { "d/plain", ]); expect(vi.mocked(pinMemory).mock.calls[0]).toEqual([ - { org: "dev", namespace: "team", agent: "claude-desktop" }, + { org: "dev", namespace: "team", agent: "claude-desktop", user_id: "alice", session_id: "s1" }, "d/plain", detail, ]); }); + describe("two rows of one key", () => { + const two = (over: Partial = {}) => [ + entry("d/plain", { user_id: "alice", session_id: "s1", ...over }), + entry("d/plain", { user_id: "alice", session_id: "s2", ...over }), + ]; + const show = async (entries: MemoryListEntry[]) => { + vi.mocked(getMemory).mockResolvedValue({ + found: true, + value: "v", + version: 1, + version_text: "1", + pinned: false, + agent: "claude-desktop", + user_id: "alice", + session_id: "s2", + } as MemoryDetail); + vi.mocked(listMemories).mockResolvedValue({ entries, total: entries.length, today: 0, truncated: false }); + render(); + await screen.findAllByText("d/plain"); + return screen.getAllByRole("checkbox", { name: "Select d/plain" }); + }; + + it("selects, and pins, only the row that was ticked", async () => { + const boxes = await show(two()); + const user = userEvent.setup(); + await user.click(boxes[1]!); + expect(boxes[0]).toHaveAttribute("aria-checked", "false"); + expect(boxes[1]).toHaveAttribute("aria-checked", "true"); + await user.click(within(toolbar()).getByRole("button", { name: "Pin" })); + await waitFor(() => expect(pinMemory).toHaveBeenCalledTimes(1)); + expect(vi.mocked(getMemory).mock.calls[0]![0]).toMatchObject({ user_id: "alice", session_id: "s2" }); + expect(vi.mocked(pinMemory).mock.calls[0]![0]).toMatchObject({ user_id: "alice", session_id: "s2" }); + }); + + it("refuses to pin a namesake returned after the selected row disappears", async () => { + const boxes = await show(two()); + const user = userEvent.setup(); + await user.click(boxes[0]!); + await user.click(within(toolbar()).getByRole("button", { name: "Pin" })); + await waitFor(() => expect(toolbar()).not.toHaveTextContent("1 selected")); + expect(getMemory).toHaveBeenCalledWith(expect.objectContaining({ session_id: "s1" }), "d/plain"); + expect(pinMemory).not.toHaveBeenCalled(); + }); + + it("deletes only the selected writer and exact listed version", async () => { + const version = "1795700603642123456"; + const boxes = await show(two({ version: Number(version), version_text: version })); + const confirm = vi.spyOn(window, "confirm").mockReturnValue(true); + try { + const user = userEvent.setup(); + await user.click(boxes[0]!); + await user.click(within(toolbar()).getByRole("button", { name: "Delete" })); + await waitFor(() => expect(toolbar()).not.toHaveTextContent("1 selected")); + expect(deleteMemoryVersion).toHaveBeenCalledExactlyOnceWith( + { org: "dev", namespace: "team", agent: "claude-desktop", user_id: "alice", session_id: "s1" }, + "d/plain", + version, + ); + expect(getMemory).not.toHaveBeenCalled(); + } finally { + confirm.mockRestore(); + } + }); + + it("does not guess between rows that name no writer: the pin is refused, not sent to either", async () => { + const boxes = await show(two({ user_id: undefined, session_id: undefined })); + const user = userEvent.setup(); + await user.click(boxes[0]!); + await user.click(within(toolbar()).getByRole("button", { name: "Pin" })); + await waitFor(() => expect(toolbar()).not.toHaveTextContent("1 selected")); + expect(getMemory).not.toHaveBeenCalled(); + expect(pinMemory).not.toHaveBeenCalled(); + }); + + it("marks as open only the row the inspector holds", async () => { + useStore.setState({ + inspectedMemoryKey: "d/plain", + inspectedAgent: "claude-desktop", + inspectedOwner: { user_id: "alice", session_id: "s2" }, + }); + const boxes = await show(two()); + const open = document.querySelectorAll("[data-active]"); + expect(open).toHaveLength(1); + expect(open[0]!.contains(boxes[1]!)).toBe(true); + useStore.setState({ inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null }); + }); + }); + it("counts a pin that committed with lists behind as pinned, and says a failure apart", async () => { - vi.mocked(getMemory).mockResolvedValue({ found: true, value: "v", version: 1, pinned: false } as MemoryDetail); + vi.mocked(getMemory).mockResolvedValue({ + found: true, + value: "v", + version: 1, + version_text: "1", + pinned: false, + agent: "claude-desktop", + user_id: "alice", + session_id: "s1", + } as MemoryDetail); vi.mocked(listMemories).mockResolvedValue({ entries: [entry("d/one"), entry("d/two")], total: 2, diff --git a/frontend/src/views/Recent.renders.test.tsx b/frontend/src/views/Recent.renders.test.tsx index 1ca03994fbf..dd9d02e76e1 100644 --- a/frontend/src/views/Recent.renders.test.tsx +++ b/frontend/src/views/Recent.renders.test.tsx @@ -26,6 +26,8 @@ const entry = (memory_key: string): MemoryListEntry => ({ pinned: false, tags: ["alerts"], agent: "claude-desktop", + user_id: "user", + session_id: "one", value: `value of ${memory_key}`, }); @@ -46,6 +48,10 @@ vi.mock("../api", async (importOriginal) => { searchMemory: vi.fn(async () => ({ results: [ { + agent: "claude-desktop", + user_id: "user", + session_id: "one", + version: 1, memory_key: "coffee_pref", memory_type: "semantic", content_excerpt: "prefers oat milk in coffee", diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index f0f75b749ca..a8315a5ce68 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -22,9 +22,14 @@ const entry = (memory_key: string): MemoryListEntry => ({ pinned: false, tags: [], agent: "claude-desktop", + user_id: "user", + session_id: "one", value: `value of ${memory_key}`, }); +// A ranked hit as the server names its row: writer in full and the revision it was read at. +const writer = { agent: "claude-desktop", user_id: "user", session_id: "one", version: 1 }; + vi.mock("../api", async (importOriginal) => { const actual = await importOriginal(); return { @@ -44,6 +49,7 @@ vi.mock("../api", async (importOriginal) => { searchMemory: vi.fn(async () => ({ results: [ { + ...writer, memory_key: "coffee_pref", memory_type: "semantic", content_excerpt: "prefers oat milk in coffee", @@ -134,6 +140,125 @@ describe("Recent search why-line", () => { }); }); +describe("Recent search with one key written by two sessions", () => { + const written = (session_id: string, over: Partial = {}): MemoryListEntry => ({ + ...entry("deploy_note"), + user_id: "user", + session_id, + value: `note of session ${session_id}`, + ...over, + }); + const ranked = (session_id: string, over: Record = {}) => ({ + memory_key: "deploy_note", + memory_type: "semantic", + content_excerpt: `note of session ${session_id}`, + distance: 0.3, + similarity: 0.7, + rank_score: 0.8, + confidence: 0.9, + agent: "claude-desktop", + user_id: "user", + session_id, + version: 1, + use_guidance: { next_step: "validate_lead", reasons: [] }, + ...over, + }); + const feed = (...entries: MemoryListEntry[]) => + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => ({ + entries: opts?.contains ? [] : entries, + total: entries.length, + today: entries.length, + truncated: false, + })); + const search = async () => { + render(); + await waitFor(() => expect(listMemories).toHaveBeenCalled()); + await userEvent.type(screen.getByLabelText("Search memories"), "deploy"); + await waitFor(() => expect(searchMemory).toHaveBeenCalled(), { timeout: 3000 }); + }; + + beforeEach(() => { + vi.clearAllMocks(); + resetNamespaceRoleCache(); + useStore.setState({ + authed: true, + whoami: admin, + myNamespaces: [row("alice", "admin")], + identity: { org: "dev", namespace: "alice", agent: "loom-ui" }, + view: "memories", + }); + }); + afterEach(() => { + cleanup(); + useStore.setState({ whoami: null, myNamespaces: null, identity: null }); + }); + + it("keeps both rows of the key on screen and gives the guidance to the ranked one only", async () => { + // Both rows hold the typed word, so both stay; only session one's was ranked. + const both = [written("one"), written("two")]; + vi.mocked(listMemories).mockResolvedValue({ entries: both, total: 2, today: 2, truncated: false }); + vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); + await search(); + + await screen.findByText("note of session one"); + expect(screen.getByText("note of session two")).toBeInTheDocument(); + const why = await screen.findAllByRole("button", { name: "Why this result" }); + expect(why).toHaveLength(2); + const cardOf = (b: HTMLElement) => b.closest("[data-memory-key]") as HTMLElement; + // The ranked row says why it was ranked; its namesake only that it holds the word. + const ofSession = (text: string) => why.find((b) => cardOf(b).textContent?.includes(text)) as HTMLElement; + await userEvent.click(ofSession("note of session two")); + expect(await screen.findByTestId("search-why")).toHaveTextContent('Contains "deploy"'); + expect(screen.getByTestId("search-why")).not.toHaveTextContent("Suggested use"); + await userEvent.keyboard("{Escape}"); + await userEvent.click(ofSession("note of session one")); + expect(await screen.findByTestId("search-why")).toHaveTextContent("Suggested use: validate lead"); + expect(screen.getAllByTestId("search-score")).toHaveLength(1); + }); + + it("keeps a ranked row visible but gives it no guidance or score when its revision is not the hit's", async () => { + feed(written("one", { version: 2 })); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { version: 1 })], + embedding_model: "fake", + } as never); + await search(); + + await screen.findByText("note of session one"); + expect(screen.queryByRole("button", { name: "Why this result" })).toBeNull(); + expect(screen.queryByTestId("search-score")).toBeNull(); + }); + + it("does the same for a hit or row that names no revision", async () => { + for (const gone of ["hit", "row"] as const) { + cleanup(); + feed(written("one", gone === "row" ? { version: undefined } : {})); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", gone === "hit" ? { version: undefined } : {})], + embedding_model: "fake", + } as never); + await search(); + await screen.findByText("note of session one"); + expect(screen.queryByTestId("search-score"), gone).toBeNull(); + expect(screen.queryByRole("button", { name: "Why this result" }), gone).toBeNull(); + } + }); + + it("keeps rows of the key a hit without its writer names, and gives none of them its guidance", async () => { + feed(written("one"), written("two")); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { user_id: undefined, session_id: undefined })], + embedding_model: "fake", + } as never); + await search(); + + await screen.findByText("note of session one"); + expect(screen.getByText("note of session two")).toBeInTheDocument(); + expect(screen.queryByTestId("search-score")).toBeNull(); + expect(screen.queryByText(/Suggested use/)).toBeNull(); + }); +}); + describe("Recent search under a tag filter", () => { beforeEach(() => { vi.clearAllMocks(); @@ -203,6 +328,7 @@ describe("Recent search after a local write", () => { : { entries: [entry("milk_note"), entry("oat_pref"), entry("old_pref")], total: 3, today: 0, truncated: false }, ); const hit = (memory_key: string) => ({ + ...writer, memory_key, memory_type: "semantic", content_excerpt: memory_key, @@ -250,6 +376,7 @@ describe("Recent search after a local write", () => { return { results: [ { + ...writer, memory_key: "far_pref", memory_type: "semantic", content_excerpt: "far_pref", @@ -294,6 +421,7 @@ describe("Recent search after a local write", () => { return { results: [ { + ...writer, memory_key: "far_pref", memory_type: "semantic", content_excerpt: "far_pref", @@ -396,6 +524,7 @@ describe("Recent search after a local write", () => { : { entries: [entry("milk_note"), entry("oat_pref")], total: 2, today: 0, truncated: false }, ); const hit = (memory_key: string) => ({ + ...writer, memory_key, memory_type: "semantic", content_excerpt: memory_key, @@ -437,6 +566,7 @@ describe("Recent search after a local write", () => { : { entries: [entry("milk_note"), entry("oat_pref")], total: 2, today: 0, truncated: false }, ); const hit = (memory_key: string) => ({ + ...writer, memory_key, memory_type: "semantic", content_excerpt: memory_key, @@ -671,6 +801,7 @@ describe("Recent search finds every row that names the word", () => { vi.mocked(searchMemory).mockImplementation(async () => ({ results: [ { + ...writer, memory_key: "coffee_pref", memory_type: "semantic", content_excerpt: "prefers oat milk in coffee", @@ -698,8 +829,9 @@ describe("Recent search finds every row that names the word", () => { ? { entries: [entry("azure_new"), entry("coffee_pref")], total: 146, today: 1, truncated: false } : { entries: [entry("coffee_pref"), entry("tea_pref")], total: 2, today: 2, truncated: false }, ); - // tea_pref is ranked and holds no "Azure": the one row that shows a score. + // coffee_pref and tea_pref are ranked; azure_new holds the word and is not. const ranked = (key: string, similarity: number) => ({ + ...writer, memory_key: key, memory_type: "semantic", content_excerpt: "", @@ -723,11 +855,13 @@ describe("Recent search finds every row that names the word", () => { "keyword list call", ); expect(kw[2]).toMatchObject({ contains: "Azure" }); - // A keyword row shows no score, a ranked hit that holds the text (coffee_pref) included; - // the ranked-only row does. + // A row that holds the text and was not ranked shows no score; the ranked rows do, the + // one that holds the text too (coffee_pref) included. const scores = await screen.findAllByTestId("search-score", undefined, { timeout: 3000 }); - expect(scores).toHaveLength(1); - expect(scores[0].closest("[data-memory-key]")).toHaveAttribute("data-memory-key", "tea_pref"); + expect(scores.map((n) => n.closest("[data-memory-key]")?.getAttribute("data-memory-key")).sort()).toEqual([ + "coffee_pref", + "tea_pref", + ]); expect(screen.getAllByRole("button", { name: "Why this result" })).toHaveLength(3); await userEvent.click(screen.getAllByRole("button", { name: "Why this result" })[0]); expect(await screen.findByTestId("search-why")).toHaveTextContent('Contains "Azure"'); diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 5854024277d..9105cbe1dd7 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -16,7 +16,7 @@ import { Select } from "@clickhouse/click-ui/Select"; import { getMemory, pinMemory, - deleteMemory, + deleteMemoryVersion, restoreMemory, conflictKeys as fetchConflictKeys, isAuthDisabled, @@ -49,7 +49,15 @@ import { Unavailable } from "../components/ui"; import { useNamespaceRoleRead } from "../lib/namespaceRole"; import { type GatedNamespaceOp, callReason, codeMember, needsLine } from "../lib/callReason"; import { canCall } from "../lib/canCall"; -import { parseSearchQuery, type SearchQuery, takePendingSearch, toggleQueryToken } from "../lib/memoriesSearch"; +import { + parseSearchQuery, + type SearchQuery, + namesWriter, + rowIdentity, + rowIds, + takePendingSearch, + toggleQueryToken, +} from "../lib/memoriesSearch"; import { oneOf } from "../lib/oneOf"; import { isPublicationPending } from "../lib/errors"; import { PHONE_QUERY, useMedia } from "../lib/useMedia"; @@ -132,6 +140,8 @@ function MemoryList() { const selectable = !pinReason && !deleteReason; const inspectedKey = useStore((s) => s.inspectedMemoryKey); const inspect = useStore((s) => s.inspect); + const inspectedAgent = useStore((s) => s.inspectedAgent); + const inspectedOwner = useStore((s) => s.inspectedOwner); // Bumped on memory writes from any surface so we re-fetch immediately // instead of waiting for the polling cycle. const memoriesVersion = useStore((s) => s.memoriesVersion); @@ -352,23 +362,6 @@ function MemoryList() { searching, ranking, } = useMemorySearch(identity, rawQuery, searchFilter, entries, memoriesVersion); - // Each hit's scores and "Why this result", made when the results change rather than in - // every render: an element made in render is a new prop each time, and every memoised card - // would render again on each keystroke. - const { searchScores, searchAsides } = useMemo(() => { - const scores = new Map(); - const asides = new Map(); - searchHits?.forEach((key, i) => { - const hit = searchWhy.get(key); - if (keywordKeys.has(key)) asides.set(key, ); - else if (hit) { - scores.set(key, ); - asides.set(key, ); - } - }); - return { searchScores: scores, searchAsides: asides }; - }, [searchHits, searchWhy, keywordKeys, keywordFor]); - // Fetch conflicts once per identity change; cards consult this set to // flag rows that need review. One namespace-wide read beats N per-card calls. // Only when the role here is known to allow it: an unknown role sends nothing and the @@ -400,8 +393,8 @@ function MemoryList() { // Fold in search hits fetched from outside the preloaded window so the // same filters + ranking below apply to them uniformly. if (searchHits != null && searchExtra.size > 0) { - const have = new Set(all.map((e) => e.memory_key)); - const extras = [...searchExtra.values()].filter((e) => !have.has(e.memory_key)); + const have = new Set(all.map((e) => rowIdentity(identity.namespace, e))); + const extras = [...searchExtra.values()].filter((e) => !have.has(rowIdentity(identity.namespace, e))); if (extras.length > 0) all = [...all, ...extras]; } // When "Recently deleted" is on, show only tombstoned rows; otherwise @@ -433,13 +426,37 @@ function MemoryList() { } if (searchHits != null) { // Re-order to the server's relevance ranking; drop entries outside top_k. - const rank = new Map(searchHits.map((k, i) => [k, i] as const)); - all = all - .filter((e) => rank.has(e.memory_key)) - .sort((a, b) => (rank.get(a.memory_key) ?? Infinity) - (rank.get(b.memory_key) ?? Infinity)); + // A row answers to its own id and to its key's: a hit that names no writer ranks every + // row of the key (the old match), one that names it ranks that row alone. + const rank = new Map(searchHits.map((id, i) => [id, i] as const)); + const at = (e: MemoryListEntry) => + Math.min(...rowIds(identity.namespace, e).map((id) => rank.get(id) ?? Infinity)); + all = all.filter((e) => at(e) !== Infinity).sort((a, b) => at(a) - at(b)); } return all; - }, [entries, searchHits, searchExtra, status, showDeleted, agentFilter, typed.agent, activeTags]); + }, [entries, searchHits, searchExtra, status, showDeleted, agentFilter, typed.agent, activeTags, identity.namespace]); + + // Each row's scores and "Why this result", made when the results or the rows change rather + // than in every render: an element made in render is a new prop each time, and every + // memoised card would render again on each keystroke. A ranked hit is shown only on the row + // it names in full (agent, user and session) and only while that row is at the revision the + // hit was read at: not on a namesake from another session, a row that names no writer, or a + // row since written again. A row holding the typed words and no such hit says what it holds. + const { searchScores, searchAsides } = useMemo(() => { + const scores = new Map(); + const asides = new Map(); + const rank = new Map((searchHits ?? []).map((id, i) => [id, i + 1] as const)); + for (const row of searchHits ? flatList : []) { + const id = rowIdentity(identity.namespace, row); + const hit = searchWhy.get(id); + const at = rank.get(id); + if (hit && at && hit.version && row.version && hit.version === row.version) { + scores.set(id, ); + asides.set(id, ); + } else if (keywordKeys.has(id)) asides.set(id, ); + } + return { searchScores: scores, searchAsides: asides }; + }, [searchHits, searchWhy, keywordKeys, keywordFor, flatList, identity.namespace]); // The agents the namespace's rows were written by, gathered as pages and filters load // (sentinels "*" and "-" are not writers); a new namespace starts again. @@ -451,15 +468,9 @@ function MemoryList() { }); }, [entries]); - // A memory's identity is (org, namespace, agent, user_id, session_id) + - // memory_key, and this list spans agents (there is an agent filter chip). The - // page identity carries the *session's* agent, so addressing a row by it - // misses anything another agent wrote: reads 404 and `memory.delete` returns - // `tombstoned: false`. The inspector already solves this by overriding agent - // with the row's writer (App.tsx) — bulk actions need the same, per row. - // Sentinel agents ("*", "-") are not real writers, so leave those alone. - const identityForRow = (rowAgent: string | undefined) => - rowAgent && !SENTINEL_AGENTS.has(rowAgent) ? { ...identity, agent: rowAgent } : identity; + const rowById = (id: string) => flatList.find((e) => rowIdentity(identity.namespace, e) === id); + const actionIdentity = (e: MemoryListEntry) => + namesWriter(e) ? { ...identity, agent: e.agent ?? "", user_id: e.user_id, session_id: e.session_id } : null; const bulkPin = async () => { if (selected.size === 0 || busy || pinReason) return; @@ -472,19 +483,24 @@ function MemoryList() { let lagging: unknown = null; let failure: unknown = null; for (const k of keys) { - const entry = flatList.find((e) => e.memory_key === k); - if (!entry) { + const entry = rowById(k); + const rowId = entry && actionIdentity(entry); + if (!entry?.version_text || !rowId) { fail++; continue; } - const rowId = identityForRow(entry.agent); try { - // pinMemory writes the whole row back; the list view doesn't carry it, so - // refetch the row before pinning, by its own user and session. - const readId = { ...rowId, user_id: entry.user_id || "-", session_id: entry.session_id || "-" }; - const got = await getMemory(readId, k); - if (got && got.found) { - await pinMemory(rowId, k, got); + // A point read can fall back to another writer or follow a redirect. + const got = await getMemory(rowId, entry.memory_key); + if ( + got?.found && + !got.resolved_from && + got.agent === rowId.agent && + got.user_id === rowId.user_id && + got.session_id === rowId.session_id && + got.version_text === entry.version_text + ) { + await pinMemory(rowId, entry.memory_key, got); ok++; } else { fail++; @@ -526,12 +542,14 @@ function MemoryList() { let ok = 0, fail = 0; for (const k of keys) { - const entry = flatList.find((e) => e.memory_key === k); + const entry = rowById(k); + const rowId = entry && actionIdentity(entry); + if (!entry?.version_text || !rowId) { + fail++; + continue; + } try { - // `tombstoned: false` is a 200, not a throw — counting only the absence - // of an exception is what made this report "Deleted N" and then show - // every row again on refresh. - const r = await deleteMemory(identityForRow(entry?.agent), k); + const r = await deleteMemoryVersion(rowId, entry.memory_key, entry.version_text); if (r.tombstoned) ok++; else fail++; } catch { @@ -555,7 +573,11 @@ function MemoryList() { () => (listFiltered && !searchActive ? flatList.slice(page * pageSize, (page + 1) * pageSize) : flatList), [flatList, listFiltered, searchActive, page, pageSize], ); - const pageKeys = useMemo(() => pageList.map((e) => e.memory_key), [pageList]); + // A checkbox names a row by its whole identity, not its key: two rows of a key are two boxes. + const pageKeys = useMemo( + () => pageList.map((e) => rowIdentity(identity.namespace, e)), + [pageList, identity.namespace], + ); // Checkboxes: one row, a Shift-click range, every row on the page; Escape clears them // while the drawer is closed (it owns Escape while open). const selection = useRowSelection(pageKeys, { enabled: !inspectedKey && selectable }); @@ -564,8 +586,22 @@ function MemoryList() { // A selection made before the role fell short is not acted on: the bar goes with the boxes. const selecting = selectable && selected.size > 0; const openCard = useCallback( - (e: MemoryListEntry) => (selecting ? toggleSelect(e.memory_key) : inspect(e.memory_key, { agent: e.agent })), - [selecting, toggleSelect, inspect], + (e: MemoryListEntry) => + selecting + ? toggleSelect(rowIdentity(identity.namespace, e)) + : inspect( + e.memory_key, + namesWriter(e) + ? { + agent: e.agent, + userId: e.user_id, + sessionId: e.session_id, + namespace: identity.namespace, + exact: true, + } + : { agent: e.agent }, + ), + [selecting, toggleSelect, inspect, identity.namespace], ); // Keyboard nav, active when no inspector is open and not typing: the list is one tab @@ -949,12 +985,19 @@ function MemoryList() {
{items.map((e) => { const isNew = newKeys.has(e.memory_key); - const isSelected = selected.has(e.memory_key); + const rowId = rowIdentity(identity.namespace, e); + const isSelected = selected.has(rowId); const isTombstoned = !!e.tombstoned_at; - const isActive = inspectedKey === e.memory_key; + // The open row is the one opened, not another row of its key. + const isActive = + inspectedKey === e.memory_key && + (!inspectedAgent || inspectedAgent === "*" || inspectedAgent === e.agent) && + (!inspectedOwner || + (inspectedOwner.user_id === (e.user_id || "-") && + inspectedOwner.session_id === (e.session_id || "-"))); return ( { ev.stopPropagation(); - toggleSelect(e.memory_key, ev.shiftKey); + toggleSelect(rowId, ev.shiftKey); }} aria-label={`Select ${e.memory_key}`} className="list-row-control" @@ -981,13 +1024,13 @@ function MemoryList() { hasConflict={conflictKeys.has(e.memory_key)} identity={identity} entry={e} - value={e.value !== undefined ? e.value : bulkValues.get(e.memory_key)} + value={e.value !== undefined ? e.value : bulkValues.get(rowId)} active={isActive} onSelect={openCard} onTagClick={toggleTag} activeTags={activeTags} - meta={searchScores.get(e.memory_key)} - aside={searchAsides.get(e.memory_key)} + meta={searchScores.get(rowId)} + aside={searchAsides.get(rowId)} /> {isTombstoned && (
diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 6798a1a71c4..557b82d827e 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -1,6 +1,7 @@ import { useEffect, useRef, useState } from "react"; import { bulkGetMemories, + getMemory, listMemories, searchMemory, type Identity, @@ -12,7 +13,7 @@ import { CARD_VALUE_CHARS } from "../components/MemoryCard"; import { errorRequestId } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; import { useAbortableEffect, useVisiblePoll } from "../lib/hooks"; -import { KEYWORD_PAGE, keywordThenRanked } from "../lib/memoriesSearch"; +import { KEYWORD_PAGE, keywordThenRanked, namesWriter, rowIdentity, rowIds } from "../lib/memoriesSearch"; // The fields the page and its cards read. Field names are a quarter of a row, so a field // the page does not read costs on every row. `sensitivity`, which marks a high row sent @@ -33,6 +34,9 @@ const MEMORIES_LIST_FIELDS = [ "verified_by", "verification", "status", + // The revision a hit's guidance was made for. + "version", + "version_text", ]; /** A tag and agent filter: what a search's keyword half reads with. */ @@ -76,6 +80,7 @@ function detailToEntry(key: string, d: MemoryDetail): MemoryListEntry { memory_type: d.memory_type || "semantic", confidence: d.confidence ?? 1, version: d.version ?? 0, + version_text: d.version_text ?? undefined, created_at: d.created_at || "", updated_at: d.updated_at ?? null, expires_at: d.expires_at ?? null, @@ -103,15 +108,16 @@ export function useMemorySearch( entries: MemoryListEntry[] | null, memoriesVersion: number, ) { - // Ordered array (not Set) to preserve the server's relevance ranking. - // Null = no active search. + // Ordered array (not Set) to preserve the server's relevance ranking. Each entry is a row's + // whole identity (`rowIdentity`), not its key: two rows of one key in different sessions + // are two rows. Null = no active search. const [searchHits, setSearchHits] = useState(null); // Per-hit ranking evidence: the server's `explanation` and `score_components`, keyed by - // memory_key, rendered under each card while a search is active so the list says why a + // the row's identity, rendered under each card while a search is active so the list says why a // row is there. const [searchWhy, setSearchWhy] = useState>(new Map()); // Full rows for search hits that fell outside the preloaded window, - // fetched on-demand so they still render (keyed by memory_key). + // fetched on-demand so they still render (keyed by the row's identity). const [searchExtra, setSearchExtra] = useState>(new Map()); const [searchAbstain, setSearchAbstain] = useState(null); // The rows whose value or key holds the typed text (newest first, ahead of the ranked @@ -175,6 +181,8 @@ export function useMemorySearch( } let cancelled = false; const ac = new AbortController(); + const idOf = (r: Parameters[1]) => rowIdentity(identity.namespace, r); + const idsOf = (r: Parameters[1]) => rowIds(identity.namespace, r); const t = setTimeout(async () => { setSearching(true); try { @@ -216,9 +224,13 @@ export function useMemorySearch( }).catch(() => null); if (cancelled) return; const kwEntries = kw?.entries ?? []; - const kwKeys = new Set(kwEntries.map((e) => e.memory_key)); - const have = new Set(entriesRef.current.map((e) => e.memory_key)); - const kwExtra = kwEntries.filter((e) => !have.has(e.memory_key)).map((e) => [e.memory_key, e] as const); + const kwOwn = kwEntries.map(idOf); + const kwKeys = new Set(kwOwn); + const have = new Set(entriesRef.current.map(idOf)); + // Every id a row the list holds answers to: a hit that names no writer is matched by + // any row of its key, and one that names it by that row alone. + const held = new Set([...entriesRef.current, ...kwEntries].flatMap(idsOf)); + const kwExtra = kwEntries.filter((e) => !have.has(idOf(e))).map((e) => [idOf(e), e] as const); setKeywordKeys(kwKeys); setKeywordFor(rawQuery.trim()); setKeywordTotal(kw?.total ?? 0); @@ -226,11 +238,11 @@ export function useMemorySearch( // the list does not shrink to the keyword rows and grow back after a write. Only // those the page or the keyword read holds: a copy read before a write is not today's. const shownKey = `${identity.org}/${identity.namespace}\n${rawQuery}`; - const kept = (rankedShownRef.current?.key === shownKey ? rankedShownRef.current.keys : []).filter( - (k) => have.has(k) || kwKeys.has(k), + const kept = (rankedShownRef.current?.key === shownKey ? rankedShownRef.current.keys : []).filter((k) => + held.has(k), ); if (kwKeys.size > 0) { - setSearchHits(keywordThenRanked([...kwKeys], kept)); + setSearchHits(keywordThenRanked(kwOwn, kept)); setSearchExtra(new Map(kwExtra)); if (kept.length === 0) setSearchWhy(new Map()); // Rows hold the words: no low-confidence note from an earlier query. @@ -248,20 +260,19 @@ export function useMemorySearch( // list goes back to the keyword rows and the next run keeps none of them. rankedShownRef.current = null; if (kept.length > 0) { - setSearchHits([...kwKeys]); + setSearchHits(kwOwn); setSearchExtra(new Map(kwExtra)); setSearchWhy(new Map()); } return; } const results = r.results || []; - const hits = keywordThenRanked( - kwEntries.map((e) => e.memory_key), - results.map((h) => h.memory_key), - ); - rankedShownRef.current = { key: shownKey, keys: results.map((h) => h.memory_key) }; + const hits = keywordThenRanked(kwOwn, results.map(idOf)); + rankedShownRef.current = { key: shownKey, keys: results.map(idOf) }; setSearchHits(hits); - setSearchWhy(new Map(results.map((h) => [h.memory_key, h] as const))); + // Only a hit that names its writer in full can be shown on a row: a hit without them + // is not told from another session's row of its key. + setSearchWhy(new Map(results.filter(namesWriter).map((h) => [idOf(h), h] as const))); // The server hedges (abstain) when the top hit is below threshold; // surface it so weak matches aren't read as confident answers. setSearchAbstain( @@ -270,29 +281,39 @@ export function useMemorySearch( // Server search spans the whole namespace, but the page only preloads // the top `limit` rows. Hydrate hits outside that window so they still // render, instead of being dropped by the key-set intersection below. - // agent="*" resolves the row regardless of which agent wrote it. - const missing = hits.filter((k) => !have.has(k) && !kwKeys.has(k)); - if (missing.length === 0) { + // agent="*" resolves the row regardless of which agent wrote it, but one row per + // key: a hit that names its writer takes that row only if it is the row it names, + // else it reads its own. + const unseen = results.filter((h) => !held.has(idOf(h))); + if (unseen.length === 0) { setSearchExtra(new Map(kwExtra)); return; } // One memory.bulk_get, not one memory.get per hit — the list path below already // reads this way. + const missing = [...new Set(unseen.map((h) => h.memory_key))]; const bulk = await bulkGetMemories({ ...identity, agent: "*" }, missing, { signal: ac.signal, }).catch(() => ({ results: {} as Record, missing, })); - const fetched = missing.map((k) => { - const d = bulk.results[k]; - return d ? detailToEntry(k, d) : null; - }); + const rowFor = async (h: SearchHit): Promise => { + const d = bulk.results[h.memory_key]; + const e = d ? detailToEntry(h.memory_key, d) : null; + if (e && idsOf(e).includes(idOf(h))) return e; + if (!namesWriter(h)) return null; + const own = { ...identity, agent: h.agent ?? "", user_id: h.user_id, session_id: h.session_id }; + const exact = await getMemory(own, h.memory_key, { signal: ac.signal }).catch(() => null); + const x = exact?.found ? detailToEntry(h.memory_key, exact) : null; + return x && idsOf(x).includes(idOf(h)) ? x : null; + }; + const fetched = await Promise.all(unseen.map(rowFor)); if (cancelled) return; setSearchExtra( new Map([ ...kwExtra, - ...fetched.filter((e): e is MemoryListEntry => e !== null).map((e) => [e.memory_key, e] as const), + ...fetched.filter((e): e is MemoryListEntry => e !== null).map((e) => [idOf(e), e] as const), ]), ); } catch { @@ -422,7 +443,10 @@ export function useMemoryListRead({ if (!live()) return; setBulkValues((prev) => { const next = new Map(prev); - for (const [k, d] of Object.entries(b.results)) next.set(k, d.value); + // By the row's own id: the one row bulk_get answers for a key may be a namesake's. + for (const [k, d] of Object.entries(b.results)) { + next.set(rowIdentity(identity.namespace, { ...d, memory_key: k }), d.value); + } return next; }); } catch { diff --git a/server/memory/app/search/anchor_pool.py b/server/memory/app/search/anchor_pool.py index 176c6a1f578..40fc226dd51 100644 --- a/server/memory/app/search/anchor_pool.py +++ b/server/memory/app/search/anchor_pool.py @@ -144,6 +144,7 @@ async def _anchor_rows_for_ns(ns: str) -> tuple[str, list[dict[str, Any]]]: memory_key=mk, memory_type=str(row.get("memory_type") or "semantic"), version=int(row.get("version") or 0), + status=str(row.get("status") or ""), content_excerpt=excerpt, distance=1.0 - sim, similarity=sim, diff --git a/server/memory/app/search/key_match.py b/server/memory/app/search/key_match.py index cab86256cef..508c37a1687 100644 --- a/server/memory/app/search/key_match.py +++ b/server/memory/app/search/key_match.py @@ -368,6 +368,7 @@ async def _rows_for_ns(ns: str) -> tuple[str, list[dict[str, Any]], bool]: memory_key=mk, memory_type=str(row.get("memory_type") or "semantic"), version=int(row.get("version") or 0), + status=str(row.get("status") or ""), content_excerpt=str(row.get("content_excerpt") or ""), distance=1.0 - sim, similarity=sim, diff --git a/server/memory/app/search/sql.py b/server/memory/app/search/sql.py index d4d9713c8e7..16b6317d915 100644 --- a/server/memory/app/search/sql.py +++ b/server/memory/app/search/sql.py @@ -113,6 +113,7 @@ def anchor_pool_sql(where_sql: str) -> str: e.agent AS agent, e.user_id AS user_id, e.version AS version, + e.status AS status, e.content_sha256 AS content_sha256, e.scope AS scope FROM loom.memory_embeddings AS e FINAL @@ -192,6 +193,7 @@ def key_match_sql(where_sql: str) -> str: e.user_id AS user_id, e.session_id AS session_id, e.version AS version, + e.status AS status, e.content_sha256 AS content_sha256, ifNull(e.source_resource_id, '') AS source_resource_id, toString(e.created_at) AS created_at, diff --git a/server/memory/store/sql.py b/server/memory/store/sql.py index 580f4a100b4..7786b421613 100644 --- a/server/memory/store/sql.py +++ b/server/memory/store/sql.py @@ -17,7 +17,9 @@ # Preserve short scalar values for the classifier without transferring arbitrary JSON. +# not a setting: the classifier reads scalars only, a wider field is substituted PROCEDURE_FIELD_MAX_BYTES = 128 +# not a setting: mirrors Python's own int() digit limit PROCEDURE_TOTAL_MAX_DIGITS = sys.get_int_max_str_digits() # Normalize the characters Python accepts in integer strings before checking the diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 690abb9a6e5..7fc47e6745b 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -36,7 +36,6 @@ 03e1950e2a26 SELECT org, namespace, agent, thread_id, msg_id, role, content, reasoning, user_id, run_id, metadata, tokens, ts FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND thread 03fb62bd1de3 ALTER TABLE loom.conversations UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {eras 041bf05dc2f6 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi -0428ee862f06 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 043eff8500c2 SELECT count() AS cnt, sum(numeric_value) AS s, avg(numeric_value) AS a, min(occurred_at) AS first_at, max(occurred_at) AS last_at FROM loom.derived_facts WHERE org = {org:String} AND namespace = {ns: 0449aa3acc7f ALTER TABLE loom.session_summaries UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = { 0456d239d20d ALTER TABLE loom.memory_extraction_queue DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sy @@ -113,6 +112,7 @@ 0cfc88297bf0 SELECT count() AS n FROM loom.knowledge_ingestions WHERE org = {org:String} AND namespace = {ns:String} 0d0074d068cf SELECT queue_id, agent, user_id, session_id, status, attempts, message_count, content_chars, written, last_error, enqueued_at, updated_at FROM loom.memory_extraction_queue FINAL PREWHERE org = {org:St 0d876bb77e37 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi +0da3d59aa537 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 0db9931937d8 SELECT count() AS n FROM loom.memory WHERE org = {org:String} AND has(tags, ?) AND hasAny(tags, {src:Array(String)}) AND hasAny(arrayMap(t -> (namespace, t), tags), {pairs:Array(Tuple(String, String)) 0de354fc6495 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 0df388be7e18 SELECT count() AS n FROM loom.memory_projection_failures WHERE org = {org:String} AND (JSONExtractString(payload, ?) = {uid:String} OR arrayExists(e -> JSONExtractString(e, ?) = {uid:String}, JSONExtr @@ -283,12 +283,12 @@ 2369b3e3394b SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em 23a1ed94437f SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 23c7e58243f2 SELECT count() AS n FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} +23d27438e361 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 241610b30143 SELECT count() AS n FROM loom.session_briefs WHERE org = {org:String} AND namespace = {ns:String} 24168bc01a22 SELECT concat(?, toString(c.session_id), ?, toString(c.chunk_index)) AS memory_key, ? AS memory_type, substring(c.content, ?, ?) AS content_excerpt, c.content AS content_full, c.agent AS agent, c.user 241769ad1a52 SELECT count() AS n FROM loom.datasets WHERE org = {org:String} AND namespace = {ns:String} 242bfccd9b35 SELECT test_name, sum(runs) AS runs_in_window, sum(fails) AS fails_in_window, count() OVER () AS matches FROM loom.qa_test_daily FINAL WHERE org = {org:String} AND qa_namespace = {ns:String} AND day > 2430fc6260ce SELECT count() AS n FROM loom.entity_edge_memories WHERE org = {org:String} AND ((namespace, memory_key) IN (SELECT namespace, memory_key FROM loom.memory WHERE org = {org:String} AND user_id = {uid:S -243925f6a914 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 2448faf35e3e SELECT DISTINCT src_path FROM loom.code_test_map FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL 244b76b58819 ALTER TABLE loom.memory UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_ta 246241942bf7 SELECT chunk_id, path, scope, kind, start_line, end_line, content, symbol_ids, context_description, arraySum(arrayMap((tok, idf) -> idf * countSubstrings(concat(?, lexemes, ?), concat(?, tok, ?)), {to @@ -377,7 +377,6 @@ 2d4f8542a110 SELECT c.session_id AS session_id, c.chunk_index AS chunk_index, c.parent_memory_key AS parent_memory_key, cosineDistance(c.embedding, {q:Array(Float32)}) AS distance FROM loom.memory_chunks AS c WHER 2d6b480eb809 SELECT path, scope, symbol_ids, kind, start_line, end_line, content, embedding_model, shingles, uniqExact(path) OVER () AS admitted_files FROM ( SELECT path, scope, symbol_ids, kind, start_line, end_l 2d7e54998a72 SELECT count() AS n FROM loom.entity_degree WHERE org = {org:String} AND namespace = {ns:String} AND ? -2d926c174d09 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 2db7427080f4 SELECT count() AS n FROM loom.documents FINAL WHERE org = {org:String} AND namespace = {ns:String} AND (superseded_at IS NULL OR (blob_path != ? AND blob_erased_at IS NULL)) 2dcb55a8b062 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 2e457daf2af4 WITH docs AS ( SELECT thread_id, msg_id, any(role) AS msg_role, argMax(content, ts) AS body, max(ts) AS saved_at, arrayFilter(t -> length(t) >= ?, splitByNonAlpha(lowerUTF8(body))) AS words FROM loom. @@ -459,6 +458,7 @@ 362f57a395d3 SELECT org, namespace FROM loom.code_symbol_stats WHERE org IN {orgs:Array(String)} AND namespace IN {namespaces:Array(String)} GROUP BY org, namespace 364f0a02ff40 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em 3696ba20e278 SELECT leftPad(lower(hex(groupBitXor(sipHash64(memory_id, content_sha256, confidence, coalesce(valid_at, updated_at))))), ?, ?) AS digest, count() AS n FROM loom.memory FINAL WHERE org = {org:String} +36b071df73a0 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 36c56add9f31 SELECT issue_number, max(computed_at) AS latest FROM loom.qa_link_candidates FINAL WHERE org = {org:String} AND qa_namespace = {ns:String} AND issue_number IN {nums:Array(UInt32)} GROUP BY issue_numbe 37222534b76c SELECT count() AS n FROM loom.knowledge_source_listings WHERE org = {org:String} AND namespace IN {ns:Array(String)} 3724de63d653 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em @@ -474,6 +474,7 @@ 38785f9683a4 SELECT count() AS n FROM loom.conversation_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL 387a67a7636a SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 388d90f60983 ALTER TABLE loom.code_search_trace DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? +389b03d6e5b0 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 38bfb0862017 SELECT chunk_id, path, kind, start_line, end_line FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embedding_model = {model:String} AND tombstoned_at IS NULL AND pa 38d2fca41ece SELECT org, namespace, agent, user_id, session_id, run_id, goal, user_request, expected_outcome, environment, model, consumer, status, started_at, completed_at, duration_ms, final_response, confidence 39020388c332 ALTER TABLE loom.knowledge_group_members DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? @@ -518,7 +519,6 @@ 3e750c517754 SELECT count() AS n FROM loom.memory_chunk_sources FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL 3ea44fb37980 ALTER TABLE loom.session_briefs DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 3eb6ce41ac13 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, toString(valid_at) AS valid_at, version FROM loom.memory_embeddings FINAL WHERE org = { -3edbc579bc32 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 3edbd7919101 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 3edbe1bd76ea SELECT DISTINCT scope, symbol_ids, kind, start_line, end_line, content, toString(indexed_commit) AS indexed_commit FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND 3ef866fb71ee SELECT (SELECT count() FROM ( SELECT org, namespace, agent, user_id, session_id, memory_key, embedding_model, length(embedding) AS vector_len FROM loom.memory_embeddings FINAL WHERE tombstoned_at IS N @@ -623,6 +623,7 @@ 49bd450f5650 SELECT tag, count() AS rows FROM (SELECT arrayJoin(tags) AS tag FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND user_id != {id:String}) GROUP 49c788209c09 SELECT count() AS n FROM loom.documents FINAL WHERE org = {org:String} AND user_id = {uid:String} AND (superseded_at IS NULL OR (blob_path != ? AND blob_erased_at IS NULL)) 49d358039870 SELECT c.session_id AS session_id, c.chunk_index AS chunk_index, c.parent_memory_key AS parent_memory_key, cosineDistance(c.embedding, {q:Array(Float32)}) AS distance FROM loom.memory_chunks AS c WHER +49d8f0bc513a SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 49e68b2fe0ca ALTER TABLE loom.memory_chunk_sources DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 49f3550b2531 SELECT count() OVER () AS total, memory_key, toString(memory_id) AS memory_id, agent, evidence FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND 4a071fdc1ffe SELECT count() AS cnt, sum(numeric_value) AS s, avg(numeric_value) AS a, min(occurred_at) AS first_at, max(occurred_at) AS last_at FROM loom.derived_facts WHERE org = {org:String} AND namespace = {ns: @@ -674,7 +675,6 @@ 51af520b7286 SELECT DISTINCT tier, qualified_name, symbol_id FROM loom.code_symbol_names WHERE org = {org:String} AND namespace = {ns:String} AND name IN {names:Array(String)} AND (qualified_name = {full:String} O 51f662fe04fe SELECT count() AS n FROM loom.learnings_queue WHERE org = {org:String} AND candidate_id IN {cids:Array(UUID)} AND status = ? 52083af6b301 SELECT count() AS n FROM system.mutations WHERE database = {db:String} AND table = {t:String} AND NOT is_done -52299eeb065a SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 52448e9cfd6b ALTER TABLE loom.memory_record_conflicts UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {er 524493debfe9 SELECT count() AS n FROM loom.datasets WHERE org = {org:String} AND namespace IN {ns:Array(String)} 52469ce6ebab SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em @@ -699,6 +699,7 @@ 541a4c06fca2 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, created_at, valid_at, version, status FROM ( SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, t 542242ea89a0 SELECT chunk_id, path, scope, kind, start_line, end_line, content, symbol_ids, context_description, arraySum(arrayMap((tok, idf) -> idf * countSubstrings(concat(?, lexemes, ?), concat(?, tok, ?)), {to 544bda275e23 ALTER TABLE loom.memory_code_link_queue DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? +546954f23e3a WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 548b3de5bbd4 SELECT memory_key, toString(memory_id) AS mid, content_sha256, agent, memory_type, -- a high value is readable by key only if(sensitivity = ?, ?, substring(value, ?, ?)) AS preview, sensitivity, tags, 549dd1314271 SELECT count() AS n FROM loom.conversation_embeddings FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL 54a586d86d34 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi @@ -776,7 +777,6 @@ 5aa9a77dc0c1 SELECT count() AS n FROM loom.context_blobs FINAL WHERE org = {org:String} AND namespace = {ns:String} 5ab4520a4503 SELECT count() AS n FROM loom.memory_webhook_outbox WHERE org = {org:String} AND namespace = {ns:String} 5ad558ab68b9 ALTER TABLE loom.memory_reinforcement DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync -5adce2281ff5 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 5b18ec31d5f5 DELETE FROM loom.chunks WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS lightweight_deletes_sync = ? 5b39f4c73106 SELECT memory_key, record_json, created_at, (memory_key, identity_agent, user_id, session_id) IN ( SELECT memory_key, agent, user_id, session_id FROM loom.memory FINAL WHERE org = {org:String} AND nam 5b82b22d8ce2 SELECT namespace, source_uri FROM loom.documents FINAL WHERE org = {org:String} AND (namespace, source_uri) IN {pairs:Array(Tuple(String, String))} LIMIT {limit:UInt32} @@ -800,9 +800,11 @@ 5e12540e53d7 SELECT memory_key, memory_type, content_excerpt, ? - cosineDistance(embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(temporal_anchor, toDateTime(?))) AS temporal_anchor, temporal_confi 5e16a6e73beb WITH all_time AS ( SELECT agent, min(ts) AS first_seen FROM (SELECT raw.ts AS ts, raw.org AS org, raw.namespace AS namespace, raw.agent AS agent, raw.user_id AS user_id, raw.session_id AS session_id, 5e685e7d200a ALTER TABLE loom.search_misses DELETE WHERE (org = {org:String} AND (has({spellings:Array(String)}, asker) OR has({spellings:Array(String)}, lowerUTF8(user_id)))) AND ({erasure_mutation_tag:String} = +5e85b0705cfc SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 5e8b03fa60c0 SELECT session_id FROM loom.session_summaries FINAL WHERE org = {org:String} AND namespace = {ns:String} AND agent = {agent:String} AND user_id = {uid:String} AND tombstoned_at IS NULL AND session_id 5e902d2cb6ad SELECT memory_id, org, namespace, agent, user_id, session_id, memory_key, memory_type, if(length(toString(value_json)) > ?, toString(value_json), value) AS value, -- The stored bytes, for version rows 5e9d05fdddf9 SELECT * FROM loom.code_scip_batches FINAL WHERE org = {org:String} AND namespace = {ns:String} AND batch_id = {bid:UUID} +5ef337e60c57 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 5f07507d00b9 INSERT INTO loom.chunk_supersessions (org, namespace, embedding_model, source_uri, doc_version, superseded_at) SELECT DISTINCT org, namespace, embedding_model, source_uri, doc_version, {when:DateTime} 5f0aadd21dd2 ALTER TABLE loom.memory_belief_sources UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND (namespace, memory_key) IN {keys:Array(Tuple(String, String))}) AND 5f3660ea1130 SELECT agent, user_id, session_id, memory_key, version_now, tombstoned_now, version_at FROM ( SELECT agent, user_id, session_id, memory_key, version AS version_now, toUInt8(tombstoned_at IS NOT NULL) @@ -869,6 +871,7 @@ 65aa1f17328b SELECT count() AS n FROM loom.memory_categories FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} 65c31ffcda22 SELECT count() AS n FROM loom.entity_edge_rows WHERE org = {org:String} AND namespace = {ns:String} AND ? 65e630aa6409 SELECT count() AS n FROM loom.code_files FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND index_error != ? +660d66f787c7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 663c96bc8c2e SELECT count() AS cnt, sum(numeric_value) AS s, avg(numeric_value) AS a, min(occurred_at) AS first_at, max(occurred_at) AS last_at FROM loom.derived_facts WHERE org = {org:String} AND namespace = {ns: 666fcf41eb4a SELECT concat(?, toString(c.session_id), ?, toString(c.chunk_index)) AS memory_key, ? AS memory_type, substring(c.content, ?, ?) AS content_excerpt, c.content AS content_full, c.agent AS agent, c.user 66a80f4706a4 ALTER TABLE loom.operator_edges DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? @@ -879,6 +882,7 @@ 6765755688ca SELECT kind, name, status, description, cardinality, created_by, updated_at FROM loom.namespace_ontology FINAL WHERE org = {org:String} AND namespace = {ns:String} AND status = {status:String} ORDER B 679aaca08b74 SELECT memory_id, org, namespace, agent, user_id, session_id, memory_key, memory_type, if(length(toString(value_json)) > ?, toString(value_json), value) AS value, -- The stored bytes, for version rows 67b04af64852 SELECT DISTINCT namespace FROM loom.documents WHERE org = {org:String} AND user_id = {uid:String} ORDER BY namespace +67c496799de1 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 67d9d7708ec1 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em 680c3774ab86 SELECT namespace, source_uri, chunk_idx, doc_version, JSONExtractUInt(chunk_metadata, ?) AS revision, cosineDistance(embedding, {q:Array(Float32)}) AS distance, ? AS lexical, arrayIntersect(keys, {key 680d46eea97c SELECT count() AS n FROM loom.memory_record_fields FINAL WHERE org = {org:String} AND tombstoned_at IS NULL AND record_id IN {ids:Array(UUID)} @@ -886,6 +890,7 @@ 687082296f51 SELECT count() AS n FROM loom.chunks WHERE org = {org:String} AND user_id = {uid:String} AND doc_superseded_at IS NULL AND (org, namespace, embedding_model, source_uri, doc_version) NOT IN (SELECT org 687db7744a91 WITH agent = {agent:String} AND tombstoned_at IS NULL AS live SELECT countIf(live AND embedding_model = {model:String} AND embedding_dim > ?) AS current, countIf(live AND (NOT is_saved OR user_id != { 68f8108c8eb8 SELECT symbol_id, qualified_name, path, fan_in_calls, fan_in_nontest, fan_in_name, caller_files, defined_files, is_test FROM loom.code_symbol_stats FINAL WHERE org = {org:String} AND namespace = {ns:S +69137636ed1e SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 69721a6b8e46 SELECT count() AS n FROM loom.conversations WHERE org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String} 6983b4c8b3a8 SELECT start_line, end_line, content, context_description FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND path = {path:String} AND tombstoned_at IS NULL ORDER BY s 69ad2d1a3b4a SELECT count() AS n FROM loom.memory_webhook_outbox WHERE org = {org:String} AND user_id = {uid:String} AND event_type != ? @@ -905,7 +910,6 @@ 6b4932fdfd22 ALTER TABLE loom.conflict_allowlist DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 6b6d53e64bd0 ALTER TABLE loom.entity_edges DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 6bb6c2026cc3 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi -6bca142f2071 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 6bca66927292 SELECT min(ts) AS first_ts, count() AS n FROM loom.audit_log 6c17c9f6e702 SELECT org, namespace, agent, thread_id, msg_id, role, content, reasoning, user_id, run_id, metadata, tokens, ts FROM loom.conversations WHERE org = {org:String} AND namespace IN {nss:Array(String)} A 6c1cb0579e58 SELECT entity, community_id FROM loom.entity_communities FINAL WHERE org = {org:String} AND namespace IN {nss:Array(String)} AND level = ? AND entity IN {ents:Array(String)} AND (namespace, computed_a @@ -924,13 +928,11 @@ 6daa2655ee73 SELECT count() AS n FROM loom.entity_degree WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? 6e07272917e3 SELECT count() AS n FROM loom.memory_versions WHERE org = {org:String} AND namespace = {ns:String} AND ? 6e1154b224c2 SELECT *, hex(SHA256(toJSONString((value_json, value)))) AS body_sha FROM (SELECT org, namespace, agent, user_id, session_id, ? AS actor, concat(?, queue_id) AS memory_key, version, ? AS value_json, t -6e4bc0b8e97e SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 6e5c949aa6b7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em 6e5e297bbb30 SELECT count() AS n FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND status != ? AND tombstoned_at IS NULL AND status != ? AND agent = {agent:String} AND user_id = {uid: 6e894706d089 SELECT count() AS n FROM loom.code_search_outcome WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? 6e90fc205193 SELECT org, namespace, agent, user_id, session_id, memory_key FROM ( SELECT DISTINCT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory WHERE tombstoned_at IS NULL AND (arrayExist 6eac9c7cf08e DELETE FROM loom.session_summaries WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS lightweight_deletes_sync -6ebb660d0149 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 6f025f927273 SELECT count() AS n FROM loom.knowledge_ingestions WHERE org = {org:String} AND user_id = {uid:String} 6f11f5e87057 SELECT DISTINCT path FROM loom.code_symbols FINAL WHERE org = {org:String} AND namespace = {ns:String} AND symbol_id IN {ids:Array(String)} AND tombstoned_at IS NULL 6f342325636b SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em @@ -999,7 +1001,6 @@ 765404bd5d8d SELECT toDate(coalesce(temporal_anchor, valid_at)) AS event_date, cosineDistance(embedding, {q:Array(Float32)}) AS distance, substring(content_excerpt, ?, ?) AS excerpt, memory_key, temporal_anchor IS 7662b4971175 SELECT org, namespace, agent, user_id, session_id, memory_id, memory_key, memory_type, value, confidence, source_trace, version, tombstoned_at, created_at, expires_at, sensitivity FROM loom.memory FIN 76f47ab9df72 SELECT ? AS present FROM loom.code_caller_guards WHERE org = {org:String} AND namespace = {ns:String} LIMIT ? -7741f7211298 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 77424b91d322 SELECT count() AS n FROM loom.memory FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} 778a3bb04c67 SELECT namespace, source_uri, title, description, tags, ingested_at, superseded_at, blob_path, blob_size, toString(blob_content_type) AS blob_content_type, original_filename, content_preview FROM loom 7799bb45ee57 SELECT ? FROM loom.memory_refusals WHERE org={org:String} AND ((scope_kind IN (?,?) AND scope_value={ns:String} AND user_id={uid:String}) OR (scope_kind=? AND scope_value={ns:String}) OR (scope_kind=? @@ -1078,6 +1079,7 @@ 7d43341a2607 ALTER TABLE loom.blacklist UPDATE tombstoned_at = {ts:DateTime} WHERE pattern_id = {pid:UUID} SETTINGS mutations_sync=? 7d5addfa6536 SELECT path, scope, symbol_ids, kind, start_line, end_line, content, embedding_model, toString(indexed_commit) AS indexed_commit FROM ( SELECT path, scope, symbol_ids, kind, start_line, end_line, cont 7d82a831fe45 SELECT count() AS n FROM loom.scim_users FINAL WHERE deleted = ? AND has(work_addresses, {a:String}) +7d8a1fc52d01 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 7dafb5876695 WITH reversals AS ( SELECT erasure_id, count() AS n FROM loom.erasure_reversals FINAL WHERE org = {org:String} GROUP BY erasure_id ) SELECT e.id AS id, e.scope_type AS scope_type, e.scope_value AS sco 7dd6dd6493db SELECT chunk_id, path, scope, kind, start_line, end_line, content, symbol_ids, context_description FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embedding_model 7dd8e38c2d91 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi @@ -1087,7 +1089,6 @@ 7e34abf20d24 ALTER TABLE loom.memory_record_versions DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_syn 7e726e6f73c0 SELECT model, count() AS turns, uniqExact(session_id) AS sessions, sum(toUInt64(input_tokens)) AS input_tokens, sum(toUInt64(cache_read_tokens)) AS cache_read_tokens, sum(toUInt64(cache_creation_5m_to 7ebae0c83ac1 SELECT symbol_id, qualified_name, name, signature, path, start_line, end_line, tier, kind, toString(indexed_commit) AS extent_commit FROM loom.code_symbols FINAL WHERE org = {org:String} AND namespace -7ec811abe7fb SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 7eccab6dfda3 SELECT org, namespace, name, source_id, kind, source_kind, config_json, items_json, credential_enc, secret_enc, access, credential_mode, owner_subject, connection_id, created_by, active, pending_delet 7ed9e5f6ceb3 ALTER TABLE loom.memory_chunk_sources UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasu 7eea2ee7caf9 SELECT memory_key, (status != ? OR tombstoned_at IS NOT NULL OR redacted_at IS NOT NULL) AS taken_out FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND agent = {agent:Str @@ -1133,6 +1134,7 @@ 82335d7ebcd4 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 824960aa6a71 SELECT DISTINCT path, kind, scope, start_line, end_line FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND path IN {paths:Array(String)} AND tombstoned_at IS NULL ORD 82554a8768f6 SELECT DISTINCT toString(record_id) AS id FROM (SELECT record_id FROM loom.memory_records WHERE org = {org:String} AND user_id = {uid:String}) +827318210a93 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 82ab558f7ff1 SELECT * FROM loom.scim_users FINAL WHERE lowerUTF8(user_name) = lowerUTF8({n:String}) AND deleted = ? LIMIT ? 82bcb1da6f37 SELECT chunk_id, path, scope, kind, start_line, end_line, embedding_dim, arraySum( arrayMap( (tok, idf) -> idf * countSubstrings( concat(?, lexemes, ?), concat(?, tok, ?) ), {tokens:Array(String)}, {i 82c613217f47 SELECT DISTINCT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory WHERE tombstoned_at IS NULL AND sensitivity = ? AND (expires_at IS NULL OR expires_at > now()) AND (match(value, @@ -1153,7 +1155,6 @@ 8452df8453eb DELETE FROM loom.memory_embeddings WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS lightweight_deletes_sync = ? 847f10f435b6 SELECT memory_id, memory_key, memory_type, version, pinned, created_at, conflict_with, sensitivity FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND status = ? AND tombst 8483426b1032 SELECT hit.? - ? AS qidx, m.memory_id, m.memory_key, m.value, m.pinned, m.agent, m.user_id, m.session_id, m.run_id, m.valid_at, hit.? AS dist FROM loom.memory m FINAL JOIN loom.memory_embeddings e FIN -84ade6ed4e28 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 84bdbba6f76c ALTER TABLE loom.knowledge_gaps DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 84c7b32e7dac ALTER TABLE loom.agent_events UPDATE user_id = ?, memory_key = if(memory_key = ?, ?, ?), args = mapApply((k, v) -> (k, if(k IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?), ?, v)), args), subject = if(s 84cf65787e43 SELECT count() AS n FROM loom.entity_edge_rows WHERE org = {org:String} AND user_id = {uid:String} AND memory_id NOT IN (SELECT memory_id FROM loom.memory FINAL WHERE org = {org:String} AND memory_id @@ -1162,6 +1163,7 @@ 850f03574fca ALTER TABLE loom.memory_records UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_muta 851e78aa71dd SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 855313d7b202 SELECT chunk_id, path, scope, kind, start_line, end_line, content, symbol_ids, context_description, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.code_chunks FINAL WHERE org = {o +855a489f558b SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 85652b8c731b SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, version FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns: 856947cf2e72 SELECT org, namespace, agent, user_id, thread_id, title, metadata, run_id, created_at, updated_at, tombstoned_at FROM loom.conversation_threads FINAL WHERE org = {org:String} AND user_id = {scope:Stri 8584bd0bafdd SELECT pr_number, merge_sha, payload, sections, built_at, indexed_commit, tokens, build_ms FROM loom.code_review_briefs FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS @@ -1170,14 +1172,17 @@ 85ce76cd2328 SELECT toString(evidence_id) AS eid, session_id, role, actor, toString(observed_at) AS observed, content, matched FROM ( SELECT evidence_id, session_id, role, actor, observed_at, content, tombstoned_a 85ee2e16a9d4 DELETE FROM loom.memory_evidence WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS lightweight_deletes_sync = ? 8634a9a7a9c9 SELECT * FROM loom.code_summaries FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embedding_model = {model:String} AND tombstoned_at IS NULL +863a76f3589e SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 865e068c8b5a SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi 866daec00d3d SELECT worker, instance_label, argMax(namespace, version) AS namespace, argMax(process, version) AS process, argMax(build_commit, version) AS build_commit, argMax(pass_started, version) AS last_starte 8670b419f394 SELECT DISTINCT path FROM loom.code_symbols FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tier = ? AND path IN {paths:Array(String)} AND tombstoned_at IS NULL 8679f24b8161 SELECT DISTINCT content_sha256 AS t FROM loom.memory_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND agent = {a:String} AND user_id = {u:String} AND parent_memory_key = {k:String +86982463c657 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 86c577a1b8e4 SELECT concat(?, toString(c.session_id), ?, toString(c.chunk_index)) AS memory_key, ? AS memory_type, substring(c.content, ?, ?) AS content_excerpt, c.content AS content_full, c.agent AS agent, c.user 87050a4708a4 SELECT count() AS n FROM loom.delete_version_checks WHERE org = {org:String} AND namespace = {ns:String} AND ? 8710a0088ece SELECT count() AS n FROM loom.knowledge_source_listings WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? 874a1036a795 SELECT hour, failing_tests, failing_prs FROM loom.qa_fail_hours FINAL WHERE org = {org:String} AND qa_namespace = {ns:String} AND hour IN {hours:Array(DateTime)} ORDER BY hour +874db5b802ac SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 87807e9276ba SELECT revision, count() AS total, countIf(ok) AS ok FROM loom.procedure_runs WHERE org = {org:String} AND namespace = {ns:String} AND memory_key = {key:String} GROUP BY revision 878eb1ccb396 SELECT org, namespace, agent, user_id, session_id, memory_key, memory_type, embedding_model, embedding, version, content_sha256, status FROM loom.memory_embeddings FINAL WHERE (org, namespace, agent, 87f6acbd04a9 SELECT count() AS n FROM loom.search_misses WHERE org = {org:String} AND (has({spellings:Array(String)}, asker) OR has({spellings:Array(String)}, lowerUTF8(user_id))) @@ -1189,8 +1194,6 @@ 888f7269df70 ALTER TABLE loom.memory_exposures DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 88c56985a4c0 SELECT memory_id, org, namespace, agent, user_id, session_id, memory_key, memory_type, if(length(toString(value_json)) > ?, toString(value_json), value) AS value, -- The stored bytes, for version rows 88cf97ec1c79 SELECT path, scope, symbol_ids, kind, start_line, end_line, content, embedding_model, toString(indexed_commit) AS indexed_commit FROM ( SELECT path, scope, symbol_ids, kind, start_line, end_line, cont -88e81d882ce9 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ -88f048234fd7 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 8915a58efbcd SELECT namespace, toString(memory_id) AS canonical_id, memory_key, memory_type, value, tags, version, agent, session_id, user_id, source_class, sensitivity, toString(created_at) AS created_at, toStrin 891d25765442 SELECT count() AS n FROM loom.shared FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} 892d86b3df6a SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi @@ -1204,6 +1207,7 @@ 89d751dde263 INSERT INTO loom.memory_records (record_id, org, namespace, schema_id, schema_name, memory_key, memory_id, identity_agent, user_id, session_id, record_json, status, valid_at, valid_to, version, create 89f40a73fa83 SELECT memory_id, org, namespace, agent, user_id, session_id, memory_key, version, value, toString(value_json) AS object_text FROM loom.memory FINAL WHERE tombstoned_at IS NULL AND sensitivity = ? AND 8a1fca063e7f SELECT org, agent, count() AS calls, countIf(if(consumer = ?, args[?], consumer) NOT IN {untagged:Array(String)}) AS tagged, calls - tagged AS untagged, round(tagged / calls, ?) AS tagged_ratio, anyIf +8a27e7aee7f9 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA 8a44f1b04017 SELECT count() AS n FROM loom.entity_triple_rows WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND memory_id NOT IN (SELECT memory_id FROM loom.memory FINAL WHERE org = {org:String} AND 8a5fb93b3273 SELECT agent, user_id, session_id, embedding_model, summary_text, key_facts, derived_from, valid_at, created_at, version, length(key_facts) AS kf, length(derived_from) AS df, coalesce(valid_at, create 8a725f267f59 SELECT count() AS n FROM loom.memory_reinforcement WHERE org = {org:String} AND namespace = {ns:String} AND ? @@ -1213,7 +1217,6 @@ 8ad70124595a SELECT count() AS rows FROM (SELECT memory_key FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND has(tags, {tag:String}) AND user_id = {scope_ui 8ae68d92a46b ALTER TABLE loom.agent_runs DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 8aee13cb4e2b SELECT block_key, content, char_limit, version, created_at, updated_at FROM loom.working_memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND agent = {agent:String} AND user_id = {uid -8afa9497d79f SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 8b04eea55270 SELECT ? AS ok FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND agent = {agent:String} AND thread_id = {tid:String} AND msg_id = {mid:String} AND (tombstoned_at IS NULL 8b1ba071278d SELECT src_path, test_path FROM loom.code_test_map FINAL WHERE org = {org:String} AND namespace = {ns:String} AND method = ? AND tombstoned_at IS NULL 8b1f0c94aff4 SELECT def_path, count() AS prs FROM ( SELECT arrayJoin(arrayIntersect(files, {defs:Array(String)})) AS def_path FROM loom.code_pr_history FINAL WHERE org = {org:String} AND namespace = {ns:String} AN @@ -1225,7 +1228,6 @@ 8c4085ac57cd SELECT count() AS n FROM loom.agent_runs WHERE org = {org:String} AND user_id = {uid:String} 8c6970ca28d8 ALTER TABLE loom.documents DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 8c79073411db SELECT count() AS documents, countIf((JSONExtractInt(coverage, ?) < JSONExtractInt(coverage, ?) OR JSONLength(coverage, ?) > ? OR length(arrayDistinct(JSONExtract(coverage, ?, ?))) > ?)) AS incomplete -8cc056d030e9 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 8cec1ec85b20 SELECT uniqExact(path) AS n FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embedding_model = {model:String} AND tombstoned_at IS NULL AND (lower(content) LIKE {sc 8d0c32e0be04 ALTER TABLE loom.memory_records DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 8d3e30521d95 ALTER TABLE loom.memory_chunk_sources UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} @@ -1298,10 +1300,10 @@ 94d67f0b9067 SELECT tag, count() AS rows FROM (SELECT arrayJoin(tags) AS tag FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND session_id = {id:String}) GROU 94ec0e54485d SELECT count() AS n FROM loom.delete_version_checks WHERE org = {org:String} AND namespace IN {ns:Array(String)} 950a23399a82 ALTER TABLE loom.agent_run_claims DELETE WHERE org = {org:String} AND namespace IN {ns:Array(String)} +9536bf5d11a7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 956295581aed SELECT count() AS n FROM loom.entity_summaries FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND tombstoned_at IS NULL 9568a0ca0e47 ALTER TABLE loom.conversation_threads DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? 9610f3c84686 SELECT org, namespace, agent, user_id, session_id, scope, embedding_model, memory_key FROM loom.memory_embeddings WHERE (org, namespace, agent, user_id, session_id, scope, embedding_model, memory_key) -961f343c4187 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 96291ba85a09 SELECT DISTINCT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory WHERE tombstoned_at IS NULL AND sensitivity = ? AND (expires_at IS NULL OR expires_at > now()) AND (match(value, 9648988c847c SELECT count() AS n FROM loom.documents FINAL WHERE org = {org:String} AND namespace = {ns:String} 96a4e124aaa7 SELECT agent, user_id, session_id, memory_key, memory_type, content_excerpt, toString(created_at) AS created_at, toString(valid_at) AS valid_at, version FROM loom.memory_embeddings FINAL WHERE org = { @@ -1359,7 +1361,6 @@ 9cea5db2333b SELECT m.org, m.namespace, m.agent, m.user_id, m.session_id, m.memory_key FROM loom.memory AS m FINAL LEFT ANTI JOIN ( SELECT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory_em 9d336f6da7c7 SELECT uniqExact(embedding_model, chunk_idx) AS chunk_count FROM loom.chunks WHERE org = {org:String} AND namespace = {ns:String} AND source_uri = {uri:String} AND JSONExtractUInt(chunk_metadata, ?) = 9d4138cd6c9a SELECT src_path, max(confidence) AS best_confidence FROM loom.code_test_map FINAL WHERE org = {org:String} AND namespace = {ns:String} AND test_path IN {paths:Array(String)} AND tombstoned_at IS NULL -9dabac51648b SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ 9daeeb2ab9a4 SELECT org, namespace, memory_key, status, tombstoned_at FROM loom.memory FINAL WHERE tombstoned_at IS NOT NULL AND status != ? 9dafb689b559 SELECT DISTINCT cityHash64(namespace, source_uri) AS h FROM loom.documents FINAL WHERE org = {org:String} AND user_id = {uid:String} 9de706c43448 SELECT count() AS n FROM loom.query_nodes WHERE org = {org:String} AND namespace IN {ns:Array(String)} @@ -1468,6 +1469,7 @@ a79a82c3db28 SELECT memory_id, org, namespace, agent, user_id, session_id, memor a7a1906eebe4 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi a7e930ac6777 SELECT toDate(coalesce(temporal_anchor, valid_at)) AS event_date, cosineDistance(embedding, {q:Array(Float32)}) AS distance, substring(content_excerpt, ?, ?) AS excerpt, memory_key, temporal_anchor IS a7eae857d8a7 SELECT src_path, test_path, max(confidence) AS confidence FROM loom.code_test_map FINAL WHERE org = {org:String} AND namespace = {ns:String} AND src_path IN {paths:Array(String)} AND tombstoned_at IS +a7ebac4d7e47 WITH (SELECT toFloat64(count()) FROM loom.memory_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL) AS n_keys, (SELECT mapFromArrays(groupArray(s), groupA a819ade52d8a SELECT org, namespace, source_uri, version, revision, title, ingested_at, superseded_at, if(format != ?, toString(format), if(if(JSONType(metadata, ?) = ?, JSONExtractString(metadata, ?), ?) != ?, if( a8284084f144 SELECT org, namespace, agent, user_id, session_id, memory_key, memory_id, version, source_class, status, requires_review, content_sha256, verified_by, verified_at, verified_sha256, sensitivity, tombst a85f83c11660 SELECT count() AS n FROM loom.memory_chunk_sources FINAL WHERE org = {org:String} AND (namespace, memory_key) IN (SELECT namespace, memory_key FROM loom.memory WHERE org = {org:String} AND user_id = { @@ -1476,7 +1478,6 @@ a87fec167d96 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e. a883073e33de SELECT count() AS n, if(n = ?, NULL, max(created_at)) AS latest FROM loom.memory_webhooks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND is_deleted = ? a8b303321d91 SELECT c.session_id AS session_id, c.chunk_index AS chunk_index, c.parent_memory_key AS parent_memory_key, cosineDistance(c.embedding, {q:Array(Float32)}) AS distance FROM loom.memory_chunks AS c WHER a8c6e74f4e8d SELECT event_type, count() AS cnt, min(ts) AS first_ts, max(ts) AS last_ts FROM loom.audit_log WHERE ts >= toDateTime64(now() - INTERVAL {since:UInt32} SECOND, ?, ?) AND NOT match(namespace, ?) AND or -a8cde78b5dd1 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ a8e1a646e7fb SELECT chunk_id, path, scope, kind, start_line, end_line, content, symbol_ids, context_description, arraySum(arrayMap((tok, idf) -> idf * countSubstrings(concat(?, lexemes, ?), concat(?, tok, ?)), {to a8ec5648cd39 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi a8ef32fbad8c SELECT content_sha256, count() AS chunk_count, uniqExact(source_uri) AS uri_count, groupArray(?)((source_uri, chunk_idx)) AS samples FROM loom.chunks WHERE org = {org:String} AND namespace = {ns:Strin @@ -1486,7 +1487,6 @@ a92198f269fa SELECT day, runs, fails, prs, groups, steps, flips, same_commit_fli a937609f7c0d SELECT memory_id, org, namespace, agent, user_id, session_id, memory_key, memory_type, if(length(toString(value_json)) > ?, toString(value_json), value) AS value, -- The stored bytes, for version rows a940d1ebe53d SELECT count() AS n FROM loom.knowledge_uploads WHERE org = {org:String} AND namespace = {ns:String} a94901681d41 SELECT tag, count() AS rows FROM (SELECT arrayJoin(tags) AS tag FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND user_id = {id:String} AND user -a9662931a4ab SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ a98d68a7b8da SELECT DISTINCT namespace, memory_key FROM (SELECT namespace, memory_key FROM loom.memory WHERE org = {org:String} AND user_id = {uid:String}) a98f2f0e55ec SELECT count() AS n FROM loom.code_search_trace WHERE org = {org:String} AND user_id = {uid:String} AND ? a9ace0ac3910 SELECT memory_type, toString(status) AS status, source_class, count() AS rows, min(updated_at) AS first_at, max(updated_at) AS last_at FROM loom.memory FINAL WHERE org = {org:String} AND namespace = { @@ -1526,6 +1526,7 @@ ad2f3798c352 SELECT ? FROM loom.memory_refusals WHERE org={org:String} AND ((sco ad39ba238825 SELECT count() AS n FROM loom.working_memory FINAL WHERE org = {org:String} AND namespace IN {ns:Array(String)} ad5724799b14 SELECT namespace, source_uri, chunk_idx, doc_version, JSONExtractUInt(chunk_metadata, ?) AS revision, content, context, tags, chunk_metadata, ingested_at, agent, session_id, toString(source_class) AS ad575f71f510 SELECT *, hex(SHA256(toJSONString((value_json, value)))) AS body_sha FROM (SELECT org, namespace, agent, user_id, ? AS session_id, ? AS actor, concat(?, entity) AS memory_key, version, ? AS value_json +ad601420e7cb SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ ad69a81ba9d2 SELECT queue_id, agent, user_id, session_id, status, attempts, message_count, content_chars, written, last_error, enqueued_at, updated_at FROM loom.memory_extraction_queue FINAL WHERE org = {org:Strin ad717da278a8 SELECT count() AS n FROM loom.entity_edge_rows WHERE org = {org:String} AND (user_id = {uid:String} OR (namespace, memory_id) IN (SELECT toString(namespace), memory_id FROM (SELECT namespace, agent, u ad8e16687ea3 SELECT count() AS n FROM loom.query_history_sources WHERE org = {org:String} AND namespace = {ns:String} @@ -1557,10 +1558,10 @@ b14f5bc32c83 SELECT memory_id, memory_key FROM loom.memory FINAL WHERE org = {or b1526afb6590 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi b1686849396a ALTER TABLE loom.memory_record_conflicts UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND (prior_record_id IN {ids:Array(UUID)} OR incoming_record_id IN {i b17835f57d67 ALTER TABLE loom.working_memory DELETE WHERE (org = {org:String} AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? -b183d0bed2c7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ b18bb1fa8a4f SELECT namespace, kind, owner_email, description, tags, active, conversation_logging_enabled, capture_generation_io, coverage_sweep, consolidation_enabled, daily_cost_cap_usd, daily_user_cost_cap_usd, b1931bf6e5a4 SELECT DISTINCT owner_email, org FROM loom.namespaces FINAL WHERE contact_email = {email:String} AND active = ? AND owner_email != ? AND (password_hash = ? OR (org, namespace) IN ( SELECT org, namespa b19a91de5abc SELECT scope_path AS path, summary, pagerank, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.code_summaries FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embeddin +b1fc16969ce9 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ b20f5792205f SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi b21e9b73a809 SELECT count() AS n FROM loom.entity_degree WHERE org = {org:String} AND namespace IN {ns:Array(String)} b2233addfc9d ALTER TABLE loom.memory_belief_sources DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? @@ -1591,6 +1592,7 @@ b478870f3be3 SELECT count() AS n FROM loom.context_blobs FINAL WHERE org = {org: b48d3c9729e7 SELECT path, scope, symbol_ids, kind, start_line, end_line, content, embedding_model, toString(indexed_commit) AS indexed_commit FROM ( SELECT path, scope, symbol_ids, kind, start_line, end_line, cont b49285646859 SELECT agent, session_id, memory_key, max(version) AS newest FROM loom.memory_versions WHERE org = {org:String} AND namespace = {ns:String} AND agent = ? AND user_id = {u:String} AND memory_type = ? A b4eaaee7f731 SELECT org, namespace, agent, user_id, session_id, name, source_id, host, port, secure, user, password_enc, cluster, databases, actor, source_class, created_at, tombstoned_at, version FROM loom.query_ +b4f8d3aca0fd SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ b4fcede7dd0d SELECT * EXCEPT (embedding) FROM loom.code_summaries FINAL WHERE (org, namespace, embedding_model, scope_type, scope_path) IN {keys:Array(Tuple(String, String, String, String, String))} AND embedding_ b50bb3c82af0 SELECT c.category_id AS category_id, count() AS rows FROM (SELECT memory_key, category_id FROM loom.memory_categories FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NU b517057ddbb9 SELECT count() AS n FROM loom.memory_ask_precedents WHERE org = {org:String} AND hasAny(arrayConcat(window_keys, cited_keys), {keys:Array(String)}) @@ -1664,7 +1666,6 @@ bbbb132eac9d DELETE FROM loom.chunks WHERE (org = {org:String} AND namespace = { bbdf075a196c SELECT memory_id, namespace FROM loom.memory FINAL WHERE org = {org:String} AND tombstoned_at IS NULL AND status != ? AND namespace = {ns:String} AND position(value, {pat:String}) > ? LIMIT {lim:UInt3 bbe117d6a55c SELECT count() AS n FROM loom.session_outcomes_by_user WHERE org = {org:String} AND namespace IN {ns:Array(String)} bbe2aef01da7 SELECT from_symbol_id, path, argMax(guards, version) AS guards, argMax(guard_kinds, version) AS guard_kinds, argMax(sites, version) AS sites, argMax(site_callees, version) AS site_callees, argMax(site -bbe8ab7147ac SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ bbe8f503595e WITH (SELECT (toFloat64(count()), sumMap(arrayFilter(s -> has({stems:Array(String)}, s), arrayDistinct(arrayMap( t -> stem(t, ?), splitByChar(?, translate(lower(memory_key), ?, ?))))) AS ks, arrayResi bc00b5272311 SELECT count() AS n FROM loom.working_memory FINAL WHERE org = {org:String} AND tombstoned_at IS NULL AND user_id = {uid:String} bc1c9ad1efe8 ALTER TABLE loom.entity_triple_memories DELETE WHERE (org = {org:String} AND (namespace, memory_key) IN {keys:Array(Tuple(String, String))}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag: @@ -1723,6 +1724,7 @@ c27ea9faed6e DELETE FROM loom.session_summaries WHERE (org = {org:String} AND us c280d9bd6950 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi c2b836edc4a5 ALTER TABLE loom.knowledge_ingest_cancels DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? c2badb0e73f9 SELECT DISTINCT msg_id FROM loom.conversations WHERE org = {org:String} AND namespace = {ns:String} AND thread_id = {tid:String} AND msg_id IN {mids:Array(String)} AND is_saved AND tombstoned_at IS NU +c2c1434eb816 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ c2f0775652ce SELECT tag, count() AS rows FROM (SELECT arrayJoin(tags) AS tag FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND user_id = {id:String}) GROUP B c2f0af86ef00 SELECT identity_agent, user_id, session_id, record_json, created_at FROM loom.memory_records FINAL WHERE org = {org:String} AND namespace = {ns:String} AND schema_name = {schema:String} AND status = ? c2f32ca67463 SELECT memory_key, memory_type, content_excerpt, ? - cosineDistance(embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(temporal_anchor, toDateTime(?))) AS temporal_anchor, temporal_confi @@ -1750,6 +1752,7 @@ c5f2a81cdd02 SELECT count() AS n FROM loom.consolidation_runs WHERE org = {org:S c6056fca9bec ALTER TABLE loom.conflict_allowlist UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure c6381f8d82cd SELECT count() AS n FROM loom.conversations WHERE org = {org:String} AND user_id = {uid:String} c65537c736d4 SELECT DISTINCT org, namespace, agent, user_id, session_id, memory_key FROM loom.memory WHERE tombstoned_at IS NULL AND sensitivity = ? AND (expires_at IS NULL OR expires_at > now()) AND (match(value, +c6707adb738f SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ c6a6b15089e3 SELECT count() AS n FROM loom.entity_triples WHERE org = {org:String} AND namespace = {ns:String} c6a8c61641b8 ALTER TABLE loom.entity_summaries UPDATE tombstoned_at = {now:DateTime} WHERE (org = {org:String} AND tombstoned_at IS NULL AND namespace IN {ns:Array(String)}) AND ({erasure_mutation_tag:String} = {e c6c0326e2dd5 SELECT DISTINCT embedding_model, msg_id FROM loom.conversation_embeddings FINAL WHERE org = {org:String} AND namespace = {ns:String} AND thread_id = {tid:String} AND tombstoned_at IS NULL AND ((agent @@ -1806,6 +1809,7 @@ cb0b352de033 SELECT count() AS n FROM loom.search_trace_log WHERE org = {org:Str cb0ffcfc5116 SELECT max(mirror_marked) AS protected, groupUniqArrayIf(?)(args[?], success AND args[?] != ?) AS digests FROM (SELECT raw.ts AS ts, raw.org AS org, raw.namespace AS namespace, raw.agent AS agent, raw cb40a5d65a6a SELECT count() AS n FROM loom.memory_records FINAL WHERE org = {org:String} AND namespace = {ns:String} cb5546d93aee ALTER TABLE loom.memory_versions DELETE WHERE (org = {org:String} AND has(tags, ?) AND hasAny(tags, {src:Array(String)}) AND hasAny(arrayMap(t -> (namespace, t), tags), {pairs:Array(Tuple(String, Stri +cbcaf5645d20 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ cbd6cc077d01 SELECT org, namespace, agent, user_id, session_id, memory_key, tags FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND has(tags, ?) AND has(tags, {srctag:String}) AND tomb cbf399def5b1 SELECT org, namespace, agent, user_id, session_id, memory_key, version FROM loom.memory FINAL PREWHERE (org, namespace, agent, user_id, session_id, memory_key) IN {keys:Array(Tuple(String, String, Str cc115227ad18 SELECT count() AS n FROM loom.namespace_guides WHERE org = {org:String} AND namespace = {ns:String} @@ -1967,7 +1971,6 @@ dbfe0a193e5b SELECT count() AS n FROM loom.documents FINAL WHERE org = {org:Stri dc003d9f3eb2 SELECT toString(failure_id) AS failure_id, org, namespace, agent, projection, source_operation, source_resource_id, memory_keys, error_type, error_message, payload, status, created_at, resolved_at FRO dc06a0e4e9ec SELECT count() AS n FROM loom.code_search_outcome WHERE org = {org:String} AND namespace IN {ns:Array(String)} dc0b35f711b3 INSERT INTO loom._migration_lock (name, holder, acquired_at, renewed_at, ttl_s, build_commit) SETTINGS keeper_map_strict_mode = ?, async_insert = ? VALUES ({name:String}, {me:String}, now64(?), now64( -dc255a67cde7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ dc258476c8e1 SELECT count() AS n FROM loom.conversation_embeddings FINAL WHERE org = {org:String} AND user_id = {uid:String} AND tombstoned_at IS NULL dc299d44addb SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi dcaad5caba4b SELECT agent, user_id, memory_key, argMax(reinforcement_count, version) AS reinforcement_count, argMax(last_reinforced_at, version) AS last_reinforced_at FROM loom.memory_reinforcement WHERE org = {or @@ -2002,9 +2005,9 @@ deb991d6fc6d SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e. ded4dbaaf6b9 SELECT toString(schema_id) AS schema_id, name, description, status FROM loom.memory_schemas FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL ORDER BY name LIMIT {li dedc23bcedfb SELECT namespace, thread_id, ts, msg_id, row_bytes, bytes_before FROM ( SELECT namespace, thread_id, ts, msg_id, row_bytes, sum(row_bytes) OVER (ORDER BY namespace, thread_id, ts, msg_id ROWS BETWEEN deec6ef78a0a SELECT to_symbol_id, count() AS call_sites, countIf(match(caller_bare, {registrar:String})) AS registration FROM ( SELECT to_symbol_id, from_symbol_id, path, line, argMax(tombstoned_at IS NULL, versio +df043ecd33bd SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ df065418883d DELETE FROM loom.chunks WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS lightweight_deletes_sync = ? df0e1be64e2f SELECT count() OVER () AS total, memory_key, toString(memory_id) AS memory_id, confidence, agent FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL A -df24eb998367 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ df31f9f54e16 SELECT from_key, to_key, relation FROM loom.operator_edges FINAL WHERE org = {org:String} AND namespace = {ns:String} AND from_key IN {keys:Array(String)} AND relation IN {rels:Array(String)} AND tomb df32750b2fbe SELECT pr_number, title, author, merged_at, files, linked_issues, (match(title, {revert_re:String}) OR positionCaseInsensitive(body_excerpt, ?) > ? ) AS is_revert FROM loom.code_pr_history FINAL WHERE df3311f16690 SELECT lang, count() AS files, countIf(index_error != ?) AS errored, max(created_at) AS last_at, min(created_at) AS first_at FROM loom.code_files FINAL WHERE org = {org:String} AND namespace = {ns:Str @@ -2057,7 +2060,6 @@ e2c662bc06eb SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e. e2d6458239f7 SELECT number, is_pr, state, state_reason, author, title, opened_at, closed_at, merged_at, updated_at FROM loom.code_gh_items FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_ e30e0afa7cd0 ALTER TABLE loom.memory_record_versions DELETE WHERE (org = {org:String} AND user_id = {uid:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? e33eba4d561f SELECT path, count() AS chunks, min(start_line) AS first_line, count() OVER () AS total FROM ( SELECT path, start_line, tombstoned_at FROM loom.code_chunks WHERE org = {org:String} AND namespace = {ns -e369fef488a6 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ e37b072cbc39 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi e3a91311885a SELECT concat(?, toString(c.session_id), ?, toString(c.chunk_index)) AS memory_key, ? AS memory_type, substring(c.content, ?, ?) AS content_excerpt, c.content AS content_full, c.agent AS agent, c.user e3ac6b4d5b37 SELECT count() AS n FROM loom.conversations WHERE org = {org:String} AND namespace IN {ns:Array(String)} @@ -2093,14 +2095,12 @@ e75f4a024984 SELECT count() AS n FROM loom.derived_facts WHERE org = {org:String e77afbb3fb28 SELECT count() AS n FROM loom.chunks WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND doc_superseded_at IS NULL AND (org, namespace, embedding_model, source_uri, doc_version) NOT IN (S e77b590b9f54 SELECT org, namespace, name, source_id, provider, generation, fingerprint, provider_id, status, secret_enc, agent, user_id, session_id, actor FROM loom.knowledge_source_push FINAL WHERE org = {org:Str e77c1e05f3c4 SELECT count() AS n FROM loom.blob_uploads WHERE org = {org:String} AND namespace IN {ns:Array(String)} AND ? -e7c9ec7af90d SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ e7d4c583cc0e ALTER TABLE loom.procedure_runs DELETE WHERE (org = {org:String} AND namespace = {ns:String}) AND ({erasure_mutation_tag:String} = {erasure_mutation_tag:String}) SETTINGS mutations_sync = ? e7ef19d41a90 SELECT agent, user_id, session_id, embedding_model, summary_text, key_facts, derived_from, valid_at, created_at, version, length(key_facts) AS kf, length(derived_from) AS df, coalesce(valid_at, create e7f1d693d5b1 SELECT count() AS n FROM loom.entity_vectors WHERE org = {org:String} AND (user_id = {uid:String} OR (namespace, memory_key) IN {keys:Array(Tuple(String, String))}) e8009bd53bc4 SELECT number, head_sha FROM loom.code_gh_items FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND is_pr AND state = ? AND head_sha != ? ORDER BY updated_at DESC, e83a1e6dec52 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi e8664cd157a4 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi -e86fe230e6f5 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ e8aec6fb1cfa SELECT if(format != ?, toString(format), if(JSONExtractString(metadata, ?) != ?, JSONExtractString(metadata, ?), if(blob_content_type != ?, toString(blob_content_type), if(lower(extract(if(original_fi e8d8f30521ad SELECT f AS path, argMin(pr_number, merged_at) AS first_pr, min(merged_at) AS first_merged_at FROM loom.code_pr_history FINAL ARRAY JOIN files AS f WHERE org = {org:String} AND namespace = {ns:String} e8d955d1a434 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, cosineDistance(e.em @@ -2227,6 +2227,7 @@ f6e57db3ddca SELECT org, namespace, name, source_id, provider, generation, finge f6e8ef149574 INSERT INTO loom.chunk_supersessions (org, namespace, embedding_model, source_uri, doc_version, superseded_at) SELECT DISTINCT org, namespace, embedding_model, source_uri, doc_version, {when:DateTime} f70eb483657a SELECT agent, user_id, session_id, memory_key, embedding FROM loom.memory_embeddings FINAL PREWHERE org = {org:String} AND namespace = {ns:String} AND embedding_model = {model:String} AND (agent, user f72c5a682989 SELECT toString(evidence_id) AS eid, session_id, role, actor, toString(observed_at) AS observed, content, matched FROM ( SELECT evidence_id, session_id, role, actor, observed_at, content, tombstoned_a +f739de95ce36 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ f7453051daff SELECT org, name, sa_subject, created_by, created_at, lineage, revoked_at IS NULL AS live FROM loom.service_accounts FINAL WHERE (created_by IN {subs:Array(String)} OR hasAny(lineage, {subs:Array(Stri f749b37e03cc SELECT org, qa_namespace AS namespace FROM loom.qa_test_daily WHERE org IN {orgs:Array(String)} AND qa_namespace IN {namespaces:Array(String)} GROUP BY org, namespace f76f74a06597 SELECT toString(f.failure_id) AS failure_id, org, namespace, agent, projection, source_operation, source_resource_id, memory_keys, error_type, error_message, payload, status, created_at, resolved_at F @@ -2251,7 +2252,6 @@ f95a8b133889 SELECT memory_key, memory_type, content_excerpt, ? - cosineDistance f9818bc5e82a SELECT count() AS n FROM loom.code_chunks WHERE org = {org:String} AND namespace = {ns:String} AND ? f985f32cedc7 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, e.status AS status, e.version AS version, e.content_sha256 AS content_sha256, -- Multi-vector axi f98a98f483aa SELECT cityHash64(namespace, subject, relation, object) AS h FROM loom.entity_triple_memories FINAL WHERE org = {org:String} GROUP BY namespace, subject, relation, object HAVING countIf(((namespace, m -f9afe41eddb1 SELECT e.memory_key AS memory_key, e.memory_type AS memory_type, e.content_excerpt AS content_excerpt, ? - cosineDistance(e.embedding, {qv:Array(Float32)}) AS similarity, toString(coalesce(e.temporal_ f9aff1abcf47 SELECT count() AS n FROM loom.memory_evidence FINAL WHERE org = {org:String} AND namespace = {ns:String} f9c70055e9f9 SELECT DISTINCT tier, qualified_name, symbol_id FROM loom.code_symbol_ids WHERE org = {org:String} AND namespace = {ns:String} AND symbol_id IN {ids:Array(String)} f9e4163b2950 SELECT ts, event_type, org, namespace, actor, subject, request_id FROM loom.audit_log WHERE org = {org:String} AND position(subject, {needle:String}) > ? AND namespace NOT IN {shown_hidden:Array(Strin diff --git a/tests/unit/test_key_match_arm.py b/tests/unit/test_key_match_arm.py index 85697e1ba54..cd591ccf6f6 100644 --- a/tests/unit/test_key_match_arm.py +++ b/tests/unit/test_key_match_arm.py @@ -508,6 +508,43 @@ async def query_all(self, sql, params=None): assert [h.version for h in ctx.all_hits] == [9] +async def test_a_key_match_row_carries_its_status(monkeypatch) -> None: + # an `include_superseded` read serves the row; a handle-only continuation re-checks + # the status the hit was served with, so the arm has to keep it + import server.core.ch as ch_mod + + row = {"memory_key": "task_worktree", "agent": "a", "user_id": "u", "session_id": "s1"} + + class _CH: + async def query_all(self, sql, params=None): + if "any_key" in sql: + return [{"any_key": 1}] + assert "e.status AS status" in sql + return [{**row, "version": 2, "status": "superseded"}] + + monkeypatch.setattr(ch_mod, "get_client", lambda: _CH()) + inp = MemorySearchInput( + org="o", + namespace="n", + agent="a", + query="task worktree", + key_match_mode="always", + include_superseded=True, + ) + ctx = SimpleNamespace( + input=inp, + all_hits=[], + actual_work={}, + namespaces=["n"], + query_vec=[0.1], + embedder=SimpleNamespace(model_name="m"), + endpoint=None, + query_shape="", + ) + await _run_key_match_pool(ctx) + assert [h.status for h in ctx.all_hits] == ["superseded"] + + @pytest.mark.parametrize("shape", ["aggregational", "temporal_diff"]) async def test_the_gate_counts_rows_per_key_as_the_final_block_keeps_them( monkeypatch, shape: str diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index b0b432dbf1b..1f0c9344996 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -2,6 +2,7 @@ from __future__ import annotations +from types import SimpleNamespace from typing import Any import pytest @@ -271,6 +272,85 @@ async def heads(keys): assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [] +async def test_unchanged_superseded_anchor_hit_survives_a_handle_only_continuation(monkeypatch): + """An anchor hit read under `include_superseded` keeps the status its row had, so the + continuation (whose request does not repeat the flag) serves it while the row is unchanged.""" + head = _head(status="superseded") + + async def heads(keys): + return {_KEY: head} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + served = MemorySearchInput(org="o", namespace="n", query="deploy", include_superseded=True) + hit = _hit() + hit.source = "anchor" + hit.status = "superseded" + await guidance.attach_search_guidance(served, [hit], snapshot_only=True) + parked = search_pages.unparked(search_pages._parked(hit)) + assert parked is not None and parked.status == "superseded" + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] + # A hit parked without its status (the anchor pool did not select it) is dropped. + parked.status = "" + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [] + + +@pytest.mark.asyncio +async def test_key_match_superseded_hit_survives_a_handle_only_continuation( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """The key-match arm's own hit, as that arm builds it, carries its row's status through + the parked page, so an unchanged superseded row stays served.""" + import server.core.ch as ch_mod + from server.memory.app.search.key_match import _run_key_match_pool + + row = { + "memory_key": _KEY[-1], + "agent": "a", + "user_id": "u", + "session_id": "s", + "version": 42, + "status": "superseded", + "content_sha256": "a" * 64, + "similarity": 0.7, + "strength": 0.9, + } + + class _CH: + async def query_all(self, sql: str, params: Any = None) -> list[dict[str, Any]]: + return [{"any_key": 1}] if "any_key" in sql else [row] + + async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, Any]]: + return {_KEY: _head(status="superseded")} + + monkeypatch.setattr(ch_mod, "get_client", lambda: _CH()) + monkeypatch.setattr(guidance, "guidance_heads", heads) + served = MemorySearchInput( + org="o", + namespace="n", + agent="a", + query="deploy notes", + key_match_mode="always", + include_superseded=True, + ) + ctx = SimpleNamespace( + input=served, + all_hits=[], + actual_work={}, + namespaces=["n"], + query_vec=[0.1], + embedder=SimpleNamespace(model_name="m"), + endpoint=None, + query_shape="", + ) + await _run_key_match_pool(ctx) + (hit,) = ctx.all_hits + assert hit.status == "superseded" + await guidance.attach_search_guidance(served, [hit], snapshot_only=True) + parked = search_pages.unparked(search_pages._parked(hit)) + assert parked is not None and parked.status == "superseded" + assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] + + async def test_previous_build_cursor_cannot_give_folded_passage_parent_approval(monkeypatch): async def heads(keys): return {_KEY: _head()} From 1791fc38feb672ab7984659ab2eebae87cce510b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 19:21:18 +0530 Subject: [PATCH 019/117] Restore focus to the originating memory row Use the same writer identity for the card and its focus key. Resolve the saved focus key when a refresh replaces the inspector opener. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- .../components/MemoryInspector.nav.test.tsx | 31 +++++++++++++++++++ frontend/src/components/MemoryInspector.tsx | 17 ++++++---- frontend/src/lib/place.ts | 2 +- frontend/src/views/Recent.lists.test.tsx | 13 ++++++++ frontend/src/views/Recent.tsx | 2 +- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/MemoryInspector.nav.test.tsx b/frontend/src/components/MemoryInspector.nav.test.tsx index 10eeaec7434..0dffa522c74 100644 --- a/frontend/src/components/MemoryInspector.nav.test.tsx +++ b/frontend/src/components/MemoryInspector.nav.test.tsx @@ -185,6 +185,37 @@ describe("an entity on a memory opens in place", () => { expect(screen.getByRole("button", { name: "Opener" })).not.toHaveFocus(); }); + it("returns focus to the opener's row when the list replaces its buttons", async () => { + const page = (drawer: boolean, generation: number) => ( + <> +
+
+ +
+
+ +
+
+ {drawer && ( + {}} onChanged={() => {}} /> + )} + + ); + const { rerender } = render(page(false, 1)); + const opener = screen.getByRole("button", { name: "Second writer" }); + opener.focus(); + rerender(page(true, 1)); + await screen.findByText("the public API allows 100 requests a minute"); + rerender(page(true, 2)); + expect(opener.isConnected).toBe(false); + rerender(page(false, 2)); + await waitFor(() => expect(screen.getByRole("button", { name: "Second writer" })).toHaveFocus()); + }); + it("shows a tag by its name, with no '#' glyph", async () => { vi.mocked(getMemory).mockResolvedValue({ ...DETAIL, tags: ["ops"] }); await open(); diff --git a/frontend/src/components/MemoryInspector.tsx b/frontend/src/components/MemoryInspector.tsx index 3732e26cb64..349a64dd56f 100644 --- a/frontend/src/components/MemoryInspector.tsx +++ b/frontend/src/components/MemoryInspector.tsx @@ -52,7 +52,7 @@ import { } from "../api"; import { LockMemoryDialog, RedactVersionDialog, RejectMemoryDialog } from "../flows/MemoryReasonDialogs"; import { navigationHref, useStore } from "../lib/state"; -import { openerUsable } from "../lib/place"; +import { keyedTarget, openerUsable } from "../lib/place"; import { graphSeedHref, isModifiedClick, openGraphAt } from "../lib/graphLink"; import { isPublicationPending } from "../lib/errors"; import { AgentBadge } from "./AgentBadge"; @@ -239,10 +239,12 @@ export function MemoryInspector({ // first render — before Radix moves focus in — and refocused on close. A // Radix modal Dialog otherwise restores to its Trigger, which this // drawer has none of, so focus would fall to . - const [opener] = useState(() => { - if (typeof document === "undefined") return null; - const el = document.activeElement; - return el instanceof HTMLElement ? el : null; + const [{ opener, focusKey }] = useState(() => { + const el = typeof document === "undefined" ? null : document.activeElement; + return { + opener: el instanceof HTMLElement ? el : null, + focusKey: el?.closest("[data-focus-key]")?.getAttribute("data-focus-key"), + }; }); const [openedAt] = useState(() => useStore.getState().navSeq); // Set by "Ask about this", which closes the drawer for the assistant panel's field. @@ -1023,7 +1025,10 @@ export function MemoryInspector({ e.preventDefault(); // A navigation since the drawer opened (a tag, a graph link) moved the focus to // its page; an opener in an assistant panel that closed is hidden. - if (!leaving.current && useStore.getState().navSeq === openedAt && openerUsable(opener)) opener?.focus(); + if (leaving.current || useStore.getState().navSeq !== openedAt) return; + // Refreshed lists can replace the opener while the drawer is open. + const target = opener?.isConnected ? opener : focusKey ? keyedTarget(focusKey) : null; + if (openerUsable(target)) target?.focus(); }} onEscapeKeyDown={onEscapeKeyDown} onPointerDownOutside={onPointerDownOutside} diff --git a/frontend/src/lib/place.ts b/frontend/src/lib/place.ts index 5b8da5eb75e..26961b7a6e2 100644 --- a/frontend/src/lib/place.ts +++ b/frontend/src/lib/place.ts @@ -136,7 +136,7 @@ const FOCUSABLE = "a[href], button, input, select, textarea, [tabindex]"; /** The element a focus key names, or inside it the row's open button (a list row is * keyed; its stretched `data-row-open` button takes the focus, not its checkbox), else * the first focusable. */ -function keyedTarget(key: string): HTMLElement | null { +export function keyedTarget(key: string): HTMLElement | null { const el = document.querySelector(`[data-focus-key="${CSS.escape(key)}"]`); if (!el) return null; if (el.matches(FOCUSABLE)) return el; diff --git a/frontend/src/views/Recent.lists.test.tsx b/frontend/src/views/Recent.lists.test.tsx index 8514e13b3f8..5ccae8d8daa 100644 --- a/frontend/src/views/Recent.lists.test.tsx +++ b/frontend/src/views/Recent.lists.test.tsx @@ -4,6 +4,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { MemoryDetail, MemoryListEntry, MemoryListResponse, MyNamespaceEntry, WhoAmI } from "../api"; import { ApiError } from "../lib/errors"; import { useStore } from "../lib/state"; +import { readPlace, rememberPlace, restorePlace } from "../lib/place"; import { resetNamespaceRoleCache } from "../lib/namespaceRole"; import { Recent } from "./Recent"; import { ToastViewport } from "../components/Toast"; @@ -579,6 +580,18 @@ describe("Memories list chrome", () => { expect(open[0]!.contains(boxes[1]!)).toBe(true); useStore.setState({ inspectedMemoryKey: null, inspectedAgent: "", inspectedOwner: null }); }); + + it("restores focus to the same writer when returning to the list", async () => { + const boxes = await show(two()); + const [first, second] = boxes.map( + (box) => box.closest(".list-row")!.querySelector("[data-row-open]")!, + ); + second!.focus(); + rememberPlace({ key: null, agent: "" }); + first!.focus(); + restorePlace(readPlace(history.state), false); + await waitFor(() => expect(second).toHaveFocus()); + }); }); it("counts a pin that committed with lists behind as pinned, and says a failure apart", async () => { diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 9105cbe1dd7..ff1927d2686 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -1000,7 +1000,7 @@ function MemoryList() { key={rowId} data-card="" // Back to this page focuses the card that had the focus. - data-focus-key={`memory:${e.memory_key}`} + data-focus-key={`memory:${rowId}`} checked={isSelected} active={isActive} deleted={isTombstoned} From 16260552b26faaf0b57b39566f6598df4754e6a1 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 19:35:27 +0530 Subject: [PATCH 020/117] Restore the inspected writer on browser history traversal Read the owner and lookup scope from the same inspection stamp as the key and agent when the entry has no saved place. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/lib/state.namespace.test.ts | 22 ++++++++++++++++++++++ frontend/src/lib/state.ts | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/state.namespace.test.ts b/frontend/src/lib/state.namespace.test.ts index 09d5824e089..95120b010d6 100644 --- a/frontend/src/lib/state.namespace.test.ts +++ b/frontend/src/lib/state.namespace.test.ts @@ -109,6 +109,28 @@ describe("writing the address", () => { expect(useStore.getState()).toMatchObject({ view: "memories", inspectedMemoryKey: "k", inspectedAgent: "bot" }); }); + it("Forward restores an exact inspection from the address entry without a saved place", async () => { + at("/recall?namespace=team", { loomNamespace: "team" }); + useStore.setState({ view: "recall" }); + useStore.getState().navigate("memories"); + useStore.getState().inspect("k", { agent: "bot", userId: "ada", sessionId: "two", namespace: "team", exact: true }); + expect(readPlace(history.state)).toBeNull(); + + await back("recall"); + expect(useStore.getState().inspectedMemoryKey).toBeNull(); + await new Promise((resolve) => { + window.addEventListener("popstate", resolve, { once: true }); + history.forward(); + }); + useStore.getState().arriveFromHistory("memories", readPlace(history.state)); + expect(useStore.getState()).toMatchObject({ + inspectedMemoryKey: "k", + inspectedAgent: "bot", + inspectedOwner: { user_id: "ada", session_id: "two" }, + inspectedScope: { namespace: "team", exact: true }, + }); + }); + it("a switch names the new namespace in place and drops what belonged to the old one", () => { at("/memories?namespace=team&memory=k"); const before = history.length; diff --git a/frontend/src/lib/state.ts b/frontend/src/lib/state.ts index 3ff3f796aaa..8e157347e75 100644 --- a/frontend/src/lib/state.ts +++ b/frontend/src/lib/state.ts @@ -582,8 +582,8 @@ export const useStore = create((set, get) => ({ sessionHandoff: here ? linkedSessionHandoff(view) : null, inspectedMemoryKey: inspected ?? opened.inspectedMemoryKey ?? null, inspectedAgent: inspected ? (place?.inspectedAgent ?? "") : (opened.inspectedAgent ?? ""), - inspectedOwner: inspected ? (place?.inspectedOwner ?? null) : null, - inspectedScope: inspected ? (place?.inspectedScope ?? null) : null, + inspectedOwner: inspected ? (place?.inspectedOwner ?? null) : (opened.inspectedOwner ?? null), + inspectedScope: inspected ? (place?.inspectedScope ?? null) : (opened.inspectedScope ?? null), }); addressPageNamespace(); }, From a048a2e4c9dd00de8d24e77ea89e56a635503f54 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 20:00:40 +0530 Subject: [PATCH 021/117] Honor field projection when serializing search writers Fill in the writer values only for fields selected by the serializer. Cover both direct dumps and projection through the search output. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- server/memory/api/models_search.py | 7 +++++-- tests/unit/test_memory_search_writer_wire.py | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/server/memory/api/models_search.py b/server/memory/api/models_search.py index 7e23288cc70..d33e30c24e6 100644 --- a/server/memory/api/models_search.py +++ b/server/memory/api/models_search.py @@ -483,8 +483,11 @@ def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, # `tags` is on the wire only when the request asked for it: None = not # requested, so the key is dropped. data: dict[str, Any] = handler(self) - if self._row_identity is not None: - data["agent"], data["user_id"], data["session_id"] = self._row_identity + identity = self._row_identity + if identity is not None: + for name, value in zip(("agent", "user_id", "session_id"), identity, strict=True): + if name in data: + data[name] = value if self.tags is None: data.pop("tags", None) if self.use_guidance is None: diff --git a/tests/unit/test_memory_search_writer_wire.py b/tests/unit/test_memory_search_writer_wire.py index 1d370158219..ac0bf3c57dd 100644 --- a/tests/unit/test_memory_search_writer_wire.py +++ b/tests/unit/test_memory_search_writer_wire.py @@ -42,4 +42,10 @@ def test_writer_serialization_honors_projection() -> None: ) hit._row_identity = ("writer-b", "alice", "shared") assert hit.model_dump(include={"memory_key"}) == {"memory_key": "seat"} - assert "agent" not in hit.model_dump(exclude={"agent"}) + wire = hit.model_dump(exclude={"agent"}) + assert "agent" not in wire + assert (wire["user_id"], wire["session_id"]) == ("alice", "shared") + output = MemorySearchOutput(results=[hit], embedding_model="test") + assert output.model_dump(mode="json", include={"results": {0: {"session_id"}}}) == { + "results": [{"session_id": "shared"}], + } From 769426bf734093b440deac767532015e64bcdf0f Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 20:40:42 +0530 Subject: [PATCH 022/117] Keep search guidance bound to current evidence Check link coverage against the indexed head and recalculate the verdict before projecting excerpts. Bind dashboard guidance to exact revisions, hydrate ranked rows through list previews, and use the shared writer check in Recall Lab. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/api.ts | 2 + frontend/src/api/search.ts | 1 + frontend/src/views/RecallLab.table.test.tsx | 4 +- frontend/src/views/RecallLab.tsx | 12 +-- frontend/src/views/Recent.search.test.tsx | 74 +++++++++++------ frontend/src/views/Recent.tsx | 2 +- frontend/src/views/memoryListReads.ts | 79 +++++++------------ sdk/python/loom/ops.py | 1 + sdk/rust/src/wire_models.rs | 2 + sdk/typescript/src/generated/ops.ts | 1 + server/memory/api/models_search.py | 10 +++ server/memory/app/code_link_reads.py | 22 +++++- server/memory/app/search/handler.py | 27 +++---- server/memory/app/search/output.py | 27 ++++--- tests/unit/test_memory_code_plane_reads.py | 41 ++++++++++ .../unit/test_memory_search_handler_gates.py | 19 +++++ tests/unit/test_memory_search_writer_wire.py | 2 + 17 files changed, 210 insertions(+), 116 deletions(-) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index a25c36a0e4d..3479fbcb9a7 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -460,6 +460,7 @@ export async function listMemories( known_version?: string; fields?: string[]; previewChars?: number; + prefix?: string; // Only rows whose value or key holds this text, any case. contains?: string; // Only rows carrying every one of these tags, in any case. @@ -489,6 +490,7 @@ export async function listMemories( // carries nothing else. ...(opts.fields ? { fields: opts.fields } : {}), ...(opts.previewChars ? { preview_chars: opts.previewChars } : {}), + ...(opts.prefix ? { prefix: opts.prefix } : {}), ...(opts.contains ? { contains: opts.contains } : {}), ...(opts.pinnedOnly ? { pinned_only: true } : {}), ...(opts.conflictedOnly ? { conflicted_only: true } : {}), diff --git a/frontend/src/api/search.ts b/frontend/src/api/search.ts index a5b89aa9e9e..d01251714d9 100644 --- a/frontend/src/api/search.ts +++ b/frontend/src/api/search.ts @@ -29,6 +29,7 @@ export interface SearchHit { session_id?: string; /** The revision the hit (and its guidance) was made for. */ version?: number; + version_text?: string; /** Server provenance note for the hit ("fact hit from namespace x; * similarity=0.62; ..."). Rides at k ≤ 15 by default and at any k under * `explain: true`. */ diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index b0a83499adc..b01fd9dc6eb 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -154,17 +154,19 @@ describe("Recall Lab: the scores table", () => { expect(useStore.getState().inspectedMemoryKey).toBe("deploy_note"); }); - it("keeps chunk and shared hits visible without opening a namesake", async () => { + it("keeps chunk, shared and sentinel hits visible without opening a namesake", async () => { searchMemory.mockResolvedValue({ results: [ hit("chunk:s:0", 0.9, { source: "chunk", agent: "writer", user_id: "u", session_id: "s" }), hit("definition", 0.8, { agent: "_shared", user_id: "-", session_id: "-" }), + hit("sentinel", 0.7, { agent: "-", user_id: "-", session_id: "-" }), ], }); render(); const table = within(await score()); expect(table.getByRole("button", { name: "chunk:s:0" })).toBeDisabled(); expect(table.getByRole("button", { name: "definition" })).toBeDisabled(); + expect(table.getByRole("button", { name: "sentinel" })).toBeDisabled(); fireEvent.click(table.getByText("excerpt of definition")); expect(useStore.getState().inspectedMemoryKey).toBeNull(); }); diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index d1a7c2efd93..7be26c54d68 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -18,7 +18,7 @@ import { ListState } from "../components/ui/ListState"; import { ListToolbar } from "../components/ui/ListToolbar"; import { displayAgent, previewValue, SENSITIVE_LABEL } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; -import { KEYWORD_PAGE, keywordThenRanked, parseSearchQuery } from "../lib/memoriesSearch"; +import { KEYWORD_PAGE, keywordThenRanked, namesWriter, parseSearchQuery, rowIdentity } from "../lib/memoriesSearch"; import { signed, termText, whyTerms } from "../lib/whyNote"; import { AskAboutThis, exact, quoted } from "../components/AskAboutThis"; @@ -273,12 +273,8 @@ interface RecallRow { hit?: SearchHit; } -function hasWriter(row: RecallRow["writer"]): boolean { - return Boolean(row.agent && row.agent !== "*" && row.user_id && row.session_id); -} - function canInspect(row: RecallRow): boolean { - return hasWriter(row.writer) && row.writer.agent !== "_shared" && !row.key.startsWith("chunk:"); + return namesWriter(row.writer) && !row.key.startsWith("chunk:"); } function recallRowId( @@ -286,9 +282,7 @@ function recallRowId( row: Pick, unidentified: string, ): string { - return hasWriter(row) - ? JSON.stringify([row.namespace || namespace, row.agent, row.user_id, row.session_id, row.memory_key]) - : unidentified; + return namesWriter(row) ? rowIdentity(namespace, row) : unidentified; } // The entity boost has its own column; the other terms that moved a hit sit under its score. diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index a8315a5ce68..f25a00923a7 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -1,7 +1,8 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from "../test/rtl"; import userEvent from "@testing-library/user-event"; -import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from "vitest"; -import type { MemoryDetail, MemoryListEntry, MyNamespaceEntry, WhoAmI } from "../api"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import type { MemoryListEntry, MyNamespaceEntry, WhoAmI } from "../api"; +import { SENSITIVE_LABEL } from "../lib/format"; import { useStore } from "../lib/state"; import { resetNamespaceRoleCache } from "../lib/namespaceRole"; import { Recent } from "./Recent"; @@ -17,6 +18,7 @@ const entry = (memory_key: string): MemoryListEntry => ({ memory_type: "semantic", confidence: 1, version: 1, + version_text: "1", created_at: "2026-09-18T09:00:00Z", expires_at: null, pinned: false, @@ -28,7 +30,7 @@ const entry = (memory_key: string): MemoryListEntry => ({ }); // A ranked hit as the server names its row: writer in full and the revision it was read at. -const writer = { agent: "claude-desktop", user_id: "user", session_id: "one", version: 1 }; +const writer = { agent: "claude-desktop", user_id: "user", session_id: "one", version: 1, version_text: "1" }; vi.mock("../api", async (importOriginal) => { const actual = await importOriginal(); @@ -42,6 +44,7 @@ vi.mock("../api", async (importOriginal) => { : { entries: [entry("coffee_pref"), entry("tea_pref")], total: 2, today: 2, truncated: false }, ), bulkGetMemories: vi.fn(async () => ({ results: {}, missing: [] })), + getMemory: vi.fn(), listConflicts: vi.fn(async () => ({ rows: [] })), conflictKeys: vi.fn(async (): Promise => []), listMine: vi.fn(async () => []), @@ -65,7 +68,7 @@ vi.mock("../api", async (importOriginal) => { })), }; }); -import { bulkGetMemories, conflictKeys, listMemories, searchMemory } from "../api"; +import { bulkGetMemories, conflictKeys, getMemory, listMemories, searchMemory } from "../api"; const row = (namespace: string, role: MyNamespaceEntry["role"]): MyNamespaceEntry => ({ namespace, @@ -112,7 +115,7 @@ describe("Recent search why-line", () => { await waitFor(() => expect(searchMemory).toHaveBeenCalled(), { timeout: 3000 }); const [, query, opts] = must(vi.mocked(searchMemory).mock.calls.at(-1), "last searchMemory call"); expect(query).toBe("milk"); - expect(opts).toMatchObject({ top_k: 50, explain: true, legs: ["memory"] }); // Memory legs only + expect(opts).toMatchObject({ top_k: 50, explain: true, legs: ["memory"], bodies: "none" }); // The hit that did not match carries no button and no score; the ranked one shows its // scores inside its open button, so they open the row and are read with it. @@ -160,6 +163,7 @@ describe("Recent search with one key written by two sessions", () => { user_id: "user", session_id, version: 1, + version_text: "1", use_guidance: { next_step: "validate_lead", reasons: [] }, ...over, }); @@ -217,9 +221,12 @@ describe("Recent search with one key written by two sessions", () => { }); it("keeps a ranked row visible but gives it no guidance or score when its revision is not the hit's", async () => { - feed(written("one", { version: 2 })); + const oldVersion = "1800000000000000000"; + const newVersion = "1800000000000000002"; + expect(Number(oldVersion)).toBe(Number(newVersion)); + feed(written("one", { version: Number(newVersion), version_text: newVersion })); vi.mocked(searchMemory).mockResolvedValue({ - results: [ranked("one", { version: 1 })], + results: [ranked("one", { version: Number(oldVersion), version_text: oldVersion })], embedding_model: "fake", } as never); await search(); @@ -232,9 +239,9 @@ describe("Recent search with one key written by two sessions", () => { it("does the same for a hit or row that names no revision", async () => { for (const gone of ["hit", "row"] as const) { cleanup(); - feed(written("one", gone === "row" ? { version: undefined } : {})); + feed(written("one", gone === "row" ? { version_text: undefined } : {})); vi.mocked(searchMemory).mockResolvedValue({ - results: [ranked("one", gone === "hit" ? { version: undefined } : {})], + results: [ranked("one", gone === "hit" ? { version_text: undefined } : {})], embedding_model: "fake", } as never); await search(); @@ -257,6 +264,28 @@ describe("Recent search with one key written by two sessions", () => { expect(screen.queryByTestId("search-score")).toBeNull(); expect(screen.queryByText(/Suggested use/)).toBeNull(); }); + + it("uses a list preview when an unloaded ranked writer's row becomes high sensitivity", async () => { + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + const entries = opts?.prefix + ? [written("one", { sensitivity: "high", version: 2, version_text: "2", value: null })] + : opts?.contains + ? [] + : [written("two")]; + return { entries, total: entries.length, today: 0, truncated: false }; + }); + vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); + await search(); + expect(await screen.findByText(SENSITIVE_LABEL)).toBeInTheDocument(); + expect(listMemories).toHaveBeenCalledWith( + expect.objectContaining({ user_id: "user", session_id: "one" }), + expect.any(Number), + expect.objectContaining({ agent: "claude-desktop", prefix: "deploy_note" }), + ); + expect(bulkGetMemories).not.toHaveBeenCalled(); + expect(getMemory).not.toHaveBeenCalled(); + expect(screen.queryByText("note of session one")).toBeNull(); + }); }); describe("Recent search under a tag filter", () => { @@ -363,13 +392,11 @@ describe("Recent search after a local write", () => { it("while a write ranks again, keeps no hit read from outside the page before the write", async () => { let written = false; - vi.mocked(listMemories).mockResolvedValue({ entries: [entry("milk_note")], total: 1, today: 0, truncated: false }); - onTestFinished(() => { - vi.mocked(bulkGetMemories).mockImplementation(async () => ({ results: {}, missing: [] })); - }); - vi.mocked(bulkGetMemories).mockImplementation(async (_id, keys) => ({ - results: Object.fromEntries(keys.map((k) => [k, { ...entry(k), value: k } as unknown as MemoryDetail])), - missing: [], + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => ({ + entries: [entry(opts?.prefix || "milk_note")], + total: 1, + today: 0, + truncated: false, })); vi.mocked(searchMemory).mockImplementation(async () => { if (written) return new Promise(() => {}) as never; @@ -403,18 +430,13 @@ describe("Recent search after a local write", () => { it("a failed re-rank that kept nothing still forgets its ranking for the next run", async () => { let phase = 0; - onTestFinished(() => { - vi.mocked(bulkGetMemories).mockImplementation(async () => ({ results: {}, missing: [] })); - }); vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => - opts?.contains || phase < 2 - ? { entries: [entry("milk_note")], total: 1, today: 0, truncated: false } - : { entries: [entry("milk_note"), entry("far_pref")], total: 2, today: 0, truncated: false }, + opts?.prefix + ? { entries: [entry(opts.prefix)], total: 1, today: 0, truncated: false } + : opts?.contains || phase < 2 + ? { entries: [entry("milk_note")], total: 1, today: 0, truncated: false } + : { entries: [entry("milk_note"), entry("far_pref")], total: 2, today: 0, truncated: false }, ); - vi.mocked(bulkGetMemories).mockImplementation(async (_id, keys) => ({ - results: Object.fromEntries(keys.map((k) => [k, { ...entry(k), value: k } as unknown as MemoryDetail])), - missing: [], - })); vi.mocked(searchMemory).mockImplementation(async () => { if (phase === 1) throw new Error("search down"); if (phase === 2) return new Promise(() => {}) as never; diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index ff1927d2686..a8b0629b3cf 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -450,7 +450,7 @@ function MemoryList() { const id = rowIdentity(identity.namespace, row); const hit = searchWhy.get(id); const at = rank.get(id); - if (hit && at && hit.version && row.version && hit.version === row.version) { + if (hit && at && hit.version_text && hit.version_text === row.version_text) { scores.set(id, ); asides.set(id, ); } else if (keywordKeys.has(id)) asides.set(id, ); diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 557b82d827e..fb70668e46c 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -1,11 +1,9 @@ import { useEffect, useRef, useState } from "react"; import { bulkGetMemories, - getMemory, listMemories, searchMemory, type Identity, - type MemoryDetail, type MemoryListEntry, type SearchHit, } from "../api"; @@ -71,29 +69,29 @@ export function useSameFilter(next: T): T { return next; } -// Shape a memory.get detail as a list entry, so a search hit fetched -// on-demand (one outside the preloaded window) renders through the same -// MemoryCard path as preloaded rows. -function detailToEntry(key: string, d: MemoryDetail): MemoryListEntry { - return { - memory_key: key, - memory_type: d.memory_type || "semantic", - confidence: d.confidence ?? 1, - version: d.version ?? 0, - version_text: d.version_text ?? undefined, - created_at: d.created_at || "", - updated_at: d.updated_at ?? null, - expires_at: d.expires_at ?? null, - tombstoned_at: null, - pinned: d.pinned, - tags: d.tags || [], - agent: d.agent, - user_id: d.user_id, - session_id: d.session_id, - value: d.value, - source_trace: d.source_trace, - status: d.status, - }; +// A search card is a list preview even when its row was outside the loaded pages. +async function readSearchPreview( + identity: Identity, + hit: SearchHit, + signal: AbortSignal, +): Promise { + const writer = namesWriter(hit); + const scope = writer ? { ...identity, user_id: hit.user_id, session_id: hit.session_id } : identity; + const key = rowIdentity(identity.namespace, hit); + for (let offset = 0; !signal.aborted; offset += KEYWORD_PAGE) { + const page = await listMemories(scope, KEYWORD_PAGE, { + agent: writer ? hit.agent : undefined, + prefix: hit.memory_key, + offset, + fields: MEMORIES_LIST_FIELDS, + previewChars: CARD_VALUE_CHARS, + signal, + }); + const entry = page.entries.find((row) => rowIds(identity.namespace, row).includes(key)); + if (entry) return { ...entry, value: entry.value ?? null }; + if (offset + KEYWORD_PAGE >= page.total) break; + } + return null; } /** @@ -204,6 +202,7 @@ export function useMemorySearch( top_k: 50, explain: true, legs: ["memory"], + bodies: "none", signal: rac.signal, }); // Awaited below; a rejection before then is not unhandled, and is not kept for the @@ -278,37 +277,15 @@ export function useMemorySearch( setSearchAbstain( r.abstain && kwKeys.size === 0 ? r.abstain_reason || "No strong match — showing best-effort results." : null, ); - // Server search spans the whole namespace, but the page only preloads - // the top `limit` rows. Hydrate hits outside that window so they still - // render, instead of being dropped by the key-set intersection below. - // agent="*" resolves the row regardless of which agent wrote it, but one row per - // key: a hit that names its writer takes that row only if it is the row it names, - // else it reads its own. + // Keep ranked hits that fell outside the loaded list window. const unseen = results.filter((h) => !held.has(idOf(h))); if (unseen.length === 0) { setSearchExtra(new Map(kwExtra)); return; } - // One memory.bulk_get, not one memory.get per hit — the list path below already - // reads this way. - const missing = [...new Set(unseen.map((h) => h.memory_key))]; - const bulk = await bulkGetMemories({ ...identity, agent: "*" }, missing, { - signal: ac.signal, - }).catch(() => ({ - results: {} as Record, - missing, - })); - const rowFor = async (h: SearchHit): Promise => { - const d = bulk.results[h.memory_key]; - const e = d ? detailToEntry(h.memory_key, d) : null; - if (e && idsOf(e).includes(idOf(h))) return e; - if (!namesWriter(h)) return null; - const own = { ...identity, agent: h.agent ?? "", user_id: h.user_id, session_id: h.session_id }; - const exact = await getMemory(own, h.memory_key, { signal: ac.signal }).catch(() => null); - const x = exact?.found ? detailToEntry(h.memory_key, exact) : null; - return x && idsOf(x).includes(idOf(h)) ? x : null; - }; - const fetched = await Promise.all(unseen.map(rowFor)); + const fetched = await Promise.all( + unseen.map((hit) => readSearchPreview(identity, hit, ac.signal).catch(() => null)), + ); if (cancelled) return; setSearchExtra( new Map([ diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 1a0ed9b6b23..edc4f56c90a 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -13127,6 +13127,7 @@ class MemorySearchHit(TypedDict, total=False): superseded_by: NotRequired[Optional[str]] superseded_at: NotRequired[Optional[str]] version: NotRequired[int] + version_text: NotRequired[str] created_at: NotRequired[str] namespace: NotRequired[str] code_state: NotRequired[ diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index 0b7c9197455..d356dfa1795 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -3754,6 +3754,8 @@ pub struct MemorySearchHit { pub superseded_at: Option, #[serde(default = "default_84")] pub version: u64, + #[serde(default)] + pub version_text: Option, #[serde(default = "default_85")] pub created_at: String, #[serde(default = "default_86")] diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index f07b58d7356..1f865244a5f 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -5215,6 +5215,7 @@ export interface MemorySearchHit { superseded_by?: string | null; superseded_at?: string | null; version?: number; + version_text?: string; created_at?: string; namespace?: string; code_state?: "fresh" | "moved" | "changed" | "unresolved" | "missing" | ""; diff --git a/server/memory/api/models_search.py b/server/memory/api/models_search.py index d33e30c24e6..78264054641 100644 --- a/server/memory/api/models_search.py +++ b/server/memory/api/models_search.py @@ -477,12 +477,20 @@ class MemorySearchInput(BaseModel): TermLegStatus = Literal["complete", "empty", "capped", "timed_out", "failed", "off"] +def _omit_schema_default(schema: dict[str, Any]) -> None: + schema.pop("default", None) + + class _MemorySearchHit(BaseModel): @model_serializer(mode="wrap") def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]: # `tags` is on the wire only when the request asked for it: None = not # requested, so the key is dropped. data: dict[str, Any] = handler(self) + if not self.version: + data.pop("version_text", None) + elif "version_text" in data: + data["version_text"] = str(self.version) identity = self._row_identity if identity is not None: for name, value in zip(("agent", "user_id", "session_id"), identity, strict=True): @@ -645,6 +653,8 @@ def _omit_unrequested(self, handler: SerializerFunctionWrapHandler) -> dict[str, superseded_by: str | None = None superseded_at: str | None = None version: int = 0 + # Exact decimal revision. Unknown revisions have no wire value or schema default. + version_text: str = Field(default="", json_schema_extra=_omit_schema_default) # Ingest time (ISO, loom.memory_embeddings.created_at); "" when unknown. The # arrival-order recency in memory.ask reads it. created_at: str = "" diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 02b1c0ded41..2e2a6d4dcd9 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -171,6 +171,12 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l mids = sorted({mid for mid, _, cns, _ in candidates.values() if cns in readable}) if not mids: return states + # A completion published after the links read cannot vouch for those rows. + namespaces = sorted(readable) + checked = await asyncio.gather( + *(code.checked_head(org, cns) for cns in namespaces), return_exceptions=True + ) + coverage = dict(zip(namespaces, checked, strict=True)) links = await store.for_memories(org, mids) except Exception as error: # noqa: BLE001 — unavailable links leave guidance uncertain log.debug("Guidance code links unavailable: %s", type(error).__name__) @@ -179,8 +185,22 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) + positive: dict[str, list[tuple[int, str]]] = defaultdict(list) for index, key in candidates.items(): - states[index] = guidance_link_state(by_revision.get(key, ()), readable) + state = guidance_link_state(by_revision.get(key, ()), readable) + if state in {"fresh", "moved"}: + if not isinstance(coverage.get(key[2]), str) or not coverage[key[2]]: + continue + positive[key[2]].append((index, state)) + else: + states[index] = state + indexed = await asyncio.gather( + *(code.indexed_head(org, cns) for cns in positive), return_exceptions=True + ) + for (cns, hits), head in zip(positive.items(), indexed, strict=True): + if head == coverage[cns]: + for index, state in hits: + states[index] = state return states diff --git a/server/memory/app/search/handler.py b/server/memory/app/search/handler.py index ef715264938..40fe77b1c3b 100644 --- a/server/memory/app/search/handler.py +++ b/server/memory/app/search/handler.py @@ -31,6 +31,7 @@ from server.memory.app.search.output import ( _build_search_output, _finish_search_output, + _select_served_hits, _serve_parked_page, _shape_final_hits, ) @@ -344,18 +345,10 @@ async def handle_memory_search(input: MemorySearchInput) -> MemorySearchOutput: ctx, run, final_hits ) - verdict_hits = final_hits final_hits, calibration, abstain_verdict = await _verdict( - ctx, run, verdict_hits, evidence_support_count + ctx, run, final_hits, evidence_support_count ) - - final_hits, _unit_bodies, _namespaces_searched, guidance_dropped = await _shape_final_hits( - ctx, final_hits - ) - if guidance_dropped: - calibration, abstain_verdict = await _verdict_after_guidance( - ctx, run, verdict_hits, final_hits, evidence_support_count - ) + _unit_bodies, _namespaces_searched = await _shape_final_hits(ctx, final_hits) _output = _build_search_output( ctx, run, @@ -371,16 +364,20 @@ async def handle_memory_search(input: MemorySearchInput) -> MemorySearchOutput: async def _verdict( - ctx: SearchContext, run: _SearchRun, final_hits: list[Any], evidence_support_count: int + ctx: SearchContext, run: _SearchRun, verdict_hits: list[Any], evidence_support_count: int ) -> tuple[list[Any], Any, tuple[bool, str, str]]: - """Phase 21: the verdict, then the term leg's governed hits placed first. The verdict - and every floor read only the hits that are not governed.""" + """Calibrate retrieval, seat governed hits and recalculate if guidance drops any row.""" calibration, abstain_verdict = _calibrate_final_hits( - ctx, run, final_hits, evidence_support_count + ctx, run, verdict_hits, evidence_support_count ) final_hits, abstain_verdict = await term_leg.join( - ctx, run.term_task, final_hits, abstain_verdict + ctx, run.term_task, verdict_hits, abstain_verdict ) + final_hits, guidance_dropped = await _select_served_hits(ctx, final_hits) + if guidance_dropped: + calibration, abstain_verdict = await _verdict_after_guidance( + ctx, run, verdict_hits, final_hits, evidence_support_count + ) return final_hits, calibration, abstain_verdict diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index 55c11bb9e4b..25c9054d1c3 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -301,17 +301,11 @@ def move_stale(hits: list[Any], input: Any) -> list[Any]: return out -async def _shape_final_hits( +async def _select_served_hits( ctx: SearchContext, final_hits: list[_MemorySearchHit] -) -> tuple[list[_MemorySearchHit], tuple[int, int, int], list[str], bool]: - """Phase 22: shape the served hits — decorate, prepend recent/anchor rows, body - floor, move down those whose code changed, unit and source bodies, relative-date - wording, foreign namespace marks, grounded excerpts, optional fields. Returns the - hits, the unit-body counts, the namespaces searched and whether guidance removed rows.""" +) -> tuple[list[_MemorySearchHit], bool]: + """Select and authorize the served rows while their retrieval excerpts are intact.""" input = ctx.input - namespaces = ctx.namespaces - actual_work = ctx.actual_work - _clock = ctx.clock _decorate_hits(final_hits, input=input) recent, stale_recent = await _prepend_recent(final_hits, input, ctx.stale_versions) anchored, stale_anchor = await _prepend_anchor(recent, input, ctx.stale_versions) @@ -328,8 +322,17 @@ async def _shape_final_hits( else: final_hits = move_stale(final_hits, input) guided_hits = await attach_search_guidance(input, final_hits, replay=input.as_of is not None) - guidance_dropped = len(guided_hits) < len(final_hits) - final_hits = guided_hits + return guided_hits, len(guided_hits) < len(final_hits) + + +async def _shape_final_hits( + ctx: SearchContext, final_hits: list[_MemorySearchHit] +) -> tuple[tuple[int, int, int], list[str]]: + """Expand and project the bodies after all verdict inputs have been read.""" + input = ctx.input + namespaces = ctx.namespaces + actual_work = ctx.actual_work + _clock = ctx.clock _unit_bodies = await _expand_unit_bodies( final_hits, input, prefer_entities=list(ctx.effective_entity_filter) ) @@ -365,7 +368,7 @@ async def _shape_final_hits( actual_work["relative_excerpts_grounded"] = ground_hits(final_hits) actual_work.update(await _fill_optional_hit_fields(final_hits, input, _namespaces_searched)) - return final_hits, _unit_bodies, _namespaces_searched, guidance_dropped + return _unit_bodies, _namespaces_searched def _build_search_output( diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 1a20567e9e1..bb1c62050f1 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -296,18 +296,59 @@ async def links(org, ids): assert ids == ["m1"] return [visible, stale] + async def checked_head(org, ns): + assert ns == "code-a" + return "" + monkeypatch.setattr( code_link_reads, "code_namespace_for", lambda org, ns, tags: ns if ns.startswith("code-") else "", ) monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) monkeypatch.setattr(code_link_reads.store, "for_memories", links) assert await code_link_reads.guidance_code_states( "o", [allowed, hidden, unresolved, unbound] ) == ["changed", "unknown", "unknown", "not_applicable"] +@pytest.mark.parametrize("state", ["fresh", "moved"]) +async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, state) -> None: + from server.memory.app import code_link_reads + + row = _excerpt("m1", "allowed") + indexed = "c2" + checked = "c1" + complete_during_read = False + + async def readable(org, namespaces): + assert namespaces == {"code-a"} + return namespaces + + async def links(org, ids): + nonlocal checked + if complete_during_read: + checked = indexed + return [_link("m1", state=state)] + + async def indexed_head(org, ns): + return indexed + + async def checked_head(org, ns): + return checked + + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", links) + monkeypatch.setattr(code_link_reads.code, "indexed_head", indexed_head) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + complete_during_read = True + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + assert await code_link_reads.guidance_code_states("o", [row]) == [state] + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] diff --git a/tests/unit/test_memory_search_handler_gates.py b/tests/unit/test_memory_search_handler_gates.py index 066839fe86c..0d3962816d9 100644 --- a/tests/unit/test_memory_search_handler_gates.py +++ b/tests/unit/test_memory_search_handler_gates.py @@ -214,6 +214,25 @@ async def support(sql, params): assert result.calibration_explanation == baseline.calibration_explanation +async def test_verdict_uses_the_retained_excerpt_when_bodies_are_omitted(search_env, monkeypatch): + from server.memory.app.search import guidance + from server.settings import settings + + monkeypatch.setattr(settings, "memory_search_identifier_grounding", True) + retained = replace(_svc_hit("retained", sim=0.85), content_excerpt="PR 123 needs review") + removed = replace(_svc_hit("removed", sim=0.95), identity=("a", "-", "-"), version=42) + + async def heads(keys): + return {keys[0]: {"version": 42, "tombstoned_at": "now"}} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + search_env.hits = [removed, retained] + result = await _run(search_env, query="PR 123", bodies="none") + + assert [(hit.memory_key, hit.content_excerpt) for hit in result.results] == [("retained", "")] + assert not result.abstain + + async def test_belief_support_binds_exact_namespace_and_key_pairs(monkeypatch) -> None: from server.memory.app.search import evidence_support diff --git a/tests/unit/test_memory_search_writer_wire.py b/tests/unit/test_memory_search_writer_wire.py index ac0bf3c57dd..da8eb1c4d41 100644 --- a/tests/unit/test_memory_search_writer_wire.py +++ b/tests/unit/test_memory_search_writer_wire.py @@ -10,10 +10,12 @@ def test_search_wire_preserves_writer_identity_through_serialization() -> None: content_excerpt="aisle", distance=0.0, similarity=1.0, + version=1_800_000_000_000_000_002, ) hit._row_identity = ("writer-b", "alice", "shared") wire = MemorySearchOutput(results=[hit], embedding_model="test").model_dump(mode="json") assert wire["results"][0]["agent"] == "writer-b" + assert wire["results"][0]["version_text"] == "1800000000000000002" from loom.memory import _parse_search_hit assert _parse_search_hit(wire["results"][0]).agent == "writer-b" From 794256d4c9c38b9160b258f4c66705ac1b0e0222 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:23:44 +0530 Subject: [PATCH 023/117] Hide the matched-text label when search omits excerpts Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/components/SearchWhy.test.tsx | 8 ++++++++ frontend/src/components/SearchWhy.tsx | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SearchWhy.test.tsx b/frontend/src/components/SearchWhy.test.tsx index 3e27a1ef316..4433ae93d99 100644 --- a/frontend/src/components/SearchWhy.test.tsx +++ b/frontend/src/components/SearchWhy.test.tsx @@ -37,6 +37,14 @@ describe("SearchWhy", () => { expect(why).toHaveTextContent("code recheck needed, human review current"); }); + it("shows suggested use without a matched-text line when the excerpt is empty", async () => { + const guidance = { next_step: "recheck_source", reasons: ["code_recheck_needed"] }; + render(); + const why = await open(); + expect(why).toHaveTextContent("Suggested use: recheck source"); + expect(why).not.toHaveTextContent("Matched text:"); + }); + it("is one button until opened; the popover shows rank, similarity, score and the terms by magnitude", async () => { const { container } = render( {hit.use_guidance && ( <> -

Matched text: {hit.content_excerpt}

+ {hit.content_excerpt?.trim() &&

Matched text: {hit.content_excerpt}

} )} From 4b3575d204011ef6ff6ddc12d260800ae42e095b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:52:24 +0530 Subject: [PATCH 024/117] Verify legacy search writers and code freshness Resolve incomplete search writers through a unique scoped list match. Keep positive code guidance off while the index trails the fetched tip or the linked path still needs a parse retry. Signed-off-by: Krishna Dobhal <107910364+krishnadobhal@users.noreply.github.com> --- frontend/src/components/HeaderSearch.test.tsx | 37 +++++++++++++++++- frontend/src/components/HeaderSearch.tsx | 39 +++++++++++++------ frontend/src/lib/memoriesSearch.ts | 33 ++++++++++++++++ frontend/src/views/RecallLab.table.test.tsx | 31 +++++++++++++++ frontend/src/views/RecallLab.tsx | 22 ++++++++++- server/code/app/memory_links.py | 17 ++++++++ server/memory/app/code_link_pass.py | 4 ++ server/memory/app/code_link_reads.py | 39 ++++++++++++++----- server/memory/app/code_link_recheck.py | 4 +- tests/unit/test_memory_code_plane_reads.py | 38 +++++++++++++++--- 10 files changed, 233 insertions(+), 31 deletions(-) diff --git a/frontend/src/components/HeaderSearch.test.tsx b/frontend/src/components/HeaderSearch.test.tsx index c2bd21153a6..c507b366a98 100644 --- a/frontend/src/components/HeaderSearch.test.tsx +++ b/frontend/src/components/HeaderSearch.test.tsx @@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { useStore } from "../lib/state"; import { HeaderSearch } from "./HeaderSearch"; import { sharedMine } from "../lib/sharedReads"; +import { listMemories } from "../api"; // The header search is a WAI-ARIA combobox: focus stays in the input while ↑↓ move the // highlighted option, which the input names through aria-activedescendant. @@ -20,6 +21,7 @@ const written = vi.hoisted(() => ({ })); const catalog = vi.hoisted(() => ({ recent: [] as Array<{ memory_key: string; agent: string }>, + writerRows: [] as Array>, profile: [] as Array<{ label: string; value: string }>, docs: [] as Array<{ source_uri: string; title: string; tags: string[]; chunk_count: number }>, // When set, memory.search answers these hits instead of the two coffee ones. @@ -29,7 +31,10 @@ vi.mock("../api", async (importOriginal) => { const actual = await importOriginal(); return { ...actual, - listMemories: vi.fn(async () => ({ entries: catalog.recent, truncated: false, total: catalog.recent.length })), + listMemories: vi.fn(async (_id, _limit, opts) => { + const entries = opts?.prefix ? catalog.writerRows : catalog.recent; + return { entries, truncated: false, total: entries.length }; + }), listKnowledge: vi.fn(async () => ({ rows: catalog.docs })), listProfile: vi.fn(async () => ({ entries: catalog.profile })), browseNamespaces: vi.fn(async () => []), @@ -50,6 +55,7 @@ beforeEach(() => { inspect.mockReset(); inspectProfile.mockReset(); catalog.recent = []; + catalog.writerRows = []; catalog.profile = []; catalog.docs = []; catalog.hits = null; @@ -62,6 +68,35 @@ beforeEach(() => { }); describe("HeaderSearch", () => { + it.each([false, true])("opens a legacy hit only when its writer is unique (ambiguous: %s)", async (ambiguous) => { + catalog.hits = [{ agent: "a", memory_key: "legacy/note", content_excerpt: "old replica" }]; + const row = { ...written, memory_key: "legacy/note" }; + catalog.writerRows = ambiguous ? [row, { ...row, session_id: "another" }] : [row]; + const user = userEvent.setup(); + render(); + await user.type(screen.getByRole("combobox", { name: "Search Loom" }), "legacy"); + const option = await screen.findByRole("option", { name: /legacy\/note/ }); + await waitFor(() => + expect(listMemories).toHaveBeenCalledWith( + expect.objectContaining({ user_id: "*", session_id: "*" }), + expect.any(Number), + expect.objectContaining({ prefix: "legacy/note", agent: "a" }), + ), + ); + if (ambiguous) expect(option).toHaveAttribute("aria-disabled", "true"); + else await waitFor(() => expect(option).not.toHaveAttribute("aria-disabled")); + await user.click(option); + if (ambiguous) expect(inspect).not.toHaveBeenCalled(); + else + expect(inspect).toHaveBeenCalledWith("legacy/note", { + agent: "a", + userId: "u", + sessionId: "s", + namespace: "team", + exact: true, + }); + }); + // The group heading names the type, so a row leads with the type's icon instead of a // coloured "memory" badge and carries no memory-type label (the inspector shows it); line // 1 is the key, line 2 the excerpt. diff --git a/frontend/src/components/HeaderSearch.tsx b/frontend/src/components/HeaderSearch.tsx index 4c7aafe530e..5c423b77e43 100644 --- a/frontend/src/components/HeaderSearch.tsx +++ b/frontend/src/components/HeaderSearch.tsx @@ -21,7 +21,7 @@ import { type SearchHit, } from "../api"; import { isCollectionName } from "../lib/namespace"; -import { namesWriter, rowIdentity } from "../lib/memoriesSearch"; +import { namesWriter, resolveSearchWriter, rowIdentity, type SearchWriter } from "../lib/memoriesSearch"; import { sharedMine } from "../lib/sharedReads"; import { useStore } from "../lib/state"; import { useAbortableEffect } from "../lib/hooks"; @@ -44,6 +44,8 @@ const MEMORY_TOP_K = 8; const MEMORY_DEBOUNCE_MS = 200; const MEMORY_MIN_CHARS = 2; +type HeaderHit = SearchHit & { inspectWriter?: SearchWriter }; + interface NsRow { namespace: string; visibility: string; @@ -98,7 +100,7 @@ export function HeaderSearch({ // Three newest rows for the empty-state "Recent memories" group; the // memory group itself comes from memory.search below. const [recent, setRecent] = useState([]); - const [hits, setHits] = useState([]); + const [hits, setHits] = useState([]); const [searching, setSearching] = useState(false); const [docs, setDocs] = useState([]); const [profileSections, setProfileSections] = useState([]); @@ -288,8 +290,25 @@ export function HeaderSearch({ window.setTimeout(() => { if (!live()) return; searchMemory(identity, memoryQuery, { top_k: MEMORY_TOP_K, tags, signal }) - .then((r) => { - if (live()) setHits(r.results || []); + .then(async (r) => { + if (!live()) return; + const results = r.results || []; + setHits( + results.map((hit) => ({ + ...hit, + inspectWriter: namesWriter(hit) && !hit.memory_key.startsWith("chunk:") ? hit : undefined, + })), + ); + setSearching(false); + await Promise.all( + results.map(async (hit, index) => { + if (namesWriter(hit)) return; + const writer = await resolveSearchWriter(identity, hit, signal); + if (live() && writer) { + setHits((shown) => shown.map((row, i) => (i === index ? { ...row, inspectWriter: writer } : row))); + } + }), + ); }) .catch(() => { if (live()) setHits([]); @@ -344,8 +363,7 @@ export function HeaderSearch({ // A row opens as the one written by its agent, user and session: another session's row of // the same key is not it. A listed row that names no writer (an older server) opens by key, - // as before. A search hit opens only when it names its writer: a shared or chunk hit, or - // one that does not, has no row of its own to open, and is not offered as one. + // as before. A ranked hit opens only after its writer is known. const openMemory = ( e: Pick & { namespace?: string }, ) => { @@ -363,8 +381,7 @@ export function HeaderSearch({ ); setOpen(false); }; - const openable = (h: SearchHit) => namesWriter(h) && !h.memory_key.startsWith("chunk:"); - const openHit = (h: SearchHit) => openable(h) && openMemory(h); + const openHit = (h: HeaderHit) => h.inspectWriter && openMemory({ memory_key: h.memory_key, ...h.inspectWriter }); const openDocument = (d: KnowledgeEntry) => { openDoc(d.source_uri); @@ -419,7 +436,7 @@ export function HeaderSearch({ | { kind: "recent"; mem: MemoryListEntry } | { kind: "ns"; ns: NsRow } | { kind: "profile"; section: ProfileEntry } - | { kind: "mem"; mem: SearchHit } + | { kind: "mem"; mem: HeaderHit } | { kind: "doc"; doc: KnowledgeEntry }; const activations: Activation[] = useMemo( () => [ @@ -792,7 +809,7 @@ export function HeaderSearch({ type="button" key={namesWriter(e) ? rowIdentity(identity?.namespace ?? "", e) : idx} {...optionProps(idx)} - aria-disabled={!openable(e) || undefined} + aria-disabled={!e.inspectWriter || undefined} onClick={() => openHit(e)} >
@@ -805,7 +822,7 @@ export function HeaderSearch({ {e.content_excerpt || "(empty)"}
- {!openable(e) &&
Preview only
} + {!e.inspectWriter &&
Preview only
} ); })} diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 1133c9c4d16..0724e96bbd1 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -3,6 +3,7 @@ // holds the query (memory.list `contains`, newest first), then the ranked hits they do // not already hold. +import { listMemories, type Identity, type SearchHit } from "../api"; import { SENTINEL_AGENTS } from "./format"; /** Keyword matches a search shows ahead of the ranked hits (a viewer's list page is 100). */ @@ -14,6 +15,38 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: return Boolean(r.agent && !SENTINEL_AGENTS.has(r.agent) && r.agent !== "_shared" && r.user_id && r.session_id); } +export type SearchWriter = Pick; + +/** Older search responses name the agent but may omit its user or session. */ +export async function resolveSearchWriter( + identity: Identity, + hit: SearchHit, + signal: AbortSignal, +): Promise { + const { agent, user_id, session_id } = hit; + if (!agent || SENTINEL_AGENTS.has(agent) || agent === "_shared" || hit.memory_key.startsWith("chunk:")) return; + if (namesWriter(hit)) return hit; + + const namespace = hit.namespace || identity.namespace; + const page = await listMemories( + { ...identity, namespace, user_id: user_id || "*", session_id: session_id || "*" }, + KEYWORD_PAGE, + { agent, prefix: hit.memory_key, include_profile: true, fields: ["agent", "user_id", "session_id"], signal }, + ).catch(() => null); + if (!page || signal.aborted || page.truncated || page.total > page.entries.length) return; + const matches = page.entries.filter( + (row) => + row.memory_key === hit.memory_key && + (!row.agent || row.agent === agent) && + (!user_id || !row.user_id || row.user_id === user_id) && + (!session_id || !row.session_id || row.session_id === session_id), + ); + const [row] = matches; + if (matches.length === 1 && row && namesWriter(row)) { + return { agent: row.agent, user_id: row.user_id, session_id: row.session_id, namespace }; + } +} + /** A row's own id: `(namespace, agent, user, session, key)`, which is what two rows of one * key differ by; `[key]` alone when the row does not name its writer. The two shapes differ * in length, so a key cannot make one pass for the other. */ diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index b01fd9dc6eb..1ba19ea50fd 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -154,6 +154,37 @@ describe("Recall Lab: the scores table", () => { expect(useStore.getState().inspectedMemoryKey).toBe("deploy_note"); }); + it.each([false, true])( + "opens a legacy ranked-only hit only when its writer is unique (ambiguous: %s)", + async (ambiguous) => { + searchMemory.mockResolvedValue({ results: [hit("legacy_note", 0.9, { agent: "writer", session_id: "one" })] }); + const row = { ...entry("legacy_note"), agent: "writer", user_id: "u", session_id: "one" }; + listMemories.mockImplementation(async (_identity, _limit, opts) => { + const entries = !opts?.prefix ? [] : ambiguous ? [row, { ...row, user_id: "other" }] : [row]; + return { entries, total: entries.length, today: 0, truncated: false }; + }); + render(); + const button = within(await score()).getByRole("button", { name: "legacy_note" }); + await waitFor(() => + expect(listMemories).toHaveBeenCalledWith( + expect.objectContaining({ user_id: "*", session_id: "one" }), + expect.any(Number), + expect.objectContaining({ prefix: "legacy_note", agent: "writer" }), + ), + ); + if (ambiguous) expect(button).toBeDisabled(); + else await waitFor(() => expect(button).toBeEnabled()); + fireEvent.click(button); + if (ambiguous) expect(useStore.getState().inspectedMemoryKey).toBeNull(); + else + expect(useStore.getState()).toMatchObject({ + inspectedMemoryKey: "legacy_note", + inspectedOwner: { user_id: "u", session_id: "one" }, + inspectedScope: { namespace: "ns", exact: true }, + }); + }, + ); + it("keeps chunk, shared and sentinel hits visible without opening a namesake", async () => { searchMemory.mockResolvedValue({ results: [ diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 7be26c54d68..f761a2b43c7 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -18,7 +18,15 @@ import { ListState } from "../components/ui/ListState"; import { ListToolbar } from "../components/ui/ListToolbar"; import { displayAgent, previewValue, SENSITIVE_LABEL } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; -import { KEYWORD_PAGE, keywordThenRanked, namesWriter, parseSearchQuery, rowIdentity } from "../lib/memoriesSearch"; +import { + KEYWORD_PAGE, + keywordThenRanked, + namesWriter, + parseSearchQuery, + resolveSearchWriter, + rowIdentity, + type SearchWriter, +} from "../lib/memoriesSearch"; import { signed, termText, whyTerms } from "../lib/whyNote"; import { AskAboutThis, exact, quoted } from "../components/AskAboutThis"; @@ -269,7 +277,7 @@ interface RecallRow { text: string; memoryType: string; keyword: boolean; - writer: Pick; + writer: SearchWriter; hit?: SearchHit; } @@ -534,6 +542,16 @@ export function RecallLab() { setAbstain(Boolean(r?.abstain) && keyword.size === 0); setModel(r?.embedding_model ?? ""); setRankedError(failure); + setLoading(false); + await Promise.all( + [...ranked].map(async ([id, hit]) => { + if (namesWriter(hit)) return; + const writer = await resolveSearchWriter(identity, hit, ac.signal); + if (!ac.signal.aborted && writer) { + setRows((shown) => shown?.map((row) => (row.id === id ? { ...row, writer } : row)) ?? null); + } + }), + ); } catch (e) { if (ac.signal.aborted) return; setError(e); diff --git a/server/code/app/memory_links.py b/server/code/app/memory_links.py index e793b848b7e..f22656b7687 100644 --- a/server/code/app/memory_links.py +++ b/server/code/app/memory_links.py @@ -73,6 +73,23 @@ async def indexed_head(org: str, namespace: str) -> str: return await CodeRepo().get_state(org, namespace, "git_head") +async def caught_up_heads(org: str, namespaces: Sequence[str]) -> dict[str, str]: + """Indexed heads that include the latest fetched tip of their branch.""" + from server.code.app.common import mirror_fetch_overdue + from server.code.app.index_status import published_clone_head + + states = await CodeRepo().all_state_many([(org, ns) for ns in namespaces]) + caught_up = {} + for (_, ns), state in states.items(): + cfg = repo_for_namespace(org, ns) + if cfg is None or mirror_fetch_overdue((state.get("clone_head") or {}).get("updated_at")): + continue + tip = published_clone_head(state, cfg.git_branch) + if tip and (state.get("git_head") or {}).get("value") == tip: + caught_up[ns] = tip + return caught_up + + async def kept_paths(org: str, namespace: str, base: str, head: str) -> dict[str, str] | None: """path -> its path at `head` ('' = deleted) for the paths `base..head` changed; None when `base` is not an ancestor of `head` (a force-push) or git cannot tell.""" diff --git a/server/memory/app/code_link_pass.py b/server/memory/app/code_link_pass.py index 2798d3f2790..c13187157e8 100644 --- a/server/memory/app/code_link_pass.py +++ b/server/memory/app/code_link_pass.py @@ -297,3 +297,7 @@ async def write(self, value: T) -> None: async def clear(self) -> None: await code.set_link_cursor(self.name, "") + + +def unparsed_cursor(org: str, namespace: str) -> Cursor[list[str]]: + return Cursor(f"unparsed/{org}/{namespace}", []) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 2e2a6d4dcd9..8d4b175ee73 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -16,6 +16,7 @@ from server.code.domain.index.repos import RegistryUnread, configured_repos from server.core.hashing import hash_text from server.memory.api.models_crud import CodeLink +from server.memory.app.code_link_pass import unparsed_cursor from server.memory.domain import code_change from server.memory.domain.redaction_lineage import is_content_hash from server.memory.store import code_links as store @@ -142,6 +143,21 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: return state or "unknown" +async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str]]: + checked = await code.checked_head(org, cns) + return checked, set(await unparsed_cursor(org, cns).read()) if checked else set() + + +async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, str]: + if not namespaces: + return {} + try: + return await code.caught_up_heads(org, namespaces) + except Exception as error: # noqa: BLE001 — unavailable coverage leaves guidance uncertain + log.debug("Guidance code heads unavailable: %s", type(error).__name__) + return {} + + async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: """Classify every readable link made from the evidence in the served memory revision.""" states = ["unknown"] * len(rows) @@ -174,7 +190,7 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l # A completion published after the links read cannot vouch for those rows. namespaces = sorted(readable) checked = await asyncio.gather( - *(code.checked_head(org, cns) for cns in namespaces), return_exceptions=True + *(_guidance_coverage(org, cns) for cns in namespaces), return_exceptions=True ) coverage = dict(zip(namespaces, checked, strict=True)) links = await store.for_memories(org, mids) @@ -185,20 +201,23 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) - positive: dict[str, list[tuple[int, str]]] = defaultdict(list) + positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) for index, key in candidates.items(): - state = guidance_link_state(by_revision.get(key, ()), readable) + rows_for_hit = by_revision.get(key, []) + state = guidance_link_state(rows_for_hit, readable) if state in {"fresh", "moved"}: - if not isinstance(coverage.get(key[2]), str) or not coverage[key[2]]: + proof = coverage.get(key[2]) + if not isinstance(proof, tuple): + continue + checked_head, owed = proof + if not checked_head or any(link["path"] in owed for link in rows_for_hit): continue - positive[key[2]].append((index, state)) + positive[key[2], checked_head].append((index, state)) else: states[index] = state - indexed = await asyncio.gather( - *(code.indexed_head(org, cns) for cns in positive), return_exceptions=True - ) - for (cns, hits), head in zip(positive.items(), indexed, strict=True): - if head == coverage[cns]: + indexed = await _guidance_indexed_heads(org, [cns for cns, _ in positive]) + for (cns, checked_head), hits in positive.items(): + if indexed.get(cns) == checked_head: for index, state in hits: states[index] = state return states diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index f2814bb1b5f..fd8c261eae5 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -275,11 +275,11 @@ async def _retry_unparsed( async def _unparsed(org: str, cns: str) -> set[str]: - return set(await link_pass.Cursor[list[str]](f"unparsed/{org}/{cns}", []).read()) + return set(await link_pass.unparsed_cursor(org, cns).read()) async def _set_unparsed(org: str, cns: str, paths: set[str]) -> None: - await link_pass.Cursor[list[str]](f"unparsed/{org}/{cns}", []).write(sorted(paths)) + await link_pass.unparsed_cursor(org, cns).write(sorted(paths)) async def _lost(org: str, cns: str, paths: set[str]) -> list[LinkRow]: diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index bb1c62050f1..144bc5d782b 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -6,6 +6,7 @@ from __future__ import annotations import asyncio +from types import SimpleNamespace from typing import Any import pytest @@ -300,6 +301,10 @@ async def checked_head(org, ns): assert ns == "code-a" return "" + async def link_cursor(name): + assert name == "unparsed/o/code-a" + return "" + monkeypatch.setattr( code_link_reads, "code_namespace_for", @@ -307,6 +312,7 @@ async def checked_head(org, ns): ) monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) monkeypatch.setattr(code_link_reads.store, "for_memories", links) assert await code_link_reads.guidance_code_states( "o", [allowed, hidden, unresolved, unbound] @@ -318,8 +324,10 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st from server.memory.app import code_link_reads row = _excerpt("m1", "allowed") - indexed = "c2" - checked = "c1" + indexed = "a" * 40 + checked = indexed + fetched = "b" * 40 + unparsed = "" complete_during_read = False async def readable(org, namespaces): @@ -332,20 +340,40 @@ async def links(org, ids): checked = indexed return [_link("m1", state=state)] - async def indexed_head(org, ns): - return indexed + async def all_state_many(pairs): + assert pairs == [("o", "code-a")] + return { + ("o", "code-a"): { + "clone_head": {"value": fetched, "detail": "main"}, + "git_head": {"value": indexed}, + }, + } async def checked_head(org, ns): return checked + async def link_cursor(name): + return unparsed + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.store, "for_memories", links) - monkeypatch.setattr(code_link_reads.code, "indexed_head", indexed_head) + monkeypatch.setattr( + code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") + ) + monkeypatch.setattr( + code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) + ) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + indexed = fetched assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] complete_during_read = True assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + unparsed = '["src/a.py"]' + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + unparsed = '["src/other.py"]' assert await code_link_reads.guidance_code_states("o", [row]) == [state] From 77e74628c89e17bf2f599acc0680d3ed7d4fa465 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:32:39 +0530 Subject: [PATCH 025/117] The reach manifest counts memory.delete_version as called by the dashboard Signed-off-by: Krishna Dobhal --- server/operations/dashboard.py | 1 - server/operations/reach_manifest.py | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/operations/dashboard.py b/server/operations/dashboard.py index 05813a1f595..90bc78e107d 100644 --- a/server/operations/dashboard.py +++ b/server/operations/dashboard.py @@ -170,7 +170,6 @@ def _named_once(*groups: dict[str, str]) -> dict[str, str]: "knowledge.bulk_add", "memory.append_batch", "memory.bulk_set", - "memory.delete_version", "memory.export_evidence", "memory.import_evidence", "memory.keys", diff --git a/server/operations/reach_manifest.py b/server/operations/reach_manifest.py index b69190c5d4e..d0b485fe955 100644 --- a/server/operations/reach_manifest.py +++ b/server/operations/reach_manifest.py @@ -630,7 +630,10 @@ "plugin_hook", "dashboard", ), - "memory.delete_version": ("sdk_method",), + "memory.delete_version": ( + "sdk_method", + "dashboard", + ), "memory.demonstrate": ("sdk_method",), "memory.demote": ( "sdk_method", From 43f92de9a9605f2fce92aaab168d2c3bafe4a5ce Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:33:16 +0530 Subject: [PATCH 026/117] A search card's preview lookup advances by the rows the server returned Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 16 ++++++++++++++++ frontend/src/views/memoryListReads.ts | 6 ++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index f25a00923a7..213d852541d 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -265,6 +265,22 @@ describe("Recent search with one key written by two sessions", () => { expect(screen.queryByText(/Suggested use/)).toBeNull(); }); + it("finds a ranked row's preview past pages the server caps below the page size", async () => { + const all = [ + ...Array.from({ length: 10 }, (_, i) => written(`other${i}`)), + written("one", { sensitivity: "high", version: 2, version_text: "2", value: null }), + ...Array.from({ length: 4 }, (_, i) => written(`late${i}`)), + ]; + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + if (!opts?.prefix) return { entries: opts?.contains ? [] : [written("two")], total: 1, today: 0, truncated: false }; + const offset = opts.offset ?? 0; + return { entries: all.slice(offset, offset + 10), total: all.length, today: 0, truncated: false }; + }); + vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); + await search(); + expect(await screen.findByText(SENSITIVE_LABEL)).toBeInTheDocument(); + }); + it("uses a list preview when an unloaded ranked writer's row becomes high sensitivity", async () => { vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { const entries = opts?.prefix diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index fb70668e46c..97f5610beed 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -78,7 +78,7 @@ async function readSearchPreview( const writer = namesWriter(hit); const scope = writer ? { ...identity, user_id: hit.user_id, session_id: hit.session_id } : identity; const key = rowIdentity(identity.namespace, hit); - for (let offset = 0; !signal.aborted; offset += KEYWORD_PAGE) { + for (let offset = 0; !signal.aborted; ) { const page = await listMemories(scope, KEYWORD_PAGE, { agent: writer ? hit.agent : undefined, prefix: hit.memory_key, @@ -89,7 +89,9 @@ async function readSearchPreview( }); const entry = page.entries.find((row) => rowIds(identity.namespace, row).includes(key)); if (entry) return { ...entry, value: entry.value ?? null }; - if (offset + KEYWORD_PAGE >= page.total) break; + // The server may cap a page below KEYWORD_PAGE: advance by the rows it returned. + offset += page.entries.length; + if (!page.entries.length || offset >= page.total) break; } return null; } From 6977c2ce70cdbaada75f74b6eb50dfd50420f6de Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:34:01 +0530 Subject: [PATCH 027/117] A legacy hit's writer lookup sends the pinned user and never a refused wildcard Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 50 +++++++++++++++++++++++++ frontend/src/lib/memoriesSearch.ts | 12 +++++- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 frontend/src/lib/memoriesSearch.test.ts diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts new file mode 100644 index 00000000000..c0f36ef452f --- /dev/null +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -0,0 +1,50 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { SearchHit } from "../api"; + +vi.mock("../api", () => ({ + listMemories: vi.fn(), + storedToken: vi.fn(), +})); +import { listMemories, storedToken } from "../api"; +import { resolveSearchWriter } from "./memoriesSearch"; + +const jwt = (claims: Record) => `h.${btoa(JSON.stringify(claims))}.s`; +const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; +const hit = { memory_key: "deploy_note", agent: "claude-desktop" } as SearchHit; +const ABORT = new AbortController().signal; + +describe("resolveSearchWriter under a narrowed token", () => { + beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(listMemories).mockResolvedValue({ + entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + total: 1, + truncated: false, + } as never); + }); + + it("sends the pinned user and no user wildcard", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({ read_user_id: "u1" })); + expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1", session_id: "s1" }); + // the session wildcard is still allowed under own_user + expect(vi.mocked(listMemories).mock.calls[0][0]).toMatchObject({ user_id: "u1", session_id: "*" }); + }); + + it("does not ask when the token narrows reads and no user is known", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({ read_scope: "own_user" })); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + expect(listMemories).not.toHaveBeenCalled(); + }); + + it("does not send a session wildcard under an own-session token", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({ read_scope: "own_session", read_user_id: "u1" })); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + expect(listMemories).not.toHaveBeenCalled(); + }); + + it("keeps the wildcards for a namespace-wide token", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + await resolveSearchWriter(identity, hit, ABORT); + expect(vi.mocked(listMemories).mock.calls[0][0]).toMatchObject({ user_id: "*", session_id: "*" }); + }); +}); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 0724e96bbd1..f49b0237071 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -3,7 +3,8 @@ // holds the query (memory.list `contains`, newest first), then the ranked hits they do // not already hold. -import { listMemories, type Identity, type SearchHit } from "../api"; +import { listMemories, storedToken, type Identity, type SearchHit } from "../api"; +import { tokenReadScope } from "../views/assistant/tokenScope"; import { SENTINEL_AGENTS } from "./format"; /** Keyword matches a search shows ahead of the ranked hits (a viewer's list page is 100). */ @@ -27,9 +28,16 @@ export async function resolveSearchWriter( if (!agent || SENTINEL_AGENTS.has(agent) || agent === "_shared" || hit.memory_key.startsWith("chunk:")) return; if (namesWriter(hit)) return hit; + // A token that narrows reads is refused the `*` wildcard (`resolve_read_filters`): send the + // pinned user, and give up when no user (or, for an own-session token, no session) is known. + const scope = tokenReadScope(storedToken()); + const uid = user_id || scope?.readUserId || (scope?.readScope ? "" : "*"); + const sid = session_id || (scope?.readScope === "own_session" ? "" : "*"); + if (!uid || !sid) return; + const namespace = hit.namespace || identity.namespace; const page = await listMemories( - { ...identity, namespace, user_id: user_id || "*", session_id: session_id || "*" }, + { ...identity, namespace, user_id: uid, session_id: sid }, KEYWORD_PAGE, { agent, prefix: hit.memory_key, include_profile: true, fields: ["agent", "user_id", "session_id"], signal }, ).catch(() => null); From a53adc398345b65c7f5d815db1e13b410176d60d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:35:46 +0530 Subject: [PATCH 028/117] Recall Lab names a legacy ranked hit's writer before it merges with the keyword rows Signed-off-by: Krishna Dobhal --- .../views/RecallLab.memoriesOrder.test.tsx | 17 ++++++++++++++++ frontend/src/views/RecallLab.tsx | 20 +++++++++---------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index cd84da05dd9..357142ccb49 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -124,6 +124,23 @@ describe("Recall Lab and the Memories list", () => { expect(screen.getAllByText("semantic +0.60")).toHaveLength(2); }); + it("shows one row for a memory the keyword read and a legacy ranked hit both hold", async () => { + const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; + const page = { entries: [held], total: 1, today: 0, truncated: false }; + // the keyword read, then the lookup that names the hit's writer + vi.mocked(listMemories).mockResolvedValueOnce(page).mockResolvedValueOnce(page); + // A legacy hit names its agent but not the user or session. + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await screen.findByText("keyword match", {}, { timeout: 3000 }); + await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(1)); + }); + it("shows a high keyword match as sensitive, not as an empty row", async () => { vi.mocked(listMemories).mockResolvedValueOnce({ entries: [{ ...entry("vault_azure"), value: null, value_truncated: true, sensitivity: "high" }], diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index f761a2b43c7..1b3da61df96 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -514,9 +514,16 @@ export function RecallLab() { const keyword = new Map( (kw?.entries ?? []).map((e, i) => [recallRowId(identity.namespace, e, `keyword:${i}`), e]), ); - const ranked = new Map( - (r?.results ?? []).map((h, i) => [recallRowId(identity.namespace, h, `ranked:${i}`), h]), + // A legacy hit omits its writer: name it before keying, so a keyword row of the same + // memory is one row, not two. + const named = await Promise.all( + (r?.results ?? []).map(async (h) => { + const writer = namesWriter(h) ? undefined : await resolveSearchWriter(identity, h, ac.signal); + return writer ? { ...h, ...writer } : h; + }), ); + if (ac.signal.aborted) return; + const ranked = new Map(named.map((h, i) => [recallRowId(identity.namespace, h, `ranked:${i}`), h])); const order = keywordThenRanked([...keyword.keys()], [...ranked.keys()]); setRowsQuery(q); setRows( @@ -543,15 +550,6 @@ export function RecallLab() { setModel(r?.embedding_model ?? ""); setRankedError(failure); setLoading(false); - await Promise.all( - [...ranked].map(async ([id, hit]) => { - if (namesWriter(hit)) return; - const writer = await resolveSearchWriter(identity, hit, ac.signal); - if (!ac.signal.aborted && writer) { - setRows((shown) => shown?.map((row) => (row.id === id ? { ...row, writer } : row)) ?? null); - } - }), - ); } catch (e) { if (ac.signal.aborted) return; setError(e); From 1f85cf92c575b863e406b77b4b0255c9cec3fbc5 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:45:10 +0530 Subject: [PATCH 029/117] Biome formatting of the search lookups and their tests Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.ts | 12 +++++++----- frontend/src/views/Recent.search.test.tsx | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index f49b0237071..d53571e7ba9 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -36,11 +36,13 @@ export async function resolveSearchWriter( if (!uid || !sid) return; const namespace = hit.namespace || identity.namespace; - const page = await listMemories( - { ...identity, namespace, user_id: uid, session_id: sid }, - KEYWORD_PAGE, - { agent, prefix: hit.memory_key, include_profile: true, fields: ["agent", "user_id", "session_id"], signal }, - ).catch(() => null); + const page = await listMemories({ ...identity, namespace, user_id: uid, session_id: sid }, KEYWORD_PAGE, { + agent, + prefix: hit.memory_key, + include_profile: true, + fields: ["agent", "user_id", "session_id"], + signal, + }).catch(() => null); if (!page || signal.aborted || page.truncated || page.total > page.entries.length) return; const matches = page.entries.filter( (row) => diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index 213d852541d..00317beeb66 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -272,7 +272,8 @@ describe("Recent search with one key written by two sessions", () => { ...Array.from({ length: 4 }, (_, i) => written(`late${i}`)), ]; vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { - if (!opts?.prefix) return { entries: opts?.contains ? [] : [written("two")], total: 1, today: 0, truncated: false }; + if (!opts?.prefix) + return { entries: opts?.contains ? [] : [written("two")], total: 1, today: 0, truncated: false }; const offset = opts.offset ?? 0; return { entries: all.slice(offset, offset + 10), total: all.length, today: 0, truncated: false }; }); From 62f8683e0168d712e24068d631897ee06c571278 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 22:55:26 +0530 Subject: [PATCH 030/117] Positive code guidance needs evidence that the head's recheck pass saw the link The recheck records when its pass began reading links together with the checked head. A link served as fresh or moved must have been rechecked at that head or written before that read, so a link built from an older commit and inserted after the pass snapshotted is unknown rather than vouched for by a checkpoint it was never part of. Signed-off-by: Krishna Dobhal --- server/code/app/memory_links.py | 19 +++++- server/memory/app/code_link_reads.py | 17 ++++-- server/memory/app/code_link_recheck.py | 17 ++++-- tests/unit/test_memory_code_links.py | 13 +++-- tests/unit/test_memory_code_plane_reads.py | 67 ++++++++++++++++++++++ 5 files changed, 116 insertions(+), 17 deletions(-) diff --git a/server/code/app/memory_links.py b/server/code/app/memory_links.py index f22656b7687..c4eb05b4202 100644 --- a/server/code/app/memory_links.py +++ b/server/code/app/memory_links.py @@ -443,13 +443,26 @@ async def refresh_repos() -> None: _MARK = "memory_links_checked" +async def _checked_mark(org: str, namespace: str) -> tuple[str, int]: + head, _, since = (await CodeRepo().get_state(org, namespace, _MARK)).partition("@") + return head, int(since) if since.isdigit() else 0 + + async def checked_head(org: str, namespace: str) -> str: """The head the namespace's memory links were last checked at.""" - return await CodeRepo().get_state(org, namespace, _MARK) + return (await _checked_mark(org, namespace))[0] + + +async def checked_since(org: str, namespace: str) -> int: + """When (`time.time_ns`) the pass that checked `checked_head` began reading its links; + 0 when the mark does not say. A link row written before it was seen by that pass.""" + return (await _checked_mark(org, namespace))[1] -async def set_checked_head(org: str, namespace: str, head: str) -> None: - await CodeRepo().set_state(org, namespace, _MARK, head) +async def set_checked_head(org: str, namespace: str, head: str, since: int = 0) -> None: + """Record `head` as checked by a pass that began reading links at `since`, in one value + so a reader never pairs a head with another pass's start.""" + await CodeRepo().set_state(org, namespace, _MARK, f"{head}@{since}" if since else head) _CURSOR_NS = "memory_code_links" diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 8d4b175ee73..a57f03e0784 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -143,9 +143,12 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: return state or "unknown" -async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str]]: +async def _guidance_coverage(org: str, cns: str) -> tuple[str, int, set[str]]: + # the start first: a pass finishing between the reads leaves an older start with a newer + # head, which vouches for less + since = await code.checked_since(org, cns) checked = await code.checked_head(org, cns) - return checked, set(await unparsed_cursor(org, cns).read()) if checked else set() + return checked, since, set(await unparsed_cursor(org, cns).read()) if checked else set() async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, str]: @@ -209,8 +212,14 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, owed = proof - if not checked_head or any(link["path"] in owed for link in rows_for_hit): + checked_head, since, owed = proof + # The head's pass saw a link only if it was rechecked at that head or written + # before the pass read its links; a later write may be from an older commit. + if not checked_head or any( + link["path"] in owed + or (link["checked_commit"] != checked_head and link["version"] >= since) + for link in rows_for_hit + ): continue positive[key[2], checked_head].append((index, state)) else: diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index fd8c261eae5..ed2f4c499de 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -117,7 +117,11 @@ async def _recheck_repository( await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) if head and head != checked: - cut_at = (await _progress(org, cns).read()).get("head", "") + cut = await _progress(org, cns).read() + cut_at = cut.get("head", "") + # links written after this are not in the pass's reads; a pass the deadline cut keeps + # the start of its first run + since = min(time_ns(), int(cut.get("since") or time_ns())) if cut_at and cut_at != head and not await files.has(cut_at): # gone with a rewrite: what that pass already wrote is in no diff, so every # link is rechecked, as after a force-push @@ -127,11 +131,11 @@ async def _recheck_repository( elif cut_at and cut_at != head: # a pass the deadline cut at another head finishes there first, so every # head is followed in turn and no move it made is left behind - await _follow(org, cns, checked, cut_at, files, result) - await code.set_checked_head(org, cns, cut_at) + await _follow(org, cns, checked, cut_at, files, result, since) + await code.set_checked_head(org, cns, cut_at, since) checked = cut_at - await _follow(org, cns, checked, head, files, result) - await code.set_checked_head(org, cns, head) + await _follow(org, cns, checked, head, files, result, since) + await code.set_checked_head(org, cns, head, since) await policy.apply_policies(org, cns, head, files, budget, result) @@ -168,6 +172,7 @@ async def _follow( head: str, files: link_pass.RepoReads, result: link_pass.PassResult, + since: int, ) -> None: """Recheck, path by path, the links `checked..head` may have changed (all of them without a range), writing every `_PATHS_PER_WRITE` paths and recording the last one @@ -207,7 +212,7 @@ async def _follow( result.rechecked += len(moves) if len(unparsed) > known: # owed before the cursor moves past them await _set_unparsed(org, cns, unparsed) - await progress.write({"head": head, "after": part[-1]}) + await progress.write({"head": head, "after": part[-1], "since": str(since)}) await progress.clear() if failed: result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 54f466bc4d3..9355b55d14e 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -1253,12 +1253,14 @@ async def nothing(*a, **k): files = code_link_pass.RepoReads("o", "code-a") with pytest.raises(TimeoutError): await code_link_recheck._follow( - "o", "code-a", "c1", "c2", files, code_link_pass.PassResult() + "o", "code-a", "c1", "c2", files, code_link_pass.PassResult(), 0 ) first = list(seen) seen.clear() monkeypatch.setattr(code_link_recheck, "_recheck", lambda *a, **_: _record(seen, a[2])) - await code_link_recheck._follow("o", "code-a", "c1", "c2", files, code_link_pass.PassResult()) + await code_link_recheck._follow( + "o", "code-a", "c1", "c2", files, code_link_pass.PassResult(), 0 + ) # the first part was written: the next pass starts after it, and ends clean assert seen == paths[code_link_recheck._PATHS_PER_WRITE :] and first[0] == paths[0] assert cursor["recheck/o/code-a"] == "" @@ -1968,6 +1970,7 @@ async def put(name, value): "h2", code_link_pass.RepoReads("o", "code-a"), code_link_pass.PassResult(), + 0, ) assert read[0] == ["a.py", "b.py", "gone.py"] @@ -2005,7 +2008,7 @@ async def indexed_head(org, cns): async def checked_head(org, cns): return state["checked"] - async def set_checked_head(org, cns, at): + async def set_checked_head(org, cns, at, since=0): state["checked"] = at for module, name in ( @@ -2778,7 +2781,9 @@ async def current(org, found): monkeypatch.setattr(code_link_recheck, "_write_moves", write) monkeypatch.setattr(code_link_recheck, "_current_moves", current) files = code_link_pass.RepoReads("o", "code-a") - await code_link_recheck._follow("o", "code-a", base, head, files, code_link_pass.PassResult()) + await code_link_recheck._follow( + "o", "code-a", base, head, files, code_link_pass.PassResult(), 0 + ) assert [(m.link.state, m.link.path) for m in moves] == [after] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 144bc5d782b..c781e6d5965 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -178,6 +178,10 @@ def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", ** } +async def _checked_since(org, ns): + return 1000 # the pass read its links at 1000; `_link` rows are written at 0 + + def _excerpt(mid: str, key: str, *, pinned: int = 0) -> dict: return { "mid": mid, @@ -312,6 +316,7 @@ async def link_cursor(name): ) monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) monkeypatch.setattr(code_link_reads.store, "for_memories", links) assert await code_link_reads.guidance_code_states( @@ -365,6 +370,7 @@ async def link_cursor(name): code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) ) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] indexed = fetched @@ -377,6 +383,67 @@ async def link_cursor(name): assert await code_link_reads.guidance_code_states("o", [row]) == [state] +async def test_positive_code_guidance_needs_evidence_for_each_link(monkeypatch) -> None: + from server.memory.app import code_link_reads + + head = "a" * 40 + old = "c" * 40 + row = _excerpt("m1", "allowed") + stored = [] + + async def readable(org, namespaces): + return namespaces + + async def links(org, ids): + return stored + + async def all_state_many(pairs): + return { + ("o", "code-a"): { + "clone_head": {"value": head, "detail": "main"}, + "git_head": {"value": head}, + } + } + + async def checked_head(org, ns): + return head + + async def link_cursor(name): + return "" + + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", links) + monkeypatch.setattr( + code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") + ) + monkeypatch.setattr( + code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) + ) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + + # written before the pass read its links, still at an older commit: the pass covered it + stored[:] = [_link("m1") | {"checked_commit": old, "version": 999}] + assert await code_link_reads.guidance_code_states("o", [row]) == ["fresh"] + # written after that read from an older commit, then the checkpoint advanced: nothing + # checked it at this head + stored[:] = [_link("m1") | {"checked_commit": old, "version": 1001}] + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + # written after it but at the head itself + stored[:] = [_link("m1") | {"checked_commit": head, "version": 1001}] + assert await code_link_reads.guidance_code_states("o", [row]) == ["fresh"] + # a mark that does not say when the pass began vouches for nothing it did not check + monkeypatch.setattr(code_link_reads.code, "checked_since", lambda *_: _zero()) + stored[:] = [_link("m1") | {"checked_commit": old, "version": 999}] + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + + +async def _zero() -> int: + return 0 + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] From 0f9724348ff4f36fde6fcbfb6e68f1e5917d5662 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Fri, 27 Nov 2026 23:37:55 +0530 Subject: [PATCH 031/117] A link inserted while a recheck may have missed it is parked and rechecked at the head The recheck writes its cursor before it reads links and clears it after the checkpoint moves, and the writer, after inserting, parks as pending any link it built while a pass is in flight or the checked head is another commit. Pending links that carry a path are re-anchored at the head by the same plan the writer uses, and a deleted path is lost, not left to expire. The read side is back to the repository checkpoint, with pending as unknown. Signed-off-by: Krishna Dobhal --- server/code/app/memory_links.py | 19 +- server/memory/app/code_link_pass.py | 6 + server/memory/app/code_link_reads.py | 17 +- server/memory/app/code_link_recheck.py | 79 ++++++--- server/memory/app/code_links.py | 25 ++- tests/unit/test_memory_code_links.py | 196 +++++++++++++++++++-- tests/unit/test_memory_code_plane_reads.py | 73 +------- 7 files changed, 282 insertions(+), 133 deletions(-) diff --git a/server/code/app/memory_links.py b/server/code/app/memory_links.py index c4eb05b4202..f22656b7687 100644 --- a/server/code/app/memory_links.py +++ b/server/code/app/memory_links.py @@ -443,26 +443,13 @@ async def refresh_repos() -> None: _MARK = "memory_links_checked" -async def _checked_mark(org: str, namespace: str) -> tuple[str, int]: - head, _, since = (await CodeRepo().get_state(org, namespace, _MARK)).partition("@") - return head, int(since) if since.isdigit() else 0 - - async def checked_head(org: str, namespace: str) -> str: """The head the namespace's memory links were last checked at.""" - return (await _checked_mark(org, namespace))[0] - - -async def checked_since(org: str, namespace: str) -> int: - """When (`time.time_ns`) the pass that checked `checked_head` began reading its links; - 0 when the mark does not say. A link row written before it was seen by that pass.""" - return (await _checked_mark(org, namespace))[1] + return await CodeRepo().get_state(org, namespace, _MARK) -async def set_checked_head(org: str, namespace: str, head: str, since: int = 0) -> None: - """Record `head` as checked by a pass that began reading links at `since`, in one value - so a reader never pairs a head with another pass's start.""" - await CodeRepo().set_state(org, namespace, _MARK, f"{head}@{since}" if since else head) +async def set_checked_head(org: str, namespace: str, head: str) -> None: + await CodeRepo().set_state(org, namespace, _MARK, head) _CURSOR_NS = "memory_code_links" diff --git a/server/memory/app/code_link_pass.py b/server/memory/app/code_link_pass.py index c13187157e8..f1124d87abd 100644 --- a/server/memory/app/code_link_pass.py +++ b/server/memory/app/code_link_pass.py @@ -301,3 +301,9 @@ async def clear(self) -> None: def unparsed_cursor(org: str, namespace: str) -> Cursor[list[str]]: return Cursor(f"unparsed/{org}/{namespace}", []) + + +def recheck_cursor(org: str, namespace: str) -> Cursor[dict[str, str]]: + """The head a repository's recheck is following and its last path done: set from the + pass's start until after its checkpoint, so a link writer can see a pass in flight.""" + return Cursor(f"recheck/{org}/{namespace}", {}) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index a57f03e0784..8d4b175ee73 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -143,12 +143,9 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: return state or "unknown" -async def _guidance_coverage(org: str, cns: str) -> tuple[str, int, set[str]]: - # the start first: a pass finishing between the reads leaves an older start with a newer - # head, which vouches for less - since = await code.checked_since(org, cns) +async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str]]: checked = await code.checked_head(org, cns) - return checked, since, set(await unparsed_cursor(org, cns).read()) if checked else set() + return checked, set(await unparsed_cursor(org, cns).read()) if checked else set() async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, str]: @@ -212,14 +209,8 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, since, owed = proof - # The head's pass saw a link only if it was rechecked at that head or written - # before the pass read its links; a later write may be from an older commit. - if not checked_head or any( - link["path"] in owed - or (link["checked_commit"] != checked_head and link["version"] >= since) - for link in rows_for_hit - ): + checked_head, owed = proof + if not checked_head or any(link["path"] in owed for link in rows_for_hit): continue positive[key[2], checked_head].append((index, state)) else: diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index ed2f4c499de..ec5d1a0c183 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -10,7 +10,7 @@ from dataclasses import dataclass from functools import cache from time import time_ns -from typing import Any +from typing import Any, cast from server.code.app import memory_links as code from server.code.domain.anchor import ( @@ -117,33 +117,25 @@ async def _recheck_repository( await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) if head and head != checked: - cut = await _progress(org, cns).read() - cut_at = cut.get("head", "") - # links written after this are not in the pass's reads; a pass the deadline cut keeps - # the start of its first run - since = min(time_ns(), int(cut.get("since") or time_ns())) + cut_at = (await link_pass.recheck_cursor(org, cns).read()).get("head", "") if cut_at and cut_at != head and not await files.has(cut_at): # gone with a rewrite: what that pass already wrote is in no diff, so every # link is rechecked, as after a force-push - await _progress(org, cns).clear() + await link_pass.recheck_cursor(org, cns).clear() await code.set_checked_head(org, cns, "") # a cut full recheck resumes as one checked = "" elif cut_at and cut_at != head: # a pass the deadline cut at another head finishes there first, so every # head is followed in turn and no move it made is left behind - await _follow(org, cns, checked, cut_at, files, result, since) - await code.set_checked_head(org, cns, cut_at, since) + await _follow(org, cns, checked, cut_at, files, result) + await code.set_checked_head(org, cns, cut_at) checked = cut_at - await _follow(org, cns, checked, head, files, result, since) - await code.set_checked_head(org, cns, head, since) + await _follow(org, cns, checked, head, files, result) + await code.set_checked_head(org, cns, head) + await link_pass.recheck_cursor(org, cns).clear() # after the checkpoint: see code_links await policy.apply_policies(org, cns, head, files, budget, result) -def _progress(org: str, cns: str) -> link_pass.Cursor[dict[str, str]]: - """The cursor a repository's recheck records its head and last path done in.""" - return link_pass.Cursor(f"recheck/{org}/{cns}", {}) - - # paths rechecked between two writes: a pass the deadline cuts keeps what it did _PATHS_PER_WRITE = 50 @@ -172,13 +164,15 @@ async def _follow( head: str, files: link_pass.RepoReads, result: link_pass.PassResult, - since: int, ) -> None: """Recheck, path by path, the links `checked..head` may have changed (all of them without a range), writing every `_PATHS_PER_WRITE` paths and recording the last one done, so a cut pass resumes.""" - progress = _progress(org, cns) + progress = link_pass.recheck_cursor(org, cns) done = await progress.read() + after = str(done.get("after", "")) if done.get("head") == head else "" + # in flight before any link is read: a writer that inserts later sees this cursor + await progress.write({"head": head, "after": after}) changed = await files.range(checked, head) if checked else None kept = changed.paths if changed is not None else None # old and new paths: a cut pass may have moved links to a new path already @@ -194,12 +188,14 @@ async def _follow( made = [c for c in await code.commits_after(org, cns, checked, head) if c != head] if made: rows += await store.for_commits(org, [cns], made) - unique = {(a["path"], a["qualified_name"], a["memory_id"]): a for a in rows} + # a pending link waits for `_reanchor`, not for a range recheck + unique = { + (a["path"], a["qualified_name"], a["memory_id"]): a for a in rows if a["state"] != "pending" + } by_path: dict[str, list[LinkRow]] = defaultdict(list) for a in unique.values(): if a["path"]: by_path[a["path"]].append(a) - after = str(done.get("after", "")) if done.get("head") == head else "" paths = [p for p in sorted(by_path) if p > after] unparsed, failed = await _unparsed(org, cns), set[str]() for i in range(0, len(paths), _PATHS_PER_WRITE): @@ -212,8 +208,7 @@ async def _follow( result.rechecked += len(moves) if len(unparsed) > known: # owed before the cursor moves past them await _set_unparsed(org, cns, unparsed) - await progress.write({"head": head, "after": part[-1], "since": str(since)}) - await progress.clear() + await progress.write({"head": head, "after": part[-1]}) if failed: result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") @@ -261,7 +256,8 @@ async def _retry_unparsed( return by_commit: dict[str, list[LinkRow]] = defaultdict(list) for a in await store.for_paths(org, [cns], sorted(paths)): - by_commit[a["checked_commit"]].append(a) + if a["state"] != "pending": + by_commit[a["checked_commit"]].append(a) still, failed = set[str](), set[str]() for commit, rows in by_commit.items(): changed = await files.range(commit, head) if commit else None @@ -590,13 +586,48 @@ async def _recheck_pending( before=before, limit=int(settings.memory_code_links_batch), ) - moves = await _resolve_pending(org, cns, head, files, result, rows) + moves = await _reanchor(org, cns, head, files, [r for r in rows if r["path"]]) + moves += await _resolve_pending( + org, cns, head, files, result, [r for r in rows if not r["path"]] + ) await _write_moves(await _current_moves(org, moves), head) result.rechecked += len(moves) if nxt != after: await cursor.write({"before": before, "after": list(nxt)} if nxt else {}) +async def _reanchor( + org: str, cns: str, head: str, files: link_pass.RepoReads, rows: list[PendingLink] +) -> list[Move]: + """The links a writer parked as pending because a recheck pass may not have seen them + (they keep their path). Each is rechecked at `head` from the commit it was built at, + as the fresh link it was, and written whatever the result: unchanged is fresh at the + head, a deleted path is `missing`. A path that does not parse stays pending.""" + if not head or not rows: + return [] + by_commit: dict[str, list[LinkRow]] = defaultdict(list) + for r in rows: + by_commit[r["checked_commit"]].append(cast(LinkRow, {**r, "state": "fresh"})) + moves: list[Move] = [] + for commit, group in by_commit.items(): + by_path: dict[str, list[LinkRow]] = defaultdict(list) + for a in group: + by_path[a["path"]].append(a) + changed = await files.range(commit, head) if commit else None + unparsed = set[str]() + found = await _recheck_paths( + org, cns, by_path, sorted(by_path), changed, head, files, unparsed, set() + ) + moved = {id(m.row) for m in found} + moves += found + moves += [ + Move(a, link_pass.link_of(a)) + for a in group + if id(a) not in moved and a["path"] not in unparsed + ] + return moves + + def _pending_definitions( rows: list[PendingLink], defs: list[Definition], named: dict[str, list[str]] ) -> list[Definition | None]: diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 239c52d0767..8825f637781 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -141,12 +141,35 @@ async def _link_org( result.linked += len(rows_out) result.unlinked += len(gone) linked += [r["mid"] for r in memories] - await store.insert(out) + await _insert_unseen(out) if linked and rereads: read = {r["mid"]: r["inputs"] for memories in todo.values() for r in memories} await _relink_rewritten(org, linked, read, result, rereads - 1) +async def _insert_unseen(inserted: list[LinkRow]) -> None: + """Insert `inserted`, then park as `pending` the links a recheck pass may not have seen. + + A pass writes its `recheck` cursor before it snapshots its links and clears it only + after it moves the checked head. A link inserted before the snapshot is in the pass; + one inserted after it was inserted after the cursor, so this read, which follows the + insert, sees the cursor, or sees the head the pass checked, which differs from the + head the link was built at. Either way `_recheck_pending` rechecks it at the head. An + empty checked head means no pass has finished: the next one snapshots after this.""" + await store.insert(inserted) + by_repo: dict[tuple[str, str], list[LinkRow]] = defaultdict(list) + for r in inserted: + if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None: + by_repo[r["org"], r["code_namespace"]].append(r) + late: list[LinkRow] = [] + for (org, cns), rows in by_repo.items(): + running = bool(await link_pass.recheck_cursor(org, cns).read()) + checked = await code.checked_head(org, cns) + late += [r for r in rows if running or checked not in ("", r["checked_commit"])] + if late: + await store.insert([store.link_row(r, follows=r["version"], state="pending") for r in late]) + + async def _relink_rewritten( org: str, linked: list[str], read: dict[str, str], result: link_pass.PassResult, rereads: int ) -> None: diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 9355b55d14e..345ce39d4f9 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -1253,17 +1253,16 @@ async def nothing(*a, **k): files = code_link_pass.RepoReads("o", "code-a") with pytest.raises(TimeoutError): await code_link_recheck._follow( - "o", "code-a", "c1", "c2", files, code_link_pass.PassResult(), 0 + "o", "code-a", "c1", "c2", files, code_link_pass.PassResult() ) first = list(seen) seen.clear() monkeypatch.setattr(code_link_recheck, "_recheck", lambda *a, **_: _record(seen, a[2])) - await code_link_recheck._follow( - "o", "code-a", "c1", "c2", files, code_link_pass.PassResult(), 0 - ) + await code_link_recheck._follow("o", "code-a", "c1", "c2", files, code_link_pass.PassResult()) # the first part was written: the next pass starts after it, and ends clean assert seen == paths[code_link_recheck._PATHS_PER_WRITE :] and first[0] == paths[0] - assert cursor["recheck/o/code-a"] == "" + # the pass clears its cursor only after the checkpoint, so a writer sees it in flight + assert json.loads(cursor["recheck/o/code-a"]) == {"head": "c2", "after": paths[-1]} async def _record(seen: list[str], part: list[dict[str, Any]]) -> list[Any]: @@ -1970,7 +1969,6 @@ async def put(name, value): "h2", code_link_pass.RepoReads("o", "code-a"), code_link_pass.PassResult(), - 0, ) assert read[0] == ["a.py", "b.py", "gone.py"] @@ -2008,7 +2006,7 @@ async def indexed_head(org, cns): async def checked_head(org, cns): return state["checked"] - async def set_checked_head(org, cns, at, since=0): + async def set_checked_head(org, cns, at): state["checked"] = at for module, name in ( @@ -2781,9 +2779,7 @@ async def current(org, found): monkeypatch.setattr(code_link_recheck, "_write_moves", write) monkeypatch.setattr(code_link_recheck, "_current_moves", current) files = code_link_pass.RepoReads("o", "code-a") - await code_link_recheck._follow( - "o", "code-a", base, head, files, code_link_pass.PassResult(), 0 - ) + await code_link_recheck._follow("o", "code-a", base, head, files, code_link_pass.PassResult()) assert [(m.link.state, m.link.path) for m in moves] == [after] @@ -4606,3 +4602,183 @@ def test_a_row_moved_by_an_earlier_pass_is_not_a_place_a_later_move_counts() -> out = code_change.rank_down(hits, 3, rescore=False) assert [h.memory_key for h in out] == ["a", "b", "c", "s", "e", "d"] assert out[5].score_components["code_changed_places"] == -3.0 + + +def _made(**kw: Any) -> dict[str, Any]: + return _full( + { + "org": "o", + "code_namespace": "code-a", + "path": "a.py", + "qualified_name": "a::f", + "memory_id": "m1", + "checked_commit": "c1", + "state": "fresh", + "version": 5, + } + | kw + ) + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + ("cursor", "checked", "parked"), + [ + ('{"head": "c1", "after": ""}', "c0", True), # a pass started before this insert + ("", "c2", True), # a pass finished at another head after its snapshot + ("", "c1", False), # no pass running, the checkpoint is the head it was built at + ("", "", False), # no pass has finished: the next one snapshots after this insert + ], +) +async def test_a_link_inserted_while_a_recheck_may_have_missed_it_is_parked( + monkeypatch, cursor, checked, parked +) -> None: + written: list[dict[str, Any]] = [] + + async def insert(rows): + written.extend(rows) + + async def link_cursor(name): + assert name == "recheck/o/code-a" + return cursor + + async def checked_head(org, cns): + return checked + + monkeypatch.setattr(code_links.store, "insert", insert) + monkeypatch.setattr(code_links.code, "link_cursor", link_cursor) + monkeypatch.setattr(code_links.code, "checked_head", checked_head) + await code_links._insert_unseen([_made()]) + assert [(r["state"], r["version"]) for r in written][1:] == ([("pending", 6)] if parked else []) + + +def _parked(path: str, qualified_name: str, **kw: Any) -> dict[str, Any]: + return _made(path=path, qualified_name=qualified_name, state="pending", **kw) + + +@pytest.mark.asyncio +async def test_parked_file_and_symbol_links_are_rechecked_and_a_deleted_path_is_lost( + monkeypatch, +) -> None: + from server.code.app.memory_links import file_definitions + + src = "def fetch_rows(n):\n return n + 1\n" + commits = {"c1": {"m.py": src, "r.py": src}, "c2": {"m.py": src}} # r.py is deleted at c2 + files = code_link_pass.RepoReads("o", "code-a") + + async def at(commit, path): + text = commits[commit].get(path) + return _file(path, text) if text is not None else None + + async def range_(base, head): + return code_link_pass.Range(base, {"r.py": ""}) + + async def candidates(org, cns, **kw): + return [] + + _reads(monkeypatch, files, at) + monkeypatch.setattr(files, "range", range_) + monkeypatch.setattr(code_links.code, "candidates", candidates) + (fn,) = [d for d in file_definitions("m.py", src.encode()) if d.name == "fetch_rows"] + rows = [ + _parked("m.py", fn.qualified_name, body_hash=fn.body_hash, checked_hash=fn.body_hash), + _parked("m.py", "", memory_id="m2"), + _parked("r.py", "", memory_id="m3"), + ] + moves = await code_link_recheck._reanchor("o", "code-a", "c2", files, rows) + assert {(m.row["memory_id"], m.link.state) for m in moves} == { + ("m1", "fresh"), + ("m2", "fresh"), + ("m3", "missing"), + } + + +@pytest.mark.asyncio +async def test_the_pending_scan_never_expires_a_parked_link(monkeypatch) -> None: + parked, named = _parked("a.py", "a::f", expired=1), _parked("", "a::g", expired=1) + seen: dict[str, list[Any]] = {} + + async def pending(org, cns, **kw): + return [parked, named], None + + async def reanchor(org, cns, head, files, rows): + seen["reanchor"] = rows + return [] + + async def resolve_pending(org, cns, head, files, result, rows): + seen["named"] = rows + return [] + + async def nothing(*a, **k): + return [] + + async def no_cursor(name): + return "" + + monkeypatch.setattr(code_links.store, "pending", pending) + monkeypatch.setattr(code_links.code, "link_cursor", no_cursor) + monkeypatch.setattr(code_link_recheck, "_reanchor", reanchor) + monkeypatch.setattr(code_link_recheck, "_resolve_pending", resolve_pending) + monkeypatch.setattr(code_link_recheck, "_current_moves", nothing) + monkeypatch.setattr(code_link_recheck, "_write_moves", nothing) + files = code_link_pass.RepoReads("o", "code-a") + await code_link_recheck._recheck_pending( + "o", "code-a", "c2", files, code_link_pass.PassResult() + ) + assert seen == {"reanchor": [parked], "named": [named]} # only a named row can expire + + +@pytest.mark.asyncio +async def test_a_pass_sets_its_cursor_before_reading_links_and_clears_it_after_the_checkpoint( + monkeypatch, +) -> None: + events: list[str] = [] + cursors: dict[str, str] = {} + + async def for_code(org, cns, **kw): + events.append("read links: " + cursors["recheck/o/code-a"]) + return [] + + async def get(name): + return cursors.get(name, "") + + async def put(name, value): + cursors[name] = value + events.append(f"cursor {value or 'cleared'}") + + async def head(org, cns): + return "c2" + + async def checked(org, cns): + return "" if not events else "c1" + + async def set_checked(org, cns, value): + events.append(f"checked {value}") + + async def nothing(*a, **k): + pass + + _stub_reads(monkeypatch, for_code) + for name, fn in ( + ("link_cursor", get), + ("set_link_cursor", put), + ("indexed_head", head), + ("checked_head", checked), + ("set_checked_head", set_checked), + ): + monkeypatch.setattr(code_links.code, name, fn) + for module, name in ( + (code_link_recheck, "_recheck_pending"), + (code_link_recheck, "_retry_unparsed"), + (code_link_rehash, "refingerprint"), + (code_link_policy, "apply_policies"), + ): + monkeypatch.setattr(module, name, nothing) + budget = code_link_pass.Budget(judgements=0) + await code_link_recheck._recheck_repository("o", "code-a", budget, code_link_pass.PassResult()) + assert events == [ + 'cursor {"head": "c2", "after": ""}', + 'read links: {"head": "c2", "after": ""}', + "checked c2", + "cursor cleared", + ] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index c781e6d5965..52ae4434fbd 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -178,10 +178,6 @@ def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", ** } -async def _checked_since(org, ns): - return 1000 # the pass read its links at 1000; `_link` rows are written at 0 - - def _excerpt(mid: str, key: str, *, pinned: int = 0) -> dict: return { "mid": mid, @@ -316,7 +312,6 @@ async def link_cursor(name): ) monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) - monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) monkeypatch.setattr(code_link_reads.store, "for_memories", links) assert await code_link_reads.guidance_code_states( @@ -324,7 +319,7 @@ async def link_cursor(name): ) == ["changed", "unknown", "unknown", "not_applicable"] -@pytest.mark.parametrize("state", ["fresh", "moved"]) +@pytest.mark.parametrize("state", ["fresh", "moved", "pending"]) async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, state) -> None: from server.memory.app import code_link_reads @@ -370,7 +365,6 @@ async def link_cursor(name): code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) ) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) - monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] indexed = fetched @@ -380,68 +374,9 @@ async def link_cursor(name): unparsed = '["src/a.py"]' assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] unparsed = '["src/other.py"]' - assert await code_link_reads.guidance_code_states("o", [row]) == [state] - - -async def test_positive_code_guidance_needs_evidence_for_each_link(monkeypatch) -> None: - from server.memory.app import code_link_reads - - head = "a" * 40 - old = "c" * 40 - row = _excerpt("m1", "allowed") - stored = [] - - async def readable(org, namespaces): - return namespaces - - async def links(org, ids): - return stored - - async def all_state_many(pairs): - return { - ("o", "code-a"): { - "clone_head": {"value": head, "detail": "main"}, - "git_head": {"value": head}, - } - } - - async def checked_head(org, ns): - return head - - async def link_cursor(name): - return "" - - monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") - monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) - monkeypatch.setattr(code_link_reads.store, "for_memories", links) - monkeypatch.setattr( - code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") - ) - monkeypatch.setattr( - code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) - ) - monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) - monkeypatch.setattr(code_link_reads.code, "checked_since", _checked_since) - monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) - - # written before the pass read its links, still at an older commit: the pass covered it - stored[:] = [_link("m1") | {"checked_commit": old, "version": 999}] - assert await code_link_reads.guidance_code_states("o", [row]) == ["fresh"] - # written after that read from an older commit, then the checkpoint advanced: nothing - # checked it at this head - stored[:] = [_link("m1") | {"checked_commit": old, "version": 1001}] - assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - # written after it but at the head itself - stored[:] = [_link("m1") | {"checked_commit": head, "version": 1001}] - assert await code_link_reads.guidance_code_states("o", [row]) == ["fresh"] - # a mark that does not say when the pass began vouches for nothing it did not check - monkeypatch.setattr(code_link_reads.code, "checked_since", lambda *_: _zero()) - stored[:] = [_link("m1") | {"checked_commit": old, "version": 999}] - assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - - -async def _zero() -> int: - return 0 + # a link the writer parked behind a running pass is unknown even at the checked head + expected = "unknown" if state == "pending" else state + assert await code_link_reads.guidance_code_states("o", [row]) == [expected] @pytest.mark.asyncio From 397c1c65ce1ba878b1d29441b492f0cc100e216d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 10:23:51 +0530 Subject: [PATCH 032/117] A link is parked pending before the fence reads and promoted only when they clear it The writer inserts a link a recheck pass may have missed as pending, reads the pass cursor and the checked head with sequential consistency, and inserts the fresh row only for links the reads clear, so a crash between the inserts leaves it pending. A pass clears a cursor left after its checkpoint, and a parked link whose path never parses expires with the pending days. The ordering argument and the rolling-upgrade window are in the architecture pages. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 21 +++ docs/architecture/rolling-upgrades.md | 9 ++ server/memory/app/code_link_recheck.py | 14 +- server/memory/app/code_links.py | 41 ++--- tests/unit/test_memory_code_links.py | 157 ++++++++++++++++--- 5 files changed, 202 insertions(+), 40 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 9a3fc49d2a8..4856c5a857a 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -649,6 +649,27 @@ ranged `next` read. HTTP and MCP preserve that omission. Enclosing-body lookups unavailable text, and verification cannot use an unread body as negative evidence. No source text is fetched from a network or fabricated to fill a gap. +## Memory links written during a recheck + +A recheck pass writes its `recheck` cursor before it snapshots the links it follows, and +clears the cursor only after it moves the checked head. A writer that links a memory +inserts each link as `pending` first. It then reads the cursor and the checked head, and +inserts the link again as fresh only when no pass is running and the checked head is +unset or is the commit the link was built at. A link inserted before the snapshot is in +the pass. A link inserted after it was inserted after the cursor, so the read that +follows the insert sees the cursor, or sees a head that differs from the build head, and +the link stays `pending`. `pending` reads as unknown. The next recheck re-anchors a +pending link that keeps its path at the current head, from the commit it was built at. +A path that never parses expires after `memory_code_links_pending_days`, as a pathless +pending link does. A crash between the two inserts leaves the link pending, never fresh; +a crash between the checked head and the cursor clear is cleared by the next pass. + +The fence reads run under `sequential_reads()`, so a cursor or checked head another +replica wrote is seen. That holds when the state writes are visible to a +sequential read, as `loom doctor` checks for `select_sequential_consistency`; a +deployment where they are not can serve a link as fresh that a pass on another replica +did not see. + ## Invariants - A code namespace is one branch; every `code_*` row is keyed by `(org, namespace)`. diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 709768400cc..b82fc55b3cc 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1045,6 +1045,15 @@ remaps a scratch restore target into the deployment client. Both paths fence all historical connection keys and verify physical owner-history deletion. Complete the separate mirror-content cleanup before serving; this account procedure does not replace it. +### Memory links written during a recheck + +A build that parks late-inserted links writes the recheck cursor before it reads links +and clears it after the checked head moves. While replicas of the previous build still +run the recheck pass, they write the cursor late, clear it early and never park, so the +write-side check can miss a link inserted then. Such a link is served as fresh until the +next pass of the new build rechecks it. The window ends when the last previous-build +replica is replaced; the new build carries no code for it. + ## Independent proposal approval Stop and drain every older API, worker and command-line writer **before** applying diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 96cfe39426d..ad9d9405d35 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -113,6 +113,8 @@ async def _recheck_repository( await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) + if head and head == checked and await link_pass.recheck_cursor(org, cns).read(): + await link_pass.recheck_cursor(org, cns).clear() # a crash left it after the checkpoint if head and head != checked: cut_at = (await link_pass.recheck_cursor(org, cns).read()).get("head", "") if cut_at and cut_at != head and not await files.has(cut_at): @@ -599,7 +601,8 @@ async def _reanchor( """The links a writer parked as pending because a recheck pass may not have seen them (they keep their path). Each is rechecked at `head` from the commit it was built at, as the fresh link it was, and written whatever the result: unchanged is fresh at the - head, a deleted path is `missing`. A path that does not parse stays pending.""" + head, a deleted path is `missing`. A path that does not parse stays pending until the + pending days pass, then the row is dropped as a pathless one is.""" if not head or not rows: return [] by_commit: dict[str, list[LinkRow]] = defaultdict(list) @@ -617,6 +620,15 @@ async def _reanchor( ) moved = {id(m.row) for m in found} moves += found + await store.insert( + store.tombstones( + [ + r + for r in rows + if r["checked_commit"] == commit and r["expired"] and r["path"] in unparsed + ] + ) + ) moves += [ Move(a, link_pass.link_of(a)) for a in group diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 16744685f28..ac0431a4120 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -31,6 +31,7 @@ resolve, ) from server.code.domain.declaration import fingerprint_version +from server.core.ch import sequential_reads from server.memory.app import code_link_pass as link_pass from server.memory.app.code_link_reads import ( SERVED, @@ -151,26 +152,28 @@ async def _link_org( async def _insert_unseen(inserted: list[LinkRow]) -> None: - """Insert `inserted`, then park as `pending` the links a recheck pass may not have seen. - - A pass writes its `recheck` cursor before it snapshots its links and clears it only - after it moves the checked head. A link inserted before the snapshot is in the pass; - one inserted after it was inserted after the cursor, so this read, which follows the - insert, sees the cursor, or sees the head the pass checked, which differs from the - head the link was built at. Either way `_recheck_pending` rechecks it at the head. An - empty checked head means no pass has finished: the next one snapshots after this.""" - await store.insert(inserted) + """Insert `inserted`, a link a recheck pass may have missed parked as `pending` first and + promoted if the fence reads clear it (docs/architecture/code-index-architecture.md).""" + guard = [ + r for r in inserted if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None + ] + parked = {id(r): store.link_row(r, follows=r["version"], state="pending") for r in guard} + await store.insert([parked.get(id(r), r) for r in inserted]) by_repo: dict[tuple[str, str], list[LinkRow]] = defaultdict(list) - for r in inserted: - if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None: - by_repo[r["org"], r["code_namespace"]].append(r) - late: list[LinkRow] = [] - for (org, cns), rows in by_repo.items(): - running = bool(await link_pass.recheck_cursor(org, cns).read()) - checked = await code.checked_head(org, cns) - late += [r for r in rows if running or checked not in ("", r["checked_commit"])] - if late: - await store.insert([store.link_row(r, follows=r["version"], state="pending") for r in late]) + for r in guard: + by_repo[r["org"], r["code_namespace"]].append(r) + clear: list[LinkRow] = [] + with sequential_reads(): + for (org, cns), rows in by_repo.items(): + running = bool(await link_pass.recheck_cursor(org, cns).read()) + checked = await code.checked_head(org, cns) + clear += [ + store.link_row(r, follows=parked[id(r)]["version"]) + for r in rows + if not running and checked in ("", r["checked_commit"]) + ] + if clear: + await store.insert(clear) async def _relink_rewritten( diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index d998ab79f01..50cb7646c9f 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -4891,40 +4891,95 @@ def _made(**kw: Any) -> dict[str, Any]: ) +class _LinkStore: + """An in-memory link table that keeps the highest version of a row, as the engine does, + with the recheck state the fence reads.""" + + def __init__(self, monkeypatch, *, cursor: str = "", checked: str = "") -> None: + self.cursor, self.checked, self.rows = cursor, checked, {} + self.fail_on_insert = 0 + monkeypatch.setattr(code_links.store, "insert", self.insert) + monkeypatch.setattr(code_links.code, "link_cursor", self.read_cursor) + monkeypatch.setattr(code_links.code, "checked_head", self.read_checked) + + async def insert(self, rows): + if self.fail_on_insert: + self.fail_on_insert -= 1 + if not self.fail_on_insert: + raise RuntimeError("replica died") + for r in rows: + key = (r["memory_id"], r["path"], r["qualified_name"]) + if key not in self.rows or self.rows[key]["version"] < r["version"]: + self.rows[key] = r + + async def read_cursor(self, name): + return self.cursor + + async def read_checked(self, org, cns): + return self.checked + + def states(self) -> list[tuple[str, int]]: + return [(r["state"], r["version"]) for r in self.rows.values()] + + @pytest.mark.asyncio @pytest.mark.parametrize( - ("cursor", "checked", "parked"), + ("cursor", "checked", "state"), [ - ('{"head": "c1", "after": ""}', "c0", True), # a pass started before this insert - ("", "c2", True), # a pass finished at another head after its snapshot - ("", "c1", False), # no pass running, the checkpoint is the head it was built at - ("", "", False), # no pass has finished: the next one snapshots after this insert + ('{"head": "c1", "after": ""}', "c0", ("pending", 6)), # a pass started before this insert + ("", "c2", ("pending", 6)), # a pass finished at another head after its snapshot + ("", "c1", ("fresh", 7)), # no pass running, the checkpoint is the head it was built at + ("", "", ("fresh", 7)), # no pass has finished: the next one snapshots after this insert ], ) async def test_a_link_inserted_while_a_recheck_may_have_missed_it_is_parked( - monkeypatch, cursor, checked, parked + monkeypatch, cursor, checked, state ) -> None: - written: list[dict[str, Any]] = [] + table = _LinkStore(monkeypatch, cursor=cursor, checked=checked) + await code_links._insert_unseen([_made()]) + assert table.states() == [state] - async def insert(rows): - written.extend(rows) - async def link_cursor(name): - assert name == "recheck/o/code-a" - return cursor +@pytest.mark.asyncio +async def test_a_link_built_before_a_pass_and_inserted_after_it_is_unknown_until_rechecked( + monkeypatch, +) -> None: + # the writer built at c1 and paused; a pass to c2 snapshotted without the link and + # moved the checked head; the writer then inserts + table = _LinkStore(monkeypatch, cursor="", checked="c2") + built = _made() + await code_links._insert_unseen([built]) + ((state, _),) = table.states() + assert state == "pending" # what the read side serves as unknown + # the next pending scan re-anchors it at the head the pass checked + files = code_link_pass.RepoReads("o", "code-a") - async def checked_head(org, cns): - return checked + async def at(commit, path): + return _file(path, "def f():" + chr(10) + " return 1" + chr(10)) - monkeypatch.setattr(code_links.store, "insert", insert) - monkeypatch.setattr(code_links.code, "link_cursor", link_cursor) - monkeypatch.setattr(code_links.code, "checked_head", checked_head) - await code_links._insert_unseen([_made()]) - assert [(r["state"], r["version"]) for r in written][1:] == ([("pending", 6)] if parked else []) + async def range_(base, head): + return code_link_pass.Range(base, {}) + + _reads(monkeypatch, files, at) + monkeypatch.setattr(files, "range", range_) + (parked,) = [{**r, "expired": 0} for r in table.rows.values()] + (move,) = await code_link_recheck._reanchor("o", "code-a", "c2", files, [parked]) + assert move.link.state == "fresh" + + +@pytest.mark.asyncio +async def test_a_crash_between_the_pending_insert_and_the_fresh_one_leaves_the_link_pending( + monkeypatch, +) -> None: + table = _LinkStore(monkeypatch) + table.fail_on_insert = 2 # the pending insert lands; the promotion dies + with pytest.raises(RuntimeError): + await code_links._insert_unseen([_made()]) + assert table.states() == [("pending", 6)] def _parked(path: str, qualified_name: str, **kw: Any) -> dict[str, Any]: - return _made(path=path, qualified_name=qualified_name, state="pending", **kw) + return _made(path=path, qualified_name=qualified_name, state="pending", **({"expired": 0} | kw)) @pytest.mark.asyncio @@ -5053,3 +5108,65 @@ async def nothing(*a, **k): "checked c2", "cursor cleared", ] + + +@pytest.mark.asyncio +@pytest.mark.parametrize(("expired", "tombstoned"), [(0, 0), (1, 1)]) +async def test_a_parked_link_whose_path_never_parses_expires_with_the_pending_days( + monkeypatch, expired, tombstoned +) -> None: + written: list[dict[str, Any]] = [] + files = code_link_pass.RepoReads("o", "code-a") + + async def at(commit, path): + raise code_links.code.ParseFailed(path, "bad") + + async def range_(base, head): + return code_link_pass.Range(base, {"a.py": "a.py"}) + + async def insert(rows): + written.extend(rows) + + _reads(monkeypatch, files, at) + monkeypatch.setattr(files, "range", range_) + + async def candidates(org, cns, **kw): + return [] + + monkeypatch.setattr(code_links.code, "candidates", candidates) + monkeypatch.setattr(code_links.store, "insert", insert) + row = _parked("a.py", "a::f", expired=expired) + assert await code_link_recheck._reanchor("o", "code-a", "c2", files, [row]) == [] + assert len(written) == tombstoned + assert all(r["tombstoned_at"] is not None for r in written) + + +@pytest.mark.asyncio +async def test_a_cursor_left_after_the_checkpoint_is_cleared_by_the_next_pass(monkeypatch) -> None: + cursors = {"recheck/o/code-a": '{"head": "c2", "after": ""}'} + + async def get(name): + return cursors.get(name, "") + + async def put(name, value): + cursors[name] = value + + async def head(org, cns): + return "c2" + + async def nothing(*a, **k): + pass + + for name, fn in (("link_cursor", get), ("set_link_cursor", put)): + monkeypatch.setattr(code_links.code, name, fn) + for name in ("indexed_head", "checked_head"): + monkeypatch.setattr(code_links.code, name, head) + monkeypatch.setattr(code_link_recheck, "_recheck_pending", nothing) + monkeypatch.setattr(code_link_recheck, "_retry_unparsed", nothing) + monkeypatch.setattr(code_link_rehash, "refingerprint", nothing) + monkeypatch.setattr(code_link_policy, "apply_policies", nothing) + result = code_link_pass.PassResult() + await code_link_recheck._recheck_repository( + "o", "code-a", code_link_pass.Budget(judgements=0), result + ) + assert cursors["recheck/o/code-a"] == "" From fb064d0fd47a45c042cd54d7bbeb629ffef89d9f Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 10:26:45 +0530 Subject: [PATCH 033/117] Recall Lab draws its rows first and names a legacy hit's writer afterwards A hit that omits its writer is dropped when exactly one keyword row holds its key and stays a preview that cannot be opened when several do. A lone one is looked up after the rows are drawn, four lookups at a time; a hit that resolves to a row already shown is that row. Signed-off-by: Krishna Dobhal --- .../views/RecallLab.memoriesOrder.test.tsx | 31 ++++++++++++++- frontend/src/views/RecallLab.tsx | 39 ++++++++++++++----- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index 357142ccb49..b62633e083f 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -127,8 +127,7 @@ describe("Recall Lab and the Memories list", () => { it("shows one row for a memory the keyword read and a legacy ranked hit both hold", async () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; const page = { entries: [held], total: 1, today: 0, truncated: false }; - // the keyword read, then the lookup that names the hit's writer - vi.mocked(listMemories).mockResolvedValueOnce(page).mockResolvedValueOnce(page); + vi.mocked(listMemories).mockResolvedValueOnce(page); // A legacy hit names its agent but not the user or session. vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], @@ -141,6 +140,34 @@ describe("Recall Lab and the Memories list", () => { await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(1)); }); + it("keeps a legacy hit as a preview when several keyword rows share its key", async () => { + const rows = ["s1", "s2"].map((session_id) => ({ ...entry("older_azure"), user_id: "u", session_id })); + vi.mocked(listMemories).mockResolvedValueOnce({ entries: rows, total: 2, today: 0, truncated: false }); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(3), { timeout: 3000 }); + expect(vi.mocked(listMemories)).toHaveBeenCalledTimes(1); // no lookup for an ambiguous key + }); + + it("draws the rows while a writer lookup hangs", async () => { + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [], total: 0, today: 0, truncated: false }) + .mockReturnValueOnce(new Promise(() => {})); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("solo_azure", 0.9), user_id: undefined, session_id: undefined }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + expect(await screen.findByText("solo_azure", {}, { timeout: 3000 })).toBeTruthy(); + }); + it("shows a high keyword match as sensitive, not as an empty row", async () => { vi.mocked(listMemories).mockResolvedValueOnce({ entries: [{ ...entry("vault_azure"), value: null, value_truncated: true, sensitivity: "high" }], diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 1b3da61df96..8bf8abae648 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -281,6 +281,9 @@ interface RecallRow { hit?: SearchHit; } +// Writer lookups a search runs at once. +const LOOKUPS_IN_FLIGHT = 4; + function canInspect(row: RecallRow): boolean { return namesWriter(row.writer) && !row.key.startsWith("chunk:"); } @@ -514,16 +517,14 @@ export function RecallLab() { const keyword = new Map( (kw?.entries ?? []).map((e, i) => [recallRowId(identity.namespace, e, `keyword:${i}`), e]), ); - // A legacy hit omits its writer: name it before keying, so a keyword row of the same - // memory is one row, not two. - const named = await Promise.all( - (r?.results ?? []).map(async (h) => { - const writer = namesWriter(h) ? undefined : await resolveSearchWriter(identity, h, ac.signal); - return writer ? { ...h, ...writer } : h; - }), - ); - if (ac.signal.aborted) return; - const ranked = new Map(named.map((h, i) => [recallRowId(identity.namespace, h, `ranked:${i}`), h])); + // A legacy hit omits its writer. One keyword row of its key already holds it, so the + // hit is dropped; several rows share the key, so it stays a preview no one can open. + const held = (key: string) => [...keyword.values()].filter((e) => e.memory_key === key).length; + const ranked = new Map(); + (r?.results ?? []).forEach((h, i) => { + if (!namesWriter(h) && held(h.memory_key) === 1) return; + ranked.set(recallRowId(identity.namespace, h, `ranked:${i}`), h); + }); const order = keywordThenRanked([...keyword.keys()], [...ranked.keys()]); setRowsQuery(q); setRows( @@ -545,6 +546,24 @@ export function RecallLab() { }; }), ); + // A lone legacy hit asks which writer holds it, a few lookups at a time, after the rows + // are drawn; a hit that resolves to a row already shown is that row. + const lookups = [...ranked].filter(([id, h]) => id.startsWith("ranked:") && held(h.memory_key) === 0); + let next = 0; + const lookup = async () => { + for (let item = lookups[next++]; item && !ac.signal.aborted; item = lookups[next++]) { + const [id, h] = item; + const writer = await resolveSearchWriter(identity, h, ac.signal).catch(() => undefined); + if (!writer || ac.signal.aborted) continue; + const named = rowIdentity(identity.namespace, { ...h, ...writer }); + setRows((cur) => + cur?.some((x) => x.id === named) + ? cur.filter((x) => x.id !== id) + : cur?.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)), + ); + } + }; + void Promise.all(Array.from({ length: LOOKUPS_IN_FLIGHT }, lookup)); // Keyword matches are real matches: the list hedges only when there are none. setAbstain(Boolean(r?.abstain) && keyword.size === 0); setModel(r?.embedding_model ?? ""); From 536a9a1538d48e17134081b28ab3d1e6f382f046 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 10:28:28 +0530 Subject: [PATCH 034/117] Recall Lab's writer patch keeps a cleared row list cleared Signed-off-by: Krishna Dobhal --- frontend/src/views/RecallLab.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 8bf8abae648..f43452104e9 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -557,9 +557,11 @@ export function RecallLab() { if (!writer || ac.signal.aborted) continue; const named = rowIdentity(identity.namespace, { ...h, ...writer }); setRows((cur) => - cur?.some((x) => x.id === named) - ? cur.filter((x) => x.id !== id) - : cur?.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)), + cur === null + ? cur + : cur.some((x) => x.id === named) + ? cur.filter((x) => x.id !== id) + : cur.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)), ); } }; From b5b5a84950541a241375e4ca0413eded8901b060 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:15:49 +0530 Subject: [PATCH 035/117] A parked page's plain lines are checked with the head's guidance evidence A parked fact row is served only when a current head vouches for it, and its code state is read again on that page, so the test gives its rows an identity, a head and the link state, and expects the [use: step] the line now carries. Signed-off-by: Krishna Dobhal --- tests/unit/test_loom_search_repo_decisions.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_loom_search_repo_decisions.py b/tests/unit/test_loom_search_repo_decisions.py index 6c25bfbc53c..7e1a04f388b 100644 --- a/tests/unit/test_loom_search_repo_decisions.py +++ b/tests/unit/test_loom_search_repo_decisions.py @@ -824,15 +824,27 @@ async def test_a_hit_whose_code_changed_says_so_in_the_block(monkeypatch) -> Non async def test_a_later_page_says_a_hits_code_changed_on_its_plain_line(monkeypatch) -> None: """A parked page carries no reader block: the agent reads the plain hit lines.""" from server.memory.app import search_pages - from server.memory.app.search import handle_memory_search + from server.memory.app.search import guidance, handle_memory_search from server.transport import mcp_tools from tests.unit._memory_search_pkg import patch_handler_name + tail = [_changed("evict_rule"), _hit("note-a", 0.7, "me")] + for h in tail: # a parked fact row is served only with a current head to vouch for it + h.version, h._row_identity, h._guidance_content_sha256 = 7, ("a", "u", "-"), "a" * 64 + + async def heads(keys): + return {key: {"version": 7, "status": "active", "content_sha256": "a" * 64} for key in keys} + + async def changed(org, rows): # the page's current link state, read again on this page + return ["changed", "fresh"][: len(rows)] + + monkeypatch.setattr(guidance, "guidance_heads", heads) + monkeypatch.setattr(guidance, "guidance_code_states", changed) content = search_pages.encode_page( query=BASE.query, top_k=BASE.top_k, candidates_total=5, - tail=[_changed("evict_rule"), _hit("note-a", 0.7, "me")], + tail=tail, namespaces_searched=["me"], namespaces_skipped=[], ) @@ -848,8 +860,8 @@ async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: payload = await _assemble(monkeypatch, parked, page=handle) answer = mcp_tools.search_answer(payload, {"query": BASE.query, "page": handle}, "me", "s1") assert ( - f" - [evict_rule] (ns=me){_CODE_NOTE} text of evict_rule\n" - " - [note-a] (ns=me) text of note-a" + f" - [evict_rule] (ns=me){_CODE_NOTE} text of evict_rule [use: recheck_source]\n" + " - [note-a] (ns=me) text of note-a [use: validate_lead]" ) in answer["content"][0]["text"] stale = answer["structuredContent"]["memory"]["results"][0] assert (stale["code_state"], stale["code_changed_since"]) == ("changed", _COMMIT) From c4986ac67f79c4ca081bae4cff0356bd594aa713 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:23:15 +0530 Subject: [PATCH 036/117] A promoted code link is parked again when a recheck pass moved in after the fence reads Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 20 ++++++----- server/memory/app/code_links.py | 37 ++++++++++++++------ tests/unit/test_memory_code_links.py | 22 ++++++++++++ 3 files changed, 61 insertions(+), 18 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 4856c5a857a..47f437c31e8 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -655,14 +655,18 @@ A recheck pass writes its `recheck` cursor before it snapshots the links it foll clears the cursor only after it moves the checked head. A writer that links a memory inserts each link as `pending` first. It then reads the cursor and the checked head, and inserts the link again as fresh only when no pass is running and the checked head is -unset or is the commit the link was built at. A link inserted before the snapshot is in -the pass. A link inserted after it was inserted after the cursor, so the read that -follows the insert sees the cursor, or sees a head that differs from the build head, and -the link stays `pending`. `pending` reads as unknown. The next recheck re-anchors a -pending link that keeps its path at the current head, from the commit it was built at. -A path that never parses expires after `memory_code_links_pending_days`, as a pathless -pending link does. A crash between the two inserts leaves the link pending, never fresh; -a crash between the checked head and the cursor clear is cleared by the next pass. +unset or is the commit the link was built at. The pass follows no pending link, so the +writer reads both again after the promotion and parks the link once more if a pass has +begun or the head has moved. A pass that snapshotted before the promotion wrote its +cursor before it, and clears it only after it moves the head, so that read sees the +cursor or the new head; a pass that snapshots after the promotion follows the fresh +link. `pending` reads as unknown. The next recheck re-anchors a pending link that keeps +its path at the current head, from the commit it was built at. A path that never parses +expires after `memory_code_links_pending_days`, as a pathless pending link does. A crash +between the inserts leaves the link pending, never fresh; a crash between the checked +head and the cursor clear is cleared by the next pass. Each link is written two or three +times, in batches per call; that cost is accepted because it is bounded by the links a +write creates and keeps a crash or a racing pass from ever leaving a link fresh. The fence reads run under `sequential_reads()`, so a cursor or checked head another replica wrote is seen. That holds when the state writes are visible to a diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index ac0431a4120..e5e50a2b8ac 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -152,8 +152,9 @@ async def _link_org( async def _insert_unseen(inserted: list[LinkRow]) -> None: - """Insert `inserted`, a link a recheck pass may have missed parked as `pending` first and - promoted if the fence reads clear it (docs/architecture/code-index-architecture.md).""" + """Insert `inserted`, a link a recheck pass may have missed parked as `pending` first, + promoted if the fence reads clear it and parked again if they change after + (docs/architecture/code-index-architecture.md).""" guard = [ r for r in inserted if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None ] @@ -162,18 +163,34 @@ async def _insert_unseen(inserted: list[LinkRow]) -> None: by_repo: dict[tuple[str, str], list[LinkRow]] = defaultdict(list) for r in guard: by_repo[r["org"], r["code_namespace"]].append(r) - clear: list[LinkRow] = [] + promoted: list[tuple[LinkRow, tuple[str, str], str]] = [] with sequential_reads(): - for (org, cns), rows in by_repo.items(): - running = bool(await link_pass.recheck_cursor(org, cns).read()) - checked = await code.checked_head(org, cns) - clear += [ - store.link_row(r, follows=parked[id(r)]["version"]) + fences = {k: await _fence(*k) for k in by_repo} + for key, rows in by_repo.items(): + running, checked = fences[key] + promoted += [ + (store.link_row(r, follows=parked[id(r)]["version"]), key, checked) for r in rows if not running and checked in ("", r["checked_commit"]) ] - if clear: - await store.insert(clear) + if not promoted: + return + await store.insert([row for row, _, _ in promoted]) + # a pass skips pending rows: one that began between the fence reads and the promotion + # left these fresh at the old head, so read again and park what moved + after = {k: await _fence(*k) for k in {key for _, key, _ in promoted}} + back = [ + store.link_row(row, follows=row["version"], state="pending") + for row, key, checked in promoted + if after[key] != (False, checked) + ] + if back: + await store.insert(back) + + +async def _fence(org: str, cns: str) -> tuple[bool, str]: + """Whether a recheck pass is in flight, and the head its last pass checked.""" + return bool(await link_pass.recheck_cursor(org, cns).read()), await code.checked_head(org, cns) async def _relink_rewritten( diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 50cb7646c9f..31c81baca21 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -4967,6 +4967,28 @@ async def range_(base, head): assert move.link.state == "fresh" +@pytest.mark.asyncio +@pytest.mark.parametrize( + ("cursor", "checked"), + [('{"head": "c2", "after": ""}', "c1"), ("", "c2")], # a pass began / finished at c2 +) +async def test_a_pass_that_moves_in_after_the_fence_reads_parks_the_promoted_link_again( + monkeypatch, cursor, checked +) -> None: + table = _LinkStore(monkeypatch, checked="c1") # the fence reads clear at the build head + insert, writes = table.insert, [] + + async def moved_after_promotion(rows): + await insert(rows) + writes.append(rows) + if len(writes) == 2: # the promotion landed; the pass skipped the pending row + table.cursor, table.checked = cursor, checked + + monkeypatch.setattr(code_links.store, "insert", moved_after_promotion) + await code_links._insert_unseen([_made()]) + assert table.states() == [("pending", 8)] + + @pytest.mark.asyncio async def test_a_crash_between_the_pending_insert_and_the_fresh_one_leaves_the_link_pending( monkeypatch, From 686257a1d1cd597bfe621ffe73934923f41cc553 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:23:15 +0530 Subject: [PATCH 037/117] Recall Lab keeps a legacy hit that another writer's keyword row of the same key may hold Signed-off-by: Krishna Dobhal --- .../src/views/RecallLab.memoriesOrder.test.tsx | 17 +++++++++++++++++ frontend/src/views/RecallLab.tsx | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index b62633e083f..8e815a77dd1 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -128,6 +128,7 @@ describe("Recall Lab and the Memories list", () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; const page = { entries: [held], total: 1, today: 0, truncated: false }; vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(listMemories).mockResolvedValueOnce(page); // the lookup finds the same row // A legacy hit names its agent but not the user or session. vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], @@ -140,6 +141,22 @@ describe("Recall Lab and the Memories list", () => { await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(1)); }); + it("keeps a legacy hit that another writer's row of the same key holds", async () => { + const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; + const other = { ...entry("older_azure"), user_id: "v", session_id: "t" }; + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [held], total: 1, today: 0, truncated: false }) + .mockResolvedValueOnce({ entries: [other], total: 1, today: 0, truncated: false }); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(2), { timeout: 3000 }); + }); + it("keeps a legacy hit as a preview when several keyword rows share its key", async () => { const rows = ["s1", "s2"].map((session_id) => ({ ...entry("older_azure"), user_id: "u", session_id })); vi.mocked(listMemories).mockResolvedValueOnce({ entries: rows, total: 2, today: 0, truncated: false }); diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index f43452104e9..69feeaa6489 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -517,12 +517,12 @@ export function RecallLab() { const keyword = new Map( (kw?.entries ?? []).map((e, i) => [recallRowId(identity.namespace, e, `keyword:${i}`), e]), ); - // A legacy hit omits its writer. One keyword row of its key already holds it, so the - // hit is dropped; several rows share the key, so it stays a preview no one can open. + // A legacy hit omits its writer, and another writer's row can share its key, so a hit + // is never dropped here: the lookup below names it, and it merges into the row that + // holds it. Several keyword rows share the key, so it stays a preview no one can open. const held = (key: string) => [...keyword.values()].filter((e) => e.memory_key === key).length; const ranked = new Map(); (r?.results ?? []).forEach((h, i) => { - if (!namesWriter(h) && held(h.memory_key) === 1) return; ranked.set(recallRowId(identity.namespace, h, `ranked:${i}`), h); }); const order = keywordThenRanked([...keyword.keys()], [...ranked.keys()]); @@ -548,7 +548,7 @@ export function RecallLab() { ); // A lone legacy hit asks which writer holds it, a few lookups at a time, after the rows // are drawn; a hit that resolves to a row already shown is that row. - const lookups = [...ranked].filter(([id, h]) => id.startsWith("ranked:") && held(h.memory_key) === 0); + const lookups = [...ranked].filter(([id, h]) => id.startsWith("ranked:") && held(h.memory_key) <= 1); let next = 0; const lookup = async () => { for (let item = lookups[next++]; item && !ac.signal.aborted; item = lookups[next++]) { From 12ab289002e041555b675eee7e1fbde6260fb4b8 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:44:18 +0530 Subject: [PATCH 038/117] A memory list page says how many rows it read before the authority dropped any Signed-off-by: Krishna Dobhal --- docs/reference/operations/memory.md | 1 + frontend/src/api.ts | 3 + sdk/python/loom/ops.py | 1 + sdk/rust/src/wire_models.rs | 3257 +++++++++++----------- sdk/rust/tests/registry_contracts.rs | 5 + sdk/typescript/src/generated/ops.ts | 1 + server/memory/api/models_crud.py | 3 + server/memory/app/query.py | 2 + tests/unit/test_memory_list_rows_read.py | 38 + 9 files changed, 1685 insertions(+), 1626 deletions(-) create mode 100644 tests/unit/test_memory_list_rows_read.py diff --git a/docs/reference/operations/memory.md b/docs/reference/operations/memory.md index 4d921bea70f..ad0829c78be 100644 --- a/docs/reference/operations/memory.md +++ b/docs/reference/operations/memory.md @@ -1268,6 +1268,7 @@ List memory keys under this identity, optionally filtered. | --- | --- | --- | | `entries` | `list[_MemoryListEntry]` | The matching rows in the requested order; empty on an `unchanged` poll. | | `truncated` | `bool` | true if more entries exist beyond `limit` | +| `rows_read` | `int` | Rows this page read from `offset` before the authority dropped any: the next page's offset is `offset + rows_read`, which `len(entries)` understates when rows were dropped. | | `total` | `int` | Total rows matching this scope (ignores `limit`), so callers can show "N of TOTAL". 0 on an `unchanged` poll, which carries no counts. | | `today` | `int` | Of `total`, how many were created since UTC midnight today — the true "today" count (not the truncated page count the day-group headers show). | | `namespace_version` | `str` | The namespace's newest memory version (any agent, any status — every write moves it). | diff --git a/frontend/src/api.ts b/frontend/src/api.ts index 3479fbcb9a7..4a633f2c01d 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -236,6 +236,9 @@ export type VerificationState = "human" | "process" | "stale" | "none"; export interface MemoryListResponse { entries: MemoryListEntry[]; truncated: boolean; + // Rows the page read from `offset` before the server dropped any: the next offset is + // `offset + rows_read`, not `offset + entries.length`. + rows_read?: number; // Total rows in this namespace scope, ignoring the page `limit`. Lets the // UI show "N of TOTAL" instead of "N of ". total: number; diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index c84a0c22ef2..8088553a7c0 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -14936,6 +14936,7 @@ class MemoryListBody(TypedDict, total=False): class MemoryListOutput(TypedDict, total=False): entries: Required[list["MemoryListEntry"]] truncated: Required[bool] + rows_read: NotRequired[int] total: NotRequired[int] today: NotRequired[int] namespace_version: NotRequired[str] diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index 4db474e2f00..b7c96d99ef7 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -36646,16 +36646,18 @@ pub struct MemoryListOutput { pub entries: Vec, pub truncated: bool, #[serde(default = "default_1700")] - pub total: Integer, + pub rows_read: Integer, #[serde(default = "default_1701")] - pub today: Integer, + pub total: Integer, #[serde(default = "default_1702")] - pub namespace_version: String, + pub today: Integer, #[serde(default = "default_1703")] - pub unchanged: bool, + pub namespace_version: String, #[serde(default = "default_1704")] - pub hidden: Integer, + pub unchanged: bool, #[serde(default = "default_1705")] + pub hidden: Integer, + #[serde(default = "default_1706")] pub hidden_hint: String, } @@ -37041,19 +37043,19 @@ impl MemoryListInput { #[non_exhaustive] pub struct MemoryLockOutput { pub locked: bool, - #[serde(default = "default_1706")] - pub reason: String, #[serde(default = "default_1707")] - pub memory_id: String, + pub reason: String, #[serde(default = "default_1708")] - pub version: Option, + pub memory_id: String, #[serde(default = "default_1709")] - pub lock_mode: String, + pub version: Option, #[serde(default = "default_1710")] - pub lock_until: Option, + pub lock_mode: String, #[serde(default = "default_1711")] - pub locked_by: String, + pub lock_until: Option, #[serde(default = "default_1712")] + pub locked_by: String, + #[serde(default = "default_1713")] pub previous_mode: String, } @@ -37212,21 +37214,21 @@ pub struct MemoryMoveOutput { pub from_key: String, pub to_key: String, pub redirected: bool, - #[serde(default = "default_1713")] - pub memory_id: String, #[serde(default = "default_1714")] - pub version: Integer, + pub memory_id: String, #[serde(default = "default_1715")] - pub content_sha256: String, + pub version: Integer, #[serde(default = "default_1716")] - pub advisories: Vec, + pub content_sha256: String, #[serde(default = "default_1717")] - pub dry_run: bool, + pub advisories: Vec, #[serde(default = "default_1718")] - pub memory_type: String, + pub dry_run: bool, #[serde(default = "default_1719")] - pub value_preview: String, + pub memory_type: String, #[serde(default = "default_1720")] + pub value_preview: String, + #[serde(default = "default_1721")] pub sensitivity: String, } @@ -37438,7 +37440,7 @@ impl MemoryMoveInput { pub struct MemoryOutcomeOutput { pub recorded: bool, pub evidence_count_after: Integer, - #[serde(default = "default_1721")] + #[serde(default = "default_1722")] pub quarantined: bool, } @@ -37681,13 +37683,13 @@ impl MemoryOutcomeRunInput { #[non_exhaustive] pub struct OutlineSession { pub session_id: String, - #[serde(default = "default_1723")] - pub date: String, #[serde(default = "default_1724")] - pub headline: String, + pub date: String, #[serde(default = "default_1725")] - pub key_facts: Integer, + pub headline: String, #[serde(default = "default_1726")] + pub key_facts: Integer, + #[serde(default = "default_1727")] pub rows: Integer, } @@ -37695,7 +37697,7 @@ pub struct OutlineSession { #[non_exhaustive] pub struct OutlineHub { pub entity: String, - #[serde(default = "default_1729")] + #[serde(default = "default_1730")] pub degree: Integer, } @@ -37703,28 +37705,28 @@ pub struct OutlineHub { #[non_exhaustive] pub struct OutlineCommunity { pub community_id: Integer, - #[serde(default = "default_1731")] - pub label: String, #[serde(default = "default_1732")] - pub size: Integer, + pub label: String, #[serde(default = "default_1733")] + pub size: Integer, + #[serde(default = "default_1734")] pub computed_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryOutlineOutput { - #[serde(default = "default_1722")] + #[serde(default = "default_1723")] pub rows_by_type: std::collections::HashMap, - #[serde(default = "default_1727")] - pub sessions: Vec, #[serde(default = "default_1728")] + pub sessions: Vec, + #[serde(default = "default_1729")] pub sessions_total: Integer, - #[serde(default = "default_1730")] + #[serde(default = "default_1731")] pub hubs: Vec, - #[serde(default = "default_1734")] - pub communities: Vec, #[serde(default = "default_1735")] + pub communities: Vec, + #[serde(default = "default_1736")] pub profile_chars: Integer, } @@ -37876,7 +37878,7 @@ pub struct OwnerUsageRow { pub recalls: Integer, pub used: Integer, pub harm: Integer, - #[serde(default = "default_1736")] + #[serde(default = "default_1737")] pub last_recalled: Option, } @@ -38363,7 +38365,7 @@ pub struct MemoryPromoteOutput { pub shared_memory_key: String, pub promotion_event: String, pub reversible_until: String, - #[serde(default = "default_1737")] + #[serde(default = "default_1738")] pub ignored_args: Vec, } @@ -38532,18 +38534,18 @@ impl MemoryPromoteInput { pub struct MemoryProposalDecision { pub memory_key: String, pub decided: bool, - #[serde(default = "default_1739")] - pub status: String, #[serde(default = "default_1740")] + pub status: String, + #[serde(default = "default_1741")] pub reason: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalDecideOutput { - #[serde(default = "default_1738")] + #[serde(default = "default_1739")] pub decided: Integer, - #[serde(default = "default_1741")] + #[serde(default = "default_1742")] pub results: Vec, } @@ -38644,33 +38646,33 @@ pub enum MemoryProposalReady { pub struct MemoryProposal { pub memory_key: String, pub memory_id: String, - #[serde(default = "default_1742")] - pub content_sha256: String, #[serde(default = "default_1743")] - pub agent: String, + pub content_sha256: String, #[serde(default = "default_1744")] - pub memory_type: String, + pub agent: String, #[serde(default = "default_1745")] - pub value_preview: String, + pub memory_type: String, #[serde(default = "default_1746")] - pub sensitivity: String, + pub value_preview: String, #[serde(default = "default_1747")] - pub tags: Vec, + pub sensitivity: String, #[serde(default = "default_1748")] - pub created_at: String, + pub tags: Vec, #[serde(default = "default_1749")] - pub graded_passes: Integer, + pub created_at: String, #[serde(default = "default_1750")] - pub graded_fails: Integer, + pub graded_passes: Integer, #[serde(default = "default_1751")] - pub last_graded_at: String, + pub graded_fails: Integer, #[serde(default = "default_1752")] - pub used_count: Integer, + pub last_graded_at: String, #[serde(default = "default_1753")] - pub harm_count: Integer, + pub used_count: Integer, #[serde(default = "default_1754")] - pub ready: MemoryProposalReady, + pub harm_count: Integer, #[serde(default = "default_1755")] + pub ready: MemoryProposalReady, + #[serde(default = "default_1756")] pub conflict_with: Vec, } @@ -38686,24 +38688,24 @@ pub enum ProposalPolicyMode { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProposalPolicy { - #[serde(default = "default_1758")] - pub mode: ProposalPolicyMode, #[serde(default = "default_1759")] - pub min_passes: Integer, + pub mode: ProposalPolicyMode, #[serde(default = "default_1760")] - pub max_fails: Integer, + pub min_passes: Integer, #[serde(default = "default_1761")] + pub max_fails: Integer, + #[serde(default = "default_1762")] pub reject_after_fails: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryProposalsOutput { - #[serde(default = "default_1756")] - pub proposals: Vec, #[serde(default = "default_1757")] + pub proposals: Vec, + #[serde(default = "default_1758")] pub total: Integer, - #[serde(default = "default_1762")] + #[serde(default = "default_1763")] pub policy: ProposalPolicy, } @@ -38810,19 +38812,19 @@ impl MemoryProposalsInput { pub struct MemoryProvenanceLink { pub direction: String, pub memory_key: String, - #[serde(default = "default_1776")] - pub relation: String, #[serde(default = "default_1777")] - pub label: String, + pub relation: String, #[serde(default = "default_1778")] - pub explanation: String, + pub label: String, #[serde(default = "default_1779")] - pub evidence: Vec, + pub explanation: String, #[serde(default = "default_1780")] - pub confidence: f64, + pub evidence: Vec, #[serde(default = "default_1781")] - pub author: String, + pub confidence: f64, #[serde(default = "default_1782")] + pub author: String, + #[serde(default = "default_1783")] pub run_id: String, } @@ -38830,33 +38832,33 @@ pub struct MemoryProvenanceLink { #[non_exhaustive] pub struct MemoryProvenanceOutput { pub found: bool, - #[serde(default = "default_1763")] - pub source_trace: String, #[serde(default = "default_1764")] - pub source_kind: String, + pub source_trace: String, #[serde(default = "default_1765")] - pub actor: String, + pub source_kind: String, #[serde(default = "default_1766")] - pub source_class: String, + pub actor: String, #[serde(default = "default_1767")] - pub source_label: String, + pub source_class: String, #[serde(default = "default_1768")] - pub thread_id: String, + pub source_label: String, #[serde(default = "default_1769")] - pub thread_exists: bool, + pub thread_id: String, #[serde(default = "default_1770")] - pub thread_title: String, + pub thread_exists: bool, #[serde(default = "default_1771")] - pub agent: String, + pub thread_title: String, #[serde(default = "default_1772")] - pub session_id: String, + pub agent: String, #[serde(default = "default_1773")] - pub run_id: String, + pub session_id: String, #[serde(default = "default_1774")] - pub written_at: String, + pub run_id: String, #[serde(default = "default_1775")] + pub written_at: String, + #[serde(default = "default_1776")] pub source_resource_id: String, - #[serde(default = "default_1783")] + #[serde(default = "default_1784")] pub links: Vec, } @@ -38951,17 +38953,17 @@ impl MemoryProvenanceInput { pub struct RecallTurn { pub evidence_id: String, pub session_id: String, - #[serde(default = "default_1784")] - pub role: String, #[serde(default = "default_1785")] - pub actor: String, + pub role: String, #[serde(default = "default_1786")] - pub observed_at: String, + pub actor: String, #[serde(default = "default_1787")] - pub content: String, + pub observed_at: String, #[serde(default = "default_1788")] - pub truncated: bool, + pub content: String, #[serde(default = "default_1789")] + pub truncated: bool, + #[serde(default = "default_1790")] pub matched_tokens: Integer, } @@ -38978,21 +38980,21 @@ pub enum MemoryRecallOutputOrder { #[non_exhaustive] pub struct MemoryRecallOutput { pub turns: Vec, - #[serde(default = "default_1790")] - pub total_matched: Integer, #[serde(default = "default_1791")] - pub returned: Integer, + pub total_matched: Integer, #[serde(default = "default_1792")] - pub has_more: bool, + pub returned: Integer, #[serde(default = "default_1793")] - pub next_cursor: String, + pub has_more: bool, #[serde(default = "default_1794")] - pub next_offset: Integer, + pub next_cursor: String, #[serde(default = "default_1795")] - pub order: MemoryRecallOutputOrder, + pub next_offset: Integer, #[serde(default = "default_1796")] - pub query_tokens: Vec, + pub order: MemoryRecallOutputOrder, #[serde(default = "default_1797")] + pub query_tokens: Vec, + #[serde(default = "default_1798")] pub tokens_returned: Integer, } @@ -39274,19 +39276,19 @@ pub struct MemoryRecordConflictRow { pub schema_name: String, pub memory_key: String, pub field_name: String, - #[serde(default = "default_1798")] - pub prior_value: Value, #[serde(default = "default_1799")] + pub prior_value: Value, + #[serde(default = "default_1800")] pub incoming_value: Value, pub prior_record_id: String, pub incoming_record_id: String, - #[serde(default = "default_1800")] - pub prior_memory_id: String, #[serde(default = "default_1801")] - pub incoming_memory_id: String, + pub prior_memory_id: String, #[serde(default = "default_1802")] - pub detected_at: Option, + pub incoming_memory_id: String, #[serde(default = "default_1803")] + pub detected_at: Option, + #[serde(default = "default_1804")] pub resolved_at: Option, } @@ -39294,7 +39296,7 @@ pub struct MemoryRecordConflictRow { #[non_exhaustive] pub struct MemoryRecordConflictsOutput { pub rows: Vec, - #[serde(default = "default_1804")] + #[serde(default = "default_1805")] pub truncated: bool, } @@ -39404,19 +39406,19 @@ pub enum MemoryRecordRowStatus { #[non_exhaustive] pub struct MemoryRecordRow { pub record_id: String, - #[serde(default = "default_1805")] - pub memory_key: String, #[serde(default = "default_1806")] - pub memory_id: String, + pub memory_key: String, #[serde(default = "default_1807")] - pub record: std::collections::HashMap, + pub memory_id: String, #[serde(default = "default_1808")] - pub field_states: std::collections::HashMap, + pub record: std::collections::HashMap, #[serde(default = "default_1809")] - pub status: MemoryRecordRowStatus, + pub field_states: std::collections::HashMap, #[serde(default = "default_1810")] - pub valid_at: Option, + pub status: MemoryRecordRowStatus, #[serde(default = "default_1811")] + pub valid_at: Option, + #[serde(default = "default_1812")] pub valid_to: Option, } @@ -39483,7 +39485,7 @@ impl MemoryRecordHistoryInput { #[non_exhaustive] pub struct MemoryRecordQueryOutput { pub rows: Vec, - #[serde(default = "default_1812")] + #[serde(default = "default_1813")] pub truncated: bool, } @@ -39707,15 +39709,15 @@ pub enum MemoryRecordWriteOutputKeySource { pub struct MemoryRecordWriteOutput { pub record_id: String, pub field_count: Integer, - #[serde(default = "default_1813")] - pub memory_key: String, #[serde(default = "default_1814")] - pub key_source: MemoryRecordWriteOutputKeySource, + pub memory_key: String, #[serde(default = "default_1815")] - pub fold: std::collections::HashMap, + pub key_source: MemoryRecordWriteOutputKeySource, #[serde(default = "default_1816")] - pub superseded_record_id: String, + pub fold: std::collections::HashMap, #[serde(default = "default_1817")] + pub superseded_record_id: String, + #[serde(default = "default_1818")] pub conflicts: Integer, } @@ -39958,13 +39960,13 @@ impl MemoryRecordWriteInput { #[non_exhaustive] pub struct MemoryRedactOutput { pub redacted: bool, - #[serde(default = "default_1818")] - pub refused_head: bool, #[serde(default = "default_1819")] - pub redacted_at: Option, + pub refused_head: bool, #[serde(default = "default_1820")] - pub cache_rows_deleted: Integer, + pub redacted_at: Option, #[serde(default = "default_1821")] + pub cache_rows_deleted: Integer, + #[serde(default = "default_1822")] pub precedent_rows_deleted: Integer, } @@ -40124,7 +40126,7 @@ impl MemoryReindexInput { #[non_exhaustive] pub struct MemoryRejectOutput { pub rejected: bool, - #[serde(default = "default_1822")] + #[serde(default = "default_1823")] pub rejected_at: Option, } @@ -40240,7 +40242,7 @@ pub struct MemoryRelatedHit { pub struct MemoryRelatedOutput { pub results: Vec, pub source_entities: Vec, - #[serde(default = "default_1823")] + #[serde(default = "default_1824")] pub reason: String, } @@ -40355,13 +40357,13 @@ impl MemoryRelatedInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryResolveOrphanDuplicatesOutput { - #[serde(default = "default_1824")] - pub candidates: Integer, #[serde(default = "default_1825")] - pub reactivated: Integer, + pub candidates: Integer, #[serde(default = "default_1826")] - pub dry_run: bool, + pub reactivated: Integer, #[serde(default = "default_1827")] + pub dry_run: bool, + #[serde(default = "default_1828")] pub memory_ids: Vec, } @@ -40438,15 +40440,15 @@ impl MemoryResolveOrphanDuplicatesInput { #[non_exhaustive] pub struct MemoryRestoreOutput { pub restored: bool, - #[serde(default = "default_1828")] - pub memory_id: Option, #[serde(default = "default_1829")] - pub version: Option, + pub memory_id: Option, #[serde(default = "default_1830")] - pub expired: bool, + pub version: Option, #[serde(default = "default_1831")] - pub redacted: bool, + pub expired: bool, #[serde(default = "default_1832")] + pub redacted: bool, + #[serde(default = "default_1833")] pub from_status: String, } @@ -40566,13 +40568,13 @@ pub struct SearchTraceHit { pub content_excerpt: String, pub distance: f64, pub similarity: f64, - #[serde(default = "default_1833")] + #[serde(default = "default_1834")] pub entity_boost: f64, pub rank_score: f64, pub rank: Integer, - #[serde(default = "default_1834")] - pub source: String, #[serde(default = "default_1835")] + pub source: String, + #[serde(default = "default_1836")] pub parent_memory_key: String, } @@ -40582,11 +40584,11 @@ pub struct MemorySearchTraceOutput { pub results: Vec, pub embedding_model: String, pub entity_filter: Vec, - #[serde(default = "default_1836")] - pub query_spellings: std::collections::HashMap, #[serde(default = "default_1837")] - pub query_spellings_skipped: bool, + pub query_spellings: std::collections::HashMap, #[serde(default = "default_1838")] + pub query_spellings_skipped: bool, + #[serde(default = "default_1839")] pub stale_dropped: Integer, } @@ -41767,7 +41769,7 @@ pub struct SearchTraceLogRow { pub embedding_model: String, pub latency_ms: Integer, pub run_id: String, - #[serde(default = "default_1839")] + #[serde(default = "default_1840")] pub operation: String, } @@ -41876,71 +41878,71 @@ pub struct RefusedFact { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySetFromMessagesOutput { - #[serde(default = "default_1840")] - pub written: Vec, #[serde(default = "default_1841")] - pub refused: Vec, + pub written: Vec, #[serde(default = "default_1842")] - pub tokens_in: Integer, + pub refused: Vec, #[serde(default = "default_1843")] - pub tokens_out: Integer, + pub tokens_in: Integer, #[serde(default = "default_1844")] - pub llm_provider: String, + pub tokens_out: Integer, #[serde(default = "default_1845")] - pub llm_model: String, + pub llm_provider: String, #[serde(default = "default_1846")] - pub segments: Integer, + pub llm_model: String, #[serde(default = "default_1847")] - pub foresight: Integer, + pub segments: Integer, #[serde(default = "default_1848")] - pub forgotten: Integer, + pub foresight: Integer, #[serde(default = "default_1849")] - pub forgotten_keys: Vec, + pub forgotten: Integer, #[serde(default = "default_1850")] - pub forget_requests: Integer, + pub forgotten_keys: Vec, #[serde(default = "default_1851")] - pub about_other: Integer, + pub forget_requests: Integer, #[serde(default = "default_1852")] - pub premise_facts: Integer, + pub about_other: Integer, #[serde(default = "default_1853")] - pub learning_candidates: Integer, + pub premise_facts: Integer, #[serde(default = "default_1854")] - pub ignored_args: Vec, + pub learning_candidates: Integer, #[serde(default = "default_1855")] - pub segmenter: String, + pub ignored_args: Vec, #[serde(default = "default_1856")] - pub cached_tokens_in: Integer, + pub segmenter: String, #[serde(default = "default_1857")] - pub ontology_warnings: Vec, + pub cached_tokens_in: Integer, #[serde(default = "default_1858")] - pub evidence_ids: Vec, + pub ontology_warnings: Vec, #[serde(default = "default_1859")] - pub belief_source_links: Integer, + pub evidence_ids: Vec, #[serde(default = "default_1860")] - pub pipeline_errors: Vec, + pub belief_source_links: Integer, #[serde(default = "default_1861")] - pub value_updates_linked: Integer, + pub pipeline_errors: Vec, #[serde(default = "default_1862")] - pub stubbed_fields: Vec, + pub value_updates_linked: Integer, #[serde(default = "default_1863")] - pub degraded: Vec, + pub stubbed_fields: Vec, #[serde(default = "default_1864")] - pub deferred: bool, + pub degraded: Vec, #[serde(default = "default_1865")] - pub queue_id: String, + pub deferred: bool, #[serde(default = "default_1866")] - pub deferred_by: String, + pub queue_id: String, #[serde(default = "default_1867")] - pub stage_ms: std::collections::HashMap, + pub deferred_by: String, #[serde(default = "default_1868")] - pub observation_date_source: String, + pub stage_ms: std::collections::HashMap, #[serde(default = "default_1869")] - pub under_operator_policy: bool, + pub observation_date_source: String, #[serde(default = "default_1870")] - pub extract_prompt_keys: Vec, + pub under_operator_policy: bool, #[serde(default = "default_1871")] - pub llm_cache_hits: Integer, + pub extract_prompt_keys: Vec, #[serde(default = "default_1872")] + pub llm_cache_hits: Integer, + #[serde(default = "default_1873")] pub llm_cache_misses: Integer, } @@ -42353,25 +42355,25 @@ pub enum StackEntrySection { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct StackEntry { - #[serde(default = "default_1873")] + #[serde(default = "default_1874")] pub use_guidance: Option, pub section: StackEntrySection, - #[serde(default = "default_1874")] - pub memory_key: String, #[serde(default = "default_1875")] - pub memory_type: String, + pub memory_key: String, #[serde(default = "default_1876")] + pub memory_type: String, + #[serde(default = "default_1877")] pub value: String, pub tokens: Integer, - #[serde(default = "default_1877")] - pub pinned: bool, #[serde(default = "default_1878")] - pub recall_count: Integer, + pub pinned: bool, #[serde(default = "default_1879")] - pub last_recalled_at: Option, + pub recall_count: Integer, #[serde(default = "default_1880")] - pub actor: String, + pub last_recalled_at: Option, #[serde(default = "default_1881")] + pub actor: String, + #[serde(default = "default_1882")] pub namespace: String, } @@ -42556,14 +42558,14 @@ impl MemoryStackInput { pub struct MemoryStatus { pub memory_id: String, pub status: String, - #[serde(default = "default_1882")] + #[serde(default = "default_1883")] pub superseded_by: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemoryStatusesOutput { - #[serde(default = "default_1883")] + #[serde(default = "default_1884")] pub rows: Vec, } @@ -42612,23 +42614,23 @@ impl MemoryStatusesInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct MemorySweepExpiredOutput { - #[serde(default = "default_1884")] - pub scanned: Integer, #[serde(default = "default_1885")] - pub tombstoned: Integer, + pub scanned: Integer, #[serde(default = "default_1886")] - pub demoted: Integer, + pub tombstoned: Integer, #[serde(default = "default_1887")] - pub anonymized: Integer, + pub demoted: Integer, #[serde(default = "default_1888")] - pub locked_skipped: Integer, + pub anonymized: Integer, #[serde(default = "default_1889")] - pub moved_skipped: Integer, + pub locked_skipped: Integer, #[serde(default = "default_1890")] - pub dry_run: bool, + pub moved_skipped: Integer, #[serde(default = "default_1891")] - pub sample: Vec>, + pub dry_run: bool, #[serde(default = "default_1892")] + pub sample: Vec>, + #[serde(default = "default_1893")] pub failures: Vec, } @@ -42705,10 +42707,10 @@ pub struct MemoryTimelineEntry { pub memory_key: String, pub memory_type: String, pub content_excerpt: String, - #[serde(default = "default_1893")] + #[serde(default = "default_1894")] pub valid_at: Option, pub created_at: String, - #[serde(default = "default_1894")] + #[serde(default = "default_1895")] pub namespace: String, } @@ -42716,7 +42718,7 @@ pub struct MemoryTimelineEntry { #[non_exhaustive] pub struct MemoryTimelineOutput { pub events: Vec, - #[serde(default = "default_1895")] + #[serde(default = "default_1896")] pub total_matching: Integer, } @@ -42908,9 +42910,9 @@ impl MemoryTimelineInput { pub struct MemoryTouchResult { pub memory_key: String, pub touched: bool, - #[serde(default = "default_1898")] - pub version: Option, #[serde(default = "default_1899")] + pub version: Option, + #[serde(default = "default_1900")] pub expires_at: Option, } @@ -42918,13 +42920,13 @@ pub struct MemoryTouchResult { #[non_exhaustive] pub struct MemoryTouchOutput { pub touched: bool, - #[serde(default = "default_1896")] - pub version: Option, #[serde(default = "default_1897")] + pub version: Option, + #[serde(default = "default_1898")] pub expires_at: Option, - #[serde(default = "default_1900")] - pub results: Vec, #[serde(default = "default_1901")] + pub results: Vec, + #[serde(default = "default_1902")] pub touched_count: Integer, } @@ -43104,15 +43106,15 @@ impl MemoryTouchInput { #[non_exhaustive] pub struct MemoryUnlockOutput { pub unlocked: bool, - #[serde(default = "default_1902")] - pub reason: String, #[serde(default = "default_1903")] - pub memory_id: String, + pub reason: String, #[serde(default = "default_1904")] - pub version: Option, + pub memory_id: String, #[serde(default = "default_1905")] - pub previous_mode: String, + pub version: Option, #[serde(default = "default_1906")] + pub previous_mode: String, + #[serde(default = "default_1907")] pub unlocked_by: String, } @@ -43217,11 +43219,11 @@ impl MemoryUnlockInput { #[non_exhaustive] pub struct MemoryUnpinOutput { pub unpinned: bool, - #[serde(default = "default_1907")] - pub reason: String, #[serde(default = "default_1908")] - pub memory_id: String, + pub reason: String, #[serde(default = "default_1909")] + pub memory_id: String, + #[serde(default = "default_1910")] pub version: Option, } @@ -43315,15 +43317,15 @@ impl MemoryUnpinInput { #[non_exhaustive] pub struct MemoryUpdateCandidate { pub memory_id: String, - #[serde(default = "default_1915")] - pub agent: String, #[serde(default = "default_1916")] - pub user_id: String, + pub agent: String, #[serde(default = "default_1917")] - pub session_id: String, + pub user_id: String, #[serde(default = "default_1918")] - pub version: Integer, + pub session_id: String, #[serde(default = "default_1919")] + pub version: Integer, + #[serde(default = "default_1920")] pub status: String, } @@ -43331,23 +43333,23 @@ pub struct MemoryUpdateCandidate { #[non_exhaustive] pub struct MemoryUpdateOutput { pub updated: bool, - #[serde(default = "default_1910")] - pub memory_id: String, #[serde(default = "default_1911")] - pub memory_key: String, + pub memory_id: String, #[serde(default = "default_1912")] - pub new_version: Integer, + pub memory_key: String, #[serde(default = "default_1913")] - pub content_sha256: String, + pub new_version: Integer, #[serde(default = "default_1914")] + pub content_sha256: String, + #[serde(default = "default_1915")] pub reason: String, - #[serde(default = "default_1920")] - pub candidates: Vec, #[serde(default = "default_1921")] - pub conflict_verdict: String, + pub candidates: Vec, #[serde(default = "default_1922")] - pub conflict_peers: Integer, + pub conflict_verdict: String, #[serde(default = "default_1923")] + pub conflict_peers: Integer, + #[serde(default = "default_1924")] pub duplicate_of: String, } @@ -43556,15 +43558,15 @@ impl MemoryUpdateInput { #[non_exhaustive] pub struct MemoryUpdateByIdOutput { pub updated: bool, - #[serde(default = "default_1924")] - pub new_version: Integer, #[serde(default = "default_1925")] - pub content_sha256: String, + pub new_version: Integer, #[serde(default = "default_1926")] - pub conflict_verdict: String, + pub content_sha256: String, #[serde(default = "default_1927")] - pub conflict_peers: Integer, + pub conflict_verdict: String, #[serde(default = "default_1928")] + pub conflict_peers: Integer, + #[serde(default = "default_1929")] pub duplicate_of: String, } @@ -43692,23 +43694,23 @@ impl MemoryUpdateByIdInput { #[non_exhaustive] pub struct MemoryVerifyOutput { pub found: bool, - #[serde(default = "default_1929")] - pub changed: bool, #[serde(default = "default_1930")] - pub memory_id: String, + pub changed: bool, #[serde(default = "default_1931")] - pub memory_key: String, + pub memory_id: String, #[serde(default = "default_1932")] - pub namespace: String, + pub memory_key: String, #[serde(default = "default_1933")] - pub verified_by: String, + pub namespace: String, #[serde(default = "default_1934")] - pub verified_at: Option, + pub verified_by: String, #[serde(default = "default_1935")] - pub verification: String, + pub verified_at: Option, #[serde(default = "default_1936")] - pub version: Integer, + pub verification: String, #[serde(default = "default_1937")] + pub version: Integer, + #[serde(default = "default_1938")] pub content_sha256: String, } @@ -43913,13 +43915,13 @@ pub struct SchemaFieldOutput { #[serde(rename = "type")] pub r#type: String, pub required: bool, - #[serde(default = "default_1940")] - pub identity: bool, #[serde(default = "default_1941")] - pub enum_values: Vec, + pub identity: bool, #[serde(default = "default_1942")] - pub constraints: std::collections::HashMap, + pub enum_values: Vec, #[serde(default = "default_1943")] + pub constraints: std::collections::HashMap, + #[serde(default = "default_1944")] pub description: String, } @@ -43928,11 +43930,11 @@ pub struct SchemaFieldOutput { pub struct MemorySchemaSummary { pub schema_id: String, pub name: String, - #[serde(default = "default_1938")] - pub description: String, #[serde(default = "default_1939")] + pub description: String, + #[serde(default = "default_1940")] pub status: String, - #[serde(default = "default_1944")] + #[serde(default = "default_1945")] pub fields: Vec, } @@ -44347,13 +44349,13 @@ impl MemorySchemaRegisterInput { #[non_exhaustive] pub struct MentorPlane { pub plane: String, - #[serde(default = "default_1946")] - pub calls: Integer, #[serde(default = "default_1947")] - pub available: Option, + pub calls: Integer, #[serde(default = "default_1948")] - pub when: String, + pub available: Option, #[serde(default = "default_1949")] + pub when: String, + #[serde(default = "default_1950")] pub mentored: bool, } @@ -44363,11 +44365,11 @@ pub struct MentorHint { pub code: String, pub severity: String, pub text: String, - #[serde(default = "default_1951")] - pub ops: Vec, #[serde(default = "default_1952")] - pub evidence: std::collections::HashMap, + pub ops: Vec, #[serde(default = "default_1953")] + pub evidence: std::collections::HashMap, + #[serde(default = "default_1954")] pub plane: Option, } @@ -44375,9 +44377,9 @@ pub struct MentorHint { #[non_exhaustive] pub struct MentorAdoption { pub code: String, - #[serde(default = "default_1955")] - pub shown_sessions: Integer, #[serde(default = "default_1956")] + pub shown_sessions: Integer, + #[serde(default = "default_1957")] pub followed_sessions: Integer, } @@ -44413,7 +44415,7 @@ pub enum UsageRungSource { #[non_exhaustive] pub struct UsageRung { pub rung: UsageRungRung, - #[serde(default = "default_1958")] + #[serde(default = "default_1959")] pub count: Option, pub source: UsageRungSource, pub meaning: String, @@ -44428,27 +44430,27 @@ pub struct MentorBriefOutput { pub window_seconds: Integer, pub computed_at: String, pub sessions: Integer, - #[serde(default = "default_1945")] + #[serde(default = "default_1946")] pub usage: std::collections::HashMap, - #[serde(default = "default_1950")] + #[serde(default = "default_1951")] pub planes: Vec, - #[serde(default = "default_1954")] + #[serde(default = "default_1955")] pub hints: Vec, - #[serde(default = "default_1957")] + #[serde(default = "default_1958")] pub adoption: Vec, - #[serde(default = "default_1959")] - pub usage_evidence: Vec, #[serde(default = "default_1960")] - pub ledger_from: Option, + pub usage_evidence: Vec, #[serde(default = "default_1961")] - pub ledger_retention_days: Option, + pub ledger_from: Option, #[serde(default = "default_1962")] - pub agents: Vec, + pub ledger_retention_days: Option, #[serde(default = "default_1963")] - pub agent_defaulted: bool, + pub agents: Vec, #[serde(default = "default_1964")] - pub skipped: Vec, + pub agent_defaulted: bool, #[serde(default = "default_1965")] + pub skipped: Vec, + #[serde(default = "default_1966")] pub healthy: bool, } @@ -44597,33 +44599,33 @@ impl MentorGuideInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct NamespaceAuditSummary { - #[serde(default = "default_1966")] - pub live_rows: Integer, #[serde(default = "default_1967")] - pub live_bytes: Integer, + pub live_rows: Integer, #[serde(default = "default_1968")] - pub excerpt_bytes: Integer, + pub live_bytes: Integer, #[serde(default = "default_1969")] - pub version_rows: Integer, + pub excerpt_bytes: Integer, #[serde(default = "default_1970")] - pub version_bytes: Integer, + pub version_rows: Integer, #[serde(default = "default_1971")] - pub unembedded_rows: Integer, + pub version_bytes: Integer, #[serde(default = "default_1972")] - pub gets: Integer, + pub unembedded_rows: Integer, #[serde(default = "default_1973")] - pub searches: Integer, + pub gets: Integer, #[serde(default = "default_1974")] - pub sets: Integer, + pub searches: Integer, #[serde(default = "default_1975")] - pub get_search_ratio: f64, + pub sets: Integer, #[serde(default = "default_1976")] - pub inspector_calls: Integer, + pub get_search_ratio: f64, #[serde(default = "default_1977")] - pub typed_gets: Integer, + pub inspector_calls: Integer, #[serde(default = "default_1978")] - pub written_in_window: Integer, + pub typed_gets: Integer, #[serde(default = "default_1979")] + pub written_in_window: Integer, + #[serde(default = "default_1980")] pub ledger_calls: Integer, } @@ -44655,25 +44657,25 @@ pub struct NamespaceAuditFinding { pub kind: NamespaceAuditFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_1980")] - pub window_seconds: Option, #[serde(default = "default_1981")] + pub window_seconds: Option, + #[serde(default = "default_1982")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_1982")] - pub evidence: Vec, #[serde(default = "default_1983")] - pub exceptions: String, + pub evidence: Vec, #[serde(default = "default_1984")] + pub exceptions: String, + #[serde(default = "default_1985")] pub uncertainty: String, pub code: String, pub severity: NamespaceAuditFindingSeverity, pub count: Integer, pub share: f64, - #[serde(default = "default_1985")] - pub bytes: Integer, #[serde(default = "default_1986")] + pub bytes: Integer, + #[serde(default = "default_1987")] pub samples: Vec>, pub detail: String, pub remedy: String, @@ -44688,7 +44690,7 @@ pub struct NamespaceAuditOutput { pub window_seconds: Integer, pub summary: NamespaceAuditSummary, pub findings: Vec, - #[serde(default = "default_1987")] + #[serde(default = "default_1988")] pub skipped: Vec, pub coverage: ReportCoverage, pub healthy: bool, @@ -44779,29 +44781,29 @@ pub enum BrowseEntryMyStatus { #[non_exhaustive] pub struct BrowseEntry { pub namespace: String, - #[serde(default = "default_1988")] + #[serde(default = "default_1989")] pub kind: String, pub description: String, pub owner_email: String, pub member_count: Integer, - #[serde(default = "default_1989")] + #[serde(default = "default_1990")] pub requires_approval: bool, pub created_at: String, - #[serde(default = "default_1990")] - pub join_policy: String, #[serde(default = "default_1991")] - pub visibility: String, + pub join_policy: String, #[serde(default = "default_1992")] - pub my_status: BrowseEntryMyStatus, + pub visibility: String, #[serde(default = "default_1993")] - pub my_role: String, + pub my_status: BrowseEntryMyStatus, #[serde(default = "default_1994")] - pub repo: String, + pub my_role: String, #[serde(default = "default_1995")] - pub branch: String, + pub repo: String, #[serde(default = "default_1996")] - pub guide_revision: Integer, + pub branch: String, #[serde(default = "default_1997")] + pub guide_revision: Integer, + #[serde(default = "default_1998")] pub guide_summary: String, } @@ -44905,9 +44907,9 @@ pub enum NamespaceCancelRequestOutputClearedRole { pub struct NamespaceCancelRequestOutput { pub cancelled: bool, pub namespace: String, - #[serde(default = "default_1998")] - pub cleared_role: Option, #[serde(default = "default_1999")] + pub cleared_role: Option, + #[serde(default = "default_2000")] pub cancelled_at: Option, } @@ -44979,7 +44981,7 @@ pub struct NamespaceDeleteOutput { pub deleted: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_2000")] + #[serde(default = "default_2001")] pub sources_retired: Vec, } @@ -45048,67 +45050,67 @@ pub enum NamespaceGetOutputClassification { pub struct NamespaceGetOutput { pub found: bool, pub namespace: String, - #[serde(default = "default_2001")] - pub kind: Option, #[serde(default = "default_2002")] - pub owner_email: Option, + pub kind: Option, #[serde(default = "default_2003")] - pub description: Option, + pub owner_email: Option, #[serde(default = "default_2004")] - pub tags: Option>, + pub description: Option, #[serde(default = "default_2005")] - pub active: Option, + pub tags: Option>, #[serde(default = "default_2006")] - pub conversation_logging_enabled: Option, + pub active: Option, #[serde(default = "default_2007")] - pub capture_generation_io: Option, + pub conversation_logging_enabled: Option, #[serde(default = "default_2008")] - pub coverage_sweep: Option, + pub capture_generation_io: Option, #[serde(default = "default_2009")] - pub consolidation_enabled: Option, + pub coverage_sweep: Option, #[serde(default = "default_2010")] - pub daily_cost_cap_usd: Option, + pub consolidation_enabled: Option, #[serde(default = "default_2011")] - pub daily_user_cost_cap_usd: Option, + pub daily_cost_cap_usd: Option, #[serde(default = "default_2012")] - pub budget_alert_inbox: Option, + pub daily_user_cost_cap_usd: Option, #[serde(default = "default_2013")] - pub conflict_threshold: Option, + pub budget_alert_inbox: Option, #[serde(default = "default_2014")] - pub retention_days: Option, + pub conflict_threshold: Option, #[serde(default = "default_2015")] - pub warm_days: Option, + pub retention_days: Option, #[serde(default = "default_2016")] - pub visibility: Option, + pub warm_days: Option, #[serde(default = "default_2017")] - pub requires_approval: Option, + pub visibility: Option, #[serde(default = "default_2018")] - pub join_policy: Option, + pub requires_approval: Option, #[serde(default = "default_2019")] - pub effective_join_policy: Option, + pub join_policy: Option, #[serde(default = "default_2020")] - pub retrieval_defaults: Option>, + pub effective_join_policy: Option, #[serde(default = "default_2021")] - pub rerank_endpoint: Option, + pub retrieval_defaults: Option>, #[serde(default = "default_2022")] - pub classify_endpoint: Option, + pub rerank_endpoint: Option, #[serde(default = "default_2023")] - pub default_conflict_policy: Option, + pub classify_endpoint: Option, #[serde(default = "default_2024")] - pub proposal_policy: Option, + pub default_conflict_policy: Option, #[serde(default = "default_2025")] - pub code_change_policy: Option, + pub proposal_policy: Option, #[serde(default = "default_2026")] - pub tag_registry: Option>>, + pub code_change_policy: Option, #[serde(default = "default_2027")] - pub classification: Option, + pub tag_registry: Option>>, #[serde(default = "default_2028")] - pub guide_revision: Option, + pub classification: Option, #[serde(default = "default_2029")] - pub guide_summary: Option, + pub guide_revision: Option, #[serde(default = "default_2030")] - pub created_at: Option, + pub guide_summary: Option, #[serde(default = "default_2031")] + pub created_at: Option, + #[serde(default = "default_2032")] pub updated_at: Option, } @@ -45161,17 +45163,17 @@ impl NamespaceGetInput { #[non_exhaustive] pub struct NamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2032")] - pub revision: Integer, #[serde(default = "default_2033")] - pub content: String, + pub revision: Integer, #[serde(default = "default_2034")] - pub summary: String, + pub content: String, #[serde(default = "default_2035")] - pub note: String, + pub summary: String, #[serde(default = "default_2036")] - pub updated_by: String, + pub note: String, #[serde(default = "default_2037")] + pub updated_by: String, + #[serde(default = "default_2038")] pub updated_at: Option, } @@ -45308,17 +45310,17 @@ impl NamespaceGuideHistoryInput { #[non_exhaustive] pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { pub found: bool, - #[serde(default = "default_2039")] - pub revision: Integer, #[serde(default = "default_2040")] - pub content: String, + pub revision: Integer, #[serde(default = "default_2041")] - pub summary: String, + pub content: String, #[serde(default = "default_2042")] - pub note: String, + pub summary: String, #[serde(default = "default_2043")] - pub updated_by: String, + pub note: String, #[serde(default = "default_2044")] + pub updated_by: String, + #[serde(default = "default_2045")] pub updated_at: Option, } @@ -45326,10 +45328,10 @@ pub struct NamespaceGuideSetOutputNamespaceGuideGetOutput { #[non_exhaustive] pub struct NamespaceGuideSetOutput { pub written: bool, - #[serde(default = "default_2038")] + #[serde(default = "default_2039")] pub conflict: bool, pub revision: Integer, - #[serde(default = "default_2045")] + #[serde(default = "default_2046")] pub current: Option, } @@ -45450,7 +45452,7 @@ pub struct InventorySection { #[serde(deserialize_with = "required_nullable")] pub latest_at: Option, pub complete: bool, - #[serde(default = "default_2046")] + #[serde(default = "default_2047")] pub reason: String, } @@ -45480,10 +45482,10 @@ pub struct InventoryPopulation { pub population: InventoryPopulationPopulation, #[serde(deserialize_with = "required_nullable")] pub total: Option, - #[serde(default = "default_2047")] + #[serde(default = "default_2048")] pub top: Vec, pub complete: bool, - #[serde(default = "default_2048")] + #[serde(default = "default_2049")] pub reason: String, } @@ -45649,11 +45651,11 @@ pub struct NamespaceJoinOutput { pub joined: bool, pub namespace: String, pub role: NamespaceJoinOutputRole, - #[serde(default = "default_2049")] - pub status: String, #[serde(default = "default_2050")] - pub requested_role: Option, + pub status: String, #[serde(default = "default_2051")] + pub requested_role: Option, + #[serde(default = "default_2052")] pub pending_admins: Vec, pub joined_at: String, } @@ -45745,7 +45747,7 @@ impl NamespaceJoinInput { pub struct NamespaceLeaveOutput { pub left: bool, pub namespace: String, - #[serde(default = "default_2052")] + #[serde(default = "default_2053")] pub left_at: Option, } @@ -45822,27 +45824,27 @@ pub enum NamespaceEntryVisibility { #[non_exhaustive] pub struct NamespaceEntry { pub namespace: String, - #[serde(default = "default_2053")] + #[serde(default = "default_2054")] pub kind: String, pub owner_email: String, pub description: String, pub tags: Vec, pub active: bool, - #[serde(default = "default_2054")] - pub consolidation_enabled: bool, #[serde(default = "default_2055")] - pub daily_cost_cap_usd: f64, + pub consolidation_enabled: bool, #[serde(default = "default_2056")] - pub daily_user_cost_cap_usd: f64, + pub daily_cost_cap_usd: f64, #[serde(default = "default_2057")] - pub budget_alert_inbox: String, + pub daily_user_cost_cap_usd: f64, #[serde(default = "default_2058")] - pub conflict_threshold: Option, + pub budget_alert_inbox: String, #[serde(default = "default_2059")] - pub retention_days: Integer, + pub conflict_threshold: Option, #[serde(default = "default_2060")] - pub warm_days: Integer, + pub retention_days: Integer, #[serde(default = "default_2061")] + pub warm_days: Integer, + #[serde(default = "default_2062")] pub visibility: NamespaceEntryVisibility, pub created_at: String, pub updated_at: String, @@ -45997,27 +45999,27 @@ pub enum MineEntryVisibility { pub struct MineEntry { pub namespace: String, pub role: String, - #[serde(default = "default_2062")] - pub status: String, #[serde(default = "default_2063")] - pub pending_role: Option, + pub status: String, #[serde(default = "default_2064")] - pub pending_since: Option, + pub pending_role: Option, #[serde(default = "default_2065")] - pub pending_admins: Vec, + pub pending_since: Option, #[serde(default = "default_2066")] - pub visibility: MineEntryVisibility, + pub pending_admins: Vec, #[serde(default = "default_2067")] - pub kind: String, + pub visibility: MineEntryVisibility, #[serde(default = "default_2068")] - pub title: String, + pub kind: String, #[serde(default = "default_2069")] - pub description: String, + pub title: String, #[serde(default = "default_2070")] - pub joined_at: Option, + pub description: String, #[serde(default = "default_2071")] - pub is_new: bool, + pub joined_at: Option, #[serde(default = "default_2072")] + pub is_new: bool, + #[serde(default = "default_2073")] pub inherited: bool, } @@ -46083,7 +46085,7 @@ pub struct OntologyEntry { pub name: String, pub status: String, pub description: String, - #[serde(default = "default_2073")] + #[serde(default = "default_2074")] pub cardinality: String, pub created_by: String, pub updated_at: String, @@ -46276,7 +46278,7 @@ pub struct NamespaceRegisterOutput { pub registered: bool, pub namespace: String, pub updated_at: String, - #[serde(default = "default_2074")] + #[serde(default = "default_2075")] pub visibility: NamespaceRegisterOutputVisibility, } @@ -47356,7 +47358,7 @@ impl NamespaceRegisterOntologyInput { #[non_exhaustive] pub struct NamespaceRestoreOutput { pub restored: bool, - #[serde(default = "default_2075")] + #[serde(default = "default_2076")] pub publication_pending: bool, pub target_namespace: String, pub snapshot_id: String, @@ -48243,15 +48245,15 @@ pub struct NamespaceRollbackOutput { pub version_at: Integer, pub reinstate: Integer, pub remove: Integer, - #[serde(default = "default_2076")] - pub skipped_no_head: Integer, #[serde(default = "default_2077")] - pub skipped_already_gone: Integer, + pub skipped_no_head: Integer, #[serde(default = "default_2078")] - pub truncated: bool, + pub skipped_already_gone: Integer, #[serde(default = "default_2079")] - pub sample: Vec>, + pub truncated: bool, #[serde(default = "default_2080")] + pub sample: Vec>, + #[serde(default = "default_2081")] pub applied_at: Option, } @@ -48430,101 +48432,101 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub confidence: f64, pub source_trace: String, pub pinned: bool, - #[serde(default = "default_2081")] - pub expires_at: Option, #[serde(default = "default_2082")] - pub entities: Vec, + pub expires_at: Option, #[serde(default = "default_2083")] - pub version: Integer, + pub entities: Vec, #[serde(default = "default_2084")] - pub content_sha256: String, + pub version: Integer, #[serde(default = "default_2085")] - pub actor: String, + pub content_sha256: String, #[serde(default = "default_2086")] - pub source_class: String, + pub actor: String, #[serde(default = "default_2087")] - pub source_resource_id: String, + pub source_class: String, #[serde(default = "default_2088")] - pub verified_by: String, + pub source_resource_id: String, #[serde(default = "default_2089")] - pub verified_at: Option, + pub verified_by: String, #[serde(default = "default_2090")] - pub verified_sha256: String, + pub verified_at: Option, #[serde(default = "default_2091")] - pub grounding: String, + pub verified_sha256: String, #[serde(default = "default_2092")] - pub evidence: String, + pub grounding: String, #[serde(default = "default_2093")] - pub tags: Vec, + pub evidence: String, #[serde(default = "default_2094")] - pub valid_at: Option, + pub tags: Vec, #[serde(default = "default_2095")] - pub valid_to: Option, + pub valid_at: Option, #[serde(default = "default_2096")] - pub created_at: Option, + pub valid_to: Option, #[serde(default = "default_2097")] - pub updated_at: Option, + pub created_at: Option, #[serde(default = "default_2098")] - pub value_json: String, + pub updated_at: Option, #[serde(default = "default_2099")] - pub status: NamespaceSnapshotOutputSnapshotMemoryRowStatus, + pub value_json: String, #[serde(default = "default_2100")] - pub requires_review: Option, + pub status: NamespaceSnapshotOutputSnapshotMemoryRowStatus, #[serde(default = "default_2101")] - pub conflict_with: Vec, + pub requires_review: Option, #[serde(default = "default_2102")] - pub duplicate_of: String, + pub conflict_with: Vec, #[serde(default = "default_2103")] - pub evidence_count: Integer, + pub duplicate_of: String, #[serde(default = "default_2104")] - pub recall_count: Integer, + pub evidence_count: Integer, #[serde(default = "default_2105")] - pub last_recalled_at: Option, + pub recall_count: Integer, #[serde(default = "default_2106")] - pub cross_promoted_from_memory_id: String, + pub last_recalled_at: Option, #[serde(default = "default_2107")] - pub cross_promoted_from_namespace: String, + pub cross_promoted_from_memory_id: String, #[serde(default = "default_2108")] - pub superseded_by: String, + pub cross_promoted_from_namespace: String, #[serde(default = "default_2109")] - pub rejection_reason: String, + pub superseded_by: String, #[serde(default = "default_2110")] - pub temporal_anchor: Option, + pub rejection_reason: String, #[serde(default = "default_2111")] - pub temporal_confidence: f64, + pub temporal_anchor: Option, #[serde(default = "default_2112")] - pub invalid_at: Option, + pub temporal_confidence: f64, #[serde(default = "default_2113")] - pub char_limit: Option, + pub invalid_at: Option, #[serde(default = "default_2114")] - pub reinforcement_count: Integer, + pub char_limit: Option, #[serde(default = "default_2115")] - pub last_reinforced_at: Option, + pub reinforcement_count: Integer, #[serde(default = "default_2116")] - pub mentioned_at: Option, + pub last_reinforced_at: Option, #[serde(default = "default_2117")] - pub sensitivity: String, + pub mentioned_at: Option, #[serde(default = "default_2118")] - pub redacted_at: Option, + pub sensitivity: String, #[serde(default = "default_2119")] - pub redaction_reason: String, + pub redacted_at: Option, #[serde(default = "default_2120")] - pub lock_mode: String, + pub redaction_reason: String, #[serde(default = "default_2121")] - pub lock_reason: String, + pub lock_mode: String, #[serde(default = "default_2122")] - pub lock_until: Option, + pub lock_reason: String, #[serde(default = "default_2123")] - pub locked_by: String, + pub lock_until: Option, #[serde(default = "default_2124")] - pub locked_at: Option, + pub locked_by: String, #[serde(default = "default_2125")] - pub on_expire: String, + pub locked_at: Option, #[serde(default = "default_2126")] - pub expire_reason: String, + pub on_expire: String, #[serde(default = "default_2127")] - pub files: Vec, + pub expire_reason: String, #[serde(default = "default_2128")] + pub files: Vec, + #[serde(default = "default_2129")] pub concepts: Vec, } @@ -48533,11 +48535,11 @@ pub struct NamespaceSnapshotOutputSnapshotMemoryRow { pub struct NamespaceSnapshotOutputSnapshotTypeRow { pub memory_type: String, pub retention_days: Integer, - #[serde(default = "default_2129")] - pub dedup_threshold: Option, #[serde(default = "default_2130")] - pub hot_quota: Integer, + pub dedup_threshold: Option, #[serde(default = "default_2131")] + pub hot_quota: Integer, + #[serde(default = "default_2132")] pub conflict_policy: String, } @@ -48752,7 +48754,7 @@ pub struct TaxonomyCommunity { pub community_id: Integer, pub label: String, pub size: Integer, - #[serde(default = "default_2132")] + #[serde(default = "default_2133")] pub top_entities: Vec, } @@ -48763,9 +48765,9 @@ pub struct NamespaceTaxonomyOutput { pub entities: Vec, pub memory_count: Integer, pub memory_types: Vec, - #[serde(default = "default_2133")] - pub communities: Vec, #[serde(default = "default_2134")] + pub communities: Vec, + #[serde(default = "default_2135")] pub communities_computed_at: String, } @@ -48865,15 +48867,15 @@ pub enum TuneProposalTarget { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TuneEvidence { - #[serde(default = "default_2136")] - pub finding_codes: Vec, #[serde(default = "default_2137")] - pub supporting_count: Integer, + pub finding_codes: Vec, #[serde(default = "default_2138")] - pub supporting: Vec, + pub supporting_count: Integer, #[serde(default = "default_2139")] - pub counter_count: Option, + pub supporting: Vec, #[serde(default = "default_2140")] + pub counter_count: Option, + #[serde(default = "default_2141")] pub documents: Vec, } @@ -48899,10 +48901,10 @@ pub enum TuneApplyVia { #[non_exhaustive] pub struct TuneApply { pub op: String, - #[serde(default = "default_2144")] + #[serde(default = "default_2145")] pub via: TuneApplyVia, pub args: std::collections::HashMap, - #[serde(default = "default_2145")] + #[serde(default = "default_2146")] pub args_complete: bool, pub required_role: String, pub guard: String, @@ -48921,7 +48923,7 @@ pub struct ChunkStats { pub sections: Integer, pub sections_cut: Integer, pub max_input_tokens: Integer, - #[serde(default = "default_2147")] + #[serde(default = "default_2148")] pub over_input_limit: Option, } @@ -48941,25 +48943,25 @@ pub struct TuneProposal { pub title: String, pub rationale: String, pub current: String, - #[serde(default = "default_2135")] + #[serde(default = "default_2136")] pub current_revision: Option, pub proposed: String, pub evidence: TuneEvidence, - #[serde(default = "default_2141")] - pub affected_agents: Vec, #[serde(default = "default_2142")] - pub affected_agents_total: Option, + pub affected_agents: Vec, #[serde(default = "default_2143")] + pub affected_agents_total: Option, + #[serde(default = "default_2144")] pub effect: TuneProposalEffect, pub historical: String, pub apply: TuneApply, - #[serde(default = "default_2146")] + #[serde(default = "default_2147")] pub apply_also: Vec, - #[serde(default = "default_2148")] - pub preview: Option, #[serde(default = "default_2149")] - pub limits: String, + pub preview: Option, #[serde(default = "default_2150")] + pub limits: String, + #[serde(default = "default_2151")] pub refs: Vec, } @@ -48967,13 +48969,13 @@ pub struct TuneProposal { #[non_exhaustive] pub struct ChunkingSample { pub cap: Integer, - #[serde(default = "default_2156")] + #[serde(default = "default_2157")] pub population: Option, pub documents: Integer, pub unread: Integer, pub load_cap: Integer, pub embedder_model: String, - #[serde(default = "default_2157")] + #[serde(default = "default_2158")] pub input_token_limit: Option, pub current: ChunkStats, } @@ -48984,21 +48986,21 @@ pub struct NamespaceTuneOutput { pub org: String, pub namespace: String, pub computed_at: String, - #[serde(default = "default_2151")] - pub proposals: Vec, #[serde(default = "default_2152")] - pub guide_revision: Option, + pub proposals: Vec, #[serde(default = "default_2153")] - pub categories_registered: Option, + pub guide_revision: Option, #[serde(default = "default_2154")] - pub extraction_policy: Option, + pub categories_registered: Option, #[serde(default = "default_2155")] + pub extraction_policy: Option, + #[serde(default = "default_2156")] pub extraction_policy_unavailable: String, - #[serde(default = "default_2158")] - pub chunking: Option, #[serde(default = "default_2159")] - pub skipped: Vec, + pub chunking: Option, #[serde(default = "default_2160")] + pub skipped: Vec, + #[serde(default = "default_2161")] pub model_used: bool, } @@ -49119,22 +49121,22 @@ pub struct NamespaceValidateFinding { pub kind: NamespaceValidateFindingKind, pub rule_version: Integer, pub source_op: String, - #[serde(default = "default_2161")] - pub window_seconds: Option, #[serde(default = "default_2162")] + pub window_seconds: Option, + #[serde(default = "default_2163")] pub population: Option, pub sample_limit: Integer, pub samples_complete: bool, - #[serde(default = "default_2163")] - pub evidence: Vec, #[serde(default = "default_2164")] - pub exceptions: String, + pub evidence: Vec, #[serde(default = "default_2165")] + pub exceptions: String, + #[serde(default = "default_2166")] pub uncertainty: String, pub check: String, pub severity: NamespaceValidateFindingSeverity, pub count: Integer, - #[serde(default = "default_2166")] + #[serde(default = "default_2167")] pub samples: Vec>, pub detail: String, } @@ -49149,9 +49151,9 @@ pub struct NamespaceValidateOutput { pub warnings: Integer, pub infos: Integer, pub findings: Vec, - #[serde(default = "default_2167")] - pub skipped: Vec, #[serde(default = "default_2168")] + pub skipped: Vec, + #[serde(default = "default_2169")] pub keys_scoped: Integer, pub coverage: ReportCoverage, pub checked_at: String, @@ -49271,9 +49273,9 @@ impl NamespaceValidateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ObserveCrystallizeOutput { - #[serde(default = "default_2169")] - pub enqueued: Integer, #[serde(default = "default_2170")] + pub enqueued: Integer, + #[serde(default = "default_2171")] pub session_id: String, } @@ -49370,23 +49372,23 @@ impl ObserveCrystallizeInput { #[non_exhaustive] pub struct ObserveRecordOutput { pub memory_key: String, - #[serde(default = "default_2171")] - pub memory_id: String, #[serde(default = "default_2172")] - pub kind: String, + pub memory_id: String, #[serde(default = "default_2173")] - pub tags: Vec, + pub kind: String, #[serde(default = "default_2174")] - pub file_paths: Vec, + pub tags: Vec, #[serde(default = "default_2175")] - pub content_sha256: String, + pub file_paths: Vec, #[serde(default = "default_2176")] - pub tool_name: String, + pub content_sha256: String, #[serde(default = "default_2177")] - pub has_error: bool, + pub tool_name: String, #[serde(default = "default_2178")] - pub narrative_chars: Integer, + pub has_error: bool, #[serde(default = "default_2179")] + pub narrative_chars: Integer, + #[serde(default = "default_2180")] pub skipped_reason: String, } @@ -49585,26 +49587,26 @@ pub struct ProjectionFailureRow { pub failure_id: String, pub org: String, pub namespace: String, - #[serde(default = "default_2180")] + #[serde(default = "default_2181")] pub agent: String, pub projection: String, - #[serde(default = "default_2181")] - pub source_operation: String, #[serde(default = "default_2182")] - pub source_resource_id: String, + pub source_operation: String, #[serde(default = "default_2183")] - pub memory_keys: Vec, + pub source_resource_id: String, #[serde(default = "default_2184")] - pub error_type: String, + pub memory_keys: Vec, #[serde(default = "default_2185")] - pub error_message: String, + pub error_type: String, #[serde(default = "default_2186")] - pub payload: std::collections::HashMap, + pub error_message: String, #[serde(default = "default_2187")] - pub status: String, + pub payload: std::collections::HashMap, #[serde(default = "default_2188")] - pub created_at: Option, + pub status: String, #[serde(default = "default_2189")] + pub created_at: Option, + #[serde(default = "default_2190")] pub resolved_at: Option, } @@ -49758,22 +49760,22 @@ pub struct ProjectionFailureRetryRow { pub projection: String, pub retried: bool, pub resolved: bool, - #[serde(default = "default_2190")] - pub abandoned: bool, #[serde(default = "default_2191")] - pub reason: String, + pub abandoned: bool, #[serde(default = "default_2192")] + pub reason: String, + #[serde(default = "default_2193")] pub error: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProjectionFailureRetryOutput { - #[serde(default = "default_2193")] + #[serde(default = "default_2194")] pub results: Vec, pub retried: Integer, pub resolved: Integer, - #[serde(default = "default_2194")] + #[serde(default = "default_2195")] pub abandoned: Integer, } @@ -49855,15 +49857,15 @@ impl ProjectionFailureRetryInput { pub struct OrgModelCallsOutput { pub org: String, pub enabled: bool, - #[serde(default = "default_2195")] - pub reason: String, #[serde(default = "default_2196")] - pub updated_by: String, + pub reason: String, #[serde(default = "default_2197")] - pub updated_at: Option, + pub updated_by: String, #[serde(default = "default_2198")] - pub locked: bool, + pub updated_at: Option, #[serde(default = "default_2199")] + pub locked: bool, + #[serde(default = "default_2200")] pub locked_by: String, } @@ -50202,7 +50204,7 @@ impl PolicyDecisionsInput { #[non_exhaustive] pub struct PolicyDeleteOutput { pub removed: bool, - #[serde(default = "default_2200")] + #[serde(default = "default_2201")] pub widening: bool, } @@ -50268,12 +50270,12 @@ pub struct PolicyRuleOut { pub condition: std::collections::HashMap, pub description: String, pub enabled: bool, - #[serde(default = "default_2201")] + #[serde(default = "default_2202")] pub mode: String, pub created_by: String, - #[serde(default = "default_2202")] - pub created_at: Option, #[serde(default = "default_2203")] + pub created_at: Option, + #[serde(default = "default_2204")] pub updated_at: Option, } @@ -50345,9 +50347,9 @@ impl PolicyListInput { pub struct PolicySetOutput { pub rule: PolicyRuleOut, pub leaf_count: Integer, - #[serde(default = "default_2204")] - pub widening: bool, #[serde(default = "default_2205")] + pub widening: bool, + #[serde(default = "default_2206")] pub change: Vec, } @@ -50617,37 +50619,37 @@ pub struct ProcedureEvolveOutput { pub revision: Integer, pub changed: bool, pub template: bool, - #[serde(default = "default_2206")] - pub folded_runs: Integer, #[serde(default = "default_2207")] - pub gate: ProcedureEvolveOutputGate, + pub folded_runs: Integer, #[serde(default = "default_2208")] - pub gate_mode: String, + pub gate: ProcedureEvolveOutputGate, #[serde(default = "default_2209")] - pub gate_llr: f64, + pub gate_mode: String, #[serde(default = "default_2210")] - pub gate_before: std::collections::HashMap, + pub gate_llr: f64, #[serde(default = "default_2211")] - pub gate_after: std::collections::HashMap, + pub gate_before: std::collections::HashMap, #[serde(default = "default_2212")] - pub gate_cost_before: std::collections::HashMap, + pub gate_after: std::collections::HashMap, #[serde(default = "default_2213")] - pub gate_cost_after: std::collections::HashMap, + pub gate_cost_before: std::collections::HashMap, #[serde(default = "default_2214")] - pub gate_reason: String, + pub gate_cost_after: std::collections::HashMap, #[serde(default = "default_2215")] - pub dead_end_steps: Vec, + pub gate_reason: String, #[serde(default = "default_2216")] - pub fail_prone_steps: Vec, + pub dead_end_steps: Vec, #[serde(default = "default_2217")] - pub fail_prone_transitions: Vec, + pub fail_prone_steps: Vec, #[serde(default = "default_2218")] - pub run_stats: std::collections::HashMap, + pub fail_prone_transitions: Vec, #[serde(default = "default_2219")] - pub strikes: Integer, + pub run_stats: std::collections::HashMap, #[serde(default = "default_2220")] - pub quarantined: bool, + pub strikes: Integer, #[serde(default = "default_2221")] + pub quarantined: bool, + #[serde(default = "default_2222")] pub retention: std::collections::HashMap, } @@ -50870,9 +50872,9 @@ pub struct ProcedureForkOutput { pub memory_key: String, pub version: Integer, pub name: String, - #[serde(default = "default_2222")] - pub steps: Vec, #[serde(default = "default_2223")] + pub steps: Vec, + #[serde(default = "default_2224")] pub forked_from: std::collections::HashMap, } @@ -51132,32 +51134,32 @@ pub enum ProcedureLocateOutputStatus { #[non_exhaustive] pub struct ProcedureLocateOutput { pub memory_key: String, - #[serde(default = "default_2224")] - pub name: String, #[serde(default = "default_2225")] + pub name: String, + #[serde(default = "default_2226")] pub status: ProcedureLocateOutputStatus, pub matched: bool, - #[serde(default = "default_2226")] - pub active: Option>, #[serde(default = "default_2227")] - pub hops: Vec>>, + pub active: Option>, #[serde(default = "default_2228")] - pub entry_nodes: Vec, + pub hops: Vec>>, #[serde(default = "default_2229")] - pub dominant_next: Vec, + pub entry_nodes: Vec, #[serde(default = "default_2230")] - pub revisits: std::collections::HashMap, + pub dominant_next: Vec, #[serde(default = "default_2231")] - pub looping: bool, + pub revisits: std::collections::HashMap, #[serde(default = "default_2232")] - pub exits: Vec, + pub looping: bool, #[serde(default = "default_2233")] - pub failure_notes: Vec>, + pub exits: Vec, #[serde(default = "default_2234")] - pub rendered: String, + pub failure_notes: Vec>, #[serde(default = "default_2235")] - pub run_stats: std::collections::HashMap, + pub rendered: String, #[serde(default = "default_2236")] + pub run_stats: std::collections::HashMap, + #[serde(default = "default_2237")] pub for_agent: std::collections::HashMap, } @@ -51309,48 +51311,48 @@ pub enum ProcedureMatchStatus { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProcedureMatch { - #[serde(default = "default_2237")] + #[serde(default = "default_2238")] pub use_guidance: Option, pub name: String, pub situation: String, pub steps: Vec, - #[serde(default = "default_2238")] - pub tags: Vec, #[serde(default = "default_2239")] + pub tags: Vec, + #[serde(default = "default_2240")] pub metadata: std::collections::HashMap, pub similarity: f64, pub memory_key: String, pub namespace: String, - #[serde(default = "default_2240")] - pub graph: Option>, #[serde(default = "default_2241")] - pub template: bool, + pub graph: Option>, #[serde(default = "default_2242")] - pub run_stats: std::collections::HashMap, + pub template: bool, #[serde(default = "default_2243")] - pub status: ProcedureMatchStatus, + pub run_stats: std::collections::HashMap, #[serde(default = "default_2244")] - pub quarantined: Option>, + pub status: ProcedureMatchStatus, #[serde(default = "default_2245")] - pub fail_prone_steps: Vec, + pub quarantined: Option>, #[serde(default = "default_2246")] - pub revision: Integer, + pub fail_prone_steps: Vec, #[serde(default = "default_2247")] - pub rejected_revisions: Vec>, + pub revision: Integer, #[serde(default = "default_2248")] - pub tool_overlap: f64, + pub rejected_revisions: Vec>, #[serde(default = "default_2249")] - pub score: f64, + pub tool_overlap: f64, #[serde(default = "default_2250")] - pub utility: f64, + pub score: f64, #[serde(default = "default_2251")] - pub goal_similarity: Option, + pub utility: f64, #[serde(default = "default_2252")] - pub for_agent: std::collections::HashMap, + pub goal_similarity: Option, #[serde(default = "default_2253")] + pub for_agent: std::collections::HashMap, + #[serde(default = "default_2254")] pub run_stats_by_agent: std::collections::HashMap>, - #[serde(default = "default_2254")] + #[serde(default = "default_2255")] pub actor: String, } @@ -51358,11 +51360,11 @@ pub struct ProcedureMatch { #[non_exhaustive] pub struct ProcedureMatchOutput { pub matches: Vec, - #[serde(default = "default_2255")] - pub matched: Integer, #[serde(default = "default_2256")] - pub procedure_key: String, + pub matched: Integer, #[serde(default = "default_2257")] + pub procedure_key: String, + #[serde(default = "default_2258")] pub score: f64, } @@ -51743,7 +51745,7 @@ pub struct ProcedureReviseOutput { pub revision: Integer, pub prior_revision: Integer, pub digest: String, - #[serde(default = "default_2258")] + #[serde(default = "default_2259")] pub steps: Vec, } @@ -51855,14 +51857,14 @@ pub struct ProfileActivityEntry { pub agent: String, pub last_activated_at: String, pub event_count: Integer, - #[serde(default = "default_2259")] + #[serde(default = "default_2260")] pub operations: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProfileActivityOutput { - #[serde(default = "default_2260")] + #[serde(default = "default_2261")] pub entries: Vec, } @@ -51970,17 +51972,17 @@ impl ProfileActivityInput { #[non_exhaustive] pub struct ProfileMutationOutput { pub version: Integer, - #[serde(default = "default_2261")] - pub memory_id: String, #[serde(default = "default_2262")] - pub content_sha256: String, + pub memory_id: String, #[serde(default = "default_2263")] - pub namespace: String, + pub content_sha256: String, #[serde(default = "default_2264")] - pub label: String, + pub namespace: String, #[serde(default = "default_2265")] - pub char_limit: Option, + pub label: String, #[serde(default = "default_2266")] + pub char_limit: Option, + #[serde(default = "default_2267")] pub value_length: Integer, } @@ -52089,7 +52091,7 @@ pub struct ProfileRenderOutput { pub rendered: String, pub section_count: Integer, pub total_chars: Integer, - #[serde(default = "default_2267")] + #[serde(default = "default_2268")] pub labels: Vec, } @@ -52474,17 +52476,17 @@ pub enum ProfileStructuredOutputStatus { #[non_exhaustive] pub struct ProfileStructuredOutput { pub status: ProfileStructuredOutputStatus, - #[serde(default = "default_2268")] - pub profile: std::collections::HashMap, #[serde(default = "default_2269")] - pub built_at: Option, + pub profile: std::collections::HashMap, #[serde(default = "default_2270")] - pub memory_id: String, + pub built_at: Option, #[serde(default = "default_2271")] - pub version: Integer, + pub memory_id: String, #[serde(default = "default_2272")] - pub version_text: String, + pub version: Integer, #[serde(default = "default_2273")] + pub version_text: String, + #[serde(default = "default_2274")] pub schema_sha256: String, } @@ -52601,13 +52603,13 @@ impl ProfileStructuredInput { #[non_exhaustive] pub struct ProfileSchemaOutput { pub found: bool, - #[serde(default = "default_2274")] - pub json_schema: std::collections::HashMap, #[serde(default = "default_2275")] - pub schema_sha256: String, + pub json_schema: std::collections::HashMap, #[serde(default = "default_2276")] - pub updated_by: String, + pub schema_sha256: String, #[serde(default = "default_2277")] + pub updated_by: String, + #[serde(default = "default_2278")] pub updated_at: Option, } @@ -52760,10 +52762,10 @@ pub enum RunBeginOutputStatus { #[non_exhaustive] pub struct RunBeginOutput { pub run_id: String, - #[serde(default = "default_2278")] + #[serde(default = "default_2279")] pub status: RunBeginOutputStatus, pub started_at: String, - #[serde(default = "default_2279")] + #[serde(default = "default_2280")] pub next: String, } @@ -52971,29 +52973,29 @@ pub struct RunCompleteOutput { pub run_id: String, pub status: RunCompleteOutputStatus, pub duration_ms: Integer, - #[serde(default = "default_2280")] - pub used_applied: Integer, #[serde(default = "default_2281")] - pub evidence_applied: Integer, + pub used_applied: Integer, #[serde(default = "default_2282")] - pub harm_applied: Integer, + pub evidence_applied: Integer, #[serde(default = "default_2283")] - pub memories_written: Vec, + pub harm_applied: Integer, #[serde(default = "default_2284")] - pub recalled: Integer, + pub memories_written: Vec, #[serde(default = "default_2285")] - pub observations: Integer, + pub recalled: Integer, #[serde(default = "default_2286")] - pub procedure_runs_recorded: Integer, + pub observations: Integer, #[serde(default = "default_2287")] - pub reflection_key: String, + pub procedure_runs_recorded: Integer, #[serde(default = "default_2288")] - pub retain: String, + pub reflection_key: String, #[serde(default = "default_2289")] - pub retained: Integer, + pub retain: String, #[serde(default = "default_2290")] - pub demoted: Integer, + pub retained: Integer, #[serde(default = "default_2291")] + pub demoted: Integer, + #[serde(default = "default_2292")] pub expiring: Integer, } @@ -53514,25 +53516,25 @@ pub enum RunGetOutputOverBudgetItem { #[non_exhaustive] pub struct RunGetOutput { pub found: bool, - #[serde(default = "default_2292")] - pub run: Option, #[serde(default = "default_2293")] - pub recalled: Integer, + pub run: Option, #[serde(default = "default_2294")] - pub recalled_keys: Vec, + pub recalled: Integer, #[serde(default = "default_2295")] - pub memories_written: Vec, + pub recalled_keys: Vec, #[serde(default = "default_2296")] - pub observations: Integer, + pub memories_written: Vec, #[serde(default = "default_2297")] - pub turns: Integer, + pub observations: Integer, #[serde(default = "default_2298")] - pub unpriced_turns: Integer, + pub turns: Integer, #[serde(default = "default_2299")] - pub cost_usd: f64, + pub unpriced_turns: Integer, #[serde(default = "default_2300")] - pub elapsed_seconds: Integer, + pub cost_usd: f64, #[serde(default = "default_2301")] + pub elapsed_seconds: Integer, + #[serde(default = "default_2302")] pub over_budget: Vec, } @@ -53599,17 +53601,17 @@ pub struct RunGradeProposal { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct RunGradeOutput { - #[serde(default = "default_2302")] - pub graded: Integer, #[serde(default = "default_2303")] - pub run_ids: Vec, + pub graded: Integer, #[serde(default = "default_2304")] - pub skipped_active: Integer, + pub run_ids: Vec, #[serde(default = "default_2305")] - pub unchanged: Integer, + pub skipped_active: Integer, #[serde(default = "default_2306")] - pub memories_counted: Integer, + pub unchanged: Integer, #[serde(default = "default_2307")] + pub memories_counted: Integer, + #[serde(default = "default_2308")] pub proposals_decided: Vec, } @@ -53724,7 +53726,7 @@ impl RunGradeInput { #[non_exhaustive] pub struct RunListOutput { pub runs: Vec, - #[serde(default = "default_2308")] + #[serde(default = "default_2309")] pub total: Option, } @@ -54001,39 +54003,39 @@ pub struct LiveSearchHit { pub title: String, pub url: String, pub provider: LiveSearchHitProvider, - #[serde(default = "default_2311")] - pub content: String, #[serde(default = "default_2312")] + pub content: String, + #[serde(default = "default_2313")] pub live: LiveSearchHitLive, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct LiveSearchResults { - #[serde(default = "default_2310")] + #[serde(default = "default_2311")] pub live: LiveSearchResultsLive, - #[serde(default = "default_2313")] + #[serde(default = "default_2314")] pub results: Vec, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SearchOutput { - #[serde(default = "default_2309")] + #[serde(default = "default_2310")] pub tracker: Option>, - #[serde(default = "default_2314")] - pub live: Option, #[serde(default = "default_2315")] - pub memory: std::collections::HashMap, + pub live: Option, #[serde(default = "default_2316")] - pub knowledge: std::collections::HashMap, + pub memory: std::collections::HashMap, #[serde(default = "default_2317")] - pub profile: std::collections::HashMap, + pub knowledge: std::collections::HashMap, #[serde(default = "default_2318")] - pub conversations: std::collections::HashMap, + pub profile: std::collections::HashMap, #[serde(default = "default_2319")] - pub withheld: Option>, + pub conversations: std::collections::HashMap, #[serde(default = "default_2320")] + pub withheld: Option>, + #[serde(default = "default_2321")] pub namespaces_skipped: Vec, } @@ -54226,7 +54228,7 @@ impl SearchInput { pub struct SessionBriefDeleteOutput { pub deleted: bool, pub brief_key: String, - #[serde(default = "default_2321")] + #[serde(default = "default_2322")] pub revision: Integer, } @@ -54319,113 +54321,113 @@ impl SessionBriefDeleteInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDecision { - #[serde(default = "default_2330")] - pub what: String, #[serde(default = "default_2331")] + pub what: String, + #[serde(default = "default_2332")] pub why: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDeadEnd { - #[serde(default = "default_2333")] - pub tried: String, #[serde(default = "default_2334")] + pub tried: String, + #[serde(default = "default_2335")] pub why_not: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefDone { - #[serde(default = "default_2336")] + #[serde(default = "default_2337")] pub what: String, - #[serde(rename = "ref", default = "default_2337")] + #[serde(rename = "ref", default = "default_2338")] pub r#ref: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefFile { - #[serde(default = "default_2341")] - pub path: String, #[serde(default = "default_2342")] + pub path: String, + #[serde(default = "default_2343")] pub role: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct BriefSections { - #[serde(default = "default_2327")] - pub goal: String, #[serde(default = "default_2328")] - pub status: String, + pub goal: String, #[serde(default = "default_2329")] + pub status: String, + #[serde(default = "default_2330")] pub verification: String, - #[serde(default = "default_2332")] + #[serde(default = "default_2333")] pub decisions: Vec, - #[serde(default = "default_2335")] + #[serde(default = "default_2336")] pub dead_ends: Vec, - #[serde(default = "default_2338")] - pub done: Vec, #[serde(default = "default_2339")] - pub open_questions: Vec, + pub done: Vec, #[serde(default = "default_2340")] + pub open_questions: Vec, + #[serde(default = "default_2341")] pub next_steps: Vec, - #[serde(default = "default_2343")] - pub files: Vec, #[serde(default = "default_2344")] - pub constraints: Vec, + pub files: Vec, #[serde(default = "default_2345")] - pub pointers: Vec, + pub constraints: Vec, #[serde(default = "default_2346")] - pub client_summary: String, + pub pointers: Vec, #[serde(default = "default_2347")] - pub client_summary_at: String, + pub client_summary: String, + #[serde(default = "default_2348")] + pub client_summary_at: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefGetOutput { pub found: bool, - #[serde(default = "default_2322")] - pub brief_key: String, #[serde(default = "default_2323")] - pub revision: Integer, + pub brief_key: String, #[serde(default = "default_2324")] - pub snapshot_id: String, + pub revision: Integer, #[serde(default = "default_2325")] - pub snapshot_key: String, + pub snapshot_id: String, #[serde(default = "default_2326")] + pub snapshot_key: String, + #[serde(default = "default_2327")] pub rendered: String, - #[serde(default = "default_2348")] - pub sections: Option, #[serde(default = "default_2349")] - pub project: String, + pub sections: Option, #[serde(default = "default_2350")] - pub branch: String, + pub project: String, #[serde(default = "default_2351")] - pub head_sha: String, + pub branch: String, #[serde(default = "default_2352")] - pub author: String, + pub head_sha: String, #[serde(default = "default_2353")] - pub trigger: String, + pub author: String, #[serde(default = "default_2354")] - pub actor: String, + pub trigger: String, #[serde(default = "default_2355")] - pub source_sessions: Vec, + pub actor: String, #[serde(default = "default_2356")] - pub updated_at: Option, + pub source_sessions: Vec, #[serde(default = "default_2357")] - pub age_seconds: Integer, + pub updated_at: Option, #[serde(default = "default_2358")] - pub revisions: Integer, + pub age_seconds: Integer, #[serde(default = "default_2359")] - pub events_total: Integer, + pub revisions: Integer, #[serde(default = "default_2360")] - pub source_chars: Integer, + pub events_total: Integer, #[serde(default = "default_2361")] - pub brief_chars: Integer, + pub source_chars: Integer, #[serde(default = "default_2362")] + pub brief_chars: Integer, + #[serde(default = "default_2363")] pub deleted: bool, } @@ -54600,34 +54602,34 @@ impl SessionBriefGetInput { pub struct SessionBriefSummary { pub brief_key: String, pub revision: Integer, - #[serde(default = "default_2363")] - pub project: String, #[serde(default = "default_2364")] - pub branch: String, + pub project: String, #[serde(default = "default_2365")] - pub agent: String, + pub branch: String, #[serde(default = "default_2366")] - pub goal: String, + pub agent: String, #[serde(default = "default_2367")] - pub status: String, + pub goal: String, #[serde(default = "default_2368")] - pub author: String, + pub status: String, #[serde(default = "default_2369")] - pub actor: String, + pub author: String, #[serde(default = "default_2370")] - pub updated_at: Option, + pub actor: String, #[serde(default = "default_2371")] - pub age_seconds: Integer, + pub updated_at: Option, #[serde(default = "default_2372")] + pub age_seconds: Integer, + #[serde(default = "default_2373")] pub brief_chars: Integer, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefListOutput { - #[serde(default = "default_2373")] - pub briefs: Vec, #[serde(default = "default_2374")] + pub briefs: Vec, + #[serde(default = "default_2375")] pub rendered: String, } @@ -54767,25 +54769,25 @@ impl SessionBriefListInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct SessionBriefStats { - #[serde(default = "default_2378")] - pub events_in: Integer, #[serde(default = "default_2379")] - pub windows: Integer, + pub events_in: Integer, #[serde(default = "default_2380")] - pub events_total: Integer, + pub windows: Integer, #[serde(default = "default_2381")] - pub source_chars: Integer, + pub events_total: Integer, #[serde(default = "default_2382")] - pub brief_chars: Integer, + pub source_chars: Integer, #[serde(default = "default_2383")] - pub compression_ratio: f64, + pub brief_chars: Integer, #[serde(default = "default_2384")] - pub dropped_ungrounded: Integer, + pub compression_ratio: f64, #[serde(default = "default_2385")] - pub tokens_in: Integer, + pub dropped_ungrounded: Integer, #[serde(default = "default_2386")] - pub tokens_out: Integer, + pub tokens_in: Integer, #[serde(default = "default_2387")] + pub tokens_out: Integer, + #[serde(default = "default_2388")] pub llm_model: String, } @@ -54795,13 +54797,13 @@ pub struct SessionBriefSaveOutput { pub brief_key: String, pub revision: Integer, pub changed: bool, - #[serde(default = "default_2375")] - pub author: String, #[serde(default = "default_2376")] - pub reason: String, + pub author: String, #[serde(default = "default_2377")] + pub reason: String, + #[serde(default = "default_2378")] pub rendered: String, - #[serde(default = "default_2388")] + #[serde(default = "default_2389")] pub stats: SessionBriefStats, } @@ -55546,39 +55548,39 @@ pub struct TaskPayload { pub priority: Integer, pub disclosure: TaskPayloadDisclosure, pub status: TaskPayloadStatus, - #[serde(default = "default_2389")] - pub reason: String, #[serde(default = "default_2390")] - pub blocked_on: String, + pub reason: String, #[serde(default = "default_2391")] - pub not_before: Option, + pub blocked_on: String, #[serde(default = "default_2392")] - pub resume_at: Option, + pub not_before: Option, #[serde(default = "default_2393")] - pub deadline: Option, + pub resume_at: Option, #[serde(default = "default_2394")] + pub deadline: Option, + #[serde(default = "default_2395")] pub defer_count: Integer, pub title: String, - #[serde(default = "default_2395")] + #[serde(default = "default_2396")] pub brief: std::collections::HashMap, pub from_agent: String, - #[serde(default = "default_2396")] - pub from_subject: String, #[serde(default = "default_2397")] - pub origin: String, + pub from_subject: String, #[serde(default = "default_2398")] - pub parent_task_id: Option, + pub origin: String, #[serde(default = "default_2399")] - pub owner: String, + pub parent_task_id: Option, #[serde(default = "default_2400")] - pub attempt: Integer, + pub owner: String, #[serde(default = "default_2401")] - pub fence: Integer, + pub attempt: Integer, #[serde(default = "default_2402")] - pub lease_until: Option, + pub fence: Integer, #[serde(default = "default_2403")] - pub outcome: std::collections::HashMap, + pub lease_until: Option, #[serde(default = "default_2404")] + pub outcome: std::collections::HashMap, + #[serde(default = "default_2405")] pub last_actor: String, pub created_at: String, pub updated_at: String, @@ -55589,7 +55591,7 @@ pub struct TaskPayload { #[non_exhaustive] pub struct TaskOutput { pub task: TaskPayload, - #[serde(default = "default_2405")] + #[serde(default = "default_2406")] pub seq: Integer, } @@ -55990,10 +55992,10 @@ impl TaskCompleteInput { pub struct InboxCount { pub inbox: String, pub status: String, - #[serde(default = "default_2406")] + #[serde(default = "default_2407")] pub blocked_on: String, pub n: Integer, - #[serde(default = "default_2407")] + #[serde(default = "default_2408")] pub oldest: Option, } @@ -56080,7 +56082,7 @@ pub struct TaskCreateOutput { pub task: TaskPayload, pub created: bool, pub seq: Integer, - #[serde(default = "default_2408")] + #[serde(default = "default_2409")] pub next: String, } @@ -56419,7 +56421,7 @@ impl TaskFailInput { #[non_exhaustive] pub struct TaskGetOutput { pub found: bool, - #[serde(default = "default_2409")] + #[serde(default = "default_2410")] pub task: Option, } @@ -56553,23 +56555,23 @@ pub struct TaskEventPayload { pub task_id: String, pub inbox: String, pub event: String, - #[serde(default = "default_2410")] - pub from_status: String, #[serde(default = "default_2411")] - pub to_status: String, + pub from_status: String, #[serde(default = "default_2412")] - pub actor: String, + pub to_status: String, #[serde(default = "default_2413")] - pub agent: String, + pub actor: String, #[serde(default = "default_2414")] - pub fence: Integer, + pub agent: String, #[serde(default = "default_2415")] - pub version: Integer, + pub fence: Integer, #[serde(default = "default_2416")] - pub reason: String, + pub version: Integer, #[serde(default = "default_2417")] - pub patch: std::collections::HashMap, + pub reason: String, #[serde(default = "default_2418")] + pub patch: std::collections::HashMap, + #[serde(default = "default_2419")] pub note: String, pub ts: String, } @@ -56909,7 +56911,7 @@ pub struct TaskPullOutput { pub tasks: Vec, pub waited_ms: Integer, pub backend: String, - #[serde(default = "default_2419")] + #[serde(default = "default_2420")] pub note: String, } @@ -57305,7 +57307,7 @@ impl TaskUnblockInput { pub struct TaskUpdateOutput { pub task: TaskPayload, pub seq: Integer, - #[serde(default = "default_2420")] + #[serde(default = "default_2421")] pub conflict: bool, } @@ -57668,19 +57670,19 @@ impl TaskReasonInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerAnswerOutput { - #[serde(default = "default_2421")] - pub intent: String, #[serde(default = "default_2422")] - pub anchors: std::collections::HashMap, + pub intent: String, #[serde(default = "default_2423")] - pub sections: Vec>, + pub anchors: std::collections::HashMap, #[serde(default = "default_2424")] - pub searched: Vec, + pub sections: Vec>, #[serde(default = "default_2425")] - pub lines: Vec, + pub searched: Vec, #[serde(default = "default_2426")] - pub restricted: bool, + pub lines: Vec, #[serde(default = "default_2427")] + pub restricted: bool, + #[serde(default = "default_2428")] pub verdict: String, } @@ -57776,17 +57778,17 @@ impl TrackerAnswerInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerBindingOutput { - #[serde(default = "default_2428")] - pub tracker_namespace: String, #[serde(default = "default_2429")] - pub tracker_namespaces: Vec, + pub tracker_namespace: String, #[serde(default = "default_2430")] - pub restricted: bool, + pub tracker_namespaces: Vec, #[serde(default = "default_2431")] - pub kind: String, + pub restricted: bool, #[serde(default = "default_2432")] - pub authorized: bool, + pub kind: String, #[serde(default = "default_2433")] + pub authorized: bool, + #[serde(default = "default_2434")] pub templates: Vec, } @@ -57839,13 +57841,13 @@ impl TrackerBindingInput { #[non_exhaustive] pub struct TrackerComponentOutput { pub component: String, - #[serde(default = "default_2434")] - pub risk: std::collections::HashMap, #[serde(default = "default_2435")] - pub open_issues: Vec>, + pub risk: std::collections::HashMap, #[serde(default = "default_2436")] - pub known: bool, + pub open_issues: Vec>, #[serde(default = "default_2437")] + pub known: bool, + #[serde(default = "default_2438")] pub tracker_unavailable: bool, } @@ -57906,9 +57908,9 @@ impl TrackerComponentInput { #[non_exhaustive] pub struct TrackerContractOutput { pub database: String, - #[serde(default = "default_2438")] - pub tables: Vec>, #[serde(default = "default_2439")] + pub tables: Vec>, + #[serde(default = "default_2440")] pub templates: std::collections::HashMap, } @@ -57961,66 +57963,66 @@ impl TrackerContractInput { #[non_exhaustive] pub struct TrackerLegStatus { pub name: String, - #[serde(default = "default_2450")] - pub status: String, #[serde(default = "default_2451")] - pub reason: String, + pub status: String, #[serde(default = "default_2452")] - pub message: String, + pub reason: String, #[serde(default = "default_2453")] - pub retried: bool, + pub message: String, #[serde(default = "default_2454")] - pub ms: Integer, + pub retried: bool, #[serde(default = "default_2455")] - pub cause: String, + pub ms: Integer, #[serde(default = "default_2456")] + pub cause: String, + #[serde(default = "default_2457")] pub namespace: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerDuplicateCheckOutput { - #[serde(default = "default_2440")] - pub verdict: String, #[serde(default = "default_2441")] - pub items: Vec>, + pub verdict: String, #[serde(default = "default_2442")] - pub undecided: bool, + pub items: Vec>, #[serde(default = "default_2443")] - pub epistemic: String, + pub undecided: bool, #[serde(default = "default_2444")] - pub thresholds: std::collections::HashMap, + pub epistemic: String, #[serde(default = "default_2445")] - pub judge: std::collections::HashMap, + pub thresholds: std::collections::HashMap, #[serde(default = "default_2446")] - pub fit_at: String, + pub judge: std::collections::HashMap, #[serde(default = "default_2447")] - pub fit: std::collections::HashMap, + pub fit_at: String, #[serde(default = "default_2448")] - pub query: std::collections::HashMap, + pub fit: std::collections::HashMap, #[serde(default = "default_2449")] + pub query: std::collections::HashMap, + #[serde(default = "default_2450")] pub legs: std::collections::HashMap, - #[serde(default = "default_2457")] - pub leg_status: Vec, #[serde(default = "default_2458")] - pub tracker_unavailable: bool, + pub leg_status: Vec, #[serde(default = "default_2459")] - pub namespaces: Vec, + pub tracker_unavailable: bool, #[serde(default = "default_2460")] - pub by_namespace: std::collections::HashMap>, + pub namespaces: Vec, #[serde(default = "default_2461")] - pub closest: Vec>, + pub by_namespace: std::collections::HashMap>, #[serde(default = "default_2462")] - pub needs: Vec>, + pub closest: Vec>, #[serde(default = "default_2463")] - pub closest_note: String, + pub needs: Vec>, #[serde(default = "default_2464")] - pub nearest: Vec>, + pub closest_note: String, #[serde(default = "default_2465")] - pub rerank: std::collections::HashMap, + pub nearest: Vec>, #[serde(default = "default_2466")] - pub answer: String, + pub rerank: std::collections::HashMap, #[serde(default = "default_2467")] + pub answer: String, + #[serde(default = "default_2468")] pub related_prs: Vec>, } @@ -58227,17 +58229,17 @@ impl TrackerDuplicateCheckInput { #[non_exhaustive] pub struct TrackerFlakyOutput { pub test_name: String, - #[serde(default = "default_2468")] - pub known_flaky: bool, #[serde(default = "default_2469")] - pub open_issues: Integer, + pub known_flaky: bool, #[serde(default = "default_2470")] - pub issues: Vec>, + pub open_issues: Integer, #[serde(default = "default_2471")] - pub verdict: String, + pub issues: Vec>, #[serde(default = "default_2472")] - pub tracker_unavailable: bool, + pub verdict: String, #[serde(default = "default_2473")] + pub tracker_unavailable: bool, + #[serde(default = "default_2474")] pub signal: Option>, } @@ -58320,9 +58322,9 @@ impl TrackerFlakyInput { #[non_exhaustive] pub struct TrackerItemOutput { pub items: Vec>, - #[serde(default = "default_2474")] - pub unknown: Vec, #[serde(default = "default_2475")] + pub unknown: Vec, + #[serde(default = "default_2476")] pub tracker_unavailable: bool, } @@ -58371,19 +58373,19 @@ impl TrackerItemInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerLinksOutput { - #[serde(default = "default_2476")] - pub subject: std::collections::HashMap, #[serde(default = "default_2477")] - pub verdict: String, + pub subject: std::collections::HashMap, #[serde(default = "default_2478")] - pub items: Vec>, + pub verdict: String, #[serde(default = "default_2479")] - pub epistemic: String, + pub items: Vec>, #[serde(default = "default_2480")] - pub record: std::collections::HashMap, + pub epistemic: String, #[serde(default = "default_2481")] - pub computed_at: String, + pub record: std::collections::HashMap, #[serde(default = "default_2482")] + pub computed_at: String, + #[serde(default = "default_2483")] pub tracker_unavailable: bool, } @@ -58481,11 +58483,11 @@ impl TrackerLinksInput { pub struct TrackerReleaseOutput { pub version: String, pub blockers: Vec>, - #[serde(default = "default_2483")] - pub active_blockers: Integer, #[serde(default = "default_2484")] - pub health: std::collections::HashMap, + pub active_blockers: Integer, #[serde(default = "default_2485")] + pub health: std::collections::HashMap, + #[serde(default = "default_2486")] pub tracker_unavailable: bool, } @@ -58534,17 +58536,17 @@ impl TrackerReleaseInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSimilarOutput { - #[serde(default = "default_2486")] - pub items: Vec>, #[serde(default = "default_2487")] - pub query: std::collections::HashMap, + pub items: Vec>, #[serde(default = "default_2488")] - pub legs: std::collections::HashMap, + pub query: std::collections::HashMap, #[serde(default = "default_2489")] - pub epistemic: String, + pub legs: std::collections::HashMap, #[serde(default = "default_2490")] - pub tracker_unavailable: bool, + pub epistemic: String, #[serde(default = "default_2491")] + pub tracker_unavailable: bool, + #[serde(default = "default_2492")] pub namespaces: Vec, } @@ -58665,19 +58667,19 @@ pub struct TrackerSourceAddOutput { pub name: String, pub host: String, pub database: String, - #[serde(default = "default_2492")] - pub namespaces: Vec>, #[serde(default = "default_2493")] - pub contract: std::collections::HashMap, + pub namespaces: Vec>, #[serde(default = "default_2494")] - pub roles: Vec, + pub contract: std::collections::HashMap, #[serde(default = "default_2495")] - pub my_role: String, + pub roles: Vec, #[serde(default = "default_2496")] - pub dry_run: bool, + pub my_role: String, #[serde(default = "default_2497")] - pub written: bool, + pub dry_run: bool, #[serde(default = "default_2498")] + pub written: bool, + #[serde(default = "default_2499")] pub view_templates: std::collections::HashMap, } @@ -58840,13 +58842,13 @@ impl TrackerSourceAddInput { #[non_exhaustive] pub struct TrackerSourceCheckOutput { pub name: String, - #[serde(default = "default_2499")] - pub database: String, #[serde(default = "default_2500")] - pub reachable: bool, + pub database: String, #[serde(default = "default_2501")] - pub contract: std::collections::HashMap, + pub reachable: bool, #[serde(default = "default_2502")] + pub contract: std::collections::HashMap, + #[serde(default = "default_2503")] pub view_templates: std::collections::HashMap, } @@ -58886,11 +58888,11 @@ impl TrackerSourceCheckInput { pub struct TrackerSourceInspectOutput { pub host: String, pub database: String, - #[serde(default = "default_2503")] - pub tables: Vec>, #[serde(default = "default_2504")] - pub roles: Vec, + pub tables: Vec>, #[serde(default = "default_2505")] + pub roles: Vec, + #[serde(default = "default_2506")] pub proposal: std::collections::HashMap, } @@ -59019,9 +59021,9 @@ impl TrackerSourceInspectInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct TrackerSourceListOutput { - #[serde(default = "default_2506")] - pub sources: Vec>, #[serde(default = "default_2507")] + pub sources: Vec>, + #[serde(default = "default_2508")] pub self_service: bool, } @@ -59074,9 +59076,9 @@ impl TrackerSourceListInput { #[non_exhaustive] pub struct TrackerSourceRemoveOutput { pub name: String, - #[serde(default = "default_2508")] - pub deactivated: bool, #[serde(default = "default_2509")] + pub deactivated: bool, + #[serde(default = "default_2510")] pub namespaces_retired: Vec, } @@ -59117,9 +59119,9 @@ impl TrackerSourceRemoveInput { #[non_exhaustive] pub struct TrackerSourceRotateOutput { pub name: String, - #[serde(default = "default_2510")] - pub contract: std::collections::HashMap, #[serde(default = "default_2511")] + pub contract: std::collections::HashMap, + #[serde(default = "default_2512")] pub rotated_at: String, } @@ -59166,11 +59168,11 @@ impl TrackerSourceRotateInput { #[non_exhaustive] pub struct TrackerSourceSetMappingOutput { pub name: String, - #[serde(default = "default_2512")] - pub contract: std::collections::HashMap, #[serde(default = "default_2513")] - pub dry_run: bool, + pub contract: std::collections::HashMap, #[serde(default = "default_2514")] + pub dry_run: bool, + #[serde(default = "default_2515")] pub written: bool, } @@ -59237,45 +59239,45 @@ impl TrackerSourceSetMappingInput { #[non_exhaustive] pub struct TrackerTestSignalOutput { pub test_name: String, - #[serde(default = "default_2515")] - pub verdict: String, #[serde(default = "default_2516")] - pub why: Vec, + pub verdict: String, #[serde(default = "default_2517")] - pub lower_bound: f64, + pub why: Vec, #[serde(default = "default_2518")] - pub window_days: Integer, + pub lower_bound: f64, #[serde(default = "default_2519")] - pub since: String, + pub window_days: Integer, #[serde(default = "default_2520")] - pub features: std::collections::HashMap, + pub since: String, #[serde(default = "default_2521")] - pub infra: std::collections::HashMap, + pub features: std::collections::HashMap, #[serde(default = "default_2522")] - pub churn: std::collections::HashMap, + pub infra: std::collections::HashMap, #[serde(default = "default_2523")] - pub thresholds: std::collections::HashMap, + pub churn: std::collections::HashMap, #[serde(default = "default_2524")] - pub source: String, + pub thresholds: std::collections::HashMap, #[serde(default = "default_2525")] - pub timings_ms: std::collections::HashMap, + pub source: String, #[serde(default = "default_2526")] - pub tracker_unavailable: bool, + pub timings_ms: std::collections::HashMap, #[serde(default = "default_2527")] - pub rollup: std::collections::HashMap, + pub tracker_unavailable: bool, #[serde(default = "default_2528")] - pub streak: std::collections::HashMap, + pub rollup: std::collections::HashMap, #[serde(default = "default_2529")] - pub smells: std::collections::HashMap, + pub streak: std::collections::HashMap, #[serde(default = "default_2530")] - pub prior: std::collections::HashMap, + pub smells: std::collections::HashMap, #[serde(default = "default_2531")] - pub unavailable_reason: String, + pub prior: std::collections::HashMap, #[serde(default = "default_2532")] - pub candidates: Vec>, + pub unavailable_reason: String, #[serde(default = "default_2533")] - pub candidate_matches: Integer, + pub candidates: Vec>, #[serde(default = "default_2534")] + pub candidate_matches: Integer, + #[serde(default = "default_2535")] pub resolved_from: String, } @@ -59379,9 +59381,9 @@ impl TrackerTestSignalInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct UiVitalsOutput { - #[serde(default = "default_2535")] - pub recorded: bool, #[serde(default = "default_2536")] + pub recorded: bool, + #[serde(default = "default_2537")] pub route: String, } @@ -59565,7 +59567,7 @@ pub struct WebhookDelivery { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookDeliveriesOutput { - #[serde(default = "default_2537")] + #[serde(default = "default_2538")] pub deliveries: Vec, } @@ -59687,14 +59689,14 @@ pub struct WebhookInfo { pub secret_ref: String, pub events: Vec, pub created_at: String, - #[serde(default = "default_2538")] + #[serde(default = "default_2539")] pub secret_present: bool, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct WebhookListOutput { - #[serde(default = "default_2539")] + #[serde(default = "default_2540")] pub webhooks: Vec, } @@ -59876,7 +59878,7 @@ pub struct WorkingMemoryMutationOutput { pub version: Integer, pub char_limit: Integer, pub value_length: Integer, - #[serde(default = "default_2540")] + #[serde(default = "default_2541")] pub fill_ratio: f64, } @@ -60100,15 +60102,15 @@ impl WorkingMemoryDeleteInput { pub struct WorkingMemoryGetOutput { pub found: bool, pub block_key: String, - #[serde(default = "default_2541")] - pub content: String, #[serde(default = "default_2542")] - pub char_limit: Integer, + pub content: String, #[serde(default = "default_2543")] - pub version: Integer, + pub char_limit: Integer, #[serde(default = "default_2544")] - pub updated_at: Option, + pub version: Integer, #[serde(default = "default_2545")] + pub updated_at: Option, + #[serde(default = "default_2546")] pub fill_ratio: f64, } @@ -60219,7 +60221,7 @@ pub struct WorkingMemoryBlock { pub content: String, pub char_limit: Integer, pub version: Integer, - #[serde(default = "default_2546")] + #[serde(default = "default_2547")] pub updated_at: Option, } @@ -60227,7 +60229,7 @@ pub struct WorkingMemoryBlock { #[non_exhaustive] pub struct WorkingMemoryRenderOutput { pub rendered: String, - #[serde(default = "default_2547")] + #[serde(default = "default_2548")] pub blocks: Vec, pub block_count: Integer, pub total_chars: Integer, @@ -65713,129 +65715,129 @@ fn default_1700() -> Integer { fn default_1701() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1702() -> String { +fn default_1702() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_1703() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1703() -> bool { +fn default_1704() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1704() -> Integer { +fn default_1705() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1705() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1706() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1707() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1708() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_1709() -> String { +fn default_1708() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1710() -> Option { +fn default_1709() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1711() -> String { +fn default_1710() -> String { serde_json::from_str("\"\"").expect("schema default") } +fn default_1711() -> Option { + serde_json::from_str("null").expect("schema default") +} fn default_1712() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1713() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1714() -> Integer { +fn default_1714() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1715() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1715() -> String { +fn default_1716() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1716() -> Vec { +fn default_1717() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1717() -> bool { +fn default_1718() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1718() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1719() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1720() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1721() -> bool { +fn default_1721() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1722() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1722() -> std::collections::HashMap { +fn default_1723() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1723() -> String { +fn default_1724() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1724() -> String { +fn default_1725() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1725() -> Integer { +fn default_1726() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1726() -> Integer { +fn default_1727() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1727() -> Vec { +fn default_1728() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1728() -> Integer { +fn default_1729() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1729() -> Integer { +fn default_1730() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1730() -> Vec { +fn default_1731() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1731() -> String { +fn default_1732() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1732() -> Integer { +fn default_1733() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1733() -> String { +fn default_1734() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1734() -> Vec { +fn default_1735() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1735() -> Integer { +fn default_1736() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1736() -> Option { +fn default_1737() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1737() -> Vec { +fn default_1738() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1738() -> Integer { +fn default_1739() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1739() -> String { +fn default_1740() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1740() -> String { +fn default_1741() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1741() -> Vec { +fn default_1742() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1742() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1743() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -65848,60 +65850,60 @@ fn default_1745() -> String { fn default_1746() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1747() -> Vec { +fn default_1747() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1748() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1748() -> String { +fn default_1749() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1749() -> Integer { +fn default_1750() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1750() -> Integer { +fn default_1751() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1751() -> String { +fn default_1752() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1752() -> Integer { +fn default_1753() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1753() -> Integer { +fn default_1754() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1754() -> MemoryProposalReady { +fn default_1755() -> MemoryProposalReady { serde_json::from_str("\"\"").expect("schema default") } -fn default_1755() -> Vec { +fn default_1756() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1756() -> Vec { +fn default_1757() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1757() -> Integer { +fn default_1758() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1758() -> ProposalPolicyMode { +fn default_1759() -> ProposalPolicyMode { serde_json::from_str("\"manual\"").expect("schema default") } -fn default_1759() -> Integer { +fn default_1760() -> Integer { serde_json::from_str("2").expect("schema default") } -fn default_1760() -> Integer { +fn default_1761() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1761() -> Integer { +fn default_1762() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1762() -> ProposalPolicy { +fn default_1763() -> ProposalPolicy { serde_json::from_str( "{\"mode\":\"manual\",\"min_passes\":2,\"max_fails\":0,\"reject_after_fails\":0}", ) .expect("schema default") } -fn default_1763() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1764() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -65917,12 +65919,12 @@ fn default_1767() -> String { fn default_1768() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1769() -> bool { - serde_json::from_str("false").expect("schema default") -} -fn default_1770() -> String { +fn default_1769() -> String { serde_json::from_str("\"\"").expect("schema default") } +fn default_1770() -> bool { + serde_json::from_str("false").expect("schema default") +} fn default_1771() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -65947,24 +65949,24 @@ fn default_1777() -> String { fn default_1778() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1779() -> Vec { +fn default_1779() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1780() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1780() -> f64 { +fn default_1781() -> f64 { serde_json::from_str("1.0").expect("schema default") } -fn default_1781() -> String { +fn default_1782() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1782() -> String { +fn default_1783() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1783() -> Vec { +fn default_1784() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1784() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1785() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -65974,11 +65976,11 @@ fn default_1786() -> String { fn default_1787() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1788() -> bool { - serde_json::from_str("false").expect("schema default") +fn default_1788() -> String { + serde_json::from_str("\"\"").expect("schema default") } -fn default_1789() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_1789() -> bool { + serde_json::from_str("false").expect("schema default") } fn default_1790() -> Integer { serde_json::from_str("0").expect("schema default") @@ -65986,183 +65988,183 @@ fn default_1790() -> Integer { fn default_1791() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1792() -> bool { +fn default_1792() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_1793() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1793() -> String { +fn default_1794() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1794() -> Integer { +fn default_1795() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_1795() -> MemoryRecallOutputOrder { +fn default_1796() -> MemoryRecallOutputOrder { serde_json::from_str("\"recent\"").expect("schema default") } -fn default_1796() -> Vec { +fn default_1797() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1797() -> Integer { +fn default_1798() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1798() -> Value { +fn default_1799() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1799() -> Value { +fn default_1800() -> Value { serde_json::from_str("null").expect("schema default") } -fn default_1800() -> String { +fn default_1801() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1801() -> String { +fn default_1802() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1802() -> Option { +fn default_1803() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1803() -> Option { +fn default_1804() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1804() -> bool { +fn default_1805() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1805() -> String { +fn default_1806() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1806() -> String { +fn default_1807() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1807() -> std::collections::HashMap { +fn default_1808() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1808() -> std::collections::HashMap { +fn default_1809() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1809() -> MemoryRecordRowStatus { +fn default_1810() -> MemoryRecordRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1810() -> Option { +fn default_1811() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1811() -> Option { +fn default_1812() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1812() -> bool { +fn default_1813() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1813() -> String { +fn default_1814() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1814() -> MemoryRecordWriteOutputKeySource { +fn default_1815() -> MemoryRecordWriteOutputKeySource { serde_json::from_str("\"anonymous\"").expect("schema default") } -fn default_1815() -> std::collections::HashMap { +fn default_1816() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1816() -> String { +fn default_1817() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1817() -> Integer { +fn default_1818() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1818() -> bool { +fn default_1819() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1819() -> Option { +fn default_1820() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1820() -> Integer { +fn default_1821() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1821() -> Integer { +fn default_1822() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1822() -> Option { +fn default_1823() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1823() -> String { +fn default_1824() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1824() -> Integer { +fn default_1825() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1825() -> Integer { +fn default_1826() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1826() -> bool { +fn default_1827() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1827() -> Vec { +fn default_1828() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1828() -> Option { +fn default_1829() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1829() -> Option { +fn default_1830() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1830() -> bool { +fn default_1831() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1831() -> bool { +fn default_1832() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1832() -> String { +fn default_1833() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1833() -> f64 { +fn default_1834() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_1834() -> String { +fn default_1835() -> String { serde_json::from_str("\"fact\"").expect("schema default") } -fn default_1835() -> String { +fn default_1836() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1836() -> std::collections::HashMap { +fn default_1837() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1837() -> bool { +fn default_1838() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1838() -> Integer { +fn default_1839() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1839() -> String { +fn default_1840() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1840() -> Vec { +fn default_1841() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1841() -> Vec { +fn default_1842() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1842() -> Integer { +fn default_1843() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1843() -> Integer { +fn default_1844() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1844() -> String { +fn default_1845() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1845() -> String { +fn default_1846() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1846() -> Integer { +fn default_1847() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_1847() -> Integer { +fn default_1848() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1848() -> Integer { +fn default_1849() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1849() -> Vec { +fn default_1850() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1850() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_1851() -> Integer { serde_json::from_str("0").expect("schema default") } @@ -66172,98 +66174,98 @@ fn default_1852() -> Integer { fn default_1853() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1854() -> Vec { +fn default_1854() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_1855() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1855() -> String { +fn default_1856() -> String { serde_json::from_str("\"whole\"").expect("schema default") } -fn default_1856() -> Integer { +fn default_1857() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1857() -> Vec { +fn default_1858() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1858() -> Vec { +fn default_1859() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1859() -> Integer { +fn default_1860() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1860() -> Vec { +fn default_1861() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1861() -> Integer { +fn default_1862() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1862() -> Vec { +fn default_1863() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1863() -> Vec { +fn default_1864() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1864() -> bool { +fn default_1865() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1865() -> String { +fn default_1866() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1866() -> String { +fn default_1867() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1867() -> std::collections::HashMap { +fn default_1868() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1868() -> String { +fn default_1869() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1869() -> bool { +fn default_1870() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1870() -> Vec { +fn default_1871() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1871() -> Integer { +fn default_1872() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1872() -> Integer { +fn default_1873() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1873() -> Option { +fn default_1874() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1874() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1875() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1876() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1877() -> bool { +fn default_1877() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1878() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1878() -> Integer { +fn default_1879() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1879() -> Option { +fn default_1880() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1880() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1881() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1882() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1883() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_1883() -> String { + serde_json::from_str("\"\"").expect("schema default") } -fn default_1884() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_1884() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_1885() -> Integer { serde_json::from_str("0").expect("schema default") @@ -66280,54 +66282,54 @@ fn default_1888() -> Integer { fn default_1889() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1890() -> bool { +fn default_1890() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_1891() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1891() -> Vec> { +fn default_1892() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1892() -> Vec { +fn default_1893() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1893() -> Option { +fn default_1894() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1894() -> String { +fn default_1895() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1895() -> Integer { +fn default_1896() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1896() -> Option { +fn default_1897() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1897() -> Option { +fn default_1898() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1898() -> Option { +fn default_1899() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1899() -> Option { +fn default_1900() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1900() -> Vec { +fn default_1901() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1901() -> Integer { +fn default_1902() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1902() -> String { +fn default_1903() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1903() -> String { +fn default_1904() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1904() -> Option { +fn default_1905() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1905() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1906() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66337,21 +66339,21 @@ fn default_1907() -> String { fn default_1908() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1909() -> Option { +fn default_1909() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1910() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1910() -> String { +fn default_1911() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1911() -> String { +fn default_1912() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1912() -> Integer { +fn default_1913() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1913() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1914() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66364,45 +66366,45 @@ fn default_1916() -> String { fn default_1917() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1918() -> Integer { +fn default_1918() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1919() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1919() -> String { +fn default_1920() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1920() -> Vec { +fn default_1921() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1921() -> String { +fn default_1922() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1922() -> Integer { +fn default_1923() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1923() -> String { +fn default_1924() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1924() -> Integer { +fn default_1925() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1925() -> String { +fn default_1926() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1926() -> String { +fn default_1927() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1927() -> Integer { +fn default_1928() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1928() -> String { +fn default_1929() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1929() -> bool { +fn default_1930() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1930() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1931() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66412,105 +66414,105 @@ fn default_1932() -> String { fn default_1933() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1934() -> Option { +fn default_1934() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1935() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1935() -> String { +fn default_1936() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1936() -> Integer { +fn default_1937() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1937() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1938() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1939() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1940() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_1940() -> bool { +fn default_1941() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1941() -> Vec { +fn default_1942() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1942() -> std::collections::HashMap { +fn default_1943() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1943() -> String { +fn default_1944() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1944() -> Vec { +fn default_1945() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1945() -> std::collections::HashMap { +fn default_1946() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1946() -> Integer { +fn default_1947() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1947() -> Option { +fn default_1948() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1948() -> String { +fn default_1949() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1949() -> bool { +fn default_1950() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1950() -> Vec { +fn default_1951() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1951() -> Vec { +fn default_1952() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1952() -> std::collections::HashMap { +fn default_1953() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_1953() -> Option { +fn default_1954() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1954() -> Vec { +fn default_1955() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1955() -> Integer { +fn default_1956() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1956() -> Integer { +fn default_1957() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1957() -> Vec { +fn default_1958() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1958() -> Option { +fn default_1959() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1959() -> Vec { +fn default_1960() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1960() -> Option { +fn default_1961() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1961() -> Option { +fn default_1962() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1962() -> Vec { +fn default_1963() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1963() -> bool { +fn default_1964() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1964() -> Vec { +fn default_1965() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1965() -> bool { +fn default_1966() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_1966() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_1967() -> Integer { serde_json::from_str("0").expect("schema default") } @@ -66535,12 +66537,12 @@ fn default_1973() -> Integer { fn default_1974() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1975() -> f64 { - serde_json::from_str("0.0").expect("schema default") -} -fn default_1976() -> Integer { +fn default_1975() -> Integer { serde_json::from_str("0").expect("schema default") } +fn default_1976() -> f64 { + serde_json::from_str("0.0").expect("schema default") +} fn default_1977() -> Integer { serde_json::from_str("0").expect("schema default") } @@ -66550,82 +66552,82 @@ fn default_1978() -> Integer { fn default_1979() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1980() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_1980() -> Integer { + serde_json::from_str("0").expect("schema default") } fn default_1981() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1982() -> Vec { +fn default_1982() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_1983() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1983() -> String { +fn default_1984() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1984() -> String { +fn default_1985() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1985() -> Integer { +fn default_1986() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1986() -> Vec> { +fn default_1987() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_1987() -> Vec { +fn default_1988() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_1988() -> String { +fn default_1989() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_1989() -> bool { +fn default_1990() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_1990() -> String { +fn default_1991() -> String { serde_json::from_str("\"approval\"").expect("schema default") } -fn default_1991() -> String { +fn default_1992() -> String { serde_json::from_str("\"public\"").expect("schema default") } -fn default_1992() -> BrowseEntryMyStatus { +fn default_1993() -> BrowseEntryMyStatus { serde_json::from_str("\"none\"").expect("schema default") } -fn default_1993() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_1994() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_1995() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1996() -> Integer { +fn default_1996() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_1997() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_1997() -> String { +fn default_1998() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_1998() -> Option { +fn default_1999() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_1999() -> Option { +fn default_2000() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2000() -> Vec { +fn default_2001() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2001() -> Option { - serde_json::from_str("null").expect("schema default") -} fn default_2002() -> Option { serde_json::from_str("null").expect("schema default") } fn default_2003() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2004() -> Option> { +fn default_2004() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2005() -> Option { +fn default_2005() -> Option> { serde_json::from_str("null").expect("schema default") } fn default_2006() -> Option { @@ -66640,40 +66642,40 @@ fn default_2008() -> Option { fn default_2009() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2010() -> Option { +fn default_2010() -> Option { serde_json::from_str("null").expect("schema default") } fn default_2011() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2012() -> Option { +fn default_2012() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2013() -> Option { +fn default_2013() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2014() -> Option { +fn default_2014() -> Option { serde_json::from_str("null").expect("schema default") } fn default_2015() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2016() -> Option { +fn default_2016() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2017() -> Option { +fn default_2017() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2018() -> Option { +fn default_2018() -> Option { serde_json::from_str("null").expect("schema default") } fn default_2019() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2020() -> Option> { +fn default_2020() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2021() -> Option { +fn default_2021() -> Option> { serde_json::from_str("null").expect("schema default") } fn default_2022() -> Option { @@ -66682,22 +66684,22 @@ fn default_2022() -> Option { fn default_2023() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2024() -> Option { +fn default_2024() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2025() -> Option { +fn default_2025() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2026() -> Option>> { +fn default_2026() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2027() -> Option { +fn default_2027() -> Option>> { serde_json::from_str("null").expect("schema default") } -fn default_2028() -> Option { +fn default_2028() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2029() -> Option { +fn default_2029() -> Option { serde_json::from_str("null").expect("schema default") } fn default_2030() -> Option { @@ -66706,11 +66708,11 @@ fn default_2030() -> Option { fn default_2031() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2032() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_2032() -> Option { + serde_json::from_str("null").expect("schema default") } -fn default_2033() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2033() -> Integer { + serde_json::from_str("0").expect("schema default") } fn default_2034() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -66721,18 +66723,18 @@ fn default_2035() -> String { fn default_2036() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2037() -> Option { +fn default_2037() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2038() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2038() -> bool { +fn default_2039() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2039() -> Integer { +fn default_2040() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2040() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2041() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66742,129 +66744,129 @@ fn default_2042() -> String { fn default_2043() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2044() -> Option { +fn default_2044() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2045() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2045() -> Option { +fn default_2046() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2046() -> String { +fn default_2047() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2047() -> Vec { +fn default_2048() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2048() -> String { +fn default_2049() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2049() -> String { +fn default_2050() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2050() -> Option { +fn default_2051() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2051() -> Vec { +fn default_2052() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2052() -> Option { +fn default_2053() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2053() -> String { +fn default_2054() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2054() -> bool { +fn default_2055() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2055() -> f64 { +fn default_2056() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2056() -> f64 { +fn default_2057() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2057() -> String { +fn default_2058() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2058() -> Option { +fn default_2059() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2059() -> Integer { +fn default_2060() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2060() -> Integer { +fn default_2061() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2061() -> NamespaceEntryVisibility { +fn default_2062() -> NamespaceEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2062() -> String { +fn default_2063() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2063() -> Option { +fn default_2064() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2064() -> Option { +fn default_2065() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2065() -> Vec { +fn default_2066() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2066() -> MineEntryVisibility { +fn default_2067() -> MineEntryVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2067() -> String { +fn default_2068() -> String { serde_json::from_str("\"memory\"").expect("schema default") } -fn default_2068() -> String { +fn default_2069() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2069() -> String { +fn default_2070() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2070() -> Option { +fn default_2071() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2071() -> bool { +fn default_2072() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2072() -> bool { +fn default_2073() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2073() -> String { +fn default_2074() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2074() -> NamespaceRegisterOutputVisibility { +fn default_2075() -> NamespaceRegisterOutputVisibility { serde_json::from_str("\"private\"").expect("schema default") } -fn default_2075() -> bool { +fn default_2076() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2076() -> Integer { +fn default_2077() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2077() -> Integer { +fn default_2078() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2078() -> bool { +fn default_2079() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2079() -> Vec> { +fn default_2080() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2080() -> Option { +fn default_2081() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2081() -> Option { +fn default_2082() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2082() -> Vec { +fn default_2083() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2083() -> Integer { +fn default_2084() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2084() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2085() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66877,23 +66879,23 @@ fn default_2087() -> String { fn default_2088() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2089() -> Option { - serde_json::from_str("null").expect("schema default") -} -fn default_2090() -> String { +fn default_2089() -> String { serde_json::from_str("\"\"").expect("schema default") } +fn default_2090() -> Option { + serde_json::from_str("null").expect("schema default") +} fn default_2091() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_2092() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2093() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2093() -> String { + serde_json::from_str("\"\"").expect("schema default") } -fn default_2094() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_2094() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_2095() -> Option { serde_json::from_str("null").expect("schema default") @@ -66904,33 +66906,33 @@ fn default_2096() -> Option { fn default_2097() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2098() -> String { +fn default_2098() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_2099() -> String { serde_json::from_str("\"{}\"").expect("schema default") } -fn default_2099() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { +fn default_2100() -> NamespaceSnapshotOutputSnapshotMemoryRowStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2100() -> Option { +fn default_2101() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2101() -> Vec { +fn default_2102() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2102() -> String { +fn default_2103() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2103() -> Integer { +fn default_2104() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2104() -> Integer { +fn default_2105() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2105() -> Option { +fn default_2106() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2106() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2107() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66940,188 +66942,188 @@ fn default_2108() -> String { fn default_2109() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2110() -> Option { +fn default_2110() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2111() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2111() -> f64 { +fn default_2112() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2112() -> Option { +fn default_2113() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2113() -> Option { +fn default_2114() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2114() -> Integer { +fn default_2115() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2115() -> Option { +fn default_2116() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2116() -> Option { +fn default_2117() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2117() -> String { +fn default_2118() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2118() -> Option { +fn default_2119() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2119() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2120() -> String { serde_json::from_str("\"\"").expect("schema default") } fn default_2121() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2122() -> Option { +fn default_2122() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2123() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2123() -> String { +fn default_2124() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2124() -> Option { +fn default_2125() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2125() -> String { +fn default_2126() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2126() -> String { +fn default_2127() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2127() -> Vec { +fn default_2128() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2128() -> Vec { +fn default_2129() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2129() -> Option { +fn default_2130() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2130() -> Integer { +fn default_2131() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2131() -> String { +fn default_2132() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2132() -> Vec { +fn default_2133() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2133() -> Vec { +fn default_2134() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2134() -> String { +fn default_2135() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2135() -> Option { +fn default_2136() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2136() -> Vec { +fn default_2137() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2137() -> Integer { +fn default_2138() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2138() -> Vec { +fn default_2139() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2139() -> Option { +fn default_2140() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2140() -> Vec { +fn default_2141() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2141() -> Vec { +fn default_2142() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2142() -> Option { +fn default_2143() -> Option { serde_json::from_str("0").expect("schema default") } -fn default_2143() -> TuneProposalEffect { +fn default_2144() -> TuneProposalEffect { serde_json::from_str("\"future\"").expect("schema default") } -fn default_2144() -> TuneApplyVia { +fn default_2145() -> TuneApplyVia { serde_json::from_str("\"op\"").expect("schema default") } -fn default_2145() -> bool { +fn default_2146() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2146() -> Vec { +fn default_2147() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2147() -> Option { +fn default_2148() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2148() -> Option { +fn default_2149() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2149() -> String { +fn default_2150() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2150() -> Vec { +fn default_2151() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2151() -> Vec { +fn default_2152() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2152() -> Option { +fn default_2153() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2153() -> Option { +fn default_2154() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2154() -> Option { +fn default_2155() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2155() -> String { +fn default_2156() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2156() -> Option { +fn default_2157() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2157() -> Option { +fn default_2158() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2158() -> Option { +fn default_2159() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2159() -> Vec { +fn default_2160() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2160() -> bool { +fn default_2161() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2161() -> Option { +fn default_2162() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2162() -> Option { +fn default_2163() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2163() -> Vec { +fn default_2164() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2164() -> String { +fn default_2165() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2165() -> String { +fn default_2166() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2166() -> Vec> { +fn default_2167() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2167() -> Vec { +fn default_2168() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2168() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_2169() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2170() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2170() -> Integer { + serde_json::from_str("0").expect("schema default") } fn default_2171() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -67129,27 +67131,27 @@ fn default_2171() -> String { fn default_2172() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2173() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2173() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2174() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2175() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2175() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_2176() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2177() -> bool { +fn default_2177() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2178() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2178() -> Integer { +fn default_2179() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2179() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2180() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -67159,104 +67161,104 @@ fn default_2181() -> String { fn default_2182() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2183() -> Vec { +fn default_2183() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2184() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2184() -> String { +fn default_2185() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2185() -> String { +fn default_2186() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2186() -> std::collections::HashMap { +fn default_2187() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2187() -> String { +fn default_2188() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2188() -> Option { +fn default_2189() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2189() -> Option { +fn default_2190() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2190() -> bool { +fn default_2191() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2191() -> String { +fn default_2192() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2192() -> String { +fn default_2193() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2193() -> Vec { +fn default_2194() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2194() -> Integer { +fn default_2195() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2195() -> String { +fn default_2196() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2196() -> String { +fn default_2197() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2197() -> Option { +fn default_2198() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2198() -> bool { +fn default_2199() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2199() -> String { +fn default_2200() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2200() -> bool { +fn default_2201() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2201() -> String { +fn default_2202() -> String { serde_json::from_str("\"inherit\"").expect("schema default") } -fn default_2202() -> Option { +fn default_2203() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2203() -> Option { +fn default_2204() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2204() -> bool { +fn default_2205() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2205() -> Vec { +fn default_2206() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2206() -> Integer { +fn default_2207() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2207() -> ProcedureEvolveOutputGate { +fn default_2208() -> ProcedureEvolveOutputGate { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2208() -> String { +fn default_2209() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2209() -> f64 { +fn default_2210() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2210() -> std::collections::HashMap { - serde_json::from_str("{}").expect("schema default") -} fn default_2211() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2212() -> std::collections::HashMap { +fn default_2212() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } fn default_2213() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2214() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2214() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") } -fn default_2215() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2215() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2216() -> Vec { serde_json::from_str("[]").expect("schema default") @@ -67264,137 +67266,137 @@ fn default_2216() -> Vec { fn default_2217() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2218() -> std::collections::HashMap { +fn default_2218() -> Vec { + serde_json::from_str("[]").expect("schema default") +} +fn default_2219() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2219() -> Integer { +fn default_2220() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2220() -> bool { +fn default_2221() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2221() -> std::collections::HashMap { +fn default_2222() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2222() -> Vec { +fn default_2223() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2223() -> std::collections::HashMap { +fn default_2224() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2224() -> String { +fn default_2225() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2225() -> ProcedureLocateOutputStatus { +fn default_2226() -> ProcedureLocateOutputStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2226() -> Option> { +fn default_2227() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2227() -> Vec>> { +fn default_2228() -> Vec>> { serde_json::from_str("[]").expect("schema default") } -fn default_2228() -> Vec { +fn default_2229() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2229() -> Vec { +fn default_2230() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2230() -> std::collections::HashMap { +fn default_2231() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2231() -> bool { +fn default_2232() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2232() -> Vec { +fn default_2233() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2233() -> Vec> { +fn default_2234() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2234() -> String { +fn default_2235() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2235() -> std::collections::HashMap { +fn default_2236() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2236() -> std::collections::HashMap { +fn default_2237() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2237() -> Option { +fn default_2238() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2238() -> Vec { +fn default_2239() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2239() -> std::collections::HashMap { +fn default_2240() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2240() -> Option> { +fn default_2241() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2241() -> bool { +fn default_2242() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2242() -> std::collections::HashMap { +fn default_2243() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2243() -> ProcedureMatchStatus { +fn default_2244() -> ProcedureMatchStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2244() -> Option> { +fn default_2245() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2245() -> Vec { +fn default_2246() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2246() -> Integer { +fn default_2247() -> Integer { serde_json::from_str("1").expect("schema default") } -fn default_2247() -> Vec> { +fn default_2248() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2248() -> f64 { - serde_json::from_str("0.0").expect("schema default") -} fn default_2249() -> f64 { serde_json::from_str("0.0").expect("schema default") } fn default_2250() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2251() -> Option { +fn default_2251() -> f64 { + serde_json::from_str("0.0").expect("schema default") +} +fn default_2252() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2252() -> std::collections::HashMap { +fn default_2253() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2253() -> std::collections::HashMap> { +fn default_2254() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2254() -> String { +fn default_2255() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2255() -> Integer { +fn default_2256() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2256() -> String { +fn default_2257() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2257() -> f64 { +fn default_2258() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2258() -> Vec { - serde_json::from_str("[]").expect("schema default") -} fn default_2259() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2260() -> Vec { +fn default_2260() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2261() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2261() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_2262() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -67405,101 +67407,101 @@ fn default_2263() -> String { fn default_2264() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2265() -> Option { +fn default_2265() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2266() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2266() -> Integer { +fn default_2267() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2267() -> Vec { +fn default_2268() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2268() -> std::collections::HashMap { +fn default_2269() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2269() -> Option { +fn default_2270() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2270() -> String { +fn default_2271() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2271() -> Integer { +fn default_2272() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2272() -> String { +fn default_2273() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2273() -> String { +fn default_2274() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2274() -> std::collections::HashMap { +fn default_2275() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2275() -> String { +fn default_2276() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2276() -> String { +fn default_2277() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2277() -> Option { +fn default_2278() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2278() -> RunBeginOutputStatus { +fn default_2279() -> RunBeginOutputStatus { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2279() -> String { +fn default_2280() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2280() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_2281() -> Integer { serde_json::from_str("0").expect("schema default") } fn default_2282() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2283() -> Vec { +fn default_2283() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2284() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2284() -> Integer { +fn default_2285() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2285() -> Integer { +fn default_2286() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2286() -> Integer { +fn default_2287() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2287() -> String { +fn default_2288() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2288() -> String { +fn default_2289() -> String { serde_json::from_str("\"keep\"").expect("schema default") } -fn default_2289() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_2290() -> Integer { serde_json::from_str("0").expect("schema default") } fn default_2291() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2292() -> Option { +fn default_2292() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2293() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2293() -> Integer { +fn default_2294() -> Integer { serde_json::from_str("-1").expect("schema default") } -fn default_2294() -> Vec { - serde_json::from_str("[]").expect("schema default") -} fn default_2295() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2296() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_2296() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_2297() -> Integer { serde_json::from_str("0").expect("schema default") @@ -67507,57 +67509,57 @@ fn default_2297() -> Integer { fn default_2298() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2299() -> f64 { +fn default_2299() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2300() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2300() -> Integer { +fn default_2301() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2301() -> Vec { +fn default_2302() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2302() -> Integer { +fn default_2303() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2303() -> Vec { +fn default_2304() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2304() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_2305() -> Integer { serde_json::from_str("0").expect("schema default") } fn default_2306() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2307() -> Vec { +fn default_2307() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2308() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2308() -> Option { +fn default_2309() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2309() -> Option> { +fn default_2310() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2310() -> LiveSearchResultsLive { +fn default_2311() -> LiveSearchResultsLive { serde_json::from_str("true").expect("schema default") } -fn default_2311() -> String { +fn default_2312() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2312() -> LiveSearchHitLive { +fn default_2313() -> LiveSearchHitLive { serde_json::from_str("true").expect("schema default") } -fn default_2313() -> Vec { +fn default_2314() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2314() -> Option { +fn default_2315() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2315() -> std::collections::HashMap { - serde_json::from_str("{}").expect("schema default") -} fn default_2316() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } @@ -67567,24 +67569,24 @@ fn default_2317() -> std::collections::HashMap { fn default_2318() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2319() -> Option> { +fn default_2319() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") +} +fn default_2320() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2320() -> Vec { +fn default_2321() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2321() -> Integer { +fn default_2322() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2322() -> String { +fn default_2323() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2323() -> Integer { +fn default_2324() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2324() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2325() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -67606,60 +67608,60 @@ fn default_2330() -> String { fn default_2331() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2332() -> Vec { +fn default_2332() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2333() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2333() -> String { +fn default_2334() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2334() -> String { +fn default_2335() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2335() -> Vec { +fn default_2336() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2336() -> String { +fn default_2337() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2337() -> String { +fn default_2338() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2338() -> Vec { +fn default_2339() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2339() -> Vec { +fn default_2340() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2340() -> Vec { +fn default_2341() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2341() -> String { +fn default_2342() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2342() -> String { +fn default_2343() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2343() -> Vec { +fn default_2344() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2344() -> Vec { +fn default_2345() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2345() -> Vec { +fn default_2346() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2346() -> String { +fn default_2347() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2347() -> String { +fn default_2348() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2348() -> Option { +fn default_2349() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2349() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2350() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -67675,15 +67677,15 @@ fn default_2353() -> String { fn default_2354() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2355() -> Vec { +fn default_2355() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2356() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2356() -> Option { +fn default_2357() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2357() -> Integer { - serde_json::from_str("0").expect("schema default") -} fn default_2358() -> Integer { serde_json::from_str("0").expect("schema default") } @@ -67696,11 +67698,11 @@ fn default_2360() -> Integer { fn default_2361() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2362() -> bool { - serde_json::from_str("false").expect("schema default") +fn default_2362() -> Integer { + serde_json::from_str("0").expect("schema default") } -fn default_2363() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2363() -> bool { + serde_json::from_str("false").expect("schema default") } fn default_2364() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -67720,21 +67722,21 @@ fn default_2368() -> String { fn default_2369() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2370() -> Option { +fn default_2370() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2371() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2371() -> Integer { +fn default_2372() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2372() -> Integer { +fn default_2373() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2373() -> Vec { +fn default_2374() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2374() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2375() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -67744,8 +67746,8 @@ fn default_2376() -> String { fn default_2377() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2378() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_2378() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2379() -> Integer { serde_json::from_str("0").expect("schema default") @@ -67759,32 +67761,32 @@ fn default_2381() -> Integer { fn default_2382() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2383() -> f64 { - serde_json::from_str("0.0").expect("schema default") -} -fn default_2384() -> Integer { +fn default_2383() -> Integer { serde_json::from_str("0").expect("schema default") } +fn default_2384() -> f64 { + serde_json::from_str("0.0").expect("schema default") +} fn default_2385() -> Integer { serde_json::from_str("0").expect("schema default") } fn default_2386() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2387() -> String { +fn default_2387() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2388() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2388() -> SessionBriefStats { +fn default_2389() -> SessionBriefStats { serde_json::from_str("{\"events_in\":0,\"windows\":0,\"events_total\":0,\"source_chars\":0,\"brief_chars\":0,\"compression_ratio\":0.0,\"dropped_ungrounded\":0,\"tokens_in\":0,\"tokens_out\":0,\"llm_model\":\"\"}").expect("schema default") } -fn default_2389() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2390() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2391() -> Option { - serde_json::from_str("null").expect("schema default") +fn default_2391() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2392() -> Option { serde_json::from_str("null").expect("schema default") @@ -67792,57 +67794,57 @@ fn default_2392() -> Option { fn default_2393() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2394() -> Integer { +fn default_2394() -> Option { + serde_json::from_str("null").expect("schema default") +} +fn default_2395() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2395() -> std::collections::HashMap { +fn default_2396() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2396() -> String { +fn default_2397() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2397() -> String { +fn default_2398() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2398() -> Option { +fn default_2399() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2399() -> String { +fn default_2400() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2400() -> Integer { +fn default_2401() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2401() -> Integer { +fn default_2402() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2402() -> Option { +fn default_2403() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2403() -> std::collections::HashMap { +fn default_2404() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2404() -> String { +fn default_2405() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2405() -> Integer { +fn default_2406() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2406() -> String { +fn default_2407() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2407() -> Option { +fn default_2408() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2408() -> String { +fn default_2409() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2409() -> Option { +fn default_2410() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2410() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2411() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -67852,327 +67854,327 @@ fn default_2412() -> String { fn default_2413() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2414() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_2414() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2415() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2416() -> String { +fn default_2416() -> Integer { + serde_json::from_str("0").expect("schema default") +} +fn default_2417() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2417() -> std::collections::HashMap { +fn default_2418() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2418() -> String { +fn default_2419() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2419() -> String { +fn default_2420() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2420() -> bool { +fn default_2421() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2421() -> String { +fn default_2422() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2422() -> std::collections::HashMap { +fn default_2423() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2423() -> Vec> { +fn default_2424() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2424() -> Vec { +fn default_2425() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2425() -> Vec { +fn default_2426() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2426() -> bool { +fn default_2427() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2427() -> String { +fn default_2428() -> String { serde_json::from_str("\"unknown\"").expect("schema default") } -fn default_2428() -> String { +fn default_2429() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2429() -> Vec { +fn default_2430() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2430() -> bool { +fn default_2431() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2431() -> String { +fn default_2432() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2432() -> bool { +fn default_2433() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2433() -> Vec { +fn default_2434() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2434() -> std::collections::HashMap { +fn default_2435() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2435() -> Vec> { +fn default_2436() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2436() -> bool { +fn default_2437() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2437() -> bool { +fn default_2438() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2438() -> Vec> { +fn default_2439() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2439() -> std::collections::HashMap { +fn default_2440() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2440() -> String { +fn default_2441() -> String { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2441() -> Vec> { +fn default_2442() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2442() -> bool { +fn default_2443() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2443() -> String { +fn default_2444() -> String { serde_json::from_str("\"calibrated\"").expect("schema default") } -fn default_2444() -> std::collections::HashMap { +fn default_2445() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2445() -> std::collections::HashMap { +fn default_2446() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2446() -> String { +fn default_2447() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2447() -> std::collections::HashMap { +fn default_2448() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2448() -> std::collections::HashMap { +fn default_2449() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2449() -> std::collections::HashMap { +fn default_2450() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2450() -> String { +fn default_2451() -> String { serde_json::from_str("\"ok\"").expect("schema default") } -fn default_2451() -> String { +fn default_2452() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2452() -> String { +fn default_2453() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2453() -> bool { +fn default_2454() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2454() -> Integer { +fn default_2455() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2455() -> String { +fn default_2456() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2456() -> String { +fn default_2457() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2457() -> Vec { +fn default_2458() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2458() -> bool { +fn default_2459() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2459() -> Vec { +fn default_2460() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2460() -> std::collections::HashMap> { +fn default_2461() -> std::collections::HashMap> { serde_json::from_str("{}").expect("schema default") } -fn default_2461() -> Vec> { +fn default_2462() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2462() -> Vec> { +fn default_2463() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2463() -> String { +fn default_2464() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2464() -> Vec> { +fn default_2465() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2465() -> std::collections::HashMap { +fn default_2466() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2466() -> String { +fn default_2467() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2467() -> Vec> { +fn default_2468() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2468() -> bool { +fn default_2469() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2469() -> Integer { +fn default_2470() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2470() -> Vec> { +fn default_2471() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2471() -> String { +fn default_2472() -> String { serde_json::from_str("\"no_flaky_signal\"").expect("schema default") } -fn default_2472() -> bool { +fn default_2473() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2473() -> Option> { +fn default_2474() -> Option> { serde_json::from_str("null").expect("schema default") } -fn default_2474() -> Vec { +fn default_2475() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2475() -> bool { +fn default_2476() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2476() -> std::collections::HashMap { +fn default_2477() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2477() -> String { +fn default_2478() -> String { serde_json::from_str("\"not_computed\"").expect("schema default") } -fn default_2478() -> Vec> { +fn default_2479() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2479() -> String { +fn default_2480() -> String { serde_json::from_str("\"candidate\"").expect("schema default") } -fn default_2480() -> std::collections::HashMap { +fn default_2481() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2481() -> String { +fn default_2482() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2482() -> bool { +fn default_2483() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2483() -> Integer { +fn default_2484() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2484() -> std::collections::HashMap { +fn default_2485() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2485() -> bool { +fn default_2486() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2486() -> Vec> { +fn default_2487() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2487() -> std::collections::HashMap { +fn default_2488() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2488() -> std::collections::HashMap { +fn default_2489() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2489() -> String { +fn default_2490() -> String { serde_json::from_str("\"lower_bound\"").expect("schema default") } -fn default_2490() -> bool { +fn default_2491() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2491() -> Vec { +fn default_2492() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2492() -> Vec> { +fn default_2493() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2493() -> std::collections::HashMap { +fn default_2494() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2494() -> Vec { +fn default_2495() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2495() -> String { +fn default_2496() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2496() -> bool { +fn default_2497() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2497() -> bool { +fn default_2498() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2498() -> std::collections::HashMap { +fn default_2499() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2499() -> String { +fn default_2500() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2500() -> bool { +fn default_2501() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2501() -> std::collections::HashMap { +fn default_2502() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2502() -> std::collections::HashMap { +fn default_2503() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2503() -> Vec> { +fn default_2504() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2504() -> Vec { +fn default_2505() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2505() -> std::collections::HashMap { +fn default_2506() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2506() -> Vec> { +fn default_2507() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2507() -> bool { +fn default_2508() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2508() -> bool { +fn default_2509() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2509() -> Vec { +fn default_2510() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2510() -> std::collections::HashMap { +fn default_2511() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2511() -> String { +fn default_2512() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2512() -> std::collections::HashMap { +fn default_2513() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2513() -> bool { +fn default_2514() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2514() -> bool { +fn default_2515() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2515() -> String { +fn default_2516() -> String { serde_json::from_str("\"no_signal\"").expect("schema default") } -fn default_2516() -> Vec { +fn default_2517() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2517() -> f64 { +fn default_2518() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2518() -> Integer { +fn default_2519() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2519() -> String { +fn default_2520() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2520() -> std::collections::HashMap { - serde_json::from_str("{}").expect("schema default") -} fn default_2521() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } @@ -68182,18 +68184,18 @@ fn default_2522() -> std::collections::HashMap { fn default_2523() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2524() -> String { +fn default_2524() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") +} +fn default_2525() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2525() -> std::collections::HashMap { +fn default_2526() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2526() -> bool { +fn default_2527() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2527() -> std::collections::HashMap { - serde_json::from_str("{}").expect("schema default") -} fn default_2528() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } @@ -68203,54 +68205,57 @@ fn default_2529() -> std::collections::HashMap { fn default_2530() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2531() -> String { +fn default_2531() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") +} +fn default_2532() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2532() -> Vec> { +fn default_2533() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2533() -> Integer { +fn default_2534() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2534() -> String { +fn default_2535() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2535() -> bool { +fn default_2536() -> bool { serde_json::from_str("true").expect("schema default") } -fn default_2536() -> String { +fn default_2537() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2537() -> Vec { +fn default_2538() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2538() -> bool { +fn default_2539() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2539() -> Vec { +fn default_2540() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2540() -> f64 { +fn default_2541() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2541() -> String { +fn default_2542() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2542() -> Integer { +fn default_2543() -> Integer { serde_json::from_str("4096").expect("schema default") } -fn default_2543() -> Integer { +fn default_2544() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2544() -> Option { +fn default_2545() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2545() -> f64 { +fn default_2546() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2546() -> Option { +fn default_2547() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2547() -> Vec { +fn default_2548() -> Vec { serde_json::from_str("[]").expect("schema default") } diff --git a/sdk/rust/tests/registry_contracts.rs b/sdk/rust/tests/registry_contracts.rs index 6adb3a6cbf8..6858c394cd2 100644 --- a/sdk/rust/tests/registry_contracts.rs +++ b/sdk/rust/tests/registry_contracts.rs @@ -467,6 +467,11 @@ fn memory_list() { serde_json::from_str("{\"entries\":[],\"truncated\":false}").unwrap(); let encoded = serde_json::to_value(value).unwrap(); assert!(encoded.is_object()); + assert_eq!( + encoded["rows_read"], + serde_json::from_str::("0").unwrap(), + "memory.list:rows_read" + ); assert_eq!( encoded["total"], serde_json::from_str::("0").unwrap(), diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index 6f1a32d4cf6..799d73bab90 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -6559,6 +6559,7 @@ export interface MemoryListEntry { export interface MemoryListOutput { entries: MemoryListEntry[]; truncated: boolean; + rows_read?: number; total?: number; today?: number; namespace_version?: string; diff --git a/server/memory/api/models_crud.py b/server/memory/api/models_crud.py index 6538520299c..9e8129493d8 100644 --- a/server/memory/api/models_crud.py +++ b/server/memory/api/models_crud.py @@ -901,6 +901,9 @@ class MemoryListOutput(BaseModel): # The matching rows in the requested order; empty on an `unchanged` poll. entries: list[_MemoryListEntry] truncated: bool # true if more entries exist beyond `limit` + # Rows this page read from `offset` before the authority dropped any: the next page's + # offset is `offset + rows_read`, which `len(entries)` understates when rows were dropped. + rows_read: int = 0 # Total rows matching this scope (ignores `limit`), so callers can show # "N of TOTAL". 0 on an `unchanged` poll, which carries no counts. total: int = 0 diff --git a/server/memory/app/query.py b/server/memory/app/query.py index fe4d407b8eb..2b3bcc8f72d 100644 --- a/server/memory/app/query.py +++ b/server/memory/app/query.py @@ -308,6 +308,7 @@ async def _handle_memory_list(input: MemoryListInput) -> MemoryListOutput: ) truncated = len(rows) > input.limit rows = rows[: input.limit] + rows_read = len(rows) rows = await _served_by_authority(input, rows, _served) if _wants_usage(keep): rows = await memory_repo.overlay_usage_totals_many(rows) @@ -426,6 +427,7 @@ async def _handle_memory_list(input: MemoryListInput) -> MemoryListOutput: for r, (pv, pcut) in ((r, _preview_for_list(r, preview_chars)) for r in rows) ], truncated=truncated, + rows_read=rows_read, ), keep, ) diff --git a/tests/unit/test_memory_list_rows_read.py b/tests/unit/test_memory_list_rows_read.py new file mode 100644 index 00000000000..168fe66debf --- /dev/null +++ b/tests/unit/test_memory_list_rows_read.py @@ -0,0 +1,38 @@ +"""A list page says how many rows it read, so a client pages past rows the authority dropped.""" + +from __future__ import annotations + +from typing import Any + +import pytest + +from server.memory import store as memory_repo +from server.memory.api.models_crud import MemoryListInput +from server.memory.app import query as mq + + +@pytest.mark.asyncio +async def test_a_page_of_dropped_rows_still_says_how_many_it_read( + monkeypatch: pytest.MonkeyPatch, +) -> None: + async def nsv(org: str, ns: str) -> int: + return 0 + + async def listed(*a: Any, **k: Any) -> list[Any]: + return [object()] * (k["limit"]) # one more than asked: more rows exist + + async def served(rows: list[Any]) -> list[Any]: + return [] # every row of the page was deleted or rewritten, not yet published + + async def count(identity: Any, **k: Any) -> int: + return 5 + + monkeypatch.setattr(memory_repo, "namespace_version", nsv) + monkeypatch.setattr(memory_repo, "list_by_namespace", listed) + monkeypatch.setattr(memory_repo, "served_rows", served) + monkeypatch.setattr(memory_repo, "count_by_namespace", count) + mq.reset_list_counts_cache() + out = await mq._handle_memory_list( + MemoryListInput(org="o", namespace="n", agent="*", limit=2, offset=2) + ) + assert (out.entries, out.truncated, out.rows_read) == ([], True, 2) From d2c91d011714dbd4f014e7d61e18ad3cbffe8c93 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:44:18 +0530 Subject: [PATCH 039/117] Search lookups page by rows read, send an end-user token no user, and read every page of a key Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 30 ++++++++ frontend/src/lib/memoriesSearch.ts | 79 ++++++++++++++++------ frontend/src/views/Recent.search.test.tsx | 14 ++++ frontend/src/views/assistant/tokenScope.ts | 7 ++ frontend/src/views/memoryListReads.ts | 21 +++--- tests/unit/test_read_scope.py | 9 +++ 6 files changed, 127 insertions(+), 33 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index c0f36ef452f..0abdaeaf14b 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -42,6 +42,36 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(listMemories).not.toHaveBeenCalled(); }); + it("leaves the user out for an end-user token, which the server pins itself", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({ sub: "user:u1", iss: "idp" })); + expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1" }); + const sent = vi.mocked(listMemories).mock.calls[0][0]; + expect(sent.user_id).toBeUndefined(); + expect(sent.session_id).toBe("*"); + }); + + it("reads later pages for a unique key and names its writer", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const other = { memory_key: "deploy_note_2", agent: "claude-desktop", user_id: "u2", session_id: "s2" }; + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [other], rows_read: 1, total: 2, truncated: true } as never) + .mockResolvedValueOnce({ + entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + rows_read: 1, + total: 2, + truncated: false, + } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1", session_id: "s1" }); + expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); + }); + + it("names no writer when the list is not read to its end", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + vi.mocked(listMemories).mockResolvedValue({ entries: [], rows_read: 0, total: 5, truncated: true } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + expect(listMemories).toHaveBeenCalledTimes(1); + }); + it("keeps the wildcards for a namespace-wide token", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); await resolveSearchWriter(identity, hit, ABORT); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index d53571e7ba9..5474ff8f5a6 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -3,8 +3,15 @@ // holds the query (memory.list `contains`, newest first), then the ranked hits they do // not already hold. -import { listMemories, storedToken, type Identity, type SearchHit } from "../api"; -import { tokenReadScope } from "../views/assistant/tokenScope"; +import { + listMemories, + storedToken, + type Identity, + type MemoryListEntry, + type MemoryListResponse, + type SearchHit, +} from "../api"; +import { endUserToken, tokenReadScope } from "../views/assistant/tokenScope"; import { SENTINEL_AGENTS } from "./format"; /** Keyword matches a search shows ahead of the ranked hits (a viewer's list page is 100). */ @@ -16,6 +23,25 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: return Boolean(r.agent && !SENTINEL_AGENTS.has(r.agent) && r.agent !== "_shared" && r.user_id && r.session_id); } +/** The pages of one list read, until the list ends or `MAX_PAGES` are read. The server may + * cap a page below `limit` and drop rows it no longer serves, so the next offset is the rows + * it read, and a page that read none ends the read. The last page yielded says whether + * the list was read to its end (`done`). */ +const MAX_PAGES = 10; +export async function* listPages( + id: Identity, + limit: number, + opts: Parameters[2] & { signal: AbortSignal }, +): AsyncGenerator { + for (let offset = 0, n = 0; n < MAX_PAGES && !opts.signal.aborted; n++) { + const page = await listMemories(id, limit, { ...opts, offset }); + const read = page.rows_read ?? page.entries.length; + offset += read; + yield { ...page, done: !read || offset >= page.total }; + if (!read || offset >= page.total) return; + } +} + export type SearchWriter = Pick; /** Older search responses name the agent but may omit its user or session. */ @@ -31,28 +57,41 @@ export async function resolveSearchWriter( // A token that narrows reads is refused the `*` wildcard (`resolve_read_filters`): send the // pinned user, and give up when no user (or, for an own-session token, no session) is known. const scope = tokenReadScope(storedToken()); - const uid = user_id || scope?.readUserId || (scope?.readScope ? "" : "*"); + // An end-user token is pinned by its issuer, which its claims do not name: leave the user + // out and the server fills in the pinned one (it refuses `*`). + const uid = user_id || scope?.readUserId || (endUserToken(storedToken()) ? undefined : scope?.readScope ? "" : "*"); const sid = session_id || (scope?.readScope === "own_session" ? "" : "*"); - if (!uid || !sid) return; + if (uid === "" || !sid) return; const namespace = hit.namespace || identity.namespace; - const page = await listMemories({ ...identity, namespace, user_id: uid, session_id: sid }, KEYWORD_PAGE, { - agent, - prefix: hit.memory_key, - include_profile: true, - fields: ["agent", "user_id", "session_id"], - signal, - }).catch(() => null); - if (!page || signal.aborted || page.truncated || page.total > page.entries.length) return; - const matches = page.entries.filter( - (row) => - row.memory_key === hit.memory_key && - (!row.agent || row.agent === agent) && - (!user_id || !row.user_id || row.user_id === user_id) && - (!session_id || !row.session_id || row.session_id === session_id), - ); + // The key is unique only when every row under its prefix has been read. + const matches: MemoryListEntry[] = []; + let done = false; + try { + for await (const page of listPages({ ...identity, namespace, user_id: uid, session_id: sid }, KEYWORD_PAGE, { + agent, + prefix: hit.memory_key, + include_profile: true, + fields: ["agent", "user_id", "session_id"], + signal, + })) { + matches.push( + ...page.entries.filter( + (row) => + row.memory_key === hit.memory_key && + (!row.agent || row.agent === agent) && + (!user_id || !row.user_id || row.user_id === user_id) && + (!session_id || !row.session_id || row.session_id === session_id), + ), + ); + done = page.done; + if (matches.length > 1) return; + } + } catch { + return; + } const [row] = matches; - if (matches.length === 1 && row && namesWriter(row)) { + if (done && !signal.aborted && matches.length === 1 && row && namesWriter(row)) { return { agent: row.agent, user_id: row.user_id, session_id: row.session_id, namespace }; } } diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index 00317beeb66..b93ef10a8e0 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -282,6 +282,20 @@ describe("Recent search with one key written by two sessions", () => { expect(await screen.findByText(SENSITIVE_LABEL)).toBeInTheDocument(); }); + it("pages past a page whose rows the server read but no longer serves", async () => { + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + if (!opts?.prefix) + return { entries: opts?.contains ? [] : [written("two")], total: 1, today: 0, truncated: false }; + const offset = opts.offset ?? 0; + const entries = + offset === 0 ? [] : [written("one", { sensitivity: "high", version: 2, version_text: "2", value: null })]; + return { entries, rows_read: offset === 0 ? 10 : 1, total: 11, today: 0, truncated: offset === 0 }; + }); + vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); + await search(); + expect(await screen.findByText(SENSITIVE_LABEL)).toBeInTheDocument(); + }); + it("uses a list preview when an unloaded ranked writer's row becomes high sensitivity", async () => { vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { const entries = opts?.prefix diff --git a/frontend/src/views/assistant/tokenScope.ts b/frontend/src/views/assistant/tokenScope.ts index 83b32dcd623..2bd9ce1fa51 100644 --- a/frontend/src/views/assistant/tokenScope.ts +++ b/frontend/src/views/assistant/tokenScope.ts @@ -10,6 +10,13 @@ export interface TokenReadScope { readUserId: string | null; } +/** Whether the token is an end user's: `sub: user:` with no namespace or service-account + * claim. The server pins its reads to that user, which `tokenReadScope` cannot see. */ +export function endUserToken(jwt: string | null | undefined): boolean { + const json = tokenPayload(jwt); + return typeof json?.sub === "string" && json.sub.startsWith("user:") && !("namespaces" in json) && !("sa" in json); +} + /** The token's read scope, read without verification: it gates what the page offers, never * what the server answers. Null for a missing or unparseable token. */ export function tokenReadScope(jwt: string | null | undefined): TokenReadScope | null { diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 97f5610beed..370d1dbabfd 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -11,7 +11,7 @@ import { CARD_VALUE_CHARS } from "../components/MemoryCard"; import { errorRequestId } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; import { useAbortableEffect, useVisiblePoll } from "../lib/hooks"; -import { KEYWORD_PAGE, keywordThenRanked, namesWriter, rowIdentity, rowIds } from "../lib/memoriesSearch"; +import { KEYWORD_PAGE, keywordThenRanked, listPages, namesWriter, rowIdentity, rowIds } from "../lib/memoriesSearch"; // The fields the page and its cards read. Field names are a quarter of a row, so a field // the page does not read costs on every row. `sensitivity`, which marks a high row sent @@ -78,20 +78,15 @@ async function readSearchPreview( const writer = namesWriter(hit); const scope = writer ? { ...identity, user_id: hit.user_id, session_id: hit.session_id } : identity; const key = rowIdentity(identity.namespace, hit); - for (let offset = 0; !signal.aborted; ) { - const page = await listMemories(scope, KEYWORD_PAGE, { - agent: writer ? hit.agent : undefined, - prefix: hit.memory_key, - offset, - fields: MEMORIES_LIST_FIELDS, - previewChars: CARD_VALUE_CHARS, - signal, - }); + for await (const page of listPages(scope, KEYWORD_PAGE, { + agent: writer ? hit.agent : undefined, + prefix: hit.memory_key, + fields: MEMORIES_LIST_FIELDS, + previewChars: CARD_VALUE_CHARS, + signal, + })) { const entry = page.entries.find((row) => rowIds(identity.namespace, row).includes(key)); if (entry) return { ...entry, value: entry.value ?? null }; - // The server may cap a page below KEYWORD_PAGE: advance by the rows it returned. - offset += page.entries.length; - if (!page.entries.length || offset >= page.total) break; } return null; } diff --git a/tests/unit/test_read_scope.py b/tests/unit/test_read_scope.py index f65e049908e..f275dbfdd2f 100644 --- a/tests/unit/test_read_scope.py +++ b/tests/unit/test_read_scope.py @@ -165,6 +165,15 @@ def test_pinned_user_fills_an_absent_body_user_and_narrows(): assert (rf.scope, rf.user_id) == ("own_user", "alice") +def test_an_end_user_token_fills_an_absent_user_and_refuses_the_wildcard(): + # the dashboard's legacy-hit lookup sends no user to such a token, never `*` + auth = _auth(read_scope="own_user", read_user_id="alice", subject="user:alice") + rf = resolve_read_filters(requested=None, user_id="-", session_id="*", auth=auth) + assert (rf.scope, rf.user_id, rf.session_id) == ("own_user", "alice", "*") + with pytest.raises(AuthInsufficientError): + resolve_read_filters(requested=None, user_id="*", session_id="*", auth=auth) + + def test_pinned_user_refuses_a_body_naming_another_user(): auth = _auth(read_user_id="alice") with pytest.raises(AuthInsufficientError): From 81fcc99d31a561eccae159e2fc174cf625676324 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 11:44:18 +0530 Subject: [PATCH 040/117] The list-fields test counts the fifteen fields the page names and skips comments Signed-off-by: Krishna Dobhal --- tests/unit/test_list_answers_what_the_page_asked.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_list_answers_what_the_page_asked.py b/tests/unit/test_list_answers_what_the_page_asked.py index 58304586c46..3d32ac4c6bc 100644 --- a/tests/unit/test_list_answers_what_the_page_asked.py +++ b/tests/unit/test_list_answers_what_the_page_asked.py @@ -124,11 +124,12 @@ def test_the_memories_page_asks_for_the_fields_it_renders() -> None: "];", reads.index("MEMORIES_LIST_FIELDS = [") ) ] - fields = set(json.loads("[" + fields_src.split("[", 1)[1].rstrip().rstrip(",") + "]")) + body = re.sub(r"//[^\n]*", "", fields_src.split("[", 1)[1]) + fields = set(json.loads("[" + body.rstrip().rstrip(",") + "]")) assert "entities" not in fields and {"memory_key", "value", "tags", "verification"} <= fields - # The thirteen fields the page names. `sensitivity`, which marks a high row sent without + # The fifteen fields the page names. `sensitivity`, which marks a high row sent without # its value, comes with every entry: named, it would 422 on an older replica. - assert len(fields) == 13 and "sensitivity" not in fields + assert len(fields) == 15 and "sensitivity" not in fields assert "sensitivity" in read_projection.LIST_ENTRY_ALWAYS known = set(memory_crud._MemoryListEntry.model_fields) assert fields <= known, sorted(fields - known) From 7a854c27ba47dabc2ed0dbdef0086edbbd3b65e0 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:02:58 +0530 Subject: [PATCH 041/117] A file link beside a stale pending move is kept with it Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_recheck.py | 3 +- tests/unit/test_memory_code_links.py | 43 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 582653a9e8a..62c3eb20ea0 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -654,8 +654,9 @@ async def _recheck_pending( moves += await _resolve_pending( org, cns, head, files, result, [r for r in rows if not r["path"]] ) + moves = await _current_moves(org, moves) # a drop beside a stale move must not outlive it moves += await _file_links_beside(org, cns, moves) - await _write_moves(await _current_moves(org, moves), head) + await _write_moves(moves, head) result.rechecked += len(moves) if nxt != after: await cursor.write({"before": before, "after": list(nxt)} if nxt else {}) diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 69b925815fd..9a5e0d9446e 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6324,6 +6324,49 @@ async def no_cursor(name): assert seen == {"reanchor": [parked], "named": [named]} # only a named row can expire +@pytest.mark.asyncio +async def test_a_file_link_is_not_dropped_beside_a_move_the_current_check_discards( + monkeypatch, +) -> None: + stale = code_link_recheck.Move(_parked("", "a::f"), None) + drop = code_link_recheck.Move(_parked("a.py", ""), None) + written: list[Any] = [] + + async def pending(org, cns, **kw): + return [], None + + async def resolve_pending(org, cns, head, files, result, rows): + return [stale] + + async def reanchor(*a, **k): + return [] + + async def discard_stale(org, moves): + return [m for m in moves if m is not stale] + + async def beside(org, cns, moves): + return [drop] if moves else [] # a drop is built only for a move that stands + + async def write(moves, head): + written.extend(moves) + + async def no_cursor(name): + return "" + + monkeypatch.setattr(code_links.store, "pending", pending) + monkeypatch.setattr(code_links.code, "link_cursor", no_cursor) + monkeypatch.setattr(code_link_recheck, "_reanchor", reanchor) + monkeypatch.setattr(code_link_recheck, "_resolve_pending", resolve_pending) + monkeypatch.setattr(code_link_recheck, "_current_moves", discard_stale) + monkeypatch.setattr(code_link_recheck, "_file_links_beside", beside) + monkeypatch.setattr(code_link_recheck, "_write_moves", write) + files = code_link_pass.RepoReads("o", "code-a") + await code_link_recheck._recheck_pending( + "o", "code-a", "c2", files, code_link_pass.PassResult() + ) + assert written == [] + + @pytest.mark.asyncio async def test_a_pass_sets_its_cursor_before_reading_links_and_clears_it_after_the_checkpoint( monkeypatch, From 21e7ea29a03d6b6c59d0603fabc40b7243240121 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:02:58 +0530 Subject: [PATCH 042/117] A score-sorted list page says how many rows it read, and a page reading none falls back to its entries Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 10 ++++++++++ frontend/src/lib/memoriesSearch.ts | 2 +- server/memory/app/query.py | 2 ++ tests/unit/test_memory_small_defects.py | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 0abdaeaf14b..3c594ea89d4 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -65,6 +65,16 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); }); + it("advances by the entries when the server reports no rows read", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = (k: string) => ({ memory_key: k, agent: "claude-desktop", user_id: "u1", session_id: "s1" }); + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [row("x")], rows_read: 0, total: 2, truncated: true } as never) + .mockResolvedValueOnce({ entries: [row("deploy_note")], rows_read: 0, total: 2, truncated: false } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1" }); + expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); + }); + it("names no writer when the list is not read to its end", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); vi.mocked(listMemories).mockResolvedValue({ entries: [], rows_read: 0, total: 5, truncated: true } as never); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 5474ff8f5a6..1b5a464066c 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -35,7 +35,7 @@ export async function* listPages( ): AsyncGenerator { for (let offset = 0, n = 0; n < MAX_PAGES && !opts.signal.aborted; n++) { const page = await listMemories(id, limit, { ...opts, offset }); - const read = page.rows_read ?? page.entries.length; + const read = page.rows_read || page.entries.length; offset += read; yield { ...page, done: !read || offset >= page.total }; if (!read || offset >= page.total) return; diff --git a/server/memory/app/query.py b/server/memory/app/query.py index 2b3bcc8f72d..3c01b7f7a57 100644 --- a/server/memory/app/query.py +++ b/server/memory/app/query.py @@ -533,6 +533,7 @@ async def _list_by_score( if input.quotas: rows_dict = _within_quotas(rows_dict, input.quotas, input.limit + 1) truncated = len(rows_dict) > input.limit + rows_read = min(len(rows_dict), input.limit) rows_dict = await memory_repo.served_rows( [{**r, "org": input.org, "namespace": input.namespace} for r in rows_dict[: input.limit]] ) @@ -546,6 +547,7 @@ async def _list_by_score( total=score_total, entries=[_score_entry(r) for r in rows_dict], truncated=truncated, + rows_read=rows_read, ) diff --git a/tests/unit/test_memory_small_defects.py b/tests/unit/test_memory_small_defects.py index f71432f1351..e8d44e7bf57 100644 --- a/tests/unit/test_memory_small_defects.py +++ b/tests/unit/test_memory_small_defects.py @@ -89,6 +89,7 @@ async def test_list_by_score_drops_the_wildcard_axes_and_keeps_the_named_ones(mo assert "session_id = {sid:String}" in sql and params["sid"] == "-" assert "agent, user_id, session_id," in sql, "the writer columns ride the score read" assert [e.agent for e in out.entries] == ["reviewer", "bot"] and out.total == 2 + assert out.rows_read == 2, "a client pages by the rows the score read returned" ch.calls.clear() await mq._handle_memory_list( From c3e71b986cdfcd6fd9ac613679bcadd0ecb4d556 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:09:12 +0530 Subject: [PATCH 043/117] A lesson served from trunk's state because the branch was unreadable gets no positive code guidance Signed-off-by: Krishna Dobhal --- server/memory/app/code_plane_reads.py | 7 ++++++- server/memory/app/for_file.py | 11 +++++++++-- tests/unit/test_memory_code_plane_reads.py | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/server/memory/app/code_plane_reads.py b/server/memory/app/code_plane_reads.py index a1c2dda2cdf..5bff2bd0d99 100644 --- a/server/memory/app/code_plane_reads.py +++ b/server/memory/app/code_plane_reads.py @@ -109,11 +109,13 @@ async def lessons_for_symbol( links = await current_links(org, candidates) if not links: return [] + trunk_only: frozenset[str] = frozenset() here = await _definitions_at(org, code_namespace, head, paths, qualified_name) if here is None: if fresh_at_commit: return [] matched = _as_trunk_has_it(links, qualified_name) + trunk_only = frozenset(a["memory_id"] for a, _, _ in matched) else: matched = _matched( links, here, on_trunk=code_namespace == trunk, require_fingerprint=bool(fresh_at_commit) @@ -161,7 +163,10 @@ async def lessons_for_symbol( out[row["mid"]] = (rank, row, lesson) ranked = sorted(out.values(), key=lambda x: x[0])[:limit] await guided_file_rows( - org, [row for _, row, _ in ranked], local_code_changes=local_code_changes + org, + [row for _, row, _ in ranked], + local_code_changes=local_code_changes, + unchecked=trunk_only, # the branch's files were not read: trunk's check is not theirs ) return fit_symbol_lessons( [lesson | {"use_guidance": row["use_guidance"].model_dump()} for _, row, lesson in ranked] diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index ed3ca68af22..bde550e6f87 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -758,9 +758,14 @@ async def current_file_rows(org: str, rows: list[dict[str, Any]]) -> list[dict[s async def guided_file_rows( - org: str, rows: list[dict[str, Any]], *, local_code_changes: set[str] | None = None + org: str, + rows: list[dict[str, Any]], + *, + local_code_changes: set[str] | None = None, + unchecked: frozenset[str] = frozenset(), ) -> None: - """Project guidance from visible memory revisions, independently of their path links.""" + """Project guidance from visible memory revisions, independently of their path links. + A row in `unchecked` was served from trunk's state, so no code state vouches for it.""" code_states, source_states = await asyncio.gather( guidance_code_states(org, rows), guidance_source_states(org, rows) ) @@ -771,6 +776,8 @@ async def guided_file_rows( and state not in code_change.DEMOTED ): state = "changed" + if unchecked and str(row["memory_id"]) in unchecked and state not in code_change.DEMOTED: + state = "unknown" row["use_guidance"] = guidance_for_row( row, code_state=state, diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index fde7a7bc6b1..fcb954a1cb5 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -443,6 +443,23 @@ async def test_a_host_still_cloning_the_mirror_serves_the_lesson_as_trunk_has_it assert (lesson["code_state"], lesson["suggestion"]) == ("changed", "s") +@pytest.mark.asyncio +async def test_a_fallback_to_trunks_state_gives_no_positive_guidance(monkeypatch) -> None: + + branch = [("src/a.py", "src.a::Reader::read", "h1")] + + for kw in ({"parse_s": settings.memory_code_plane_parse_timeout_s * 2}, {"has_mirror": False}): + (lesson,) = await _lessons( + monkeypatch, [_link("m1")], [_excerpt("m1", "k1")], branch, ns="code-a-26-8", **kw + ) + + assert lesson["code_state"] == "fresh" # trunk's check, still shown + + assert lesson["use_guidance"]["freshness"]["code"] == "unknown" + + assert lesson["use_guidance"]["next_step"] != "follow_if_applicable" + + @pytest.mark.asyncio async def test_a_lesson_is_the_symbols_own_not_a_namesakes(monkeypatch) -> None: links = [_link("m1", qn="src.a::Writer::read"), _link("m2"), _link("m3")] From a4b986c6dd2c0de5cd0dfe0252c2a4f9974bca60 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:10:34 +0530 Subject: [PATCH 044/117] A parked search hit drops the change commit cached on page one when it refreshes its code state Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 2 ++ tests/unit/test_search_use_guidance.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index d07275c23f9..425b35b8bc9 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -301,5 +301,7 @@ async def attach_search_guidance( if parked: # Link state can change while the served memory revision stays the same. hit.code_state = worst([hit.use_guidance.freshness.code]) + # the commit the first page cached may not be the one that state rests on now + hit.code_changed_since = "" kept.append(hit) return kept diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index 1f0c9344996..874c900c87e 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -87,12 +87,14 @@ async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: monkeypatch.setattr(guidance, "guidance_code_states", code_states) hit = _hit() hit.code_state = "missing" + hit.code_changed_since = "commit-a" # the page-one state, since moved or unreadable await guidance.attach_search_guidance(_INPUT, [hit], snapshot_only=True) parked = search_pages.unparked(search_pages._parked(hit)) assert parked is not None assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [parked] assert parked.use_guidance is not None and parked.use_guidance.freshness.code == state assert parked.code_state == (state if state in ("changed", "fresh") else "") + assert parked.code_changed_since == "" @pytest.mark.asyncio From 573d59517da1bc9772b9e159b2c90256addfa138 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:33:22 +0530 Subject: [PATCH 045/117] A link writer inserts under the repository's recheck lease at the head it built at The writer no longer parks links as pending and promotes them. It takes the repository's recheck lease, checks the indexed head is still the one the links were built at, and inserts; a pass that checked a later head makes it raise LeaseBusy and the queue page is rebuilt. A pass that starts later sees the links. No link carries a state that waits for a pass, so a previous build that resolves pending rows by name has no path-bearing row to re-anchor. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 35 +- docs/architecture/rolling-upgrades.md | 11 +- server/memory/app/code_link_pass.py | 8 +- server/memory/app/code_link_recheck.py | 91 +---- server/memory/app/code_links.py | 63 ++-- tests/integration/test_memory_code_links.py | 4 +- tests/unit/test_memory_code_links.py | 359 +++---------------- 7 files changed, 121 insertions(+), 450 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 3350d981725..3571d83b677 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -683,28 +683,19 @@ No source text is fetched from a network or fabricated to fill a gap. ## Memory links written during a recheck -A recheck pass writes its `recheck` cursor before it snapshots the links it follows, and -clears the cursor only after it moves the checked head. A writer that links a memory -inserts each link as `pending` first. It then reads the cursor and the checked head, and -inserts the link again as fresh only when no pass is running and the checked head is -unset or is the commit the link was built at. The pass follows no pending link, so the -writer reads both again after the promotion and parks the link once more if a pass has -begun or the head has moved. A pass that snapshotted before the promotion wrote its -cursor before it, and clears it only after it moves the head, so that read sees the -cursor or the new head; a pass that snapshots after the promotion follows the fresh -link. `pending` reads as unknown. The next recheck re-anchors a pending link that keeps -its path at the current head, from the commit it was built at. A path that never parses -expires after `memory_code_links_pending_days`, as a pathless pending link does. A crash -between the inserts leaves the link pending, never fresh; a crash between the checked -head and the cursor clear is cleared by the next pass. Each link is written two or three -times, in batches per call; that cost is accepted because it is bounded by the links a -write creates and keeps a crash or a racing pass from ever leaving a link fresh. - -The fence reads run under `sequential_reads()`, so a cursor or checked head another -replica wrote is seen. That holds when the state writes are visible to a -sequential read, as `loom doctor` checks for `select_sequential_consistency`; a -deployment where they are not can serve a link as fresh that a pass on another replica -did not see. +A recheck pass follows a repository's links from its checked head to its indexed head +under the repository's lease, and a writer that links a memory inserts its links under +the same lease. A pass that starts after the insert reads the new links. A pass that ran +before the writer took the lease checked a head the writer's links were not built at, +so the writer finds the indexed head moved, inserts nothing and raises `LeaseBusy`; the +link worker retries the queue page, which builds the links at the new head. A writer +that finds the lease held waits `memory_code_links_interval_seconds` for the next pass +the same way. No link is stored in a state that waits for a pass, and the read side +trusts a link only when the checked head is the indexed head. + +The indexed head is read under `sequential_reads()`, so a head another replica indexed +is seen. That holds when the state writes are visible to a sequential read, as +`loom doctor` checks for `select_sequential_consistency`. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 7ae02ac4116..d7e851d7ef2 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1064,12 +1064,11 @@ separate mirror-content cleanup before serving; this account procedure does not ### Memory links written during a recheck -A build that parks late-inserted links writes the recheck cursor before it reads links -and clears it after the checked head moves. While replicas of the previous build still -run the recheck pass, they write the cursor late, clear it early and never park, so the -write-side check can miss a link inserted then. Such a link is served as fresh until the -next pass of the new build rechecks it. The window ends when the last previous-build -replica is replaced; the new build carries no code for it. +A build that takes the repository's recheck lease to insert a memory's links writes no +new row shape and no setting. Replicas of the previous build insert without the lease, so +while they run the link worker a link can be inserted just after a pass snapshotted and +be served as fresh until the next pass of any build rechecks it. The window ends when the +last previous-build replica is replaced; the new build carries no code for it. ## Independent proposal approval diff --git a/server/memory/app/code_link_pass.py b/server/memory/app/code_link_pass.py index a382837c5a4..3b87a31bb34 100644 --- a/server/memory/app/code_link_pass.py +++ b/server/memory/app/code_link_pass.py @@ -3,6 +3,7 @@ from __future__ import annotations +import hashlib import json import logging from collections import OrderedDict @@ -397,7 +398,6 @@ def unparsed_cursor(org: str, namespace: str) -> Cursor[list[str]]: return Cursor(f"unparsed/{org}/{namespace}", []) -def recheck_cursor(org: str, namespace: str) -> Cursor[dict[str, str]]: - """The head a repository's recheck is following and its last path done: set from the - pass's start until after its checkpoint, so a link writer can see a pass in flight.""" - return Cursor(f"recheck/{org}/{namespace}", {}) +def lock_name(org: str, namespace: str) -> str: + """The lease a repository's recheck pass holds, and a writer of its links takes to insert.""" + return "code_links/" + hashlib.sha256(f"{org}\x1f{namespace}".encode()).hexdigest()[:40] diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 62c3eb20ea0..2635fbdcb9f 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -4,13 +4,12 @@ from __future__ import annotations import asyncio -import hashlib import itertools from collections import defaultdict from dataclasses import dataclass from functools import cache from time import time_ns -from typing import Any, cast +from typing import Any from server.code.app import memory_links as code from server.code.domain.anchor import ( @@ -91,7 +90,7 @@ async def recheck_all(result: link_pass.PassResult) -> None: granted = (left + rest - 1) // rest budget = link_pass.Budget(judgements=granted) try: - async with link_pass.repository_locks.lease(_lock_name(org, cns)): + async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): await _recheck_repository(org, cns, budget, result) except LeaseBusy: pass # another pass is checking this repository @@ -110,15 +109,11 @@ async def recheck_repository(org: str, cns: str) -> link_pass.PassResult | None: if not settings.memory_code_links_enabled or (org, cns) not in await store.code_namespaces(): return None result = link_pass.PassResult() - async with link_pass.repository_locks.lease(_lock_name(org, cns)): + async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): await _recheck_repository(org, cns, link_pass.Budget(judgements=0), result) return result -def _lock_name(org: str, cns: str) -> str: - return "code_links/" + hashlib.sha256(f"{org}\x1f{cns}".encode()).hexdigest()[:40] - - async def _recheck_repository( org: str, cns: str, budget: link_pass.Budget, result: link_pass.PassResult ) -> None: @@ -129,14 +124,12 @@ async def _recheck_repository( await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) - if head and head == checked and await link_pass.recheck_cursor(org, cns).read(): - await link_pass.recheck_cursor(org, cns).clear() # a crash left it after the checkpoint if head and head != checked: - cut_at = (await link_pass.recheck_cursor(org, cns).read()).get("head", "") + cut_at = (await _progress(org, cns).read()).get("head", "") if cut_at and cut_at != head and not await files.has(cut_at): # gone with a rewrite: what that pass already wrote is in no diff, so every # link is rechecked, as after a force-push - await link_pass.recheck_cursor(org, cns).clear() + await _progress(org, cns).clear() await code.set_checked_head(org, cns, "") # a cut full recheck resumes as one checked = "" elif cut_at and cut_at != head: @@ -147,11 +140,15 @@ async def _recheck_repository( checked = cut_at await _follow(org, cns, checked, head, files, result) await code.set_checked_head(org, cns, head) - await link_pass.recheck_cursor(org, cns).clear() # after the checkpoint: see code_links result.wide_ranges += files.wide_ranges await policy.apply_policies(org, cns, head, files, budget, result) +def _progress(org: str, cns: str) -> link_pass.Cursor[dict[str, str]]: + """The cursor a repository's recheck records its head and last path done in.""" + return link_pass.Cursor(f"recheck/{org}/{cns}", {}) + + # paths rechecked between two writes: a pass the deadline cuts keeps what it did _PATHS_PER_WRITE = 50 @@ -186,11 +183,8 @@ async def _follow( """Recheck, path by path, the links `checked..head` may have changed (all of them without a range), writing every `_PATHS_PER_WRITE` paths and recording the last one done, so a cut pass resumes.""" - progress = link_pass.recheck_cursor(org, cns) + progress = _progress(org, cns) done = await progress.read() - after = str(done.get("after", "")) if done.get("head") == head else "" - # in flight before any link is read: a writer that inserts later sees this cursor - await progress.write({"head": head, "after": after}) changed = await files.range(checked, head) if checked else None kept = changed.paths if changed is not None else None # old and new paths: a cut pass may have moved links to a new path already @@ -206,14 +200,12 @@ async def _follow( made = [c for c in await code.commits_after(org, cns, checked, head) if c != head] if made: rows += await store.for_commits(org, [cns], made) - # a pending link waits for `_reanchor`, not for a range recheck - unique = { - (a["path"], a["qualified_name"], a["memory_id"]): a for a in rows if a["state"] != "pending" - } + unique = {(a["path"], a["qualified_name"], a["memory_id"]): a for a in rows} by_path: dict[str, list[LinkRow]] = defaultdict(list) for a in unique.values(): if a["path"]: by_path[a["path"]].append(a) + after = str(done.get("after", "")) if done.get("head") == head else "" paths = [p for p in sorted(by_path) if p > after] unparsed, failed = await _unparsed(org, cns), set[str]() for i in range(0, len(paths), _PATHS_PER_WRITE): @@ -227,6 +219,7 @@ async def _follow( if len(unparsed) > known: # owed before the cursor moves past them await _set_unparsed(org, cns, unparsed) await progress.write({"head": head, "after": part[-1]}) + await progress.clear() if failed: result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") @@ -274,8 +267,7 @@ async def _retry_unparsed( return by_commit: dict[str, list[LinkRow]] = defaultdict(list) for a in await store.for_paths(org, [cns], sorted(paths)): - if a["state"] != "pending": - by_commit[a["checked_commit"]].append(a) + by_commit[a["checked_commit"]].append(a) still, failed = set[str](), set[str]() for commit, rows in by_commit.items(): changed = await files.range(commit, head) if commit else None @@ -294,11 +286,11 @@ async def _retry_unparsed( async def _unparsed(org: str, cns: str) -> set[str]: - return set(await link_pass.unparsed_cursor(org, cns).read()) + return set(await link_pass.Cursor[list[str]](f"unparsed/{org}/{cns}", []).read()) async def _set_unparsed(org: str, cns: str, paths: set[str]) -> None: - await link_pass.unparsed_cursor(org, cns).write(sorted(paths)) + await link_pass.Cursor[list[str]](f"unparsed/{org}/{cns}", []).write(sorted(paths)) async def _lost(org: str, cns: str, paths: set[str]) -> list[LinkRow]: @@ -637,7 +629,7 @@ async def _elsewhere(org: str, cns: str, lost: dict[str, str]) -> dict[str, list async def _recheck_pending( org: str, cns: str, head: str, files: link_pass.RepoReads, result: link_pass.PassResult ) -> None: - cursor = link_pass.Cursor[dict[str, Any]](f"{_lock_name(org, cns)}/pending", {}) + cursor = link_pass.Cursor[dict[str, Any]](f"{link_pass.lock_name(org, cns)}/pending", {}) state = await cursor.read() stored_after = state.get("after") after = (int(stored_after[0]), str(stored_after[1])) if stored_after else None @@ -650,10 +642,7 @@ async def _recheck_pending( before=before, limit=int(settings.memory_code_links_batch), ) - moves = await _reanchor(org, cns, head, files, [r for r in rows if r["path"]]) - moves += await _resolve_pending( - org, cns, head, files, result, [r for r in rows if not r["path"]] - ) + moves = await _resolve_pending(org, cns, head, files, result, rows) moves = await _current_moves(org, moves) # a drop beside a stale move must not outlive it moves += await _file_links_beside(org, cns, moves) await _write_moves(moves, head) @@ -662,48 +651,6 @@ async def _recheck_pending( await cursor.write({"before": before, "after": list(nxt)} if nxt else {}) -async def _reanchor( - org: str, cns: str, head: str, files: link_pass.RepoReads, rows: list[PendingLink] -) -> list[Move]: - """The links a writer parked as pending because a recheck pass may not have seen them - (they keep their path). Each is rechecked at `head` from the commit it was built at, - as the fresh link it was, and written whatever the result: unchanged is fresh at the - head, a deleted path is `missing`. A path that does not parse stays pending until the - pending days pass, then the row is dropped as a pathless one is.""" - if not head or not rows: - return [] - by_commit: dict[str, list[LinkRow]] = defaultdict(list) - for r in rows: - by_commit[r["checked_commit"]].append(cast(LinkRow, {**r, "state": "fresh"})) - moves: list[Move] = [] - for commit, group in by_commit.items(): - by_path: dict[str, list[LinkRow]] = defaultdict(list) - for a in group: - by_path[a["path"]].append(a) - changed = await files.range(commit, head) if commit else None - unparsed = set[str]() - found = await _recheck_paths( - org, cns, by_path, sorted(by_path), changed, head, files, unparsed, set() - ) - moved = {id(m.row) for m in found} - moves += found - await store.insert( - store.tombstones( - [ - r - for r in rows - if r["checked_commit"] == commit and r["expired"] and r["path"] in unparsed - ] - ) - ) - moves += [ - Move(a, link_pass.link_of(a)) - for a in group - if id(a) not in moved and a["path"] not in unparsed - ] - return moves - - async def _file_links_beside(org: str, cns: str, moves: list[Move]) -> list[Move]: """The drops of the file links beside the definitions `moves` link: a memory's link to a file goes once it has one to a definition in that file.""" diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 754898558ad..211b7f43112 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -18,7 +18,7 @@ import time from collections import defaultdict from collections.abc import Mapping, Sequence -from contextlib import AbstractAsyncContextManager +from contextlib import AbstractAsyncContextManager, AsyncExitStack from dataclasses import dataclass, replace from typing import Any @@ -45,6 +45,7 @@ from server.memory.domain.code_link_keys import IDENTITY, QueuePosition from server.memory.store import code_links as store from server.memory.store.code_links import LinkRow +from server.memory.store.key_write_lock import LeaseBusy from server.settings import settings # names and links read of one memory at most @@ -148,52 +149,32 @@ async def _link_org( result.linked += len(rows_out) result.unlinked += len(gone) linked += [r["mid"] for r in memories] - await _insert_unseen(out) + await _insert_at_head(out) if linked and rereads: read = {r["mid"]: r["inputs"] for memories in todo.values() for r in memories} await _relink_rewritten(org, linked, read, result, rereads - 1) -async def _insert_unseen(inserted: list[LinkRow]) -> None: - """Insert `inserted`, a link a recheck pass may have missed parked as `pending` first, - promoted if the fence reads clear it and parked again if they change after +async def _insert_at_head(inserted: list[LinkRow]) -> None: + """Insert `inserted` while holding each linked repository's recheck lease, and only if + its indexed head is still the one the links were built at. A pass that checked a later + head ran before the lease and would never have seen them: LeaseBusy, the queue + retries and builds at the new head. A pass that starts after reads them (docs/architecture/code-index-architecture.md).""" - guard = [ - r for r in inserted if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None - ] - parked = {id(r): store.link_row(r, follows=r["version"], state="pending") for r in guard} - await store.insert([parked.get(id(r), r) for r in inserted]) - by_repo: dict[tuple[str, str], list[LinkRow]] = defaultdict(list) - for r in guard: - by_repo[r["org"], r["code_namespace"]].append(r) - promoted: list[tuple[LinkRow, tuple[str, str], str]] = [] - with sequential_reads(): - fences = {k: await _fence(*k) for k in by_repo} - for key, rows in by_repo.items(): - running, checked = fences[key] - promoted += [ - (store.link_row(r, follows=parked[id(r)]["version"]), key, checked) - for r in rows - if not running and checked in ("", r["checked_commit"]) - ] - if not promoted: - return - await store.insert([row for row, _, _ in promoted]) - # a pass skips pending rows: one that began between the fence reads and the promotion - # left these fresh at the old head, so read again and park what moved - after = {k: await _fence(*k) for k in {key for _, key, _ in promoted}} - back = [ - store.link_row(row, follows=row["version"], state="pending") - for row, key, checked in promoted - if after[key] != (False, checked) - ] - if back: - await store.insert(back) - - -async def _fence(org: str, cns: str) -> tuple[bool, str]: - """Whether a recheck pass is in flight, and the head its last pass checked.""" - return bool(await link_pass.recheck_cursor(org, cns).read()), await code.checked_head(org, cns) + heads: dict[tuple[str, str], set[str]] = defaultdict(set) + for r in inserted: + if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None: + heads[r["org"], r["code_namespace"]].add(r["checked_commit"]) + async with AsyncExitStack() as held: + for key in sorted(heads): + await held.enter_async_context( + link_pass.repository_locks.lease(link_pass.lock_name(*key)) + ) + with sequential_reads(): + now = await code.indexed_head(*key) + if heads[key] != {now}: + raise LeaseBusy(f"{key[0]}/{key[1]} moved to {now} while its links were built") + await store.insert(inserted) async def _relink_rewritten( diff --git a/tests/integration/test_memory_code_links.py b/tests/integration/test_memory_code_links.py index f0fe16ac017..85c61146177 100644 --- a/tests/integration/test_memory_code_links.py +++ b/tests/integration/test_memory_code_links.py @@ -897,7 +897,7 @@ async def test_a_refresh_follows_the_links_to_the_head_it_indexed(env, monkeypat from server.code.api.models_ingest import CodeRefreshInput from server.code.app.index.pass_budget import CodeIngestResult from server.code.app.ingest import handle_code_refresh - from server.memory.app import code_link_judge, code_link_pass, code_link_recheck + from server.memory.app import code_link_judge, code_link_pass from server.settings import settings repo = env @@ -924,7 +924,7 @@ async def judge(claim: str, before: str, after: str) -> tuple[str, str]: monkeypatch.setattr(ingest_pass, "run_pass", ingest) monkeypatch.setattr(code_link_judge, "judge_claim", judge) refresh = CodeRefreshInput(org=ORG, namespace=TRUNK, wait=True) - async with code_link_pass.repository_locks.lease(code_link_recheck._lock_name(ORG, TRUNK)): + async with code_link_pass.repository_locks.lease(code_link_pass.lock_name(ORG, TRUNK)): out = await handle_code_refresh(refresh) assert (out.triggered, out.head_after) == (True, c2) assert [link["state"] for link in await _links(mid)] == ["fresh"] diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 9a5e0d9446e..84d7f0f62d7 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -10,7 +10,6 @@ import logging import re import subprocess -import types from collections.abc import Callable from datetime import datetime from pathlib import Path @@ -1349,7 +1348,7 @@ async def recheck(org, cns, budget, result): @asynccontextmanager async def lease(name): - if name == code_link_recheck._lock_name("o", "code-a"): + if name == code_link_pass.lock_name("o", "code-a"): raise LeaseBusy(name) yield @@ -1446,7 +1445,7 @@ async def recheck(org, cns, budget, result): @asynccontextmanager async def lease(name): - if name == code_link_recheck._lock_name("o", "code-held"): + if name == code_link_pass.lock_name("o", "code-held"): raise LeaseBusy(name) held.append(name) yield @@ -1456,7 +1455,7 @@ async def lease(name): monkeypatch.setattr(code_link_pass.repository_locks, "lease", lease) result = await code_link_recheck.recheck_repository("o", "code-a") assert result is not None and result.rechecked == 1 - assert ran == [("code-a", 0)] and held == [code_link_recheck._lock_name("o", "code-a")] + assert ran == [("code-a", 0)] and held == [code_link_pass.lock_name("o", "code-a")] with pytest.raises(LeaseBusy): # another pass is checking it await code_link_recheck.recheck_repository("o", "code-held") # no memory links to it, or links are off: no lease taken, nothing read of it @@ -1572,8 +1571,7 @@ async def nothing(*a, **k): await code_link_recheck._follow("o", "code-a", "c1", "c2", files, code_link_pass.PassResult()) # the first part was written: the next pass starts after it, and ends clean assert seen == paths[code_link_recheck._PATHS_PER_WRITE :] and first[0] == paths[0] - # the pass clears its cursor only after the checkpoint, so a writer sees it in flight - assert json.loads(cursor["recheck/o/code-a"]) == {"head": "c2", "after": paths[-1]} + assert cursor["recheck/o/code-a"] == "" async def _record(seen: list[str], part: list[dict[str, Any]]) -> list[Any]: @@ -5722,18 +5720,12 @@ async def test_the_recheck_reports_the_ranges_it_did_not_search(monkeypatch) -> async def nothing(*a, **k): return None - async def nothing_dict(): - return {} - async def head(org, cns): return "c1" monkeypatch.setattr(code_link_pass, "RepoReads", lambda org, cns: files) monkeypatch.setattr(code_link_recheck.code, "indexed_head", head) monkeypatch.setattr(code_link_recheck.code, "checked_head", head) - monkeypatch.setattr( - code_link_pass, "recheck_cursor", lambda org, cns: types.SimpleNamespace(read=nothing_dict) - ) for name in ("_recheck_pending", "_retry_unparsed"): monkeypatch.setattr(code_link_recheck, name, nothing) monkeypatch.setattr(code_link_recheck.rehash, "refingerprint", nothing) @@ -6134,202 +6126,85 @@ def _made(**kw: Any) -> dict[str, Any]: ) -class _LinkStore: - """An in-memory link table that keeps the highest version of a row, as the engine does, - with the recheck state the fence reads.""" - - def __init__(self, monkeypatch, *, cursor: str = "", checked: str = "") -> None: - self.cursor, self.checked, self.rows = cursor, checked, {} - self.fail_on_insert = 0 - monkeypatch.setattr(code_links.store, "insert", self.insert) - monkeypatch.setattr(code_links.code, "link_cursor", self.read_cursor) - monkeypatch.setattr(code_links.code, "checked_head", self.read_checked) +class _Table: + """A link table and the recheck lease, recording what happens in what order.""" - async def insert(self, rows): - if self.fail_on_insert: - self.fail_on_insert -= 1 - if not self.fail_on_insert: - raise RuntimeError("replica died") - for r in rows: - key = (r["memory_id"], r["path"], r["qualified_name"]) - if key not in self.rows or self.rows[key]["version"] < r["version"]: - self.rows[key] = r + def __init__(self, monkeypatch, *, indexed: str = "c1", busy: bool = False) -> None: + from contextlib import asynccontextmanager - async def read_cursor(self, name): - return self.cursor - - async def read_checked(self, org, cns): - return self.checked - - def states(self) -> list[tuple[str, int]]: - return [(r["state"], r["version"]) for r in self.rows.values()] - - -@pytest.mark.asyncio -@pytest.mark.parametrize( - ("cursor", "checked", "state"), - [ - ('{"head": "c1", "after": ""}', "c0", ("pending", 6)), # a pass started before this insert - ("", "c2", ("pending", 6)), # a pass finished at another head after its snapshot - ("", "c1", ("fresh", 7)), # no pass running, the checkpoint is the head it was built at - ("", "", ("fresh", 7)), # no pass has finished: the next one snapshots after this insert - ], -) -async def test_a_link_inserted_while_a_recheck_may_have_missed_it_is_parked( - monkeypatch, cursor, checked, state -) -> None: - table = _LinkStore(monkeypatch, cursor=cursor, checked=checked) - await code_links._insert_unseen([_made()]) - assert table.states() == [state] + from server.memory.store.key_write_lock import LeaseBusy + self.indexed, self.events, self.rows = indexed, [], [] -@pytest.mark.asyncio -async def test_a_link_built_before_a_pass_and_inserted_after_it_is_unknown_until_rechecked( - monkeypatch, -) -> None: - # the writer built at c1 and paused; a pass to c2 snapshotted without the link and - # moved the checked head; the writer then inserts - table = _LinkStore(monkeypatch, cursor="", checked="c2") - built = _made() - await code_links._insert_unseen([built]) - ((state, _),) = table.states() - assert state == "pending" # what the read side serves as unknown - # the next pending scan re-anchors it at the head the pass checked - files = code_link_pass.RepoReads("o", "code-a") + @asynccontextmanager + async def lease(name): + if busy: + raise LeaseBusy(name) + self.events.append(("take", name)) + try: + yield + finally: + self.events.append(("release", name)) - async def at(commit, path): - return _file(path, "def f():" + chr(10) + " return 1" + chr(10)) + async def indexed_head(org, cns): + return self.indexed - async def range_(base, head): - return code_link_pass.Range(base, {}) + async def insert(rows): + self.events.append(("insert", len(rows))) + self.rows += rows - _reads(monkeypatch, files, at) - monkeypatch.setattr(files, "range", range_) - (parked,) = [{**r, "expired": 0} for r in table.rows.values()] - (move,) = await code_link_recheck._reanchor("o", "code-a", "c2", files, [parked]) - assert move.link.state == "fresh" + monkeypatch.setattr(code_link_pass.repository_locks, "lease", lease) + monkeypatch.setattr(code_links.code, "indexed_head", indexed_head) + monkeypatch.setattr(code_links.store, "insert", insert) @pytest.mark.asyncio -@pytest.mark.parametrize( - ("cursor", "checked"), - [('{"head": "c2", "after": ""}', "c1"), ("", "c2")], # a pass began / finished at c2 -) -async def test_a_pass_that_moves_in_after_the_fence_reads_parks_the_promoted_link_again( - monkeypatch, cursor, checked -) -> None: - table = _LinkStore(monkeypatch, checked="c1") # the fence reads clear at the build head - insert, writes = table.insert, [] - - async def moved_after_promotion(rows): - await insert(rows) - writes.append(rows) - if len(writes) == 2: # the promotion landed; the pass skipped the pending row - table.cursor, table.checked = cursor, checked - - monkeypatch.setattr(code_links.store, "insert", moved_after_promotion) - await code_links._insert_unseen([_made()]) - assert table.states() == [("pending", 8)] +async def test_links_are_inserted_inside_their_repositorys_recheck_lease(monkeypatch) -> None: + table = _Table(monkeypatch) + await code_links._insert_at_head([_made(), _made(memory_id="m2")]) + lock = code_link_pass.lock_name("o", "code-a") + # a pass starts only after the release, so its snapshot holds both links; one that + # ended before the take is the next test + assert table.events == [("take", lock), ("insert", 2), ("release", lock)] + # no row waits as pending with a path: a build that resolves pending rows by name + # (N-1 in a rolling upgrade) has none of these to re-anchor at the wrong head + assert {r["state"] for r in table.rows} == {"fresh"} @pytest.mark.asyncio -async def test_a_crash_between_the_pending_insert_and_the_fresh_one_leaves_the_link_pending( - monkeypatch, -) -> None: - table = _LinkStore(monkeypatch) - table.fail_on_insert = 2 # the pending insert lands; the promotion dies - with pytest.raises(RuntimeError): - await code_links._insert_unseen([_made()]) - assert table.states() == [("pending", 6)] - +async def test_links_built_before_a_pass_moved_the_head_are_not_inserted(monkeypatch) -> None: + from server.memory.store.key_write_lock import LeaseBusy -def _parked(path: str, qualified_name: str, **kw: Any) -> dict[str, Any]: - return _made(path=path, qualified_name=qualified_name, state="pending", **({"expired": 0} | kw)) + table = _Table(monkeypatch, indexed="c2") # a pass checked c2 after these were built at c1 + with pytest.raises(LeaseBusy): + await code_links._insert_at_head([_made()]) + assert table.rows == [] and table.events[-1][0] == "release" @pytest.mark.asyncio -async def test_parked_file_and_symbol_links_are_rechecked_and_a_deleted_path_is_lost( - monkeypatch, -) -> None: - from server.code.app.memory_links import file_definitions - - src = "def fetch_rows(n):\n return n + 1\n" - commits = {"c1": {"m.py": src, "r.py": src}, "c2": {"m.py": src}} # r.py is deleted at c2 - files = code_link_pass.RepoReads("o", "code-a") - - async def at(commit, path): - text = commits[commit].get(path) - return _file(path, text) if text is not None else None - - async def range_(base, head): - return code_link_pass.Range(base, {"r.py": ""}) - - async def candidates(org, cns, **kw): - return [] - - _reads(monkeypatch, files, at) - monkeypatch.setattr(files, "range", range_) - - async def no_file_links(org, cns, links, *a, **k): - return [None] * len(links) +async def test_links_wait_for_a_pass_that_holds_the_lease(monkeypatch) -> None: + from server.memory.store.key_write_lock import LeaseBusy - monkeypatch.setattr(code_links, "file_links", no_file_links) - monkeypatch.setattr(code_links.code, "candidates", candidates) - (fn,) = [d for d in file_definitions("m.py", src.encode()) if d.name == "fetch_rows"] - rows = [ - _parked("m.py", fn.qualified_name, body_hash=fn.body_hash, checked_hash=fn.body_hash), - _parked("m.py", "", memory_id="m2"), - _parked("r.py", "", memory_id="m3"), - ] - moves = await code_link_recheck._reanchor("o", "code-a", "c2", files, rows) - assert {(m.row["memory_id"], m.link.state) for m in moves} == { - ("m1", "fresh"), - ("m2", "fresh"), - ("m3", "missing"), - } + table = _Table(monkeypatch, busy=True) + with pytest.raises(LeaseBusy): + await code_links._insert_at_head([_made()]) + assert table.rows == [] @pytest.mark.asyncio -async def test_the_pending_scan_never_expires_a_parked_link(monkeypatch) -> None: - parked, named = _parked("a.py", "a::f", expired=1), _parked("", "a::g", expired=1) - seen: dict[str, list[Any]] = {} - - async def pending(org, cns, **kw): - return [parked, named], None - - async def reanchor(org, cns, head, files, rows): - seen["reanchor"] = rows - return [] - - async def resolve_pending(org, cns, head, files, result, rows): - seen["named"] = rows - return [] - - async def nothing(*a, **k): - return [] - - async def no_cursor(name): - return "" - - monkeypatch.setattr(code_links.store, "pending", pending) - monkeypatch.setattr(code_links.code, "link_cursor", no_cursor) - monkeypatch.setattr(code_link_recheck, "_reanchor", reanchor) - monkeypatch.setattr(code_link_recheck, "_resolve_pending", resolve_pending) - monkeypatch.setattr(code_link_recheck, "_current_moves", nothing) - monkeypatch.setattr(code_link_recheck, "_write_moves", nothing) - files = code_link_pass.RepoReads("o", "code-a") - await code_link_recheck._recheck_pending( - "o", "code-a", "c2", files, code_link_pass.PassResult() - ) - assert seen == {"reanchor": [parked], "named": [named]} # only a named row can expire +async def test_rows_that_name_no_checked_path_take_no_lease(monkeypatch) -> None: + table = _Table(monkeypatch, busy=True) + gone = _made(tombstoned_at=datetime(2026, 1, 1)) + await code_links._insert_at_head([gone, _made(path="", qualified_name="*", state="pending")]) + assert len(table.rows) == 2 @pytest.mark.asyncio async def test_a_file_link_is_not_dropped_beside_a_move_the_current_check_discards( monkeypatch, ) -> None: - stale = code_link_recheck.Move(_parked("", "a::f"), None) - drop = code_link_recheck.Move(_parked("a.py", ""), None) + stale = code_link_recheck.Move(_made(path="", qualified_name="a::f"), None) + drop = code_link_recheck.Move(_made(path="a.py", qualified_name=""), None) written: list[Any] = [] async def pending(org, cns, **kw): @@ -6338,9 +6213,6 @@ async def pending(org, cns, **kw): async def resolve_pending(org, cns, head, files, result, rows): return [stale] - async def reanchor(*a, **k): - return [] - async def discard_stale(org, moves): return [m for m in moves if m is not stale] @@ -6355,7 +6227,6 @@ async def no_cursor(name): monkeypatch.setattr(code_links.store, "pending", pending) monkeypatch.setattr(code_links.code, "link_cursor", no_cursor) - monkeypatch.setattr(code_link_recheck, "_reanchor", reanchor) monkeypatch.setattr(code_link_recheck, "_resolve_pending", resolve_pending) monkeypatch.setattr(code_link_recheck, "_current_moves", discard_stale) monkeypatch.setattr(code_link_recheck, "_file_links_beside", beside) @@ -6365,121 +6236,3 @@ async def no_cursor(name): "o", "code-a", "c2", files, code_link_pass.PassResult() ) assert written == [] - - -@pytest.mark.asyncio -async def test_a_pass_sets_its_cursor_before_reading_links_and_clears_it_after_the_checkpoint( - monkeypatch, -) -> None: - events: list[str] = [] - cursors: dict[str, str] = {} - - async def for_code(org, cns, **kw): - events.append("read links: " + cursors["recheck/o/code-a"]) - return [] - - async def get(name): - return cursors.get(name, "") - - async def put(name, value): - cursors[name] = value - events.append(f"cursor {value or 'cleared'}") - - async def head(org, cns): - return "c2" - - async def checked(org, cns): - return "" if not events else "c1" - - async def set_checked(org, cns, value): - events.append(f"checked {value}") - - async def nothing(*a, **k): - pass - - _stub_reads(monkeypatch, for_code) - for name, fn in ( - ("link_cursor", get), - ("set_link_cursor", put), - ("indexed_head", head), - ("checked_head", checked), - ("set_checked_head", set_checked), - ): - monkeypatch.setattr(code_links.code, name, fn) - for module, name in ( - (code_link_recheck, "_recheck_pending"), - (code_link_recheck, "_retry_unparsed"), - (code_link_rehash, "refingerprint"), - (code_link_policy, "apply_policies"), - ): - monkeypatch.setattr(module, name, nothing) - budget = code_link_pass.Budget(judgements=0) - await code_link_recheck._recheck_repository("o", "code-a", budget, code_link_pass.PassResult()) - assert events == [ - 'cursor {"head": "c2", "after": ""}', - 'read links: {"head": "c2", "after": ""}', - "checked c2", - "cursor cleared", - ] - - -@pytest.mark.asyncio -@pytest.mark.parametrize(("expired", "tombstoned"), [(0, 0), (1, 1)]) -async def test_a_parked_link_whose_path_never_parses_expires_with_the_pending_days( - monkeypatch, expired, tombstoned -) -> None: - written: list[dict[str, Any]] = [] - files = code_link_pass.RepoReads("o", "code-a") - - async def at(commit, path): - raise code_links.code.ParseFailed(path, "bad") - - async def range_(base, head): - return code_link_pass.Range(base, {"a.py": "a.py"}) - - async def insert(rows): - written.extend(rows) - - _reads(monkeypatch, files, at) - monkeypatch.setattr(files, "range", range_) - - async def candidates(org, cns, **kw): - return [] - - monkeypatch.setattr(code_links.code, "candidates", candidates) - monkeypatch.setattr(code_links.store, "insert", insert) - row = _parked("a.py", "a::f", expired=expired) - assert await code_link_recheck._reanchor("o", "code-a", "c2", files, [row]) == [] - assert len(written) == tombstoned - assert all(r["tombstoned_at"] is not None for r in written) - - -@pytest.mark.asyncio -async def test_a_cursor_left_after_the_checkpoint_is_cleared_by_the_next_pass(monkeypatch) -> None: - cursors = {"recheck/o/code-a": '{"head": "c2", "after": ""}'} - - async def get(name): - return cursors.get(name, "") - - async def put(name, value): - cursors[name] = value - - async def head(org, cns): - return "c2" - - async def nothing(*a, **k): - pass - - for name, fn in (("link_cursor", get), ("set_link_cursor", put)): - monkeypatch.setattr(code_links.code, name, fn) - for name in ("indexed_head", "checked_head"): - monkeypatch.setattr(code_links.code, name, head) - monkeypatch.setattr(code_link_recheck, "_recheck_pending", nothing) - monkeypatch.setattr(code_link_recheck, "_retry_unparsed", nothing) - monkeypatch.setattr(code_link_rehash, "refingerprint", nothing) - monkeypatch.setattr(code_link_policy, "apply_policies", nothing) - result = code_link_pass.PassResult() - await code_link_recheck._recheck_repository( - "o", "code-a", code_link_pass.Budget(judgements=0), result - ) - assert cursors["recheck/o/code-a"] == "" From d39ef19df36176ff7f12386584d020a912264b5b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:45:38 +0530 Subject: [PATCH 046/117] The Python SDK search hit carries version_text Signed-off-by: Krishna Dobhal --- sdk/python/loom/memory.py | 3 +++ tests/unit/test_sdk_search_hit_parity.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/sdk/python/loom/memory.py b/sdk/python/loom/memory.py index 6ddaed4f54d..445fa127fda 100644 --- a/sdk/python/loom/memory.py +++ b/sdk/python/loom/memory.py @@ -456,6 +456,8 @@ class MemorySearchHit: # hidden `duplicate` row, that row's memory_key; None otherwise. resolved_from: str | None = None version: int = 0 + # The exact decimal revision, when the server sent one; "" otherwise. + version_text: str = field(default="", kw_only=True) # Ingest time (ISO); "" when unknown. created_at: str = "" # Provenance class (asserted | extracted | observed | derived | imported | @@ -655,6 +657,7 @@ def _parse_search_hit(r: dict[str, Any]) -> MemorySearchHit: superseded_at=_opt_str(r.get("superseded_at")), resolved_from=_opt_str(r.get("resolved_from")), version=int(r.get("version") or 0), + version_text=str(r.get("version_text") or ""), created_at=str(r.get("created_at") or ""), source_class=str(r.get("source_class") or ""), source_resource_id=str(r.get("source_resource_id") or ""), diff --git a/tests/unit/test_sdk_search_hit_parity.py b/tests/unit/test_sdk_search_hit_parity.py index 833a9c99fa6..e00f7635ffe 100644 --- a/tests/unit/test_sdk_search_hit_parity.py +++ b/tests/unit/test_sdk_search_hit_parity.py @@ -78,3 +78,12 @@ def test_relocated_code_links_round_trip() -> None: } assert _parse_search_hit(base | {"code_moved": [link]}).code_moved == [link] assert _parse_search_hit(base).code_moved == [] + + +def test_the_exact_revision_reaches_the_hit() -> None: + base = {"memory_key": "k", "memory_type": "semantic", "content_excerpt": "x"} + base |= {"distance": 0.1, "similarity": 0.9} + assert _parse_search_hit(base | {"version_text": "9007199254740993"}).version_text == ( + "9007199254740993" + ) + assert _parse_search_hit(base).version_text == "" From 7a58b6a186a56eefebe643301af251bc5c722960 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:52:52 +0530 Subject: [PATCH 047/117] Lessons served from trunk show an unknown code state, not a positive one Signed-off-by: Krishna Dobhal --- server/memory/app/code_plane_reads.py | 4 +++- tests/unit/test_memory_code_plane_reads.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/memory/app/code_plane_reads.py b/server/memory/app/code_plane_reads.py index 5bff2bd0d99..504ad33dc7d 100644 --- a/server/memory/app/code_plane_reads.py +++ b/server/memory/app/code_plane_reads.py @@ -154,7 +154,9 @@ async def lessons_for_symbol( "memory_key": str(row["memory_key"]), "namespace": str(row["namespace"]), "excerpt": str(row["excerpt"]), - "code_state": state, + "code_state": ( + "unknown" if a["memory_id"] in trunk_only and state in ("fresh", "moved") else state + ), "changed_since": a["changed_since"] if state == "changed" else "", "suggestion": suggestion, } diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index fcb954a1cb5..3e13fdf7941 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -453,7 +453,7 @@ async def test_a_fallback_to_trunks_state_gives_no_positive_guidance(monkeypatch monkeypatch, [_link("m1")], [_excerpt("m1", "k1")], branch, ns="code-a-26-8", **kw ) - assert lesson["code_state"] == "fresh" # trunk's check, still shown + assert lesson["code_state"] == "unknown" # trunk's check is not the branch's assert lesson["use_guidance"]["freshness"]["code"] == "unknown" From 90932210c45830d7d595c8ec78e7ce418cdf8c72 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:52:52 +0530 Subject: [PATCH 048/117] A parked search hit drops the moved links it cached Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 1 + tests/unit/test_search_use_guidance.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 425b35b8bc9..bdbaaa157d9 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -303,5 +303,6 @@ async def attach_search_guidance( hit.code_state = worst([hit.use_guidance.freshness.code]) # the commit the first page cached may not be the one that state rests on now hit.code_changed_since = "" + hit.code_moved = [] kept.append(hit) return kept diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index 874c900c87e..5f7beb7780a 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -8,6 +8,7 @@ import pytest from server.identity.domain.read_scope import ReadFilters +from server.memory.api.models_crud import CodeLink from server.memory.api.models_search import MemorySearchInput, _MemorySearchHit from server.memory.app import search_pages from server.memory.app.search import guidance @@ -88,6 +89,7 @@ async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: hit = _hit() hit.code_state = "missing" hit.code_changed_since = "commit-a" # the page-one state, since moved or unreadable + hit.code_moved = [CodeLink(code_namespace="c", path="old.py", state="moved")] await guidance.attach_search_guidance(_INPUT, [hit], snapshot_only=True) parked = search_pages.unparked(search_pages._parked(hit)) assert parked is not None @@ -95,6 +97,7 @@ async def code_states(org: str, rows: list[dict[str, Any]]) -> list[str]: assert parked.use_guidance is not None and parked.use_guidance.freshness.code == state assert parked.code_state == (state if state in ("changed", "fresh") else "") assert parked.code_changed_since == "" + assert parked.code_moved == [] @pytest.mark.asyncio From 6dea395ffeca1135cc12885661fe554e01012cf4 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 16:52:53 +0530 Subject: [PATCH 049/117] A busy repository no longer stalls the links of the others in a batch Signed-off-by: Krishna Dobhal --- server/memory/app/code_links.py | 59 +++++++++++-------- tests/unit/test_memory_code_links.py | 84 ++++++++++++++++++++++++---- 2 files changed, 107 insertions(+), 36 deletions(-) diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 211b7f43112..660ecc70b35 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -18,7 +18,7 @@ import time from collections import defaultdict from collections.abc import Mapping, Sequence -from contextlib import AbstractAsyncContextManager, AsyncExitStack +from contextlib import AbstractAsyncContextManager from dataclasses import dataclass, replace from typing import Any @@ -145,36 +145,45 @@ async def _link_org( out += [_awaiting(r, cns) for r, _ in unparsed] waiting = {r["mid"] for r, _ in unparsed} memories = [r for r in memories if r["mid"] not in waiting] - out += rows_out + store.tombstones(gone) + if not await _insert_at_head(org, cns, rows_out + store.tombstones(gone)): + # its pending scan, under the lease, links them at its own head + result.errors.append(f"link {org}/{cns}: a recheck is ahead of these links") + out += [_awaiting(r, cns) for r in memories] + continue result.linked += len(rows_out) result.unlinked += len(gone) linked += [r["mid"] for r in memories] - await _insert_at_head(out) + await store.insert(out) if linked and rereads: read = {r["mid"]: r["inputs"] for memories in todo.values() for r in memories} await _relink_rewritten(org, linked, read, result, rereads - 1) -async def _insert_at_head(inserted: list[LinkRow]) -> None: - """Insert `inserted` while holding each linked repository's recheck lease, and only if - its indexed head is still the one the links were built at. A pass that checked a later - head ran before the lease and would never have seen them: LeaseBusy, the queue - retries and builds at the new head. A pass that starts after reads them +async def _insert_at_head(org: str, cns: str, inserted: list[LinkRow]) -> bool: + """Insert one repository's `inserted` links under its recheck lease, if its indexed + head is still the one they were built at. False, nothing inserted, when a pass holds + the lease or checked a later head: it never saw these links, and the caller leaves + them to its pending scan. A pass that starts after the insert reads them (docs/architecture/code-index-architecture.md).""" - heads: dict[tuple[str, str], set[str]] = defaultdict(set) - for r in inserted: - if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None: - heads[r["org"], r["code_namespace"]].add(r["checked_commit"]) - async with AsyncExitStack() as held: - for key in sorted(heads): - await held.enter_async_context( - link_pass.repository_locks.lease(link_pass.lock_name(*key)) - ) + built = { + r["checked_commit"] + for r in inserted + if r["path"] and r["state"] != "pending" and r["tombstoned_at"] is None + } + if not built: + if inserted: + await store.insert(inserted) + return True + try: + async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): with sequential_reads(): - now = await code.indexed_head(*key) - if heads[key] != {now}: - raise LeaseBusy(f"{key[0]}/{key[1]} moved to {now} while its links were built") - await store.insert(inserted) + now = await code.indexed_head(org, cns) + if built != {now}: + return False + await store.insert(inserted) + except LeaseBusy: + return False + return True async def _relink_rewritten( @@ -210,8 +219,9 @@ async def link_each( ) -> tuple[list[LinkRow], list[LinkRow], list[tuple[dict[str, Any], str]]]: """`_link`, and the memories it could not link, each with the file it names that does not parse; the others are linked all the same.""" + head = await code.indexed_head(org, cns) # one head for the batch, as its insert checks try: - return *await _link(org, cns, memories, existing, files), [] + return *await _link(org, cns, memories, existing, files, head), [] except code.ParseFailed: pass rows: list[LinkRow] = [] @@ -219,7 +229,7 @@ async def link_each( unparsed: list[tuple[dict[str, Any], str]] = [] for m in memories: try: - made, dropped = await _link(org, cns, [m], existing, files) + made, dropped = await _link(org, cns, [m], existing, files, head) except code.ParseFailed as e: unparsed.append((m, e.path)) continue @@ -234,11 +244,12 @@ async def _link( memories: list[dict[str, Any]], existing: dict[str, list[LinkRow]], files: link_pass.RepoReads, + head: str | None = None, ) -> tuple[list[LinkRow], list[LinkRow]]: """The link rows of `memories` (one repository's) at its indexed head, and their existing links that no longer hold. Before the repository's first index each memory gets a `*` marker instead, resolved once the index exists.""" - head = await code.indexed_head(org, cns) + head = await code.indexed_head(org, cns) if head is None else head if not head: markers = [_awaiting(r, cns) for r in memories] old = [a for r in memories for a in existing.get(r["mid"], [])] diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 84d7f0f62d7..ec76d068ee7 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6129,7 +6129,14 @@ def _made(**kw: Any) -> dict[str, Any]: class _Table: """A link table and the recheck lease, recording what happens in what order.""" - def __init__(self, monkeypatch, *, indexed: str = "c1", busy: bool = False) -> None: + def __init__( + self, + monkeypatch, + *, + indexed: str = "c1", + busy: bool = False, + busy_names: frozenset[str] | set[str] = frozenset(), + ) -> None: from contextlib import asynccontextmanager from server.memory.store.key_write_lock import LeaseBusy @@ -6138,7 +6145,7 @@ def __init__(self, monkeypatch, *, indexed: str = "c1", busy: bool = False) -> N @asynccontextmanager async def lease(name): - if busy: + if busy or name in busy_names: raise LeaseBusy(name) self.events.append(("take", name)) try: @@ -6161,7 +6168,7 @@ async def insert(rows): @pytest.mark.asyncio async def test_links_are_inserted_inside_their_repositorys_recheck_lease(monkeypatch) -> None: table = _Table(monkeypatch) - await code_links._insert_at_head([_made(), _made(memory_id="m2")]) + assert await code_links._insert_at_head("o", "code-a", [_made(), _made(memory_id="m2")]) lock = code_link_pass.lock_name("o", "code-a") # a pass starts only after the release, so its snapshot holds both links; one that # ended before the take is the next test @@ -6173,21 +6180,15 @@ async def test_links_are_inserted_inside_their_repositorys_recheck_lease(monkeyp @pytest.mark.asyncio async def test_links_built_before_a_pass_moved_the_head_are_not_inserted(monkeypatch) -> None: - from server.memory.store.key_write_lock import LeaseBusy - table = _Table(monkeypatch, indexed="c2") # a pass checked c2 after these were built at c1 - with pytest.raises(LeaseBusy): - await code_links._insert_at_head([_made()]) + assert not await code_links._insert_at_head("o", "code-a", [_made()]) assert table.rows == [] and table.events[-1][0] == "release" @pytest.mark.asyncio async def test_links_wait_for_a_pass_that_holds_the_lease(monkeypatch) -> None: - from server.memory.store.key_write_lock import LeaseBusy - table = _Table(monkeypatch, busy=True) - with pytest.raises(LeaseBusy): - await code_links._insert_at_head([_made()]) + assert not await code_links._insert_at_head("o", "code-a", [_made()]) assert table.rows == [] @@ -6195,10 +6196,69 @@ async def test_links_wait_for_a_pass_that_holds_the_lease(monkeypatch) -> None: async def test_rows_that_name_no_checked_path_take_no_lease(monkeypatch) -> None: table = _Table(monkeypatch, busy=True) gone = _made(tombstoned_at=datetime(2026, 1, 1)) - await code_links._insert_at_head([gone, _made(path="", qualified_name="*", state="pending")]) + rows = [gone, _made(path="", qualified_name="*", state="pending")] + assert await code_links._insert_at_head("o", "code-a", rows) assert len(table.rows) == 2 +@pytest.mark.asyncio +async def test_a_busy_repository_leaves_the_others_linked_and_waits_for_its_pass( + monkeypatch, +) -> None: + table = _Table(monkeypatch, busy_names={code_link_pass.lock_name("o", "code-b")}) + + def memory(mid: str, tag: str) -> dict[str, Any]: + return { + "org": "o", "namespace": "n", "agent": "a", "user_id": "-", "session_id": "-", + "memory_key": mid, "mid": mid, "sha": "s", "value": "v", "tags": [tag], + "files": ["a.py"], "status": "active", "tombstoned_at": None, + } # fmt: skip + + async def link_each(org, cns, memories, existing, files): + return [_made(code_namespace=cns, memory_id=r["mid"]) for r in memories], [], [] + + async def none(*a, **k): + return [] + + async def nothing(*a, **k): + return None + + monkeypatch.setattr(code_links.store, "for_memories", none) + monkeypatch.setattr(code_links, "link_each", link_each) + monkeypatch.setattr(code_links, "_relink_rewritten", nothing) + monkeypatch.setattr( + code_links, "code_namespace_for", lambda org, ns, tags: "code-" + tags[0][-1] + ) + monkeypatch.setattr(code_links, "mentions", lambda text: []) + result = code_link_pass.PassResult() + await code_links._link_org("o", [memory("ma", "repo:a"), memory("mb", "repo:b")], result) + by_state = {(r["memory_id"], r["code_namespace"]): r["state"] for r in table.rows} + # repository a is linked; b's memory is parked on the `*` marker its pass resolves + assert by_state == {("ma", "code-a"): "fresh", ("mb", "code-b"): "pending"} + assert [r["qualified_name"] for r in table.rows if r["memory_id"] == "mb"] == ["*"] + assert (result.linked, len(result.errors)) == (1, 1) + + +@pytest.mark.asyncio +async def test_one_batch_is_built_at_one_head_when_a_file_does_not_parse(monkeypatch) -> None: + heads = iter(["c1", "c2", "c3"]) + seen: list[str | None] = [] + + async def indexed_head(org, cns): + return next(heads) + + async def link(org, cns, memories, existing, files, head=None): + seen.append(head) + if len(memories) > 1: + raise code_links.code.ParseFailed("a.py", "bad") + return [], [] + + monkeypatch.setattr(code_links.code, "indexed_head", indexed_head) + monkeypatch.setattr(code_links, "_link", link) + await code_links.link_each("o", "code-a", [{"mid": "m1"}, {"mid": "m2"}], {}, None) + assert seen == ["c1", "c1", "c1"] + + @pytest.mark.asyncio async def test_a_file_link_is_not_dropped_beside_a_move_the_current_check_discards( monkeypatch, From 7ea185717b8034e46c2d1067beae95f9fd89fef0 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 17:08:47 +0530 Subject: [PATCH 050/117] A pass at an unchanged head rechecks links an older build inserted behind it Each pass records a digest of the links not checked at its head, read before any link; the next pass at that head rechecks them when it changed. Recheck passes read under sequential_reads(), and one repository's batch is linked in its own function so the busy-lease test stubs fit. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 28 ++++--- docs/architecture/rolling-upgrades.md | 8 +- server/memory/app/code_link_recheck.py | 64 +++++++++++++-- server/memory/app/code_links.py | 54 ++++++++----- server/memory/store/code_links.py | 30 +++++++ tests/unit/test_memory_code_links.py | 83 +++++++++++++++++++- tests/unit/test_memory_code_plane_reads.py | 2 +- 7 files changed, 224 insertions(+), 45 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 3571d83b677..89c5773faba 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -687,15 +687,25 @@ A recheck pass follows a repository's links from its checked head to its indexed under the repository's lease, and a writer that links a memory inserts its links under the same lease. A pass that starts after the insert reads the new links. A pass that ran before the writer took the lease checked a head the writer's links were not built at, -so the writer finds the indexed head moved, inserts nothing and raises `LeaseBusy`; the -link worker retries the queue page, which builds the links at the new head. A writer -that finds the lease held waits `memory_code_links_interval_seconds` for the next pass -the same way. No link is stored in a state that waits for a pass, and the read side -trusts a link only when the checked head is the indexed head. - -The indexed head is read under `sequential_reads()`, so a head another replica indexed -is seen. That holds when the state writes are visible to a sequential read, as -`loom doctor` checks for `select_sequential_consistency`. +so the writer finds the indexed head moved and inserts nothing: it parks that +repository's memories behind the `*` marker (the other repositories of the batch are +inserted and the queue cursor moves on), and the pending scan, which runs under the +lease, links them at its own head. A writer that finds the lease held does the same. No +link is stored in a state that waits for a pass, and the read side trusts a link only +when the checked head is the indexed head. + +The indexed head, and every read a pass makes of the links, run under +`sequential_reads()`, so a head another replica indexed and a link another replica +inserted under the lease are seen. That holds when the state writes are visible to a +sequential read, as `loom doctor` checks for `select_sequential_consistency`. + +A build without the lease (the previous one during a rolling upgrade) can insert a link +built at an older commit after a pass read the table. A pass at an unchanged head follows +nothing, so each pass records, before it reads any link, a digest of the live links not +checked at its head (`store.behind_digest`: each key and version). The next pass at that +head finds the digest changed and rechecks those links from their own checked commit +(`_catch_up`). The digest is compared, never a timestamp, so no host's clock matters; a +pass that moved links changes the digest once more and its next catch-up is a no-op. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index d7e851d7ef2..eb2ca362a28 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1066,9 +1066,11 @@ separate mirror-content cleanup before serving; this account procedure does not A build that takes the repository's recheck lease to insert a memory's links writes no new row shape and no setting. Replicas of the previous build insert without the lease, so -while they run the link worker a link can be inserted just after a pass snapshotted and -be served as fresh until the next pass of any build rechecks it. The window ends when the -last previous-build replica is replaced; the new build carries no code for it. +while they run the link worker a link can be inserted just after a pass snapshotted. Each +pass records a digest of the links not checked at its head, taken before it reads any +link; the next pass at the same head that finds the digest changed rechecks those links, +so such a link stops being served as fresh within two passes, with no wait for the last +previous-build replica to go. ## Independent proposal approval diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 2635fbdcb9f..422bcba62fb 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -25,6 +25,7 @@ from server.code.domain.declaration import fingerprint_version from server.code.domain.index.repos import repo_for_namespace from server.code.domain.successor import Side, Successor, close_to, elsewhere, successor +from server.core.ch import sequential_reads from server.core.datetimes import naive_utc_now from server.memory.app import code_link_pass as link_pass from server.memory.app import code_link_policy as policy @@ -90,8 +91,10 @@ async def recheck_all(result: link_pass.PassResult) -> None: granted = (left + rest - 1) // rest budget = link_pass.Budget(judgements=granted) try: - async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): - await _recheck_repository(org, cns, budget, result) + # sequential reads see a link another replica inserted under the lease + with sequential_reads(): + async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): + await _recheck_repository(org, cns, budget, result) except LeaseBusy: pass # another pass is checking this repository except Exception as e: # noqa: BLE001 — one repository's failure never stops the pass @@ -109,8 +112,9 @@ async def recheck_repository(org: str, cns: str) -> link_pass.PassResult | None: if not settings.memory_code_links_enabled or (org, cns) not in await store.code_namespaces(): return None result = link_pass.PassResult() - async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): - await _recheck_repository(org, cns, link_pass.Budget(judgements=0), result) + with sequential_reads(): + async with link_pass.repository_locks.lease(link_pass.lock_name(org, cns)): + await _recheck_repository(org, cns, link_pass.Budget(judgements=0), result) return result @@ -121,6 +125,7 @@ async def _recheck_repository( files = link_pass.RepoReads(org, cns) head = await code.indexed_head(org, cns) checked = await code.checked_head(org, cns) + behind = await store.behind_digest(org, cns, head) if head else "" await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) @@ -140,6 +145,8 @@ async def _recheck_repository( checked = cut_at await _follow(org, cns, checked, head, files, result) await code.set_checked_head(org, cns, head) + if head: + await _catch_up(org, cns, head, behind, files, result) result.wide_ranges += files.wide_ranges await policy.apply_policies(org, cns, head, files, budget, result) @@ -265,8 +272,26 @@ async def _retry_unparsed( paths = await _unparsed(org, cns) if not paths or not head: return + still, failed = await _recheck_rows( + org, cns, head, files, result, await store.for_paths(org, [cns], sorted(paths)) + ) + if failed: + result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") + await _set_unparsed(org, cns, still) + + +async def _recheck_rows( + org: str, + cns: str, + head: str, + files: link_pass.RepoReads, + result: link_pass.PassResult, + links: list[LinkRow], +) -> tuple[set[str], set[str]]: + """Recheck `links` at `head`, each from the commit it was last checked at; the paths + that still do not parse, and those that failed this time.""" by_commit: dict[str, list[LinkRow]] = defaultdict(list) - for a in await store.for_paths(org, [cns], sorted(paths)): + for a in links: by_commit[a["checked_commit"]].append(a) still, failed = set[str](), set[str]() for commit, rows in by_commit.items(): @@ -280,9 +305,32 @@ async def _retry_unparsed( ) await _write_moves(await _current_moves(org, moves), head) result.rechecked += len(moves) - if failed: - result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") - await _set_unparsed(org, cns, still) + return still, failed + + +async def _catch_up( + org: str, + cns: str, + head: str, + now: str, + files: link_pass.RepoReads, + result: link_pass.PassResult, +) -> None: + """Recheck the links a pass at `head` never saw. A pass at an unchanged head follows + nothing, so a link an older build inserted after the last pass read the table, built + at another commit, would keep its state. The pass records a digest of the links not + checked at `head`, taken before it read any link (`now`), so none it missed is + vouched for; when the next one finds it changed, those links are rechecked. A pass + that moved links makes the next digest differ once more, and that recheck is a no-op.""" + seen = link_pass.Cursor[dict[str, str]](f"behind/{org}/{cns}", {}) + before = await seen.read() + if before.get("head") == head and before.get("links") != now: + links = await store.behind(org, cns, head) + still, failed = await _recheck_rows(org, cns, head, files, result, links) + await _set_unparsed(org, cns, await _unparsed(org, cns) | still) + if failed: + result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") + await seen.write({"head": head, "links": now}) async def _unparsed(org: str, cns: str) -> set[str]: diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 660ecc70b35..6d94a30606f 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -132,33 +132,45 @@ async def _link_org( result.unlinked += len(stale) linked: list[str] = [] for cns, memories in todo.items(): - files = link_pass.RepoReads(org, cns) - try: - rows_out, gone, unparsed = await link_each(org, cns, memories, existing, files) - except Exception as e: # noqa: BLE001 — one repository's failure never stops the pass - result.failed(f"link {org}/{cns}: {e}", e, f"{cns}:link") - out += [_awaiting(r, cns) for r in memories] - continue - if unparsed: - paths = ", ".join(sorted({path for _, path in unparsed})) - result.errors.append(f"link {org}/{cns}: did not parse: {paths}") - out += [_awaiting(r, cns) for r, _ in unparsed] - waiting = {r["mid"] for r, _ in unparsed} - memories = [r for r in memories if r["mid"] not in waiting] - if not await _insert_at_head(org, cns, rows_out + store.tombstones(gone)): - # its pending scan, under the lease, links them at its own head - result.errors.append(f"link {org}/{cns}: a recheck is ahead of these links") - out += [_awaiting(r, cns) for r in memories] - continue - result.linked += len(rows_out) - result.unlinked += len(gone) - linked += [r["mid"] for r in memories] + waiting, made = await _link_repository(org, cns, memories, existing, result) + out += waiting + linked += made await store.insert(out) if linked and rereads: read = {r["mid"]: r["inputs"] for memories in todo.values() for r in memories} await _relink_rewritten(org, linked, read, result, rereads - 1) +async def _link_repository( + org: str, + cns: str, + memories: list[dict[str, Any]], + existing: dict[str, list[LinkRow]], + result: link_pass.PassResult, +) -> tuple[list[LinkRow], list[str]]: + """Link one repository's `memories`: the `*` markers of those that must wait, and the + ids of those linked.""" + files = link_pass.RepoReads(org, cns) + try: + rows_out, gone, unparsed = await link_each(org, cns, memories, existing, files) + except Exception as e: # noqa: BLE001 — one repository's failure never stops the pass + result.failed(f"link {org}/{cns}: {e}", e, f"{cns}:link") + return [_awaiting(r, cns) for r in memories], [] + waiting = [_awaiting(r, cns) for r, _ in unparsed] + if unparsed: + paths = ", ".join(sorted({path for _, path in unparsed})) + result.errors.append(f"link {org}/{cns}: did not parse: {paths}") + parked = {r["mid"] for r, _ in unparsed} + memories = [r for r in memories if r["mid"] not in parked] + if not await _insert_at_head(org, cns, rows_out + store.tombstones(gone)): + # its pending scan, under the lease, links them at its own head + result.errors.append(f"link {org}/{cns}: a recheck is ahead of these links") + return waiting + [_awaiting(r, cns) for r in memories], [] + result.linked += len(rows_out) + result.unlinked += len(gone) + return waiting, [r["mid"] for r in memories] + + async def _insert_at_head(org: str, cns: str, inserted: list[LinkRow]) -> bool: """Insert one repository's `inserted` links under its recheck lease, if its indexed head is still the one they were built at. False, nothing inserted, when a pass holds diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 0f38b12facb..60802eb62b6 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -453,6 +453,36 @@ async def _for_code( ) +_BEHIND = ( + "{_LIVE} AND org = {{org:String}} AND code_namespace = {{cns:String}} " + "AND state != 'pending' AND checked_commit != {{head:String}}" +) + + +async def behind_digest( + org: str, code_namespace: str, head: str, *, ch: _CHClient | None = None +) -> str: + """A digest of the live links not checked at `head`, each by key and version: it + changes whenever one is written, relinked or removed.""" + rows = await (ch or _default_client()).query_all( + f"SELECT count() AS n, hex(groupBitXor(sipHash64({_KEY}, version))) AS d " + + _BEHIND.format(_LIVE=_LIVE), + params={"org": org, "cns": code_namespace, "head": head}, + ) + return f"{rows[0]['n']}:{rows[0]['d']}" + + +async def behind( + org: str, code_namespace: str, head: str, *, ch: _CHClient | None = None +) -> list[LinkRow]: + """The live links not checked at `head`.""" + rows = await (ch or _default_client()).query_all( + "SELECT * " + _BEHIND.format(_LIVE=_LIVE), + params={"org": org, "cns": code_namespace, "head": head}, + ) + return _links(rows) + + async def stale_fingerprints( org: str, code_namespace: str, diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index ec76d068ee7..004522dd40e 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -56,6 +56,15 @@ async def lease(name, *, wait_s=None): monkeypatch.setattr(code_link_pass.repository_locks, "lease", lease) +@pytest.fixture(autouse=True) +def _no_links_behind(monkeypatch): + # no ClickHouse here: no link waits behind the head unless a test says so + async def digest(org, cns, head): + return "0:0" + + monkeypatch.setattr(code_links.store, "behind_digest", digest) + + @pytest.fixture(autouse=True) def _mirror_holds_every_commit(monkeypatch): async def has(self, commit): @@ -506,6 +515,7 @@ async def nothing(*_args): monkeypatch.setattr(code_links.store, "insert", nothing) monkeypatch.setattr(code_link_recheck, "_write_moves", publish) monkeypatch.setattr(code_link_recheck, "_retry_unparsed", nothing) + monkeypatch.setattr(code_link_recheck, "_catch_up", nothing) monkeypatch.setattr(code_link_rehash, "refingerprint", nothing) monkeypatch.setattr(code_link_policy, "apply_policies", nothing) @@ -749,7 +759,7 @@ async def for_memories(org, ids): async def insert(rows): written.extend(rows) - async def link(org, cns, memories, existing, files): + async def link(org, cns, memories, existing, files, head=None): if cns == "code-bad": raise RuntimeError("down") return [], [] @@ -761,6 +771,11 @@ async def memory_heads(org, ids): monkeypatch.setattr(code_links.store, "for_memories", for_memories) monkeypatch.setattr(code_links.store, "memory_heads", memory_heads) monkeypatch.setattr(code_links.store, "insert", insert) + + async def indexed_head(org, cns): + return "h" + + monkeypatch.setattr(code_links.code, "indexed_head", indexed_head) monkeypatch.setattr(code_links, "_link", link) monkeypatch.setattr( code_links, "code_namespace_for", lambda org, ns, tags: f"code-{tags[0][5:]}" @@ -2326,6 +2341,7 @@ async def set_checked_head(org, cns, at): (code_link_recheck, "_write_moves"), (code_link_recheck, "_current_moves"), (code_link_recheck, "_retry_unparsed"), + (code_link_recheck, "_catch_up"), (code_link_rehash, "refingerprint"), (code_link_policy, "apply_policies"), ): @@ -4549,7 +4565,7 @@ async def drop_unlinkable(org, ids): dropped.append((org, set(ids))) return len(ids) - async def link(org, cns, memories, existing, files): + async def link(org, cns, memories, existing, files, head=None): raise AssertionError(f"linked {[m['memory_key'] for m in memories]}") monkeypatch.setattr(code_links.store, "for_memories", for_memories) @@ -5726,7 +5742,7 @@ async def head(org, cns): monkeypatch.setattr(code_link_pass, "RepoReads", lambda org, cns: files) monkeypatch.setattr(code_link_recheck.code, "indexed_head", head) monkeypatch.setattr(code_link_recheck.code, "checked_head", head) - for name in ("_recheck_pending", "_retry_unparsed"): + for name in ("_recheck_pending", "_retry_unparsed", "_catch_up"): monkeypatch.setattr(code_link_recheck, name, nothing) monkeypatch.setattr(code_link_recheck.rehash, "refingerprint", nothing) monkeypatch.setattr(code_link_recheck.policy, "apply_policies", nothing) @@ -6296,3 +6312,64 @@ async def no_cursor(name): "o", "code-a", "c2", files, code_link_pass.PassResult() ) assert written == [] + + +@pytest.mark.asyncio +async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_the_same_head( + monkeypatch, +) -> None: + # the table's links behind h1: what the passes read and what a writer inserts + behind: list[dict[str, Any]] = [] + cursors: dict[str, str] = {} + rechecked: list[list[str]] = [] + + async def digest(org, cns, head): + return str(sorted(a["memory_id"] for a in behind)) + + async def read_behind(org, cns, head): + return list(behind) + + async def recheck_rows(org, cns, head, files, result, links): + rechecked.extend([[a["memory_id"] for a in links]] if links else []) + behind.clear() # rechecked at the head + return set(), set() + + async def get(name): + return cursors.get(name, "") + + async def put(name, value): + cursors[name] = value + + async def unparsed(org, cns): + return set() + + async def set_unparsed(org, cns, paths): + return None + + monkeypatch.setattr(code_links.store, "behind_digest", digest) + monkeypatch.setattr(code_links.store, "behind", read_behind) + monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) + monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) + monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) + monkeypatch.setattr(code_links.code, "link_cursor", get) + monkeypatch.setattr(code_links.code, "set_link_cursor", put) + + async def one_pass() -> None: + # the digest is read first, as `_recheck_repository` does, before any link + now = await digest("o", "code-a", "h1") + await code_link_recheck._catch_up( + "o", + "code-a", + "h1", + now, + None, + code_link_pass.PassResult(), # type: ignore[arg-type] + ) + + await one_pass() # the first pass at h1: nothing waits + behind.append(_full({"memory_id": "late", "checked_commit": "h0"})) # an older build's insert + await one_pass() # the next pass at h1 reads it behind the head + assert rechecked == [["late"]] + await one_pass() # settled: the recheck made the digest differ once, then it holds + await one_pass() + assert rechecked == [["late"]] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 3e13fdf7941..14b34020d8f 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -582,7 +582,7 @@ async def readable(org: str, nss: set[str]) -> set[str]: (lesson,) = await _lessons( monkeypatch, [_renamed("m1")], [_excerpt("m1", "k1")], [], has_mirror=False ) - assert (lesson["code_state"], "code_moved" in lesson) == ("moved", False) + assert (lesson["code_state"], "code_moved" in lesson) == ("unknown", False) @pytest.mark.asyncio From a688f3f1cbef36d91625d1eb16a5489a778ae44e Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 17:14:47 +0530 Subject: [PATCH 051/117] The recheck and rolling-upgrade pages describe the link fence in plain prose Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 46 ++++++++++---------- docs/architecture/rolling-upgrades.md | 12 ++--- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 89c5773faba..8d270330c1e 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -684,28 +684,30 @@ No source text is fetched from a network or fabricated to fill a gap. ## Memory links written during a recheck A recheck pass follows a repository's links from its checked head to its indexed head -under the repository's lease, and a writer that links a memory inserts its links under -the same lease. A pass that starts after the insert reads the new links. A pass that ran -before the writer took the lease checked a head the writer's links were not built at, -so the writer finds the indexed head moved and inserts nothing: it parks that -repository's memories behind the `*` marker (the other repositories of the batch are -inserted and the queue cursor moves on), and the pending scan, which runs under the -lease, links them at its own head. A writer that finds the lease held does the same. No -link is stored in a state that waits for a pass, and the read side trusts a link only -when the checked head is the indexed head. - -The indexed head, and every read a pass makes of the links, run under -`sequential_reads()`, so a head another replica indexed and a link another replica -inserted under the lease are seen. That holds when the state writes are visible to a -sequential read, as `loom doctor` checks for `select_sequential_consistency`. - -A build without the lease (the previous one during a rolling upgrade) can insert a link -built at an older commit after a pass read the table. A pass at an unchanged head follows -nothing, so each pass records, before it reads any link, a digest of the live links not -checked at its head (`store.behind_digest`: each key and version). The next pass at that -head finds the digest changed and rechecks those links from their own checked commit -(`_catch_up`). The digest is compared, never a timestamp, so no host's clock matters; a -pass that moved links changes the digest once more and its next catch-up is a no-op. +under the repository's lease. A writer that links a memory inserts its links under the +same lease, so a pass that starts after the insert reads the new links. + +A pass can run before the writer takes the lease and check a head the writer's links +were not built at. The writer then finds the indexed head moved and inserts nothing. It +parks that repository's memories behind the `*` marker, inserts the other repositories +of the batch and moves the queue cursor on. The pending scan, which runs under the +lease, links the parked memories at its own head. A writer that finds the lease held +does the same. No link is stored in a state that waits for a pass, and the read side +trusts a link only when the checked head is the indexed head. + +The indexed head and every read a pass makes of the links run under +`sequential_reads()`, so the pass sees a head another replica indexed and a link another +replica inserted under the lease. That holds when state writes are visible to a +sequential read, which `loom doctor` checks through `select_sequential_consistency`. + +A build without the lease, such as the previous build during a rolling upgrade, can +insert a link built at an older commit after a pass read the table. A pass at an +unchanged head follows nothing, so each pass records a digest of the live links not +checked at its head (`store.behind_digest`, over each key and version). It takes the +digest before it reads any link. The next pass at that head rechecks those links from +their own checked commit (`_catch_up`) when the digest changed. The check compares +digests and never timestamps, so no host's clock matters. A pass that moved links +changes the digest once more, and the catch-up after it rechecks nothing. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index eb2ca362a28..9a86aad2501 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1065,12 +1065,12 @@ separate mirror-content cleanup before serving; this account procedure does not ### Memory links written during a recheck A build that takes the repository's recheck lease to insert a memory's links writes no -new row shape and no setting. Replicas of the previous build insert without the lease, so -while they run the link worker a link can be inserted just after a pass snapshotted. Each -pass records a digest of the links not checked at its head, taken before it reads any -link; the next pass at the same head that finds the digest changed rechecks those links, -so such a link stops being served as fresh within two passes, with no wait for the last -previous-build replica to go. +new row shape and adds no setting. Replicas of the previous build insert without the +lease, so while they run the link worker a link can be inserted just after a pass read +the table. Each pass records a digest of the links not checked at its head, taken before +it reads any link. The next pass at the same head rechecks those links when the digest +changed, so such a link stops being served as fresh within two passes, whether or not a +previous-build replica is still running. ## Independent proposal approval From 6702cb018c31187ac2f342cd9f1dc375c147cdfe Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 17:26:57 +0530 Subject: [PATCH 052/117] A recheck of lost links leaves the catch-up digest unchanged A lost link keeps its checked commit when a recheck rewrites it, so the digest counts it by key and commit instead of version; the catch-up no longer rewrites lost links on every pass. Lease contention in a link batch is logged at debug level instead of being added to the pass errors. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 9 ++-- server/memory/app/code_link_recheck.py | 7 +-- server/memory/app/code_links.py | 2 +- server/memory/store/code_links.py | 9 ++-- tests/unit/test_memory_code_links.py | 53 +++++++++++++++++++- 5 files changed, 68 insertions(+), 12 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 8d270330c1e..97d33387cdf 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -703,11 +703,12 @@ sequential read, which `loom doctor` checks through `select_sequential_consisten A build without the lease, such as the previous build during a rolling upgrade, can insert a link built at an older commit after a pass read the table. A pass at an unchanged head follows nothing, so each pass records a digest of the live links not -checked at its head (`store.behind_digest`, over each key and version). It takes the -digest before it reads any link. The next pass at that head rechecks those links from +checked at its head (`store.behind_digest`, over each key and version, and over each +key and commit for a lost link). It takes the digest before it reads any link. The next pass at that head rechecks those links from their own checked commit (`_catch_up`) when the digest changed. The check compares -digests and never timestamps, so no host's clock matters. A pass that moved links -changes the digest once more, and the catch-up after it rechecks nothing. +digests and never timestamps, so no host's clock matters. A recheck +moves the links it finds out of that set, and a lost link keeps its digest when the +recheck rewrites it, so the catch-up after it rechecks nothing. ## Invariants diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 422bcba62fb..e4e980d67f7 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -125,7 +125,7 @@ async def _recheck_repository( files = link_pass.RepoReads(org, cns) head = await code.indexed_head(org, cns) checked = await code.checked_head(org, cns) - behind = await store.behind_digest(org, cns, head) if head else "" + behind = await store.behind_digest(org, cns, head) if head else "" # before any link read await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) @@ -320,8 +320,9 @@ async def _catch_up( nothing, so a link an older build inserted after the last pass read the table, built at another commit, would keep its state. The pass records a digest of the links not checked at `head`, taken before it read any link (`now`), so none it missed is - vouched for; when the next one finds it changed, those links are rechecked. A pass - that moved links makes the next digest differ once more, and that recheck is a no-op.""" + vouched for; when the next one finds it changed, those links are rechecked. Links + that were rechecked leave the set, and lost ones keep their digest, so a catch-up + that moved links is followed by one that rechecks nothing.""" seen = link_pass.Cursor[dict[str, str]](f"behind/{org}/{cns}", {}) before = await seen.read() if before.get("head") == head and before.get("links") != now: diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index 6d94a30606f..22bde6395f4 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -164,7 +164,7 @@ async def _link_repository( memories = [r for r in memories if r["mid"] not in parked] if not await _insert_at_head(org, cns, rows_out + store.tombstones(gone)): # its pending scan, under the lease, links them at its own head - result.errors.append(f"link {org}/{cns}: a recheck is ahead of these links") + link_pass.log.debug("link %s/%s: a recheck is ahead of these links", org, cns) return waiting + [_awaiting(r, cns) for r in memories], [] result.linked += len(rows_out) result.unlinked += len(gone) diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 60802eb62b6..58e18039f7b 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -462,10 +462,13 @@ async def _for_code( async def behind_digest( org: str, code_namespace: str, head: str, *, ch: _CHClient | None = None ) -> str: - """A digest of the live links not checked at `head`, each by key and version: it - changes whenever one is written, relinked or removed.""" + """A digest of the live links not checked at `head`: it changes whenever one is + inserted, relinked or removed. A lost link keeps its commit when a recheck rewrites + it, so it counts by key and commit, not version: rechecking it changes nothing. + One aggregate over the repository's live links, on every pass.""" rows = await (ch or _default_client()).query_all( - f"SELECT count() AS n, hex(groupBitXor(sipHash64({_KEY}, version))) AS d " + f"SELECT count() AS n, hex(groupBitXor(if(state IN ('unresolved', 'missing'), " + f"sipHash64({_KEY}, checked_commit), sipHash64({_KEY}, version)))) AS d " + _BEHIND.format(_LIVE=_LIVE), params={"org": org, "cns": code_namespace, "head": head}, ) diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 004522dd40e..631ebfca306 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6252,7 +6252,7 @@ async def nothing(*a, **k): # repository a is linked; b's memory is parked on the `*` marker its pass resolves assert by_state == {("ma", "code-a"): "fresh", ("mb", "code-b"): "pending"} assert [r["qualified_name"] for r in table.rows if r["memory_id"] == "mb"] == ["*"] - assert (result.linked, len(result.errors)) == (1, 1) + assert (result.linked, len(result.errors)) == (1, 0) # contention is logged only @pytest.mark.asyncio @@ -6373,3 +6373,54 @@ async def one_pass() -> None: await one_pass() # settled: the recheck made the digest differ once, then it holds await one_pass() assert rechecked == [["late"]] + + +@pytest.mark.asyncio +async def test_a_lost_link_at_a_steady_head_is_not_rechecked_by_later_passes(monkeypatch) -> None: + # a lost link keeps its checked commit, so a recheck rewrites it as another version: + # the digest counts it by key and commit, as the store's does, and stays put + lost = _full({"memory_id": "m", "state": "missing", "checked_commit": "h0", "version": 1}) + table = [lost] + cursors: dict[str, str] = {} + rechecks: list[int] = [] + + async def digest(org, cns, head): + return str([(a["memory_id"], a["checked_commit"]) for a in table]) + + async def read_behind(org, cns, head): + return list(table) + + async def recheck_rows(org, cns, head, files, result, links): + rechecks.append(len(links)) + table[:] = [a | {"version": a["version"] + 1} for a in table] # rewritten, still lost + return set(), set() + + async def get(name): + return cursors.get(name, "") + + async def put(name, value): + cursors[name] = value + + async def unparsed(org, cns): + return set() + + async def set_unparsed(org, cns, paths): + return None + + monkeypatch.setattr(code_links.store, "behind", read_behind) + monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) + monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) + monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) + monkeypatch.setattr(code_links.code, "link_cursor", get) + monkeypatch.setattr(code_links.code, "set_link_cursor", put) + for _ in range(3): + now = await digest("o", "code-a", "h1") + await code_link_recheck._catch_up( + "o", + "code-a", + "h1", + now, + None, + code_link_pass.PassResult(), # type: ignore[arg-type] + ) + assert rechecks == [] From a03b9a554f70b69147b58c605d213d3bdf12bad0 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 17:38:31 +0530 Subject: [PATCH 053/117] The catch-up never adopts a digest for links it has not rechecked, and reads them in pages A pass trusts the behind-head digest only as the digest of a set already rechecked: a missing cursor, another head or a different digest rechecks every link behind the head, a page of the code-link batch size per pass in key order, and stores the digest the sweep started at after the last page. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 19 +++- docs/architecture/rolling-upgrades.md | 4 +- server/memory/app/code_link_recheck.py | 41 ++++--- server/memory/store/code_links.py | 32 ++++-- tests/unit/test_memory_code_links.py | 112 ++++++++++++++++++- 5 files changed, 173 insertions(+), 35 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 97d33387cdf..5e484e00218 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -702,13 +702,20 @@ sequential read, which `loom doctor` checks through `select_sequential_consisten A build without the lease, such as the previous build during a rolling upgrade, can insert a link built at an older commit after a pass read the table. A pass at an -unchanged head follows nothing, so each pass records a digest of the live links not +unchanged head follows nothing, so each pass takes a digest of the live links not checked at its head (`store.behind_digest`, over each key and version, and over each -key and commit for a lost link). It takes the digest before it reads any link. The next pass at that head rechecks those links from -their own checked commit (`_catch_up`) when the digest changed. The check compares -digests and never timestamps, so no host's clock matters. A recheck -moves the links it finds out of that set, and a lost link keeps its digest when the -recheck rewrites it, so the catch-up after it rechecks nothing. +key and commit for a lost link) before it reads any link. It trusts that digest only as +the digest of a set it has already rechecked. When the `behind/` cursor holds no +verified digest for this head, or a different one, `_catch_up` rechecks the whole set +from each link's own checked commit. That includes the first pass after an upgrade, a +pass at a new head (after its follow, which moves the links it loaded out of the set), +and a pass that finds the digest changed. It reads a page of `memory_code_links_batch` +links in key order per pass and keeps its place in the cursor. The cursor stores the +digest the sweep started at only after the last page, so a link that arrives during the +sweep makes the digest differ and starts another. The check compares digests and never +timestamps, so no host's clock matters. A recheck moves the links it finds out of that +set, and a lost link keeps its digest when the recheck rewrites it, so the sweep after +it rechecks nothing. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 9a86aad2501..1f6697d1827 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1069,8 +1069,8 @@ new row shape and adds no setting. Replicas of the previous build insert without lease, so while they run the link worker a link can be inserted just after a pass read the table. Each pass records a digest of the links not checked at its head, taken before it reads any link. The next pass at the same head rechecks those links when the digest -changed, so such a link stops being served as fresh within two passes, whether or not a -previous-build replica is still running. +changed, a page of links per pass, so such a link is rechecked within a few passes +whether or not a previous-build replica is still running. ## Independent proposal approval diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index e4e980d67f7..a1828ce9341 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -316,22 +316,33 @@ async def _catch_up( files: link_pass.RepoReads, result: link_pass.PassResult, ) -> None: - """Recheck the links a pass at `head` never saw. A pass at an unchanged head follows - nothing, so a link an older build inserted after the last pass read the table, built - at another commit, would keep its state. The pass records a digest of the links not - checked at `head`, taken before it read any link (`now`), so none it missed is - vouched for; when the next one finds it changed, those links are rechecked. Links - that were rechecked leave the set, and lost ones keep their digest, so a catch-up - that moved links is followed by one that rechecks nothing.""" - seen = link_pass.Cursor[dict[str, str]](f"behind/{org}/{cns}", {}) + """Recheck the links not checked at `head` that no pass followed. A pass at an + unchanged head follows nothing, so a link an older build inserted after the last pass + read the table, built at another commit, would keep its state. `now` is a digest of + those links taken before the pass read any link. It is trusted only as the digest of + a set already rechecked: when the cursor holds no verified digest for this head, or a + different one, the whole set is rechecked, a page of the batch size per pass in key + order, and the digest the sweep started at is stored after its last page. Rechecked + links leave the set and lost ones keep their digest, so a sweep that moved links is + followed by one that rechecks nothing.""" + seen = link_pass.Cursor[dict[str, Any]](f"behind/{org}/{cns}", {}) before = await seen.read() - if before.get("head") == head and before.get("links") != now: - links = await store.behind(org, cns, head) - still, failed = await _recheck_rows(org, cns, head, files, result, links) - await _set_unparsed(org, cns, await _unparsed(org, cns) | still) - if failed: - result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") - await seen.write({"head": head, "links": now}) + mine = before.get("head") == head + if mine and before.get("links") == now: + return + after = tuple(before["after"]) if mine and before.get("after") else None + target = before["target"] if after else now + links, nxt = await store.behind( + org, cns, head, after=after, limit=int(settings.memory_code_links_batch) + ) + still, failed = await _recheck_rows(org, cns, head, files, result, links) + await _set_unparsed(org, cns, await _unparsed(org, cns) | still) + if failed: + result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") + if nxt: + await seen.write({"head": head, "links": "", "target": target, "after": list(nxt)}) + else: + await seen.write({"head": head, "links": target}) async def _unparsed(org: str, cns: str) -> set[str]: diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 58e18039f7b..498cbf07bd7 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -476,14 +476,32 @@ async def behind_digest( async def behind( - org: str, code_namespace: str, head: str, *, ch: _CHClient | None = None -) -> list[LinkRow]: - """The live links not checked at `head`.""" - rows = await (ch or _default_client()).query_all( - "SELECT * " + _BEHIND.format(_LIVE=_LIVE), - params={"org": org, "cns": code_namespace, "head": head}, + org: str, + code_namespace: str, + head: str, + *, + after: tuple[str, ...] | None, + limit: int, + ch: _CHClient | None = None, +) -> tuple[list[LinkRow], tuple[str, ...] | None]: + """Up to `limit` live links not checked at `head`, in key order after `after`, and + the next page's start (None at the end).""" + since = f" AND {_past(_KEY_COLUMNS, _KEY_TYPES)}" if after else "" + rows = _links( + await (ch or _default_client()).query_all( + "SELECT * " + + _BEHIND.format(_LIVE=_LIVE) + + f"{since} ORDER BY {_KEY} LIMIT {{lim:UInt32}}", + params={ + "org": org, + "cns": code_namespace, + "head": head, + "lim": int(limit), + **_past_params(after or ()), + }, + ) ) - return _links(rows) + return rows, _key(rows[-1]) if len(rows) == int(limit) else None async def stale_fingerprints( diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 631ebfca306..9a4a5ff1279 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6326,8 +6326,8 @@ async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_ async def digest(org, cns, head): return str(sorted(a["memory_id"] for a in behind)) - async def read_behind(org, cns, head): - return list(behind) + async def read_behind(org, cns, head, *, after, limit): + return list(behind), None async def recheck_rows(org, cns, head, files, result, links): rechecked.extend([[a["memory_id"] for a in links]] if links else []) @@ -6387,8 +6387,8 @@ async def test_a_lost_link_at_a_steady_head_is_not_rechecked_by_later_passes(mon async def digest(org, cns, head): return str([(a["memory_id"], a["checked_commit"]) for a in table]) - async def read_behind(org, cns, head): - return list(table) + async def read_behind(org, cns, head, *, after, limit): + return list(table), None async def recheck_rows(org, cns, head, files, result, links): rechecks.append(len(links)) @@ -6423,4 +6423,106 @@ async def set_unparsed(org, cns, paths): None, code_link_pass.PassResult(), # type: ignore[arg-type] ) - assert rechecks == [] + assert rechecks == [1] # the first pass checks it; the rewrites change no digest + + +def _catch_up_world(monkeypatch, behind: list[dict[str, Any]], page: int = 100): + """A table of links behind the head, a cursor store and the rechecks made, per page.""" + cursors: dict[str, str] = {} + rechecked: list[list[str]] = [] + + async def digest_of() -> str: + return str(sorted(a["memory_id"] for a in behind)) + + async def read_behind(org, cns, head, *, after, limit): + rows = [ + a + for a in sorted(behind, key=lambda a: a["memory_id"]) + if after is None or (a["memory_id"],) > after + ] + rows = rows[:limit] + return rows, ((rows[-1]["memory_id"],) if len(rows) == limit else None) + + async def recheck_rows(org, cns, head, files, result, links): + rechecked.extend([[a["memory_id"] for a in links]] if links else []) + for a in links: + behind.remove(a) # rechecked at the head + return set(), set() + + async def get(name): + return cursors.get(name, "") + + async def put(name, value): + cursors[name] = value + + async def unparsed(org, cns): + return set() + + async def set_unparsed(org, cns, paths): + return None + + monkeypatch.setattr(settings, "memory_code_links_batch", page) + monkeypatch.setattr(code_links.store, "behind", read_behind) + monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) + monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) + monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) + monkeypatch.setattr(code_links.code, "link_cursor", get) + monkeypatch.setattr(code_links.code, "set_link_cursor", put) + + async def one_pass(head: str = "h1", *, between=None) -> None: + now = await digest_of() # read before any link, as `_recheck_repository` does + if between: + between() # a write while the pass runs + await code_link_recheck._catch_up( + "o", + "code-a", + head, + now, + None, + code_link_pass.PassResult(), # type: ignore[arg-type] + ) + + return rechecked, one_pass, cursors + + +@pytest.mark.asyncio +async def test_the_first_pass_with_no_cursor_rechecks_the_links_already_behind(monkeypatch) -> None: + # an older writer's link at the previous commit, found before any pass kept a digest + behind = [_full({"memory_id": "a", "checked_commit": "h0"})] + rechecked, one_pass, _ = _catch_up_world(monkeypatch, behind) + await one_pass() + assert rechecked == [["a"]] + await one_pass() + assert rechecked == [["a"]] + + +@pytest.mark.asyncio +async def test_a_link_inserted_while_a_head_moving_pass_runs_is_not_vouched_for( + monkeypatch, +) -> None: + behind: list[dict[str, Any]] = [] + rechecked, one_pass, _ = _catch_up_world(monkeypatch, behind) + await one_pass("h0") + late = _full({"memory_id": "late", "checked_commit": "h0"}) + # the pass at the new head took its digest, then the writer inserted, then it ended + await one_pass("h1", between=lambda: behind.append(late)) + assert rechecked == [["late"]] # this pass's catch-up reads the table after the follow + await one_pass("h1") + assert rechecked == [["late"]] + + +@pytest.mark.asyncio +async def test_more_links_than_a_page_take_several_passes_and_the_digest_comes_last( + monkeypatch, +) -> None: + behind = [_full({"memory_id": f"m{i}", "checked_commit": "h0"}) for i in range(5)] + rechecked, one_pass, cursors = _catch_up_world(monkeypatch, behind, page=2) + await one_pass() + await one_pass() + assert [len(r) for r in rechecked] == [2, 2] + assert json.loads(cursors["behind/o/code-a"])["links"] == "" # not yet vouched for + await one_pass() + assert [len(r) for r in rechecked] == [2, 2, 1] + assert json.loads(cursors["behind/o/code-a"])["links"] != "" + await one_pass() + assert [len(r) for r in rechecked] == [2, 2, 1] From 099a3e2bcd7d10e80565e5fd1ecc08bfed181a36 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 18:20:24 +0530 Subject: [PATCH 054/117] The link catch-up and guidance use the insert time ClickHouse stamps on each link Migration 116 adds inserted_at to memory_code_links. A pass takes ClickHouse's time before it reads any link; its catch-up rechecks the links stamped since the previous pass's start from their own commits, in pages, and guidance trusts no link stamped after the last finished start. The digest sweep and its cursor are removed. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 31 +- docs/architecture/rolling-upgrades.md | 14 +- .../116_memory_code_link_inserted_at.sql | 5 + server/memory/app/code_link_reads.py | 48 ++- server/memory/app/code_link_recheck.py | 54 +-- server/memory/store/code_links.py | 69 ++-- tests/unit/test_memory_code_links.py | 323 +++++++----------- tests/unit/test_memory_code_plane_reads.py | 19 +- tests/unit/test_schema_baseline.py | 1 + 9 files changed, 293 insertions(+), 271 deletions(-) create mode 100644 schemas/migrations/116_memory_code_link_inserted_at.sql diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 5e484e00218..54bdafb45f7 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -702,20 +702,23 @@ sequential read, which `loom doctor` checks through `select_sequential_consisten A build without the lease, such as the previous build during a rolling upgrade, can insert a link built at an older commit after a pass read the table. A pass at an -unchanged head follows nothing, so each pass takes a digest of the live links not -checked at its head (`store.behind_digest`, over each key and version, and over each -key and commit for a lost link) before it reads any link. It trusts that digest only as -the digest of a set it has already rechecked. When the `behind/` cursor holds no -verified digest for this head, or a different one, `_catch_up` rechecks the whole set -from each link's own checked commit. That includes the first pass after an upgrade, a -pass at a new head (after its follow, which moves the links it loaded out of the set), -and a pass that finds the digest changed. It reads a page of `memory_code_links_batch` -links in key order per pass and keeps its place in the cursor. The cursor stores the -digest the sweep started at only after the last page, so a link that arrives during the -sweep makes the digest differ and starts another. The check compares digests and never -timestamps, so no host's clock matters. A recheck moves the links it finds out of that -set, and a lost link keeps its digest when the recheck rewrites it, so the sweep after -it rechecks nothing. +unchanged head follows nothing, so ClickHouse stamps every link row with `inserted_at` +as it is inserted, and each pass takes ClickHouse's time before it reads any link. Its +catch-up (`_catch_up`) rechecks every live link not checked at the head that was stamped +since the previous pass's start, from each link's own checked commit. That covers a +link inserted at any point after the previous pass began reading, including one that +arrives while the pass itself runs. It reads a page of `memory_code_links_batch` links +in key order per pass and keeps its place in the `seen/` cursor. The cursor's `read` +moves to the start of the pass only after the last page. With no cursor, as on the first +pass after an upgrade, every link not at the head is rechecked once. A link a recheck +leaves unchanged writes nothing, so a lost link is rechecked once and then stays out. + +The read side trusts a link only if it is checked at the checked head or was stamped +before `read`. A link stamped later may be one no pass has seen, and without a `read` +no link qualifies, so guidance on it is unknown until the catch-up finishes. A skew +margin of two seconds on a pass's start covers a replica whose clock runs behind. This +needs ClickHouse to assign `inserted_at` on replicas with synchronised clocks; a larger +skew than the margin needs a larger margin. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 1f6697d1827..3a5a0b025ae 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1064,13 +1064,13 @@ separate mirror-content cleanup before serving; this account procedure does not ### Memory links written during a recheck -A build that takes the repository's recheck lease to insert a memory's links writes no -new row shape and adds no setting. Replicas of the previous build insert without the -lease, so while they run the link worker a link can be inserted just after a pass read -the table. Each pass records a digest of the links not checked at its head, taken before -it reads any link. The next pass at the same head rechecks those links when the digest -changed, a page of links per pass, so such a link is rechecked within a few passes -whether or not a previous-build replica is still running. +A build that takes the repository's recheck lease to insert a memory's links adds the +column `inserted_at`, which ClickHouse fills when a replica of the +previous build omits it, and no setting. Those replicas insert without the lease, so +while they run the link worker a link can be inserted just after a pass read the table. +The next pass rechecks every link stamped since the previous pass began reading, and +guidance trusts no link stamped after that start, so such a link reads as unknown until +a pass covers it, whether or not a previous-build replica is still running. ## Independent proposal approval diff --git a/schemas/migrations/116_memory_code_link_inserted_at.sql b/schemas/migrations/116_memory_code_link_inserted_at.sql new file mode 100644 index 00000000000..0363cbfd794 --- /dev/null +++ b/schemas/migrations/116_memory_code_link_inserted_at.sql @@ -0,0 +1,5 @@ +-- ClickHouse stamps each link row as it is inserted. The recheck's catch-up and the +-- guidance read it to find links written after a pass read the table. +ALTER TABLE loom.memory_code_links ADD COLUMN IF NOT EXISTS inserted_at DateTime64(3) DEFAULT now64(3); +-- rows stored before the column exists would read as inserted now: give them this time +ALTER TABLE loom.memory_code_links MATERIALIZE COLUMN inserted_at; diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index e75b259376c..6c57e34689e 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -17,6 +17,7 @@ from server.code.domain.index.repos import RegistryUnread, configured_repos from server.core.hashing import hash_text from server.memory.api.models_crud import CodeLink +from server.memory.app import code_link_pass as link_pass from server.memory.app.code_link_pass import unparsed_cursor from server.memory.domain import code_change from server.memory.domain.redaction_lineage import is_content_hash @@ -153,9 +154,14 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: return state or "unknown" -async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str]]: +async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str], int | None]: + """The head the repository's links were last checked at, the paths still owed a + recheck, and the ClickHouse time (ms) the last finished catch-up began reading at + (None before one finished): a link stamped after it may be one no pass has seen.""" checked = await code.checked_head(org, cns) - return checked, set(await unparsed_cursor(org, cns).read()) if checked else set() + owed = set(await unparsed_cursor(org, cns).read()) if checked else set() + read = (await link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}).read()).get("read") + return checked, owed, read async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, str]: @@ -168,6 +174,34 @@ async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, return {} +async def _seen_hits( + org: str, cns: str, head: str, read: int, hits: list[tuple[int, str, str]] +) -> dict[int, str]: + """The hits whose memories hold no link stamped after the catch-up began reading.""" + try: + unseen = await store.unchecked_memories(org, cns, [mid for _, _, mid in hits], head, read) + except Exception as error: # noqa: BLE001 — unread stamps leave guidance uncertain + log.debug("Guidance link stamps unavailable: %s", type(error).__name__) + return {} + return {index: state for index, state, mid in hits if mid not in unseen} + + +async def _confirm( + org: str, + positive: dict[tuple[str, str], list[tuple[int, str, str]]], + coverage: dict[str, Any], + states: list[str], +) -> None: + """Serve the positive states of the repositories whose checked head is the indexed + one, for the memories no link stamped after the finished catch-up began reading.""" + indexed = await _guidance_indexed_heads(org, [cns for cns, _ in positive]) + for (cns, checked_head), hits in positive.items(): + read = coverage[cns][2] + if indexed.get(cns) == checked_head and read is not None: + for index, state in (await _seen_hits(org, cns, checked_head, read, hits)).items(): + states[index] = state + + async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: """Classify every readable link made from the evidence in the served memory revision.""" states = ["unknown"] * len(rows) @@ -219,17 +253,13 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, owed = proof + checked_head, owed, _ = proof if not checked_head or any(link["path"] in owed for link in rows_for_hit): continue - positive[key[2], checked_head].append((index, state)) + positive[key[2], checked_head].append((index, state, key[0])) else: states[index] = state - indexed = await _guidance_indexed_heads(org, [cns for cns, _ in positive]) - for (cns, checked_head), hits in positive.items(): - if indexed.get(cns) == checked_head: - for index, state in hits: - states[index] = state + await _confirm(org, positive, coverage, states) return states diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index a1828ce9341..22b319a1778 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -125,7 +125,7 @@ async def _recheck_repository( files = link_pass.RepoReads(org, cns) head = await code.indexed_head(org, cns) checked = await code.checked_head(org, cns) - behind = await store.behind_digest(org, cns, head) if head else "" # before any link read + started = await store.clock() - _SKEW_MS # before any link read await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) @@ -146,7 +146,7 @@ async def _recheck_repository( await _follow(org, cns, checked, head, files, result) await code.set_checked_head(org, cns, head) if head: - await _catch_up(org, cns, head, behind, files, result) + await _catch_up(org, cns, head, started, files, result) result.wide_ranges += files.wide_ranges await policy.apply_policies(org, cns, head, files, budget, result) @@ -308,41 +308,49 @@ async def _recheck_rows( return still, failed +# ponytail: ClickHouse stamps `inserted_at` on whichever replica takes the write, so a +# slow clock can stamp a link just before a pass's start. The margin covers a replica +# this far behind; NTP-synced clocks are a precondition, a larger skew needs a larger one. +_SKEW_MS = 2000 + + async def _catch_up( org: str, cns: str, head: str, - now: str, + started: int, files: link_pass.RepoReads, result: link_pass.PassResult, ) -> None: - """Recheck the links not checked at `head` that no pass followed. A pass at an - unchanged head follows nothing, so a link an older build inserted after the last pass - read the table, built at another commit, would keep its state. `now` is a digest of - those links taken before the pass read any link. It is trusted only as the digest of - a set already rechecked: when the cursor holds no verified digest for this head, or a - different one, the whole set is rechecked, a page of the batch size per pass in key - order, and the digest the sweep started at is stored after its last page. Rechecked - links leave the set and lost ones keep their digest, so a sweep that moved links is - followed by one that rechecks nothing.""" - seen = link_pass.Cursor[dict[str, Any]](f"behind/{org}/{cns}", {}) - before = await seen.read() - mine = before.get("head") == head - if mine and before.get("links") == now: - return - after = tuple(before["after"]) if mine and before.get("after") else None - target = before["target"] if after else now - links, nxt = await store.behind( - org, cns, head, after=after, limit=int(settings.memory_code_links_batch) + """Recheck the links an older build inserted after the last pass read the table. A + pass at an unchanged head follows nothing, so a link built at another commit would + keep its state. ClickHouse stamps each link as it is inserted, and `started` is its + time (less a skew margin) before this pass read any link: every link stamped since + the previous pass's `read` that is not checked at `head` is rechecked from its own + commit, a page of the batch size per pass in key order. `read` moves to this pass's + start only after the last page, and guidance trusts no link stamped after it. With + no cursor (the first pass, or links an older build had stored) every link not at + `head` is rechecked once.""" + seen = link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}) + cursor = await seen.read() + after = tuple(cursor["after"]) if cursor.get("after") else None + target = cursor["target"] if after else started + links, nxt = await store.inserted_since( + org, + cns, + head, + cursor.get("read", 0), + after=after, + limit=int(settings.memory_code_links_batch), ) still, failed = await _recheck_rows(org, cns, head, files, result, links) await _set_unparsed(org, cns, await _unparsed(org, cns) | still) if failed: result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") if nxt: - await seen.write({"head": head, "links": "", "target": target, "after": list(nxt)}) + await seen.write({**cursor, "target": target, "after": list(nxt)}) else: - await seen.write({"head": head, "links": target}) + await seen.write({"read": target}) async def _unparsed(org: str, cns: str) -> set[str]: diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 498cbf07bd7..e0db5b7f629 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -453,49 +453,42 @@ async def _for_code( ) -_BEHIND = ( - "{_LIVE} AND org = {{org:String}} AND code_namespace = {{cns:String}} " - "AND state != 'pending' AND checked_commit != {{head:String}}" -) +async def clock(*, ch: _CHClient | None = None) -> int: + """ClickHouse's time in milliseconds, the clock that stamps `inserted_at`.""" + rows = await (ch or _default_client()).query_all("SELECT toUnixTimestamp64Milli(now64(3)) AS t") + return int(rows[0]["t"]) -async def behind_digest( - org: str, code_namespace: str, head: str, *, ch: _CHClient | None = None -) -> str: - """A digest of the live links not checked at `head`: it changes whenever one is - inserted, relinked or removed. A lost link keeps its commit when a recheck rewrites - it, so it counts by key and commit, not version: rechecking it changes nothing. - One aggregate over the repository's live links, on every pass.""" - rows = await (ch or _default_client()).query_all( - f"SELECT count() AS n, hex(groupBitXor(if(state IN ('unresolved', 'missing'), " - f"sipHash64({_KEY}, checked_commit), sipHash64({_KEY}, version)))) AS d " - + _BEHIND.format(_LIVE=_LIVE), - params={"org": org, "cns": code_namespace, "head": head}, - ) - return f"{rows[0]['n']}:{rows[0]['d']}" +_UNCHECKED = ( + "{_LIVE} AND org = {{org:String}} AND code_namespace = {{cns:String}} " + "AND state != 'pending' AND checked_commit != {{head:String}} " + "AND toUnixTimestamp64Milli(inserted_at) >= {{since:Int64}}" +) -async def behind( +async def inserted_since( org: str, code_namespace: str, head: str, + since: int, *, after: tuple[str, ...] | None, limit: int, ch: _CHClient | None = None, ) -> tuple[list[LinkRow], tuple[str, ...] | None]: - """Up to `limit` live links not checked at `head`, in key order after `after`, and - the next page's start (None at the end).""" - since = f" AND {_past(_KEY_COLUMNS, _KEY_TYPES)}" if after else "" + """Up to `limit` live links not checked at `head` that were inserted at or after + `since` (ms), in key order after `after`, and the next page's start (None at the end).""" + past = f"AND {_past(_KEY_COLUMNS, _KEY_TYPES)} " if after else "" rows = _links( await (ch or _default_client()).query_all( "SELECT * " - + _BEHIND.format(_LIVE=_LIVE) - + f"{since} ORDER BY {_KEY} LIMIT {{lim:UInt32}}", + + _UNCHECKED.format(_LIVE=_LIVE) + + f" {past}ORDER BY {_KEY} LIMIT {{lim:UInt32}}", params={ "org": org, "cns": code_namespace, "head": head, + "since": since, "lim": int(limit), **_past_params(after or ()), }, @@ -504,6 +497,34 @@ async def behind( return rows, _key(rows[-1]) if len(rows) == int(limit) else None +async def unchecked_memories( + org: str, + code_namespace: str, + memory_ids: Sequence[str], + head: str, + since: int, + *, + ch: _CHClient | None = None, +) -> set[str]: + """The memories among `memory_ids` with a live link not checked at `head` that was + inserted at or after `since` (ms).""" + rows = await query_all_sliced( + ch or _default_client(), + "SELECT DISTINCT memory_id " + + _UNCHECKED.format(_LIVE=_LIVE) + + " AND memory_id IN {ids:Array(UUID)}", + { + "org": org, + "cns": code_namespace, + "head": head, + "since": since, + "ids": sorted(set(memory_ids)), + }, + "ids", + ) + return {str(r["memory_id"]) for r in rows} + + async def stale_fingerprints( org: str, code_namespace: str, diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 9a4a5ff1279..08116754d45 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -57,12 +57,12 @@ async def lease(name, *, wait_s=None): @pytest.fixture(autouse=True) -def _no_links_behind(monkeypatch): - # no ClickHouse here: no link waits behind the head unless a test says so - async def digest(org, cns, head): - return "0:0" +def _a_clock(monkeypatch): + # no ClickHouse here: its clock stands still unless a test moves it + async def clock(): + return 10_000 - monkeypatch.setattr(code_links.store, "behind_digest", digest) + monkeypatch.setattr(code_links.store, "clock", clock) @pytest.fixture(autouse=True) @@ -6314,215 +6314,154 @@ async def no_cursor(name): assert written == [] -@pytest.mark.asyncio -async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_the_same_head( - monkeypatch, -) -> None: - # the table's links behind h1: what the passes read and what a writer inserts - behind: list[dict[str, Any]] = [] - cursors: dict[str, str] = {} - rechecked: list[list[str]] = [] - - async def digest(org, cns, head): - return str(sorted(a["memory_id"] for a in behind)) - - async def read_behind(org, cns, head, *, after, limit): - return list(behind), None - - async def recheck_rows(org, cns, head, files, result, links): - rechecked.extend([[a["memory_id"] for a in links]] if links else []) - behind.clear() # rechecked at the head - return set(), set() - - async def get(name): - return cursors.get(name, "") - - async def put(name, value): - cursors[name] = value - - async def unparsed(org, cns): - return set() - - async def set_unparsed(org, cns, paths): - return None - - monkeypatch.setattr(code_links.store, "behind_digest", digest) - monkeypatch.setattr(code_links.store, "behind", read_behind) - monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) - monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) - monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) - monkeypatch.setattr(code_links.code, "link_cursor", get) - monkeypatch.setattr(code_links.code, "set_link_cursor", put) +class _Stamped: + """The link table as ClickHouse keeps it: each row has the time (ms) it was inserted, + and a recheck moves a live link to the head, as `_write_moves` does, leaving a lost + one unwritten, as `_recheck` does when nothing about it changed.""" + + def __init__(self, monkeypatch, page: int = 100) -> None: + self.now = 10_000 + self.table: list[dict[str, Any]] = [] + self.cursors: dict[str, str] = {} + self.rechecked: list[list[str]] = [] + + async def clock(): + return self.now + + async def inserted_since(org, cns, head, since, *, after, limit): + rows = sorted( + ( + a + for a in self.table + if a["checked_commit"] != head + and a["state"] != "pending" + and a["ins"] >= since + and (after is None or (a["memory_id"],) > after) + ), + key=lambda a: a["memory_id"], + )[:limit] + return rows, ((rows[-1]["memory_id"],) if len(rows) == limit else None) + + async def recheck_rows(org, cns, head, files, result, links): + self.rechecked.append([a["memory_id"] for a in links]) + for a in links: + if a["state"] not in ("missing", "unresolved"): + a["checked_commit"], a["ins"] = head, self.now + return set(), set() + + async def get(name): + return self.cursors.get(name, "") + + async def put(name, value): + self.cursors[name] = value + + async def unparsed(org, cns): + return set() + + async def set_unparsed(org, cns, paths): + return None - async def one_pass() -> None: - # the digest is read first, as `_recheck_repository` does, before any link - now = await digest("o", "code-a", "h1") + monkeypatch.setattr(settings, "memory_code_links_batch", page) + monkeypatch.setattr(code_links.store, "clock", clock) + monkeypatch.setattr(code_links.store, "inserted_since", inserted_since) + monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) + monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) + monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) + monkeypatch.setattr(code_links.code, "link_cursor", get) + monkeypatch.setattr(code_links.code, "set_link_cursor", put) + + def add(self, memory_id: str, checked_commit: str, state: str = "fresh", ins: int = 1) -> None: + link = _full({"memory_id": memory_id, "checked_commit": checked_commit, "state": state}) + self.table.append(link | {"ins": ins}) + + async def pass_at(self, head: str = "h1", *, between=None) -> None: + """One pass: it takes its start first, as `_recheck_repository` does.""" + started = await code_links.store.clock() - code_link_recheck._SKEW_MS + self.now += 1000 await code_link_recheck._catch_up( "o", "code-a", - "h1", - now, + head, + started, None, code_link_pass.PassResult(), # type: ignore[arg-type] ) + if between: + between() # a writer inserts after the pass read the table - await one_pass() # the first pass at h1: nothing waits - behind.append(_full({"memory_id": "late", "checked_commit": "h0"})) # an older build's insert - await one_pass() # the next pass at h1 reads it behind the head - assert rechecked == [["late"]] - await one_pass() # settled: the recheck made the digest differ once, then it holds - await one_pass() - assert rechecked == [["late"]] + def read(self) -> int | None: + """What guidance trusts: the start of the last finished catch-up.""" + return json.loads(self.cursors["seen/o/code-a"]).get("read") @pytest.mark.asyncio -async def test_a_lost_link_at_a_steady_head_is_not_rechecked_by_later_passes(monkeypatch) -> None: - # a lost link keeps its checked commit, so a recheck rewrites it as another version: - # the digest counts it by key and commit, as the store's does, and stays put - lost = _full({"memory_id": "m", "state": "missing", "checked_commit": "h0", "version": 1}) - table = [lost] - cursors: dict[str, str] = {} - rechecks: list[int] = [] - - async def digest(org, cns, head): - return str([(a["memory_id"], a["checked_commit"]) for a in table]) - - async def read_behind(org, cns, head, *, after, limit): - return list(table), None - - async def recheck_rows(org, cns, head, files, result, links): - rechecks.append(len(links)) - table[:] = [a | {"version": a["version"] + 1} for a in table] # rewritten, still lost - return set(), set() - - async def get(name): - return cursors.get(name, "") - - async def put(name, value): - cursors[name] = value - - async def unparsed(org, cns): - return set() - - async def set_unparsed(org, cns, paths): - return None - - monkeypatch.setattr(code_links.store, "behind", read_behind) - monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) - monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) - monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) - monkeypatch.setattr(code_links.code, "link_cursor", get) - monkeypatch.setattr(code_links.code, "set_link_cursor", put) +async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_the_same_head( + monkeypatch, +) -> None: + w = _Stamped(monkeypatch) + w.add("old", "h0", ins=1) # stored before the first pass, still at h0 + await w.pass_at() + assert w.rechecked == [["old"]] # no cursor: the first pass rechecks what is behind + read = w.read() + await w.pass_at() # steady head, nothing inserted since + assert w.rechecked == [["old"], []] + # an older build inserts a link built at h0 after a pass at h1 read the table + await w.pass_at(between=lambda: w.add("late", "h0", ins=w.now)) + late = next(a for a in w.table if a["memory_id"] == "late") + # guidance distrusts it: it was stamped after the finished catch-up began reading + assert late["ins"] >= w.read() + await w.pass_at() + assert w.rechecked[-1] == ["late"] # the next pass rechecks it at the same head + assert late["checked_commit"] == "h1" + assert w.read() > read + + +@pytest.mark.asyncio +async def test_a_steady_head_with_no_inserts_rechecks_nothing(monkeypatch) -> None: + w = _Stamped(monkeypatch) + w.add("a", "h1") + w.add("b", "h0") # unchanged since a past pass: it keeps an older commit + await w.pass_at() + w.add("c", "h1", ins=w.now) # at the head: nothing to recheck for _ in range(3): - now = await digest("o", "code-a", "h1") - await code_link_recheck._catch_up( - "o", - "code-a", - "h1", - now, - None, - code_link_pass.PassResult(), # type: ignore[arg-type] - ) - assert rechecks == [1] # the first pass checks it; the rewrites change no digest - - -def _catch_up_world(monkeypatch, behind: list[dict[str, Any]], page: int = 100): - """A table of links behind the head, a cursor store and the rechecks made, per page.""" - cursors: dict[str, str] = {} - rechecked: list[list[str]] = [] - - async def digest_of() -> str: - return str(sorted(a["memory_id"] for a in behind)) - - async def read_behind(org, cns, head, *, after, limit): - rows = [ - a - for a in sorted(behind, key=lambda a: a["memory_id"]) - if after is None or (a["memory_id"],) > after - ] - rows = rows[:limit] - return rows, ((rows[-1]["memory_id"],) if len(rows) == limit else None) - - async def recheck_rows(org, cns, head, files, result, links): - rechecked.extend([[a["memory_id"] for a in links]] if links else []) - for a in links: - behind.remove(a) # rechecked at the head - return set(), set() - - async def get(name): - return cursors.get(name, "") - - async def put(name, value): - cursors[name] = value - - async def unparsed(org, cns): - return set() - - async def set_unparsed(org, cns, paths): - return None - - monkeypatch.setattr(settings, "memory_code_links_batch", page) - monkeypatch.setattr(code_links.store, "behind", read_behind) - monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) - monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) - monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) - monkeypatch.setattr(code_links.code, "link_cursor", get) - monkeypatch.setattr(code_links.code, "set_link_cursor", put) - - async def one_pass(head: str = "h1", *, between=None) -> None: - now = await digest_of() # read before any link, as `_recheck_repository` does - if between: - between() # a write while the pass runs - await code_link_recheck._catch_up( - "o", - "code-a", - head, - now, - None, - code_link_pass.PassResult(), # type: ignore[arg-type] - ) - - return rechecked, one_pass, cursors + await w.pass_at() + assert w.rechecked == [["b"], [], [], []] @pytest.mark.asyncio -async def test_the_first_pass_with_no_cursor_rechecks_the_links_already_behind(monkeypatch) -> None: - # an older writer's link at the previous commit, found before any pass kept a digest - behind = [_full({"memory_id": "a", "checked_commit": "h0"})] - rechecked, one_pass, _ = _catch_up_world(monkeypatch, behind) - await one_pass() - assert rechecked == [["a"]] - await one_pass() - assert rechecked == [["a"]] +async def test_a_lost_link_is_rechecked_once_and_never_rewritten_each_pass(monkeypatch) -> None: + w = _Stamped(monkeypatch) + w.add("m", "h0", state="missing") + for _ in range(3): + await w.pass_at() + assert w.rechecked == [["m"], [], []] @pytest.mark.asyncio -async def test_a_link_inserted_while_a_head_moving_pass_runs_is_not_vouched_for( +async def test_the_first_pass_after_an_upgrade_rechecks_links_stored_before_the_column( monkeypatch, ) -> None: - behind: list[dict[str, Any]] = [] - rechecked, one_pass, _ = _catch_up_world(monkeypatch, behind) - await one_pass("h0") - late = _full({"memory_id": "late", "checked_commit": "h0"}) - # the pass at the new head took its digest, then the writer inserted, then it ended - await one_pass("h1", between=lambda: behind.append(late)) - assert rechecked == [["late"]] # this pass's catch-up reads the table after the follow - await one_pass("h1") - assert rechecked == [["late"]] + w = _Stamped(monkeypatch) + w.add("a", "h0", ins=0) # an older build's link, long stored + assert "seen/o/code-a" not in w.cursors # guidance trusts no link without a cursor + await w.pass_at() + assert w.rechecked == [["a"]] + assert w.read() is not None @pytest.mark.asyncio -async def test_more_links_than_a_page_take_several_passes_and_the_digest_comes_last( +async def test_more_links_than_a_page_take_several_passes_and_the_mark_moves_last( monkeypatch, ) -> None: - behind = [_full({"memory_id": f"m{i}", "checked_commit": "h0"}) for i in range(5)] - rechecked, one_pass, cursors = _catch_up_world(monkeypatch, behind, page=2) - await one_pass() - await one_pass() - assert [len(r) for r in rechecked] == [2, 2] - assert json.loads(cursors["behind/o/code-a"])["links"] == "" # not yet vouched for - await one_pass() - assert [len(r) for r in rechecked] == [2, 2, 1] - assert json.loads(cursors["behind/o/code-a"])["links"] != "" - await one_pass() - assert [len(r) for r in rechecked] == [2, 2, 1] + w = _Stamped(monkeypatch, page=2) + for i in range(5): + w.add(f"m{i}", "h0") + await w.pass_at() + await w.pass_at() + assert [len(r) for r in w.rechecked] == [2, 2] + assert "seen/o/code-a" in w.cursors and w.read() is None # still sweeping + await w.pass_at() + assert [len(r) for r in w.rechecked] == [2, 2, 1] + assert w.read() is not None + await w.pass_at() + assert [len(r) for r in w.rechecked] == [2, 2, 1, 0] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 14b34020d8f..bd1aee4eae9 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -302,7 +302,7 @@ async def checked_head(org, ns): return "" async def link_cursor(name): - assert name == "unparsed/o/code-a" + assert name in ("unparsed/o/code-a", "seen/o/code-a") return "" monkeypatch.setattr( @@ -328,6 +328,8 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st checked = indexed fetched = "b" * 40 unparsed = "" + seen = '{"read": 500}' + stamped: set[str] = set() complete_during_read = False async def readable(org, namespaces): @@ -353,7 +355,11 @@ async def checked_head(org, ns): return checked async def link_cursor(name): - return unparsed + return seen if name.startswith("seen/") else unparsed + + async def unchecked_memories(org, cns, ids, head, since): + assert (cns, head, since) == ("code-a", checked, 500) + return stamped & set(ids) monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) @@ -366,6 +372,7 @@ async def link_cursor(name): ) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + monkeypatch.setattr(code_link_reads.store, "unchecked_memories", unchecked_memories) assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] indexed = fetched assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] @@ -374,6 +381,14 @@ async def link_cursor(name): unparsed = '["src/a.py"]' assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] unparsed = '["src/other.py"]' + # a link stamped after the last finished catch-up began reading may be one no pass saw, + # and with no finished catch-up none is known to be seen + stamped = {"m1"} + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + stamped = set() + seen = "" + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + seen = '{"read": 500}' # a link the writer parked behind a running pass is unknown even at the checked head expected = "unknown" if state == "pending" else state assert await code_link_reads.guidance_code_states("o", [row]) == [expected] diff --git a/tests/unit/test_schema_baseline.py b/tests/unit/test_schema_baseline.py index f0aff2c8dda..b3012681afd 100644 --- a/tests/unit/test_schema_baseline.py +++ b/tests/unit/test_schema_baseline.py @@ -171,6 +171,7 @@ def test_the_journal_files() -> None: "113_oauth_verified_email.sql", "114_memory_proposal_review.sql", "115_memory_refusals.sql", + "116_memory_code_link_inserted_at.sql", ] From 9a0357c1276dd66286fcbdf173b788af281eaf98 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 20:45:40 +0530 Subject: [PATCH 055/117] schema.sql carries memory_code_links.inserted_at Dumped from migration 116 applied on an empty ClickHouse. Signed-off-by: Krishna Dobhal --- schemas/schema.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/schemas/schema.sql b/schemas/schema.sql index 2b8590f2d8c..5955f1949ed 100644 --- a/schemas/schema.sql +++ b/schemas/schema.sql @@ -2699,6 +2699,7 @@ CREATE TABLE IF NOT EXISTS loom.memory_code_links `checked_at` DateTime DEFAULT now(), `tombstoned_at` Nullable(DateTime) DEFAULT NULL, `version` UInt64 DEFAULT toUInt64(toUnixTimestamp64Nano(now64(9))), + `inserted_at` DateTime64(3) DEFAULT now64(3), INDEX idx_memory_code_links_memory_id memory_id TYPE bloom_filter GRANULARITY 1, INDEX idx_memory_code_links_memory_key memory_key TYPE bloom_filter GRANULARITY 1, INDEX idx_memory_code_links_former_paths former.path TYPE bloom_filter GRANULARITY 1, From 7ec4e18608c26ecb2313728155d863fc527613b5 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 21:44:34 +0530 Subject: [PATCH 056/117] The link catch-up and guidance overlap by the stamp-to-commit gap A link stamped up to STAMP_LAG_MS before a pass's read can commit after it. The catch-up now starts that much before the previous read and guidance trusts only stamps older than that, so such a link is rechecked and meanwhile read as unknown. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 17 +++++++++-------- docs/architecture/rolling-upgrades.md | 13 +++++++------ server/memory/app/code_link_pass.py | 6 ++++++ server/memory/app/code_link_reads.py | 6 ++++-- server/memory/app/code_link_recheck.py | 16 ++++++---------- tests/unit/test_memory_code_links.py | 20 +++++++++++++++++++- tests/unit/test_memory_code_plane_reads.py | 6 +++--- 7 files changed, 54 insertions(+), 30 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 54bdafb45f7..5bb23538b0d 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -705,20 +705,21 @@ insert a link built at an older commit after a pass read the table. A pass at an unchanged head follows nothing, so ClickHouse stamps every link row with `inserted_at` as it is inserted, and each pass takes ClickHouse's time before it reads any link. Its catch-up (`_catch_up`) rechecks every live link not checked at the head that was stamped -since the previous pass's start, from each link's own checked commit. That covers a -link inserted at any point after the previous pass began reading, including one that -arrives while the pass itself runs. It reads a page of `memory_code_links_batch` links +since two seconds before the previous pass's start, from each link's own checked commit. +That covers a link inserted at any point after the previous pass began reading, +including one that arrives while the pass itself runs. It reads a page of `memory_code_links_batch` links in key order per pass and keeps its place in the `seen/` cursor. The cursor's `read` moves to the start of the pass only after the last page. With no cursor, as on the first pass after an upgrade, every link not at the head is rechecked once. A link a recheck leaves unchanged writes nothing, so a lost link is rechecked once and then stays out. The read side trusts a link only if it is checked at the checked head or was stamped -before `read`. A link stamped later may be one no pass has seen, and without a `read` -no link qualifies, so guidance on it is unknown until the catch-up finishes. A skew -margin of two seconds on a pass's start covers a replica whose clock runs behind. This -needs ClickHouse to assign `inserted_at` on replicas with synchronised clocks; a larger -skew than the margin needs a larger margin. +more than two seconds before `read`. A link stamped later may be one no pass has seen, +and without a `read` no link qualifies, so guidance on it is unknown until the catch-up +finishes. The two seconds (`STAMP_LAG_MS`) cover a replica whose clock runs behind and +the time a write takes to commit: the stamp is set before the row is visible. This +needs ClickHouse to assign `inserted_at` on replicas with synchronised clocks. A commit +or clock gap longer than the margin is not covered and needs a larger margin. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 3a5a0b025ae..734b9177b07 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1065,12 +1065,13 @@ separate mirror-content cleanup before serving; this account procedure does not ### Memory links written during a recheck A build that takes the repository's recheck lease to insert a memory's links adds the -column `inserted_at`, which ClickHouse fills when a replica of the -previous build omits it, and no setting. Those replicas insert without the lease, so -while they run the link worker a link can be inserted just after a pass read the table. -The next pass rechecks every link stamped since the previous pass began reading, and -guidance trusts no link stamped after that start, so such a link reads as unknown until -a pass covers it, whether or not a previous-build replica is still running. +column `inserted_at` and no setting. The column has a ClickHouse default, so an insert +from the previous build that omits it is still stamped. Those replicas insert without +the lease, so while they run the link worker a link can be inserted just after a pass +read the table. The next pass rechecks every link stamped since shortly before the +previous pass began reading, and guidance trusts no link stamped after that point, so +such a link reads as unknown until a pass covers it, whether or not a previous-build +replica is still running. ## Independent proposal approval diff --git a/server/memory/app/code_link_pass.py b/server/memory/app/code_link_pass.py index 3b87a31bb34..3a287b9d6a0 100644 --- a/server/memory/app/code_link_pass.py +++ b/server/memory/app/code_link_pass.py @@ -24,6 +24,12 @@ from server.settings import settings from server.workers import pass_context +# ponytail: ClickHouse stamps `inserted_at` on whichever replica takes the write, before the +# row commits. A link can carry a stamp this far before a pass's read and still miss it, +# from a slow clock or a slow commit. NTP-synced clocks are a precondition; a gap longer +# than this needs a larger margin. +STAMP_LAG_MS = 2000 # not a setting: a margin on the stamp-to-commit gap + log = logging.getLogger(__name__) # One host rechecks a repository at a time; the lease outlives the worker's pass budget. diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 6c57e34689e..9404cdeafd9 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -179,7 +179,9 @@ async def _seen_hits( ) -> dict[int, str]: """The hits whose memories hold no link stamped after the catch-up began reading.""" try: - unseen = await store.unchecked_memories(org, cns, [mid for _, _, mid in hits], head, read) + unseen = await store.unchecked_memories( + org, cns, [mid for _, _, mid in hits], head, max(0, read - link_pass.STAMP_LAG_MS) + ) except Exception as error: # noqa: BLE001 — unread stamps leave guidance uncertain log.debug("Guidance link stamps unavailable: %s", type(error).__name__) return {} @@ -245,7 +247,7 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) - positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) + positive: dict[tuple[str, str], list[tuple[int, str, str]]] = defaultdict(list) for index, key in candidates.items(): rows_for_hit = by_revision.get(key, []) state = guidance_link_state(rows_for_hit, readable) diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 22b319a1778..be8d20f28d1 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -125,7 +125,7 @@ async def _recheck_repository( files = link_pass.RepoReads(org, cns) head = await code.indexed_head(org, cns) checked = await code.checked_head(org, cns) - started = await store.clock() - _SKEW_MS # before any link read + started = await store.clock() # before any link read await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) @@ -308,12 +308,6 @@ async def _recheck_rows( return still, failed -# ponytail: ClickHouse stamps `inserted_at` on whichever replica takes the write, so a -# slow clock can stamp a link just before a pass's start. The margin covers a replica -# this far behind; NTP-synced clocks are a precondition, a larger skew needs a larger one. -_SKEW_MS = 2000 - - async def _catch_up( org: str, cns: str, @@ -325,10 +319,12 @@ async def _catch_up( """Recheck the links an older build inserted after the last pass read the table. A pass at an unchanged head follows nothing, so a link built at another commit would keep its state. ClickHouse stamps each link as it is inserted, and `started` is its - time (less a skew margin) before this pass read any link: every link stamped since + time before this pass read any link: every link stamped since `STAMP_LAG_MS` before the previous pass's `read` that is not checked at `head` is rechecked from its own commit, a page of the batch size per pass in key order. `read` moves to this pass's - start only after the last page, and guidance trusts no link stamped after it. With + start only after the last page, and guidance trusts no link stamped after `STAMP_LAG_MS` + before it, so a link stamped up to that much before a pass read but committed after + it is rechecked, and meanwhile not trusted. With no cursor (the first pass, or links an older build had stored) every link not at `head` is rechecked once.""" seen = link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}) @@ -339,7 +335,7 @@ async def _catch_up( org, cns, head, - cursor.get("read", 0), + max(0, cursor.get("read", 0) - link_pass.STAMP_LAG_MS), after=after, limit=int(settings.memory_code_links_batch), ) diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 08116754d45..1eb3026ff88 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6376,7 +6376,7 @@ def add(self, memory_id: str, checked_commit: str, state: str = "fresh", ins: in async def pass_at(self, head: str = "h1", *, between=None) -> None: """One pass: it takes its start first, as `_recheck_repository` does.""" - started = await code_links.store.clock() - code_link_recheck._SKEW_MS + started = await code_links.store.clock() self.now += 1000 await code_link_recheck._catch_up( "o", @@ -6416,6 +6416,24 @@ async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_ assert w.read() > read +@pytest.mark.asyncio +async def test_a_link_stamped_just_before_the_last_read_but_committed_after_it_is_rechecked( + monkeypatch, +) -> None: + w = _Stamped(monkeypatch) + await w.pass_at() + read = w.read() + assert read is not None + lag = code_link_pass.STAMP_LAG_MS + # an insert stamped inside the margin before the read that committed after it + w.add("slow", "h0", ins=read - lag + 500) + w.add("beyond", "h0", ins=read - lag - 500) # a gap past the margin is the ceiling + # guidance trusts a link only if stamped below `read - lag` + assert next(a for a in w.table if a["memory_id"] == "slow")["ins"] >= read - lag + await w.pass_at() + assert w.rechecked[-1] == ["slow"] + + @pytest.mark.asyncio async def test_a_steady_head_with_no_inserts_rechecks_nothing(monkeypatch) -> None: w = _Stamped(monkeypatch) diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index bd1aee4eae9..2ad3e1b126c 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -328,7 +328,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st checked = indexed fetched = "b" * 40 unparsed = "" - seen = '{"read": 500}' + seen = '{"read": 5000}' stamped: set[str] = set() complete_during_read = False @@ -358,7 +358,7 @@ async def link_cursor(name): return seen if name.startswith("seen/") else unparsed async def unchecked_memories(org, cns, ids, head, since): - assert (cns, head, since) == ("code-a", checked, 500) + assert (cns, head, since) == ("code-a", checked, 3000) # the read less the margin return stamped & set(ids) monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") @@ -388,7 +388,7 @@ async def unchecked_memories(org, cns, ids, head, since): stamped = set() seen = "" assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - seen = '{"read": 500}' + seen = '{"read": 5000}' # a link the writer parked behind a running pass is unknown even at the checked head expected = "unknown" if state == "pending" else state assert await code_link_reads.guidance_code_states("o", [row]) == [expected] From 07c78396621d498442c7299eeb4068468296360a Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 21:50:48 +0530 Subject: [PATCH 057/117] The stamp-margin test calls guidance and pins the boundary The test runs _seen_hits against a store that applies the stamp filter, and a link stamped exactly at read minus the margin is rechecked and unseen. The _catch_up docstring is rewrapped. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_recheck.py | 5 ++--- tests/unit/test_memory_code_links.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index be8d20f28d1..ece0dcec1cc 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -324,9 +324,8 @@ async def _catch_up( commit, a page of the batch size per pass in key order. `read` moves to this pass's start only after the last page, and guidance trusts no link stamped after `STAMP_LAG_MS` before it, so a link stamped up to that much before a pass read but committed after - it is rechecked, and meanwhile not trusted. With - no cursor (the first pass, or links an older build had stored) every link not at - `head` is rechecked once.""" + it is rechecked, and meanwhile not trusted. With no cursor (the first pass, or links an + older build had stored) every link not at `head` is rechecked once.""" seen = link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}) cursor = await seen.read() after = tuple(cursor["after"]) if cursor.get("after") else None diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 1eb3026ff88..9e69c6997e2 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6427,11 +6427,18 @@ async def test_a_link_stamped_just_before_the_last_read_but_committed_after_it_i lag = code_link_pass.STAMP_LAG_MS # an insert stamped inside the margin before the read that committed after it w.add("slow", "h0", ins=read - lag + 500) + w.add("edge", "h0", ins=read - lag) # exactly at the boundary: `>=` includes it w.add("beyond", "h0", ins=read - lag - 500) # a gap past the margin is the ceiling - # guidance trusts a link only if stamped below `read - lag` - assert next(a for a in w.table if a["memory_id"] == "slow")["ins"] >= read - lag + + async def unchecked(org, cns, ids, head, since): + return {a["memory_id"] for a in w.table if a["memory_id"] in ids and a["ins"] >= since} + + monkeypatch.setattr(code_links.store, "unchecked_memories", unchecked) + hits = [(i, "fresh", m) for i, m in enumerate(("slow", "edge", "beyond"))] + seen = await code_link_reads._seen_hits("o", "code-a", "h1", read, hits) + assert seen == {2: "fresh"} # only `beyond` is trusted; `slow` and `edge` are unseen await w.pass_at() - assert w.rechecked[-1] == ["slow"] + assert w.rechecked[-1] == ["edge", "slow"] @pytest.mark.asyncio From 3e9a043335780b30bab2eba47e83941b752ebc4d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 22:43:28 +0530 Subject: [PATCH 058/117] Guidance trusts a link by the row it classified, not by a second lookup Each link row guidance reads carries its insert stamp, and a link not checked at the head is trusted only when stamped before the finished catch-up's read less the margin. A catch-up that rewrites the link between two reads can no longer turn it fresh. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 49 ++++++++---------- server/memory/store/code_links.py | 41 ++++----------- tests/unit/test_memory_code_links.py | 8 --- tests/unit/test_memory_code_plane_reads.py | 60 ++++++++++++++++++---- 4 files changed, 81 insertions(+), 77 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 9404cdeafd9..809d0dc1efb 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -174,33 +174,16 @@ async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, return {} -async def _seen_hits( - org: str, cns: str, head: str, read: int, hits: list[tuple[int, str, str]] -) -> dict[int, str]: - """The hits whose memories hold no link stamped after the catch-up began reading.""" - try: - unseen = await store.unchecked_memories( - org, cns, [mid for _, _, mid in hits], head, max(0, read - link_pass.STAMP_LAG_MS) - ) - except Exception as error: # noqa: BLE001 — unread stamps leave guidance uncertain - log.debug("Guidance link stamps unavailable: %s", type(error).__name__) - return {} - return {index: state for index, state, mid in hits if mid not in unseen} - - async def _confirm( org: str, - positive: dict[tuple[str, str], list[tuple[int, str, str]]], - coverage: dict[str, Any], + positive: dict[tuple[str, str], list[tuple[int, str]]], states: list[str], ) -> None: - """Serve the positive states of the repositories whose checked head is the indexed - one, for the memories no link stamped after the finished catch-up began reading.""" + """Serve the positive states of the repositories whose checked head is the indexed one.""" indexed = await _guidance_indexed_heads(org, [cns for cns, _ in positive]) for (cns, checked_head), hits in positive.items(): - read = coverage[cns][2] - if indexed.get(cns) == checked_head and read is not None: - for index, state in (await _seen_hits(org, cns, checked_head, read, hits)).items(): + if indexed.get(cns) == checked_head: + for index, state in hits: states[index] = state @@ -243,11 +226,11 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l except Exception as error: # noqa: BLE001 — unavailable links leave guidance uncertain log.debug("Guidance code links unavailable: %s", type(error).__name__) return states - by_revision: dict[tuple[str, str, str, str], list[LinkRow]] = defaultdict(list) + by_revision: dict[tuple[str, str, str, str], list[store.StampedLink]] = defaultdict(list) for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) - positive: dict[tuple[str, str], list[tuple[int, str, str]]] = defaultdict(list) + positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) for index, key in candidates.items(): rows_for_hit = by_revision.get(key, []) state = guidance_link_state(rows_for_hit, readable) @@ -255,13 +238,21 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, owed, _ = proof - if not checked_head or any(link["path"] in owed for link in rows_for_hit): + checked_head, owed, read = proof + # A link stamped after the last finished catch-up began reading may be one no + # pass has seen; the stamp is on the row classified, so no later write can + # change what it says about itself. + cut = max(0, read - link_pass.STAMP_LAG_MS) if read is not None else 0 + if not checked_head or any( + link["path"] in owed + or (link["checked_commit"] != checked_head and link["inserted_ms"] >= cut) + for link in rows_for_hit + ): continue - positive[key[2], checked_head].append((index, state, key[0])) + positive[key[2], checked_head].append((index, state)) else: states[index] = state - await _confirm(org, positive, coverage, states) + await _confirm(org, positive, states) return states @@ -298,7 +289,9 @@ async def links_of(org: str, memory: dict[str, Any]) -> list[CodeLink]: tags = [str(t) for t in memory.get("tags") or []] if not code_namespace_for(org, str(memory["namespace"]), tags): return [] # no link is made from a memory that names no repository - rows = current(org, memory, await store.for_memories(org, [str(memory["mid"])])) + rows = current( + org, memory, cast("list[LinkRow]", await store.for_memories(org, [str(memory["mid"])])) + ) seen = await readable_namespaces(org, {a["code_namespace"] for a in rows}) except Exception as e: # noqa: BLE001 — the links are additive to the read log.debug("code links unavailable: %s", e) diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index e0db5b7f629..9dfea9caa1a 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -87,6 +87,10 @@ def _empty(hint: Any) -> Any: } +class StampedLink(LinkRow): + inserted_ms: int # ClickHouse's time (ms) the row was inserted, read only + + class PendingLink(LinkRow): expired: int # older than the days `pending` was asked for @@ -285,17 +289,18 @@ def tombstones(rows: Sequence[LinkRow]) -> list[LinkRow]: async def for_memories( org: str, memory_ids: Sequence[str], *, ch: _CHClient | None = None -) -> list[LinkRow]: - """Live links of these memories.""" +) -> list[StampedLink]: + """Live links of these memories, each with the time it was inserted.""" if not memory_ids: return [] rows = await query_all_sliced( ch or _default_client(), - f"SELECT * {_LIVE} AND org = {{org:String}} AND memory_id IN {{ids:Array(UUID)}}", + "SELECT *, toUnixTimestamp64Milli(inserted_at) AS inserted_ms " + f"{_LIVE} AND org = {{org:String}} AND memory_id IN {{ids:Array(UUID)}}", {"org": org, "ids": sorted({str(i) for i in memory_ids})}, "ids", ) - return _links(rows) + return cast(list[StampedLink], _links(rows)) async def for_paths( @@ -497,34 +502,6 @@ async def inserted_since( return rows, _key(rows[-1]) if len(rows) == int(limit) else None -async def unchecked_memories( - org: str, - code_namespace: str, - memory_ids: Sequence[str], - head: str, - since: int, - *, - ch: _CHClient | None = None, -) -> set[str]: - """The memories among `memory_ids` with a live link not checked at `head` that was - inserted at or after `since` (ms).""" - rows = await query_all_sliced( - ch or _default_client(), - "SELECT DISTINCT memory_id " - + _UNCHECKED.format(_LIVE=_LIVE) - + " AND memory_id IN {ids:Array(UUID)}", - { - "org": org, - "cns": code_namespace, - "head": head, - "since": since, - "ids": sorted(set(memory_ids)), - }, - "ids", - ) - return {str(r["memory_id"]) for r in rows} - - async def stale_fingerprints( org: str, code_namespace: str, diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 9e69c6997e2..59404955922 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -6429,14 +6429,6 @@ async def test_a_link_stamped_just_before_the_last_read_but_committed_after_it_i w.add("slow", "h0", ins=read - lag + 500) w.add("edge", "h0", ins=read - lag) # exactly at the boundary: `>=` includes it w.add("beyond", "h0", ins=read - lag - 500) # a gap past the margin is the ceiling - - async def unchecked(org, cns, ids, head, since): - return {a["memory_id"] for a in w.table if a["memory_id"] in ids and a["ins"] >= since} - - monkeypatch.setattr(code_links.store, "unchecked_memories", unchecked) - hits = [(i, "fresh", m) for i, m in enumerate(("slow", "edge", "beyond"))] - seen = await code_link_reads._seen_hits("o", "code-a", "h1", read, hits) - assert seen == {2: "fresh"} # only `beyond` is trusted; `slow` and `edge` are unseen await w.pass_at() assert w.rechecked[-1] == ["edge", "slow"] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 2ad3e1b126c..ed388341da4 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -175,6 +175,8 @@ def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", ** "state": state, "changed_since": kw.get("since", ""), "fingerprint_version": kw.get("version", fingerprint_version()), + "checked_commit": kw.get("checked", "a" * 40), + "inserted_ms": kw.get("stamped", 0), } @@ -329,7 +331,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st fetched = "b" * 40 unparsed = "" seen = '{"read": 5000}' - stamped: set[str] = set() + stamped = 0 complete_during_read = False async def readable(org, namespaces): @@ -340,7 +342,7 @@ async def links(org, ids): nonlocal checked if complete_during_read: checked = indexed - return [_link("m1", state=state)] + return [_link("m1", state=state, checked="c" * 40, stamped=stamped)] async def all_state_many(pairs): assert pairs == [("o", "code-a")] @@ -357,10 +359,6 @@ async def checked_head(org, ns): async def link_cursor(name): return seen if name.startswith("seen/") else unparsed - async def unchecked_memories(org, cns, ids, head, since): - assert (cns, head, since) == ("code-a", checked, 3000) # the read less the margin - return stamped & set(ids) - monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.store, "for_memories", links) @@ -372,7 +370,6 @@ async def unchecked_memories(org, cns, ids, head, since): ) monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) - monkeypatch.setattr(code_link_reads.store, "unchecked_memories", unchecked_memories) assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] indexed = fetched assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] @@ -383,9 +380,10 @@ async def unchecked_memories(org, cns, ids, head, since): unparsed = '["src/other.py"]' # a link stamped after the last finished catch-up began reading may be one no pass saw, # and with no finished catch-up none is known to be seen - stamped = {"m1"} + # (the cut is the read less the margin: 5000 - 2000) + stamped = 3000 assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - stamped = set() + stamped = 2999 seen = "" assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] seen = '{"read": 5000}' @@ -394,6 +392,50 @@ async def unchecked_memories(org, cns, ids, head, since): assert await code_link_reads.guidance_code_states("o", [row]) == [expected] +async def test_guidance_judges_a_late_link_by_the_row_it_classified(monkeypatch) -> None: + """The catch-up rewrites a late link at the head while guidance reads it: the stamp + that decides coverage is on the row guidance classified, so it stays unknown.""" + from server.memory.app import code_link_reads + + head = "a" * 40 + reads = 0 + + async def readable(org, namespaces): + return namespaces + + async def links(org, ids): + nonlocal reads + reads += 1 + # the first read sees the late link (built at another commit, stamped after the + # cut); a second read would see the catch-up's rewrite at the head + return [_link("m1", checked="c" * 40 if reads == 1 else head, stamped=4000)] + + async def link_cursor(name): + return '{"read": 5000}' if name.startswith("seen/") else "" + + async def checked_head(org, ns): + return head + + async def all_state_many(pairs): + return {("o", "code-a"): {"clone_head": {"value": head}, "git_head": {"value": head}}} + + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", links) + monkeypatch.setattr( + code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") + ) + monkeypatch.setattr( + code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) + ) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + assert await code_link_reads.guidance_code_states("o", [_excerpt("m1", "allowed")]) == [ + "unknown" + ] + assert reads == 1 + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] From 0b707106d24785b1ae0069dcd8d0d18d87386e23 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 22:43:28 +0530 Subject: [PATCH 059/117] A code lesson keeps the links its code moved to CodeLesson declares the optional code_moved field, so validating a lesson no longer drops the previous path and symbol. Signed-off-by: Krishna Dobhal --- sdk/python/loom/ops.py | 1 + sdk/typescript/src/generated/ops.ts | 1 + server/code/domain/lesson.py | 3 +++ tests/unit/test_code_result_lessons.py | 8 ++++++++ 4 files changed, 13 insertions(+) diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 34d23c2b702..fc03176fe3e 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -6030,6 +6030,7 @@ class CodeLesson(TypedDict, total=False): code_state: NotRequired[str] path: NotRequired[str] changed_since: NotRequired[str] + code_moved: NotRequired[list[dict[str, Any]]] supersedes_key: NotRequired[str] suggestion: NotRequired[str] owner_symbol: NotRequired[str] diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index 9dab95c566f..c1f099dfc2a 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -464,6 +464,7 @@ export interface CodeLesson { code_state?: string; path?: string; changed_since?: string; + code_moved?: Array>; supersedes_key?: string; suggestion?: string; owner_symbol?: string; diff --git a/server/code/domain/lesson.py b/server/code/domain/lesson.py index 949dfc9dd82..bf9f8504fc2 100644 --- a/server/code/domain/lesson.py +++ b/server/code/domain/lesson.py @@ -1,5 +1,7 @@ """A memory excerpt attached to a code result or symbol definition.""" +from typing import Any + from pydantic import TypeAdapter from typing_extensions import TypedDict @@ -13,6 +15,7 @@ class CodeLesson(TypedDict, total=False): code_state: str path: str changed_since: str + code_moved: list[dict[str, Any]] supersedes_key: str suggestion: str owner_symbol: str diff --git a/tests/unit/test_code_result_lessons.py b/tests/unit/test_code_result_lessons.py index e570ea596e4..2800ba93c3a 100644 --- a/tests/unit/test_code_result_lessons.py +++ b/tests/unit/test_code_result_lessons.py @@ -1111,3 +1111,11 @@ async def test_unlimited_lessons_keep_all_selected_rows(monkeypatch: pytest.Monk ] found = await _lessons(monkeypatch, {"a.py": rows}, ["a.py"], budget=0) assert {row["memory_key"] for row in found} == {str(i) for i in range(8)} + + +def test_a_lesson_keeps_the_links_the_code_moved_to() -> None: + from server.code.domain.lesson import code_lessons + + moved = [{"path": "b.py", "symbol": "g", "state": "moved", "was_path": "a.py"}] + [kept] = code_lessons.validate_python([{"memory_key": "k", "code_moved": moved}]) + assert kept["code_moved"] == moved From f74754a37e800b2521568645794da47fd7efdd7b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sat, 28 Nov 2026 22:43:29 +0530 Subject: [PATCH 060/117] Recall Lab keeps a legacy hit's score on the keyword row it resolves to When the writer lookup finds the keyword row for the same memory, that row takes the ranked hit instead of showing dashes. Signed-off-by: Krishna Dobhal --- .../src/views/RecallLab.memoriesOrder.test.tsx | 2 ++ frontend/src/views/RecallLab.tsx | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index 8e815a77dd1..c54100395e7 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -139,6 +139,8 @@ describe("Recall Lab and the Memories list", () => { await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); await screen.findByText("keyword match", {}, { timeout: 3000 }); await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(1)); + // The merged row keeps the ranked hit's score. + await waitFor(() => expect(screen.getByText("0.900")).toBeTruthy()); }); it("keeps a legacy hit that another writer's row of the same key holds", async () => { diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 69feeaa6489..640da0a6ecd 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -556,13 +556,14 @@ export function RecallLab() { const writer = await resolveSearchWriter(identity, h, ac.signal).catch(() => undefined); if (!writer || ac.signal.aborted) continue; const named = rowIdentity(identity.namespace, { ...h, ...writer }); - setRows((cur) => - cur === null - ? cur - : cur.some((x) => x.id === named) - ? cur.filter((x) => x.id !== id) - : cur.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)), - ); + setRows((cur) => { + const mine = cur?.find((x) => x.id === id); + if (!cur || !mine) return cur; + // The keyword row that holds the hit gains its score and evidence. + if (cur.some((x) => x.id === named)) + return cur.filter((x) => x.id !== id).map((x) => (x.id === named ? { ...x, hit: mine.hit } : x)); + return cur.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)); + }); } }; void Promise.all(Array.from({ length: LOOKUPS_IN_FLIGHT }, lookup)); From 67950fe6903a8f4d45f918be5943dc4da2ab38ad Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 04:17:37 +0530 Subject: [PATCH 061/117] Recall Lab moves a ranked hit onto a keyword row only for the same revision A hit whose revision differs from the keyword row's keeps its own row, excerpt and score. Signed-off-by: Krishna Dobhal --- .../views/RecallLab.memoriesOrder.test.tsx | 27 +++++++++++++++++++ frontend/src/views/RecallLab.tsx | 11 +++++--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index c54100395e7..cd33f273363 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -143,6 +143,33 @@ describe("Recall Lab and the Memories list", () => { await waitFor(() => expect(screen.getByText("0.900")).toBeTruthy()); }); + it("keeps a legacy hit with its own text when the keyword row shows another revision", async () => { + const held = { ...entry("older_azure"), user_id: "u", session_id: "s", version_text: "v2" }; + held.value = "Azure cache uses provider B"; + const page = { entries: [held], total: 1, today: 0, truncated: false }; + vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [ + { + ...hit("older_azure", 0.9), + content_excerpt: "Azure cache uses provider A", + version_text: "v1", + user_id: undefined, + session_id: undefined, + }, + ], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await screen.findByText("Azure cache uses provider B", {}, { timeout: 3000 }); + await waitFor(() => expect(screen.getByText("Azure cache uses provider A")).toBeTruthy()); + expect(screen.getAllByText("older_azure")).toHaveLength(2); + expect(screen.getAllByText("0.900")).toHaveLength(1); // the score stays on the ranked hit's own row + }); + it("keeps a legacy hit that another writer's row of the same key holds", async () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; const other = { ...entry("older_azure"), user_id: "v", session_id: "t" }; diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index 640da0a6ecd..e12713ec4f8 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -279,6 +279,7 @@ interface RecallRow { keyword: boolean; writer: SearchWriter; hit?: SearchHit; + version?: string; // the keyword row's revision, which a ranked hit must match to merge into it } // Writer lookups a search runs at once. @@ -543,6 +544,7 @@ export function RecallLab() { keyword: entry !== undefined, writer: row, hit, + version: entry?.version_text, }; }), ); @@ -559,10 +561,13 @@ export function RecallLab() { setRows((cur) => { const mine = cur?.find((x) => x.id === id); if (!cur || !mine) return cur; - // The keyword row that holds the hit gains its score and evidence. - if (cur.some((x) => x.id === named)) + // The keyword row that holds the hit's revision gains its score and evidence; a row + // showing another revision stays as it is, and the hit keeps its own row and text. + const held = cur.find((x) => x.id === named); + if (held && held.version === mine.hit?.version_text) return cur.filter((x) => x.id !== id).map((x) => (x.id === named ? { ...x, hit: mine.hit } : x)); - return cur.map((x) => (x.id === id ? { ...x, id: named, writer: { ...x.writer, ...writer } } : x)); + const rowId = held ? id : named; + return cur.map((x) => (x.id === id ? { ...x, id: rowId, writer: { ...x.writer, ...writer } } : x)); }); } }; From 34bd6754b3ab36a3edf7dd6f9423b53fd15eb2d6 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 04:18:47 +0530 Subject: [PATCH 062/117] Guidance docstring says a missing catch-up read leaves links at the head trusted Without a finished catch-up every link not checked at the head counts as stamped after it. A test covers links at the head under an empty cursor. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 3 ++- tests/unit/test_memory_code_plane_reads.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 809d0dc1efb..b52a867d32f 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -157,7 +157,8 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str], int | None]: """The head the repository's links were last checked at, the paths still owed a recheck, and the ClickHouse time (ms) the last finished catch-up began reading at - (None before one finished): a link stamped after it may be one no pass has seen.""" + (None before one finished, when every link not checked at the head counts as stamped + after it): a link stamped after it may be one no pass has seen.""" checked = await code.checked_head(org, cns) owed = set(await unparsed_cursor(org, cns).read()) if checked else set() read = (await link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}).read()).get("read") diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index ed388341da4..bfbe3e1d50f 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -332,6 +332,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st unparsed = "" seen = '{"read": 5000}' stamped = 0 + at_head = False complete_during_read = False async def readable(org, namespaces): @@ -342,7 +343,7 @@ async def links(org, ids): nonlocal checked if complete_during_read: checked = indexed - return [_link("m1", state=state, checked="c" * 40, stamped=stamped)] + return [_link("m1", state=state, checked=indexed if at_head else "c" * 40, stamped=stamped)] async def all_state_many(pairs): assert pairs == [("o", "code-a")] @@ -386,6 +387,12 @@ async def link_cursor(name): stamped = 2999 seen = "" assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + # without a finished catch-up, links checked at the head still count + at_head = True + assert await code_link_reads.guidance_code_states("o", [row]) == [ + "unknown" if state == "pending" else state + ] + at_head = False seen = '{"read": 5000}' # a link the writer parked behind a running pass is unknown even at the checked head expected = "unknown" if state == "pending" else state From 1a333f158df50e608b27967c6e39e334a8b7cad3 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 05:32:52 +0530 Subject: [PATCH 063/117] Recall Lab merges a ranked hit into a keyword row only when both revisions are known and equal Signed-off-by: Krishna Dobhal --- .../views/RecallLab.memoriesOrder.test.tsx | 37 +++++++++++++++++++ frontend/src/views/RecallLab.table.test.tsx | 2 + frontend/src/views/RecallLab.tsx | 29 +++++++++++++-- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index cd33f273363..d0af042e529 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -24,6 +24,7 @@ const entry = (memory_key: string): MemoryListEntry => ({ user_id: "-", session_id: "-", value: `value of ${memory_key}`, + version_text: "v1", }); const hit = (memory_key: string, rank_score: number): SearchHit => ({ @@ -38,6 +39,7 @@ const hit = (memory_key: string, rank_score: number): SearchHit => ({ user_id: "-", session_id: "-", score_components: { semantic: 0.6 }, + version_text: "v1", }); vi.mock("../api", async (importOriginal) => { @@ -170,6 +172,41 @@ describe("Recall Lab and the Memories list", () => { expect(screen.getAllByText("0.900")).toHaveLength(1); // the score stays on the ranked hit's own row }); + it.each([ + ["the keyword row", { version_text: undefined }, {}], + ["the hit", {}, { version_text: undefined }], + ["both", { version_text: undefined }, { version_text: undefined }], + ])("does not merge a legacy hit when the revision is missing on %s", async (_n, mine, theirs) => { + const held = { ...entry("older_azure"), user_id: "u", session_id: "s", ...mine }; + const page = { entries: [held], total: 1, today: 0, truncated: false }; + vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined, ...theirs }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(2), { timeout: 3000 }); + }); + + it("does not merge a named-writer hit that holds another revision", async () => { + const held = { ...entry("older_azure"), version_text: "v2" }; + held.value = "Azure cache uses provider B"; + vi.mocked(listMemories).mockResolvedValueOnce({ entries: [held], total: 1, today: 0, truncated: false }); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), content_excerpt: "Azure cache uses provider A", version_text: "v1" }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await screen.findByText("Azure cache uses provider B", {}, { timeout: 3000 }); + expect(screen.getByText("Azure cache uses provider A")).toBeTruthy(); + expect(screen.getAllByText("older_azure")).toHaveLength(2); + }); + it("keeps a legacy hit that another writer's row of the same key holds", async () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; const other = { ...entry("older_azure"), user_id: "v", session_id: "t" }; diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index 1ba19ea50fd..7e4bc6165fa 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -31,6 +31,7 @@ const hit = (key: string, rank_score: number, extra: Partial = {}): S rank_score, confidence: 1, score_components: { semantic: 0.6, entity_ann_boost_effective: 0.06 }, + version_text: "v1", ...extra, }); @@ -45,6 +46,7 @@ const entry = (memory_key: string): MemoryListEntry => ({ tags: [], agent: "claude-code", value: `value of ${memory_key}`, + version_text: "v1", }); async function score(text = "deploy") { diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index e12713ec4f8..a4387b233e2 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -503,7 +503,7 @@ export function RecallLab() { const kw = await listMemories(identity, KEYWORD_PAGE, { contains: q, // `sensitivity` comes with every entry; naming it would 422 on an older replica - fields: ["memory_key", "memory_type", "value", "agent", "user_id", "session_id"], + fields: ["memory_key", "memory_type", "value", "agent", "user_id", "session_id", "version_text"], previewChars: 200, signal: ac.signal, }).catch(() => null); @@ -529,11 +529,34 @@ export function RecallLab() { const order = keywordThenRanked([...keyword.keys()], [...ranked.keys()]); setRowsQuery(q); setRows( - order.flatMap((id) => { + order.flatMap((id): RecallRow | RecallRow[] => { const hit = ranked.get(id); const entry = keyword.get(id); const row = hit ?? entry; if (!row) return []; + // A named hit joins the keyword row that holds it only at the same, known revision. + if (hit && entry && !(entry.version_text && entry.version_text === hit.version_text)) { + return [ + { + id, + key: entry.memory_key, + text: entry.sensitivity === "high" ? SENSITIVE_LABEL : previewValue(entry.value), + memoryType: entry.memory_type ?? "", + keyword: true, + writer: entry, + version: entry.version_text, + }, + { + id: `${id}:ranked`, + key: hit.memory_key, + text: hit.content_excerpt ?? "", + memoryType: hit.memory_type ?? "", + keyword: false, + writer: hit, + hit, + }, + ]; + } return { id, key: row.memory_key, @@ -564,7 +587,7 @@ export function RecallLab() { // The keyword row that holds the hit's revision gains its score and evidence; a row // showing another revision stays as it is, and the hit keeps its own row and text. const held = cur.find((x) => x.id === named); - if (held && held.version === mine.hit?.version_text) + if (held?.version && held.version === mine.hit?.version_text) return cur.filter((x) => x.id !== id).map((x) => (x.id === named ? { ...x, hit: mine.hit } : x)); const rowId = held ? id : named; return cur.map((x) => (x.id === id ? { ...x, id: rowId, writer: { ...x.writer, ...writer } } : x)); From dcda05951876a0ee6c9d608255d207d3a33e8fb4 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 08:31:30 +0530 Subject: [PATCH 064/117] The code link insert-stamp migration takes number 118 Signed-off-by: Krishna Dobhal --- ...ink_inserted_at.sql => 118_memory_code_link_inserted_at.sql} | 0 tests/unit/test_schema_baseline.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename schemas/migrations/{116_memory_code_link_inserted_at.sql => 118_memory_code_link_inserted_at.sql} (100%) diff --git a/schemas/migrations/116_memory_code_link_inserted_at.sql b/schemas/migrations/118_memory_code_link_inserted_at.sql similarity index 100% rename from schemas/migrations/116_memory_code_link_inserted_at.sql rename to schemas/migrations/118_memory_code_link_inserted_at.sql diff --git a/tests/unit/test_schema_baseline.py b/tests/unit/test_schema_baseline.py index 5b5d824f850..d2dba7964b2 100644 --- a/tests/unit/test_schema_baseline.py +++ b/tests/unit/test_schema_baseline.py @@ -171,8 +171,8 @@ def test_the_journal_files() -> None: "113_oauth_verified_email.sql", "114_memory_proposal_review.sql", "115_memory_refusals.sql", - "116_memory_code_link_inserted_at.sql", "117_code_term_df_unchanged_refresh.sql", + "118_memory_code_link_inserted_at.sql", ] From 6e8c49fc0b12b98248996963e6650d5f97f8e5b0 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 08:31:30 +0530 Subject: [PATCH 065/117] Remove the root work plan Signed-off-by: Krishna Dobhal --- plan.md | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 plan.md diff --git a/plan.md b/plan.md deleted file mode 100644 index b6d67cec934..00000000000 --- a/plan.md +++ /dev/null @@ -1,12 +0,0 @@ -# Retrieved knowledge use guidance - -Give agents a deterministic next step for each maintained item they can read. The projection runs after authorization, on the served revision. Ranking, publication and procedure matching keep their existing rules. - -1. Define the pure domain projection and typed output. Keep source class, lifecycle, review requirement, content-bound attestation, source and code freshness, and disputes separately inspectable. Prefer inspect_only, clarify_dispute, recheck_source, obtain_review, validate_lead for unavailable required evidence, then follow_if_applicable for eligible current human review. Other leads remain usable with validation. Emit all applicable reasons in stable order. -2. Wire memory.search first, including first-page tiers and parked pages. Use exact identities and revisions from the active authority. Withhold inaccessible or erased artifacts. Treat missing optional evidence as unknown. Keep computed guidance out of shared caches. -3. Once the contract is fixed, propagate through unified search, authorized document reads, memory.for_file and code lessons. Preserve structured guidance in HTTP, SDK and MCP output, including compact representations. -4. Carry guidance for the actually served citations through context assembly, startup, decisions, procedures and stacks. Preserve source publication and budget boundaries. -5. Show the server decision and reasons in dashboard search. Document precedence, unknown states, and host policy responsibilities. Regenerate SDKs, operation references and reach inventory. -6. Verify the decision table, revision and scope parity, access revocation, edits, erasure, pagination, rendering and client compatibility. Use isolated dependencies and a private database for live checks. - -Sol workers implement and verify the memory read path, file and document adapters, context and clients in dependency order. Keep public issue and pull request actions separate from local implementation. From 069a49d1fa9fa65709e960f4360dd1983beabd41 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:40 +0530 Subject: [PATCH 066/117] Recall Lab shows a ranked hit beside a row of another revision as preview-only Signed-off-by: Krishna Dobhal --- frontend/src/views/RecallLab.memoriesOrder.test.tsx | 5 ++++- frontend/src/views/RecallLab.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index d0af042e529..73bfcee7ae2 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -204,7 +204,10 @@ describe("Recall Lab and the Memories list", () => { await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); await screen.findByText("Azure cache uses provider B", {}, { timeout: 3000 }); expect(screen.getByText("Azure cache uses provider A")).toBeTruthy(); - expect(screen.getAllByText("older_azure")).toHaveLength(2); + const keys = screen.getAllByRole("button", { name: "older_azure" }) as HTMLButtonElement[]; + expect(keys).toHaveLength(2); + // Only the keyword row at revision 2 opens the inspector; the older ranked row is preview-only. + expect(keys.map((b) => b.disabled)).toEqual([false, true]); }); it("keeps a legacy hit that another writer's row of the same key holds", async () => { diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index a4387b233e2..bf0a8da3505 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -280,13 +280,14 @@ interface RecallRow { writer: SearchWriter; hit?: SearchHit; version?: string; // the keyword row's revision, which a ranked hit must match to merge into it + preview?: boolean; // a hit beside a row of another revision: the inspector would open that row } // Writer lookups a search runs at once. const LOOKUPS_IN_FLIGHT = 4; function canInspect(row: RecallRow): boolean { - return namesWriter(row.writer) && !row.key.startsWith("chunk:"); + return namesWriter(row.writer) && !row.preview && !row.key.startsWith("chunk:"); } function recallRowId( @@ -554,6 +555,7 @@ export function RecallLab() { keyword: false, writer: hit, hit, + preview: true, }, ]; } @@ -590,7 +592,9 @@ export function RecallLab() { if (held?.version && held.version === mine.hit?.version_text) return cur.filter((x) => x.id !== id).map((x) => (x.id === named ? { ...x, hit: mine.hit } : x)); const rowId = held ? id : named; - return cur.map((x) => (x.id === id ? { ...x, id: rowId, writer: { ...x.writer, ...writer } } : x)); + return cur.map((x) => + x.id === id ? { ...x, id: rowId, writer: { ...x.writer, ...writer }, preview: Boolean(held) } : x, + ); }); } }; From ccb40d55e7f139c5c50731f053722568412cd3d9 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:40 +0530 Subject: [PATCH 067/117] A search reads the previews of unseen hits four at a time Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 22 +++++++++++++++++++++ frontend/src/views/memoryListReads.ts | 24 ++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index b93ef10a8e0..ffebf7b06df 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -282,6 +282,28 @@ describe("Recent search with one key written by two sessions", () => { expect(await screen.findByText(SENSITIVE_LABEL)).toBeInTheDocument(); }); + it("reads the previews of several unseen hits a few at a time", async () => { + const keys = Array.from({ length: 12 }, (_, i) => `hit${i}`); + let running = 0; + let peak = 0; + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + if (!opts?.prefix) return { entries: [], total: 0, today: 0, truncated: false }; + running++; + peak = Math.max(peak, running); + await new Promise((resolve) => setTimeout(resolve, 5)); + running--; + return { entries: keys.map((k) => written(k)), total: 12, today: 0, truncated: false }; + }); + vi.mocked(searchMemory).mockResolvedValue({ + results: keys.map((k) => ranked(k)), + embedding_model: "fake", + } as never); + await search(); + await screen.findByText(`note of session ${keys[11]}`); + expect(peak).toBeLessThanOrEqual(4); + expect(vi.mocked(listMemories).mock.calls.filter(([, , o]) => o?.prefix)).toHaveLength(12); + }); + it("pages past a page whose rows the server read but no longer serves", async () => { vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { if (!opts?.prefix) diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 370d1dbabfd..049e4f0d40d 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -91,6 +91,26 @@ async function readSearchPreview( return null; } +// Preview reads a search runs at once: the server has no multi-key list, so a result page +// of unseen hits is read a few at a time rather than all together. +const PREVIEWS_IN_FLIGHT = 4; + +async function readSearchPreviews( + identity: Identity, + hits: SearchHit[], + signal: AbortSignal, +): Promise<(MemoryListEntry | null)[]> { + const out: (MemoryListEntry | null)[] = hits.map(() => null); + let next = 0; + const worker = async () => { + for (let i = next++; i < hits.length && !signal.aborted; i = next++) { + out[i] = await readSearchPreview(identity, hits[i], signal).catch(() => null); + } + }; + await Promise.all(Array.from({ length: Math.min(PREVIEWS_IN_FLIGHT, hits.length) }, worker)); + return out; +} + /** * The Memories search: the rows holding the typed words, then the server's ranking, read * for `rawQuery` under the list's tag and agent filter. `entries` is the page the list @@ -280,9 +300,7 @@ export function useMemorySearch( setSearchExtra(new Map(kwExtra)); return; } - const fetched = await Promise.all( - unseen.map((hit) => readSearchPreview(identity, hit, ac.signal).catch(() => null)), - ); + const fetched = await readSearchPreviews(identity, unseen, ac.signal); if (cancelled) return; setSearchExtra( new Map([ From 4de9ed783a989973100594731ff14d745600424b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:40 +0530 Subject: [PATCH 068/117] A narrowed caller's source-changed marker is checked against the sources it can read Signed-off-by: Krishna Dobhal --- server/memory/app/use_guidance.py | 8 +++----- tests/unit/test_use_guidance_sources.py | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/server/memory/app/use_guidance.py b/server/memory/app/use_guidance.py index ef8bb5d9085..0c3bf5fcd4f 100644 --- a/server/memory/app/use_guidance.py +++ b/server/memory/app/use_guidance.py @@ -10,7 +10,6 @@ from server.auth.authz import row_in_scope from server.core.hashing import served_row_value -from server.identity.app.request_scope import request_narrowed from server.knowledge.app.document_reads import ordinary_source_uris from server.memory.api.models_procedure import ProcedureStatus from server.memory.domain.decision_schema import SOURCE_CHANGED_TAG @@ -47,10 +46,9 @@ async def guidance_source_states(org: str, rows: Sequence[Mapping[str, Any]]) -> """The recorded change marker applies only to a currently readable source.""" references = [_changed_document(row) for row in rows] by_ns: dict[str, set[str]] = defaultdict(set) - if not request_narrowed(): - for ref in references: - if ref: - by_ns[ref[0]].add(ref[1]) + for ref in references: + if ref: + by_ns[ref[0]].add(ref[1]) visible: set[tuple[str, str]] = set() if by_ns: reads = (_readable_documents(org, ns, uris) for ns, uris in by_ns.items()) diff --git a/tests/unit/test_use_guidance_sources.py b/tests/unit/test_use_guidance_sources.py index 218d40d3729..678e63bc48d 100644 --- a/tests/unit/test_use_guidance_sources.py +++ b/tests/unit/test_use_guidance_sources.py @@ -4,6 +4,7 @@ from server.knowledge.store import documents from server.memory.app import use_guidance as source +from server.memory.domain.use_guidance import guidance_for_row @pytest.mark.asyncio @@ -12,7 +13,6 @@ async def test_changed_source_requires_current_access_and_unambiguous_identity(m gate = AsyncMock(side_effect=lambda org, ns, **kw: ns == "team") monkeypatch.setattr(documents, "ordinary_live_source_uris", docs) monkeypatch.setattr(source, "row_in_scope", gate) - monkeypatch.setattr(source, "request_narrowed", lambda: False) rows = [ {"tags": ["source-changed"], "source_resource_id": "knowledge:" + cite} for cite in [ @@ -31,10 +31,20 @@ async def test_changed_source_requires_current_access_and_unambiguous_identity(m "changed", ] docs.assert_awaited_once_with("org", "team", ["mirror", "public"]) - docs.reset_mock() - monkeypatch.setattr(source, "request_narrowed", lambda: True) - assert await source.guidance_source_states("org", rows) == ["unknown"] * len(rows) - docs.assert_not_awaited() + + +@pytest.mark.asyncio +async def test_a_narrowed_caller_gets_recheck_source_for_a_readable_changed_source(monkeypatch): + monkeypatch.setattr(documents, "ordinary_live_source_uris", AsyncMock(return_value={"doc"})) + monkeypatch.setattr(source, "row_in_scope", AsyncMock(return_value=True)) + monkeypatch.setattr("server.identity.app.request_scope.request_narrowed", lambda: True) + row = {"tags": ["source-changed"], "source_resource_id": "knowledge:team/doc#intro"} + [state] = await source.guidance_source_states("org", [row]) + assert state == "changed" + guidance = guidance_for_row( + {"status": "active"}, source_state=state, code_state="not_applicable" + ) + assert guidance.next_step == "recheck_source" def test_noncanonical_procedure_keeps_unknown_status(): From 3f7d499a9494135612fcd21effef64f1dffe0902 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:41 +0530 Subject: [PATCH 069/117] A code lesson keeps its revision and first-written time Signed-off-by: Krishna Dobhal --- sdk/python/loom/ops.py | 2 ++ sdk/typescript/src/generated/ops.ts | 2 ++ server/code/domain/lesson.py | 2 ++ tests/unit/test_code_result_lessons.py | 7 +++++++ 4 files changed, 13 insertions(+) diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index 4456853f3d4..fa7c511e698 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -6032,6 +6032,8 @@ class CodeLesson(TypedDict, total=False): path: NotRequired[str] changed_since: NotRequired[str] code_moved: NotRequired[list[dict[str, Any]]] + rev: NotRequired[str] + first_written: NotRequired[str] supersedes_key: NotRequired[str] suggestion: NotRequired[str] owner_symbol: NotRequired[str] diff --git a/sdk/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index 0cd36f40367..2eb70b829da 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -466,6 +466,8 @@ export interface CodeLesson { path?: string; changed_since?: string; code_moved?: Array>; + rev?: string; + first_written?: string; supersedes_key?: string; suggestion?: string; owner_symbol?: string; diff --git a/server/code/domain/lesson.py b/server/code/domain/lesson.py index bf9f8504fc2..9dae0308988 100644 --- a/server/code/domain/lesson.py +++ b/server/code/domain/lesson.py @@ -16,6 +16,8 @@ class CodeLesson(TypedDict, total=False): path: str changed_since: str code_moved: list[dict[str, Any]] + rev: str + first_written: str supersedes_key: str suggestion: str owner_symbol: str diff --git a/tests/unit/test_code_result_lessons.py b/tests/unit/test_code_result_lessons.py index 2800ba93c3a..207d577591e 100644 --- a/tests/unit/test_code_result_lessons.py +++ b/tests/unit/test_code_result_lessons.py @@ -1119,3 +1119,10 @@ def test_a_lesson_keeps_the_links_the_code_moved_to() -> None: moved = [{"path": "b.py", "symbol": "g", "state": "moved", "was_path": "a.py"}] [kept] = code_lessons.validate_python([{"memory_key": "k", "code_moved": moved}]) assert kept["code_moved"] == moved + + +def test_a_lesson_keeps_its_revision_and_first_written_time() -> None: + from server.code.domain.lesson import code_lessons + + [kept] = code_lessons.validate_python([{"memory_key": "k", "rev": "2", "first_written": "t0"}]) + assert (kept["rev"], kept["first_written"]) == ("2", "t0") From 2c54889d60136c568f0e23ced3f76c2a4a486951 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:41 +0530 Subject: [PATCH 070/117] The reviewed-body test binds the hit to the head version it serves Signed-off-by: Krishna Dobhal --- tests/unit/test_unit_bodies_follow_hit_session.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_unit_bodies_follow_hit_session.py b/tests/unit/test_unit_bodies_follow_hit_session.py index 40d463739da..d3b5833038f 100644 --- a/tests/unit/test_unit_bodies_follow_hit_session.py +++ b/tests/unit/test_unit_bodies_follow_hit_session.py @@ -183,6 +183,7 @@ async def test_unit_body_keeps_approval_only_for_reviewed_content(monkeypatch, b hit.version = 42 digest = served_content_sha256("reviewed text") hit._guidance_content_sha256 = digest + hit._guidance_head_version = 42 hit.use_guidance = guidance_for_row( { "status": "active", From 79866289f383941af0ce3cc7582a3dc838a2a837 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:36:41 +0530 Subject: [PATCH 071/117] The column inventory records inserted_at as filled by the DDL only Signed-off-by: Krishna Dobhal --- tests/unit/test_repository_column_sets_match_schema.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_repository_column_sets_match_schema.py b/tests/unit/test_repository_column_sets_match_schema.py index b1a5bc7f2d1..8b5823d9cc2 100644 --- a/tests/unit/test_repository_column_sets_match_schema.py +++ b/tests/unit/test_repository_column_sets_match_schema.py @@ -39,7 +39,12 @@ "loom.qa_rollup_days", frozenset(), ), - ("server.memory.store.code_links", "LINK_COLS", "loom.memory_code_links", frozenset()), + ( + "server.memory.store.code_links", + "LINK_COLS", + "loom.memory_code_links", + frozenset({"inserted_at"}), + ), ( "server.memory.app.extraction_queue", "COLUMNS", From fdcb8c7111ed6094572439e27be3dde6f9a72c16 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 10:50:22 +0530 Subject: [PATCH 072/117] The narrowed source-guidance test binds a real own_user read scope Signed-off-by: Krishna Dobhal --- tests/unit/test_use_guidance_sources.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_use_guidance_sources.py b/tests/unit/test_use_guidance_sources.py index 678e63bc48d..12ec3b814d9 100644 --- a/tests/unit/test_use_guidance_sources.py +++ b/tests/unit/test_use_guidance_sources.py @@ -35,12 +35,23 @@ async def test_changed_source_requires_current_access_and_unambiguous_identity(m @pytest.mark.asyncio async def test_a_narrowed_caller_gets_recheck_source_for_a_readable_changed_source(monkeypatch): + from server.identity.domain.read_scope import ( + ReadFilters, + read_filters_bound, + request_read_narrowed, + ) + from tests.unit.principals import acting_as, principal + + gate = AsyncMock(return_value=True) monkeypatch.setattr(documents, "ordinary_live_source_uris", AsyncMock(return_value={"doc"})) - monkeypatch.setattr(source, "row_in_scope", AsyncMock(return_value=True)) - monkeypatch.setattr("server.identity.app.request_scope.request_narrowed", lambda: True) + monkeypatch.setattr(source, "row_in_scope", gate) row = {"tags": ["source-changed"], "source_resource_id": "knowledge:team/doc#intro"} - [state] = await source.guidance_source_states("org", [row]) + auth = principal("viewer", org="org", namespaces=("team",)) + with acting_as(auth), read_filters_bound(auth, ReadFilters("own_user", "u1", None)): + assert request_read_narrowed(auth) + [state] = await source.guidance_source_states("org", [row]) assert state == "changed" + assert gate.await_args.args[:2] == ("org", "team") guidance = guidance_for_row( {"status": "active"}, source_state=state, code_state="not_applicable" ) From 878b15daf3316765aa1da3d571ff6f9a2e9aca1d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 12:35:45 +0530 Subject: [PATCH 073/117] The Memories list asks for version_text only, and the ranked-row fixtures carry the writer and revision the dashboard matches on Signed-off-by: Krishna Dobhal --- frontend/e2e/docs-screenshots.spec.ts | 5 +++++ frontend/e2e/fixtures.ts | 3 +++ frontend/e2e/list-pages.spec.ts | 4 ++++ frontend/e2e/perf-budget.spec.ts | 18 ++++++++++++++---- frontend/src/views/Recent.renders.test.tsx | 2 ++ frontend/src/views/memoryListReads.ts | 1 - 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/e2e/docs-screenshots.spec.ts b/frontend/e2e/docs-screenshots.spec.ts index b511f17afd7..094759930d5 100644 --- a/frontend/e2e/docs-screenshots.spec.ts +++ b/frontend/e2e/docs-screenshots.spec.ts @@ -211,6 +211,7 @@ function listEntry(m: DemoMemory) { memory_type: m.type, confidence: 0.95, version: m.version ?? 1, + version_text: String(m.version ?? 1), created_at: ago(m.hours), updated_at: ago(m.hours), expires_at: null, @@ -603,6 +604,10 @@ function recallHitsFor(query: string) { memory_key: key, memory_type: m?.type ?? "semantic", content_excerpt: m?.value ?? "", + agent: m?.agent ?? "", + user_id: "-", + session_id: "-", + version_text: String(m?.version ?? 1), distance: 1 - sim, similarity: sim, rank_score: sim + boost, diff --git a/frontend/e2e/fixtures.ts b/frontend/e2e/fixtures.ts index d36bfa35ccd..259a129bbbf 100644 --- a/frontend/e2e/fixtures.ts +++ b/frontend/e2e/fixtures.ts @@ -1495,6 +1495,9 @@ function memoryRowsFixture( memory_type: i % 3 ? "semantic" : "episodic", confidence: 0.9, version: 1, + version_text: "1", + user_id: "-", + session_id: "-", created_at: `2026-09-19T0${i % 10}:${String(i % 60).padStart(2, "0")}:00Z`, expires_at: null, pinned: i % 17 === 0, diff --git a/frontend/e2e/list-pages.spec.ts b/frontend/e2e/list-pages.spec.ts index 814498d23b1..f0ac9913d80 100644 --- a/frontend/e2e/list-pages.spec.ts +++ b/frontend/e2e/list-pages.spec.ts @@ -244,6 +244,10 @@ for (const width of [375, 700, 1400]) { results: [0, 1].map((i) => ({ memory_key: `alerts/2026-09-19/000${i}`, memory_type: "semantic", + agent: i === 0 ? "ingest-lane-partition-watchdog-agent" : "alert-bot", + user_id: "-", + session_id: "-", + version_text: "1", content_excerpt: "", distance: 0.3, similarity: 0.72 - i * 0.1, diff --git a/frontend/e2e/perf-budget.spec.ts b/frontend/e2e/perf-budget.spec.ts index c3227a87410..c2b66b4ed08 100644 --- a/frontend/e2e/perf-budget.spec.ts +++ b/frontend/e2e/perf-budget.spec.ts @@ -249,9 +249,9 @@ test("the Memories search asks for memory legs only and aborts a stale search", expect(calls.search[1]).toMatchObject({ query: "exporter lane", legs: ["memory"] }); }); -// The Memories page asks for the thirteen fields its cards and its Conflicted status read and +// The Memories page asks for the fourteen fields its cards and its Conflicted status read and // the preview length they show (CARD_VALUE_CHARS); the list answers nothing else. -test("the Memories list asks for the thirteen fields the page reads and a 320-character preview", async ({ page }) => { +test("the Memories list asks for the fourteen fields the page reads and a 320-character preview", async ({ page }) => { const calls = await installApi(page, { memoryRows: 12 }); await page.goto("/memories", { waitUntil: "domcontentloaded" }); await expect(page.locator("[data-memory-key]").first()).toBeVisible(); @@ -260,10 +260,20 @@ test("the Memories list asks for the thirteen fields the page reads and a 320-ch expect(body.preview_chars, "preview_chars rides on the list request").toBe(320); const fields = stringArray(body.fields) ?? []; expect(fields.length > 0, "fields rides on the list request").toBe(true); - for (const f of ["memory_key", "value", "tags", "agent", "created_at", "pinned", "verification", "status"]) { + for (const f of [ + "memory_key", + "value", + "tags", + "agent", + "created_at", + "pinned", + "verification", + "status", + "version_text", + ]) { expect(fields, `the page asks for ${f}`).toContain(f); } - expect(fields.length, "thirteen fields, no more").toBe(13); + expect(fields.length, "fourteen fields, no more").toBe(14); for (const f of [ "entities", "source_trace", diff --git a/frontend/src/views/Recent.renders.test.tsx b/frontend/src/views/Recent.renders.test.tsx index dd9d02e76e1..e2ec71f3946 100644 --- a/frontend/src/views/Recent.renders.test.tsx +++ b/frontend/src/views/Recent.renders.test.tsx @@ -21,6 +21,7 @@ const entry = (memory_key: string): MemoryListEntry => ({ memory_type: "semantic", confidence: 1, version: 1, + version_text: "1", created_at: "2026-09-18T09:00:00Z", expires_at: null, pinned: false, @@ -52,6 +53,7 @@ vi.mock("../api", async (importOriginal) => { user_id: "user", session_id: "one", version: 1, + version_text: "1", memory_key: "coffee_pref", memory_type: "semantic", content_excerpt: "prefers oat milk in coffee", diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 049e4f0d40d..8d867d29ee1 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -33,7 +33,6 @@ const MEMORIES_LIST_FIELDS = [ "verification", "status", // The revision a hit's guidance was made for. - "version", "version_text", ]; From 694673b3708da8b2c0fc178c47e99f6cf4c37a54 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 13:04:38 +0530 Subject: [PATCH 074/117] Positive code guidance rests on a per-link covered flag, not on an insert stamp and a time margin A link is served as current when it is checked at the checkpoint or covered: inserted under the repository lease, or checked by a pass under it. A row from a build without the lease is uncovered however long its insert took, and the catch-up covers it. The checkpoint and the links are read under sequential_reads. Migration 118 adds memory_code_links.covered. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 35 ++-- docs/architecture/rolling-upgrades.md | 15 +- .../118_memory_code_link_covered.sql | 3 + .../118_memory_code_link_inserted_at.sql | 5 - schemas/schema.sql | 2 +- server/memory/app/code_link_pass.py | 6 - server/memory/app/code_link_reads.py | 44 +++-- server/memory/app/code_link_recheck.py | 79 +++++---- server/memory/app/code_links.py | 1 + server/memory/store/code_links.py | 35 ++-- tests/unit/test_memory_code_links.py | 151 ++++++------------ tests/unit/test_memory_code_plane_reads.py | 89 ++++++++--- ...est_repository_column_sets_match_schema.py | 7 +- tests/unit/test_schema_baseline.py | 2 +- 14 files changed, 222 insertions(+), 252 deletions(-) create mode 100644 schemas/migrations/118_memory_code_link_covered.sql delete mode 100644 schemas/migrations/118_memory_code_link_inserted_at.sql diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 03c5850cec3..d5baadfcf95 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -752,25 +752,22 @@ replica inserted under the lease. That holds when state writes are visible to a sequential read, which `loom doctor` checks through `select_sequential_consistency`. A build without the lease, such as the previous build during a rolling upgrade, can -insert a link built at an older commit after a pass read the table. A pass at an -unchanged head follows nothing, so ClickHouse stamps every link row with `inserted_at` -as it is inserted, and each pass takes ClickHouse's time before it reads any link. Its -catch-up (`_catch_up`) rechecks every live link not checked at the head that was stamped -since two seconds before the previous pass's start, from each link's own checked commit. -That covers a link inserted at any point after the previous pass began reading, -including one that arrives while the pass itself runs. It reads a page of `memory_code_links_batch` links -in key order per pass and keeps its place in the `seen/` cursor. The cursor's `read` -moves to the start of the pass only after the last page. With no cursor, as on the first -pass after an upgrade, every link not at the head is rechecked once. A link a recheck -leaves unchanged writes nothing, so a lost link is rechecked once and then stays out. - -The read side trusts a link only if it is checked at the checked head or was stamped -more than two seconds before `read`. A link stamped later may be one no pass has seen, -and without a `read` no link qualifies, so guidance on it is unknown until the catch-up -finishes. The two seconds (`STAMP_LAG_MS`) cover a replica whose clock runs behind and -the time a write takes to commit: the stamp is set before the row is visible. This -needs ClickHouse to assign `inserted_at` on replicas with synchronised clocks. A commit -or clock gap longer than the margin is not covered and needs a larger margin. +insert a link built at an older commit after a pass read the table, however long its +insert takes. Each link row has a `covered` flag. A writer that holds the lease inserts +its links covered, because the pass that follows sees them. A recheck writes every link +it moves or finds unchanged covered. A row from the previous build is not covered. + +The catch-up (`_catch_up`) rechecks every live link that is not covered and not checked +at the head, from its own checked commit, and writes it covered. It reads a page of +`memory_code_links_batch` links in key order per pass and keeps its place in the `seen/` +cursor, which it clears after the last page. A lost link keeps its commit and is +rechecked once. A link on a file that does not parse stays uncovered and is retried. + +The read side trusts a link only if it is checked at the checked head or covered. Any +other row, such as a late insert from the previous build, reads as unknown until the +next pass covers it. The checkpoint and the links are read together under +`sequential_reads()`, so a lagging replica cannot show an old link against a newer +checkpoint. ## Invariants diff --git a/docs/architecture/rolling-upgrades.md b/docs/architecture/rolling-upgrades.md index 715a6868664..e2556d78b96 100644 --- a/docs/architecture/rolling-upgrades.md +++ b/docs/architecture/rolling-upgrades.md @@ -1085,14 +1085,13 @@ separate mirror-content cleanup before serving; this account procedure does not ### Memory links written during a recheck -A build that takes the repository's recheck lease to insert a memory's links adds the -column `inserted_at` and no setting. The column has a ClickHouse default, so an insert -from the previous build that omits it is still stamped. Those replicas insert without -the lease, so while they run the link worker a link can be inserted just after a pass -read the table. The next pass rechecks every link stamped since shortly before the -previous pass began reading, and guidance trusts no link stamped after that point, so -such a link reads as unknown until a pass covers it, whether or not a previous-build -replica is still running. +Migration `118_memory_code_link_covered.sql` adds `memory_code_links.covered` with a +default of 0, and no setting is added. A build that takes the repository's recheck lease +inserts its links covered. The previous build omits the column, so its links are not +covered, and it inserts without the lease, so a link can arrive after a pass read the +table. Guidance on a link that is neither checked at the checked head nor covered is +unknown until the next pass covers it, whether or not a previous-build replica is still +running. ## Independent proposal approval diff --git a/schemas/migrations/118_memory_code_link_covered.sql b/schemas/migrations/118_memory_code_link_covered.sql new file mode 100644 index 00000000000..a8cd51e15de --- /dev/null +++ b/schemas/migrations/118_memory_code_link_covered.sql @@ -0,0 +1,3 @@ +-- A link a recheck pass covered, or that a writer inserted under the repository's lease at +-- its checked head. Rows stored before this are 0 and are covered by the next pass. +ALTER TABLE loom.memory_code_links ADD COLUMN IF NOT EXISTS covered UInt8 DEFAULT 0; diff --git a/schemas/migrations/118_memory_code_link_inserted_at.sql b/schemas/migrations/118_memory_code_link_inserted_at.sql deleted file mode 100644 index 0363cbfd794..00000000000 --- a/schemas/migrations/118_memory_code_link_inserted_at.sql +++ /dev/null @@ -1,5 +0,0 @@ --- ClickHouse stamps each link row as it is inserted. The recheck's catch-up and the --- guidance read it to find links written after a pass read the table. -ALTER TABLE loom.memory_code_links ADD COLUMN IF NOT EXISTS inserted_at DateTime64(3) DEFAULT now64(3); --- rows stored before the column exists would read as inserted now: give them this time -ALTER TABLE loom.memory_code_links MATERIALIZE COLUMN inserted_at; diff --git a/schemas/schema.sql b/schemas/schema.sql index c3c107bd738..aa6eef1fd90 100644 --- a/schemas/schema.sql +++ b/schemas/schema.sql @@ -2699,7 +2699,7 @@ CREATE TABLE IF NOT EXISTS loom.memory_code_links `checked_at` DateTime DEFAULT now(), `tombstoned_at` Nullable(DateTime) DEFAULT NULL, `version` UInt64 DEFAULT toUInt64(toUnixTimestamp64Nano(now64(9))), - `inserted_at` DateTime64(3) DEFAULT now64(3), + `covered` UInt8 DEFAULT 0, INDEX idx_memory_code_links_memory_id memory_id TYPE bloom_filter GRANULARITY 1, INDEX idx_memory_code_links_memory_key memory_key TYPE bloom_filter GRANULARITY 1, INDEX idx_memory_code_links_former_paths former.path TYPE bloom_filter GRANULARITY 1, diff --git a/server/memory/app/code_link_pass.py b/server/memory/app/code_link_pass.py index bcfcc88beed..b375c49b1ba 100644 --- a/server/memory/app/code_link_pass.py +++ b/server/memory/app/code_link_pass.py @@ -24,12 +24,6 @@ from server.settings import settings from server.workers import pass_context -# ponytail: ClickHouse stamps `inserted_at` on whichever replica takes the write, before the -# row commits. A link can carry a stamp this far before a pass's read and still miss it, -# from a slow clock or a slow commit. NTP-synced clocks are a precondition; a gap longer -# than this needs a larger margin. -STAMP_LAG_MS = 2000 # not a setting: a margin on the stamp-to-commit gap - log = logging.getLogger(__name__) # One host rechecks a repository at a time; the lease outlives the worker's pass budget. diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index baa54fadcac..43718878283 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -15,9 +15,9 @@ from server.code.app import memory_links as code from server.code.domain.index.remote import repo_tag from server.code.domain.index.repos import RegistryUnread, configured_repos +from server.core.ch import sequential_reads from server.core.hashing import hash_text from server.memory.api.models_crud import CodeLink -from server.memory.app import code_link_pass as link_pass from server.memory.app.code_link_pass import unparsed_cursor from server.memory.domain import code_change from server.memory.domain.files import names_file @@ -155,15 +155,12 @@ def guidance_link_state(links: Sequence[LinkRow], readable: set[str]) -> str: return state or "unknown" -async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str], int | None]: - """The head the repository's links were last checked at, the paths still owed a - recheck, and the ClickHouse time (ms) the last finished catch-up began reading at - (None before one finished, when every link not checked at the head counts as stamped - after it): a link stamped after it may be one no pass has seen.""" +async def _guidance_coverage(org: str, cns: str) -> tuple[str, set[str]]: + """The head the repository's links were last checked at and the paths still owed a + recheck.""" checked = await code.checked_head(org, cns) owed = set(await unparsed_cursor(org, cns).read()) if checked else set() - read = (await link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}).read()).get("read") - return checked, owed, read + return checked, owed async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, str]: @@ -218,17 +215,19 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l mids = sorted({mid for mid, _, cns, _ in candidates.values() if cns in readable}) if not mids: return states - # A completion published after the links read cannot vouch for those rows. + # The checkpoint is read before the links on one replica's consistency, so a lagging + # replica cannot show an old link against a newer checkpoint. namespaces = sorted(readable) - checked = await asyncio.gather( - *(_guidance_coverage(org, cns) for cns in namespaces), return_exceptions=True - ) - coverage = dict(zip(namespaces, checked, strict=True)) - links = await store.for_memories(org, mids) + with sequential_reads(): + checked = await asyncio.gather( + *(_guidance_coverage(org, cns) for cns in namespaces), return_exceptions=True + ) + coverage = dict(zip(namespaces, checked, strict=True)) + links = await store.for_memories(org, mids) except Exception as error: # noqa: BLE001 — unavailable links leave guidance uncertain log.debug("Guidance code links unavailable: %s", type(error).__name__) return states - by_revision: dict[tuple[str, str, str, str], list[store.StampedLink]] = defaultdict(list) + by_revision: dict[tuple[str, str, str, str], list[LinkRow]] = defaultdict(list) for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) @@ -240,14 +239,13 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, owed, read = proof - # A link stamped after the last finished catch-up began reading may be one no - # pass has seen; the stamp is on the row classified, so no later write can - # change what it says about itself. - cut = max(0, read - link_pass.STAMP_LAG_MS) if read is not None else 0 + checked_head, owed = proof + # A link is current at the checkpoint when it was checked there or a pass + # under the repository lease covered it; a row an older build wrote carries + # neither, so it waits for the next pass. if not checked_head or any( link["path"] in owed - or (link["checked_commit"] != checked_head and link["inserted_ms"] >= cut) + or (link["checked_commit"] != checked_head and not link["covered"]) for link in rows_for_hit ): continue @@ -291,9 +289,7 @@ async def links_of(org: str, memory: dict[str, Any]) -> list[CodeLink]: tags = [str(t) for t in memory.get("tags") or []] if not code_namespace_for(org, str(memory["namespace"]), tags): return [] # no link is made from a memory that names no repository - rows = current( - org, memory, cast("list[LinkRow]", await store.for_memories(org, [str(memory["mid"])])) - ) + rows = current(org, memory, await store.for_memories(org, [str(memory["mid"])])) seen = await readable_namespaces(org, {a["code_namespace"] for a in rows}) except Exception as e: # noqa: BLE001 — the links are additive to the read log.debug("code links unavailable: %s", e) diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 0e0907f7c91..21db82d1a55 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -135,7 +135,6 @@ async def _recheck_repository( files = link_pass.RepoReads(org, cns) head = await code.indexed_head(org, cns) checked = await code.checked_head(org, cns) - started = await store.clock() # before any link read await _recheck_pending(org, cns, head, files, result) await rehash.refingerprint(org, cns, files, result) await _retry_unparsed(org, cns, head, files, result) @@ -156,7 +155,7 @@ async def _recheck_repository( await _follow(org, cns, checked, head, files, result) await code.set_checked_head(org, cns, head) if head: - await _catch_up(org, cns, head, started, files, result) + await _catch_up(org, cns, head, files, result) result.wide_ranges += files.wide_ranges await policy.apply_policies(org, cns, head, files, budget, result) @@ -297,9 +296,12 @@ async def _recheck_rows( files: link_pass.RepoReads, result: link_pass.PassResult, links: list[LinkRow], + *, + cover: bool = False, ) -> tuple[set[str], set[str]]: """Recheck `links` at `head`, each from the commit it was last checked at; the paths - that still do not parse, and those that failed this time.""" + that still do not parse, and those that failed this time. With `cover`, a link that + did not move and whose file parsed is written covered.""" by_commit: dict[str, list[LinkRow]] = defaultdict(list) for a in links: by_commit[a["checked_commit"]].append(a) @@ -314,48 +316,54 @@ async def _recheck_rows( org, cns, by_path, paths_now, changed, head, files, still, failed ) await _write_moves(await _current_moves(org, moves), head) + if cover: + moved = {id(m.row) for m in moves} + await _write_covered( + [a for a in rows if id(a) not in moved and a["path"] not in still | failed], head + ) result.rechecked += len(moves) return still, failed +async def _write_covered(rows: list[LinkRow], head: str) -> None: + """The links a pass found unchanged, written covered above the version read.""" + await store.insert( + [ + store.link_row( + a, + follows=a["version"], + covered=1, + checked_commit=_checked_at(a, a["state"], head), + checked_at=naive_utc_now(), + ) + for a in rows + ] + ) + + async def _catch_up( - org: str, - cns: str, - head: str, - started: int, - files: link_pass.RepoReads, - result: link_pass.PassResult, + org: str, cns: str, head: str, files: link_pass.RepoReads, result: link_pass.PassResult ) -> None: - """Recheck the links an older build inserted after the last pass read the table. A + """Cover the links an older build inserted, which no lease ordered against a pass. A pass at an unchanged head follows nothing, so a link built at another commit would - keep its state. ClickHouse stamps each link as it is inserted, and `started` is its - time before this pass read any link: every link stamped since `STAMP_LAG_MS` before - the previous pass's `read` that is not checked at `head` is rechecked from its own - commit, a page of the batch size per pass in key order. `read` moves to this pass's - start only after the last page, and guidance trusts no link stamped after `STAMP_LAG_MS` - before it, so a link stamped up to that much before a pass read but committed after - it is rechecked, and meanwhile not trusted. With no cursor (the first pass, or links an - older build had stored) every link not at `head` is rechecked once.""" + keep its state; guidance serves such a link only once it is covered. Each link not + covered and not checked at `head` is rechecked from its own commit and written + covered, a page of the batch size per pass in key order; a link whose file does not + parse stays uncovered and is retried.""" seen = link_pass.Cursor[dict[str, Any]](f"seen/{org}/{cns}", {}) cursor = await seen.read() after = tuple(cursor["after"]) if cursor.get("after") else None - target = cursor["target"] if after else started - links, nxt = await store.inserted_since( - org, - cns, - head, - max(0, cursor.get("read", 0) - link_pass.STAMP_LAG_MS), - after=after, - limit=int(settings.memory_code_links_batch), + links, nxt = await store.uncovered( + org, cns, head, after=after, limit=int(settings.memory_code_links_batch) ) - still, failed = await _recheck_rows(org, cns, head, files, result, links) + still, failed = await _recheck_rows(org, cns, head, files, result, links, cover=True) await _set_unparsed(org, cns, await _unparsed(org, cns) | still) if failed: result.errors.append(f"recheck {org}/{cns}: did not parse: {', '.join(sorted(failed))}") if nxt: - await seen.write({**cursor, "target": target, "after": list(nxt)}) + await seen.write({"after": list(nxt)}) else: - await seen.write({"read": target}) + await seen.clear() async def _unparsed(org: str, cns: str) -> set[str]: @@ -1015,11 +1023,8 @@ async def _write_moves(moves: list[Move], head: str) -> None: carried=int(link.carried), # code not found: keep the commit it was last read at, so a later pass # (or a re-hash) still has the text the link was checked against - checked_commit=( - a["checked_commit"] - if link.state in _LOST_STATES and a["checked_commit"] - else head - ), + checked_commit=_checked_at(a, link.state, head), + covered=1, checked_path=link.checked_path, checked_at=naive_utc_now(), **_former(a, moved_from), @@ -1042,6 +1047,12 @@ async def _write_moves(moves: list[Move], head: str) -> None: await store.insert(store.tombstones(list(gone.values())) + rows) +def _checked_at(a: LinkRow, state: str, head: str) -> str: + """The commit a link now in `state` is checked at: one not found keeps the commit it + was last read at.""" + return a["checked_commit"] if state in _LOST_STATES and a["checked_commit"] else head + + def _edited(a: LinkRow, link: Link) -> bool: """The link reads changed for an edit not yet judged: newly, or edited again. A move or a shift of its lines is no edit.""" diff --git a/server/memory/app/code_links.py b/server/memory/app/code_links.py index a02f9549a07..90b25d3f3b0 100644 --- a/server/memory/app/code_links.py +++ b/server/memory/app/code_links.py @@ -565,6 +565,7 @@ def _link_row( anchored_hash=d.body_hash if d else "", anchored_name=qualified_name, fingerprint_version=fingerprint_version(), + covered=1, # inserted under the repository lease, which a recheck pass cannot overlap ) diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 9dfea9caa1a..08db78d3dba 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -72,6 +72,7 @@ class LinkRow(TypedDict): checked_at: datetime tombstoned_at: datetime | None version: int + covered: int # a pass under the repository lease checked it, or it was inserted under one # the columns whose default is not their type's empty value @@ -87,10 +88,6 @@ def _empty(hint: Any) -> Any: } -class StampedLink(LinkRow): - inserted_ms: int # ClickHouse's time (ms) the row was inserted, read only - - class PendingLink(LinkRow): expired: int # older than the days `pending` was asked for @@ -289,18 +286,17 @@ def tombstones(rows: Sequence[LinkRow]) -> list[LinkRow]: async def for_memories( org: str, memory_ids: Sequence[str], *, ch: _CHClient | None = None -) -> list[StampedLink]: - """Live links of these memories, each with the time it was inserted.""" +) -> list[LinkRow]: + """Live links of these memories.""" if not memory_ids: return [] rows = await query_all_sliced( ch or _default_client(), - "SELECT *, toUnixTimestamp64Milli(inserted_at) AS inserted_ms " - f"{_LIVE} AND org = {{org:String}} AND memory_id IN {{ids:Array(UUID)}}", + f"SELECT * {_LIVE} AND org = {{org:String}} AND memory_id IN {{ids:Array(UUID)}}", {"org": org, "ids": sorted({str(i) for i in memory_ids})}, "ids", ) - return cast(list[StampedLink], _links(rows)) + return _links(rows) async def for_paths( @@ -458,42 +454,33 @@ async def _for_code( ) -async def clock(*, ch: _CHClient | None = None) -> int: - """ClickHouse's time in milliseconds, the clock that stamps `inserted_at`.""" - rows = await (ch or _default_client()).query_all("SELECT toUnixTimestamp64Milli(now64(3)) AS t") - return int(rows[0]["t"]) - - -_UNCHECKED = ( +_UNCOVERED = ( "{_LIVE} AND org = {{org:String}} AND code_namespace = {{cns:String}} " - "AND state != 'pending' AND checked_commit != {{head:String}} " - "AND toUnixTimestamp64Milli(inserted_at) >= {{since:Int64}}" + "AND state != 'pending' AND NOT covered AND checked_commit != {{head:String}}" ) -async def inserted_since( +async def uncovered( org: str, code_namespace: str, head: str, - since: int, *, after: tuple[str, ...] | None, limit: int, ch: _CHClient | None = None, ) -> tuple[list[LinkRow], tuple[str, ...] | None]: - """Up to `limit` live links not checked at `head` that were inserted at or after - `since` (ms), in key order after `after`, and the next page's start (None at the end).""" + """Up to `limit` live links no pass has covered and not checked at `head`, in key + order after `after`, and the next page's start (None at the end).""" past = f"AND {_past(_KEY_COLUMNS, _KEY_TYPES)} " if after else "" rows = _links( await (ch or _default_client()).query_all( "SELECT * " - + _UNCHECKED.format(_LIVE=_LIVE) + + _UNCOVERED.format(_LIVE=_LIVE) + f" {past}ORDER BY {_KEY} LIMIT {{lim:UInt32}}", params={ "org": org, "cns": code_namespace, "head": head, - "since": since, "lim": int(limit), **_past_params(after or ()), }, diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index cc3209c61fb..baa455466bd 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -59,15 +59,6 @@ async def lease(name, *, wait_s=None): monkeypatch.setattr(code_link_pass.repository_locks, "lease", lease) -@pytest.fixture(autouse=True) -def _a_clock(monkeypatch): - # no ClickHouse here: its clock stands still unless a test moves it - async def clock(): - return 10_000 - - monkeypatch.setattr(code_links.store, "clock", clock) - - @pytest.fixture(autouse=True) def _mirror_holds_every_commit(monkeypatch): async def has(self, commit): @@ -7069,39 +7060,36 @@ async def no_cursor(name): assert written == [] -class _Stamped: - """The link table as ClickHouse keeps it: each row has the time (ms) it was inserted, - and a recheck moves a live link to the head, as `_write_moves` does, leaving a lost - one unwritten, as `_recheck` does when nothing about it changed.""" +class _Covering: + """The link table as ClickHouse keeps it: each row says whether a pass covered it, and + a recheck writes a live link at the head, covered, leaving a lost one at its commit.""" def __init__(self, monkeypatch, page: int = 100) -> None: - self.now = 10_000 self.table: list[dict[str, Any]] = [] self.cursors: dict[str, str] = {} self.rechecked: list[list[str]] = [] - async def clock(): - return self.now - - async def inserted_since(org, cns, head, since, *, after, limit): + async def uncovered(org, cns, head, *, after, limit): rows = sorted( ( a for a in self.table if a["checked_commit"] != head and a["state"] != "pending" - and a["ins"] >= since + and not a["covered"] and (after is None or (a["memory_id"],) > after) ), key=lambda a: a["memory_id"], )[:limit] return rows, ((rows[-1]["memory_id"],) if len(rows) == limit else None) - async def recheck_rows(org, cns, head, files, result, links): + async def recheck_rows(org, cns, head, files, result, links, *, cover): + assert cover self.rechecked.append([a["memory_id"] for a in links]) for a in links: + a["covered"] = 1 if a["state"] not in ("missing", "unresolved"): - a["checked_commit"], a["ins"] = head, self.now + a["checked_commit"] = head return set(), set() async def get(name): @@ -7117,123 +7105,80 @@ async def set_unparsed(org, cns, paths): return None monkeypatch.setattr(settings, "memory_code_links_batch", page) - monkeypatch.setattr(code_links.store, "clock", clock) - monkeypatch.setattr(code_links.store, "inserted_since", inserted_since) + monkeypatch.setattr(code_links.store, "uncovered", uncovered) monkeypatch.setattr(code_link_recheck, "_recheck_rows", recheck_rows) monkeypatch.setattr(code_link_recheck, "_unparsed", unparsed) monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) monkeypatch.setattr(code_links.code, "link_cursor", get) monkeypatch.setattr(code_links.code, "set_link_cursor", put) - def add(self, memory_id: str, checked_commit: str, state: str = "fresh", ins: int = 1) -> None: - link = _full({"memory_id": memory_id, "checked_commit": checked_commit, "state": state}) - self.table.append(link | {"ins": ins}) + def add( + self, memory_id: str, checked_commit: str, state: str = "fresh", covered: int = 0 + ) -> None: + self.table.append( + _full( + { + "memory_id": memory_id, + "checked_commit": checked_commit, + "state": state, + "covered": covered, + } + ) + ) - async def pass_at(self, head: str = "h1", *, between=None) -> None: - """One pass: it takes its start first, as `_recheck_repository` does.""" - started = await code_links.store.clock() - self.now += 1000 + async def pass_at(self, head: str = "h1") -> None: await code_link_recheck._catch_up( "o", "code-a", head, - started, - None, + None, # type: ignore[arg-type] code_link_pass.PassResult(), # type: ignore[arg-type] ) - if between: - between() # a writer inserts after the pass read the table - - def read(self) -> int | None: - """What guidance trusts: the start of the last finished catch-up.""" - return json.loads(self.cursors["seen/o/code-a"]).get("read") @pytest.mark.asyncio -async def test_a_link_an_older_build_inserted_after_a_pass_read_is_rechecked_at_the_same_head( +async def test_a_link_inserted_by_an_older_build_late_is_covered_by_the_next_pass( monkeypatch, ) -> None: - w = _Stamped(monkeypatch) - w.add("old", "h0", ins=1) # stored before the first pass, still at h0 + w = _Covering(monkeypatch) await w.pass_at() - assert w.rechecked == [["old"]] # no cursor: the first pass rechecks what is behind - read = w.read() - await w.pass_at() # steady head, nothing inserted since - assert w.rechecked == [["old"], []] - # an older build inserts a link built at h0 after a pass at h1 read the table - await w.pass_at(between=lambda: w.add("late", "h0", ins=w.now)) - late = next(a for a in w.table if a["memory_id"] == "late") - # guidance distrusts it: it was stamped after the finished catch-up began reading - assert late["ins"] >= w.read() + assert w.rechecked == [[]] + # an older build commits a link built at h0 whenever its insert finishes: it carries + # no coverage, so guidance waits for a pass however long the insert took + w.add("late", "h0") await w.pass_at() - assert w.rechecked[-1] == ["late"] # the next pass rechecks it at the same head - assert late["checked_commit"] == "h1" - assert w.read() > read + assert w.rechecked[-1] == ["late"] + late = w.table[0] + assert late["checked_commit"] == "h1" and late["covered"] @pytest.mark.asyncio -async def test_a_link_stamped_just_before_the_last_read_but_committed_after_it_is_rechecked( - monkeypatch, -) -> None: - w = _Stamped(monkeypatch) - await w.pass_at() - read = w.read() - assert read is not None - lag = code_link_pass.STAMP_LAG_MS - # an insert stamped inside the margin before the read that committed after it - w.add("slow", "h0", ins=read - lag + 500) - w.add("edge", "h0", ins=read - lag) # exactly at the boundary: `>=` includes it - w.add("beyond", "h0", ins=read - lag - 500) # a gap past the margin is the ceiling - await w.pass_at() - assert w.rechecked[-1] == ["edge", "slow"] - - -@pytest.mark.asyncio -async def test_a_steady_head_with_no_inserts_rechecks_nothing(monkeypatch) -> None: - w = _Stamped(monkeypatch) - w.add("a", "h1") - w.add("b", "h0") # unchanged since a past pass: it keeps an older commit - await w.pass_at() - w.add("c", "h1", ins=w.now) # at the head: nothing to recheck +async def test_a_steady_head_covers_each_link_once(monkeypatch) -> None: + w = _Covering(monkeypatch) + w.add("a", "h1") # at the head + w.add("b", "h0", covered=1) # a lease writer's link: covered at its older commit + w.add("c", "h0") for _ in range(3): await w.pass_at() - assert w.rechecked == [["b"], [], [], []] + assert w.rechecked == [["c"], [], []] @pytest.mark.asyncio -async def test_a_lost_link_is_rechecked_once_and_never_rewritten_each_pass(monkeypatch) -> None: - w = _Stamped(monkeypatch) +async def test_a_lost_link_is_covered_once_and_never_rewritten_each_pass(monkeypatch) -> None: + w = _Covering(monkeypatch) w.add("m", "h0", state="missing") for _ in range(3): await w.pass_at() assert w.rechecked == [["m"], [], []] + assert w.table[0]["checked_commit"] == "h0" @pytest.mark.asyncio -async def test_the_first_pass_after_an_upgrade_rechecks_links_stored_before_the_column( - monkeypatch, -) -> None: - w = _Stamped(monkeypatch) - w.add("a", "h0", ins=0) # an older build's link, long stored - assert "seen/o/code-a" not in w.cursors # guidance trusts no link without a cursor - await w.pass_at() - assert w.rechecked == [["a"]] - assert w.read() is not None - - -@pytest.mark.asyncio -async def test_more_links_than_a_page_take_several_passes_and_the_mark_moves_last( - monkeypatch, -) -> None: - w = _Stamped(monkeypatch, page=2) +async def test_more_links_than_a_page_take_several_passes(monkeypatch) -> None: + w = _Covering(monkeypatch, page=2) for i in range(5): w.add(f"m{i}", "h0") - await w.pass_at() - await w.pass_at() - assert [len(r) for r in w.rechecked] == [2, 2] - assert "seen/o/code-a" in w.cursors and w.read() is None # still sweeping - await w.pass_at() - assert [len(r) for r in w.rechecked] == [2, 2, 1] - assert w.read() is not None - await w.pass_at() + for _ in range(4): + await w.pass_at() assert [len(r) for r in w.rechecked] == [2, 2, 1, 0] + assert "seen/o/code-a" not in w.cursors or not w.cursors["seen/o/code-a"] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 9eb8b7f81b1..64ee0d64ff0 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -177,7 +177,7 @@ def _link(mid: str, *, qn: str = "src.a::Reader::read", state: str = "fresh", ** "changed_since": kw.get("since", ""), "fingerprint_version": kw.get("version", fingerprint_version()), "checked_commit": kw.get("checked", "a" * 40), - "inserted_ms": kw.get("stamped", 0), + "covered": kw.get("covered", 0), } @@ -306,7 +306,7 @@ async def checked_head(org, ns): return "" async def link_cursor(name): - assert name in ("unparsed/o/code-a", "seen/o/code-a") + assert name == "unparsed/o/code-a" return "" monkeypatch.setattr( @@ -332,8 +332,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st checked = indexed fetched = "b" * 40 unparsed = "" - seen = '{"read": 5000}' - stamped = 0 + covered = 0 at_head = False complete_during_read = False @@ -345,7 +344,7 @@ async def links(org, ids): nonlocal checked if complete_during_read: checked = indexed - return [_link("m1", state=state, checked=indexed if at_head else "c" * 40, stamped=stamped)] + return [_link("m1", state=state, checked=indexed if at_head else "c" * 40, covered=covered)] async def all_state_many(pairs): assert pairs == [("o", "code-a")] @@ -360,7 +359,7 @@ async def checked_head(org, ns): return checked async def link_cursor(name): - return seen if name.startswith("seen/") else unparsed + return unparsed monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) @@ -381,29 +380,27 @@ async def link_cursor(name): unparsed = '["src/a.py"]' assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] unparsed = '["src/other.py"]' - # a link stamped after the last finished catch-up began reading may be one no pass saw, - # and with no finished catch-up none is known to be seen - # (the cut is the read less the margin: 5000 - 2000) - stamped = 3000 + # an older commit with no coverage may be a link no pass saw, however it was inserted assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - stamped = 2999 - seen = "" - assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] - # without a finished catch-up, links checked at the head still count + covered = 1 + assert await code_link_reads.guidance_code_states("o", [row]) == [ + "unknown" if state == "pending" else state + ] + covered = 0 at_head = True assert await code_link_reads.guidance_code_states("o", [row]) == [ "unknown" if state == "pending" else state ] at_head = False - seen = '{"read": 5000}' + covered = 1 # a link the writer parked behind a running pass is unknown even at the checked head expected = "unknown" if state == "pending" else state assert await code_link_reads.guidance_code_states("o", [row]) == [expected] async def test_guidance_judges_a_late_link_by_the_row_it_classified(monkeypatch) -> None: - """The catch-up rewrites a late link at the head while guidance reads it: the stamp - that decides coverage is on the row guidance classified, so it stays unknown.""" + """The catch-up rewrites a late link at the head while guidance reads it: the coverage + that decides is on the row guidance classified, so it stays unknown.""" from server.memory.app import code_link_reads head = "a" * 40 @@ -415,12 +412,12 @@ async def readable(org, namespaces): async def links(org, ids): nonlocal reads reads += 1 - # the first read sees the late link (built at another commit, stamped after the - # cut); a second read would see the catch-up's rewrite at the head - return [_link("m1", checked="c" * 40 if reads == 1 else head, stamped=4000)] + # the first read sees the late link (built at another commit, never covered); a + # second read would see the catch-up's rewrite at the head + return [_link("m1", checked="c" * 40 if reads == 1 else head)] async def link_cursor(name): - return '{"read": 5000}' if name.startswith("seen/") else "" + return "" async def checked_head(org, ns): return head @@ -445,6 +442,56 @@ async def all_state_many(pairs): assert reads == 1 +async def test_guidance_reads_the_checkpoint_and_the_links_under_sequential_reads( + monkeypatch, +) -> None: + """A replica that lags the checkpoint shows the link as it was before the pass that + advanced the head covered it; both reads ask for sequential consistency, which the + lagging replica cannot answer stale.""" + from server.core.ch import sequential_reads_active + from server.memory.app import code_link_reads + + head = "a" * 40 + seen_active: list[bool] = [] + + async def readable(org, namespaces): + return namespaces + + async def links(org, ids): + seen_active.append(sequential_reads_active()) + lagging = not sequential_reads_active() + return [_link("m1", checked="c" * 40, covered=0 if lagging else 1)] + + async def checked_head(org, ns): + seen_active.append(sequential_reads_active()) + return head + + async def link_cursor(name): + return "" + + async def all_state_many(pairs): + return { + ("o", "code-a"): { + "clone_head": {"value": head, "detail": "main"}, + "git_head": {"value": head}, + } + } + + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", links) + monkeypatch.setattr( + code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") + ) + monkeypatch.setattr( + code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) + ) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + assert await code_link_reads.guidance_code_states("o", [_excerpt("m1", "allowed")]) == ["fresh"] + assert seen_active == [True, True] + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] diff --git a/tests/unit/test_repository_column_sets_match_schema.py b/tests/unit/test_repository_column_sets_match_schema.py index 8b5823d9cc2..b1a5bc7f2d1 100644 --- a/tests/unit/test_repository_column_sets_match_schema.py +++ b/tests/unit/test_repository_column_sets_match_schema.py @@ -39,12 +39,7 @@ "loom.qa_rollup_days", frozenset(), ), - ( - "server.memory.store.code_links", - "LINK_COLS", - "loom.memory_code_links", - frozenset({"inserted_at"}), - ), + ("server.memory.store.code_links", "LINK_COLS", "loom.memory_code_links", frozenset()), ( "server.memory.app.extraction_queue", "COLUMNS", diff --git a/tests/unit/test_schema_baseline.py b/tests/unit/test_schema_baseline.py index d2dba7964b2..6d74e87e95b 100644 --- a/tests/unit/test_schema_baseline.py +++ b/tests/unit/test_schema_baseline.py @@ -172,7 +172,7 @@ def test_the_journal_files() -> None: "114_memory_proposal_review.sql", "115_memory_refusals.sql", "117_code_term_df_unchanged_refresh.sql", - "118_memory_code_link_inserted_at.sql", + "118_memory_code_link_covered.sql", ] From 2787db67bf97dd64b599f201055aa54ac5754771 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 13:19:18 +0530 Subject: [PATCH 075/117] The catch-up leaves dropped links dropped and links checked past the head where they are _write_covered re-reads the live links and writes only those still at the version it read, so a link the queue tombstoned or dropped meanwhile is not written back. A group checked at or after the head is not covered, as _recheck does not recheck it. The guidance read takes the indexed head under sequential_reads with the checkpoint and the links. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 3 +- server/memory/app/code_link_recheck.py | 19 ++++++-- server/memory/store/code_links.py | 8 ++-- tests/unit/test_memory_code_links.py | 60 ++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 43718878283..021c26ac81c 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -252,7 +252,8 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l positive[key[2], checked_head].append((index, state)) else: states[index] = state - await _confirm(org, positive, states) + with sequential_reads(): + await _confirm(org, positive, states) return states diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 21db82d1a55..6614049a81f 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -316,17 +316,27 @@ async def _recheck_rows( org, cns, by_path, paths_now, changed, head, files, still, failed ) await _write_moves(await _current_moves(org, moves), head) - if cover: + if cover and not (commit and commit != head and await files.is_ancestor(head, commit)): + # a link checked at or after `head` is not rechecked, so not covered here moved = {id(m.row) for m in moves} await _write_covered( - [a for a in rows if id(a) not in moved and a["path"] not in still | failed], head + org, + [a for a in rows if id(a) not in moved and a["path"] not in still | failed], + head, ) result.rechecked += len(moves) return still, failed -async def _write_covered(rows: list[LinkRow], head: str) -> None: - """The links a pass found unchanged, written covered above the version read.""" +async def _write_covered(org: str, rows: list[LinkRow], head: str) -> None: + """The links a pass found unchanged, written covered above the version read. A link the + queue tombstoned, replaced or dropped since it was read stays as it is.""" + if not rows: + return + live = { + (*store.key_of(a), a["version"]) + for a in await store.for_memories(org, sorted({a["memory_id"] for a in rows})) + } await store.insert( [ store.link_row( @@ -337,6 +347,7 @@ async def _write_covered(rows: list[LinkRow], head: str) -> None: checked_at=naive_utc_now(), ) for a in rows + if (*store.key_of(a), a["version"]) in live ] ) diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index 08db78d3dba..59425b45dad 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -319,7 +319,7 @@ async def for_paths( reads = await asyncio.gather( *(_for_code(ch, org, code_namespaces, {column: paths, **narrow}) for column in columns) ) - return list({_key(r): r for rows in reads for r in rows}.values()) + return list({key_of(r): r for rows in reads for r in rows}.values()) async def in_code_namespace( @@ -408,7 +408,7 @@ async def for_commits( return await _for_code(ch or _default_client(), org, code_namespaces, narrow) -def _key(r: LinkRow) -> tuple[str, ...]: +def key_of(r: LinkRow) -> tuple[str, ...]: """The table's sort key of link `r`.""" row = cast(Mapping[str, str], r) return tuple(row[c] for c in _KEY_COLUMNS) @@ -486,7 +486,7 @@ async def uncovered( }, ) ) - return rows, _key(rows[-1]) if len(rows) == int(limit) else None + return rows, key_of(rows[-1]) if len(rows) == int(limit) else None async def stale_fingerprints( @@ -515,7 +515,7 @@ async def stale_fingerprints( }, ) ) - return rows, _key(rows[-1]) if len(rows) == int(limit) else None + return rows, key_of(rows[-1]) if len(rows) == int(limit) else None async def pending( diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index baa455466bd..dd6e2b6c2ff 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -7182,3 +7182,63 @@ async def test_more_links_than_a_page_take_several_passes(monkeypatch) -> None: await w.pass_at() assert [len(r) for r in w.rechecked] == [2, 2, 1, 0] assert "seen/o/code-a" not in w.cursors or not w.cursors["seen/o/code-a"] + + +@pytest.mark.asyncio +async def test_a_link_dropped_while_the_catch_up_rechecked_it_stays_dropped(monkeypatch) -> None: + kept = _full({"memory_id": "00000000-0000-0000-0000-000000000001", "version": 5}) + dropped = _full({"memory_id": "00000000-0000-0000-0000-000000000002", "version": 5}) + written: list[dict[str, Any]] = [] + + async def for_memories(org, ids): + return [kept] # the other link was tombstoned after it was read at version 5 + + async def insert(rows): + written.extend(rows) + + monkeypatch.setattr(code_links.store, "for_memories", for_memories) + monkeypatch.setattr(code_links.store, "insert", insert) + await code_link_recheck._write_covered("o", [kept, dropped], "h1") # type: ignore[arg-type] + assert [r["memory_id"] for r in written] == [kept["memory_id"]] + assert written[0]["covered"] == 1 and written[0]["version"] == 6 + + +@pytest.mark.asyncio +async def test_a_link_checked_after_the_head_is_not_covered_back_to_it(monkeypatch) -> None: + written: list[Any] = [] + + async def recheck_paths(*args): + return [] + + async def current(org, moves): + return moves + + async def write_moves(moves, head): + return None + + async def write_covered(org, rows, head): + written.extend(rows) + + class Files: + async def range(self, a, b): + return None + + async def is_ancestor(self, a, b): + return (a, b) == ("h1", "h2") # head is an ancestor of the link's commit + + monkeypatch.setattr(code_link_recheck, "_recheck_paths", recheck_paths) + monkeypatch.setattr(code_link_recheck, "_current_moves", current) + monkeypatch.setattr(code_link_recheck, "_write_moves", write_moves) + monkeypatch.setattr(code_link_recheck, "_write_covered", write_covered) + ahead = _full({"memory_id": "a", "checked_commit": "h2"}) + behind = _full({"memory_id": "b", "checked_commit": "h0"}) + await code_link_recheck._recheck_rows( + "o", + "code-a", + "h1", + Files(), + code_link_pass.PassResult(), + [ahead, behind], + cover=True, # type: ignore[arg-type] + ) + assert [a["memory_id"] for a in written] == ["b"] From 1e66002b7104c0f7fb3b20b1ddefbaf1a9913a4d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 14:24:55 +0530 Subject: [PATCH 076/117] Covered links count only on the checkpoint's history, and a link checked past the head is covered at it A covered link is trusted when its checked commit is the checked head or an ancestor of it, so a covered row from a tip the branch was rewound past reads as unknown. _recheck compares every row of a commit group at the head (the range of a descendant commit is None), so the catch-up covers the whole group and no link is left uncovered to loop. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 7 +-- server/memory/app/code_link_reads.py | 48 ++++++++++++++++---- server/memory/app/code_link_recheck.py | 3 +- tests/unit/test_memory_code_links.py | 12 ++--- tests/unit/test_memory_code_plane_reads.py | 14 ++++++ 5 files changed, 61 insertions(+), 23 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index d5baadfcf95..9e280522dc9 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -763,9 +763,10 @@ at the head, from its own checked commit, and writes it covered. It reads a page cursor, which it clears after the last page. A lost link keeps its commit and is rechecked once. A link on a file that does not parse stays uncovered and is retried. -The read side trusts a link only if it is checked at the checked head or covered. Any -other row, such as a late insert from the previous build, reads as unknown until the -next pass covers it. The checkpoint and the links are read together under +The read side trusts a link only if it is checked at the checked head or covered at a +commit in the checked head's history. Any other row, such as a late insert from the +previous build or a covered row from a tip the branch was rewound past, reads as unknown +until the next pass covers it. The checkpoint and the links are read together under `sequential_reads()`, so a lagging replica cannot show an old link against a newer checkpoint. diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 021c26ac81c..2edb9f2dfaa 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -173,6 +173,41 @@ async def _guidance_indexed_heads(org: str, namespaces: list[str]) -> dict[str, return {} +def _current(a: LinkRow, proof: tuple[str, set[str]], kept: Mapping[tuple[str, str], bool]) -> bool: + """Whether link `a` is current at the checkpoint: checked there, or covered by a pass + under the repository lease at a commit in the checkpoint's history (a rewound branch + drops the rest); a row an older build wrote carries neither, so it waits for a pass.""" + head, owed = proof + return a["path"] not in owed and ( + a["checked_commit"] == head + or bool(a["covered"] and kept[a["code_namespace"], a["checked_commit"]]) + ) + + +async def _on_history( + org: str, coverage: Mapping[str, Any], links: Sequence[LinkRow] +) -> dict[tuple[str, str], bool]: + """(repository, commit) -> whether a covered link's commit is in the checkpoint's + history; False when git cannot tell.""" + pairs = { + (a["code_namespace"], a["checked_commit"]) + for a in links + if a["covered"] + and isinstance(proof := coverage.get(a["code_namespace"]), tuple) + and a["checked_commit"] != proof[0] + } + + async def one(cns: str, commit: str) -> bool: + try: + return await code.descends(org, cns, commit, coverage[cns][0]) + except Exception as e: # noqa: BLE001 — a failed git read must not fail the search + log.debug("Guidance link history unavailable: %s", type(e).__name__) + return False + + done = await asyncio.gather(*(one(*p) for p in sorted(pairs))) + return dict(zip(sorted(pairs), done, strict=True)) + + async def _confirm( org: str, positive: dict[tuple[str, str], list[tuple[int, str]]], @@ -232,6 +267,7 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) + kept = await _on_history(org, coverage, links) for index, key in candidates.items(): rows_for_hit = by_revision.get(key, []) state = guidance_link_state(rows_for_hit, readable) @@ -239,17 +275,9 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l proof = coverage.get(key[2]) if not isinstance(proof, tuple): continue - checked_head, owed = proof - # A link is current at the checkpoint when it was checked there or a pass - # under the repository lease covered it; a row an older build wrote carries - # neither, so it waits for the next pass. - if not checked_head or any( - link["path"] in owed - or (link["checked_commit"] != checked_head and not link["covered"]) - for link in rows_for_hit - ): + if not proof[0] or not all(_current(a, proof, kept) for a in rows_for_hit): continue - positive[key[2], checked_head].append((index, state)) + positive[key[2], proof[0]].append((index, state)) else: states[index] = state with sequential_reads(): diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index 6614049a81f..d658c9f9f49 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -316,8 +316,7 @@ async def _recheck_rows( org, cns, by_path, paths_now, changed, head, files, still, failed ) await _write_moves(await _current_moves(org, moves), head) - if cover and not (commit and commit != head and await files.is_ancestor(head, commit)): - # a link checked at or after `head` is not rechecked, so not covered here + if cover: moved = {id(m.row) for m in moves} await _write_covered( org, diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index dd6e2b6c2ff..b29f5392b56 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -7204,7 +7204,7 @@ async def insert(rows): @pytest.mark.asyncio -async def test_a_link_checked_after_the_head_is_not_covered_back_to_it(monkeypatch) -> None: +async def test_a_link_checked_past_the_head_is_rechecked_and_covered_at_it(monkeypatch) -> None: written: list[Any] = [] async def recheck_paths(*args): @@ -7221,24 +7221,20 @@ async def write_covered(org, rows, head): class Files: async def range(self, a, b): - return None - - async def is_ancestor(self, a, b): - return (a, b) == ("h1", "h2") # head is an ancestor of the link's commit + return None # git cannot tell: the row is compared at the head monkeypatch.setattr(code_link_recheck, "_recheck_paths", recheck_paths) monkeypatch.setattr(code_link_recheck, "_current_moves", current) monkeypatch.setattr(code_link_recheck, "_write_moves", write_moves) monkeypatch.setattr(code_link_recheck, "_write_covered", write_covered) ahead = _full({"memory_id": "a", "checked_commit": "h2"}) - behind = _full({"memory_id": "b", "checked_commit": "h0"}) await code_link_recheck._recheck_rows( "o", "code-a", "h1", Files(), code_link_pass.PassResult(), - [ahead, behind], + [ahead], cover=True, # type: ignore[arg-type] ) - assert [a["memory_id"] for a in written] == ["b"] + assert [a["memory_id"] for a in written] == ["a"] diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 64ee0d64ff0..47b5b5586f8 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -334,6 +334,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st unparsed = "" covered = 0 at_head = False + on_history = True complete_during_read = False async def readable(org, namespaces): @@ -361,6 +362,10 @@ async def checked_head(org, ns): async def link_cursor(name): return unparsed + async def descends(org, ns, ancestor, descendant): + return on_history + + monkeypatch.setattr(code_link_reads.code, "descends", descends) monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.store, "for_memories", links) @@ -386,6 +391,10 @@ async def link_cursor(name): assert await code_link_reads.guidance_code_states("o", [row]) == [ "unknown" if state == "pending" else state ] + # a covered row from a tip the branch was rewound past is no longer on its history + on_history = False + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + on_history = True covered = 0 at_head = True assert await code_link_reads.guidance_code_states("o", [row]) == [ @@ -469,6 +478,9 @@ async def checked_head(org, ns): async def link_cursor(name): return "" + async def descends(org, ns, ancestor, descendant): + return True + async def all_state_many(pairs): return { ("o", "code-a"): { @@ -477,6 +489,8 @@ async def all_state_many(pairs): } } + monkeypatch.setattr(code_link_reads.code, "descends", descends) + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) monkeypatch.setattr(code_link_reads.store, "for_memories", links) From 18dd2361be1008c9e5bf6f390871f600ce8c21ab Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 14:54:09 +0530 Subject: [PATCH 077/117] A full recheck covers the links that did not move, and the history reads run a few at a time When there is no range (a rewind or force-push) _follow writes the unmoved links of each parsed path covered at the head, through the guarded _write_covered, so a covered row from the abandoned tip is not left unknown. _on_history runs at most four ancestry reads at once. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 15 +++++- server/memory/app/code_link_recheck.py | 15 ++++++ tests/unit/test_memory_code_links.py | 63 ++++++++++++++++++++++ tests/unit/test_memory_code_plane_reads.py | 22 ++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 2edb9f2dfaa..3150b0e9202 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -184,6 +184,10 @@ def _current(a: LinkRow, proof: tuple[str, set[str]], kept: Mapping[tuple[str, s ) +# git ancestry reads one guidance call runs at once +_HISTORY_READS = 4 + + async def _on_history( org: str, coverage: Mapping[str, Any], links: Sequence[LinkRow] ) -> dict[tuple[str, str], bool]: @@ -204,8 +208,15 @@ async def one(cns: str, commit: str) -> bool: log.debug("Guidance link history unavailable: %s", type(e).__name__) return False - done = await asyncio.gather(*(one(*p) for p in sorted(pairs))) - return dict(zip(sorted(pairs), done, strict=True)) + # a few git processes at once: a rewind leaves few such commits, but nothing bounds them + gate = asyncio.Semaphore(_HISTORY_READS) + + async def bounded(pair: tuple[str, str]) -> bool: + async with gate: + return await one(*pair) + + ordered = sorted(pairs) + return dict(zip(ordered, await asyncio.gather(*map(bounded, ordered)), strict=True)) async def _confirm( diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index d658c9f9f49..edae38c8d99 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -231,6 +231,21 @@ async def _follow( org, cns, by_path, part, changed, head, files, unparsed, failed ) await _write_moves(await _current_moves(org, moves), head) + if changed is None: + # no range (a rewind, a force-push): every link was checked at the head, so the + # ones that did not move are covered at it, not left on a commit off its history + moved = {id(m.row) for m in moves} + await _write_covered( + org, + [ + a + for p in part + if p not in unparsed | failed + for a in by_path[p] + if id(a) not in moved + ], + head, + ) result.rechecked += len(moves) if len(unparsed) > known: # owed before the cursor moves past them await _set_unparsed(org, cns, unparsed) diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index b29f5392b56..57be11e7ee0 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -2817,8 +2817,12 @@ async def recheck(org, cns, part, changed, at, files): async def has(self, commit): return commit != "gone" + async def no_cover(org, rows, head): + return None + _stub_reads(monkeypatch, every) monkeypatch.setattr(code_link_recheck, "_recheck", recheck) + monkeypatch.setattr(code_link_recheck, "_write_covered", no_cover) monkeypatch.setattr(code_link_pass.RepoReads, "has", has) budget, result = code_link_pass.Budget(0), code_link_pass.PassResult() with pytest.raises(TimeoutError): @@ -7238,3 +7242,62 @@ async def range(self, a, b): cover=True, # type: ignore[arg-type] ) assert [a["memory_id"] for a in written] == ["a"] + + +@pytest.mark.asyncio +async def test_a_follow_without_a_range_covers_the_links_that_did_not_move(monkeypatch) -> None: + from collections import defaultdict as _dd # noqa: F401 + + unmoved = _full({"memory_id": "a", "path": "a.py", "checked_commit": "B", "covered": 1}) + failed_row = _full({"memory_id": "b", "path": "b.py", "checked_commit": "B", "covered": 1}) + covered: list[Any] = [] + + class Files: + async def range(self, a, b): + return None # a rewind: the range from B back to A is unknown + + async def in_ns(org, cns): + return [unmoved, failed_row] + + async def recheck_paths(org, cns, by_path, part, changed, head, files, unparsed, failed): + assert changed is None + unparsed.add("b.py") + return [] + + async def current(org, moves): + return moves + + async def write_moves(moves, head): + return None + + async def write_covered(org, rows, head): + covered.extend(rows) + + async def no_unparsed(org, cns): + return set() + + async def set_unparsed(org, cns, paths): + return None + + async def cursor(name): + return {} + + monkeypatch.setattr(code_links.store, "in_code_namespace", in_ns) + monkeypatch.setattr(code_link_recheck, "_recheck_paths", recheck_paths) + monkeypatch.setattr(code_link_recheck, "_current_moves", current) + monkeypatch.setattr(code_link_recheck, "_write_moves", write_moves) + monkeypatch.setattr(code_link_recheck, "_write_covered", write_covered) + monkeypatch.setattr(code_link_recheck, "_unparsed", no_unparsed) + monkeypatch.setattr(code_link_recheck, "_set_unparsed", set_unparsed) + monkeypatch.setattr(code_link_pass.Cursor, "read", lambda self: cursor("")) + monkeypatch.setattr(code_link_pass.Cursor, "write", lambda self, v: cursor("")) + monkeypatch.setattr(code_link_pass.Cursor, "clear", lambda self: cursor("")) + await code_link_recheck._follow( + "o", + "code-a", + "B", + "A", + Files(), + code_link_pass.PassResult(), # type: ignore[arg-type] + ) + assert [a["memory_id"] for a in covered] == ["a"] # the unparsed path stays as it was diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 47b5b5586f8..df06d376626 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -906,3 +906,25 @@ def unavailable(*args): monkeypatch.setattr(code_link_reads, "code_namespace_for", unavailable) row = _excerpt("m1", "readable memory") | {"namespace": "code-a"} assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + + +async def test_history_reads_run_a_few_at_a_time(monkeypatch) -> None: + import asyncio + + from server.memory.app import code_link_reads + + running = peak = 0 + + async def descends(org, ns, ancestor, descendant): + nonlocal running, peak + running += 1 + peak = max(peak, running) + await asyncio.sleep(0) + running -= 1 + return True + + monkeypatch.setattr(code_link_reads.code, "descends", descends) + links = [_link("m1", checked=f"{i:040d}", covered=1) for i in range(12)] + out = await code_link_reads._on_history("o", {"code-a": ("h" * 40, set())}, links) + assert len(out) == 12 and all(out.values()) + assert peak <= code_link_reads._HISTORY_READS From ea97dda639b0f0c49eac6bfa58c978efac0d7a09 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Sun, 29 Nov 2026 14:59:31 +0530 Subject: [PATCH 078/117] The follow-without-range test pins each guard of the covering The test now has a failed path, a moved row and the head argument, and fails if the moved filter or the failed set is dropped. _follow names the skipped paths once. Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_recheck.py | 9 ++------- tests/unit/test_memory_code_links.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/server/memory/app/code_link_recheck.py b/server/memory/app/code_link_recheck.py index edae38c8d99..e0e4b1d2f8e 100644 --- a/server/memory/app/code_link_recheck.py +++ b/server/memory/app/code_link_recheck.py @@ -235,15 +235,10 @@ async def _follow( # no range (a rewind, a force-push): every link was checked at the head, so the # ones that did not move are covered at it, not left on a commit off its history moved = {id(m.row) for m in moves} + skip = unparsed | failed await _write_covered( org, - [ - a - for p in part - if p not in unparsed | failed - for a in by_path[p] - if id(a) not in moved - ], + [a for p in part if p not in skip for a in by_path[p] if id(a) not in moved], head, ) result.rechecked += len(moves) diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 57be11e7ee0..ef50a5b3b72 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -7246,23 +7246,27 @@ async def range(self, a, b): @pytest.mark.asyncio async def test_a_follow_without_a_range_covers_the_links_that_did_not_move(monkeypatch) -> None: - from collections import defaultdict as _dd # noqa: F401 + from types import SimpleNamespace unmoved = _full({"memory_id": "a", "path": "a.py", "checked_commit": "B", "covered": 1}) failed_row = _full({"memory_id": "b", "path": "b.py", "checked_commit": "B", "covered": 1}) + failed_path = _full({"memory_id": "c", "path": "c.py", "checked_commit": "B", "covered": 1}) + moved = _full({"memory_id": "m", "path": "m.py", "checked_commit": "B", "covered": 1}) covered: list[Any] = [] + heads: list[str] = [] class Files: async def range(self, a, b): return None # a rewind: the range from B back to A is unknown async def in_ns(org, cns): - return [unmoved, failed_row] + return [unmoved, failed_row, failed_path, moved] async def recheck_paths(org, cns, by_path, part, changed, head, files, unparsed, failed): assert changed is None unparsed.add("b.py") - return [] + failed.add("c.py") + return [SimpleNamespace(row=moved)] async def current(org, moves): return moves @@ -7272,6 +7276,7 @@ async def write_moves(moves, head): async def write_covered(org, rows, head): covered.extend(rows) + heads.append(head) async def no_unparsed(org, cns): return set() @@ -7300,4 +7305,6 @@ async def cursor(name): Files(), code_link_pass.PassResult(), # type: ignore[arg-type] ) - assert [a["memory_id"] for a in covered] == ["a"] # the unparsed path stays as it was + # unparsed, failed and moved rows stay as they were + assert [a["memory_id"] for a in covered] == ["a"] + assert heads == ["A"] From 11c081eb9eafb37bfc2473705d73fd20340470d1 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 20:15:43 +0530 Subject: [PATCH 079/117] Guidance reads check link history only for links that could serve, within a pair cap and a deadline Ancestry checks ran for every covered link at an older commit, with no bound on the pairs or the time. A read now checks only links that can still earn positive guidance, at most 8 distinct commits under one 0.2 second deadline, and a pair over either reads as unknown. Recall Lab and Memory inspector end-to-end fixtures name a complete writer, and the list projection test expects 14 fields. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 7 ++ frontend/e2e/back-restores-place.spec.ts | 12 +++- frontend/e2e/recall-lab.spec.ts | 3 + server/memory/app/code_link_reads.py | 72 ++++++++++++------- .../test_list_answers_what_the_page_asked.py | 4 +- tests/unit/test_memory_code_plane_reads.py | 58 ++++++++++++++- 6 files changed, 125 insertions(+), 31 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 4417cc78bdf..d62778a4b1e 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -790,6 +790,13 @@ until the next pass covers it. The checkpoint and the links are read together un `sequential_reads()`, so a lagging replica cannot show an old link against a newer checkpoint. +A covered link at an older commit needs one `git merge-base --is-ancestor` to prove that +commit is on the checkpoint's history. A read runs those checks only for links that could +still serve positive guidance: a fresh or moved state, a checkpoint, and no path owed a +recheck. One request checks at most 8 distinct (repository, commit) pairs, four at a time, +under one 0.2 second deadline. A pair over the cap, or still running at the deadline, is +cancelled and reads as unknown, so a slow mirror never turns a link positive. + ## Invariants - A code namespace is one branch; every `code_*` row is keyed by `(org, namespace)`. diff --git a/frontend/e2e/back-restores-place.spec.ts b/frontend/e2e/back-restores-place.spec.ts index d8c5f6c7b8f..c5eed636798 100644 --- a/frontend/e2e/back-restores-place.spec.ts +++ b/frontend/e2e/back-restores-place.spec.ts @@ -13,7 +13,12 @@ const ENTITY = "rate limiting"; /** memory.get, memory.related and facts.related for a memory that names two entities. */ async function entityApi(page: Page) { await page.route("**/v1/memory.get", async (route) => { - const body = route.request().postDataJSON() as { memory_key: string }; + const body = route.request().postDataJSON() as { + memory_key: string; + agent?: string; + user_id?: string; + session_id?: string; + }; await route.fulfill({ status: 200, contentType: "application/json", @@ -29,7 +34,10 @@ async function entityApi(page: Page) { created_at: "2026-09-19T00:00:00Z", updated_at: "2026-09-19T00:00:00Z", status: "active", - agent: "alert-bot", + // the selected writer, so the inspector finds the row it asked for + agent: body.agent ?? "alert-bot", + user_id: body.user_id ?? "-", + session_id: body.session_id ?? "-", entities: [ENTITY, "redis"], recall_count: 0, last_recalled_at: null, diff --git a/frontend/e2e/recall-lab.spec.ts b/frontend/e2e/recall-lab.spec.ts index 195154a9248..fdc59830efb 100644 --- a/frontend/e2e/recall-lab.spec.ts +++ b/frontend/e2e/recall-lab.spec.ts @@ -11,6 +11,9 @@ const SHOTS = process.env.RECALL_SHOTS; const hit = (i: number) => ({ memory_key: `runbooks/deploy/step-${i}-with-a-rather-long-key-name`, memory_type: i % 2 ? "procedural" : "semantic", + agent: "alert-bot", + user_id: "-", + session_id: "-", content_excerpt: `Drain lane ${i} before re-pointing the ingest, then replay the backlog from the last checkpoint.`, distance: 0.2 + i * 0.05, similarity: 0.82 - i * 0.05, diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 3150b0e9202..6a5e8454748 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -180,43 +180,51 @@ def _current(a: LinkRow, proof: tuple[str, set[str]], kept: Mapping[tuple[str, s head, owed = proof return a["path"] not in owed and ( a["checked_commit"] == head - or bool(a["covered"] and kept[a["code_namespace"], a["checked_commit"]]) + or bool(a["covered"] and kept.get((a["code_namespace"], a["checked_commit"]), False)) ) -# git ancestry reads one guidance call runs at once +# not a setting: git processes at once; the pair cap and deadline bound the rest _HISTORY_READS = 4 +# not a setting: distinct (repository, commit) pairs one request checks; the rest read unknown +_HISTORY_PAIRS = 8 +# not a setting: seconds the whole ancestry phase may take; a late answer reads as unknown +_HISTORY_DEADLINE = 0.2 async def _on_history( org: str, coverage: Mapping[str, Any], links: Sequence[LinkRow] ) -> dict[tuple[str, str], bool]: """(repository, commit) -> whether a covered link's commit is in the checkpoint's - history; False when git cannot tell.""" - pairs = { - (a["code_namespace"], a["checked_commit"]) - for a in links - if a["covered"] - and isinstance(proof := coverage.get(a["code_namespace"]), tuple) - and a["checked_commit"] != proof[0] - } - - async def one(cns: str, commit: str) -> bool: - try: - return await code.descends(org, cns, commit, coverage[cns][0]) - except Exception as e: # noqa: BLE001 — a failed git read must not fail the search - log.debug("Guidance link history unavailable: %s", type(e).__name__) - return False - - # a few git processes at once: a rewind leaves few such commits, but nothing bounds them + history. At most `_HISTORY_PAIRS` pairs are checked, all under one `_HISTORY_DEADLINE`; + a pair left out, late or git cannot tell reads False, so it never earns positive + guidance.""" + pairs = sorted( + { + (a["code_namespace"], a["checked_commit"]) + for a in links + if a["covered"] + and isinstance(proof := coverage.get(a["code_namespace"]), tuple) + and a["checked_commit"] != proof[0] + } + ) + kept = dict.fromkeys(pairs, False) gate = asyncio.Semaphore(_HISTORY_READS) - async def bounded(pair: tuple[str, str]) -> bool: + async def one(cns: str, commit: str) -> None: async with gate: - return await one(*pair) + try: + kept[cns, commit] = await code.descends(org, cns, commit, coverage[cns][0]) + except Exception as e: # noqa: BLE001 — a failed git read must not fail the search + log.debug("Guidance link history unavailable: %s", type(e).__name__) - ordered = sorted(pairs) - return dict(zip(ordered, await asyncio.gather(*map(bounded, ordered)), strict=True)) + try: + async with asyncio.timeout(_HISTORY_DEADLINE), asyncio.TaskGroup() as group: + for pair in pairs[:_HISTORY_PAIRS]: + group.create_task(one(*pair)) + except TimeoutError: + log.debug("Guidance link history past its deadline") + return kept async def _confirm( @@ -278,10 +286,24 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) - kept = await _on_history(org, coverage, links) + states_by_index = { + index: guidance_link_state(by_revision.get(key, []), readable) + for index, key in candidates.items() + } + # git ancestry only for links that could still earn positive guidance + eligible = [ + a + for index, key in candidates.items() + if states_by_index[index] in {"fresh", "moved"} + and isinstance(proof := coverage.get(key[2]), tuple) + and proof[0] + for a in by_revision.get(key, []) + if a["path"] not in proof[1] + ] + kept = await _on_history(org, coverage, eligible) for index, key in candidates.items(): rows_for_hit = by_revision.get(key, []) - state = guidance_link_state(rows_for_hit, readable) + state = states_by_index[index] if state in {"fresh", "moved"}: proof = coverage.get(key[2]) if not isinstance(proof, tuple): diff --git a/tests/unit/test_list_answers_what_the_page_asked.py b/tests/unit/test_list_answers_what_the_page_asked.py index 3d32ac4c6bc..a228687e4ad 100644 --- a/tests/unit/test_list_answers_what_the_page_asked.py +++ b/tests/unit/test_list_answers_what_the_page_asked.py @@ -127,9 +127,9 @@ def test_the_memories_page_asks_for_the_fields_it_renders() -> None: body = re.sub(r"//[^\n]*", "", fields_src.split("[", 1)[1]) fields = set(json.loads("[" + body.rstrip().rstrip(",") + "]")) assert "entities" not in fields and {"memory_key", "value", "tags", "verification"} <= fields - # The fifteen fields the page names. `sensitivity`, which marks a high row sent without + # The fourteen fields the page names. `sensitivity`, which marks a high row sent without # its value, comes with every entry: named, it would 422 on an older replica. - assert len(fields) == 15 and "sensitivity" not in fields + assert len(fields) == 14 and "sensitivity" not in fields assert "sensitivity" in read_projection.LIST_ENTRY_ALWAYS known = set(memory_crud._MemoryListEntry.model_fields) assert fields <= known, sorted(fields - known) diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index df06d376626..a4cb788d147 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -336,6 +336,7 @@ async def test_positive_code_guidance_waits_for_the_indexed_head(monkeypatch, st at_head = False on_history = True complete_during_read = False + asked = 0 async def readable(org, namespaces): assert namespaces == {"code-a"} @@ -363,6 +364,8 @@ async def link_cursor(name): return unparsed async def descends(org, ns, ancestor, descendant): + nonlocal asked + asked += 1 return on_history monkeypatch.setattr(code_link_reads.code, "descends", descends) @@ -405,6 +408,12 @@ async def descends(org, ns, ancestor, descendant): # a link the writer parked behind a running pass is unknown even at the checked head expected = "unknown" if state == "pending" else state assert await code_link_reads.guidance_code_states("o", [row]) == [expected] + # a link that cannot earn positive guidance costs no git read: a pending state, or a + # path still owed a recheck + asked = 0 + unparsed = '["src/a.py"]' + assert await code_link_reads.guidance_code_states("o", [row]) == ["unknown"] + assert asked == 0 async def test_guidance_judges_a_late_link_by_the_row_it_classified(monkeypatch) -> None: @@ -924,7 +933,52 @@ async def descends(org, ns, ancestor, descendant): return True monkeypatch.setattr(code_link_reads.code, "descends", descends) - links = [_link("m1", checked=f"{i:040d}", covered=1) for i in range(12)] + n = code_link_reads._HISTORY_PAIRS + links = [_link("m1", checked=f"{i:040d}", covered=1) for i in range(n)] out = await code_link_reads._on_history("o", {"code-a": ("h" * 40, set())}, links) - assert len(out) == 12 and all(out.values()) + assert len(out) == n and all(out.values()) assert peak <= code_link_reads._HISTORY_READS + + +async def test_history_reads_stop_at_the_pair_cap(monkeypatch) -> None: + from server.memory.app import code_link_reads + + asked: list[str] = [] + + async def descends(org, ns, ancestor, descendant): + asked.append(ancestor) + return True + + monkeypatch.setattr(code_link_reads.code, "descends", descends) + n = code_link_reads._HISTORY_PAIRS + 5 + links = [_link("m1", checked=f"{i:040d}", covered=1) for i in range(n)] + out = await code_link_reads._on_history("o", {"code-a": ("h" * 40, set())}, links) + assert len(asked) == code_link_reads._HISTORY_PAIRS + assert len(out) == n and sum(out.values()) == code_link_reads._HISTORY_PAIRS + + +async def test_history_reads_past_the_deadline_read_unknown(monkeypatch) -> None: + import asyncio + import time + + from server.memory.app import code_link_reads + + cancelled = 0 + + async def descends(org, ns, ancestor, descendant): + nonlocal cancelled + try: + await asyncio.sleep(30) + except asyncio.CancelledError: + cancelled += 1 + raise + return True + + monkeypatch.setattr(code_link_reads.code, "descends", descends) + monkeypatch.setattr(code_link_reads, "_HISTORY_DEADLINE", 0.05) + links = [_link("m1", checked=f"{i:040d}", covered=1) for i in range(3)] + started = time.monotonic() + out = await code_link_reads._on_history("o", {"code-a": ("h" * 40, set())}, links) + assert time.monotonic() - started < 1 + assert len(out) == 3 and not any(out.values()) + assert cancelled == 3 From 3709f7f9b48fdf8d68ffa512544cfef33dc7d19b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 20:57:49 +0530 Subject: [PATCH 080/117] Guidance history reads end before search's own budget and skip a memory that is owed a recheck The history deadline equalled the outer 0.2 second search budget, so one slow pair wiped every hit to unknown. It is now 0.1 seconds. Ancestry checks run only for memories whose links are all clear of owed paths and whose checkpoint is the indexed head, so they do not spend pair slots. Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 13 +-- server/memory/app/code_link_reads.py | 54 ++++++------- tests/unit/test_memory_code_plane_reads.py | 84 ++++++++++++++++++++ 3 files changed, 115 insertions(+), 36 deletions(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index 432960438fb..a07254fb859 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -900,11 +900,14 @@ until the next pass covers it. The checkpoint and the links are read together un checkpoint. A covered link at an older commit needs one `git merge-base --is-ancestor` to prove that -commit is on the checkpoint's history. A read runs those checks only for links that could -still serve positive guidance: a fresh or moved state, a checkpoint, and no path owed a -recheck. One request checks at most 8 distinct (repository, commit) pairs, four at a time, -under one 0.2 second deadline. A pair over the cap, or still running at the deadline, is -cancelled and reads as unknown, so a slow mirror never turns a link positive. +commit is on the checkpoint's history. A read runs those checks only for a memory that +could still serve positive guidance: a fresh or moved state, a checkpoint that is the +indexed head, and no link owed a path recheck. If any link of a memory fails that, none of +its links is checked. One request checks at most 8 distinct (repository, commit) pairs, +four at a time, under one 0.1 second deadline, inside the 0.2 second budget search gives +guidance. A pair over the cap is never started, and a running pair is cancelled at the +deadline. Both read as unknown, so a slow mirror never turns a link positive and never +costs the memories that were checked at the head. ## Invariants diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 6a5e8454748..1cd6c494b78 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -188,8 +188,9 @@ def _current(a: LinkRow, proof: tuple[str, set[str]], kept: Mapping[tuple[str, s _HISTORY_READS = 4 # not a setting: distinct (repository, commit) pairs one request checks; the rest read unknown _HISTORY_PAIRS = 8 -# not a setting: seconds the whole ancestry phase may take; a late answer reads as unknown -_HISTORY_DEADLINE = 0.2 +# not a setting: seconds the whole ancestry phase may take; a late answer reads as unknown. +# Search bounds all of guidance at 0.2, so this stays well under it and leaves room to answer. +_HISTORY_DEADLINE = 0.1 async def _on_history( @@ -227,19 +228,6 @@ async def one(cns: str, commit: str) -> None: return kept -async def _confirm( - org: str, - positive: dict[tuple[str, str], list[tuple[int, str]]], - states: list[str], -) -> None: - """Serve the positive states of the repositories whose checked head is the indexed one.""" - indexed = await _guidance_indexed_heads(org, [cns for cns, _ in positive]) - for (cns, checked_head), hits in positive.items(): - if indexed.get(cns) == checked_head: - for index, state in hits: - states[index] = state - - async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: """Classify every readable link made from the evidence in the served memory revision.""" states = ["unknown"] * len(rows) @@ -285,36 +273,40 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for link in links: key = (link["memory_id"], link["namespace"], link["code_namespace"], link["inputs_hash"]) by_revision[key].append(link) - positive: dict[tuple[str, str], list[tuple[int, str]]] = defaultdict(list) states_by_index = { index: guidance_link_state(by_revision.get(key, []), readable) for index, key in candidates.items() } - # git ancestry only for links that could still earn positive guidance - eligible = [ - a + # Only a memory that could still earn positive guidance costs a git read: a fresh or + # moved state, a checkpoint that is the indexed head, and no link owed a recheck. + served = { + index: key for index, key in candidates.items() if states_by_index[index] in {"fresh", "moved"} and isinstance(proof := coverage.get(key[2]), tuple) and proof[0] + } + with sequential_reads(): + indexed = await _guidance_indexed_heads(org, sorted({key[2] for key in served.values()})) + eligible = [ + a + for key in served.values() + if indexed.get(key[2]) == coverage[key[2]][0] + and not any(a["path"] in coverage[key[2]][1] for a in by_revision.get(key, [])) for a in by_revision.get(key, []) - if a["path"] not in proof[1] ] kept = await _on_history(org, coverage, eligible) for index, key in candidates.items(): - rows_for_hit = by_revision.get(key, []) state = states_by_index[index] - if state in {"fresh", "moved"}: - proof = coverage.get(key[2]) - if not isinstance(proof, tuple): - continue - if not proof[0] or not all(_current(a, proof, kept) for a in rows_for_hit): - continue - positive[key[2], proof[0]].append((index, state)) - else: + if index not in served: + if state not in {"fresh", "moved"}: + states[index] = state + continue + proof = coverage[key[2]] + if indexed.get(key[2]) == proof[0] and all( + _current(a, proof, kept) for a in by_revision.get(key, []) + ): states[index] = state - with sequential_reads(): - await _confirm(org, positive, states) return states diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index a4cb788d147..972f3a9dcb1 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -515,6 +515,90 @@ async def all_state_many(pairs): assert seen_active == [True, True] +def _two_memories(monkeypatch, links, *, owed: str = "", descends=None) -> None: + from server.memory.app import code_link_reads + + head = "a" * 40 + + async def readable(org, namespaces): + return namespaces + + async def for_memories(org, ids): + return links + + async def checked_head(org, ns): + return head + + async def link_cursor(name): + return owed + + async def all_state_many(pairs): + return { + ("o", "code-a"): { + "clone_head": {"value": head, "detail": "main"}, + "git_head": {"value": head}, + } + } + + async def yes(org, ns, ancestor, descendant): + return True + + monkeypatch.setattr(code_link_reads.code, "descends", descends or yes) + monkeypatch.setattr(code_link_reads, "code_namespace_for", lambda *_: "code-a") + monkeypatch.setattr(code_link_reads, "readable_namespaces", readable) + monkeypatch.setattr(code_link_reads.store, "for_memories", for_memories) + monkeypatch.setattr( + code_link_reads.code, "repo_for_namespace", lambda *_: SimpleNamespace(git_branch="main") + ) + monkeypatch.setattr( + code_link_reads.code, "CodeRepo", lambda: SimpleNamespace(all_state_many=all_state_many) + ) + monkeypatch.setattr(code_link_reads.code, "checked_head", checked_head) + monkeypatch.setattr(code_link_reads.code, "link_cursor", link_cursor) + + +@pytest.mark.asyncio +async def test_a_slow_history_read_does_not_wipe_an_at_head_memory(monkeypatch) -> None: + """Search bounds guidance at 0.2 seconds; the history deadline fires first, so the + memory checked at the head keeps its state when another memory's pair is slow.""" + import asyncio + + from server.memory.app import code_link_reads + + async def slow(org, ns, ancestor, descendant): + await asyncio.sleep(30) + return True + + links = [ + _link("m1", checked="a" * 40), + _link("m2", checked="c" * 40, covered=1), + ] + _two_memories(monkeypatch, links, descends=slow) + rows = [_excerpt("m1", "one"), _excerpt("m2", "two")] + states = await asyncio.wait_for(code_link_reads.guidance_code_states("o", rows), 0.2) + assert states == ["fresh", "unknown"] + + +@pytest.mark.asyncio +async def test_a_memory_owed_a_recheck_spends_no_history_read(monkeypatch) -> None: + """One owed link rules out the whole memory, so its clean links take no pair slot.""" + from server.memory.app import code_link_reads + + asked: list[str] = [] + + async def descends(org, ns, ancestor, descendant): + asked.append(ancestor) + return True + + links = [ + _link("m1", qn="a::A::x", path="src/owed.py", checked="c" * 40, covered=1), + _link("m1", qn="a::A::y", path="src/clean.py", checked="d" * 40, covered=1), + ] + _two_memories(monkeypatch, links, owed='["src/owed.py"]', descends=descends) + assert await code_link_reads.guidance_code_states("o", [_excerpt("m1", "one")]) == ["unknown"] + assert asked == [] + + @pytest.mark.asyncio async def test_code_gone_from_trunk_still_teaches_the_branch_that_has_it(monkeypatch) -> None: links = [_link("m1", state="missing", since="c3")] From 0801ea4867f24a1da3e713bfd53232789762d115 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 22:21:18 +0530 Subject: [PATCH 081/117] Guidance code states narrow each namespace's checkpoint to a proof once, so the history and head reads index a typed mapping Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 1cd6c494b78..8216a7c6e35 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -264,7 +264,11 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l checked = await asyncio.gather( *(_guidance_coverage(org, cns) for cns in namespaces), return_exceptions=True ) - coverage = dict(zip(namespaces, checked, strict=True)) + proofs: dict[str, tuple[str, set[str]]] = { + cns: proof + for cns, proof in zip(namespaces, checked, strict=True) + if isinstance(proof, tuple) + } links = await store.for_memories(org, mids) except Exception as error: # noqa: BLE001 — unavailable links leave guidance uncertain log.debug("Guidance code links unavailable: %s", type(error).__name__) @@ -283,7 +287,7 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l index: key for index, key in candidates.items() if states_by_index[index] in {"fresh", "moved"} - and isinstance(proof := coverage.get(key[2]), tuple) + and (proof := proofs.get(key[2])) is not None and proof[0] } with sequential_reads(): @@ -291,18 +295,18 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l eligible = [ a for key in served.values() - if indexed.get(key[2]) == coverage[key[2]][0] - and not any(a["path"] in coverage[key[2]][1] for a in by_revision.get(key, [])) + if indexed.get(key[2]) == proofs[key[2]][0] + and not any(a["path"] in proofs[key[2]][1] for a in by_revision.get(key, [])) for a in by_revision.get(key, []) ] - kept = await _on_history(org, coverage, eligible) + kept = await _on_history(org, proofs, eligible) for index, key in candidates.items(): state = states_by_index[index] if index not in served: if state not in {"fresh", "moved"}: states[index] = state continue - proof = coverage[key[2]] + proof = proofs[key[2]] if indexed.get(key[2]) == proof[0] and all( _current(a, proof, kept) for a in by_revision.get(key, []) ): From c29ada920bead6f326382b908431316a0675112b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 22:28:44 +0530 Subject: [PATCH 082/117] Guidance confirms the indexed head again after its ancestry reads, so a head that advanced meanwhile reads unknown Signed-off-by: Krishna Dobhal --- docs/architecture/code-index-architecture.md | 3 ++- server/memory/app/code_link_reads.py | 5 +++++ tests/unit/test_memory_code_plane_reads.py | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/architecture/code-index-architecture.md b/docs/architecture/code-index-architecture.md index a07254fb859..739fb97e0e3 100644 --- a/docs/architecture/code-index-architecture.md +++ b/docs/architecture/code-index-architecture.md @@ -907,7 +907,8 @@ its links is checked. One request checks at most 8 distinct (repository, commit) four at a time, under one 0.1 second deadline, inside the 0.2 second budget search gives guidance. A pair over the cap is never started, and a running pair is cancelled at the deadline. Both read as unknown, so a slow mirror never turns a link positive and never -costs the memories that were checked at the head. +costs the memories that were checked at the head. The indexed head is read again after the +ancestry checks, and a namespace whose head moved meanwhile reads as unknown. ## Invariants diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 8216a7c6e35..db85cc3cf3b 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -300,6 +300,11 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for a in by_revision.get(key, []) ] kept = await _on_history(org, proofs, eligible) + if kept: + # The index may advance while git answers: confirm the head after the ancestry reads. + with sequential_reads(): + after = await _guidance_indexed_heads(org, sorted({key[2] for key in served.values()})) + indexed = {cns: head for cns, head in indexed.items() if after.get(cns) == head} for index, key in candidates.items(): state = states_by_index[index] if index not in served: diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 972f3a9dcb1..33903b5ee6c 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -579,6 +579,25 @@ async def slow(org, ns, ancestor, descendant): assert states == ["fresh", "unknown"] +@pytest.mark.asyncio +async def test_a_head_that_advances_during_ancestry_reads_unknown(monkeypatch) -> None: + from server.memory.app import code_link_reads + + heads = {"code-a": "a" * 40} + + async def descends(org, ns, ancestor, descendant): + heads["code-a"] = "b" * 40 + return True + + async def caught_up(org, namespaces): + return dict(heads) + + links = [_link("m1", checked="c" * 40, covered=1)] + _two_memories(monkeypatch, links, descends=descends) + monkeypatch.setattr(code_link_reads.code, "caught_up_heads", caught_up) + assert await code_link_reads.guidance_code_states("o", [_excerpt("m1", "one")]) == ["unknown"] + + @pytest.mark.asyncio async def test_a_memory_owed_a_recheck_spends_no_history_read(monkeypatch) -> None: """One owed link rules out the whole memory, so its clean links take no pair slot.""" From 36f28f32d8c9d99208a628a5ef60ab7526ed33bc Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 22:28:45 +0530 Subject: [PATCH 083/117] A list read that ends on an empty truncated page is incomplete, so a single match is not taken as the unique writer Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 9 +++++++++ frontend/src/lib/memoriesSearch.ts | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 3c594ea89d4..d49e565272c 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -82,6 +82,15 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(listMemories).toHaveBeenCalledTimes(1); }); + it("names no writer when an empty truncated page follows one match", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [row], rows_read: 1, total: 3, truncated: true } as never) + .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 3, truncated: true } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + }); + it("keeps the wildcards for a namespace-wide token", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); await resolveSearchWriter(identity, hit, ABORT); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 1b5a464066c..05332af8c55 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -25,7 +25,7 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: /** The pages of one list read, until the list ends or `MAX_PAGES` are read. The server may * cap a page below `limit` and drop rows it no longer serves, so the next offset is the rows - * it read, and a page that read none ends the read. The last page yielded says whether + * it read, and a page that read none ends the read, `done` only if it is not truncated. The last page yielded says whether * the list was read to its end (`done`). */ const MAX_PAGES = 10; export async function* listPages( @@ -37,8 +37,10 @@ export async function* listPages( const page = await listMemories(id, limit, { ...opts, offset }); const read = page.rows_read || page.entries.length; offset += read; - yield { ...page, done: !read || offset >= page.total }; - if (!read || offset >= page.total) return; + // A page that read nothing ends the list only when it is not truncated. + const done = offset >= page.total || (!read && !page.truncated); + yield { ...page, done }; + if (done || !read) return; } } From 1b7ecf608e5e5ddc82d2a58701bfb15231061af6 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Mon, 30 Nov 2026 22:32:42 +0530 Subject: [PATCH 084/117] Guidance re-reads the indexed head whenever it waited on git, so a timed-out history check cannot leave a stale head fresh Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 2 +- tests/unit/test_memory_code_plane_reads.py | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index db85cc3cf3b..f739bc829a7 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -300,7 +300,7 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l for a in by_revision.get(key, []) ] kept = await _on_history(org, proofs, eligible) - if kept: + if eligible: # The index may advance while git answers: confirm the head after the ancestry reads. with sequential_reads(): after = await _guidance_indexed_heads(org, sorted({key[2] for key in served.values()})) diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 33903b5ee6c..2c34b6c4318 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -598,6 +598,30 @@ async def caught_up(org, namespaces): assert await code_link_reads.guidance_code_states("o", [_excerpt("m1", "one")]) == ["unknown"] +@pytest.mark.asyncio +async def test_a_head_that_advances_while_history_times_out_reads_unknown(monkeypatch) -> None: + import asyncio + + from server.memory.app import code_link_reads + + heads = {"code-a": "a" * 40} + + async def slow(org, ns, ancestor, descendant): + heads["code-a"] = "b" * 40 + await asyncio.sleep(30) + return True + + async def caught_up(org, namespaces): + return dict(heads) + + links = [_link("m1", checked="a" * 40), _link("m2", checked="c" * 40, covered=1)] + _two_memories(monkeypatch, links, descends=slow) + monkeypatch.setattr(code_link_reads.code, "caught_up_heads", caught_up) + rows = [_excerpt("m1", "one"), _excerpt("m2", "two")] + states = await asyncio.wait_for(code_link_reads.guidance_code_states("o", rows), 0.2) + assert states == ["unknown", "unknown"] + + @pytest.mark.asyncio async def test_a_memory_owed_a_recheck_spends_no_history_read(monkeypatch) -> None: """One owed link rules out the whole memory, so its clean links take no pair slot.""" From 2006a33eaf2171c36f427fd601cdbe74f2677bb3 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 00:24:13 +0530 Subject: [PATCH 085/117] A truncated list page never ends the read as complete, so the search writer lookup keeps paging past a lagging total Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 20 ++++++++++++++++++++ frontend/src/lib/memoriesSearch.ts | 8 +++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index d49e565272c..d1c6acbf037 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -91,6 +91,26 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); }); + it("keeps paging past a stale total while the page is truncated and finds a second writer", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = (u: string) => ({ memory_key: "deploy_note", agent: "claude-desktop", user_id: u, session_id: "s1" }); + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [row("u1")], rows_read: 1, total: 1, truncated: true } as never) + .mockResolvedValueOnce({ entries: [row("u2")], rows_read: 1, total: 2, truncated: false } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); + }); + + it("names no writer when the total is reached on a truncated page with nothing after it", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + vi.mocked(listMemories) + .mockResolvedValueOnce({ entries: [row], rows_read: 1, total: 1, truncated: true } as never) + .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 1, truncated: true } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + expect(listMemories).toHaveBeenCalledTimes(2); + }); + it("keeps the wildcards for a namespace-wide token", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); await resolveSearchWriter(identity, hit, ABORT); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 05332af8c55..3326c8e6b16 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -25,7 +25,8 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: /** The pages of one list read, until the list ends or `MAX_PAGES` are read. The server may * cap a page below `limit` and drop rows it no longer serves, so the next offset is the rows - * it read, and a page that read none ends the read, `done` only if it is not truncated. The last page yielded says whether + * it read, and a page that read none ends the read. A truncated page is never `done`, even at + * `total`, so the read goes on while rows come back. The last page yielded says whether * the list was read to its end (`done`). */ const MAX_PAGES = 10; export async function* listPages( @@ -37,8 +38,9 @@ export async function* listPages( const page = await listMemories(id, limit, { ...opts, offset }); const read = page.rows_read || page.entries.length; offset += read; - // A page that read nothing ends the list only when it is not truncated. - const done = offset >= page.total || (!read && !page.truncated); + // A truncated page never completes the list (its total is cached apart from the page, so + // it can lag): paging goes on while rows are read, and an empty truncated page ends it incomplete. + const done = !page.truncated && (offset >= page.total || !read); yield { ...page, done }; if (done || !read) return; } From a8cd4c1ac3e1f78cdefc7c85e79cd44e259177ff Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 01:14:17 +0530 Subject: [PATCH 086/117] Guidance candidate selection and evidence line labels are their own helpers, so both functions stay under the length gate Signed-off-by: Krishna Dobhal --- server/memory/app/code_link_reads.py | 15 ++++++++++++--- server/memory/domain/evidence_pack.py | 22 +++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index f739bc829a7..df5d89f7fbf 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -228,9 +228,11 @@ async def one(cns: str, commit: str) -> None: return kept -async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: - """Classify every readable link made from the evidence in the served memory revision.""" - states = ["unknown"] * len(rows) +def _guidance_candidates( + org: str, rows: Sequence[Mapping[str, Any]], states: list[str] +) -> dict[int, tuple[str, str, str, str]]: + """The rows whose revision can have links, keyed by row index to (memory id, namespace, + code namespace, inputs hash); a row with no code namespace settles in `states` here.""" candidates: dict[int, tuple[str, str, str, str]] = {} for index, row in enumerate(rows): if not {"namespace", "tags", "files", "user_id"} <= row.keys(): @@ -250,6 +252,13 @@ async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> l files = [str(path) for path in row["files"] or ()] inputs = inputs_hash(sha, files, cns, str(row["user_id"])) candidates[index] = (str(row["memory_id"]), ns, cns, inputs) + return candidates + + +async def guidance_code_states(org: str, rows: Sequence[Mapping[str, Any]]) -> list[str]: + """Classify every readable link made from the evidence in the served memory revision.""" + states = ["unknown"] * len(rows) + candidates = _guidance_candidates(org, rows, states) if not candidates: return states try: diff --git a/server/memory/domain/evidence_pack.py b/server/memory/domain/evidence_pack.py index 730ffb84697..8970ec03131 100644 --- a/server/memory/domain/evidence_pack.py +++ b/server/memory/domain/evidence_pack.py @@ -85,6 +85,18 @@ def _opening(states: list[str], changed: bool) -> list[str]: return [sentence for sentence in said if sentence] +def _labels(item: EvidenceItem) -> str: + """The `key=value` labels a line carries after its citation.""" + marker = " conflict=true" if item.conflict else "" + date = f" date={item.temporal_anchor[:10]}" if item.temporal_anchor else "" + code = f" code_state={item.code_state}" if item.code_state else "" + code += f" rev={item.code_rev[:12]}" if item.code_rev else "" + if code: + code += code_change.written_on(item.code_written, item.code_first_written) + code += session_change.label(item.changed_in) + return f"source={item.source}{item.author}{_derived(item)}{date}{marker}{code}" + + def pack_evidence( items: list[EvidenceItem], *, @@ -138,15 +150,7 @@ def pack_evidence( changed = False # a line served is of a memory of code before its session's change for item in ordered: group = item.group or item.source or "fact" - marker = " conflict=true" if item.conflict else "" - date = f" date={item.temporal_anchor[:10]}" if item.temporal_anchor else "" - code = f" code_state={item.code_state}" if item.code_state else "" - code += f" rev={item.code_rev[:12]}" if item.code_rev else "" - if code: - code += code_change.written_on(item.code_written, item.code_first_written) - code += session_change.label(item.changed_in) - labels = f"source={item.source}{item.author}{_derived(item)}{date}{marker}{code}" - line = one_item(f"- [{label_part(item.citation)} {labels}] {item.text}") + line = one_item(f"- [{label_part(item.citation)} {_labels(item)}] {item.text}") # the line fits with the sentences the list then opens with said = _opening([*served, _state(item)], changed or bool(item.changed_in)) if len("\n".join([*said, *lines, line])) > char_budget: From fdc691fb107eeb0abacfe254420a5bc9b8deaea5 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 07:07:58 +0530 Subject: [PATCH 087/117] A writer lookup that sees the namespace version change between pages is incomplete, so it names no unique writer Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 22 ++++++++++++++++++++++ frontend/src/lib/memoriesSearch.ts | 11 ++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index d1c6acbf037..1ec99c4ebf3 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -111,6 +111,28 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(listMemories).toHaveBeenCalledTimes(2); }); + it("names no writer when the namespace version changes between pages", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const fill = Array.from({ length: 99 }, (_, i) => ({ ...row, memory_key: `deploy_note_${i}` })); + vi.mocked(listMemories) + .mockResolvedValueOnce({ + entries: [row, ...fill], + rows_read: 100, + total: 101, + truncated: false, + namespace_version: "1", + } as never) + .mockResolvedValueOnce({ + entries: [], + rows_read: 0, + total: 100, + truncated: false, + namespace_version: "2", + } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + }); + it("keeps the wildcards for a namespace-wide token", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); await resolveSearchWriter(identity, hit, ABORT); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 3326c8e6b16..2e60b436c89 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -27,22 +27,27 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: * cap a page below `limit` and drop rows it no longer serves, so the next offset is the rows * it read, and a page that read none ends the read. A truncated page is never `done`, even at * `total`, so the read goes on while rows come back. The last page yielded says whether - * the list was read to its end (`done`). */ + * the list was read to its end (`done`). Offsets only line up while the namespace holds still, + * so a page whose `namespace_version` differs from the first page's (or lacks it) ends the + * read incomplete. */ const MAX_PAGES = 10; export async function* listPages( id: Identity, limit: number, opts: Parameters[2] & { signal: AbortSignal }, ): AsyncGenerator { + let version: string | undefined; for (let offset = 0, n = 0; n < MAX_PAGES && !opts.signal.aborted; n++) { const page = await listMemories(id, limit, { ...opts, offset }); const read = page.rows_read || page.entries.length; offset += read; // A truncated page never completes the list (its total is cached apart from the page, so // it can lag): paging goes on while rows are read, and an empty truncated page ends it incomplete. - const done = !page.truncated && (offset >= page.total || !read); + if (n === 0) version = page.namespace_version; + const stable = page.namespace_version === version; + const done = stable && !page.truncated && (offset >= page.total || !read); yield { ...page, done }; - if (done || !read) return; + if (done || !read || !stable) return; } } From 45d6c875c8f4239b1adf85fb2be99291732512df Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 08:22:31 +0530 Subject: [PATCH 088/117] A row from another owned namespace reaches guidance only while its Postgres head is current memory.for_file attached guidance to rows of the caller's other namespaces without the current-head check the request's own rows pass, so a mirror row whose head was redacted or tombstoned could still be served. Signed-off-by: Krishna Dobhal --- server/memory/app/for_file.py | 5 +++- tests/unit/test_file_rules_shared.py | 34 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index 06a6e7bbc9b..8207d5e7cef 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -1048,7 +1048,10 @@ async def handle_memory_for_file(input: MemoryForFileInput) -> MemoryForFileOutp ) if others is not None: note_budget_shape("own_namespaces") - rows = rows + others[: max(int(input.top_k) - len(rows), 0)] + # Postgres owns what is current: a mirror row whose head is redacted never reaches + # guidance, and the places `top_k` leaves go to rows that pass. + current = await current_file_rows(input.org, others) + rows = rows + current[: max(int(input.top_k) - len(rows), 0)] await guided_file_rows(input.org, rows) hits: list[_MemoryForFileHit] = [] diff --git a/tests/unit/test_file_rules_shared.py b/tests/unit/test_file_rules_shared.py index 583f327df25..27df82d0468 100644 --- a/tests/unit/test_file_rules_shared.py +++ b/tests/unit/test_file_rules_shared.py @@ -655,6 +655,40 @@ async def test_all_mine_serves_the_rows_the_caller_wrote_in_their_other_namespac assert out._served_rows == [("code-x", "rule"), ("session", "mine"), ("records", "lesson")] +@pytest.mark.asyncio +async def test_a_row_of_another_namespace_whose_postgres_head_is_redacted_is_not_served( + monkeypatch: pytest.MonkeyPatch, fixed_now: None +) -> None: + ident = {"agent": "a", "user_id": "-", "session_id": "-", "version": 1} + ch = _OwnCH( + { + "records": [ + _row("kept", "v", actor=_ME, **ident, content_sha256="h"), + _row("redacted", "stale mirror text", actor=_ME, **ident, content_sha256="h"), + ] + } + ) + monkeypatch.setattr(mff, "get_client", lambda: ch) + _fan_out(monkeypatch, "all_mine", ["records"]) + + async def heads(keys: Any) -> dict[Any, dict[str, Any]]: + head = {"version": 1, "content_sha256": "h", "status": "active"} + return { + k: head + | { + "memory_id": f"id-{k[-1]}", + "redacted_at": "2026-09-25" if k[-1] == "redacted" else None, + } + for k in keys + } + + monkeypatch.setattr(mff.pg, "enabled", lambda: True) + monkeypatch.setattr(mff.memory_reads, "guidance_heads", heads) + out = await mff.handle_memory_for_file(_request()) + assert [(h.namespace, h.memory_key) for h in out.hits] == [("records", "kept")] + assert "stale mirror text" not in out.rendered + + @pytest.mark.asyncio @pytest.mark.parametrize("session_rows", [0, 1]) async def test_a_row_from_elsewhere_prints_capped_with_or_without_a_row_of_the_requests_own( From 92958d2af315c037b98e8624abd163d964933a42 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 08:44:24 +0530 Subject: [PATCH 089/117] A list page names a namespace version only when no write landed while its rows were read memory.list sampled the version before the rows, so a deletion between the two left rows newer than the version a pager compares across pages. The version is sampled again after the rows and dropped when it moved; the pager already ends a read incomplete on a page with no version. Signed-off-by: Krishna Dobhal --- server/memory/app/query.py | 6 ++++++ .../unit/test_memory_list_change_watermark.py | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/server/memory/app/query.py b/server/memory/app/query.py index 3c01b7f7a57..720d2633cfd 100644 --- a/server/memory/app/query.py +++ b/server/memory/app/query.py @@ -306,6 +306,12 @@ async def _handle_memory_list(input: MemoryListInput) -> MemoryListOutput: **_served, scope=scope, ) + # Sampled before the rows so a poller never misses a write, and again after: a write in + # between leaves rows newer than the version, so none is served (a pager reads it as moved). + if namespace_version and not count_only: + after = await memory_repo.namespace_version(input.org, input.namespace) + if str(after) != namespace_version: + namespace_version = "" truncated = len(rows) > input.limit rows = rows[: input.limit] rows_read = len(rows) diff --git a/tests/unit/test_memory_list_change_watermark.py b/tests/unit/test_memory_list_change_watermark.py index 60d6aed687a..68957e4976c 100644 --- a/tests/unit/test_memory_list_change_watermark.py +++ b/tests/unit/test_memory_list_change_watermark.py @@ -145,3 +145,24 @@ def test_the_watermark_read_has_no_final_and_no_value_column() -> None: src = text[start : text.index("\n\n\nasync def", start)] sql = src.split('"""')[3] assert "max(version)" in sql and "FINAL" not in sql and "value" not in sql + + +@pytest.mark.asyncio +async def test_a_version_the_rows_were_read_under_is_the_only_one_served( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """A write between the version sample and the row read leaves the rows newer than the + version, so the answer names no version rather than one that covers rows it does not.""" + from server.memory.api.models_crud import MemoryListInput + from server.memory.app.query import _handle_memory_list + + seen = iter([4200, 4201]) + + async def moving(org: str, ns: str, **kw: Any) -> int: + return next(seen) + + monkeypatch.setattr(memory_repo, "namespace_version", moving) + out = await _handle_memory_list( + MemoryListInput(org="acme", namespace="team", agent="*", limit=100, offset=100) + ) + assert out.namespace_version == "" From 91379cd8832cf442c4cb229d0617579d81900052 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 08:52:33 +0530 Subject: [PATCH 090/117] The list namespace_version comment names the write-during-read case The field is empty also when a write landed while the rows were read. The generated reference and SDKs carry only the first sentence, so they are unchanged. Signed-off-by: Krishna Dobhal --- server/memory/api/models_crud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/memory/api/models_crud.py b/server/memory/api/models_crud.py index 6ffc95fe24a..47b70db0cae 100644 --- a/server/memory/api/models_crud.py +++ b/server/memory/api/models_crud.py @@ -923,7 +923,7 @@ class MemoryListOutput(BaseModel): # The namespace's newest memory version (any # agent, any status — every write moves it). Send it back as # `known_version` to learn cheaply whether anything changed. "" when the - # namespace has no rows or the read did not compute it. + # namespace has no rows, the read did not compute it, or a write landed while the rows were read. namespace_version: str = "" # True when `known_version` matched: entries, total and today were not # read and are their defaults. From 66e7432fff26062334d1f2d3ada2bb26b1548591 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 08:59:01 +0530 Subject: [PATCH 091/117] The head check of the other namespaces' rows runs under their time bound and failure guard A slow or failing Postgres read now drops those rows instead of failing the request. The check runs among the rows read, so it does not fetch more. Signed-off-by: Krishna Dobhal --- server/memory/app/for_file.py | 8 +++----- tests/unit/test_file_rules_shared.py | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/server/memory/app/for_file.py b/server/memory/app/for_file.py index 8207d5e7cef..e8b41e79466 100644 --- a/server/memory/app/for_file.py +++ b/server/memory/app/for_file.py @@ -887,7 +887,8 @@ async def _read_own( "links": held, } ) - return _supersede_order(sorted(rows, key=_order_key)) + # Postgres owns what is current: among the rows read, a redacted head never reaches guidance. + return await current_file_rows(input.org, _supersede_order(sorted(rows, key=_order_key))) def _hit(r: dict[str, Any], input: MemoryForFileInput) -> _MemoryForFileHit: @@ -1048,10 +1049,7 @@ async def handle_memory_for_file(input: MemoryForFileInput) -> MemoryForFileOutp ) if others is not None: note_budget_shape("own_namespaces") - # Postgres owns what is current: a mirror row whose head is redacted never reaches - # guidance, and the places `top_k` leaves go to rows that pass. - current = await current_file_rows(input.org, others) - rows = rows + current[: max(int(input.top_k) - len(rows), 0)] + rows = rows + others[: max(int(input.top_k) - len(rows), 0)] await guided_file_rows(input.org, rows) hits: list[_MemoryForFileHit] = [] diff --git a/tests/unit/test_file_rules_shared.py b/tests/unit/test_file_rules_shared.py index 27df82d0468..6bd3cdb0ac1 100644 --- a/tests/unit/test_file_rules_shared.py +++ b/tests/unit/test_file_rules_shared.py @@ -689,6 +689,32 @@ async def heads(keys: Any) -> dict[Any, dict[str, Any]]: assert "stale mirror text" not in out.rendered +@pytest.mark.asyncio +async def test_a_failing_head_check_of_the_other_namespaces_leaves_the_requests_own_rows( + monkeypatch: pytest.MonkeyPatch, fixed_now: None +) -> None: + ident = {"agent": "a", "user_id": "-", "session_id": "-", "version": 1} + ch = _OwnCH( + { + "session": [_row("mine", "v", **ident, content_sha256="h")], + "records": [_row("lesson", "v", actor=_ME, **ident, content_sha256="h")], + } + ) + monkeypatch.setattr(mff, "get_client", lambda: ch) + _fan_out(monkeypatch, "all_mine", ["records"]) + + async def heads(keys: Any) -> dict[Any, dict[str, Any]]: + if any(k[1] == "records" for k in keys): + raise RuntimeError("postgres is down") + head = {"version": 1, "content_sha256": "h", "status": "active", "memory_id": "id-mine"} + return {k: head for k in keys} + + monkeypatch.setattr(mff.pg, "enabled", lambda: True) + monkeypatch.setattr(mff.memory_reads, "guidance_heads", heads) + out = await mff.handle_memory_for_file(_request()) + assert [(h.namespace, h.memory_key) for h in out.hits] == [("session", "mine")] + + @pytest.mark.asyncio @pytest.mark.parametrize("session_rows", [0, 1]) async def test_a_row_from_elsewhere_prints_capped_with_or_without_a_row_of_the_requests_own( From 9eeebae8b1f5ce758c4a33705ebaee754288189d Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 08:59:01 +0530 Subject: [PATCH 092/117] A list page with no namespace version never counts as stable Two pages that both lack a version compared equal and ended the read as complete. Also wraps the field comment to the line limit. Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 41 +++++++++++++++++++++++-- frontend/src/lib/memoriesSearch.ts | 2 +- server/memory/api/models_crud.py | 3 +- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 1ec99c4ebf3..6bcc86b3b6a 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -54,12 +54,19 @@ describe("resolveSearchWriter under a narrowed token", () => { vi.mocked(storedToken).mockReturnValue(jwt({})); const other = { memory_key: "deploy_note_2", agent: "claude-desktop", user_id: "u2", session_id: "s2" }; vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [other], rows_read: 1, total: 2, truncated: true } as never) + .mockResolvedValueOnce({ + entries: [other], + rows_read: 1, + total: 2, + truncated: true, + namespace_version: "1", + } as never) .mockResolvedValueOnce({ entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], rows_read: 1, total: 2, truncated: false, + namespace_version: "1", } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1", session_id: "s1" }); expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); @@ -69,8 +76,20 @@ describe("resolveSearchWriter under a narrowed token", () => { vi.mocked(storedToken).mockReturnValue(jwt({})); const row = (k: string) => ({ memory_key: k, agent: "claude-desktop", user_id: "u1", session_id: "s1" }); vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [row("x")], rows_read: 0, total: 2, truncated: true } as never) - .mockResolvedValueOnce({ entries: [row("deploy_note")], rows_read: 0, total: 2, truncated: false } as never); + .mockResolvedValueOnce({ + entries: [row("x")], + rows_read: 0, + total: 2, + truncated: true, + namespace_version: "1", + } as never) + .mockResolvedValueOnce({ + entries: [row("deploy_note")], + rows_read: 0, + total: 2, + truncated: false, + namespace_version: "1", + } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1" }); expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); }); @@ -133,6 +152,22 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); }); + it("names no writer when neither page carries a namespace version", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const fill = Array.from({ length: 99 }, (_, i) => ({ ...row, memory_key: `deploy_note_${i}` })); + vi.mocked(listMemories) + .mockResolvedValueOnce({ + entries: [row, ...fill], + rows_read: 100, + total: 101, + truncated: false, + namespace_version: "", + } as never) + .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 100, truncated: false, namespace_version: "" } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + }); + it("keeps the wildcards for a namespace-wide token", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); await resolveSearchWriter(identity, hit, ABORT); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 2e60b436c89..e6e59b0c0fc 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -44,7 +44,7 @@ export async function* listPages( // A truncated page never completes the list (its total is cached apart from the page, so // it can lag): paging goes on while rows are read, and an empty truncated page ends it incomplete. if (n === 0) version = page.namespace_version; - const stable = page.namespace_version === version; + const stable = n === 0 || (!!version && page.namespace_version === version); const done = stable && !page.truncated && (offset >= page.total || !read); yield { ...page, done }; if (done || !read || !stable) return; diff --git a/server/memory/api/models_crud.py b/server/memory/api/models_crud.py index 47b70db0cae..dcf4bdeb3e4 100644 --- a/server/memory/api/models_crud.py +++ b/server/memory/api/models_crud.py @@ -923,7 +923,8 @@ class MemoryListOutput(BaseModel): # The namespace's newest memory version (any # agent, any status — every write moves it). Send it back as # `known_version` to learn cheaply whether anything changed. "" when the - # namespace has no rows, the read did not compute it, or a write landed while the rows were read. + # namespace has no rows, the read did not compute it, or a write landed while the + # rows were read. namespace_version: str = "" # True when `known_version` matched: entries, total and today were not # read and are their defaults. From 3252833dd0d35c3eb029c82343fe173a277c738b Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 12:12:50 +0530 Subject: [PATCH 093/117] A fallback to trunk's link state keeps the recorded code state and holds back only the guidance The memory list's two count reads move into a helper so the list handler stays under the function-length cap. Signed-off-by: Krishna Dobhal --- server/memory/app/code_plane_reads.py | 4 +- server/memory/app/query.py | 129 ++++++++++++--------- tests/unit/test_memory_code_plane_reads.py | 6 +- 3 files changed, 78 insertions(+), 61 deletions(-) diff --git a/server/memory/app/code_plane_reads.py b/server/memory/app/code_plane_reads.py index 43b0db503d6..cad831fc6b6 100644 --- a/server/memory/app/code_plane_reads.py +++ b/server/memory/app/code_plane_reads.py @@ -155,9 +155,7 @@ async def lessons_for_symbol( "memory_key": str(row["memory_key"]), "namespace": str(row["namespace"]), "excerpt": str(row["excerpt"]), - "code_state": ( - "unknown" if a["memory_id"] in trunk_only and state in ("fresh", "moved") else state - ), + "code_state": state, # as recorded; `unchecked` below holds back the guidance "rev": str(a.get("anchored_commit") or "")[:12], "first_written": str(row.get("created_at") or "")[:10], "changed_since": a["changed_since"] if state == "changed" else "", diff --git a/server/memory/app/query.py b/server/memory/app/query.py index 720d2633cfd..a1a84520678 100644 --- a/server/memory/app/query.py +++ b/server/memory/app/query.py @@ -318,10 +318,82 @@ async def _handle_memory_list(input: MemoryListInput) -> MemoryListOutput: rows = await _served_by_authority(input, rows, _served) if _wants_usage(keep): rows = await memory_repo.overlay_usage_totals_many(rows) + total, today = await _list_counts( + input, identity, tag_filter, _served, scope, namespace_version + ) + VALUE_PREVIEW_BYTES = 2048 + # The caller's preview length, at most the stored one. + preview_chars = min( + VALUE_PREVIEW_BYTES, + int(input.preview_chars or VALUE_PREVIEW_BYTES), + ) + return _project_entries( + MemoryListOutput( + total=total, + today=today, + namespace_version=namespace_version, + **await _hidden_under_prefix(input, identity, tag_filter, _served, total), + entries=[ + _MemoryListEntry( + memory_key=r.memory_key, + memory_type=r.memory_type, + confidence=r.confidence, + version=r.version, + created_at=r.created_at, + updated_at=r.updated_at or r.created_at, + expires_at=r.expires_at, + valid_at=r.valid_at, + tombstoned_at=r.tombstoned_at, + status=r.status or "active", + pinned=r.pinned, + verified_by=r.verified_by, + verification=_trust.verification_state( + r.verified_by, + r.verified_sha256, + _trust.row_content_sha256(r), + ), + evidence_count=r.evidence_count, + recall_count=r.recall_count, + last_recalled_at=r.last_recalled_at, + sensitivity=r.sensitivity, + tags=list(r.tags or []), + # A row labelled high after the extractor ran keeps entities mined from + # its value. + entities=[] if r.sensitivity == "high" else public_entities(r.entities), + agent=r.agent or "", + user_id=r.user_id or "", + session_id=r.session_id or "", + source_trace=r.source_trace, + value=pv, + value_truncated=pcut, + # A short secret's hash can be guessed; a high row's comes with the value. + content_sha256="" if r.sensitivity == "high" else _trust.row_content_sha256(r), + char_limit=r.char_limit, + ) + for r, (pv, pcut) in ((r, _preview_for_list(r, preview_chars)) for r in rows) + ], + truncated=truncated, + rows_read=rows_read, + ), + keep, + ) + + +async def _list_counts( + input: MemoryListInput, + identity: Any, + tag_filter: Any, + _served: ServedFlags, + scope: Any, + namespace_version: str, +) -> tuple[int, int]: + """The total and today counts, remembered per (scope, namespace version, UTC day).""" # The two counts under FINAL are remembered per (scope, namespace version, UTC day) — a # changed page recomputes them once, not on every poll that saw a change. from datetime import UTC, datetime + import server.memory.store as memory_repo + _today_start = datetime.now(UTC).replace(hour=0, minute=0, second=0, microsecond=0, tzinfo=None) count_key = ( scope, @@ -381,62 +453,7 @@ async def _handle_memory_list(input: MemoryListInput) -> MemoryListOutput: if len(_list_counts_cache) > 2048: _list_counts_cache.clear() _list_counts_cache[count_key] = (total, today) - VALUE_PREVIEW_BYTES = 2048 - # The caller's preview length, at most the stored one. - preview_chars = min( - VALUE_PREVIEW_BYTES, - int(input.preview_chars or VALUE_PREVIEW_BYTES), - ) - return _project_entries( - MemoryListOutput( - total=total, - today=today, - namespace_version=namespace_version, - **await _hidden_under_prefix(input, identity, tag_filter, _served, total), - entries=[ - _MemoryListEntry( - memory_key=r.memory_key, - memory_type=r.memory_type, - confidence=r.confidence, - version=r.version, - created_at=r.created_at, - updated_at=r.updated_at or r.created_at, - expires_at=r.expires_at, - valid_at=r.valid_at, - tombstoned_at=r.tombstoned_at, - status=r.status or "active", - pinned=r.pinned, - verified_by=r.verified_by, - verification=_trust.verification_state( - r.verified_by, - r.verified_sha256, - _trust.row_content_sha256(r), - ), - evidence_count=r.evidence_count, - recall_count=r.recall_count, - last_recalled_at=r.last_recalled_at, - sensitivity=r.sensitivity, - tags=list(r.tags or []), - # A row labelled high after the extractor ran keeps entities mined from - # its value. - entities=[] if r.sensitivity == "high" else public_entities(r.entities), - agent=r.agent or "", - user_id=r.user_id or "", - session_id=r.session_id or "", - source_trace=r.source_trace, - value=pv, - value_truncated=pcut, - # A short secret's hash can be guessed; a high row's comes with the value. - content_sha256="" if r.sensitivity == "high" else _trust.row_content_sha256(r), - char_limit=r.char_limit, - ) - for r, (pv, pcut) in ((r, _preview_for_list(r, preview_chars)) for r in rows) - ], - truncated=truncated, - rows_read=rows_read, - ), - keep, - ) + return total, today async def _served_by_authority( diff --git a/tests/unit/test_memory_code_plane_reads.py b/tests/unit/test_memory_code_plane_reads.py index 2c34b6c4318..aae14a36f84 100644 --- a/tests/unit/test_memory_code_plane_reads.py +++ b/tests/unit/test_memory_code_plane_reads.py @@ -718,7 +718,9 @@ async def test_a_fallback_to_trunks_state_gives_no_positive_guidance(monkeypatch monkeypatch, [_link("m1")], [_excerpt("m1", "k1")], branch, ns="code-a-26-8", **kw ) - assert lesson["code_state"] == "unknown" # trunk's check is not the branch's + assert ( + lesson["code_state"] == "fresh" + ) # the recorded link state; only the guidance is held back assert lesson["use_guidance"]["freshness"]["code"] == "unknown" @@ -847,7 +849,7 @@ async def readable(org: str, nss: set[str]) -> set[str]: (lesson,) = await _lessons( monkeypatch, [_renamed("m1")], [_excerpt("m1", "k1")], [], has_mirror=False ) - assert (lesson["code_state"], "code_moved" in lesson) == ("unknown", False) + assert (lesson["code_state"], "code_moved" in lesson) == ("moved", False) @pytest.mark.asyncio From db8d223f824b3908852e2668097f84cb4d3df8f0 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 12:36:09 +0530 Subject: [PATCH 094/117] The memories search test file follows the Biome format Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 6bcc86b3b6a..7acd5f1ccfe 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -164,7 +164,13 @@ describe("resolveSearchWriter under a narrowed token", () => { truncated: false, namespace_version: "", } as never) - .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 100, truncated: false, namespace_version: "" } as never); + .mockResolvedValueOnce({ + entries: [], + rows_read: 0, + total: 100, + truncated: false, + namespace_version: "", + } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); }); From 4ba835c34073dd6347bdc3b2c93f9b426e0624a1 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 20:35:19 +0530 Subject: [PATCH 095/117] A search preview and a writer lookup name a row only from a list read that carries a namespace version and a unique writer A first page with no namespace version counted as stable, so a single complete page could name a writer from a read that could not show the namespace held still. The legacy search preview took the first row whose key matched; it now resolves a unique writer as the header search and Recall Lab do. Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 48 ++++++++++++++++--- frontend/src/lib/memoriesSearch.ts | 5 +- .../src/views/memoryListReads.preview.test.ts | 41 ++++++++++++++++ frontend/src/views/memoryListReads.ts | 28 ++++++++--- 4 files changed, 108 insertions(+), 14 deletions(-) create mode 100644 frontend/src/views/memoryListReads.preview.test.ts diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 7acd5f1ccfe..4f24ec05702 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -20,9 +20,21 @@ describe("resolveSearchWriter under a narrowed token", () => { entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], total: 1, truncated: false, + namespace_version: "1", } as never); }); + it("names no writer from a single complete page that carries no namespace version", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + vi.mocked(listMemories).mockResolvedValue({ + entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + total: 1, + truncated: false, + namespace_version: "", + } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + }); + it("sends the pinned user and no user wildcard", async () => { vi.mocked(storedToken).mockReturnValue(jwt({ read_user_id: "u1" })); expect(await resolveSearchWriter(identity, hit, ABORT)).toMatchObject({ user_id: "u1", session_id: "s1" }); @@ -105,8 +117,14 @@ describe("resolveSearchWriter under a narrowed token", () => { vi.mocked(storedToken).mockReturnValue(jwt({})); const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [row], rows_read: 1, total: 3, truncated: true } as never) - .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 3, truncated: true } as never); + .mockResolvedValueOnce({ + entries: [row], + rows_read: 1, + total: 3, + truncated: true, + namespace_version: "1", + } as never) + .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 3, truncated: true, namespace_version: "1" } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); }); @@ -114,8 +132,20 @@ describe("resolveSearchWriter under a narrowed token", () => { vi.mocked(storedToken).mockReturnValue(jwt({})); const row = (u: string) => ({ memory_key: "deploy_note", agent: "claude-desktop", user_id: u, session_id: "s1" }); vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [row("u1")], rows_read: 1, total: 1, truncated: true } as never) - .mockResolvedValueOnce({ entries: [row("u2")], rows_read: 1, total: 2, truncated: false } as never); + .mockResolvedValueOnce({ + entries: [row("u1")], + rows_read: 1, + total: 1, + truncated: true, + namespace_version: "1", + } as never) + .mockResolvedValueOnce({ + entries: [row("u2")], + rows_read: 1, + total: 2, + truncated: false, + namespace_version: "1", + } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); expect(vi.mocked(listMemories).mock.calls.map((c) => c[2]?.offset)).toEqual([0, 1]); }); @@ -124,8 +154,14 @@ describe("resolveSearchWriter under a narrowed token", () => { vi.mocked(storedToken).mockReturnValue(jwt({})); const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [row], rows_read: 1, total: 1, truncated: true } as never) - .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 1, truncated: true } as never); + .mockResolvedValueOnce({ + entries: [row], + rows_read: 1, + total: 1, + truncated: true, + namespace_version: "1", + } as never) + .mockResolvedValueOnce({ entries: [], rows_read: 0, total: 1, truncated: true, namespace_version: "1" } as never); expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); expect(listMemories).toHaveBeenCalledTimes(2); }); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index e6e59b0c0fc..a0c00d8dcdd 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -28,7 +28,7 @@ export function namesWriter(r: { agent?: string; user_id?: string; session_id?: * it read, and a page that read none ends the read. A truncated page is never `done`, even at * `total`, so the read goes on while rows come back. The last page yielded says whether * the list was read to its end (`done`). Offsets only line up while the namespace holds still, - * so a page whose `namespace_version` differs from the first page's (or lacks it) ends the + * so a page whose `namespace_version` differs from the first page's, or a page that lacks it, ends the * read incomplete. */ const MAX_PAGES = 10; export async function* listPages( @@ -44,7 +44,8 @@ export async function* listPages( // A truncated page never completes the list (its total is cached apart from the page, so // it can lag): paging goes on while rows are read, and an empty truncated page ends it incomplete. if (n === 0) version = page.namespace_version; - const stable = n === 0 || (!!version && page.namespace_version === version); + // A page without a version cannot show the namespace held still, the first one included. + const stable = !!version && page.namespace_version === version; const done = stable && !page.truncated && (offset >= page.total || !read); yield { ...page, done }; if (done || !read || !stable) return; diff --git a/frontend/src/views/memoryListReads.preview.test.ts b/frontend/src/views/memoryListReads.preview.test.ts new file mode 100644 index 00000000000..ff6afd1679f --- /dev/null +++ b/frontend/src/views/memoryListReads.preview.test.ts @@ -0,0 +1,41 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { SearchHit } from "../api"; + +vi.mock("../api", () => ({ + listMemories: vi.fn(), + storedToken: vi.fn(), +})); +import { listMemories, storedToken } from "../api"; +import { readSearchPreview } from "./memoryListReads"; + +const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; +const hit = { memory_key: "deploy_note", agent: "claude-desktop" } as SearchHit; +const row = (user_id: string) => ({ memory_key: "deploy_note", agent: "claude-desktop", user_id, session_id: "s1" }); +const ABORT = new AbortController().signal; + +describe("readSearchPreview for a hit that names no user or session", () => { + beforeEach(() => { + vi.clearAllMocks(); + vi.mocked(storedToken).mockReturnValue(`h.${btoa("{}")}.s`); + }); + + it("returns no preview when two writers share the key", async () => { + vi.mocked(listMemories).mockResolvedValue({ + entries: [row("u1"), row("u2")], + total: 2, + truncated: false, + namespace_version: "1", + } as never); + expect(await readSearchPreview(identity, hit, ABORT)).toBeNull(); + }); + + it("returns the preview when one writer holds the key", async () => { + vi.mocked(listMemories).mockResolvedValue({ + entries: [row("u1")], + total: 1, + truncated: false, + namespace_version: "1", + } as never); + expect(await readSearchPreview(identity, hit, ABORT)).toMatchObject({ user_id: "u1" }); + }); +}); diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 8d867d29ee1..16c790624f8 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -11,7 +11,15 @@ import { CARD_VALUE_CHARS } from "../components/MemoryCard"; import { errorRequestId } from "../lib/format"; import { humanizeError } from "../lib/errorWords"; import { useAbortableEffect, useVisiblePoll } from "../lib/hooks"; -import { KEYWORD_PAGE, keywordThenRanked, listPages, namesWriter, rowIdentity, rowIds } from "../lib/memoriesSearch"; +import { + KEYWORD_PAGE, + keywordThenRanked, + listPages, + namesWriter, + resolveSearchWriter, + rowIdentity, + rowIds, +} from "../lib/memoriesSearch"; // The fields the page and its cards read. Field names are a quarter of a row, so a field // the page does not read costs on every row. `sensitivity`, which marks a high row sent @@ -69,16 +77,24 @@ export function useSameFilter(next: T): T { } // A search card is a list preview even when its row was outside the loaded pages. -async function readSearchPreview( +export async function readSearchPreview( identity: Identity, hit: SearchHit, signal: AbortSignal, ): Promise { - const writer = namesWriter(hit); - const scope = writer ? { ...identity, user_id: hit.user_id, session_id: hit.session_id } : identity; - const key = rowIdentity(identity.namespace, hit); + // A hit that names no user or session is read only once one writer holds its key, as the + // header search and Recall Lab read it: a namesake's row is not this hit's preview. + const writer = await resolveSearchWriter(identity, hit, signal); + if (!writer) return null; + const scope = { + ...identity, + namespace: writer.namespace || identity.namespace, + user_id: writer.user_id, + session_id: writer.session_id, + }; + const key = rowIdentity(identity.namespace, { ...hit, ...writer }); for await (const page of listPages(scope, KEYWORD_PAGE, { - agent: writer ? hit.agent : undefined, + agent: writer.agent, prefix: hit.memory_key, fields: MEMORIES_LIST_FIELDS, previewChars: CARD_VALUE_CHARS, From 981ac0386b8ff80f8d35b7572ffcc07645e769f9 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 20:58:26 +0530 Subject: [PATCH 096/117] A search preview matches list entries in the namespace the list was read in Signed-off-by: Krishna Dobhal --- frontend/src/views/memoryListReads.preview.test.ts | 11 +++++++++++ frontend/src/views/memoryListReads.ts | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/memoryListReads.preview.test.ts b/frontend/src/views/memoryListReads.preview.test.ts index ff6afd1679f..76015fe87d9 100644 --- a/frontend/src/views/memoryListReads.preview.test.ts +++ b/frontend/src/views/memoryListReads.preview.test.ts @@ -38,4 +38,15 @@ describe("readSearchPreview for a hit that names no user or session", () => { } as never); expect(await readSearchPreview(identity, hit, ABORT)).toMatchObject({ user_id: "u1" }); }); + + it("matches the row in the writer's namespace when it differs from the page's", async () => { + vi.mocked(listMemories).mockResolvedValue({ + entries: [row("u1")], + total: 1, + truncated: false, + namespace_version: "1", + } as never); + const named = { ...hit, namespace: "bob", user_id: "u1", session_id: "s1" } as SearchHit; + expect(await readSearchPreview(identity, named, ABORT)).toMatchObject({ user_id: "u1" }); + }); }); diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 16c790624f8..ff57050c7c5 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -86,13 +86,15 @@ export async function readSearchPreview( // header search and Recall Lab read it: a namesake's row is not this hit's preview. const writer = await resolveSearchWriter(identity, hit, signal); if (!writer) return null; + // The list is read in the writer's namespace, so its entries (which carry none) match there. + const namespace = writer.namespace || identity.namespace; const scope = { ...identity, - namespace: writer.namespace || identity.namespace, + namespace, user_id: writer.user_id, session_id: writer.session_id, }; - const key = rowIdentity(identity.namespace, { ...hit, ...writer }); + const key = rowIdentity(namespace, { ...hit, ...writer }); for await (const page of listPages(scope, KEYWORD_PAGE, { agent: writer.agent, prefix: hit.memory_key, @@ -100,7 +102,7 @@ export async function readSearchPreview( previewChars: CARD_VALUE_CHARS, signal, })) { - const entry = page.entries.find((row) => rowIds(identity.namespace, row).includes(key)); + const entry = page.entries.find((row) => rowIds(namespace, row).includes(key)); if (entry) return { ...entry, value: entry.value ?? null }; } return null; From 8bef6189a82ed76bfde050650f6792421fe0875c Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 22:49:49 +0530 Subject: [PATCH 097/117] A search preview keeps its namespace, and a hit with no writer opens only the row at its revision readSearchPreview returns the entry with the namespace its list was read in, so a cross-namespace preview joins the hits keyed by that namespace and cannot overwrite a same-writer keyword row of the page namespace. resolveSearchWriter enables inspection for a hit that names no writer only when one row of its key holds the hit's own revision, for header search, Recall Lab and the Memories list alike. Signed-off-by: Krishna Dobhal --- frontend/src/components/HeaderSearch.test.tsx | 6 +- frontend/src/lib/memoriesSearch.test.ts | 81 ++++++++++++++++--- frontend/src/lib/memoriesSearch.ts | 6 +- .../views/RecallLab.memoriesOrder.test.tsx | 39 ++++++--- frontend/src/views/RecallLab.table.test.tsx | 2 +- .../src/views/memoryListReads.preview.test.ts | 25 +++++- frontend/src/views/memoryListReads.ts | 6 +- 7 files changed, 135 insertions(+), 30 deletions(-) diff --git a/frontend/src/components/HeaderSearch.test.tsx b/frontend/src/components/HeaderSearch.test.tsx index c507b366a98..4fc8ec6d986 100644 --- a/frontend/src/components/HeaderSearch.test.tsx +++ b/frontend/src/components/HeaderSearch.test.tsx @@ -33,7 +33,7 @@ vi.mock("../api", async (importOriginal) => { ...actual, listMemories: vi.fn(async (_id, _limit, opts) => { const entries = opts?.prefix ? catalog.writerRows : catalog.recent; - return { entries, truncated: false, total: entries.length }; + return { entries, truncated: false, total: entries.length, namespace_version: "1" }; }), listKnowledge: vi.fn(async () => ({ rows: catalog.docs })), listProfile: vi.fn(async () => ({ entries: catalog.profile })), @@ -69,8 +69,8 @@ beforeEach(() => { describe("HeaderSearch", () => { it.each([false, true])("opens a legacy hit only when its writer is unique (ambiguous: %s)", async (ambiguous) => { - catalog.hits = [{ agent: "a", memory_key: "legacy/note", content_excerpt: "old replica" }]; - const row = { ...written, memory_key: "legacy/note" }; + catalog.hits = [{ agent: "a", memory_key: "legacy/note", content_excerpt: "old replica", version_text: "v1" }]; + const row = { ...written, memory_key: "legacy/note", version_text: "v1" }; catalog.writerRows = ambiguous ? [row, { ...row, session_id: "another" }] : [row]; const user = userEvent.setup(); render(); diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 4f24ec05702..2641fdd685c 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -10,14 +10,16 @@ import { resolveSearchWriter } from "./memoriesSearch"; const jwt = (claims: Record) => `h.${btoa(JSON.stringify(claims))}.s`; const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; -const hit = { memory_key: "deploy_note", agent: "claude-desktop" } as SearchHit; +const hit = { memory_key: "deploy_note", agent: "claude-desktop", version_text: "1" } as SearchHit; const ABORT = new AbortController().signal; describe("resolveSearchWriter under a narrowed token", () => { beforeEach(() => { vi.clearAllMocks(); vi.mocked(listMemories).mockResolvedValue({ - entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + entries: [ + { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1", version_text: "1" }, + ], total: 1, truncated: false, namespace_version: "1", @@ -27,7 +29,9 @@ describe("resolveSearchWriter under a narrowed token", () => { it("names no writer from a single complete page that carries no namespace version", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); vi.mocked(listMemories).mockResolvedValue({ - entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + entries: [ + { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1", version_text: "1" }, + ], total: 1, truncated: false, namespace_version: "", @@ -74,7 +78,9 @@ describe("resolveSearchWriter under a narrowed token", () => { namespace_version: "1", } as never) .mockResolvedValueOnce({ - entries: [{ memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }], + entries: [ + { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1", version_text: "1" }, + ], rows_read: 1, total: 2, truncated: false, @@ -86,7 +92,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("advances by the entries when the server reports no rows read", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = (k: string) => ({ memory_key: k, agent: "claude-desktop", user_id: "u1", session_id: "s1" }); + const row = (k: string) => ({ + memory_key: k, + agent: "claude-desktop", + user_id: "u1", + session_id: "s1", + version_text: "1", + }); vi.mocked(listMemories) .mockResolvedValueOnce({ entries: [row("x")], @@ -115,7 +127,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("names no writer when an empty truncated page follows one match", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const row = { + memory_key: "deploy_note", + agent: "claude-desktop", + user_id: "u1", + session_id: "s1", + version_text: "1", + }; vi.mocked(listMemories) .mockResolvedValueOnce({ entries: [row], @@ -130,7 +148,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("keeps paging past a stale total while the page is truncated and finds a second writer", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = (u: string) => ({ memory_key: "deploy_note", agent: "claude-desktop", user_id: u, session_id: "s1" }); + const row = (u: string) => ({ + memory_key: "deploy_note", + agent: "claude-desktop", + user_id: u, + session_id: "s1", + version_text: "1", + }); vi.mocked(listMemories) .mockResolvedValueOnce({ entries: [row("u1")], @@ -152,7 +176,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("names no writer when the total is reached on a truncated page with nothing after it", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const row = { + memory_key: "deploy_note", + agent: "claude-desktop", + user_id: "u1", + session_id: "s1", + version_text: "1", + }; vi.mocked(listMemories) .mockResolvedValueOnce({ entries: [row], @@ -168,7 +198,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("names no writer when the namespace version changes between pages", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const row = { + memory_key: "deploy_note", + agent: "claude-desktop", + user_id: "u1", + session_id: "s1", + version_text: "1", + }; const fill = Array.from({ length: 99 }, (_, i) => ({ ...row, memory_key: `deploy_note_${i}` })); vi.mocked(listMemories) .mockResolvedValueOnce({ @@ -190,7 +226,13 @@ describe("resolveSearchWriter under a narrowed token", () => { it("names no writer when neither page carries a namespace version", async () => { vi.mocked(storedToken).mockReturnValue(jwt({})); - const row = { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u1", session_id: "s1" }; + const row = { + memory_key: "deploy_note", + agent: "claude-desktop", + user_id: "u1", + session_id: "s1", + version_text: "1", + }; const fill = Array.from({ length: 99 }, (_, i) => ({ ...row, memory_key: `deploy_note_${i}` })); vi.mocked(listMemories) .mockResolvedValueOnce({ @@ -215,4 +257,23 @@ describe("resolveSearchWriter under a narrowed token", () => { await resolveSearchWriter(identity, hit, ABORT); expect(vi.mocked(listMemories).mock.calls[0][0]).toMatchObject({ user_id: "*", session_id: "*" }); }); + + it("names no writer from a row at another revision than the hit", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + vi.mocked(listMemories).mockResolvedValue({ + entries: [ + { memory_key: "deploy_note", agent: "claude-desktop", user_id: "u2", session_id: "s2", version_text: "2" }, + ], + total: 1, + truncated: false, + namespace_version: "1", + } as never); + expect(await resolveSearchWriter(identity, hit, ABORT)).toBeUndefined(); + }); + + it("names no writer for a hit that carries no revision", async () => { + vi.mocked(storedToken).mockReturnValue(jwt({})); + const bare = { memory_key: "deploy_note", agent: "claude-desktop" } as SearchHit; + expect(await resolveSearchWriter(identity, bare, ABORT)).toBeUndefined(); + }); }); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index a0c00d8dcdd..d6fc32d4498 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -63,6 +63,9 @@ export async function resolveSearchWriter( const { agent, user_id, session_id } = hit; if (!agent || SENTINEL_AGENTS.has(agent) || agent === "_shared" || hit.memory_key.startsWith("chunk:")) return; if (namesWriter(hit)) return hit; + // A hit that names no writer is told from a namesake only by its revision: without one, or + // against a row at another revision, it stays a preview. + if (!hit.version_text) return; // A token that narrows reads is refused the `*` wildcard (`resolve_read_filters`): send the // pinned user, and give up when no user (or, for an own-session token, no session) is known. @@ -82,13 +85,14 @@ export async function resolveSearchWriter( agent, prefix: hit.memory_key, include_profile: true, - fields: ["agent", "user_id", "session_id"], + fields: ["agent", "user_id", "session_id", "version_text"], signal, })) { matches.push( ...page.entries.filter( (row) => row.memory_key === hit.memory_key && + row.version_text === hit.version_text && (!row.agent || row.agent === agent) && (!user_id || !row.user_id || row.user_id === user_id) && (!session_id || !row.session_id || row.session_id === session_id), diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index 73bfcee7ae2..27236c36423 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -48,7 +48,13 @@ vi.mock("../api", async (importOriginal) => { ...actual, listMemories: vi.fn(async (_id: unknown, _limit?: number, opts?: { contains?: string }) => opts?.contains - ? { entries: [entry("newer_azure"), entry("older_azure")], total: 2, today: 0, truncated: false } + ? { + entries: [entry("newer_azure"), entry("older_azure")], + total: 2, + today: 0, + truncated: false, + namespace_version: "1", + } : { entries: [entry("newer_azure"), entry("older_azure"), entry("blob_storage")], total: 3, @@ -128,7 +134,7 @@ describe("Recall Lab and the Memories list", () => { it("shows one row for a memory the keyword read and a legacy ranked hit both hold", async () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; - const page = { entries: [held], total: 1, today: 0, truncated: false }; + const page = { entries: [held], total: 1, today: 0, truncated: false, namespace_version: "1" }; vi.mocked(listMemories).mockResolvedValueOnce(page); vi.mocked(listMemories).mockResolvedValueOnce(page); // the lookup finds the same row // A legacy hit names its agent but not the user or session. @@ -148,7 +154,7 @@ describe("Recall Lab and the Memories list", () => { it("keeps a legacy hit with its own text when the keyword row shows another revision", async () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s", version_text: "v2" }; held.value = "Azure cache uses provider B"; - const page = { entries: [held], total: 1, today: 0, truncated: false }; + const page = { entries: [held], total: 1, today: 0, truncated: false, namespace_version: "1" }; vi.mocked(listMemories).mockResolvedValueOnce(page); vi.mocked(listMemories).mockResolvedValueOnce(page); vi.mocked(searchMemory).mockResolvedValueOnce({ @@ -178,9 +184,10 @@ describe("Recall Lab and the Memories list", () => { ["both", { version_text: undefined }, { version_text: undefined }], ])("does not merge a legacy hit when the revision is missing on %s", async (_n, mine, theirs) => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s", ...mine }; - const page = { entries: [held], total: 1, today: 0, truncated: false }; - vi.mocked(listMemories).mockResolvedValueOnce(page); + const page = { entries: [held], total: 1, today: 0, truncated: false, namespace_version: "1" }; vi.mocked(listMemories).mockResolvedValueOnce(page); + // A hit with no revision is never looked up. + if (!("version_text" in theirs)) vi.mocked(listMemories).mockResolvedValueOnce(page); vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined, ...theirs }], embedding_model: "m", @@ -194,7 +201,13 @@ describe("Recall Lab and the Memories list", () => { it("does not merge a named-writer hit that holds another revision", async () => { const held = { ...entry("older_azure"), version_text: "v2" }; held.value = "Azure cache uses provider B"; - vi.mocked(listMemories).mockResolvedValueOnce({ entries: [held], total: 1, today: 0, truncated: false }); + vi.mocked(listMemories).mockResolvedValueOnce({ + entries: [held], + total: 1, + today: 0, + truncated: false, + namespace_version: "1", + }); vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), content_excerpt: "Azure cache uses provider A", version_text: "v1" }], embedding_model: "m", @@ -214,8 +227,8 @@ describe("Recall Lab and the Memories list", () => { const held = { ...entry("older_azure"), user_id: "u", session_id: "s" }; const other = { ...entry("older_azure"), user_id: "v", session_id: "t" }; vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [held], total: 1, today: 0, truncated: false }) - .mockResolvedValueOnce({ entries: [other], total: 1, today: 0, truncated: false }); + .mockResolvedValueOnce({ entries: [held], total: 1, today: 0, truncated: false, namespace_version: "1" }) + .mockResolvedValueOnce({ entries: [other], total: 1, today: 0, truncated: false, namespace_version: "1" }); vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], embedding_model: "m", @@ -228,7 +241,13 @@ describe("Recall Lab and the Memories list", () => { it("keeps a legacy hit as a preview when several keyword rows share its key", async () => { const rows = ["s1", "s2"].map((session_id) => ({ ...entry("older_azure"), user_id: "u", session_id })); - vi.mocked(listMemories).mockResolvedValueOnce({ entries: rows, total: 2, today: 0, truncated: false }); + vi.mocked(listMemories).mockResolvedValueOnce({ + entries: rows, + total: 2, + today: 0, + truncated: false, + namespace_version: "1", + }); vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("older_azure", 0.9), user_id: undefined, session_id: undefined }], embedding_model: "m", @@ -242,7 +261,7 @@ describe("Recall Lab and the Memories list", () => { it("draws the rows while a writer lookup hangs", async () => { vi.mocked(listMemories) - .mockResolvedValueOnce({ entries: [], total: 0, today: 0, truncated: false }) + .mockResolvedValueOnce({ entries: [], total: 0, today: 0, truncated: false, namespace_version: "1" }) .mockReturnValueOnce(new Promise(() => {})); vi.mocked(searchMemory).mockResolvedValueOnce({ results: [{ ...hit("solo_azure", 0.9), user_id: undefined, session_id: undefined }], diff --git a/frontend/src/views/RecallLab.table.test.tsx b/frontend/src/views/RecallLab.table.test.tsx index 7e4bc6165fa..d4735b5fff7 100644 --- a/frontend/src/views/RecallLab.table.test.tsx +++ b/frontend/src/views/RecallLab.table.test.tsx @@ -163,7 +163,7 @@ describe("Recall Lab: the scores table", () => { const row = { ...entry("legacy_note"), agent: "writer", user_id: "u", session_id: "one" }; listMemories.mockImplementation(async (_identity, _limit, opts) => { const entries = !opts?.prefix ? [] : ambiguous ? [row, { ...row, user_id: "other" }] : [row]; - return { entries, total: entries.length, today: 0, truncated: false }; + return { entries, total: entries.length, today: 0, truncated: false, namespace_version: "1" }; }); render(); const button = within(await score()).getByRole("button", { name: "legacy_note" }); diff --git a/frontend/src/views/memoryListReads.preview.test.ts b/frontend/src/views/memoryListReads.preview.test.ts index 76015fe87d9..c151119f616 100644 --- a/frontend/src/views/memoryListReads.preview.test.ts +++ b/frontend/src/views/memoryListReads.preview.test.ts @@ -6,11 +6,18 @@ vi.mock("../api", () => ({ storedToken: vi.fn(), })); import { listMemories, storedToken } from "../api"; +import { rowIdentity } from "../lib/memoriesSearch"; import { readSearchPreview } from "./memoryListReads"; const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; -const hit = { memory_key: "deploy_note", agent: "claude-desktop" } as SearchHit; -const row = (user_id: string) => ({ memory_key: "deploy_note", agent: "claude-desktop", user_id, session_id: "s1" }); +const hit = { memory_key: "deploy_note", agent: "claude-desktop", version_text: "1" } as SearchHit; +const row = (user_id: string) => ({ + memory_key: "deploy_note", + agent: "claude-desktop", + user_id, + session_id: "s1", + version_text: "1", +}); const ABORT = new AbortController().signal; describe("readSearchPreview for a hit that names no user or session", () => { @@ -49,4 +56,18 @@ describe("readSearchPreview for a hit that names no user or session", () => { const named = { ...hit, namespace: "bob", user_id: "u1", session_id: "s1" } as SearchHit; expect(await readSearchPreview(identity, named, ABORT)).toMatchObject({ user_id: "u1" }); }); + + it("carries the namespace the list was read in on the entry", async () => { + vi.mocked(listMemories).mockResolvedValue({ + entries: [row("u1")], + total: 1, + truncated: false, + namespace_version: "1", + } as never); + const named = { ...hit, namespace: "bob", user_id: "u1", session_id: "s1" } as SearchHit; + const entry = await readSearchPreview(identity, named, ABORT); + expect(entry).toMatchObject({ namespace: "bob" }); + // The page keys the preview as it keys the hit, so the two join. + expect(rowIdentity(identity.namespace, entry as never)).toBe(rowIdentity(identity.namespace, named)); + }); }); diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index ff57050c7c5..2485af98a1b 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -81,7 +81,7 @@ export async function readSearchPreview( identity: Identity, hit: SearchHit, signal: AbortSignal, -): Promise { +): Promise<(MemoryListEntry & { namespace: string }) | null> { // A hit that names no user or session is read only once one writer holds its key, as the // header search and Recall Lab read it: a namesake's row is not this hit's preview. const writer = await resolveSearchWriter(identity, hit, signal); @@ -103,7 +103,7 @@ export async function readSearchPreview( signal, })) { const entry = page.entries.find((row) => rowIds(namespace, row).includes(key)); - if (entry) return { ...entry, value: entry.value ?? null }; + if (entry) return { ...entry, namespace, value: entry.value ?? null }; } return null; } @@ -322,7 +322,7 @@ export function useMemorySearch( setSearchExtra( new Map([ ...kwExtra, - ...fetched.filter((e): e is MemoryListEntry => e !== null).map((e) => [idOf(e), e] as const), + ...fetched.filter((e): e is NonNullable => e !== null).map((e) => [idOf(e), e] as const), ]), ); } catch { From 24198c6d480bc38986a32b27016c0437b50e728e Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 22:49:49 +0530 Subject: [PATCH 098/117] A parked page of an older build expires when a tail hit is withheld An older build's cursor holds only the tail hits and the first page's candidate count, so the readable total cannot be recovered once a tail hit is withheld. encode_page now always writes first_page_scope, and a cursor without it answers as an expired page in that case. Signed-off-by: Krishna Dobhal --- server/memory/app/search/output.py | 4 ++ server/memory/app/search_pages.py | 16 +++----- tests/unit/test_loom_search_repo_decisions.py | 40 +++++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index 25c9054d1c3..ef8ca84bb05 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -104,6 +104,10 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: allow_unidentified=same_scope and row.get("source") not in (None, "fact", "anchor"), ) ) + if withheld and "first_page_scope" not in payload: + # A page parked before the first page's scope was kept cannot say how many of its + # candidates are still readable. + return empty # Rows the authority no longer serves stay in it, counted per page in `stale_dropped`; # a shared definition withheld since the first page stays in it too, counted nowhere. total = len(parked_rows) - withheld if withheld else int(payload.get("candidates_total") or 0) diff --git a/server/memory/app/search_pages.py b/server/memory/app/search_pages.py index 667100fc463..7055d08d8c9 100644 --- a/server/memory/app/search_pages.py +++ b/server/memory/app/search_pages.py @@ -142,16 +142,12 @@ def encode_page( "hits": hits, READ_SCOPE_KEY: stored_read_scope(request_scope()), } - if first_page: - # Scope metadata lets later pages count the original hits without keeping their text. - page["first_page_scope"] = [ - { - "namespace": hit.namespace, - "row_identity": hit._row_identity, - "source": hit.source, - } - for hit in first_page - ] + # Scope metadata lets later pages count the original hits without keeping their text; the + # key is always present, so a page without it was parked before it existed. + page["first_page_scope"] = [ + {"namespace": hit.namespace, "row_identity": hit._row_identity, "source": hit.source} + for hit in first_page + ] if replay: page["replay"] = True return json.dumps( diff --git a/tests/unit/test_loom_search_repo_decisions.py b/tests/unit/test_loom_search_repo_decisions.py index c1e93ae67d8..d0ae331b1c6 100644 --- a/tests/unit/test_loom_search_repo_decisions.py +++ b/tests/unit/test_loom_search_repo_decisions.py @@ -649,6 +649,7 @@ async def test_merged_repository_decision_keeps_exact_authorized_guidance( _svc_hit("decision:evict", sim=0.9, mtype="decision"), identity=("a", "alice", "s1"), version=42, + content_sha256="a" * 64, ) hidden = replace( _svc_hit("decision:private", sim=0.8, mtype="decision"), @@ -888,6 +889,45 @@ async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: assert (stale["code_state"], stale.get("code_changed_since", "")) == ("changed", "") +@pytest.mark.asyncio +async def test_a_parked_page_of_an_older_build_expires_when_a_tail_hit_is_withheld( + monkeypatch, +) -> None: + """An older build parked only the tail hits and the first page's candidate count: + with one tail row no longer readable, the total cannot be recovered, so the cursor + expires rather than answering a short count.""" + import json + + from server.memory.app import search_pages + from server.memory.app.search import handle_memory_search + from tests.unit._memory_search_pkg import patch_handler_name + + tail = [_hit("a", 0.7, "me"), _hit("b", 0.6, "me"), _hit("c", 0.5, "revoked-ns")] + for h in tail: + h._row_identity = ("a", "u", "-") + older = json.loads( + search_pages.encode_page( + query=BASE.query, + top_k=BASE.top_k, + candidates_total=5, + tail=tail, + namespaces_searched=["me", "revoked-ns"], + namespaces_skipped=[], + ) + ) + older.pop("first_page_scope", None) # the older build never wrote it + content = json.dumps(older) + + class _Parked: + async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: + return {"content": content} + + patch_handler_name(monkeypatch, "get_client", _Parked) + handle = search_pages.make_handle(search_pages.page_blob_key(content), 0) + out = await handle_memory_search(BASE.model_copy(update={"page": handle})) + assert out.abstain_code == "page_expired" and out.results == [] + + @pytest.mark.asyncio async def test_an_excerpt_quoting_another_rows_head_cannot_carry_that_row(monkeypatch) -> None: """The block is rendered from the served rows, never parsed back: a From 560a4097cff8ef06e068bc6112ac721d531949fd Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Tue, 1 Dec 2026 22:49:50 +0530 Subject: [PATCH 099/117] A tier hit takes the head's review only for the body it served Tier hits now carry the served content digest, and guidance attaches the authority's review only when that digest equals the head's. A hit with no digest has no positive review. Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 14 ++++++++++++- server/memory/app/search/tiers.py | 3 +++ tests/unit/test_search_use_guidance.py | 27 ++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index bdbaaa157d9..bc5d37a1d33 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -127,13 +127,23 @@ def _memory_evidence( denied.add(i) continue evidence[i] = dict(row, namespace=key[1], user_id=key[3]) - if not parked and hit._row_chunk is None and is_content_hash(digest): + if ( + not parked + and hit._row_chunk is None + and is_content_hash(digest) + and digest == served_digest + ): hit._guidance_content_sha256 = digest hit._guidance_head_version = int(row.get("version") or 0) return denied, evidence +def _served_the_head(hit: _MemorySearchHit, row: dict[str, Any]) -> bool: + served = hit._row_content_sha256 + return is_content_hash(served) and served == hash_text(row.get("content_sha256")) + + async def _replay_evidence( keys: dict[int, IdentityKey], rows: dict[IdentityKey, dict[str, Any]], @@ -272,6 +282,8 @@ async def attach_search_guidance( and not hits[i]._chunk_typed and hits[i]._row_chunk is None and (not parked or hits[i]._guidance_content_sha256) + # Review is the head's: it applies only to the body this hit served. + and (parked or _served_the_head(hits[i], row)) } code_states: dict[int, str] = {} source_states: dict[int, str] = {} diff --git a/server/memory/app/search/tiers.py b/server/memory/app/search/tiers.py index 682dba04a64..e2a953c308d 100644 --- a/server/memory/app/search/tiers.py +++ b/server/memory/app/search/tiers.py @@ -8,6 +8,7 @@ from typing import Any from server.core.error_summary import error_summary +from server.core.hashing import hash_text from server.core.tag_sql import TagFilter from server.identity.app.request_scope import request_scope from server.memory.app.search import pg_validation @@ -119,6 +120,8 @@ async def _prepend_tier( if None not in who: hit._row_identity = (str(who[0]), str(who[1]), str(who[2])) hit._row_version = int(getattr(r, "version", 0) or 0) + # The body served: guidance takes the head's review only for this one. + hit._row_content_sha256 = hash_text(getattr(r, "content_sha256", "")) # `_apply_bodies` reads them: a constraint keeps its excerpt. tier_rows.append(stamp_row_tags(hit, getattr(r, "tags", None))) try: diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index 5f7beb7780a..72ef745c806 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -29,6 +29,7 @@ def _hit(*, version: int = 42, user: str = "u") -> _MemorySearchHit: version=version, ) hit._row_identity = ("a", user, "s") + hit._row_content_sha256 = "a" * 64 return hit @@ -136,6 +137,7 @@ async def heads(keys: list[tuple[str, ...]]) -> dict[tuple[str, ...], dict[str, monkeypatch.setattr(guidance, "guidance_heads", heads) hit = _hit() + hit._row_content_sha256 = "" # no served digest to tie a newer head to this body fresh = await guidance.attach_search_guidance(_INPUT, [hit]) if head is not None and head.get("version") == 43: assert fresh == [hit] @@ -480,3 +482,28 @@ async def history(org, memory_id, version): _INPUT, [current, edited, expired], parked=True, replay=True ) assert kept == ([current] if history_fails else [current, edited]) + + +@pytest.mark.asyncio +@pytest.mark.parametrize( + ("served", "review"), [("a" * 64, "human"), ("", "unknown"), ("b" * 64, None)] +) +async def test_a_tier_hit_inherits_review_only_when_the_served_body_is_the_reviewed_one( + monkeypatch, served, review +): + """A tier hit (recent_first) is read from the list; the authority's head at the same + version may hold a replacement body. Review follows the body served, so a hit with no + served digest has none, and one with another digest is not served.""" + + async def heads(keys): + return {_KEY: _head()} + + monkeypatch.setattr(guidance, "guidance_heads", heads) + hit = _hit() + hit._row_content_sha256 = served + hit.score_components = {"recent_first": 1.0} + kept = await guidance.attach_search_guidance(_INPUT, [hit]) + if review is None: + assert kept == [] + else: + assert hit.use_guidance is not None and hit.use_guidance.review == review From f5c06703e9e02f95280cb9a059d455a443abe63a Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 07:26:00 +0530 Subject: [PATCH 100/117] An older parked page expires when a namespace it recorded lost access A cursor parked before the first page's scope was kept carries only a candidate count. Its total now stands only while every namespace the payload recorded is still readable; a payload that recorded none expires. Signed-off-by: Krishna Dobhal --- server/memory/app/search/output.py | 12 ++++-- tests/unit/test_loom_search_repo_decisions.py | 39 +++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index ef8ca84bb05..9802d0b1f58 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -104,10 +104,16 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: allow_unidentified=same_scope and row.get("source") not in (None, "fact", "anchor"), ) ) - if withheld and "first_page_scope" not in payload: + if "first_page_scope" not in payload: # A page parked before the first page's scope was kept cannot say how many of its - # candidates are still readable. - return empty + # candidates are still readable: its count stands only while every namespace it + # recorded is readable, and it recorded none it can be checked against otherwise. + recorded = { + *(payload.get("namespaces_searched") or []), + *(payload.get("namespaces_skipped") or []), + } + if withheld or not recorded or not recorded <= readable: + return empty # Rows the authority no longer serves stay in it, counted per page in `stale_dropped`; # a shared definition withheld since the first page stays in it too, counted nowhere. total = len(parked_rows) - withheld if withheld else int(payload.get("candidates_total") or 0) diff --git a/tests/unit/test_loom_search_repo_decisions.py b/tests/unit/test_loom_search_repo_decisions.py index d0ae331b1c6..49399f64a60 100644 --- a/tests/unit/test_loom_search_repo_decisions.py +++ b/tests/unit/test_loom_search_repo_decisions.py @@ -928,6 +928,45 @@ async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: assert out.abstain_code == "page_expired" and out.results == [] +@pytest.mark.asyncio +async def test_a_parked_page_of_an_older_build_expires_when_a_page_one_namespace_lost_access( + monkeypatch, +) -> None: + """The older payload keeps the first page's candidate count but not its rows: with + every tail hit still readable and a namespace of page one revoked, the count would + overstate what the caller may see, so the cursor expires.""" + import json + + from server.memory.app import search_pages + from server.memory.app.search import handle_memory_search + from tests.unit._memory_search_pkg import patch_handler_name + + tail = [_hit("a", 0.7, "me"), _hit("b", 0.6, "me"), _hit("c", 0.5, "me")] + for h in tail: + h._row_identity = ("a", "u", "-") + older = json.loads( + search_pages.encode_page( + query=BASE.query, + top_k=BASE.top_k, + candidates_total=5, + tail=tail, + namespaces_searched=["me", "revoked-ns"], + namespaces_skipped=[], + ) + ) + older.pop("first_page_scope", None) # the older build never wrote it + content = json.dumps(older) + + class _Parked: + async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: + return {"content": content} + + patch_handler_name(monkeypatch, "get_client", _Parked) + handle = search_pages.make_handle(search_pages.page_blob_key(content), 0) + out = await handle_memory_search(BASE.model_copy(update={"page": handle})) + assert out.abstain_code == "page_expired" and out.results == [] + + @pytest.mark.asyncio async def test_an_excerpt_quoting_another_rows_head_cannot_carry_that_row(monkeypatch) -> None: """The block is rendered from the served rows, never parsed back: a From 18c511c2a665a03140bc818e0fdfe24bf8b00aec Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 08:13:32 +0530 Subject: [PATCH 101/117] A search cursor with no first-page scope expires A cursor parked before the first page's scope was kept cannot prove the writer scope or the first page's rows, so a caller narrowed to their own rows could be counted rows they cannot read. Every such cursor now answers page_expired, and the withheld-tail and namespace checks it needed are gone. Signed-off-by: Krishna Dobhal --- server/memory/app/search/output.py | 14 ++----- tests/unit/test_loom_search_repo_decisions.py | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/server/memory/app/search/output.py b/server/memory/app/search/output.py index 9802d0b1f58..c1732caf2df 100644 --- a/server/memory/app/search/output.py +++ b/server/memory/app/search/output.py @@ -88,7 +88,9 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: payload = await _pages.load_page( get_client(), org=input.org, namespace=input.namespace, blob_key=blob_key ) - if payload is None: + # A cursor parked before the first page's scope was kept cannot prove its writer scope + # or its first-page rows: it expires rather than count rows the caller may not read. + if payload is None or "first_page_scope" not in payload: return empty readable = await _readable_namespaces(input.org, input.namespace, payload) hits, nxt, stale_dropped = await _parked_slice(input, payload, offset, readable) @@ -104,16 +106,6 @@ async def _serve_parked_page(input: MemorySearchInput) -> MemorySearchOutput: allow_unidentified=same_scope and row.get("source") not in (None, "fact", "anchor"), ) ) - if "first_page_scope" not in payload: - # A page parked before the first page's scope was kept cannot say how many of its - # candidates are still readable: its count stands only while every namespace it - # recorded is readable, and it recorded none it can be checked against otherwise. - recorded = { - *(payload.get("namespaces_searched") or []), - *(payload.get("namespaces_skipped") or []), - } - if withheld or not recorded or not recorded <= readable: - return empty # Rows the authority no longer serves stay in it, counted per page in `stale_dropped`; # a shared definition withheld since the first page stays in it too, counted nowhere. total = len(parked_rows) - withheld if withheld else int(payload.get("candidates_total") or 0) diff --git a/tests/unit/test_loom_search_repo_decisions.py b/tests/unit/test_loom_search_repo_decisions.py index 49399f64a60..45ddee6dc36 100644 --- a/tests/unit/test_loom_search_repo_decisions.py +++ b/tests/unit/test_loom_search_repo_decisions.py @@ -967,6 +967,45 @@ async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: assert out.abstain_code == "page_expired" and out.results == [] +@pytest.mark.asyncio +async def test_a_parked_page_of_an_older_build_expires_even_when_every_tail_hit_is_readable( + monkeypatch, +) -> None: + """A cursor with no `first_page_scope` cannot prove the writer scope or the first + page's rows: a caller narrowed to their own rows, with every withheld row on page one, + would pass the tail checks and be counted those rows. It expires whatever else holds.""" + import json + + from server.memory.app import search_pages + from server.memory.app.search import handle_memory_search + from tests.unit._memory_search_pkg import patch_handler_name + + tail = [_hit("a", 0.7, "me"), _hit("b", 0.6, "me")] + for h in tail: + h._row_identity = ("a", "u", "-") + older = json.loads( + search_pages.encode_page( + query=BASE.query, + top_k=BASE.top_k, + candidates_total=5, + tail=tail, + namespaces_searched=["me"], + namespaces_skipped=[], + ) + ) + older.pop("first_page_scope", None) # the older build never wrote it + content = json.dumps(older) + + class _Parked: + async def query_one(self, sql: str, params: dict[str, Any]) -> dict[str, str]: + return {"content": content} + + patch_handler_name(monkeypatch, "get_client", _Parked) + handle = search_pages.make_handle(search_pages.page_blob_key(content), 0) + out = await handle_memory_search(BASE.model_copy(update={"page": handle})) + assert out.abstain_code == "page_expired" and out.results == [] + + @pytest.mark.asyncio async def test_an_excerpt_quoting_another_rows_head_cannot_carry_that_row(monkeypatch) -> None: """The block is rendered from the served rows, never parsed back: a From 24c4c13461c6148a1ed2ed6d2fe993ed388d175f Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 08:23:18 +0530 Subject: [PATCH 102/117] A ranked preview from another namespace opens and acts in its own Inspecting a foreign hit's preview and a bulk pin or delete of it used the page's namespace, so with the same key and writer in both namespaces they reached the home row. The row's own namespace now decides the inspector scope and the bulk identity, and bulk actions on it are held to the role in that namespace. Signed-off-by: Krishna Dobhal --- frontend/src/api.ts | 2 + frontend/src/views/Recent.search.test.tsx | 59 +++++++++++++++++++++++ frontend/src/views/Recent.tsx | 23 +++++++-- 3 files changed, 79 insertions(+), 5 deletions(-) diff --git a/frontend/src/api.ts b/frontend/src/api.ts index de11c1681e5..405340a5d00 100644 --- a/frontend/src/api.ts +++ b/frontend/src/api.ts @@ -213,6 +213,8 @@ export interface MemoryListEntry { agent?: string; user_id?: string; session_id?: string; + // The namespace a ranked preview was read in, when it is not the page's. + namespace?: string; value?: unknown; // Provenance, e.g. "conversation:" for seeder-promoted facts. source_trace?: string; diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index ffebf7b06df..bbc1452d20c 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -197,6 +197,65 @@ describe("Recent search with one key written by two sessions", () => { useStore.setState({ whoami: null, myNamespaces: null, identity: null }); }); + it("opens and selects a foreign hit's preview in its own namespace, not the page's", async () => { + // The same key and writer in the page's namespace and in bob's: the ranked hit is bob's. + const home = written("one", { value: "home note" }); + const away = written("one", { value: "bob note", version: 2, version_text: "2" }); + vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => { + const bob = (id as { namespace: string }).namespace === "bob"; + return { + entries: opts?.contains ? [] : [bob ? away : home], + total: 1, + today: 1, + truncated: false, + }; + }); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { namespace: "bob", version: 2, version_text: "2" })], + embedding_model: "fake", + } as never); + useStore.setState({ myNamespaces: [row("alice", "admin"), row("bob", "writer")] }); + await search(); + + const open = await screen.findByRole("button", { name: /deploy_note/ }); + await screen.findByText("bob note"); + await userEvent.click(open); + expect(useStore.getState().inspectedScope).toEqual({ namespace: "bob", exact: true }); + }); + + it("builds a foreign hit's bulk identity in its own namespace, and holds it to that namespace's role", async () => { + const away = written("one", { value: "bob note", version: 2, version_text: "2" }); + vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => ({ + entries: opts?.contains || (id as { namespace: string }).namespace !== "bob" ? [] : [away], + total: 1, + today: 1, + truncated: false, + })); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { namespace: "bob", version: 2, version_text: "2" })], + embedding_model: "fake", + } as never); + vi.mocked(getMemory).mockResolvedValue({ found: false } as never); + // A writer in alice and a viewer in bob: the page may pin, bob's row may not be. + useStore.setState({ + whoami: { ...admin, roles: [] }, + myNamespaces: [row("alice", "writer"), row("bob", "viewer")], + }); + await search(); + const box = await screen.findByLabelText("Select deploy_note"); + await userEvent.click(box); + await userEvent.click(await screen.findByRole("button", { name: "Pin" })); + await waitFor(() => expect(screen.getByLabelText("Select deploy_note")).not.toBeChecked()); + expect(getMemory).not.toHaveBeenCalled(); + + // The same selection as a writer in bob reads the row in bob. + useStore.setState({ myNamespaces: [row("alice", "writer"), row("bob", "writer")] }); + await userEvent.click(screen.getByLabelText("Select deploy_note")); + await userEvent.click(await screen.findByRole("button", { name: "Pin" })); + await waitFor(() => expect(getMemory).toHaveBeenCalled()); + expect(getMemory).toHaveBeenCalledWith(expect.objectContaining({ namespace: "bob" }), "deploy_note"); + }); + it("keeps both rows of the key on screen and gives the guidance to the ranked one only", async () => { // Both rows hold the typed word, so both stay; only session one's was ranked. const both = [written("one"), written("two")]; diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 1ecd179bf73..97432d086d7 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -46,7 +46,7 @@ import { MemoryTabs } from "../components/MemoryTabs"; import { ScopeBadge } from "../components/ScopeBadge"; import { NamespaceGuideButton } from "../components/NamespaceGuideButton"; import { Unavailable } from "../components/ui"; -import { useNamespaceRoleRead } from "../lib/namespaceRole"; +import { roleOnNamespace, useNamespaceRoleRead } from "../lib/namespaceRole"; import { type GatedNamespaceOp, callReason, codeMember, needsLine } from "../lib/callReason"; import { canCall } from "../lib/canCall"; import { @@ -469,8 +469,21 @@ function MemoryList() { }, [entries]); const rowById = (id: string) => flatList.find((e) => rowIdentity(identity.namespace, e) === id); + // A ranked preview from another readable namespace acts in its own, under that namespace's role. const actionIdentity = (e: MemoryListEntry) => - namesWriter(e) ? { ...identity, agent: e.agent ?? "", user_id: e.user_id, session_id: e.session_id } : null; + namesWriter(e) + ? { + ...identity, + namespace: e.namespace || identity.namespace, + agent: e.agent ?? "", + user_id: e.user_id, + session_id: e.session_id, + } + : null; + const rowReason = (op: GatedNamespaceOp, e: MemoryListEntry) => + !e.namespace || e.namespace === identity.namespace + ? null + : callReason(op, { ...roleRead, role: roleOnNamespace(whoami, roleRead.rows, e.namespace) }, whoami, e.namespace); const bulkPin = async () => { if (selected.size === 0 || busy || pinReason) return; @@ -485,7 +498,7 @@ function MemoryList() { for (const k of keys) { const entry = rowById(k); const rowId = entry && actionIdentity(entry); - if (!entry?.version_text || !rowId) { + if (!entry?.version_text || !rowId || rowReason("memory.pin", entry)) { fail++; continue; } @@ -544,7 +557,7 @@ function MemoryList() { for (const k of keys) { const entry = rowById(k); const rowId = entry && actionIdentity(entry); - if (!entry?.version_text || !rowId) { + if (!entry?.version_text || !rowId || rowReason("memory.delete", entry)) { fail++; continue; } @@ -596,7 +609,7 @@ function MemoryList() { agent: e.agent, userId: e.user_id, sessionId: e.session_id, - namespace: identity.namespace, + namespace: e.namespace || identity.namespace, exact: true, } : { agent: e.agent }, From a37c937b8ae7531929a86956601d14805e7867f6 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 10:19:37 +0530 Subject: [PATCH 103/117] Only the opened row is active when two namespaces hold the same row identity Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 24 +++++++++++++++++++++++ frontend/src/views/Recent.tsx | 2 ++ 2 files changed, 26 insertions(+) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index bbc1452d20c..cc9b27e2705 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -223,6 +223,30 @@ describe("Recent search with one key written by two sessions", () => { expect(useStore.getState().inspectedScope).toEqual({ namespace: "bob", exact: true }); }); + it("marks only the opened row active when two namespaces hold the same key, agent, user and session", async () => { + const home = written("one", { value: "home note" }); + const away = written("one", { value: "bob note", version: 2, version_text: "2" }); + vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => ({ + entries: opts?.contains ? [] : [(id as { namespace: string }).namespace === "bob" ? away : home], + total: 1, + today: 1, + truncated: false, + })); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one"), ranked("one", { namespace: "bob", version: 2, version_text: "2" })], + embedding_model: "fake", + } as never); + useStore.setState({ myNamespaces: [row("alice", "admin"), row("bob", "writer")] }); + await search(); + + await screen.findByText("bob note"); + const rows = await screen.findAllByRole("button", { name: /deploy_note/ }); + expect(rows).toHaveLength(2); + await userEvent.click(rows[1]!); + expect(useStore.getState().inspectedScope).toEqual({ namespace: "bob", exact: true }); + expect(document.querySelectorAll('[data-active]')).toHaveLength(1); + }); + it("builds a foreign hit's bulk identity in its own namespace, and holds it to that namespace's role", async () => { const away = written("one", { value: "bob note", version: 2, version_text: "2" }); vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => ({ diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 97432d086d7..e1f95bb916e 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -142,6 +142,7 @@ function MemoryList() { const inspect = useStore((s) => s.inspect); const inspectedAgent = useStore((s) => s.inspectedAgent); const inspectedOwner = useStore((s) => s.inspectedOwner); + const inspectedScope = useStore((s) => s.inspectedScope); // Bumped on memory writes from any surface so we re-fetch immediately // instead of waiting for the polling cycle. const memoriesVersion = useStore((s) => s.memoriesVersion); @@ -1001,6 +1002,7 @@ function MemoryList() { // The open row is the one opened, not another row of its key. const isActive = inspectedKey === e.memory_key && + (e.namespace || identity.namespace) === (inspectedScope?.namespace || identity.namespace) && (!inspectedAgent || inspectedAgent === "*" || inspectedAgent === e.agent) && (!inspectedOwner || (inspectedOwner.user_id === (e.user_id || "-") && From 723a05509ac37e286ea7e2edabec2d40f7db55b5 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 10:22:19 +0530 Subject: [PATCH 104/117] A ranked preview test names the namespace version a complete writer lookup requires Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index cc9b27e2705..552e40e55db 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -244,7 +244,7 @@ describe("Recent search with one key written by two sessions", () => { expect(rows).toHaveLength(2); await userEvent.click(rows[1]!); expect(useStore.getState().inspectedScope).toEqual({ namespace: "bob", exact: true }); - expect(document.querySelectorAll('[data-active]')).toHaveLength(1); + expect(document.querySelectorAll("[data-active]")).toHaveLength(1); }); it("builds a foreign hit's bulk identity in its own namespace, and holds it to that namespace's role", async () => { @@ -358,7 +358,13 @@ describe("Recent search with one key written by two sessions", () => { if (!opts?.prefix) return { entries: opts?.contains ? [] : [written("two")], total: 1, today: 0, truncated: false }; const offset = opts.offset ?? 0; - return { entries: all.slice(offset, offset + 10), total: all.length, today: 0, truncated: false }; + return { + entries: all.slice(offset, offset + 10), + total: all.length, + today: 0, + truncated: false, + namespace_version: "1", + }; }); vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); await search(); @@ -394,7 +400,14 @@ describe("Recent search with one key written by two sessions", () => { const offset = opts.offset ?? 0; const entries = offset === 0 ? [] : [written("one", { sensitivity: "high", version: 2, version_text: "2", value: null })]; - return { entries, rows_read: offset === 0 ? 10 : 1, total: 11, today: 0, truncated: offset === 0 }; + return { + entries, + rows_read: offset === 0 ? 10 : 1, + total: 11, + today: 0, + truncated: offset === 0, + namespace_version: "1", + }; }); vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); await search(); From f2362776513e37531f1f8595e3f8d9a83a57da64 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 12:04:02 +0530 Subject: [PATCH 105/117] A parked-page test builds a cursor with a first_page_scope Signed-off-by: Krishna Dobhal --- tests/unit/test_search_shared_definitions.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_search_shared_definitions.py b/tests/unit/test_search_shared_definitions.py index eb3901e4f20..c8dc3a31b2e 100644 --- a/tests/unit/test_search_shared_definitions.py +++ b/tests/unit/test_search_shared_definitions.py @@ -244,7 +244,10 @@ async def test_a_parked_page_answers_with_the_withheld_note_on_degraded( sources: dict[str, Any], monkeypatch: pytest.MonkeyPatch ) -> None: async def page(*_a: Any, **_k: Any) -> dict[str, Any]: - return {"hits": [_parked("note", "bot"), _parked("definition/arr", "_shared")]} + return { + "first_page_scope": [], + "hits": [_parked("note", "bot"), _parked("definition/arr", "_shared")], + } async def readable(*_a: Any) -> set[str]: return {""} From 9afd536cfa623b09afdc44bb0868c952f8520db9 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 12:36:36 +0530 Subject: [PATCH 106/117] A hit that names no writer is held by a row of its own namespace only, so a foreign hit gets its writer lookup Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 11 ++++++++++- frontend/src/lib/memoriesSearch.ts | 9 ++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 2641fdd685c..29ba24966f4 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -6,7 +6,7 @@ vi.mock("../api", () => ({ storedToken: vi.fn(), })); import { listMemories, storedToken } from "../api"; -import { resolveSearchWriter } from "./memoriesSearch"; +import { resolveSearchWriter, rowIdentity, rowIds } from "./memoriesSearch"; const jwt = (claims: Record) => `h.${btoa(JSON.stringify(claims))}.s`; const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; @@ -277,3 +277,12 @@ describe("resolveSearchWriter under a narrowed token", () => { expect(await resolveSearchWriter(identity, bare, ABORT)).toBeUndefined(); }); }); + +describe("incomplete row identity", () => { + it("is held by a row of the same namespace and key only", () => { + const home = { memory_key: "k", agent: "a", user_id: "u", session_id: "s" }; + const foreign = { memory_key: "k", agent: "a", user_id: "u", namespace: "bob" }; + expect(rowIds("alice", home)).not.toContain(rowIdentity("alice", foreign)); + expect(rowIds("bob", { memory_key: "k" })).toContain(rowIdentity("alice", foreign)); + }); +}); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index d6fc32d4498..4fcaa296a9a 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -111,22 +111,21 @@ export async function resolveSearchWriter( } /** A row's own id: `(namespace, agent, user, session, key)`, which is what two rows of one - * key differ by; `[key]` alone when the row does not name its writer. The two shapes differ + * key differ by; `[namespace, key]` when the row does not name its writer. The two shapes differ * in length, so a key cannot make one pass for the other. */ export function rowIdentity( namespace: string, r: { memory_key: string; agent?: string; user_id?: string; session_id?: string; namespace?: string }, ): string { - return JSON.stringify( - namesWriter(r) ? [r.namespace || namespace, r.agent, r.user_id, r.session_id, r.memory_key] : [r.memory_key], - ); + const ns = r.namespace || namespace; + return JSON.stringify(namesWriter(r) ? [ns, r.agent, r.user_id, r.session_id, r.memory_key] : [ns, r.memory_key]); } /** Every id a row answers to: its own and its key's. A hit that names no writer is the key * alone (the old match, which keeps every row of the key); a hit that names one matches * only the row it names. */ export function rowIds(namespace: string, r: Parameters[1]): string[] { - return [rowIdentity(namespace, r), JSON.stringify([r.memory_key])]; + return [rowIdentity(namespace, r), JSON.stringify([r.namespace || namespace, r.memory_key])]; } export function keywordThenRanked(keywordKeys: string[], rankedKeys: string[]): string[] { From b21fb9d86fd3103b441c83c8c57134af8af3408a Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 12:57:57 +0530 Subject: [PATCH 107/117] A ranked hit that names less than its writer is resolved in its own namespace before it is held or ranked, and a loaded row never stands in for it Signed-off-by: Krishna Dobhal --- frontend/src/lib/memoriesSearch.test.ts | 31 +++++++++--- frontend/src/lib/memoriesSearch.ts | 18 +++++-- frontend/src/views/Recent.search.test.tsx | 62 +++++++++++++++++++++-- frontend/src/views/Recent.tsx | 7 +-- frontend/src/views/memoryListReads.ts | 33 ++++++++---- 5 files changed, 120 insertions(+), 31 deletions(-) diff --git a/frontend/src/lib/memoriesSearch.test.ts b/frontend/src/lib/memoriesSearch.test.ts index 29ba24966f4..4d1fad45e04 100644 --- a/frontend/src/lib/memoriesSearch.test.ts +++ b/frontend/src/lib/memoriesSearch.test.ts @@ -6,7 +6,7 @@ vi.mock("../api", () => ({ storedToken: vi.fn(), })); import { listMemories, storedToken } from "../api"; -import { resolveSearchWriter, rowIdentity, rowIds } from "./memoriesSearch"; +import { hitIdentity, resolveSearchWriter, rowIdentity } from "./memoriesSearch"; const jwt = (claims: Record) => `h.${btoa(JSON.stringify(claims))}.s`; const identity = { org: "dev", namespace: "alice", agent: "loom-ui" }; @@ -278,11 +278,28 @@ describe("resolveSearchWriter under a narrowed token", () => { }); }); -describe("incomplete row identity", () => { - it("is held by a row of the same namespace and key only", () => { - const home = { memory_key: "k", agent: "a", user_id: "u", session_id: "s" }; - const foreign = { memory_key: "k", agent: "a", user_id: "u", namespace: "bob" }; - expect(rowIds("alice", home)).not.toContain(rowIdentity("alice", foreign)); - expect(rowIds("bob", { memory_key: "k" })).toContain(rowIdentity("alice", foreign)); +describe("hit identity", () => { + const full = { memory_key: "k", agent: "a", user_id: "u", session_id: "s" }; + + it("is a row's own identity when the hit names its writer in full", () => { + expect(hitIdentity("alice", full)).toBe(rowIdentity("alice", full)); + }); + + it("matches no row when the hit leaves a writer field out", () => { + const ids = [ + { memory_key: "k", agent: "a", user_id: "other" }, + { memory_key: "k", agent: "a" }, + { memory_key: "k" }, + ].map((h) => hitIdentity("alice", h)); + for (const id of ids) { + expect(id).not.toBe(rowIdentity("alice", full)); + expect(id).not.toBe(rowIdentity("alice", { memory_key: "k" })); + } + expect(new Set(ids).size).toBe(3); + }); + + it("keeps a foreign namespace's hit apart from the home row", () => { + const foreign = { ...full, namespace: "bob" }; + expect(hitIdentity("alice", foreign)).not.toBe(rowIdentity("alice", full)); }); }); diff --git a/frontend/src/lib/memoriesSearch.ts b/frontend/src/lib/memoriesSearch.ts index 4fcaa296a9a..48d93d164bf 100644 --- a/frontend/src/lib/memoriesSearch.ts +++ b/frontend/src/lib/memoriesSearch.ts @@ -121,11 +121,19 @@ export function rowIdentity( return JSON.stringify(namesWriter(r) ? [ns, r.agent, r.user_id, r.session_id, r.memory_key] : [ns, r.memory_key]); } -/** Every id a row answers to: its own and its key's. A hit that names no writer is the key - * alone (the old match, which keeps every row of the key); a hit that names one matches - * only the row it names. */ -export function rowIds(namespace: string, r: Parameters[1]): string[] { - return [rowIdentity(namespace, r), JSON.stringify([r.namespace || namespace, r.memory_key])]; +/** A ranked hit's id. A hit that names its writer in full is its row's id; one that leaves + * a field out is any of several rows, so its id matches none (a loaded row never stands in + * for it) until its writer is resolved in its own namespace. */ +export function hitIdentity(namespace: string, h: Parameters[1]): string { + if (namesWriter(h)) return rowIdentity(namespace, h); + return JSON.stringify([ + h.namespace || namespace, + h.memory_key, + "unresolved", + h.agent ?? "", + h.user_id ?? "", + h.session_id ?? "", + ]); } export function keywordThenRanked(keywordKeys: string[], rankedKeys: string[]): string[] { diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index 552e40e55db..a6c7f79eb90 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -334,7 +334,7 @@ describe("Recent search with one key written by two sessions", () => { } }); - it("keeps rows of the key a hit without its writer names, and gives none of them its guidance", async () => { + it("ranks no loaded row of the key a hit without its writer names", async () => { feed(written("one"), written("two")); vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one", { user_id: undefined, session_id: undefined })], @@ -342,10 +342,10 @@ describe("Recent search with one key written by two sessions", () => { } as never); await search(); - await screen.findByText("note of session one"); - expect(screen.getByText("note of session two")).toBeInTheDocument(); + await waitFor(() => expect(searchMemory).toHaveBeenCalled(), { timeout: 3000 }); + await waitFor(() => expect(screen.queryByText("note of session one")).toBeNull()); + expect(screen.queryByText("note of session two")).toBeNull(); expect(screen.queryByTestId("search-score")).toBeNull(); - expect(screen.queryByText(/Suggested use/)).toBeNull(); }); it("finds a ranked row's preview past pages the server caps below the page size", async () => { @@ -1052,6 +1052,7 @@ describe("Recent search finds every row that names the word", () => { resolve({ results: [ { + ...writer, memory_key: "tea_pref", memory_type: "semantic", content_excerpt: "green tea", @@ -1122,3 +1123,56 @@ describe("Recent search finds every row that names the word", () => { expect(screen.getByText(/^\d+ match(es)?$/).closest("[aria-live]")).not.toBeNull(); }); }); + +describe("Recent search with a hit that names no session", () => { + beforeEach(() => { + vi.clearAllMocks(); + resetNamespaceRoleCache(); + useStore.setState({ + authed: true, + whoami: admin, + myNamespaces: [row("alice", "admin")], + identity: { org: "dev", namespace: "alice", agent: "loom-ui" }, + view: "memories", + }); + }); + afterEach(() => { + cleanup(); + useStore.setState({ whoami: null, myNamespaces: null, identity: null }); + }); + + it("does not rank or show another user's loaded row of the same key", async () => { + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => + opts?.contains + ? { entries: [], total: 0, today: 0, truncated: false } + : { entries: [entry("coffee_pref"), entry("tea_pref")], total: 2, today: 2, truncated: false }, + ); + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [ + { + agent: "claude-desktop", + user_id: "other", + version: 1, + version_text: "1", + memory_key: "coffee_pref", + memory_type: "semantic", + content_excerpt: "prefers oat milk in coffee", + distance: 0.3, + similarity: 0.7, + rank_score: 0.8, + confidence: 0.9, + }, + ], + embedding_model: "fake", + } as never); + render(); + await screen.findByText("coffee_pref"); + + await userEvent.type(screen.getByLabelText("Search memories"), "milk"); + await waitFor(() => expect(searchMemory).toHaveBeenCalled(), { timeout: 3000 }); + + // The loaded row is user "user"'s; the hit is user "other"'s and is not resolved. + await waitFor(() => expect(screen.queryByText("coffee_pref")).toBeNull()); + expect(screen.queryByText("tea_pref")).toBeNull(); + }); +}); diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index e1f95bb916e..e4f0cb8302f 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -54,7 +54,6 @@ import { type SearchQuery, namesWriter, rowIdentity, - rowIds, takePendingSearch, toggleQueryToken, } from "../lib/memoriesSearch"; @@ -427,11 +426,9 @@ function MemoryList() { } if (searchHits != null) { // Re-order to the server's relevance ranking; drop entries outside top_k. - // A row answers to its own id and to its key's: a hit that names no writer ranks every - // row of the key (the old match), one that names it ranks that row alone. + // A row is ranked by its own id; a hit that names less than its writer is resolved first. const rank = new Map(searchHits.map((id, i) => [id, i] as const)); - const at = (e: MemoryListEntry) => - Math.min(...rowIds(identity.namespace, e).map((id) => rank.get(id) ?? Infinity)); + const at = (e: MemoryListEntry) => rank.get(rowIdentity(identity.namespace, e)) ?? Infinity; all = all.filter((e) => at(e) !== Infinity).sort((a, b) => at(a) - at(b)); } return all; diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 2485af98a1b..f0643b155f6 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -17,8 +17,8 @@ import { listPages, namesWriter, resolveSearchWriter, + hitIdentity, rowIdentity, - rowIds, } from "../lib/memoriesSearch"; // The fields the page and its cards read. Field names are a quarter of a row, so a field @@ -94,7 +94,7 @@ export async function readSearchPreview( user_id: writer.user_id, session_id: writer.session_id, }; - const key = rowIdentity(namespace, { ...hit, ...writer }); + const key = hitIdentity(namespace, { ...hit, ...writer }); for await (const page of listPages(scope, KEYWORD_PAGE, { agent: writer.agent, prefix: hit.memory_key, @@ -102,7 +102,7 @@ export async function readSearchPreview( previewChars: CARD_VALUE_CHARS, signal, })) { - const entry = page.entries.find((row) => rowIds(namespace, row).includes(key)); + const entry = page.entries.find((row) => rowIdentity(namespace, row) === key); if (entry) return { ...entry, namespace, value: entry.value ?? null }; } return null; @@ -214,7 +214,7 @@ export function useMemorySearch( let cancelled = false; const ac = new AbortController(); const idOf = (r: Parameters[1]) => rowIdentity(identity.namespace, r); - const idsOf = (r: Parameters[1]) => rowIds(identity.namespace, r); + const hitId = (h: Parameters[1]) => hitIdentity(identity.namespace, h); const t = setTimeout(async () => { setSearching(true); try { @@ -260,9 +260,9 @@ export function useMemorySearch( const kwOwn = kwEntries.map(idOf); const kwKeys = new Set(kwOwn); const have = new Set(entriesRef.current.map(idOf)); - // Every id a row the list holds answers to: a hit that names no writer is matched by - // any row of its key, and one that names it by that row alone. - const held = new Set([...entriesRef.current, ...kwEntries].flatMap(idsOf)); + // A hit is held only by the row it names in full; one that names less is resolved + // below before it is ranked. + const held = new Set([...entriesRef.current, ...kwEntries].map(idOf)); const kwExtra = kwEntries.filter((e) => !have.has(idOf(e))).map((e) => [idOf(e), e] as const); setKeywordKeys(kwKeys); setKeywordFor(rawQuery.trim()); @@ -300,8 +300,8 @@ export function useMemorySearch( return; } const results = r.results || []; - const hits = keywordThenRanked(kwOwn, results.map(idOf)); - rankedShownRef.current = { key: shownKey, keys: results.map(idOf) }; + const hits = keywordThenRanked(kwOwn, results.map(hitId)); + rankedShownRef.current = { key: shownKey, keys: results.map(hitId) }; setSearchHits(hits); // Only a hit that names its writer in full can be shown on a row: a hit without them // is not told from another session's row of its key. @@ -312,13 +312,26 @@ export function useMemorySearch( r.abstain && kwKeys.size === 0 ? r.abstain_reason || "No strong match — showing best-effort results." : null, ); // Keep ranked hits that fell outside the loaded list window. - const unseen = results.filter((h) => !held.has(idOf(h))); + const unseen = results.filter((h) => !held.has(hitId(h))); if (unseen.length === 0) { setSearchExtra(new Map(kwExtra)); return; } const fetched = await readSearchPreviews(identity, unseen, ac.signal); if (cancelled) return; + // A hit that named less than its writer now ranks as the row it resolved to. + const resolved = new Map( + unseen.flatMap((h, i) => { + const e = fetched[i]; + return e ? [[hitId(h), idOf(e)] as const] : []; + }), + ); + if (resolved.size > 0) { + const at = (id: string) => resolved.get(id) ?? id; + setSearchHits(hits.map(at)); + if (rankedShownRef.current?.key === shownKey) + rankedShownRef.current.keys = rankedShownRef.current.keys.map(at); + } setSearchExtra( new Map([ ...kwExtra, From bc7316161df2ead2bd7dff1e3d5a4107fa3e2bf9 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 13:22:12 +0530 Subject: [PATCH 108/117] A ranked hit that names less than its writer commits its ranking once, after its writer resolves, and its row carries the hit's scores and guidance Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 49 +++++++++++++++++++++++ frontend/src/views/memoryListReads.ts | 49 +++++++++++------------ 2 files changed, 73 insertions(+), 25 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index a6c7f79eb90..d1624407332 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -348,6 +348,55 @@ describe("Recent search with one key written by two sessions", () => { expect(screen.queryByTestId("search-score")).toBeNull(); }); + it("gives a resolved incomplete hit's row its scores and guidance", async () => { + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => ({ + entries: opts?.prefix ? [written("one")] : [], + total: 1, + today: 0, + truncated: false, + namespace_version: "1", + })); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { user_id: undefined, session_id: undefined })], + embedding_model: "fake", + } as never); + await search(); + + await screen.findByText("note of session one"); + expect(await screen.findByTestId("search-score")).toBeInTheDocument(); + await userEvent.click(await screen.findByRole("button", { name: "Why this result" })); + expect(await screen.findByTestId("search-why")).toHaveTextContent("Suggested use: validate lead"); + }); + + it("keeps ranking in progress until a hit's writer is resolved, then shows the resolved row", async () => { + let release: () => void = () => {}; + const gate = new Promise((resolve) => { + release = resolve; + }); + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + if (opts?.prefix) { + await gate; + return { entries: [written("one")], total: 1, today: 0, truncated: false, namespace_version: "1" }; + } + return { entries: opts?.contains ? [written("two")] : [], total: 1, today: 0, truncated: false }; + }); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { user_id: undefined, session_id: undefined })], + embedding_model: "fake", + } as never); + await search(); + + await screen.findByText("note of session two"); + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 50)); + }); + expect(screen.getByText(/finding related/)).toBeInTheDocument(); + expect(screen.queryByText("note of session one")).toBeNull(); + release(); + await screen.findByText("note of session one"); + await waitFor(() => expect(screen.queryByText(/finding related/)).toBeNull()); + }); + it("finds a ranked row's preview past pages the server caps below the page size", async () => { const all = [ ...Array.from({ length: 10 }, (_, i) => written(`other${i}`)), diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index f0643b155f6..512037cc14c 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -287,8 +287,8 @@ export function useMemorySearch( // empties as before. const r = await (kwKeys.size > 0 ? ranked.catch(() => null) : ranked); if (cancelled) return; - setRanking(false); if (r === null) { + setRanking(false); // The new ranking failed: the hits kept from the last one are not today's, so the // list goes back to the keyword rows and the next run keeps none of them. rankedShownRef.current = null; @@ -300,38 +300,37 @@ export function useMemorySearch( return; } const results = r.results || []; - const hits = keywordThenRanked(kwOwn, results.map(hitId)); - rankedShownRef.current = { key: shownKey, keys: results.map(hitId) }; - setSearchHits(hits); - // Only a hit that names its writer in full can be shown on a row: a hit without them - // is not told from another session's row of its key. - setSearchWhy(new Map(results.filter(namesWriter).map((h) => [idOf(h), h] as const))); - // The server hedges (abstain) when the top hit is below threshold; - // surface it so weak matches aren't read as confident answers. - setSearchAbstain( - r.abstain && kwKeys.size === 0 ? r.abstain_reason || "No strong match — showing best-effort results." : null, - ); - // Keep ranked hits that fell outside the loaded list window. + // Hits outside the loaded rows are read on their own; one that named less than its + // writer is ranked as the row it resolved to. Ranking commits once, after this read, + // so no id that matches no row is ever shown. const unseen = results.filter((h) => !held.has(hitId(h))); - if (unseen.length === 0) { - setSearchExtra(new Map(kwExtra)); - return; - } - const fetched = await readSearchPreviews(identity, unseen, ac.signal); + const fetched = unseen.length > 0 ? await readSearchPreviews(identity, unseen, ac.signal) : []; if (cancelled) return; - // A hit that named less than its writer now ranks as the row it resolved to. const resolved = new Map( unseen.flatMap((h, i) => { const e = fetched[i]; return e ? [[hitId(h), idOf(e)] as const] : []; }), ); - if (resolved.size > 0) { - const at = (id: string) => resolved.get(id) ?? id; - setSearchHits(hits.map(at)); - if (rankedShownRef.current?.key === shownKey) - rankedShownRef.current.keys = rankedShownRef.current.keys.map(at); - } + const at = (id: string) => resolved.get(id) ?? id; + const ids = results.map((h) => at(hitId(h))); + rankedShownRef.current = { key: shownKey, keys: ids }; + setRanking(false); + setSearchHits(keywordThenRanked(kwOwn, ids)); + // A hit that names its writer in full, or one resolved to its row, carries its scores + // and guidance on that row; one left unresolved is not told from another session's row + // of its key. + setSearchWhy( + new Map( + results.flatMap((h) => (namesWriter(h) || resolved.has(hitId(h)) ? [[at(hitId(h)), h] as const] : [])), + ), + ); + // The server hedges (abstain) when the top hit is below threshold; + // surface it so weak matches aren't read as confident answers. + setSearchAbstain( + r.abstain && kwKeys.size === 0 ? r.abstain_reason || "No strong match — showing best-effort results." : null, + ); + // Keep ranked hits that fell outside the loaded list window. setSearchExtra( new Map([ ...kwExtra, From 7d140013b620f1d5a95b6d91ecdd19492c24d784 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 13:43:05 +0530 Subject: [PATCH 109/117] A ranked search shows the hits it already holds at once and keeps ranking in progress only while an incomplete hit's writer resolves Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 45 +++++++++++++ frontend/src/views/memoryListReads.ts | 77 +++++++++++++---------- 2 files changed, 90 insertions(+), 32 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index d1624407332..b85ed37573b 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -397,6 +397,51 @@ describe("Recent search with one key written by two sessions", () => { await waitFor(() => expect(screen.queryByText(/finding related/)).toBeNull()); }); + const gatedPrefix = (loaded: MemoryListEntry[], resolved: MemoryListEntry) => { + let release: () => void = () => {}; + const gate = new Promise((resolve) => { + release = resolve; + }); + vi.mocked(listMemories).mockImplementation(async (_id, _limit, opts) => { + if (opts?.prefix) { + await gate; + return { entries: [resolved], total: 1, today: 0, truncated: false, namespace_version: "1" }; + } + return { entries: opts?.contains ? [] : loaded, total: loaded.length, today: 0, truncated: false }; + }); + return release; + }; + + it("shows an already-held ranked row at once while another hit's preview is still read", async () => { + const release = gatedPrefix([written("one"), written("two")], written("three")); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one"), ranked("three", { user_id: undefined, session_id: undefined })], + embedding_model: "fake", + } as never); + await search(); + + await waitFor(() => expect(screen.queryByText("note of session two")).toBeNull()); + expect(screen.getByText("note of session one")).toBeInTheDocument(); + expect(screen.getByText(/finding related/)).toBeInTheDocument(); + release(); + await screen.findByText("note of session three"); + await waitFor(() => expect(screen.queryByText(/finding related/)).toBeNull()); + }); + + it("does not keep the unfiltered list while the only hit's preview is read", async () => { + const release = gatedPrefix([written("two")], written("one")); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { user_id: undefined, session_id: undefined })], + embedding_model: "fake", + } as never); + await search(); + + await waitFor(() => expect(screen.queryByText("note of session two")).toBeNull()); + expect(screen.getByText(/finding related/)).toBeInTheDocument(); + release(); + await screen.findByText("note of session one"); + }); + it("finds a ranked row's preview past pages the server caps below the page size", async () => { const all = [ ...Array.from({ length: 10 }, (_, i) => written(`other${i}`)), diff --git a/frontend/src/views/memoryListReads.ts b/frontend/src/views/memoryListReads.ts index 512037cc14c..86ea02c2421 100644 --- a/frontend/src/views/memoryListReads.ts +++ b/frontend/src/views/memoryListReads.ts @@ -300,42 +300,55 @@ export function useMemorySearch( return; } const results = r.results || []; - // Hits outside the loaded rows are read on their own; one that named less than its - // writer is ranked as the row it resolved to. Ranking commits once, after this read, - // so no id that matches no row is ever shown. + // A hit held by a loaded row is settled and shows now; one outside the loaded rows + // is read on its own, and one that named less than its writer is ranked as the row + // it resolved to. Ranking stays in progress only while those reads run, so no id + // that matches no row is ever shown. const unseen = results.filter((h) => !held.has(hitId(h))); - const fetched = unseen.length > 0 ? await readSearchPreviews(identity, unseen, ac.signal) : []; + const commit = (resolved: Map, fetched: (MemoryListEntry | null)[]) => { + const at = (id: string) => resolved.get(id) ?? id; + const done = unseen.length === 0 || fetched.length > 0; + const shown = results.filter((h) => done || held.has(hitId(h))); + const ids = shown.map((h) => at(hitId(h))); + if (done) rankedShownRef.current = { key: shownKey, keys: ids }; + setRanking(!done); + setSearchHits(keywordThenRanked(kwOwn, ids)); + // A hit that names its writer in full, or one resolved to its row, carries its + // scores and guidance on that row; one left unresolved is not told from another + // session's row of its key. + setSearchWhy( + new Map( + shown.flatMap((h) => (namesWriter(h) || resolved.has(hitId(h)) ? [[at(hitId(h)), h] as const] : [])), + ), + ); + // The server hedges (abstain) when the top hit is below threshold; + // surface it so weak matches aren't read as confident answers. + setSearchAbstain( + r.abstain && kwKeys.size === 0 + ? r.abstain_reason || "No strong match — showing best-effort results." + : null, + ); + // Keep ranked hits that fell outside the loaded list window. + setSearchExtra( + new Map([ + ...kwExtra, + ...fetched.filter((e): e is NonNullable => e !== null).map((e) => [idOf(e), e] as const), + ]), + ); + }; + commit(new Map(), []); + setSearching(false); + if (unseen.length === 0) return; + const fetched = await readSearchPreviews(identity, unseen, ac.signal); if (cancelled) return; - const resolved = new Map( - unseen.flatMap((h, i) => { - const e = fetched[i]; - return e ? [[hitId(h), idOf(e)] as const] : []; - }), - ); - const at = (id: string) => resolved.get(id) ?? id; - const ids = results.map((h) => at(hitId(h))); - rankedShownRef.current = { key: shownKey, keys: ids }; - setRanking(false); - setSearchHits(keywordThenRanked(kwOwn, ids)); - // A hit that names its writer in full, or one resolved to its row, carries its scores - // and guidance on that row; one left unresolved is not told from another session's row - // of its key. - setSearchWhy( + commit( new Map( - results.flatMap((h) => (namesWriter(h) || resolved.has(hitId(h)) ? [[at(hitId(h)), h] as const] : [])), + unseen.flatMap((h, i) => { + const e = fetched[i]; + return e ? [[hitId(h), idOf(e)] as const] : []; + }), ), - ); - // The server hedges (abstain) when the top hit is below threshold; - // surface it so weak matches aren't read as confident answers. - setSearchAbstain( - r.abstain && kwKeys.size === 0 ? r.abstain_reason || "No strong match — showing best-effort results." : null, - ); - // Keep ranked hits that fell outside the loaded list window. - setSearchExtra( - new Map([ - ...kwExtra, - ...fetched.filter((e): e is NonNullable => e !== null).map((e) => [idOf(e), e] as const), - ]), + fetched, ); } catch { if (!cancelled) { From 7adbd0a074ef3f2376c7978756192bcfc5d1c757 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 17:17:56 +0530 Subject: [PATCH 110/117] A ranked search shows neither no matches nor the low-confidence note while a hit's preview is still read The empty state and the abstain banner keyed off searching alone, which the first ranking commit clears before unseen previews return. Both now also wait for ranking. The bulk-identity test waits for the search a role change reruns before it selects. Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 29 +++++++++++++++++++++-- frontend/src/views/Recent.tsx | 3 ++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index b85ed37573b..6cfcb5815b7 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -273,9 +273,14 @@ describe("Recent search with one key written by two sessions", () => { expect(getMemory).not.toHaveBeenCalled(); // The same selection as a writer in bob reads the row in bob. - useStore.setState({ myNamespaces: [row("alice", "writer"), row("bob", "writer")] }); + // A role change runs the search again; select once it has answered, or its rows reset the selection. + act(() => useStore.setState({ myNamespaces: [row("alice", "writer"), row("bob", "writer")] })); + await waitFor(() => expect(searchMemory).toHaveBeenCalledTimes(2)); + await waitFor(() => expect(screen.queryByText(/finding related/)).toBeNull()); await userEvent.click(screen.getByLabelText("Select deploy_note")); - await userEvent.click(await screen.findByRole("button", { name: "Pin" })); + // The first bulk pin may still be settling: a click while it is busy does nothing. + await waitFor(() => expect(screen.getByRole("button", { name: "Pin" })).toBeEnabled()); + await userEvent.click(screen.getByRole("button", { name: "Pin" })); await waitFor(() => expect(getMemory).toHaveBeenCalled()); expect(getMemory).toHaveBeenCalledWith(expect.objectContaining({ namespace: "bob" }), "deploy_note"); }); @@ -442,6 +447,26 @@ describe("Recent search with one key written by two sessions", () => { await screen.findByText("note of session one"); }); + it("shows neither the empty state nor the low-confidence note while a hit's preview is still read", async () => { + const release = gatedPrefix([], written("one")); + vi.mocked(searchMemory).mockResolvedValue({ + results: [ranked("one", { user_id: undefined, session_id: undefined })], + abstain: true, + embedding_model: "fake", + } as never); + await search(); + + await screen.findByText(/finding related/); + await act(async () => { + await new Promise((resolve) => setTimeout(resolve, 50)); + }); + expect(screen.queryByText(/No memories match/)).toBeNull(); + expect(screen.queryByText(/Low confidence/)).toBeNull(); + release(); + await screen.findByText("note of session one"); + expect(screen.getByText(/Low confidence/)).toBeInTheDocument(); + }); + it("finds a ranked row's preview past pages the server caps below the page size", async () => { const all = [ ...Array.from({ length: 10 }, (_, i) => written(`other${i}`)), diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index e4f0cb8302f..6ea067a9506 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -855,7 +855,7 @@ function MemoryList() { )}
)} - {!searching && searchAbstain && ( + {!searching && !ranking && searchAbstain && ( Date: Wed, 2 Dec 2026 18:18:55 +0530 Subject: [PATCH 111/117] The memory stack drops a pinned or recent row whose validity has ended Both ClickHouse queries now use FILE_LISTING_VISIBLE, which carries the valid_to check, so an ended interval no longer gets follow_if_applicable guidance. Signed-off-by: Krishna Dobhal --- server/memory/app/stack.py | 9 +++------ tests/unit/test_source_checked_stack.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/server/memory/app/stack.py b/server/memory/app/stack.py index ab3b33bf304..1d9516ff31f 100644 --- a/server/memory/app/stack.py +++ b/server/memory/app/stack.py @@ -22,6 +22,7 @@ from server.memory.app.stack_knowledge import StackKnowledge from server.memory.app.use_guidance import guidance_source_states, procedure_status_for_row from server.memory.domain.use_guidance import UseGuidance, guidance_for_row +from server.memory.store.sql import FILE_LISTING_VISIBLE log = logging.getLogger(__name__) @@ -154,10 +155,8 @@ async def _stack_pinned(ch: Any, input: MemoryStackInput, fill: _StackFill) -> N AND user_id = {{uid:String}} AND session_id = {{sid:String}} AND pinned = 1 - AND tombstoned_at IS NULL - AND (expires_at IS NULL OR expires_at > now()) + AND ({FILE_LISTING_VISIBLE}) AND status IN ('active', 'conflicted') - AND sensitivity != 'high' {scope} ORDER BY version DESC LIMIT {{lim:UInt32}} @@ -221,10 +220,8 @@ async def _stack_recent(ch: Any, input: MemoryStackInput, fill: _StackFill) -> s AND agent = {{agent:String}} AND user_id = {{uid:String}} AND session_id = {{sid:String}} - AND tombstoned_at IS NULL - AND (expires_at IS NULL OR expires_at > now()) + AND ({FILE_LISTING_VISIBLE}) AND status IN ('active', 'conflicted') - AND sensitivity != 'high' AND (sensitivity != 'medium' OR {{medium_ok:UInt8}} = 1) AND pinned = 0 AND recall_count > 0 diff --git a/tests/unit/test_source_checked_stack.py b/tests/unit/test_source_checked_stack.py index 830364956a0..67c6707a998 100644 --- a/tests/unit/test_source_checked_stack.py +++ b/tests/unit/test_source_checked_stack.py @@ -310,3 +310,26 @@ async def discover(plan, query, **kwargs): # The live new raw row still shadows the source family, while the old physical # fallback is gone. Logical-key membership must not retain the old object. assert [entry.value for entry in checked.output.entries] == ["prefix"] + + +@pytest.mark.asyncio +@pytest.mark.parametrize("section", ["_stack_pinned", "_stack_recent"]) +async def test_pinned_and_recent_queries_drop_an_ended_validity_interval( + section: str, monkeypatch: pytest.MonkeyPatch +) -> None: + """A row whose `valid_to` has passed is not current, so it never rides the stack with + follow_if_applicable guidance before retention handles it.""" + seen: list[str] = [] + + class _CH: + async def query_all(self, sql: str, params: object = None) -> list[dict]: + seen.append(sql) + return [] + + monkeypatch.setattr(stack, "request_scope", lambda: None) + monkeypatch.setattr(stack, "scope_and", lambda scope, params: "") + fill = stack._StackFill(budget=1000) + await getattr(stack, section)( + _CH(), MemoryStackInput(org="o", namespace="ns", agent="a", seed_query="q"), fill + ) + assert "valid_to IS NULL OR valid_to > now()" in seen[0] From b741d2105e59929e92b318e3fd5df36303c92428 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 18:18:56 +0530 Subject: [PATCH 112/117] A ranked preview from another namespace shows its own conflict status The conflict-key set is the page namespace's, so a foreign row is judged by its status instead. Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 3 +++ frontend/src/views/Recent.tsx | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index 6cfcb5815b7..5cfd336850e 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -236,12 +236,15 @@ describe("Recent search with one key written by two sessions", () => { results: [ranked("one"), ranked("one", { namespace: "bob", version: 2, version_text: "2" })], embedding_model: "fake", } as never); + // The page's namespace holds a conflict under the key; bob's row of that key has none. + vi.mocked(conflictKeys).mockResolvedValue(["deploy_note"]); useStore.setState({ myNamespaces: [row("alice", "admin"), row("bob", "writer")] }); await search(); await screen.findByText("bob note"); const rows = await screen.findAllByRole("button", { name: /deploy_note/ }); expect(rows).toHaveLength(2); + await waitFor(() => expect(screen.getAllByText("Conflicted")).toHaveLength(1)); await userEvent.click(rows[1]!); expect(useStore.getState().inspectedScope).toEqual({ namespace: "bob", exact: true }); expect(document.querySelectorAll("[data-active]")).toHaveLength(1); diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 6ea067a9506..780e99809e2 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -1031,7 +1031,13 @@ function MemoryList() { > Date: Wed, 2 Dec 2026 22:47:05 +0530 Subject: [PATCH 113/117] Recall Lab asks the writer lookup about every legacy hit, so a key held at two revisions merges into the row at the hit's revision Signed-off-by: Krishna Dobhal --- .../views/RecallLab.memoriesOrder.test.tsx | 22 ++++++++++++++++++- frontend/src/views/RecallLab.tsx | 5 ++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/RecallLab.memoriesOrder.test.tsx b/frontend/src/views/RecallLab.memoriesOrder.test.tsx index 27236c36423..b8157a9ad64 100644 --- a/frontend/src/views/RecallLab.memoriesOrder.test.tsx +++ b/frontend/src/views/RecallLab.memoriesOrder.test.tsx @@ -256,7 +256,27 @@ describe("Recall Lab and the Memories list", () => { render(); await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(3), { timeout: 3000 }); - expect(vi.mocked(listMemories)).toHaveBeenCalledTimes(1); // no lookup for an ambiguous key + // the lookup finds two rows at the hit's revision and names no writer + await waitFor(() => expect(vi.mocked(listMemories)).toHaveBeenCalledTimes(2)); + }); + + it("merges a legacy hit into the one keyword row that holds its revision when the key has several", async () => { + const rows = [ + { ...entry("older_azure"), user_id: "u", session_id: "s1", version_text: "v1" }, + { ...entry("older_azure"), user_id: "u", session_id: "s2", version_text: "v2" }, + ]; + const page = { entries: rows, total: 2, today: 0, truncated: false, namespace_version: "1" }; + vi.mocked(listMemories).mockResolvedValueOnce(page); + vi.mocked(listMemories).mockResolvedValueOnce(page); // the lookup reads both rows + vi.mocked(searchMemory).mockResolvedValueOnce({ + results: [{ ...hit("older_azure", 0.9), version_text: "v2", user_id: undefined, session_id: undefined }], + embedding_model: "m", + }); + useStore.setState({ view: "recall" }); + render(); + await userEvent.type(screen.getByLabelText("Recall query"), "Azure"); + await waitFor(() => expect(screen.getAllByText("older_azure")).toHaveLength(2), { timeout: 3000 }); + expect(screen.getAllByText("0.900")).toHaveLength(1); }); it("draws the rows while a writer lookup hangs", async () => { diff --git a/frontend/src/views/RecallLab.tsx b/frontend/src/views/RecallLab.tsx index bf0a8da3505..d10da38e0b5 100644 --- a/frontend/src/views/RecallLab.tsx +++ b/frontend/src/views/RecallLab.tsx @@ -521,8 +521,7 @@ export function RecallLab() { ); // A legacy hit omits its writer, and another writer's row can share its key, so a hit // is never dropped here: the lookup below names it, and it merges into the row that - // holds it. Several keyword rows share the key, so it stays a preview no one can open. - const held = (key: string) => [...keyword.values()].filter((e) => e.memory_key === key).length; + // holds it. A key several rows share stays a preview no one can open unless one row holds its revision. const ranked = new Map(); (r?.results ?? []).forEach((h, i) => { ranked.set(recallRowId(identity.namespace, h, `ranked:${i}`), h); @@ -575,7 +574,7 @@ export function RecallLab() { ); // A lone legacy hit asks which writer holds it, a few lookups at a time, after the rows // are drawn; a hit that resolves to a row already shown is that row. - const lookups = [...ranked].filter(([id, h]) => id.startsWith("ranked:") && held(h.memory_key) <= 1); + const lookups = [...ranked].filter(([id]) => id.startsWith("ranked:")); let next = 0; const lookup = async () => { for (let item = lookups[next++]; item && !ac.signal.aborted; item = lookups[next++]) { From a5b30e1f136ba4e9aa25aae0d5a2cf2eb4d1581f Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 22:47:05 +0530 Subject: [PATCH 114/117] A parked shared hit is kept only while its head is current, unexpired and holds the body it served Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 30 +++++++++++++++++++---- server/memory/store/shared.py | 13 +++++++--- tests/unit/test_search_use_guidance.py | 33 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index bc5d37a1d33..34abc2a14d8 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -34,6 +34,15 @@ def _fact_row(hit: _MemorySearchHit) -> bool: return hit.source in ("fact", "anchor") +def _served_digest(hit: _MemorySearchHit, parked: bool) -> str: + return hit._guidance_content_sha256 if parked else hit._row_content_sha256 + + +def _digest_diverges(head_digest: str, served_digest: str) -> bool: + """Whether the head holds a different body than the one this hit served.""" + return is_content_hash(served_digest) and head_digest != served_digest + + def _status_kept( status: str, hit: _MemorySearchHit, input: MemorySearchInput, *, parked: bool ) -> bool: @@ -119,11 +128,11 @@ def _memory_evidence( denied.add(i) continue digest = hash_text(row.get("content_sha256")) - served_digest = hit._guidance_content_sha256 if parked else hit._row_content_sha256 + served_digest = _served_digest(hit, parked) if int(row.get("version") or 0) == version or ( not replay and is_content_hash(digest) and digest == served_digest ): - if is_content_hash(served_digest) and digest != served_digest: + if _digest_diverges(digest, served_digest): denied.add(i) continue evidence[i] = dict(row, namespace=key[1], user_id=key[3]) @@ -176,14 +185,25 @@ def _shared_evidence( hits: list[_MemorySearchHit], keys: dict[int, tuple[str, str]], rows: dict[tuple[str, str], dict[str, Any]] | None, + *, + replay: bool, + parked: bool, ) -> tuple[set[int], dict[int, dict[str, Any]]]: denied: set[int] = set() evidence: dict[int, dict[str, Any]] = {} if rows is None: return denied, evidence + now = naive_utc_now() for i, key in keys.items(): row = rows.get(key) - if row is None or row.get("tombstoned_at") is not None or row.get("superseded_by"): + if ( + row is None + or not _current(row, now, replay=replay) + or row.get("superseded_by") + or _digest_diverges( + hash_text(row.get("content_sha256")), _served_digest(hits[i], parked) + ) + ): denied.add(i) elif int(row.get("version") or 0) == doc_version(hits[i]): # A promoted row has its own lifecycle. Its private contributors' review @@ -269,7 +289,9 @@ async def attach_search_guidance( _replay_evidence(replay_keys, rows, hits), timeout_s=timeout_s, parked=True ) evidence.update(historical or {}) - denied_shared, shared_evidence = _shared_evidence(hits, shared_keys, shared) + denied_shared, shared_evidence = _shared_evidence( + hits, shared_keys, shared, replay=replay, parked=parked + ) denied |= denied_memory | denied_shared evidence.update(shared_evidence) authorized = evidence.keys() diff --git a/server/memory/store/shared.py b/server/memory/store/shared.py index 1d6d03bc106..d0eba522816 100644 --- a/server/memory/store/shared.py +++ b/server/memory/store/shared.py @@ -17,6 +17,7 @@ from datetime import datetime from typing import Any +from server.core.hashing import served_row_value, sha256_value from server.core.repo_base import _CHClient, _default_client, query_all_sliced from server.core.rmt_carry import register from server.memory.domain.definitions import DEFINITION_KEY_PREFIX @@ -113,7 +114,6 @@ async def shared_embedding_source( ) -> tuple[dict[str, Any], Any, set[str]] | None: """The complete approved source behind this shared cache row, if it still agrees.""" from server.core import pg - from server.core.hashing import served_row_value, sha256_value from server.memory.domain.excerpt import build_excerpt from server.memory.domain.promotion_source import promotion_keys, promotion_users from server.memory.domain.temporal_sql import SERVED_STATUSES @@ -205,7 +205,7 @@ async def guidance_heads( rows = await query_all_sliced( _default_client(), f""" - SELECT namespace, memory_key, version, superseded_by, tombstoned_at + SELECT namespace, memory_key, value, version, superseded_by, tombstoned_at FROM loom.shared FINAL PREWHERE org = {{org:String}} AND (namespace, memory_key) IN {{keys:Array(Tuple(String, String))}} @@ -214,7 +214,14 @@ async def guidance_heads( {"org": org, "keys": sorted(set(keys))}, "keys", ) - return {(str(r["namespace"]), str(r["memory_key"])): r for r in rows} + # The body a shared hit serves is hashed as `shared_embedding_source` hashes it. + return { + (str(r["namespace"]), str(r["memory_key"])): { + **{k: v for k, v in r.items() if k != "value"}, + "content_sha256": sha256_value(served_row_value(r)), + } + for r in rows + } async def fetch_shared( diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index 72ef745c806..d4aa1594ddb 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -279,6 +279,39 @@ async def heads(keys): assert await guidance.attach_search_guidance(_INPUT, [parked], parked=True) == [] +@pytest.mark.parametrize( + "change", + [ + {"expires_at": "2000-01-01T00:00:00"}, + {"valid_to": "2000-01-01T00:00:00"}, + {"content_sha256": "b" * 64}, + ], + ids=["expired", "ended", "replaced-same-version"], +) +@pytest.mark.parametrize("parked", [False, True]) +async def test_a_shared_hit_is_dropped_when_its_head_is_no_longer_current( + monkeypatch, change, parked +): + head = {"version": 42, "content_sha256": "a" * 64} + + async def shared_heads(org, keys): + return {("n", _KEY[-1]): dict(head, **change)} + + monkeypatch.setattr(guidance, "shared_guidance_heads", shared_heads) + hit = _hit() + hit._row_identity = ("_shared", "-", "-") + hit._row_content_sha256 = hit._guidance_content_sha256 = "a" * 64 + assert await guidance.attach_search_guidance(_INPUT, [hit], parked=parked) == [] + head_ok = dict(head) + shared = {("n", _KEY[-1]): head_ok} + + async def current(org, keys): + return shared + + monkeypatch.setattr(guidance, "shared_guidance_heads", current) + assert await guidance.attach_search_guidance(_INPUT, [hit], parked=parked) == [hit] + + async def test_unchanged_superseded_anchor_hit_survives_a_handle_only_continuation(monkeypatch): """An anchor hit read under `include_superseded` keeps the status its row had, so the continuation (whose request does not repeat the flag) serves it while the row is unchanged.""" From 9e9d84f49d486a996f650f39e0fdc2ac81a94061 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Wed, 2 Dec 2026 22:59:55 +0530 Subject: [PATCH 115/117] A parked shared hit's served digest is recorded on the live pass, so a same-version replacement is caught Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 10 +++++++++ tests/unit/test_search_use_guidance.py | 29 +++++++++++--------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 34abc2a14d8..50b230fad3f 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -209,6 +209,16 @@ def _shared_evidence( # A promoted row has its own lifecycle. Its private contributors' review # does not attest the shared copy and may not be readable here. evidence[i] = {"status": "active", "source_class": hits[i].source_class} + digest = hash_text(row.get("content_sha256")) + if ( + not parked + and hits[i]._row_chunk is None + and is_content_hash(digest) + and digest == hits[i]._row_content_sha256 + ): + # Recorded here so a parked page can tell a replaced body from the one served. + hits[i]._guidance_content_sha256 = digest + hits[i]._guidance_head_version = int(row.get("version") or 0) return denied, evidence diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index d4aa1594ddb..ef504237f55 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -281,35 +281,30 @@ async def heads(keys): @pytest.mark.parametrize( "change", - [ - {"expires_at": "2000-01-01T00:00:00"}, - {"valid_to": "2000-01-01T00:00:00"}, - {"content_sha256": "b" * 64}, - ], - ids=["expired", "ended", "replaced-same-version"], + [{"content_sha256": "b" * 64}, {"tombstoned_at": "2000-01-01T00:00:00"}], + ids=["replaced-same-version", "tombstoned"], ) @pytest.mark.parametrize("parked", [False, True]) async def test_a_shared_hit_is_dropped_when_its_head_is_no_longer_current( monkeypatch, change, parked ): head = {"version": 42, "content_sha256": "a" * 64} + heads = {"row": head} async def shared_heads(org, keys): - return {("n", _KEY[-1]): dict(head, **change)} + return {("n", _KEY[-1]): heads["row"]} monkeypatch.setattr(guidance, "shared_guidance_heads", shared_heads) hit = _hit() hit._row_identity = ("_shared", "-", "-") - hit._row_content_sha256 = hit._guidance_content_sha256 = "a" * 64 - assert await guidance.attach_search_guidance(_INPUT, [hit], parked=parked) == [] - head_ok = dict(head) - shared = {("n", _KEY[-1]): head_ok} - - async def current(org, keys): - return shared - - monkeypatch.setattr(guidance, "shared_guidance_heads", current) - assert await guidance.attach_search_guidance(_INPUT, [hit], parked=parked) == [hit] + # The live pass records the served digest; a parked page restores it. + assert await guidance.attach_search_guidance(_INPUT, [hit]) == [hit] + served = search_pages.unparked(search_pages._parked(hit)) if parked else hit + assert served is not None + heads["row"] = dict(head, **change) + assert await guidance.attach_search_guidance(_INPUT, [served], parked=parked) == [] + heads["row"] = dict(head) + assert await guidance.attach_search_guidance(_INPUT, [served], parked=parked) == [served] async def test_unchanged_superseded_anchor_hit_survives_a_handle_only_continuation(monkeypatch): From b482833e03381b086fe06ff7118fad3ebc0d30b6 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Thu, 3 Dec 2026 02:08:22 +0530 Subject: [PATCH 116/117] A live shared hit is kept, without the head's guidance, when a newer head holds other content A shared hit follows the private-row order: the digest check applies only when the head is the served revision. Signed-off-by: Krishna Dobhal --- server/memory/app/search/guidance.py | 47 +++++++++++++++++--------- tests/unit/test_search_use_guidance.py | 47 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 16 deletions(-) diff --git a/server/memory/app/search/guidance.py b/server/memory/app/search/guidance.py index 50b230fad3f..7731f31de7e 100644 --- a/server/memory/app/search/guidance.py +++ b/server/memory/app/search/guidance.py @@ -43,6 +43,18 @@ def _digest_diverges(head_digest: str, served_digest: str) -> bool: return is_content_hash(served_digest) and head_digest != served_digest +def _head_holds_hit( + head_version: int, hit_version: int, digest: str, served: str, *, replay: bool +) -> bool | None: + """Whether the head is the revision the hit served: None for another revision, False + for the same revision holding a replaced body, True for the revision as served.""" + if head_version != hit_version and not ( + not replay and is_content_hash(digest) and digest == served + ): + return None + return not _digest_diverges(digest, served) + + def _status_kept( status: str, hit: _MemorySearchHit, input: MemorySearchInput, *, parked: bool ) -> bool: @@ -129,12 +141,12 @@ def _memory_evidence( continue digest = hash_text(row.get("content_sha256")) served_digest = _served_digest(hit, parked) - if int(row.get("version") or 0) == version or ( - not replay and is_content_hash(digest) and digest == served_digest - ): - if _digest_diverges(digest, served_digest): - denied.add(i) - continue + held = _head_holds_hit( + int(row.get("version") or 0), version, digest, served_digest, replay=replay + ) + if held is False: + denied.add(i) + elif held: evidence[i] = dict(row, namespace=key[1], user_id=key[3]) if ( not parked @@ -196,20 +208,23 @@ def _shared_evidence( now = naive_utc_now() for i, key in keys.items(): row = rows.get(key) - if ( - row is None - or not _current(row, now, replay=replay) - or row.get("superseded_by") - or _digest_diverges( - hash_text(row.get("content_sha256")), _served_digest(hits[i], parked) - ) - ): + if row is None or not _current(row, now, replay=replay) or row.get("superseded_by"): + denied.add(i) + continue + digest = hash_text(row.get("content_sha256")) + held = _head_holds_hit( + int(row.get("version") or 0), + doc_version(hits[i]), + digest, + _served_digest(hits[i], parked), + replay=replay, + ) + if held is False: denied.add(i) - elif int(row.get("version") or 0) == doc_version(hits[i]): + elif held: # A promoted row has its own lifecycle. Its private contributors' review # does not attest the shared copy and may not be readable here. evidence[i] = {"status": "active", "source_class": hits[i].source_class} - digest = hash_text(row.get("content_sha256")) if ( not parked and hits[i]._row_chunk is None diff --git a/tests/unit/test_search_use_guidance.py b/tests/unit/test_search_use_guidance.py index ef504237f55..88cc0d321cd 100644 --- a/tests/unit/test_search_use_guidance.py +++ b/tests/unit/test_search_use_guidance.py @@ -535,3 +535,50 @@ async def heads(keys): assert kept == [] else: assert hit.use_guidance is not None and hit.use_guidance.review == review + + +@pytest.mark.parametrize("parked", [False, True]) +async def test_a_live_shared_hit_stays_served_without_guidance_when_a_newer_head_holds_other_content( + monkeypatch, parked +): + """A re-promoted shared row is still the hit's own revision for a reader: the hit is + kept, but the newer head's lifecycle is not read as its review.""" + head = {"version": 42, "content_sha256": "a" * 64} + heads = {"row": head} + + async def shared_heads(org, keys): + return {("n", _KEY[-1]): heads["row"]} + + monkeypatch.setattr(guidance, "shared_guidance_heads", shared_heads) + hit = _hit() + hit._row_identity = ("_shared", "-", "-") + assert await guidance.attach_search_guidance(_INPUT, [hit]) == [hit] + served = search_pages.unparked(search_pages._parked(hit)) if parked else hit + assert served is not None + heads["row"] = {"version": 43, "content_sha256": "b" * 64} + # A parked page keeps a fact body only while its head still serves it, as for a private row. + kept = await guidance.attach_search_guidance(_INPUT, [served], parked=parked) + assert kept == ([] if parked else [served]) + assert served.use_guidance is None or served.use_guidance.review == "unknown" + heads["row"] = {"version": 42, "content_sha256": "b" * 64} + assert await guidance.attach_search_guidance(_INPUT, [served], parked=parked) == [] + + +@pytest.mark.parametrize("value", [{}, [], "", 0, False, None]) +async def test_a_shared_head_hashes_the_body_the_embedding_digest_was_taken_from( + monkeypatch, value +): + import json + + from server.core.hashing import sha256_value + from server.memory.store import shared + + row = {"namespace": "n", "memory_key": "k", "value": json.dumps(value), "version": 1} + + async def rows(*a: Any, **k: Any) -> list[dict[str, Any]]: + return [row] + + monkeypatch.setattr(shared, "query_all_sliced", rows) + monkeypatch.setattr(shared, "_default_client", lambda: None) + heads = await shared.guidance_heads("o", [("n", "k")]) + assert heads[("n", "k")]["content_sha256"] == sha256_value(value) From 9f1135493d6d56aa4dda624e23325edd51ab7e68 Mon Sep 17 00:00:00 2001 From: Krishna Dobhal Date: Thu, 3 Dec 2026 02:08:23 +0530 Subject: [PATCH 117/117] A ranked preview's Conflicted badge reads its own status in every namespace The badge now matches the Conflicted filter, so another writer's conflict on the same key does not mark it. Signed-off-by: Krishna Dobhal --- frontend/src/views/Recent.search.test.tsx | 17 ++++++++++++++--- frontend/src/views/Recent.tsx | 10 +++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/Recent.search.test.tsx b/frontend/src/views/Recent.search.test.tsx index 5cfd336850e..7b5b60e677d 100644 --- a/frontend/src/views/Recent.search.test.tsx +++ b/frontend/src/views/Recent.search.test.tsx @@ -224,7 +224,7 @@ describe("Recent search with one key written by two sessions", () => { }); it("marks only the opened row active when two namespaces hold the same key, agent, user and session", async () => { - const home = written("one", { value: "home note" }); + const home = written("one", { value: "home note", status: "conflicted" }); const away = written("one", { value: "bob note", version: 2, version_text: "2" }); vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => ({ entries: opts?.contains ? [] : [(id as { namespace: string }).namespace === "bob" ? away : home], @@ -236,8 +236,7 @@ describe("Recent search with one key written by two sessions", () => { results: [ranked("one"), ranked("one", { namespace: "bob", version: 2, version_text: "2" })], embedding_model: "fake", } as never); - // The page's namespace holds a conflict under the key; bob's row of that key has none. - vi.mocked(conflictKeys).mockResolvedValue(["deploy_note"]); + // The page namespace's row is conflicted; bob's row of that key is not. useStore.setState({ myNamespaces: [row("alice", "admin"), row("bob", "writer")] }); await search(); @@ -250,6 +249,18 @@ describe("Recent search with one key written by two sessions", () => { expect(document.querySelectorAll("[data-active]")).toHaveLength(1); }); + it("judges a ranked preview by its own status when another writer in the namespace holds the conflict", async () => { + // Two writers hold the key in the page's namespace: session two's row is conflicted, + // session one's is not, and only session one is ranked. + feed(written("one"), written("two", { status: "conflicted" })); + vi.mocked(searchMemory).mockResolvedValue({ results: [ranked("one")], embedding_model: "fake" } as never); + vi.mocked(conflictKeys).mockResolvedValue(["deploy_note"]); + await search(); + + await screen.findByText("note of session one"); + expect(screen.queryByText("Conflicted")).toBeNull(); + }); + it("builds a foreign hit's bulk identity in its own namespace, and holds it to that namespace's role", async () => { const away = written("one", { value: "bob note", version: 2, version_text: "2" }); vi.mocked(listMemories).mockImplementation(async (id, _limit, opts) => ({ diff --git a/frontend/src/views/Recent.tsx b/frontend/src/views/Recent.tsx index 780e99809e2..7703812d3b8 100644 --- a/frontend/src/views/Recent.tsx +++ b/frontend/src/views/Recent.tsx @@ -1031,13 +1031,9 @@ function MemoryList() { >