legion-apollo 0.3.5 → 0.3.6

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: 1b3c0668c2af6ecd24eec20affa9da56b2418d4c37ffde60529f15072712213e
4
- data.tar.gz: faac4c926f2db4c77533ed589042020e521686866334b4cb0fadf6fc9f69f71f
3
+ metadata.gz: 618bc61aef669f5084bf63093f5ad71705adc70981cc267c66c17e47ca4f5a95
4
+ data.tar.gz: 3170ead8864d7ca3ec97788d07e3e672eaf37c093ea70447516fe91f99a39c09
5
5
  SHA512:
6
- metadata.gz: efe1e40e94d96b16dfe997386fd4f55c2e62bb994e9bd701c0466ce630470d9f0c723d141ec52565f151d0a869c7c47beae074a5f60b4b05d57fe2fcae261ad4
7
- data.tar.gz: a5e2d49ec89a148cfec6678fc3099839f82095904eb84e2c828aeb1dfdc424fd8dee236d23434c5e3a4ef407c7ebf49350705410e82f6f873c70e4c19dd2dec2
6
+ metadata.gz: c819ce92195d179a520115219f650ddf43638905bcf0d522b74a87e09acfce7537a7c3a9f407f265a5f867486f3cac708c25ed989ed0ca28a1c6d26b5ea23746
7
+ data.tar.gz: c27a2fbd299e4af232625efccaeb75b7bb2e54c925975df507e72d9e7d941383a3de9d87672ec3c5cc3816445a2c2f48e0c55c3a569126c47a4c04252fb677ed
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.6] - 2026-03-31
4
+
5
+ ### Added
6
+ - `Apollo::Local#upsert` — tag-based update-or-insert for tracker persistence; sorts tags for deterministic matching, rebuilds FTS5 on update
7
+ - Partner seed file (`data/self-knowledge/11-my-partner.md`) — declares bond type and identity keys for GAIA self-knowledge
8
+
3
9
  ## [0.3.5] - 2026-03-28
4
10
 
5
11
  ### Fixed
@@ -0,0 +1,17 @@
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.
@@ -64,6 +64,25 @@ module Legion
64
64
  { success: false, error: e.message }
65
65
  end
66
66
 
67
+ def upsert(content:, tags: [], **opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
68
+ return not_started_error unless started?
69
+
70
+ sorted_tags = Array(tags).map(&:to_s).sort
71
+ tag_json = Legion::JSON.dump(sorted_tags)
72
+ existing = db[:local_knowledge].where(tags: tag_json).first
73
+
74
+ if existing
75
+ update_upsert_entry(existing, content, tag_json, opts)
76
+ else
77
+ result = ingest(content: content, tags: sorted_tags, **opts)
78
+ result[:mode] = :inserted if result[:success] && result[:mode] != :deduplicated
79
+ result
80
+ end
81
+ rescue StandardError => e
82
+ Legion::Logging.warn "Apollo::Local upsert error: #{e.message}" if defined?(Legion::Logging)
83
+ { success: false, error: e.message }
84
+ end
85
+
67
86
  def query(text:, limit: nil, min_confidence: nil, tags: nil, **) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
68
87
  return not_started_error unless started?
69
88
 
@@ -300,6 +319,30 @@ module Legion
300
319
  default
301
320
  end
302
321
 
322
+ def update_upsert_entry(existing, content, tags_json, opts) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
323
+ new_hash = content_hash(content)
324
+ now = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%LZ')
325
+
326
+ db[:local_knowledge].where(id: existing[:id]).update(
327
+ content: content.to_s,
328
+ content_hash: new_hash,
329
+ confidence: opts.fetch(:confidence, existing[:confidence]),
330
+ source_channel: opts.fetch(:source_channel, existing[:source_channel]),
331
+ source_agent: opts.fetch(:source_agent, existing[:source_agent]),
332
+ submitted_by: opts.fetch(:submitted_by, existing[:submitted_by]),
333
+ updated_at: now
334
+ )
335
+ rebuild_fts_entry(existing[:id], content.to_s, tags_json)
336
+ { success: true, mode: :updated, id: existing[:id] }
337
+ end
338
+
339
+ def rebuild_fts_entry(id, content, tags_json)
340
+ db.run("DELETE FROM local_knowledge_fts WHERE rowid = #{id}")
341
+ sync_fts(id, content, tags_json)
342
+ rescue StandardError
343
+ nil
344
+ end
345
+
303
346
  def not_started_error
304
347
  { success: false, error: :not_started }
305
348
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Legion
4
4
  module Apollo
5
- VERSION = '0.3.5'
5
+ VERSION = '0.3.6'
6
6
  end
7
7
  end
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.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esity
@@ -76,6 +76,7 @@ files:
76
76
  - data/self-knowledge/08-cognitive-layer.md
77
77
  - data/self-knowledge/09-teams-integration.md
78
78
  - data/self-knowledge/10-deployment.md
79
+ - data/self-knowledge/11-my-partner.md
79
80
  - lib/legion/apollo.rb
80
81
  - lib/legion/apollo/helpers/confidence.rb
81
82
  - lib/legion/apollo/helpers/similarity.rb