mirror of
https://github.com/mudler/LocalAI.git
synced 2026-09-12 22:33:54 -04:00
* docs: design configurable copy buffering Document the context-aware copy buffer option and its validation plan. Assisted-by: Codex:gpt-5 * docs: design durable distributed staging operations Assisted-by: Codex:gpt-5 * docs: design distributed model config revisions Assisted-by: Codex:GPT-5 [apply_patch] [exec_command] * feat(config): add stable model revisions Hash typed model configuration and effective protobuf options deterministically for distributed revision comparisons. Assisted-by: Codex:GPT-5 [apply_patch] [exec_command] * feat(worker): acknowledge exact model stops Assisted-by: Codex:GPT-5 [apply_patch] [exec_command] * feat(nodes): track model config revisions Assisted-by: Codex:GPT-5 [apply_patch] * fix(distributed): retry quarantined model cleanup Stop quarantined replicas by exact process identity, retain failed cleanup as durable capped retries, and compare-and-delete only the claimed registry row. Process one sufficiently leased row at a time so multiple frontends cannot duplicate slow cleanup work. Assisted-by: Codex:gpt-5 * fix(distributed): bind loads to config revisions Assisted-by: Codex: GPT-5 [OpenAI Codex] * fix(modeladmin): apply config revisions consistently Route model edits, patches, state changes, deletion, and peer refreshes through the same revision lifecycle. Quarantine stale replicas before exact cleanup and report durable pending cleanup without failing successful config writes. Assisted-by: Codex: GPT-5 [OpenAI Codex] * feat(distributed): expose model config revision state Document replica revision observability and durable cleanup behavior. Keep pending cleanup explicit in model mutation responses and verify endpoint contracts expose revision state without serialized load options. Assisted-by: Codex:GPT-5 [OpenAI Codex] * test(distributed): cover model revision convergence Exercise cross-frontend quarantine, stale replay rejection, exact cleanup retry, worker re-registration, and current-generation replica convergence against the distributed PostgreSQL harness. Assisted-by: Codex:gpt-5 * fix(distributed): pass config revision CI checks Keep configured gallery sources out of authoritative runtime snapshots only after validating their real schema, and harden rollback snapshots against symlink races and non-regular files. Assisted-by: Codex: GPT-5 [OpenAI Codex] --------- Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package safefile_test
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
|
|
"github.com/mudler/LocalAI/pkg/safefile"
|
|
)
|
|
|
|
var _ = Describe("ReadRegularAt", func() {
|
|
It("reads a regular direct child", func() {
|
|
dir := GinkgoT().TempDir()
|
|
Expect(os.WriteFile(filepath.Join(dir, "model.yaml"), []byte("safe"), 0o640)).To(Succeed())
|
|
data, mode, err := safefile.ReadRegularAt(dir, "model.yaml")
|
|
Expect(err).NotTo(HaveOccurred())
|
|
Expect(data).To(Equal([]byte("safe")))
|
|
Expect(mode).To(Equal(os.FileMode(0o640)))
|
|
})
|
|
|
|
It("rejects symbolic links", func() {
|
|
dir := GinkgoT().TempDir()
|
|
target := filepath.Join(dir, "target")
|
|
Expect(os.WriteFile(target, []byte("secret"), 0o600)).To(Succeed())
|
|
Expect(os.Symlink(target, filepath.Join(dir, "model.yaml"))).To(Succeed())
|
|
_, _, err := safefile.ReadRegularAt(dir, "model.yaml")
|
|
Expect(err).To(HaveOccurred())
|
|
})
|
|
|
|
It("rejects non-regular files without reading them", func() {
|
|
dir := GinkgoT().TempDir()
|
|
Expect(os.Mkdir(filepath.Join(dir, "model.yaml"), 0o700)).To(Succeed())
|
|
_, _, err := safefile.ReadRegularAt(dir, "model.yaml")
|
|
Expect(err).To(MatchError(ContainSubstring("not a regular file")))
|
|
})
|
|
})
|