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 ¶
- func AddConstraint(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, agentID string, ...) ([]memory.ConstraintEntry, error)
- func DeleteProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, agentID string) error
- func GetConstraints(ctx context.Context, q *sqlc.Queries, userID int64, agentID string) ([]memory.ConstraintEntry, error)
- func ParseConstraintsJSON(raw string) ([]memory.ConstraintEntry, error)
- func RemoveConstraint(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, agentID string, ...) ([]memory.ConstraintEntry, error)
- func SetAgentSoul(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, agentID string, ...) error
- func SetProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, agentID string, ...) error
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 int64, 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 DeleteProfile ¶
func DeleteProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, 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 int64, 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 ParseConstraintsJSON ¶
func ParseConstraintsJSON(raw string) ([]memory.ConstraintEntry, error)
ParseConstraintsJSON parses a constraints JSON string into a slice. Returns empty slice for "", "[]", or null.
func RemoveConstraint ¶
func RemoveConstraint(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, 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 int64, agentID string, content string) error
SetAgentSoul writes a soul update within a transaction, incrementing version and appending a changelog entry atomically.
func SetProfile ¶
func SetProfile(ctx context.Context, db *sql.DB, q *sqlc.Queries, userID int64, 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.