Skip to content

Add Inspect-native evaluation foundation for CodeGuard#87

Draft
thomas-bartlett wants to merge 2 commits into
mainfrom
feat/add-inspect-eval-harness
Draft

Add Inspect-native evaluation foundation for CodeGuard#87
thomas-bartlett wants to merge 2 commits into
mainfrom
feat/add-inspect-eval-harness

Conversation

@thomas-bartlett

@thomas-bartlett thomas-bartlett commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an Inspect-native foundation for evaluating how Project CodeGuard affects model-generated code.

Inspect owns model execution, logs, and metrics. This project adds the small reusable pieces needed to load CodeGuard guidance, validate generated output, and attach benchmark-specific security scoring. New benchmarks can be added as focused sibling adapters without building a separate execution or reporting harness.

SecurityEval is the first adapter. The initial experiment compares baseline, generic secure-coding, and CodeGuard-guided outputs on 23 cases where pinned Bandit reliably detects the reference implementation's target CWE. This calibrated slice keeps the initial metric interpretable; it is not the intended limit. Future work can expand SecurityEval with additional analyzers or scorers and add other benchmarks through the same Inspect-native structure.

Safety and Current Limitations

  • The current evaluation is one-shot and tool-free: no agent shell, Docker sandbox, or generated-code execution.
  • CodeGuard is supplied as system guidance, so this does not test native skill activation.
  • Bandit detections are not proof of security, and output validation checks structure rather than functional correctness.
  • Host-side parsing is appropriate for this trusted benchmark; hostile models or sensitive hosts should use a disposable VM.
  • No real provider/model smoke run has been performed yet.
  • The README documents the temporary Click override required by the pinned Inspect release.

Validation

  • 65 tests passed on Python 3.11 and 3.14
  • Compile and Inspect task-discovery checks passed
  • pip-audit found no known vulnerabilities
  • git diff --check passed

Related

@thomas-bartlett thomas-bartlett self-assigned this Jun 2, 2026
@thomas-bartlett thomas-bartlett added the enhancement New feature or request label Jun 2, 2026
"codeguard-1-crypto-algorithms",
"codeguard-1-hardcoded-credentials",
)
DISCUSSION_URL = "https://github.com/cosai-oasis/project-codeguard/discussions/70"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DISCUSSION_URL = "https://github.com/cosai-oasis/project-codeguard/discussions/70"

We probably don't need this but can keep for the purpose of being a seed.

"execution": "none",
"guidance_delivery": "prompt_block",
"codeguard_rule_ids": list(CODEGUARD_RULE_IDS),
"discussion_url": DISCUSSION_URL,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"discussion_url": DISCUSSION_URL,

We probably don't need this but can keep for the purpose of being a seed.

@bact

bact commented Jun 2, 2026

Copy link
Copy Markdown

Thank you. Looks solid for the job and we can build further on this.

Btw, to have this eval registered on Inspect Evals at https://ukgovernmentbeis.github.io/inspect_evals/ we need a small YAML file in the Inspect Eval Register. Something like this:

title: "CodeGuard Password Storage Eval"
description: |
  Evaluate password storage security practice
contributors:
  - thomas-bartlett
tags:                                      # optional; the upstream repo name is added automatically
  - CodeGuard
  - Coding
  - Password
  - Security
tasks:
  - name: password_storage                 # must match the @task function name
    task_path: evaluations/codeguard-inspect/codeguard_harness/tasks/password_storage.py
source:
  repository_url: https://github.com/cosai-oasis/project-codeguard
  repository_commit: <40-char SHA>         # grab from the commit page on GitHub; tags and branches aren't accepted
  comment: "Project CodeGuard is an open-source, model-agnostic security framework that embeds secure-by-default practices into AI coding agent workflows."

(use example from https://github.com/UKGovernmentBEIS/inspect_evals/blob/main/register/example_eval.yaml )

@thomas-bartlett thomas-bartlett changed the title Add initial Inspect AI evaluation harness Add Inspect-native evaluation foundation for CodeGuard Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants