-- function_versions: historial de versiones por function_id. -- Fuente principal = `call_monitor snapshot` que lee registry.db.functions.content_hash -- tras cada `fn index`. Edit-hook tambien anota cambios con sha256 del archivo. -- copy_detected = source de la fase 0085k (fn doctor copied-code). -- -- PK incluye source para permitir que cada source mantenga su propio espacio de -- hashes (el sha256 del archivo NO coincide con el content_hash canonical del -- registry.db, que incluye metadata adicional). CREATE TABLE IF NOT EXISTS function_versions ( function_id TEXT NOT NULL, content_hash TEXT NOT NULL, version TEXT NOT NULL DEFAULT '', snapped_at INTEGER NOT NULL, source TEXT NOT NULL, lines_added INTEGER NOT NULL DEFAULT 0, lines_removed INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (function_id, content_hash, source) ); CREATE INDEX IF NOT EXISTS idx_fn_versions_function ON function_versions(function_id); CREATE INDEX IF NOT EXISTS idx_fn_versions_snapped_at ON function_versions(snapped_at); CREATE INDEX IF NOT EXISTS idx_fn_versions_source ON function_versions(source);