providers

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package providers defines the LanguageProvider contract — the extensibility seam (PRD section 14). Each language implements this interface (tree-sitter queries, ecosystem best-practice rules, schema/ORM parsing, benchmark harness, test detection, review prompt context). Adding a language means implementing a provider; it never touches the core, the sensors, the MCP server, the CLI or the reporting.

The interface is parser-agnostic (ADR 0001): the provider owns its parser and returns findings via AnalyzeSecurity/AnalyzePractices, so adding a language never touches the core or the sensors. The Go provider (codefit's self-audit bootstrap) backs it with go/ast.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LanguageProvider

type LanguageProvider interface {
	// Identity.
	Language() string         // "go", "typescript", "java", "python"
	Frameworks() []string     // recognized frameworks
	FileExtensions() []string // e.g. [".go"], [".ts", ".tsx"]

	// DefaultPathCriticality returns sensible production/test/example defaults
	// for this ecosystem (RF-11), overridable in .codefit.yaml.
	DefaultPathCriticality() config.PathCriticality

	// AnalyzeSecurity runs the provider's language-specific static security
	// analysis (the AST layer of the pyramid) and returns deterministic
	// findings with their natural, pre-path-criticality severity.
	AnalyzeSecurity(src SourceFile) ([]findings.Finding, error)

	// AnalyzePractices runs the provider's best-practice checks.
	AnalyzePractices(src SourceFile) ([]findings.Finding, error)

	// AnalyzeSurface maps the auditable structural surface of a file (PRD
	// section 10): it enumerates, per category, every structure the agent
	// should reason about (e.g. HTTP handlers to verify authorization on). It
	// does not judge whether an item is vulnerable.
	//
	// Provisional: this parser-agnostic, provider-owns-analysis shape (ADR 0001)
	// is revisited in Fase 1 against the real TypeScript provider, where a
	// declarative SurfaceQuery model may replace it.
	AnalyzeSurface(src SourceFile) ([]findings.SurfaceItem, error)
}

LanguageProvider is the contract every supported language implements. The core depends only on this interface, never on a concrete language — which is what lets codefit scale to new languages without changing the engine.

The provider owns its parser (go/ast for Go, tree-sitter for TS/Java/Python later) and exposes analysis that returns findings, so the interface stays parser-agnostic (see ADR 0001).

type QueryExtractor added in v0.2.4

type QueryExtractor interface {
	ExtractQueryFilters(src SourceFile) ([]query.QueryFilter, error)
}

QueryExtractor is the optional capability a provider implements to extract the neutral query-filter facts from application code — the CODE side of the code↔schema cross (index-vs-query), mirroring how SchemaParser produces the SCHEMA side. It is intentionally NOT part of LanguageProvider: the caller resolves it by type-assertion (provider.(providers.QueryExtractor)), exactly as SchemaParser and CoverageManifest are resolved today (ADR 0014, ADR 0029). Convergence into LanguageProvider waits for a second real extractor to validate the shape.

It is per-file and filesystem-free, mirroring LanguageProvider.AnalyzeSurface: it receives one already-read SourceFile and returns the query filters found in it; the caller walks the project. A file with no column-filtering query yields nil — a query that filters nothing has nothing to cross against an index.

type SchemaParser added in v0.2.0

type SchemaParser interface {
	ParseSchema(sources []SourceFile) (*db.Schema, error)
}

SchemaParser is the optional capability a provider implements to parse a database schema into the neutral db.Schema model. It is intentionally NOT part of LanguageProvider: the caller resolves it by type-assertion (provider.(providers.SchemaParser)), exactly as codefit-coverage resolves CoverageManifest today — convergence into LanguageProvider waits for a second real parser to validate the shape (ADR 0003, ADR 0014).

The interface lives here, beside LanguageProvider, while its return type lives in core/db — mirroring how LanguageProvider.AnalyzeSurface returns findings.SurfaceItem. providers depends on core/db; core/db never depends on providers (the one-way dependency invariant of ADR 0014).

The implementation is filesystem-free: it receives the already-read SourceFiles (content in hand), never a path. The caller resolves cfg.Database.SchemaPaths from disk.

type SourceFile

type SourceFile struct {
	Path    string
	Content []byte
}

SourceFile is the input to a provider's analysis: a project-relative path and the file's raw content.

Directories

Path Synopsis
Package golang is the Go LanguageProvider.
Package golang is the Go LanguageProvider.
Package sqlddl is codefit's hand-written SQL-DDL parser.
Package sqlddl is codefit's hand-written SQL-DDL parser.
Package typescript is the TypeScript/TSX LanguageProvider.
Package typescript is the TypeScript/TSX LanguageProvider.

Jump to

Keyboard shortcuts

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