ports

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassifyIn

type ClassifyIn struct {
	File     string
	Fragment string
	Context  string
}

ClassifyIn is a fragment sent to an LLM.

type ClassifyOut

type ClassifyOut struct {
	RuleSuggestion string `json:"rule_suggestion"`
	Rationale      string `json:"rationale"`
	Confidence     string `json:"confidence"`
	Agent          string `json:"agent,omitempty"`
}

ClassifyOut is schema-validated LLM output.

type Cleaner

type Cleaner interface {
	CanClean(domain.Finding) bool
	Plan(u domain.Unit, findings []domain.Finding) (domain.Patch, error)
}

Cleaner plans byte-level mutations for a unit.

type Detector

type Detector interface {
	ID() string
	Families() []domain.Family
	Scan(ctx context.Context, u domain.Unit) ([]domain.Finding, error)
}

Detector scans one already-loaded unit.

type FileMeta

type FileMeta struct {
	Path    string
	RelPath string
	Size    int64
}

FileMeta is a walked filesystem entry.

type LLM

type LLM interface {
	Name() string
	Classify(ctx context.Context, in ClassifyIn) (ClassifyOut, error)
	Rewrite(ctx context.Context, in RewriteIn) (RewriteOut, error)
	Close() error
}

LLM is optional. The default implementation is a noop.

type Layers

type Layers struct {
	A         int      `json:"a"`
	Files     int      `json:"files"`
	B         int      `json:"b"`
	BOptional int      `json:"b_optional,omitempty" yaml:"b_optional,omitempty"`
	BFiles    []string `json:"b_files,omitempty" yaml:"b_files,omitempty"`
	Note      string   `json:"note,omitempty" yaml:"note,omitempty"`
}

Layers is the three-channel inspect summary (WR A / Files / B).

type Progress

type Progress interface {
	File(done, total int, path, detector string)
	Finding(domain.Finding)
	Finish()
}

Progress receives live scan updates. Calls are sequential.

type ProtectSpan

type ProtectSpan struct {
	Span   domain.Span
	Reason string
}

ProtectSpan is a region that defaults to report-only cleaning.

type Protector

type Protector interface {
	Protect(ctx context.Context, u domain.Unit) ([]ProtectSpan, error)
}

Protector optionally marks spans that must not be mutated unless aggressive.

type Report

type Report struct {
	FilesScanned int              `json:"files_scanned" yaml:"files_scanned"`
	FilesSkipped int              `json:"files_skipped" yaml:"files_skipped"`
	Findings     []domain.Finding `json:"findings" yaml:"findings"`
	Patches      []domain.Patch   `json:"patches,omitempty" yaml:"patches,omitempty"`
	DryRun       bool             `json:"dry_run,omitempty" yaml:"dry_run,omitempty"`
	Score        domain.Score     `json:"score" yaml:"score"`
	After        *domain.Score    `json:"after,omitempty" yaml:"after,omitempty"`
	Leftover     []domain.Finding `json:"leftover,omitempty" yaml:"leftover,omitempty"`
	Disclaimer   string           `json:"disclaimer,omitempty" yaml:"disclaimer,omitempty"`
	Streamed     bool             `json:"-" yaml:"-"`
	TextFiles    int              `json:"text_files,omitempty" yaml:"text_files,omitempty"`
	ImageFiles   int              `json:"image_files,omitempty" yaml:"image_files,omitempty"`
	DocFiles     int              `json:"doc_files,omitempty" yaml:"doc_files,omitempty"`
	DetectorHits map[string]int   `json:"detector_hits,omitempty" yaml:"detector_hits,omitempty"`
	Layers       *Layers          `json:"layers,omitempty" yaml:"layers,omitempty"`
}

Report is the formatter view of a scan.

type Reporter

type Reporter interface {
	Write(w io.Writer, res Report) error
}

Reporter writes a scan result.

type RewriteIn

type RewriteIn struct {
	Fragment string
	Context  string
	Strength string
}

RewriteIn asks the LLM to paraphrase a fragment.

type RewriteOut

type RewriteOut struct {
	Rewrite   string `json:"rewrite"`
	Rationale string `json:"rationale"`
}

RewriteOut is schema-validated LLM rewrite output.

type WalkFunc

type WalkFunc func(ctx context.Context, meta FileMeta) error

WalkFunc is called for each candidate file.

type Walker

type Walker interface {
	Walk(ctx context.Context, roots []string, fn WalkFunc) error
}

Walker enumerates files. Git-aware walkers can replace the FS walker later.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL