(ctx context.Context, db *sql.DB, record memcontract.OperationRecord)
| 1551 | } |
| 1552 | |
| 1553 | func 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 | |
| 1579 | func insertMemoryEventTx(ctx context.Context, tx *sql.Tx, record memcontract.OperationRecord, legacy bool) error { |
| 1580 | metadata := eventMetadata(record) |
no test coverage detected