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

63 lines
1.6 KiB
Go

package testutil
import (
"os"
"path/filepath"
"runtime"
"testing"
)
// TempDirInMemory creates a temporary directory that preferentially uses
// in-memory filesystems (tmpfs/ramdisk) when available. This reduces I/O
// overhead for git-heavy tests.
//
// On Linux: Uses /dev/shm if available (tmpfs ramdisk)
// On macOS: Falls back to standard temp (ramdisks require manual setup)
// On Windows: Falls back to standard temp
//
// The directory is automatically cleaned up when the test ends.
func TempDirInMemory(t testing.TB) string {
t.Helper()
var baseDir string
switch runtime.GOOS {
case "linux":
// Try /dev/shm (tmpfs ramdisk) first
if stat, err := os.Stat("/dev/shm"); err == nil && stat.IsDir() {
// Create subdirectory with proper permissions
tmpBase := filepath.Join("/dev/shm", "beads-test")
if err := os.MkdirAll(tmpBase, 0755); err == nil {
baseDir = tmpBase
}
}
case "darwin":
// macOS: /tmp might already be on APFS with fast I/O
// Creating a ramdisk requires sudo, so we rely on system defaults
// Users can manually mount /tmp as tmpfs if needed:
// diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://2048000`
baseDir = os.TempDir()
default:
// Windows and others: use standard temp
baseDir = os.TempDir()
}
// If we didn't set baseDir (e.g., /dev/shm unavailable), use default
if baseDir == "" {
baseDir = os.TempDir()
}
// Create unique temp directory
tmpDir, err := os.MkdirTemp(baseDir, "beads-test-*")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
// Register cleanup
t.Cleanup(func() {
_ = os.RemoveAll(tmpDir)
})
return tmpDir
}