Repository navigation
Add --context sources: host classification, MCP reader hints, local document inlining and per-source coverage (#125) - #133
saryeljaramany wants to merge 6 commits into
Conversation
|
Thank you for this, @saryeljaramany. Most of #125 is here and works: Blocking
Should fix
Cleanup
Looking forward to the next version. |
|
Thanks for the careful review, @vsn411. All ten items are addressed, each with regression tests. Reopening for another look. Blocking
Should fix Cleanup Tests. |
|
Please create a new PR. We will review and merge it. Thank you |
|
Since GitHub does not allow contributors to reopen a PR closed by maintainers, I have opened the updated PR with all 10 review fixes and tests here: #146 |
Fixes #125
Update after review (#133): the review items are fixed in the commits after the first push; see the comment below. The screenshots further down show the first version's test runs; the final numbers are in the comment.
What this does
secfoo run --context <url-or-path>(repeatable) accepts any documentation source, tells the agent which configured MCP server is likely to read each URL, inlines local documents itself, and records one coverage row per source, which is shown on the run page and in--json.--contextis repeatable;--confluence/-cstays as an alias feeding the same list;[defaults].contextinconfig.tomlapplies to every run. Merge order: config,--confluence,--context; duplicates are dropped.https://only, no credentials in a URL, local files must be Markdown, text, PDF, DOCX or PPTX, and nothing inside the scanned target or a folder containing it is accepted (the target is untrusted). The error names where the value came from.[[mcp_servers]]by name, URL, command or args (never env or headers); if none matches, the brief says so, so the gap is expected rather than discovered. Local files and folders are extracted withdocext, capped (20,000 characters per source, 60,000 in total, 50 files per folder, with the caps shown in the brief), never follow symlinks, are shown by name and not by absolute path, and are wrapped in delimiters as reference data. The safety preamble now allows reading any source listed under "Additional context", not only a Confluence URL.### Documentation coveragetable (Source | Type | Reached | Notes; Secret Scanning's section 5 is renamed to match). A new parser (report/context_coverage.py) reconciles it with what secfoo knows: a source the agent leaves out is stored as not reached ("not reported by the agent"), and URL sources of a run that did not complete are "run did not complete".--jsonand dashboard. Newcontext_sourcestable (created on open, no migration);context_sourcesarray per run in--json; "Documentation coverage" card plus a receipt line on the run detail page (green/red per source, everything autoescaped, links only forhttpsURLs).docs/REFERENCE.mdanddocs/CI.mdupdated.Decisions I'd like a maintainer to confirm
run.--confluencewith a non-httpsvalue used to print a warning and be silently dropped by the renderer; it now fails with an error because it shares the new validation.versionis unchanged (the "definition changed" marker on the run page uses the sha256, so it will show once for those skills).Notes for review
confluence_urlsnow holds only URLs classified as Confluence (plus anything passed through--confluence), so cloud sync, run status and the run page no longer label SharePoint, Notion, Google Docs or Jira links as Confluence pages; every source appears under Documentation coverage. Local paths never go into it.prompt.md.apiagent has no tool loop (MCP for theapiagent: a tool loop so API-key runs can read Confluence, Jira, SharePoint and secfoo-memory too #123), so URL sources are recorded as not reached with that agent; local files work with every agent.docs/CI.mdsays so.tests/test_property_parsers.pyandfuzz/fuzz_parsers.py;atherisdoesn't install on my Windows machine, so I could not run the fuzz harness (onlypy_compile).Tests
New:
test_context_sources.py,test_context_brief.py,test_report/test_context_coverage.py,test_context_sources_storage.py, plus additions to the CLI, settings, runner, renderer, secret-scanning, property-parser and run-page tests.On Windows (Python 3.12),
mainbefore my changes gave 11 failed, 1316 passed (screenshot 7). After my changes: 12 failed, 1436 passed (screenshot 6a). Both runs contain the same 11 failures that do not depend on this PR: ten deterministic ones (permission bits intest_cloudandtest_memory, symlink creation intest_memory_bank, POSIX signals intest_port_guard, skill-pack name derivation from a Windows path intest_skill_packs) andtest_runtime/test_protocol, which fails intermittently on my machine (it also failed onmainbefore my changes, and it passed in some of my other full runs). The one extra failure in the later run is a Hypothesistoo_slowhealth check in the existingtest_property_parsers.py: input generation took 1.4 s while the machine was loaded by the 7-minute full run, and the file passes when rerun straight afterwards (screenshot 6b).rufferror counts on every existing file I touched are unchanged, and the new files are clean.Testing and validation (screenshots)
1.
secfoo run --help: the new--contextflag next to the--confluencealias2. Validation:
http://, scheme-less URL, in-target file, unsupported type, and missing file (all exit code 2)3. Alias, config merge, and CLI wiring tests (
-k "context or confluence" -v)4. New test files (102 passed, 1 skipped)
5. Brief for sample sources: Confluence matched to the
atlassianMCP server, SharePoint flagged as having no matching server, local file inlined by name6a. Full test suite (12 failed, 1436 passed on Windows)
6b. Rerun of
test_property_parsers.py(passes) andtest_protocol.py(the intermittent failure that is also onmain), plusruffbefore/after7. Baseline recorded before my changes (11 failed, 1316 passed)
8.
--jsonoutput withcontext_sources9. Run detail page: Documentation coverage card (1 of 2 sources reached)
AI assistance was used to draft parts of this; I reviewed the diff and ran the tests myself.