Derive a subject URI from a vault path and entry type.
(path: &str, entry_type: VaultEntryType)
| 778 | |
| 779 | /// Derive a subject URI from a vault path and entry type. |
| 780 | pub(super) fn entry_subject(path: &str, entry_type: VaultEntryType) -> String { |
| 781 | match entry_type { |
| 782 | VaultEntryType::Session => { |
| 783 | // goals/swift-meadow-a3f2/_goal.md -> goal:swift-meadow-a3f2 |
| 784 | let name = path |
| 785 | .strip_prefix("goals/") |
| 786 | .and_then(|s| s.strip_suffix("/_goal.md")) |
| 787 | .unwrap_or(path); |
| 788 | format!("goal:{}", name) |
| 789 | } |
| 790 | VaultEntryType::Intent => { |
| 791 | // intents/pimo-1/intent.md -> intent:PIMO-1 |
| 792 | let id = path |
| 793 | .strip_prefix("intents/") |
| 794 | .and_then(|s| s.strip_suffix("/intent.md")) |
| 795 | .unwrap_or(path) |
| 796 | .to_uppercase(); |
| 797 | format!("intent:{}", id) |
| 798 | } |
| 799 | VaultEntryType::Memory => { |
| 800 | // memory/architecture.md -> memory:architecture |
| 801 | let name = path |
| 802 | .strip_prefix("memory/") |
| 803 | .and_then(|s| s.strip_suffix(".md")) |
| 804 | .unwrap_or(path); |
| 805 | format!("memory:{}", name) |
| 806 | } |
| 807 | VaultEntryType::Skill => { |
| 808 | let name = path |
| 809 | .strip_prefix("skills/") |
| 810 | .and_then(|s| s.strip_suffix(".md")) |
| 811 | .unwrap_or(path); |
| 812 | format!("skill:{}", name) |
| 813 | } |
| 814 | VaultEntryType::ToolResult => { |
| 815 | format!("tool:{}", path.replace('/', ":")) |
| 816 | } |
| 817 | VaultEntryType::Scratch => { |
| 818 | format!("scratch:{}", path.replace('/', ":")) |
| 819 | } |
| 820 | VaultEntryType::Attestation => { |
| 821 | // attestations/<sanitized-intent-id>/attested.md -> attestation:<sanitized-intent-id> |
| 822 | let name = path |
| 823 | .strip_prefix("attestations/") |
| 824 | .and_then(|s| s.strip_suffix("/attested.md")) |
| 825 | .unwrap_or(path); |
| 826 | format!("attestation:{}", name) |
| 827 | } |
| 828 | } |
| 829 | } |
| 830 | |
| 831 | /// Convert a vault path to a subject URI (simplified). |
| 832 | fn path_to_subject(path: &str) -> String { |
no outgoing calls