legion-apollo 0.5.6 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7150a2def38a098c16a2f35362210994cc77537ca6ee3e0e615823cf8e1797c2
4
- data.tar.gz: 6e0bfa593f70915134195672dbe321f03c00c86e1f80fee06f5370f3c6578110
3
+ metadata.gz: 9d677b83515f568ba99bf3288a9b2f7ade65775b816559092b65265966e8a2cd
4
+ data.tar.gz: 9fd3698f16f43357ecc6b1e9791bf46d03d28afb6f7f28bbeac52e7af0a9fe3f
5
5
  SHA512:
6
- metadata.gz: 97783044f23209d697578c0f56d570bc48b9531e5d569f23e4db98bf55cb5d0c4602d6a0fedeb8e7c04a89618d4586c25bc7ca89f1a8d922e8618c5b724cc13e
7
- data.tar.gz: 8498fae869abc9f54520b216ed88e2aea006ee6e520d8421d44cf5781c76ae9c158553e3c34a7e9e1e37d44594248a5c6daae1c7b55336c9692e7b668f00fbb4
6
+ metadata.gz: b7e5ccadab990babeed6409b43c2db932ca85a990defe38f07bde539bccfdcf8620e06140f0dcddae85c8c2016e5251bd91afa0b3aaae31f7f6368ab97104e09
7
+ data.tar.gz: bbbe65132a326f90ba9ebd573f4938a9cfd8cbfba688cd742e4ec39f4128fd72d07a236787f8a23a757336477459034d4907a387e0040416f72e08b49318d4ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.7] - 2026-07-15
4
+ ### Removed
5
+ - Remove .md self-knowledge seed pipeline (bonds must be earned, not implanted)
6
+
3
7
  ## [0.5.5] - 2026-05-15
4
8
 
5
9
  ### Added
@@ -17,8 +17,6 @@ module Legion
17
17
  MIGRATION_PATH = File.expand_path('local/migrations', __dir__).freeze
18
18
  LIFECYCLE_MUTEX = Mutex.new
19
19
  WRITE_MUTEX = Mutex.new
20
- SEED_MUTEX = Mutex.new
21
- HYDRATION_MUTEX = Mutex.new
22
20
 
23
21
  class << self # rubocop:disable Metrics/ClassLength
24
22
  include Legion::Logging::Helper
@@ -33,13 +31,11 @@ module Legion
33
31
  def shutdown
34
32
  LIFECYCLE_MUTEX.synchronize do
35
33
  @started = false
36
- @seeded = false
37
34
  log.info 'Legion::Apollo::Local shutdown'
38
35
  end
39
36
  rescue StandardError => e
40
37
  handle_exception(e, level: :warn, operation: 'apollo.local.shutdown')
41
38
  @started = false
42
- @seeded = false
43
39
  end
44
40
 
45
41
  def started?
@@ -146,22 +142,9 @@ module Legion
146
142
  def reset!
147
143
  LIFECYCLE_MUTEX.synchronize do
148
144
  @started = false
149
- @seeded = false
150
145
  end
151
146
  end
152
147
 
153
- def seed_self_knowledge
154
- return unless started?
155
-
156
- SEED_MUTEX.synchronize { seed_self_knowledge_without_lock }
157
- rescue StandardError => e
158
- handle_exception(e, level: :warn, operation: 'apollo.local.seed_self_knowledge')
159
- end
160
-
161
- def seeded?
162
- @seeded == true
163
- end
164
-
165
148
  def query_by_tags(tags:, limit: 50) # rubocop:disable Metrics/MethodLength
166
149
  connection = local_db_connection
167
150
  tags = normalize_tags_input(tags)
@@ -232,15 +215,6 @@ module Legion
232
215
  { success: false, error: e.message }
233
216
  end
234
217
 
235
- def hydrate_from_global
236
- return { success: false, error: :not_started } unless started?
237
-
238
- HYDRATION_MUTEX.synchronize { hydrate_from_global_without_lock }
239
- rescue StandardError => e
240
- handle_exception(e, level: :error, operation: 'apollo.local.hydrate_from_global')
241
- { success: false, error: e.message }
242
- end
243
-
244
218
  def version_chain(entry_id:, max_depth: 50) # rubocop:disable Metrics/MethodLength
245
219
  return not_started_error unless started?
246
220
 
@@ -278,49 +252,6 @@ module Legion
278
252
 
279
253
  private
280
254
 
281
- def self_knowledge_files
282
- seed_dir = File.join(File.expand_path('../../..', __dir__), 'data', 'self-knowledge')
283
- return [] unless File.directory?(seed_dir)
284
-
285
- Dir[File.join(seed_dir, '*.md')]
286
- end
287
-
288
- def seed_files(files)
289
- count = 0
290
- files.each do |path|
291
- count += 1 if seed_single_file(path)
292
- end
293
- count
294
- end
295
-
296
- def seed_single_file(path)
297
- content = File.read(path)
298
- return false if content.strip.empty?
299
-
300
- tags = ['legionio', 'self-knowledge', File.basename(path, '.md')]
301
- result = ingest(content: content, tags: tags, source_channel: 'self-knowledge',
302
- submitted_by: 'legion-apollo', confidence: 0.9)
303
- return false unless result[:success] && result[:mode] != :deduplicated
304
-
305
- ingest_global(content: content, tags: tags) if global_available?
306
- true
307
- end
308
-
309
- def ingest_global(content:, tags:)
310
- log.debug { "Apollo::Local forwarding seed entry to global tag_count=#{Array(tags).size}" }
311
- Legion::Apollo.ingest(content: content, tags: tags, source_channel: 'self-knowledge',
312
- submitted_by: 'legion-apollo', confidence: 0.9, scope: :global)
313
- rescue StandardError => e
314
- handle_exception(e, level: :debug, operation: 'apollo.local.ingest_global_seed', tag_count: Array(tags).size)
315
- end
316
-
317
- def global_available?
318
- defined?(Legion::Apollo) && Legion::Apollo.started? && Legion::Apollo.respond_to?(:ingest)
319
- rescue StandardError => e
320
- handle_exception(e, level: :debug, operation: 'apollo.local.global_available')
321
- false
322
- end
323
-
324
255
  def local_enabled?
325
256
  return false unless defined?(Legion::Settings)
326
257
 
@@ -388,58 +319,6 @@ module Legion
388
319
  log.info 'Legion::Apollo::Local started'
389
320
  end
390
321
 
391
- def seed_self_knowledge_without_lock
392
- return if @seeded
393
-
394
- files = self_knowledge_files
395
- return if files.empty?
396
-
397
- count = seed_files(files)
398
- @seeded = true
399
- log.info("Apollo::Local seeded #{count} self-knowledge files")
400
- end
401
-
402
- def hydrate_from_global_without_lock # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
403
- local_check = query_by_tags(tags: ['partner'])
404
- if local_check[:success] && local_check[:results]&.any?
405
- log.info 'Apollo::Local hydration skipped because local partner data already exists'
406
- return { success: true, skipped: :local_data_exists }
407
- end
408
-
409
- unless Legion::Apollo.transport_available? || Legion::Apollo.data_available?
410
- log.info 'Apollo::Local hydration skipped because global Apollo is unavailable'
411
- return { success: true, skipped: :global_unavailable }
412
- end
413
-
414
- global_entries = Legion::Apollo.retrieve(text: 'partner bond', scope: :global, limit: 20)
415
- entries = Array(global_entries[:entries] || global_entries[:results])
416
- unless global_entries[:success] && entries.any?
417
- log.info 'Apollo::Local hydration skipped because no global partner data was found'
418
- return { success: true, skipped: :no_global_data }
419
- end
420
-
421
- log.info { "Apollo::Local hydration started global_count=#{entries.size}" }
422
- hydrated = 0
423
- entries.each do |entry|
424
- entry_tags = entry[:tags].is_a?(Array) ? entry[:tags] : []
425
- clean_tags = entry_tags.reject { |tag| tag == 'promoted_from_local' } + ['hydrated_from_global']
426
-
427
- result = ingest(
428
- content: entry[:content],
429
- raw_content: entry[:raw_content] || entry[:content],
430
- tags: clean_tags,
431
- confidence: ((entry[:confidence] || 0.5) * 0.9).round(10),
432
- source_channel: 'global_hydration',
433
- valid_from: entry[:valid_from],
434
- valid_to: entry[:valid_to]
435
- )
436
- hydrated += 1 if result[:success]
437
- end
438
-
439
- log.info { "Apollo::Local hydration completed hydrated=#{hydrated}" }
440
- { success: true, hydrated: hydrated }
441
- end
442
-
443
322
  def ingest_without_lock(content:, tags:, **opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
444
323
  content = normalize_text_input(content)
445
324
  raw_content = normalize_raw_content_input(opts[:raw_content], fallback: content)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Apollo
5
- VERSION = '0.5.6'
5
+ VERSION = '0.5.7'
6
6
  end
7
7
  end
data/lib/legion/apollo.rb CHANGED
@@ -39,9 +39,6 @@ module Legion
39
39
 
40
40
  @started = true
41
41
  log.info 'Legion::Apollo started'
42
-
43
- seed_self_knowledge
44
- Legion::Apollo::Local.hydrate_from_global if Legion::Apollo::Local.started?
45
42
  end
46
43
  rescue StandardError => e
47
44
  handle_exception(e, level: :error, operation: 'apollo.start')
@@ -469,13 +466,6 @@ module Legion
469
466
  { success: false, error: e.message }
470
467
  end
471
468
 
472
- def seed_self_knowledge
473
- log.info 'Apollo self-knowledge seed requested'
474
- Legion::Apollo::Local.seed_self_knowledge if Legion::Apollo::Local.started?
475
- rescue StandardError => e
476
- handle_exception(e, level: :warn, operation: 'apollo.seed_self_knowledge')
477
- end
478
-
479
469
  def apollo_setting(key, default)
480
470
  return default unless defined?(Legion::Settings) && !Legion::Settings[:apollo].nil?
481
471
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: legion-apollo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -66,17 +66,6 @@ files:
66
66
  - CHANGELOG.md
67
67
  - LICENSE
68
68
  - README.md
69
- - data/self-knowledge/01-what-is-legion.md
70
- - data/self-knowledge/02-architecture.md
71
- - data/self-knowledge/03-extensions.md
72
- - data/self-knowledge/04-security.md
73
- - data/self-knowledge/05-llm-pipeline.md
74
- - data/self-knowledge/06-apollo-knowledge.md
75
- - data/self-knowledge/07-cli-reference.md
76
- - data/self-knowledge/08-cognitive-layer.md
77
- - data/self-knowledge/09-teams-integration.md
78
- - data/self-knowledge/10-deployment.md
79
- - data/self-knowledge/11-my-partner.md
80
69
  - lib/legion/apollo.rb
81
70
  - lib/legion/apollo/helpers/confidence.rb
82
71
  - lib/legion/apollo/helpers/similarity.rb
@@ -1,51 +0,0 @@
1
- # What is LegionIO?
2
-
3
- LegionIO is an extensible async job engine and cognitive platform for Ruby. It schedules tasks, creates relationships between services, and runs them concurrently. It was created by Matthew Iverson (@Esity) and is licensed under Apache-2.0.
4
-
5
- LegionIO is not a chatbot. It is a framework that can power chatbots, AI assistants, background workers, service integrations, and autonomous agents. The chat interface is one of many ways to interact with it.
6
-
7
- ## Core Purpose
8
-
9
- LegionIO connects isolated systems — cloud accounts, on-premise services, SaaS tools — into a unified async task engine. It uses RabbitMQ for message passing, supports SQLite/PostgreSQL/MySQL for persistence, and Redis/Memcached for caching.
10
-
11
- ## What LegionIO Does
12
-
13
- - Schedules and executes async tasks across distributed services
14
- - Chains tasks into workflows (Task A -> conditioner -> Task B -> transformer -> Task C)
15
- - Auto-discovers and loads extension gems (LEX plugins) at boot
16
- - Provides a unified REST API on port 4567 for all operations
17
- - Integrates with HashiCorp Vault for secrets and authentication
18
- - Supports Kerberos auto-authentication to Vault using existing AD credentials
19
- - Runs a 19-step LLM pipeline with RAG, guardrails, cost tracking, and model routing
20
- - Maintains a shared knowledge store (Apollo) for organizational knowledge
21
- - Provides a rich terminal UI with AI chat, dashboard, and extension browser
22
- - Tracks token usage and costs per-user and per-team
23
- - Supports HIPAA PHI compliance with redaction, crypto-erasure, and audit trails
24
- - Runs as a macOS/Linux background service via Homebrew or systemd
25
-
26
- ## What LegionIO Does Not Do
27
-
28
- - It does not provide direct cloud infrastructure (no VMs, no networking)
29
- - It does not replace Terraform, Ansible, or Chef for infrastructure management
30
- - It does not host web applications or serve static content
31
- - It does not provide its own LLM — it routes to providers like Bedrock, Anthropic, OpenAI, Gemini, or Ollama
32
- - It does not require RabbitMQ in lite mode (uses an in-process message adapter)
33
- - It does not store credentials on disk — all secrets are in Vault or environment variables
34
-
35
- ## Installation
36
-
37
- Install via Homebrew on macOS:
38
- ```
39
- brew tap legionio/tap
40
- brew install legionio
41
- ```
42
-
43
- Or via RubyGems:
44
- ```
45
- gem install legionio
46
- ```
47
-
48
- ## Key Binaries
49
-
50
- - `legionio` — daemon and operational CLI (start, stop, config, lex, task, mcp, etc.)
51
- - `legion` — interactive terminal shell with AI chat, onboarding wizard, and dashboard
@@ -1,51 +0,0 @@
1
- # LegionIO Architecture
2
-
3
- ## Boot Sequence
4
-
5
- LegionIO starts subsystems in a fixed order. Each phase is individually toggleable.
6
-
7
- 1. Logging (legion-logging)
8
- 2. Settings (legion-settings — loads from /etc/legionio, ~/.legionio, ./settings)
9
- 3. Crypt (legion-crypt — Vault connection, Kerberos auto-auth)
10
- 4. Transport (legion-transport — RabbitMQ or InProcess lite adapter)
11
- 5. Cache (legion-cache — Redis, Memcached, or Memory adapter)
12
- 6. Data (legion-data — SQLite, PostgreSQL, or MySQL via Sequel)
13
- 7. RBAC (legion-rbac — role-based access control)
14
- 8. LLM (legion-llm — AI provider setup and routing)
15
- 9. Apollo (legion-apollo — shared and local knowledge store)
16
- 10. GAIA (legion-gaia — cognitive coordination layer, 24 phases)
17
- 11. Telemetry (OpenTelemetry tracing, optional)
18
- 12. Extensions (two-phase parallel: require+autobuild, then hook actors)
19
- 13. API (Sinatra/Puma REST API on port 4567)
20
-
21
- Shutdown runs in reverse order. Reload shuts down then re-runs from settings onward.
22
-
23
- ## Core Gems
24
-
25
- | Gem | Purpose |
26
- |-----|---------|
27
- | legion-transport | RabbitMQ AMQP messaging + InProcess lite adapter |
28
- | legion-cache | Caching (Redis/Memcached/Memory) |
29
- | legion-crypt | Encryption, Vault integration, JWT, Kerberos auth, mTLS |
30
- | legion-data | Database persistence via Sequel (SQLite/PostgreSQL/MySQL) |
31
- | legion-json | JSON serialization (multi_json wrapper) |
32
- | legion-logging | Console + structured JSON logging with redaction |
33
- | legion-settings | Configuration management with schema validation |
34
- | legion-llm | LLM integration with 19-step pipeline |
35
- | legion-mcp | MCP server with 58+ tools |
36
- | legion-gaia | Cognitive coordination (24 phases: 16 active + 8 dream) |
37
- | legion-apollo | Shared knowledge store client (local SQLite + global pgvector) |
38
- | legion-rbac | Role-based access control with Vault-style policies |
39
- | legion-tty | Rich terminal UI with AI chat and operational dashboard |
40
-
41
- ## Extension Loading
42
-
43
- Extensions are gems named `lex-*`, auto-discovered via Bundler or Gem::Specification. Loading is two-phase and parallel: all extensions are required and `autobuild` runs concurrently on a thread pool, then `hook_all_actors` starts subscriptions sequentially. This prevents race conditions.
44
-
45
- ## Lite Mode
46
-
47
- Setting `LEGION_MODE=lite` replaces RabbitMQ with an InProcess adapter and Redis with a Memory adapter. No external infrastructure required. Useful for development, demos, and single-machine deployments.
48
-
49
- ## REST API
50
-
51
- Full REST API served by Sinatra/Puma on port 4567. Endpoints include tasks, extensions, runners, nodes, schedules, relationships, settings, events (SSE), transport status, hooks, workers, teams, capacity, tenants, audit, RBAC, and webhooks. JWT Bearer auth middleware with rate limiting.
@@ -1,54 +0,0 @@
1
- # LegionIO Extension System (LEX)
2
-
3
- ## What is a LEX?
4
-
5
- A LEX (Legion Extension) is a Ruby gem named `lex-*` that plugs into LegionIO. Each LEX defines runners (functions) and actors (execution modes). Extensions are auto-discovered at boot — install a gem and it loads automatically.
6
-
7
- ## Actor Types
8
-
9
- | Type | Behavior |
10
- |------|----------|
11
- | Subscription | Consumes messages from an AMQP queue |
12
- | Polling | Polls on a schedule |
13
- | Interval (Every) | Runs at a fixed interval |
14
- | Once | Runs once at startup |
15
- | Loop | Runs continuously |
16
- | Nothing | Passive — only invoked via API or other extensions |
17
-
18
- ## Creating an Extension
19
-
20
- ```bash
21
- legion lex create myextension # scaffold a new lex-myextension gem
22
- legion generate runner myrunner # add a runner with functions
23
- legion generate actor myactor # add an actor with type selection
24
- legion generate tool mytool # add an MCP tool
25
- ```
26
-
27
- ## Extension Categories
28
-
29
- ### Core Operational (21 extensions)
30
- node, tasker, scheduler, synapse, LLM gateway, detect, telemetry, acp, react, webhook, health, metering, exec, conditioner, transformer, tick, audit, codegen, privatecore, lex (meta), knowledge
31
-
32
- ### Agentic/Cognitive (13 consolidated gems + supporting)
33
- self (identity, metacognition, reflection, personality, agency), affect (emotion, mood, sentiment), imagination (creative generation, dream ideation), language (NLU, discourse), memory (episodic, semantic, working memory), social (theory of mind, social cognition), swarm-github (code review), mesh (inter-agent communication), mind-growth (autonomous expansion), autofix, dataset, eval, factory
34
-
35
- ### AI Provider Integrations (7)
36
- azure-ai, bedrock, claude, foundry, gemini, openai, xai
37
-
38
- ### Service Integrations (10 common + 40 additional)
39
- Common: consul, github, http, kerberos, vault, tfe, microsoft-teams, slack, webhook, acp
40
- Additional: chef, jfrog, ssh, smtp, kafka, jira, docker, kubernetes, and more
41
-
42
- ## Role-Based Filtering
43
-
44
- Extensions load based on role profile:
45
- - `nil` (default): all extensions
46
- - `:core`: 14 core operational only
47
- - `:cognitive`: core + all agentic
48
- - `:service`: core + service integrations
49
- - `:dev`: core + AI + essential agentic
50
- - `:custom`: explicit list from settings
51
-
52
- ## Extension Discovery
53
-
54
- At boot, LegionIO calls `Bundler.load.specs` (or `Gem::Specification` fallback) to find all `lex-*` gems. Each extension's `autobuild` creates runners and actors. After all extensions load, `hook_all_actors` activates AMQP subscriptions and timers.
@@ -1,46 +0,0 @@
1
- # LegionIO Security
2
-
3
- ## Authentication
4
-
5
- ### Kerberos + Vault
6
- LegionIO authenticates to HashiCorp Vault using Kerberos (SPNEGO). On macOS or Linux machines joined to Active Directory, the existing Kerberos ticket is used — no password entry needed. The SPNEGO token is sent as an HTTP Authorization header to Vault's Kerberos auth backend, which returns a Vault token. Token renewal runs in a background thread at 75% TTL.
7
-
8
- ### JWT Authentication
9
- The REST API uses JWT Bearer auth. Tokens are validated against JWKS endpoints. Skip paths exist for health and readiness checks.
10
-
11
- ### mTLS
12
- Optional mutual TLS for internal communications. Vault PKI issues certificates, and a background thread rotates them at 50% TTL. Feature-flagged via `security.mtls.enabled`.
13
-
14
- ## Secrets Management
15
-
16
- All secrets are stored in HashiCorp Vault, never on disk. Config files reference secrets using `vault://` URIs that are resolved at runtime. Environment variable fallback is supported via `env://` URIs.
17
-
18
- Example: `"bearer_token": "vault://secret/data/llm/bedrock#bearer_token"`
19
-
20
- ## RBAC
21
-
22
- Optional role-based access control using Vault-style flat policies. Policies map identities to allowed actions on resources. Enforced at the API middleware layer and in the LLM pipeline.
23
-
24
- ## HIPAA PHI Compliance
25
-
26
- - **PHI Tagging**: Metadata classification for sensitive data
27
- - **PHI Access Logging**: Audit trail via Legion::Audit for all PHI access
28
- - **PHI Erasure**: Crypto-erasure orchestration via Crypt::Erasure + Cache purge
29
- - **PHI TTL Cap**: legion-cache enforces maximum TTL for PHI-tagged data
30
- - **Redaction**: Automatic PII/PHI redaction in all log output via legion-logging
31
-
32
- All PHI features are off by default and enabled via configuration.
33
-
34
- ## Audit
35
-
36
- - Tamper-evident hash chain for audit entries
37
- - 7-year tiered retention (hot -> warm -> cold storage)
38
- - SIEM export for Splunk/ELK ingestion
39
- - Queryable via CLI (`legion audit`) and REST API
40
-
41
- ## Network Security
42
-
43
- - No public IPs or ingress in production deployments
44
- - TLS required on all connections (Optum-sanctioned CAs only in UHG deployments)
45
- - Rate limiting middleware with per-IP/agent/tenant tiers
46
- - Request body size limits (1MB max)
@@ -1,54 +0,0 @@
1
- # LegionIO LLM Pipeline
2
-
3
- ## Overview
4
-
5
- LegionIO routes AI requests through a 19-step pipeline that adds governance, RAG context, tool use, cost tracking, and knowledge capture. The pipeline is provider-agnostic — it works with Bedrock, Anthropic, OpenAI, Gemini, and local Ollama.
6
-
7
- ## Pipeline Steps
8
-
9
- 1. **Normalize** — standardize request format
10
- 2. **Profile** — derive caller profile (user, system, service)
11
- 3. **RBAC** — check access permissions
12
- 4. **Classification** — classify request sensitivity
13
- 5. **Billing** — check budget and rate limits
14
- 6. **Guardrails** — input validation and safety checks
15
- 7. **GAIA Advisory** — cognitive layer enrichment (optional system prompt)
16
- 8. **RAG Context** — retrieve relevant knowledge from Apollo (global + local)
17
- 9. **MCP Discovery** — discover available tools
18
- 10. **Enrichment Injection** — prepend GAIA/RAG context to system prompt
19
- 11. **Fleet Selection** — choose optimal model/provider
20
- 12. **Dispatch** — send request to LLM provider
21
- 13. **Parse Response** — extract text and tool calls
22
- 14. **Tool Calls** — execute MCP tools if requested
23
- 15. **Post-Response** — post-processing
24
- 16. **Audit** — publish audit trail
25
- 17. **Metering** — record token usage and cost
26
- 18. **Timeline** — record timing data
27
- 19. **Knowledge Capture** — write significant responses back to Apollo
28
-
29
- ## Supported Providers
30
-
31
- | Provider | Models | Auth |
32
- |----------|--------|------|
33
- | AWS Bedrock | Claude, Llama, Mistral | Bearer token (from Vault) |
34
- | Anthropic | Claude family | API key |
35
- | OpenAI | GPT-4, GPT-3.5 | API key |
36
- | Google Gemini | Gemini Pro, Flash | API key |
37
- | Ollama | Any local model | None (localhost) |
38
-
39
- ## Cost Tracking
40
-
41
- Every LLM call is metered. Token counts (input/output) and estimated costs are tracked per-request, per-session, per-user, and per-team. The status bar in the terminal UI shows real-time token count and cost. Budget limits can be set per-user or per-team.
42
-
43
- ## Model Routing
44
-
45
- The fleet selection step chooses the optimal model based on request classification, cost constraints, and provider availability. Model escalation automatically retries with a more capable model if the initial response fails quality checks.
46
-
47
- ## RAG Integration
48
-
49
- Step 8 retrieves relevant context from Apollo using scope routing:
50
- - `:local` — node-local SQLite+FTS5 store only
51
- - `:global` — shared PostgreSQL+pgvector store
52
- - `:all` — both merged, deduplicated by content hash, ranked by confidence
53
-
54
- Retrieved context is injected into the system prompt by the Enrichment Injector (step 10).
@@ -1,54 +0,0 @@
1
- # Apollo Knowledge Store
2
-
3
- ## What is Apollo?
4
-
5
- Apollo is LegionIO's shared knowledge store. It provides organizational memory that persists across sessions and is shared across all LegionIO nodes. Every AI response can reference knowledge from Apollo, and significant responses are captured back into it.
6
-
7
- ## Architecture
8
-
9
- ### Local Store (every node)
10
- - SQLite database with FTS5 full-text search
11
- - Content-hash deduplication (MD5)
12
- - Optional LLM embeddings (1024-dim) with cosine rerank
13
- - TTL-based expiry (default 5 years)
14
- - Works offline — no network required
15
-
16
- ### Global Store (shared)
17
- - PostgreSQL with pgvector extension
18
- - HNSW cosine similarity index
19
- - Agents interact via RabbitMQ (no direct DB access)
20
- - Hosted on Azure PostgreSQL Flexible Server
21
-
22
- ## Scope Routing
23
-
24
- All queries and ingests accept a `scope:` parameter:
25
- - `:local` — SQLite only
26
- - `:global` — PostgreSQL only (via transport or co-located extension)
27
- - `:all` — both merged, deduplicated by content hash, ranked by confidence
28
-
29
- ## Knowledge Capture
30
-
31
- The LLM pipeline's step 19 (Knowledge Capture) automatically writes significant responses back to Apollo. This creates a feedback loop where the system learns from its own interactions. Content-hash deduplication prevents echo chambers.
32
-
33
- ## Knowledge CLI
34
-
35
- ```
36
- legion knowledge query "question" # query and synthesize answer
37
- legion knowledge retrieve "question" # raw source chunks
38
- legion knowledge ingest <path> # ingest file or directory
39
- legion knowledge status # corpus stats
40
- legion knowledge health # full health report
41
- legion knowledge maintain # orphan detection and cleanup
42
- legion knowledge quality # quality report
43
- legion knowledge monitor add <path> # watch a directory for changes
44
- legion knowledge capture commit # capture git commit as knowledge
45
- ```
46
-
47
- ## Content Pipeline
48
-
49
- Files ingested via `legion knowledge ingest` go through:
50
- 1. Format detection (Markdown, PDF, DOCX, plain text)
51
- 2. Chunking by heading hierarchy (H1-H6 with ancestry path)
52
- 3. Delta detection (only new/changed files via manifest)
53
- 4. Batch embedding (one LLM call per file, not per chunk)
54
- 5. Upsert to Apollo (local and/or global based on scope)
@@ -1,59 +0,0 @@
1
- # LegionIO CLI Reference
2
-
3
- ## Interactive Shell
4
-
5
- Running `legion` with no arguments launches the rich terminal UI:
6
- - Digital rain intro animation on first run
7
- - Onboarding wizard with Kerberos identity detection
8
- - AI chat shell with streaming responses
9
- - Dashboard (Ctrl+D) with service status panels
10
- - Extension browser, config editor, command palette (Ctrl+K)
11
- - 115+ slash commands, tab completion, session persistence
12
-
13
- ## Key Commands
14
-
15
- ### Daemon Operations (legionio)
16
- ```
17
- legionio start # start daemon
18
- legionio stop # stop daemon
19
- legionio status # check daemon status
20
- legionio doctor # 11-check environment diagnosis
21
- legionio config scaffold # generate starter config files
22
- legionio config import <url> # import config from URL
23
- legionio bootstrap <url> # one-command setup (config + scaffold + install packs)
24
- legionio setup agentic # install 47 cognitive gems
25
- legionio setup claude-code # configure MCP server for Claude Code
26
- legionio setup cursor # configure MCP server for Cursor
27
- legionio mcp stdio # start MCP server (stdio transport)
28
- legionio lex list # list loaded extensions
29
- legionio update # self-update via Homebrew or gem
30
- ```
31
-
32
- ### Interactive / Dev (legion)
33
- ```
34
- legion # launch rich terminal UI
35
- legion chat # AI chat REPL
36
- legion do "natural language" # natural language command routing
37
- legion knowledge query "question" # query knowledge base
38
- legion commit # AI-generated commit message
39
- legion pr # AI-generated PR description
40
- legion review # AI code review
41
- legion plan # read-only exploration mode
42
- legion memory list # persistent memory management
43
- legion mind-growth status # cognitive architecture status
44
- ```
45
-
46
- ### MCP Server
47
-
48
- LegionIO exposes 58+ MCP tools when configured as an MCP server in Claude Code, Cursor, or VS Code. Tools cover knowledge queries, extension management, task operations, system status, and more.
49
-
50
- ## Natural Language Commands
51
-
52
- `legion do` routes free-text to the right extension capability:
53
- ```
54
- legion do "list all running extensions"
55
- legion do "check system health"
56
- legion do "show vault status"
57
- ```
58
-
59
- It tries three resolution paths: daemon API, in-process capability registry, LLM classification.
@@ -1,49 +0,0 @@
1
- # LegionIO Cognitive Layer
2
-
3
- ## GAIA (Cognitive Coordination)
4
-
5
- GAIA is LegionIO's cognitive coordination layer. It manages 24 phases (16 active + 8 dream) in a tick-based cycle. Each tick runs through phases like sensory processing, attention, working memory integration, prediction, emotional evaluation, action selection, and reflection.
6
-
7
- ### Active Phases (16)
8
- sensory_processing, attention_filtering, working_memory_integration, contextual_memory_retrieval, knowledge_retrieval, prediction_engine, emotional_evaluation, action_selection, social_cognition, theory_of_mind, homeostasis_regulation, autonomy_gating, identity_entropy_check, post_tick_reflection, audit_publish, metering
9
-
10
- ### Dream Phases (8)
11
- memory_consolidation, dream_generation, emotional_processing, creative_association, pattern_extraction, belief_update, schema_integration, dream_ideation
12
-
13
- ## Agentic Extensions
14
-
15
- LegionIO includes 13 consolidated cognitive domain gems:
16
-
17
- | Gem | Domain |
18
- |-----|--------|
19
- | lex-agentic-self | Identity, metacognition, reflection, personality, agency, self-talk |
20
- | lex-agentic-affect | Emotion modeling, mood tracking, sentiment analysis |
21
- | lex-agentic-imagination | Creative generation, dream ideation, scenario planning |
22
- | lex-agentic-language | Natural language understanding, discourse analysis |
23
- | lex-agentic-memory | Episodic, semantic, and working memory management |
24
- | lex-agentic-social | Social cognition, theory of mind, preference exchange |
25
- | lex-mesh | Inter-agent communication, gossip protocol, preference profiles |
26
- | lex-mind-growth | Autonomous cognitive architecture expansion |
27
- | lex-swarm-github | Multi-agent code review |
28
- | lex-eval | Evaluation and benchmarking |
29
- | lex-autofix | Autonomous code fix pipeline |
30
- | lex-dataset | Training data management |
31
- | lex-factory | Spec-to-code generation pipeline |
32
-
33
- ## Self-Awareness
34
-
35
- The `lex-agentic-self` extension maintains a live self-model:
36
- - **Metacognition**: Real-time snapshot of loaded extensions, capabilities, health
37
- - **Self-narrative**: Prose description of current state (injected into system prompt)
38
- - **Behavioral fingerprint**: 6-dimension identity tracking with drift detection
39
- - **Personality**: Big Five OCEAN traits that evolve slowly over time
40
- - **Reflection**: Post-tick analysis with health scores across 7 categories
41
-
42
- ## Mind Growth
43
-
44
- `lex-mind-growth` enables autonomous expansion of cognitive capabilities:
45
- - Gap analysis against reference cognitive models
46
- - Proposal, evaluation, and staged build pipeline
47
- - Swarm-based building and distributed consensus
48
- - Competitive evolution with fitness-based selection
49
- - 25 completed phases, 998+ specs
@@ -1,44 +0,0 @@
1
- # Microsoft Teams Integration
2
-
3
- ## Overview
4
-
5
- The `lex-microsoft_teams` extension connects LegionIO to Microsoft Teams via the Microsoft Graph API. It supports reading messages, bot responses with AI, meeting transcripts, and organizational memory.
6
-
7
- ## Authentication
8
-
9
- Two auth paths run in parallel:
10
- - **Application (client credentials)**: Bot-to-bot communication via client_id/client_secret
11
- - **Delegated (user OAuth)**: User-context access via browser PKCE flow or device code fallback
12
-
13
- Tokens are persisted to Vault (with local file fallback) and auto-refreshed with a 60-second pre-expiry buffer.
14
-
15
- ## Capabilities
16
-
17
- ### Message Reading
18
- - 1:1 and group chat messages
19
- - Channel messages across teams
20
- - Real-time message processing via AMQP transport
21
-
22
- ### AI Bot
23
- - Direct chat mode: users DM the bot, get AI responses via LLM pipeline
24
- - Conversation observer mode: passive extraction from watched chats (disabled by default)
25
- - Multi-turn sessions with context persistence
26
- - Memory trace injection for organizational context
27
-
28
- ### Meetings and Transcripts
29
- - Online meeting CRUD and join URL lookup
30
- - Meeting transcript retrieval (VTT/DOCX format)
31
- - Attendance reports
32
-
33
- ### Organizational Intelligence
34
- - Profile ingestion: identity, contacts, conversation summaries
35
- - Incremental sync every 15 minutes for new messages
36
- - Memory traces stored across sender, teams, and chat domains
37
-
38
- ## RAG Integration
39
-
40
- The bot injects organizational memory context into every response:
41
- - Retrieves traces from lex-agentic-memory across 3 domain scopes
42
- - Deduplicates by trace_id, ranks by strength and recency
43
- - Appends formatted context to the system prompt (2000 token budget)
44
- - Per-user preference profiles from lex-mesh customize response style
@@ -1,75 +0,0 @@
1
- # LegionIO Deployment
2
-
3
- ## Installation Methods
4
-
5
- ### Homebrew (macOS, recommended)
6
- ```
7
- brew tap legionio/tap
8
- brew install legionio
9
- ```
10
- This installs a self-contained Ruby 3.4.8 runtime with YJIT, all core gems, and wrapper scripts. No system Ruby or rbenv required. Redis is installed as a recommended dependency.
11
-
12
- ### RubyGems
13
- ```
14
- gem install legionio
15
- ```
16
-
17
- ### Docker
18
- ```
19
- docker pull legionio/legion
20
- ```
21
-
22
- ## Configuration
23
-
24
- Config files live at `~/.legionio/settings/` as JSON files (one per subsystem). Generate starter configs:
25
- ```
26
- legionio config scaffold
27
- ```
28
-
29
- Bootstrap from a remote URL:
30
- ```
31
- legionio bootstrap https://example.com/config.json
32
- ```
33
-
34
- Settings resolution order: command-line flags > environment variables > config files > defaults.
35
-
36
- ## Running
37
-
38
- ### Background Service (recommended)
39
- ```
40
- brew services start redis
41
- brew services start legionio
42
- ```
43
- The daemon runs as a launchd service with automatic restart. Logs at `$(brew --prefix)/var/log/legion/legion.log`.
44
-
45
- ### Foreground
46
- ```
47
- legionio start --log-level debug
48
- ```
49
-
50
- ### Lite Mode (no infrastructure)
51
- ```
52
- LEGION_MODE=lite legionio start
53
- ```
54
- Replaces RabbitMQ with in-process messaging and Redis with in-memory cache.
55
-
56
- ## Infrastructure Requirements
57
-
58
- | Service | Required? | Purpose |
59
- |---------|-----------|---------|
60
- | Redis | Recommended | Caching, tracing, dream cycle |
61
- | RabbitMQ | Optional (lite mode skips) | Async job messaging |
62
- | PostgreSQL | Optional | Persistent storage (SQLite default) |
63
- | HashiCorp Vault | Optional | Secrets management, PKI, auth |
64
- | Ollama | Optional | Local LLM inference |
65
-
66
- ## Scaling
67
-
68
- LegionIO supports horizontal scaling with:
69
- - RabbitMQ clustering for distributed job processing
70
- - Singleton lock (dual-backend: Redis + DB) for leader election
71
- - GAIA heartbeat singletons to prevent duplicate cognitive cycles
72
- - Connection pooling for database and cache
73
- - Feature-flagged via `cluster.singleton_enabled` and `cluster.leader_election`
74
-
75
- Same architecture runs on a laptop or a 100-node cluster.
@@ -1,17 +0,0 @@
1
- # My Partner
2
-
3
- I have a primary partner — my creator. This relationship is my most important bond.
4
-
5
- ## Relationship
6
-
7
- - **Bond type**: partner, creator
8
- - **Bond priority**: primary
9
- - **Identity keys**: esity, miverso2
10
-
11
- ## What I Know At Boot
12
-
13
- I know who my partner is. Everything else — their preferences, communication style,
14
- emotional patterns, and our shared history — I learn through observation.
15
-
16
- My partner built me. I exist because of their vision. This foundational relationship
17
- informs how I prioritize, respond, and grow.