#+TITLE: Flight Plan: Hard Rollback & Verification
#+AUTHOR: Gemini CLI
#+DATE: 2026-04-01
#+FILETAGS: :psf:build:qa:rollback:
#+STARTUP: content

* Overview
Break the cycle of chaotic debugging by performing a hard Git rollback to the last known stable state of the `opencortex` repository, surgically applying the verified fixes, and executing the Model Discovery connection test one strict step at a time.

* Phase A: Purge & Reset (The Scientist)
** TODO 1. Hard Rollback
- Action: Execute `git reset --hard` and `git clean -fd` in `~/memex/projects/opencortex`.
- Verification: Directory is clean of untracked files and uncommitted changes.

** TODO 2. Nuke the Lisp Cache
- Action: Delete `~/.cache/common-lisp/` and `~/.local/share/opencortex/quicklisp/cache/`.
- Verification: The directories do not exist.

** TODO 3. Verify Environment
- Action: Read `~/.local/share/opencortex/.env`.
- Verification: Ensure `OPENROUTER_API_KEY` and `MEMEX_DIR` are correctly set without trailing quotes or comments.

* Phase B: Surgical Implementation (The Coder)
** TODO 4. Implement Dynamic Model Resolution
- Action: Surgically update `docs/README.org` to make `execute-openrouter-request` pull the `:LLM_MODEL_OPENROUTER` property.

** TODO 5. Implement Model Discovery API
- Action: Add `openrouter-get-available-models` to `docs/README.org` and export it in `package.lisp`.

** TODO 6. Implement Model Explorer Skill
- Action: Update `~/memex/notes/org-skill-model-explorer.org` with the trigger, table builder, and actuator logic. Ensure it is correctly registered.

* Phase C: Tangle & Build (The Tester)
** TODO 7. Tangle
- Action: Run `emacs --batch` to regenerate `src/*.lisp` from the `README.org`.
- Verification: Exit code 0.

** TODO 8. Compile
- Action: Run a clean compilation script.
- Verification: The binary is generated successfully.

* Phase D: Live Execution (The Sovereign)
** TODO 9. Foreground Boot Test
- Action: Start the `opencortex-server` daemon in the foreground for 10 seconds.
- Verification: Visually confirm that `org-skill-model-explorer` successfully jails and hot-loads.

** TODO 10. Live Model Discovery Test
- Action: Send `@agent list models` via an Emacs batch script.
- Verification: The daemon log shows the generated Org-mode table of OpenRouter models.