Skip to content

Memory: pasclaw memory provision + onboarding download hook#166

Merged
FMXExpress merged 1 commit into
mainfrom
claude/memory-vector-provision
Jun 7, 2026
Merged

Memory: pasclaw memory provision + onboarding download hook#166
FMXExpress merged 1 commit into
mainfrom
claude/memory-vector-provision

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

PR #165's PasClaw.Memory.Vector.Open() needs three artifacts under $PASCLAW_HOME/cache/localvector/ — sqlite-vec extension, ONNX Runtime, MiniLM model + vocab — before the hybrid backend will engage. Until now operators had to know to download those themselves. This PR closes that loop with one new command and an onboarding hook.

New command: src/cmd/PasClaw.Cmd.Memory.pas

Two subcommands:

pasclaw memory provision

Downloads sqlite-vec, ONNX Runtime, MiniLM model + vocab into $PASCLAW_HOME/cache/localvector/. Idempotent — re-running skips anything already present and redownloads anything suspiciously small (treated as a partial fetch by TModelDownloader, mirrors the localvector convention).

Calls the in-tree provisioning helpers that PR #165 brought in:

Helper What it fetches
LocalVector.VecProvision.EnsureVec0 sqlite-vec from asg017/sqlite-vec GitHub releases — cross-platform: linux / macos / windows × x86_64 / aarch64
LocalVector.OrtProvision.EnsureOnnxRuntime ONNX Runtime; auto-download is win-x64 only per CanAutoProvisionRuntime. Other platforms print install instructions for the system package manager.
LocalVector.Downloader.TModelDownloader MiniLM model.onnx (~90 MB) + vocab.txt from HuggingFace

Per-step status: green ✓ on success, red ✗ on failure, dim · for "platform doesn't support auto-download here". Final summary tells the operator whether the hybrid backend is ready or whether memory_search will still fall back to FTS. Exit code 0 on full success, 1 if any of the three steps failed.

pasclaw memory status

Read-only view: shows the active backend (hybrid when vector_search_enabled and artifacts present, else FTS-only), the cache directory, and a per-artifact ✓/· checklist mirroring what PasClaw.Memory.Vector.Open looks for. Useful for "did the provision actually take" diagnostics without running a real memory_search.

Onboarding hook

After the existing PromptVectorSearch question, when the operator said yes, ask once more: "Download now? [y/N]". Default NO because the artifacts are ~91 MB and an Enter-through-everything onboarding shouldn't trigger a fat download the user didn't opt into. Yes invokes Cmd_Memory_Run(['provision']) inline; No prints "deferred, run pasclaw memory provision when ready".

Dropped the now-stale "follow-up release downloads the model on first use" disclaimer from the prompt — that follow-up release is this PR.

Test plan

Verified end-to-end on Linux/FPC:

$ pasclaw memory status
  · sqlite-vec missing at .../vec0.so
  · all-MiniLM-L6-v2 model missing at .../model.onnx
  · vocab missing at .../vocab.txt

$ pasclaw memory provision
  ✓ sqlite-vec extension installed at .../vec0.so       (160 KB)
  · ONNX Runtime auto-download is win-x64 only on this build;
    install via your system package manager:
      Debian / Ubuntu:  apt install libonnxruntime-dev
      macOS (Homebrew): brew install onnxruntime
      Other Linux:      see https://onnxruntime.ai/docs/install/
  ✗ ONNX Runtime: Could not load onnxruntime. Put onnxruntime.so
    next to the executable or on the loader path.
    (install per the instructions above, then re-run
     `pasclaw memory provision`)
  ✓ embedding model all-MiniLM-L6-v2 (~90 MB) installed at .../models/...
  ! provisioning incomplete — memory_search will fall back to FTS-only

$ pasclaw memory status
  ✓ sqlite-vec at .../vec0.so
  ✓ all-MiniLM-L6-v2 model at .../model.onnx
  ✓ vocab at .../vocab.txt

$ NewVectorMemoryIndex.Open()  → returns False (ONNX missing → falls back
                                  to FTS-only as designed)
  • Real download of sqlite-vec (160 KB tar.gz extracted to vec0.so).
  • Real download of MiniLM model.onnx (90 MB) + vocab.txt (232 KB) from HuggingFace.
  • ONNX-Runtime-missing path prints install instructions cleanly and exits 1.
  • pasclaw memory status reports the post-provision state accurately.
  • PasClaw.Memory.Vector.Open() still returns False quietly when ONNX is missing — fallback to FTS works.
  • Full test suite green: smoke + hashline + toolview + anthropic-server-tools + openai-server-tools + println-helper + utf8-codepage-tag + gemini-schema-strip + markdown-render + json-utf8-roundtrip.
  • Live pasclaw memory provision on Windows-x64 to confirm the ONNX auto-download branch (didn't fire on the Linux test rig).
  • Live exercise of the hybrid memory_search path on a host with libonnxruntime installed system-wide — that's the full integration test which needs an environment we don't have in CI.

Stacks on top of

PR #165 (the in-tree localvector port). #165 must merge first.


Generated by Claude Code

PR #165's PasClaw.Memory.Vector landed but its Open() needs three
artifacts under $PASCLAW_HOME/cache/localvector/ — sqlite-vec
extension, ONNX Runtime, and the MiniLM model + vocab — before the
hybrid backend will engage. Operators had to know to download those
themselves. This PR closes that loop with one new command and an
onboarding hook.

New: src/cmd/PasClaw.Cmd.Memory.pas

  Two subcommands:

    pasclaw memory provision
      Downloads sqlite-vec, ONNX Runtime, MiniLM model + vocab into
      $PASCLAW_HOME/cache/localvector/.

      Idempotent — re-running skips anything already present and
      redownloads anything suspiciously small (treated as partial
      fetch by TModelDownloader, mirrors the localvector convention).

      Calls the in-tree provisioning helpers wired by PR #165:
        LocalVector.VecProvision.EnsureVec0      — sqlite-vec from
                                                   asg017/sqlite-vec
                                                   GitHub releases
                                                   (cross-platform —
                                                   linux/macos/windows
                                                   × x86_64/aarch64).
        LocalVector.OrtProvision.EnsureOnnxRuntime — ONNX Runtime;
                                                   auto-download is
                                                   win-x64 only per
                                                   CanAutoProvisionRuntime.
                                                   On other platforms
                                                   prints install
                                                   instructions for
                                                   the system package
                                                   manager.
        LocalVector.Downloader.TModelDownloader — MiniLM model.onnx
                                                   (~90 MB) + vocab.txt
                                                   from HuggingFace.

      Per-step status: green ✓ on success, red ✗ on failure, dim ·
      for "platform doesn't support auto-download here". Final
      summary tells the operator whether the hybrid backend is
      ready or whether memory_search will still fall back to FTS.

      Exit code 0 on full success, 1 if any of the three steps
      failed. ONNX Runtime missing on Linux/macOS is the expected
      partial-success case — that exits 1 with clear "install via
      apt/brew, then re-run" guidance.

    pasclaw memory status
      Read-only view: shows the active backend (hybrid when
      vector_search_enabled and artifacts present, else FTS-only),
      the cache directory, and a per-artifact ✓/· checklist mirroring
      what PasClaw.Memory.Vector.Open looks for. Useful for "did the
      provision actually take" diagnostics without running a real
      memory_search.

Onboarding hook: src/cmd/PasClaw.Cmd.Onboard.pas

  After the existing PromptVectorSearch question, when the operator
  said yes, ask once more: "Download now? [y/N]". Default NO because
  the artifacts are ~91 MB and an Enter-through-everything onboarding
  shouldn't trigger a fat download the user didn't opt into. Yes
  invokes Cmd_Memory_Run(['provision']) inline; No prints "deferred,
  run pasclaw memory provision when ready".

  Dropped the now-stale "follow-up release downloads the model on
  first use" disclaimer from the prompt — that follow-up release is
  this PR.

Root.pas:
  - Register 'memory' in the subcommand list (slot 20 — between
    update and version to mirror the implementation-order Sub[]
    array).
  - Wire Cmd_Memory_Run into DispatchCommand.

Verified end-to-end on Linux/FPC:

  $ pasclaw memory status
    config setting: hybrid (when artifacts present) else FTS-only
    cache dir:      /root/.pasclaw/cache/localvector
    · sqlite-vec missing at .../vec0.so
    · all-MiniLM-L6-v2 model missing at .../model.onnx
    · vocab missing at .../vocab.txt

  $ pasclaw memory provision
    ✓ sqlite-vec extension installed at .../vec0.so
    · ONNX Runtime auto-download is win-x64 only on this build;
      install via your system package manager:
        Debian / Ubuntu:  apt install libonnxruntime-dev
        macOS (Homebrew): brew install onnxruntime
        Other Linux:      see https://onnxruntime.ai/docs/install/
    ✗ ONNX Runtime: Could not load onnxruntime. Put onnxruntime.so
      next to the executable or on the loader path.
      (install per the instructions above, then re-run
       `pasclaw memory provision`)
    ✓ embedding model all-MiniLM-L6-v2 (~90 MB) installed at .../models/...
    ! provisioning incomplete — memory_search will fall back to FTS-only

  $ pasclaw memory status
    ✓ sqlite-vec at .../vec0.so
    ✓ all-MiniLM-L6-v2 model at .../model.onnx
    ✓ vocab at .../vocab.txt
    (ONNX Runtime not shown because the status checklist mirrors
    the on-disk artifacts; the ONNX runtime is loadable-only, not
    a file we can stat.)

  $ ls -la $PASCLAW_HOME/cache/localvector/
    vec0.so                                160 KB
    models/all-MiniLM-L6-v2/model.onnx     90 MB
    models/all-MiniLM-L6-v2/vocab.txt      232 KB

  $ NewVectorMemoryIndex.Open() — returns False (ONNX missing →
    falls back to FTS as designed; with libonnxruntime-dev
    installed it'd return True and the hybrid path would activate
    on the next memory_search).

Full test suite green: smoke + hashline + toolview +
anthropic-server-tools + openai-server-tools + println-helper +
utf8-codepage-tag + gemini-schema-strip + markdown-render +
json-utf8-roundtrip.

Stacks on top of PR #165 (the in-tree localvector port). #165
must merge first.
@FMXExpress FMXExpress merged commit ecd110d into main Jun 7, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71f37eeff0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +273 to +277
PrintLn(Ansi.Bold + 'memory_search backend' + Ansi.Reset);
PrintLn(' config setting: ' + Active);
PrintLn(' cache dir: ' + CacheDir);
PrintLn;
PrintLn(Ansi.Bold + 'Runtime artifacts' + Ansi.Reset);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report ONNX availability in memory status

When pasclaw memory status runs on a host that has vec0 and the model/vocab files but no loadable ONNX Runtime (common on Linux/macOS, where this command does not auto-download it), this checklist prints every listed artifact as present even though TVectorMemoryIndex.Open still calls EnsureOnnxRuntime(..., False, ...) before enabling the hybrid backend. That makes the diagnostic say the provision “took” while memory_search will continue falling back to FTS-only; include an ONNX/cache-or-loader check here so status mirrors the actual backend gate.

Useful? React with 👍 / 👎.

FMXExpress pushed a commit that referenced this pull request Jun 7, 2026
Codex flagged that `pasclaw memory status` was lying when artifacts
were partially provisioned: with vec0 + model + vocab on disk but no
loadable ONNX Runtime (the common Linux/macOS state, since
auto-download is win-x64 only), every checklist row went green even
though TVectorMemoryIndex.Open() would still fail at the
EnsureOnnxRuntime call and memory_search would keep falling back to
FTS-only. The diagnostic said "provision took"; the runtime said
otherwise.

Fix: run the same EnsureOnnxRuntime check the backend gate uses
(AllowDownload=False so status stays read-only), and surface a fourth
checklist row with the result. On failure, when CanAutoProvisionRuntime
is False (Linux/macOS today), also print the system-package install
instructions in dim text so the operator knows the path forward
without having to re-run `pasclaw memory provision` just to see them.

Status output now matches PasClaw.Memory.Vector.Open's actual decision
exactly: green ✓ on every row → hybrid backend will engage on the
next memory_search; any row · → it'll fall back to FTS-only.

Verified by synthesising the exact partial-provision scenario Codex
described (touch the three artifact files so they exist, leave ONNX
unprovisioned):

  $ pasclaw memory status
    ✓ sqlite-vec at .../vec0.so
    ✓ all-MiniLM-L6-v2 model at .../model.onnx
    ✓ vocab at .../vocab.txt
    · ONNX Runtime not loadable — Could not load onnxruntime. Put
      onnxruntime.so next to the executable or on the loader path.
      auto-download is win-x64 only on this build; install via:
        Debian / Ubuntu:  apt install libonnxruntime-dev
        macOS (Homebrew): brew install onnxruntime
        Other Linux:      see https://onnxruntime.ai/docs/install/

Same scenario pre-fix showed all three files as ✓ and zero signal
that the hybrid backend wouldn't engage.

Full test suite green: smoke + hashline + toolview +
anthropic-server-tools + openai-server-tools + println-helper +
utf8-codepage-tag + gemini-schema-strip + markdown-render +
json-utf8-roundtrip.

Landed on PR #167 (the dproj fix branch) per maintainer routing —
this commit lives alongside the dproj edits since PR #166 already
went up for review.
FMXExpress added a commit that referenced this pull request Jun 7, 2026
Delphi dproj + PR #166 review fix (status checks ONNX Runtime)
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.

2 participants