caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

79 lines
2.1 KiB
Go

package fix
import (
"os"
"path/filepath"
"testing"
"time"
)
func TestStaleLockFiles(t *testing.T) {
t.Run("no beads dir", func(t *testing.T) {
tmpDir := t.TempDir()
if err := StaleLockFiles(tmpDir); err != nil {
t.Errorf("expected no error for missing .beads dir, got %v", err)
}
})
t.Run("no lock files", func(t *testing.T) {
tmpDir := t.TempDir()
if err := os.MkdirAll(filepath.Join(tmpDir, ".beads"), 0755); err != nil {
t.Fatal(err)
}
if err := StaleLockFiles(tmpDir); err != nil {
t.Errorf("expected no error for empty .beads dir, got %v", err)
}
})
t.Run("stale bootstrap lock still removed", func(t *testing.T) {
// Verify we didn't break existing cleanup
tmpDir := t.TempDir()
beadsDir := filepath.Join(tmpDir, ".beads")
if err := os.MkdirAll(beadsDir, 0755); err != nil {
t.Fatal(err)
}
lockPath := filepath.Join(beadsDir, "dolt.bootstrap.lock")
if err := os.WriteFile(lockPath, []byte("lock"), 0600); err != nil {
t.Fatal(err)
}
oldTime := time.Now().Add(-10 * time.Minute)
if err := os.Chtimes(lockPath, oldTime, oldTime); err != nil {
t.Fatal(err)
}
if err := StaleLockFiles(tmpDir); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, err := os.Stat(lockPath); !os.IsNotExist(err) {
t.Error("stale bootstrap lock should be removed")
}
})
t.Run("shared worktree stale lock is removed from shared beads dir", func(t *testing.T) {
mainRepoDir, worktreeDir := setupSharedWorktreeWorkspace(t)
sharedBeadsDir := filepath.Join(mainRepoDir, ".beads")
if err := os.MkdirAll(sharedBeadsDir, 0o755); err != nil {
t.Fatal(err)
}
lockPath := filepath.Join(sharedBeadsDir, "dolt.bootstrap.lock")
if err := os.WriteFile(lockPath, []byte("lock"), 0o600); err != nil {
t.Fatal(err)
}
oldTime := time.Now().Add(-10 * time.Minute)
if err := os.Chtimes(lockPath, oldTime, oldTime); err != nil {
t.Fatal(err)
}
if err := StaleLockFiles(worktreeDir); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if _, err := os.Stat(lockPath); !os.IsNotExist(err) {
t.Error("shared stale bootstrap lock should be removed")
}
})
}