A webhook set SenderID to its configured route path. The turn path reads that field through a per-channel resolver which refuses webhook, but the session curator derives its participant from the raw field with no channel filter, so a webhook session with exactly one distinct sender and one extracted fact wrote agent-user memory addressed to User: "/hooks/...". Nothing reads it, and every pass added more, because the facts are identical strings with no dedup. docs/prds/memory-engine-unification.md criterion 7 requires that a route path never become a user identity. Clear it at the producer rather than teaching every consumer which channels are lying: a route path is a source, not a person, so it no longer enters SenderID. It still keys the inbound rate limit, where it is the documented per-source budget for webhooks (config.RateLimitConfig), so it travels in the new transport-only Inbound.BudgetKey -- carried on the wire beside Page, never persisted, and never read as an identity. pb.Message gains budget_key (field 9) for the same reason page (field 7) exists: transport context that rides with an inbound message and is deliberately absent from storedProto's rendering of a canonical record. The curator needs no change. An empty SenderID already fails closed as an unidentified user message, which is the path a dashboard session takes, and sessionParticipant's existing skip covers it; the test name now says so.
76 lines
3.2 KiB
Go
76 lines
3.2 KiB
Go
package messaging
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Inbound is a message arriving from a channel together with the
|
|
// transport context that is not part of the canonical record.
|
|
//
|
|
// Message is the record itself, exactly as it will be persisted. Channels
|
|
// construct it directly: ConversationID addresses the chat (a Telegram
|
|
// chat ID and topic thread, an email recipient, a webhook path), Sender is
|
|
// the channel-native attribution, and Role is always RoleUser --
|
|
// a channel only ever carries what a person said. ID is left empty for a
|
|
// newly received message so the store derives one from SourceID, and
|
|
// honoured when set, which is what lets a read-modify-write of a history
|
|
// keep its identities rather than minting new ones.
|
|
type Inbound struct {
|
|
Message Message
|
|
// Page is the dashboard route the operator is on when they sent
|
|
// this message. Transport-only: it reaches the system prompt and
|
|
// is never persisted. Empty for non-web channels.
|
|
Page string
|
|
// BudgetKey is what the Gateway charges this message against in its
|
|
// inbound rate limiter (internal/ratelimit), for a channel whose
|
|
// Message.SenderID is empty because it carries no per-person
|
|
// identity but still has a stable, operator-controlled source to
|
|
// budget -- a webhook's configured route path, today. It is
|
|
// deliberately not SenderID: SenderID means "this is who sent it",
|
|
// and several consumers (internal/app/archied/chat_identity.go,
|
|
// sessioncurator) read it as a person, so a route path in that field
|
|
// becomes a user identity. BudgetKey is transport-only and never
|
|
// persisted, exactly like Page. Empty means the message is not
|
|
// rate limited, which is correct for a source with no stable key of
|
|
// its own (the dashboard).
|
|
BudgetKey string
|
|
}
|
|
|
|
// SpawnRequest is a chat-originated task creation request. Repo and
|
|
// Workflow are optional -- empty means "the daemon's configured
|
|
// default for this identity".
|
|
type SpawnRequest struct {
|
|
Title string
|
|
Body string // operator instructions carried into the admitted task
|
|
Repo string // "owner/name"; empty = identity's default repo
|
|
Workflow string // empty = daemon's default workflow routing
|
|
Identity string // the identity spawning this task; propagated from Router.Identity
|
|
}
|
|
|
|
// TaskCreator creates a native (non-forge-backed) task from a chat
|
|
// command. The daemon supplies an implementation backed by the store.
|
|
// When nil on a Router, /spawn returns "not configured". CreateTask
|
|
// must return the task's real, durable database ID -- never a
|
|
// synthetic or fabricated value.
|
|
type TaskCreator interface {
|
|
CreateTask(ctx context.Context, req SpawnRequest) (taskID int64, err error)
|
|
}
|
|
|
|
// DangerousCommandAuthority is the sandbox-owned authority for operations
|
|
// that can destroy process or filesystem state. Adapters only request and
|
|
// present approval; they never implement these operations themselves.
|
|
type DangerousCommandAuthority interface {
|
|
StopProcess(context.Context, string) error
|
|
Rollback(context.Context, int) (string, error)
|
|
ListCheckpoints(context.Context) ([]CheckpointInfo, error)
|
|
}
|
|
|
|
// CheckpointInfo describes a saved sandbox filesystem checkpoint.
|
|
type CheckpointInfo struct {
|
|
Number int
|
|
Timestamp time.Time
|
|
Label string
|
|
Size string
|
|
}
|