loom.core.use_case.markers¶
Functions
|
Factory returning the runtime marker for a named agent handle parameter. |
|
Factory returning the runtime marker for the caller-identity parameter. |
|
Factory returning marker for boolean existence checks. |
|
Factory returning the runtime marker for command payload parameters. |
|
Factory returning marker for preloaded entity parameters by field. |
|
Factory returning marker for preloaded entity parameters by id. |
|
Factory returning the runtime marker for a named MCP server handle parameter. |
Classes
|
Lookup strategy used by marker-driven prefetch. |
|
Policy applied when a marker lookup does not resolve an entity. |
|
Origin of a lookup value used by Load/Exists markers. |
|
Marks a parameter as a named agent handle bound to the verified caller. |
|
Marks a parameter as the verified identity running the execution. |
|
Marks a parameter as a boolean existence check. |
|
Marks a parameter as the command payload input. |
|
Marks a parameter as a prefetched entity loaded by id. |
|
Marks a parameter as a prefetched entity loaded by an arbitrary field. |
|
Marks a parameter as a named MCP server handle bound to this execution. |
- class loom.core.use_case.markers.SourceKind(value)[source]¶
Bases:
StrEnumOrigin of a lookup value used by Load/Exists markers.
- class loom.core.use_case.markers.LookupKind(value)[source]¶
Bases:
StrEnumLookup strategy used by marker-driven prefetch.
- class loom.core.use_case.markers.OnMissing(value)[source]¶
Bases:
StrEnumPolicy applied when a marker lookup does not resolve an entity.
- loom.core.use_case.markers.Input()[source]¶
Factory returning the runtime marker for command payload parameters.
Returned value is intentionally typed as
Anyin overloads to avoidmypydefault-argument incompatibility in signatures like:cmd: Command = Input().- Return type:
- loom.core.use_case.markers.Caller()[source]¶
Factory returning the runtime marker for the caller-identity parameter.
The executor injects the
Identitythe transport verified for this execution. It is a declaration, not an ambient read: the identity travels with the execution instead of hiding in a global.Returned value is intentionally typed as
Anyin overloads to avoidmypydefault-argument incompatibility in signatures like:caller: Identity = Caller().Example:
async def execute(self, query: QuerySpec, caller: Identity = Caller()) -> Report: return await self._reports.for_owner(caller.require_subject(), query)
- Return type:
- loom.core.use_case.markers.Agent(name)[source]¶
Factory returning the runtime marker for a named agent handle parameter.
The executor resolves name against the agents compiled for this deployment and injects an
AgentHandlebound to this execution’s verified caller — the only way a use case reaches an agent (constructor injection is not offered for this resource). The output type the handle carries is read from the parameter’s ownAgentHandle[...]annotation, never from this factory, and is checked at start-up against the named agent’s declared output.Returned value is intentionally typed as
Anyin overloads to avoidmypydefault-argument incompatibility in signatures like:triage: AgentHandle[SeverityAssessment] = Agent("incident-triage").Example:
async def execute( self, caller: Identity = Caller(), triage: AgentHandle[SeverityAssessment] = Agent("incident-triage"), ) -> IncidentReport: assessment = await triage.run("Assess this incident.") ...
- loom.core.use_case.markers.Mcp(server, *, include)[source]¶
Factory returning the runtime marker for a named MCP server handle parameter.
The executor resolves server against the MCP servers compiled for this deployment and injects an
McpHandlebound to this execution’s verified caller — the only way a use case reaches an MCP server (constructor injection is not offered for this resource). Names in include are globs, matched by the sameselect_names/admitsthe model’s own toolset filter uses; there is noexcludein this version because no caller has asked for one and a short allow-list already expresses every case on the table. Underai.remote_clients: optional, a server tolerated unreachable at start-up still resolves to a handle — every call on it fails withTOOL_UNAVAILABLEinstead.Unlike
Agent(), no output type is ever checked against the parameter’s annotation:McpHandlecarries no type parameter, so there is no declared shape to compare it with. Both checks aMcp()marker gets are already wired at start-up, aborting the boot rather than waiting for a first call: server is validated againstai.mcp_servers, naming the declaring use case and parameter when it is not configured, and include is checked against the server’s real tool list under the samestartup_timeout_msan agent’s ownmcpfilter is checked against. The second check needs a listing, so underai.remote_clients: optionala server that never connected is skipped rather than failing: a tolerated outage means the filter goes unverified, not that it verified clean.Returned value is intentionally typed as
Anyto avoidmypydefault-argument incompatibility in signatures like:search: McpHandle = Mcp("docs-server", include=["search"]).- Parameters:
server (str) – Name of a configured MCP server, as declared under
ai.mcp_servers.include (Sequence[str]) – Glob patterns naming the tools this handle may call. Keyword-only and required: everywhere this include/exclude shape is used, an empty
includemeans “every name” — the filter only narrows when it carries at least one pattern — so an empty sequence here would silently grant the entire server, not the handful of tools the signature names.Mcp()raisesValueErrorinstead of widening the grant behind the caller’s back. A barestris rejected the same way:strsatisfiesSequence[str], soinclude="search"would type-check yet split into six single-character glob patterns at runtime.
- Raises:
ValueError – If include is empty, or is a single string instead of a sequence of patterns.
- Return type:
Example:
async def execute( self, caller: Identity = Caller(), docs: McpHandle = Mcp("docs-server", include=["search", "fetch"]), ) -> Report: names = docs.tools() ...
- loom.core.use_case.markers.LoadById(entity_type, *, by='id', profile='default', on_missing=OnMissing.RAISE)[source]¶
Factory returning marker for preloaded entity parameters by id.
Returned value is intentionally typed as
Anyin overloads to avoidmypydefault-argument incompatibility in signatures like:entity: User = LoadById(User, by="id").- Parameters:
entity_type (type[EntityT]) – Domain entity type the repository should load.
by (str) – Name of the primitive parameter used as the lookup key. Defaults to
"id".profile (str) – Loading profile forwarded to
repo.get_by_id. Defaults to"default".on_missing (OnMissing) – Missing-entity policy. Defaults to
OnMissing.RAISE.
- Return type:
- loom.core.use_case.markers.Load(entity_type, *, from_param=None, from_command=None, against, profile='default', on_missing=OnMissing.RAISE)[source]¶
Factory returning marker for preloaded entity parameters by field.