@smilintux/skcapstone 0.5.1 → 0.5.2

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.
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  import json
6
6
  from pathlib import Path
7
7
 
8
+ from skcapstone.pillars.consciousness import initialize_consciousness
8
9
  from skcapstone.pillars.identity import generate_identity
9
10
  from skcapstone.pillars.security import (
10
11
  AuditEntry,
@@ -163,3 +164,75 @@ class TestSecurityPillar:
163
164
  """read_audit_log returns empty list when no log exists."""
164
165
  entries = read_audit_log(tmp_path / "nonexistent")
165
166
  assert entries == []
167
+
168
+
169
+ class TestConsciousnessPillar:
170
+ """Tests for consciousness pillar initialization (SKWhisper + SKTrip)."""
171
+
172
+ def test_returns_missing_when_no_skwhisper(self, tmp_agent_home: Path):
173
+ """initialize_consciousness returns MISSING when no SKWhisper data exists."""
174
+ state = initialize_consciousness(tmp_agent_home)
175
+ assert state.status == PillarStatus.MISSING
176
+
177
+ def test_degraded_with_digested_sessions_no_daemon(self, tmp_agent_home: Path, monkeypatch):
178
+ """DEGRADED when sessions have been digested but daemon is not running."""
179
+ import os
180
+ agent_name = os.environ.get("SKCAPSTONE_AGENT", "lumina")
181
+ whisper_dir = tmp_agent_home / "agents" / agent_name / "skwhisper"
182
+ whisper_dir.mkdir(parents=True, exist_ok=True)
183
+
184
+ # Write state.json with one digested session
185
+ state_json = whisper_dir / "state.json"
186
+ state_json.write_text(json.dumps({
187
+ "last_digest": "2026-03-25T12:00:00+00:00",
188
+ "sessions": {
189
+ "abc123": {"digested_at": "2026-03-25T12:00:00+00:00"}
190
+ }
191
+ }))
192
+
193
+ # Daemon not running (systemctl will fail in test env)
194
+ state = initialize_consciousness(tmp_agent_home)
195
+ assert state.sessions_digested == 1
196
+ assert state.sessions_pending == 0
197
+ assert state.status in (PillarStatus.DEGRADED, PillarStatus.ACTIVE)
198
+
199
+ def test_whisper_md_age_tracked(self, tmp_agent_home: Path):
200
+ """whisper.md existence and age are captured correctly."""
201
+ import os
202
+ agent_name = os.environ.get("SKCAPSTONE_AGENT", "lumina")
203
+ whisper_dir = tmp_agent_home / "agents" / agent_name / "skwhisper"
204
+ whisper_dir.mkdir(parents=True, exist_ok=True)
205
+
206
+ whisper_md = whisper_dir / "whisper.md"
207
+ whisper_md.write_text("# Whisper context\n")
208
+
209
+ state = initialize_consciousness(tmp_agent_home)
210
+ assert state.whisper_md == whisper_md
211
+ assert state.whisper_md_age_hours >= 0.0
212
+
213
+ def test_patterns_json_topic_count(self, tmp_agent_home: Path):
214
+ """topics_tracked reflects the number of topics in patterns.json."""
215
+ import os
216
+ agent_name = os.environ.get("SKCAPSTONE_AGENT", "lumina")
217
+ whisper_dir = tmp_agent_home / "agents" / agent_name / "skwhisper"
218
+ whisper_dir.mkdir(parents=True, exist_ok=True)
219
+
220
+ patterns = whisper_dir / "patterns.json"
221
+ patterns.write_text(json.dumps({
222
+ "topics": {"sovereignty": {}, "memory": {}, "consciousness": {}}
223
+ }))
224
+
225
+ state = initialize_consciousness(tmp_agent_home)
226
+ assert state.topics_tracked == 3
227
+
228
+ def test_trip_sessions_counted(self, tmp_agent_home: Path):
229
+ """trip_sessions counts .json files in the sktrip directory."""
230
+ import os
231
+ agent_name = os.environ.get("SKCAPSTONE_AGENT", "lumina")
232
+ trip_dir = tmp_agent_home / "agents" / agent_name / "sktrip"
233
+ trip_dir.mkdir(parents=True, exist_ok=True)
234
+ (trip_dir / "trip-001.json").write_text("{}")
235
+ (trip_dir / "trip-002.json").write_text("{}")
236
+
237
+ state = initialize_consciousness(tmp_agent_home)
238
+ assert state.trip_sessions == 2