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

60 lines
1.7 KiB
Go

package issueops
import (
"context"
"fmt"
"strings"
"github.com/steveyegge/beads/internal/storage/domain"
"github.com/steveyegge/beads/internal/types"
)
func CountDependencyEdgesInTx(ctx context.Context, tx DBTX, sourceID string, dir domain.DepDirection, typeFilter []types.DependencyType) (int64, error) {
typeClause, typeArgs := buildDepTypeClause(typeFilter)
var total int64
for _, table := range []string{"dependencies", "wisp_dependencies"} {
if dir == domain.DepDirectionOut || dir == domain.DepDirectionBoth {
n, err := countDepWhere(ctx, tx, table, "issue_id = ?", typeClause, sourceID, typeArgs)
if err != nil {
return 0, err
}
total += n
}
if dir == domain.DepDirectionIn || dir == domain.DepDirectionBoth {
n, err := countDepWhere(ctx, tx, table, DepTargetExpr+" = ?", typeClause, sourceID, typeArgs)
if err != nil {
return 0, err
}
total += n
}
}
return total, nil
}
func countDepWhere(ctx context.Context, tx DBTX, table, whereExpr, typeClause string, sourceID string, typeArgs []any) (int64, error) {
q := fmt.Sprintf("SELECT count(*) FROM %s WHERE %s", table, whereExpr) //nolint:gosec
if typeClause != "" {
q += " AND " + typeClause
}
args := append([]any{sourceID}, typeArgs...)
var n int64
if err := tx.QueryRowContext(ctx, q, args...).Scan(&n); err != nil {
return 0, fmt.Errorf("count %s: %w", table, err)
}
return n, nil
}
func buildDepTypeClause(filter []types.DependencyType) (string, []any) {
if len(filter) == 0 {
return "", nil
}
placeholders := make([]string, len(filter))
args := make([]any, len(filter))
for i, t := range filter {
placeholders[i] = "?"
args[i] = string(t)
}
return "type IN (" + strings.Join(placeholders, ",") + ")", args
}