{"modulePath":"github.com/codefit-cli/codefit","version":"v0.2.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package crossrules\n\nPackage 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.\n\nLike 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.\n\nThis 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.\n\n## Functions\n\n```go\nfunc OwnedCategories() []string\n```\nOwnedCategories 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.\n\n```go\nfunc Run(s *db.Schema, filters []query.QueryFilter) ([]findings.Finding, []findings.SurfaceItem)\n```\nRun 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.\n\n```go\nfunc RunWith(s *db.Schema, filters []query.QueryFilter, rules []Rule) ([]findings.Finding, []findings.SurfaceItem)\n```\nRunWith 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.\n\n## Types\n\n```go\ntype Rule interface {\n\tID() string\n\tCheck(*db.Schema, []query.QueryFilter) ([]findings.Finding, []findings.SurfaceItem)\n}\n```\nRule 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).\n\n```go\nfunc All() []Rule\n```\nAll 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.\n\n","path":"github.com/codefit-cli/codefit/internal/core/crossrules","name":"crossrules","synopsis":"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).","isRedistributable":true}
