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>
89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
//go:build integration && !windows
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Diagnostics captures state information for debugging test failures.
|
|
type Diagnostics struct {
|
|
t *testing.T
|
|
beadsDir string
|
|
}
|
|
|
|
// NewDiagnostics creates a diagnostics collector for the given .beads directory.
|
|
func NewDiagnostics(t *testing.T, beadsDir string) *Diagnostics {
|
|
return &Diagnostics{t: t, beadsDir: beadsDir}
|
|
}
|
|
|
|
// CaptureOnFailure registers a t.Cleanup that dumps diagnostic info if the
|
|
// test has failed. Call early in the test setup.
|
|
func (d *Diagnostics) CaptureOnFailure() {
|
|
d.t.Helper()
|
|
d.t.Cleanup(func() {
|
|
if !d.t.Failed() {
|
|
return
|
|
}
|
|
d.t.Log("=== DIAGNOSTICS (test failed) ===")
|
|
d.dumpStateFiles()
|
|
d.dumpProcessList()
|
|
})
|
|
}
|
|
|
|
// dumpStateFiles logs the content of PID and port files if they exist.
|
|
func (d *Diagnostics) dumpStateFiles() {
|
|
for _, name := range []string{"dolt-server.pid", "dolt-server.port", "dolt-server.log"} {
|
|
path := filepath.Join(d.beadsDir, name)
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
d.t.Logf(" %s: not found", name)
|
|
continue
|
|
}
|
|
content := strings.TrimSpace(string(data))
|
|
if len(content) > 500 {
|
|
content = content[:500] + "... (truncated)"
|
|
}
|
|
d.t.Logf(" %s: %s", name, content)
|
|
}
|
|
}
|
|
|
|
// dumpProcessList logs any dolt processes visible via /proc or ps.
|
|
func (d *Diagnostics) dumpProcessList() {
|
|
entries, err := os.ReadDir("/proc")
|
|
if err != nil {
|
|
d.t.Log(" /proc: not available")
|
|
return
|
|
}
|
|
var doltProcs []string
|
|
for _, entry := range entries {
|
|
if !entry.IsDir() {
|
|
continue
|
|
}
|
|
// Only numeric directories (PIDs).
|
|
pid := entry.Name()
|
|
if pid[0] < '0' || pid[0] > '9' {
|
|
continue
|
|
}
|
|
cmdline, err := os.ReadFile(filepath.Join("/proc", pid, "cmdline"))
|
|
if err != nil {
|
|
continue
|
|
}
|
|
if strings.Contains(string(cmdline), "dolt") {
|
|
doltProcs = append(doltProcs, fmt.Sprintf("PID %s: %s", pid, strings.ReplaceAll(string(cmdline), "\x00", " ")))
|
|
}
|
|
}
|
|
if len(doltProcs) == 0 {
|
|
d.t.Log(" dolt processes: none found")
|
|
} else {
|
|
d.t.Logf(" dolt processes (%d):", len(doltProcs))
|
|
for _, p := range doltProcs {
|
|
d.t.Logf(" %s", p)
|
|
}
|
|
}
|
|
}
|