lex-cognitive-tapestry
A LegionIO cognitive architecture extension that models narrative construction as weaving. Individual cognitive elements (threads) are spun and then woven into tapestries — structured compositions that measure coherence and completeness.
What It Does
Manages two types of objects:
-
Threads: individual cognitive strands of five types —
experience,belief,memory,emotion,narrative— each with strength, domain, and content - Tapestries: compositions that hold threads, measured by completeness (how full they are) and coherence (how aligned the threads are)
Threads strengthen or fray over time. A tapestry becomes a :masterwork when its threads are taut and it is fully complete.
Usage
require 'lex-cognitive-tapestry'
client = Legion::Extensions::CognitiveTapestry::Client.new
# Spin some threads
t1 = client.spin_thread(thread_type: :memory, domain: :childhood, content: 'summer at the lake', strength: 0.8)
# => { success: true, thread: { id: "uuid...", thread_type: :memory, color: :blue, strength: 0.8, ... } }
t2 = client.spin_thread(thread_type: :emotion, domain: :childhood, content: 'warmth and safety')
t3 = client.spin_thread(thread_type: :narrative, domain: :identity, content: 'I am someone who loves nature')
# Create a tapestry
tap = client.create_tapestry(name: 'Childhood Summer', pattern: :satin, capacity: 10)
# => { success: true, tapestry: { id: "uuid...", pattern: :satin, completeness: 0.0, ... } }
# Weave threads into the tapestry
client.weave(thread_id: t1[:thread][:id], tapestry_id: tap[:tapestry][:id])
client.weave(thread_id: t2[:thread][:id], tapestry_id: tap[:tapestry][:id])
client.weave(thread_id: t3[:thread][:id], tapestry_id: tap[:tapestry][:id])
# List all tapestries
client.list_tapestries
# => { success: true, tapestries: [{ completeness: 0.3, coherence_score: 0.61, fraying: false, ... }], count: 1 }
# List only fraying tapestries
client.list_tapestries(fraying_only: true)
# => { success: true, tapestries: [], count: 0 }
# Filter by pattern
client.list_tapestries(pattern: :satin)
# => { success: true, tapestries: [...], count: 1 }
# Loom status report
client.loom_status
# => { success: true, report: { total_threads: 3, total_tapestries: 1, loose_count: 0, by_type: { memory: 1, emotion: 1, narrative: 1, ... }, fraying_count: 0, avg_completeness: 0.3 } }Development
bundle install
bundle exec rspec
bundle exec rubocopLicense
MIT