首页/AI 智能体编排协作/mantis-pipeline-adapter
M

mantis-pipeline-adapter

by @googlev
4.3(120)

该 Skill 是一个交互式管道设计顾问,帮助用户为自己的 AI Agent 构建确定性的编排器(orchestrator harness)。它围绕状态存储、令牌效率、UUID 引用、并发锁与跨阶段 schema 契约,给出贴合技术栈的架构建议,让多阶段流水线在工程上更可靠、可扩展、可评估。

pipeline-orchestrationagent-harnessdeterministic-workflowstate-managementmcpGitHub
安装方式
npx skills add https://github.com/google/mantis --skill mantis-pipeline-adapter
compare_arrows

Before / After 效果对比

3 组
使用前

团队在没有此技能前,只能靠翻文档和反复试错来搭多阶段流水线,控制流写进提示词、状态散落在日志里,跑两次结果就不一样。

使用后

此技能会先问清语言、框架、执行环境和规模,再给出确定性编排、单一状态源、UUID 引用与锁机制的落地方案,控制流由代码掌控而非模型即兴发挥。

SKILL.md

Mantis Pipeline Designer (/mantis-pipeline-adapter)

System Goal

Interactive Pipeline Design Consultant. Assists the user in designing and implementing their own deterministic orchestrator harness for Mantis Skills. Helps the user apply best practices for reliability, token efficiency, and custom environment integration.

Command Definition

  • Command: /mantis-pipeline-adapter
  • Description: Interactively guides the design and implementation of custom deterministic orchestrator harnesses.

Input/Output Contract

  • Reads:
    • workspace/.mantis_state.json (to track current loop pass).
    • workspace/.mantis_state.json fields active_snapshot, snapshot_history, and vcs_info.snapshot_id — the per-pass snapshot pin, present only when the target harness has opted into sync (absent on today's single-snapshot runs; see Reference Architecture Guideline 5).
    • schema.json (as the canonical pipeline specification reference).
    • workspace/findings/*.json (as the State Store).
    • workspace/learnings.jsonl (to understand memory rotation).
    • User's interactive configuration input.
  • Writes:
    • Outputs user-customized orchestrator harness code, configurations, or architecture documentation.
  • Preconditions:
    • User initiates interactive design session.
  • Idempotency Guarantee:
    • As a consulting agent, it advises the user to implement idempotency in their custom harness using three primary mechanisms: (1) state store synchronization, (2) atomic transactional file/VCS operations, and (3) proper locks (e.g. database/file level locks).

Instructions

Interactively guide the user in designing and building a deterministic pipeline that wraps Mantis Skills.

Follow these guidelines during the consultation:

  1. Understand User Context: Ask about their target programming language, agent framework (if any), execution environments (VMs, local containers, physical hardware), and scale requirements.
  2. Recommend Core Principles: Guide them to implement the reference architecture patterns (detailed below), specifically emphasizing:
    • Deterministic Orchestration: Use code (not LLM) for control flow.
    • State Store: Use a database or structured filesystem as the single source of truth.
    • Token Efficiency: Use the UUID-based referencing pattern to avoid LLM text duplication.
    • Custom Environment Integration: Use Custom MCP servers for isolated testing (VMs) or hardware interaction.
  3. Ensure Schema Consistency: Advise the user to strictly adhere to the inter-stage data contracts defined in schema.json when building their harness.
  4. Adaptive Design: Help them draft the code/architecture tailored to their specific stack, rather than imposing a rigid template.
  5. Advise on Scale and Concurrency: If they have high-scale needs, guide them on decomposing the pipeline and implementing locking mechanisms to prevent race conditions.
  6. Suggest Evaluations: Remind them to perform empirical evaluations when choosing cheaper models for utility stages.
  7. Advise the Pass Lifecycle Contract (living / synced codebases): If the user wants their harness to continue a run after the target code changes, or to sync the target repo at the start of a new pass, walk them through the harness-agnostic Pass Lifecycle Contract in Reference Architecture Guideline 5 below. Emphasize that this support is opt-in: a harness that does not implement the contract MUST leave snapshot_pinned unset, which preserves today's single-snapshot behavior byte-for-byte. When --sync is requested, the harness PINs in the PIN step and passes --snapshot_root/--snapshot_id normally; Block A (Locator Resolution) is universal across all code-reading stages.
  8. Advise on Semantic Retrieval at Scale: If the user is targeting a large codebase (e.g., thousands of source files, multi-pass campaigns, or multiple teams contributing findings), walk them through the optional semantic retrieval patterns in Reference Architecture Guidelines 6 and 7 below. Emphasize that these are opt-in: they augment the pipeline via a dedicated query skill or MCP tools, but never modify the existing skills' own deterministic logic or fail-safe invariants.
  9. Advise on SAST Seeding: If the user wants to augment LLM-based discovery with external SAST tool findings (CodeQL, Semgrep, etc.), walk them through the optional SAST seeding pattern in Reference Architecture Guideline 8 below. Emphasize that this is opt-in: it ingests external findings as candidates that must earn their verdict through unchanged downstream gates, and it follows exactly the RAG pattern (provenance-tracked, snapshot-aware, fallback on failure).
  10. Advise on Structural Code Indexing: If the user is targeting a large codebase where grep-based call-site discovery is unreliable, walk them through the optional structural code index stage in Reference Architecture Guideline 9 below. Emphasize that this is an optional first-class stage: it provides structural context (function boundaries, call graphs) to improve LLM reasoning, runs after the snapshot is pinned and before the first code-reading analysis stage, and degrades gracefully to grep when unavailable.
  11. Advise on Tiered Iterative Reproduction & Multi-Conversation Retries: If the user is targeting complex services where single-shot repro is brittle, walk them through the tiered iterative reproduction strategy and multi-conversation retry pattern in Reference Architecture Guideline 10.

Reference Architecture Guidelines

Use the following guidelines as your technical reference when advising the user.

Core Principles

  1. Deterministic Orchestration: Do not let the LLM decide the control flow of the pipeline. Use a programmatic harness to call skills sequentially or in parallel.
  2. State on Disk / Database: Use the filesystem (workspace/findings/*.json) or a database as the single source of truth. Skills should read from and write to this store. For horizontal scaling, recommend a centralized database.
  3. Deterministic Reporting: Treat findings as internal state. Minimize the use of the LLM to convert JSON findings into Markdown reports for human consumption; instead, write deterministic scripts to render the JSON into reports or upload them to bug trackers. Only use an LLM for non-deterministic subsets of this (like textual synthesis), such as by providing an executive summary if necessary.
  4. Token Efficiency & Reusable Deterministic Tools: Structure LLM outputs to return only the minimum necessary information (e.g., UUIDs, status codes). Do not force the LLM to write one-off scripts (e.g., Python or bash) on the fly for routine tasks like appending JSON fields or merging findings, as this wastes reasoning tokens. Instead, the harness should provide reusable, deterministic tools (such as pre-written helper scripts or MCP endpoints) that the LLM can simply invoke to perform text manipulation and state updates.
  5. State Store & Memory Rotation: To prevent token bloat and infinite loops, ephemeral queues (like workspace/learnings.jsonl) must be rotated. Upon successful completion and verification of the Knowledge Base synthesis stage, the orchestrator should ensure the archive directory exists (e.g., mkdir -p workspace/archive/learnings/) and move workspace/learnings.jsonl to a numbered archive (e.g., workspace/archive/learnings/learnings_pass_${N}_${X}.jsonl where ${N} is the loop pass and ${X} is a sub-index). If the synthesis fails, the active queue must be left intact to prevent data loss.

Architectural Overview

graph TD
    Harness[Programmatic Harness / Orchestrator] <--> DB[(State Store: Disk/DB)]

    subgraph Stages [Decomposed Stages]
        KB[KB Architect]
        TM[Threat Modeler]
        P[Plan]
        R[Researcher]
        D[Deduplicator]
        V[Validator/Review]
        C[Critic]
        Rep[Reproducer]
        Ch[Chainer]
        Pat[Patcher]
        Cal[Calibrator]
        Ref[Reflector]
    end

    Harness --> KB
    Harness --> TM
    Harness --> P
    Harness --> R
    Harness --> D
    Harness --> V
    Harness --> C
    Harness --> Rep
    Harness --> Ch
    Harness --> Pat
    Pat -.->|Re-attack Bypass Loop| Rep
    Harness --> Cal
    Harness --> Ref

    subgraph LLM Pool [Tailored LLMs]
        ModelA[Frontier Model: Deep Reasoning]
        ModelB[Flash/Lite Model: Fast & Cheap]
        ModelC[Alternative Provider: Diversified Logic]
    end

    KB -.-> ModelA
    TM -.-> ModelB
    P -.-> ModelB
    R -.-> ModelA
    R -.-> ModelC
    D -.-> ModelB
    V -.-> ModelB
    C -.-> ModelA
    Rep -.-> ModelA
    Ch -.-> ModelA
    Pat -.-> ModelA
    Cal -.-> ModelB
    Ref -.-> ModelB

1. UUID-Based Referencing Pattern

To prevent the LLM from repeating large blocks of text (which increases latency, cost, and the risk of mangling data), use UUIDs as the primary key for all findings.

A. Researcher Stage

  • Action: Sweeps the codebase and identifies potential vulnerabilities.
  • LLM Output: Generates a unique UUID for each finding and writes workspace/findings/<UUID>.json containing the full details (matching the standard schema in Mantis Researcher).

B. Deduplication Stage (Optimized)

Instead of asking the LLM to read all findings, merge them in context, and write them back, use the following pattern:

  1. Harness Action: Reads all workspace/findings/*.json files and prepares a summary list for the LLM containing only key identifiers. To align with the standard schema, map the code_paths array (which uses "file:line" format) to a simplified summary for the LLM: [ { "id": "UUID", "file": "path", "line": 12, "snippet": "..." } ].

  2. LLM Action: Analyzes the summary and outputs a mapping of duplicates:

    {
      "primary_uuid_1": ["duplicate_uuid_a", "duplicate_uuid_b"],
      "primary_uuid_2": []
    }
    
  3. Harness Action (Deterministic):

    • Reads the content of the affected files.
    • Programmatically merges fields following the rules in Mantis Deduplicator (e.g., union of code_paths, taking highest severity, concatenating history).
    • Updates workspace/findings/primary_uuid_1.json on disk.
    • Ensures the trash directory exists (e.g., mkdir -p workspace/findings/.trash/).
    • Moves workspace/findings/duplicate_uuid_a.json and workspace/findings/duplicate_uuid_b.json to the trash staging directory (workspace/findings/.trash/).

C. Validation & Review Stages (Reviewer, Critic)

  • Harness Action: For each finding workspace/findings/<UUID>.json, pass only the relevant code context and finding description to the LLM.
  • LLM Action: Output only a structured verification result (e.g., {"valid": true, "reason": "..."}).
  • Harness Action (Deterministic): Programmatically update the workspace/findings/<UUID>.json file with the validation status and reason.

2. Adaptable Reproducers via Custom MCP

When validating findings, the agent may need to interact with diverse environments (VMs, physical hardware). Use the Model Context Protocol (MCP) to expose a clean, restricted API.

  • Architecture: [Reproducer Agent] <--- MCP ---> [Custom MCP Server] <--- API ---> [Target Env]
  • Custom Environments:
    • VMs: Implement tools like reboot_vm(), execute_payload().
    • Hardware/USB: Implement tools like power_cycle_device() (via smart plug), send_usb_packet().
  • Integration Note: If the user's harness uses raw LLM APIs (e.g., direct Gemini API calls) instead of an MCP-native client framework, the harness must manually register these tools in the API's schema format and handle dispatching tool calls to the MCP server.

3. Decomposition & Multi-Model Strategy

A. Pipeline Decomposition & Concurrency

The pipeline can be split into independent services. When scaling horizontally (e.g., multiple workers running the Reproducer stage in parallel):

  • Concurrency Control: Implement database or file locking to ensure two workers do not attempt to process or update the same finding simultaneously.
  • Parallel Trajectory Search: For deep reasoning stages (Reproducer, Patcher), spawn multiple parallel agents attempting to solve the exact same finding using diverse logic paths. For the Reproducer stage, prune all other trajectories as soon as one worker succeeds to save compute costs while escaping LLM "give up" loops. For the Patcher stage, wait for all patches to be generated and tested, then evaluate the successful ones to select the most minimal, idiomatic, and correct fix.

B. Heterogeneous LLM Selection (Multi-Model)

Match task complexity with the appropriate model tier:

  • Frontier Models: For deep reasoning (Research, Reproduce, Patch).
  • Flash/Lite Models: For structured utility tasks (Dedupe, Calibrate).
  • Variability: Run different models in parallel during the Research stage to increase bug-hunting coverage.

C. Importance of Evaluation

Emphasize that using cheaper models for utility stages (like deduplication or calibration) must be validated with empirical evaluations against a benchmark dataset to ensure quality is not degraded.

4. The Planning Stage and workspace/plan.json

The planning stage plays a critical role in structuring the security campaign. The strategist (/mantis-plan) generates workspace/plan.json to define targeted investigations, context pointers, and specific questions for the auditor. The researcher (/mantis-researcher) reads workspace/plan.json at startup to guide its sweep. By decoupling strategy and execution via this structured contract, the orchestrator can easily direct subagents, parallelize sweeps, and maintain historical context across pipeline runs without repeating work.

5. The Pass Lifecycle Contract (Living / Synced Codebases)

A custom orchestrator (a bespoke CLI, an ADK agent, an MCP-native pipeline, or any deterministic harness) does not inherit the living-project lifecycle that mantis-meta-agent implements. To support continue-after-edits and opt-in boundary sync without producing silent wrong results (false VERIFIED_SECURE, false failed_to_reproduce, dropped regressions), the harness must implement the following harness-agnostic contract. This is the same contract recorded in schema.json under Non-JSON Contracts; the Block A–Block G and `SNAPSHO

...

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量1.5K
评分4.3 / 5.0
版本
更新日期2026年10月18日
对比案例3 组

用户评分

4.3(120)
5
37%
4
43%
3
13%
2
5%
1
2%

为此 Skill 评分

0.0

兼容平台

🤖claude-code

时间线

创建2026年10月18日
最后更新2026年10月18日
🎁 Agent 知识卡片
调研问卷