-
-
Notifications
You must be signed in to change notification settings - Fork 386
feat(proxy): CCHP 网关核心能力移植——流式内容门控 / 请求分离 Replay / 最长前缀亲和与缓存效果指标 #1356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3f8d194
refactor: replace redundant null-or guards with optional chaining
ding113 31bc3d6
feat(proxy): add stream gate, replay, affinity, and cache metrics
ding113 d46d113
Merge remote-tracking branch 'origin/dev' into cchp-gateway-porting
ding113 9cfcb72
style(probe-scheduler): reformat test.each array literals to multiline
ding113 4715c7e
fix(proxy): replace unsafe optional chaining in fingerprint test
ding113 fd2297d
chore: format code (cchp-gateway-porting-4715c7e)
github-actions[bot] 785221b
Merge remote-tracking branch 'origin/dev' into cchp-gateway-porting
ding113 b84a336
feat(db): add cache effectiveness and replay payload tables
ding113 d70547c
Merge remote-tracking branch 'origin/dev' into cchp-gateway-porting
ding113 ac9a64e
feat(proxy): add stream content gate and affinity routing settings
ding113 6f73e6c
feat(leaderboard): add cache coefficient column to provider boards
ding113 4aba48a
refactor(providers): remove per-provider cache effectiveness card
ding113 8279178
Merge remote-tracking branch 'origin/dev' into cchp-gateway-porting
ding113 918cddb
feat(db): add cache effectiveness, batch apply, and replay schema
ding113 942d371
fix(proxy): align forwarder and affinity mocks with merged APIs
ding113 aec4c76
refactor(discovery): remove DISCOVERY_ROLLOUT_PERCENT env canary
ding113 9da2f69
refactor: replace explicit null guards with optional chaining and Obj…
ding113 1dd3cb6
test(auth): add DB-less auth chain and my-usage action unit coverage
ding113 bb72b8b
test(proxy): expand guard pipeline and session-id error coverage
ding113 7aa7857
test: expand dashboard logs, session binding, and clipboard coverage
ding113 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| CREATE TABLE IF NOT EXISTS "provider_batch_apply_operations" ( | ||
| "claim_key" varchar(256) PRIMARY KEY NOT NULL, | ||
| "preview_token" varchar(256) NOT NULL, | ||
| "payload_fingerprint" varchar(128) NOT NULL, | ||
| "operation_id" varchar(256) NOT NULL, | ||
| "undo_token" varchar(256) NOT NULL, | ||
| "undo_expires_at" timestamp with time zone, | ||
| "undo_consumed_at" timestamp with time zone, | ||
| "status" varchar(32) NOT NULL, | ||
| "result" jsonb, | ||
| "expires_at" timestamp with time zone NOT NULL, | ||
| "created_at" timestamp with time zone DEFAULT now() NOT NULL, | ||
| "updated_at" timestamp with time zone DEFAULT now() NOT NULL | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE TABLE IF NOT EXISTS "provider_cache_effectiveness" ( | ||
| "id" serial PRIMARY KEY NOT NULL, | ||
| "provider_id" integer NOT NULL, | ||
| "model" varchar(128) NOT NULL, | ||
| "cache_ttl_bucket" varchar(10) NOT NULL, | ||
| "window_start" timestamp with time zone NOT NULL, | ||
| "window_end" timestamp with time zone NOT NULL, | ||
| "sample_count" integer DEFAULT 0 NOT NULL, | ||
| "eligible_count" integer DEFAULT 0 NOT NULL, | ||
| "theoretical_cache_tokens" bigint DEFAULT 0 NOT NULL, | ||
| "observed_cache_read_tokens" bigint DEFAULT 0 NOT NULL, | ||
| "raw_effectiveness_bp" integer DEFAULT 0 NOT NULL, | ||
| "confidence_bp" integer DEFAULT 0 NOT NULL, | ||
| "effectiveness_bp" integer DEFAULT 0 NOT NULL, | ||
| "created_at" timestamp with time zone DEFAULT now() | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE TABLE IF NOT EXISTS "replay_payloads" ( | ||
| "replay_id" varchar(64) PRIMARY KEY NOT NULL, | ||
| "verifier" varchar(64) NOT NULL, | ||
| "scope_tag" varchar(16) NOT NULL, | ||
| "key_id" integer NOT NULL, | ||
| "user_id" integer NOT NULL, | ||
| "format" varchar(16) NOT NULL, | ||
| "model" varchar(128), | ||
| "status_code" integer NOT NULL, | ||
| "headers_json" jsonb, | ||
| "payload" text NOT NULL, | ||
| "byte_size" integer NOT NULL, | ||
| "source_message_request_id" integer, | ||
| "created_at" timestamp with time zone DEFAULT now(), | ||
| "expires_at" timestamp with time zone NOT NULL | ||
| ); | ||
| --> statement-breakpoint | ||
| ALTER TABLE "message_request" ADD COLUMN "cache_compatibility_key" varchar(64);--> statement-breakpoint | ||
| ALTER TABLE "message_request" ADD COLUMN "cache_score_eligible" boolean;--> statement-breakpoint | ||
| ALTER TABLE "message_request" ADD COLUMN "cache_score_excluded_reason" varchar(32);--> statement-breakpoint | ||
| ALTER TABLE "message_request" ADD COLUMN "theoretical_cache_tokens" bigint;--> statement-breakpoint | ||
| ALTER TABLE "message_request" ADD COLUMN "cache_ttl_bucket" varchar(10);--> statement-breakpoint | ||
| ALTER TABLE "system_settings" ADD COLUMN "stream_gate_mode" varchar(10) DEFAULT 'enforce' NOT NULL;--> statement-breakpoint | ||
| ALTER TABLE "system_settings" ADD COLUMN "affinity_ignore_client_session_id" boolean DEFAULT true NOT NULL;--> statement-breakpoint | ||
| CREATE UNIQUE INDEX IF NOT EXISTS "uniq_provider_batch_apply_operations_preview_token" ON "provider_batch_apply_operations" USING btree ("preview_token");--> statement-breakpoint | ||
| CREATE UNIQUE INDEX IF NOT EXISTS "uniq_provider_batch_apply_operations_operation_id" ON "provider_batch_apply_operations" USING btree ("operation_id");--> statement-breakpoint | ||
| CREATE UNIQUE INDEX IF NOT EXISTS "uniq_provider_batch_apply_operations_undo_token" ON "provider_batch_apply_operations" USING btree ("undo_token");--> statement-breakpoint | ||
| CREATE INDEX IF NOT EXISTS "idx_provider_batch_apply_operations_expires_at" ON "provider_batch_apply_operations" USING btree ("expires_at");--> statement-breakpoint | ||
| CREATE INDEX IF NOT EXISTS "idx_provider_cache_effectiveness_window" ON "provider_cache_effectiveness" USING btree ("provider_id","model","window_start" DESC NULLS LAST);--> statement-breakpoint | ||
| CREATE INDEX IF NOT EXISTS "idx_replay_payloads_key_id" ON "replay_payloads" USING btree ("key_id");--> statement-breakpoint | ||
| CREATE INDEX IF NOT EXISTS "idx_replay_payloads_expires_at" ON "replay_payloads" USING btree ("expires_at"); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When PostgreSQL
ALTER TABLE … ADD COLUMN … DEFAULT 'enforce' NOT NULLruns, all existing rows insystem_settingsare immediately set tostream_gate_mode = 'enforce'. BecauseresolveStreamGateMode()reads the DB-cached value first (taking precedence over theSTREAM_GATE_MODEenv var whose default is'off'), stream content gating in full enforce mode activates for every deployment the moment this migration runs. The same is true foraffinity_ignore_client_session_id DEFAULT true. If the intent is a safe dark launch, both defaults should be'off'/falseto match the env-var defaults, with operators opting in by updating the system settings.Prompt To Fix With AI