Current gap
SourceCorpus already versions game-scoped documents with SQLite FTS5, but run completion saves the assistant answer as the content for every citation. That is not the fetched source. Tool output must be captured at dispatch/event time, not reconstructed from citations.
Critical integration decision: add a Hermes-side redacted tool-result capture hook/plugin and structured capture envelope. Do not make the Nagato bridge bypass Hermes and call GTC directly. The current Runs API does not expose arguments or raw results, so this upstream seam is the first implementation prerequisite.
Capture pipeline
Coverage
| Tool family | Save | Normalize |
|---|---|---|
| GTC search/answer | Raw result JSON, query, ranked URLs/snippets | One discovery artifact plus source stubs |
| GTC scrape/extract/llmstxt | Complete returned text/markdown and metadata | Canonical URL document version |
| GTC crawl/map/agent | Manifest and each page payload | Parent job + child documents |
| HTTP/curl-like tools | URL, status, safe headers, content body/hash | Typed source when content is textual |
| Local files | Path alias, file hash, extracted text | Manual/PDF/install document |
Data model
source_artifacts(id, game_id, run_id, tool_call_id, source_uri, source_kind, title, fetched_at, status, content_type, raw_blob_id, content_hash, parent_id, license_hint, trust, metadata_json) document_versions(id, artifact_id, canonical_uri, normalized_text, extractor, extractor_version, language, created_at) source_chunks(id, version_id, ordinal, heading_path, text, token_count) run_source_links(run_id, artifact_id, use=cited|consulted|discovered)
Policy
- Auto-save tool outputs only under current canonical
game_id. - Redact credentials, cookies, authorization headers and configured sensitive argument fields before disk.
- Keep content hashes and retrieval timestamps; never silently overwrite versions.
- Allow per-game corpus pause, source deletion, export and storage quotas.
- Do not indiscriminately republish copyrighted content; local personal indexing stores extracted content and source attribution.
- Robots/terms, authentication boundaries and paywalls remain respected by the tools.
Also update packages/protocol/game-command.schema.json: the bridge already implements corpus_save/corpus_search, but the shared command schema does not currently declare them.
UI
Add a Sources view under Research or as a card drill-down: source title/type/trust/date/size/version count, open original, raw artifact, extracted text, chunks, citing runs, refresh and delete. A response’s citations should link to the exact stored version used.
Acceptance
- A GTC scrape result is retrievable byte-for-byte after restart.
- A citation links to exact source version, not a copy of the assistant answer.
- Repeated identical fetch dedupes by canonical URI + hash; changed content creates a version.
- Secrets are absent from persisted fixtures.
- Deleting a game corpus removes documents, chunks, embeddings and raw blobs safely.