-
Notifications
You must be signed in to change notification settings - Fork 1
How To Extend
Three common extensions, each a few lines. The reference is designed so that these are the only places you need to touch.
The whole point of the Capability Provider Model: swapping who answers a capability changes nothing above it.
from genesis_kernel import CapabilityProvider, Capability, Result
class MyModelProvider(CapabilityProvider):
name = "my-llm"
provides = [Capability.REASONING, Capability.PLANNING]
leaves_box = True # be honest: does invoking send data off-box?
deterministic = False
def available(self) -> bool:
return bool(os.environ.get("MY_LLM_API_KEY")) # skipped silently if absent
def invoke(self, capability, request):
# ... call your model ...
return Result(ok=True, output=..., provider=self.name)
kernel.register_provider(MyModelProvider()) # register BEFORE the EchoProvider to prefer it- Set
leaves_box/deterministictruthfully — the router relies on them for sovereignty and reproducibility decisions. - With no key,
available()returnsFalseand the router falls back — no crash.
from genesis_kernel import Subsystem, Capability, Event, Context
class ResearchSubsystem(Subsystem):
name = "research"
abi_version = "0.2" # a wrong version is refused at registration
provides = [Capability.REASONING]
def handle(self, event: Event, ctx: Context):
ctx.spend(300) # account for compute before using it
# ... do work; MUST NOT touch the outside world directly (ask the kernel) ...
return event.derive("research.done", findings=[...])
kernel.register_subsystem(ResearchSubsystem())Rules the ABI enforces: don't call another subsystem directly (compose via events), don't perform
outside side effects directly, always spend() budget. See specs/kernel-abi.md.
Registering a policy can only ever make the system more careful (most-restrictive-wins).
from genesis_kernel import Policy, HookPoint, Decision
class RateLimitPolicy(Policy):
name = "ratelimit.r1"
point = HookPoint.PRE_ACT
def evaluate(self, event, ctx) -> Decision:
if too_many_actions(ctx):
return Decision(False, "rate limit exceeded", self.name) # fail-closed friendly
return Decision(True, "within limit", self.name)
kernel.register_policy(RateLimitPolicy())Remember: any exception you raise becomes a deny (fail-closed), and both allow and deny are audited automatically.
Whatever you add, keep the reference tests green — they are the conformance oracle:
cd reference && python tests/test_kernel.pyIf your implementation disagrees with the reference on a lifecycle or fail-closed question, the reference is the tie-breaker.
→ Next: Contributing · Roadmap
Genesis OS — Cognitive Agent Architecture Blueprint · Apache-2.0 · Capability must never outrun accountability.
Start
Core ideas
- Cognitive Kernel ABI
- Policy Hook Surface
- Capability Provider Model
- Reality Grading Loop
- Governance and Constitution
Build & contribute
Reference