# Planner → Orchestrator Autonomous Execution Plan

**Plan ID:** `1793689484676-planner-autonomous-execution-plan`
**Target:** Orchestrator autonomous execution
**Authoritative Plan:** `.kilo/plans/CyberBrain26cil-031026-v2.md` (approved 2026-10-03)
**Gate Target:** Gate 1 verified → Gate 2 E2E flow evidence
**Plan Agent:** Kilo Code (plan mode — creates plans, does not implement)

---

## Goal

Create an autonomous execution plan for the CyberBrain26 orchestrator that:
- Diagnoses current system state (knowledge database, memory, index, security chain)
- Proposes prioritized improvements with subagent assignments
- Delegates all execution steps to subagents via the delegation matrix
- Maintains Gate 1 → Gate 2 → Gate 3 checkpoints with evidence

---

## Diagnostics (Current State Assessment)

The following are established from the existing codebase and prior session memory:

| Component | Status | Evidence |
|-----------|--------|----------|
| Knowledge Plane | [OVĚŘENO] implemented | `src/cyberbrain26/knowledge_plane/` — contracts, repository, vector store, embedding service, chunker, navigation, deduplication |
| Memory Plane | [OVĚŘENO] implemented | `src/cyberbrain26/data_plane/sqlite_memory.py` — SQLiteMemoryProvider with trust labels, keyword retrieval, provenance SHA-256 |
| SQLite Store | [OVĚŘENO] implemented | `src/cyberbrain26/data_plane/sqlite_store.py` — migrations 1–3, knowledge_documents table, audit chain, project_memories |
| Vector Store | [HYPOTÉZA] configured but unverified live | `src/cyberbrain26/knowledge_plane/vector_store.py` — LanceDB, requires Ollama at `http://127.0.0.1:11434` |
| Embedding Service | [HYPOTÉZA] configured but unverified live | `src/cyberbrain26/knowledge_plane/embedding_service.py` — Ollama `/api/embed`, model `qwen3-embedding:0.6b`, 1024 dim |
| Test Suite | [OVĚŘENO] green | `tests/test_knowledge_plane.py`, `test_knowledge_embedding.py`, `test_knowledge_deepweb.py` pass; 626 tests passed per memory |
| Security Chain | [OVĚŘENO] implemented | `security_plane/` — identity, policy, permission, approval, audit, fail-closed |
| Kilo Config | [OVĚŘENO] enforced | `.kilo/kilo.jsonc` — `subagent_depth: 1`, `bash: deny`, `task: deny`, MCP `enabled: false` |
| Orchestrator | [OVĚŘENO] single delegator | `.kilo/agent/orchestrator.md` — delegation matrix for 10 subagents |

---

## Improvement Proposals (Prioritized)

| # | Title | Effort | Risk | Subagent | Dependency | Rationale |
|---|-------|--------|------|----------|------------|-----------|
| P1 | Verify Ollama + LanceDB are running; validate embedding pipeline end-to-end | HIGH | LOW | tester | Gate 1 pass | Vector store depends on external Ollama service |
| P2 | Create diagnostic artifacts: diagnostic.md, health_check.json, evidence-index.txt | MEDIUM | NONE | documenter | P1 | Complete diagnostic report with evidence refs |
| P3 | Audit security chain gaps per PROJECT_STATUS.md §5 | MEDIUM | NONE | security-auditor | Gate 1 pass | Missing AIFirewall wiring, cgroup quotas, etc. |
| P4 | Verify Gate 1 determinism: pytest, ruff, mypy all green | LOW | NONE | tester | Gate 1 pass | Establish baseline before any changes |
| P5 | Review `.kilo/plans/CyberBrain26cil-031026-v2.md` phase position (currently F2) | LOW | NONE | deep-research | P4 | Confirm what blocks transition to Gate 2 |

---

## Execution Plan (Sequenced Steps)

| Step | Action | Subagent | Gate | Evidence Requirement |
|------|--------|----------|------|---------------------|
| S1 | Gate 1: `pytest -q`, `ruff check`, `mypy src/cyberbrain26` | tester | Gate 1 | Exit codes, test counts, `[OVĚŘENO] all green` |
| S2 | Capture baseline: git status, .kilo/kilo.jsonc, agent frontmatter | deep-research | Gate 1 | file:line refs for config, uncommitted files |
| S3 | Security chain audit: read security_plane modules, verify fail-closed | security-auditor | Gate 1 | [OVĚŘENO] each link has +ve/-ve test, ExecutionRefused on missing approval |
| S4 | Verify Ollama health + LanceDB connectivity | tester | Gate 1 | `health_check()` output, Ollama port 11434 reachable |
| S5 | Produce diagnostic artifacts: diagnostic.md, health_check.json, evidence-index.txt | documenter | Gate 2 | All claims with file:line or test refs |
| S6 | Gate 2: verify artifacts exist and match evidence | tester | Gate 2 | `[OVĚŘENO]` artifact validation |
| S7 | Gate 3: independent verification run | gate3-auditor | Gate 3 | PASS/FAIL/REJECT_UNVERIFIED verdict |

---

## Constraints

- D1-D10 from `.kilo/plans/CyberBrain26cil-031026-v2.md`
- Security chain: identity → policy → permission → approval → sandbox → audit, fail-closed
- No silent transitions; all findings marked `[OVĚŘENO]`, `[NÁVRH]`, `[HYPOTÉZA]`
- One orchestration path only (Kilo as sole orchestrator)
- All `declared_actions` must exist in `src/cyberbrain26/security_plane/actions.py:242-272` (`ACTION_SCOPE_REQUIREMENTS`)
- `owner_role` required on every delegated step; exactly one owner
- No source code modifications in this plan (read-only diagnostic)

---

## Declared Actions

| Action | Scope | Owner | Used In |
|--------|-------|-------|---------|
| read_file | READ_FILE | deep-research / security-auditor / tester / documenter | S2, S3 |
| execute_shell | SHELL | tester | S1, S4, S6, S7 |
| execute_git | GIT | deep-research | S2 |
| write_file | WRITE_FILE | documenter | S5 (markdown artifacts only) |
| access_network | NETWORK | tester | S4 (Ollama health check) |

All actions are verified against `ACTION_SCOPE_REQUIREMENTS` in `src/cyberbrain26/security_plane/actions.py:242-272`.

---

## Out of Scope

- Source code changes to `src/`, `tests/`, `.github/`, `.kilo/kilo.jsonc`, `pyproject.toml`
- Fixing discovered security gaps (F3+ work)
- Live model calls (would require EgressGate approval)
- Customer discovery (F5 blocker)

---

## Validation Criteria

| Gate | Criterion | How Verified |
|------|-----------|--------------|
| Gate 1 | All quality gates green | `pytest -q` + `ruff check` + `mypy` exit code 0 |
| Gate 1 | Security chain fail-closed | `ExecutionRefused` / `SecurityError` on missing approval |
| Gate 1 | Model gateway local-first | Ollama `health_check()` returns `healthy: true`, `prefer_local=true` |
| Gate 1 | Kilo config enforced | `subagent_depth: 1`, `bash: deny`, `task: deny`, MCP `enabled: false` |
| Gate 2 | Diagnostic artifacts exist | diagnostic.md, health_check.json, evidence-index.txt written |
| Gate 2 | Evidence completeness | Every `[OVĚŘENO]` claim has file:line or test reference |
| Gate 3 | Independent verification | `gate3-auditor` verdict PASS/FAIL/REJECT_UNVERIFIED |

---

## Next Step for Implementation-Capable Agent

This plan is implementation-ready. To execute, switch to an agent with `bash`/`edit` permissions (e.g., `implementer` or `tester`) and delegate steps S1–S7 per the delegation matrix in `.kilo/agent/orchestrator.md`.
