Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
04be3e1
feat(memory): durable note store and memory tools
gnanam1990 Aug 12, 2026
526eece
fix(memory): the description cap is linear, and it runs where the des…
gnanam1990 Aug 16, 2026
b96704d
test(memory): pin the extension rule, the resolved scope, and partial…
gnanam1990 Aug 16, 2026
e504dd9
fix(memory): refuse a link at any store ancestor, and fail closed on …
gnanam1990 Aug 16, 2026
89913d3
test(memory): exercise the ancestor guard against a Windows junction
gnanam1990 Aug 16, 2026
9adc2e8
fix(memory): the ignore gate follows git's rules, and refuses a linke…
gnanam1990 Aug 16, 2026
d9fb9b7
test(memory): assert that a linked ignore is refused, not which error…
gnanam1990 Aug 16, 2026
c3e5a5c
fix(memory): a refused ancestor is reported as a refusal, not as an e…
gnanam1990 Aug 17, 2026
32193ae
fix(memory): decide refusal on what the handle can OPEN, not on what …
gnanam1990 Aug 18, 2026
75df084
test(memory): close the probe handle that turned the Windows skip int…
gnanam1990 Aug 18, 2026
5e2c2a8
fix(memory): make the unscoped round trip return what it wrote, and s…
gnanam1990 Aug 19, 2026
e9167a3
fix(memory): one resolution order, a named listing order, and each se…
gnanam1990 Aug 20, 2026
150d8cf
fix(memory): the delete door takes the clash guard the other two alre…
gnanam1990 Aug 20, 2026
00f0c0d
fix(memory): the index decides whether a local note is private, not t…
gnanam1990 Aug 24, 2026
848ae55
fix(memory): resolve linked workspaces by handle
gnanam1990 Sep 9, 2026
3acc071
fix(memory): distinguish inert git markers from repository metadata
gnanam1990 Sep 12, 2026
f083871
fix(memory): recover failed ignore installation
gnanam1990 Sep 12, 2026
5c1defc
fix(memory): remove ignore after close failure
gnanam1990 Sep 12, 2026
0724b52
fix(memory): report ignore cleanup failures
gnanam1990 Sep 12, 2026
664d560
fix(memory): refuse deletion after read failure
gnanam1990 Sep 12, 2026
21caeb0
test(memory): exercise native link and document parsing paths
gnanam1990 Sep 14, 2026
0433cbf
fix(tools): lead a failed memory listing with the failure, not empty-…
gnanam1990 Sep 21, 2026
bcdab8f
fix(memory): bind privacy checks to enclosing indexes and report link…
Nov 13, 2026
d3f5d9c
fix(memory): sync notes before publish, isolate git fixtures, surface…
jatmn Nov 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,162 changes: 1,162 additions & 0 deletions internal/memory/escape_test.go

Large diffs are not rendered by default.

1,215 changes: 1,215 additions & 0 deletions internal/memory/memory.go

Large diffs are not rendered by default.

532 changes: 532 additions & 0 deletions internal/memory/memory_test.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions internal/memory/physical_path_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//go:build !windows

package memory

import (
"os"
"path/filepath"
)

func resolvePhysicalPath(_ *os.Root, _ string, path string) (string, error) {
return filepath.EvalSymlinks(path)
}
48 changes: 48 additions & 0 deletions internal/memory/physical_path_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//go:build windows

package memory

import (
"fmt"
"os"
"path/filepath"
"strings"

"golang.org/x/sys/windows"
)

// resolvePhysicalPath asks the opened directory handle for its final DOS path.
// filepath.EvalSymlinks cannot resolve children beneath a directory junction on
// Windows even though ordinary opens and git's working-directory discovery can.
func resolvePhysicalPath(handle *os.Root, relative, _ string) (string, error) {
dir, err := handle.Open(relative)
if err != nil {
return "", err
}
defer dir.Close()

const maxPathUTF16 = 32768
size := uint32(260)
for size <= maxPathUTF16 {
buffer := make([]uint16, size)
n, err := windows.GetFinalPathNameByHandle(windows.Handle(dir.Fd()), &buffer[0], size, 0)
if err != nil {
return "", err
}
if n < size {
resolved := windows.UTF16ToString(buffer[:n])
switch {
case strings.HasPrefix(resolved, `\\?\UNC\`):
resolved = `\\` + strings.TrimPrefix(resolved, `\\?\UNC\`)
case strings.HasPrefix(resolved, `\\?\`):
resolved = strings.TrimPrefix(resolved, `\\?\`)
}
return filepath.Clean(resolved), nil
}
if n >= maxPathUTF16 {
break
}
size = n + 1
}
return "", fmt.Errorf("resolved path exceeds the Windows path limit")
}
71 changes: 71 additions & 0 deletions internal/memory/privacy_review_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package memory

import (
"errors"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
)

func TestNestedRepositoryCannotHideOuterTrackedLocalNote(t *testing.T) {
for _, atStore := range []bool{false, true} {
t.Run(map[bool]string{false: "ancestor", true: "store"}[atStore], func(t *testing.T) {
root := t.TempDir()
paths := DefaultPaths(root)
const original = "---\nname: private\n---\n\noriginal\n"
p := writeStoreFile(t, paths, "private.md", original)
writeStoreFile(t, paths, gitignoreName, localIgnoreContent)
seedStoreRepo(t, root)
runStoreGit(t, root, "add", "-f", ".zero/memory/local/private.md")
runStoreGit(t, root, "commit", "-m", "track local note")
nested := filepath.Dir(paths.LocalDir)
if atStore {
nested = paths.LocalDir
}
runStoreGit(t, nested, "init")
if _, err := Write(paths, ScopeLocal, "private", "d", "secret"); !errors.Is(err, ErrNotPrivate) {
t.Fatalf("outer index bypass: %v", err)
}
body, err := os.ReadFile(p)
if err != nil || string(body) != original {
t.Fatalf("tracked body changed: %q, %v", body, err)
}
})
}
}

func TestMixedCaseGitIndexRedirectCannotHideLocalNote(t *testing.T) {
if runtime.GOOS != "windows" {
t.Skip("environment keys fold case on Windows")
}
for _, key := range []string{"git_index_file", "Git_Index_File"} {
t.Run(key, func(t *testing.T) {
root := t.TempDir()
paths := DefaultPaths(root)
writeStoreFile(t, paths, "private.md", "---\nname: private\n---\n\noriginal\n")
seedStoreRepo(t, root)
runStoreGit(t, root, "add", ".zero/memory/local/private.md")
runStoreGit(t, root, "commit", "-m", "track local note")
t.Setenv(key, filepath.Join(t.TempDir(), "empty.index"))
if _, err := Write(paths, ScopeLocal, "private", "d", "secret"); !errors.Is(err, ErrNotPrivate) {
t.Fatalf("%s bypass: %v", key, err)
}
})
}
}

func TestGitDiscoveryEnvironmentUsesPlatformKeySemantics(t *testing.T) {
input := []string{"GIT_DIR=elsewhere", "git_index_file=empty", "Git_Work_Tree=other", "UNCHANGED=value"}
got := strings.Join(gitDiscoveryEnv(input), "\n")
if strings.Contains(got, "GIT_DIR=") {
t.Fatal("uppercase redirect kept")
}
if runtime.GOOS == "windows" && strings.Contains(strings.ToUpper(got), "GIT_") {
t.Fatalf("Windows redirect kept: %s", got)
}
if runtime.GOOS != "windows" && !strings.Contains(got, "git_index_file=empty") {
t.Fatal("case-sensitive environment key removed")
}
}
Loading
Loading