API Reference
Auto-generated API documentation for the XYBEROS public surface.
xyberos — Top-level facade
xyberos.assistant
XYBEROS — unified facade for the cognitive platform.
Provides a single entry point for interacting with the full XYBEROS cognitive stack: chat, reasoning, planning, memory, and actions.
Usage::
from xyberos import xyberos
response = xyberos.chat("What is the weather?")
result = xyberos.reason("If A > B and B > C, what follows?")
memories = xyberos.remember("past conversations about weather")
XYBEROS
Unified facade for the XYBEROS cognitive platform.
Lazy-initialises all subsystems on first use so you can create
an XYBEROS with no arguments and start using it immediately.
Usage::
from xyberos import xyberos
ctx = xyberos.chat("Hello!")
print(ctx.action.metadata)
Source code in xyberos\assistant.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
context
property
The context from the most recent chat call.
achat(message)
async
chat(message)
Send a message through the full cognitive pipeline.
Returns the CognitiveContext with the complete cycle
result (observation, thought, goal, plan, decision, action).
Source code in xyberos\assistant.py
configure(config)
Reconfigure the instance with a new config.
Resets lazy-initialised subsystems so they pick up the new configuration on next access.
Source code in xyberos\assistant.py
execute(action_name, **params)
Execute a direct action.
Parameters
action_name:
The action provider name (e.g. "shell", "calculator").
**params:
Parameters passed to the action provider.
Returns
Any The action result.
Source code in xyberos\assistant.py
plan(goal_description)
Generate a plan to achieve a goal.
Parameters
goal_description: Description of the goal.
Returns
list[str] Ordered steps in the plan.
Source code in xyberos\assistant.py
reason(observation, context='', strategy=None)
Run reasoning directly without the full cognitive loop.
Parameters
observation:
The observation or question to reason about.
context:
Optional context to inform reasoning.
strategy:
Reasoning strategy to use (default "deductive").
Returns
str The reasoned conclusion.
Source code in xyberos\assistant.py
remember(query, limit=5)
Retrieve relevant memories across all tiers.
Parameters
query: Natural language query. limit: Maximum results.
Returns
list[str] Memory content strings.
Source code in xyberos\assistant.py
store_memory(key, content, tier='working', **metadata)
Store a value in the specified memory tier.
Source code in xyberos\assistant.py
xyberos.plugins — Plugin system
xyberos.plugins
XYBEROS Plugin System — a unified module for discoverable, composable plugins.
Architecture
-
Plugin — An :class:
ABCthat every plugin implements. Declares what it contributes via :meth:Plugin.componentsand provides optional :meth:Plugin.initialize/ :meth:Plugin.shutdownhooks. -
Component — A lightweight dataclass representing a single unit a plugin contributes (a tool, a skill, an agent, a provider, …).
-
PluginRegistry — Tracks loaded plugins and provides component-aware queries (e.g. "which plugins contribute tools?").
-
PluginManager — The central orchestrator. Discovers plugins via entry points, loads them, routes their components to the correct type-specific registries, and manages unload.
-
PluginLoader — Dynamically loads plugin classes from dotted module paths or discovers them via Python entry points.
-
PluginManifest — Metadata describing a plugin (name, version, dependencies, etc.).
Plugin
Bases: ABC
Base class for all runtime plugins.
Subclasses must implement :meth:components to declare what they
contribute. Lifecycle hooks (:meth:initialize / :meth:shutdown)
are optional.
Identity is provided via properties so that both attribute-style
(self.name in __init__) and property-style
(@property def name) subclasses work seamlessly::
# Attribute-style (Skill, custom plugins)
class MyPlugin(Plugin):
def __init__(self) -> None:
self.name = "my-plugin"
self.version = "2.0.0"
# Property-style (Tool)
class MyToolPlugin(Plugin):
@property
def name(self) -> str:
return "my-tool"
Usage::
class MyPlugin(Plugin):
def components(self) -> list[Component]:
return [
Component(kind="tool", name="web_search", instance=WebSearchTool()),
]
async def initialize(self) -> None:
await self.db.connect()
Source code in xyberos\plugins\plugin.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
description
property
writable
Human-readable description.
name
property
writable
Plugin name. Defaults to the class name.
version
property
writable
Plugin version string.
components()
abstractmethod
Return the components this plugin contributes.
Each component is a (kind, name, instance) triple that the
:class:PluginManager will route to the correct registry.
Returns
list[Component] An empty list is valid — the plugin may only need lifecycle hooks.
Source code in xyberos\plugins\plugin.py
initialize()
async
Called once when the plugin is loaded.
Use this to set up connections, validate configuration, or register non-component resources.
shutdown()
async
Called once when the plugin is unloaded.
Use this to release connections, flush buffers, or clean up temporary resources.
Component
dataclass
A named, typed unit contributed by a plugin.
Attributes
kind:
The component type identifier, e.g. "tool", "skill",
"agent", "provider", "processor".
name:
Unique name for this component within its kind.
instance:
The actual runtime object (a Tool, Skill, etc.).
metadata:
Optional key-value metadata describing the component
(version, tags, dependencies, etc.).
Source code in xyberos\plugins\component.py
PluginRegistry
Bases: RuntimeRegistry[Plugin]
Registry of loaded plugins.
In addition to standard :class:RuntimeRegistry operations, this
registry provides helpers to query plugins by the components they
contribute.
Source code in xyberos\plugins\registry.py
get_component_names_by_kind(kind)
Return names of all components of kind across all plugins.
Parameters
kind : Component type to query.
Returns
list[str] Sorted unique component names.
Source code in xyberos\plugins\registry.py
get_components_by_kind(kind)
Return all components of kind across all loaded plugins.
Parameters
kind :
Component type to collect (e.g. "tool", "skill").
Returns
list[Component] All matching components across every loaded plugin.
Source code in xyberos\plugins\registry.py
get_plugins_by_component_kind(kind)
Return all plugins that contribute a component of kind.
Parameters
kind :
Component type to filter by (e.g. "tool", "skill").
Returns
list[Plugin]
Plugins whose :meth:Plugin.components contain at least
one component with the matching kind.
Source code in xyberos\plugins\registry.py
PluginManager
Central orchestrator for the plugin system.
Responsibilities:
- Discover plugin classes via entry points (
xyberos.plugins). - Load and instantiate plugins.
- Initialize plugins (lifecycle hook).
- Route each plugin's :meth:
Plugin.componentsto the appropriate type-specific registries (tool registry, skill registry, agent registry, etc.). - Unload plugins cleanly (remove components, call shutdown).
Usage::
# Wire up component registries
manager = PluginManager()
manager.register_component_registry("tool", tool_registry)
manager.register_component_registry("skill", skill_registry)
# Load everything
await manager.load_all()
# Or load one at a time
await manager.load_plugin("my_package:MyPlugin")
# Use the components via their own registries
tool_registry.get("web_search").run(...)
Source code in xyberos\plugins\manager.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
component_kinds
property
Return the list of registered component kind identifiers.
loader
property
The underlying plugin loader.
registry
property
The underlying plugin registry.
get_component_registry(kind)
load_all(group=ENTRY_POINT_GROUP)
async
Discover and load all plugins registered via entry points.
Parameters
group:
Entry-point group to scan (default xyberos.plugins).
Returns
list[Plugin] All successfully loaded plugin instances.
Source code in xyberos\plugins\manager.py
load_plugin(plugin_cls)
async
Instantiate, initialize, and register a plugin.
All components declared by the plugin are routed to their respective type-specific registries.
Parameters
plugin_cls:
The plugin class to instantiate (must be a Plugin
subclass).
Returns
Plugin The initialized plugin instance.
Source code in xyberos\plugins\manager.py
register_component_registry(kind, registry)
Register a target registry for a component kind.
When a plugin is loaded, every component whose kind matches
will be registered into the corresponding registry.
The registry can be any object with register(name, instance)
and unregister(name) methods — typically a
:class:~xyberos.runtime.core.registry.RuntimeRegistry or
:class:~xyberos.common.registry.ProviderRegistry subclass.
Parameters
kind:
Component type identifier (e.g. "tool", "skill").
registry:
The registry that manages instances of this kind.
Source code in xyberos\plugins\manager.py
unload_all()
async
unload_plugin(name)
async
Unload a previously loaded plugin by name.
Removes all components from their type-specific registries
and calls :meth:Plugin.shutdown.
Parameters
name: The registered name of the plugin to unload.
Source code in xyberos\plugins\manager.py
PluginLoader
Dynamically loads plugin classes.
Supports two modes:
- Explicit loading — load a single plugin class from a
module_path:ClassNamestring. - Entry-point discovery — scan the installed packages for plugins registered via a given entry-point group.
Entry-point group (pyproject.toml)::
[project.entry-points."xyberos.plugins"]
my_plugin = "my_package:MyPlugin"
Source code in xyberos\plugins\loader.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
discover(group='xyberos.plugins')
Discover plugin classes registered via Python entry points.
Parameters
group:
Entry-point group name (default "xyberos.plugins").
Returns
dict[str, Type[Plugin]]
Mapping of entry-point name → plugin class. Entries that
fail to load or are not Plugin subclasses are skipped
with a warning.
Source code in xyberos\plugins\loader.py
load(spec)
Load a single plugin class from a dotted spec.
Parameters
spec:
Either "module_path:ClassName" or "module_path.ClassName".
Returns
Type[Plugin] The plugin class.
Raises
TypeError
If the resolved class does not inherit from Plugin.
Source code in xyberos\plugins\loader.py
xyberos.tools — Tool system
xyberos.tools
XYBEROS Platform — Pluggable Tools module.
Pluggable tools that can be invoked by agents and LLMs to interact with external systems and perform specific operations (web search, file I/O, code execution, database queries, etc.).
Every tool implements :class:Tool (a :class:~xyberos.common.provider.Provider
subclass) and is registered in the :class:ToolRegistry. The
:class:ToolManager orchestrates execution, entry-point discovery,
and LLM function-calling integration.
Entry-point group: xyberos.tools::
[project.entry-points."xyberos.tools"]
my_tool = "my_package:MyTool"
Usage::
from xyberos.tools import ToolManager, CalculatorTool
manager = ToolManager()
manager.register("calc", CalculatorTool())
result = manager.run("calc", expression="2 + 2")
print(result.value) # 4
Tool
Base class for all pluggable tools.
A Tool is a self-contained function that an agent or LLM can invoke to perform a specific operation (web search, file I/O, code execution, database query, etc.).
Tools implement both the :class:Provider and :class:Plugin
interfaces — each tool contributes itself as a "tool" component.
Subclasses must implement :meth:run.
Source code in xyberos\tools\base.py
capability
property
Self-declared capability. Override in subclasses as needed.
components()
execute(input)
Execute the tool from a :class:ToolInput wrapper.
Parameters
input: Structured input including parameters and context.
Returns
ToolResult The outcome of the execution.
Source code in xyberos\tools\base.py
run(**kwargs)
abstractmethod
Execute the tool with the given parameters.
Parameters
**kwargs: Tool-specific keyword arguments.
Returns
ToolResult The outcome of the execution.
Source code in xyberos\tools\base.py
to_spec()
Return a :class:ToolSpec describing this tool for LLM
function-calling integration.
Override in subclasses to provide a custom parameter schema.
Source code in xyberos\tools\base.py
ToolRegistry
Bases: ProviderRegistry[Tool]
Registry of pluggable tools.
Each tool is registered by name and can be looked up at runtime for execution or LLM function-calling integration.
Usage::
registry = ToolRegistry()
registry.register("web_search", WebSearchTool(), default=True)
registry.register("read_file", ReadFileTool())
Source code in xyberos\tools\registry.py
ToolManager
Orchestrates tool lifecycle, discovery, and execution.
When connected to a :class:PluginManager, tools are registered
as "tool" components and loaded through the unified plugin
pipeline. The manager can also operate standalone for backward
compatibility.
Standalone usage::
manager = ToolManager()
result = manager.run("web_search", query="latest news")
print(result.value)
Plugin-managed usage::
plugin_manager = PluginManager()
tool_manager = ToolManager(plugin_manager=plugin_manager)
await plugin_manager.load_all() # discovers & routes tool components
Source code in xyberos\tools\manager.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
registry
property
The underlying tool registry.
get_tool(name)
Look up a tool by name. Raises ToolNotFoundError if missing.
list_tools()
register(name, tool, *, default=False)
Register a tool instance.
run(tool_name, timeout=30.0, **params)
Execute a tool by name with the given parameters.
Parameters
tool_name: Name of the registered tool. timeout: Maximum execution time in seconds. **params: Tool-specific keyword arguments.
Returns
ToolResult The outcome of the execution.
Source code in xyberos\tools\manager.py
run_async(tool_name, timeout=30.0, **params)
async
Execute a tool asynchronously (if the tool supports async).
Falls back to synchronous execution if the tool's run
is not a coroutine function.
Source code in xyberos\tools\manager.py
to_specs()
Return a list of :class:ToolSpec for all registered tools.
Useful for integrating with LLM function-calling APIs.
ToolResult
dataclass
Outcome of a tool execution.
Attributes
success: Whether the tool completed successfully. value: The return value (output, response data, ...). error: Error message if the tool failed. duration_ms: Execution duration in milliseconds. metadata: Arbitrary key-value metadata.
Source code in xyberos\tools\models.py
fail(error, duration_ms=0.0, metadata=None, **extra)
classmethod
Create a failure result.
Source code in xyberos\tools\models.py
ok(value=None, duration_ms=0.0, metadata=None, **extra)
classmethod
Create a successful result.
Source code in xyberos\tools\models.py
ToolSpec
dataclass
Declarative specification of a tool for LLM function-calling.
Serialises to JSON-compatible dicts for provider integration (OpenAI tool format, Anthropic tool format, etc.).
Attributes
name: The tool's unique name. description: Human-readable description of what the tool does. parameters: JSON Schema dict describing the expected parameters.
Source code in xyberos\tools\models.py
xyberos.skills — Skill system
xyberos.skills
Skill
Bases: Plugin
Base class for all runtime skills.
A skill is a reusable capability that an agent can invoke.
Skills implement the :class:Plugin interface — each skill
contributes itself as a "skill" component.
Subclasses must implement :meth:execute.
Source code in xyberos\skills\base.py
components()
execute(**kwargs)
abstractmethod
async
initialize()
async
SkillRegistry
SkillManager
Bases: RuntimeManager[Skill]
Runtime manager for skills.
When connected to a :class:PluginManager, skills are registered
as "skill" components and loaded through the unified plugin
pipeline. The manager can also operate standalone for backward
compatibility.
Standalone usage::
manager = SkillManager()
manager.register("my_skill", MySkill())
Plugin-managed usage::
plugin_manager = PluginManager()
skill_manager = SkillManager(plugin_manager=plugin_manager)
await plugin_manager.load_all() # discovers & routes skill components
Source code in xyberos\skills\manager.py
xyberos.agents — Multi-agent system
xyberos.agents
Multi-Agent Runtime — agents with communication, shared memory, and collaboration.
Agent
dataclass
Base runtime agent with inter-agent communication, shared memory, and collaborative intelligence.
Agents can
- Send/receive messages via the shared :class:
MessageBus - Read/write to shared memory via :attr:
shared_memory - Collaborate via :attr:
collaboration(voting, knowledge sharing, collective problem solving)
Specialized agents extend this class and override :meth:handle_message.
Usage::
class ResearcherAgent(Agent):
async def handle_message(self, msg):
# Access shared memory
await self.shared_memory.store("finding:x", value, agent_id=self.id)
# Collaborate with other agents
result = await self.collaboration.conduct_vote(...)
Source code in xyberos\agents\agent.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
collaboration
property
Access the collaboration engine for voting and collective problem solving.
shared_memory
property
Access the shared memory space shared by all agents.
broadcast(content, *, msg_type='broadcast')
async
handle_message(message)
async
Handle an incoming message. Override in subclasses.
Default behavior: log the message.
query_knowledge(topic, *, limit=10)
async
Query shared knowledge on a topic from all agents.
reply_to(original, content)
async
request(receiver, content, *, timeout=10.0)
async
Send a request and wait for a reply.
Source code in xyberos\agents\agent.py
send_message(receiver, content, *, msg_type='message', correlation_id='')
async
Send a message to another agent.
Source code in xyberos\agents\agent.py
share_knowledge(topic, content, *, tags=None)
async
Share knowledge on a topic with all agents via shared memory.
Source code in xyberos\agents\agent.py
start()
async
Called when the agent starts. Subscribes to the message bus.
Source code in xyberos\agents\agent.py
stop()
async
vote_on(question, agents, options)
async
Conduct a vote among agents on a question.
Source code in xyberos\agents\agent.py
AgentPlugin
Bases: Plugin
Adapter that wraps a single :class:Agent as a :class:Plugin.
Lifecycle mapping:
AgentPlugin.initialize()→Agent.start()AgentPlugin.shutdown()→Agent.stop()
The plugin's name/description are taken from the agent's
own fields. Subclass to provide a custom version or additional
components.
Usage::
# Wrap an existing agent
plugin = AgentPlugin(my_agent)
# Or subclass for custom metadata
class MyResearcherPlugin(AgentPlugin):
def __init__(self) -> None:
super().__init__(
Agent(id="researcher-1", name="Researcher"),
)
self.version = "2.0.0"
Source code in xyberos\agents\plugin.py
agent
property
The wrapped agent instance.
components()
Contribute the wrapped agent as a single "agent" component.
The component name is the agent's name field so that
lookups via agent_registry.get(agent_name) work naturally.
Source code in xyberos\agents\plugin.py
initialize()
async
AgentManager
Bases: RuntimeManager[Agent]
Runtime manager for agents.
Manages agent lifecycle (start/stop), inter-agent communication
via :class:MessageBus, shared memory via :class:SharedMemory,
and collaborative intelligence via :class:CollaborationEngine.
When connected to a :class:PluginManager, agents are registered
as "agent" components and loaded through the unified plugin
pipeline. The manager can also operate standalone for backward
compatibility.
Standalone usage::
manager = AgentManager()
manager.start_all()
await manager.send("agent_a", "agent_b", "Hello!")
Plugin-managed usage::
plugin_manager = PluginManager()
agent_manager = AgentManager(plugin_manager=plugin_manager)
await plugin_manager.load_all()
Source code in xyberos\agents\manager.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
bus
property
The shared message bus for inter-agent communication.
collaboration
property
The collaboration engine for voting and collective problem solving.
shared_memory
property
The shared memory space accessible by all agents.
register(name, agent)
Register an agent and connect it to message bus, shared memory, and collaboration.
Source code in xyberos\agents\manager.py
send(sender_id, receiver_id, content)
async
Send a message from one agent to another.
Source code in xyberos\agents\manager.py
start_all()
async
Start all registered agents.
Source code in xyberos\agents\manager.py
stop_all()
async
Stop all registered agents.
Source code in xyberos\agents\manager.py
AgentRegistry
MessageBus
Publish/subscribe message bus for inter-agent communication.
Agents subscribe to receive messages. Messages can be sent to a specific agent or broadcast to all subscribers.
Source code in xyberos\agents\message_bus.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
subscriber_count
property
Number of currently subscribed agents.
reply(original, content, **kwargs)
async
Send a reply to an original request message.
Source code in xyberos\agents\message_bus.py
request(sender, receiver, content, *, msg_type='request', timeout=10.0)
async
Send a request and wait for a reply.
Returns the reply message, or None on timeout.
Source code in xyberos\agents\message_bus.py
send(message)
async
Send a message to a specific agent or broadcast to all.
If message.receiver is "*", delivers to all subscribers.
Source code in xyberos\agents\message_bus.py
subscribe(agent_id)
async
Register an agent to receive messages. Returns the agent's queue.
Source code in xyberos\agents\message_bus.py
SharedMemory
A shared knowledge space accessible by all agents.
Supports storing, retrieving, searching, and watching entries. Entries are tagged with the originating agent for provenance.
Usage::
memory = SharedMemory()
await memory.store("goal:1", "Build a web app", agent_id="planner")
entry = await memory.retrieve("goal:1")
results = await memory.search("web app")
Source code in xyberos\agents\shared_memory.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
agent_ids
property
Set of all agent IDs that have written to shared memory.
count
property
Number of entries currently stored.
clear()
async
delete(key)
async
list_by_agent(agent_id)
async
list_by_tag(tag)
async
retrieve(key)
async
Retrieve an entry by key. Returns None if not found.
search(query, *, limit=10, agent_id=None, tags=None)
async
Search entries by keyword matching against key, value, and tags.
Parameters
query: Keywords to search for. limit: Maximum results. agent_id: If set, only return entries from this agent. tags: If set, only return entries with at least one matching tag.
Returns
list[SharedEntry] Matching entries sorted by recency.
Source code in xyberos\agents\shared_memory.py
store(key, value, agent_id='', *, tags=None, metadata=None)
async
Store a value in shared memory.
If key already exists, it is overwritten and the timestamp is updated.
Source code in xyberos\agents\shared_memory.py
watch(key_pattern, callback)
async
Register a callback that fires when an entry matching key_pattern
is stored or updated. The pattern supports simple * wildcard.
The callback receives (key, SharedEntry).
Source code in xyberos\agents\shared_memory.py
CollaborationEngine
Orchestrates collaborative intelligence among agents.
Provides voting, consensus-building, and knowledge-sharing primitives that agents can use to work together.
Usage::
engine = CollaborationEngine(shared_memory=memory)
result = await engine.conduct_vote(
question="What approach should we take?",
agents=[agent_a, agent_b, agent_c],
options=["approach_a", "approach_b"],
)
Source code in xyberos\agents\collaboration.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
memory
property
The shared memory instance used by all agents.
conduct_vote(question, agents, options, *, timeout=10.0, consensus_threshold=0.6)
async
Conduct a vote among agents on a question with given options.
Each agent is asked to choose an option and provide a confidence. The winner is the option with the highest weighted confidence sum.
Source code in xyberos\agents\collaboration.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | |
query_knowledge(topic, *, limit=10)
async
Query shared memory for knowledge on a topic.
Source code in xyberos\agents\collaboration.py
share_knowledge(agent, topic, content, *, tags=None)
async
Share knowledge from agent on a topic to all other agents.
The knowledge is stored in shared memory and a broadcast notification is sent to all agents.
Source code in xyberos\agents\collaboration.py
solve_collectively(problem, coordinator, agents, *, sub_problems=None, timeout=15.0)
async
Solve a problem collectively.
- Coordinator decomposes problem into sub_problems
- Each sub-problem is assigned to an agent (or the coordinator)
- Results are collected and merged
- Final answer stored in shared memory
Source code in xyberos\agents\collaboration.py
xyberos.ml — Machine learning
xyberos.ml
XYBEROS ML — Machine Learning module for training, optimization, evaluation, and pipeline orchestration.
Provides the ML interfaces consumed by :class:~xyberos.brain.learning.Learner
and the :class:MLService that connects to the plugin system.
Entry-point group: xyberos.ml::
[project.entry-points."xyberos.ml"]
my_model = "my_package:MyModelPlugin"
MLService
Central orchestrator for ML capabilities.
Manages registries for trainers, evaluators, optimizers, and
pipelines. When connected to a :class:PluginManager, the
service registers the "ml" component kind so that plugins
can contribute ML components.
Usage::
# Standalone
service = MLService()
service.register_trainer("classifier", MyTrainer())
report = service.evaluate("classifier", predictions=[...], ground_truth=[...])
# Plugin-managed
plugin_manager = PluginManager()
service = MLService(plugin_manager=plugin_manager)
await plugin_manager.load_all() # discovers ML plugins
Source code in xyberos\ml\service.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
evaluators
property
Registry of registered evaluators.
optimizers
property
Registry of registered optimizers.
pipelines
property
Registry of registered ML pipelines.
trainers
property
Registry of registered trainers.
evaluate(model_name, *, predictions, ground_truth, evaluator_name='default', **metadata)
Evaluate predictions against ground truth using a named evaluator.
Parameters
model_name:
Identifier for the model.
predictions:
Model output values.
ground_truth:
Expected target values.
evaluator_name:
Name of the registered evaluator to use (default "default").
**metadata:
Extra metadata for the report.
Returns
EvaluationReport
Source code in xyberos\ml\service.py
get_evaluator(name)
get_optimizer(name)
get_pipeline(name)
get_trainer(name)
register_evaluator(name, evaluator)
Register an evaluator by name.
register_optimizer(name, optimizer)
Register an optimizer by name.
register_pipeline(name, pipeline)
register_trainer(name, trainer)
run_pipeline(name, *, train_data, val_data=None, **metadata)
Run a registered ML pipeline by name.
Parameters
name: Pipeline name (as registered). train_data: Training dataset. val_data: Optional validation dataset.
Returns
PipelineResult
Source code in xyberos\ml\service.py
MLPipeline
Composable ML pipeline that chains preprocessing → training → evaluation.
Usage::
pipeline = MLPipeline(
name="text-classifier",
trainer=MyTrainer(),
evaluator=DefaultMLEvaluator(),
)
pipeline.add_step(TokenizerStep())
pipeline.add_step(FeatureExtractor())
result = pipeline.run(
train_data=[...],
val_data=[...],
)
print(result.evaluation.classification.accuracy)
Source code in xyberos\ml\pipeline.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
steps
property
Registered pipeline steps (read-only view).
add_step(step)
run(*, train_data, val_data=None, **metadata)
Execute the full pipeline.
Parameters
train_data: Training dataset. val_data: Optional validation dataset. If provided, evaluation will use it; otherwise evaluation runs on training data. **metadata: Extra metadata attached to the result.
Returns
PipelineResult Outcome including evaluation report.
Source code in xyberos\ml\pipeline.py
MLEvaluator
Bases: ABC
Evaluates ML model predictions against ground truth.
Subclasses implement :meth:evaluate to produce an
:class:EvaluationReport with the relevant metrics.
Source code in xyberos\ml\evaluator.py
evaluate(*, model_name, predictions, ground_truth, **metadata)
abstractmethod
Evaluate predictions against ground truth.
Parameters
model_name: Identifier for the model being evaluated. predictions: Model output values. ground_truth: Expected target values. **metadata: Extra metadata to attach to the report.
Returns
EvaluationReport Computed metrics and predictions.
Source code in xyberos\ml\evaluator.py
DefaultMLEvaluator
Bases: MLEvaluator
Default evaluator that infers metric type from data.
- If ground_truth contains only
{0, 1}or{True, False}→ computes :class:ClassificationMetrics. - If ground_truth contains
intorfloatvalues beyond 0/1 → computes :class:RegressionMetrics. - Otherwise → empty report.
Source code in xyberos\ml\evaluator.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
ClassificationMetrics
dataclass
RegressionMetrics
dataclass
Standard regression metrics.
Source code in xyberos\ml\evaluator.py
EvaluationReport
dataclass
Full evaluation report for a model.
Contains classification metrics, regression metrics (whichever is relevant), plus optional raw predictions and metadata.
Source code in xyberos\ml\evaluator.py
Trainer
Bases: ABC
Base interface for training cognitive models.
Source code in xyberos\ml\trainer.py
Optimizer
Bases: ABC
Base interface for optimization strategies.
Optimizers improve cognitive components such as prompts, policies, models, or routing decisions based on accumulated experience.
Source code in xyberos\ml\optimizer.py
xyberos.security — Security subsystem
xyberos.security
XYBEROS Security — first-class authentication, authorization, and safety subsystem.
Sub-modules
providers— Pluggable backends (RBAC, OAuth, LDAP, …)guardian— Central decision engine (Guardian)risk— Action risk scoring (0–100)audit— Structured audit trailcapability— Agent capability managementpolicy— Rule-based policy evaluationapproval— Human-in-the-loop approval workflowgovernor— Resource consumption limits
Usage::
from xyberos.security import SecurityService, Principal, Permission, Role
from xyberos.security.providers import DefaultSecurityProvider
svc = SecurityService(provider=DefaultSecurityProvider())
svc.authenticate(principal)
svc.authorize(principal, "files.read")
With Guardian::
from xyberos.security import SecurityService
from xyberos.security.guardian import GuardianEngine
from xyberos.security.risk import RiskEngine
from xyberos.security.audit import AuditService
svc = SecurityService(
provider=DefaultSecurityProvider(),
guardian=GuardianEngine(),
risk=RiskEngine(),
audit=AuditService(),
)
decision = svc.guard("tool:delete_file", principal)
SecurityService
Bases: ISecurityService
Unified security orchestrator.
Wraps a :class:SecurityProvider with evaluators, and optionally
connects to the Guardian Engine, Risk Engine, Audit Service, and
Capability Manager for richer decision-making.
Usage::
service = SecurityService(provider=DefaultSecurityProvider())
service.authenticate(principal)
service.authorize(principal, "files.read")
With Guardian integration::
service = SecurityService(
provider=...,
guardian=guardian_engine,
audit=audit_service,
)
decision = service.guard(action="tool:delete_file", principal=principal)
Source code in xyberos\security\service.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
provider
property
writable
The active security provider.
guard(action, principal, *, resource=None, metadata=None)
Run the full Guardian decision pipeline.
Returns one of ALLOW, DENY, APPROVE, SANDBOX,
or ESCALATE.
Requires :attr:guardian to be configured.
Source code in xyberos\security\service.py
ISecurityService
Bases: ABC
Public interface for the XYBEROS security subsystem.
Source code in xyberos\security\interface.py
authenticate(principal)
abstractmethod
authorize(principal, permission)
abstractmethod
grant(role, permission)
abstractmethod
has_permission(principal, permission)
abstractmethod
has_role(principal, role)
abstractmethod
register_permission(permission)
abstractmethod
register_role(role)
abstractmethod
revoke(role, permission)
abstractmethod
unregister_permission(name)
abstractmethod
Principal
dataclass
An authenticated identity (user, agent, service, …).
tenant_id scopes the principal to an organization. When empty, the principal is treated as a global/system principal.
Source code in xyberos\security\models.py
PrincipalType
Bases: str, Enum
Types of principals recognized by the security system.
Source code in xyberos\security\models.py
Role
dataclass
Permission
dataclass
SecurityContext
dataclass
Security context for a single action or execution scope.
Carries the authenticated principal, optional tenant affiliation, plus arbitrary metadata (e.g. IP address, session id, request id).
Source code in xyberos\security\models.py
tenant_id
property
Convenience — tenant from principal or metadata.
PermissionEvaluator
Evaluates whether a principal has a specific permission.
Fires an optional on_check callback with structured context for metrics, tracing, or audit integration.
Source code in xyberos\security\evaluator.py
check(principal, permission, provider_check)
Evaluate a permission check.
Parameters
principal: The principal being checked. permission: The permission name to evaluate. provider_check: The result from the underlying SecurityProvider.
Returns
bool Whether the permission is granted.
Source code in xyberos\security\evaluator.py
PolicyEvaluator
Evaluates role-based policy membership.
Fires an optional on_evaluate callback for observability.
Source code in xyberos\security\evaluator.py
evaluate(principal, role, provider_check)
Evaluate a role-based policy.
Parameters
principal: The principal being evaluated. role: The role name to evaluate. provider_check: The result from the underlying SecurityProvider.
Returns
bool Whether the policy allows access.
Source code in xyberos\security\evaluator.py
SecurityError
AuthenticationError
Bases: SecurityError
Authentication failed.
AuthorizationError
Bases: SecurityError
Authorization failed.
RoleNotFound
Bases: SecurityError
Unknown role.
PermissionNotFound
Bases: SecurityError
Unknown permission.
xyberos.security.guardian — Guardian Engine
xyberos.security.guardian
Guardian Engine — central decision orchestrator.
GuardianEngine
Central decision engine for the security subsystem.
Every action flows here. The engine chains:
- Authentication — is the principal known?
- Capability — does the agent possess this action?
- Permission — is the principal allowed?
- Risk scoring — how dangerous is this action?
- Policy check — what does policy say at this risk level?
- Resource limits — within budget / rate limits?
- Approval — does this need human sign-off?
- Sandbox — should this be isolated?
Usage::
engine = GuardianEngine()
decision = engine.evaluate("tool:delete_file", context, security_service)
Source code in xyberos\security\guardian\engine.py
evaluate(action, context, security)
Run the full decision pipeline for action.
Parameters
action:
The action being evaluated (e.g. "tool:delete_file").
context:
Security context with the principal and metadata.
security:
The SecurityService for auth, capability, risk lookups.
Returns
Decision
Source code in xyberos\security\guardian\engine.py
Decision
Bases: str, Enum
Possible outcomes of a Guardian evaluation.
Source code in xyberos\security\guardian\engine.py
xyberos.security.risk — Risk Engine
xyberos.security.risk
Risk Engine — scores actions on a 0–100 scale.
RiskEngine
Scores actions on a 0–100 risk scale.
Built-in baseline table covers common actions. Callers or plugins
can extend the table via :meth:register_action_risk or provide
a custom risk_table at construction.
Usage::
engine = RiskEngine()
score = engine.score("tool:delete_file", context)
if score.level > 70:
... # require approval
Source code in xyberos\security\risk\engine.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
get_action_risk(action)
register_action_risk(action, level)
Register or override the baseline risk for an action.
Parameters
action: Action identifier. level: Risk level (0–100).
Source code in xyberos\security\risk\engine.py
score(action, context=None)
Score an action.
Parameters
action:
The action identifier (e.g. "tool:delete_file").
context:
Optional security context for context-aware scoring.
Returns
RiskScore
Source code in xyberos\security\risk\engine.py
RiskScore
dataclass
Result of a risk assessment.
Attributes
level: Overall risk level (0–100). factors: Contributing factors with individual weights and reasons.
Source code in xyberos\security\risk\engine.py
xyberos.security.audit — Audit Service
xyberos.security.audit
Audit Service — structured, queryable audit trail.
AuditService
Structured audit trail for security decisions.
Stores entries in-memory by default. Callers can subscribe via on_record for persistence, streaming, or external sinks.
Usage::
audit = AuditService()
audit.record(principal=alice, action="tool:delete_file", decision="DENY", reason="Risk 92")
recent = audit.query(limit=10)
Source code in xyberos\security\audit\service.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
clear()
count()
query(*, limit=50, offset=0, principal_id=None, action=None, decision=None, min_risk=0)
Query the audit trail with optional filters.
Returns entries sorted newest-first.
Source code in xyberos\security\audit\service.py
record(principal, action, decision, reason, *, risk_level=0, policies=None, duration_ms=0.0, result=None, metadata=None)
Record a security decision in the audit trail.
Parameters
principal: The principal who performed (or attempted) the action. action: The action identifier. decision: The decision outcome. reason: Why the decision was made. risk_level: Risk score at the time of decision. policies: Policy identifiers that matched. duration_ms: How long evaluation took. result: What actually happened after the decision. metadata: Additional structured context.
Returns
AuditEntry The newly created entry.
Source code in xyberos\security\audit\service.py
AuditEntry
dataclass
A single audit record.
Captures the full context of a security decision so that every action is fully explainable post-hoc.
Source code in xyberos\security\audit\models.py
xyberos.security.capability — Capability Manager
xyberos.security.capability
Capability Manager — what an agent can do vs. what it's allowed to do.
CapabilityManager
Manages agent→capability mappings.
Usage::
manager = CapabilityManager()
manager.register("weather-agent", "web.search")
manager.register("weather-agent", "forecast")
assert manager.possesses("weather-agent", "web.search") # True
assert manager.possesses("weather-agent", "execute_shell") # False
Source code in xyberos\security\capability\manager.py
xyberos.security.policy — Policy Engine
xyberos.security.policy
Policy Engine — rule evaluation for security decisions.
Policies are composed of rules that map actions + conditions to effects.
PolicyEngine
Evaluates actions against a set of policies.
Rules are sorted by priority (descending). The first matching rule determines the result. If no rule matches, the default effect is DENY.
Usage::
engine = PolicyEngine()
engine.add_rule(PolicyRule(
effect=PolicyEffect.ALLOW,
action_pattern="tool:read_file",
role="developer",
))
result = engine.evaluate("tool:read_file", context)
Source code in xyberos\security\policy\engine.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
add_policy(policy)
add_rule(rule, policy_name='default')
Add a rule to a policy, creating the policy if needed.
Source code in xyberos\security\policy\engine.py
clear()
evaluate(action, context=None, risk_level=0)
Evaluate action against all policies.
Returns the first matching rule's effect, or DENY if no rule matches.
Source code in xyberos\security\policy\engine.py
Policy
dataclass
PolicyRule
dataclass
A single policy rule.
Parameters
effect:
What to do when this rule matches.
action_pattern:
Glob-style action pattern (e.g. "tool:*", "tool:read_file").
role:
Optional — only applies to principals with this role.
min_risk:
Optional — only applies when risk >= this threshold.
max_risk:
Optional — only applies when risk <= this threshold.
priority:
Higher priority rules are evaluated first (default 0).
Source code in xyberos\security\policy\engine.py
PolicyEffect
PolicyResult
dataclass
xyberos.security.approval — Approval Engine
xyberos.security.approval
Approval Engine — human-in-the-loop for high-risk actions.
ApprovalEngine
Manages human-in-the-loop approval workflows.
High-risk actions can require explicit approval before execution. The engine tracks pending requests and resolves them.
Usage::
engine = ApprovalEngine()
req = engine.request(principal, "tool:delete_file", risk_level=85)
# … external UI prompts human …
engine.approve(req.id, "admin-user")
# or
engine.deny(req.id, "admin-user")
Source code in xyberos\security\approval\engine.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
approve(request_id, approver)
Approve a pending request.
Source code in xyberos\security\approval\engine.py
deny(request_id, approver)
Deny a pending request.
Source code in xyberos\security\approval\engine.py
get(request_id)
is_approved(request_id)
is_pending(request_id)
pending()
request(principal, action, *, reason='', risk_level=0, metadata=None)
Create a new approval request.
Returns the pending request so callers can display or forward it to the appropriate approver.
Source code in xyberos\security\approval\engine.py
ApprovalRequest
dataclass
A pending approval request.
Source code in xyberos\security\approval\engine.py
xyberos.security.governor — Resource Governor
xyberos.security.governor
Resource Governor — actively manages resource consumption and limits.
ResourceGovernor
Enforces resource limits per principal.
Usage::
gov = ResourceGovernor()
gov.set_limits("alice", ResourceLimits(max_actions=100))
ok, reason = gov.check("alice")
if ok:
gov.consume("alice", action_count=1)
Source code in xyberos\security\governor\governor.py
ResourceLimits
dataclass
Maximum resource consumption allowed for a principal or role.
Source code in xyberos\security\governor\models.py
ResourceBudget
dataclass
Current resource consumption for a principal.
Resets according to reset_period (e.g. "hourly", "daily").
Source code in xyberos\security\governor\models.py
xyberos.security.kill_switch — Kill Switch
xyberos.security.kill_switch
Kill Switch — emergency stop for agents, plugins, workflows, sessions, and the runtime.
KillTarget = Callable[[], Any]
module-attribute
KillSwitch
Emergency kill switch for the XYBEROS runtime.
Maintains a registry of KillTarget callables grouped by scope.
Each target can be tripped individually or by scope. Once a target
is tripped it is marked as killed and cannot be tripped again.
Source code in xyberos\security\kill_switch\engine.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
register(target_id, target, *, scope=KillScope.ALL.value)
Register a killable target.
reset()
Reset the kill switch — clear all targets, killed set, and history.
trip(target_id)
async
Kill a single target by ID.
Source code in xyberos\security\kill_switch\engine.py
trip_agents()
async
trip_all()
async
Kill all registered targets regardless of scope.
Source code in xyberos\security\kill_switch\engine.py
trip_plugins()
async
trip_runtime()
async
trip_scope(scope)
async
Kill all targets in a scope.
Source code in xyberos\security\kill_switch\engine.py
trip_sessions()
async
trip_workflows()
async
unregister(target_id)
Remove a previously registered target.
KillRecord
dataclass
A record of a kill event.
Source code in xyberos\security\kill_switch\engine.py
KillReport
dataclass
Summary of a kill operation (trip_all or trip_scope).
Source code in xyberos\security\kill_switch\engine.py
KillScope
Bases: str, Enum
Scopes that can be killed in bulk.
Source code in xyberos\security\kill_switch\engine.py
xyberos.security.secrets — Secrets Manager
xyberos.security.secrets
Secrets Manager — secure credential storage and retrieval.
Provides a pluggable secrets provider abstraction with built-in implementations for environment variables and HashiCorp Vault.
Usage::
from xyberos.security.secrets import SecretsManager, EnvSecretsProvider
mgr = SecretsManager(provider=EnvSecretsProvider())
api_key = mgr.get("OPENAI_API_KEY")
SecretsManager
Orchestrates secret retrieval with optional caching and TTL.
Usage::
mgr = SecretsManager(provider=VaultSecretsProvider(), cache_ttl=300)
key = mgr.get("OPENAI_API_KEY")
Source code in xyberos\security\secrets\manager.py
clear_cache()
delete(key)
get(key, *, default=None)
Retrieve a secret, respecting cache TTL.
Source code in xyberos\security\secrets\manager.py
invalidate(key)
set(key, value)
Store a secret and update cache.
Source code in xyberos\security\secrets\manager.py
SecretsProvider
Bases: ABC
Abstract interface for a secrets storage backend.
Source code in xyberos\security\secrets\providers.py
delete(key)
abstractmethod
get(key, *, default=None)
abstractmethod
list_keys()
abstractmethod
EnvSecretsProvider
Bases: SecretsProvider
Reads secrets from environment variables — zero-config default.
Source code in xyberos\security\secrets\providers.py
VaultSecretsProvider
Bases: SecretsProvider
HashiCorp Vault integration via the hvac client.
Requires the hvac package and the following env vars:
VAULT_ADDR— Vault server URL (defaulthttp://127.0.0.1:8200)VAULT_TOKEN— Authentication tokenVAULT_MOUNT_POINT— KV mount point (defaultsecret)
If hvac is not installed or Vault is unreachable, falls back
to environment variables.
Source code in xyberos\security\secrets\providers.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
xyberos.security.models — Security Models
xyberos.security.models
Security data models — Principal, Role, Permission, SecurityContext, Tenant.
These are the canonical definitions, moved from the kernel internals
to a first-class :mod:xyberos.security module.
Tenant
dataclass
A tenant — isolated organizational unit within the platform.
Each tenant has a unique identifier and may carry configuration specific to that organization (e.g. custom RBAC, resource quotas).
Source code in xyberos\security\models.py
resolve_tenant_id(tenant_id=None)
Resolve a tenant ID, falling back to env var then "default".
xyberos.server — REST API Server
xyberos.server.auth — Authentication
xyberos.server.auth
Authentication & authorization middleware for the XYBEROS REST API.
Provides JWT token creation/validation, API key authentication, and FastAPI dependency injection helpers.
Usage::
from fastapi import Depends, FastAPI
from xyberos.server.auth import (
create_access_token,
get_current_principal,
AuthMiddleware,
)
app = FastAPI()
app.add_middleware(AuthMiddleware)
@app.get("/secure")
async def secure_route(principal=Depends(get_current_principal)):
return {"user": principal.id}
AuthMiddleware
FastAPI middleware that enriches request state with the current principal.
Add to your app::
from xyberos.server.auth import AuthMiddleware
app.add_middleware(AuthMiddleware)
Source code in xyberos\server\auth.py
create_access_token(principal_id, *, secret='', expires_minutes=60, tenant_id='', extra_claims=None)
Create a self-contained JWT access token (HS256).
Parameters
principal_id:
Unique identifier for the principal.
secret:
Signing secret. Auto-generated from env XYBEROS_JWT_SECRET
if empty (with a warning).
expires_minutes:
Token validity in minutes.
tenant_id:
Optional tenant scope.
extra_claims:
Additional claims to include in the payload.
Returns
str Encoded JWT string.
Source code in xyberos\server\auth.py
decode_access_token(token, *, secret='')
Decode and verify a JWT access token.
Raises HTTPException(401) if the token is invalid or expired.
Source code in xyberos\server\auth.py
get_current_principal(credentials=None, request=None)
async
FastAPI dependency — extract authenticated principal from request.
Checks (in order):
1. Authorization: Bearer <token> header (JWT)
2. X-API-Key header
3. Falls back to an anonymous principal if no auth is configured.
Source code in xyberos\server\auth.py
get_security_context(principal=None, request=None)
async
FastAPI dependency — build a SecurityContext from the request.
Source code in xyberos\server\auth.py
xyberos.server.models — API Models
xyberos.server.models
Pydantic models for the XYBEROS REST API.
ChatRequest
ChatResponse
Bases: BaseModel
Response from POST /chat.
Source code in xyberos\server\models.py
ReasonRequest
Bases: BaseModel
Request body for POST /reason.
Source code in xyberos\server\models.py
ReasonResponse
PlanRequest
PlanResponse
MemoryQueryRequest
Bases: BaseModel
Request body for GET /memory (query params).
Source code in xyberos\server\models.py
MemoryStoreRequest
Bases: BaseModel
Request body for POST /memory.
Source code in xyberos\server\models.py
ActionRequest
ActionResponse
ToolInfo
xyberos.storage.tenant — Tenant Storage
xyberos.storage.tenant
Tenant-aware storage provider wrapper.
Isolates data by prefixing storage keys with {tenant_id}:.
TenantStorageWrapper
Bases: IStorageProvider
Wraps a storage provider with tenant key isolation.
Source code in xyberos\storage\tenant.py
xyberos.memory — Memory system
xyberos.memory
XYBEROS Memory subsystem (Phase 4).
Multi-tier memory with fallback chain:
Working → Episodic → Semantic → Procedural → Vector → Knowledge Graph
Every tier implements IMemoryStore(Provider) and is registered
in the MemoryRegistry. The MemoryManager orchestrates
queries across all tiers, promoting results back to working memory.
MemoryManager
Orchestrates memory across all tiers using the Fallback Chain pattern:
- Query working memory (fastest)
- If miss → query episodic + semantic (parallel)
- If still miss → query vector store
- Last resort → knowledge graph
- Promote results back to working memory for fast future access
Usage::
manager = MemoryManager()
manager.register_defaults()
manager.store(MemoryItem(key="k1", content="hello"))
result = manager.query(MemoryQuery(text="hello"))
Source code in xyberos\memory\manager.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
clear(tier=None)
Clear a specific tier, or all tiers if None.
Source code in xyberos\memory\manager.py
count(tier=None)
Count items in a specific tier, or sum across all.
Source code in xyberos\memory\manager.py
delete(key, tier=None)
Delete from a specific tier, or all tiers if None.
Source code in xyberos\memory\manager.py
query(query, strategy='hybrid')
Execute the fallback chain.
- Query working memory (fastest)
- If miss → query episodic + semantic
- If still miss → procedural
- If still miss → vector store
- Last resort → knowledge graph
- Promote best results to working memory
Source code in xyberos\memory\manager.py
register_defaults()
Register all built-in memory tier providers.
Discovers tiers from xyberos.memory entry points first, then
falls back to hardcoded imports for built-in tiers that are
not yet registered via entry points.
Source code in xyberos\memory\manager.py
register_tier(name, provider, *, default=False)
Register a custom memory tier.
Source code in xyberos\memory\manager.py
retrieve(query, tier='working')
Query a specific tier directly, skipping the fallback chain.
Source code in xyberos\memory\manager.py
store(item, tier=None)
Store item in the specified tier, or in all tiers if None.
Source code in xyberos\memory\manager.py
MemoryItem
dataclass
A single unit of memory.
Attributes
key:
Unique identifier for this memory item.
content:
The stored data (text, embedding vector, structured dict, …).
metadata:
Arbitrary key-value tags (timestamp, source, priority, …).
embedding:
Optional embedding vector for similarity search.
timestamp:
When this item was created.
access_count:
How many times this item has been retrieved.
ttl_seconds:
Time-to-live in seconds. None = permanent.
Source code in xyberos\memory\models.py
is_expired
property
Check whether this item has exceeded its TTL.
MemoryQuery
dataclass
Query for memory retrieval.
Attributes
text: Natural-language query string. embedding: Optional embedding vector for similarity search. keys: If set, only retrieve items with these keys. limit: Maximum number of results. min_score: Minimum relevance score threshold. filters: Key-value pairs that metadata must match.
Source code in xyberos\memory\models.py
MemoryResult
dataclass
Result of a memory retrieval.
Attributes
items: Retrieved items, ordered by relevance (highest first). total_count: Total matching items (useful for pagination). tier: Which tier produced this result.
Source code in xyberos\memory\models.py
xyberos.storage — Storage system
xyberos.storage
XYBEROS Storage subsystem.
Pluggable storage with fallback chain:
Memory → Local Filesystem → (S3 / GCS / SQL … via entry points)
Every backend implements IStorageProvider(Provider) and is registered
in the StorageRegistry. The StorageManager orchestrates reads
across all backends with automatic fallback and promotion.
StorageManager
Orchestrates storage across multiple providers using the Fallback Chain pattern:
- Try the default (highest-priority) provider first.
- On failure, fall through to the next available provider.
- Promote successful results to the default provider for fast access.
Usage::
manager = StorageManager()
manager.register_defaults()
manager.save(StorageItem(key="config.json", content={"theme": "dark"}))
result = manager.load(StorageQuery(key="config.json"))
Source code in xyberos\storage\manager.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
clear(provider=None)
Clear a specific provider, or all providers if None.
Source code in xyberos\storage\manager.py
count(provider=None)
Count items in a specific provider, or sum across all.
Source code in xyberos\storage\manager.py
delete(key, provider=None)
Delete from a specific provider, or all providers if None.
Source code in xyberos\storage\manager.py
exists(key, provider=None)
Check existence in a specific provider, or any provider if None.
Source code in xyberos\storage\manager.py
get(key, provider=None)
Shorthand to load a single key from the fallback chain or a specific provider.
Source code in xyberos\storage\manager.py
list_keys(provider=None)
List all keys from a specific provider, or aggregate across all.
Source code in xyberos\storage\manager.py
load(query)
Execute the fallback chain.
- Try the default provider first (fastest).
- On miss or failure, try the next provider in order.
- Promote found results to the default provider.
Source code in xyberos\storage\manager.py
register_defaults()
Register all built-in storage providers.
Discovers providers from xyberos.storage entry points first,
then falls back to hardcoded imports for built-in providers
that are not yet registered via entry points.
Source code in xyberos\storage\manager.py
register_provider(name, provider, *, default=False)
Register a custom storage provider.
Source code in xyberos\storage\manager.py
save(item, provider=None)
Persist item.
If provider is specified, saves only to that provider. Otherwise saves to all available providers for redundancy.
Source code in xyberos\storage\manager.py
StorageItem
dataclass
A single unit of stored data.
Attributes
key:
Unique identifier for this storage item (e.g. a file path,
object key, or database row ID).
content:
The stored data — bytes, string, dict, or any serialisable type.
metadata:
Arbitrary key-value tags (content_type, size, checksum, …).
timestamp:
When this item was created / last written.
ttl_seconds:
Time-to-live in seconds. None = permanent.
Source code in xyberos\storage\models.py
is_expired
property
Check whether this item has exceeded its TTL.
StorageResult
dataclass
Result of a storage retrieval.
Attributes
items: Retrieved items, ordered by key (sorted). total_count: Total matching items (useful for pagination). provider: Which provider produced this result.
Source code in xyberos\storage\models.py
xyberos.database — Database system
xyberos.database
XYBEROS Database subsystem.
Pluggable database backends with a unified interface:
Memory → SQLite → PostgreSQL → MySQL → (custom via entry points)
Every backend implements IDatabaseProvider(Provider) and is registered
in the DatabaseRegistry. The DatabaseManager orchestrates
connection lifecycle, query execution, transaction management, and
schema migrations across named providers.
Sub-modules
interfaces—IDatabaseProviderabstract base class.registry—DatabaseRegistry(ProviderRegistry[IDatabaseProvider]).manager—DatabaseManagerwith event-bus integration.service—DatabaseService(ProviderService[IDatabaseProvider])for lightweight registry access.pool—ConnectionPoolfor reusable connection management.models— Data models:ConnectionConfig,Query,QueryResult,Migration,DatabaseStats.exceptions— Exception hierarchy.events— Event name constants for event-bus integration.providers— Built-in backends (memory, SQLite).
Typical usage::
from xyberos.database import DatabaseManager, ConnectionConfig
mgr = DatabaseManager()
mgr.register_defaults()
# Connect a SQLite database
mgr.connect(ConnectionConfig.for_sqlite("my_app.db"))
# Execute a query
result = mgr.execute("SELECT * FROM users")
for row in result.rows:
print(row)
# Transactional block
with mgr.transaction():
mgr.execute(
"INSERT INTO users (name) VALUES (?)",
params=("Alice",),
)
DatabaseManager
Orchestrates database access across multiple providers.
The manager maintains a registry of database providers and supports:
- Named provider selection (connect to
"default","analytics", …) - Connection lifecycle management
- Query execution with timing, monitoring, and event-bus integration
- Transaction context managers
- Schema migration orchestration
Usage::
mgr = DatabaseManager()
mgr.register_defaults()
# Connect the default provider
mgr.connect(ConnectionConfig.for_sqlite("app.db"))
# Execute a query
result = mgr.execute("SELECT * FROM users")
# Transaction context
with mgr.transaction():
mgr.execute("INSERT INTO users (name) VALUES (?)", params=("Alice",))
Source code in xyberos\database\manager.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
default_name
property
writable
Return the name of the default provider alias.
event_bus
property
Return the event bus used for publishing database events.
Returns the kernel EventBusService if available, otherwise
a no-op _NullEventBus.
registry
property
Return the underlying database provider registry.
connect(config, provider=None)
Open a connection on the specified provider (or the default).
Parameters
config:
Connection configuration.
provider:
Provider name to connect. Uses self.default_name when
None.
Source code in xyberos\database\manager.py
disconnect(provider=None)
Close the connection on the specified provider.
If provider is None, disconnects all registered providers.
Source code in xyberos\database\manager.py
dispose(provider=None)
Dispose of all resources held by the specified provider.
If provider is None, disposes all registered providers.
Source code in xyberos\database\manager.py
execute(statement, *, params=None, fetch=0, timeout=None, provider=None)
Execute a SQL statement and return the result.
Parameters
statement:
SQL statement with ? or %s placeholders.
params:
Positional or named parameters.
fetch:
Maximum rows to fetch (0 = all).
timeout:
Query timeout in seconds.
provider:
Provider to execute on. Uses self.default_name when
None.
Returns
QueryResult
Source code in xyberos\database\manager.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | |
execute_many(statement, params, *, provider=None)
Execute a statement with multiple parameter sets.
Returns the total number of rows affected.
Source code in xyberos\database\manager.py
execute_script(sql, *, provider=None)
Execute a multi-statement SQL script.
Source code in xyberos\database\manager.py
list_tables(*, provider=None)
migrate(migrations, *, provider=None)
Apply pending migrations on the specified provider.
Source code in xyberos\database\manager.py
register_defaults()
Register all built-in database providers.
Discovers providers from xyberos.database entry points first,
then falls back to hardcoded imports for built-in providers
that are not yet registered via entry points.
Source code in xyberos\database\manager.py
register_provider(name, provider, *, default=False)
Register a custom database provider.
stats(*, provider=None)
Return runtime statistics for a provider.
table_exists(table_name, *, provider=None)
Check whether table_name exists.
Source code in xyberos\database\manager.py
transaction(provider=None)
Context manager for transactional execution.
Usage::
with mgr.transaction():
mgr.execute("INSERT INTO users (name) VALUES (?)", params=("Alice",))
mgr.execute("INSERT INTO logs (msg) VALUES (?)", params=("created",))
Source code in xyberos\database\manager.py
ConnectionConfig
dataclass
Configuration for a database connection.
Attributes
database_type:
The database engine type.
host:
Server hostname (not used for SQLite).
port:
Server port (not used for SQLite).
database:
Database name (for SQLite this is the file path).
username:
Authentication username.
password:
Authentication password.
pool_size:
Maximum connection pool size (0 = no pooling).
pool_timeout:
Seconds to wait for a connection from the pool.
isolation_level:
Default transaction isolation level.
extra:
Engine-specific keyword arguments (e.g. ssl_mode).
Source code in xyberos\database\models.py
dsn
property
Return a DSN-style connection string.
for_postgres(*, host='localhost', port=5432, database='postgres', username='postgres', password='', pool_size=10)
classmethod
Convenience factory for a PostgreSQL config.
Source code in xyberos\database\models.py
for_sqlite(path=':memory:')
classmethod
QueryResult
dataclass
Result of a query execution.
Attributes
rows: Fetched rows as a list of dicts (column name → value). row_count: Number of rows affected (for INSERT/UPDATE/DELETE). columns: Column names from the result set. duration_ms: Execution time in milliseconds. provider: Which provider produced this result.
Source code in xyberos\database\models.py
xyberos.common — Common abstractions
xyberos.common
xyberos.common — Zero-dependency shared layer for the XYBEROS platform.
Provides the foundational abstractions used by every subsystem:
provider — Provider(ABC) base class with name, priority, enabled,
capability, and can_handle
registry — ProviderRegistry[T] generic registry with entry-point
discovery, capability-based selection, and graceful
degradation
service — ProviderService[T] convenience wrapper around a registry
pipeline — Pipeline[T] generic sequential processor chain
capabilities — ProviderCapability dataclass + phase factory helpers
errors — XyberosError base with contextual error information
types — Factory helpers for slotted dataclass fields
guards — Input validation helpers
plugin — discover_entry_points, discover_and_register,
select_best_provider, fallback_execute
Provider
Bases: ABC
Base class for every provider in XYBEROS.
Every provider — whether for language detection, entity extraction, safety evaluation, or embedding — inherits from this class.
Subclasses must provide a unique name and may optionally override priority (higher = runs first), enabled, capability, and can_handle.
Source code in xyberos\common\provider.py
capability
property
Self-declared capability of this provider.
Defaults to a Phase 1 deterministic capability. Override in subclasses to declare actual capabilities.
enabled
property
Whether this provider is currently active.
name
abstractmethod
property
writable
Unique provider name (e.g. "regex", "lingua").
priority
property
Execution priority. Higher values run first.
can_handle(input)
Determine whether this provider can process input.
The default implementation returns True for any input.
Override in subclasses to implement capability gating
based on input content, size, language, or other criteria.
Parameters
input : The input to check (e.g. a string, an Observation, etc.). The type depends on the specific provider interface.
Returns
bool
True if this provider can handle input.
Source code in xyberos\common\provider.py
ProviderRegistry
Bases: Generic[T]
Generic registry for typed providers.
Manages a named collection of providers and tracks a default. Used throughout XYBEROS by every subsystem that supports pluggable backends.
Usage::
registry: ProviderRegistry[ILanguageProvider] = ProviderRegistry()
registry.register("lingua", LinguaLanguageProvider(), default=True)
provider = registry.default()
Source code in xyberos\common\registry.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
all()
best(input, *, max_phase=None, prefer_fast=False)
Select the best registered provider for input.
Uses :func:select_best_provider to evaluate all
registered providers.
Parameters
input : The input to check compatibility for. max_phase : Maximum capability phase to consider. prefer_fast : Prefer lower latency over higher priority.
Returns
T or None
Source code in xyberos\common\registry.py
clear()
default()
Return the default provider. Raises RuntimeError if none.
default_name()
discover(group, *, extra_groups=None, default_name=None)
Discover and register plugins via Python entry points.
Parameters
group :
Entry point group (e.g. "xyberos.providers").
extra_groups :
Additional groups for backward compatibility.
default_name :
If given, set this entry as the default.
Returns
list[str] Names of successfully registered providers.
Source code in xyberos\common\registry.py
exists(name)
fallback(input, method_name, *args, max_phase=None, default_result=None, **kwargs)
Execute method_name with graceful degradation across providers.
Attempts each provider in priority order. Falls through on failure.
Parameters
input :
Input to pass to can_handle() and the target method.
method_name :
Method to call on each provider (e.g. "detect").
max_phase :
Maximum capability phase to consider.
default_result :
Returned if all providers fail.
args, kwargs :
Additional arguments forwarded to the method.
Returns
Any
Source code in xyberos\common\registry.py
get(name)
Retrieve a provider by name. Raises KeyError if missing.
names()
register(name, provider, *, default=False)
Register a provider under name.
If default is True or no default has been set yet,
this provider becomes the default.
Source code in xyberos\common\registry.py
remove(name)
Unregister a provider. No-op if name does not exist.
Source code in xyberos\common\registry.py
set_default(name)
ProviderService
Bases: Generic[T]
Convenience base for services that manage a provider registry.
Wraps a :class:ProviderRegistry and exposes the most common
operations directly so subclasses don't have to repeat delegation.
Also surfaces capability-based selection and graceful degradation.
Usage::
class MyService(ProviderService[IMyProvider]):
def do_something(self) -> None:
provider = self.default()
provider.run()
Source code in xyberos\common\service.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
registry
property
Return the underlying provider registry.
best(input, *, max_phase=None, prefer_fast=False)
Select the best registered provider for input.
Parameters
input : The input to check compatibility for. max_phase : Maximum capability phase to consider. prefer_fast : Prefer lower latency over higher priority.
Returns
T or None
Source code in xyberos\common\service.py
clear_providers()
default()
default_name()
discover(group, *, extra_groups=None, default_name=None)
Discover and register plugins via Python entry points.
Parameters
group :
Entry point group (e.g. "xyberos.providers").
extra_groups :
Additional groups for backward compatibility.
default_name :
If given, set this entry as the default.
Returns
list[str] Names of successfully registered providers.
Source code in xyberos\common\service.py
fallback(input, method_name, *args, max_phase=None, default_result=None, **kwargs)
Execute method_name with graceful degradation across providers.
Parameters
input :
Input to pass to can_handle() and the target method.
method_name :
Method to call on each provider (e.g. "detect").
max_phase :
Maximum capability phase to consider.
default_result :
Returned if all providers fail.
args, kwargs :
Additional arguments forwarded to the method.
Returns
Any
Source code in xyberos\common\service.py
has_provider(name)
provider(name)
providers()
register(name, provider, *, default=False)
Register a provider (delegates to self.registry).
remove_provider(name)
ProviderCapability
dataclass
Self-declared capability of a provider.
Used by :meth:Provider.can_handle to determine whether a provider
is suitable for a given input, and by managers to select the best
matching provider.
Attributes
phase :
Processing phase (1=deterministic, 2=NLP, 3=ML, 4=LLM).
languages :
ISO language codes this provider supports (empty = any).
min_input_length :
Minimum input length (characters) this provider requires.
max_input_length :
Maximum input length (characters) this provider can handle.
0 means no limit.
latency_p95_ms :
Expected p95 latency in milliseconds.
requires_gpu :
Whether this provider requires GPU hardware.
requires_network :
Whether this provider needs network access (e.g. API calls).
description :
Human-readable description of what this provider does.
metadata :
Arbitrary key-value pairs for extension.
Source code in xyberos\common\capabilities.py
Pipeline
Bases: Generic[T]
Generic sequential processor chain.
Executes a list of :class:Stage instances in order.
If a stage fails the error is wrapped in an :class:XyberosError
with full context and re-raised.
When a monitor is provided, every stage execution emits duration and error metrics.
Usage::
pipeline: Pipeline[Observation] = Pipeline([
LanguageProcessor(),
TokenizerProcessor(),
])
result = pipeline.execute(observation)
Source code in xyberos\common\pipeline.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
stages
property
Return a copy of the registered stages.
add(stage)
execute(initial)
Run all stages sequentially, emitting metrics per stage.
Source code in xyberos\common\pipeline.py
insert(index, stage)
Stage
Bases: ABC, Generic[T]
A single stage in a processing pipeline.
Subclasses implement :meth:process and provide a name
for logging and error reporting.
Source code in xyberos\common\pipeline.py
name
abstractmethod
property
Human-readable stage name (e.g. "LanguageProcessor").