Architecture

Retrieve & Recursive Marker Resolution

paginatefilter_contentCcrStore (sqlite/in-memory)inline_ccr LRU (proxy AppState)marker::normalize_hashhandle_retrievecaller (Hermes / curl)paginatefilter_contentCcrStore (sqlite/in-memory)inline_ccr LRU (proxy AppState)marker::normalize_hashhandle_retrievecaller (Hermes / curl)alt[hash missing]alt[backend HIT][miss / no backend]alt[inline HIT][inline miss]alt[offset >= total (non-empty doc)][full-document window][partial window]POST /retrieve {hash, query?, offset?, limit?}1normalize_hash(hash) (strip |type|size suffix, trim)2400 {found:false, error:"`hash` required"}3inline_ccr.get(hash)4content (inline_ccr_hits++, ccr_hits++)5ccr_get(hash).await (inline_ccr_misses++)6content (ccr_hits++)7404 {found:false, error:"CCR entry not found"}8filter_content(content, query) (case-insensitive, query capped 512 chars)9paginate(content, offset, limit)10Err → 400 "[offset N out of range]"11(content verbatim, truncated=false) ← byte-exact, keeps trailing \n12("[lines a-b/total]\n...", truncated=true)13200 {found:true, content, source:"ccr", truncated}14
/RETRIEVE HTTP PATH
resolve_oneyes cyclenoyesnoyesnononeyesyesnoyesnoexpand(state, hash)resolve_recursive(depth=0)hash in visited?return resolved.get(hash) - cached pre-expansionvaluevisited.push(hash)depth >= RECURSIVE_DEPTH (5)?resolve_one(state,hash) - RAW leaf content, nofurther expandresolved cache hit?return cachedcontent = resolve_one(hash)? (None → propagate)resolved.insert(hash, content)find_markers(content) - scan <<<CCR:...>>>nested markers?return contentfor each nested: recurse(depth+1) or reuse cachereplace marker text with resolved valuenested unresolved?LEAVE original marker text intact - may heallatersubstitutereturn result - NOT written back over hash(content-address invariant)normalize_hashi: prefix?inline_store_get (inline-only)inline_store_get(hash)
RECURSIVE RESOLUTION (RESOLVE::EXPAND)
IN THIS DOCUMENT

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

Two related paths turn a <<<CCR:hash|type|size>>> marker back into content:

  • the HTTP /retrieve endpoint (inline_ccr → CcrStore, query filter + pagination, byte-exact round-trip)
  • and the in-process recursive resolver resolve::expand (nested markers, depth limit, cycle-safe, never writes back).

/retrieve HTTP path

paginatefilter_contentCcrStore (sqlite/in-memory)inline_ccr LRU (proxy AppState)marker::normalize_hashhandle_retrievecaller (Hermes / curl)paginatefilter_contentCcrStore (sqlite/in-memory)inline_ccr LRU (proxy AppState)marker::normalize_hashhandle_retrievecaller (Hermes / curl)alt[hash missing]alt[backend HIT][miss / no backend]alt[inline HIT][inline miss]alt[offset >= total (non-empty doc)][full-document window][partial window]POST /retrieve {hash, query?, offset?, limit?}1normalize_hash(hash) (strip |type|size suffix, trim)2400 {found:false, error:"`hash` required"}3inline_ccr.get(hash)4content (inline_ccr_hits++, ccr_hits++)5ccr_get(hash).await (inline_ccr_misses++)6content (ccr_hits++)7404 {found:false, error:"CCR entry not found"}8filter_content(content, query) (case-insensitive, query capped 512 chars)9paginate(content, offset, limit)10Err → 400 "[offset N out of range]"11(content verbatim, truncated=false) ← byte-exact, keeps trailing \n12("[lines a-b/total]\n...", truncated=true)13200 {found:true, content, source:"ccr", truncated}14
/RETRIEVE HTTP PATH

Pagination facts: an explicit nonzero limit clamps to a 10,000-line server cap; limit == 0 is not capped and returns the full document.

An empty stored document (content: "") is a valid zero-line result, not an out-of-range offset.

A full-window retrieval skips the lossy lines()/join() round-trip entirely, so the returned bytes hash back to the marker’s own hash.

Recursive resolution (resolve::expand)

resolve_oneyes cyclenoyesnoyesnononeyesyesnoyesnoexpand(state, hash)resolve_recursive(depth=0)hash in visited?return resolved.get(hash) - cached pre-expansionvaluevisited.push(hash)depth >= RECURSIVE_DEPTH (5)?resolve_one(state,hash) - RAW leaf content, nofurther expandresolved cache hit?return cachedcontent = resolve_one(hash)? (None → propagate)resolved.insert(hash, content)find_markers(content) - scan <<<CCR:...>>>nested markers?return contentfor each nested: recurse(depth+1) or reuse cachereplace marker text with resolved valuenested unresolved?LEAVE original marker text intact - may heallatersubstitutereturn result - NOT written back over hash(content-address invariant)normalize_hashi: prefix?inline_store_get (inline-only)inline_store_get(hash)
RECURSIVE RESOLUTION (RESOLVE::EXPAND)

find_markers walks <<<CCR: …

>>> pairs, tolerating unclosed prefixes without panicking.

marker::extract_hashes additionally recognizes [CCR:...] and the ⫷...⫸ glyph forms via a LazyLock regex whose hash class is anchored to [0-9a-fA-F:i]{6,64} (never crossing a newline).

Call sites

ConcernModule
handle_retrievecrates/aphrodite/src/retrieve.rs
filter_content / paginatecrates/aphrodite/src/retrieve.rs
resolve::expand / resolve_recursive / resolve_onecrates/aphrodite/src/resolve/
find_markers / parse_marker_hashcrates/aphrodite/src/resolve/
normalize_hash / extract_hashes (HASH_RE)crates/aphrodite/src/marker/