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

memorywrite

package
v0.43.0 Latest Latest
Warning

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

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

Documentation

Overview

Package memorywrite provides shared transactional write helpers for profile and soul memory updates. Each write increments the version counter atomically and appends a changelog entry in the same transaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConstraint

func AddConstraint(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID string, agentID string, text string) ([]memory.ConstraintEntry, error)

AddConstraint appends a new constraint entry transactionally, bumps version, and records a changelog entry with scope='constraint', action='create'.

func AddProfileEntry added in v0.42.0

func AddProfileEntry(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID, agentID, text string) ([]memory.ProfileEntry, error)

AddProfileEntry appends an auto-generated dated entry to the profile_entries column, bumps version, and records a changelog entry. The manual profile content column is never touched.

func DeleteProfile

func DeleteProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID string, agentID string) error

DeleteProfile writes a changelog entry for a profile deletion, then deletes the record.

func GetConstraints

func GetConstraints(ctx context.Context, q *sqlc.Queries, userID string, agentID string) ([]memory.ConstraintEntry, error)

GetConstraints reads the constraints JSON array from the DB row. Returns an empty slice (not an error) when no row exists or constraints is empty/default.

func GetGroupMemory added in v0.42.0

func GetGroupMemory(ctx context.Context, q *sqlc.Queries, groupID string) (string, error)

GetGroupMemory reads the shared memory content for a group. Returns ("", nil) when no row exists.

func GetProfileEntries added in v0.42.0

func GetProfileEntries(ctx context.Context, q *sqlc.Queries, userID, agentID string) ([]memory.ProfileEntry, error)

GetProfileEntries reads the auto-generated dated profile entries from a user's memory row. Returns an empty slice when no row or entries exist.

func ParseConstraintsJSON

func ParseConstraintsJSON(raw string) ([]memory.ConstraintEntry, error)

ParseConstraintsJSON parses a constraints JSON string into a slice. Returns empty slice for "", "[]", or null.

func ParseProfileEntriesJSON added in v0.42.0

func ParseProfileEntriesJSON(raw string) ([]memory.ProfileEntry, error)

ParseProfileEntriesJSON parses profile entries JSON. Returns empty slice for "", "[]", or "null".

func RemoveConstraint

func RemoveConstraint(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID string, agentID string, id string) ([]memory.ConstraintEntry, error)

RemoveConstraint removes a constraint by ID transactionally, bumps version, and records a changelog entry with scope='constraint', action='delete'.

func SetAgentSoul

func SetAgentSoul(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID string, agentID string, content string) error

SetAgentSoul writes a soul update within a transaction, incrementing version and appending a changelog entry atomically.

func SetGroupMemory added in v0.42.0

func SetGroupMemory(ctx context.Context, db *sql.DB, q *sqlc.Queries, groupID string, content string) error

SetGroupMemory writes a group's shared memory content, incrementing version atomically. Group memory has no auth_user FK — it is keyed solely by group_id. This function MUST NOT be called from DM write paths; the type-level separation between group and user writers enforces the private→group wall.

func SetProfile

func SetProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID string, agentID string, content string) error

SetProfile writes a profile update within a transaction. It increments the version, reads the before-state, and appends a changelog entry, all atomically. The source is derived from ctx via memory.ChangeSourceFromContext.

Types

This section is empty.

Jump to

Keyboard shortcuts

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