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>
56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
package issueops
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/steveyegge/beads/internal/storage"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
// GetIssueInTx retrieves a single issue by ID within an existing transaction,
|
|
// including its labels. Automatically routes to the wisps/wisp_labels tables
|
|
// if the ID is an active wisp. Returns storage.ErrNotFound (wrapped) if the
|
|
// issue does not exist in either table.
|
|
func GetIssueInTx(ctx context.Context, tx DBTX, id string) (*types.Issue, error) {
|
|
issue, err := getIssueFromTableInTx(ctx, tx, "issues", "labels", id)
|
|
if err == nil {
|
|
return issue, nil
|
|
}
|
|
if !errors.Is(err, storage.ErrNotFound) {
|
|
return nil, err
|
|
}
|
|
|
|
issue, err = getIssueFromTableInTx(ctx, tx, "wisps", "wisp_labels", id)
|
|
if err == nil {
|
|
return issue, nil
|
|
}
|
|
if errors.Is(err, storage.ErrNotFound) {
|
|
return nil, fmt.Errorf("%w: issue %s", storage.ErrNotFound, id)
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
func getIssueFromTableInTx(ctx context.Context, tx DBTX, issueTable, labelTable, id string) (*types.Issue, error) {
|
|
//nolint:gosec // G201: issueTable is a hardcoded literal supplied by GetIssueInTx ("issues" or "wisps")
|
|
row := tx.QueryRowContext(ctx, fmt.Sprintf(`SELECT %s FROM %s WHERE id = ?`, IssueSelectColumns, issueTable), id)
|
|
issue, err := ScanIssueFrom(row)
|
|
if err == sql.ErrNoRows || isTableNotExistError(err) {
|
|
return nil, storage.ErrNotFound
|
|
}
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get issue: %w", err)
|
|
}
|
|
|
|
// Fetch labels in the same transaction to avoid MaxOpenConns=1 deadlock.
|
|
labels, err := GetLabelsInTx(ctx, tx, labelTable, id)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get issue labels: %w", err)
|
|
}
|
|
issue.Labels = labels
|
|
|
|
return issue, nil
|
|
}
|