crossrules

package
v0.2.5-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package crossrules is codefit's family of deterministic checks that reason over BOTH neutral inputs at once — the schema (db.Schema) AND the code's query filters (query.QueryFilter) — the code↔schema cross that index-vs-query needs (ADR 0029). It is DISTINCT from internal/core/dbrules (schema-only): a cross rule's Check takes two arguments, so it has its own Rule interface and runner.

Like dbrules, it lives in the core and NEVER imports a provider: both inputs are neutral core types (db.Schema from a SchemaParser, query.QueryFilter from a QueryExtractor), so the cross reasons over them without depending on any language. This is the whole point of the neutral query model — it lets the core cross code and schema without a core→provider edge. Locked by TestCoreCrossrules_NeverImportProvider.

This slice (0.2.x) ships the INFRASTRUCTURE only: the neutral model, the runner, and the reconciliation, with an EMPTY rule set — the seam proven end-to-end with no output change (ADR 0020). The first cross-rules, DB-010 (missing index on a filtered column) and DB-013 (missing composite index), are later slices built on this infra.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OwnedCategories

func OwnedCategories() []string

OwnedCategories are the baseline Item categories the cross rules produce. The adapter unions them into the db-dimension baseline scope (ADR 0019/0029) so the cross's surface items are tracked and pruned like every other db item — they are produced by the cross, not the schema-only db sensor, so they are declared here.

func Run

func Run(s *db.Schema, filters []query.QueryFilter) ([]findings.Finding, []findings.SurfaceItem)

Run executes the production rule set (All()) over the schema and query filters. A nil schema (no database) yields nothing; nil filters (the provider has no QueryExtractor, or nothing filters a column) means every rule sees an empty code side.

func RunWith

func RunWith(s *db.Schema, filters []query.QueryFilter, rules []Rule) ([]findings.Finding, []findings.SurfaceItem)

RunWith executes an EXPLICIT rule set over the schema and query filters — the injectable core of Run. Production calls Run (which passes All()); the seam gate passes an empty set so it proves the MERGE mechanism (that appending the runner's output leaves the db result byte-identical) independently of which rules All() happens to hold — otherwise the first real rule would put the seam gate red.

Types

type Rule

type Rule interface {
	ID() string
	Check(*db.Schema, []query.QueryFilter) ([]findings.Finding, []findings.SurfaceItem)
}

Rule is one deterministic check over BOTH neutral inputs — the schema AND the code's query filters. It is a DISTINCT family from dbrules.Rule (schema-only): the cross needs two arguments, so it has its own runner. Like dbrules, a rule emits affirmations (Findings, Confidence 1.0) and/or surface (SurfaceItems); it never sees a provider — both inputs are neutral (ADR 0029).

func All

func All() []Rule

All is the enumerated cross-rule set: DB-010 (single-column filter without a covering index, ADR 0030) and DB-013 (multi-column filter without a covering composite index, ADR 0031). The two partition every reconciled filter by its column count — DB-010 the single-column ones, DB-013 the multi-column ones — so they never double-report one filter. Both reuse reconcile and the shared coverage of core/db.

Jump to

Keyboard shortcuts

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