Files
memex/system/plans/flight-plan-recursive-kernel.org
Amr Gharbeia 4f34969224 rename: opencortex → passepartout across memex
- .gitmodules: update submodule paths (projects/opencortex → projects/passepartout,
  projects/opencortex-contrib → projects/passepartout-contrib)
- gtd.org, README.org: update project references and display names
- check.lisp, gemini-vision.org, agora/TODO.org: update file paths
- dotemacs: update agenda paths and template config
- system/plans/: update all flight plan references
- system/backups/: update monolithic backup references
2026-05-03 11:47:52 -04:00

1.9 KiB

## Objective Implement a recursive `cognitive-cycle` that allows the agent to chain multiple actions (tool calls) and observe results before finalising a response, similar to SOTA agents like Claude Code.

## Key Files & Context

  • `projects/passepartout/docs/README.org`: The primary source of truth for the kernel logic.
  • `projects/passepartout/src/core.lisp`: Tangled kernel implementation.
  • `projects/passepartout/src/symbolic.lisp`: Contains the `decide` logic.

## Implementation Steps

### 1. State & Interruption

  • Define `*interrupt-flag*` and `*interrupt-lock*` in the kernel state.
  • Update the `perceive` function to detect the `:interrupt` sensor stimulus and set the flag.

### 2. Recursive `cognitive-cycle`

  • Modify `cognitive-cycle` to accept an optional `depth` parameter (default 0).
  • Add a check at the beginning of the loop for `depth > 10` or `*interrupt-flag*`.
  • Refactor the loop to capture the return value of `dispatch-action`.
  • If the action was a "Tool Call" (any target except `:emacs` or `:system-message`) and produced a result, recursively call `cognitive-cycle` with a new `:EVENT` containing that result.

### 3. Actuator Harmonization

  • Ensure `execute-system-action` (for `:eval`) returns meaningful results that can be fed back into the loop.
  • Update `dispatch-action` to return the result of the actuator call.

### 4. Literate Tangle & Load

  • Apply these changes to the `README.org` document.
  • Tangle to update `.lisp` files.
  • Hot-load the updated code into the live image via Swank.

## Verification & Testing

  • Multi-turn Test: In the chat, ask the agent to "Calculate the sum of 5+5 and then multiply it by 2 using eval".
  • Introspection Check: Verify the `*opencortex-reasoning*` buffer shows the two distinct `eval` steps.
  • Interrupt Test: Trigger a long-running or recursive task and press `C-c C-k` in Emacs to verify the loop halts.