koi_net.protocol.knowledge_object

Classes

KnowledgeObject(**data)

A normalized knowledge representation for internal processing.

class koi_net.protocol.knowledge_object.KnowledgeObject(**data)[source]

Bases: BaseModel

A normalized knowledge representation for internal processing.

Represents an RID, manifest, bundle, or event. Contains three fields (normalized_event_type, source, network_targets) used for decision making in the knowledge processing pipeline.

The source indicates which node this object originated from, or None if it was generated by this node.

The normalized event type indicates how the knowledge object is viewed from the perspective of this node, and what cache actions will take place. (NEW, UPDATE) -> cache write, FORGET -> cache delete, None -> no cache action, and end of pipeline.

The network targets indicate other nodes in the network this knowledge object will be sent to. The event sent to them will be constructed from this knowledge object’s RID, manifest, contents, and normalized event type.

Parameters:
  • rid (RID)

  • manifest (Manifest | None)

  • contents (dict | None)

  • event_type (EventType | None)

  • normalized_event_type (EventType | None)

  • source (KoiNetNode | None)

  • network_targets (set[KoiNetNode])

property bundle: Bundle

Bundle representation of knowledge object.

contents: dict | None
event_type: EventType | None
classmethod from_bundle(bundle, event_type=None, source=None)[source]

Creates a KnowledgeObject from a Bundle.

Return type:

KnowledgeObject

Parameters:
  • bundle (Bundle)

  • event_type (EventType | None)

  • source (KoiNetNode | None)

classmethod from_event(event, source=None)[source]

Creates a KnowledgeObject from an Event.

Return type:

KnowledgeObject

Parameters:
  • event (Event)

  • source (KoiNetNode | None)

classmethod from_manifest(manifest, event_type=None, source=None)[source]

Creates a KnowledgeObject from a Manifest.

Return type:

KnowledgeObject

Parameters:
  • manifest (Manifest)

  • event_type (EventType | None)

  • source (KoiNetNode | None)

classmethod from_rid(rid, event_type=None, source=None)[source]

Creates a KnowledgeObject from an RID.

Return type:

KnowledgeObject

Parameters:
  • rid (RID)

  • event_type (EventType | None)

  • source (KoiNetNode | None)

manifest: Manifest | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

network_targets: set[KoiNetNode]
property normalized_event: Event

Event representation of knowledge object.

normalized_event_type: EventType | None
rid: RID
source: KoiNetNode | None