Skip to content

fix(review): expand review budget for 1M context and refine shared context pattern - #61

Merged
yaojin3616 merged 2 commits into
mainfrom
fix/review-budget-long-context
Oct 21, 2026
Merged

yaojin3616 merged 2 commits into
mainfrom
fix/review-budget-long-context

Conversation

@yaojin3616

Copy link
Copy Markdown
Collaborator

变更背景与原因

在自动化安全审查门禁中,部分 PR(如 #59)出现 共享审核上下文超出预算,需人工处理 阻断。排查发现存在两个问题:

  1. 分类正则过于宽泛:contextPattern 匹配所有 dsh/.*,导致若投稿将业务代码置于 dsh/ 目录下,会被全部作为共享上下文(基础元数据)打包进每次请求,导致基础上下文激增。
  2. 预算阈值偏保守:原审查脚本按早期小模型上下文限制(~120k tokens)设定了 100k 共享上下文、150k 每批证据、230k 请求字符上限。当前审核模型已具备 1M 长上下文能力,未能充分利用。

改动内容

  1. 修正上下文匹配正则(scripts/llm-review.mjs):
    • 将 contextPattern 中的 dsh/.* 调整为限定入口/契约文件:dsh/(?:index\.[cm]?[jt]sx?|manifest\.json)。
    • 避免将常规业务脚本放入全批次共享上下文,转而作为代码切片(pieces)正常分块审查。
  2. 放宽审核预算阈值以适配 1M 上下文:
    • 共享上下文上限 MAX_CONTEXT_SIZE 从 100k 放宽至 500k 字符。
    • 每批分块上限 MAX_BATCH_SIZE 从 150k 放宽至 1,000,000 字符。
    • 单次请求预检查上限 MAX_REQUEST_CHARS 从 230k 放宽至 1,500,000 字符。
  3. 更新单测与文档:
    • test/security-review.test.mjs:调整分块边界断言,并新增针对 dsh/ 业务代码分块及入口识别的专项测试。全部 106 项单测通过。
    • docs/security-review.md:同步更新规范文档中的字符上限说明。

…ntext pattern

- Refine contextPattern so only manifests and entrypoints (dsh/index.*, package.json, etc.) are treated as shared context
- Increase MAX_CONTEXT_SIZE to 500k, MAX_BATCH_SIZE to 1M, and MAX_REQUEST_CHARS to 1.5M to utilize 1M token context
- Update unit tests and security review documentation
@github-actions github-actions Bot added the feature 非工作台 YAML 投稿,需要维护者评估 label Oct 21, 2026
@yaojin3616
yaojin3616 merged commit b3c9fd9 into main Oct 21, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 非工作台 YAML 投稿,需要维护者评估

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant