Skill Runtime V2.1

September 4, 2026 · View on GitHub

只读审计(除 Bundle persistence 修复外)。数据驱动:961 Skill 覆盖、检索质量、dead skill、 与 Builtin 默认授权的数据建议。未修改任何 Builtin Agent Skill Assignment。


1. Bundle Persistence Fix(Part A)

修复内容

新增 src/agent-library/grant-diff.ts 纯函数 computeGrantDiff(checked, inherited, bundles), Manage Skills Modal 提交时优先 Bundle 级:

Case场景持久化
1完整勾选 Bundle(非完整继承)skills: [{type:bundle,id}](不展开 leaf)
2只选 Bundle 部分 Leafskills: [{type:skill,id} × N]
3inherited 完整 Bundle 取消单个 LeafskillsRemove: [{type:skill,id}](不展开 bundle)
4取消整个 inherited BundleskillsRemove: [{type:bundle,id}]

测试

  • test/grant-diff.test.ts(8 个):Case 1-4 + no-op + standalone + round-trip serialization。
  • test/agent-library.test.ts:Bundle grant 的 Profile 在 Bundle 增加新 Leaf 后自动获得新 Leaf (resolver 动态展开,非 snapshot leaf 集合)。

结论

Bundle persistence semantic: PASS

2. Current Builtin Coverage(Part B)

数据(运行统计,非手写)

Total Skills:              961
Builtin Covered:            80   (8.3%)
Builtin Uncovered:         881   (91.7%)
  single-agent coverage:    67
  multi-agent coverage:     13
Builtin Agent当前 allowedSkillIds
web48
impact16
recon11
validation9
vulnerability8
reporting4
threat-model2

核心发现:当前 Builtin 沿用约 98 个历史 Leaf Assignment,仅覆盖 80 个 unique Skill(8.3%), 881 个 Skill 对任何 Builtin Agent 都不可发现。这是 Grant Failure 的根源(见 §8)。


3. Agent Capability Model(Part B.3)

以 profile systemPrompt 为真实依据(非硬编码):

AgentprimaryDomainsworkflowFocus排除
webweb-security, api-security, authenticationdetection, validationnetwork infra, AD, forensics, rev
reconreconnaissance, network-securitydiscoveryexploitation, post-exploit, reporting
threat-modelgeneral-pentestingmodeling, prioritizationactive exploitation, forensics
vulnerabilityweb/api/injection/auth/source/network/clouddetection, analysisactive exploit verify, lateral, report
validationinjection, auth, AD, windows, linuxvalidation, exploitationrecon, reporting, threat-model
impactpost-exploit, AD, windows, linux, cloudexploitation, assessmentweb discovery, recon, reporting
reportingreportingreportingexploitation, recon, scanning

产物:analysis/skill-runtime-benchmark/agent-capability-model.json


4. Uncovered Skill Classification(Part B.2)

对 881 uncovered 按 Card(primary_domain/role/workflow_focus/technique_tags)分类:

SHOULD_ASSIGN:          604   (66%)
ROUTER_OR_KNOWLEDGE:    128   (14%)  security-knowledge / threat-intel / router / checklist
OUTSIDE_DEFAULT_PTES:   143   (16%)  forensics / reverse-engineering / mobile / binary
MANUAL_ONLY:              6   ( 1%)  ctf tricks

精化(offensive vs defensive,关键 nuance)

对 604 个 SHOULD_ASSIGN 用 summary 词表进一步区分工作流方向:

offensive-leaning:       126   (真正属于 offensive pentest 默认 scope)
defensive-leaning:       210   (detection/hardening/monitoring/incident-response → 应重分类)
mixed / ambiguous:       268   (需逐个语义审查)

关键结论:粗略 domain 分类会高估"应授权"数量。604 个 SHOULD_ASSIGN 中, 仅 ~126 个是明确 offensive;210 个是 blue-team defensive(不应默认给 offensive agent), 268 个 ambiguous。这说明 domain 不足以判定 agent 归属,必须结合 workflow_focus 区分 offensive vs defensive


5. Skill → Agent Recommendation(Part B.4)

产物:analysis/skill-runtime-benchmark/skill-agent-recommendations.json(961 条)。

结构:{ skillId, currentAgents, recommendedAgents, confidence, reason }

  • SHOULD_ASSIGN + domain 命中映射 → confidence 0.7;未命中映射 → 0.4。
  • 当前已授权 → confidence 1(currently-assigned)。
  • 推荐允许 0 / 1 / 多 agent(如 web+vulnerability、impact+validation)。

6. Retrieval Benchmark Design(Part C)

  • analysis/skill-runtime-benchmark/benchmark-queries.json101 query,覆盖 16 类 (Web / API / Auth / Injection / Recon / Network / AD / Windows / Linux / Cloud / Source / Reverse / Forensics / Post-Exploit / Reporting / CTF)。
  • 每 query:mustRecall(强相关)/ goodToRecall / irrelevant(负样本)。
  • Query 是真实 Subagent 需求(如 "Kerberoasting with Impacket GetUserSPNs"、 "blind SQL injection with sqlmap verification workflow"),非 skill 名称本身。
  • Gold label 的 skill id 全部经 runtime index 校验(0 missing)。

7. Retrieval Metrics(Part C.3)

Benchmark Queries:        101
Recall@3:               0.545
Recall@5:               0.693
Recall@8:               0.772
MRR:                    0.440
MustRecall miss rate:   0.228   (23/101 query 完全未召回 mustRecall)
Duplicate rate:         0.881   (top-8 存在同 family 聚集)
Complementary coverage: 1.000   (top-8 覆盖 ≥2 不同 family)

检索质量诊断

  • Retrieval 未失败但 ranking 偏弱:MRR 0.44 说明正确 Skill 平均排名第 2~3 位(非第 1)。
  • miss 根因 = 语义等价未覆盖:deterministic lexical ranking(§15 v1 不调 LLM)无法捕捉 brute force ≈ fuzzingEntra ID ≈ Azure ADROADtools(工具名未进 query token 匹配)等 同义表达。miss 的 query 中,多数 mustRecall Skill 的 Card 本身是准确的(含关键词), 但 query 与 Card 的 token 重叠不足。
  • 少量 gold label 标注误差(如最初 AWS IAM 误标 GCP skill)已修正,不属 runtime 缺陷。

结论

deterministic lexical ranking 的 Recall 天花板约为 0.77(Recall@8);要进一步抬升需引入 语义检索(超出 v1 锁定范围,属 follow-up)。


8. Grant Failure vs Retrieval Failure(Part D,最重要)

Assignment-aware 基准(14 个 query-agent 对,用真实 Builtin allowed):

pairs:                14
grant failures:        6   (43%)  — 正确 Skill 根本不在 allowed set
retrieval failures:    0   ( 0%)  — 在 allowed set 内 search 全部找回

核心结论:当前检索失效的主要原因是 Grant Failure(43%),不是 Retrieval Failure(0%)。 即:pentester_skill_search 引擎在"已授权集合内"检索可靠;真正的问题是 正确 Skill 没有被授权给对应 Agent(§2 的 8.3% 覆盖率的直接后果)。

这验证了本审计的价值:提升检索质量的第一优先级是扩大 Builtin 授权覆盖, 而非调 ranking。


9. Dead Skill Analysis(Part E)

totalDeadSkills:        881   (在默认 Builtin + Stage 下无 search 路径)

intentional:            149   — OUTSIDE_DEFAULT_PTES (143) + MANUAL_ONLY (6)
unintentional:          604   — SHOULD_ASSIGN(粗分)
  其中 offensive-leaning ~126(真应授权)
  其中 defensive-leaning ~210(blue-team,实为 intentional 或需人工)
  其中 mixed/ambiguous  ~268
unclear:                128   — ROUTER_OR_KNOWLEDGE

目标不是 deadSkill=0,而是让所有 dead skill 都是有意识的产品决定。当前 881 个 dead 中,真正"无意的"(offensive 且应授权)约 126 个;其余需按 defensive/offensive 语义 精分后再决定(见 §11)。


10. Proposed Builtin Grant Changes(Part F)

产物:analysis/skill-runtime-benchmark/proposed-builtin-grants.json(未应用)。

confidence ≥ 0.7 的 SHould-assign 建议规模:

Agentkeepadd(建议)remove
web481230
recon111840
threat-model2300
vulnerability84280
validation91300
impact162470
reporting470

注意:上述 add 数量被 domain→agent 粗映射显著高估(尤其 vulnerability=428),因为把 大量 defensive 工作流(detection/hardening/monitoring)误映射到了 offensive agent。 不可直接应用;须先按 §11 的 offensive/defensive 语义重分后,只保留 offensive-leaning 的 ~126 个高置信建议。


11. High-risk Ambiguities

  1. offensive vs defensive 未分离:604 SHOULD_ASSIGN 中 210 defensive + 268 mixed 的 归属需逐个判断,domain 映射不可靠。
  2. security-knowledge(120):MITRE ATT&CK / threat intel / compliance 是"知识"而非 执行 skill;是否应作为 threat-model/recon 的只读知识授权,或全部 OUTSIDE,需产品决定。
  3. forensics(80):memory/disk forensics 与 impact(post-exploitation)有交集 (如 analyzing-linux-kernel-rootkits 用 Volatility),但多数是 blue-team IR,不应默认授权。
  4. network-security(138):同时含 offensive(recon/C2 分析)与 defensive(IDS/SIEM), 需按 workflow_focus 拆分。
  5. cloud-security(129):同时含 offensive(pacu/stratus 攻击模拟)与 defensive (CIS 审计/Sentinel),需拆分。

  1. 不要自动应用 proposal(§Safe to apply = NO):先做一轮 offensive/defensive 语义重分 (基于 workflow_focus + role + technique_tags),把 SHOULD_ASSIGN 从 604 收敛到 ~126 offensive-leaning 高置信集。
  2. 收敛后的高置信 add(~126)分批应用到对应 Builtin Agent,每批后跑 scripts/run-benchmark.mts 复测 grant failure 应显著下降(当前 43%)。
  3. Bundle Assignment 只作为用户配置能力(§G):Builtin 默认保持精确 Leaf Assignment, 除非数据证明某整个 Bundle 与某 Agent scope 高度一致(当前无证据,6 个顶层 Bundle 都是 来源/组织 Bundle,非语义 capability bundle)。
  4. 检索质量(Recall@8 0.77)的第二优先级是语义检索(超出 v1 deterministic 范围), 先做授权覆盖,再做语义。

SKILL_RUNTIME_V2_1_AUDIT_COMPLETE

Bundle persistence semantic:
PASS

Total Skills:
961

Builtin Covered:
80

Builtin Uncovered:
881

Intentional Uncovered:
149

Unintentional Uncovered:
604 (coarse) / ~126 (offensive-leaning)

Benchmark Queries:
101

Recall@5:
0.693

Recall@8:
0.772

Grant Failures:
6

Retrieval Failures:
0

Dead Skills:
881

Builtin Grant Proposal Ready:
YES

Safe to apply grant changes automatically:
NO