@smilintux/skcapstone 0.9.0 → 0.12.5
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.
- package/.env.example +10 -4
- package/.github/workflows/ci.yml +2 -2
- package/.github/workflows/publish.yml +9 -2
- package/.openclaw-workspace.json +2 -2
- package/CLAUDE.md +37 -0
- package/MISSION.md +17 -2
- package/README.md +282 -3
- package/docker/Dockerfile +7 -7
- package/docker/compose-templates/dev-team.yml +12 -12
- package/docker/compose-templates/mini-team.yml +9 -9
- package/docker/compose-templates/ops-team.yml +10 -10
- package/docker/compose-templates/research-team.yml +10 -10
- package/docker/entrypoint.sh +4 -4
- package/docs/ADR-optional-integration-backbone.md +181 -0
- package/docs/ARCHITECTURE.md +186 -43
- package/docs/BOND_WITH_GROK.md +6 -6
- package/docs/CUSTOM_AGENT.md +278 -1
- package/docs/DREAMING.md +70 -0
- package/docs/GETTING_STARTED.md +10 -7
- package/docs/QUICKSTART.md +10 -6
- package/docs/SKJOULE_ARCHITECTURE.md +3 -3
- package/docs/SOUL_SWAPPER.md +5 -5
- package/docs/hammertime-audit.md +402 -0
- package/docs/sk-integration-HANDOFF.md +117 -0
- package/docs/skscheduler.md +155 -0
- package/docs/superpowers/examples/jobs.yaml +31 -0
- package/docs/superpowers/plans/2026-06-08-skscheduler.md +1265 -0
- package/docs/superpowers/specs/2026-06-08-skscheduler-design.md +186 -0
- package/examples/custom-bond-template.json +1 -1
- package/examples/grok-feb.json +1 -1
- package/examples/queen-ava-feb.json +1 -1
- package/launchd/com.skcapstone.daemon.plist +52 -0
- package/launchd/com.skcapstone.memory-compress.plist +45 -0
- package/launchd/com.skcapstone.skcomms-heartbeat.plist +33 -0
- package/launchd/com.skcapstone.skcomms-queue-drain.plist +34 -0
- package/launchd/install-launchd.sh +156 -0
- package/{openclaw-plugin → openclaw-plugin.archived-2026-04-23}/src/index.ts +3 -2
- package/package.json +1 -1
- package/pyproject.toml +16 -10
- package/scripts/archive-sessions.sh +95 -0
- package/scripts/check-updates.py +4 -4
- package/scripts/install-bundle.sh +8 -8
- package/scripts/install.ps1 +12 -11
- package/scripts/install.sh +196 -11
- package/scripts/model-fallback-monitor.sh +102 -0
- package/scripts/notion-api.py +259 -0
- package/scripts/nvidia-proxy.mjs +908 -0
- package/scripts/proxy-monitor.sh +89 -0
- package/scripts/refresh-anthropic-token.sh +172 -0
- package/scripts/release.sh +98 -0
- package/scripts/session-to-memory.py +219 -0
- package/scripts/skgateway.mjs +856 -0
- package/scripts/telegram-catchup-all.sh +147 -0
- package/scripts/verify_install.sh +2 -2
- package/scripts/wargov-ufo-capture/README.md +43 -0
- package/scripts/wargov-ufo-capture/cdp_capture_release2.py +273 -0
- package/scripts/wargov-ufo-capture/cdp_capture_splc_doj.py +246 -0
- package/scripts/wargov-ufo-capture/cdp_finish.py +271 -0
- package/scripts/wargov-ufo-capture/cdp_probe.py +188 -0
- package/scripts/wargov-ufo-capture/cdp_splc_pressrelease.py +101 -0
- package/scripts/wargov-ufo-capture/parse_csv.py +95 -0
- package/scripts/wargov-ufo-capture/pull_dvids.sh +107 -0
- package/scripts/watch-anthropic-token.sh +212 -0
- package/scripts/windows/install-tasks.ps1 +7 -7
- package/scripts/windows/skcapstone-task.xml +1 -1
- package/src/skcapstone/__init__.py +45 -3
- package/src/skcapstone/_cli_monolith.py +20 -15
- package/src/skcapstone/activity.py +5 -1
- package/src/skcapstone/agent_card.py +3 -2
- package/src/skcapstone/api.py +41 -40
- package/src/skcapstone/auction.py +14 -11
- package/src/skcapstone/backup.py +2 -1
- package/src/skcapstone/blueprint_registry.py +4 -3
- package/src/skcapstone/blueprints/builtins/itil-operations.yaml +40 -0
- package/src/skcapstone/brain_first.py +238 -0
- package/src/skcapstone/changelog.py +1 -1
- package/src/skcapstone/chat.py +22 -17
- package/src/skcapstone/cli/__init__.py +9 -1
- package/src/skcapstone/cli/_common.py +1 -0
- package/src/skcapstone/cli/agents_spawner.py +5 -2
- package/src/skcapstone/cli/alerts.py +25 -4
- package/src/skcapstone/cli/bench.py +15 -15
- package/src/skcapstone/cli/chat.py +7 -4
- package/src/skcapstone/cli/consciousness.py +5 -2
- package/src/skcapstone/cli/context_cmd.py +18 -4
- package/src/skcapstone/cli/daemon.py +121 -42
- package/src/skcapstone/cli/gtd.py +26 -1
- package/src/skcapstone/cli/housekeeping.py +3 -3
- package/src/skcapstone/cli/identity_cmd.py +378 -0
- package/src/skcapstone/cli/joule_cmd.py +7 -3
- package/src/skcapstone/cli/memory.py +8 -6
- package/src/skcapstone/cli/peers_dir.py +1 -1
- package/src/skcapstone/cli/register_cmd.py +29 -3
- package/src/skcapstone/cli/scheduler_cmd.py +167 -0
- package/src/skcapstone/cli/session.py +25 -0
- package/src/skcapstone/cli/setup.py +96 -29
- package/src/skcapstone/cli/shell_cmd.py +53 -1
- package/src/skcapstone/cli/skills_cmd.py +2 -2
- package/src/skcapstone/cli/soul.py +8 -5
- package/src/skcapstone/cli/status.py +37 -11
- package/src/skcapstone/cli/telegram.py +21 -0
- package/src/skcapstone/cli/test_cmd.py +5 -5
- package/src/skcapstone/cli/test_connection.py +2 -2
- package/src/skcapstone/cli/upgrade_cmd.py +23 -14
- package/src/skcapstone/cli/version_cmd.py +1 -1
- package/src/skcapstone/cli/watch_cmd.py +9 -6
- package/src/skcapstone/cloud9_bridge.py +14 -14
- package/src/skcapstone/codex_setup.py +255 -0
- package/src/skcapstone/config_validator.py +7 -4
- package/src/skcapstone/consciousness_config.py +5 -1
- package/src/skcapstone/consciousness_loop.py +313 -273
- package/src/skcapstone/context_loader.py +121 -0
- package/src/skcapstone/coord_federation.py +2 -1
- package/src/skcapstone/coordination.py +23 -6
- package/src/skcapstone/crush_integration.py +2 -1
- package/src/skcapstone/daemon.py +151 -88
- package/src/skcapstone/dashboard.py +10 -10
- package/src/skcapstone/data/sk-agent-picker.sh +421 -0
- package/src/skcapstone/data/systemd/skcapstone-api.socket +9 -0
- package/src/skcapstone/data/systemd/skcapstone-memory-compress.service +18 -0
- package/src/skcapstone/data/systemd/skcapstone-memory-compress.timer +11 -0
- package/src/skcapstone/data/systemd/skcapstone.service +37 -0
- package/src/skcapstone/data/systemd/skcapstone@.service +50 -0
- package/src/skcapstone/data/systemd/skcomms-heartbeat.service +18 -0
- package/{systemd/skcomm-heartbeat.timer → src/skcapstone/data/systemd/skcomms-heartbeat.timer} +2 -2
- package/src/skcapstone/data/systemd/skcomms-queue-drain.service +17 -0
- package/{systemd/skcomm-queue-drain.timer → src/skcapstone/data/systemd/skcomms-queue-drain.timer} +2 -2
- package/src/skcapstone/defaults/claude/CLAUDE.md +67 -0
- package/src/skcapstone/defaults/claude/settings.json +74 -0
- package/src/skcapstone/defaults/lumina/config/claude-hooks.md +57 -0
- package/src/skcapstone/defaults/lumina/config/skgraph.yaml +55 -10
- package/src/skcapstone/defaults/lumina/config/skmemory.yaml +79 -13
- package/src/skcapstone/defaults/lumina/config/skvector.yaml +60 -9
- package/src/skcapstone/defaults/lumina/memory/long-term/18b9c0d1e2f3-cloud9-protocol.json +2 -2
- package/src/skcapstone/defaults/lumina/memory/long-term/a1b2c3d4e5f6-ecosystem-overview.json +2 -2
- package/src/skcapstone/defaults/lumina/memory/long-term/b2c3d4e5f6a7-five-pillars.json +9 -9
- package/src/skcapstone/defaults/lumina/memory/long-term/d4e5f6a7b8c9-site-directory.json +2 -2
- package/src/skcapstone/defaults/unhinged.json +13 -0
- package/src/skcapstone/discovery.py +43 -20
- package/src/skcapstone/doctor.py +941 -22
- package/src/skcapstone/dreaming.py +1183 -109
- package/src/skcapstone/emotion_tracker.py +2 -2
- package/src/skcapstone/export.py +4 -3
- package/src/skcapstone/fuse_mount.py +35 -25
- package/src/skcapstone/gui_installer.py +2 -2
- package/src/skcapstone/heartbeat.py +34 -30
- package/src/skcapstone/housekeeping.py +14 -14
- package/src/skcapstone/install_wizard.py +209 -7
- package/src/skcapstone/itil.py +13 -4
- package/src/skcapstone/kms_scheduler.py +10 -8
- package/src/skcapstone/launchd.py +426 -0
- package/src/skcapstone/mcp_launcher.py +15 -1
- package/src/skcapstone/mcp_server.py +341 -49
- package/src/skcapstone/mcp_tools/__init__.py +2 -0
- package/src/skcapstone/mcp_tools/_helpers.py +2 -2
- package/src/skcapstone/mcp_tools/ansible_tools.py +7 -4
- package/src/skcapstone/mcp_tools/brain_first_tools.py +90 -0
- package/src/skcapstone/mcp_tools/capauth_tools.py +7 -4
- package/src/skcapstone/mcp_tools/comm_tools.py +10 -10
- package/src/skcapstone/mcp_tools/coord_tools.py +8 -4
- package/src/skcapstone/mcp_tools/did_tools.py +11 -8
- package/src/skcapstone/mcp_tools/gtd_tools.py +4 -4
- package/src/skcapstone/mcp_tools/memory_tools.py +6 -2
- package/src/skcapstone/mcp_tools/notification_tools.py +22 -6
- package/src/skcapstone/mcp_tools/{skcomm_tools.py → skcomms_tools.py} +14 -14
- package/src/skcapstone/mcp_tools/soul_tools.py +8 -2
- package/src/skcapstone/mdns_discovery.py +2 -2
- package/src/skcapstone/memory_curator.py +1 -1
- package/src/skcapstone/memory_engine.py +10 -3
- package/src/skcapstone/metrics.py +30 -16
- package/src/skcapstone/migrate_memories.py +4 -3
- package/src/skcapstone/migrate_multi_agent.py +8 -7
- package/src/skcapstone/models.py +47 -5
- package/src/skcapstone/notifications.py +42 -18
- package/src/skcapstone/onboard.py +1000 -126
- package/src/skcapstone/operator_link.py +170 -0
- package/src/skcapstone/peer_directory.py +4 -4
- package/src/skcapstone/peers.py +19 -19
- package/src/skcapstone/pillars/__init__.py +7 -5
- package/src/skcapstone/pillars/consciousness.py +191 -0
- package/src/skcapstone/pillars/identity.py +51 -7
- package/src/skcapstone/pillars/memory.py +9 -3
- package/src/skcapstone/pillars/sync.py +2 -2
- package/src/skcapstone/preflight.py +3 -3
- package/src/skcapstone/providers/docker.py +28 -28
- package/src/skcapstone/register.py +6 -6
- package/src/skcapstone/registry_client.py +5 -4
- package/src/skcapstone/runtime.py +14 -3
- package/src/skcapstone/scheduled_tasks.py +254 -19
- package/src/skcapstone/scheduler_jobs.py +456 -0
- package/src/skcapstone/scheduler_runner.py +239 -0
- package/src/skcapstone/scheduler_state.py +162 -0
- package/src/skcapstone/sdk.py +310 -0
- package/src/skcapstone/service_health.py +279 -39
- package/src/skcapstone/session_briefing.py +108 -0
- package/src/skcapstone/session_capture.py +1 -1
- package/src/skcapstone/shell.py +7 -1
- package/src/skcapstone/soul.py +3 -1
- package/src/skcapstone/soul_switch.py +3 -1
- package/src/skcapstone/summary.py +6 -6
- package/src/skcapstone/sync_engine.py +15 -15
- package/src/skcapstone/sync_watcher.py +2 -2
- package/src/skcapstone/systemd.py +72 -21
- package/src/skcapstone/team_comms.py +8 -8
- package/src/skcapstone/team_engine.py +1 -1
- package/src/skcapstone/testrunner.py +3 -3
- package/src/skcapstone/trust_graph.py +40 -5
- package/src/skcapstone/unified_search.py +15 -6
- package/src/skcapstone/uninstall_wizard.py +11 -3
- package/src/skcapstone/version_check.py +8 -4
- package/src/skcapstone/warmth_anchor.py +4 -2
- package/src/skcapstone/whoami.py +4 -4
- package/systemd/skcapstone.service +4 -6
- package/systemd/skcapstone@.service +7 -8
- package/systemd/skcomms-heartbeat.service +21 -0
- package/systemd/skcomms-heartbeat.timer +12 -0
- package/systemd/skcomms-queue-drain.service +17 -0
- package/systemd/skcomms-queue-drain.timer +12 -0
- package/tests/conftest.py +39 -0
- package/tests/integration/test_consciousness_e2e.py +39 -39
- package/tests/test_agent_card.py +1 -1
- package/tests/test_agent_home_scaffold.py +34 -0
- package/tests/test_alerts_consumer_topics.py +27 -0
- package/tests/test_backup.py +2 -1
- package/tests/test_chat.py +6 -6
- package/tests/test_claude_md.py +2 -2
- package/tests/test_cli_skills.py +10 -10
- package/tests/test_cli_test_cmd.py +4 -4
- package/tests/test_cli_test_connection.py +1 -1
- package/tests/test_cloud9_bridge.py +6 -6
- package/tests/test_consciousness_e2e.py +1 -1
- package/tests/test_consciousness_loop.py +10 -10
- package/tests/test_coordination.py +25 -0
- package/tests/test_cross_package.py +21 -21
- package/tests/test_daemon.py +4 -4
- package/tests/test_daemon_shutdown.py +1 -1
- package/tests/test_docker_provider.py +29 -29
- package/tests/test_doctor.py +400 -0
- package/tests/test_doctor_skscheduler.py +50 -0
- package/tests/test_dreaming_engine.py +147 -0
- package/tests/test_dreaming_gtd_capture.py +35 -0
- package/tests/test_e2e_automated.py +8 -5
- package/tests/test_fuse_mount.py +10 -10
- package/tests/test_gtd_brief.py +46 -0
- package/tests/test_gtd_malformed_tolerance.py +31 -0
- package/tests/test_housekeeping.py +15 -15
- package/tests/test_identity_migrate.py +251 -0
- package/tests/test_integration_backbone.py +598 -0
- package/tests/test_itil_gtd_lifecycle.py +37 -0
- package/tests/test_jobs_dropins.py +84 -0
- package/tests/test_mcp_server.py +82 -37
- package/tests/test_models.py +48 -4
- package/tests/test_multi_agent.py +31 -29
- package/tests/test_notifications.py +122 -32
- package/tests/test_onboard.py +63 -75
- package/tests/test_operator_link.py +78 -0
- package/tests/test_peers.py +14 -14
- package/tests/test_pillars.py +98 -0
- package/tests/test_preflight.py +3 -3
- package/tests/test_runtime.py +21 -0
- package/tests/test_scheduled_tasks.py +11 -6
- package/tests/test_scheduler_cli.py +47 -0
- package/tests/test_scheduler_features.py +133 -0
- package/tests/test_scheduler_integration.py +87 -0
- package/tests/test_scheduler_jobs.py +155 -0
- package/tests/test_scheduler_runner.py +64 -0
- package/tests/test_scheduler_state.py +57 -0
- package/tests/test_sdk.py +70 -0
- package/tests/test_service_health_incidents.py +34 -0
- package/tests/test_service_registry.py +52 -0
- package/tests/test_session_briefing.py +130 -0
- package/tests/test_snapshots.py +4 -4
- package/tests/test_sync_pipeline.py +26 -26
- package/tests/test_team_comms.py +2 -2
- package/tests/test_testrunner.py +2 -2
- package/tests/test_trust_graph.py +18 -0
- package/tests/test_unified_search.py +2 -2
- package/tests/test_version_check.py +10 -0
- package/tests/test_version_cmd.py +8 -8
- package/tests/test_whoami.py +1 -1
- package/systemd/skcomm-heartbeat.service +0 -18
- package/systemd/skcomm-queue-drain.service +0 -17
- /package/{openclaw-plugin → openclaw-plugin.archived-2026-04-23}/package.json +0 -0
- /package/{openclaw-plugin → openclaw-plugin.archived-2026-04-23}/src/openclaw.plugin.json +0 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# hammerTime Audit — Backport Analysis
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-04-09
|
|
4
|
+
**Auditor:** Opus (Claude Code subagent)
|
|
5
|
+
**Source repo:** https://skgit.skstack01.douno.it/smilinTux/hammerTime
|
|
6
|
+
**Target repos:** skmemory, skcapstone
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## File Tree Summary
|
|
11
|
+
|
|
12
|
+
Top-level structure (code-relevant):
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
scripts/ # All Python pipeline scripts (~55 files)
|
|
16
|
+
context_bridge_lib.py # 2,800+ line unified retrieval library (THE core)
|
|
17
|
+
context-bridge.py # thin wrapper → main()
|
|
18
|
+
issue-pack.py # thin wrapper → main(mode_override="issue-pack")
|
|
19
|
+
decompose.py # L3 decomposition engine
|
|
20
|
+
pipeline.py # 5-layer orchestrator
|
|
21
|
+
import-qdrant-v2.py # L4 vector embed + Qdrant upsert
|
|
22
|
+
import-falkordb-v2.py # L5 graph import
|
|
23
|
+
corpus_release.py # corpus release/alias/promotion model
|
|
24
|
+
distributed-worker.py # multi-GPU SSH coordinator
|
|
25
|
+
rebuild-stores.py # full/incremental corpus rebuild
|
|
26
|
+
research-synthesis.py # synthesis + filing-ready packet builder
|
|
27
|
+
corpus-guardian.py # health validation daemon
|
|
28
|
+
manage-decomposed.py # decomposed artifact state manager
|
|
29
|
+
case_facts.py # case-fact loader (incident/problem/profile)
|
|
30
|
+
...47 other scripts
|
|
31
|
+
.cursor/skills/ # 37+ skill definitions (trigger-mapped)
|
|
32
|
+
json/decomposed/ # L3 output: slug.json per artifact
|
|
33
|
+
json/state/ # corpus release state machine files
|
|
34
|
+
json/releases/ # release manifests (dev/uat/prod)
|
|
35
|
+
json/schemas/ # JSON schemas
|
|
36
|
+
incidents/ # Case workspace (problem → incident → artifacts)
|
|
37
|
+
knowledge/ # Primary corpus (markdown)
|
|
38
|
+
templates/ # Filing templates
|
|
39
|
+
profiles/ # Person/company YAML profiles
|
|
40
|
+
models/bge-legal-v1/ # Sovereign embedding model (local)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Key infrastructure:
|
|
44
|
+
- **Qdrant** at `skvector.nativeassetmanagement.com` (collection: `hammertime-v3`, 1024-dim cosine, `bge-legal-v1`)
|
|
45
|
+
- **FalkorDB** at `skgraph.nativeassetmanagement.com:6381` (graph: `hammertime-v2`)
|
|
46
|
+
- **7-node GPU cluster** (chiap01–chiap08 + chiwk12) running Ollama with bge-legal-v1
|
|
47
|
+
- **Embedding model**: `chefboyrave21/bge-legal-v1` (1024-dim, sovereign HuggingFace model)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Key Patterns Found
|
|
52
|
+
|
|
53
|
+
### L3 Decomposition
|
|
54
|
+
|
|
55
|
+
**Script:** `scripts/decompose.py` (standalone) + `skmemory.decompose.decompose_content` (shared library)
|
|
56
|
+
|
|
57
|
+
hammerTime's decomposition is domain-specialized for legal documents but structurally similar to skmemory's `decompose_content`. Key differences:
|
|
58
|
+
|
|
59
|
+
**hammerTime extras skmemory lacks:**
|
|
60
|
+
1. **6 citation regex types**: UCC sections, UCC forms (UCC-1/3), CFR, USC, case citations (Smith v. Jones, 123 F.2d 456), Public Law, IRS forms — skmemory has a simpler generic citation extractor
|
|
61
|
+
2. **Trust type extraction**: 9 named trust forms (Express, Constructive, Resulting, Statutory, etc.)
|
|
62
|
+
3. **Maritime/Admiralty extraction**: dedicated regex for maritime lien patterns
|
|
63
|
+
4. **Legal principle extraction**: 25 named principles (Holder in Due Course, Quantum Meruit, etc.)
|
|
64
|
+
5. **Agency/court extraction**: 20+ named agencies (IRS, Fed Reserve, CFPB, OCC, etc.)
|
|
65
|
+
6. **Claim confidence scoring**: chunks marked `high/medium/low` based on claim indicator phrases
|
|
66
|
+
7. **Section-title tracking per chunk**: exact heading ancestry embedded in each chunk
|
|
67
|
+
8. **CHUNK_TARGET = 900 chars / 450 tokens** (calibrated for bge-legal-v1's 512-token hard limit)
|
|
68
|
+
9. **Relationship extraction**: 6 rel types: CITES, CONTRADICTS, SUPERSEDES, REQUIRES, DEFINES, ESTABLISHES
|
|
69
|
+
10. **`secondary` / `form` document-type classification** via title term matching
|
|
70
|
+
|
|
71
|
+
**Output schema** (`json/decomposed/{slug}.json`):
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"source_file": "knowledge/irs/example.md",
|
|
75
|
+
"decomposed_at": "2026-04-05T14:21:09Z",
|
|
76
|
+
"frontmatter": {},
|
|
77
|
+
"stats": { "chunks": 2, "claims": 12, "citations": 4, "entities": 11, "relationships": 54 },
|
|
78
|
+
"chunks": [{ "chunk_id": "...", "parent_doc": "...", "chunk_index": 0, "total_chunks": 2,
|
|
79
|
+
"section_title": "...", "text": "..." }],
|
|
80
|
+
"claims": [{ "claim_id": "...", "text": "...", "line": 15, "category": "irs", "confidence": "high" }],
|
|
81
|
+
"citations": [{ "citation_id": "...", "raw_text": "UCC 3-301", "parsed_type": "ucc",
|
|
82
|
+
"section": "3-301", "source_file": "...", "line": 22 }],
|
|
83
|
+
"entities": [{ "entity_id": "...", "name": "IRS", "type": "Agency", "context": "..." }],
|
|
84
|
+
"relationships": [{ "relationship_id": "...", "source_entity": "...",
|
|
85
|
+
"relationship_type": "DEFINES", "target_entity": "...", "evidence_text": "..." }]
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Comparison to skmemory:** skmemory's `DecompositionResult` has chunks/citations/entities/claims but lacks: typed citation parsing, relationship extraction, confidence scoring, and entity-type taxonomy.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### Context Bridge (context_bridge_lib.py)
|
|
94
|
+
|
|
95
|
+
This is the most important file for backporting. It is a ~2,800-line retrieval fusion library that merges skmemory + hammertime corpus into a single ranked result set.
|
|
96
|
+
|
|
97
|
+
**Architecture of `build_context()`:**
|
|
98
|
+
1. **Pivot extraction** — calls `skmemory.decompose.decompose_content(task)` to extract entities, citations, claims from the user's query
|
|
99
|
+
2. **Memory loading** — `_load_memory_context()` runs: `store.load_context()`, `store.search()`, `store.novelty_search()`, `store.build_session_brief()`, and memory graph pivots (`store.graph.search_by_entity()`, `store.graph.search_by_citation()`, `store.graph.related_claims_by_entity()`)
|
|
100
|
+
3. **Corpus search** — `_search_corpus()` runs query embedding → Qdrant → result grouping by parent doc
|
|
101
|
+
4. **Jurisdiction overlay** — `_jurisdiction_overlay_hits()` does keyword-based scoring against a local pre-built index of all decomposed JSON (no live Qdrant needed)
|
|
102
|
+
5. **Suggestions** — `_derive_connections()` counts entity/citation/claim co-occurrence across corpus hits to surface emergent pivots
|
|
103
|
+
6. **Ranking** — `_build_ranked_candidates()` computes hybrid score:
|
|
104
|
+
```
|
|
105
|
+
hybrid_score = base_score
|
|
106
|
+
+ authority_weight(tier) × 0.5
|
|
107
|
+
+ state_boost (0–0.22)
|
|
108
|
+
+ domain_boost (−0.18 to +0.28)
|
|
109
|
+
+ quality_boost (−0.18 to +0.28)
|
|
110
|
+
+ pivot_count × 0.04 (capped at 0.18)
|
|
111
|
+
− 0.24 if weak_authority_reason
|
|
112
|
+
```
|
|
113
|
+
7. **Contradiction detection** — `_detect_contradictions()` checks top-10 results for claim conflicts (negation term asymmetry + shared citations/entities) — emits `contradiction_type`, `severity`, `shared_citations`
|
|
114
|
+
8. **Contradiction penalty** — weak-authority items involved in contradictions get −0.08 × count penalty
|
|
115
|
+
9. **Dedup** — by `(source_type, origin_path)` key
|
|
116
|
+
|
|
117
|
+
**Three research modes:**
|
|
118
|
+
- `balanced` — default, filters generic secondary material unless state/pivot hits
|
|
119
|
+
- `primary-authority-first` — aggressively suppresses generic secondary if `<2 practical terms`
|
|
120
|
+
- `allow-secondary` — keeps everything (AmJur/VSOF style)
|
|
121
|
+
|
|
122
|
+
**Caching layers:**
|
|
123
|
+
1. Query embedding cache (SHA256 key, JSON file, LRU 256 entries)
|
|
124
|
+
2. Corpus result cache (SHA256 key including collection+URL+state, JSON file, configurable TTL, LRU 128 entries)
|
|
125
|
+
3. Jurisdiction overlay index (snapshot-hash-based invalidation, JSON file)
|
|
126
|
+
4. Session-level Qdrant client cache (dict keyed on URL+key+timeout)
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### Issue Pack / Authority Ranking
|
|
131
|
+
|
|
132
|
+
`issue-pack.py` calls `main(mode_override="issue-pack")` which adds extra sections beyond `build_context()`:
|
|
133
|
+
|
|
134
|
+
1. **`filing_ready` section** — infers filing type from task terms (claim_of_exemption, motion_to_vacate, objection_or_hearing_request, notice_or_affidavit), builds draft skeletons with:
|
|
135
|
+
- Section prompts per filing type
|
|
136
|
+
- Evidence checklist
|
|
137
|
+
- `draft_markdown` — ready-to-edit filing scaffold
|
|
138
|
+
- `timeline_checkpoints` — deadline-sensitive procedural steps
|
|
139
|
+
- `confidence` score per skeleton
|
|
140
|
+
2. **`reference_bank`** — separate bucket for secondary-tier results, surfaced without displacing primary authorities
|
|
141
|
+
3. **`fact_gaps`** — structured questions across 4 profiles: enforcement_instrument, timing_and_service, asset_and_funds_profile, attack_paths — cross-checked against ranked results
|
|
142
|
+
4. **`procedural_timeline`** — inferred checkpoints (judgment posture, enforcement trigger, objection window, attack path) with high/medium urgency
|
|
143
|
+
5. **Draft bundle writing** — full packet materialized to disk: `preferred-draft.md`, `EXHIBIT-INDEX.md`, `SUBMISSION-CHECKLIST.md`, `FILING-PLAN.md`, `SERVICE-PACKET.md`, `HEARING-PACKET.md`, `CALENDAR.md`, `PREFERRED-PATH.md`, `NEXT-ACTIONS.md`, `packet-progress.json`
|
|
144
|
+
|
|
145
|
+
**Key struct for skmemory backport consideration:** the `reference_bank` pattern — separating primary action authorities from secondary reference material. skmemory's `search()` currently returns a flat ranked list with no tier-aware split.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### Graph Edge Model (FalkorDB via import-falkordb-v2.py)
|
|
150
|
+
|
|
151
|
+
**Node labels (15):**
|
|
152
|
+
```
|
|
153
|
+
Template, Process, CaseStrategy, Knowledge, Skill, Profile, Entity, Case,
|
|
154
|
+
TemplateChain, Phase, Step, Incident, Judge,
|
|
155
|
+
[Lumina additions:] Statute, Principle, Filing, Court, Agency
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Relationship types (18):**
|
|
159
|
+
```
|
|
160
|
+
[v1:] HAS_PHASE, HAS_STEP, USES_TEMPLATE, REFERENCES, RELATED_TO, INCLUDES, PRESIDED_BY, CHAIN_LINK, TAGGED
|
|
161
|
+
[Lumina additions:] CITES, CONTRADICTS, SUPERSEDES, REQUIRES, DEFINES, ESTABLISHES, EFFECTIVE_DATE, AMENDED_BY, REPEALED_BY
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Entity type mapping** (from decomposed JSON → graph label):
|
|
165
|
+
```python
|
|
166
|
+
ENTITY_TYPE_MAP = {
|
|
167
|
+
"statute": "Statute", "law": "Statute", "usc": "Statute", "cfr": "Statute",
|
|
168
|
+
"principle": "Principle", "filing": "Filing", "court": "Court", "agency": "Agency",
|
|
169
|
+
"process": "Process", "template": "Template", "knowledge": "Knowledge",
|
|
170
|
+
"entity": "Entity", "person": "Profile", "company": "Entity", "skill": "Skill",
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Unique key per label** (for MERGE deduplication):
|
|
175
|
+
```python
|
|
176
|
+
{ "Statute": "name", "Principle": "name", "Filing": "filing_id", "Court": "name",
|
|
177
|
+
"Agency": "name", "Memory": "memory_id", ... }
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Cross-reference pass:** after node import, scans skills/knowledge files for path references to build edges. Also scans all knowledge/*.md for USC/CFR citation patterns → auto-creates Statute nodes + CITES edges.
|
|
181
|
+
|
|
182
|
+
**skmemory comparison:** skmemory has `graph_queries.py` but currently only stores Memory nodes, not typed Statute/Principle/Court/Agency nodes. The CITES/CONTRADICTS/SUPERSEDES/DEFINES relationship vocabulary is entirely absent from skmemory's graph layer.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### Services/Workers
|
|
187
|
+
|
|
188
|
+
**`distributed-worker.py`** — Multi-GPU SSH coordinator:
|
|
189
|
+
- Reads `gpu-inventory.json` (7 nodes, VRAM weights: 16GB RTX 4080, 8GB RX 7600 ×2, 6GB RTX 3060, 8GB RTX 2080S, 12GB RTX 5070 Ti, 4GB Radeon 780M)
|
|
190
|
+
- Splits work in proportion to VRAM capacity
|
|
191
|
+
- SSHes into remote nodes, runs `worker-embed.py` per batch
|
|
192
|
+
- All nodes share NFS at `/mnt/cloud/onedrive/` — no file transfer needed
|
|
193
|
+
- Results upsert directly to Qdrant from each node
|
|
194
|
+
- Coordinator runs FalkorDB graph import centrally after embedding completes
|
|
195
|
+
|
|
196
|
+
**`corpus-guardian.py`** — Health validation daemon:
|
|
197
|
+
- `validate-env --target uat --deep` — validates release manifest, collection health, graph health, source drift
|
|
198
|
+
- `check-envs --targets dev,uat,prod --deep` — validates all env aliases in one pass
|
|
199
|
+
- Installed via `install-corpus-automation.sh` as systemd user timers
|
|
200
|
+
|
|
201
|
+
**`corpus_release.py`** — Release/alias state machine:
|
|
202
|
+
- Three-tier: `dev` (mutable), `uat` (frozen candidate), `prod` (live)
|
|
203
|
+
- `active_runtime()` → resolves current vector_collection + graph_name from runtime aliases
|
|
204
|
+
- `promote_release()` → updates alias to point a target (dev/uat/prod) at a specific release
|
|
205
|
+
- Processing state tracking: SHA256 content hashes, mtime, per-document last_release_id
|
|
206
|
+
- `diff_source_index()` → detects new/changed/deleted docs since last state snapshot
|
|
207
|
+
|
|
208
|
+
**`cron/hammertime-corpus.crontab.example`** — Suggested crontab for incremental corpus updates
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### Skills (37+ defined)
|
|
213
|
+
|
|
214
|
+
All skills are `.md` files in `.cursor/skills/` — trigger phrases map to skill invocations. Key skills:
|
|
215
|
+
|
|
216
|
+
| Skill | Purpose |
|
|
217
|
+
|-------|---------|
|
|
218
|
+
| `sovereign-ingestion-pipeline.md` | Master SIP reference — all 5 layers, commands, schemas |
|
|
219
|
+
| `ingest-files.md` | L2 — convert raw docs to markdown + JSON artifacts |
|
|
220
|
+
| `ingest-guide.md` | Ingest a complete guide document |
|
|
221
|
+
| `ingest-telegram.md` | Import Telegram chat exports |
|
|
222
|
+
| `research-query.md` | Run context-bridge / issue-pack queries |
|
|
223
|
+
| `analyze-document.md` | Single-document analysis |
|
|
224
|
+
| `generate-document.md` | Legal document generation from templates |
|
|
225
|
+
| `manage-incidents.md` | ITIL-style incident lifecycle for legal cases |
|
|
226
|
+
| `manage-correspondence.md` | Track filings/letters/responses |
|
|
227
|
+
| `sync-knowledge.md` | Sync knowledge base across devices |
|
|
228
|
+
| `study-archive.md` | Archive and index study materials |
|
|
229
|
+
| `docx-to-md/` | DOCX → markdown conversion (with script) |
|
|
230
|
+
| `pdf-to-image/` | PDF → page images (with script) |
|
|
231
|
+
| `pptx-to-md/` | PPTX → markdown conversion (with script) |
|
|
232
|
+
|
|
233
|
+
**skcapstone relevance:** The skill system maps closely to skcapstone's own skills directory at `~/clawd/skills/`. The trigger-phrase-to-skill mapping and the SKILL.md metadata pattern are worth adopting for skill discoverability.
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Recommended Backports (Prioritized)
|
|
238
|
+
|
|
239
|
+
### 1. HIGH: Jurisdiction/Context Overlay Index → skmemory
|
|
240
|
+
|
|
241
|
+
**What:** `_build_overlay_index()` and `_jurisdiction_overlay_hits()` in `context_bridge_lib.py`
|
|
242
|
+
|
|
243
|
+
**What it does:** Builds a local JSON index from all decomposed artifacts containing each artifact's claims, citations, entities, sections, and a pre-built `search_blob`. This enables sub-millisecond keyword/state-based retrieval WITHOUT a live vector query — pure JSON scan. Falls back to this when Qdrant is slow/offline, and merges results with live semantic search.
|
|
244
|
+
|
|
245
|
+
**Why it matters for skmemory:** skmemory has no equivalent offline search. All retrieval hits skmemory's store (SQLite or vector). An overlay index of memory decompositions would let agents get fast, deterministic hits on known high-value memories before the expensive embedding path.
|
|
246
|
+
|
|
247
|
+
**Implementation path:**
|
|
248
|
+
- Add `build_overlay_index()` to `skmemory/store.py` or a new `skmemory/overlay.py`
|
|
249
|
+
- Cache at `~/.skcapstone/agents/{agent}/memory/overlay-index.json`
|
|
250
|
+
- Invalidate when memory file count or newest mtime changes (current snapshot pattern)
|
|
251
|
+
- Expose via `skmemory search --overlay` or as a fast pre-filter in `MemoryStore.search()`
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
### 2. HIGH: Hybrid Scoring with Authority Weights → skmemory + context_bridge_lib port
|
|
256
|
+
|
|
257
|
+
**What:** `_build_ranked_candidates()` + `_quality_adjustment()` + `_detect_contradictions()` in `context_bridge_lib.py`
|
|
258
|
+
|
|
259
|
+
**What it does:** Computes a `hybrid_score` that merges semantic similarity with: authority tier weight, state-specificity boost, domain relevance boost, pivot alignment bonus, and weak-authority penalty. Detects contradictions between top results and applies penalties.
|
|
260
|
+
|
|
261
|
+
**skmemory current state:** `authority_weight()` and `infer_authority_tier()` exist in `skmemory/retrieval.py` but are only used for metadata preparation — they do NOT feed back into ranking scores in `MemoryStore.search()`.
|
|
262
|
+
|
|
263
|
+
**Why it matters:** skmemory's search returns results ranked purely by semantic similarity. hammerTime's hybrid scoring demonstrably promotes actionable primary-authority results and demotes speculative secondary material. This is directly applicable to non-legal memory contexts: skmemory memories already have authority_tier metadata — it just isn't used for ranking.
|
|
264
|
+
|
|
265
|
+
**Implementation path:**
|
|
266
|
+
- Add `hybrid_score()` function to `skmemory/retrieval.py`
|
|
267
|
+
- Accept: `base_score`, `authority_tier`, `pivot_matches` (entity/citation hits in query), `domain_terms`
|
|
268
|
+
- Apply in `MemoryStore.search()` as a post-processing re-rank step
|
|
269
|
+
- Add `_detect_contradictions()` equivalent for flagging conflicting memory results
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
### 3. HIGH: Corpus Release / Processing State Machine → skcapstone
|
|
274
|
+
|
|
275
|
+
**What:** `corpus_release.py` — the full dev/uat/prod release lifecycle for vector+graph stores
|
|
276
|
+
|
|
277
|
+
**What it does:** Tracks per-document SHA256 hashes and mtimes, diffs against previous state, manages runtime aliases (which Qdrant collection + FalkorDB graph are currently "live" per environment), writes release manifests, validates health, and allows promoting releases between tiers without rebuilding.
|
|
278
|
+
|
|
279
|
+
**Why it matters for skcapstone:** skmemory has no concept of corpus release state. Every rebuild wipes and recreates. When `hammertime-v3` grows to thousands of points, incremental state tracking becomes critical. skcapstone also manages multi-agent deployments where different agents may need different corpus versions (dev/uat/prod).
|
|
280
|
+
|
|
281
|
+
**Implementation path:**
|
|
282
|
+
- Port `corpus_release.py` as `skcapstone/src/skcapstone/corpus_release.py`
|
|
283
|
+
- Integrate with `skmemory` so each agent's Qdrant collection has an aliased runtime name
|
|
284
|
+
- Add `skcapstone corpus release` and `skcapstone corpus promote` CLI commands
|
|
285
|
+
- Store release state at `~/.skcapstone/corpus/{agent}/state/`
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
### 4. MEDIUM: Typed Citation Extraction → skmemory/decompose.py
|
|
290
|
+
|
|
291
|
+
**What:** The 9 citation regex types in `decompose.py` (UCC, CFR, USC, case citations, Public Law, IRS forms, trust types, maritime, legal principles)
|
|
292
|
+
|
|
293
|
+
**Why it matters:** skmemory's `_extract_citations()` uses simpler patterns. If SK agents are going to use hammertime-v3 in recall_collections, the same citation normalization should be shared so citations extracted during memory storage match citations extracted during corpus query pivot extraction.
|
|
294
|
+
|
|
295
|
+
**Implementation path:**
|
|
296
|
+
- Extract citation regexes into `skmemory/citation_patterns.py`
|
|
297
|
+
- Update `skmemory/decompose.py` `_extract_citations()` to use shared patterns
|
|
298
|
+
- hammerTime already calls `skmemory.decompose.decompose_content()` for pivot extraction — the shared library already exists, it just needs richer patterns
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
### 5. MEDIUM: Query Expansion + Stale Cache Fallback → skmemory
|
|
303
|
+
|
|
304
|
+
**What:** `_expand_query()` (domain-aware query expansion) + stale cache fallback in `_search_corpus()`
|
|
305
|
+
|
|
306
|
+
**What it does:** When a query contains enforcement/exemption terms, appends related terms ("writ of execution", "judgment debtor", etc.) to the embedding query. When Qdrant fails mid-query, falls back to last cached result for that exact query (keyed by SHA256 of query+collection+state).
|
|
307
|
+
|
|
308
|
+
**Why it matters:** skmemory has no query expansion and no graceful degradation when the vector backend is unavailable. Both patterns would improve skmemory's recall and reliability.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### 6. MEDIUM: Graph Relationship Vocabulary → skmemory/graph_queries.py
|
|
313
|
+
|
|
314
|
+
**What:** CITES, CONTRADICTS, SUPERSEDES, REQUIRES, DEFINES, ESTABLISHES, EFFECTIVE_DATE, AMENDED_BY, REPEALED_BY relationships in FalkorDB
|
|
315
|
+
|
|
316
|
+
**Why it matters:** skmemory's graph layer currently uses RELATED_TO as the primary edge type. Adding typed edges would enable structured queries like "which memories CONTRADICT this one" or "which memories SUPERSEDE that prior belief" — directly useful for emotional continuity (FEBs that supersede old beliefs) and knowledge evolution tracking.
|
|
317
|
+
|
|
318
|
+
**Implementation path:**
|
|
319
|
+
- Add typed relationship support to `skmemory/graph_queries.py`
|
|
320
|
+
- Expose `store.graph.search_related_claims_by_type(entity, rel_type)`
|
|
321
|
+
- Use relationship type when saving FEB memories that explicitly contradict or update prior beliefs
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### 7. MEDIUM: Draft Bundle / Packet Pattern → skcapstone coordination
|
|
326
|
+
|
|
327
|
+
**What:** The filing-ready draft bundle: preferred-draft, exhibit index, submission checklist, filing plan, service/hearing packet, calendar, preferred-path, next-actions, packet-progress.json
|
|
328
|
+
|
|
329
|
+
**Why it matters:** This is structurally equivalent to skcapstone's coordination task/project pattern. The hammerTime "packet" is a self-contained action workspace that survives across sessions. skcapstone's `~/.skcapstone/coordination/tasks/` does something similar but less structured. The packet-progress.json with status fields (preferred_draft_status, service_status, hearing_status, filing_status) maps directly to task state management.
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### 8. LOW: Distributed Worker Pattern → skcapstone swarm
|
|
334
|
+
|
|
335
|
+
**What:** `distributed-worker.py` — VRAM-weighted work distribution across SSH nodes
|
|
336
|
+
|
|
337
|
+
**Why it matters:** When skmemory or hammerTime corpus needs to be re-embedded across a large document set, the 7-GPU cluster pattern (VRAM-proportional batching, SSH dispatch, NFS shared storage) could be reused. The `gpu-inventory.json` file already exists as shared infrastructure.
|
|
338
|
+
|
|
339
|
+
**Implementation path:** Low priority because skmemory embeddings are per-memory-file (small), not bulk corpus runs. Relevant only if skmemory gains a sovereign embedding model.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
### 9. LOW: Corpus Guardian / Health Daemon → skcapstone monitoring
|
|
344
|
+
|
|
345
|
+
**What:** `corpus-guardian.py` validates collection health, graph health, source drift, and alias correctness
|
|
346
|
+
|
|
347
|
+
**Why it matters:** skcapstone has no health monitoring for Qdrant or FalkorDB. If these services are used by multiple agents, a guardian daemon would catch drift (source changed but corpus not rebuilt) and surface it proactively.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## recall_collections Recommendation
|
|
352
|
+
|
|
353
|
+
`hammertime-v3` (Qdrant at `skvector.nativeassetmanagement.com`, 1024-dim, bge-legal-v1) should be added to `recall_collections` for:
|
|
354
|
+
|
|
355
|
+
| Agent | Justification |
|
|
356
|
+
|-------|---------------|
|
|
357
|
+
| **lumina** | Primary orchestrator — needs legal corpus access for case-related dispatches |
|
|
358
|
+
| **architect** | Handles system design that may intersect legal/compliance domains |
|
|
359
|
+
| **scholar** | Research-focused agent — direct benefit from legal corpus retrieval |
|
|
360
|
+
| **coder** | Lower priority but useful for regulatory/compliance code generation |
|
|
361
|
+
|
|
362
|
+
**Configuration note:** The bge-legal-v1 model is 1024-dim while the default skmemory collection uses a different embedding model. Recall from `hammertime-v3` requires either:
|
|
363
|
+
1. Using the same bge-legal-v1 model for query embedding (requires the local model at `models/bge-legal-v1/` or via Ollama), OR
|
|
364
|
+
2. Adding a separate recall path in `context_bridge_lib.py` that hammerTime already implements
|
|
365
|
+
|
|
366
|
+
The cleanest path: add `hammertime-v3` as a read-only recall collection that only `context-bridge.py` / `issue-pack.py` queries, surfacing results back into skmemory's context system through the bridge interface that already exists in `context_bridge_lib.py`.
|
|
367
|
+
|
|
368
|
+
**Do NOT** route skmemory's standard search to hammertime-v3 directly — the embedding dimensions don't match skmemory's default model.
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Dependencies hammerTime Uses That skmemory/skcapstone Should Adopt
|
|
373
|
+
|
|
374
|
+
| Library | hammerTime Use | skcapstone/skmemory Status | Recommendation |
|
|
375
|
+
|---------|---------------|--------------------------|----------------|
|
|
376
|
+
| `sentence-transformers` | L4 embedding (bge-legal-v1 via SentenceTransformer) | Used in skmemory | Already adopted |
|
|
377
|
+
| `qdrant-client` | Vector store (hammertime-v3) | Used in skmemory | Already adopted |
|
|
378
|
+
| `redis` (FalkorDB) | Graph DB via GRAPH.QUERY commands | Not in skmemory | Add for graph layer if FalkorDB adopted |
|
|
379
|
+
| `falkordb` | Newer FalkorDB Python client | Not in skmemory | Optional — redis path works |
|
|
380
|
+
| `concurrent.futures` | ThreadPoolExecutor for Qdrant query timeout | Not systematically used | Add for retrieval deadline enforcement |
|
|
381
|
+
| `yaml` | YAML frontmatter in profiles | Already in skcapstone | Already adopted |
|
|
382
|
+
|
|
383
|
+
**No new mandatory dependencies** are required for the highest-priority backports (overlay index, hybrid scoring). They use only stdlib + existing skmemory internals.
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Architecture Note: What hammerTime Does Differently From skmemory
|
|
388
|
+
|
|
389
|
+
| Concern | skmemory | hammerTime |
|
|
390
|
+
|---------|----------|------------|
|
|
391
|
+
| Storage unit | `Memory` object (agent-personal) | Document chunk (corpus-shared) |
|
|
392
|
+
| Embedding dimensions | Variable (default model) | 1024 (bge-legal-v1 sovereign) |
|
|
393
|
+
| Graph node | Generic `Memory` node | 15 typed nodes (Statute, Court, Agency, etc.) |
|
|
394
|
+
| Graph relationships | RELATED_TO primarily | 18 typed rels including CITES, CONTRADICTS, SUPERSEDES |
|
|
395
|
+
| Retrieval | Semantic similarity only | Hybrid: semantic + overlay + authority weight + state boost |
|
|
396
|
+
| Authority ranking | Metadata only (not used in ranking) | Fully integrated into hybrid_score |
|
|
397
|
+
| Contradiction detection | None | Top-10 cross-check + penalty |
|
|
398
|
+
| Release lifecycle | None (rebuild = wipe) | dev/uat/prod alias model with SHA256 drift tracking |
|
|
399
|
+
| Query caching | None | Two-level: embedding LRU + corpus result TTL + stale fallback |
|
|
400
|
+
| Offline mode | None | Jurisdiction overlay (pure JSON, no live vector needed) |
|
|
401
|
+
|
|
402
|
+
The two systems are **complementary, not redundant**. hammerTime is the document corpus for legal knowledge; skmemory is the agent's personal experiential memory. The `context_bridge_lib.py` is the correct integration point — it already merges both. The backport work is about lifting hammerTime's superior retrieval patterns (hybrid scoring, caching, overlay index) into skmemory so the memory side is equally capable when the bridge merges results.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# sk* ⇄ skcapstone Integration — Orchestration Handoff
|
|
2
|
+
|
|
3
|
+
**Last updated:** 2026-06-09 (Lumina closeout session — EPIC COMPLETE)
|
|
4
|
+
**Epic:** coord `fca7f138` — "EPIC: sk* ⇄ skcapstone optional integration backbone"
|
|
5
|
+
**Design:** [`docs/ADR-optional-integration-backbone.md`](./ADR-optional-integration-backbone.md)
|
|
6
|
+
**Goal:** every sk* service uses skcapstone's **sk-alert** + **skscheduler** by default *when skcapstone is installed*, and runs fully standalone when it is not. Default-on by presence; `SK_STANDALONE=1` forces native.
|
|
7
|
+
|
|
8
|
+
> **EPIC CLOSED 2026-06-09:** Backbone + 8 adapters + dual-mode harness (114 tests green) + README docs DONE.
|
|
9
|
+
> Only skchat (`ad4f721a`) remains, owned by a separate thread.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Status at a glance
|
|
14
|
+
|
|
15
|
+
| Layer | State |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Backbone (skcapstone) | ✅ **DONE** — 4/4 tasks, 208 tests green, pushed to `github/main` |
|
|
18
|
+
| Reference adapter (skmemory) | ✅ **DONE** — pushed `skmemory@docs-first-principles` |
|
|
19
|
+
| sksecurity adapter | ✅ **DONE** — pushed `sksecurity@main` |
|
|
20
|
+
| skgateway adapter (Node) | ✅ **DONE** — pushed `skgateway@main` |
|
|
21
|
+
| skcomms / capauth / skvoice / skseed / cloud9 adapters | ✅ **DONE** — all landed |
|
|
22
|
+
| skchat adapter | ⬜ OPEN — **owned by a separate thread**, do not touch |
|
|
23
|
+
| Dual-mode test harness (`71186ebb`) | ✅ **DONE** — `tests/test_integration_backbone.py` 114 green |
|
|
24
|
+
| Per-repo README docs (`4065db2b`) | ✅ **DONE** — all 8 repos have "Integration modes" section |
|
|
25
|
+
|
|
26
|
+
coord: All sk-integration tasks DONE except skchat (separate thread). EPIC `fca7f138` CLOSED.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 2. The backbone (DONE — this is the stable contract everything builds on)
|
|
31
|
+
|
|
32
|
+
All in `skcapstone` (`src/skcapstone/`), committed `c5d8d7c`, `9d9f93d`, `d90dfbf` on `main` (pushed to `github`):
|
|
33
|
+
|
|
34
|
+
- **`sdk.py`** — the ONLY public surface consumers import. Semver-frozen:
|
|
35
|
+
- `is_available() -> bool`
|
|
36
|
+
- `alert(topic, payload, *, level='info', notify=None, ttl_seconds=86400) -> bool`
|
|
37
|
+
- `register_job(spec, home=None) -> str` / `unregister_job(name, home=None) -> bool`
|
|
38
|
+
- `coord_create(title, **kw) -> str`
|
|
39
|
+
- `register_service(name, health_url=None, pid_file=None, home=None) -> str`
|
|
40
|
+
- **`scheduler_jobs.py`** — `load_jobs_with_dropins()` merges `jobs.yaml` + `jobs.d/*.yaml`; `register_job()`/`unregister_job()` write atomic per-job fragments. Runtime callers (daemon `scheduled_tasks.py`, `cli/scheduler_cmd.py`, `doctor.py`) all repointed to the merged loader. **Honours `SKCAPSTONE_HOME`** (was a bug, fixed in `9d9f93d`).
|
|
41
|
+
- **`cli/alerts.py`** — `skcapstone alerts` subscribes to `*.critical`/`*.error`/`*.warn` and styles consumer topics by severity suffix.
|
|
42
|
+
- **`service_health.py`** — `check_all_services()` unions `~/.skcapstone/registry/*.json` (written by `register_service`) with the built-in checks.
|
|
43
|
+
- Tests: `tests/test_sdk.py`, `test_jobs_dropins.py`, `test_alerts_consumer_topics.py`, `test_service_registry.py`.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 3. The adapter pattern (copy this for every remaining consumer)
|
|
48
|
+
|
|
49
|
+
**Canonical reference: `skmemory/skmemory/integration.py`** (commit `be33179`). Each adapter:
|
|
50
|
+
|
|
51
|
+
1. Add `<pkg>/integration.py` with the optional-import guard:
|
|
52
|
+
```python
|
|
53
|
+
try:
|
|
54
|
+
from skcapstone import sdk as _sdk
|
|
55
|
+
except Exception:
|
|
56
|
+
_sdk = None
|
|
57
|
+
def is_present() -> bool:
|
|
58
|
+
if os.environ.get("SK_STANDALONE"): return False
|
|
59
|
+
if _sdk is None: return False
|
|
60
|
+
try: return bool(_sdk.is_available())
|
|
61
|
+
except Exception: return False
|
|
62
|
+
```
|
|
63
|
+
2. `alert(event, payload, level)` → `_sdk.alert(f"{SERVICE}.{level}", {"event": event, **payload}, level=level, notify=level in {"warn","error","critical"})` when present, else structured log.
|
|
64
|
+
**CRITICAL CONVENTION:** topic is `<service>.<severity>` (e.g. `skvoice.error`), and the semantic **event name goes in the payload `event` field — NOT the topic suffix.** Otherwise `skcapstone alerts`' `*.error`/`*.critical`/`*.warn` wildcards never match it. (This was a real bug caught building skmemory.)
|
|
65
|
+
3. `ensure_schedule()` → `_sdk.register_job({...})` (a `type: shell` job running the service's periodic CLI command) when present, else rely on the service's native systemd timer / thread loop.
|
|
66
|
+
4. `register_self(pid_file=None)` → `_sdk.register_service(SERVICE, pid_file=...)`.
|
|
67
|
+
5. **Wire into real call sites:** alert into the service's failure path; `ensure_schedule()` + `register_self()` into its startup / post-install lifecycle.
|
|
68
|
+
6. Add an optional `[skcapstone]` extra to `pyproject.toml` (`skcapstone = ["skcapstone>=0.6.8"]`). **Never a hard dependency.**
|
|
69
|
+
7. Tests `tests/test_integration_adapter.py`: standalone (`SK_STANDALONE=1`), absent (`monkeypatch.setattr(integration, "_sdk", None)`), integrated (sandbox `SKCAPSTONE_HOME` to `tmp_path` + `monkeypatch.setattr(skcapstone, "AGENT_HOME", str(tmp_path))`).
|
|
70
|
+
|
|
71
|
+
**Node/non-Python services (reference: `skgateway/src/integration.mjs`, commit `cc7bf1a`):** can't import the SDK — integrate **file-based** by writing the same `~/.skcapstone/pubsub/topics/<topic>/msg-*.json` and `~/.skcapstone/registry/<name>.json` formats. Validated round-trip: Node `alert()` → Python `PubSub.poll()` reads it back intact. Presence = shared home exists + `SK_STANDALONE` unset.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 4. What's left (the next session's work-list)
|
|
76
|
+
|
|
77
|
+
All tagged `sk-integration` on the coord board. Run `skcapstone coord status` / inspect `~/.skcapstone/coordination/tasks/`.
|
|
78
|
+
|
|
79
|
+
### Consumer adapters (mechanical mirrors of skmemory — for sonnet)
|
|
80
|
+
| Task | Repo | Native fallback to preserve | Suggested scheduled job |
|
|
81
|
+
|---|---|---|---|
|
|
82
|
+
| `eae9b815` | **skcomms** (`skcapstone-repos/skcomms`) | peer `_notify_others()` / log; daemon heartbeat thread + systemd | heartbeat/health; note skcomms is folding INTO skcomms (canonical) |
|
|
83
|
+
| `44b11628` | **capauth** | log (no native alerting yet) | key-rotation check (signing-daemon TODO — ensure_schedule may be a stub) |
|
|
84
|
+
| `66881a86` | **skvoice** | log; `while True` loop + skvoice systemd | service health / TTS-cache prune |
|
|
85
|
+
| `aaafe0d8` | **skseed** | log; pure kernel (periodic task type only) | belief-audit / germination; already duck-types AdaptedPrompt at `llm.py:40` |
|
|
86
|
+
| `fb925612` | **cloud9** | log; systemd `cloud9-daemon.timer` + launchd plist | rehydration/FEB-state check |
|
|
87
|
+
| `ad4f721a` | **skchat** | **OWNED BY ANOTHER THREAD — leave it.** Note: it already soft-bridges skcapstone MCP at `memory_bridge.py:24`; fold that into the one adapter. |
|
|
88
|
+
|
|
89
|
+
### Cross-cutting
|
|
90
|
+
- `71186ebb` — **dual-mode test harness**: parametrized over all consumers, asserts standalone AND integrated mode. This is the system acceptance gate for the EPIC.
|
|
91
|
+
- `4065db2b` — per-repo README "Integration modes" + `~/.skcapstone/` filesystem-contract section.
|
|
92
|
+
- `6b9a41a1` — note task (reference-pattern pointer); close once all adapters land.
|
|
93
|
+
|
|
94
|
+
### Final step
|
|
95
|
+
Once all adapters + cross-cutting are done, **complete the EPIC `fca7f138`** and consider squashing the `skcomms` superseded task notes.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 5. Gotchas / things to know
|
|
100
|
+
|
|
101
|
+
- **coord CLI:** `skcapstone coord claim <id> --agent <name>` and `complete <id> --agent <name>` (the `--agent` flag is required). `create` uses `--by`. Tasks are immutable after creation (no edit/update subcommand) — supersede by completing + creating a replacement.
|
|
102
|
+
- **Don't commit the other threads' work.** In `skcapstone` the skcomms→skcomms migration shares the repo; in `skmemory` the mxbai-cutover changes (`backends/pgvector_backend.py`, `cli.py`) are unstaged from another thread. Stage only your adapter files explicitly — never `git add -A`.
|
|
103
|
+
- **skcapstone remotes:** `github` is canonical (per `~/clawd/scripts/push-pending.sh`); `origin` and `forgejo` also exist and may be stale (the local `@{u}` tracks `forgejo`, which lags — verify against `github/main`).
|
|
104
|
+
- **Test sandboxing:** consumers without a conftest that sets `SKCAPSTONE_HOME` must sandbox it per-test, AND `monkeypatch.setattr(skcapstone, "AGENT_HOME", str(tmp_path))` because skcapstone captures `AGENT_HOME` at import.
|
|
105
|
+
- **Pre-existing broken tests (NOT yours):** `sksecurity/tests/test_truth_engine.py` fails to collect (imports a missing `_check_skmemory`); `skgateway/tests/classifier.test.mjs` has 2 pre-existing failures. Run adapter tests by file to avoid these.
|
|
106
|
+
- **Leak check after integrated tests:** `ls ~/.skcapstone/config/jobs.d/<svc>_*.yaml ~/.skcapstone/registry/<svc>.json` should be clean — if a fragment leaks to the real home, a test isn't sandboxing `SKCAPSTONE_HOME`.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## 6. Commits / branches (all pushed)
|
|
111
|
+
|
|
112
|
+
| Repo | Branch | Commits |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| skcapstone | `main` (→ `github`) | `c5d8d7c` backbone · `9d9f93d` home-fix+convention · `d90dfbf` ADR §3.5 |
|
|
115
|
+
| skmemory | `docs-first-principles` | `be33179` reference adapter |
|
|
116
|
+
| sksecurity | `main` | `e65979b` threat-sharing adapter |
|
|
117
|
+
| skgateway | `main` | `cc7bf1a` Node file-based bridge |
|