mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
Implement generic pool member scoring and probing
This commit is contained in:
@@ -294,6 +294,36 @@ CREATE TABLE IF NOT EXISTS provider_api_keys (
|
||||
KEY provider_api_keys_provider_id_idx (provider_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pool_member_scores (
|
||||
id VARCHAR(192) PRIMARY KEY,
|
||||
pool_kind VARCHAR(64) NOT NULL,
|
||||
pool_id VARCHAR(64) NOT NULL,
|
||||
member_kind VARCHAR(64) NOT NULL,
|
||||
member_id VARCHAR(64) NOT NULL,
|
||||
capability VARCHAR(64) NOT NULL,
|
||||
scope_kind VARCHAR(64) NOT NULL,
|
||||
scope_id VARCHAR(128),
|
||||
score DOUBLE NOT NULL DEFAULT 0,
|
||||
hard_state VARCHAR(64) NOT NULL DEFAULT 'unknown',
|
||||
score_version BIGINT NOT NULL DEFAULT 1,
|
||||
score_reason TEXT NOT NULL,
|
||||
last_ranked_at BIGINT,
|
||||
last_scheduled_at BIGINT,
|
||||
last_success_at BIGINT,
|
||||
last_failure_at BIGINT,
|
||||
failure_count BIGINT NOT NULL DEFAULT 0,
|
||||
last_probe_attempt_at BIGINT,
|
||||
last_probe_success_at BIGINT,
|
||||
last_probe_failure_at BIGINT,
|
||||
probe_failure_count BIGINT NOT NULL DEFAULT 0,
|
||||
probe_status VARCHAR(64) NOT NULL DEFAULT 'never',
|
||||
updated_at BIGINT NOT NULL,
|
||||
KEY pool_member_scores_rank_idx (pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC),
|
||||
KEY pool_member_scores_member_idx (pool_kind, pool_id, member_kind, member_id),
|
||||
KEY pool_member_scores_probe_idx (pool_kind, pool_id, probe_status, last_probe_success_at),
|
||||
KEY pool_member_scores_updated_at_idx (updated_at)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS gemini_file_mappings (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
file_name VARCHAR(512) NOT NULL,
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
CREATE TABLE IF NOT EXISTS pool_member_scores (
|
||||
id VARCHAR(192) PRIMARY KEY,
|
||||
pool_kind VARCHAR(64) NOT NULL,
|
||||
pool_id VARCHAR(64) NOT NULL,
|
||||
member_kind VARCHAR(64) NOT NULL,
|
||||
member_id VARCHAR(64) NOT NULL,
|
||||
capability VARCHAR(64) NOT NULL,
|
||||
scope_kind VARCHAR(64) NOT NULL,
|
||||
scope_id VARCHAR(128),
|
||||
score DOUBLE NOT NULL DEFAULT 0,
|
||||
hard_state VARCHAR(64) NOT NULL DEFAULT 'unknown',
|
||||
score_version BIGINT NOT NULL DEFAULT 1,
|
||||
score_reason TEXT NOT NULL,
|
||||
last_ranked_at BIGINT,
|
||||
last_scheduled_at BIGINT,
|
||||
last_success_at BIGINT,
|
||||
last_failure_at BIGINT,
|
||||
failure_count BIGINT NOT NULL DEFAULT 0,
|
||||
last_probe_attempt_at BIGINT,
|
||||
last_probe_success_at BIGINT,
|
||||
last_probe_failure_at BIGINT,
|
||||
probe_failure_count BIGINT NOT NULL DEFAULT 0,
|
||||
probe_status VARCHAR(64) NOT NULL DEFAULT 'never',
|
||||
updated_at BIGINT NOT NULL,
|
||||
KEY pool_member_scores_rank_idx (pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC),
|
||||
KEY pool_member_scores_member_idx (pool_kind, pool_id, member_kind, member_id),
|
||||
KEY pool_member_scores_probe_idx (pool_kind, pool_id, probe_status, last_probe_success_at),
|
||||
KEY pool_member_scores_updated_at_idx (updated_at)
|
||||
);
|
||||
@@ -534,6 +534,38 @@ CREATE TABLE IF NOT EXISTS public.provider_api_keys (
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public.pool_member_scores (
|
||||
id character varying(192) NOT NULL,
|
||||
pool_kind character varying(64) NOT NULL,
|
||||
pool_id character varying(64) NOT NULL,
|
||||
member_kind character varying(64) NOT NULL,
|
||||
member_id character varying(64) NOT NULL,
|
||||
capability character varying(64) NOT NULL,
|
||||
scope_kind character varying(64) NOT NULL,
|
||||
scope_id character varying(128),
|
||||
score double precision DEFAULT 0 NOT NULL,
|
||||
hard_state character varying(64) DEFAULT 'unknown'::character varying NOT NULL,
|
||||
score_version bigint DEFAULT 1 NOT NULL,
|
||||
score_reason jsonb NOT NULL,
|
||||
last_ranked_at bigint,
|
||||
last_scheduled_at bigint,
|
||||
last_success_at bigint,
|
||||
last_failure_at bigint,
|
||||
failure_count bigint DEFAULT 0 NOT NULL,
|
||||
last_probe_attempt_at bigint,
|
||||
last_probe_success_at bigint,
|
||||
last_probe_failure_at bigint,
|
||||
probe_failure_count bigint DEFAULT 0 NOT NULL,
|
||||
probe_status character varying(64) DEFAULT 'never'::character varying NOT NULL,
|
||||
updated_at bigint NOT NULL
|
||||
);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: provider_endpoints; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1659,6 +1691,21 @@ END $mig$;
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores pool_member_scores_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
DO $mig$ BEGIN
|
||||
ALTER TABLE ONLY public.pool_member_scores
|
||||
ADD CONSTRAINT pool_member_scores_pkey PRIMARY KEY (id);
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN NULL;
|
||||
WHEN duplicate_table THEN NULL;
|
||||
WHEN invalid_table_definition THEN NULL;
|
||||
END $mig$;
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: provider_endpoints provider_endpoints_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3401,6 +3448,38 @@ CREATE INDEX IF NOT EXISTS ix_provider_api_keys_id ON public.provider_api_keys U
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores_rank_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_rank_idx ON public.pool_member_scores USING btree (pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores_member_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_member_idx ON public.pool_member_scores USING btree (pool_kind, pool_id, member_kind, member_id);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores_probe_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_probe_idx ON public.pool_member_scores USING btree (pool_kind, pool_id, probe_status, last_probe_success_at);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: pool_member_scores_updated_at_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_updated_at_idx ON public.pool_member_scores USING btree (updated_at);
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Name: ix_provider_endpoints_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
CREATE TABLE IF NOT EXISTS public.pool_member_scores (
|
||||
id character varying(192) PRIMARY KEY,
|
||||
pool_kind character varying(64) NOT NULL,
|
||||
pool_id character varying(64) NOT NULL,
|
||||
member_kind character varying(64) NOT NULL,
|
||||
member_id character varying(64) NOT NULL,
|
||||
capability character varying(64) NOT NULL,
|
||||
scope_kind character varying(64) NOT NULL,
|
||||
scope_id character varying(128),
|
||||
score double precision NOT NULL DEFAULT 0,
|
||||
hard_state character varying(64) NOT NULL DEFAULT 'unknown',
|
||||
score_version bigint NOT NULL DEFAULT 1,
|
||||
score_reason jsonb NOT NULL,
|
||||
last_ranked_at bigint,
|
||||
last_scheduled_at bigint,
|
||||
last_success_at bigint,
|
||||
last_failure_at bigint,
|
||||
failure_count bigint NOT NULL DEFAULT 0,
|
||||
last_probe_attempt_at bigint,
|
||||
last_probe_success_at bigint,
|
||||
last_probe_failure_at bigint,
|
||||
probe_failure_count bigint NOT NULL DEFAULT 0,
|
||||
probe_status character varying(64) NOT NULL DEFAULT 'never',
|
||||
updated_at bigint NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_rank_idx
|
||||
ON public.pool_member_scores USING btree
|
||||
(pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_member_idx
|
||||
ON public.pool_member_scores USING btree
|
||||
(pool_kind, pool_id, member_kind, member_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_probe_idx
|
||||
ON public.pool_member_scores USING btree
|
||||
(pool_kind, pool_id, probe_status, last_probe_success_at);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_updated_at_idx
|
||||
ON public.pool_member_scores USING btree (updated_at);
|
||||
@@ -301,6 +301,36 @@ CREATE TABLE IF NOT EXISTS provider_api_keys (
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS provider_api_keys_provider_id_idx ON provider_api_keys (provider_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS pool_member_scores (
|
||||
id TEXT PRIMARY KEY,
|
||||
pool_kind TEXT NOT NULL,
|
||||
pool_id TEXT NOT NULL,
|
||||
member_kind TEXT NOT NULL,
|
||||
member_id TEXT NOT NULL,
|
||||
capability TEXT NOT NULL,
|
||||
scope_kind TEXT NOT NULL,
|
||||
scope_id TEXT,
|
||||
score REAL NOT NULL DEFAULT 0,
|
||||
hard_state TEXT NOT NULL DEFAULT 'unknown',
|
||||
score_version INTEGER NOT NULL DEFAULT 1,
|
||||
score_reason TEXT NOT NULL,
|
||||
last_ranked_at INTEGER,
|
||||
last_scheduled_at INTEGER,
|
||||
last_success_at INTEGER,
|
||||
last_failure_at INTEGER,
|
||||
failure_count INTEGER NOT NULL DEFAULT 0,
|
||||
last_probe_attempt_at INTEGER,
|
||||
last_probe_success_at INTEGER,
|
||||
last_probe_failure_at INTEGER,
|
||||
probe_failure_count INTEGER NOT NULL DEFAULT 0,
|
||||
probe_status TEXT NOT NULL DEFAULT 'never',
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_rank_idx ON pool_member_scores (pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC);
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_member_idx ON pool_member_scores (pool_kind, pool_id, member_kind, member_id);
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_probe_idx ON pool_member_scores (pool_kind, pool_id, probe_status, last_probe_success_at);
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_updated_at_idx ON pool_member_scores (updated_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS gemini_file_mappings (
|
||||
id TEXT PRIMARY KEY,
|
||||
file_name TEXT NOT NULL UNIQUE,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
CREATE TABLE IF NOT EXISTS pool_member_scores (
|
||||
id TEXT PRIMARY KEY,
|
||||
pool_kind TEXT NOT NULL,
|
||||
pool_id TEXT NOT NULL,
|
||||
member_kind TEXT NOT NULL,
|
||||
member_id TEXT NOT NULL,
|
||||
capability TEXT NOT NULL,
|
||||
scope_kind TEXT NOT NULL,
|
||||
scope_id TEXT,
|
||||
score REAL NOT NULL DEFAULT 0,
|
||||
hard_state TEXT NOT NULL DEFAULT 'unknown',
|
||||
score_version INTEGER NOT NULL DEFAULT 1,
|
||||
score_reason TEXT NOT NULL,
|
||||
last_ranked_at INTEGER,
|
||||
last_scheduled_at INTEGER,
|
||||
last_success_at INTEGER,
|
||||
last_failure_at INTEGER,
|
||||
failure_count INTEGER NOT NULL DEFAULT 0,
|
||||
last_probe_attempt_at INTEGER,
|
||||
last_probe_success_at INTEGER,
|
||||
last_probe_failure_at INTEGER,
|
||||
probe_failure_count INTEGER NOT NULL DEFAULT 0,
|
||||
probe_status TEXT NOT NULL DEFAULT 'never',
|
||||
updated_at INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_rank_idx
|
||||
ON pool_member_scores (pool_kind, pool_id, capability, scope_kind, scope_id, hard_state, score DESC);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_member_idx
|
||||
ON pool_member_scores (pool_kind, pool_id, member_kind, member_id);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_probe_idx
|
||||
ON pool_member_scores (pool_kind, pool_id, probe_status, last_probe_success_at);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS pool_member_scores_updated_at_idx
|
||||
ON pool_member_scores (updated_at);
|
||||
Reference in New Issue
Block a user