# Implementation Plan: The Micro-Loader (Boot Sequence Refactor) ## Objective Consolidate and harden the kernel's skill-loading logic into a stateful "Micro-Loader." This improves boot reliability, provides clear error reporting for malformed skills, and centralizes all capability management within the `skills` module. ## Key Files & Context - **Target:** `projects/org-agent/literate/skills.org` (Consolidating logic here). - **Target:** `projects/org-agent/literate/core.org` (Moving `load-all-skills` out of here). - **Mandate:** Syntax Pre-flight and Dependency Assertion. ## Implementation Steps ### 1. Define the Skill Catalog - Introduce `*skill-catalog*` in `skills.lisp` to track metadata and load status for every skill file found in `SKILLS_DIR`. - Statuses: `:discovered`, `:loading`, `:ready`, `:failed`. ### 2. Refactor `load-skill-from-org` (Harden) - **Syntax Check:** Invoke `validate-lisp-syntax` before evaluation. - **Dependency Check:** If `#+DEPENDS_ON` refers to a skill that failed or is missing, mark this skill as `:failed` immediately with a clear error. - **Detailed Logging:** Record the specific reason for failure (syntax, timeout, runtime error) in the catalog. ### 3. Implement `initialize-all-skills` (The Orchestrator) - Move the directory scanning and loop logic from `core.lisp` into `skills.lisp`. - This function will: 1. Scan `SKILLS_DIR`. 2. Populate the catalog. 3. Run the topological sort. 4. Execute the load loop with timeouts. 5. Print a final "Boot Summary" report. ### 4. Simplify Kernel Boot - Update `start-daemon` in `core.lisp` to call `(initialize-all-skills)` instead of the old `load-all-skills`. ## Phase E: Chaos (Verification) - **Integrity Test:** Add a test that verifies `initialize-all-skills` correctly identifies a missing dependency and prevents the dependent skill from attempting to load. - **Report Test:** Verify that the skill catalog correctly reflects the status of loaded vs. failed skills.