Skip to content

Refactor Cortex namespace/event contracts for KempOS reliability#11

Open
jessekemp1 wants to merge 15 commits into
mainfrom
refactor/kempos-contracts
Open

Refactor Cortex namespace/event contracts for KempOS reliability#11
jessekemp1 wants to merge 15 commits into
mainfrom
refactor/kempos-contracts

Conversation

@jessekemp1

@jessekemp1 jessekemp1 commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Pass 1 and the first cut of Pass 2 from the KempOS reliability contracts refactor in issue #10.

This PR adds a minimal reliability substrate that KempOS can depend on without optional Cortex subsystems, then exposes those contracts through CortexBridge.

Added

Pass 1: Filesystem substrate

  • namespaces.py — safe namespace validation and private namespace directory resolution
  • events.py — append-only JSONL event store scoped by namespace
  • capabilities.py — explicit capability registry with available/degraded/missing statuses
  • health.py — namespace doctor checks for write/read/private-path validation
  • tests for namespaces, events, capabilities, and doctor checks

Pass 2: Bridge integration

  • recommendations_store.py — namespaced recommendation storage
  • bridge_kempos.py — bridge mixin for capability/event/doctor/recommendation contracts
  • bridge.py now composes KempOSContractsMixin
  • tests/test_bridge_kempos_contract.py

Roadmap

  • docs/kempos_contracts_roadmap.md — full future phases roadmap through private KempOS MVP, scheduler, pattern intelligence, and dashboard/reporting

Design constraints

  • No Anthropic key required
  • No ChromaDB required
  • No MCP required
  • No scheduler required
  • No optional Cortex intelligence modules required
  • No private KempOS data written into the public repo tree

Intended test command

pytest tests/test_namespaces.py \
  tests/test_events.py \
  tests/test_capabilities.py \
  tests/test_namespace_doctor.py \
  tests/test_bridge_kempos_contract.py

Compatibility note

CortexBridge now uses KempOSContractsMixin before IntelligenceMixin, so inject_recommendation is overridden to support optional namespace and visibility params while preserving default legacy behavior. This needs local/CI validation before the PR is marked ready.

Notes

I could not run the test suite from this GitHub connector environment. The PR remains draft until local/CI validation passes.

Closes part of #10.

@jessekemp1

Copy link
Copy Markdown
Owner Author

Validation update after PR head ebe3d53:

  • Local focused suite: 24 passed in 1.28s
  • Command: .venv/bin/pytest tests/test_namespaces.py tests/test_events.py tests/test_capabilities.py tests/test_namespace_doctor.py tests/test_bridge_kempos_contract.py
  • CI run 29026013059: passed smoke (3.11), smoke (3.12), and integration (3.12)
  • Fix added: wrapped namespace path creation failures in EventStore.append() as EventWriteError, matching tests/test_events.py::test_event_append_failure_raises.

Note: local commit/push used --no-verify because the parent worktree hooks point at missing .claude/hooks/*.py files inside the isolated PR worktree; validation was performed directly with pytest and GitHub Actions.

@jessekemp1 jessekemp1 marked this pull request as ready for review July 9, 2026 14:45
@jessekemp1

Copy link
Copy Markdown
Owner Author

Ready-for-review validation update after PR head 63d0e6d03:

  • Local focused suite: 25 passed in 2.44s
  • Command: .venv/bin/pytest tests/test_namespaces.py tests/test_events.py tests/test_capabilities.py tests/test_namespace_doctor.py tests/test_bridge_kempos_contract.py
  • CI run 29026625535: passed smoke (3.11), smoke (3.12), and integration (3.12)
  • Additional review fix: RecommendationStore.add() now wraps namespace path creation failures as RecommendationWriteError, with a regression in tests/test_bridge_kempos_contract.py::test_recommendation_write_failure_raises.

I marked the PR ready for review because the PR body's draft blocker was local/CI validation, and that blocker is now cleared.

Copy link
Copy Markdown
Owner Author

Phase 1 merge order: hold this PR until #9 lands, then rebase onto updated main and rerun the focused namespace/event/bridge contract tests plus the full Cortex suite. Particular validation target: CortexBridge mixin order and legacy inject_recommendation behavior. No Cortex scope removal is part of this phase. Tracked in jessekemp1/dev#77.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant