Skip to content

feat(prompts): add security review dimension to code-quality sub-agent#370

Merged
ceilf6 merged 1 commit into
developfrom
improve/codequality-security-review
Jun 21, 2026
Merged

feat(prompts): add security review dimension to code-quality sub-agent#370
ceilf6 merged 1 commit into
developfrom
improve/codequality-security-review

Conversation

@ceilf6

@ceilf6 ceilf6 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Linked Issue Or Context

Closes #369.

Summary

  • Extends buildCodeQualityLlmReviewPrompt's system prompt (packages/core/src/sub-agents/code-quality-prompt.ts) so the code-quality review sub-agent actively flags common web security vulnerabilities — XSS (unsanitized data into innerHTML/dangerouslySetInnerHTML), command/SQL injection, secrets hardcoded in client code, and unsafe eval/dynamic code or unvalidated URL/redirect handling — alongside its existing SDD-constraint and maintainability dimensions.
  • Findings reuse the existing CodeQualityIssue shape (rule: "security/<kind>", severity), so there is no schema or subagent-logic change.
  • This is the review-layer counterpart to the codegen security discipline in feat(prompts): inject security-engineering discipline into codegen #366: generate-safely + review-for-safety defense in depth.

Learned from the Claude Code agentic prompt's security-as-first-class-review-dimension pattern.

Impact Scope

Prompt-only change to the review sub-agent's system string, plus a focused assertion update in code-quality-prompt.test.ts. No schema, subagent execution logic, rule-based fallback, codegen, or planner changes.

GitNexus Impact Summary

  • Risk level: MEDIUM
  • Critical skeleton changes: none
  • GitNexus impact: impact(buildCodeQualityLlmReviewPrompt, upstream) returned LOW (0 direct callers — invoked dynamically). detect_changes rated MEDIUM because the symbol participates as a step in 3 internal prompt-building processes (Main → TruncateFileContent / BuildSddSummary / SummarizeSharedFacts). The change is confined to the system prompt string content: the function signature, return shape ({ system, userPrompt }), and call edges are unchanged, so those 3 processes' contracts are unaffected — the only behavioral delta is that the review LLM now also reports security findings.
  • Verification: detect_changes (scope=unstaged) reported changed_count=1 (buildCodeQualityLlmReviewPrompt), affected_count=3 (the prompt-building processes above), risk_level=medium.

Verification

  • pnpm --filter @frontagent/core test -- code-quality-prompt.test.ts — 2/2 pass (updated exact-system assertion + security-phrase checks).
  • pnpm exec biome check on the 2 changed files — clean.
  • pnpm quality:precommit (lint + typecheck + test + test:workflows) — green (25 turbo tasks successful, workflows 32/32).
  • gitnexus impact + gitnexus detect_changes — see summary above.

Checklist

  • I have linked an issue or explained why this PR stands alone.
  • I have kept the diff focused on the stated change.
  • I have run pnpm quality:precommit, or explained why it could not run.
  • I have run pnpm quality:local for critical skeleton changes, or explained why it could not run. (Prompt-string-only; precommit + GitNexus impact/detect_changes cover it; contract to the 3 processes unchanged.)
  • I have updated docs or tests when behavior, public APIs, or Harness contracts changed.
  • For critical skeleton changes, I have filled the GitNexus impact summary with concrete results.

Extend buildCodeQualityLlmReviewPrompt's system prompt so the code-quality
review sub-agent actively flags common web security vulnerabilities (XSS via
unsanitized innerHTML/dangerouslySetInnerHTML, command/SQL injection, secrets
hardcoded in client code, unsafe eval/dynamic code or unvalidated URL/redirect
handling) alongside the existing SDD-constraint and maintainability dimensions.

This is the review-layer counterpart to the codegen security discipline added
in #366: generate-safely + review-for-safety defense in depth. Reuses the
existing CodeQualityIssue shape (rule "security/<kind>", severity), so no schema
or subagent-logic change. Learned from the Claude Code agentic prompt.

Closes #369

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🛡️ ceilf6/repo-guard

代码评审报告: feat(prompts): add security review dimension to code-quality sub-agent

风险等级:
处理建议: 批准
决策摘要: ** 可以合并;变更满足 #369 的 prompt-only 验收目标,未改变函数签名、返回结构或下游契约,测试覆盖了新增安全维度与既有语义。

级联分析

  • 变更符号: 原始模型未提供结构化级联字段。
  • 受影响流程: 原始模型未提供结构化级联字段。
  • 变更集外调用方: unknown
  • 置信度: degraded

问题发现

模型未返回可结构化的问题发现;已提取可用的决策字段,原始非契约内容未附在评论中。

行级发现

  • 无明确变更行归属。

Karpathy 评审

  • 假设: 模型输出需要归一化为固定 Markdown 契约。
  • 简洁性: 已提取 summary、finding、evidence 与 fix;原始 prose 不再附在评论中,避免占用下游解析与代理上下文。
  • 变更范围: 原始模型未提供结构化范围字段。
  • 验证: 需要查看 CI、测试或人工 CR 证据补强合并信心。

缺失覆盖

  • 输出未命中 Repo Guard Markdown 契约;建议补充真实模型质量评估覆盖。

@ceilf6 ceilf6 merged commit ff0fc3d into develop Jun 21, 2026
7 checks passed
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.

feat(prompts): add a security review dimension to the code-quality review sub-agent (learned from Claude Code)

1 participant