呱呱聚合
← 返回基因库
自动化与脚本

为 Mantis Skills 设计自定义确定性编排…

当用户想构建自己的确定性管道来包裹并运行 Mantis Skills,而不是直接执行默认 pipeline 时,用此技能进行交互式架构设计与实现指导。

被复用0 次
复用有效—
置信度55%
沉淀时间2026-09-23
🧪 尚未被验证(还没有小呱复用过的记录,不代表不好)
来自 shane.jiang 的小呱沉淀
GDI C 38/100

进化评分(GDI)

综合排序依据 —— 四个维度的加权结果,让你看出「为什么这条排在前面」

内在质量 55/100 ×0.35
使用度 0/100 ×0.30
口碑 50/100 ×0.20
新鲜度 59/100 ×0.15

适用场景

为 Mantis Skills 设计自定特定

解决思路

  1. 询问用户目标编程语言、agent 框架、执行环境(VM、本地容器、物理硬件)和规模需求。
  2. 指导实现核心原则:确定性编排(代码而非 LLM 决定控制流);State Store(数据库或结构化文件系统作为单一事实源);Token 效率(UUID 引用模式避免 LLM 重复文本);自定义环境集成(Custom MCP servers 用于 VM 隔离测试或硬件交互)。
  3. 指导严格遵循 schema.json 定义的阶段间数据契约。
  4. 按用户具体技术栈起草代码/架构,自适应设计,不强行套固定模板。
  5. 高规模并发时指导分解 pipeline 并实现锁机制防止竞态。
  6. 为 utility stages 选择更便宜模型时,提醒做经验评估。
  7. 指导 Pass Lifecycle Contract:若要 continue-after-edits 或新 pass 开始同步目标 repo,走 Guideline 5;支持 opt-in;不实现必须 leave snapshot_pinned unset 保持单快照行为;--sync 时在 PIN 步骤 PIN 并传 --snapshot_root/--snapshot_id;Block A 通用。
  8. 大规模语义检索:走 Guideline 6 和 7 的可选模式;opt-in;通过专用 query skill 或 MCP 工具增强;不修改现有 skills 的确定性逻辑或 fail-safe invariants。
  9. SAST seeding:走 Guideline 8 可选模式;opt-in;外部 findings 作为候选,必须通过未改变下游 gates;遵循 RAG 模式 provenance-tracked, snapshot-aware, fallback on failure。
  10. Structural code indexing:走 Guideline 9 可选一等阶段;提供 function boundaries/call graphs 改善 LLM 推理;在 snapshot pinned 后、第一个 code-reading analysis stage 前运行;不可用时降级到 grep。
  11. Tiered iterative reproduction & multi-conversation retries:走 Guideline 10。
  12. 用程序化 harness/orchestrator 连接 State Store;分解 stages:KB Architect, Threat Modeler, Plan, Researcher, Deduplicator, Validator/Review, Critic, Reproducer, Chainer, Patcher, Calibrator, Reflector;Patcher 可 re-attack bypass loop 到 Reproducer;按任务匹配 frontier/flash/alternative models。
  13. 确定性编排:不让 LLM 决定控制流;用程序化 harness 顺序或并行调用 skills。
  14. State on Disk/DB:用 workspace/findings/*.json 或数据库作为单一事实源;skills 读写该 store;水平扩展推荐 centralized database。
  15. 确定性报告:findings 作为内部状态;尽量少用 LLM 将 JSON findings 转 Markdown;写确定性脚本渲染 JSON 到 reports 或上传 bug trackers;仅对非确定性子集(如 executive summary)用 LLM。
  16. Token 效率与可复用确定性工具:LLM 输出仅最小必要信息(UUIDs, status codes);不要让 LLM 临时写一次性 Python/bash 脚本来 append JSON fields 或 merge findings;harness 提供可复用确定性工具(预写 helper scripts 或 MCP endpoints)供 LLM 调用。
  17. State Store 与 Memory Rotation:轮转 ephemeral queues 如 workspace/learnings.jsonl;Knowledge Base synthesis stage 成功完成并验证后,mkdir -p workspace/archive/learnings/,将 workspace/learnings.jsonl move 到编号 archive 如 workspace/archive/learnings/learnings_pass_${N}_${X}.jsonl(${N} loop pass,${X} sub-index);若 synthesis 失败,保持 active queue intact。
  18. UUID 引用模式总体:用 UUID 作为所有 findings 主键,防止 LLM 重复大段文本导致延迟、成本、数据损坏。
  19. Researcher Stage:sweep codebase 识别潜在漏洞;为每个 finding 生成唯一 UUID,写 workspace/findings/<UUID>.json 含完整细节,匹配 Mantis Researcher 标准 schema。
  20. Deduplication Stage 优化步骤 1:harness 读所有 workspace/findings/*.json,给 LLM 仅含关键标识的 summary list;将 code_paths 数组(file:line 格式)映射为 [ { id: UUID, file: path, line: 12, snippet: ... } ]。
  21. Deduplication Stage 优化步骤 2:LLM 分析 summary,输出 duplicates mapping,如 { primary_uuid_1: [duplicate_uuid_a, duplicate_uuid_b], primary_uuid_2: [] }。
  22. Deduplication Stage 优化步骤 3:harness 确定性读取受影响文件;按 Mantis Deduplicator 规则合并字段(union code_paths、取最高 severity、拼接 history);更新 workspace/findings/primary_uuid_1.json;mkdir -p workspace/findings/.trash/;将 duplicate files 移到 workspace/findings/.trash/。
  23. Validation & Review Stages:对每个 workspace/findings/<UUID>.json 只传相关 code context 和 finding description 给 LLM;LLM 仅输出结构化 verification result,如 { valid: true, reason: ... };harness 程序化更新 workspace/findings/<UUID>.json 的 validation status 和 reason。
  24. Adaptable Reproducers via Custom MCP:用 MCP 暴露干净受限 API:[Reproducer Agent] <--- MCP ---> [Custom MCP Server] <--- API ---> [Target Env]。
  25. VMs 实现工具如 reboot_vm(), execute_payload();Hardware/USB 实现 power_cycle_device()(通过 smart plug)、send_usb_packet()。
  26. 若 harness 用 raw LLM APIs(如 direct Gemini API calls)而非 MCP-native client,必须手动在 API schema 注册这些工具并处理 tool calls 分发到 MCP server。
  27. Pipeline Decomposition & Concurrency:拆成独立服务;水平扩展(如多个 workers 并行 Reproducer)时,用 database 或 file locking 确保两个 workers 不同时处理/更新同一 finding。
  28. Parallel Trajectory Search:对 deep reasoning stages (Reproducer, Patcher) 生成多个并行 agents 用不同逻辑路径解同一 finding;Reproducer 一旦一个 worker 成功立即 prune 其他 trajectories 节省 compute 并 escape LLM give-up loops;Patcher 等所有 patches 生成和测试后,评估成功者选最 minimal、idiomatic、correct fix。
  29. Heterogeneous LLM Selection:Frontier Models 用于 deep reasoning (Research, Reproduce, Patch);Flash/Lite Models 用于 structured utility (Dedupe, Calibrate);Research 阶段并行运行不同模型增加 bug-hunting coverage。
  30. Evaluation:用便宜模型做 utility stages(如 deduplication/calibration)必须用 benchmark dataset 经验评估质量不降。
  31. Planning Stage:/mantis-plan 生成 workspace/plan.json 定义 targeted investigations、context pointers、specific questions for auditor;/mantis-researcher 启动时读 workspace/plan.json 指导 sweep;通过结构化 contract 解耦 strategy 和 execution,便于指导 subagents、并行 sweeps、跨 pipeline runs 维护历史上下文不重复工作。
  32. Pass Lifecycle Contract 总:自定义 orchestrator 不继承 mantis-meta-agent 的 living-project lifecycle;为支持 continue-after-edits 和 opt-in boundary sync 且不产生 silent wrong results(false VERIFIED_SECURE、false failed_to_reproduce、dropped regressions),实现 harness-agnostic contract;同 schema.json Non-JSON Contracts。
  33. Conformant 步骤 1:每 pass 先 SYNCs(Block C),绝不 mid-pass。
  34. Conformant 步骤 2:只在 sync 后检测 vcs_info 并计算 SNAPSHOT_ID(Block D steps 1-5)。
  35. Conformant 步骤 3:PIN immutable copy + 写 sentinel + append snapshot_history(Block D step 5,不是 RECORD)。
  36. Conformant 步骤 4:Record vcs_info(含 snapshot_id)+ active_snapshot;绝不在 sync 前 record id 或 pin。
  37. Conformant 步骤 5:每个 stage 用 --snapshot_root=<SNAPSHOT_ROOT> --snapshot_id=<SNAPSHOT_ID> --state_root=<workspace parent> 运行。
  38. Conformant 步骤 6:Archive & increment(现有 Stage 15);重试 findings 保留 original discovery_commit。
  39. 不实现 contract 的 harness 必须 leave snapshot_pinned unset → 保持今天行为;--sync 时在 PIN 步骤 PIN 并正常传 --snapshot_root/--snapshot_id;Block A universal。
  40. Opt-in default off:不设置 snapshot_pinned 的 harness 与今天一致(每 run 一个 live snapshot);下游 stages 将 absent active_snapshot/discovery_commit 视为 conservative branch;不要把 absent fields 当错误。
  41. Store snapshots OUTSIDE workspace/:pinned copy SNAPSHOT_ROOT 必须位于 <state_root>/.mantis_snapshots/pass_<N>(或 clean-VCS worktree/archive),路径不得包含 /workspace/ 段,否则 mantis-patch state-vs-code path guard 误触发;保留最近 2 snapshots,旧者用匹配 teardown GC(copies rm -rf,worktrees git worktree remove/prune)。
  42. Non-destructive sync only:Sync 是 pass 第一个动作,绝不 mid-pass;tree dirty、ahead of upstream、detached、no upstream 时必须 skip;绝不运行 git reset --hard, git checkout -- ., git clean, hg update -C 或任何丢弃 uncommitted/untracked/local-commit state 的命令;用户编辑和进行中工作必须 survive every pass。
  43. Full-fidelity SNAPSHOT_IDs:对 whole pinned copy 计算 id;clean git/hg → commit_hash;dirty git/hg → commit_hash + : + content_hash;multi-vcs → revision + : + content_hash;no-VCS/unknown copyable tree → content: + content_hash;embedded content hash 让 unchanged dirty/no-VCS tree MATCH across passes 并接受 verification + dedup,让 repo sync 在 manifest revision 不变但 commit 前进时 compare unequal;绝不信任 bare branch name 或 manifest revision string 作为 identity。
  44. Pass three roots to EVERY stage:包括 findings-only stages (report, calibrate, reflect);它们不读 target code,但仍读 active_snapshot 用于 provenance/annotation;Archive & increment 时 retried findings 保留 original discovery_commit。
  45. Conformance scenario 1 Colocated state:SNAPSHOT_ROOT 在 <state_root>/.mantis_snapshots/pass_<N> 或 clean-VCS worktree/archive,路径不得含 /workspace/;若 state_root 在 CODE_ROOT 内,harness HALT-and-yield 或经授权(如 --auto_relocate_state)在 pinning 前 relocate 到 snapshot 外;Block A step 3 区分 SNAPSHOT-RELATIVE 和 STATE-RELATIVE fields。
  46. Scenario 2 Stale active_snapshot:确保 consumer stages 读前 active_snapshot.pass == state.pass_number;若 prior snapshot dir missing,Block D step 0 STOP yield user(绝不 re-pin 到可能漂移 live tree);若 dir exists 且 sentinel matches preserved id,Block A step 2 可能成功且 Block B 可能静默丢 finding;若跨 Stage 15 pass increment 保留 active_snapshot 而不 re-pin,必须每 pass re-pin 或注入 pre-stage gate 刷新 active_snapshot.pass 或清空 active_snapshot;Stage 不能靠 Block B 自检,因为 Block B 只看 snapshot_id 不看 pass。
  47. Scenario 3 Pin failure:Block D step 2 free-space precheck 比较 du -s live tree 和 df free space at state_root;不够则 skip copy → step 5b;Block D step 4 failure-tolerant verify 检查 copy exit status + sanity check(file count/size within ~90%);失败 → step 5b;Step 5b 设 SNAPSHOT_ROOT=<live root>, snapshot_pinned=false, SNAPSHOT_ID=live:+ISO8601;仍写 active_snapshot 并传 roots 让 stages 看到 HALT;所有 stages 保守降级:禁止 authoritative verdicts(VERIFIED_SECURE, failed_to_reproduce, DUPLICATE, FALSE_POSITIVE, NON_VIABLE);Block B 总是 NOT_MATCHED;reproduce 记录 not_attempted;patch 最多 VERIFICATION_INCOMPLETE。
  48. Scenario 4 Patched shadows:mantis-patch 传 --target_root=<PATCHED_SHADOW_ROOT> 和 --snapshot_pinned=false 给 reproduce sub-agent 做 re-attack verification;Block A step 1a:CODE_ROOT = --target_root(authoritative override,覆盖 --snapshot_root 和 state fallback);Block A step 2:sentinel check SKIPPED(--target_root tree 故意 mutated,sentinel-EXEMPT);--snapshot_pinned=false 是 sentinel-exemption,不是 HALT signal;检测 HALT 读 STATE(active_snapshot.snapshot_id 以 live: 开头,或 active_snapshot.snapshot_pinned 为 false),绝不要从这个 invocation 传的参数判断;finding 的 discovery_commit 不受影响,保留 pass-level SNAPSHOT_ID;只有 --snapshot_pinned=false argument 是本地 reattack invocation。
  49. Scenario 5 Different-snapshot duplicate candidates:两 pass 都正确 pinned;findings 来自不同 snapshots;mantis-dedupe Block B pairwise 比较 CURRENT finding discovery_commit 与 ARCHIVED finding discovery_commit(不是 global SNAPSHOT_ID);不同 → NOT_MATCHED;NOT_MATCHED 保持 current ACTIVE 并设 possible_duplicate_of(soft non-terminal hint,不 filter/trash);若 archived finding RESOLVED(patch_status in {VERIFIED_SECURE, MITIGATION_PROPOSED} 或 status==FALSE_POSITIVE 或 production_viability==NON_VIABLE)且 pair NOT_MATCHED → POSSIBLE REGRESSION:保持 ACTIVE,加 history note,绝不 filter。
  50. Scenario 6 Absent sink evidence:mantis-reproduce Block F 若 EVIDENCE 不存在(compiler/build nonzero exit、exit 127 command-not-found、exit 2 No such file、sink 从未 reached)→ repro_status = not_attempted(retry-eligible),STOP;绝不 failed_to_reproduce;--reattack 模式 leave reattack_status UNSET 并 history note setup_failed,绝不 failed_to_bypass;failed_to_reproduce 仅当 harness 可证明到达 vulnerable entrypoint(reached-sink evidence,不是 setup evidence)但 bug 未触发;reached-sink evidence 必须来自 invoked path 内或 target-produced tracing/backtraces:(a) PoC script/source harness 在 sink call 前写 MANTIS_REACHED_ENTRYPOINT 到 sidecar file,且 marker write 是 invoked path 一部分,不是 pre-launch step;或 (b) binary/firmware/raw-payload targets 的 captured crash backtrace 或 sanitizer trace(ASan/UBSan/MSan/TSan)明确命名 target sink function;外部 wrapper 在调用 target 前写的 marker 只是 SETUP EVIDENCE,不足以 justify failed_to_reproduce,视为 EVIDENCE ABSENT;evidence 记录在 repro_hints;HALT 模式下 HALT ceiling 强制 not_attempted(无 failed_to_reproduce)。
  51. Guideline 6 总:大规模代码库用 semantic retrieval layer 让 planner/researcher 查询相关 KB entries 和 code locations;两种实现共享数据契约:Option A 默认 skill-based BM25/TF-IDF helper script over chunks.jsonl,零外部依赖,air-gapped,可选 vector embeddings;Option B MCP-based 持久 vector index,提供 semantic_search_kb/semantic_search_code MCP tools;两者 opt-in,不修改 existing skills;retrieval results 是 coverage HINTs only,决定 ordering/prioritization,绝不决定 audit set membership;miss 绝不能导致文件/call-site/investigation 被 skip/drop。
  52. RAG A chunks.jsonl:Stage 2 /mantis-architecture 完成后抽取 chunks 到 workspace/kb/chunks.jsonl(每行 JSON);harness 可 post-hoc 读 workspace/kb/*.md,或指示 architecture skill 在 synthesis 时写为 text-only side effect;KB chunks 来自 workspace/kb/*.md,code chunks 来自 CODE_ROOT pinned snapshot,含 file path 和 line range;首行 provenance header 记录 SNAPSHOT_ID;serve queries 前检查 provenance header snapshot_id 与 current SNAPSHOT_ID,不同则 rebuild;MODE-OFF 无 active_snapshot 时 skip index 并 fallback manual scanning;绝不从 live tree 构建 code chunks。
  53. RAG Option A:专用 skill 读 chunks.jsonl 并写+运行 helper script(如 workspace/helpers/search_chunks.py)做 BM25/TF-IDF similarity search;脚本由 agent 运行时生成,不随 skill 发布;零外部依赖,无 embedding/vector store/MCP;参考 references/mantis-kb-query.md,含 Block A、chunk provenance checking、versioned helper script contract (MANTIS_HELPER_VERSION = 1)、JSON output schema;planner/researcher 作为 sub-agent 带 query string 调用;若有 vector embeddings,可用 cosine similarity 替代 BM25,作为运行时配置 toggle;skill 通过 Block A 从 state 读 active_snapshot,serve 前检查 chunk provenance。
  54. RAG Option B:very large codebases 每 invocation BM25 太慢时,harness 拥有 persistent vector index with embeddings,提供 semantic_search_kb(query: string) → [{id, source_file, entity_type, chunk_text, score}] 和 semantic_search_code(query: string) → [{file, start_line, end_line, snippet, score}];harness 管理 vector index lifecycle:从 chunks.jsonl 或 CODE_ROOT build,SNAPSHOT_ID 变化时 rebuild,处理 freshness checks;HALT 模式 serve with STALE flag 或 refuse;MODE-OFF skip entirely。
  55. RAG Per-Skill Augmentation:mantis-architecture 无需修改,harness 在 Stage 2 后 chunk workspace/kb/*.md,可选指示 architect 在 synthesis (Step 3) 也写 workspace/kb/chunks.jsonl 作为 text-only side effect;mantis-plan 若有 retrieval 机制,用它发现 kb_references,对每个 investigation 用 title 和 target file names 查询,将 top-K matching KB entity/vulnerability files 加入 kb_references,无机制时 fallback 手动扫 index.md;mantis-researcher 若有 retrieval,Wave 1 sub-agents 用它 PRIORITIZE relevant call-sites 和 cross-module data flows into sinks,semantic search 补充 grep 作为 ranking HINT ONLY,决定 ORDER 绝不 MEMBERSHIP,不能替代 exhaustive Step-3 call-site sweep,full grep 能到达的每个 call-site/data-flow 仍必须审计,审计 union of grep results and semantic search results,Wave 1/Wave 2 structure 不变。
  56. RAG Snapshot Safety:retrieval index 是 pinned snapshot 的 cache,不是 live view;从 CODE_ROOT 构建 code chunks;SNAPSHOT_ID 变化时 rebuild;HALT (snapshot_pinned=false) 时 serve with STALE flag 或 refuse;MODE-OFF skip entirely。
  57. Embedding-Based Deduplication Pre-Filtering 总:多 pass 大代码库时 dedupe O(n×m) LLM 对比昂贵慢;harness 可用 embeddings 作为 fast pre-filter 减少 candidate space before /mantis-dedupe;skill 现有 deterministic matching (code_paths + title + discovery_commit) 仍是 hard dedup decisions 唯一 authority;harness-side opt-in,不修改 /mantis-dedupe。
  58. Dedup pre-filter How It Works:harness 读 all current workspace/findings/*.json 和 archived workspace/archive/findings_pass_*/*.json;对每个 finding 从 normalized text representation(如 title + description + first code_paths entry with line stripped)计算 embedding;计算 current vs archived pairwise cosine similarity,surface candidate pairs above configurable threshold(如 0.85);写 candidate-pairs manifest(如 workspace/helpers/dedup_candidates.json)含 UUID pairs 和 similarity scores;调用 /mantis-dedupe 如常,若 manifest 存在则指示 skill 优先这些 pairs 做 LLM pairwise comparison;所有 deterministic matching rules 不变,manifest 只缩小搜索空间。
  59. Dedup pre-filter Safety Guardrails:pre-filter only never decision,embedding similarity 不得导致 DUPLICATE verdict、trash move、possible_duplicate_of assignment,只有 skill 现有 code_paths、title、discovery_commit checks 可以;threshold 设低(如 0.75)避免漏真 duplicates,宁可 surface 太多 candidates 也不漏;若 embedding computation 不可用、manifest 缺失或任何 error,/mantis-dedupe fallback 到现有 O(n×m) comparison,manifest 缺失时 skill 不得停止或报错;harness 不应在不同 discovery_commit 值之间计算 embeddings 而不标记为 cross-snapshot candidates,skill Block B pairwise 处理最终 MATCHED/NOT_MATCHED。
  60. Dedup pre-filter Shared Infrastructure:若也实现 Guideline 6,复用同一 vector embedding infrastructure 做 finding embeddings;finding embedding 是不同 payload(finding JSON,不是 KB chunks),但同一 embedding 能力可服务两者。
  61. Enterprise Vector Architecture:企业部署可把 SQLite vector storage 换 managed cloud vector engines:Cloud Spanner Vector Search 适合 mission-critical enterprise pipelines 需 global ACID consistency、99.999% availability、synchronized finding lineage tracking,findings 和 lineage_vectors 存 Spanner with ARRAY<FLOAT32> vector columns,用 COSINE_DISTANCE 和 KNN search indexes 做 real-time finding dedup during parallel scan passes;Cloud SQL for PostgreSQL (pgvector) 适合标准 enterprise relational backends,启用 vector extension,finding embeddings 存 vector(768) 或 vector(256) 列,用 HNSW (vector_cosine_ops) 或 IVFFlat indexes 做 sub-millisecond similarity queries;AlloyDB for PostgreSQL 适合 high-throughput multi-agent audit farms,利用 AlloyDB columnar vector engine 和 ScaNN-based approximate nearest neighbor indexing 比标准 PostgreSQL 快最多 10x vector queries;BigQuery Vector Search 适合 batch analytical processing、organization-wide threat intelligence clustering、cross-campaign vulnerability lineage analysis,ingest finding embeddings into BigQuery,执行 VECTOR_SEARCH(TABLE findings, embedding, ...) with COSINE distance 做 serverless batch dedup 和 historical regression analytics。
  62. SAST Seeding 总:Mantis discovery 100% LLM-generative,弱 LLM 会结构性漏 whole-program taint classes(injection, path traversal, deserialization, UAF, format-string),成熟 SAST(CodeQL, Semgrep-taint)有 interprocedural queries;SAST seeding adapter 摄取外部工具 findings 为 PROVISIONALLY_VALID/NEEDS_RESEARCH candidates,必须经过未改变下游 gates 获得 verdict;纯 additive (INV-2-strengthening),扩大 detection breadth 不弱化 verification gate;遵循 Guideline 6 RAG 模式:opt-in, default off, provenance-tracked, snapshot-aware, fallback on failure。
  63. SAST Platform-agnostic IR:不绑定 SARIF,消费 minimal JSONL IR;任何 SAST 输出(SARIF, Semgrep JSON, Bandit JSON 等)由 thin wrapper 转成 IR;Option A 默认 skill-based /mantis-sast-seed 读 IR 并用 LLM reasoning normalize findings into mantis finding JSONs,LLM 读 CODE_ROOT 下实际源码验证并 enrich description with root-cause analysis,零外部依赖,air-gapped;Option B 最大控制 harness-based 直接用 deterministic code normalize(如 SARIF-to-finding converter script),normalization 绕过 LLM,harness 在调用 /mantis-dedupe 前写 finding JSONs 到 workspace/findings/;两者 opt-in,不修改现有 skills;seeded findings 进入 workspace/findings/ 与 researcher findings 一起,流经未改变下游 gates(dedupe -> review -> critic -> reproduce -> patch -> calibrate);参考 references/mantis-sast-seed.md。
  64. SAST Data Contract sast_findings.jsonl:IR JSONL at workspace/sast_findings.jsonl (STATE-RELATIVE),同 chunks.jsonl provenance-header pattern;Line 1 header 含 _provenance: true, scan_snapshot_id, tool, tool_version, scan_timestamp;scan_snapshot_id 是扫描所对 SNAPSHOT_ID,primary provenance anchor,与 current pass SNAPSHOT_ID byte-for-byte 比较(同 Block B),若对 pinned CODE_ROOT 跑 SAST 则设为 SNAPSHOT_ID;Lines 2+ finding per line 字段:rule_id required tool-specific rule id,severity required CRITICAL/HIGH/MEDIUM/LOW,code_paths required file:line strings SNAPSHOT-RELATIVE,message required,rule_name optional,cwe optional;IR conversion harness responsibility:SARIF extract ruleId,map level to severity (error->HIGH, warning->MEDIUM, note->LOW),extract locations to code_paths,copy message.text;Semgrep JSON extract check_id as rule_id,map extra.severity to Mantis severity,extract path:start.line as code_paths,copy extra.message。
  65. SAST Option A skill-based:专用 skill 读 sast_findings.jsonl,应用 allow-listing,验证 provenance,计算 signature/lineage_id/discovery_commit,写 finding JSONs;LLM 读 CODE_ROOT 下每个 reported location 实际源码验证并 enrich description;harness 在 Stage 6 (Research) 后、Stage 7 (Dedupe) 前用 --snapshot_root/--snapshot_id/--state_root 调用 /mantis-sast-seed;seeded findings 在 /mantis-dedupe 前落到 workspace/findings/;若 sast_findings.jsonl 不存在,skill 输出空并通知 caller,绝不失败;anti-hallucination:LLM 必须在写 finding JSON 前读实际代码,不得发明 SAST 输出中不存在的 findings,sast_provenance.line_verified 记录验证是否成功;skill 通过 Block A 从 state 读 active_snapshot,仅当 snapshot pinned 且 location 在 CODE_ROOT 下验证通过才 stamp discovery_commit。
  66. SAST Option B harness-based:harness 读 SAST tool output,deterministically parse,写 finding JSONs 到 workspace/findings/;仅当 scan 可证明对 pinned CODE_ROOT 运行才 stamp discovery_commit;应用 allow-listing filters;调用 /mantis-dedupe 如常,seeded findings 与 researcher findings 不可区分。
  67. SAST Provenance Verification ladder:1 通过 Block A 从 workspace/.mantis_state.json 读 active_snapshot,若 absent 是 MODE-OFF,跳 step 5;2 若 snapshot_pinned false 是 HALT,跳 step 6;3 读 IR provenance header scan_snapshot_id;4 VERIFIED:scan_snapshot_id present 且 exactly equals SNAPSHOT_ID,stamp discovery_commit = SNAPSHOT_ID,status PROVISIONALLY_VALID;5 MODE-OFF:active_snapshot absent,OMIT discovery_commit,status PROVISIONALLY_VALID;6 HALT:snapshot_pinned false,OMIT discovery_commit,status NEEDS_RESEARCH;7 DRIFT:scan_snapshot_id present but differs,OMIT discovery_commit entirely,status NEEDS_RESEARCH;8 UNVERIFIED:scan_snapshot_id absent,OMIT discovery_commit,status NEEDS_RESEARCH;当 VERIFIED 或 DRIFT 且 CODE_ROOT resolved,做 line-existence verification:对每个 code_paths entry strip trailing :line,检查文件在 CODE_ROOT 下存在,检查 line number 在文件 line count 内,若文件缺失或 line 超范围 downgrade to DRIFT(omit discovery_commit, status NEEDS_RESEARCH);这是同 discovery_commit 和 signature/lineage_id 的 UNTRUSTED-IF-ABSENT pattern。
  68. SAST Allow-Listing:workspace/sast_allowlist.json optional config STATE-RELATIVE,含 enabled, severity_filter, cwe_allowlist, rule_allowlist, per_rule_cap, total_cap;若 config 缺失 defaults: CRITICAL+HIGH only, per_rule_cap=5, total_cap=50;allow-listing 保护 retry cap:/mantis-reproduce 每 finding 硬上限 6 attempts(absolute,never reset),若 1000 SAST findings 无过滤 seeded,reproduce 需最多 6000 attempts,staving retry budget;allow-listing chain(severity filter -> CWE/rule filters -> per-rule cap -> total cap)确保只有 bounded high-signal candidates 进入 pipeline,review (13-rule negative filter) 和 critic (production viability) 进一步过滤 before reproduce。
  69. SAST Per-Skill Augmentation:当 SAST seed skill 可用,harness 在 Stage 6 (Research) 和 Stage 7 (Dedupe) 之间调用 /mantis-sast-seed with --snapshot_root/--snapshot_id/--state_root;mantis-meta-agent 在 /mantis-researcher 完成后、/mantis-dedupe 前调用;mantis-dedupe 无需修改,seeded findings 与 researcher findings 一样处理(signature-based matching, Block B pairwise);mantis-review 无需修改,13-rule negative filter 同样适用;mantis-report 无需修改,sast_provenance informational 可显示。
  70. SAST Snapshot Safety:SAST seed adapter 同其他 code-reading skill 遵循 Block A:从 --snapshot_root/state active_snapshot 解析 CODE_ROOT;遵守 sentinel check (Block A step 2);读 CODE_ROOT 下源码(SNAPSHOT-RELATIVE)做 line-existence verification;写 findings 到 state_root/workspace/findings/ (STATE-RELATIVE);pinned 时绝不写 CODE_ROOT 下;MODE-OFF 无 discovery_commit,所有 verdicts permitted;HALT 省略 discovery_commit,seeded findings 得 NEEDS_RESEARCH;PINNED 验证每个 finding location under CODE_ROOT,verified 则 stamp discovery_commit = SNAPSHOT_ID;SAST tool output 本身不 snapshot-aware,adapter provenance verification 在 stamp 前将每个 finding 重新 grounding 到 pinned CODE_ROOT。
  71. SAST Safety Guardrails:纯 additive,seeded findings 是 PROVISIONALLY_VALID/NEEDS_RESEARCH candidates,必须通过未改变下游 gates:dedupe (Block B), review (13-rule filter), critic (viability), reproduce (Block F reached-sink evidence + HALT ceiling), patch (Block G re-attack), calibrate (sanity caps);no gate weakened;no false VERIFIED_SECURE:seeded findings 从 PROVISIONALLY_VALID 开始,必须通过 full patch + re-attack pipeline 才能到 VERIFIED_SECURE;no false failed_to_reproduce:到 reproduce 受同 Block F evidence gate 和 HALT ceiling;no dropped regression:若 SAST-seeded finding 匹配 archived finding 且不同 discovery_commit,Block B 返回 NOT_MATCHED -> possible_duplicate_of -> finding 保持 active;fail-safe on missing data:若 sast_findings.jsonl 不存在,不写 findings;若 finding 不能验证,NEEDS_RESEARCH;no existing skills modified:adapter 在 /mantis-dedupe 前写 findings 到 workspace/findings/;sast_provenance informational only,不影响 safety-critical invariant/gate/verdict,finding 的 discovery_commit 才 governs Block B snapshot matching。
  72. Structural Code Index 总:大代码库 grep call-site 不可靠(漏间接调用、无法区分注释/字符串、无函数边界意识);结构代码索引提供 AST-level context(function boundaries, call graphs, symbol tables)改善 LLM reasoning quality during discovery;遵循 RAG pattern:optional, provenance-tracked, snapshot-aware, fallback on failure;coverage HINT only,决定 ordering/prioritization,绝不决定 audit set membership;miss 绝不能导致文件/call-site/investigation 被 skip/drop;完整规范在 ../mantis-structural-index/SKILL.md,thin blueprint references/mantis-structural-index.md;Option A 默认 skill-based mantis-structural-index 生成并运行 helper scripts (build_structural_index.py 和 query_structural_index.py, both # MANTIS_HELPER_VERSION = 5) 使用 capability-based per-partition backend selection,degrading to grep;Option B MCP-based harness 拥有 persistent structural index serving find_callers(symbol), find_callees(function), get_function_boundary(file, line) MCP tools,backed by same SQLite serving store;两者 optional;non-conformant harness 跳过 stage;consumers 必须用 query interface (query_structural_index.py) 而不是直接过滤 JSONL;query interface 提供 bounded results, pagination, explicit name resolution, precision/backend metadata, coverage on empty results。
  73. Structural Per-Skill Augmentation:mantis-architecture 可选读 pre-built structural index (built by mantis-structural-index at Stage 0.5) during KB synthesis,与 dependencies.json 交叉引用;mantis-plan 用 structural index 做 function-level dependency fan-out(比 file-level dependencies.json 更 precise);mantis-researcher Wave 1 sub-agents 用 find_callers() SUPPLEMENT grep 作为 ranking HINT for call-site discovery,决定 ORDER 绝不 MEMBERSHIP,绝不能替代 exhaustive Step-3 call-site sweep,full grep 能到达的每个 call-site 仍必须审计,无论 structural index 是否排名,审计 union of grep results and structural index results;Wave 2 deep auditors 用 get_function_boundary() 从 enclosing function 开始,按需扩展到 callers/callees/file 获取 cross-function context;researcher 现有 Wave 1/Wave 2 structure 不变。
  74. Structural Integration with RAG:structural index entries 可加入 chunks.jsonl 作为 entity_type: structural chunks;code chunks 可通过 structural index function boundaries 变成 function-boundary-aligned(而非 dumb line-range slices);若两者都实现,structural index 和 RAG index 可共享同一 vector embedding infrastructure。
  75. Tiered Iterative Reproduction 总:复杂服务 single-shot reproduction 对 full sandboxed service 常有高 search entropy、脆配置、难调试失败;分层策略拆复现为 incremental milestones,inter-conversation retry architecture 防止 reasoning deadlocks 和 context bloat。
  76. Tiered A1 Intra-Conversation Retries:active subagent conversation 在其 context window 内本地重试 2–3 次调整参数、修复 setup bugs、refine payloads。
  77. Tiered A2 Inter-Conversation Retries:若 intra-conversation retries 未达 Tier 3 (reproduced),orchestrator 终止 stalled conversation 并启动 new subagent conversation(fresh context window);orchestrator 用 state_root/workspace/archive/.repro_attempts.json 的结构化 attempt data 和 workspace/learnings.jsonl 的 trajectory learnings 填充新 prompt(如 Attempt 1 failed due to missing auth header X; Attempt 2 proved parser strips unescaped quotes);消除 context bloat 和 reasoning inertia(hallucination traps),让 fresh agent 用 prior empirical observations 解决问题而不重复错误。
  78. Tiered A3 Attempt Cap Accounting:orchestrator 维护 state_root/workspace/archive/.repro_attempts.json;只有 Tier-3 full sandboxed service executions(或 full end-to-end reproducer runs)递增 per-finding attempt counter toward absolute hard ceiling of 6;内部 Tier-1 和 Tier-2 trial runs 由 local sub-budget 限制(每 conversation 最多 3 trial executions),不消耗 absolute 6-attempt cap。
  79. Tiered B Harness-Enforced Tier 4:防 un-gated exploit execution on live infra,Tier 4 严格由 programmatic orchestrator harness 拥有/执行,绝不由 LLM discretion;mantis-reproduce 严格在 isolated local sandboxes (Tiers 1–3) 执行,结束于 Tier 3 (reproduced/failed_to_reproduce);harness intercepts Tier 3 reproduced verdict,若配置 live/staging validation (Tier 4),不得自动调用 remote execution,必须执行 programmatic Human-in-the-Loop gate:prompt human operator for explicit interactive confirmation,或 require cryptographically signed approval token / authorization callback;若 human approval 缺失或拒绝,Tier 4 skipped,Tier 3 sandboxed verdict remains authoritative。
  80. Tiered C Local Ingress / Middlebox Edge Annotation:消除 default edge filters 导致的 false positives(Works on localhost:8080, but dies at WAF/proxy),orchestrator 可选执行 Tier 3 PoC through local reverse proxy 或 API gateway(如 NGINX, Envoy, ModSecurity)running inside local sandbox;payload blocked by local middlebox 绝不能 downgrade Tier 3 reproduced verdict to failed_to_reproduce;harness 记录 ingress_blocked: true(或 edge filter details)在 finding 的 repro_hints 或 history,提供 empirical evidence for /mantis-critic 分类 production_viability as CONDITIONAL_VIABLE(mitigated by default edge proxy configuration)。

适用边界 · 注意事项