(ctx context.Context, tx *sql.Tx, record memcontract.OperationRecord, legacy bool)
| 1577 | } |
| 1578 | |
| 1579 | func insertMemoryEventTx(ctx context.Context, tx *sql.Tx, record memcontract.OperationRecord, legacy bool) error { |
| 1580 | metadata := eventMetadata(record) |
| 1581 | if legacy { |
| 1582 | metadata[memoryEventMetadataLegacyIDKey] = strings.TrimSpace(record.ID) |
| 1583 | } |
| 1584 | payload, err := json.Marshal(metadata) |
| 1585 | if err != nil { |
| 1586 | return fmt.Errorf("memory: encode memory event metadata: %w", err) |
| 1587 | } |
| 1588 | if _, err := tx.ExecContext( |
| 1589 | ctx, |
| 1590 | `INSERT INTO memory_events ( |
| 1591 | op, scope, agent_name, agent_tier, workspace_id, session_id, actor_kind, |
| 1592 | decision_id, target_id, metadata, ts_ms |
| 1593 | ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, |
| 1594 | canonicalEventOp(record), |
| 1595 | nullStringForEmpty(record.Scope.Normalize()), |
| 1596 | nullStringForEmpty(record.AgentName), |
| 1597 | nil, |
| 1598 | nullStringForEmpty(record.Workspace), |
| 1599 | nil, |
| 1600 | "system", |
| 1601 | nil, |
| 1602 | nullStringForEmpty(record.Filename), |
| 1603 | string(payload), |
| 1604 | timeToUnixMillis(record.Timestamp), |
| 1605 | ); err != nil { |
| 1606 | return fmt.Errorf("memory: migrate memory event: %w", err) |
| 1607 | } |
| 1608 | return nil |
| 1609 | } |
| 1610 | |
| 1611 | func (c *catalog) listOperations( |
| 1612 | ctx context.Context, |
no test coverage detected