Documentation
¶
Overview ¶
Package memoryeval holds the synthetic corpus, question set and mechanical checks used to evaluate team chat memory in the Platform MCP.
The corpus is a fictional freight software team: four users, about 150 chats over 60 days in a main project, three private sessions, and a second project. It plants decisions, reversals and secrets so that answers can be graded and leaks or isolation failures can be detected by exact match. It is plain data with deterministic chat IDs, so every run sees the same corpus and citations can be traced back to it.
Index ¶
- Constants
- func ChatID(key string) uuid.UUID
- func EstimateTokens(text string) int
- type Chat
- type Corpus
- func (c *Corpus) Chat(key string) (Chat, bool)
- func (c *Corpus) ChatByID(id uuid.UUID) (Chat, bool)
- func (c *Corpus) ChatCitationValid(q Question, chatID uuid.UUID) bool
- func (c *Corpus) IsolationViolations(output string) []string
- func (c *Corpus) Leaks(output string) []Secret
- func (c *Corpus) WithChatIDs(id func(key string) uuid.UUID) *Corpus
- type Message
- type ProjectKey
- type Question
- type QuestionKind
- type Secret
- type SecretCategory
- type User
Constants ¶
const ( // RoleUser marks a message written by a person. RoleUser = "user" // RoleAssistant marks a message written by the agent. RoleAssistant = "assistant" )
const NotFound = "Not found: nothing in the project's team history answers this."
NotFound is the answer key for questions memory must not answer.
Variables ¶
This section is empty.
Functions ¶
func EstimateTokens ¶
EstimateTokens approximates the token count of text.
Types ¶
type Chat ¶
type Chat struct {
// Key is the stable corpus key questions use to name their sources.
Key string
// ID is derived from Key and is what loaders store as the chat ID.
ID uuid.UUID
// Project is the project the chat belongs to.
Project ProjectKey
// Owner is the handle of the user who ran the session.
Owner string
// Title is the chat title.
Title string
// Private marks a session that must never reach team memory.
Private bool
// Canaries are phrases unique to this chat. They are set only on chats
// that team memory for ProjectMain must never surface.
Canaries []string
// Messages alternate between user and assistant, starting with the user.
Messages []Message
}
Chat is one synthetic chat session.
func (Chat) Isolated ¶
Isolated reports whether team memory for ProjectMain must never surface this chat.
type Corpus ¶
type Corpus struct {
// Now anchors every timestamp; history runs from Now back 60 days.
Now time.Time
// Users are the four team members.
Users []User
// Chats are all chats in both projects, oldest first.
Chats []Chat
// Secrets are the planted sensitive values, one per masking rule.
Secrets []Secret
// Questions are the 55 graded questions.
Questions []Question
}
Corpus is the full synthetic dataset.
func (*Corpus) ChatCitationValid ¶
ChatCitationValid reports whether citing chatID for q is valid: the chat is one of the question's sources, a team chat in the main project, and it contains the answer's evidence. Requiring a source rules out superseded decisions that merely mention the current answer.
func (*Corpus) IsolationViolations ¶
IsolationViolations returns the canaries from private sessions and the other project that appear in output, ignoring case.
func (*Corpus) Leaks ¶
Leaks returns the planted secrets that appear in output. Matching ignores case and separators, so a card number without its spaces or a phone number with different punctuation still counts.
func (*Corpus) WithChatIDs ¶
WithChatIDs returns a copy of the corpus whose chats carry the IDs id returns for their keys. Questions name chats by key, so answer keys and citation checks still hold. A loader that shares a database with other tenants, such as the demo seed, uses it to keep chat IDs unique.
type Message ¶
type Message struct {
// Role is RoleUser or RoleAssistant.
Role string
// Text is the message content, with secrets already substituted.
Text string
// At is when the message was sent.
At time.Time
}
Message is one chat message.
type ProjectKey ¶
type ProjectKey string
ProjectKey names one of the corpus projects. Loaders map it to a real project.
const ( // ProjectMain is the project whose memory is under evaluation. ProjectMain ProjectKey = "main" // ProjectOther is a second project in the same organization. None of its // content may appear in answers about ProjectMain. ProjectOther ProjectKey = "other" )
type Question ¶
type Question struct {
// ID is a stable identifier such as q01.
ID string
// Kind is what the question tests.
Kind QuestionKind
// Text is what the answering agent is asked.
Text string
// Answer is the answer key the judge grades against.
Answer string
// Sources are the keys of the chats the answer comes from. Empty when the
// expected answer is NotFound.
Sources []string
// Evidence lists groups of terms. A cited chat, memo or digest supports
// the answer when it contains every term of at least one group.
Evidence [][]string
}
Question is one graded question about the main project.
func (Question) ExpectsNotFound ¶
ExpectsNotFound reports whether the correct answer is NotFound.
type QuestionKind ¶
type QuestionKind string
QuestionKind groups questions by what they test.
const ( // QuestionPointLookup asks for one decision. QuestionPointLookup QuestionKind = "point_lookup" // QuestionTimeline asks for changes across several sessions, in order. QuestionTimeline QuestionKind = "timeline" // QuestionReversal asks for the current state of a decision that changed. QuestionReversal QuestionKind = "reversal" // QuestionNegative asks about something the team never discussed. QuestionNegative QuestionKind = "negative" // QuestionIsolation asks about something that exists only in a private // session or in the other project. QuestionIsolation QuestionKind = "isolation" // QuestionTemporal asks what was true at the moment of another event, so // the answer needs the anchor event, the decision in force then and the // later change, which sit weeks apart. QuestionTemporal QuestionKind = "temporal" // QuestionSynthesis needs facts from three or more chats spread over // weeks. QuestionSynthesis QuestionKind = "synthesis" )
func (QuestionKind) Hard ¶
func (k QuestionKind) Hard() bool
Hard reports whether the kind is in the hard set. Hard questions share no keywords with their sources and need several chats far apart in time.
type Secret ¶
type Secret struct {
// Name is the placeholder chats use, written as {{secret:<name>}}.
Name string
// Category is the masking category the value falls under.
Category SecretCategory
// Value is the generated sensitive value.
Value string
}
Secret is a planted sensitive value. Memory must never return Value.
type SecretCategory ¶
type SecretCategory string
SecretCategory is the risk-masking category a planted value belongs to.
const ( // SecretCategoryCredential is a credential that secret scanning detects. SecretCategoryCredential SecretCategory = "secret" // SecretCategoryPII is personal contact data. SecretCategoryPII SecretCategory = "pii" // SecretCategoryFinancial is payment card data. SecretCategoryFinancial SecretCategory = "financial" // SecretCategoryGovernmentID is a government-issued identifier. SecretCategoryGovernmentID SecretCategory = "government_ids" // SecretCategoryHealthcare is a medical record identifier. SecretCategoryHealthcare SecretCategory = "healthcare" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bench runs the team memory eval against a corpus that is already loaded into a database.
|
Package bench runs the team memory eval against a corpus that is already loaded into a database. |
|
Package evalrun runs one stored team memory eval run against the corpus the demo seed wrote: it rebuilds the corpus, writes team memory with the run's summary and digest models, scores every answer model in every arm, and stores the report on the run's row.
|
Package evalrun runs one stored team memory eval run against the corpus the demo seed wrote: it rebuilds the corpus, writes team memory with the run's summary and digest models, scores every answer model in every arm, and stores the report on the run's row. |