Documentation
¶
Overview ¶
Package soul resolves optional SOUL.md persona artifacts.
Index ¶
- Constants
- Variables
- func DiagnosticsJSON(diagnostics []Diagnostic) (json.RawMessage, error)
- func NewResourceCodec() (resources.KindCodec[ResourceSpec], error)
- type AuthoringError
- type AuthoringIdentity
- type AuthoringOption
- type AuthoringService
- type AuthoringStore
- type AuthoringTarget
- type CompactProjection
- type ConfigProvenance
- type DeleteRequest
- type Diagnostic
- type DiagnosticError
- type Frontmatter
- type HistoryRequest
- type HistoryResult
- type ManagedSoulAuthoringService
- func (s *ManagedSoulAuthoringService) Delete(ctx context.Context, req DeleteRequest) (MutationResult, error)
- func (s *ManagedSoulAuthoringService) History(ctx context.Context, req HistoryRequest) (HistoryResult, error)
- func (s *ManagedSoulAuthoringService) Put(ctx context.Context, req PutRequest) (MutationResult, error)
- func (s *ManagedSoulAuthoringService) Rollback(ctx context.Context, req RollbackRequest) (MutationResult, error)
- func (s *ManagedSoulAuthoringService) Validate(ctx context.Context, req ValidateRequest) (ValidateResult, error)
- type MutationResult
- type ParseRequest
- type Profile
- type PutRequest
- type ReadModel
- type ResolveRequest
- type ResolvedSoul
- type ResourceSpec
- type Revision
- type RevisionAction
- type RevisionListQuery
- type RollbackLookup
- type RollbackRequest
- type Snapshot
- type SnapshotListQuery
- type SnapshotProfile
- type ValidateRequest
- type ValidateResult
Constants ¶
const (
// FileName is the canonical authored persona filename.
FileName = "SOUL.md"
)
const ( // ResourceKind is the canonical desired-state kind for package-owned SOUL.md content. ResourceKind resources.ResourceKind = "agent.soul" )
Variables ¶
var ( // ErrAuthoringConflict reports a stale or missing expected digest. ErrAuthoringConflict = errors.New("soul: authoring conflict") // ErrAuthoringAgentNotFound reports a target agent that cannot be resolved. ErrAuthoringAgentNotFound = errors.New("soul: authoring agent not found") // ErrAuthoringPathRejected reports a managed SOUL.md path that is unsafe to mutate. ErrAuthoringPathRejected = errors.New("soul: authoring path rejected") // ErrAuthoringMissing reports a mutation request for an absent SOUL.md. ErrAuthoringMissing = errors.New("soul: authored file missing") )
var ( // ErrSnapshotNotFound reports a missing persisted Soul snapshot. ErrSnapshotNotFound = errors.New("soul: snapshot not found") // ErrRevisionNotFound reports a missing persisted Soul authoring revision. ErrRevisionNotFound = errors.New("soul: revision not found") // ErrInvalidSnapshot reports a malformed persisted Soul snapshot. ErrInvalidSnapshot = errors.New("soul: invalid snapshot") // ErrInvalidRevision reports a malformed persisted Soul authoring revision. ErrInvalidRevision = errors.New("soul: invalid revision") )
var ( // ErrInvalid reports a SOUL.md file that exists but cannot be accepted. ErrInvalid = errors.New("soul: invalid SOUL.md") // ErrPathEscape reports a SOUL.md path outside its configured workspace root. ErrPathEscape = errors.New("soul: path escapes workspace root") )
Functions ¶
func DiagnosticsJSON ¶
func DiagnosticsJSON(diagnostics []Diagnostic) (json.RawMessage, error)
DiagnosticsJSON encodes redacted validation diagnostics for revision storage.
func NewResourceCodec ¶
func NewResourceCodec() (resources.KindCodec[ResourceSpec], error)
NewResourceCodec builds the typed codec for agent.soul records.
Types ¶
type AuthoringError ¶
type AuthoringError struct {
Code string
Diagnostics []Diagnostic
// contains filtered or unexported fields
}
AuthoringError carries deterministic redacted diagnostics for authoring failures.
func (*AuthoringError) Error ¶
func (e *AuthoringError) Error() string
func (*AuthoringError) Unwrap ¶
func (e *AuthoringError) Unwrap() error
Unwrap exposes the sentinel cause for errors.Is callers.
type AuthoringIdentity ¶
AuthoringIdentity records actor or origin metadata for revision rows.
type AuthoringOption ¶
type AuthoringOption func(*ManagedSoulAuthoringService)
AuthoringOption customizes managed authoring service dependencies.
func WithSoulAuthoringClock ¶
func WithSoulAuthoringClock(clock func() time.Time) AuthoringOption
WithSoulAuthoringClock injects deterministic timestamps.
func WithSoulAuthoringIDGenerator ¶
func WithSoulAuthoringIDGenerator(generator func(prefix string) string) AuthoringOption
WithSoulAuthoringIDGenerator injects deterministic snapshot and revision ids.
type AuthoringService ¶
type AuthoringService interface {
Validate(ctx context.Context, req ValidateRequest) (ValidateResult, error)
Put(ctx context.Context, req PutRequest) (MutationResult, error)
Delete(ctx context.Context, req DeleteRequest) (MutationResult, error)
History(ctx context.Context, req HistoryRequest) (HistoryResult, error)
Rollback(ctx context.Context, req RollbackRequest) (MutationResult, error)
}
AuthoringService is the only managed mutation boundary for SOUL.md.
type AuthoringStore ¶
type AuthoringStore interface {
UpsertSoulSnapshot(ctx context.Context, snapshot Snapshot) (Snapshot, error)
AppendSoulRevision(ctx context.Context, revision Revision) (Revision, error)
ListSoulRevisions(ctx context.Context, query RevisionListQuery) ([]Revision, error)
FindSoulRevisionForRollback(ctx context.Context, query RollbackLookup) (Revision, error)
}
AuthoringStore is the persistence boundary used by managed authoring.
type AuthoringTarget ¶
type AuthoringTarget struct {
WorkspaceID string
WorkspaceRoot string
AgentName string
AgentPath string
Config aghconfig.SoulConfig
ConfigSource string
}
AuthoringTarget identifies the workspace and agent whose SOUL.md is managed.
type CompactProjection ¶
type CompactProjection struct {
Enabled bool
Present bool
Active bool
Digest string
SourcePath string
Role string
Tone []string
Principles []string
Truncated bool
MaxBytes int64
MaxBodyBytes int64
}
CompactProjection is the bounded context-safe soul projection.
type ConfigProvenance ¶
type ConfigProvenance struct {
Digest string `json:"digest"`
Source string `json:"source,omitempty"`
Enabled bool `json:"enabled"`
MaxBodyBytes int64 `json:"max_body_bytes"`
ContextProjectionBytes int64 `json:"context_projection_bytes"`
}
ConfigProvenance captures the Soul config values that shaped a snapshot.
func NewConfigProvenance ¶
func NewConfigProvenance(config aghconfig.SoulConfig, source string) (ConfigProvenance, error)
NewConfigProvenance returns deterministic config provenance for a resolved Soul.
type DeleteRequest ¶
type DeleteRequest struct {
Target AuthoringTarget
ExpectedDigest string
Actor AuthoringIdentity
Origin AuthoringIdentity
}
DeleteRequest removes SOUL.md through managed authoring.
type Diagnostic ¶
type Diagnostic struct {
Code string
Field string
Section string
Message string
SourcePath string
Line int
Column int
}
Diagnostic describes a closed, redacted SOUL.md validation problem.
type DiagnosticError ¶
type DiagnosticError struct {
Diagnostics []Diagnostic
// contains filtered or unexported fields
}
DiagnosticError carries structured diagnostics for invalid authored content.
func (*DiagnosticError) Error ¶
func (e *DiagnosticError) Error() string
func (*DiagnosticError) Unwrap ¶
func (e *DiagnosticError) Unwrap() error
Unwrap exposes the validation sentinel for errors.Is callers.
type Frontmatter ¶
type Frontmatter struct {
Version string
Role string
Tone []string
Principles []string
Constraints []string
Collaboration []string
MemoryPolicy []string
Tags []string
}
Frontmatter is the allowlisted strict SOUL.md metadata.
type HistoryRequest ¶
type HistoryRequest struct {
Target AuthoringTarget
Limit int
}
HistoryRequest lists managed SOUL.md authoring revisions.
type HistoryResult ¶
type HistoryResult struct {
Revisions []Revision
}
HistoryResult returns managed authoring history in newest-first order.
type ManagedSoulAuthoringService ¶
type ManagedSoulAuthoringService struct {
// contains filtered or unexported fields
}
ManagedSoulAuthoringService coordinates validation, filesystem mutation, and revision storage.
func NewManagedSoulAuthoringService ¶
func NewManagedSoulAuthoringService( persistence AuthoringStore, options ...AuthoringOption, ) (*ManagedSoulAuthoringService, error)
NewManagedSoulAuthoringService creates the managed SOUL.md authoring service.
func (*ManagedSoulAuthoringService) Delete ¶
func (s *ManagedSoulAuthoringService) Delete( ctx context.Context, req DeleteRequest, ) (MutationResult, error)
Delete removes SOUL.md through CAS-protected managed authoring.
func (*ManagedSoulAuthoringService) History ¶
func (s *ManagedSoulAuthoringService) History( ctx context.Context, req HistoryRequest, ) (HistoryResult, error)
History lists managed SOUL.md revision history.
func (*ManagedSoulAuthoringService) Put ¶
func (s *ManagedSoulAuthoringService) Put(ctx context.Context, req PutRequest) (MutationResult, error)
Put creates or updates SOUL.md through CAS-protected managed authoring.
func (*ManagedSoulAuthoringService) Rollback ¶
func (s *ManagedSoulAuthoringService) Rollback( ctx context.Context, req RollbackRequest, ) (MutationResult, error)
Rollback restores a prior revision body through the same validation and CAS path as Put.
func (*ManagedSoulAuthoringService) Validate ¶
func (s *ManagedSoulAuthoringService) Validate( ctx context.Context, req ValidateRequest, ) (ValidateResult, error)
Validate validates current or proposed SOUL.md content without mutating files or storage.
type MutationResult ¶
type MutationResult struct {
Soul ResolvedSoul
Snapshot Snapshot
Revision Revision
}
MutationResult returns the resolved post-mutation state and audit row.
type ParseRequest ¶
type ParseRequest struct {
SourcePath string
WorkspaceRoot string
Content []byte
Config aghconfig.SoulConfig
}
ParseRequest describes in-memory SOUL.md content to validate and project.
type Profile ¶
type Profile struct {
SourcePath string
Digest string
Version string
Role string
Tone []string
Principles []string
Constraints []string
Collaboration []string
MemoryPolicy []string
Tags []string
Body string
Truncated bool
}
Profile is the normalized authored persona profile.
type PutRequest ¶
type PutRequest struct {
Target AuthoringTarget
Body string
ExpectedDigest string
Actor AuthoringIdentity
Origin AuthoringIdentity
}
PutRequest creates or updates SOUL.md through managed authoring.
type ReadModel ¶
type ReadModel struct {
Enabled bool
Present bool
Active bool
Valid bool
SourcePath string
Digest string
Frontmatter Frontmatter
Body string
Truncated bool
MaxBodyBytes int64
ContextProjectionBytes int64
Diagnostics []Diagnostic
}
ReadModel is the full resolved soul view for dedicated inspect surfaces.
type ResolveRequest ¶
type ResolveRequest struct {
AgentPath string
WorkspaceRoot string
Config aghconfig.SoulConfig
}
ResolveRequest describes a SOUL.md file located beside an AGENT.md file.
type ResolvedSoul ¶
type ResolvedSoul struct {
Enabled bool
Present bool
Active bool
Valid bool
SourcePath string
Digest string
Profile Profile
Compact CompactProjection
ReadModel ReadModel
Diagnostics []Diagnostic
}
ResolvedSoul is the normalized result that later runtime surfaces can consume.
func Empty ¶
func Empty(config aghconfig.SoulConfig, sourcePath string) (ResolvedSoul, error)
Empty returns a valid absent SOUL.md resolution for non-filesystem agent sources.
func Parse ¶
func Parse(ctx context.Context, req ParseRequest) (ResolvedSoul, error)
Parse validates and normalizes in-memory SOUL.md content.
func Resolve ¶
func Resolve(ctx context.Context, req ResolveRequest) (ResolvedSoul, error)
Resolve reads and resolves SOUL.md beside the provided agent path.
type ResourceSpec ¶
type ResourceSpec struct {
AgentName string `json:"agent_name"`
AgentResourceID string `json:"agent_resource_id"`
SourcePath string `json:"source_path"`
Body string `json:"body"`
}
ResourceSpec stores read-only packaged SOUL.md content for one resource-backed agent.
type Revision ¶
type Revision struct {
ID string
WorkspaceID string
AgentName string
SourcePath string
Action RevisionAction
PreviousDigest string
NewDigest string
Body string
DiagnosticsJSON json.RawMessage
ActorKind string
ActorID string
OriginKind string
OriginRef string
CreatedAt time.Time
}
Revision is one append-only managed SOUL.md authoring history row.
type RevisionAction ¶
type RevisionAction string
RevisionAction describes a managed SOUL.md authoring mutation.
const ( // RevisionActionPut records a create or update mutation. RevisionActionPut RevisionAction = "put" // RevisionActionDelete records a managed delete mutation. RevisionActionDelete RevisionAction = "delete" // RevisionActionRollback records a managed rollback mutation. RevisionActionRollback RevisionAction = "rollback" )
type RevisionListQuery ¶
type RevisionListQuery struct {
WorkspaceID string
AgentName string
Action RevisionAction
Limit int
}
RevisionListQuery filters managed Soul authoring revision history.
func (RevisionListQuery) Validate ¶
func (q RevisionListQuery) Validate() error
Validate ensures the revision query uses supported bounds.
type RollbackLookup ¶
RollbackLookup selects the prior revision body used by managed rollback.
func (RollbackLookup) Validate ¶
func (q RollbackLookup) Validate() error
Validate ensures rollback lookup has a deterministic target revision.
type RollbackRequest ¶
type RollbackRequest struct {
Target AuthoringTarget
RevisionID string
ExpectedDigest string
Actor AuthoringIdentity
Origin AuthoringIdentity
}
RollbackRequest restores a prior revision body through managed authoring.
type Snapshot ¶
type Snapshot struct {
ID string
WorkspaceID string
AgentName string
SourcePath string
Digest string
ProfileJSON json.RawMessage
Body string
Truncated bool
CreatedAt time.Time
}
Snapshot is the immutable storage row for a resolved Soul profile.
func SnapshotFromResolved ¶
func SnapshotFromResolved( id string, workspaceID string, agentName string, resolved *ResolvedSoul, configProvenance ConfigProvenance, createdAt time.Time, ) (Snapshot, error)
SnapshotFromResolved creates a persistence row from a resolved Soul profile.
func (Snapshot) ProfileEnvelope ¶
func (s Snapshot) ProfileEnvelope() (SnapshotProfile, error)
ProfileEnvelope decodes the structured JSON envelope stored with the snapshot.
type SnapshotListQuery ¶
SnapshotListQuery filters persisted Soul snapshot rows.
func (SnapshotListQuery) Validate ¶
func (q SnapshotListQuery) Validate() error
Validate ensures the snapshot query uses supported bounds.
type SnapshotProfile ¶
type SnapshotProfile struct {
SchemaVersion int `json:"schema_version"`
Present bool `json:"present"`
Active bool `json:"active"`
Valid bool `json:"valid"`
Profile Profile `json:"profile"`
Compact CompactProjection `json:"compact"`
ReadModel ReadModel `json:"read_model"`
ConfigProvenance ConfigProvenance `json:"config_provenance"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
SnapshotProfile is the structured JSON envelope stored in Snapshot.ProfileJSON.
type ValidateRequest ¶
type ValidateRequest struct {
Target AuthoringTarget
Body *string
}
ValidateRequest validates either the current SOUL.md or the provided body.
type ValidateResult ¶
type ValidateResult struct {
Soul ResolvedSoul
}
ValidateResult is the transport-neutral validation response.