Documentation
¶
Overview ¶
Package postgres provides a PostgreSQL backed NodeLog matching SQLite semantics.
Hash identity stays in trajir/nodes (RFC 8785 + SHA-256). This package only persists rows. Schema aligns with drivers/postgres and infrastructure.md.
Index ¶
- Variables
- type NodeLog
- func (l *NodeLog) Append(kind string, stepN *int, payload map[string]any, trajectoryID, tenantID string, ...) (*nodes.Node, error)
- func (l *NodeLog) ClaimToolCall(stepN int, payload map[string]any, trajectoryID, tenantID string, seq int) (claimed bool, err error)
- func (l *NodeLog) Close() error
- func (l *NodeLog) Has(trajectoryID, tenantID string, stepN int, kind string, seq *int) (bool, error)
- func (l *NodeLog) HasAllTenants(trajectoryID string, stepN int, kind string, seq *int) (bool, error)
- func (l *NodeLog) ListNodes(trajectoryID, tenantID string) ([]map[string]any, error)
- func (l *NodeLog) ListNodesAllTenants(trajectoryID string) ([]map[string]any, error)
Constants ¶
This section is empty.
Variables ¶
var ErrSlotConflict = errors.New("postgres: slot conflict")
ErrSlotConflict is raised when a different payload already occupies the slot.
Functions ¶
This section is empty.
Types ¶
type NodeLog ¶
type NodeLog struct {
// contains filtered or unexported fields
}
NodeLog is an append only, content addressed IR log on PostgreSQL.
func OpenDB ¶
OpenDB wraps an existing *sql.DB (for tests or advanced wiring). The caller owns the connection lifecycle unless Close is used after OpenDB when the NodeLog is no longer needed; OpenDB does not close the DB on error after schema setup fails on a caller owned handle.
func OpenFromEnv ¶
OpenFromEnv resolves TRAJIR_DATABASE_URL or DATABASE_URL and opens a log.
func (*NodeLog) Append ¶
func (l *NodeLog) Append( kind string, stepN *int, payload map[string]any, trajectoryID, tenantID string, seq int, ) (*nodes.Node, error)
Append stores a node. Same content id is ignored. Different payload at the same logical slot returns ErrSlotConflict.
func (*NodeLog) ClaimToolCall ¶
func (l *NodeLog) ClaimToolCall( stepN int, payload map[string]any, trajectoryID, tenantID string, seq int, ) (claimed bool, err error)
ClaimToolCall claims a TOOL_CALL slot. claimed=false means lost the race.
func (*NodeLog) Has ¶
func (l *NodeLog) Has(trajectoryID, tenantID string, stepN int, kind string, seq *int) (bool, error)
Has reports whether a node of kind exists for trajectory and step scoped to tenantID. When seq is non nil, the match is limited to that sequence slot. tenantID must be non-empty; use HasAllTenants for cross-tenant administrative checks.
func (*NodeLog) HasAllTenants ¶
func (l *NodeLog) HasAllTenants(trajectoryID string, stepN int, kind string, seq *int) (bool, error)
HasAllTenants reports whether a node of kind exists for trajectory and step across any tenant. This bypasses tenant isolation and is intended for administrative or diagnostic tools only.