Class: Insika::Commands::WriteConcept
- Inherits:
-
Object
- Object
- Insika::Commands::WriteConcept
- Defined in:
- lib/insika/commands/write_concept.rb
Overview
Control command: writes a concept (complete concept markdown) into the
KnowledgeStore. Validates the frontmatter (a name is required) before
writing — same discipline as WriteSkill. The STORE POSITION (the
agent/name/tenant triple) is the identity, exactly like a skill:
an operator editing the raw markdown may leave the frontmatter name:
unchanged even while promoting provenance: observed to policy —
that promotion IS this command, no separate "promote" action needed.
-> { name, agent, tenant, updated_at }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(knowledge_store:, event_stream:) ⇒ WriteConcept
constructor
A new instance of WriteConcept.
Constructor Details
#initialize(knowledge_store:, event_stream:) ⇒ WriteConcept
Returns a new instance of WriteConcept.
16 17 18 19 |
# File 'lib/insika/commands/write_concept.rb', line 16 def initialize(knowledge_store:, event_stream:) @knowledge_store = knowledge_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/insika/commands/write_concept.rb', line 21 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) agent = AgentPayload.presence(p[:agent]) tenant = AgentPayload.presence(p[:tenant]) content = p[:content].to_s raise Insika::ValidationError, "name is required" if name.nil? raise Insika::ValidationError, "agent is required" if agent.nil? parsed = validate_frontmatter!(content) rec = @knowledge_store.write(agent, name, content, tenant: tenant) emit(parsed[:type], name, agent) { name: name, agent: agent, tenant: tenant, updated_at: rec["updated_at"] } end |