nodelog

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package nodelog provides an append only, content addressed node log on SQLite. Behaviour matches pkg/trajectory_ir/runtime/log.py so Go and Python share one IR story.

The import path is trajir/log; the package name is nodelog to avoid clashing with the standard library log package at call sites.

Index

Constants

This section is empty.

Variables

View Source
var ErrSlotConflict = postgres.ErrSlotConflict

Functions

This section is empty.

Types

type NodeLog

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

NodeLog is an append only SQLite log keyed by content addressed node id. INSERT OR IGNORE makes replaying the same node a no op, which is what durable step replay relies on.

func Open

func Open(path string) (*NodeLog, error)

Open creates or opens a SQLite database at path and ensures the schema exists.

func (*NodeLog) Append

func (l *NodeLog) Append(
	kind string,
	stepN *int,
	payload map[string]any,
	trajectoryID, tenantID string,
	seq int,
) (*nodes.Node, error)

Append builds a node via trajir/nodes and stores it. Same content id is ignored (idempotent replay). 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 atomically inserts a TOOL_CALL at (trajectory, step, seq). Returns claimed=true if this caller owns the slot and may run the tool. Returns claimed=false if the slot was already taken (block-and-gate).

func (*NodeLog) Close

func (l *NodeLog) Close() error

Close releases the database handle.

func (*NodeLog) Count

func (l *NodeLog) Count(nodeID string) (int, error)

Count returns how many rows share nodeID (0 or 1 for a healthy log).

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.

func (*NodeLog) ListNodes

func (l *NodeLog) ListNodes(trajectoryID, tenantID string) ([]map[string]any, error)

ListNodes returns nodes for a trajectory scoped to tenantID. tenantID is required so this method always enforces tenant isolation at the read path. Callers that genuinely need rows across tenants (e.g. tir.Export's own mixed-tenant check) must use ListNodesAllTenants explicitly instead.

func (*NodeLog) ListNodesAllTenants

func (l *NodeLog) ListNodesAllTenants(trajectoryID string) ([]map[string]any, error)

ListNodesAllTenants returns nodes for a trajectory across all tenants. This bypasses tenant isolation and should only be used by code that performs its own tenant-scoping check on the result, such as tir.Export detecting a trajectory with mixed tenant_id values.

Jump to

Keyboard shortcuts

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