diff --git a/docs/concepts/memory.md b/docs/concepts/memory.md index 19494eb8cc..586bd1058f 100644 --- a/docs/concepts/memory.md +++ b/docs/concepts/memory.md @@ -615,7 +615,8 @@ The links are read where the code is: the memories whose code moved, changed or went, with the same clause for a link now at another path or symbol. - `namespace.validate` lists memories whose code changed, was not found again or is - gone, in the repositories the caller may read. + gone, in the repositories the caller may read, and the edits that bring a memory's + text up to a rename its link followed. A memory with no link reads exactly as one whose code is current. `namespace.validate` counts the served memories that name code (a backticked or qualified name, a call, or @@ -634,6 +635,53 @@ linked, is not counted. How far each repository's links trail its index is a gauge, and a health warning when it lasts ([monitoring](../operations/monitoring.md#what-to-alert-on)). +A `moved` link is at its code, and the memory's text may still name the old definition or +path. `namespace.validate` lists each memory whose text does under the `info` finding +`code_rename_edits`, with either the `edits` its text allows (replace `old` with `new` +from `start` to `end`, counted in Unicode code points of the text, where the text reads +`old`) and the `content_sha256` they are of, or the one `reason` no edit is offered. The finding's `totals` count the memories by `edits` and by reason. Loom +writes nothing: to apply an edit, read the sentence it changes, then call `memory.update` +on the key with the revised text and `if_match_sha256` set to the listed hash. That is a +revision by the caller, with its conflict check, and it is refused when the memory changed +after the report read it. The link pass then links the revised memory where the code is. + +An edit is offered only for a name written as code (a whole backticked identifier, an +`A::b`, or a call written `a.b(` or `name()`) and for a whole repository path, in the +spelling the text uses: `Reader.get` becomes `Reader.fetch`, a full dotted name becomes the +full new one, and `self.get` keeps its receiver. The whole memory gets no edit for the +first of these reasons that applies: + +| Reason | The memory | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `not_text` | has a value that is not one string. | +| `link_not_settled` | has a link that is pending, `changed`, `unresolved` or `missing`, that its renamed class carried, or that is hashed under older fingerprint rules. | +| `incomplete` | names more code than the link caps keep. | +| `overloaded` | is linked to a definition the index numbers among several of one name. | +| `quoted_or_literal` | holds the old name or path in a fenced block, a URL, a quoted string or a backticked span that is more than one name. | +| `prose_occurrence` | writes the old name as a bare word of the prose. | +| `old_name_remains` | would still hold the old name or path where no edit reaches: a plain word, a part of a longer name, a longer name written as code that names no definition on the indexed trunk (`conn.read_rows()`), the dotted module the definition left (two segments or more) outside a name written as code that names a definition on the indexed trunk, a path before a line number, or a path whose file still exists. | +| `names_several` | writes one name that two of its links were written against. | +| `receiver_form` | writes the name as `self.name`, `cls.name` or `this.name`, and its `files` do not name the defining file. | +| `old_name_still_defined` | spells the old name in a way that still names a definition on the indexed trunk. | +| `new_name_present` | already holds the new name or path. | +| `dated_claim` | is dated (`valid_to`, `invalid_at` or `temporal_anchor`), or the sentence to edit holds a commit hash, a version tag, a year, a month (`May` only capitalised after another word), or a pull request or issue number. | +| `about_naming` | would be edited in a sentence about the name or the place: it holds `name`, `names`, `named`, `naming`, a word that starts with `renam` or `alias`, `called`, `formerly`, `used to`, `replaced`, `moved from`, `deprecated`, `legacy`, `before` or `previously`. | +| `named_in_key_or_tags` | holds the old name or path in its `memory_key` or a tag. | +| `named_in_files` | lists the old path in `files`, which `memory.update` keeps. | +| `would_unlink` | would lose a link once revised: the new name is not one definition on the indexed trunk, or the revised text no longer names a definition or file it is linked to. | + +A memory whose text names no old name or path is not listed, whatever its links, key, tags +and `files` say: its bare name still holds after a move, or the link is back where the text +says. A sentence ends after `.`, `!` or `?` and a space (not after a one-letter abbreviation +such as `e.g.`), at a blank line and before a list item; a line break alone does not end +one. The words that mark a sentence as +being about the name are English, and `call` or `calls` is not one: it is read as calling +the code. The finding reads the 2,000 memories whose `moved` link was last checked (all +under `keys` when given), in the repositories the caller may read, and no high-sensitivity +memory; a link whose code also changed is listed under `code_links_stale`. Neither the +memory's key, tags, `files`, entities and concepts nor a line number written in its text +is edited. + ## Time | Column | Axis | Meaning | diff --git a/docs/use-cases/memory-linked-to-code.md b/docs/use-cases/memory-linked-to-code.md index c67655eea6..2c887eb96b 100644 --- a/docs/use-cases/memory-linked-to-code.md +++ b/docs/use-cases/memory-linked-to-code.md @@ -86,6 +86,9 @@ reported commit](#check-a-lesson-after-a-code-edit). [`namespace.validate`](../reference/operations/namespace.md#namespacevalidate) lists the memories whose code changed, was not found again or is gone, and the dashboard shows each memory's links and their state. +- **The edit a rename allows.** After a rename or a move the link follows, the same report + lists the exact token edits that bring the memory's text up to date, or the reason it + offers none. [Bring a lesson's text up to a rename](#bring-a-lessons-text-up-to-a-rename) ![A memory's detail in the dashboard: its linked code, one definition current and one changed since a commit](../assets/screenshots/memory-linked-code.webp) @@ -150,6 +153,44 @@ tool selection are not tested. For removal, held-memory exceptions and model-backed revision, see the [link policies](../concepts/memory.md#memories-linked-to-code). +## Bring a lesson's text up to a rename + +When a definition is renamed or moved with nothing else changed, its link follows it and +reads `moved`. A lesson that wrote the old name, module or path still says it. Loom does +not rewrite it; `namespace.validate` lists what a rewrite would be: + +1. Call `namespace.validate` on the memory namespace (with `keys` to check the lessons + one session wrote) and read the `code_rename_edits` finding. Each sample is one lesson + with either `edits` and a `content_sha256`, or a `reason`. +2. For a lesson with `edits`, `start` and `end` count Unicode code points of its text (a + Python string index; not the UTF-16 units of a JavaScript string, nor bytes). Check + that the text from `start` to `end` reads `old`, and apply nothing when it does not: + the positions were counted in another unit. Then replace it with `new`, applying the + last edit first so the earlier positions hold. Read the edited sentence: an edit is + offered on the spelling and the index, and whether the claim survives the swap is + yours to judge. +3. Call `memory.update` on the key with the revised text and `if_match_sha256` set to the + sample's `content_sha256`. A lesson that changed since the report returns `409`; run + the report again. +4. After the next link pass the lesson is linked at the new name and reads `fresh`, and + the finding lists it no more. + +A lesson with a `reason` gets no edit: the old name is a word of the prose, sits in a +quoted snippet, still names another definition, or the sentence is about the name itself +([every reason](../concepts/memory.md#memories-linked-to-code)). Check it against the code +and rewrite it by hand. + +The finding's `totals` count a namespace's lessons by `edits` and by reason: how often a +mechanical edit is offered there, and what stops the rest. Applying the edits without a +person reading them is worth considering only for a namespace whose `totals` come from its +own lessons and where at least 100 listed edits were checked by hand against the lesson +text with none wrong. + +The `test_validate_lists_the_edit_a_followed_rename_allows_and_an_update_applies_it` +[integration regression](https://github.com/ClickHouse/loom/blob/main/tests/integration/test_memory_code_links.py) +renames a function, reads the listed edit, applies it with `memory.update` and checks the +link at the new name. + ## Compare a code-linked lesson across branches When trunk and a maintained release branch diverge, a lesson can still apply to one of diff --git a/sdk/python/loom/ops.py b/sdk/python/loom/ops.py index b1a67f48c1..09e9cc043c 100644 --- a/sdk/python/loom/ops.py +++ b/sdk/python/loom/ops.py @@ -18189,6 +18189,7 @@ class NamespaceValidateFinding(TypedDict, total=False): count: Required[int] samples: NotRequired[list[dict[str, Any]]] detail: Required[str] + totals: NotRequired[dict[str, int]] class ObserveCrystallizeInput(TypedDict, total=False): diff --git a/sdk/rust/src/wire_models.rs b/sdk/rust/src/wire_models.rs index db9f8890c2..891148d0ef 100644 --- a/sdk/rust/src/wire_models.rs +++ b/sdk/rust/src/wire_models.rs @@ -48936,6 +48936,8 @@ pub struct NamespaceValidateFinding { #[serde(default = "default_2167")] pub samples: Vec>, pub detail: String, + #[serde(default = "default_2168")] + pub totals: std::collections::HashMap, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] @@ -48948,9 +48950,9 @@ pub struct NamespaceValidateOutput { pub warnings: Integer, pub infos: Integer, pub findings: Vec, - #[serde(default = "default_2168")] - pub skipped: Vec, #[serde(default = "default_2169")] + pub skipped: Vec, + #[serde(default = "default_2170")] pub keys_scoped: Integer, pub coverage: ReportCoverage, pub checked_at: String, @@ -49070,9 +49072,9 @@ impl NamespaceValidateInput { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ObserveCrystallizeOutput { - #[serde(default = "default_2170")] - pub enqueued: Integer, #[serde(default = "default_2171")] + pub enqueued: Integer, + #[serde(default = "default_2172")] pub session_id: String, } @@ -49169,23 +49171,23 @@ impl ObserveCrystallizeInput { #[non_exhaustive] pub struct ObserveRecordOutput { pub memory_key: String, - #[serde(default = "default_2172")] - pub memory_id: String, #[serde(default = "default_2173")] - pub kind: String, + pub memory_id: String, #[serde(default = "default_2174")] - pub tags: Vec, + pub kind: String, #[serde(default = "default_2175")] - pub file_paths: Vec, + pub tags: Vec, #[serde(default = "default_2176")] - pub content_sha256: String, + pub file_paths: Vec, #[serde(default = "default_2177")] - pub tool_name: String, + pub content_sha256: String, #[serde(default = "default_2178")] - pub has_error: bool, + pub tool_name: String, #[serde(default = "default_2179")] - pub narrative_chars: Integer, + pub has_error: bool, #[serde(default = "default_2180")] + pub narrative_chars: Integer, + #[serde(default = "default_2181")] pub skipped_reason: String, } @@ -49384,26 +49386,26 @@ pub struct ProjectionFailureRow { pub failure_id: String, pub org: String, pub namespace: String, - #[serde(default = "default_2181")] + #[serde(default = "default_2182")] pub agent: String, pub projection: String, - #[serde(default = "default_2182")] - pub source_operation: String, #[serde(default = "default_2183")] - pub source_resource_id: String, + pub source_operation: String, #[serde(default = "default_2184")] - pub memory_keys: Vec, + pub source_resource_id: String, #[serde(default = "default_2185")] - pub error_type: String, + pub memory_keys: Vec, #[serde(default = "default_2186")] - pub error_message: String, + pub error_type: String, #[serde(default = "default_2187")] - pub payload: std::collections::HashMap, + pub error_message: String, #[serde(default = "default_2188")] - pub status: String, + pub payload: std::collections::HashMap, #[serde(default = "default_2189")] - pub created_at: Option, + pub status: String, #[serde(default = "default_2190")] + pub created_at: Option, + #[serde(default = "default_2191")] pub resolved_at: Option, } @@ -49557,22 +49559,22 @@ pub struct ProjectionFailureRetryRow { pub projection: String, pub retried: bool, pub resolved: bool, - #[serde(default = "default_2191")] - pub abandoned: bool, #[serde(default = "default_2192")] - pub reason: String, + pub abandoned: bool, #[serde(default = "default_2193")] + pub reason: String, + #[serde(default = "default_2194")] pub error: String, } #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] #[non_exhaustive] pub struct ProjectionFailureRetryOutput { - #[serde(default = "default_2194")] + #[serde(default = "default_2195")] pub results: Vec, pub retried: Integer, pub resolved: Integer, - #[serde(default = "default_2195")] + #[serde(default = "default_2196")] pub abandoned: Integer, } @@ -49654,15 +49656,15 @@ impl ProjectionFailureRetryInput { pub struct OrgModelCallsOutput { pub org: String, pub enabled: bool, - #[serde(default = "default_2196")] - pub reason: String, #[serde(default = "default_2197")] - pub updated_by: String, + pub reason: String, #[serde(default = "default_2198")] - pub updated_at: Option, + pub updated_by: String, #[serde(default = "default_2199")] - pub locked: bool, + pub updated_at: Option, #[serde(default = "default_2200")] + pub locked: bool, + #[serde(default = "default_2201")] pub locked_by: String, } @@ -50001,7 +50003,7 @@ impl PolicyDecisionsInput { #[non_exhaustive] pub struct PolicyDeleteOutput { pub removed: bool, - #[serde(default = "default_2201")] + #[serde(default = "default_2202")] pub widening: bool, } @@ -50067,12 +50069,12 @@ pub struct PolicyRuleOut { pub condition: std::collections::HashMap, pub description: String, pub enabled: bool, - #[serde(default = "default_2202")] + #[serde(default = "default_2203")] pub mode: String, pub created_by: String, - #[serde(default = "default_2203")] - pub created_at: Option, #[serde(default = "default_2204")] + pub created_at: Option, + #[serde(default = "default_2205")] pub updated_at: Option, } @@ -50144,9 +50146,9 @@ impl PolicyListInput { pub struct PolicySetOutput { pub rule: PolicyRuleOut, pub leaf_count: Integer, - #[serde(default = "default_2205")] - pub widening: bool, #[serde(default = "default_2206")] + pub widening: bool, + #[serde(default = "default_2207")] pub change: Vec, } @@ -50416,37 +50418,37 @@ pub struct ProcedureEvolveOutput { pub revision: Integer, pub changed: bool, pub template: bool, - #[serde(default = "default_2207")] - pub folded_runs: Integer, #[serde(default = "default_2208")] - pub gate: ProcedureEvolveOutputGate, + pub folded_runs: Integer, #[serde(default = "default_2209")] - pub gate_mode: String, + pub gate: ProcedureEvolveOutputGate, #[serde(default = "default_2210")] - pub gate_llr: f64, + pub gate_mode: String, #[serde(default = "default_2211")] - pub gate_before: std::collections::HashMap, + pub gate_llr: f64, #[serde(default = "default_2212")] - pub gate_after: std::collections::HashMap, + pub gate_before: std::collections::HashMap, #[serde(default = "default_2213")] - pub gate_cost_before: std::collections::HashMap, + pub gate_after: std::collections::HashMap, #[serde(default = "default_2214")] - pub gate_cost_after: std::collections::HashMap, + pub gate_cost_before: std::collections::HashMap, #[serde(default = "default_2215")] - pub gate_reason: String, + pub gate_cost_after: std::collections::HashMap, #[serde(default = "default_2216")] - pub dead_end_steps: Vec, + pub gate_reason: String, #[serde(default = "default_2217")] - pub fail_prone_steps: Vec, + pub dead_end_steps: Vec, #[serde(default = "default_2218")] - pub fail_prone_transitions: Vec, + pub fail_prone_steps: Vec, #[serde(default = "default_2219")] - pub run_stats: std::collections::HashMap, + pub fail_prone_transitions: Vec, #[serde(default = "default_2220")] - pub strikes: Integer, + pub run_stats: std::collections::HashMap, #[serde(default = "default_2221")] - pub quarantined: bool, + pub strikes: Integer, #[serde(default = "default_2222")] + pub quarantined: bool, + #[serde(default = "default_2223")] pub retention: std::collections::HashMap, } @@ -50669,9 +50671,9 @@ pub struct ProcedureForkOutput { pub memory_key: String, pub version: Integer, pub name: String, - #[serde(default = "default_2223")] - pub steps: Vec, #[serde(default = "default_2224")] + pub steps: Vec, + #[serde(default = "default_2225")] pub forked_from: std::collections::HashMap, } @@ -50931,32 +50933,32 @@ pub enum ProcedureLocateOutputStatus { #[non_exhaustive] pub struct ProcedureLocateOutput { pub memory_key: String, - #[serde(default = "default_2225")] - pub name: String, #[serde(default = "default_2226")] + pub name: String, + #[serde(default = "default_2227")] pub status: ProcedureLocateOutputStatus, pub matched: bool, - #[serde(default = "default_2227")] - pub active: Option>, #[serde(default = "default_2228")] - pub hops: Vec>>, + pub active: Option>, #[serde(default = "default_2229")] - pub entry_nodes: Vec, + pub hops: Vec>>, #[serde(default = "default_2230")] - pub dominant_next: Vec, + pub entry_nodes: Vec, #[serde(default = "default_2231")] - pub revisits: std::collections::HashMap, + pub dominant_next: Vec, #[serde(default = "default_2232")] - pub looping: bool, + pub revisits: std::collections::HashMap, #[serde(default = "default_2233")] - pub exits: Vec, + pub looping: bool, #[serde(default = "default_2234")] - pub failure_notes: Vec>, + pub exits: Vec, #[serde(default = "default_2235")] - pub rendered: String, + pub failure_notes: Vec>, #[serde(default = "default_2236")] - pub run_stats: std::collections::HashMap, + pub rendered: String, #[serde(default = "default_2237")] + pub run_stats: std::collections::HashMap, + #[serde(default = "default_2238")] pub for_agent: std::collections::HashMap, } @@ -51111,43 +51113,43 @@ pub struct ProcedureMatch { 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, } @@ -51155,11 +51157,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, } @@ -51540,7 +51542,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, } @@ -51652,14 +51654,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, } @@ -51767,17 +51769,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, } @@ -51886,7 +51888,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, } @@ -52271,17 +52273,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, } @@ -52398,13 +52400,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, } @@ -52557,10 +52559,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, } @@ -52768,29 +52770,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, } @@ -53311,25 +53313,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, } @@ -53396,17 +53398,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, } @@ -53521,7 +53523,7 @@ impl RunGradeInput { #[non_exhaustive] pub struct RunListOutput { pub runs: Vec, - #[serde(default = "default_2308")] + #[serde(default = "default_2309")] pub total: Option, } @@ -53798,39 +53800,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, } @@ -54023,7 +54025,7 @@ impl SearchInput { pub struct SessionBriefDeleteOutput { pub deleted: bool, pub brief_key: String, - #[serde(default = "default_2321")] + #[serde(default = "default_2322")] pub revision: Integer, } @@ -54116,67 +54118,67 @@ 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: String, + #[serde(default = "default_2348")] pub client_summary_at: String, } @@ -54184,45 +54186,45 @@ pub struct BriefSections { #[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, } @@ -54397,34 +54399,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, } @@ -54564,25 +54566,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, } @@ -54592,13 +54594,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, } @@ -55343,39 +55345,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, @@ -55386,7 +55388,7 @@ pub struct TaskPayload { #[non_exhaustive] pub struct TaskOutput { pub task: TaskPayload, - #[serde(default = "default_2405")] + #[serde(default = "default_2406")] pub seq: Integer, } @@ -55787,10 +55789,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, } @@ -55877,7 +55879,7 @@ pub struct TaskCreateOutput { pub task: TaskPayload, pub created: bool, pub seq: Integer, - #[serde(default = "default_2408")] + #[serde(default = "default_2409")] pub next: String, } @@ -56216,7 +56218,7 @@ impl TaskFailInput { #[non_exhaustive] pub struct TaskGetOutput { pub found: bool, - #[serde(default = "default_2409")] + #[serde(default = "default_2410")] pub task: Option, } @@ -56350,23 +56352,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, } @@ -56706,7 +56708,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, } @@ -57102,7 +57104,7 @@ impl TaskUnblockInput { pub struct TaskUpdateOutput { pub task: TaskPayload, pub seq: Integer, - #[serde(default = "default_2420")] + #[serde(default = "default_2421")] pub conflict: bool, } @@ -57465,19 +57467,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, } @@ -57573,17 +57575,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, } @@ -57636,13 +57638,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, } @@ -57703,9 +57705,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, } @@ -57758,66 +57760,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>, } @@ -58024,17 +58026,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>, } @@ -58117,9 +58119,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, } @@ -58168,19 +58170,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, } @@ -58278,11 +58280,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, } @@ -58331,17 +58333,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, } @@ -58462,19 +58464,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, } @@ -58637,13 +58639,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, } @@ -58682,12 +58684,12 @@ impl TrackerSourceCheckInput { #[non_exhaustive] pub struct TrackerSourceInspectOutput { pub host: String, - pub database: String, - #[serde(default = "default_2503")] - pub tables: Vec>, + pub database: String, #[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, } @@ -58816,9 +58818,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, } @@ -58871,9 +58873,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, } @@ -58914,9 +58916,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, } @@ -58963,11 +58965,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, } @@ -59034,45 +59036,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, } @@ -59176,9 +59178,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, } @@ -59362,7 +59364,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, } @@ -59484,14 +59486,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, } @@ -59673,7 +59675,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, } @@ -59897,15 +59899,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, } @@ -60016,7 +60018,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, } @@ -60024,7 +60026,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, @@ -66911,17 +66913,17 @@ fn default_2166() -> String { fn default_2167() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2168() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2168() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") } -fn default_2169() -> Integer { - serde_json::from_str("0").expect("schema default") +fn default_2169() -> Vec { + 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") +fn default_2171() -> Integer { + serde_json::from_str("0").expect("schema default") } fn default_2172() -> String { serde_json::from_str("\"\"").expect("schema default") @@ -66929,27 +66931,27 @@ fn default_2172() -> String { fn default_2173() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2174() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2174() -> 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_2176() -> Vec { + serde_json::from_str("[]").expect("schema default") } fn default_2177() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2178() -> bool { +fn default_2178() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2179() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2179() -> Integer { +fn default_2180() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2180() -> String { - serde_json::from_str("\"\"").expect("schema default") -} fn default_2181() -> String { serde_json::from_str("\"\"").expect("schema default") } @@ -66959,104 +66961,104 @@ fn default_2182() -> String { fn default_2183() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2184() -> Vec { +fn default_2184() -> String { + serde_json::from_str("\"\"").expect("schema default") +} +fn default_2185() -> Vec { 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() -> String { +fn default_2187() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2187() -> std::collections::HashMap { +fn default_2188() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2188() -> String { +fn default_2189() -> String { serde_json::from_str("\"active\"").expect("schema default") } -fn default_2189() -> Option { +fn default_2190() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2190() -> Option { +fn default_2191() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2191() -> bool { +fn default_2192() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2192() -> String { +fn default_2193() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2193() -> String { +fn default_2194() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2194() -> Vec { +fn default_2195() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2195() -> Integer { +fn default_2196() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2196() -> String { +fn default_2197() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2197() -> String { +fn default_2198() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2198() -> Option { +fn default_2199() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2199() -> bool { +fn default_2200() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2200() -> String { +fn default_2201() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2201() -> bool { +fn default_2202() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2202() -> String { +fn default_2203() -> String { serde_json::from_str("\"inherit\"").expect("schema default") } -fn default_2203() -> Option { +fn default_2204() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2204() -> Option { +fn default_2205() -> Option { serde_json::from_str("null").expect("schema default") } -fn default_2205() -> bool { +fn default_2206() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2206() -> Vec { +fn default_2207() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2207() -> Integer { +fn default_2208() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2208() -> ProcedureEvolveOutputGate { +fn default_2209() -> ProcedureEvolveOutputGate { serde_json::from_str("\"none\"").expect("schema default") } -fn default_2209() -> String { +fn default_2210() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2210() -> f64 { +fn default_2211() -> f64 { serde_json::from_str("0.0").expect("schema default") } -fn default_2211() -> std::collections::HashMap { - serde_json::from_str("{}").expect("schema default") -} fn default_2212() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2213() -> std::collections::HashMap { +fn default_2213() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } fn default_2214() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2215() -> String { - serde_json::from_str("\"\"").expect("schema default") +fn default_2215() -> std::collections::HashMap { + serde_json::from_str("{}").expect("schema default") } -fn default_2216() -> Vec { - serde_json::from_str("[]").expect("schema default") +fn default_2216() -> String { + serde_json::from_str("\"\"").expect("schema default") } fn default_2217() -> Vec { serde_json::from_str("[]").expect("schema default") @@ -67064,134 +67066,134 @@ fn default_2217() -> Vec { fn default_2218() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2219() -> std::collections::HashMap { +fn default_2219() -> Vec { + serde_json::from_str("[]").expect("schema default") +} +fn default_2220() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2220() -> Integer { +fn default_2221() -> Integer { serde_json::from_str("0").expect("schema default") } -fn default_2221() -> bool { +fn default_2222() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2222() -> std::collections::HashMap { +fn default_2223() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2223() -> Vec { +fn default_2224() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2224() -> std::collections::HashMap { +fn default_2225() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2225() -> String { +fn default_2226() -> String { serde_json::from_str("\"\"").expect("schema default") } -fn default_2226() -> ProcedureLocateOutputStatus { +fn default_2227() -> ProcedureLocateOutputStatus { serde_json::from_str("\"authored\"").expect("schema default") } -fn default_2227() -> Option> { +fn default_2228() -> Option> { serde_json::from_str("null").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() -> Vec { +fn default_2231() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2231() -> std::collections::HashMap { +fn default_2232() -> std::collections::HashMap { serde_json::from_str("{}").expect("schema default") } -fn default_2232() -> bool { +fn default_2233() -> bool { serde_json::from_str("false").expect("schema default") } -fn default_2233() -> Vec { +fn default_2234() -> Vec { serde_json::from_str("[]").expect("schema default") } -fn default_2234() -> Vec> { +fn default_2235() -> Vec> { serde_json::from_str("[]").expect("schema default") } -fn default_2235() -> String { +fn default_2236() -> String { 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() -> std::collections::HashMap { +fn default_2238() -> std::collections::HashMap { serde_json::from_str("{}").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") @@ -67202,101 +67204,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") @@ -67304,57 +67306,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") } @@ -67364,24 +67366,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") } @@ -67403,60 +67405,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") } @@ -67472,15 +67474,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") } @@ -67493,11 +67495,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") @@ -67517,21 +67519,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") } @@ -67541,8 +67543,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") @@ -67556,32 +67558,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") @@ -67589,57 +67591,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") } @@ -67649,327 +67651,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") } @@ -67979,18 +67981,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") } @@ -68000,54 +68002,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/typescript/src/generated/ops.ts b/sdk/typescript/src/generated/ops.ts index c48498b848..a52cbb0f31 100644 --- a/sdk/typescript/src/generated/ops.ts +++ b/sdk/typescript/src/generated/ops.ts @@ -8705,6 +8705,7 @@ export interface NamespaceValidateFinding { count: number; samples?: Array>; detail: string; + totals?: Record; } export interface NamespaceValidateOutput { diff --git a/server/code/app/memory_links.py b/server/code/app/memory_links.py index 853c0c47b5..8d242b45a9 100644 --- a/server/code/app/memory_links.py +++ b/server/code/app/memory_links.py @@ -10,6 +10,7 @@ import logging from collections.abc import Sequence from dataclasses import dataclass +from itertools import batched from typing import Any from server.code.app.index import gitrepo, mirrors @@ -409,11 +410,14 @@ async def live_paths(org: str, namespace: str, refs: list[str]) -> dict[str, str """ref -> the live path it names: itself when indexed, else the one live path whose basename it is. Unresolved or ambiguous refs are absent.""" repo = CodeRepo() - present = await repo.live_paths_present(org, namespace, refs) - out = {r: r for r in refs if r in present} - bare = [r for r in refs if r not in out and "/" not in r] - named = await repo.live_paths_by_basename(org, namespace, bare) if bare else {} - out.update((r, paths[0]) for r, paths in named.items() if len(paths) == 1) + out: dict[str, str] = {} + # the store answers for at most 500 paths of one read + for some in batched(sorted(set(refs)), 500): + present = await repo.live_paths_present(org, namespace, list(some)) + out.update((r, r) for r in some if r in present) + bare = [r for r in some if r not in present and "/" not in r] + named = await repo.live_paths_by_basename(org, namespace, bare) if bare else {} + out.update((r, paths[0]) for r, paths in named.items() if len(paths) == 1) return out diff --git a/server/code/domain/anchor.py b/server/code/domain/anchor.py index e183637530..3e5e6f52dc 100644 --- a/server/code/domain/anchor.py +++ b/server/code/domain/anchor.py @@ -205,6 +205,85 @@ def mentions(text: str, *, cap: int = 16) -> list[Mention]: return [Mention(name, in_prose) for name, in_prose in list(out.items())[:cap]] +class Span(NamedTuple): + """A name written as code: where it is in the text and how it is spelled, without + the `self.`, `cls.` or `this.` before it (`receiver`, '' when it has none).""" + + start: int + end: int + name: str + receiver: str = "" + + +# what quotes code and names none: a fenced block (an unclosed one runs to the end), a +# URL, a quoted string (an apostrophe inside a word opens none) +_FENCED = re.compile(r"^[ \t]*(```|~~~)[^\n]*\n.*?(?:^[ \t]*\1[^\n]*$|\Z)", re.M | re.S) +_URL = re.compile(r"(? bool: + """What is written from `start` to `end` is a part of something longer: a path, a + flag, a URL fragment, an assignment, a file name.""" + before = text[start - 1] if start else " " + after = text[end] if end < len(text) else " " + return before in _JOINS_BEFORE or after in _JOINS_AFTER or bool(_FILE_SUFFIX.match(text, end)) + + +def code_spans(text: str) -> tuple[list[Span], list[tuple[int, int]]]: + """The names `text` writes as code, in text order, and the spans that quote code + without naming any. A name is a whole backticked identifier (`` `Reader.get` ``, + `` `load_rows()` ``), an `A::b`, or a call written `a.b(` or `f()`; never a word + of the prose, which `mentions` reads and a rewrite may not. Quoted are a fenced + block, a URL, a quoted string and a backticked span that is more than one name. A + name joined to something longer (`--load_rows`, `load_rows.py`, `x=Reader::get`) + is neither.""" + quoted: list[tuple[int, int]] = [] + found: list[Span] = [] + + def blank(m: re.Match[str]) -> str: + quoted.append(m.span()) + return re.sub(r"[^\n]", " ", m[0]) + + def ticked(m: re.Match[str]) -> str: + name = _TICKED_NAME.fullmatch(m[1]) + if name is None: + return blank(m) + if not _joined(m.string, m.start(), m.end()): + found.append(_span(m.start(1) + name.start(1), name[1])) + return " " * len(m[0]) + + masked = _mask_pytest_nodes(text or "") + for rx in (_FENCED, _URL, _QUOTED): + masked = rx.sub(blank, masked) + masked = _TICKED.sub(ticked, masked) + for rx in (_QUALIFIED, _DOTTED_CALL, _EMPTY_CALL): + found.extend( + _span(m.start(), m[0]) for m in rx.finditer(masked) if not _joined(masked, *m.span()) + ) + return sorted(found), sorted(quoted) + + +def _span(start: int, spelled: str) -> Span: + """The span of a name spelled `spelled` at `start`, its receiver apart.""" + name = _RECEIVER.sub("", spelled) + receiver = spelled[: len(spelled) - len(name)] + return Span(start + len(receiver), start + len(spelled), name, receiver) + + +def code_shaped(word: str) -> bool: + """`word` alone is a name `mentions` reads in prose: camelCase, PascalCase or + snake_case.""" + return bool(_CAMEL.fullmatch(word) or _SNAKE.fullmatch(word)) + + def names_symbol(mention: str, qualified_name: str, path: str) -> bool: """`mention` is the qualified name or a `::`- / `.`-separated suffix of it.""" m, q = mention.replace("::", "."), qualified_name.replace("::", ".") diff --git a/server/identity/api/models_namespace_catalog.py b/server/identity/api/models_namespace_catalog.py index 249fc84df5..89a51d48e4 100644 --- a/server/identity/api/models_namespace_catalog.py +++ b/server/identity/api/models_namespace_catalog.py @@ -284,6 +284,9 @@ class _NamespaceValidateFinding(FindingContract): samples: list[dict[str, Any]] = Field(default_factory=list) # One sentence: what the check means and what to do about a hit. detail: str + # `count` by the check's own classes, for a check that names them in its `detail` + # (`code_rename_edits`: `edits`, or the reason no edit is offered); empty otherwise. + totals: dict[str, int] = Field(default_factory=dict) class NamespaceValidateOutput(BaseModel): diff --git a/server/identity/app/namespace_validate.py b/server/identity/app/namespace_validate.py index 3ae5a0883a..312ecb6b08 100644 --- a/server/identity/app/namespace_validate.py +++ b/server/identity/app/namespace_validate.py @@ -6,7 +6,7 @@ handler is that call: the same class of invariants, scoped to one (org, namespace), returned with samples the caller can act on. -Eighteen checks, each a read over existing tables (the four `code_unlinked_*` share +Nineteen checks, each a read over existing tables (the four `code_unlinked_*` share one). No mutation, no new storage. A check that fails to run is reported in `skipped` and the rest still return — the report closes a task, it must never fail one. Under Postgres the checks start once ClickHouse holds what the namespace committed @@ -33,6 +33,7 @@ import asyncio import functools import logging +from collections import Counter from collections.abc import Awaitable, Callable from typing import Any @@ -401,6 +402,23 @@ "A memory that still holds after its code changed is counted until someone checks it." ), ), + # Its predicate is the planner's (`code_rename.plan`) and the names the link pass + # reads as code (`anchor.code_spans`): a change to either raises this version. + "code_rename_edits": RuleContract( + "usage_heuristic", + 1, + exceptions=( + f"Only the {code_unlinked.SCANNED} memories whose `moved` link was last checked " + "are read (all under `keys` when given), only in repositories the caller may " + "read, and no high-sensitivity memory. A link whose code also changed is " + "`code_links_stale`'s." + ), + uncertainty=( + "An edit is offered on the spelling and the index alone: whether the sentence " + "still holds once the name is swapped is for whoever applies it to read. The " + "words that mark a sentence as being about the name are English." + ), + ), "code_unlinked_no_repository": RuleContract( "usage_heuristic", 1, @@ -482,6 +500,40 @@ async def _code_links_stale(params: dict[str, Any]) -> list[dict[str, Any]]: ] +# Planned by the code links rather than with SQL: the same links, and the index, decide +# which name may be swapped. +_CODE_RENAME_EDITS = ( + "info", + "A memory whose linked code was renamed or moved and followed there: the link is at " + "the new name or path and the memory's text still says the old one. Each sample " + "carries either `edits` (replace `old` with `new` at `start`..`end` of the text, " + "counted in Unicode code points; apply none unless that slice reads `old`) " + "with the `content_sha256` they are of, or the `reason` no edit is offered; `totals` " + "counts the memories by `edits` and by reason. Nothing is written: to apply, read " + "the edited sentence, then memory.update the key with the revised text and " + "`if_match_sha256` set to the sample's `content_sha256`. Only repositories you may " + "read are counted.", +) + + +class _RenameEdits: + """`code_rename_edits`'s rows in the shape the SQL checks give, and their totals by + outcome once they are read.""" + + def __init__(self, params: dict[str, Any]) -> None: + self.params = params + self.totals: dict[str, int] = {} + + async def rows(self) -> list[dict[str, Any]]: + from server.memory.app import code_renames + + params = self.params + found = await code_renames.planned(params["org"], params["ns"], params["keys"] or None) + counts = Counter(str(m.get("reason") or code_renames.OFFERED) for m in found) + self.totals = dict(sorted(counts.items())) + return [{"total": len(found), **m} for m in found[: params["lim"]]] + + # A served memory that names code and holds no link, by cause: a read shows it exactly # as one whose code is current. One read (`code_unlinked.unlinked`) answers the four. _CODE_UNLINKED: dict[str, tuple[str, str]] = { @@ -568,6 +620,7 @@ async def run( severity: str, detail: str, query: Callable[[], Awaitable[list[dict[str, Any]]]], + totals: Callable[[], dict[str, int]] = dict, ) -> None: try: rows = await query() @@ -592,6 +645,7 @@ async def run( samples_complete=total <= len(samples), exceptions=rule.exceptions, uncertainty=rule.uncertainty, + totals=totals(), ) ) @@ -599,6 +653,8 @@ async def run( for name, (severity, detail, sql) in _CHECKS.items(): await run(name, severity, detail, functools.partial(ch.query_all, sql, params=params)) await run("code_links_stale", *_CODE_LINKS_STALE, functools.partial(_code_links_stale, params)) + renames = _RenameEdits(params) + await run("code_rename_edits", *_CODE_RENAME_EDITS, renames.rows, lambda: renames.totals) unlinked = _code_unlinked(params) for name, (cause, detail) in _CODE_UNLINKED.items(): await run(name, "info", detail, functools.partial(unlinked, cause)) diff --git a/server/memory/app/code_link_reads.py b/server/memory/app/code_link_reads.py index 051055e2e6..f6310e0567 100644 --- a/server/memory/app/code_link_reads.py +++ b/server/memory/app/code_link_reads.py @@ -81,14 +81,23 @@ async def current_links(org: str, links: list[LinkRow]) -> list[LinkRow]: return [a for h in heads for a in current(org, h, by_mid.get(str(h["mid"]), []))] +# the states of a link whose code is not what its memory was written against +STALE = ("changed", "unresolved", "missing") + + async def stale_links( - org: str, namespace: str, keys: Sequence[str] | None = None, *, limit: int + org: str, + namespace: str, + keys: Sequence[str] | None = None, + *, + limit: int, + states: Sequence[str] = STALE, ) -> list[dict[str, Any]]: - """Up to `limit` of the namespace's changed, unresolved and missing links into - repositories the caller may read, of its served memories (those under `keys` when - given) as they are now, one per memory, newest check first; each with its memory_key, - memory_id, code_namespace, path, qualified_name, state, changed_since, checked_at and - `total`, the number of memories they are of.""" + """Up to `limit` of the namespace's links in `states` (changed, unresolved and + missing unless given) into repositories the caller may read, of its served memories + (those under `keys` when given) as they are now, one per memory, newest check first; + each with its memory_key, memory_id, code_namespace, path, qualified_name, state, + changed_since, checked_at and `total`, the number of memories they are of.""" trunk = code.trunk_namespace(org, namespace) tagged = [] if trunk else _tag_namespaces(org) seen = await readable_namespaces(org, {trunk, *(cns for _, cns in tagged)} - {""}) @@ -97,7 +106,7 @@ async def stale_links( return await store.stale_of_served( org, namespace, - ["changed", "unresolved", "missing"], + list(states), memory_keys=keys, trunk=trunk, tag_namespaces=tagged, diff --git a/server/memory/app/code_renames.py b/server/memory/app/code_renames.py new file mode 100644 index 0000000000..701b564c5d --- /dev/null +++ b/server/memory/app/code_renames.py @@ -0,0 +1,121 @@ +"""The edits that bring a namespace's memories up to renames their links followed, for +namespace.validate. + +A link in state `moved` is at its code, and its memory's text may still name the old +definition or path. This reads each such memory, its links and the index at the head, +and plans its edits (`server.memory.domain.code_rename`): the old and new token with +their positions and the hash to apply them against, or the one reason none is offered. +A memory whose text names nothing old is not listed. +Nothing is written: a principal applies an edit with memory.update and +`if_match_sha256`. +""" + +from __future__ import annotations + +import asyncio +from collections import defaultdict +from collections.abc import Sequence +from typing import Any + +from server.code.app import memory_links as code +from server.code.domain.anchor import Definition, bare_name, mentions +from server.code.domain.declaration import fingerprint_version +from server.memory.app import code_link_pass as link_pass +from server.memory.app import code_link_reads +from server.memory.app.code_unlinked import SCANNED +from server.memory.domain import code_rename +from server.memory.store import code_links as store +from server.memory.store.code_links import LinkRow + +# What `planned` counts a memory under when it offers edits; else under its reason. +OFFERED = "edits" + +# A memory to plan: its head and the links made from it as it is now. +_Linked = tuple[dict[str, Any], list[LinkRow]] +# What the index says of one repository: its definitions under their bare names, and +# the old paths its head no longer has. +_Index = tuple[dict[str, list[Definition]], set[str]] + + +async def planned( + org: str, namespace: str, keys: Sequence[str] | None = None +) -> list[dict[str, Any]]: + """One row per served memory of the namespace (under `keys` when given) that holds + a `moved` link into a repository the caller may read and whose text names an old + name or path, the newest checked first, of the `SCANNED` newest: its memory_key and + memory_id, and either its `edits` (each a `start`, `end`, `old` and `new` over the + text) with the `content_sha256` they are of, or the `reason` it gets none + (`code_rename.REASONS` but `UNNAMED`). A high-sensitivity memory is not read: an + edit quotes its text.""" + moved = await code_link_reads.stale_links( + org, namespace, keys, limit=SCANNED, states=("moved",) + ) + if not moved: + return [] + ids = [str(a["memory_id"]) for a in moved] + readable = {str(a["code_namespace"]) for a in moved} + heads, rows = await asyncio.gather(store.memory_heads(org, ids), store.for_memories(org, ids)) + by_memory: dict[str, list[LinkRow]] = defaultdict(list) + for a in rows: + if a["code_namespace"] in readable: + by_memory[a["memory_id"]].append(a) + read = {str(h["mid"]): h for h in heads if _quotable(h)} + memories: list[_Linked] = [] + for mid in ids: + links = code_link_reads.current(org, read[mid], by_memory[mid]) if mid in read else [] + if any(a["state"] == "moved" for a in links): + memories.append((read[mid], links)) + # reading names and planning are CPU work: off the loop + wanted = await asyncio.to_thread(_wanted, memories) + index: dict[str, _Index] = {} + for cns, (names, paths) in wanted.items(): + by_name: dict[str, list[Definition]] = defaultdict(list) + for d in await code.candidates(org, cns, names=sorted(names)): + by_name[d.name].append(d) + live = await code.live_paths(org, cns, sorted(paths)) + index[cns] = by_name, {p for p in paths if live.get(p) != p} + return await asyncio.to_thread(_rows, memories, index) + + +def _quotable(head: dict[str, Any]) -> bool: + """A served memory whose text a report may quote.""" + return ( + head["status"] in code_link_reads.SERVED + and head.get("tombstoned_at") is None + and head.get("sensitivity") != "high" + ) + + +def _wanted(memories: Sequence[_Linked]) -> dict[str, tuple[set[str], set[str]]]: + """Code namespace -> what a plan reads of its index: the bare names its memories + mention or are linked to, and the paths their links were written against.""" + out: dict[str, tuple[set[str], set[str]]] = defaultdict(lambda: (set(), set())) + for head, links in memories: + names, paths = out[links[0]["code_namespace"]] + text = link_pass.claim_of(head["value"]) or "" + names.update(bare_name(m.name) for m in mentions(text, cap=len(text))) + for a in links: + was_path, was_name = code_rename.written_as(a) + names.update(bare_name(n) for n in (was_name, a["qualified_name"]) if n) + paths.add(was_path) + return out + + +def _rows(memories: Sequence[_Linked], index: dict[str, _Index]) -> list[dict[str, Any]]: + rules = fingerprint_version() + out: list[dict[str, Any]] = [] + for head, links in memories: + by_name, gone = index[links[0]["code_namespace"]] + plan = code_rename.plan( + link_pass.claim_of(head["value"]), head, links, by_name, gone=gone, rules=rules + ) + if plan.reason == code_rename.UNNAMED: + continue # its text holds as it is + row: dict[str, Any] = {"memory_key": str(head["memory_key"]), "memory_id": str(head["mid"])} + if plan.reason: + row["reason"] = plan.reason + else: + row["edits"] = [e._asdict() for e in plan.edits] + row["content_sha256"] = plan.sha256 + out.append(row) + return out diff --git a/server/memory/domain/code_rename.py b/server/memory/domain/code_rename.py new file mode 100644 index 0000000000..a42d390ba4 --- /dev/null +++ b/server/memory/domain/code_rename.py @@ -0,0 +1,491 @@ +"""The edits that bring a memory's text up to a rename its link followed, or why none +is offered. + +A link that followed its definition to another name or file leaves the memory's text +naming the old one. Whether the name can be swapped in the text depends on how it is +spelled and on the sentence around it, not on the link: the same rename is unambiguous +as a full dotted name, ambiguous as a bare word another definition also bears, and +wrong in any spelling when the sentence is about the name, the place or a past state. +`plan` offers an edit only for a name written as code (`anchor.code_spans`) or a whole +path, and withholds the whole memory for the first of `REASONS` that applies. Nothing +here writes: a principal applies the edits with memory.update and `if_match_sha256`. +""" + +from __future__ import annotations + +import re +from collections.abc import Collection, Mapping, Sequence +from dataclasses import dataclass +from typing import Any, NamedTuple + +from server.code.domain.anchor import ( + Definition, + Span, + bare_name, + code_shaped, + code_spans, + local_name, + mentions, + names_symbol, + path_matches, + resolve, +) +from server.code.domain.python_names import import_forms +from server.core.hashing import served_content_sha256 + +# Why a memory gets no edit, in the order `plan` reports them: the first that applies. +REASONS = ( + "not_text", # its value is not one string + "link_not_settled", # a link is pending, changed, lost, or not on its baseline + "incomplete", # the caps cut its links: not all of its code is known + "overloaded", # an old or new name is one of several definitions under its name + "quoted_or_literal", # an old name or path sits in a fenced block, a URL, a quoted + # string or a longer backticked span + "prose_occurrence", # an old name is written as a word of the prose + "old_name_remains", # an old name or path stays where no edit reaches it + "names_several", # one written name is the old name of more than one link + "receiver_form", # `self.name`, and the memory's files do not name its file + "old_name_still_defined", # the name as written names a definition at the head + "new_name_present", # the text already holds the new name or path + "dated_claim", # the memory, or the sentence, is about a point in time + "about_naming", # the sentence is about the name or the place itself + "named_in_key_or_tags", # the memory_key or a tag holds an old name or path + "named_in_files", # `files` names the old path, which memory.update keeps + "would_unlink", # the revised memory would not link to all the code it links to now + "no_code_token", # the text names no old name or path: nothing to edit +) +# the reason of a memory whose text holds as it is +UNNAMED = REASONS[-1] +# the reasons the links, the labels and `files` give whatever the text says: they +# withhold only a text that names something old +_UNWRITTEN = frozenset({"link_not_settled", "incomplete", "named_in_key_or_tags", "named_in_files"}) + +# what makes a sentence a statement about a point in time: a commit, a version tag, a +# year, a month, a pull request or issue. `May` is the month only capitalised after +# another word: elsewhere it is the verb. +_DATED = re.compile( + r"\b(?=[0-9a-f]*\d)(?=[0-9a-f]*[a-f])[0-9a-f]{7,40}\b" + r"|\bv\d+(?:\.\d+)*\b|\b\d+\.\d+\.\d+\b" + r"|\b(?:19|20)\d\d\b" + r"|\b(?:january|february|march|april|june|july|august|september|october|november" + r"|december)\b|(?<=\w\s)(?-i:May)\b" + r"|#\d+\b|\b(?:pr|mr|gh)[- ]?\d+\b|\b(?:issue|pull request)s? \d+", + re.IGNORECASE, +) +# what makes a sentence a statement about the name or the place (English only). Not +# `call` or `calls`: far more often the code is called than named. +_NAMING = re.compile( + r"\b(?:nam(?:e|es|ed|ing)|renam\w+|called|alias\w*|formerly|used to|replaced" + r"|moved from|deprecated|legacy|before|previously)\b", + re.IGNORECASE, +) +# a sentence ends after `.`, `!` or `?` and a space (not after a one-letter abbreviation: +# `e.g.`, `i.e.`), at a blank line (`\r\n` ends a line too) and before a list item; a +# wrapped line goes on +_SENTENCE_END = re.compile( + r"(? tuple[str, str]: + """(path, qualified name) the memory's text was written against: the oldest + identity the link keeps, else its anchor. A definition link that replaced a file + link was never that file: only an identity of the link's own kind counts.""" + of_symbol = bool(link.get("qualified_name")) + former = [f for f in link.get("former") or [] if bool(f["name"]) == of_symbol] + if former: + return str(former[0]["path"]), str(former[0]["name"]) + return str(link.get("anchored_path") or ""), str(link.get("anchored_name") or "") + + +def revised(text: str, edits: Sequence[Edit]) -> str: + """`text` with `edits` applied.""" + out, at = [], 0 + for e in sorted(edits): + out += [text[at : e.start], e.new] + at = e.end + return "".join(out) + text[at:] + + +def plan( + text: str | None, + memory: Mapping[str, Any], + links: Sequence[Mapping[str, Any]], + by_name: Mapping[str, Sequence[Definition]], + *, + gone: Collection[str] = (), + rules: str, +) -> Plan: + """The edits that make `text` (a memory's value; None when it is not a string) name + its code where the code is now, or the reason none is offered. + + `memory` is its head (`files`, `memory_key`, `tags`, the columns that date it) and + `links` the links made from it as it is now. `by_name` holds the index's definitions + at the head under every bare name the text mentions and every new name; `gone` the + old paths the head no longer has; `rules` the fingerprint rules in force. Only a link + in state `moved` on its baseline is revised, and only when every link is settled: + applying an edit makes the link pass link the memory again from its new text.""" + if text is None: + return Plan(reason="not_text") + why: set[str] = set() + if not all(_settled(a, rules) for a in links): + why.add("link_not_settled") + if not all(a["complete"] for a in links): + why.add("incomplete") + files = [str(f) for f in memory.get("files") or []] + spans, quoted = code_spans(text) + edits: dict[tuple[int, int], Edit] = {} + moves = [m for a in links if a["state"] == "moved" and (m := _move(a))] + for m in moves: + alive = m.was_path not in gone + why |= _in_labels(memory, m, alive) + if m.name: + why |= _renamed(text, m, moves, spans, quoted, by_name, files, edits) + if m.was_path != m.path: + why |= _repathed(text, m, quoted, files, alive, edits) + why |= _old_modules(text, moves, list(edits), spans, quoted, by_name) + if edits: + why |= _about(text, memory, edits.values()) + why |= _unlinked(revised(text, list(edits.values())), links, by_name, files) + elif why <= _UNWRITTEN: + return Plan(reason=UNNAMED) + for reason in REASONS: + if reason in why: + return Plan(reason=reason) + return Plan(edits=tuple(sorted(edits.values())), sha256=served_content_sha256(text)) + + +def _settled(link: Mapping[str, Any], rules: str) -> bool: + """The link is at its code, on the text its memory was written against, hashed + under the rules in force.""" + return ( + link["state"] in ("fresh", "moved") + and not link["carried"] + and link["body_hash"] == link["checked_hash"] + and link["fingerprint_version"] == rules + ) + + +def _move(link: Mapping[str, Any]) -> _Move | None: + """Where `link` was written and where it is; None for one back where it was.""" + was, now = written_as(link), (str(link["path"]), str(link["qualified_name"])) + return _Move(*was, *now) if was[0] and was != now else None + + +def _forms(path: str, qualified_name: str) -> tuple[str, ...]: + """The dotted names a text may spell the definition by, the qualified name first.""" + dotted = qualified_name.replace("::", ".") + return tuple(dict.fromkeys((dotted, *import_forms(path, qualified_name.split("::"))))) + + +def _respelled(written: str, m: _Move) -> str: + """`written`, a spelling of the old name, as the same spelling of the new one, joined + as `written` joins it. A name written inside its module (`get`, `Reader.get`) keeps + as many segments. One written with its module names the whole new name inside the + new module, under as many module segments, and under the whole module when it wrote + the whole old one: a full dotted name stays one, also where no part of it is the + module (C and C++).""" + dotted = written.replace("::", ".") + old, new = _forms(m.was_path, m.was_name), _forms(m.path, m.name) + at = next((i for i, f in enumerate(old) if f == dotted or f.endswith("." + dotted)), 0) + was_local = local_name(m.was_name, m.was_path).split(".") + local = local_name(m.name, m.path).split(".") + joins = _JOIN.findall(written) + over = len(joins) + 1 - len(was_local) # the module segments it wrote + if dotted == old[0]: + parts = new[0].split(".") + elif over <= 0: + parts = local[-(len(joins) + 1) :] + else: + module = new[min(at, len(new) - 1)].split(".")[: -len(local)] + whole = over >= len(old[at].split(".")) - len(was_local) + parts = (module if whole else module[-over:]) + local + # its own joins, from the right; a longer name repeats its first + joins = joins[:1] * (len(parts) - 1 - len(joins)) + joins + joins = joins[len(joins) - (len(parts) - 1) :] + return parts[0] + "".join(j + p for j, p in zip(joins, parts[1:], strict=True)) + + +def _renamed( + text: str, + m: _Move, + moves: Sequence[_Move], + spans: Sequence[Span], + quoted: Sequence[tuple[int, int]], + by_name: Mapping[str, Sequence[Definition]], + files: Sequence[str], + edits: dict[tuple[int, int], Edit], +) -> set[str]: + """Add to `edits` the names in `text` that spell the old definition of `m` and not + the new one, each as the same spelling of the new one; the reasons they withhold.""" + was, now = _plain(m.was_name), _plain(m.name) + old, new = bare_name(was), bare_name(now) + mine = [ + s + for s in spans + if names_symbol(s.name, was, m.was_path) and not names_symbol(s.name, now, m.path) + ] + if (was, now) != (m.was_name, m.name): + # one of several under its name: withheld where the text writes the old one + return {"overloaded"} if mine or (old != new and _word(old).search(text)) else set() + why: set[str] = set() + for s in mine: + to = _respelled(s.name, m) + if s.receiver and not any(path_matches(p, f) for f in files for p in (m.was_path, m.path)): + why.add("receiver_form") + if _names_another(s.name, m, by_name): + why.add("old_name_still_defined") + at = resolve(to, by_name.get(new, ()), files) + if at is None or (at.path, at.qualified_name) != (m.path, m.name): + why.add("would_unlink") + if edits.setdefault((s.start, s.end), Edit(s.start, s.end, s.name, to)).new != to: + why.add("names_several") + # a move keeps the bare name valid: only the spellings it replaces may be left over + olds = [old] if old != new else sorted({s.name for s in mine}) + news = [new] if old != new else sorted({_respelled(s.name, m) for s in mine}) + # a name that ends in an old spelling holds as it is when it names another + # definition at the head, and is edited by the link whose old definition it names + others = [ + s + for s in spans + if _names_another(s.name, m, by_name) + or any(x != m and x.name and names_symbol(s.name, x.was_name, x.was_path) for x in moves) + ] + why |= _left_over(text, olds, [*mine, *others], spans, quoted) + if mine and any(_word(t).search(text) for t in news): + why.add("new_name_present") + return why + + +def _names_another(name: str, m: _Move, by_name: Mapping[str, Sequence[Definition]]) -> bool: + """`name` as written names a definition at the head other than the one `m` is at.""" + return any( + names_symbol(name, _plain(d.qualified_name), d.path) + for d in by_name.get(bare_name(name), ()) + if (d.path, d.qualified_name) != (m.path, m.name) + ) + + +def _plain(qualified_name: str) -> str: + """`qualified_name` without the index's ordinals: `Reader#2::get` is a `Reader::get`.""" + return _ORDINAL.sub("", qualified_name) + + +def _word(spelling: str) -> re.Pattern[str]: + return re.compile(rf"(? tuple[int, int] | None: + """The first of `regions` that holds start..end.""" + return next(((a, b) for a, b in regions if a <= start and end <= b), None) + + +def _left_over( + text: str, + olds: Sequence[str], + covered: Sequence[Span], + spans: Sequence[Span], + quoted: Sequence[tuple[int, int]], +) -> set[str]: + """Why an old spelling withholds the memory, unless it ends one of the `covered` + names: those an edit replaces and those that name other code.""" + why: set[str] = set() + for spelling in olds: + for o in _word(spelling).finditer(text): + if any(s.start <= o.start() and o.end() == s.end for s in covered): + continue + if _inside(quoted, *o.span()): + why.add("quoted_or_literal") + elif any(s.start <= o.start() and o.end() <= s.end for s in spans): + # `Reader.get` still holds the old `Reader`; `cfg.read_rows()` names nothing + why.add("old_name_remains") + else: + why.add("prose_occurrence" if code_shaped(spelling) else "old_name_remains") + return why + + +def _modules(path: str, qualified_name: str) -> set[str]: + """The dotted spellings of the module a definition is in: whole, and from each of + its segments on.""" + local = "." + local_name(qualified_name, path) + out: set[str] = set() + for form in _forms(path, qualified_name): + parts = form.removesuffix(local).split(".") if form.endswith(local) else [] + out.update(".".join(parts[i:]) for i in range(len(parts))) + return out + + +def _old_modules( + text: str, + moves: Sequence[_Move], + edited: Sequence[tuple[int, int]], + spans: Sequence[Span], + quoted: Sequence[tuple[int, int]], + by_name: Mapping[str, Sequence[Definition]], +) -> set[str]: + """Why a module a definition of `moves` left withholds the memory: `text` writes it, + over more than one segment, outside the `edited` spans (an import, a sentence about + the place), so the revised text would name both places. One segment is as often a + word of the prose, and a name written as code that names a definition at the head + (another one still in that module) holds as it is.""" + why: set[str] = set() + held = [ + (s.start, s.end) + for s in spans + if any( + names_symbol(s.name, _plain(d.qualified_name), d.path) + for d in by_name.get(bare_name(s.name), ()) + ) + ] + for m in moves: + left = _modules(m.was_path, m.was_name) - _modules(m.path, m.name) if m.name else set() + for module in (x for x in left if "." in x): + spelled = re.escape(module).replace(r"\.", r"(?:\.|::)") + for o in re.finditer(rf"(? set[str]: + """Add to `edits` the whole old path of `m` wherever `text` writes it, when the head + no longer has that file (`alive` False); the reasons its path withholds. A path in + a longer one, before a line number or in a test id, and the old file's bare name, + are left over; so is every one while the old file is still there, where the text + may be about the file.""" + why: set[str] = set() + whole = re.compile(rf"(? set[str]: + """`named_in_key_or_tags` when the memory's key or a tag (stored lowercased) holds + the old bare name of `m`, or its old path once the head no longer has that file + (`alive` False): an edit of the text leaves them.""" + labels = [str(memory.get("memory_key") or ""), *(str(t) for t in memory.get("tags") or [])] + old, new = bare_name(m.was_name), bare_name(m.name) + held = [] + if old and old != new: + held.append(re.compile(rf"(? str: + """The sentence of `text` that holds position `at`.""" + start = max((b.end() for b in _SENTENCE_END.finditer(text, 0, at)), default=0) + end = _SENTENCE_END.search(text, at) + return text[start : end.start() if end else len(text)] + + +def _about(text: str, memory: Mapping[str, Any], edits: Collection[Edit]) -> set[str]: + """The reasons the sentences `edits` change, or the memory's own dates, withhold + them: a claim about a point in time, or about the name itself, is right as it is.""" + why: set[str] = set() + if any(memory.get(column) for column in _DATES): + why.add("dated_claim") + # without the names themselves: a path under `v2/` dates nothing + rest = revised(text, [e._replace(new=" " * (e.end - e.start)) for e in edits]) + for sentence in {_sentence(rest, e.start) for e in edits}: + if _DATED.search(sentence): + why.add("dated_claim") + if _NAMING.search(sentence): + why.add("about_naming") + return why + + +def _unlinked( + text: str, + links: Sequence[Mapping[str, Any]], + by_name: Mapping[str, Sequence[Definition]], + files: Sequence[str], +) -> set[str]: + """`would_unlink` when `text` (the revised one) would not be linked to every + definition and file `links` are at: each name resolved as the link pass resolves it + (`anchor.resolve`), each file link named by `files`.""" + named = set() + for mention in mentions(text, cap=len(text)): + d = resolve( + mention.name, by_name.get(bare_name(mention.name), ()), files, in_prose=mention.in_prose + ) + if d is not None: + named.add((d.path, d.qualified_name)) + for a in links: + if a["qualified_name"]: + kept = (a["path"], a["qualified_name"]) in named + else: + kept = any(path_matches(a["path"], f) for f in files) + if not kept: + return {"would_unlink"} + return set() diff --git a/server/memory/store/code_links.py b/server/memory/store/code_links.py index fdae938c20..0f38b12fac 100644 --- a/server/memory/store/code_links.py +++ b/server/memory/store/code_links.py @@ -579,7 +579,8 @@ async def code_namespaces( toString(memory_id) AS mid, value, tags, files, toString(content_sha256) AS sha, CAST(status AS String) AS status, tombstoned_at, - pinned, lock_mode, lock_until, verified_by, verified_sha256, sensitivity + pinned, lock_mode, lock_until, verified_by, verified_sha256, sensitivity, + valid_to, invalid_at, temporal_anchor FROM loom.memory FINAL """ diff --git a/tests/analyzer/shapes.txt b/tests/analyzer/shapes.txt index 856558c536..7d97f253ae 100644 --- a/tests/analyzer/shapes.txt +++ b/tests/analyzer/shapes.txt @@ -2,7 +2,6 @@ # \t; sorted. Regenerate with # python -m tests.analyzer.corpus --write # and review the diff: a new line is a new statement shape. -001824490f23 SELECT org, namespace, agent, user_id, session_id, memory_key, actor, toString(memory_id) AS mid, value, tags, files, toString(content_sha256) AS sha, CAST(status AS String) AS status, tombstoned_at, 001eb6c5587e SELECT DISTINCT canonical_text FROM loom.entity_canonical_map FINAL WHERE org = {org:String} AND namespace IN {namespaces:Array(String)} AND mention_text IN {mentions:Array(String)} AND tombstoned_at 0028ff84bbed SELECT agent, user_id, session_id, memory_key FROM loom.memory FINAL WHERE org = {org:String} AND namespace = {ns:String} AND tombstoned_at IS NULL AND has(tags, {tag:String}) ORDER BY updated_at DESC 004f2544bc01 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 @@ -2248,6 +2247,7 @@ f7c04f2fe996 SELECT count() AS n FROM loom.document_blobs WHERE org = {org:Strin f8081de4841b 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 f833c025305d 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 f83401bb2bae SELECT * FROM loom.service_accounts FINAL WHERE org = {org:String} AND name = {name:String} AND (created_by IN {subs:Array(String)} OR hasAny(lineage, {subs:Array(String)})) AND revoked_at IS NULL AND +f83f4bc3fef2 SELECT org, namespace, agent, user_id, session_id, memory_key, actor, toString(memory_id) AS mid, value, tags, files, toString(content_sha256) AS sha, CAST(status AS String) AS status, tombstoned_at, f8544e732b91 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 f86ba4e3e00f SELECT conflict_threshold, duplicate_threshold, default_conflict_policy FROM loom.namespaces FINAL WHERE org = {org:String} AND namespace = {ns:String} LIMIT ? f86df7b89de1 SELECT chunk_id, path, cosineDistance(embedding, {q:Array(Float32)}) AS distance FROM loom.code_chunks FINAL WHERE org = {org:String} AND namespace = {ns:String} AND embedding_model = {model:String} A diff --git a/tests/integration/test_memory_code_links.py b/tests/integration/test_memory_code_links.py index 995f65d59b..21d26ddd36 100644 --- a/tests/integration/test_memory_code_links.py +++ b/tests/integration/test_memory_code_links.py @@ -1533,6 +1533,101 @@ async def stale_for(namespaces: tuple[str, ...]) -> Any: assert (memory_only.count, memory_only.samples) == (0, []) +async def test_validate_lists_the_edit_a_followed_rename_allows_and_an_update_applies_it( + env, +) -> None: + """After a rename the link follows, the memory's text still says the old name. The + report lists the edit its spelling allows, or why none is offered, and writes + nothing; memory.update with the listed hash applies it, the link pass links the + revised memory where the code is, and a caller who may not read the repository is + told nothing.""" + from fastapi import HTTPException + + from server.auth.context import set_current_auth + from server.auth.jwt import AuthInfo + from server.identity.api.models_namespace_catalog import NamespaceValidateInput + from server.identity.app.namespace_validate import handle_namespace_validate + from server.memory.api.models_crud import MemoryUpdateInput + from server.memory.app.update import handle_memory_update + from server.operations.base import Role + + repo = env + path = "src/widgets/io.py" + src = "def fetch_rows(conn, n):\n rows = conn.read(n)\n return [r for r in rows if r]\n" + c1 = repo.commit({path: src}) + await _index(TRUNK, repo, c1, [path]) + text = "`fetch_rows` drops empty rows" + mid = await _remember(MEM, "fetch-rows", text) + # a word of the prose links inside the memory's files, and is never edited + await _remember(MEM, "fetch-rows-prose", "fetch_rows drops empty rows", files=[path]) + await _pass() + c2 = repo.commit({path: src.replace("fetch_rows", "load_rows")}) + await _index(TRUNK, repo, c2, [path]) + await _pass() + + async def renames_for(namespaces: tuple[str, ...]) -> Any: + set_current_auth( + AuthInfo( + subject="it@example.com", + org=ORG, + namespaces=namespaces, + roles=(Role.VIEWER,), + is_service_account=False, + ) + ) + try: + report = await handle_namespace_validate(NamespaceValidateInput(org=ORG, namespace=MEM)) + finally: + set_current_auth(None) + return next(f for f in report.findings if f.check == "code_rename_edits") + + listed = await renames_for((MEM, TRUNK)) + assert listed.count == 2 and listed.totals == {"edits": 1, "prose_occurrence": 1} + by_key = {s["memory_key"]: s for s in listed.samples} + assert by_key["fetch-rows-prose"]["reason"] == "prose_occurrence" + offered = by_key["fetch-rows"] + assert offered["memory_id"] == mid + assert offered["edits"] == [{"start": 1, "end": 11, "old": "fetch_rows", "new": "load_rows"}] + # the listed hash is the one memory.get serves: the report cites the same revision + cited = {e.memory_key: e.content_sha256 for e in listed.evidence} + assert offered["content_sha256"] == cited["fetch-rows"] + # nothing was written + assert (await _row(mid)).value == text + hidden = await renames_for((MEM,)) + assert (hidden.count, hidden.samples, hidden.totals) == (0, [], {}) + + (edit,) = offered["edits"] + revised = text[: edit["start"]] + edit["new"] + text[edit["end"] :] + applied = await handle_memory_update( + MemoryUpdateInput( + org=ORG, + namespace=MEM, + memory_key="fetch-rows", + value=revised, + if_match_sha256=offered["content_sha256"], + ) + ) + assert applied.updated and (await _row(mid)).value == "`load_rows` drops empty rows" + # the same edit against the value it was planned from is refused once that is gone + with pytest.raises(HTTPException) as refused: + await handle_memory_update( + MemoryUpdateInput( + org=ORG, + namespace=MEM, + memory_key="fetch-rows", + value=revised, + if_match_sha256=offered["content_sha256"], + ) + ) + assert refused.value.status_code == 409 + await _pass() + (link,) = await _links(mid) + assert (link["symbol"].rsplit("::", 1)[-1], link["state"]) == ("load_rows", "fresh") + after = await renames_for((MEM, TRUNK)) + assert after.totals == {"prose_occurrence": 1} + assert [s["memory_key"] for s in after.samples] == ["fetch-rows-prose"] + + async def test_validate_counts_unlinked_code_memories_by_cause(env) -> None: """A memory that names code and holds no link reads as one whose code is current; the report counts each under why it has none, from the rows the pass stored and the diff --git a/tests/unit/test_code_anchor.py b/tests/unit/test_code_anchor.py index e973c50b19..228f610443 100644 --- a/tests/unit/test_code_anchor.py +++ b/tests/unit/test_code_anchor.py @@ -11,6 +11,7 @@ cited_fingerprint, cited_lines, cited_names, + code_spans, local_name, mentions, recheck, @@ -499,3 +500,83 @@ def test_a_go_package_renamed_in_place_keeps_the_link() -> None: here = [_d("pkg/x.go", "pkg.rows::B::Read", "h2")] after = recheck(link, path_now="pkg/x.go", here=here, head="c2") assert (after.state, after.qualified_name) == ("changed", "pkg.rows::B::Read") + + +def _spans(text: str) -> list[str]: + """Each name `text` writes as code, as the text spells it there.""" + return [text[s.start - len(s.receiver) : s.end] for s in code_spans(text)[0]] + + +def test_code_spans_are_the_names_written_as_code_where_they_are() -> None: + text = "`Reader.get` calls ns::load_rows, then cfg.read_rows() and flush_all(); `load()` too" + spans, quoted = code_spans(text) + assert [(s.name, text[s.start : s.end]) for s in spans] == [ + ("Reader.get", "Reader.get"), + ("ns::load_rows", "ns::load_rows"), + ("cfg.read_rows", "cfg.read_rows"), + ("flush_all", "flush_all"), + ("load", "load"), + ] + assert quoted == [] + + +def test_a_word_of_the_prose_is_no_code_span() -> None: + # `mentions` reads these inside a memory's files; a rewrite may not + assert _spans("read_rows retries and fetchRows does not; Reader.get is hot") == [] + + +def test_a_receiver_is_kept_apart_from_the_name_it_precedes() -> None: + text = "`self.read_rows` and this.fetchRows() leak" + spans, _ = code_spans(text) + assert [(s.receiver, s.name) for s in spans] == [("self.", "read_rows"), ("this.", "fetchRows")] + assert [text[s.start : s.end] for s in spans] == ["read_rows", "fetchRows"] + + +def test_quoted_code_names_nothing() -> None: + fenced = "run:\n```python\nload_rows()\n```\nthen `load_rows`" + spans, quoted = code_spans(fenced) + assert [s.name for s in spans] == ["load_rows"] and fenced[spans[0].start :].startswith("load") + assert [fenced[a:b] for a, b in quoted] == ["```python\nload_rows()\n```"] + for text, held in ( + ("see https://example.org/api/load_rows() for it", "https://example.org/api/load_rows()"), + ('the "ns::load_rows" key', '"ns::load_rows"'), + ("the 'load_rows()' key", "'load_rows()'"), + ("`rows = load_rows(conn)`", "`rows = load_rows(conn)`"), + ("`python tools/load_rows.py`", "`python tools/load_rows.py`"), + ): + spans, quoted = code_spans(text) + assert spans == [] and [text[a:b] for a, b in quoted] == [held], text + # an unclosed fence quotes the rest; an apostrophe inside a word opens no quote + assert code_spans("```\nload_rows()")[0] == [] + assert _spans("it doesn't call `load_rows` when the reader isn't ready") == ["load_rows"] + + +def test_a_name_joined_to_something_longer_is_no_code_span() -> None: + for text in ( + "pass --load_rows() to enable", + "pass --mode=`fast_path`", + "in tools/load_rows() and tools/`load_rows`", + "ping @`load_rows` or #load_rows()", + "the file `load_rows`.py and ns::load_rows.py", + "x.ns::load_rows and ns::load_rows.attr()", + "`load_rows`'s rows", + ): + assert _spans(text) == [], text + # the end of a sentence joins nothing + assert _spans("It calls `load_rows`. Then ns::load_rows.") == ["load_rows", "ns::load_rows"] + + +def test_a_pytest_node_id_holds_no_code_span() -> None: + assert _spans("tests/test_io.py::TestReader::test_read fails; `TestReader` is slow") == [ + "TestReader" + ] + + +def test_reading_code_spans_is_linear_in_the_text() -> None: + from tests.unit.step_count import steps + + def work(n: int) -> int: + text = " ".join(f'`read_rows_{i}` a.b.c{i}-d "q{i}" A::b{i} http://x/{i}' for i in range(n)) + return steps(lambda: code_spans(text)) + + assert work(1600) / work(200) < 12 diff --git a/tests/unit/test_memory_code_links.py b/tests/unit/test_memory_code_links.py index 78d824d354..0dead70d41 100644 --- a/tests/unit/test_memory_code_links.py +++ b/tests/unit/test_memory_code_links.py @@ -1765,6 +1765,9 @@ async def readable(org, nss): assert asked["states"] == ["changed", "unresolved", "missing"] and asked["keys"] == ["k"] assert asked["trunk"] == "" and asked["readable"] == ["code-a"] and asked["limit"] == 3 assert asked["tag_namespaces"] == [("repo:acme/a", "code-a"), ("repo:acme/s", "code-secret")] + # the states asked for, under the same scope + await code_link_reads.stale_links("o", "ns", limit=3, states=("moved",)) + assert asked["states"] == ["moved"] and asked["readable"] == ["code-a"] monkeypatch.setattr(code_link_reads, "readable_namespaces", lambda org, nss: _async(set())) assert await code_link_reads.stale_links("o", "ns", limit=3) == [] # nothing readable diff --git a/tests/unit/test_memory_code_rename_plan.py b/tests/unit/test_memory_code_rename_plan.py new file mode 100644 index 0000000000..4f0954c118 --- /dev/null +++ b/tests/unit/test_memory_code_rename_plan.py @@ -0,0 +1,679 @@ +"""The edits that bring a memory's text up to a rename its link followed: which +spellings are edited, which withhold the whole memory and why, and what the listing +namespace.validate reads returns.""" + +from __future__ import annotations + +import json +from collections import defaultdict +from typing import Any + +import pytest + +from server.code.domain.anchor import Definition +from server.core.hashing import served_content_sha256 +from server.memory.app import code_link_reads, code_renames +from server.memory.domain.code_rename import REASONS, Plan, plan, revised, written_as + +RULES = "rules-1" +PATH = "src/io/reader.py" +OLD = "src.io.reader::Reader::read_rows" +NEW = "src.io.reader::Reader::fetch_rows" + + +def _d(path: str, qn: str) -> Definition: + return Definition(path=path, qualified_name=qn, name=qn.replace("::", ".").split(".")[-1]) + + +def _link(path: str, qn: str, *, was: tuple[str, str] | None = None, **fields: Any) -> dict: + """A link at (path, qn), written against `was`: `moved` when that is elsewhere.""" + was_path, was_name = was or (path, qn) + row = { + "path": path, + "qualified_name": qn, + "state": "moved" if (was_path, was_name) != (path, qn) else "fresh", + "complete": 1, + "carried": 0, + "body_hash": "h1", + "checked_hash": "h1", + "fingerprint_version": RULES, + "anchored_path": was_path, + "anchored_name": was_name, + "former": [], + "code_namespace": "code", + "suggestion": "", + } + return row | fields + + +RENAMED = _link(PATH, NEW, was=(PATH, OLD)) + + +def _plan( + text: Any, + *, + links: list[dict] | None = None, + defs: list[Definition] | None = None, + gone: tuple[str, ...] = (), + **memory: Any, +) -> Plan: + by_name: dict[str, list[Definition]] = defaultdict(list) + for d in [_d(PATH, NEW)] if defs is None else defs: + by_name[d.name].append(d) + return plan( + text, memory, [RENAMED] if links is None else links, by_name, gone=gone, rules=RULES + ) + + +def _revised(text: str, **kw: Any) -> str: + """`text` with its planned edits applied; the plan offers some.""" + planned = _plan(text, **kw) + assert planned.reason == "" and planned.edits, planned + return revised(text, planned.edits) + + +@pytest.mark.parametrize( + ("text", "want"), + [ + ("`read_rows` retries twice.", "`fetch_rows` retries twice."), + ("`read_rows()` retries twice.", "`fetch_rows()` retries twice."), + ("`Reader.read_rows` retries.", "`Reader.fetch_rows` retries."), + ("`Reader::read_rows` retries.", "`Reader::fetch_rows` retries."), + ("Reader::read_rows retries.", "Reader::fetch_rows retries."), + ("Reader.read_rows() retries.", "Reader.fetch_rows() retries."), + ("Call read_rows() once.", "Call fetch_rows() once."), + ( + "`src.io.reader.Reader.read_rows` retries.", + "`src.io.reader.Reader.fetch_rows` retries.", + ), + ( + "`read_rows` retries; so does Reader.read_rows().", + "`fetch_rows` retries; so does Reader.fetch_rows().", + ), + ], +) +def test_every_explicit_spelling_is_edited_at_its_own_depth_and_separator( + text: str, want: str +) -> None: + planned = _plan(text) + assert revised(text, planned.edits) == want + assert planned.sha256 == served_content_sha256(text) + for e in planned.edits: + assert text[e.start : e.end] == e.old + + +def test_text_outside_the_edits_is_byte_identical() -> None: + text = "Ünïcode — get_read_rows_fast and read_rowsx stay;\n\t`read_rows` goes.\r\n" + planned = _plan(text) + (edit,) = planned.edits + assert (edit.old, edit.new) == ("read_rows", "fetch_rows") + assert text[: edit.start] + edit.new + text[edit.end :] == revised(text, planned.edits) + assert revised(text, planned.edits) == text.replace("`read_rows`", "`fetch_rows`") + + +def test_an_edit_is_positioned_in_unicode_code_points() -> None: + """A character outside the Basic Multilingual Plane before the edit is one position, + not the two UTF-16 units or four bytes it takes elsewhere.""" + text = "\U0001f680 `read_rows` retries." + (edit,) = _plan(text).edits + assert (edit.start, edit.end, edit.old) == (3, 12, "read_rows") + assert text[edit.start : edit.end] == edit.old + utf16 = text.encode("utf-16-le") + assert utf16[2 * edit.start : 2 * edit.end].decode("utf-16-le") == "`read_row" + assert revised(text, [edit]) == "\U0001f680 `fetch_rows` retries." + + +def test_planning_the_revised_text_again_offers_no_edit() -> None: + text = "`Reader.read_rows` retries; `read_rows` backs off." + after = _revised(text) + # with the links not yet made again, and once the link pass has made them from it + assert _plan(after).edits == () + assert _plan(after, links=[_link(PATH, NEW)]) == Plan(reason="no_code_token") + + +@pytest.mark.parametrize( + ("text", "reason"), + [ + # a word of the prose, which the link pass reads inside the memory's files + ("read_rows retries twice.", "prose_occurrence"), + ("`read_rows` retries; read_rows backs off.", "prose_occurrence"), + ("pass --read_rows to `read_rows`", "prose_occurrence"), + ("read_rows.py holds `read_rows`", "prose_occurrence"), + # quoted code + ("see https://example.org/api/read_rows for `read_rows`", "quoted_or_literal"), + ('the "read_rows" key feeds `read_rows`', "quoted_or_literal"), + ("```\nread_rows(conn)\n```\n`read_rows` is hot", "quoted_or_literal"), + ("`rows = read_rows(conn)` then `read_rows`", "quoted_or_literal"), + # written as code through something the index does not define + ("`read_rows` retries; call cfg.read_rows() once.", "old_name_remains"), + ("`Reader.read_rows` retries; wrap `conn.read_rows()` in a try.", "old_name_remains"), + # the sentence is about the name, or about a point in time + ("We should rename `read_rows` to something shorter.", "about_naming"), + ("`read_rows`, formerly the slow path, retries.", "about_naming"), + ("`read_rows` was called from the loader.", "about_naming"), + ("`read_rows` is a bad name for this.", "about_naming"), + ("Never name a helper `read_rows`: it collides with the fixture.", "about_naming"), + ("The loader names it `read_rows`.", "about_naming"), + ("The naming of `read_rows` follows the loader.", "about_naming"), + ("The helper is called `read_rows`.", "about_naming"), + ("`read_rows` is an alias of the loader.", "about_naming"), + # a wrapped line and a one-letter abbreviation do not end the sentence + ("The loader was formerly named\n`read_rows`.", "about_naming"), + ("It was renamed, e.g. `read_rows` retries.", "about_naming"), + ("`read_rows` regressed in a1b2c3d4e5.", "dated_claim"), + ("`read_rows` retries since v2.3.", "dated_claim"), + ("`read_rows` retries, see #1234.", "dated_claim"), + ("In March `read_rows` retried twice.", "dated_claim"), + ("In May `read_rows` retried twice.", "dated_claim"), + # the new name is there already + ("`read_rows` calls `fetch_rows`.", "new_name_present"), + ("`read_rows` and the fetch_rows helper.", "new_name_present"), + # written through its receiver, with no file that says whose + ("`self.read_rows()` leaks.", "receiver_form"), + ], +) +def test_a_spelling_or_sentence_that_cannot_be_swapped_withholds_the_memory( + text: str, reason: str +) -> None: + assert _plan(text) == Plan(reason=reason) + + +def test_a_cue_in_another_sentence_does_not_withhold() -> None: + for text in ( + "The loader was renamed in 2019. `read_rows` retries twice.\nSee #12 for the loader.", + # a blank line and a list item end a sentence that has no full stop + "The loader was renamed\n\n`read_rows` retries twice", + "The loader was renamed\r\n\r\n`read_rows` retries twice", + "- the loader was renamed\n- `read_rows` retries twice\n3. see #12", + ): + assert _revised(text) == text.replace("read_rows", "fetch_rows") + + +def test_a_longer_word_that_holds_a_cue_or_a_call_of_the_code_does_not_withhold() -> None: + for text in ( + "`read_rows` reads the filename, the hostname and the namespace.", + "The worker calls `read_rows` twice.", + "`read_rows` may retry twice.", + "May `read_rows` retry twice?", + ): + assert _revised(text) == text.replace("read_rows", "fetch_rows") + + +def test_a_cue_inside_the_edited_name_itself_does_not_withhold() -> None: + was, now = "src/v2/reader2019.py", "src/v2/read2019.py" + link = _link(now, "", was=(was, "")) + text = "`src/v2/reader2019.py` holds the retry loop." + planned = _plan(text, links=[link], defs=[], gone=(was,), files=["read2019.py"]) + assert revised(text, planned.edits) == "`src/v2/read2019.py` holds the retry loop." + + +def test_a_plain_word_or_a_part_of_a_longer_name_is_not_an_occurrence() -> None: + # `close` renamed: the prose word stays and withholds; a longer name is another name + link = _link(PATH, "src.io.reader::Reader::shut", was=(PATH, "src.io.reader::Reader::close")) + defs = [_d(PATH, "src.io.reader::Reader::shut")] + assert _plan("`close` runs when files close.", links=[link], defs=defs).reason == ( + "old_name_remains" + ) + text = "`close` runs; close_all and unclose do not." + assert _revised(text, links=[link], defs=defs) == "`shut` runs; close_all and unclose do not." + + +def test_a_receiver_form_is_edited_when_the_files_name_its_file() -> None: + assert _revised("`self.read_rows()` leaks.", files=[PATH]) == "`self.fetch_rows()` leaks." + assert _revised("cls.read_rows() leaks.", files=["reader.py"]) == "cls.fetch_rows() leaks." + + +def test_an_old_name_another_definition_still_bears_withholds() -> None: + homonym = _d("src/io/writer.py", "src.io.writer::Writer::read_rows") + defs = [_d(PATH, NEW), homonym] + assert _plan("`read_rows` retries.", defs=defs).reason == "old_name_still_defined" + # the spelling decides: `Reader.read_rows` names no other definition + assert _revised("`Reader.read_rows` retries.", defs=defs) == "`Reader.fetch_rows` retries." + # a definition in a scope the index numbers (a second `impl`) is still that name + numbered = [_d(PATH, NEW), _d(PATH, "src.io.reader::Reader#2::read_rows")] + assert _plan("`Reader.read_rows` retries.", defs=numbered).reason == "old_name_still_defined" + + +def test_a_name_another_definition_is_written_by_is_left_alone() -> None: + other = _d("src/io/writer.py", "src.io.writer::Writer::read_rows") + text = "`Writer.read_rows` buffers; `Reader.read_rows` retries." + links = [RENAMED, _link("src/io/writer.py", other.qualified_name)] + assert _revised(text, links=links, defs=[_d(PATH, NEW), other]) == ( + "`Writer.read_rows` buffers; `Reader.fetch_rows` retries." + ) + # renamed as well, under its own link: each link edits its own name + now = _d("src/io/writer.py", "src.io.writer::Writer::fetch_rows") + links = [RENAMED, _link(now.path, now.qualified_name, was=(other.path, other.qualified_name))] + assert _revised(text, links=links, defs=[_d(PATH, NEW), now]) == ( + "`Writer.fetch_rows` buffers; `Reader.fetch_rows` retries." + ) + # the head no longer defines it and no link follows it + assert _plan(text).reason == "old_name_remains" + + +def test_a_new_name_that_does_not_resolve_to_the_link_withholds() -> None: + homonym = _d("src/io/writer.py", "src.io.writer::Writer::fetch_rows") + assert _plan("`read_rows` retries.", defs=[_d(PATH, NEW), homonym]).reason == "would_unlink" + # inside the memory's files it is one definition + assert _plan("`read_rows` retries.", defs=[_d(PATH, NEW), homonym], files=[PATH]).edits + # the index does not have the new definition yet + assert _plan("`read_rows` retries.", defs=[]).reason == "would_unlink" + + +def test_an_edit_that_would_drop_another_link_withholds() -> None: + # the update relinks the memory from its text: a link no name of it resolves to goes + other = _link("src/io/writer.py", "src.io.writer::Writer::flush") + assert _plan("`read_rows` retries.", links=[RENAMED, other]).reason == "would_unlink" + defs = [_d(PATH, NEW), _d("src/io/writer.py", "src.io.writer::Writer::flush")] + text = "`read_rows` retries before `Writer.flush`." + assert _plan(text, links=[RENAMED, other], defs=defs).reason == "about_naming" # "before" + text = "`read_rows` retries and `Writer.flush` runs." + assert _revised(text, links=[RENAMED, other], defs=defs).startswith("`fetch_rows`") + + +@pytest.mark.parametrize( + ("fields", "reason"), + [ + ({"state": "pending", "path": "", "qualified_name": "pkg.later"}, "link_not_settled"), + ({"state": "changed"}, "link_not_settled"), + ({"state": "unresolved"}, "link_not_settled"), + ({"state": "missing"}, "link_not_settled"), + ({"carried": 1}, "link_not_settled"), + ({"checked_hash": "h2"}, "link_not_settled"), + ({"fingerprint_version": "rules-0"}, "link_not_settled"), + ({"complete": 0}, "incomplete"), + ], +) +def test_a_link_that_is_not_settled_or_was_cut_withholds(fields: dict, reason: str) -> None: + other = _link("src/io/writer.py", "src.io.writer::Writer::flush") | fields + assert _plan("`read_rows` retries.", links=[RENAMED, other]).reason == reason + + +def test_an_ordinal_name_withholds() -> None: + numbered = "src.io.reader::Reader#2::fetch_rows" + for was, now in ((OLD + "#2", NEW), (OLD, NEW + "#2"), (OLD, numbered)): + link = _link(PATH, now, was=(PATH, was)) + assert _plan("`Reader.read_rows` retries.", links=[link]).reason == "overloaded" + + +def test_a_value_that_is_not_one_string_is_not_text() -> None: + assert _plan(None) == Plan(reason="not_text") + # what the listing passes for a stored object, list or number + for value in ({"claim": "`read_rows` retries."}, ["`read_rows`"], 7): + assert code_renames.link_pass.claim_of(json.dumps(value)) is None + + +def test_the_old_name_in_the_key_or_a_tag_withholds() -> None: + text = "`read_rows` retries." + assert _plan(text, memory_key="repo/lesson/read_rows-retry").reason == "named_in_key_or_tags" + assert _plan(text, tags=["repo:x", "Read_Rows"]).reason == "named_in_key_or_tags" + assert _plan(text, memory_key="repo/lesson/read_rows_twice", tags=["thread_rows"]).edits + + +def test_a_dated_memory_withholds() -> None: + for column in ("valid_to", "invalid_at", "temporal_anchor"): + assert _plan("`read_rows` retries.", **{column: "2031-01-01 00:00:00"}).reason == ( + "dated_claim" + ) + + +def test_one_name_two_links_wrote_withholds() -> None: + # two definitions moved apart under one written name + a = _link("src/a.py", "src.a::load_all", was=("src/a.py", "src.a::load")) + b = _link("src/b.py", "src.b::load_some", was=("src/b.py", "src.b::load")) + defs = [_d("src/a.py", "src.a::load_all"), _d("src/b.py", "src.b::load_some")] + assert _plan("`load` is slow.", links=[a, b], defs=defs).reason == "names_several" + + +def test_a_scope_change_edits_only_the_spellings_that_name_the_old_scope() -> None: + # the class was renamed and its own link followed it: the bare name still holds + link = _link(PATH, "src.io.reader::Loader", was=(PATH, "src.io.reader::Reader")) + defs = [_d(PATH, "src.io.reader::Loader")] + assert _revised("`Reader` wraps the socket.", links=[link], defs=defs) == ( + "`Loader` wraps the socket." + ) + # a member written through the old class is not this link's to rename + for text in ("`Reader` wraps; `Reader.get` reads.", "`Reader` wraps; `~Reader` closes."): + assert _plan(text, links=[link], defs=defs).reason == "old_name_remains" + # moved to another module under its own name: only a qualified spelling changes + moved = _link( + "src/net/util.py", "src.net.util::backoff", was=("src/io/util.py", "src.io.util::backoff") + ) + defs = [_d("src/net/util.py", "src.net.util::backoff")] + assert _plan("`backoff` doubles.", links=[moved], defs=defs) == Plan(reason="no_code_token") + assert _revised("`io.util.backoff` doubles.", links=[moved], defs=defs) == ( + "`net.util.backoff` doubles." + ) + text = "`io.util.backoff` doubles; io.util.backoff is shared." + assert _plan(text, links=[moved], defs=defs).reason == "old_name_remains" + + +def test_a_whole_name_with_no_module_part_becomes_the_whole_new_name() -> None: + # C++ names carry no path: the whole old name gains the namespace the new one has + path = "src/reader.cpp" + link = _link(path, "ns::io::Reader::get", was=(path, "ns::Reader::get")) + kw: dict[str, Any] = {"links": [link], "defs": [_d(path, "ns::io::Reader::get")]} + assert _revised("`ns::Reader::get` retries.", **kw) == "`ns::io::Reader::get` retries." + assert _revised("ns.Reader.get() retries.", **kw) == "ns.io.Reader.get() retries." + # a shorter spelling still names the new one: nothing to edit + assert _plan("`Reader::get` retries.", **kw) == Plan(reason="no_code_token") + back = _link(path, "ns::Reader::get", was=(path, "ns::io::Reader::get")) + kw = {"links": [back], "defs": [_d(path, "ns::Reader::get")]} + assert _revised("`ns::io::Reader::get` retries.", **kw) == "`ns::Reader::get` retries." + assert _revised("`io::Reader::get` retries.", **kw) == "`ns::Reader::get` retries." + + +def test_the_module_a_definition_left_withholds_where_no_edit_reaches_it() -> None: + was, now = "src/io/util.py", "src/net/util.py" + moved = _link(now, "src.net.util::backoff", was=(was, "src.io.util::backoff")) + defs = [_d(now, "src.net.util::backoff")] + for text, reason in ( + ("`io.util.backoff` doubles; `from src.io.util import backoff`.", "quoted_or_literal"), + ("`io.util.backoff` doubles; it lives in the io.util module.", "old_name_remains"), + ("`io.util.backoff` doubles; see `src.io.util`.", "old_name_remains"), + ("`backoff` doubles; it lives in src::io::util.", "old_name_remains"), + ): + assert _plan(text, links=[moved], defs=defs).reason == reason, text + # the part both modules end in is not the old one, and one segment may be a word + text = "`io.util.backoff` doubles; util and io hold the rest." + assert _revised(text, links=[moved], defs=defs).startswith("`net.util.backoff`") + # two definitions that left one module are both edited: each covers its own module + jitter = _link(now, "src.net.util::jitter", was=(was, "src.io.util::jitter")) + text = "`src.io.util.backoff` and `src.io.util.jitter` double." + both = [*defs, _d(now, "src.net.util::jitter")] + assert _revised(text, links=[moved, jitter], defs=both) == ( + "`src.net.util.backoff` and `src.net.util.jitter` double." + ) + # a name written as code that the old module still defines holds as it is + text = "`io.util.backoff` doubles; `io.util.helper` and src::io::util::helper() do not." + stays = [*defs, _d(was, "src.io.util::helper")] + assert _revised(text, links=[moved], defs=stays) == text.replace( + "io.util.backoff", "net.util.backoff" + ) + # the index defines no such name: the text may be about the place + assert _plan(text, links=[moved], defs=defs).reason == "old_name_remains" + + +def test_a_renamed_file_edits_its_whole_path_once_the_old_one_is_gone() -> None: + was, now = "src/io/reader.py", "src/io/read.py" + link = _link(now, "src.io.read::Reader::get", was=(was, "src.io.reader::Reader::get")) + defs = [_d(now, "src.io.read::Reader::get")] + kw: dict[str, Any] = {"links": [link], "defs": defs, "gone": (was,)} + text = "`Reader.get` in `src/io/reader.py` retries (see src/io/reader.py)." + assert _revised(text, **kw) == "`Reader.get` in `src/io/read.py` retries (see src/io/read.py)." + assert _revised("`reader.Reader.get` retries.", **kw) == "`read.Reader.get` retries." + for text, reason in ( + # the old file is still there: the text may be about the file + ("`Reader.get` in `src/io/reader.py` retries.", "old_name_remains"), + ): + assert _plan(text, links=[link], defs=defs).reason == reason + for text, reason in ( + ("`Reader.get` at src/io/reader.py:120 retries.", "old_name_remains"), + ("`Reader.get` in reader.py retries.", "old_name_remains"), + ("`Reader.get` in lib/src/io/reader.py retries.", "old_name_remains"), + ("`python src/io/reader.py` runs `Reader.get`.", "quoted_or_literal"), + ("see https://example.org/src/io/reader.py for `Reader.get`", "quoted_or_literal"), + ("`src/io/reader.py` became `src/io/read.py`.", "new_name_present"), + ): + assert _plan(text, **kw).reason == reason, text + + +def test_files_and_labels_that_name_the_old_path_withhold() -> None: + was, now = "src/io/reader.py", "src/io/read.py" + link = _link(now, "", was=(was, "")) + text = "`src/io/reader.py` holds the retry loop." + kw: dict[str, Any] = {"links": [link], "defs": [], "gone": (was,)} + # memory.update keeps `files`: the old entry would stay, and the file link with it + assert _plan(text, files=[was], **kw).reason == "named_in_files" + assert _plan(text, files=[now], memory_key="repo/file/src/io/reader.py", **kw).reason == ( + "named_in_key_or_tags" + ) + # a file moved under its own bare name is still what `files` names + moved = _link("lib/reader.py", "", was=("src/reader.py", "")) + kw = {"links": [moved], "defs": [], "gone": ("src/reader.py",)} + assert _revised("`src/reader.py` holds it.", files=["reader.py"], **kw) == ( + "`lib/reader.py` holds it." + ) + # no file of the memory names the file link's path any more + assert _plan("`src/reader.py` holds it.", files=[], **kw).reason == "would_unlink" + # the new path as a path of its own is there already; inside a longer one it is not + for also in ("lib/reader.py:12", "`lib/reader.py`", "./lib/reader.py", "/lib/reader.py."): + text = f"`src/reader.py` holds it; see {also}" + assert _plan(text, files=["reader.py"], **kw).reason == "new_name_present", text + for also in ("test/lib/reader.py", "lib/reader.pyc", "https://example.org/lib/reader.py"): + text = f"`src/reader.py` holds it; see {also}" + assert _revised(text, files=["reader.py"], **kw) == text.replace("`src/", "`lib/"), text + + +def test_a_text_that_names_nothing_old_holds_whatever_its_links_and_labels_say() -> None: + """A reason the links, the key, a tag or `files` give withholds an edit: a text with + no old name or path in it has none, and its memory is not listed.""" + holds = Plan(reason="no_code_token") + text = "`Reader` wraps the socket." + other = _link("src/io/writer.py", "src.io.writer::Writer::flush") + for fields in ({"state": "changed"}, {"complete": 0}): + assert _plan(text, links=[RENAMED, other | fields]) == holds + assert _plan(text, memory_key="repo/lesson/read_rows-retry", tags=["read_rows"]) == holds + numbered = _link(PATH, NEW, was=(PATH, OLD + "#2")) + assert _plan(text, links=[numbered]) == holds + was = "src/io/reader.py" + kw: dict[str, Any] = {"links": [_link("src/io/read.py", "", was=(was, ""))], "defs": []} + assert _plan("The retry loop is hot.", files=[was], gone=(was,), **kw) == holds + # the old name where no edit reaches it is something old: the reason is given + assert _plan("read_rows retries.", links=[numbered]).reason == "overloaded" + assert _plan("read_rows retries.", links=[RENAMED, other | {"complete": 0}]).reason == ( + "incomplete" + ) + + +def test_a_link_back_where_it_was_written_or_reanchored_gets_no_edit() -> None: + # renamed and renamed back: the text names it + back = _link(PATH, OLD, state="moved", anchored_name=NEW, former=[_former(PATH, OLD)]) + assert _plan("`read_rows` retries.", links=[back], defs=[_d(PATH, OLD)]) == ( + Plan(reason="no_code_token") + ) + # re-anchored where the code is by a `holds` verdict: no move is planned from it + held = _link(PATH, NEW, former=[_former(PATH, OLD)]) + assert held["state"] == "fresh" + assert _plan("`read_rows` retries.", links=[held]) == Plan(reason="no_code_token") + # beside a renamed link, the update would drop it: its old name resolves nowhere + other = _link("src/a.py", "src.a::load_all", was=("src/a.py", "src.a::load")) + defs = [_d(PATH, NEW), _d("src/a.py", "src.a::load_all")] + text = "`read_rows` retries and `load` is slow." + assert _plan(text, links=[held, other], defs=defs).reason == "would_unlink" + + +def _former(path: str, name: str) -> dict[str, str]: + return {"path": path, "name": name, "hash": "h1"} + + +def test_written_as_is_the_oldest_identity_of_the_links_own_kind() -> None: + link = _link(PATH, NEW, was=(PATH, "src.io.reader::Reader::load")) + assert written_as(link) == (PATH, "src.io.reader::Reader::load") + link["former"] = [_former(PATH, OLD), _former(PATH, "src.io.reader::Reader::load")] + assert written_as(link) == (PATH, OLD) + # a definition link that replaced a file link was never that file + link["former"] = [_former(PATH, "")] + assert written_as(link) == (PATH, "src.io.reader::Reader::load") + + +def test_every_reason_is_one_the_plan_can_give() -> None: + assert len(set(REASONS)) == len(REASONS) + assert REASONS[0] == "not_text" and REASONS[-1] == "no_code_token" + + +# ---- the listing namespace.validate reads ---------------------------------------------- + + +def _head(mid: str, text: Any, **fields: Any) -> dict[str, Any]: + head = { + "mid": mid, + "namespace": "ns", + "memory_key": f"k/{mid}", + "user_id": "-", + "value": json.dumps(text), + "tags": ["repo:x"], + "files": [], + "sha": "s", + "status": "active", + "tombstoned_at": None, + "sensitivity": "normal", + } + return head | fields + + +@pytest.fixture +def listing(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]: + """A store of heads and links, an index and one readable repository.""" + world: dict[str, Any] = {"heads": [], "links": [], "defs": [_d(PATH, NEW)], "live": {}} + monkeypatch.setattr(code_renames, "fingerprint_version", lambda: RULES) + monkeypatch.setattr(code_link_reads, "inputs_now", lambda org, memory: "inputs") + + async def stale_links(org: str, ns: str, keys: Any = None, *, limit: int, states: Any) -> Any: + world["asked"] = (keys, limit, tuple(states)) + moved = [ + a for a in world["links"] if a["state"] == "moved" and a["code_namespace"] == "code" + ] + return [{"memory_id": a["memory_id"], "code_namespace": "code"} for a in moved] + + async def memory_heads(org: str, ids: list[str]) -> list[dict[str, Any]]: + return [h for h in world["heads"] if h["mid"] in ids] + + async def for_memories(org: str, ids: list[str]) -> list[dict[str, Any]]: + return [a for a in world["links"] if a["memory_id"] in ids] + + async def candidates(org: str, cns: str, *, names: list[str]) -> list[Definition]: + world["names"] = names + return [d for d in world["defs"] if d.name in names] + + async def live_paths(org: str, cns: str, refs: list[str]) -> dict[str, str]: + return {r: world["live"].get(r, r) for r in refs if r not in world.get("gone", ())} + + monkeypatch.setattr(code_link_reads, "stale_links", stale_links) + monkeypatch.setattr(code_renames.store, "memory_heads", memory_heads) + monkeypatch.setattr(code_renames.store, "for_memories", for_memories) + monkeypatch.setattr(code_renames.code, "candidates", candidates) + monkeypatch.setattr(code_renames.code, "live_paths", live_paths) + return world + + +def _stored( + world: dict[str, Any], mid: str, text: Any, link: dict | None = None, **head: Any +) -> None: + world["heads"].append(_head(mid, text, **head)) + world["links"].append((link or RENAMED) | {"memory_id": mid, "inputs_hash": "inputs"}) + + +@pytest.mark.asyncio +async def test_the_listing_gives_each_memory_its_edits_or_its_reason(listing: dict) -> None: + _stored(listing, "m1", "`read_rows` retries twice.") + _stored(listing, "m2", "read_rows retries twice.") + _stored(listing, "m3", {"claim": "`read_rows` retries twice."}) + # names nothing old: its text holds as it is, and it is not listed + _stored(listing, "m4", "`Reader` wraps the socket.") + rows = await code_renames.planned("o", "ns", ["k"]) + assert rows == [ + { + "memory_key": "k/m1", + "memory_id": "m1", + "edits": [{"start": 1, "end": 10, "old": "read_rows", "new": "fetch_rows"}], + "content_sha256": served_content_sha256("`read_rows` retries twice."), + }, + {"memory_key": "k/m2", "memory_id": "m2", "reason": "prose_occurrence"}, + {"memory_key": "k/m3", "memory_id": "m3", "reason": "not_text"}, + ] + assert listing["asked"] == (["k"], code_renames.SCANNED, ("moved",)) + # the index is asked for the old and new bare names and what the text mentions + assert {"read_rows", "fetch_rows"} <= set(listing["names"]) + + +@pytest.mark.asyncio +async def test_the_listing_reads_no_memory_it_may_not_quote_or_serve(listing: dict) -> None: + _stored(listing, "m1", "`read_rows` retries.", sensitivity="high") + _stored(listing, "m2", "`read_rows` retries.", status="superseded") + _stored(listing, "m3", "`read_rows` retries.", tombstoned_at="2031-01-01 00:00:00") + # its links were made from an earlier value: the link pass has not read this one + _stored(listing, "m4", "`read_rows` retries.") + listing["links"][-1]["inputs_hash"] = "older" + assert await code_renames.planned("o", "ns") == [] + + +@pytest.mark.asyncio +async def test_the_listing_gives_no_row_for_a_repository_the_caller_may_not_read( + listing: dict, monkeypatch: pytest.MonkeyPatch +) -> None: + _stored(listing, "m1", "`read_rows` retries.", link=RENAMED | {"code_namespace": "secret"}) + assert await code_renames.planned("o", "ns") == [] + # through the real read: nothing is read of a namespace with no readable repository + monkeypatch.setattr(code_link_reads, "stale_links", _REAL_STALE_LINKS) + monkeypatch.setattr(code_link_reads.code, "trunk_namespace", lambda org, ns: "secret") + + async def none_readable(org: str, namespaces: set[str]) -> set[str]: + return set() + + async def unread(*a: Any, **kw: Any) -> Any: + raise AssertionError("no link, memory or index is read") + + monkeypatch.setattr(code_link_reads, "readable_namespaces", none_readable) + for name in ("stale_of_served", "memory_heads", "for_memories"): + monkeypatch.setattr(code_renames.store, name, unread) + monkeypatch.setattr(code_renames.code, "candidates", unread) + assert await code_renames.planned("o", "ns") == [] + + +_REAL_STALE_LINKS = code_link_reads.stale_links +_REAL_LIVE_PATHS = code_renames.code.live_paths + + +@pytest.mark.asyncio +async def test_the_listing_asks_the_index_which_old_paths_are_gone(listing: dict) -> None: + was, now = "src/io/reader.py", "src/io/read.py" + link = _link(now, "src.io.read::Reader::get", was=(was, "src.io.reader::Reader::get")) + listing["defs"] = [_d(now, "src.io.read::Reader::get")] + _stored(listing, "m1", "`Reader.get` in `src/io/reader.py` retries.", link=link) + (row,) = await code_renames.planned("o", "ns") + assert row["reason"] == "old_name_remains" # the index still has the old file + listing["gone"] = (was,) + (row,) = await code_renames.planned("o", "ns") + assert [(e["old"], e["new"]) for e in row["edits"]] == [(was, now)] + # a bare name the index resolves to another file is not the old path + listing["gone"], listing["live"] = (), {was: "other/src/io/reader.py"} + (row,) = await code_renames.planned("o", "ns") + assert [(e["old"], e["new"]) for e in row["edits"]] == [(was, now)] + + +class _Files: + """The file table of an index, answering as the store's reads ask it.""" + + def __init__(self, live: set[str]) -> None: + self.live = live + self.asked: list[int] = [] + + async def query_all(self, sql: str, params: dict[str, Any]) -> list[dict[str, Any]]: + self.asked.append(len(params["paths"])) + return [{"path": p} for p in params["paths"] if p in self.live] + + +@pytest.mark.asyncio +async def test_an_old_path_past_the_store_reads_cap_is_still_asked_for( + listing: dict, monkeypatch: pytest.MonkeyPatch +) -> None: + """The store answers for 500 paths of one read: a report with more old paths than + that asks in slices, so the last path, which the head still has, is not read as gone.""" + from server.code.store.index import CodeRepo + + last = 500 + for i in range(last + 1): + was, now = f"src/old/f{i:03}.py", f"src/new/f{i:03}.py" + link = _link(now, "", was=(was, "")) + _stored(listing, f"m{i:03}", f"`{was}` holds it.", link=link, files=[f"f{i:03}.py"]) + files = _Files({f"src/old/f{last}.py"}) + monkeypatch.setattr(code_renames.code, "live_paths", _REAL_LIVE_PATHS) + monkeypatch.setattr(code_renames.code, "CodeRepo", lambda: CodeRepo(files)) + rows = {r["memory_id"]: r for r in await code_renames.planned("o", "ns")} + assert files.asked == [500, 1] + assert rows[f"m{last}"]["reason"] == "old_name_remains" + assert [(e["old"], e["new"]) for e in rows["m000"]["edits"]] == [ + ("src/old/f000.py", "src/new/f000.py") + ] + assert sum("edits" in r for r in rows.values()) == last diff --git a/tests/unit/test_namespace_validate.py b/tests/unit/test_namespace_validate.py index 839671205b..c17ad5a9de 100644 --- a/tests/unit/test_namespace_validate.py +++ b/tests/unit/test_namespace_validate.py @@ -19,6 +19,8 @@ from server.transport import mcp_descriptions _STALE_LINKS = code_link_reads.stale_links # the real read, before `_no_code_links` +# the checks read from the code links rather than with SQL of their own +_CODE_LINK_CHECKS = ("code_links_stale", "code_rename_edits") class _CH: @@ -69,7 +71,7 @@ async def test_clean_namespace_is_healthy_and_lists_every_check( assert out.healthy is True assert (out.errors, out.warnings, out.infos) == (0, 0, 0) names = [f.check for f in out.findings] - assert set(names) == {*nv._CHECKS, "code_links_stale", *nv._CODE_UNLINKED} + assert set(names) == {*nv._CHECKS, *_CODE_LINK_CHECKS, *nv._CODE_UNLINKED} assert "unresolved_evidence" in names assert all(f.count == 0 and f.samples == [] for f in out.findings) assert out.skipped == [] @@ -137,8 +139,9 @@ async def test_one_failing_check_is_skipped_not_raised(monkeypatch: pytest.Monke out = await nv.handle_namespace_validate(_inp()) assert out.skipped == ["orphan_vectors: RuntimeError"] assert "orphan_vectors" not in [f.check for f in out.findings] - # every other check, the stale code links and the unlinked memories by cause - assert len(out.findings) == len(nv._CHECKS) + len(nv._CODE_UNLINKED) + # every other check, the two read from the code links and the unlinked memories by cause + others = len(nv._CHECKS) - 1 + assert len(out.findings) == others + len(_CODE_LINK_CHECKS) + len(nv._CODE_UNLINKED) assert out.healthy is True @@ -290,7 +293,11 @@ def link(key: str) -> dict[str, Any]: asked: list[Any] = [] - async def stale_links(org: str, namespace: str, keys: Any = None, *, limit: int) -> Any: + async def stale_links( + org: str, namespace: str, keys: Any = None, *, limit: int, states: Any = () + ) -> Any: + if "moved" in states: + return [] # the rename check's read asked.append((keys, limit)) return [link("new")] @@ -304,7 +311,7 @@ async def stale_links(org: str, namespace: str, keys: Any = None, *, limit: int) def test_every_check_declares_its_kind_version_and_uncertainty() -> None: - assert set(nv._CONTRACT) == {*nv._CHECKS, "code_links_stale", *nv._CODE_UNLINKED} + assert set(nv._CONTRACT) == {*nv._CHECKS, *_CODE_LINK_CHECKS, *nv._CODE_UNLINKED} assert {r.kind for r in nv._CONTRACT.values()} == { "contract_violation", "usage_heuristic", @@ -419,7 +426,7 @@ async def test_stale_code_links_are_named_skipped_while_the_code_registry_is_unr out = await nv.handle_namespace_validate(_inp()) # every check that reads which repositories are configured assert out.skipped == [ - f"{check}: RegistryUnread" for check in ("code_links_stale", *nv._CODE_UNLINKED) + f"{check}: RegistryUnread" for check in (*_CODE_LINK_CHECKS, *nv._CODE_UNLINKED) ] assert out.coverage.complete is False @@ -487,4 +494,91 @@ async def unlinked(org: str, namespace: str, keys: Any = None) -> dict[str, list monkeypatch.setattr(nv, "get_client", lambda: _CH({})) out = await nv.handle_namespace_validate(_inp()) assert out.skipped == [f"{check}: TimeoutError" for check in nv._CODE_UNLINKED] - assert reads == 1 and {f.check for f in out.findings} == {*nv._CHECKS, "code_links_stale"} + assert reads == 1 and {f.check for f in out.findings} == {*nv._CHECKS, *_CODE_LINK_CHECKS} + + +@pytest.mark.asyncio +async def test_rename_edits_are_listed_with_their_totals_by_outcome( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """A memory whose link followed a rename is listed with the edits its text allows, + or the reason it gets none; the totals count every memory listed, not only the + samples. Information: it never makes a namespace unhealthy, even under `strict`.""" + from server.memory.app import code_renames + + asked: list[Any] = [] + edit = {"start": 1, "end": 10, "old": "read_rows", "new": "fetch_rows"} + + def memory(n: int, **more: Any) -> dict[str, Any]: + return {"memory_key": f"k{n}", "memory_id": f"00000000-0000-0000-0000-{n:012d}", **more} + + found = [ + memory(1, edits=[edit], content_sha256="a" * 64), + memory(2, reason="prose_occurrence"), + memory(3, reason="old_name_still_defined"), + memory(4, reason="prose_occurrence"), + ] + + async def planned(org: str, namespace: str, keys: Any = None) -> list[dict[str, Any]]: + asked.append((org, namespace, keys)) + return found + + monkeypatch.setattr(code_renames, "planned", planned) + monkeypatch.setattr(nv, "get_client", lambda: _CH({})) + out = await nv.handle_namespace_validate(_inp(keys=["k1"], sample_limit=2, strict=True)) + renames = next(f for f in out.findings if f.check == "code_rename_edits") + assert renames.count == 4 and renames.samples == found[:2] + assert renames.samples_complete is False and renames.severity == "info" + assert renames.totals == {"edits": 1, "old_name_still_defined": 1, "prose_occurrence": 2} + assert (out.infos, out.warnings, out.errors, out.healthy) == (4, 0, 0, True) + assert "memory.update" in renames.detail and "if_match_sha256" in renames.detail + assert asked == [("o", "ns", ["k1"])] + # no sample asked for: every memory is still counted, by outcome + out = await nv.handle_namespace_validate(_inp(sample_limit=0)) + renames = next(f for f in out.findings if f.check == "code_rename_edits") + assert (renames.count, renames.samples) == (4, []) and sum(renames.totals.values()) == 4 + assert asked[-1] == ("o", "ns", None) + # a check with no classes of its own carries no totals + assert all(f.totals == {} for f in out.findings if f.check != "code_rename_edits") + + +@pytest.mark.asyncio +async def test_a_failed_rename_read_skips_its_check_and_no_other( + monkeypatch: pytest.MonkeyPatch, +) -> None: + from server.memory.app import code_renames + + async def planned(org: str, namespace: str, keys: Any = None) -> list[dict[str, Any]]: + raise TimeoutError("read timed out") + + monkeypatch.setattr(code_renames, "planned", planned) + monkeypatch.setattr(nv, "get_client", lambda: _CH({})) + out = await nv.handle_namespace_validate(_inp()) + assert out.skipped == ["code_rename_edits: TimeoutError"] + assert "code_rename_edits" not in {f.check for f in out.findings} + + +@pytest.mark.asyncio +async def test_rename_edits_list_nothing_of_a_repository_the_caller_may_not_read( + monkeypatch: pytest.MonkeyPatch, +) -> None: + """The listing starts from the links into repositories the caller may read: with + none readable, no memory, link or index row is read and nothing is listed.""" + from server.memory.app import code_renames + + async def none_readable(org: str, namespaces: set[str]) -> set[str]: + return set() + + async def unread(*args: Any, **kw: Any) -> Any: + raise AssertionError("nothing is read of an unreadable repository") + + monkeypatch.setattr(code_link_reads, "stale_links", _STALE_LINKS) + monkeypatch.setattr(code_link_reads.code, "trunk_namespace", lambda org, ns: "secret-code") + monkeypatch.setattr(code_link_reads, "readable_namespaces", none_readable) + for name in ("stale_of_served", "memory_heads", "for_memories"): + monkeypatch.setattr(code_renames.store, name, unread) + monkeypatch.setattr(code_renames.code, "candidates", unread) + monkeypatch.setattr(nv, "get_client", lambda: _CH({})) + out = await nv.handle_namespace_validate(_inp()) + renames = next(f for f in out.findings if f.check == "code_rename_edits") + assert (renames.count, renames.samples, renames.totals) == (0, [], {})