Feedback model: learn ranking from analyst decisions #12

Open
amiryahaya wants to merge 5 commits from feat/feedback-model into main
Owner

Summary

The AI feature requested for the RSD demo — a model that helps the analysis and learns from what the analyst decides, implemented the honest way for this project:

decision journal (confirm/reject with pinned evidence)
  → training samples (verified against the evidence hash the analyst saw)
  → pure-Rust logistic model over the matcher's scaled feature deltas
  → learned re-ranking of future candidates + suggested novelty cutoff
  → UI: learned-model badge, learned % per candidate, "model suggestions, not confirmed findings"

No neural net, no Python, no new dependencies: a 3-weight logistic model trained by deterministic gradient descent, fully inspectable (weights published in the model card), versioned by content hash. Learning improves as the analyst uses the tool — the journal is the labeled dataset.

Evidence

  • Before: rankings used a fixed formula; analyst decisions were recorded but never learned from.
    After: POST /api/model/train learns from the journal (requires ≥4 decisions across both classes — honest 400s otherwise); GET /api/model exposes the model card; candidates?use_model=true re-ranks by learned probability and recomputes the state from the suggested cutoff. Browser-verified loop: 5 fixtures → 4 decisions → train → badge learned model fb1-… · 4 decisions, learned 75% per candidate, disclaimer caption, Relearn button.
  • Guardrails shipped: learned re-ranking is response-only — the persisted, hash-pinned ranked.json and CLI parity are untouched (byte-compare test); training verifies each event's pinned result_sha256 and skips tampered/mismatched evidence (test); fit numbers are labeled in-sample everywhere; suggestions never become confirmed findings (REPORT_SPEC distinction).
  • Local gates: module_gate.sh PASS for pattern-engine (93.29% package, learn.rs 100%) and web (85.35%); 121 workspace tests, 0 failed; fmt/Clippy clean.
  • Independent focused review verified the math (incl. L2-not-on-bias, sigmoid overflow safety) and found 2 MEDIUM + 3 LOW findings — all fixed (evidence-hash verification, UI disclaimer, mtime-based pruning protecting the active model, atomic pointer write, empty-candidate handling). docs/reviews/feedback-model.md. Commit d30bfba passed Forgejo run 54.

Merge Danger

Door: Two-way

Blast Radius: Additive endpoints + one UI surface; ranking evidence chain unchanged (test-pinned)

The model is a mechanism demo, not a validated classifier: with a handful of decisions the weights demonstrate learning, and the fit number says so in the UI and model card. No operational accuracy claim is made anywhere; suggestions require analyst confirmation like every other model output.

## Summary The AI feature requested for the RSD demo — a model that **helps the analysis and learns from what the analyst decides**, implemented the honest way for this project: ```text decision journal (confirm/reject with pinned evidence) → training samples (verified against the evidence hash the analyst saw) → pure-Rust logistic model over the matcher's scaled feature deltas → learned re-ranking of future candidates + suggested novelty cutoff → UI: learned-model badge, learned % per candidate, "model suggestions, not confirmed findings" ``` No neural net, no Python, no new dependencies: a 3-weight logistic model trained by deterministic gradient descent, fully inspectable (weights published in the model card), versioned by content hash. Learning improves as the analyst uses the tool — the journal *is* the labeled dataset. ## Evidence - **Before:** rankings used a fixed formula; analyst decisions were recorded but never learned from. **After:** `POST /api/model/train` learns from the journal (requires ≥4 decisions across both classes — honest 400s otherwise); `GET /api/model` exposes the model card; `candidates?use_model=true` re-ranks by learned probability and recomputes the state from the suggested cutoff. Browser-verified loop: 5 fixtures → 4 decisions → train → badge `learned model fb1-… · 4 decisions`, `learned 75%` per candidate, disclaimer caption, Relearn button. - Guardrails shipped: learned re-ranking is **response-only** — the persisted, hash-pinned `ranked.json` and CLI parity are untouched (byte-compare test); training verifies each event's pinned `result_sha256` and skips tampered/mismatched evidence (test); fit numbers are labeled in-sample everywhere; suggestions never become confirmed findings (REPORT_SPEC distinction). - Local gates: `module_gate.sh` PASS for pattern-engine (93.29% package, learn.rs 100%) and web (85.35%); **121 workspace tests, 0 failed**; fmt/Clippy clean. - Independent focused review verified the math (incl. L2-not-on-bias, sigmoid overflow safety) and found 2 MEDIUM + 3 LOW findings — all fixed (evidence-hash verification, UI disclaimer, mtime-based pruning protecting the active model, atomic pointer write, empty-candidate handling). `docs/reviews/feedback-model.md`. Commit `d30bfba` passed Forgejo run 54. ## Merge Danger **Door:** Two-way **Blast Radius:** Additive endpoints + one UI surface; ranking evidence chain unchanged (test-pinned) The model is a mechanism demo, not a validated classifier: with a handful of decisions the weights demonstrate learning, and the fit number says so in the UI and model card. No operational accuracy claim is made anywhere; suggestions require analyst confirmation like every other model output.
All checks were successful
Rust CI / rust-quality (push) Successful in 8m7s
Rust CI / rust-quality (pull_request) Successful in 9m49s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'feat/feedback-model:feat/feedback-model'
git switch 'feat/feedback-model'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'feat/feedback-model'
git switch 'feat/feedback-model'
git rebase 'main'
git switch 'main'
git merge --ff-only 'feat/feedback-model'
git switch 'feat/feedback-model'
git rebase 'main'
git switch 'main'
git merge --no-ff 'feat/feedback-model'
git switch 'main'
git merge --squash 'feat/feedback-model'
git switch 'main'
git merge --ff-only 'feat/feedback-model'
git switch 'main'
git merge 'feat/feedback-model'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/wavetree!12
No description provided.