Skip to content

feat(cli): let audit read corpus settings from the config file (fixes #121)#184

Merged
bityodha merged 3 commits into
OpenAgentHQ:mainfrom
Nitjsefnie:feat-121-corpus-config
Jul 17, 2026
Merged

feat(cli): let audit read corpus settings from the config file (fixes #121)#184
bityodha merged 3 commits into
OpenAgentHQ:mainfrom
Nitjsefnie:feat-121-corpus-config

Conversation

@Nitjsefnie

Copy link
Copy Markdown
Contributor

Fixes #121 — with a premise correction worth stating up front.

What the code showed vs what the issue says

Two of the issue's three asks were already implemented before it was filed: CorpusConfig already lives in config/models.py:119 and is already wired as corpus: CorpusConfig | None on the main Config (landed in 8908183, Phase 9), and the loader already parses a corpus: section (plain pydantic — verified empirically). There is no competing CorpusConfig in corpus/. The genuine gap was ask #3: oaeval audit never read any of it — required positional path, CLI flags only, no load_config call. That's what this PR adds.

Design (precedent-cited)

  • audit gains --config/-C; the positional corpus path becomes optional and falls back to corpus.path.
  • Precedence follows the run command's own override pattern (flags default to None sentinels, applied only when provided): explicit flag > config value > built-in default, via a pure _resolve_audit_settings helper.
  • Unknown keys in corpus: behave exactly like every sibling section (pydantic extra="ignore" — pinned by a test). The Add validation for retriever settings field to catch typos early #116 warn-drop precedent governs the free-form retriever settings dict, not typed model fields, so it doesn't apply here.
  • Deliberately NOT wired: CorpusConfig.llm_provider (config field is str | None but CorpusAuditor wants a provider object — nothing consumes it today; noted below) and cwd auto-discovery of config.yaml (an explicit --config avoids silently changing existing oaeval audit ./kb behavior — happy to switch to run-style auto-discovery if you prefer).

Tests + verification

10 new tests: 4 model-integration (defaults, section parse, absent section, unknown-key-ignored) + 6 CliRunner tests with the auditor mocked at the boundary (file-values-when-flags-absent, flag-overrides-file, positional-overrides-config-path, builtin-defaults, and both error paths). Mutation-checked (implementer, then independently re-run before opening): inverting the flag/file precedence fails exactly test_audit_flag_overrides_config_value; removing the corpus field fails all four model tests; dropping the path fallback fails the file-values tests. Gates: pytest tests/unit = 868 passed vs the 858-passed clean-main baseline, same single pre-existing BERTScore failure, nothing else. Also ran a real (unmocked) oaeval audit --config cfg.yaml -v end-to-end: the config-specified check drives the audit.

Possible follow-up (observation, not fixed here): CorpusConfig.llm_provider/model/embedding_model parse from config but no code path consumes them, so contradiction detection can't yet be configured via file. Happy to file/take that separately.


🤖 This PR was written with AI assistance (Claude), directed and verified by a human-supervised workflow.

Nitjsefnie and others added 3 commits July 17, 2026 10:00
…HQ#121)

The corpus: section is already part of the main Config model and the
loader parses it, but the audit command ignored config files entirely
and only accepted CLI flags. Add a --config option to audit: it reads
the corpus: section and uses those values, while explicit CLI flags keep
precedence over the file (mirroring how run merges overrides). The
corpus path may now come from corpus.path when the positional argument
is omitted. Adds unit tests for corpus-section parsing, unknown-key
handling, and the flag-vs-file precedence.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bityodha
bityodha merged commit f9685b4 into OpenAgentHQ:main Jul 17, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

🎉 Congratulations @Nitjsefnie!

Your pull request has been successfully merged into main. 🚀

Thank you for contributing to OpenAgentHQ and helping improve the project.

We truly appreciate your contribution and hope to see you back with more amazing PRs!

Happy Open Sourcing! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CorpusConfig to the main Config model for unified configuration

2 participants