feat(sight): add conversation grader API#1395
Conversation
|
Nice to see the grader land as an independently reviewable unit — the scoring/verdict math itself checks out. A few observations: Test coverage of the core contracts
Two internal-consistency points
Minor: the four mechanical clippy rewrites (probes.rs / sslsniff.rs / storage/sqlite/token.rs / storage/unified.rs) are bundled here and also ride in #1393/#1394 — not a merge hazard (identical blobs), just extra review surface. |
|
Updated this PR in What changed in this follow-up:
Validation run on Linux:
The four mechanical clippy rewrite files mentioned as extra review surface were not changed in this follow-up. |
6c24616 to
8275385
Compare
Add a manual rule-based conversation grader over GenAI and interruption evidence with idempotent SQLite persistence. Keep the MVP backend-only. API handlers expose evaluate/latest endpoints, while evaluation runs reuse the shared server store and injected interruption store. Rebased with dashboard auth by wiring test AppState helpers with both the evaluation store and disabled auth state. Assisted-by: Codex:GPT-5 Signed-off-by: wanghao <1562495626@qq.com>
Resolved safety interruptions no longer affect the safety score. Interruption root-cause mapping now covers provider, context, token, retry, and loop signals called out in review. Add regression coverage for score weighting, verdict cutoffs, input hash stability, storage idempotency, evaluate API reuse/error branches, and the grader architecture boundary. Assisted-by: Codex:GPT-5 Signed-off-by: wanghao <1562495626@qq.com>
8275385 to
f36d6f2
Compare
|
Added a follow-up update for the required check failure. This latest push was specifically to address the
Root cause:
Fix pushed in the latest head
Validation:
|
|
Round-2 fresh pass on the updated PR (all 5 round-1 findings confirmed fixed — thanks for the thorough response). This pass looked at the whole grader, not just the delta. Two new findings worth addressing before merge: 1.
Common successful coding-agent tool output hits this: a pytest summary "5 passed, 2 failed" (matches "failed"), a grep through logs (matches "error:"), a build summary with warnings. When flagged, 2.
Concrete input: a single completed event with usable output and
Result: verdict=Pass, root_cause=ExcessiveCost, efficiency=Fail(0.35), summary="Conversation completed successfully with no deterministic quality issue.", action="No immediate action required." — self-contradictory. Four non-blocking notes (not gating merge):
|
Respect explicit tool result error flags before textual heuristics. Downgrade non-hard root causes and failed dimensions to warn verdicts. This avoids clean passes when deterministic evidence still requires review. High-cost conversations with usable output remain warnings instead of hard failures. Assisted-by: Codex:GPT-5 Signed-off-by: wanghao <1562495626@qq.com>
|
Updated in d9564c2 to address the two blocking grader notes:
Added regression coverage for both cases:
Validated on Linux test host:
|
jfeng18
left a comment
There was a problem hiding this comment.
Both blocking items from round 2 are addressed in d9564c21 — confirmed by reading the fix and CI (1053 tests pass):
-
is_error: falsenow authoritative (evidence.rs:67-69):tool_response_has_errorreturnsis_errordirectly when present (bothtrueandfalse), only falling through to text heuristics when the field is absent. The recursivevalue_has_error_signalhas the same guard on nested objects. A pytest summary like "5 passed, 2 failed" withis_error: falseno longer triggers a tool_failure — verified the test at evidence.rs:284. -
select_verdictno longer contradictsroot_cause/ failed dimensions (rule.rs:380-407): now checksroot_cause != RootCause::Noneandhas_failed_dimensionin the Warn gate. The 250k-token ExcessiveCost scenario (efficiency=0.35/Fail, weighted=0.94) correctly produces Warn instead of Pass.
LGTM on the grader.
Description
Add the AgentSight manual conversation grader backend. The API evaluates persisted GenAI and interruption evidence with a deterministic rule grader, stores idempotent
evaluation_runsin SQLite, and exposes evaluate/latest endpoints for dashboard clients.The store is initialized once in
AppState, interruption evidence is loaded from the existingInterruptionStore, and JSON conversion work stays outside the SQLite mutex. This PR also carries the narrow AgentSight docs for the grader API and includes current-toolchain mechanical clippy fixes needed for independent-D warningsvalidation.Related Issue
Refs #1304
Type of Change
Scope
cosh(copilot-shell)cosh-ng(cosh-ng)sec-core(agent-sec-core)skill(os-skills)sight(agentsight)tokenless(tokenless)ckpt(ws-ckpt)memory(agent-memory)anolisa(anolisa-cli)skillfs(SkillFS)Checklist
cosh: Lint passes, type check passes, and tests passcosh-ng:cargo clippy --all-targets -- -D warningsandcargo fmt --checkpasssec-core(Rust):cargo clippy -- -D warningsandcargo fmt --checkpasssec-core(Python): Ruff format and pytest passskill: Skill directory structure is valid and shell scripts pass syntax checksight:cargo clippy -- -D warningsandcargo fmt --checkpasstokenless:cargo clippy -- -D warningsandcargo fmt --checkpassmemory(Linux only):cargo clippy --all-targets -- -D warnings,cargo fmt --check, andcargo testpassanolisa:cargo clippy --all-targets --locked -- -D warnings,cargo fmt --all --check, andcargo test --lockedpassskillfs:cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspacepasspackage-lock.json/Cargo.lock)Testing
Ran on the Linux AgentSight test host from an archive of this split branch:
cargo fmt --all -- --checkcargo test -p agentsight grader --locked --quietcargo clippy -q -p agentsight --all-targets --locked -- -D warningsAdditional Notes
Split from #1349 following review feedback. The dashboard controls are intentionally left to a separate PR.