symfonic.core.plugins.contribution¶
contribution ¶
PluginContribution dataclass + position vocabulary.
Item 14 (7.4) — richer plugin-contribution model that lets plugins emit content at multiple cache positions (cached prefix vs. volatile suffix) without invalidating the cached prefix on every warm turn.
See BaseDomainPlugin.inject_contributions (documented in
symfonic.core.plugins.base) for the full contract. Design note:
.claude/docs/2026-05-26-plugin-api-redesign-design.md.
PluginContribution
dataclass
¶
PluginContribution(
content: str,
position: Position = "cached",
order: int = 100,
header: str | None = None,
origin: str | None = None,
cache_ttl: CacheTtl | None = None,
)
A single section emitted by a plugin into a cache position.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
str
|
Rendered text. Empty string skips the contribution silently (no header, no separator). |
position |
Position
|
|
order |
int
|
Sort key within a position. LOWER values render first.
Default |
header |
str | None
|
|
origin |
str | None
|
Engine-populated diagnostic field carrying the plugin name. Plugins MUST NOT set this; the dispatcher fills it in during dispatch so the auto-header logic and observability tooling can attribute contributions to plugins. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
with_origin ¶
render_position_group ¶
Render contributions at a single position into one joined string.
Applies the header rule (§9 of the design): the FIRST contribution
per (origin, position) gets an auto-header of
### {origin} when its header is None; subsequent
contributions from the SAME origin at the SAME position emit raw
content (no duplicate header). header="" always means "no
header". A non-empty explicit header is emitted verbatim before
the content.
Empty-string content is skipped silently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
contributions
|
list[PluginContribution]
|
All contributions for the current turn (any
position). The function filters to the requested |
required |
position
|
Position
|
Which position group to render. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Joined string for the position, or |
str | None
|
at this position produced renderable text. Returning |
str | None
|
(instead of |
str | None
|
from its layered join. |