memorypolicy

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

ValidTiers is the ordered set of accepted memory governance tiers.

Functions

func AcceptProposal added in v0.3.1

func AcceptProposal(ctx context.Context, db *sql.DB, proposalID, reviewedBy string, committedMemoryID *string) error

AcceptProposal marks a proposal as accepted and optionally records the committed memory ID. The reviewedBy field identifies the parent agent that approved the proposal.

func AgentCanAccessMemory

func AgentCanAccessMemory(ctx context.Context, db *sql.DB, memoryID, agentID, workspaceID string, readableTiers []Tier) (bool, error)

AgentCanAccessMemory checks explicit ACL grants, workspace tier visibility, and the agent's own workspace scratch memory allowance.

func GrantReadACL

func GrantReadACL(ctx context.Context, db *sql.DB, memoryID, agentID, grantedBy string) error

GrantReadACL grants one agent explicit read access to one memory item.

func RejectProposal added in v0.3.1

func RejectProposal(ctx context.Context, db *sql.DB, proposalID, reviewedBy string) error

RejectProposal marks a proposal as rejected. The reviewedBy field identifies the parent agent that rejected the proposal.

func RevokeACL

func RevokeACL(ctx context.Context, db *sql.DB, memoryID, agentID, permission string) error

RevokeACL removes one explicit ACL grant.

func ValidProposalKind added in v0.3.1

func ValidProposalKind(k string) bool

ValidProposalKind returns true if k is a recognized proposal kind.

func ValidTier

func ValidTier(raw string) bool

ValidTier reports whether raw names one of Goncho's memory governance tiers.

func ValidateTierOrErr

func ValidateTierOrErr(raw string) error

ValidateTierOrErr rejects unknown tier names with a public error message.

Types

type ACLQuery

type ACLQuery struct {
	AgentID     string
	IsParent    bool
	ReadTiers   []Tier
	WriteTier   Tier
	WorkspaceID string
}

ACLQuery captures the caller's memory tier window and explicit ACL identity.

func (ACLQuery) CanRead

func (q ACLQuery) CanRead(tier Tier) bool

CanRead reports whether the query identity can read tier through its tier window.

func (ACLQuery) CanWrite

func (q ACLQuery) CanWrite(tier Tier) bool

CanWrite reports whether the query identity can write tier.

func (ACLQuery) ReadScopeSQL

func (q ACLQuery) ReadScopeSQL() (string, []any)

ReadScopeSQL returns the SQL clause and args for readable memory rows.

type MemoryProposal added in v0.3.1

type MemoryProposal struct {
	ID                int64           `json:"id"`
	ProposalID        string          `json:"proposal_id"`
	SubtaskID         string          `json:"subtask_id"`
	ChildAgentID      string          `json:"child_agent_id"`
	ParentAgentID     string          `json:"parent_agent_id"`
	ProposedTier      Tier            `json:"proposed_tier"`
	Kind              ProposalKind    `json:"kind"`
	Content           string          `json:"content"`
	EvidenceJSON      json.RawMessage `json:"evidence_json"`
	Status            ProposalStatus  `json:"status"`
	ReviewedBy        *string         `json:"reviewed_by,omitempty"`
	ReviewedAt        *int64          `json:"reviewed_at,omitempty"`
	CommittedMemoryID *string         `json:"committed_memory_id,omitempty"`
	CreatedAt         int64           `json:"created_at"`
}

MemoryProposal represents a child agent's tentative write to durable memory. Children propose; parents review and commit.

func GetProposal added in v0.3.1

func GetProposal(ctx context.Context, db *sql.DB, proposalID string) (*MemoryProposal, error)

GetProposal fetches a single proposal by its ID.

func ListPendingProposals added in v0.3.1

func ListPendingProposals(ctx context.Context, db *sql.DB, parentAgentID string) ([]MemoryProposal, error)

ListPendingProposals returns all pending proposals for a given parent agent, ordered by creation time (newest first).

type ProposalKind added in v0.3.1

type ProposalKind string

ProposalKind enumerates the types of memory a child agent can propose.

const (
	KindFact        ProposalKind = "fact"
	KindPreference  ProposalKind = "preference"
	KindDecision    ProposalKind = "decision"
	KindObservation ProposalKind = "observation"
	KindReport      ProposalKind = "report"
	KindArtifact    ProposalKind = "artifact"
)

type ProposalRef added in v0.3.1

type ProposalRef struct {
	ProposalID    string         `json:"proposal_id"`
	ChildAgentID  string         `json:"child_agent_id"`
	ParentAgentID string         `json:"parent_agent_id"`
	Status        ProposalStatus `json:"status"`
}

ProposalRef is a lightweight handle returned when submitting a proposal.

func SubmitProposal added in v0.3.1

func SubmitProposal(ctx context.Context, db *sql.DB, subtaskID, childAgentID, parentAgentID, content string, tier Tier, kind ProposalKind, evidence any) (*ProposalRef, error)

SubmitProposal inserts a child agent's memory proposal into the database. The proposal enters "pending" status awaiting parent review. Returns a ProposalRef for the caller to track the submission.

type ProposalStatus added in v0.3.1

type ProposalStatus string

ProposalStatus tracks the lifecycle state of a memory proposal.

const (
	StatusPending  ProposalStatus = "pending"
	StatusAccepted ProposalStatus = "accepted"
	StatusRejected ProposalStatus = "rejected"
)

type Tier

type Tier string

Tier identifies the governance level that owns a memory item.

const (
	TierGlobal    Tier = "global"
	TierProject   Tier = "project"
	TierTask      Tier = "task"
	TierWorkspace Tier = "workspace"
	TierDecision  Tier = "decision"
)

func DefaultTierForSource

func DefaultTierForSource(sourceKind string) Tier

DefaultTierForSource assigns source kinds to conservative memory tiers.

func Hierarchy

func Hierarchy() []Tier

Hierarchy returns tiers from broadest/global to most governed/decision.

func NormalizeTier

func NormalizeTier(raw string) Tier

NormalizeTier returns a valid tier, defaulting unknown input to global.

func ReadableBy

func ReadableBy(agentTier Tier) []Tier

ReadableBy returns the tier window visible to an agent at agentTier.

func WritableBy

func WritableBy(isParent bool) []Tier

WritableBy returns the tiers an agent may write directly.

Jump to

Keyboard shortcuts

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