Skip to content

symfonic.capabilities.knowledge.assembly

assembly

The seam between this capability and the prompt compiler.

One function, and it returns a mapping rather than a compiler object. That is the whole design: the composition root โ€” which is allowed to see both capabilities โ€” turns the spec into a PromptContribution; this package never imports the prompting package, so neither capability can quietly start depending on the other's internals.

A mapping is also what makes the alignment testable. tests/capabilities/ knowledge/test_prompting_seam.py holds both halves at once and compiles a real prompt from a real spec, so a vocabulary drift shows up as a red test rather than as a runtime ValueError in an adopter's deployment.

contribution_spec

contribution_spec(contribution: ContextContribution) -> Mapping[str, object]

Project a validated declaration into compiler-ready keyword values.

Validation runs first and unconditionally. A spec is the last moment this capability controls, so emitting one for a declaration it would have refused would move the refusal into the compiler, where the error message can no longer explain which bridge got it wrong.

Enum members are emitted as their string values. The prompt contract's layers, tiers, and scopes are StrEnums over the same strings, so the composition root's conversion is total by construction.

Source code in src/symfonic/capabilities/knowledge/assembly.py
def contribution_spec(contribution: ContextContribution) -> Mapping[str, object]:
    """Project a validated declaration into compiler-ready keyword values.

    Validation runs first and unconditionally. A spec is the last moment this
    capability controls, so emitting one for a declaration it would have
    refused would move the refusal into the compiler, where the error message
    can no longer explain which bridge got it wrong.

    Enum members are emitted as their string values. The prompt contract's
    layers, tiers, and scopes are ``StrEnum``s over the same strings, so the
    composition root's conversion is total by construction.
    """
    contribution.validate()
    return MappingProxyType(
        {
            "contribution_id": contribution.contribution_id,
            "source": contribution.source,
            "capability": contribution.capability,
            "layer": contribution.layer.value,
            "tier": contribution.tier.value,
            "scope": contribution.scope.value,
            "order": contribution.order,
            "inherit": contribution.inherit,
            "pinned": contribution.pinned,
            "requires_hydration": contribution.requires_hydration,
        }
    )