MCPcopy Create free account
hub / github.com/compozy/agh / insertRecallEvent

Method insertRecallEvent

internal/memory/recall_source.go:465–511  ·  view source on GitHub ↗
(
	ctx context.Context,
	op string,
	query memcontract.Query,
	targetID string,
	metadata map[string]string,
)

Source from the content-addressed store, hash-verified

463}
464
465func (s *Store) insertRecallEvent(
466 ctx context.Context,
467 op string,
468 query memcontract.Query,
469 targetID string,
470 metadata map[string]string,
471) error {
472 if s.catalog == nil {
473 return nil
474 }
475 payload, err := json.Marshal(metadata)
476 if err != nil {
477 return fmt.Errorf("memory: encode recall event metadata: %w", err)
478 }
479 workspaceID := strings.TrimSpace(query.WorkspaceID)
480 scope := memcontract.ScopeGlobal
481 if workspaceID != "" {
482 scope = memcontract.ScopeWorkspace
483 }
484 agentName := strings.TrimSpace(query.AgentName)
485 if agentName == "" {
486 agentName = catalogEventAgentName
487 }
488 return s.catalog.withCatalogWriteTx(ctx, "recall event insert", func(tx *storepkg.WriteTx) error {
489 if _, err := tx.ExecContext(
490 ctx,
491 `INSERT INTO memory_events (
492 op, scope, agent_name, agent_tier, workspace_id, session_id, actor_kind,
493 decision_id, target_id, metadata, ts_ms
494 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
495 strings.TrimSpace(op),
496 string(scope),
497 agentName,
498 nil,
499 nullStringForEmpty(workspaceID),
500 nil,
501 "system",
502 nil,
503 nullStringForEmpty(targetID),
504 string(payload),
505 timeToUnixMillis(time.Now().UTC()),
506 ); err != nil {
507 return fmt.Errorf("memory: write recall event %q: %w", op, err)
508 }
509 return nil
510 })
511}

Callers 5

RecordRecallExecutedMethod · 0.95
RecordRecallSkippedMethod · 0.95
RecordShadowMethod · 0.95

Calls 5

nullStringForEmptyFunction · 0.85
timeToUnixMillisFunction · 0.85
withCatalogWriteTxMethod · 0.80
ExecContextMethod · 0.65
NowMethod · 0.45

Tested by

no test coverage detected