Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0sec labs 0 Finding Generation Pattern

From Leeroopedia
Knowledge Sources
Domains Source_Code_Review, Finding_Management, Reporting
Last Updated 2026-10-29 00:00 GMT

Overview

Pattern documentation for the finding deduplication, severity ranking, and GitHub PR emission pipeline within the 0security agent loop.

Description

This is a Pattern Doc' — it documents the internal pipeline behavior of the 0security agent loop, not a single callable API. The finding generation pattern operates inside @0/cores agent loop: confirmed findings are deduplicated by location and signature, severity-ranked, and optionally emitted as GitHub PRs (--emit pr) with reproduction evidence and suggested patches. Unverified findings roll up into hypotheses.md. The --dry-run flag prints git/gh commands instead of executing them.

Usage

This pattern is invoked when the review workflow reaches Step 5. It is controlled by CLI flags on the review command — there is no separate import.

Code Reference

Source Location

  • Repository: 0security
  • File: packages/core/src/agent/ (agent loop, finding generation, dedup), packages/cli/src/commands/run.ts (emit pr wiring)

Pattern Specification

// The finding generation pattern is internal to the agent loop:
// 1. Agent loop produces raw findings (hypotheses + confirmed)
// 2. Findings are deduplicated by (file, line, rule_id) signature
// 3. Severity is ranked: critical > high > medium > low > info
// 4. If --emit pr:
//    a. For each reproduced finding: create a GitHub PR with repro + suggested patch
//    b. Base branch from --base (default main)
//    c. --dry-run prints git/gh commands instead of executing
// 5. Unverified findings roll up into hypotheses.md
// 6. Results persisted to SQLite via @0/db

// CLI flags controlling this pattern:
// --emit pr        Emit each reproduced finding as a GitHub PR
// --base <branch>  Base branch for PR (default main)
// --dry-run        Print git/gh commands instead of running them

I/O Contract

Inputs

Name Type Required Description
Confirmed findings Finding[] Yes /// From the agent loop
--emit string No /// "pr" for GitHub PR emission
--base string No /// Base branch (default main)
--dry-run boolean No /// Print commands instead of executing

Outputs

Name Type Description
Deduplicated findings Finding[] /// Severity-ranked, unique findings
GitHub PRs PR[] /// One per reproduced finding (when --emit pr)
hypotheses.md File /// Unverified findings roll-up

Usage Examples

Via CLI

# Emit GitHub PRs for reproduced findings
0 review ./repo --emit pr --base main

# Dry-run: see what PRs would be created
0 review ./repo --emit pr --dry-run

# Standard output (no PR emission)
0 review ./repo --format json

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment