nodes

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: 9 Imported by: 0

Documentation

Overview

Package nodes implements Trajectory IR node identity for the Go IR core.

Hashing matches the Python reference in pkg/trajectory_ir/runtime/nodes.py: RFC 8785 JCS of the payload, then SHA-256 hex for payload_hash; node_id is SHA-256 hex of tenant|trajectory|step|seq|kind|payload_hash with the same string rules as Python (step None formats as the four characters None).

Index

Constants

This section is empty.

Variables

View Source
var NODE_KINDS = map[string]struct{}{
	"INPUT":           {},
	"CONSTRAINT":      {},
	"STATE_SET":       {},
	"PROJECT_CONTEXT": {},
	"THOUGHT":         {},
	"DECISION":        {},
	"TOOL_CALL":       {},
	"TOOL_RESULT":     {},
	"ARTIFACT_PUT":    {},
	"ARTIFACT_REF":    {},
	"LTM_QUERY":       {},
	"LTM_HIT":         {},
	"LTM_PROJECT":     {},
	"COMMIT_STEP":     {},
	"ABORT":           {},
	"REDACTION":       {},
}

NODE_KINDS is the Phase 1A set used by the Python reference.

Functions

func NodeID

func NodeID(tenantID, trajectoryID string, stepN *int, seq int, kind, phash string) (string, error)

NodeID builds the content-addressed id string used by the Python reference. stepN nil is formatted as "None" so it matches Python f-string None.

func PayloadHash

func PayloadHash(payload map[string]any) (string, error)

PayloadHash returns SHA-256 hex of the RFC 8785 canonical form of payload. The payload must not contain a "ts" key (wall clock is never hashed).

func ValidateIDComponent

func ValidateIDComponent(name, value string) error

ValidateIDComponent rejects empty values and characters that break the '|' joined node_id preimage (delimiter / control injection).

Types

type Node

type Node struct {
	Kind         string
	TrajectoryID string
	TenantID     string
	StepN        *int
	Seq          int
	Payload      map[string]any
	TS           float64
	PHash        string
	ID           string
}

Node is a hashed IR event. Identity fields are computed on construction.

func NewNode

func NewNode(kind, trajectoryID, tenantID string, stepN *int, seq int, payload map[string]any) (*Node, error)

NewNode validates kind and payload rules and fills PHash and ID.

Jump to

Keyboard shortcuts

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