lex-cognitive-boundary 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8531830d314da99e92950ba57165b26f405e5a75950038f9a0e1310e198662bd
4
+ data.tar.gz: 947a41d2f19e39bcafc4d6d507aca0846b7f96181f610555645d7788ba9902c6
5
+ SHA512:
6
+ metadata.gz: 2f6d4d6f43054595474ab937a65cd57e3b5a1c0db51e348d18578e6b546cc67695ba785bf5e8f794aba15c280c6efcf32bef0b702833f9c3f327443d1ccacbce
7
+ data.tar.gz: ab00e7a0af21c262dab7ce413ffdcbc7fadd41805ed080d068a631355825358fd34d9c370bac84c56e5830a3ca7c30bb6df83741d37848189013d37fccf6e2bf
@@ -0,0 +1,16 @@
1
+ name: CI
2
+ on:
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+
7
+ jobs:
8
+ ci:
9
+ uses: LegionIO/.github/.github/workflows/ci.yml@main
10
+
11
+ release:
12
+ needs: ci
13
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14
+ uses: LegionIO/.github/.github/workflows/release.yml@main
15
+ secrets:
16
+ rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }}
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .rspec_status
2
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --order random
data/.rubocop.yml ADDED
@@ -0,0 +1,40 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.4
4
+
5
+ Style/Documentation:
6
+ Enabled: false
7
+
8
+ Naming/PredicateMethod:
9
+ Enabled: false
10
+
11
+ Metrics/ClassLength:
12
+ Max: 150
13
+
14
+ Metrics/MethodLength:
15
+ Max: 25
16
+
17
+ Metrics/AbcSize:
18
+ Max: 25
19
+
20
+ Metrics/ParameterLists:
21
+ Max: 8
22
+ MaxOptionalParameters: 8
23
+
24
+ Layout/HashAlignment:
25
+ EnforcedColonStyle: table
26
+ EnforcedHashRocketStyle: table
27
+
28
+ Metrics/BlockLength:
29
+ Exclude:
30
+ - 'spec/**/*'
31
+
32
+ Style/FrozenStringLiteralComment:
33
+ Enabled: true
34
+
35
+ Style/StringLiterals:
36
+ EnforcedStyle: single_quotes
37
+
38
+ Style/OneClassPerFile:
39
+ Exclude:
40
+ - 'spec/spec_helper.rb'
data/CLAUDE.md ADDED
@@ -0,0 +1,77 @@
1
+ # lex-cognitive-boundary
2
+
3
+ **Level 3 Documentation**
4
+ - **Parent**: `/Users/miverso2/rubymine/legion/extensions-agentic/CLAUDE.md`
5
+ - **Grandparent**: `/Users/miverso2/rubymine/legion/CLAUDE.md`
6
+
7
+ ## Purpose
8
+
9
+ Models permeable cognitive boundaries with integrity tracking and breach detection. Boundaries represent the membranes between cognitive domains (cognitive, emotional, social, informational, temporal, authority, privacy). Each boundary has a permeability score and integrity score; violations degrade both.
10
+
11
+ ## Gem Info
12
+
13
+ - **Gem name**: `lex-cognitive-boundary`
14
+ - **Version**: `0.1.0`
15
+ - **Module**: `Legion::Extensions::CognitiveBoundary`
16
+ - **Ruby**: `>= 3.4`
17
+ - **License**: MIT
18
+
19
+ ## File Structure
20
+
21
+ ```
22
+ lib/legion/extensions/cognitive_boundary/
23
+ cognitive_boundary.rb
24
+ version.rb
25
+ client.rb
26
+ helpers/
27
+ constants.rb
28
+ boundary.rb
29
+ boundary_engine.rb
30
+ runners/
31
+ cognitive_boundary.rb
32
+ ```
33
+
34
+ ## Key Constants
35
+
36
+ From `helpers/constants.rb`:
37
+
38
+ - `BOUNDARY_TYPES` — `%i[cognitive emotional social informational temporal authority privacy]`
39
+ - `MAX_BOUNDARIES` = `100`, `MAX_VIOLATIONS` = `500`
40
+ - `DEFAULT_PERMEABILITY` = `0.5`, `PERMEABILITY_BOOST` = `0.05`, `PERMEABILITY_DECAY` = `0.03`
41
+ - `BREACH_THRESHOLD` = `0.8` (permeability >= this = breached boundary)
42
+ - `PERMEABILITY_LABELS` — `0.8+` = `:open`, `0.6` = `:permeable`, `0.4` = `:selective`, `0.2` = `:guarded`, below = `:sealed`
43
+ - `INTEGRITY_LABELS` — `0.8+` = `:intact`, `0.6` = `:stable`, `0.4` = `:stressed`, `0.2` = `:compromised`, below = `:breached`
44
+
45
+ ## Runners
46
+
47
+ All methods in `Runners::CognitiveBoundary`:
48
+
49
+ - `create_boundary(name:, boundary_type: :cognitive, permeability: DEFAULT_PERMEABILITY)` — creates a new named boundary
50
+ - `open_boundary(boundary_id:, amount: PERMEABILITY_BOOST)` — increases permeability
51
+ - `close_boundary(boundary_id:, amount: PERMEABILITY_BOOST)` — decreases permeability
52
+ - `violate_boundary(boundary_id:)` — records a violation; degrades integrity
53
+ - `repair_boundary(boundary_id:)` — recovers integrity
54
+ - `seal_boundary(boundary_id:)` — sets permeability to minimum (sealed state)
55
+ - `breached_boundaries` — returns all boundaries where permeability >= `BREACH_THRESHOLD`
56
+ - `boundaries_by_type(boundary_type:)` — filters by type
57
+ - `overall_integrity` — average integrity across all boundaries
58
+ - `overall_permeability` — average permeability across all boundaries
59
+ - `boundary_report` — full report with all boundaries and aggregate metrics
60
+
61
+ ## Helpers
62
+
63
+ - `BoundaryEngine` — manages boundaries and violation log. `overall_integrity` and `overall_permeability` are arithmetic means.
64
+ - `Boundary` — named boundary with `permeability`, `integrity`, `boundary_type`, `violation_count`. Methods: `open!`, `close!`, `violate!`, `repair!`, `seal!`, `breached?`.
65
+
66
+ ## Integration Points
67
+
68
+ - `lex-privatecore` enforces privacy boundaries; this extension models them as permeable objects with integrity degradation, enabling upstream callers to monitor boundary health.
69
+ - `lex-consent` manages authority and autonomy boundaries — the consent tier maps naturally to boundary permeability (higher consent = more open boundary).
70
+ - `lex-tick` can check `breached_boundaries` in safety phases to detect when cognitive or emotional boundaries have been overwhelmed.
71
+
72
+ ## Development Notes
73
+
74
+ - `Boundary` names are stored as-is (not coerced to symbols). Callers should use consistent naming conventions.
75
+ - `violate_boundary` decrements integrity; `repair_boundary` recovers it. Neither crosses zero (clamped).
76
+ - `BREACH_THRESHOLD = 0.8` for permeability, not integrity — a boundary is breached when it is too open, not when integrity is too low. These are separate dimensions.
77
+ - `MAX_VIOLATIONS = 500` is a history cap on the violation log, not a per-boundary limit.
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'rspec', '~> 3.13'
9
+ gem 'rubocop', '~> 1.75'
10
+ gem 'rubocop-rspec'
11
+ end
12
+
13
+ gem 'legion-gaia', path: '../../legion-gaia'
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lex-cognitive-boundary (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.8.9)
10
+ public_suffix (>= 2.0.2, < 8.0)
11
+ ast (2.4.3)
12
+ bigdecimal (4.0.1)
13
+ diff-lcs (1.6.2)
14
+ json (2.19.1)
15
+ json-schema (6.2.0)
16
+ addressable (~> 2.8)
17
+ bigdecimal (>= 3.1, < 5)
18
+ language_server-protocol (3.17.0.5)
19
+ lint_roller (1.1.0)
20
+ mcp (0.8.0)
21
+ json-schema (>= 4.1)
22
+ parallel (1.27.0)
23
+ parser (3.3.10.2)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ prism (1.9.0)
27
+ public_suffix (7.0.5)
28
+ racc (1.8.1)
29
+ rainbow (3.1.1)
30
+ regexp_parser (2.11.3)
31
+ rspec (3.13.2)
32
+ rspec-core (~> 3.13.0)
33
+ rspec-expectations (~> 3.13.0)
34
+ rspec-mocks (~> 3.13.0)
35
+ rspec-core (3.13.6)
36
+ rspec-support (~> 3.13.0)
37
+ rspec-expectations (3.13.5)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.13.0)
40
+ rspec-mocks (3.13.8)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.13.0)
43
+ rspec-support (3.13.7)
44
+ rubocop (1.85.1)
45
+ json (~> 2.3)
46
+ language_server-protocol (~> 3.17.0.2)
47
+ lint_roller (~> 1.1.0)
48
+ mcp (~> 0.6)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.3.0.2)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 2.9.3, < 3.0)
53
+ rubocop-ast (>= 1.49.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 2.4.0, < 4.0)
56
+ rubocop-ast (1.49.1)
57
+ parser (>= 3.3.7.2)
58
+ prism (~> 1.7)
59
+ rubocop-rspec (3.9.0)
60
+ lint_roller (~> 1.1)
61
+ rubocop (~> 1.81)
62
+ ruby-progressbar (1.13.0)
63
+ unicode-display_width (3.2.0)
64
+ unicode-emoji (~> 4.1)
65
+ unicode-emoji (4.2.0)
66
+
67
+ PLATFORMS
68
+ arm64-darwin-25
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ lex-cognitive-boundary!
73
+ rspec (~> 3.13)
74
+ rubocop (~> 1.75)
75
+ rubocop-rspec
76
+
77
+ BUNDLED WITH
78
+ 2.6.9
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # lex-cognitive-boundary
2
+
3
+ Cognitive boundary enforcement for LegionIO. Models permeable cognitive boundaries with integrity tracking and breach detection.
4
+
5
+ ## What It Does
6
+
7
+ Cognitive boundaries are the membranes between domains of thought, feeling, and authority. This extension gives each boundary a permeability score (how open it is to external influence) and an integrity score (how intact the membrane is). Violations degrade integrity; deliberate repair restores it. Breached boundaries (too open) are flagged for attention.
8
+
9
+ Boundary types include cognitive, emotional, social, informational, temporal, authority, and privacy — mapping to the real boundaries an agent must maintain between its own processing and external influence.
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ client = Legion::Extensions::CognitiveBoundary::Client.new
15
+
16
+ boundary = client.create_boundary(
17
+ name: 'emotional_regulation',
18
+ boundary_type: :emotional,
19
+ permeability: 0.4
20
+ )
21
+
22
+ client.violate_boundary(boundary_id: boundary[:boundary][:id])
23
+ client.repair_boundary(boundary_id: boundary[:boundary][:id])
24
+
25
+ client.breached_boundaries
26
+ client.boundary_report
27
+ ```
28
+
29
+ ## Development
30
+
31
+ ```bash
32
+ bundle install
33
+ bundle exec rspec
34
+ bundle exec rubocop
35
+ ```
36
+
37
+ ## License
38
+
39
+ MIT
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/legion/extensions/cognitive_boundary/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'lex-cognitive-boundary'
7
+ spec.version = Legion::Extensions::CognitiveBoundary::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'Cognitive boundary enforcement for LegionIO'
12
+ spec.description = 'Models permeable cognitive boundaries with integrity tracking and breach detection'
13
+ spec.homepage = 'https://github.com/LegionIO/lex-cognitive-boundary'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.4'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = spec.homepage
19
+ spec.metadata['documentation_uri'] = "#{spec.homepage}/blob/main/README.md"
20
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/main/CHANGELOG.md"
21
+ spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
+
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{\A(?:test|spec|features)/})
27
+ end
28
+ end
29
+ spec.require_paths = ['lib']
30
+ spec.add_development_dependency 'legion-gaia'
31
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveBoundary
6
+ class Client
7
+ include Runners::CognitiveBoundary
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ module Legion
6
+ module Extensions
7
+ module CognitiveBoundary
8
+ module Helpers
9
+ class Boundary
10
+ include Constants
11
+
12
+ attr_reader :id, :name, :boundary_type, :permeability, :violations,
13
+ :created_at
14
+
15
+ def initialize(name:, boundary_type: :cognitive, permeability: DEFAULT_PERMEABILITY)
16
+ @id = SecureRandom.uuid
17
+ @name = name
18
+ @boundary_type = boundary_type.to_sym
19
+ @permeability = permeability.to_f.clamp(0.0, 1.0)
20
+ @violations = 0
21
+ @created_at = Time.now.utc
22
+ end
23
+
24
+ def integrity
25
+ base = 1.0 - (@violations * 0.05)
26
+ [base, 0.0].max.round(10)
27
+ end
28
+
29
+ def integrity_label
30
+ match = INTEGRITY_LABELS.find { |range, _| range.cover?(integrity) }
31
+ match ? match.last : :breached
32
+ end
33
+
34
+ def permeability_label
35
+ match = PERMEABILITY_LABELS.find { |range, _| range.cover?(@permeability) }
36
+ match ? match.last : :sealed
37
+ end
38
+
39
+ def breached?
40
+ @permeability >= BREACH_THRESHOLD || integrity < 0.2
41
+ end
42
+
43
+ def open!(amount: PERMEABILITY_BOOST)
44
+ @permeability = (@permeability + amount).clamp(0.0, 1.0).round(10)
45
+ self
46
+ end
47
+
48
+ def close!(amount: PERMEABILITY_BOOST)
49
+ @permeability = (@permeability - amount).clamp(0.0, 1.0).round(10)
50
+ self
51
+ end
52
+
53
+ def violate!
54
+ @violations += 1
55
+ self
56
+ end
57
+
58
+ def repair!
59
+ @violations = [(@violations - 1), 0].max
60
+ self
61
+ end
62
+
63
+ def seal!
64
+ @permeability = 0.0
65
+ self
66
+ end
67
+
68
+ def to_h
69
+ {
70
+ id: @id,
71
+ name: @name,
72
+ boundary_type: @boundary_type,
73
+ permeability: @permeability,
74
+ permeability_label: permeability_label,
75
+ integrity: integrity,
76
+ integrity_label: integrity_label,
77
+ breached: breached?,
78
+ violations: @violations,
79
+ created_at: @created_at
80
+ }
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveBoundary
6
+ module Helpers
7
+ class BoundaryEngine
8
+ include Constants
9
+
10
+ def initialize
11
+ @boundaries = {}
12
+ end
13
+
14
+ def create_boundary(name:, boundary_type: :cognitive,
15
+ permeability: DEFAULT_PERMEABILITY)
16
+ prune_if_needed
17
+ boundary = Boundary.new(
18
+ name: name,
19
+ boundary_type: boundary_type,
20
+ permeability: permeability
21
+ )
22
+ @boundaries[boundary.id] = boundary
23
+ boundary
24
+ end
25
+
26
+ def open_boundary(boundary_id:, amount: PERMEABILITY_BOOST)
27
+ boundary = @boundaries[boundary_id]
28
+ return nil unless boundary
29
+
30
+ boundary.open!(amount: amount)
31
+ end
32
+
33
+ def close_boundary(boundary_id:, amount: PERMEABILITY_BOOST)
34
+ boundary = @boundaries[boundary_id]
35
+ return nil unless boundary
36
+
37
+ boundary.close!(amount: amount)
38
+ end
39
+
40
+ def violate_boundary(boundary_id:)
41
+ boundary = @boundaries[boundary_id]
42
+ return nil unless boundary
43
+
44
+ boundary.violate!
45
+ end
46
+
47
+ def repair_boundary(boundary_id:)
48
+ boundary = @boundaries[boundary_id]
49
+ return nil unless boundary
50
+
51
+ boundary.repair!
52
+ end
53
+
54
+ def seal_boundary(boundary_id:)
55
+ boundary = @boundaries[boundary_id]
56
+ return nil unless boundary
57
+
58
+ boundary.seal!
59
+ end
60
+
61
+ def breached_boundaries
62
+ @boundaries.values.select(&:breached?)
63
+ end
64
+
65
+ def boundaries_by_type(boundary_type:)
66
+ bt = boundary_type.to_sym
67
+ @boundaries.values.select { |b| b.boundary_type == bt }
68
+ end
69
+
70
+ def most_violated(limit: 5)
71
+ @boundaries.values.sort_by { |b| -b.violations }.first(limit)
72
+ end
73
+
74
+ def overall_integrity
75
+ return 1.0 if @boundaries.empty?
76
+
77
+ scores = @boundaries.values.map(&:integrity)
78
+ (scores.sum / scores.size).round(10)
79
+ end
80
+
81
+ def overall_permeability
82
+ return 0.5 if @boundaries.empty?
83
+
84
+ perms = @boundaries.values.map(&:permeability)
85
+ (perms.sum / perms.size).round(10)
86
+ end
87
+
88
+ def boundary_report
89
+ {
90
+ total_boundaries: @boundaries.size,
91
+ breached_count: breached_boundaries.size,
92
+ overall_integrity: overall_integrity,
93
+ overall_permeability: overall_permeability,
94
+ most_violated: most_violated(limit: 3).map(&:to_h)
95
+ }
96
+ end
97
+
98
+ def to_h
99
+ {
100
+ total_boundaries: @boundaries.size,
101
+ breached_count: breached_boundaries.size,
102
+ overall_integrity: overall_integrity,
103
+ overall_permeability: overall_permeability
104
+ }
105
+ end
106
+
107
+ private
108
+
109
+ def prune_if_needed
110
+ return if @boundaries.size < MAX_BOUNDARIES
111
+
112
+ least_violated = @boundaries.values.min_by(&:violations)
113
+ @boundaries.delete(least_violated.id) if least_violated
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveBoundary
6
+ module Helpers
7
+ module Constants
8
+ MAX_BOUNDARIES = 100
9
+ MAX_VIOLATIONS = 500
10
+
11
+ DEFAULT_PERMEABILITY = 0.5
12
+ PERMEABILITY_BOOST = 0.05
13
+ PERMEABILITY_DECAY = 0.03
14
+ BREACH_THRESHOLD = 0.8
15
+
16
+ PERMEABILITY_LABELS = {
17
+ (0.8..) => :open,
18
+ (0.6...0.8) => :permeable,
19
+ (0.4...0.6) => :selective,
20
+ (0.2...0.4) => :guarded,
21
+ (..0.2) => :sealed
22
+ }.freeze
23
+
24
+ INTEGRITY_LABELS = {
25
+ (0.8..) => :intact,
26
+ (0.6...0.8) => :stable,
27
+ (0.4...0.6) => :stressed,
28
+ (0.2...0.4) => :compromised,
29
+ (..0.2) => :breached
30
+ }.freeze
31
+
32
+ BOUNDARY_TYPES = %i[
33
+ cognitive emotional social informational
34
+ temporal authority privacy
35
+ ].freeze
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveBoundary
6
+ module Runners
7
+ module CognitiveBoundary
8
+ include Helpers::Constants
9
+
10
+ include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
11
+
12
+ def create_boundary(name:, engine: nil, boundary_type: :cognitive,
13
+ permeability: DEFAULT_PERMEABILITY, **)
14
+ eng = engine || default_engine
15
+ boundary = eng.create_boundary(name: name, boundary_type: boundary_type,
16
+ permeability: permeability)
17
+ { success: true, boundary: boundary.to_h }
18
+ end
19
+
20
+ def open_boundary(boundary_id:, engine: nil, amount: PERMEABILITY_BOOST, **)
21
+ eng = engine || default_engine
22
+ result = eng.open_boundary(boundary_id: boundary_id, amount: amount)
23
+ return { success: false, error: 'boundary not found' } unless result
24
+
25
+ { success: true, boundary: result.to_h }
26
+ end
27
+
28
+ def close_boundary(boundary_id:, engine: nil, amount: PERMEABILITY_BOOST, **)
29
+ eng = engine || default_engine
30
+ result = eng.close_boundary(boundary_id: boundary_id, amount: amount)
31
+ return { success: false, error: 'boundary not found' } unless result
32
+
33
+ { success: true, boundary: result.to_h }
34
+ end
35
+
36
+ def violate_boundary(boundary_id:, engine: nil, **)
37
+ eng = engine || default_engine
38
+ result = eng.violate_boundary(boundary_id: boundary_id)
39
+ return { success: false, error: 'boundary not found' } unless result
40
+
41
+ { success: true, boundary: result.to_h }
42
+ end
43
+
44
+ def repair_boundary(boundary_id:, engine: nil, **)
45
+ eng = engine || default_engine
46
+ result = eng.repair_boundary(boundary_id: boundary_id)
47
+ return { success: false, error: 'boundary not found' } unless result
48
+
49
+ { success: true, boundary: result.to_h }
50
+ end
51
+
52
+ def seal_boundary(boundary_id:, engine: nil, **)
53
+ eng = engine || default_engine
54
+ result = eng.seal_boundary(boundary_id: boundary_id)
55
+ return { success: false, error: 'boundary not found' } unless result
56
+
57
+ { success: true, boundary: result.to_h }
58
+ end
59
+
60
+ def breached_boundaries(engine: nil, **)
61
+ eng = engine || default_engine
62
+ breached = eng.breached_boundaries.map(&:to_h)
63
+ { success: true, breached: breached, count: breached.size }
64
+ end
65
+
66
+ def boundaries_by_type(boundary_type:, engine: nil, **)
67
+ eng = engine || default_engine
68
+ boundaries = eng.boundaries_by_type(boundary_type: boundary_type).map(&:to_h)
69
+ { success: true, boundaries: boundaries, count: boundaries.size }
70
+ end
71
+
72
+ def overall_integrity(engine: nil, **)
73
+ eng = engine || default_engine
74
+ { success: true, integrity: eng.overall_integrity }
75
+ end
76
+
77
+ def overall_permeability(engine: nil, **)
78
+ eng = engine || default_engine
79
+ { success: true, permeability: eng.overall_permeability }
80
+ end
81
+
82
+ def boundary_report(engine: nil, **)
83
+ eng = engine || default_engine
84
+ { success: true, report: eng.boundary_report }
85
+ end
86
+
87
+ private
88
+
89
+ def default_engine
90
+ @default_engine ||= Helpers::BoundaryEngine.new
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Legion
4
+ module Extensions
5
+ module CognitiveBoundary
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'cognitive_boundary/version'
4
+ require_relative 'cognitive_boundary/helpers/constants'
5
+ require_relative 'cognitive_boundary/helpers/boundary'
6
+ require_relative 'cognitive_boundary/helpers/boundary_engine'
7
+ require_relative 'cognitive_boundary/runners/cognitive_boundary'
8
+ require_relative 'cognitive_boundary/client'
9
+
10
+ module Legion
11
+ module Extensions
12
+ module CognitiveBoundary
13
+ end
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lex-cognitive-boundary
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Esity
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: legion-gaia
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ description: Models permeable cognitive boundaries with integrity tracking and breach
27
+ detection
28
+ email:
29
+ - matthewdiverson@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/workflows/ci.yml"
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - CLAUDE.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - README.md
42
+ - lex-cognitive-boundary.gemspec
43
+ - lib/legion/extensions/cognitive_boundary.rb
44
+ - lib/legion/extensions/cognitive_boundary/client.rb
45
+ - lib/legion/extensions/cognitive_boundary/helpers/boundary.rb
46
+ - lib/legion/extensions/cognitive_boundary/helpers/boundary_engine.rb
47
+ - lib/legion/extensions/cognitive_boundary/helpers/constants.rb
48
+ - lib/legion/extensions/cognitive_boundary/runners/cognitive_boundary.rb
49
+ - lib/legion/extensions/cognitive_boundary/version.rb
50
+ homepage: https://github.com/LegionIO/lex-cognitive-boundary
51
+ licenses:
52
+ - MIT
53
+ metadata:
54
+ homepage_uri: https://github.com/LegionIO/lex-cognitive-boundary
55
+ source_code_uri: https://github.com/LegionIO/lex-cognitive-boundary
56
+ documentation_uri: https://github.com/LegionIO/lex-cognitive-boundary/blob/main/README.md
57
+ changelog_uri: https://github.com/LegionIO/lex-cognitive-boundary/blob/main/CHANGELOG.md
58
+ bug_tracker_uri: https://github.com/LegionIO/lex-cognitive-boundary/issues
59
+ rubygems_mfa_required: 'true'
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '3.4'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.6.9
75
+ specification_version: 4
76
+ summary: Cognitive boundary enforcement for LegionIO
77
+ test_files: []