foley.agent.protocols#
The structural DI seams of the SELECT stage — Decomposer / Judge / Refiner.
Three @runtime_checkable typing.Protocols (PEP 544), each a
behaviour-free, open-closed contract that every implementation (the deterministic
fake and the Anthropic-backed real impl) satisfies. They are dependency-injected
into foley.agent.find() by keyword (decomposer= / judge= / refiner=),
defaulting to a hermetic fake when anthropic (the foley[agent] extra) is absent.
Stdlib-only: the base shapes are imported under TYPE_CHECKING only (mirroring
foley.index.protocols), so importing this module pulls no heavy dependency and
keeps import foley dol-only.
Classes
|
Narrative context → a sparse, salience-ranked, diegetic-tagged event list. |
|
One rung of the verify ladder: does this candidate match this event? (report 10 §4.2). |
|
One event query → 2–4 paraphrases/expansions (query-expansion for retrieval). |
- class foley.agent.protocols.Decomposer(*args, **kwargs)[source]#
Bases:
ProtocolNarrative context → a sparse, salience-ranked, diegetic-tagged event list.
Turns a story/commentary passage into
<= max_eventsSoundEvents, enforcing the salience/density budget and the anachronism (era_place) guard. The default is the deterministicKeywordDecomposer;AnthropicDecomposeris the LLM-backed impl.
- class foley.agent.protocols.Judge(*args, **kwargs)[source]#
Bases:
ProtocolOne rung of the verify ladder: does this candidate match this event? (report 10 §4.2).
levelselects the rung —clap(cheap score gate),listen(audio-LM),judge(LLM arbitration + scene consistency). The returnedVerdictcarrieslevel== the rung that produced it. Only thejudgerung’s real impl calls the LLM.
- class foley.agent.protocols.Refiner(*args, **kwargs)[source]#
Bases:
ProtocolOne event query → 2–4 paraphrases/expansions (query-expansion for retrieval).
hintcarries the verify-failure reason so the re-retrieval loop can steer the next paraphrases. v1 feeds the list into a multi-query RRF search (embedding-fusion is a later drop-in behind this same seam). The default is the deterministicKeywordRefiner.