Help us shape the future of Go! Take the 2026 Go Developer Survey

postgres

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Overview

Package postgres

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open added in v0.5.0

func Open(ctx context.Context, dsn string) (*pgxpool.Pool, error)

Types

type Driver

type Driver struct {
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(ctx context.Context, connStr string) (*Driver, error)

func (*Driver) Ancestry added in v0.5.0

func (d *Driver) Ancestry(ctx context.Context, hash string) ([]*merkle.Node, error)

func (*Driver) AncestryChain added in v0.5.0

func (d *Driver) AncestryChain(ctx context.Context, hash string) (*storage.Chain, error)

func (*Driver) AncestryChains added in v0.5.0

func (d *Driver) AncestryChains(ctx context.Context, hashes []string) (map[string]*storage.Chain, error)

func (*Driver) BackfillSession added in v0.10.0

BackfillSession links existing legacy nodes to a session table row. It is used by transcript backfills where the node DAG already exists but the original ingest path predated session envelopes.

func (*Driver) Close added in v0.5.0

func (d *Driver) Close() error

func (*Driver) CountSessions added in v0.5.0

func (d *Driver) CountSessions(ctx context.Context, opts storage.ListOpts) (storage.SessionStats, error)

func (*Driver) DB added in v0.5.0

func (d *Driver) DB() *pgxpool.Pool

func (*Driver) Depth added in v0.5.0

func (d *Driver) Depth(ctx context.Context, hash string) (int, error)

func (*Driver) Get added in v0.5.0

func (d *Driver) Get(ctx context.Context, hash string) (*merkle.Node, error)

func (*Driver) GetByParent added in v0.5.0

func (d *Driver) GetByParent(ctx context.Context, parentHash *string) ([]*merkle.Node, error)

func (*Driver) GetSessionRecord added in v0.12.0

func (d *Driver) GetSessionRecord(ctx context.Context, orgID, id string) (*storage.SessionRecord, error)

GetSessionRecord returns a single session by its UUID, or nil if not found.

func (*Driver) Has added in v0.5.0

func (d *Driver) Has(ctx context.Context, hash string) (bool, error)

func (*Driver) IngestTurn added in v0.10.0

IngestTurn implements storage.SessionIngester for the Postgres driver. The session-tracking flow runs in a single transaction: resolve / UPSERT a sessions row, resolve the optional fork-parent FK (placeholder-inserting the parent when its own first turn hasn't landed yet), insert every node in the supplied chain, stamp session_id onto each newly-inserted node, and roll up the per-turn counters.

func (*Driver) Leaves added in v0.5.0

func (d *Driver) Leaves(ctx context.Context) ([]*merkle.Node, error)

func (*Driver) List added in v0.5.0

func (d *Driver) List(ctx context.Context) ([]*merkle.Node, error)

func (*Driver) ListNodesBySession added in v0.12.0

func (d *Driver) ListNodesBySession(ctx context.Context, sessionID string) ([]*merkle.Node, error)

ListNodesBySession returns all nodes attributed to a session ordered by created_at ASC (chronological order).

func (*Driver) ListParentRefs added in v0.5.0

func (d *Driver) ListParentRefs(ctx context.Context) ([]storage.ParentRef, error)

func (*Driver) ListSessionRecords added in v0.12.0

func (d *Driver) ListSessionRecords(
	ctx context.Context,
	orgID string,
	limit int,
	cursorTs *time.Time,
	cursorID *string,
) ([]storage.SessionRecord, error)

ListSessionRecords returns a page of sessions for an org ordered by last_seen_at DESC. Pass nil cursorTs/cursorID to start from the beginning.

func (*Driver) ListSessions added in v0.5.0

func (d *Driver) ListSessions(ctx context.Context, opts storage.ListOpts) (*storage.Page[*merkle.Node], error)

func (*Driver) LoadDag added in v0.5.0

func (d *Driver) LoadDag(ctx context.Context, hash string) (*merkle.Dag, error)

func (*Driver) Open added in v0.5.0

func (d *Driver) Open(ctx context.Context) error

func (*Driver) Put added in v0.5.0

func (d *Driver) Put(ctx context.Context, n *merkle.Node) (bool, error)

func (*Driver) Roots added in v0.5.0

func (d *Driver) Roots(ctx context.Context) ([]*merkle.Node, error)

func (*Driver) SessionIdentityByHash added in v0.10.0

func (d *Driver) SessionIdentityByHash(ctx context.Context, orgID, hash string) (*storage.SessionIdentity, error)

SessionIdentityByHash returns the harness identity for the sessions row attached to a node hash, scoped to orgID. Older rows, legacy Put writes, and non-Postgres stores may not have session tracking metadata; those return nil without error so read APIs can expose the field opportunistically.

The org_id predicate is load-bearing, not cosmetic: nodes is keyed by the composite (org_id, hash), so identical content yields one row per org. A lookup on hash alone would return an arbitrary org's row for shared content, leaking another tenant's harness_session_id. An empty orgID maps to the nil-UUID sentinel bucket (legacy / non-session writes).

func (*Driver) UpdateUsage added in v0.5.0

func (d *Driver) UpdateUsage(ctx context.Context, hash string, usage *llm.Usage) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL