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

Function insertMemoryEventDB

internal/memory/catalog.go:1553–1577  ·  view source on GitHub ↗
(ctx context.Context, db *sql.DB, record memcontract.OperationRecord)

Source from the content-addressed store, hash-verified

1551}
1552
1553func insertMemoryEventDB(ctx context.Context, db *sql.DB, record memcontract.OperationRecord) error {
1554 return storepkg.ExecuteWrite(ctx, db, func(ctx context.Context, tx *storepkg.WriteTx) error {
1555 if _, err := tx.ExecContext(
1556 ctx,
1557 `INSERT INTO memory_events (
1558 op, scope, agent_name, agent_tier, workspace_id, session_id, actor_kind,
1559 decision_id, target_id, metadata, ts_ms
1560 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
1561 canonicalEventOp(record),
1562 nullStringForEmpty(record.Scope.Normalize()),
1563 nullStringForEmpty(record.AgentName),
1564 nil,
1565 nullStringForEmpty(record.Workspace),
1566 nil,
1567 "system",
1568 nil,
1569 nullStringForEmpty(record.Filename),
1570 mustEventMetadata(record),
1571 timeToUnixMillis(record.Timestamp),
1572 ); err != nil {
1573 return fmt.Errorf("memory: write memory event: %w", err)
1574 }
1575 return nil
1576 })
1577}
1578
1579func insertMemoryEventTx(ctx context.Context, tx *sql.Tx, record memcontract.OperationRecord, legacy bool) error {
1580 metadata := eventMetadata(record)

Callers 1

logEventMethod · 0.85

Calls 6

canonicalEventOpFunction · 0.85
nullStringForEmptyFunction · 0.85
mustEventMetadataFunction · 0.85
timeToUnixMillisFunction · 0.85
ExecContextMethod · 0.65
NormalizeMethod · 0.45

Tested by

no test coverage detected