# Plan: MASTER ROADMAP Final V4.1.1 Alignment + Gate 1 Stabilization

## Context
- Authoritative baseline: `CyberBrain26_master_roadmapv4-1-1.md` (MASTER ROADMAP Final V4.1.1, ~21 phases, ~2349 lines). Supersedes ROADMAP_V5/V6/V7 and earlier plan copies; ROADMAP_V8.md never existed.
- Prior execution plan: `/home/oem/CyberBrain26-unified/.kilo/plans/1793833697348-phase5-7-plan.md` (Phase 5–7 Steps 5–7).
- User mandate (2026-11-05): current work must be in line with MASTER ROADMAP Final V4.1.1.

## Current state (as of 2026-11-05)
- Phase 5 (Model Layer): mostly implemented (`provider_interface.py` with `ProviderABC`/`ProviderProtocol`, LiteLLM/Ollama/llama_cpp clients inherit `ProviderABC`).
- Phase 6 (Agent Layer): partially integrated (`agents/orchestrator.py` has `BaseAgent`, planner/coder/evaluator/security/research/browser agents, fail-closed bus-authorizer wiring; LangGraph integration explicitly deferred by decision D2).
- Phase 7 (Execution Layer): partially implemented (`execution_backends.py` + `bubblewrap_provider.py` + `secure_gateway.py`).
- Gate 1 is RED and must be green before any `src/` change.

## Gate 1 failure matrix
- pytest: 1 failed, 862 passed, 2 skipped — failure in `tests/test_plan_authority.py:106` (AGENTS.md must contain the literal `tests/test_plan_authority.py` marker; also must not contain stray `NEEXISTUJE` before the first occurrence).
- ruff: 236 errors; 90 auto-fixable via `ruff check --fix .`.
- mypy: 21 errors in 9 files; ~14 error lines across 6 files needing manual fixes.

## Decisions
1. Scope: stabilize Gate 1, then complete Steps 5–7 from the Phase 5–7 plan. Full roadmap-wide alignment refactor deferred past this plan.
2. Gate order: Gate 1 (pytest + ruff + mypy) green before any `src/` change; then Phase completion; then Gate 2.
3. mypy cannot be auto-fixed via CLI; manual edits at flagged locations required.
4. AGENTS.md must contain `tests/test_plan_authority.py` and must not carry the `NEEXISTUJE` marker in the post-first-occurrence window.

## Implementation task list (implementation agent)
1. Repair AGENTS.md plan-authority marker so `tests/test_plan_authority.py` passes.
2. Run `ruff check --fix .` at repo root; confirm `ruff check .` → 0 errors.
3. Manually patch mypy errors at:
   - `src/cyberbrain26/memory/core.py` (9)
   - `src/cyberbrain26/services/safe_oi/app.py` (2)
   - `src/cyberbrain26/knowledge_plane/batch_processor.py` (1)
   - `src/cyberbrain26/memory/auto.py` (1)
   - `src/cyberbrain26/knowledge_plane/markdown_store.py` (1)
   - `src/cyberbrain26/services/safe_oi/web_search.py` (1)
4. Run Gate 1: `pytest -q`, `ruff check .`, `mypy src/cyberbrain26` → all green.
5. Resume Phase 5–7 step execution per `1793833697348-phase5-7-plan.md`.

## Risks
- Changes to `src/`, `tests/`, `.github/`, `.kilo/kilo.jsonc`, `pyproject.toml` require owner approval (AGENTS.md).
- Execution-capable agent needed for ruff/mypy fixes; bash/edit write scopes differ by agent.

## Validation plan
- `pytest -q` → green
- `ruff check .` → green
- `mypy src/cyberbrain26` → green
- Receipt: `file:line` + verifying command (e.g. `ruff check .`).

## Open question
1. Should this pass stop at Gate 1 stabilization, or immediately proceed into Phase 5–7 completion afterward?
