MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _find_existing

Method _find_existing

uncommon_route/artifacts.py:134–158  ·  view source on GitHub ↗
(
        self,
        *,
        sha256: str,
        kind: str,
        role: str,
        session_id: str,
        tool_name: str,
        tool_call_id: str,
    )

Source from the content-addressed store, hash-verified

132 return sum(1 for _ in self._root.glob("*.json"))
133
134 def _find_existing(
135 self,
136 *,
137 sha256: str,
138 kind: str,
139 role: str,
140 session_id: str,
141 tool_name: str,
142 tool_call_id: str,
143 ) -> ArtifactRecord | None:
144 for meta_path in self._root.glob("*.json"):
145 try:
146 meta = json.loads(meta_path.read_text())
147 except Exception:
148 continue
149 if (
150 meta.get("sha256") == sha256
151 and meta.get("kind", "raw") == kind
152 and meta.get("role") == role
153 and meta.get("session_id", "") == session_id
154 and meta.get("tool_name", "") == tool_name
155 and meta.get("tool_call_id", "") == tool_call_id
156 ):
157 return ArtifactRecord(**meta)
158 return None
159
160 def _meta_path(self, artifact_id: str) -> Path:
161 return self._root / f"{artifact_id}.json"

Callers 1

store_textMethod · 0.95

Calls 2

ArtifactRecordClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected