Skip to content

feat(models): secfoo models, pre-run validation, per-skill defaults, and dashboard/cost display (#111) - #209

Merged
vsn411 merged 5 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/models-discovery-111
Nov 29, 2026
Merged

vsn411 merged 5 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/models-discovery-111

Conversation

@SriRamkunamsetty

Copy link
Copy Markdown
Contributor

Fixes #111

What does this change, and why?

Until now, --model and [agents.<id>].model required callers to guess exact model IDs (typos only failed minutes later in the agent CLI), agy and devin silently ignored --model with a warning, per-skill model defaults were unsupported, and runs.model was stored without being surfaced in CLI commands, secfoo cost, or the dashboard.

This PR adds:

  1. Model discovery & 24h caching (secfoo models [--agent ID] [--refresh] [--json]):
    • Added ModelInfo, 24-hour ~/.secfoo/models.json cache (fingerprinted by active key env vars and binary path), and list_models() across every adapter (cli listing -> provider REST API -> litellm.model_cost filtered by present keys for api -> curated fallback with verified_at).
  2. Pre-run validation & fail-fast on unsupported adapters:
    • secfoo run --model X validates against live model lists before invoking the agent, failing fast with up to 3 difflib suggestions and secfoo models --agent <id>. --model-unchecked bypasses; curated-only lists warn rather than blocking.
    • agy and devin now raise UnsupportedModelError / exit 1 on explicit model selection instead of warning and ignoring.
  3. 4-level model precedence & secfoo config set/get:
    • Added [skills.<skill-id>].model and [agents.<id>.skills.<skill-id>].model in settings.py with precedence: --model > agents.<id>.skills.<skill>.model > skills.<skill>.model > agents.<id>.model > CLI default.
    • Added secfoo config set and secfoo config get with comment-preserving TOML updates and validation via load_config().
  4. Surface model everywhere (CLI, cost, web):
    • Added Model column to secfoo list, model label to secfoo show, "model" per run in secfoo run --json, and secfoo cost --by model.
    • Added model to run_detail.html, project.html, assessments/detail.html, overview.html recent runs, and a By agent / By model segmented toggle on the overview AI spend card (/?spend=model).
  5. Documentation:
    • Updated docs/agents.md with a Models column and docs/REFERENCE.md with precedence, secfoo models, secfoo config set/get, and secfoo cost --by model.

Testing

  • ruff check . passes (0 errors)
  • bandit -c .bandit -ll -r src/secfoo passes (0 medium/high issues)
  • pip-audit --skip-editable passes (0 known vulnerabilities)
  • python -m secfoo.cli sensor conformance -- python -m secfoo.sensor -m secfoo.runtime.conformance.sample_app passes (6/6)
  • python -m secfoo.cli skills validate examples/skills passes (2 valid)
  • git merge-tree --write-tree HEAD upstream/main cleanly merges with 0 conflicts
  • Added/updated unit & integration tests in tests/test_agents/test_models.py (37 tests in test_models.py, 384 passed across agent/cli/settings/cost/runner/docs/web suites, 715 passed across storage/report/runtime/sensor/skills/targets; note: lxml C-extension tests (test_context_brief.py, test_docext.py, 5 docx upload cases) are blocked locally by Windows App Control policy, not code failures — CI runners will verify those).

@SriRamkunamsetty
SriRamkunamsetty force-pushed the feat/models-discovery-111 branch from 2072e87 to cff8b1a Compare November 29, 2026 02:12
… config set

config set wrote config.toml with write_text (0644 under a default
umask); the file can hold MCP bearer tokens, so write it with
write_private_text (0600, atomic, symlink-safe) like the rest of secfoo.

A [[mcp_servers]] header was not recognised as a table boundary, so a
key appended to the table above it could land inside the last MCP
server entry instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vsn411

vsn411 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks, and welcome! This covers #111 end to end:

  • discovery with a cache keyed on key names (never the key values), with a curated fallback;
  • difflib suggestions;
  • --model-unchecked;
  • the hard error for agy and devin that the issue asks for;
  • the four-level precedence;
  • the model shown in the CLI, in secfoo cost and in the dashboard.

I pushed one commit (d90e842) with two small fixes in set_config_value:

  1. config.toml stays private. It was written with write_text, which gives 0644 under a default umask, and the file can hold MCP bearer tokens. It now goes through write_private_text (0600, atomic, symlink-safe), like the rest of secfoo. The temp copy is removed whether or not validation passes.
  2. [[mcp_servers]] is a table boundary. _TABLE_HEADER_RE didn't match [[…]] headers. So when the target table was followed by MCP server entries, an appended key could land inside the last server entry instead.

Once a maintainer approves the workflow run and CI is green, this is ready to merge.

Comment thread src/secfoo/agents/base.py Fixed
Comment thread src/secfoo/agents/models.py Fixed
Comment thread tests/test_agents/test_models.py Fixed
Comment thread tests/test_agents/test_models.py Fixed
Comment thread tests/test_agents/test_models.py Fixed
Comment thread src/secfoo/agents/models.py Fixed
vsn411 and others added 2 commits November 29, 2026 10:15
# Conflicts:
#	docs/agents.md
#	src/secfoo/agents/copilot.py
#	src/secfoo/settings.py
CodeQL flagged py/unsafe-cyclic-import: base.py imported ModelInfo at
runtime while models.py imports base. base.py only uses it in
annotations, so import it under TYPE_CHECKING. Also explain the empty
except around the cache write, and match provider URLs by prefix in the
test fake.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/secfoo/agents/base.py Fixed
CodeQL still reported the base <-> models cycle with the import under
TYPE_CHECKING. ModelInfo now lives in a module both import, so there is
no cycle at all. agents.models still exports it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vsn411
vsn411 merged commit aa0e363 into secfoo-com:main Nov 29, 2026
16 checks passed
@vsn411

vsn411 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Merged, thank you! 🎉 secfoo models, pre-run validation and per-skill model defaults are in, which closes #111.

Before merging, I pushed a few fixes to your branch:

CI and CodeQL were green.

@github-actions

Copy link
Copy Markdown

Leaderboard update

SriRamkunamsetty now has 16 points (rank #7). 9 more to reach Bronze.

Full leaderboard

vsn411 added a commit to saryeljaramany/secfoo that referenced this pull request Nov 29, 2026
Resolve the docs conflicts with secfoo-com#205 (api MCP tool loop), secfoo-com#209 (Models
column) and secfoo-com#214: keep both the api and Codex MCP text. Also drop the
header row that the secfoo-com#209 merge duplicated in docs/agents.md, and say
'remove the entry, then run sync again' for key rotation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Pick any model your agent offers: secfoo models, validation before the run, per-skill defaults, model in the dashboard and cost

3 participants