CoreProtocol — The Coordinator
The core is the bus. It connects stacks, plugins, and the model. It has an ID. It routes operations. It manages the composition. The core is not “the entity.” The entity is the composition. But the core is what holds the composition together.The
core_id persists across reconfigurations. Swap the model, change the stacks, add or remove plugins — the core_id stays the same.CoreProtocol Interface
The default implementation iskernle.entity.Entity.
Properties
Model Management
Stack Management
Plugin Management
Routed Memory Operations
Upsert Semantics (v0.13.12)
drive() and relationship() use get-then-atomic-update-or-create:
drive()— Looks up an existing drive bydrive_type. If found, updatesintensity,focus_areas, and other fields in place. The originalid,created_at, and version chain are preserved. Only explicitly provided optional fields are overwritten.relationship()— Looks up an existing relationship byentity_name(other_stack_id). If found, updates fields in place and incrementsinteraction_count. If not found, creates a new relationship.
VersionConflictError propagates if the record was modified between read and write.
Routed Search, Load, and Status
Trust Operations
Checkpoint & Binding
Stack Management
The core manages multiple stacks with one active at a time. All routed operations go to the active stack.stack.on_attach(core_id, inference_service) so the stack can pass the inference service to its components. When detached, stack.on_detach(core_id) clears inference access.
Plugin Lifecycle
Plugins follow a strict lifecycle managed by the core.Protocol Version Enforcement
The core checks the plugin’sprotocol_version property on load:
Operation Routing
When you callentity.episode(...), the core does not just forward to the stack. It enforces provenance first.
The provenance step populates:
- id: New UUID
- stack_id: From the active stack
- source_entity:
"core:{core_id}"or a custom source (plugins use"plugin:{name}") - source_type: Explicit on all write paths. Accepts a string or
SourceTypeenum value. Defaults to"direct_experience"when not specified. Invalid strings raiseValueError. Internal subsystems pass explicit values: checkpoint uses"observation", sync uses"external"withsource_entity="kernle:sync", doctor uses"observation"withsource_entity="kernle:doctor". - created_at: Current UTC timestamp
- derived_from: Optional lineage chain
- context / context_tags: Optional grouping
stack.save_*() calls skip provenance, producing memories with incomplete attribution.
Checkpoint Save and Restore
Thecheckpoint() method saves the current composition to a timestamped JSON file. from_checkpoint() restores an Entity from a saved checkpoint.
schema_version— format version (currently1) for forward compatibilitycheckpoint_id— unique identifier for this checkpointmessage— human-readable descriptionbinding— the composition snapshot (core_id, model_config, stacks, plugins)created_at— UTC timestamp
- Missing
schema_versionis treated as version 1 with a warning (backward compat for checkpoints created before this change) schema_version > 1raisesValueError(forward compat — prevents loading newer formats with older code)
checkpoint() call retains the 10 most recent checkpoints per core_id, removing older ones automatically.