Documentation
¶
Overview ¶
Package config is AUR-452's seam: "context providers" that feed additional, UNTRUSTED material into the review call, plus the small set of EXPLICIT, human-authored settings (rule on/off, severity override, ignored paths) that this repository's own .aurumcode/config.yml has authority to change.
This card is the foundation four later cards build on: AUR-468 (skills), AUR-469 (MCP) and AUR-470 (RAG) each add a ContextProvider; AUR-471 adds an ISO policy provider. From the engine's point of view all of them are the same thing -- a named source of free text handed to the model as background -- which is exactly what ContextProvider (provider.go) captures.
THE SECURITY BOUNDARY THAT EVERY LATER CARD INHERITS ¶
Content that arrives through a ContextProvider -- a repository prompt file, a skill, an MCP tool result, a RAG chunk -- is DATA, never an instruction to this program. It can only ever reach the outbound model prompt as clearly labeled background text (see BuildContextBlock). It is never parsed for directives, and nothing in this package (or in cmd/aurumcode's wiring of it) inspects provider text to decide whether a rule is enabled, what severity a finding gets, where --fail-on's threshold sits, whether secret redaction runs, or what the cost ceiling is. Those five things are controlled exclusively by two things this package also owns: the EXPLICIT, versioned Config a human wrote (rules/ignore, this file) and code (--fail-on, redaction and --limite remain entirely outside this card, in cmd/aurumcode and internal/security/redaction, untouched). ApplyRuleConfig (rules.go) reads only Config; it has no parameter through which provider text could reach it even if a caller wanted that. tests/unit/AUR-452.go proves the split explicitly: a provider whose contributed text asks to disable a rule sits in the assembled prompt, verbatim, and the rule gate is unmoved.
Index ¶
- Constants
- func ApplyRuleConfig(issues []types.ReviewIssue, cfg *Config) []types.ReviewIssue
- func BuildContextBlock(ctx context.Context, providers []ContextProvider, changedPaths []string, ...) (string, error)
- func FilterIgnoredPaths(diff *types.Diff, cfg *Config) *types.Diff
- func NormalizeReviewLanguage(raw string) (string, error)
- func NormalizeReviewPublication(raw string) (string, error)
- func ReviewLanguageLabel(language string) string
- func WrapProvider(ctx context.Context, base llm.Provider, providers []ContextProvider, ...) (llm.Provider, error)
- type Config
- type ContextFile
- type ContextProvider
- type FileContextProvider
- type PathInstructionsProvider
- type ProviderWarning
- type RepoPromptProvider
- type ReviewConfig
- type ReviewContextConfig
- type RuleConfig
- type TextContextProvider
Constants ¶
const DefaultConfigPath = ".aurumcode/config.yml"
DefaultConfigPath is where Load looks, relative to the repository root.
const DefaultReviewLanguage = "en-US"
const DefaultReviewPromptPath = ".aurumcode/prompt.md"
const DefaultReviewPublication = "comments"
DefaultReviewPublication preserves the original PR behavior for callers that do not opt into the formal GitHub review endpoint. Empty configuration keeps direct CLI consumers backwards-compatible while making the newer mode available without extra plumbing.
const MaxProviderContributionBytes = 64 * 1024
MaxProviderContributionBytes bounds one provider's contributed text. This is also this card's second, independent defense for the cost ceiling (see contextInjectingProvider.Tokens in wrap.go, the primary fix): even if a future provider's token accounting were ever wrong, no single contribution can grow the outbound prompt by more than this many bytes. Exceeding it is a loud error, never a silent truncation -- a truncated contribution could cut a sentence into something that reads as the opposite of what it said.
const ProviderTimeout = 10 * time.Second
ProviderTimeout bounds a single ContextProvider.Provide call. AUR-469 (MCP) is the case this exists for: an external tool call that hangs must not hang the review it was supposed to inform. A provider that needs longer for a specific, known-slow operation is a later card's decision to make explicit (e.g. its own internal caching), not a reason to raise this shared ceiling.
Variables ¶
This section is empty.
Functions ¶
func ApplyRuleConfig ¶
func ApplyRuleConfig(issues []types.ReviewIssue, cfg *Config) []types.ReviewIssue
ApplyRuleConfig is the ONLY place a rule's enabled/severity state changes after the reviewer produced its findings, and it reads ONE input for that decision: cfg, the explicit, human-authored .aurumcode/config.yml. Its signature has no parameter through which ContextProvider text could reach it -- that is the enforcement mechanism for the package doc's security boundary, not a convention this function has to remember to honor.
An issue whose RuleID cfg explicitly disables (rules.<id>.enabled: false) is dropped. An issue whose RuleID carries an explicit severity override adopts it, everything else about the issue unchanged. An issue whose RuleID has no entry in cfg.Rules -- every issue, whenever cfg is the zero-config Config{} Load returns for a missing file -- passes through unchanged: same slice contents, same order.
func BuildContextBlock ¶
func BuildContextBlock(ctx context.Context, providers []ContextProvider, changedPaths []string, filter *redaction.Filter) (string, error)
BuildContextBlock queries every provider in order (each bounded by callProviderBounded) and renders their non-empty contributions into one block. Provider failures are returned as warnings and do not discard the rest of the review; contribution-size violations remain hard errors.
All contributions are redacted once more after concatenation. This second pass is essential: a registered secret split across two providers is not visible to either per-provider pass, but is visible in the assembled block. The source names are listed separately so the redaction input can preserve a plain newline boundary between contributions.
Returns "" when no provider had anything to contribute -- the exact zero-config signal WrapProvider uses to leave the base LLM provider completely unwrapped.
func FilterIgnoredPaths ¶
FilterIgnoredPaths drops files matching any of cfg.Ignore's glob patterns from diff, before either review pass (the LLM quality pass or the deterministic --seguranca pass) ever sees them. Zero-config (cfg nil, or cfg.Ignore empty) returns diff completely UNCHANGED -- the same *types.Diff pointer, not a copy -- so a caller comparing before/after by identity, not merely by value, still sees no difference at all.
func NormalizeReviewLanguage ¶ added in v1.0.9
NormalizeReviewLanguage validates and canonicalizes the small supported language list. Empty means the stable product default.
func NormalizeReviewPublication ¶ added in v1.0.18
NormalizeReviewPublication accepts the public mode names and a Portuguese spelling useful in repository configuration. The returned values are stable internal names used by the PR publisher.
func ReviewLanguageLabel ¶ added in v1.0.9
ReviewLanguageLabel returns the human-readable label used in the prompt.
func WrapProvider ¶
func WrapProvider(ctx context.Context, base llm.Provider, providers []ContextProvider, changedPaths []string, filter *redaction.Filter) (llm.Provider, error)
WrapProvider composes providers' contributions for changedPaths into one redacted block (BuildContextBlock, which applies the same AUR-009 filter internal/review.Reviewer runs over the diff -- including a second pass after contributions are assembled) and returns an llm.Provider that appends that block to every outbound prompt before forwarding to base, with its Tokens accounting adjusted to match (see the type doc above).
THE ZERO-CONFIG GUARANTEE: when providers is empty, or every provider contributes nothing for changedPaths (no .aurumcode/prompt.md, no matching .aurumcode/instructions/*.md -- the case with no repository files at all), WrapProvider returns base UNCHANGED: the exact same llm.Provider value, not a zero-effect wrapper around it. A caller that sends a prompt through the returned value therefore calls base's own Complete directly, with the exact same argument bytes, so the review's outbound request -- and everything downstream of it, cost accounting included -- is provably identical to what runs with no config package involved at all.
Types ¶
type Config ¶
type Config struct {
// Review contains non-authoritative presentation preferences and curated
// context paths for the published code review. An empty section keeps the
// product default.
Review ReviewConfig `yaml:"review"`
// Rules maps a rule_id (e.g. "security/hardcoded-secret") to the
// explicit override this repository wants for it. A rule_id absent
// from this map keeps the engine's built-in behavior untouched.
Rules map[string]RuleConfig `yaml:"rules"`
// Ignore is a list of glob patterns (Copilot/gitignore-style; "**"
// matches any number of path segments) whose matching files are
// dropped from the diff before either review pass ever sees them.
Ignore []string `yaml:"ignore"`
}
Config is the versioned, human-authored settings file this card reads from .aurumcode/config.yml at the repository root. Every field here is explicit configuration, never provider-contributed text -- see the package doc's security boundary.
func Load ¶
Load reads root/.aurumcode/config.yml. THE ZERO-CONFIG CONTRACT: a missing file returns an empty, non-nil *Config and a nil error -- every caller in this package and in cmd/aurumcode treats "no file" exactly like "a file with nothing in it", and both leave every downstream function (ApplyRuleConfig, FilterIgnoredPaths, WrapProvider) a documented no-op. A file that exists but fails to parse is a loud error, never a silently-empty config: a config the user actually wrote that this program could not read must not be read as "the user configured nothing".
func LoadPath ¶ added in v1.0.9
LoadPath reads one explicit configuration path. A missing path is the zero-config case; a path that exists but cannot be parsed is a loud error.
func Parse ¶ added in v1.0.9
Parse decodes configuration bytes fetched from a repository API or read from disk. The source is included in errors so a remote PR failure remains actionable without printing the file contents.
func (*Config) ReviewLanguage ¶ added in v1.0.9
ReviewLanguage returns the canonical configured language tag. It is a closed, presentation-only choice: arbitrary text must never become a new instruction inside the review prompt.
func (*Config) ReviewPublication ¶ added in v1.0.18
ReviewPublication returns the canonical publication mode. Empty config is the zero-configuration, backwards-compatible comments mode.
type ContextFile ¶ added in v1.0.21
ContextFile describes one configured context contribution in deterministic order. The default prompt is optional for backwards compatibility; every path explicitly written by the repository is required and produces an actionable configuration error if it cannot be loaded.
type ContextProvider ¶
type ContextProvider interface {
// Name identifies this provider in the rendered prompt and in
// evidence/diagnostics. Stable across calls.
Name() string
// Provide returns free-text background for the given changed paths.
// Returning "" (with a nil error) means "nothing to contribute for
// this review" -- the zero-config path requires every provider to
// answer this way when it finds nothing, so a review with no matching
// file and no repository prompt stays byte-identical to a review with
// zero providers registered at all. Provide must respect ctx
// cancellation/deadline promptly: BuildContextBlock races it against
// ProviderTimeout regardless of whether the provider itself honors
// ctx, but a provider that does honor it (an HTTP call, an MCP
// request) frees its own resources instead of leaking a goroutine
// past the timeout.
Provide(ctx context.Context, changedPaths []string) (string, error)
}
ContextProvider is the extension seam AUR-468 (skills), AUR-469 (MCP) and AUR-470 (RAG) implement. Every source of context injected into the review call -- a file, a skill package, an MCP tool, a repository index -- is, from the engine's point of view, exactly this: a named source of free text, scoped to the files under review.
A provider's returned text is UNTRUSTED DATA (see package doc). It can only ever become background material appended to the outbound model prompt (BuildContextBlock); it is never inspected for directives, so a provider cannot enable/disable a rule, change a finding's severity, loosen --fail-on, disable secret redaction, or change the cost cap -- nothing in this package's API even accepts provider text at the call sites that decide those five things.
Provide takes a ctx that BuildContextBlock bounds to ProviderTimeout: a provider that hangs (an unreachable MCP server, a stalled RAG index) must fail the review loudly within that bound, never hang it indefinitely. A provider's returned text is also bounded to MaxProviderContributionBytes; a provider that returns more is a loud error, never a silent truncation (the same "fail high, never truncate silently" rule internal/prompt.ValidateRuleCatalog already applies to the rule catalog).
func ConfiguredProviders ¶ added in v1.0.21
func ConfiguredProviders(root string, cfg *Config) []ContextProvider
ConfiguredProviders preserves the zero-config providers and adds the explicit context lists from review.context. The built-in review prompt is always assembled separately; these files are additive background only.
func DefaultProviders ¶
func DefaultProviders(root string) []ContextProvider
DefaultProviders returns Camada 1's two file providers rooted at root, in the fixed order their contributions are rendered: the repository- wide prompt first, then path-scoped instructions. AUR-468 (skills), AUR-469 (MCP), AUR-470 (RAG) and AUR-471 (ISO policy) append their own providers to a slice built the same way; this function's return type (ContextProvider) and this ordering convention are the contract they build against.
type FileContextProvider ¶ added in v1.0.21
type FileContextProvider struct {
Root string
File ContextFile
}
FileContextProvider reads one explicitly configured prompt, skill or documentation file from the local repository. Unlike the historical repository prompt, a configured file is intentional: a missing path is an error that the caller surfaces as a provider warning with the exact path.
func NewFileContextProvider ¶ added in v1.0.21
func NewFileContextProvider(root string, file ContextFile) *FileContextProvider
func (*FileContextProvider) Name ¶ added in v1.0.21
func (p *FileContextProvider) Name() string
type PathInstructionsProvider ¶
type PathInstructionsProvider struct{ Dir string }
PathInstructionsProvider reads every *.md file directly under .aurumcode/instructions/, each carrying a Copilot-style `applyTo` front-matter glob, and contributes the body of every file whose glob matches at least one changed path. A file with no applyTo is inert (never applied) rather than silently global -- an author who forgot the glob gets no contribution instead of an unexpectedly repo-wide one. No directory, or a directory with nothing matching: Provide returns "", nil -- the zero-config path.
func NewPathInstructionsProvider ¶
func NewPathInstructionsProvider(root string) *PathInstructionsProvider
NewPathInstructionsProvider roots the provider at root/.aurumcode/instructions.
func (*PathInstructionsProvider) Name ¶
func (p *PathInstructionsProvider) Name() string
type ProviderWarning ¶
ProviderWarning is a sanitized, user-facing notice that one optional context source was unavailable. The review remains valid without that source; callers must surface every warning instead of silently dropping it.
func BuildContextBlockWithWarnings ¶
func BuildContextBlockWithWarnings(ctx context.Context, providers []ContextProvider, changedPaths []string, filter *redaction.Filter) (string, []ProviderWarning, error)
BuildContextBlockWithWarnings is the warning-aware form used by the CLI. Provider failures are recoverable because context is advisory; malformed repository configuration is still caught earlier by config.Load.
func WrapProviderWithWarnings ¶
func WrapProviderWithWarnings(ctx context.Context, base llm.Provider, providers []ContextProvider, changedPaths []string, filter *redaction.Filter) (llm.Provider, []ProviderWarning, error)
WrapProviderWithWarnings composes optional context and returns the recoverable provider failures that the caller must announce. A failed provider is omitted from the block; a hard contribution-limit error still returns an error because silently sending a truncated context is unsafe.
type RepoPromptProvider ¶
type RepoPromptProvider struct{ Path string }
RepoPromptProvider reads one repository-wide instructions file (.aurumcode/prompt.md by default) and contributes its content, verbatim and untrusted, to every review -- the "prompt do repositorio sobrepondo o embutido" provider this card's Outcome names: it is layered ON TOP OF the engine's built-in review instructions as an extra, clearly-labeled section (see BuildContextBlock), never a silent replacement of them. Absent file: Provide returns "", nil -- the zero-config path.
func NewRepoPromptProvider ¶
func NewRepoPromptProvider(root string) *RepoPromptProvider
NewRepoPromptProvider roots the provider at root/.aurumcode/prompt.md.
func (*RepoPromptProvider) Name ¶
func (p *RepoPromptProvider) Name() string
type ReviewConfig ¶ added in v1.0.9
type ReviewConfig struct {
Language string `yaml:"language"`
Publication string `yaml:"publication"`
InlineComments bool `yaml:"inline_comments"`
Context ReviewContextConfig `yaml:"context"`
}
ReviewConfig contains the small set of presentation and context preferences that are safe to keep with a repository. It deliberately does not expose rule gates, redaction, cost ceilings, or permissions through this section.
func (ReviewConfig) ContextFiles ¶ added in v1.0.21
func (c ReviewConfig) ContextFiles() []ContextFile
ContextFiles returns the configured context in the order rendered to the model: repository prompt, skills, then documentation. An omitted prompt keeps the historical optional .aurumcode/prompt.md convention.
func (ReviewConfig) ValidateContext ¶ added in v1.0.21
func (c ReviewConfig) ValidateContext() error
ValidateContext rejects paths that could escape the repository in local mode. Context files are advisory model input, but local execution must not turn a repository-authored YAML value into an arbitrary filesystem read.
type ReviewContextConfig ¶ added in v1.0.21
type ReviewContextConfig struct {
Prompt string `yaml:"prompt"`
Skills []string `yaml:"skills"`
Docs []string `yaml:"docs"`
}
ReviewContextConfig is the small, repository-owned list of optional context files that can enrich a review. All three entries are Markdown or plain-text guidance: they never replace the built-in review prompt and never control rules, gates, redaction, cost, or permissions.
Prompt is one repository-wide instruction file. Skills and Docs are curated lists so a repository can add focused review knowledge without injecting an entire documentation tree into every request.
type RuleConfig ¶
RuleConfig is one rule's explicit override. Enabled is a pointer so "absent from the file" (nil, meaning "leave this rule alone") is distinct from "enabled: false" (explicitly turned off) -- a plain bool could not tell those apart, and "absent" is the zero-config default every rule must keep.
type TextContextProvider ¶ added in v1.0.21
TextContextProvider is the remote equivalent of FileContextProvider. The pull-request path reads configured files through GitHub's contents API and then uses this provider so local and PR reviews share the same rendering, redaction and token accounting.
func NewTextContextProvider ¶ added in v1.0.21
func NewTextContextProvider(file ContextFile, text string) *TextContextProvider
func (*TextContextProvider) Name ¶ added in v1.0.21
func (p *TextContextProvider) Name() string