Documentation
¶
Overview ¶
Package memory provides deliberate, scoped context for PitCrew agents.
Package memory stores local, project-aware context for registered agents. It is separate from shared project knowledge pages.
Index ¶
- Constants
- Variables
- func RedactPrompt(value string) string
- func Serve(ctx context.Context, in io.Reader, out io.Writer, store *Store, ...) error
- func SkillFiles() map[string][]byte
- type EngramArchivedSession
- type EngramDiagnostic
- type EngramImportItem
- type EngramImportParams
- type EngramImportResult
- type EngramProvenance
- type EngramSessionItem
- type EngramSessionProvenance
- type MCPHandler
- type Record
- type SaveParams
- type SearchParams
- type SearchResults
- type Session
- type Store
- func (s *Store) CapturePrompt(ctx context.Context, cwd, sessionID, redactedPrompt string) (Record, error)
- func (s *Store) Close() error
- func (s *Store) Context(ctx context.Context, projectName, owner string, limit int) ([]Record, error)
- func (s *Store) CrossProjectRecallEnabled(ctx context.Context, owner string) (bool, error)
- func (s *Store) CurrentSession(ctx context.Context, cwd string) (Session, error)
- func (s *Store) Delete(ctx context.Context, id int64, expectedRevision int, hard bool, who string) error
- func (s *Store) DeleteEngramSession(ctx context.Context, projectName, owner string, id int64) error
- func (s *Store) EndSession(ctx context.Context, sessionID, cwd string) error
- func (s *Store) EngramSessions(ctx context.Context, projectName, owner string, id, after int64, limit int) ([]EngramArchivedSession, error)
- func (s *Store) EngramSource(ctx context.Context, id int64) (*EngramProvenance, error)
- func (s *Store) Get(ctx context.Context, id int64) (Record, error)
- func (s *Store) GetForContext(ctx context.Context, id int64, projectName, owner string) (Record, error)
- func (s *Store) GetForRecall(ctx context.Context, id int64, projectName, owner string) (Record, error)
- func (s *Store) ImportEngram(ctx context.Context, input io.Reader, p EngramImportParams) (EngramImportResult, error)
- func (s *Store) List(ctx context.Context, projectName, owner string, limit int) ([]Record, error)
- func (s *Store) ListSessions(ctx context.Context, cwd string) ([]Session, error)
- func (s *Store) PromptCaptureEnabled(ctx context.Context) (bool, error)
- func (s *Store) RegisterSession(ctx context.Context, sessionID, cwd, agentID string) (Session, error)
- func (s *Store) Save(ctx context.Context, params SaveParams) (Record, error)
- func (s *Store) Search(ctx context.Context, params SearchParams) (SearchResults, error)
- func (s *Store) SessionForHost(ctx context.Context, id, root, host string) (Session, error)
- func (s *Store) SessionScopeActive(ctx context.Context, root string) (bool, error)
- func (s *Store) SetCrossProjectRecall(ctx context.Context, owner, policy, who string) error
- func (s *Store) SetPromptCapture(ctx context.Context, enabled bool, who string) error
- func (s *Store) SummarizeSession(ctx context.Context, cwd, sessionID, summary, who string) (Record, error)
- func (s *Store) Update(ctx context.Context, p UpdateParams) (Record, error)
- type UpdateParams
Constants ¶
const ( DefaultOwner = "codex" DefaultAgent = "codex" MaxContentBytes = 1 << 20 MaxTitleBytes = 512 MaxTopicBytes = 256 MaxSearchLimit = 100 DefaultSearchMax = 20 )
const MaxEngramDiagnostics = 100
const MaxEngramExportBytes = 64 << 20
const SkillName = "pitcrew-memory"
const SkillVersion = "1.3.0"
Variables ¶
var ( ErrProjectNotFound = errors.New("memory project not found") ErrProjectArchived = errors.New("memory project is archived") ErrNotFound = errors.New("memory record not found") ErrSessionNotFound = errors.New("registered runtime session not found") ErrSessionConflict = errors.New("runtime session identity conflicts with its registered checkout") ErrNoActiveSession = errors.New("no active registered runtime session for this checkout") ErrAmbiguousSession = errors.New("multiple active runtime sessions exist for this checkout; memory writes are disabled") ErrInvalidInput = errors.New("invalid memory input") ErrRevisionConflict = errors.New("memory changed; read the latest revision and reconcile the edit") ErrRepositoryNotReady = errors.New("checkout is not associated with an active PitCrew project") )
Functions ¶
func RedactPrompt ¶
RedactPrompt removes common credential forms before an explicitly enabled prompt capture. It does not inspect or read a conversation transcript.
func Serve ¶
func Serve(ctx context.Context, in io.Reader, out io.Writer, store *Store, repositoryRoot string) error
Serve remains the memory-only transport entry point for package callers.
func SkillFiles ¶
SkillFiles returns a fresh copy of the installable, product-owned memory skill package.
Types ¶
type EngramArchivedSession ¶ added in v0.36.0
type EngramDiagnostic ¶ added in v0.36.0
type EngramImportItem ¶ added in v0.35.0
type EngramImportParams ¶ added in v0.35.0
type EngramImportResult ¶ added in v0.35.0
type EngramImportResult struct {
Project string `json:"project"`
SourceProject string `json:"sourceProject"`
Apply bool `json:"apply"`
Applied bool `json:"applied"`
Selected int `json:"selected"`
ProjectObservations int `json:"projectObservations"`
PersonalObservations int `json:"personalObservations"`
IncludePersonal bool `json:"includePersonal"`
Ignored int `json:"ignoredOtherProjects"`
Sessions int `json:"historicalSessions"`
StandaloneSessions int `json:"standaloneSessions"`
Items []EngramImportItem `json:"items"`
SessionItems []EngramSessionItem `json:"sessionItems"`
Blockers int `json:"blockers"`
Diagnostics []EngramDiagnostic `json:"diagnostics"`
DiagnosticsTruncated bool `json:"diagnosticsTruncated"`
Types map[string]int `json:"sourceTypes"`
Scopes map[string]int `json:"sourceScopes"`
}
type EngramProvenance ¶ added in v0.35.0
type EngramProvenance struct {
Source string `json:"source"`
SourceID string `json:"sourceId"`
SourceProject string `json:"sourceProject"`
SourceKey string `json:"sourceKey"`
Historical bool `json:"historical"`
Observation json.RawMessage `json:"observation"`
Session json.RawMessage `json:"session,omitempty"`
ExportMetadata json.RawMessage `json:"exportMetadata"`
}
EngramProvenance is historical, untrusted source data, never runtime identity.
type EngramSessionItem ¶ added in v0.36.0
type EngramSessionProvenance ¶ added in v0.36.0
type EngramSessionProvenance struct {
Source string `json:"source"`
SourceID string `json:"sourceId"`
SourceProject string `json:"sourceProject"`
SourceKey string `json:"sourceKey"`
Historical bool `json:"historical"`
Session json.RawMessage `json:"session"`
ExportMetadata json.RawMessage `json:"exportMetadata"`
}
EngramSessionProvenance is an archived source record, never a live session.
type MCPHandler ¶
type MCPHandler struct {
// contains filtered or unexported fields
}
func NewHostMCPHandler ¶ added in v0.34.0
func NewHostMCPHandler(store *Store, repositoryRoot, host string) (*MCPHandler, error)
NewHostMCPHandler binds the server to the host agent without inferring a session.
func NewMCPHandler ¶
func NewMCPHandler(store *Store, repositoryRoot string) (*MCPHandler, error)
func (*MCPHandler) Tools ¶
func (h *MCPHandler) Tools() []mcpserver.Tool
type Record ¶
type Record struct {
Historical bool `json:"historical,omitempty"`
EngramSource *EngramProvenance `json:"engramSource,omitempty"`
ID int64 `json:"id"`
Scope string `json:"scope"`
ProjectID *int64 `json:"projectId,omitempty"`
ProjectKey string `json:"projectKey,omitempty"`
OwnerID string `json:"ownerId"`
Type string `json:"type"`
Title string `json:"title"`
Content string `json:"content,omitempty"`
Topic string `json:"topic,omitempty"`
AgentID string `json:"agentId,omitempty"`
SessionID string `json:"sessionId,omitempty"`
Revision int `json:"revision"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
Snippet string `json:"snippet,omitempty"`
MatchedFields []string `json:"matchedFields,omitempty"`
ContentTruncated bool `json:"contentTruncated,omitempty"`
// contains filtered or unexported fields
}
Record is one current memory item. Content is omitted by metadata-only reads.
type SaveParams ¶
type SearchParams ¶
type SearchResults ¶
type Session ¶
type Session struct {
ID string `json:"sessionId"`
ProjectID int64 `json:"projectId"`
Project string `json:"projectKey"`
RepoRoot string `json:"repositoryRoot"`
AgentID string `json:"agentId"`
StartedAt time.Time `json:"startedAt"`
LastSeen time.Time `json:"lastSeenAt"`
EndedAt *time.Time `json:"endedAt,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns memory records and runtime session registration in the shared DB.
func (*Store) CapturePrompt ¶
func (s *Store) CapturePrompt(ctx context.Context, cwd, sessionID, redactedPrompt string) (Record, error)
CapturePrompt records one already-redacted prompt only after explicit opt-in.
func (*Store) Context ¶
func (s *Store) Context(ctx context.Context, projectName, owner string, limit int) ([]Record, error)
Context returns a small recent set for session startup or post-compaction.
func (*Store) CrossProjectRecallEnabled ¶ added in v0.33.0
CrossProjectRecallEnabled fails closed: an agent without an explicit durable preference retains project isolation. This preference is not session identity.
func (*Store) CurrentSession ¶
func (*Store) Delete ¶
func (s *Store) Delete(ctx context.Context, id int64, expectedRevision int, hard bool, who string) error
Delete soft-deletes by default. Hard deletion removes content after recording a metadata-only audit event; audit history never stores memory text.
func (*Store) DeleteEngramSession ¶ added in v0.36.0
DeleteEngramSession erases raw session/export data, retaining a conflict tombstone.
func (*Store) EndSession ¶
func (*Store) EngramSessions ¶ added in v0.36.0
func (s *Store) EngramSessions(ctx context.Context, projectName, owner string, id, after int64, limit int) ([]EngramArchivedSession, error)
EngramSessions lists metadata in one explicitly selected project and owner. Raw source/session IDs appear only in the explicitly requested full read.
func (*Store) EngramSource ¶ added in v0.35.0
EngramSource returns preserved provenance, including unknown source fields.
func (*Store) GetForContext ¶
func (s *Store) GetForContext(ctx context.Context, id int64, projectName, owner string) (Record, error)
GetForContext limits agent reads to its current project and personal scope.
func (*Store) GetForRecall ¶ added in v0.33.0
func (s *Store) GetForRecall(ctx context.Context, id int64, projectName, owner string) (Record, error)
GetForRecall permits read-only retrieval from other active registered projects. Mutations still use GetForContext and therefore cannot modify fallback records.
func (*Store) ImportEngram ¶ added in v0.35.0
func (s *Store) ImportEngram(ctx context.Context, input io.Reader, p EngramImportParams) (EngramImportResult, error)
ImportEngram previews or atomically applies one explicitly mapped project. Personal source observations require explicit consent and retain owner-only scope.
func (*Store) ListSessions ¶
func (*Store) PromptCaptureEnabled ¶
func (*Store) RegisterSession ¶
func (*Store) Save ¶
Save creates a record or updates the active record with the same scoped topic. Session attribution is validated against a session registered by the host hook.
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, params SearchParams) (SearchResults, error)
func (*Store) SessionForHost ¶ added in v0.34.0
SessionForHost validates exact session, checkout registration and host identity.
func (*Store) SessionScopeActive ¶ added in v0.34.0
SessionScopeActive distinguishes absent/inactive registrations from store errors.
func (*Store) SetCrossProjectRecall ¶ added in v0.33.0
func (*Store) SetPromptCapture ¶
SetPromptCapture stores only the explicit preference; it is disabled on fresh installs.