Repository navigation
Responsible AI: output contract, program dashboard and AI-BOM cross-check (#131) - #208
Conversation
vsn411
left a comment
There was a problem hiding this comment.
Thanks, and welcome! This covers every part of #131:
- the contract;
- a pure parser that falls back for legacy reports;
- the stored rating with a backfill migration, so the badge no longer opens N files per page load;
- the dashboard and dimension view;
- the AI-BOM diff;
- docs with a real screenshot.
The parser is careful too: an unknown status is skipped, never promoted to "adequate", and the CWE column of a legacy report is never read as a dimension. Templates use autoescaping, with no |safe on report text.
Two changes before we merge:
-
A repeated finding ID turns a successful run into a crash.
rai_findingshasUNIQUE (run_id, finding_ref), butextract_findingsdoesn't deduplicate register rows. Models do sometimes repeat a row, or write a second register table. When that happens, the insert raisesIntegrityErrorinsidecomplete_run'swith self._conn:. That rolls back the run's own UPDATE (status, report path, counts, cost). The runner'sexcept BaseExceptionthen marks the run crashed and re-raises, so a scan that succeeded and was paid for is recorded as a crash. Please do both:- deduplicate by finding ID in
extract_findings, keeping the first, the wayextract_dimension_coveragealready does withseen; - treat the RAI rows as best-effort. Use
INSERT OR IGNORE, or a savepoint that logs and drops the RAI rows on error, so a parse problem can never lose the run row.
Please add a test with a register that repeats
F1. - deduplicate by finding ID in
-
The AI-BOM section goes to every skill.
ai_bom_sectionis set on the sharedTargetContext, so on an assessment with a BOM, SAST, secret scanning and the rest also get the block. They also get "In the AI System Profile, name models…", a section their contracts don't have. That costs tokens and can confuse their output. Please add it only when the skill's output type isresponsible-ai-compliance, as #131 describes.
Nit, fine to leave: _backfill_responsible_ai_ratings runs on every repository open. A run whose report has no rating stays NULL and is re-read each time. Storing a sentinel such as '' for "checked, no rating" would make it truly one-time.
CI hasn't run yet because this is your first PR here. A maintainer will approve the workflow run.
- Dedupe Responsible AI finding IDs before persistence and write RAI rows best-effort (savepoint + INSERT OR IGNORE) so a repeated F1 cannot roll back a successful, paid-for run. - Render the AI-BOM brief only for the responsible-ai-compliance output type, including custom skills that reuse it. - Store an empty rating sentinel for parsed RAI reports with no rating so badges and the backfill migration never re-open those files. - Add parser, storage, renderer, runner and end-to-end regressions; update the /responsible-ai info-tip expectations for the new risk cards.
|
Thanks @vsn411 — addressed both review points in
I also took the nit: parsed RAI reports with no rating store 233 targeted tests pass and |
Only ? placeholders and the constant _LATEST_RAI_RUN fragment are interpolated; bandit is now blocking in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the quick, thorough follow-up. Both review points are fixed exactly as needed:
The Since #206, bandit runs as a blocking CI step. It flagged three B608 "string-built SQL" false positives in Once a maintainer approves the workflow run and CI is green, this is ready to merge. |
| from secfoo.report.sast import ( | ||
| SKILL_ID, # noqa: F401 -- re-exported: routes/activities.py uses sast_dashboard.SKILL_ID | ||
| ) |
| renderer must gate it by the skill's output type rather than letting | ||
| SAST, secret scanning and the rest pay for an irrelevant brief. | ||
| """ | ||
| import secfoo.runner |
vsn411
left a comment
There was a problem hiding this comment.
Both review points are addressed (deduplicated finding IDs with a savepoint, AI-BOM limited to Responsible AI). CI is green. Approving.
|
Merged, thank you, and congratulations on your first contribution to secfoo! 🎉 Responsible AI now has a real contract, stored ratings and its own program dashboard, which closes #131. Before merging I added the |
Leaderboard update
Shruti070107 now has 10 points (rank #8). 15 more to reach Bronze. |
Fixes #131.
What changed
RESPONSIBLE_AI_OUTPUT_CONTRACTforresponsible-ai-compliance, registered inSKILL_OUTPUT_CONTRACTS. The report now asks for an AI System Profile, a seven-row Dimension Coverage table, a Findings Register withDimension/ optionalFrameworkinstead ofCWE/ verdict, detailed### [SEVERITY] Fn:blocks, a remediation roadmap and coverage notes. The skill text tells the agent to mark no-finding dimensionsadequatewith evidence and to stop emitting CWE IDs.src/secfoo/report/responsible_ai.py) for the profile, dimension rows, dimension/framework/stakes-tagged findings and the overall rating. Legacy CWE-shaped reports still yield findings and a rating, but their CWE column is never mislabelled as a dimension.runs.overall_rating,rai_dimensionsandrai_findingsin the same transaction ascomplete_run(). Adds a one-time migration that backfills the rating from stored reports. Badges andcount_assessments_with_responsible_ai_risk()now read the stored column, so page loads no longer open N report files; a missing report file no longer un-rates an assessment./activities/responsible-ai-compliance/dimensionsview carries evidence and complete finding text. Legacy reports still show the generic cards until a contract-shaped run exists./responsible-ai.docs/REFERENCE.mdwith a real screenshot of the seeded page (docs/assets/responsible-ai-dashboard.png).Tests
Targeted RAI, storage and assessment suites pass. The repository's pre-existing Python 3.14 baseline failures are unchanged by this PR.
Screenshot