Skip to content

feat(jev): Claim 判定合约与 Jev 客户端独立成模块 - #12

Merged
M09Ic merged 1 commit into
masterfrom
feat/jev
Sep 27, 2026
Merged

M09Ic merged 1 commit into
masterfrom
feat/jev

Conversation

@M09Ic

@M09Ic M09Ic commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

背景

fingers 的判定层(chainreactors/fingers#35)里有一套与指纹无关的通用机制:Claim 合约、校验、缓存和 Jev HTTP 客户端。这些不应该作为新抽象留在 fingers 中,因此下沉为 utils 的独立模块 github.com/chainreactors/utils/jev,fingers 只保留指纹相关的断言。

内容

  • 合约:Claim / Option / Outcome(holds / refuted / insufficient)/ Ruling。每个 Claim 必须显式提供 insufficient 弃权选项。Claim.Resolve(ruling, minConfidence) 是唯一的语义解释入口,低置信度解析为 Insufficient,但保留原始选项。
  • 校验:ValidateClaims、ValidateRulings。非法或缺失的回答算错误,不算证据不足。
  • 执行:Provider 接口和 jev.Judge(ctx, p, state, claims)。它校验输入,把证据冻结为 JSON,并校验完整回答。
  • 缓存:Cached(p, capacity) 对完整批次做精确 LRU,并合并并发的相同请求;失败的批次不缓存。
  • 客户端:Client / NewClient 对接 TypeSafe Jev(System One),遇到 429/529 按指数退避重试。DefaultMinConfidence = 0.3 是针对 jev-1.13.0 在 69 页验收集上标定的值。

模块为 go 1.17,只依赖标准库。说明见 jev/README.md。

测试

  • go1.17.13:go vet、go test 通过
  • go test -race 通过

测试内容覆盖合约校验、弃权、缓存(淘汰、失败不缓存、并发合并与取消),以及 HTTP 线上格式和 confidence 必填。

关联

🤖 Generated with Claude Code

Moves the provider-neutral judgement contract out of fingers/judge so
fingers keeps only fingerprint claims:

- Claim / Option / Outcome / Ruling, Claim.Resolve, ValidateClaims and
  ValidateRulings: a Provider picks one finite option per claim with a
  confidence; Resolve is the only interpretation of that pick.
- Provider interface and jev.Judge, which validates a batch, freezes the
  evidence as JSON once and validates the complete answer.
- Cached: exact LRU over whole batches with coalescing of identical
  concurrent requests; failures are never cached.
- Client: the TypeSafe Jev (System One) HTTP provider, with retry on
  429/529 and DefaultMinConfidence 0.3 calibrated for jev-1.13.0.

go 1.17, standard library only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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