API

Retrieve Endpoint

paginateCcrStore (sqlite/in-memory)inline_ccr LRUhandle_retrievecaller (Hermes / curl)paginateCcrStore (sqlite/in-memory)inline_ccr LRUhandle_retrievecaller (Hermes / curl)alt[hash missing]alt[backend hit][miss or no backend]alt[inline hit][inline miss]alt[offset at or past end, non-empty document][full-document window][partial window]POST /retrieve with hash, query?, offset?, limit?1normalize_hash - strip |type|size suffix, trim2400 - hash required3inline_ccr.get(hash)4content (inline_ccr_hits++, ccr_hits++)5ccr_get(hash)6content (ccr_hits++)7404 - CCR entry not found8filter_content(query) - case-insensitive, capped at 512 chars9paginate(offset, limit)10out of range - 40011original bytes verbatim, truncated=false12[lines a-b/total] header, truncated=true13200 - found:true, content, source:ccr, truncated14
RETRIEVE FLOW
IN THIS DOCUMENT

Crimson marks the heading currently in view; every entry is one of the document's own headings.

POST /retrieve resolves a CCR hash back to its original content, with optional line filtering and pagination. It is the HTTP path behind the aphrodite_retrieve tool and external callers.

Endpoint

MethodPathAccessAuth
POST/retrieveLoopbackBearer token when APHRODITE_MGMT_TOKEN is set

Loopback only, plus Authorization: Bearer <token> when APHRODITE_MGMT_TOKEN is set (unset = any loopback caller, back-compat) - see Environment Variables.

Request

{
	"hash": "abc123...",
	"query": "optional filter string",
	"offset": 0,
	"limit": 100
}

Request Schema

pub struct RetrieveRequest {
    pub hash: Option<String>,       // Required
    pub query: Option<String>,      // Optional: case-insensitive line filter
    #[serde(default)]
    pub offset: usize,              // 0-based line offset for pagination
    #[serde(default)]
    pub limit: usize,               // Max lines (0 = FULL document, no cap; explicit limits clamp to 10,000)
}

handle_retrieve normalized the hash argument before lookup: it stripped the |type|size marker-body suffix and surrounding whitespace, so a hash echoed back in full marker form still resolves.

Response

Success (200)

{
	"found": true,
	"content": "original content...",
	"source": "ccr",
	"error": null,
	"truncated": false
}

truncated is true when content is a partial window of a larger stored document - because of offset/limit, or because an explicit limit hit the 10,000-line server cap.

limit: 0 requests the FULL document and never truncates - see Pagination.

Not Found (404)

{
	"found": false,
	"content": null,
	"source": "none",
	"error": "CCR entry not found: abc123...",
	"truncated": false
}

Bad Request (400)

{
	"found": false,
	"content": null,
	"source": "none",
	"error": "`hash` required",
	"truncated": false
}

Pagination Out of Range (400)

{
	"found": false,
	"content": "[offset 500 out of range; document has 42 lines]",
	"source": "ccr",
	"error": null,
	"truncated": false
}

Response Schema

pub struct RetrieveResponse {
    pub found: bool,
    pub content: Option<String>,
    pub source: String,           // "ccr" on success, "none" on error
    pub truncated: bool,          // true if content is a partial window
    pub error: Option<String>,
}

Retrieve Flow

paginateCcrStore (sqlite/in-memory)inline_ccr LRUhandle_retrievecaller (Hermes / curl)paginateCcrStore (sqlite/in-memory)inline_ccr LRUhandle_retrievecaller (Hermes / curl)alt[hash missing]alt[backend hit][miss or no backend]alt[inline hit][inline miss]alt[offset at or past end, non-empty document][full-document window][partial window]POST /retrieve with hash, query?, offset?, limit?1normalize_hash - strip |type|size suffix, trim2400 - hash required3inline_ccr.get(hash)4content (inline_ccr_hits++, ccr_hits++)5ccr_get(hash)6content (ccr_hits++)7404 - CCR entry not found8filter_content(query) - case-insensitive, capped at 512 chars9paginate(offset, limit)10out of range - 40011original bytes verbatim, truncated=false12[lines a-b/total] header, truncated=true13200 - found:true, content, source:ccr, truncated14
RETRIEVE FLOW

Query Filter

fn filter_content(content: &str, query: Option<&str>) -> String {
    match query {
        Some(q) if !q.is_empty() => {
            // Truncate FIRST, char-boundary-safe, then match case-insensitively
            let q = floor_boundary(q, 512);
            let q_lower = q.to_ascii_lowercase();
            let filtered: Vec<&str> = content
                .lines()
                .filter(|line| line.to_ascii_lowercase().contains(&q_lower))
                .collect();
            if filtered.is_empty() {
                format!("[no lines matching {:?} in {} lines]", q, content.lines().count())
            } else {
                filtered.join("\n")
            }
        },
        _ => content.to_string(),
    }
}
BehaviorDetail
MatchingCase-insensitive substring match per line
Query lengthTruncated to 512 chars (char-boundary-safe)
No matchesReturns [no lines matching "q" in N lines]

Pagination

limit: 0 requests the FULL document with no cap - this is the round-trip contract: a full-document retrieval returns the exact original bytes (the lossy lines/join round-trip is skipped entirely, so a trailing newline is preserved and the body hashes back to the marker’s own hash).

Any explicit limit - including one above 10,000 - is clamped to a 10,000-line server cap.

When the returned window does not cover the whole document (because of offset, an explicit limit, or the cap), a [lines a-b/total] header is prepended to content and truncated is true, so a caller can distinguish a truncated result from a genuinely short document without parsing the header.

An empty stored document (content: "") is a valid zero-line entry, not an out-of-range offset - it returns empty content with truncated: false.

Source Tracking

source valueMeaning
"ccr"Found - served by the inline store or CCR backend
"none"Not found (error response)

The success path always reports "ccr" regardless of which store served the content. source is "none" on 400/404 error responses.

Production Notes

  • The inline_ccr lock is dropped before any .await, so a !Send MutexGuard never crosses an await point; the inline check-and-resolve is scoped in a block.
  • No zstd decompression happens on this path: backends store and return content verbatim as UTF-8 strings, so retrieval is byte-exact by construction.