From 09930c59901c8d58ee0c900c1799aaa7920117ba Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Tue, 6 Oct 2026 23:13:28 +0800 Subject: [PATCH] fix(ml): provisioning writes user-local interscript-ml paths; secryst path kept as legacy fallback --- lib/interscript/ml/provisioning.rb | 14 ++++++++------ spec/stdlib_functions_spec.rb | 11 +++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/interscript/ml/provisioning.rb b/lib/interscript/ml/provisioning.rb index 3d7932a7..2c58bec8 100644 --- a/lib/interscript/ml/provisioning.rb +++ b/lib/interscript/ml/provisioning.rb @@ -27,12 +27,7 @@ def prepare_environment # we use it to store the Secryst data we need. Otherwise, we try the following # paths: - possible_paths = [ - "/var/lib/secryst", - "/usr/local/share/secryst", - "/usr/share/secryst", - File.join(Dir.home, ".local/share/secryst") - ] + possible_paths = candidate_paths # We find the first writable path to become the primary one. The remaining # ones will be used read-only if they exist @@ -95,6 +90,13 @@ def prepare_environment @preload_models.each { |i| locate(i) } end + def self.candidate_paths + [ + File.join(Dir.home, ".local/share/interscript-ml"), + File.join(Dir.home, ".local/share/secryst") # legacy fallback + ] + end + def locate(name) # Shortcut this if user gave a filename. return name if name =~ %r{[.\\/]} diff --git a/spec/stdlib_functions_spec.rb b/spec/stdlib_functions_spec.rb index fe732d59..5021c534 100644 --- a/spec/stdlib_functions_spec.rb +++ b/spec/stdlib_functions_spec.rb @@ -93,3 +93,14 @@ expect(described_class.name).to eq("Interscript::Stdlib::Functions::SecrystAdapter") end end + +RSpec.describe Interscript::ML::Provisioning do + describe "candidate paths" do + it "prefers interscript-ml locations, keeping secryst paths as legacy fallbacks" do + paths = described_class.candidate_paths + expect(paths.first).to eq(File.join(Dir.home, ".local/share/interscript-ml")) + expect(paths).to include(File.join(Dir.home, ".local/share/secryst")) + expect(paths.join(" ")).not_to match(%r{/var/lib/secryst}) + end + end +end