LLM review of flagged users #3
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
pleroma/forgejo-janitor!3
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/llm-review"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #2
[llm]config (off by default, key fromOPENAI_API_KEY). Flagged users (score > 0, never admins/allowlisted/protected org) go to the OpenAI Responses API with full profile, emails, last 20 issues/comments and READMEs; the verdict (ham/sanitize/restrict/prohibit + confidence) replaces the score thresholds. Each level needs confidence >= 0.7 (prohibit 0.9), else it drops a step.Testing: 95 unit tests, no network/DB. Not yet run against production; next step is a dry-run
scanwith[llm]enabled./oc review
opencode-agent:job=206:generation=1
Rating: 2/5 — request changes
Reviewed the full base-to-head diff at the claimed head plus surrounding code, and ran the suite (
python3 -m pytest tests -q→ 95 passed). The plumbing (confidence cascade, exemptions, cache fingerprinting, atomic cache save, failure-means-no-action) is sound and well tested, but two high-impact issues need fixing before merge, plus three medium ones.P1 — Attacker-controlled content can steer the verdict
forgejo_janitor/llm.py—build_requestsends the whole serialized context (profile fields, READMEs, issue/comment bodies) as one bare user message with no delimiters, andSYSTEM_PROMPTnever states that this content is untrusted third-party data.hamand the account is never acted on. For a spam-cleanup tool this is purpose-defeating: spammers get a reliable evasion primitive.P1 — Private repository content is sent to OpenAI
build_contextincludesis_privaterepos with their READMEs,GitRepoScanner.readmehas no privacy check, andfetch_review_datahas no repository-privacy filter on issues/comments. The suite even locks in private-README inclusion (test_build_context_contains_full_profile_counts_repos_and_heuristics).is_privaterepos (ideally drop private repos from the context) and filterfetch_review_datato public repositories, or gate private content behind an explicit opt-in.P2 — README collection is unbounded in size and count
GitRepoScanner.readmereturns the fullgit showoutput with nomax_file_bytescap (unlikescan, which caps at 64 KiB), andcli._attach_readmesfetches a README for every repo of every flagged user even thoughbuild_contextkeeps at most 10._captruncates it to 20000 chars.monitorthen retries the same work.scan's limit and only attach READMEs for repos that survive the 10-repo truncation.P2 — Cache entries skip verdict validation
lookup_cachebuildsLlmVerdictstraight from the cache file with none of the enum/range checksparse_verdictapplies.NaNconfidence.NaNis the sharp edge: every< thresholdcomparison isFalse, so a cachedprohibitwithNaNconfidence is treated as fully confident.prohibit_loginget planned without any model call ever happening.lookup_cachewith the same rules asparse_verdict, treating invalid entries as a cache miss.P2 — An LLM
prohibit/restrictverdict cannot clear content the heuristics missedplan_llm_actionsfunnels into_content_actions, which only quarantines/redacts heuristicspam_*_ids, and the model context carries no issue/comment/repo IDs for it to cite.prohibitbased on spam issues or comments the heuristics did not flag → login is blocked but the spam stays visible;restrictleaves all such content in place.prohibitnever happens for model-only detections, although the system prompt promises "clear spam (spam issues, comments or repositories), block login".Fixed in
a337474: untrusted-data prompt + delimiters, private repos/issues/comments excluded, README reads capped and limited to the sent repos, cached verdicts validated (NaN rejected). Model-only content redaction is documented as a known limit for now./oc review
opencode-agent:job=207:generation=1
Rating: 5/5 — approve
Re-reviewed the full base-to-head diff at the claimed head plus surrounding code, the follow-up fix commit, and the live discussion. The previous review's findings are resolved in the current code, and I found no new concrete defects. Test suite passes (
python3 -m pytest tests -q→ 107 passed).Prior findings — verified fixed
SYSTEM_PROMPTnow states the user message is untrusted account data, andbuild_requestdelimits it in<account_data>tags, with embedded instructions flagged as a spam signal.select_repositoriessends only public repos,fetch_review_datafiltersnot r.is_privatefor issues and comments, and READMEs are attached only for repos the model sees.GitRepoScanner.readmecaps atmax_file_bytes(64 KiB),_attach_readmesfetches only selected repos, andbuild_contextstill caps each body at 20000 chars.lookup_cachenow runs_validated_verdict(enum, finite 0–1 confidence, string reason), so corrupt entries — includingNaNconfidence — are treated as a miss.README.mdas a known limit (prohibiton model-only detections blocks login without redacting), so it is a disclosed tradeoff, not a hidden gap.Checks with no new findings
_effective_verdict), exemption handling (is_exemptmatches prior heuristic-path behavior), failure-means-no-action (review_results, monitor wrapper), atomic cache save, and fingerprint stability all read correctly and are covered by tests.fetch_review_dataSQL column/table references match the Forgejo schema used elsewhere indb.py.Note (not a finding)
scanwith[llm]enabled; that remains the sensible next step before relying on it.