#+TITLE: Flight Plan: Verified Clean Build & LLM Test
#+AUTHOR: Gemini CLI
#+DATE: 2026-04-01
#+FILETAGS: :psf:build:qa:
#+STARTUP: content

* Overview
This flight plan defines the strict, step-by-step protocol for escaping the Lisp caching trap, properly tangling the literate source, and verifying the live OpenRouter connection. 

*Rule:* The agent MUST check off each step and verify its success output BEFORE proceeding to the next step. No chained commands.

* Phase A: Purge & Verify (The Scientist)
** DONE 1. Nuke the Lisp Cache
- Action: Delete =~/.cache/common-lisp/= to destroy all stale =.fasl= binaries.
- Verification: The directory must not exist.
- Result: *SUCCESS: Cache purged.*

** DONE 2. Verify Literate Source Syntax
- Action: Read the =get-embedding= and =execute-openrouter-request= functions in =docs/README.org=.
- Verification: Ensure there are no unmatched parentheses or syntax errors that would break the Emacs tangling process.
- Result: *SUCCESS: Syntax verified (no unmatched parentheses found).*

* Phase B: Tangle & Audit (The Coder)
** TODO 3. Tangle the Literate Source
- Action: Run =emacs --batch --eval '(require (quote ob-tangle))' --eval '(org-babel-tangle-file "~/memex/projects/opencortex/docs/README.org")'=
- Verification: The command must exit with code 0 and report that blocks were tangled.

** TODO 4. Audit the Physical Lisp Files
- Action: Read =src/embedding.lisp= and =src/core.lisp=.
- Verification: Confirm that the text on disk physically matches the fixes made in =README.org= (e.g., =get-embedding= is correct, =start-daemon= skips whitespace).

* Phase C: Quality Gate (The Tester)
** TODO 5. Run the Lisp Test Suite
- Action: Execute =sbcl --non-interactive --eval "(asdf:test-system :opencortex)"=
- Verification: All 13 cognitive tests must pass. If any fail, STOP and return to Phase A.

** TODO 6. Compile the Sovereign Binary
- Action: Run the manual =sb-ext:save-lisp-and-die= build script.
- Verification: The binary is generated without fatal compiler errors.

* Phase D: Live Execution (The Sovereign)
** TODO 7. Clean Restart
- Action: Kill all stale =opencortex-server= processes and start the new binary in the background.
- Verification: The log shows =opencortex Kernel Booted Successfully= and =Daemon Listening=.

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