Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(web): use stored project names in scoped search links
Samir Hanna Verza82c8ab6f4bdd
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 67a4da09..d1636902 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -13,6 +13,11 @@ version in [`docs/changelog/`](docs/changelog/):### Fixed+- Project search links now use the project's current stored name after+ resolving a canonical or legacy key. Results no longer lead to a 404 when+ searched through the other spelling, and the breadcrumb and scope selector+ stay on that project without renaming it (#PR).+- The web UI's root operator now sees every user's sessions in a project'sSessions, Agents and Token usage tabs, on each agent's page and on eachsession's page, and so do the `/api/v1` session list and observationsdiff --git a/crates/ai-memory-web/src/routes/search.rs b/crates/ai-memory-web/src/routes/search.rsindex 7b16563b..2c2bff95 100644--- a/crates/ai-memory-web/src/routes/search.rs+++ b/crates/ai-memory-web/src/routes/search.rs@@ -96,7 +96,7 @@ pub(crate) async fn handler(.as_deref().is_some_and(|v| matches!(v, "1" | "true" | "on" | "yes"));let viewer = viewer.map(|axum::Extension(viewer)| viewer.user());- let scope = match non_empty(params.scope.as_deref()) {+ let mut scope = match non_empty(params.scope.as_deref()) {Some(value) => match value.split_once('/') {Some((workspace, project)) if !workspace.is_empty() && !project.is_empty() => {Some((workspace.to_owned(), project.to_owned()))@@ -158,13 +158,25 @@ pub(crate) async fn handler(let mut truncated = false;let mut timings = None;let mut streams_active: Vec<&'static str> = Vec::new();- match &scope {+ match &mut scope {Some((workspace, project)) => {let resolved = match super::resolve_read_scope(&state, viewer, workspace, project).await{Ok(resolved) => resolved,Err(refusal) => return super::page::refusal_response(&refusal),};+ // Scope lookup accepts canonical and legacy keys, but page URLs+ // use the exact stored name. Resolve it only after authorization,+ // without promoting the project as a side effect of a read.+ *project = match state+ .reader+ .project_name_by_id(resolved.workspace_id, resolved.project_id)+ .await+ {+ Ok(Some(name)) => name,+ Ok(None) => return super::page::not_found_response(),+ Err(error) => return internal(error),+ };if !query.is_empty() {let limit = params.limitdiff --git a/crates/ai-memory-web/tests/suite/routes.rs b/crates/ai-memory-web/tests/suite/routes.rsindex f4e2103f..111ab8a8 100644--- a/crates/ai-memory-web/tests/suite/routes.rs+++ b/crates/ai-memory-web/tests/suite/routes.rs@@ -6385,3 +6385,226 @@ async fn search_page_scope_selector_round_trips_and_rejects_malformed_values() {assert_eq!(status, StatusCode::BAD_REQUEST, "scope={bad}");}}++/// Old clients can register the basename while explicit reads already accept+/// its canonical key. Only an explicit write promotes the stored name.+async fn search_alias_fixture() -> (+ TempDir,+ Store,+ Wiki,+ ai_memory_core::WorkspaceId,+ ai_memory_core::ProjectId,+) {+ use ai_memory_core::repository_identity::{IdentitySource, IdentityStyle, RepositoryIdentity};++ let (tmp, store, wiki) = setup().await;+ let ws = store+ .writer+ .get_or_create_workspace("default")+ .await+ .unwrap();+ let (project, _) = store+ .writer+ .resolve_project_by_identity(+ ws,+ RepositoryIdentity {+ identity: "github.com/acme/api".into(),+ source: IdentitySource::GitRemote,+ },+ IdentityStyle::HostPath,+ "api",+ Some("/work/api".into()),+ None,+ None,+ )+ .await+ .unwrap();+ wiki.write_page(wiki_req(+ ws,+ project,+ "notes/alias.md",+ "# Alias note\n\naliaslookupword",+ ))+ .await+ .unwrap();+ (tmp, store, wiki, ws, project)+}++#[tokio::test]+async fn search_alias_links_open_before_and_after_project_promotion() {+ let (_tmp, store, wiki, ws, project) = search_alias_fixture().await;+ let app = router(store.reader.clone(), wiki);++ for current_name in ["api", "acme-api"] {+ if current_name == "acme-api" {+ let promoted =+ ai_memory_store::create_explicit_scope(&store.writer, "default", current_name)+ .await+ .unwrap();+ assert_eq!(promoted.scope.project_id, project);+ assert_eq!(promoted.promoted_from.as_deref(), Some("api"));+ }+ for requested_name in ["api", "acme-api"] {+ for scope in [+ format!("workspace=default&project={requested_name}"),+ format!("scope=default/{requested_name}"),+ ] {+ for query in ["aliaslookupword", ""] {+ let uri = format!("/search?q={query}&{scope}&explain=1");+ let (status, html) = get_text(&app, &uri, None).await;+ assert_eq!(status, StatusCode::OK, "{uri}: {html}");+ if !query.is_empty() {+ // Follow the rendered result, including its recall context,+ // rather than constructing the expected URL ourselves.+ let href = html+ .split("href=\"")+ .filter_map(|part| part.split_once('"').map(|(href, _)| href))+ .find(|href| href.contains("/p/notes/alias.md"))+ .unwrap_or_else(|| panic!("{uri} had no result link: {html}"))+ .replace("&", "&")+ .replace("&", "&");+ let (page_status, page) = get_text(&app, &format!("/{href}"), None).await;+ assert_eq!(+ page_status,+ StatusCode::OK,+ "{uri} linked to {href}: {page}"+ );+ assert!(page.contains("aliaslookupword"), "{page}");+ assert!(href.starts_with(&format!("w/default/{current_name}/p/")));+ }+ assert!(+ html.contains(&format!("href=\"w/default/{current_name}\"")),+ "breadcrumb for {uri}: {html}"+ );+ assert!(+ html.contains(&format!("value=\"default/{current_name}\" selected")),+ "selector for {uri}: {html}"+ );+ }+ }+ }+ // Reads through either spelling neither rename nor create a project.+ assert_eq!(+ store+ .reader+ .project_name_by_id(ws, project)+ .await+ .unwrap()+ .as_deref(),+ Some(current_name)+ );+ assert_eq!(+ store+ .reader+ .list_projects_with_stats(None)+ .await+ .unwrap()+ .len(),+ 1+ );+ }+}++#[tokio::test]+async fn search_alias_links_require_a_grant_and_refuse_ambiguous_names() {+ use ai_memory_core::repository_identity::{IdentitySource, IdentityStyle, RepositoryIdentity};+ use ai_memory_core::{NewUser, UserRole};+ use ai_memory_store::{AccessMode, GrantLevel};++ let (_tmp, store, wiki, ws, project) = search_alias_fixture().await;+ store+ .writer+ .set_access_mode(project, AccessMode::Restricted)+ .await+ .unwrap();+ let mut users = Vec::new();+ for username in ["reader", "outsider"] {+ users.push(+ store+ .writer+ .create_human_user(+ NewUser {+ username: username.into(),+ name: None,+ email: None,+ },+ UserRole::User,+ None,+ false,+ )+ .await+ .unwrap(),+ );+ }+ store+ .writer+ .grant_memory(users[0], project, GrantLevel::Read, None)+ .await+ .unwrap();+ let app = router(store.reader.clone(), wiki);++ for current_name in ["api", "acme-api"] {+ if current_name == "acme-api" {+ ai_memory_store::create_explicit_scope(&store.writer, "default", current_name)+ .await+ .unwrap();+ }+ for requested_name in ["api", "acme-api"] {+ for scope in [+ format!("workspace=default&project={requested_name}"),+ format!("scope=default/{requested_name}"),+ ] {+ for query in ["aliaslookupword", ""] {+ let uri = format!("/search?q={query}&{scope}&explain=1");+ let (status, html) = get_text(&app, &uri, Some(users[1])).await;+ assert_eq!(status, StatusCode::FORBIDDEN, "{uri}: {html}");+ assert!(!html.contains("notes/alias.md"), "{html}");+ assert!(!html.contains("aliaslookupword"), "{html}");+ assert!(!html.contains("Recall trace"), "{html}");+ // The granted reader and root still reach the same project.+ for viewer in [Some(users[0]), None] {+ let (status, html) = get_text(&app, &uri, viewer).await;+ assert_eq!(status, StatusCode::OK, "{uri}: {html}");+ assert!(+ html.contains(&format!("value=\"default/{current_name}\" selected"))+ );+ }+ }+ }+ }+ }++ // A second repository with the same basename makes the legacy key+ // ambiguous; normalization must not silently choose either project.+ let (other, _) = store+ .writer+ .resolve_project_by_identity_for_capture(+ ws,+ RepositoryIdentity {+ identity: "github.com/other/api".into(),+ source: IdentitySource::GitRemote,+ },+ IdentityStyle::Path,+ "other-api",+ Some("/other/api".into()),+ None,+ None,+ )+ .await+ .unwrap();+ assert_ne!(other, project);+ for scope in ["workspace=default&project=api", "scope=default/api"] {+ let uri = format!("/search?q=aliaslookupword&{scope}");+ let (status, html) = get_text(&app, &uri, None).await;+ assert_eq!(status, StatusCode::BAD_REQUEST, "{uri}: {html}");+ assert!(!html.contains("notes/alias.md"), "{html}");+ }+ let (status, html) = get_text(+ &app,+ "/search?q=aliaslookupword&scope=default/acme-api",+ Some(users[0]),+ )+ .await;+ assert_eq!(status, StatusCode::OK, "{html}");+ assert!(html.contains("notes/alias.md"), "{html}");+}diff --git a/docs/features.md b/docs/features.mdindex 4ca4b601..89d08e8c 100644--- a/docs/features.md+++ b/docs/features.md@@ -206,6 +206,10 @@ normal retrieval. Declared contradictions include only live, readable far ends,and they do not decide which statement is correct. Evidence pages hold twentycitations.+Project searches accept canonical and legacy project keys; their result links,+breadcrumb and scope selector use the current stored name. Searching does not+rename the project.+Search result links carry the query, filters, result limit and the project orglobal mode. "Recompute explanation" runs the same authorized ranker on demandand shows stream ranks, RRF contributions, authority and optional rerankingdiff --git a/docs/security-boundaries.md b/docs/security-boundaries.mdindex 9eab6ef6..72258675 100644--- a/docs/security-boundaries.md+++ b/docs/security-boundaries.md@@ -142,7 +142,7 @@ the legitimate restricted-project control and the failed-query cases.| 14d | `include_related` and the web page's backlinks show and walk only readable projects (#708) | `ai-memory-store/src/reader.rs` `related_walk(.., viewer)` — both the outgoing and incoming hop queries carry `readable_repository_predicate("pg.project_id", viewer)`, the same far-end filter `page_links` and `page_links_preview` apply (the preview's visible totals are counted under it too), so a page in a project the viewer cannot read is neither returned nor expanded; `ai-memory-mcp/src/server.rs` `memory_read_page` passes `viewer_from_parts`, `ai-memory-web/src/routes/page.rs` passes the request's viewer to `page_links_preview`, and the access bump only touches the filtered nodes | `related_walk.rs` `the_walk_hides_and_does_not_cross_projects_the_viewer_cannot_read` (an outgoing and an incoming neighbour in an ungranted restricted project are absent, and so is a granted page reachable only through one; control: a granted restricted project is shown, and no viewer walks the whole graph) — fails with the predicate removed; `ai-memory-web` `tests/suite/routes.rs` `page_backlink_from_an_unreadable_project_is_hidden` (the `/web` page's "Cited by" omits a page in an ungranted restricted project, with no title, path or project name; controls: a reader of both projects and an unrestricted viewer see it) — fails with the page handler passing no viewer to `page_links_preview`; `related_walk.rs` `page_links_preview_caps_in_sql_and_counts_only_readable_neighbours` (back-links from an ungranted restricted project are neither listed nor counted in the total behind "and N more"; control: no viewer counts them all) — fails with the predicate removed; `ai-memory-mcp` `server.rs` `bob_does_not_see_restricted_pages_through_the_related_walk` (a 600-character UTF-8 body capped by `max_chars=500`; an ungranted user's `memory_read_page{include_related}` omits the restricted page; control: no viewer still reaches it) — fails with `memory_read_page` passing `None` instead of `viewer_from_parts` | STRONG || 14e | `memory_write_page` session evidence cites only a session of the target project (#708) | `ai-memory-mcp/src/server.rs` `memory_write_page` — a `session_id` is accepted only when `require_session_in_scope` resolves the session (where its observations landed, else its session row, as `Consolidator::session_target` does) to the same `(workspace_id, project_id)` the write grant was checked against; unknown and foreign ids get one refusal, so the error is no existence oracle; `scope: "global"` with a `session_id` is refused; `refuse_pinned_page_overwrite` keeps a write that cites a session off a pinned page; only a write to `sessions/<id>.md` reconciles the session's queued SessionEnd job | `server.rs` `write_page_refuses_a_session_from_another_project` (a foreign and an unknown session refused, no evidence row written, the foreign job still queued; control: the project's own session accepted), `session_evidence_write_leaves_a_pinned_page_alone` (control: the same write without `session_id` edits the page), `session_evidence_on_another_path_leaves_the_job_queued`, `write_page_rejects_a_malformed_or_global_session_id` — each of the scope check, the pinned check and the session-page-only reconcile proven to fail its test when removed | STRONG || 14f | Consolidation apply path validates generated cross-scope body links and every typed relation against the store (#1218, #1353) | `ai-memory-consolidate/src/link_guard.rs` `unresolved_generated_links` keeps body and relation refusals separate. Every `[[project:path]]` / `[[workspace/project:path]]` / `[[_global:path]]` target in a proposed body is resolved with the no-create `lookup_existing_scope` and batch-checked via `reader.rs` `existing_latest_paths`; a missing workspace/project, ambiguous project name, missing or TTL-expired target de-links the body link. Every typed `relations:` target is checked too, including same-project targets; a local target is admitted only when its latest version is unexpired or it is another page in the same atomic batch. `prune_relations` drops malformed and unresolved entries. Same-project body links stay untouched by design. Wired into consolidation single/batch and bootstrap before writes; restricted cross-project probes reveal no paths | `consolidator.rs` `batch_delinks_invented_cross_scope_wikilinks`, `single_page_delinks_invented_cross_scope_wikilinks`, `single_page_drops_unresolved_cross_scope_relations`; `link_guard.rs` `same_project_relations_require_existing_or_same_batch_targets` (missing local relation refused, same-batch relation and dangling local body link controls), malformed and cross-scope prune tests; bootstrap cross-scope test; store `multi_session.rs` `existing_latest_paths_reports_exactly_the_live_paths` (expired target refused, live and future-expiry controls admitted), `existing_latest_paths_reports_nothing_for_a_restricted_project` | STRONG |-| 14g | Web project search and its recall trace honour `memory_query`'s scope rules (#708) and never describe another project | `ai-memory-web/src/routes/search.rs` resolves `workspace`+`project` through `resolve_read_scope` (`lookup_existing_scope_guarded`, no-create, `ProjectAccess::Read`) before any ranking, and refuses partial scope; scoped `/api/v1/search` keeps `lookup_project` / `resolve_many_existing_scopes_guarded`; `ai-memory-web/src/recall.rs` ranks only the resolved scopes through `ReaderPool::hybrid_search_scopes`, whose streams and graph expansion are bound to each `(workspace_id, project_id)`; a search with no scope stays `search_pages_with_meta(.., viewer)` (readable repositories only) | `ai-memory-web` `tests/suite/recall_trace.rs` — `project_search_refuses_a_restricted_project_without_a_grant` (bob, with no grant, gets 403 from `/web/search` with and without `explain=1` and from scoped `/api/v1/search`, with no path, body text or trace in the response, and a `scopes` POST naming the restricted project next to an open one is refused; alice's grant and an unrestricted viewer are the controls), `project_search_fails_closed_on_unknown_and_partial_scope` (unknown project or workspace 404 with nothing created, partial scope 400), `explain_renders_stream_ranks_rrf_authority_and_timings` (a better-matching page in a sibling project never reaches the hits or the trace), `search_scope_selector_lists_only_readable_projects` (the search page's "Search in" selector lists only projects the viewer may read, and a hand-typed `scope=` for an ungranted project is a 403 that leaks nothing; controls: the granted reader and an unrestricted viewer; passing no viewer to `list_projects_with_stats` in the handler fails it), `routes.rs` `search_page_scope_selector_round_trips_and_rejects_malformed_values` (a malformed `scope` is a 400); `recall_trace.rs` `kind_filter_does_not_widen_what_a_viewer_can_read` (a `kind`/`tier` filter only narrows: bob gets no hits and a 403 on a scoped search; alice and an unrestricted viewer are the controls), `search_filters_a_project_by_kind_and_tier_keeping_rank_order` (survivors of a filter keep the unfiltered order), `reranker_is_shown_only_the_pages_the_filter_keeps` (a dropped page never reaches the reranker), `kind_and_tier_filters_hold_in_every_stream` (FTS, entity, vector, observation and both graph directions each filter in SQL; dropping any one stream's predicate fails it), `kind_filter_finds_a_rare_kind_the_unfiltered_page_ranks_out` and `cross_project_kind_filter_sees_past_the_candidate_window` (the filter sees past the candidate window in both modes); `ai-memory-mcp` `tests/suite/web_search_parity.rs` (same top-k order as `memory_query` from `/web` and `/api/v1`, with a deterministic embedder and with none, explain on and off, and merged `scopes`; controls show a web search without the embedder, or the old FTS-only scoped search, would fail it) | STRONG. Bite checks: passing no viewer to `resolve_read_scope` in the search handler, to `lookup_project` or to `resolve_scopes` in the API each fails the restricted-project test; dropping the query vector in `recall.rs` fails the embedder parity tests |+| 14g | Web project search and its recall trace honour `memory_query`'s scope rules (#708) and never describe another project | `ai-memory-web/src/routes/search.rs` resolves `workspace`+`project` through `resolve_read_scope` (`lookup_existing_scope_guarded`, no-create, `ProjectAccess::Read`) before any ranking, and refuses partial scope; scoped `/api/v1/search` keeps `lookup_project` / `resolve_many_existing_scopes_guarded`; `ai-memory-web/src/recall.rs` ranks only the resolved scopes through `ReaderPool::hybrid_search_scopes`, whose streams and graph expansion are bound to each `(workspace_id, project_id)`; a search with no scope stays `search_pages_with_meta(.., viewer)` (readable repositories only) | `ai-memory-web` `tests/suite/recall_trace.rs` — `project_search_refuses_a_restricted_project_without_a_grant` (bob, with no grant, gets 403 from `/web/search` with and without `explain=1` and from scoped `/api/v1/search`, with no path, body text or trace in the response, and a `scopes` POST naming the restricted project next to an open one is refused; alice's grant and an unrestricted viewer are the controls), `project_search_fails_closed_on_unknown_and_partial_scope` (unknown project or workspace 404 with nothing created, partial scope 400), `explain_renders_stream_ranks_rrf_authority_and_timings` (a better-matching page in a sibling project never reaches the hits or the trace), `search_scope_selector_lists_only_readable_projects` (the search page's "Search in" selector lists only projects the viewer may read, and a hand-typed `scope=` for an ungranted project is a 403 that leaks nothing; controls: the granted reader and an unrestricted viewer; passing no viewer to `list_projects_with_stats` in the handler fails it), `routes.rs` `search_page_scope_selector_round_trips_and_rejects_malformed_values` (a malformed `scope` is a 400), `search_alias_links_require_a_grant_and_refuse_ambiguous_names` (canonical and legacy keys, before and after promotion, refuse an ungranted reader without hits or trace, including an empty query; a granted reader and root are controls, and an ambiguous legacy key stays a 400); `recall_trace.rs` `kind_filter_does_not_widen_what_a_viewer_can_read` (a `kind`/`tier` filter only narrows: bob gets no hits and a 403 on a scoped search; alice and an unrestricted viewer are the controls), `search_filters_a_project_by_kind_and_tier_keeping_rank_order` (survivors of a filter keep the unfiltered order), `reranker_is_shown_only_the_pages_the_filter_keeps` (a dropped page never reaches the reranker), `kind_and_tier_filters_hold_in_every_stream` (FTS, entity, vector, observation and both graph directions each filter in SQL; dropping any one stream's predicate fails it), `kind_filter_finds_a_rare_kind_the_unfiltered_page_ranks_out` and `cross_project_kind_filter_sees_past_the_candidate_window` (the filter sees past the candidate window in both modes); `ai-memory-mcp` `tests/suite/web_search_parity.rs` (same top-k order as `memory_query` from `/web` and `/api/v1`, with a deterministic embedder and with none, explain on and off, and merged `scopes`; controls show a web search without the embedder, or the old FTS-only scoped search, would fail it) | STRONG. Bite checks: passing no viewer to `resolve_read_scope` in the search handler, to `lookup_project` or to `resolve_scopes` in the API each fails the restricted-project test; dropping the query vector in `recall.rs` fails the embedder parity tests || 14h | Wiki link graph pages and JSON show only readable projects (#708) | `ai-memory-web/src/routes/graph.rs` `global_handler` calls `ReaderPool::cross_project_edges(None, viewer)` so an edge needs both ends readable; `project_handler` resolves through `resolve_read_scope` (`lookup_existing_scope_guarded`, no-create, `ProjectAccess::Read`) then `project_link_graph`, which ranks and caps nodes in SQL before loading them and queries only edges whose endpoints are among those selected pages; `api.rs` `graph_handler` accepts `workspace`+`project` together (partial scope 400) and passes the same viewer filter, and `project_graph_handler` uses `lookup_project` | `routes.rs` `metadata_shows_only_what_the_viewer_may_read` (HTML `/web/graph`, `/web/w/…/graph`, `/api/v1/…/graph`, and scoped `/api/v1/graph?workspace=&project=`: bob cannot see alpha or client-work, a 403 on alpha's graph leaks neither title nor path, a scoped graph hides an edge whose far end he cannot read; carol and no-viewer controls keep the edge; partial scope 400); store `project_link_graph.rs` hides expired pages, omits cross-project and unresolved links, and verifies the 120-node SQL cap preserves high-degree nodes; `graph.rs` `graph_page_renders_hostile_titles_inert` | STRONG. Bite checks: passing no viewer to `cross_project_edges` in the HTML global handler, resolving the project graph through unguarded `lookup_existing_scope`, or removing the SQL limit fails the restricted-project or node-cap assertions || 14i | Decoded ordinary Markdown destinations stay inside their original project | `ai-memory-wiki/src/markdown.rs` `decode_markdown_destination_path` decodes URL path bytes once before `normalize_link_target` applies scheme, separator and project-root traversal checks; wikilinks remain literal. `ai-memory-web/src/markdown.rs` `scope_relative_link` checks the decoded path before route encoding; an encoded spelling cannot become a generated cross-scope route. | `markdown_url_paths_decode_once_before_link_resolution` (space, Unicode and literal-percent controls); `decoded_markdown_paths_cannot_escape_or_change_scope` (encoded root escape, backslash, external scheme, invalid UTF-8 and controls refused; legitimate in-root normalization passes); `routes.rs` `encoded_markdown_links_resolve_and_remain_in_the_source_scope` writes colliding targets in sibling projects and workspaces, verifies home resolution and no foreign backlinks, and follows the generated home URL; web `decoded_markdown_destinations_cannot_change_the_web_scope` (encoded traversal, root route, separator and scheme refused, encoded `w/` remains a page inside the current scope); `markdown_url_destinations_are_decoded_once_before_route_encoding` | STRONG for one-decode path handling and project confinement; URL grammar outside local Markdown destinations remains owned by the Markdown parser and existing safe-URL checks || 14j | Structured MCP query filters only narrow authorized page results | `ai-memory-mcp/src/server.rs` parses bounded `kind`, `tier`, literal `path_prefix` and exact `tag` values without changing the normal scope-shape or authorization paths, then passes one typed `PageFilter` through project, multi-scope, cross-project, reserved-global/profile, historical and pinned searches. `ai-memory-store/src/reader.rs` binds every filter value as a SQL parameter before each stream's candidate cut; path wildcard characters are escaped and an exact binary-prefix check preserves case, while tags match only string members of a JSON array. A filtered miss cannot fall through to raw observations, which carry no page metadata. | `server.rs` `memory_query_filters_apply_before_every_result_source` combines all filters and covers literal `%`/`_`, case-sensitive paths, tag arrays versus scalars, multi-scope and global search, `as_of`, superseded metadata, `pin_first`, the reserved-global/profile union, traversal-shaped input, invalid tiers, controls and Unicode length bounds; store `structured_filters_hold_in_vector_and_both_graph_directions` isolates path filtering in the vector stream and tag filtering in outgoing and incoming graph expansion; `page_filtering_precedes_the_observation_candidate_cut` puts 80 stronger excluded observations ahead of an eligible tagged session; `memory_query_returns_raw_hits_when_pages_miss` proves an unfiltered miss retains fallback while a filtered miss omits it; `prompts_and_tool_schema_document_query_options` pins the public schema. Existing web every-stream and authorization tests in row 14g exercise kind/tier across the same shared SQL. | STRONG: filters are candidate predicates, never an alternative scope resolver. Empty filter fields normalize to absent for backward compatibility; observation fallback remains available only to unfiltered queries. |