omnigraph/crates
Ragnor Comerford ca474e23b1
mr-668: derive any_per_graph_policy on RegistrySnapshot; simplify dup check
`AppState::requires_bearer_auth` walked the entire registry per
request (cloning Arcs into a `Vec`, then `.iter().any(|h| h.policy
.is_some())`) to decide whether the auth middleware should challenge.
The walk is unnecessary — the answer only changes when the registry
mutates, which is exactly the moment a new snapshot is constructed.

Move the flag onto the snapshot itself:

* `RegistrySnapshot { graphs, any_per_graph_policy: bool }`.
* `RegistrySnapshot::new(graphs)` is the only construction path —
  it derives the flag from `graphs.values().any(|h| h.policy
  .is_some())` so the cached value can't drift from the source data.
* `Default` delegates to `new(HashMap::new())`.
* `GraphRegistry::from_handles` and `insert` build snapshots via
  `RegistrySnapshot::new(...)`.
* `GraphRegistry::snapshot_ref()` exposes the current snapshot
  through an `arc_swap::Guard`; callers that need cached derived
  state go through this accessor (callers that only want `graphs`
  still use `list` / `get`).

`requires_bearer_auth` becomes one `ArcSwap::load` + bool read.

Also (drive-by, same file, same hunk): replace the dead
`if let Some(other) = seen_uris.get(...)` + `let _ = other;` pattern
in `from_handles` with a plain `seen_uris.contains_key(...)`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 12:02:51 +02:00
..
omnigraph mr-668: comment cleanup and policy format style 2026-05-27 11:57:04 +02:00
omnigraph-cli mr-668: drop actor_id from PolicyRequest; pass actor as separate arg 2026-05-27 12:00:52 +02:00
omnigraph-compiler mr-668: composite e2e tests, race fix, v0.7.0 release (PR 9/10) 2026-05-25 21:32:49 +02:00
omnigraph-policy mr-668: drop actor_id from PolicyRequest; pass actor as separate arg 2026-05-27 12:00:52 +02:00
omnigraph-server mr-668: derive any_per_graph_policy on RegistrySnapshot; simplify dup check 2026-05-27 12:02:51 +02:00