Skip to content

AI feature: automated feasibility check between designing and building an experiment - #283

Open
jdpigeon wants to merge 2 commits into
mainfrom
feat/feasibility-coach
Open

jdpigeon wants to merge 2 commits into
mainfrom
feat/feasibility-coach

Conversation

@jdpigeon

Copy link
Copy Markdown
Contributor

A "computational thinking in the age of AI" prototype for custom experiments.

Flow

  1. Design: Overview (question / hypothesis / methods), Conditions (names + keys), Trials (counts + order), Parameters. Each step has a Next → button; Parameters ends with Check feasibility →.
  2. Feasibility Analysis: a blocking modal (no Escape, outside click, or ✕). The buttons unlock when the local model finishes. Revise my design returns to editing; Continue is the only way through, and it is always offered, so the student is never hard-blocked.
  3. Build: Stimuli (image/sound folders + trial list, new step), Instructions, Preview.

Entering any build step with a design that changed since the last passed check reopens the modal. A green / yellow / red verdict chip in the design nav shows while the passed check still matches the design. It is saved with the workspace (params.feasibilityCheckedPrompt) and disappears on any edit that changes the analysis.

How it works

  • Rules decide (src/renderer/utils/feasibility/rules.ts): keyword rules (most limiting wins) plus pitfalls (trials per condition, session length, movement, missing hypothesis). They are meant for advisor review.
  • A small local model phrases it: Qwen3-4B-Instruct-2507 or Qwen3.5-2B (Q4_K_M GGUF, Apache-2.0), picked by RAM, with thinking off and a 200-token cap. With no model installed, the modal uses the rules' own wording.
  • Process model: node-llama-cpp runs in an Electron utilityProcess (src/main/llm), forked lazily and killed on quit, behind llm:generate / llm:abort / llm:event. The worker is bundled via electron-vite ?modulePath.
  • Trial counts are planned up front. balanceStimuliByCondition already samples ceil(nbTrials / conditions) per condition, so folder picks no longer overwrite counts (countPhases removed). Custom defaults are now 100 experimental / 10 practice.

Full design notes: docs/feasibility-coach.md. Background research on local models: Running a Local LLM (MiMo) Inside Brainwaves (Electron).md (MiMo was dropped as too slow for lab PCs).

Try it

Models are not bundled or downloaded by the app yet. Install one by hand:

cd ~/Library/Application\ Support/BrainWaves/models   # mkdir -p first
curl -L -C - -O https://huggingface.co/bartowski/Qwen_Qwen3-4B-Instruct-2507-GGUF/resolve/main/Qwen_Qwen3-4B-Instruct-2507-Q4_K_M.gguf

Verification

  • npm test: 59 files, 317 passed. npm run typecheck is clean.
  • New tests cover rule precedence and thresholds, the RAM-based model pick, the gate (disabled until the model finishes; Revise doesn't pass; an unchanged design isn't re-asked), and the chip lifecycle across reopening.
  • Clicked through in the Electron window over CDP: design steps, blocking modal (~5 s to the first answer with the 4B model on an M4 Pro), Continue into Stimuli, the chip appearing, and the chip disappearing plus the gate reopening after a trial-count edit.

Not done

  • In-app model download (progress / resume / checksum).
  • Benchmark on a real 4-core, 8 GB lab PC; only Apple Silicon has been run.
  • Windows / Linux verification of the node-llama-cpp prebuilts (they are in asarUnpack).

@jdpigeon

Copy link
Copy Markdown
Contributor Author
Screenshot 2026-09-27 at 1 54 17 PM
Screen.Recording.2026-09-27.at.1.50.40.PM.mov

@jdpigeon

Copy link
Copy Markdown
Contributor Author

@alexandrebarachant !

@jdpigeon jdpigeon changed the title feat(custom): feasibility check between designing and building an experiment AI feature: automated feasibility check between designing and building an experiment Sep 29, 2026
…eriment

Custom experiments now run in two phases. Students design first (question,
hypothesis, conditions, trial counts, parameters), then pass a blocking
Feasibility Analysis, then gather stimuli and preview. The student is never
hard-blocked: Continue is always offered once the analysis has finished.

- Rules (utils/feasibility/rules.ts) make the call: a green/yellow/red verdict
  plus pitfalls. A small local model (Qwen3 4B / Qwen3.5 2B GGUF) only phrases
  it and falls back to the rules' own words if it is unavailable.
- The model runs in an Electron utilityProcess (src/main/llm) behind llm:*
  IPC, forked lazily, and uses the best tier the machine's RAM can hold.
- A verdict chip in the design nav shows while the checked design still
  matches the current one; the check is saved as feasibilityCheckedPrompt.
- Trial counts are planned before any folder is chosen; picking folders no
  longer overwrites them (countPhases removed). Custom defaults are 100/10.
- The new Stimuli step holds the condition folders and trial list.

See docs/feasibility-coach.md.
@jdpigeon
jdpigeon force-pushed the feat/feasibility-coach branch from 0b3e0a4 to ee03d60 Compare October 7, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant