Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a401603
chore(risk): clean backend dead code, fix cache/log/panel inconsisten…
dofastted Dec 1, 2026
82325b4
chore(web): align risk audit copy, unify JEV/key status SSOT, and pru…
dofastted Dec 1, 2026
b9e61f1
docs(risk): sync risk-audit, JEV, and refusal-guard documentation wit…
dofastted Dec 1, 2026
5b7cfa2
fix(risk): sync dual-table session unban cache invalidation and onboa…
dofastted Dec 1, 2026
008e6ec
fix(risk): switch downgrade pool picker to unified /api/panel/pools a…
dofastted Dec 1, 2026
0622f85
fix(risk): align personal profile, jev:distill 429 disguise, and Code…
dofastted Dec 1, 2026
219f635
fix(risk): extract Gemini native contents, systemInstruction, and att…
dofastted Dec 1, 2026
8859485
refactor(risk,errors): unify policy/distill block errors to 400 SSOT …
dofastted Dec 1, 2026
b094784
chore(web): align risk 400 copy, remove dead jev_decision, and consol…
dofastted Dec 1, 2026
a1f77d8
perf(risk): eliminate ban cache invalidation storms, harden PG concur…
dofastted Dec 1, 2026
00d1cbc
perf(risk,jev): async batch JevUsageRepo, unify channel EntityCache s…
dofastted Dec 1, 2026
afac45d
perf(db): single-scan protocolEntryStats async offload and risk/jev i…
dofastted Dec 1, 2026
1ab4802
feat(risk,pg): wire async SWR stats, distill settings sync, bounded G…
dofastted Dec 1, 2026
9c1eb7f
chore(risk,pg): finish cross-branch consolidation for async refusal-g…
dofastted Dec 1, 2026
e3cc731
Merge remote-tracking branch 'origin/dev' into feat/jev-risk-overhaul
dofastted Dec 1, 2026
a903f85
Merge remote-tracking branch 'origin/dev' into feat/jev-risk-overhaul
dofastted Dec 1, 2026
15d1577
fix(risk,jev): resolve PR #2462 review findings (M1-M5, Minors 5-7)
dofastted Dec 1, 2026
26fa3e0
chore(merge): merge origin/dev into #2462 and renumber PG migration 0…
dofastted Dec 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
- **PostgreSQL + Redis 多级缓存**:支持 `deploy/install-pg.sh` 一键安装或从存量 SQLite 无缝迁移至 PostgreSQL 18 + Redis 8 L2 缓存,见 [PostgreSQL 迁移指南](docs/POSTGRES_MIGRATION.md)。
- **内容脱敏(可选)**:设置 →「脱敏」页(`/console/#/settings/redaction`)可配置凭据、个人信息与自定义规则;默认关闭。启用需本机 `bin/kin-redact`,helper 未就绪时不能保存为开启,请求也不会回落明文。
- **API 直连**:在 `#/api` 为渠道「获取模型」,已保存且未改配置的渠道会立即写入模型列表,新建或修改的渠道需点「保存」。生成密钥时选择「API 直连」和具体渠道;此密钥的 `/v1/models` 和推理都只用所选渠道,不经 OAuth / Codex 槽位。已有未绑定密钥沿用原协议范围,可编辑后绑定。Anthropic 端点可单独开关「风控前置审查」。
- **协议与计费**:官方 Claude Code 透传、缓存断点 TTL 与 `max_tokens` 默认值(如 Haiku 5.5 为 100K)与面板一致;GPT Image 模型可在 Chat / Responses 路径出图;第三方计费限制类上游错误写入拒答缓存(`refusal_guard`)。
- **协议与计费**:官方 Claude Code 透传、缓存断点 TTL 与 `max_tokens` 默认值(如 Haiku 5.5 为 100K)与面板一致;GPT Image 模型可在 Chat / Responses 路径出图;第三方计费限制类上游错误返回 400 `third_party_client`(不写拒答缓存,真实上游 400 按 10 分钟会话封锁处理)。
- **封控与配额**:决策模型支持多组 URL / Key;托管密钥可 `GET /v1/me/quota` 与 `GET /v1/me/usage`;租户可看用量统计,虚拟机只读(无代理与重新授权)。
- **面板与运维**:按角色隐藏无权页面;槽位官方登录执行 `claude auth login`;平滑停机时 `/health` 返回 503 `shutting_down`;控制面升级由 `panel-upgrade.sh` 重建控制面并调用 `fleet-services.mjs`(同步 `wrap-cli` 与 telemetry)及 `vm-maintain.mjs`;升级 CRAG 请通过面板 `/wrap` 或 `deploy/install.sh crag-update`,勿覆盖 `routing.json`、`vms/`、`data/`、`.env`。
- **集群**:支持运行中 / 冷迁移 Linux KVM 槽与内存扩容,见 [槽位迁移说明](docs/slot-migration.md)。
Expand Down Expand Up @@ -113,9 +113,9 @@

### 3️⃣ 封控拦截与风险审计

推理出站前检查设备/会话封禁、禁用工具、系统提示词改写(可关闭)、蒸馏、硬正则和拒答缓存。通过硬规则后,Jev 只审核用户会话和可解析的内联文件文本,并在常规放行、指定账号池/渠道、指定模型和拒绝之间选择。没有身份字段的第三方请求不因此被封禁。
推理出站前检查设备/会话封禁、禁用工具、系统提示词改写(可关闭)、蒸馏、硬正则和拒答缓存。通过硬规则后,JEV 只审核用户会话和可解析的内联文件文本,并在常规放行、指定账号池/渠道、指定模型和拒绝之间选择。没有身份字段的第三方请求不因此被封禁。

「风险审计」(`/console/#/risk`)展示封禁原因和原请求、上游 HTTP 400,以及实际降级出站次数。默认设备封禁阶梯为 10 分钟、24 小时、永久;违规会话持续封锁。普通上游 400 不计违规。
「风险审计」(`/console/#/risk`)展示封禁原因和原请求、上游 HTTP 400,以及实际降级出站次数。默认设备封禁阶梯为 10 分钟、10 分钟、永久(`[10, 10, 0]`,非递减);违规会话持续封锁。普通上游 400 不计违规。

细则:[docs/RISK.md](docs/RISK.md)。

Expand Down Expand Up @@ -300,7 +300,7 @@ Current v1.5 baseline (`VERSION=1.5.006`; see [CHANGELOG.md](CHANGELOG.md) for f
- **PostgreSQL + Redis multi-tier cache**: One-line install or seamless SQLite migration to PostgreSQL 18 + optional Redis 8 L2 cache via `deploy/install-pg.sh`—see [docs/POSTGRES_MIGRATION.md](docs/POSTGRES_MIGRATION.md).
- **Redaction (optional)**: Settings → Redaction (`/console/#/settings/redaction`). Off by default; requires local `bin/kin-redact`—no plaintext fallback when the helper is missing.
- **Direct API**: Panel API config at `#/api`; `api` keys route to upstream by endpoint protocol, not OAuth/Codex slots. Anthropic endpoints can enable pre-hop risk review separately.
- **Protocol & billing**: Official Claude Code passthrough, cache TTL, and default `max_tokens` align with the panel; GPT Image works via Chat/Responses; upstream third-party billing limits map to `refusal_guard` + refusal cache.
- **Protocol & billing**: Official Claude Code passthrough, cache TTL, and default `max_tokens` align with the panel; GPT Image works via Chat/Responses; upstream third-party billing limits return 400 `third_party_client` (not added to the refusal cache; real upstream 400s apply a 10-minute session block).
- **Gates & tenants**: Decision model supports multiple URL/key sets; keys expose `GET /v1/me/quota` and `GET /v1/me/usage`; tenant stats and read-only VM views.
- **Panel & ops**: Role-based page access; slot login runs `claude auth login`; draining upgrades expose 503 on `/health`. Panel upgrades recreate the control plane and run `fleet-services.mjs` (`wrap-cli` + telemetry) and `vm-maintain.mjs`; upgrade CRAG via `/wrap` or `deploy/install.sh crag-update`, and never overwrite `routing.json`, `vms/`, `data/`, or `.env`.
- **Cluster**: Live and cold KVM slot migration plus RAM resize—[docs/slot-migration.md](docs/slot-migration.md).
Expand Down Expand Up @@ -331,9 +331,9 @@ Nine pillars for anti-ban emulation and production operations:

### 3️⃣ Pre-hop risk gates

Before inference egress, hard rules check device and session bans, blocked tools, system-prompt rewrites, distillation, regex rules, and cached refusals. Jev reviews only user turns and readable inline file text, then can allow the standard route, narrow it to a configured pool or channel, select a configured model, or reject the request.
Before inference egress, hard rules check device and session bans, blocked tools, system-prompt rewrites, distillation, regex rules, and cached refusals. JEV reviews only user turns and readable inline file text, then can allow the standard route, narrow it to a configured pool or channel, select a configured model, or reject the request.

The **Risk** page (`/console/#/risk`) links bans to their source logs and lists upstream HTTP 400s and actual downgraded requests separately. The default device ban ladder is 10 minutes, 24 hours, then permanent. Ordinary upstream 400s do not count as violations. Full rules: [docs/RISK.md](docs/RISK.md).
The **Risk** page (`/console/#/risk`) links bans to their source logs and lists upstream HTTP 400s and actual downgraded requests separately. The default device ban ladder is 10 minutes, 10 minutes, then permanent (`[10, 10, 0]`, non-decreasing). Ordinary upstream 400s do not count as violations. Full rules: [docs/RISK.md](docs/RISK.md).

### 4️⃣ Completely Isolated Network (1 VM = 1 Egress)
- **Zero Cross-Account Contamination**: Every VM slot is strictly bound to its own dedicated SOCKS5 proxy or local egress gateway.
Expand Down
4 changes: 2 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ curl -sS http://127.0.0.1:8787/health
|------|-----------|
| `authentication_error` | 401 |
| `permission_error` | 403 |
| `policy_blocked`(拒答守卫) | 400 |
| `policy_blocked`(拒答守卫 / 硬正则 / 蒸馏默认) | 400 |
| `invalid_request_error` | 400 |
| `rate_limit_error` | 429 |
| `quota_error` | 429 |
Expand All @@ -442,7 +442,7 @@ curl -sS http://127.0.0.1:8787/health
| `upstream_error` | 401/403/502 |
| `api_error` | 500 |

Claude Code Usage Policy `API Error`(含内核报成 400 的)不换号、不修复重试,客户端收到 400 `policy_blocked` / `refusal_guard`,避免 Claude Code 误提示 `/login` 或按一般 400 做修复重试;并把该 prompt 永久写入拒答缓存;再次相同请求,或用户正文与已缓存正文的估计 Jaccard 达到面板阈值(默认 0.90,可选 0.80/0.85/0.90/0.95),都在 hop 前被拦。上游 HTTP 400/503「Third-party apps now draw from your extra usage」和「no third-party apps allowed」是计费限制(Anthropic 把调用方认成第三方客户端,而该号没有 extra usage),不是拒答:客户端收到 400 `third_party_client`(`invalid_request_error`,`details.upstream_message` 带上游原文,`retryable: false`),不换号、不冷却槽位,不写拒答缓存、不封会话或设备,请求日志归「请求格式」,不计 SLA 失败。`content_policy`、`cyber_policy`、`moderation_blocked` 等内容错误码(含 `upstream_code`)同样入库。协议硬正则,或面板所选的 Jev / Laya / ModernBERT(`/v1/systemone`,`noul ≥ 0.5`)判为 NSFW、蒸馏、破解、破限时返回 403 `policy_blocked`,不 hop,不写入拒答缓存;device 封禁开启时封禁入站 device。模型不可用且 `fail_open` 为 false 时同样 403,文案写明决策模型不可用,不封设备。近似和 device 封禁可在面板关闭。拒答命中在 device 封禁开启时还会永久封禁该入站 device id。400 的原文后追加原因,`details.reason` 为 `device` / `exact` / `similar`。
Claude Code Usage Policy `API Error`(含内核报成 400 的)不换号、不修复重试,客户端收到 400 `policy_blocked` / `refusal_guard`,避免 Claude Code 误提示 `/login` 或按一般 400 做修复重试;并把该 prompt 永久写入拒答缓存;再次相同请求,或用户正文与已缓存正文的估计 Jaccard 达到面板阈值(默认 0.90,可选 0.80/0.85/0.90/0.95),都在 hop 前被拦。上游 HTTP 400/503「Third-party apps now draw from your extra usage」和「no third-party apps allowed」是计费限制(Anthropic 把调用方认成第三方客户端,而该号没有 extra usage),不是拒答:客户端收到 400 `third_party_client`(`invalid_request_error`,`details.upstream_message` 带上游原文,`retryable: false`),不换号、不冷却槽位、不写拒答缓存、不封设备,但真实上游 400 在开启「封锁拒答会话」时会临时封锁当前会话 10 分钟(`upstream_400:third_party_client`),请求日志归「请求格式」,不计 SLA 失败。`content_policy`、`cyber_policy`、`moderation_blocked` 等内容错误码(含 `upstream_code`)同样入库。协议硬正则命中(含系统提示词改写、禁用工具与内置类别正则)以及默认蒸馏拦截统一返回 400 `policy_blocked`(`details.retryable: false`,避免 Claude Code 将 403 误判为登录失效;蒸馏仍支持在 `distill-rules.json` 或面板中显式覆盖状态码与文案),不 hop、不写入拒答缓存,仅拒绝本次请求而不封设备或会话(其中 NSFW 类别强制走设备阶梯封禁,思考泄露类蒸馏硬正则仅封锁当前会话 10 分钟)。面板配置的 JEV 决策模型(`/v1/systemone`,默认高分安全、`noul < 0.5` 拦截)命中后不 hop、不写入拒答缓存:临界单次拦截、临时冷却及 `jev:distill`(仅封会话 10 分钟)对外返回 429 `pool_overloaded` 伪装过载(带 `Retry-After`),触发永久封禁(默认第 3 次)时返回 400 `refusal_guard`;模型不可用且 `fail_open` 为 false 时返回 503(`overloaded_error` / `policy_blocked`),文案写明决策模型不可用,不封设备。近似和 device 封禁可在面板关闭。拒答命中在 `device_block_enabled` 开启时按设备封禁阶梯(默认 `[10, 10, 0]`,即第 1 次 10 分钟、第 2 次 10 分钟、第 3 次永久,非递减)封禁该入站设备。400 的原文后追加原因,`details.reason` 为 `device` / `exact` / `similar`。

号池结果分开返回,不互相伪装:

Expand Down
Loading
Loading