symfonic.capabilities.prompting.declarations¶
declarations ¶
Turning what a composition root declares into what the compiler compiles.
persona_sources and guardrail_sources return sources -- the objects
with a read. The compiler works on contributions, which wrap a source
with where it sits and what may drop it. A composition root handed the first
had to know the second existed, and the mismatch did not fail where it was
made: it surfaced inside the compiler as a missing validate on a type that
file never names.
One function, so both doors of :class:PromptingCapability normalise the same
way and a declaration list means the same thing at declaration time and at
stage time.
as_contributions ¶
Accept a declaration or a bare source; return declarations.
Identity comes from the source's own type and its position, which keeps
two personas in one list distinct and keeps the declared order the compile
order -- the ordering persona_sources documents (identity first) is a
promise about this list, so it must survive the wrapping.
Source code in src/symfonic/capabilities/prompting/declarations.py
split_by_door ¶
Partition declared sources into ones the sync door can read, and awaited ones.
Needed because :meth:PromptingCapability.contribute is synchronous — a
capability declares its stage before any loop is running — while an awaited
source can only be read once the stage runs. The partition is what keeps the
descriptor honest: static_prompt_digest covers what was actually
compiled here, and awaited_sources counts what it could not cover.
A source offering both members is not deferred: the synchronous door can read it, so the digest covers it and the async door still awaits it at stage time.