(&self)
| 417 | |
| 418 | impl Command for MemoryList { |
| 419 | fn run(&self) -> CliResult<()> { |
| 420 | if crate::commands::rpc::memory_list(self)? { |
| 421 | return Ok(()); |
| 422 | } |
| 423 | |
| 424 | let root = find_repository_root()?; |
| 425 | let repo = |
| 426 | crate::commands::open_readonly_repository(&root).map_err(CliError::Repository)?; |
| 427 | |
| 428 | let verifier = resolve_verifier(&self.identity)?; |
| 429 | |
| 430 | // Enumerate via the SAME call `atomic vault memory list` makes; the |
| 431 | // `memory/` prefix already excludes attestation entries, and the filter |
| 432 | // is a belt-and-suspenders guard (mirrors memory/mod.rs' invariant test). |
| 433 | let entries = repo |
| 434 | .vault_list("memory/", None) |
| 435 | .map_err(CliError::Repository)?; |
| 436 | let mut items: Vec<(String, String)> = entries |
| 437 | .iter() |
| 438 | .filter(|e| !e.path.starts_with("attestations/")) |
| 439 | // The default `memory/MEMORY.md` index scaffold is NOT a canonical |
| 440 | // memory (no `uid`/`memoryKind`; its frontmatter is `type:index`). |
| 441 | // Skip it so the attestation-aware list only shows real memories. |
| 442 | .filter(|e| !is_index_scaffold(&repo, &e.path)) |
| 443 | .map(|e| (bridge::memory_id(&e.path), e.updated_at.clone())) |
| 444 | .collect(); |
| 445 | // Most-recent first (`updated_at` is RFC 3339, so lexical == chronological); |
| 446 | // id as a stable tiebreaker. |
| 447 | items.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0))); |
| 448 | // The default order needs only (id, updated), so `--limit` can cut |
| 449 | // before the per-row attestation work; any other key needs every |
| 450 | // row's computed columns first. |
| 451 | if self.is_default_sort() { |
| 452 | if let Some(limit) = self.limit { |
| 453 | items.truncate(limit); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | let mut rows: Vec<Row> = items |
| 458 | .iter() |
| 459 | .map(|(id, updated)| Row { |
| 460 | updated: updated.clone(), |
| 461 | ..compute_row(&repo, id, verifier.as_ref()) |
| 462 | }) |
| 463 | .collect(); |
| 464 | if !self.is_default_sort() { |
| 465 | sort_rows(&mut rows, self.sort, self.reverse); |
| 466 | if let Some(limit) = self.limit { |
| 467 | rows.truncate(limit); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | if self.json { |
| 472 | let json: Vec<serde_json::Value> = rows |
| 473 | .iter() |
| 474 | .map(|r| { |
| 475 | serde_json::json!({ |
| 476 | "id": r.id, |
nothing calls this directly
no test coverage detected