Files
tutti/packages/agent/store-sqlite/migrations_goal_provenance_ledger.go
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

43 lines
1.4 KiB
Go

package storesqlite
import (
"context"
"fmt"
)
func (s *Store) applyWorkspaceAgentGoalProvenanceLedgerV1(ctx context.Context) error {
applied, err := s.hasMigration(ctx, schemaMigrationWorkspaceAgentGoalProvenanceLedgerV1)
if err != nil || applied {
return err
}
tx, err := s.db.BeginTx(ctx, nil)
if err != nil {
return err
}
defer func() { _ = tx.Rollback() }()
if _, err = tx.ExecContext(ctx, `
CREATE TABLE IF NOT EXISTS workspace_agent_goal_provenance_ledger (
workspace_id TEXT NOT NULL,
agent_session_id TEXT NOT NULL,
session_created_at_unix_ms INTEGER NOT NULL,
provider_session_id TEXT NOT NULL,
fingerprint TEXT NOT NULL,
operation_id TEXT NOT NULL DEFAULT '',
goal_revision INTEGER NOT NULL DEFAULT 0,
repair_epoch INTEGER NOT NULL DEFAULT 0,
ambiguous INTEGER NOT NULL DEFAULT 0 CHECK(ambiguous IN (0,1)),
created_at_unix_ms INTEGER NOT NULL,
updated_at_unix_ms INTEGER NOT NULL,
PRIMARY KEY(workspace_id,agent_session_id,session_created_at_unix_ms,provider_session_id,fingerprint)
);
CREATE INDEX IF NOT EXISTS idx_goal_provenance_ledger_session
ON workspace_agent_goal_provenance_ledger(workspace_id,agent_session_id);
`); err != nil {
return fmt.Errorf("create durable goal provenance ledger: %w", err)
}
if err = recordMigrationTx(ctx, tx, schemaMigrationWorkspaceAgentGoalProvenanceLedgerV1); err != nil {
return err
}
return tx.Commit()
}