Skip to content

Make Claude v2 profile authoritative for TLS, session, and cache exits#2

Merged
dofastted merged 12 commits into
mainfrom
autoresearch/profile-sub2api-tls-id-ttl-profile-20260624
Jun 24, 2026
Merged

Make Claude v2 profile authoritative for TLS, session, and cache exits#2
dofastted merged 12 commits into
mainfrom
autoresearch/profile-sub2api-tls-id-ttl-profile-20260624

Conversation

@dofastted

Copy link
Copy Markdown
Owner

Summary

  • Add profile-owned TLS profile, session seed, and cache policy fields for Claude environment profiles.
  • Make profile-enabled requests authoritative across beta headers, metadata user_id session/device rewrite, cache TTL/breakpoint policy, main/count_tokens forwarding, retries, and OpenAI-compatible conversion send paths.
  • Add autoresearch workload covering legacy conflict exits and target metrics.

Review

  • Reviewed changed files across correctness, security, performance, readability, testing, and architecture dimensions.
  • No Critical or High findings found.
  • Main risk checked: request-attached profile TLS fallback behavior and count_tokens cache rewrite ordering.

Verification

  • bash autoresearch.sh
  • go test ./internal/service -count=1

Metrics

  • profile_conflict_count=0
  • profile_alignment_checks=3
  • profile_workload_cases=7

Claude Code via ted and others added 12 commits June 24, 2026 13:28
Benchmark entrypoint: bash autoresearch.sh
Goal: 分析近期 profile 模块与旧 sub2api 逻辑(TLS 指纹、会话 ID 伪装、缓存 TTL/断点替换、旧 header profile)是否冲突,并寻找让 profile 启动时作为唯一出口的改进点。
Result: {"status":"keep","profile_conflict_count":4,"profile_alignment_checks":3,"profile_workload_cases":8}
Result: {"status":"keep","profile_conflict_count":3,"profile_alignment_checks":3,"profile_workload_cases":7}
Result: {"status":"keep","profile_conflict_count":1,"profile_alignment_checks":3,"profile_workload_cases":6}
Result: {"status":"keep","profile_conflict_count":0,"profile_alignment_checks":3,"profile_workload_cases":5}
…he policy

Result: {"status":"keep","profile_conflict_count":0,"profile_alignment_checks":3,"profile_workload_cases":7}
Preserve existing per-OS device identity (client_id/device_id/session_seed)
when upgrading a legacy auto_default pool to schema v2 so upstream
fingerprints stay continuous. Reject already-v2 or missing pools, and clear
the legacy single-profile key to avoid stale fallback after migration.
…lly work

The VersionFetcherService never refreshed codex/claude CLI versions into
profiles due to three compounding defects: ua_auto_fetch defaulted to
disabled (Start returned immediately), the first fetch waited a full
interval after boot, and registry.Swap only updated an in-memory
atomic.Pointer with no persistence (lost on restart, never written to
profile/DB).

- Default gateway.ua_auto_fetch.enabled to true (config + deploy example)
- Bootstrap from DB on Start: load persisted versions into the registry
  so profiles use the last fetched version immediately on boot
- Fetch once immediately on Start before entering the ticker loop
- Split all-or-nothing: claude and codex fetch/persist independently so
  one side failing no longer discards the other's fresh version
- Persist fetched versions to the setting table
  (claude_cli_version JSON {cli,sdk}, codex_cli_version) and reload them
  on boot; falls back to hardcoded defaults when DB is empty
- Wire SettingRepository into NewVersionFetcherService
- Tests: update constructor signature, partial-success semantics, and
  add persistence / bootstrap coverage
…cleanup

The repository-presentation cleanup (9afaa31) rewrote the first comment
line of several migration files from "Sub2API" to "claude2api". This
changed their trimmed-content checksums while leaving DDL and resulting
schema identical. Existing deployments recorded the pre-cleanup checksums
in schema_migrations, so rebuilding the image from source fails startup
with a checksum mismatch.

Add compatibility rules for the four affected, already-applied files
(001_init, 002_account_type_migration, 003_subscription,
052_migrate_upstream_to_apikey) so the new checksum is accepted against
the legacy DB checksum without modifying migrations or the database.
051 is unaffected (its content trims to empty, identical checksum).
…PI gateway

- gofmt: normalize import grouping/ordering and indentation across service/handler files (no logic change)
- rebrand UI subtitle 'Subscription to API Conversion Platform' -> 'Local-first AI API gateway' (en.ts, SettingsView.vue, VISUAL_GUIDE.md)
)

32a46e3 covered the four files touched by 9afaa31's Sub2API->claude2api
cleanup but missed 038_ops_errors_..._classification.sql, which the same
cleanup also rewrote (first-line comment + one owner-normalization WHERE
condition sub2api->claude2api). The migration was already applied on the
green/sub2api-migrated DB, so DDL/data are unaffected; only its trimmed
checksum changed. Without this rule, rebuilding from source fails startup
with a 038 checksum mismatch (db=4cc121d9..., file=3281353a...).

Verified by booting the image against a restored production snapshot.
@dofastted dofastted merged commit cc9b4d5 into main Jun 24, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant