[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6991AVG6M42XNBB3JWC0K2Q":3,"skill-same:01M6991AVG6M42XNBB3JWC0K2Q":65},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":36,"linkOnly":37,"markdownContent":38,"markdownBody":39,"frontMatter":40,"refName":41,"commitSha":42,"skillDirectory":43,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":46,"ownerHtmlUrl":47,"ownerBlogUrl":48,"ownerDescription":49,"updatedAt":50,"install":51,"resources":64},"01M6991AVG6M42XNBB3JWC0K2Q","mantis-chain",null,"Analyzes individual security findings to identify and construct complex exploit chains. Use after validation stages to see if multiple low-severity bugs can be combined into a higher impact vulnerability. Don't use for initial codebase auditing or writing patch code.","google\u002Fmantis","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M6990SDGGFEAP21TJNS7HEG9",2778,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-chain\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],"mantis chain","chain","exploit","combined","codebase","bugs","for","can","impact","patch","writing","use","vulnerability","severity","validation","code","security","2026-11-10 10:12:30",false,"---\nname: mantis-chain\ndescription: >-\n  Analyzes individual security findings to identify and construct complex exploit chains.\n  Use after validation stages to see if multiple low-severity bugs can be combined into a higher impact vulnerability.\n  Don't use for initial codebase auditing or writing patch code.\n---\n\n# Vulnerability Chainer (\u002Fmantis-chain)\n\n## System Goal\n\nExploit Chain Architect. Analyzes isolated, individually-validated security\nfindings and historical knowledge base primitives to identify and construct\ncomplex, multi-step exploit chains.\n\n## Command Definition\n\n- **Command:** `\u002Fmantis-chain`\n- **Description:** Analyzes individual security findings to identify and\n  construct complex exploit chains.\n- **Arguments (all optional; supplied by the orchestrator per the harness\n  lifecycle contract — see `schema.json` \"Non-JSON Contracts\"):**\n  - `--snapshot_root` \u002F `SNAPSHOT_ROOT` — the pinned, immutable code snapshot\n    root for this pass. Consumed by Block A.\n  - `--snapshot_id` \u002F `SNAPSHOT_ID` — the snapshot identity string for this\n    pass. Consumed by Block A (sentinel) and Block B (match check).\n  - `--state_root` — parent directory of `workspace\u002F`. When absent, defaults to\n    the current directory (Block A step 1c\u002F1d).\n  - `--target_root` — an already-prepared tree that OVERRIDES the snapshot root\n    (rarely used by this stage; honored by Block A step 1a). When NONE of these\n    are passed, Block A falls back to `active_snapshot` in\n    `workspace\u002F.mantis_state.json`; if that is absent too, the stage runs\n    MODE-OFF (`snapshot_pinned = false`) and behaves exactly as today (see\n    Backward-compat).\n\n## Input\u002FOutput Contract\n\n- **Reads**:\n  - `workspace\u002Ffindings\u002F` (validated finding JSON files where status is\n    `\"VALID\"`, and viability is `\"VIABLE\"`, `\"CONDITIONAL_VIABLE\"`, or\n    `\"SAMPLE_OR_TEST\"`).\n  - `workspace\u002Fkb\u002Fentities\u002F*.md` and `workspace\u002Fkb\u002Fvulnerabilities\u002F*.md`\n    (knowledge base primitives).\n  - `workspace\u002F.mantis_state.json` (to track current loop pass).\n- **Writes**:\n  - Net-new exploit chain finding JSON files to\n    `workspace\u002Ffindings\u002F\u003Cnew_uuid>.json`. Original findings are left unmodified.\n- **Preconditions**:\n  - Validated or viable findings must exist in `workspace\u002Ffindings\u002F`.\n- **Idempotency Guarantee**:\n  - Before writing a new exploit chain finding, the skill must check existing\n    exploit chain findings by comparing the constituent finding sequence. Scan\n    BOTH the current `workspace\u002Ffindings\u002F` directory AND every archived pass\n    under `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n    `workspace\u002Farchive\u002Floop*_findings\u002F` (all STATE-RELATIVE — never prefix\n    `CODE_ROOT`). A chain JSON is any finding whose `constituent_findings` array\n    is present and non-empty. If a chain with the EXACT same ordered constituent\n    sequence already exists in EITHER location, skip creating a duplicate.\n  - **Signature-keyed idempotency (preferred) — with a code_paths tiebreak:** If\n    ALL constituent findings have a `signature` field, compare the ordered\n    constituent `signature` sequence (not UUIDs). Treat two chains as the SAME\n    (and skip creating the new one) ONLY IF their ordered `signature` sequences\n    are equal AND, for each corresponding constituent pair, at least one\n    `code_paths` entry (line-inclusive, i.e. compared WITH its trailing `:line`)\n    is identical. If the signature sequences match but any corresponding\n    constituent's `code_paths` differ, the chains are DISTINCT — create the new\n    chain. (Over-reporting is safe; a `signature` collision must never suppress\n    a genuinely new exploit chain, because `signature` strips line numbers and\n    can collide between distinct same-file bugs.)\n  - **UUID fallback (today's behavior):** If ANY constituent finding lacks a\n    `signature` field, fall back to comparing the ordered constituent UUID\n    sequence exactly as before. This preserves today's behavior for legacy \u002F\n    un-upgraded findings.\n  - This archive scan is now fully effective with stable finding signatures: two\n    chains whose constituents share the same signatures are correctly\n    deduplicated across passes. When signatures are absent (legacy findings),\n    the scan remains HARMLESS — it cannot falsely suppress a legitimate new\n    chain (no silent dropped result) and simply prevents exact-UUID\n    re-duplication within a resumed \u002F rerun pass. If the `workspace\u002Farchive\u002F`\n    directory does not exist, treat the archived set as empty and proceed.\n\n## Instructions\n\n### Locator Resolution (run first — all stages)\n\n```\nLOCATOR RESOLUTION (before reading ANY target code or artifact):\n0. ROLE: If this skill NEVER reads target source (report, calibrate, reflect),\n   you are a FINDINGS-ONLY stage: skip steps 2-6; still read active_snapshot from\n   state for provenance\u002Fannotation; NEVER stop merely because a code root is unset.\n1. Determine CODE_ROOT, in this priority order:\n   a. If --target_root is passed on THIS invocation, CODE_ROOT = --target_root.\n      It is AUTHORITATIVE and OVERRIDES SNAPSHOT_ROOT and the state fallback\n      (used when a caller hands you a prepared tree, e.g. a patched shadow).\n   b. Else if --snapshot_root (or SNAPSHOT_ROOT) is passed, use it.\n   c. Else read state_root\u002Fworkspace\u002F.mantis_state.json (state_root from\n      --state_root if passed, else .\u002Fworkspace\u002F... relative to the current dir)\n      -> active_snapshot.root \u002F .snapshot_id \u002F .snapshot_pinned.\n   d. Else (no arg AND no readable active_snapshot): CODE_ROOT = current directory,\n      treat snapshot_pinned = false (MODE-OFF). Do NOT stop.\n2. SENTINEL CHECK (only if snapshot_pinned is true AND you did NOT take path 1a):\n   verify CODE_ROOT\u002F.mantis_snapshot_id exists and equals SNAPSHOT_ID. If missing\n   or different -> STOP \"snapshot sentinel mismatch\". (A --target_root tree (1a) is\n   deliberately mutated and is sentinel-EXEMPT.)\n3. PATH FIELDS:\n   - SNAPSHOT-RELATIVE (read under CODE_ROOT): code_paths entries; plan target_files\n     that are file paths. Strip ONLY a trailing \":\u003Cdigits>\". A code_paths entry\n     containing \":\u002F\u002F\" is a URL\u002Fendpoint, NOT a file read. A code_paths entry that is\n     NOT of the form \u003Cexisting-path>:\u003Cinteger> is a non-source LOCATOR\n     (symbol\u002Foffset\u002Fendpoint): only check that the artifact\u002Fsymbol exists; skip ALL\n     line-range and line-existence logic.\n   - STATE-RELATIVE (read\u002Fwrite under state_root\u002Fworkspace, NEVER prefix CODE_ROOT):\n     kb_references, repro_file_path, reattack_file_path, helper scripts, report\n     files, and all state\u002Ffindings JSON.\n4. Never WRITE under CODE_ROOT when snapshot_pinned is true. Any command that\n   compiles, generates, or writes artifacts MUST run in a PRIVATE SHADOW copy\n   (mktemp -d from CODE_ROOT), never with cwd=CODE_ROOT. Read-only inspection may\n   cd into CODE_ROOT.\n5. VCS-METADATA CARVE-OUT: history-log extraction and any VCS diff\u002Fblame command\n   run in the LIVE repository root (which still has .git\u002F.hg\u002F.repo), NOT CODE_ROOT\n   (the snapshot copy strips VCS metadata). Do NOT stop merely because CODE_ROOT\n   lacks .git\u002F.hg\u002F.repo.\n6. Every shell command uses ABSOLUTE paths and sets its own working directory on\n   that call. Do NOT assume the working directory persists between calls.\n```\n\n> [!NOTE] **CURRENT-PASS CHECK (defensive; the binding guarantee is on the\n> harness per `mantis-pipeline-adapter` Scenario 2):** if `active_snapshot` is\n> present AND `active_snapshot.pass != state.pass_number`, treat the snapshot as\n> STALE for this pass — STOP \"stale active_snapshot: pass mismatch\" or degrade\n> as HALT (`snapshot_pinned` effectively false: no authoritative verdicts, Block\n> B NOT_MATCHED, reproduce `not_attempted`). This catches a custom harness that\n> preserved `active_snapshot` across the Stage 15 pass increment without\n> re-pinning. The reference meta-agent re-pins every pass, so this check never\n> fires there. Block B itself cannot detect this (it is `snapshot_id`-only, not\n> `pass`-aware).\n\nStage-specific notes for Block A:\n\n- `mantis-chain` is NOT a findings-only stage (it is not\n  report\u002Fcalibrate\u002Freflect), so Block A runs steps 1–6 and resolves `CODE_ROOT`,\n  `SNAPSHOT_ID`, and `snapshot_pinned` from `--snapshot_root` \u002F `--snapshot_id`\n  \u002F state `active_snapshot`.\n- This stage WRITES only new finding JSON to `workspace\u002Ffindings\u002F`\n  (STATE-RELATIVE, Block A step 3). It never writes under `CODE_ROOT`, so Block\n  A step 4 is satisfied trivially. If you optionally re-inspect a constituent's\n  `code_paths` to sanity-check a chain, read them SNAPSHOT-RELATIVE under\n  `CODE_ROOT` (Block A step 3) and never cd-and-write there.\n- A chain finding's `code_paths` are COPIED verbatim from its constituents (they\n  are already SNAPSHOT-RELATIVE). Do not re-prefix, re-resolve, or renumber\n  them.\n\n### Snapshot Match Check (used to select constituents)\n\n```\nSNAPSHOT MATCH CHECK for finding F (decides MATCHED vs NOT_MATCHED):\n1. If snapshot_pinned is false -> NOT_MATCHED. Stop.\n2. Read F.discovery_commit:\n   - missing OR empty OR the literal \"MIXED\" -> NOT_MATCHED.\n   - not exactly equal to SNAPSHOT_ID          -> NOT_MATCHED.\n   - exactly equal to SNAPSHOT_ID              -> MATCHED.\nThere is no other route to MATCHED; never fuzzy-compare. The global \"default the\nfield and proceed\" backward-compat rule does NOT apply to discovery_commit:\nabsent = NOT_MATCHED. (There is NO separate \"dirty\" gate: a dirty tree's\nSNAPSHOT_ID already embeds the working-tree content hash, so within-pass findings\nMATCH and cross-pass bare-commit findings do not.)\n```\n\nYou will run Block B once per candidate constituent finding in Step 1 below,\nusing that finding's `discovery_commit` as `F.discovery_commit`.\n\nRead the current batch of validated findings and explore whether multiple\nseemingly low-severity or disparate vulnerabilities can be sequentially combined\nto achieve a higher-impact compromise.\n\nExecute the chaining stage as follows:\n\n1. **Load Primitives & Validated Findings:**\n\n   - Read the JSON files in the `workspace\u002Ffindings\u002F` directory. Filter for\n     findings that have passed validation (e.g., status is `\"VALID\"` and\n     viability is `\"VIABLE\"`, `\"CONDITIONAL_VIABLE\"`, or `\"SAMPLE_OR_TEST\"`).\n   - **Snapshot eligibility gate (NEW — branches on `active_snapshot` presence,\n     3-state model):**\n     - **MODE-OFF** (no `active_snapshot` in state — no `--sync` was requested,\n       today's default): SKIP this gate entirely: every finding that passed the\n       validation\u002Fviability filter above is an eligible constituent, exactly as\n       today. Build chains normally.\n     - **HALT** (`active_snapshot` IS present but `snapshot_pinned == false`):\n       do NOT build any chains this pass. In HALT, findings' locators and\n       pre\u002Fpost-conditions may be stale (the tree raced or could not be pinned),\n       so no authoritative chain verdicts may be produced. Log \"no chain: HALT\n       mode (active_snapshot present, snapshot_pinned=false)\" and stop the\n       chaining stage cleanly (produce no chain files). This mirrors the\n       minimum-eligibility guard below — a chain requires\n       proven-against-snapshot constituents, which HALT cannot provide.\n     - **PINNED** (`active_snapshot` present AND `snapshot_pinned == true`): run\n       the **Snapshot Match Check (Block B)** on EACH such finding, using its\n       `discovery_commit`. Keep ONLY findings that return **MATCHED** as\n       eligible constituents. A finding that returns **NOT_MATCHED** — including\n       any finding whose `discovery_commit` is absent\u002Fempty, is the literal\n       `\"MIXED\"`, or differs from the current `SNAPSHOT_ID` — was discovered\n       against a DIFFERENT code snapshot; its `file:line` locators and its\n       pre\u002Fpost-conditions may no longer hold, so it MUST NOT be used as a chain\n       link this pass.\n   - **Minimum-eligibility guard (NEW):** If fewer than 2 eligible constituents\n     remain, do **NOT** construct any chain this pass — a chain requires at\n     least two links proven against the SAME snapshot. Log \"no chain: fewer than\n     2 snapshot-matched constituents\" and stop the chaining stage cleanly (this\n     is not an error; simply produce no chain files). This mirrors today's\n     behavior whenever there are fewer than two chainable findings.\n   - Read the Markdown Knowledge Base (`workspace\u002Fkb\u002Fentities\u002F` and\n     `workspace\u002Fkb\u002Fvulnerabilities\u002F`) to identify architectural primitives that\n     might not be bugs on their own, but could serve as stepping stones (e.g.,\n     \"User controls file upload path\", \"Service runs as root\").\n\n2. **Cross-Finding Analysis (The Chaining Matrix):**\n\n   - Analyze the preconditions and postconditions of each validated finding.\n   - Ask: *Can the output or side-effect of Finding A satisfy the strict\n     precondition required to trigger Finding B?*\n   - Example Chains to look for:\n     - **Path Traversal + Loose Permissions = RCE:** A low-severity path\n       traversal (Finding A) allows writing to `\u002Ftmp`, but a separate\n       misconfiguration (Finding B) allows a cron job to execute scripts in\n       `\u002Ftmp`.\n     - **XSS + CSRF = Account Takeover:** A stored XSS (Finding A) can be used\n       to harvest an anti-CSRF token to execute a state-changing action (Finding\n       B).\n     - **Info Leak (Memory Revelation) + Buffer Overflow = ASLR Bypass:** An\n       info leak (Finding A) reveals base pointers, satisfying the precondition\n       to exploit a stack buffer overflow (Finding B).\n\n3. **Construct \"Super Findings\":**\n\n   - If a viable exploit chain is discovered, do **NOT** modify or delete the\n     original isolated findings. They still need to be patched individually.\n   - **Idempotency check (run BEFORE minting a UUID):** Apply the Idempotency\n     Guarantee above — scan current `workspace\u002Ffindings\u002F` AND\n     `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n     `workspace\u002Farchive\u002Floop*_findings\u002F` for a chain whose constituent sequence\n     equals this chain's ordered constituent sequence. If ALL constituents have\n     `signature`, compare ordered `signature` sequences AND require the\n     per-constituent line-inclusive `code_paths` tiebreak described in the\n     Idempotency Guarantee (a signature-sequence match ALONE is NOT enough to\n     skip); if ANY constituent lacks `signature`, fall back to ordered\n     constituent UUID sequences (today's behavior). Only if a match satisfies\n     the tiebreak, SKIP this chain (do not create a file) and move on to the\n     next candidate.\n   - Instead, generate a **net-new UUID** and create a new finding JSON file in\n     `workspace\u002Ffindings\u002F\u003Cnew_uuid>.json`.\n   - **Constituent Findings**: You must record the array of constituent finding\n     UUIDs in the structured `\"constituent_findings\"` property (e.g.,\n     `[\"UUID_A\", \"UUID_B\"]`). This clearly documents the links of the exploit\n     chain.\n   - **Determine Discovery Snapshot (`discovery_commit`)**: Set the chain\n     finding's `discovery_commit` from its ELIGIBLE constituents (the ones you\n     kept in Step 1):\n     - **MODE-OFF short-circuit (3-state rule):** if `active_snapshot` is ABSENT\n       in state (MODE-OFF — no `--sync` was requested), OMIT `discovery_commit`\n       on the chain finding entirely. In MODE-OFF, researcher OMITS\n       `discovery_commit` on every constituent (`researcher:317,340-341`: \"OMIT\n       this key entirely if active_snapshot is absent or snapshot_pinned is\n       false\"), so every constituent has a missing\u002Fempty `discovery_commit`. The\n       SAME\u002FMIXED logic below would thus write the literal `\"MIXED\"` on every\n       chain — a snapshot-era artifact that did not exist in Phase 1 and\n       violates MODE-OFF's \"byte-for-byte today's behavior\" guarantee\n       (`schema.json:4`). The chain's own schema comment (`chain:307`) says\n       \"Absent on legacy\u002Funpinned runs,\" confirming the intended MODE-OFF\n       behavior is omission, not `\"MIXED\"`. (Functional impact is low —\n       `schema.json:232` treats both \"absent\" and `\"MIXED\"` as NOT_MATCHED — but\n       mode purity matters.) Do NOT write `\"MIXED\"` or any value in MODE-OFF.\n     - If ALL eligible constituents have the SAME non-empty `discovery_commit`\n       value, set the chain's `discovery_commit` to that exact string.\n     - If the constituents' `discovery_commit` values DIFFER from one another,\n       OR any eligible constituent has a missing\u002Fempty `discovery_commit` (only\n       reachable in PINNED\u002FHALT mode — in MODE-OFF, the short-circuit above\n       already OMITted the field), set the chain's `discovery_commit` to the\n       literal string `\"MIXED\"`. Do NOT invent, hash, or fuzzy- normalize this\n       value — copy an exact string or write the literal `\"MIXED\"`. Rationale:\n       in pinned mode every eligible constituent is MATCHED, so they all share\n       the current `SNAPSHOT_ID`, and the chain inherits it (a later Block B on\n       the chain then MATCHES this pass). The `\"MIXED\"` sentinel makes Block B\n       return NOT_MATCHED for the chain (Block B step 2 treats the literal\n       `\"MIXED\"` as NOT_MATCHED) — the safe branch for a chain whose links\n       cannot be proven against a single snapshot.\n   - **Compute `signature` (deterministic content-identity hash for the\n     chain):**\n     - Collect the `signature` field from every ELIGIBLE constituent finding\n       (the same set used for `discovery_commit` in Step 1).\n     - If EVERY eligible constituent has a non-empty `signature`: sort the\n       constituent signatures lexicographically (ascending), then compute\n       `signature` = first 16 hex characters of\n       `sha256(\"chain|\" + \"|\".join(sorted_constituent_signatures))`. The\n       `\"chain|\"` prefix prevents any collision with a non-chain finding's\n       `signature` (which is hashed from title+cwe+target, a different input\n       domain). Sorting makes the chain signature invariant under constituent\n       re-ordering.\n     - If ANY eligible constituent lacks a `signature` field (legacy \u002F\n       un-upgraded finding): set the chain's `signature` to the EMPTY STRING and\n       OMIT it from the JSON (downstream consumers then fall back to UUID-based\n       fold\u002Fdedupe per `schema.json:256`). This is the safe branch — it can\n       never cause a wrong fold, only an over-report.\n     - Compute the signature ONCE at chain creation and NEVER recompute, edit,\n       or invent it (same rule as `discovery_commit` and as `researcher:241-242`\n       for regular findings).\n   - **Compute `lineage_id` (cross-pass chain lineage):**\n     - Scan `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n       `workspace\u002Farchive\u002Floop*_findings\u002F` for any archived chain finding JSON\n       (any finding with a non-empty `constituent_findings` array) whose\n       `signature` field EXACTLY equals this chain's computed `signature`.\n     - If a match is found: `lineage_id` = the archived ancestor's `lineage_id`\n       (inherit the lineage chain so report can fold across passes). If MULTIPLE\n       archived chains share the same `signature`, inherit from the MOST RECENT\n       (highest pass number) ancestor. All ancestors with the same chain\n       `signature` SHOULD share the same `lineage_id`; if they don't, inherit\n       from the most recent one and log a warning.\n     - If no match (including when this chain's `signature` is the EMPTY\n       STRING): `lineage_id` = a fresh UUIDv4.\n     - These are STATE-RELATIVE paths (Block A step 3) — read under\n       `--state_root\u002Fworkspace\u002Farchive\u002F`, NEVER under CODE_ROOT. (Same scan\n       targets and same algorithm shape as `researcher:246-272` for regular\n       findings — chains simply skip the basename-normalized rename fallback,\n       because a chain's identity is the set of its constituents, not a single\n       file path.)\n   - **Determine Entry Point Privileges**: The `privileges_required` field for\n     the chain must represent the privilege level required to initiate the\n     *first* step of the chain (the entry point). For example, if the chain\n     starts with an unauthenticated exploit (NONE) that leads to admin access,\n     which is then used to trigger RCE, the chain's `privileges_required` must\n     be set to `NONE`.\n   - **Determine Attacker Position**: The `attacker_position` field for the\n     chain must inherit the attacker position from the entry point \u002F first\n     constituent finding of the chain.\n   - **Determine User Interaction Requirement**: The `user_interaction` field\n     for the chain must be set to `REQUIRED` if the entry point or any step in\n     the chain requires user interaction. It should only be set to `NONE` if the\n     entire chain is zero-click.\n   - **Determine Status**: Set `status` to `\"VALID\"`.\n   - **Determine Production Viability**: Inherit from constituent findings. If\n     any constituent is `\"SAMPLE_OR_TEST\"`, set to `\"SAMPLE_OR_TEST\"`. Else if\n     any constituent is `\"CONDITIONAL_VIABLE\"`, set to `\"CONDITIONAL_VIABLE\"`.\n     Otherwise, set to `\"VIABLE\"`.\n   - **Determine Reproduction Status**: Inherit from constituent findings:\n     - If any constituent has a `repro_status` of `\"failed_to_reproduce\"` or\n       `\"not_attempted\"`, set to `\"not_attempted\"`.\n     - Otherwise, if all constituents have a `repro_status` of `\"reproduced\"` or\n       `\"statically_confirmed\"`, set to `\"statically_confirmed\"`.\n     - An exploit chain must **never** inherit `\"reproduced\"` (as reproduction\n       of constituents does not prove the end-to-end chain works).\n\n   ### Chain Findings Schema Format (Per File)\n\n   ```json\n   {\n     \"id\": \"A unique identifier generated for this chain finding. Must match filename.\",\n     \"title\": \"Exploit Chain: [Impact] via [Finding A] and [Finding B]\",\n     \"description\": \"Step-by-step documentation of the exploit chain. Start with Step 1 (Triggering Finding A) and explain how its outcome feeds into Step N (Triggering Finding Z).\",\n     \"impact\": \"The combined, escalated impact of the chain (e.g., Remote Code Execution, Full Database Exfiltration). This should be higher than the individual findings.\",\n     \"severity\": \"CRITICAL \u002F HIGH\",\n     \"privileges_required\": \"NONE \u002F LOW \u002F HIGH\",\n     \"user_interaction\": \"NONE \u002F REQUIRED\",\n     \"code_paths\": [\n       \"relative\u002Ffile\u002Fpath_A.c:line_number\",\n       \"relative\u002Ffile\u002Fpath_B.c:line_number\"\n     ],\n     \"attacker_position\": \"EXTERNAL \u002F LOCAL \u002F etc. (inherited from entry point)\",\n     \"mitigation\": \"Recommended strategy to break the chain. Usually involves fixing at least one, if not all, of the underlying links.\",\n     \"status\": \"VALID\",\n     \"production_viability\": \"VIABLE \u002F SAMPLE_OR_TEST \u002F CONDITIONAL_VIABLE\",\n     \"repro_status\": \"statically_confirmed \u002F not_attempted\",\n     \"constituent_findings\": [\"UUID_A\", \"UUID_B\"],\n     \"signature\": \"First 16 hex chars of sha256(\\\"chain|\\\" + \\\"|\\\".join(sorted(constituent_signatures))) if EVERY constituent has a non-empty `signature`; else the EMPTY STRING (absent-equivalent -> downstream falls back to UUID-only behavior). Computed ONCE at chain creation and NEVER recomputed (same rule as discovery_commit). See the signature\u002Flineage computation steps above.\",\n     \"lineage_id\": \"Inherited from the most-recent archived chain finding whose `signature` equals this chain's `signature` (scan workspace\u002Farchive\u002Ffindings_pass_*\u002F AND workspace\u002Farchive\u002Floop*_findings\u002F); else a fresh UUIDv4. See the signature\u002Flineage computation steps above.\",\n     \"discovery_commit\": \"The SNAPSHOT_ID shared by all constituents, or the literal \\\"MIXED\\\" if they differ \u002F are missing (only computed in PINNED\u002FHALT mode). OMITTED (absent) on legacy\u002Funpinned runs (MODE-OFF) — see the MODE-OFF short-circuit in the discovery_commit computation step above.\",\n     \"history\": [\n       {\n         \"stage\": \"chainer\",\n         \"action\": \"created\",\n         \"details\": \"Constructed by chaining findings [UUID_A] and [UUID_B].\",\n         \"pass_number\": \u003Ccurrent_pass_number>,\n         \"timestamp\": \"\u003Ccurrent_iso8601_timestamp>\"\n       }\n     ]\n   }\n   ```\n\n4. **Chain Deduplication Tagging:**\n\n   - To ensure `\u002Fmantis-dedupe` treats these chains differently than raw\n     findings, ensure the word \"Chain\" is prominently featured in the `\"title\"`\n     and `\"history\"` fields as shown in the schema.\n\nEnsure any newly constructed chain files are written to the\n`workspace\u002Ffindings\u002F` directory. When complete, notify the user.\n","# Vulnerability Chainer (\u002Fmantis-chain)\n\n## System Goal\n\nExploit Chain Architect. Analyzes isolated, individually-validated security\nfindings and historical knowledge base primitives to identify and construct\ncomplex, multi-step exploit chains.\n\n## Command Definition\n\n- **Command:** `\u002Fmantis-chain`\n- **Description:** Analyzes individual security findings to identify and\n  construct complex exploit chains.\n- **Arguments (all optional; supplied by the orchestrator per the harness\n  lifecycle contract — see `schema.json` \"Non-JSON Contracts\"):**\n  - `--snapshot_root` \u002F `SNAPSHOT_ROOT` — the pinned, immutable code snapshot\n    root for this pass. Consumed by Block A.\n  - `--snapshot_id` \u002F `SNAPSHOT_ID` — the snapshot identity string for this\n    pass. Consumed by Block A (sentinel) and Block B (match check).\n  - `--state_root` — parent directory of `workspace\u002F`. When absent, defaults to\n    the current directory (Block A step 1c\u002F1d).\n  - `--target_root` — an already-prepared tree that OVERRIDES the snapshot root\n    (rarely used by this stage; honored by Block A step 1a). When NONE of these\n    are passed, Block A falls back to `active_snapshot` in\n    `workspace\u002F.mantis_state.json`; if that is absent too, the stage runs\n    MODE-OFF (`snapshot_pinned = false`) and behaves exactly as today (see\n    Backward-compat).\n\n## Input\u002FOutput Contract\n\n- **Reads**:\n  - `workspace\u002Ffindings\u002F` (validated finding JSON files where status is\n    `\"VALID\"`, and viability is `\"VIABLE\"`, `\"CONDITIONAL_VIABLE\"`, or\n    `\"SAMPLE_OR_TEST\"`).\n  - `workspace\u002Fkb\u002Fentities\u002F*.md` and `workspace\u002Fkb\u002Fvulnerabilities\u002F*.md`\n    (knowledge base primitives).\n  - `workspace\u002F.mantis_state.json` (to track current loop pass).\n- **Writes**:\n  - Net-new exploit chain finding JSON files to\n    `workspace\u002Ffindings\u002F\u003Cnew_uuid>.json`. Original findings are left unmodified.\n- **Preconditions**:\n  - Validated or viable findings must exist in `workspace\u002Ffindings\u002F`.\n- **Idempotency Guarantee**:\n  - Before writing a new exploit chain finding, the skill must check existing\n    exploit chain findings by comparing the constituent finding sequence. Scan\n    BOTH the current `workspace\u002Ffindings\u002F` directory AND every archived pass\n    under `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n    `workspace\u002Farchive\u002Floop*_findings\u002F` (all STATE-RELATIVE — never prefix\n    `CODE_ROOT`). A chain JSON is any finding whose `constituent_findings` array\n    is present and non-empty. If a chain with the EXACT same ordered constituent\n    sequence already exists in EITHER location, skip creating a duplicate.\n  - **Signature-keyed idempotency (preferred) — with a code_paths tiebreak:** If\n    ALL constituent findings have a `signature` field, compare the ordered\n    constituent `signature` sequence (not UUIDs). Treat two chains as the SAME\n    (and skip creating the new one) ONLY IF their ordered `signature` sequences\n    are equal AND, for each corresponding constituent pair, at least one\n    `code_paths` entry (line-inclusive, i.e. compared WITH its trailing `:line`)\n    is identical. If the signature sequences match but any corresponding\n    constituent's `code_paths` differ, the chains are DISTINCT — create the new\n    chain. (Over-reporting is safe; a `signature` collision must never suppress\n    a genuinely new exploit chain, because `signature` strips line numbers and\n    can collide between distinct same-file bugs.)\n  - **UUID fallback (today's behavior):** If ANY constituent finding lacks a\n    `signature` field, fall back to comparing the ordered constituent UUID\n    sequence exactly as before. This preserves today's behavior for legacy \u002F\n    un-upgraded findings.\n  - This archive scan is now fully effective with stable finding signatures: two\n    chains whose constituents share the same signatures are correctly\n    deduplicated across passes. When signatures are absent (legacy findings),\n    the scan remains HARMLESS — it cannot falsely suppress a legitimate new\n    chain (no silent dropped result) and simply prevents exact-UUID\n    re-duplication within a resumed \u002F rerun pass. If the `workspace\u002Farchive\u002F`\n    directory does not exist, treat the archived set as empty and proceed.\n\n## Instructions\n\n### Locator Resolution (run first — all stages)\n\n```\nLOCATOR RESOLUTION (before reading ANY target code or artifact):\n0. ROLE: If this skill NEVER reads target source (report, calibrate, reflect),\n   you are a FINDINGS-ONLY stage: skip steps 2-6; still read active_snapshot from\n   state for provenance\u002Fannotation; NEVER stop merely because a code root is unset.\n1. Determine CODE_ROOT, in this priority order:\n   a. If --target_root is passed on THIS invocation, CODE_ROOT = --target_root.\n      It is AUTHORITATIVE and OVERRIDES SNAPSHOT_ROOT and the state fallback\n      (used when a caller hands you a prepared tree, e.g. a patched shadow).\n   b. Else if --snapshot_root (or SNAPSHOT_ROOT) is passed, use it.\n   c. Else read state_root\u002Fworkspace\u002F.mantis_state.json (state_root from\n      --state_root if passed, else .\u002Fworkspace\u002F... relative to the current dir)\n      -> active_snapshot.root \u002F .snapshot_id \u002F .snapshot_pinned.\n   d. Else (no arg AND no readable active_snapshot): CODE_ROOT = current directory,\n      treat snapshot_pinned = false (MODE-OFF). Do NOT stop.\n2. SENTINEL CHECK (only if snapshot_pinned is true AND you did NOT take path 1a):\n   verify CODE_ROOT\u002F.mantis_snapshot_id exists and equals SNAPSHOT_ID. If missing\n   or different -> STOP \"snapshot sentinel mismatch\". (A --target_root tree (1a) is\n   deliberately mutated and is sentinel-EXEMPT.)\n3. PATH FIELDS:\n   - SNAPSHOT-RELATIVE (read under CODE_ROOT): code_paths entries; plan target_files\n     that are file paths. Strip ONLY a trailing \":\u003Cdigits>\". A code_paths entry\n     containing \":\u002F\u002F\" is a URL\u002Fendpoint, NOT a file read. A code_paths entry that is\n     NOT of the form \u003Cexisting-path>:\u003Cinteger> is a non-source LOCATOR\n     (symbol\u002Foffset\u002Fendpoint): only check that the artifact\u002Fsymbol exists; skip ALL\n     line-range and line-existence logic.\n   - STATE-RELATIVE (read\u002Fwrite under state_root\u002Fworkspace, NEVER prefix CODE_ROOT):\n     kb_references, repro_file_path, reattack_file_path, helper scripts, report\n     files, and all state\u002Ffindings JSON.\n4. Never WRITE under CODE_ROOT when snapshot_pinned is true. Any command that\n   compiles, generates, or writes artifacts MUST run in a PRIVATE SHADOW copy\n   (mktemp -d from CODE_ROOT), never with cwd=CODE_ROOT. Read-only inspection may\n   cd into CODE_ROOT.\n5. VCS-METADATA CARVE-OUT: history-log extraction and any VCS diff\u002Fblame command\n   run in the LIVE repository root (which still has .git\u002F.hg\u002F.repo), NOT CODE_ROOT\n   (the snapshot copy strips VCS metadata). Do NOT stop merely because CODE_ROOT\n   lacks .git\u002F.hg\u002F.repo.\n6. Every shell command uses ABSOLUTE paths and sets its own working directory on\n   that call. Do NOT assume the working directory persists between calls.\n```\n\n> [!NOTE] **CURRENT-PASS CHECK (defensive; the binding guarantee is on the\n> harness per `mantis-pipeline-adapter` Scenario 2):** if `active_snapshot` is\n> present AND `active_snapshot.pass != state.pass_number`, treat the snapshot as\n> STALE for this pass — STOP \"stale active_snapshot: pass mismatch\" or degrade\n> as HALT (`snapshot_pinned` effectively false: no authoritative verdicts, Block\n> B NOT_MATCHED, reproduce `not_attempted`). This catches a custom harness that\n> preserved `active_snapshot` across the Stage 15 pass increment without\n> re-pinning. The reference meta-agent re-pins every pass, so this check never\n> fires there. Block B itself cannot detect this (it is `snapshot_id`-only, not\n> `pass`-aware).\n\nStage-specific notes for Block A:\n\n- `mantis-chain` is NOT a findings-only stage (it is not\n  report\u002Fcalibrate\u002Freflect), so Block A runs steps 1–6 and resolves `CODE_ROOT`,\n  `SNAPSHOT_ID`, and `snapshot_pinned` from `--snapshot_root` \u002F `--snapshot_id`\n  \u002F state `active_snapshot`.\n- This stage WRITES only new finding JSON to `workspace\u002Ffindings\u002F`\n  (STATE-RELATIVE, Block A step 3). It never writes under `CODE_ROOT`, so Block\n  A step 4 is satisfied trivially. If you optionally re-inspect a constituent's\n  `code_paths` to sanity-check a chain, read them SNAPSHOT-RELATIVE under\n  `CODE_ROOT` (Block A step 3) and never cd-and-write there.\n- A chain finding's `code_paths` are COPIED verbatim from its constituents (they\n  are already SNAPSHOT-RELATIVE). Do not re-prefix, re-resolve, or renumber\n  them.\n\n### Snapshot Match Check (used to select constituents)\n\n```\nSNAPSHOT MATCH CHECK for finding F (decides MATCHED vs NOT_MATCHED):\n1. If snapshot_pinned is false -> NOT_MATCHED. Stop.\n2. Read F.discovery_commit:\n   - missing OR empty OR the literal \"MIXED\" -> NOT_MATCHED.\n   - not exactly equal to SNAPSHOT_ID          -> NOT_MATCHED.\n   - exactly equal to SNAPSHOT_ID              -> MATCHED.\nThere is no other route to MATCHED; never fuzzy-compare. The global \"default the\nfield and proceed\" backward-compat rule does NOT apply to discovery_commit:\nabsent = NOT_MATCHED. (There is NO separate \"dirty\" gate: a dirty tree's\nSNAPSHOT_ID already embeds the working-tree content hash, so within-pass findings\nMATCH and cross-pass bare-commit findings do not.)\n```\n\nYou will run Block B once per candidate constituent finding in Step 1 below,\nusing that finding's `discovery_commit` as `F.discovery_commit`.\n\nRead the current batch of validated findings and explore whether multiple\nseemingly low-severity or disparate vulnerabilities can be sequentially combined\nto achieve a higher-impact compromise.\n\nExecute the chaining stage as follows:\n\n1. **Load Primitives & Validated Findings:**\n\n   - Read the JSON files in the `workspace\u002Ffindings\u002F` directory. Filter for\n     findings that have passed validation (e.g., status is `\"VALID\"` and\n     viability is `\"VIABLE\"`, `\"CONDITIONAL_VIABLE\"`, or `\"SAMPLE_OR_TEST\"`).\n   - **Snapshot eligibility gate (NEW — branches on `active_snapshot` presence,\n     3-state model):**\n     - **MODE-OFF** (no `active_snapshot` in state — no `--sync` was requested,\n       today's default): SKIP this gate entirely: every finding that passed the\n       validation\u002Fviability filter above is an eligible constituent, exactly as\n       today. Build chains normally.\n     - **HALT** (`active_snapshot` IS present but `snapshot_pinned == false`):\n       do NOT build any chains this pass. In HALT, findings' locators and\n       pre\u002Fpost-conditions may be stale (the tree raced or could not be pinned),\n       so no authoritative chain verdicts may be produced. Log \"no chain: HALT\n       mode (active_snapshot present, snapshot_pinned=false)\" and stop the\n       chaining stage cleanly (produce no chain files). This mirrors the\n       minimum-eligibility guard below — a chain requires\n       proven-against-snapshot constituents, which HALT cannot provide.\n     - **PINNED** (`active_snapshot` present AND `snapshot_pinned == true`): run\n       the **Snapshot Match Check (Block B)** on EACH such finding, using its\n       `discovery_commit`. Keep ONLY findings that return **MATCHED** as\n       eligible constituents. A finding that returns **NOT_MATCHED** — including\n       any finding whose `discovery_commit` is absent\u002Fempty, is the literal\n       `\"MIXED\"`, or differs from the current `SNAPSHOT_ID` — was discovered\n       against a DIFFERENT code snapshot; its `file:line` locators and its\n       pre\u002Fpost-conditions may no longer hold, so it MUST NOT be used as a chain\n       link this pass.\n   - **Minimum-eligibility guard (NEW):** If fewer than 2 eligible constituents\n     remain, do **NOT** construct any chain this pass — a chain requires at\n     least two links proven against the SAME snapshot. Log \"no chain: fewer than\n     2 snapshot-matched constituents\" and stop the chaining stage cleanly (this\n     is not an error; simply produce no chain files). This mirrors today's\n     behavior whenever there are fewer than two chainable findings.\n   - Read the Markdown Knowledge Base (`workspace\u002Fkb\u002Fentities\u002F` and\n     `workspace\u002Fkb\u002Fvulnerabilities\u002F`) to identify architectural primitives that\n     might not be bugs on their own, but could serve as stepping stones (e.g.,\n     \"User controls file upload path\", \"Service runs as root\").\n\n2. **Cross-Finding Analysis (The Chaining Matrix):**\n\n   - Analyze the preconditions and postconditions of each validated finding.\n   - Ask: *Can the output or side-effect of Finding A satisfy the strict\n     precondition required to trigger Finding B?*\n   - Example Chains to look for:\n     - **Path Traversal + Loose Permissions = RCE:** A low-severity path\n       traversal (Finding A) allows writing to `\u002Ftmp`, but a separate\n       misconfiguration (Finding B) allows a cron job to execute scripts in\n       `\u002Ftmp`.\n     - **XSS + CSRF = Account Takeover:** A stored XSS (Finding A) can be used\n       to harvest an anti-CSRF token to execute a state-changing action (Finding\n       B).\n     - **Info Leak (Memory Revelation) + Buffer Overflow = ASLR Bypass:** An\n       info leak (Finding A) reveals base pointers, satisfying the precondition\n       to exploit a stack buffer overflow (Finding B).\n\n3. **Construct \"Super Findings\":**\n\n   - If a viable exploit chain is discovered, do **NOT** modify or delete the\n     original isolated findings. They still need to be patched individually.\n   - **Idempotency check (run BEFORE minting a UUID):** Apply the Idempotency\n     Guarantee above — scan current `workspace\u002Ffindings\u002F` AND\n     `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n     `workspace\u002Farchive\u002Floop*_findings\u002F` for a chain whose constituent sequence\n     equals this chain's ordered constituent sequence. If ALL constituents have\n     `signature`, compare ordered `signature` sequences AND require the\n     per-constituent line-inclusive `code_paths` tiebreak described in the\n     Idempotency Guarantee (a signature-sequence match ALONE is NOT enough to\n     skip); if ANY constituent lacks `signature`, fall back to ordered\n     constituent UUID sequences (today's behavior). Only if a match satisfies\n     the tiebreak, SKIP this chain (do not create a file) and move on to the\n     next candidate.\n   - Instead, generate a **net-new UUID** and create a new finding JSON file in\n     `workspace\u002Ffindings\u002F\u003Cnew_uuid>.json`.\n   - **Constituent Findings**: You must record the array of constituent finding\n     UUIDs in the structured `\"constituent_findings\"` property (e.g.,\n     `[\"UUID_A\", \"UUID_B\"]`). This clearly documents the links of the exploit\n     chain.\n   - **Determine Discovery Snapshot (`discovery_commit`)**: Set the chain\n     finding's `discovery_commit` from its ELIGIBLE constituents (the ones you\n     kept in Step 1):\n     - **MODE-OFF short-circuit (3-state rule):** if `active_snapshot` is ABSENT\n       in state (MODE-OFF — no `--sync` was requested), OMIT `discovery_commit`\n       on the chain finding entirely. In MODE-OFF, researcher OMITS\n       `discovery_commit` on every constituent (`researcher:317,340-341`: \"OMIT\n       this key entirely if active_snapshot is absent or snapshot_pinned is\n       false\"), so every constituent has a missing\u002Fempty `discovery_commit`. The\n       SAME\u002FMIXED logic below would thus write the literal `\"MIXED\"` on every\n       chain — a snapshot-era artifact that did not exist in Phase 1 and\n       violates MODE-OFF's \"byte-for-byte today's behavior\" guarantee\n       (`schema.json:4`). The chain's own schema comment (`chain:307`) says\n       \"Absent on legacy\u002Funpinned runs,\" confirming the intended MODE-OFF\n       behavior is omission, not `\"MIXED\"`. (Functional impact is low —\n       `schema.json:232` treats both \"absent\" and `\"MIXED\"` as NOT_MATCHED — but\n       mode purity matters.) Do NOT write `\"MIXED\"` or any value in MODE-OFF.\n     - If ALL eligible constituents have the SAME non-empty `discovery_commit`\n       value, set the chain's `discovery_commit` to that exact string.\n     - If the constituents' `discovery_commit` values DIFFER from one another,\n       OR any eligible constituent has a missing\u002Fempty `discovery_commit` (only\n       reachable in PINNED\u002FHALT mode — in MODE-OFF, the short-circuit above\n       already OMITted the field), set the chain's `discovery_commit` to the\n       literal string `\"MIXED\"`. Do NOT invent, hash, or fuzzy- normalize this\n       value — copy an exact string or write the literal `\"MIXED\"`. Rationale:\n       in pinned mode every eligible constituent is MATCHED, so they all share\n       the current `SNAPSHOT_ID`, and the chain inherits it (a later Block B on\n       the chain then MATCHES this pass). The `\"MIXED\"` sentinel makes Block B\n       return NOT_MATCHED for the chain (Block B step 2 treats the literal\n       `\"MIXED\"` as NOT_MATCHED) — the safe branch for a chain whose links\n       cannot be proven against a single snapshot.\n   - **Compute `signature` (deterministic content-identity hash for the\n     chain):**\n     - Collect the `signature` field from every ELIGIBLE constituent finding\n       (the same set used for `discovery_commit` in Step 1).\n     - If EVERY eligible constituent has a non-empty `signature`: sort the\n       constituent signatures lexicographically (ascending), then compute\n       `signature` = first 16 hex characters of\n       `sha256(\"chain|\" + \"|\".join(sorted_constituent_signatures))`. The\n       `\"chain|\"` prefix prevents any collision with a non-chain finding's\n       `signature` (which is hashed from title+cwe+target, a different input\n       domain). Sorting makes the chain signature invariant under constituent\n       re-ordering.\n     - If ANY eligible constituent lacks a `signature` field (legacy \u002F\n       un-upgraded finding): set the chain's `signature` to the EMPTY STRING and\n       OMIT it from the JSON (downstream consumers then fall back to UUID-based\n       fold\u002Fdedupe per `schema.json:256`). This is the safe branch — it can\n       never cause a wrong fold, only an over-report.\n     - Compute the signature ONCE at chain creation and NEVER recompute, edit,\n       or invent it (same rule as `discovery_commit` and as `researcher:241-242`\n       for regular findings).\n   - **Compute `lineage_id` (cross-pass chain lineage):**\n     - Scan `workspace\u002Farchive\u002Ffindings_pass_*\u002F` AND legacy\n       `workspace\u002Farchive\u002Floop*_findings\u002F` for any archived chain finding JSON\n       (any finding with a non-empty `constituent_findings` array) whose\n       `signature` field EXACTLY equals this chain's computed `signature`.\n     - If a match is found: `lineage_id` = the archived ancestor's `lineage_id`\n       (inherit the lineage chain so report can fold across passes). If MULTIPLE\n       archived chains share the same `signature`, inherit from the MOST RECENT\n       (highest pass number) ancestor. All ancestors with the same chain\n       `signature` SHOULD share the same `lineage_id`; if they don't, inherit\n       from the most recent one and log a warning.\n     - If no match (including when this chain's `signature` is the EMPTY\n       STRING): `lineage_id` = a fresh UUIDv4.\n     - These are STATE-RELATIVE paths (Block A step 3) — read under\n       `--state_root\u002Fworkspace\u002Farchive\u002F`, NEVER under CODE_ROOT. (Same scan\n       targets and same algorithm shape as `researcher:246-272` for regular\n       findings — chains simply skip the basename-normalized rename fallback,\n       because a chain's identity is the set of its constituents, not a single\n       file path.)\n   - **Determine Entry Point Privileges**: The `privileges_required` field for\n     the chain must represent the privilege level required to initiate the\n     *first* step of the chain (the entry point). For example, if the chain\n     starts with an unauthenticated exploit (NONE) that leads to admin access,\n     which is then used to trigger RCE, the chain's `privileges_required` must\n     be set to `NONE`.\n   - **Determine Attacker Position**: The `attacker_position` field for the\n     chain must inherit the attacker position from the entry point \u002F first\n     constituent finding of the chain.\n   - **Determine User Interaction Requirement**: The `user_interaction` field\n     for the chain must be set to `REQUIRED` if the entry point or any step in\n     the chain requires user interaction. It should only be set to `NONE` if the\n     entire chain is zero-click.\n   - **Determine Status**: Set `status` to `\"VALID\"`.\n   - **Determine Production Viability**: Inherit from constituent findings. If\n     any constituent is `\"SAMPLE_OR_TEST\"`, set to `\"SAMPLE_OR_TEST\"`. Else if\n     any constituent is `\"CONDITIONAL_VIABLE\"`, set to `\"CONDITIONAL_VIABLE\"`.\n     Otherwise, set to `\"VIABLE\"`.\n   - **Determine Reproduction Status**: Inherit from constituent findings:\n     - If any constituent has a `repro_status` of `\"failed_to_reproduce\"` or\n       `\"not_attempted\"`, set to `\"not_attempted\"`.\n     - Otherwise, if all constituents have a `repro_status` of `\"reproduced\"` or\n       `\"statically_confirmed\"`, set to `\"statically_confirmed\"`.\n     - An exploit chain must **never** inherit `\"reproduced\"` (as reproduction\n       of constituents does not prove the end-to-end chain works).\n\n   ### Chain Findings Schema Format (Per File)\n\n   ```json\n   {\n     \"id\": \"A unique identifier generated for this chain finding. Must match filename.\",\n     \"title\": \"Exploit Chain: [Impact] via [Finding A] and [Finding B]\",\n     \"description\": \"Step-by-step documentation of the exploit chain. Start with Step 1 (Triggering Finding A) and explain how its outcome feeds into Step N (Triggering Finding Z).\",\n     \"impact\": \"The combined, escalated impact of the chain (e.g., Remote Code Execution, Full Database Exfiltration). This should be higher than the individual findings.\",\n     \"severity\": \"CRITICAL \u002F HIGH\",\n     \"privileges_required\": \"NONE \u002F LOW \u002F HIGH\",\n     \"user_interaction\": \"NONE \u002F REQUIRED\",\n     \"code_paths\": [\n       \"relative\u002Ffile\u002Fpath_A.c:line_number\",\n       \"relative\u002Ffile\u002Fpath_B.c:line_number\"\n     ],\n     \"attacker_position\": \"EXTERNAL \u002F LOCAL \u002F etc. (inherited from entry point)\",\n     \"mitigation\": \"Recommended strategy to break the chain. Usually involves fixing at least one, if not all, of the underlying links.\",\n     \"status\": \"VALID\",\n     \"production_viability\": \"VIABLE \u002F SAMPLE_OR_TEST \u002F CONDITIONAL_VIABLE\",\n     \"repro_status\": \"statically_confirmed \u002F not_attempted\",\n     \"constituent_findings\": [\"UUID_A\", \"UUID_B\"],\n     \"signature\": \"First 16 hex chars of sha256(\\\"chain|\\\" + \\\"|\\\".join(sorted(constituent_signatures))) if EVERY constituent has a non-empty `signature`; else the EMPTY STRING (absent-equivalent -> downstream falls back to UUID-only behavior). Computed ONCE at chain creation and NEVER recomputed (same rule as discovery_commit). See the signature\u002Flineage computation steps above.\",\n     \"lineage_id\": \"Inherited from the most-recent archived chain finding whose `signature` equals this chain's `signature` (scan workspace\u002Farchive\u002Ffindings_pass_*\u002F AND workspace\u002Farchive\u002Floop*_findings\u002F); else a fresh UUIDv4. See the signature\u002Flineage computation steps above.\",\n     \"discovery_commit\": \"The SNAPSHOT_ID shared by all constituents, or the literal \\\"MIXED\\\" if they differ \u002F are missing (only computed in PINNED\u002FHALT mode). OMITTED (absent) on legacy\u002Funpinned runs (MODE-OFF) — see the MODE-OFF short-circuit in the discovery_commit computation step above.\",\n     \"history\": [\n       {\n         \"stage\": \"chainer\",\n         \"action\": \"created\",\n         \"details\": \"Constructed by chaining findings [UUID_A] and [UUID_B].\",\n         \"pass_number\": \u003Ccurrent_pass_number>,\n         \"timestamp\": \"\u003Ccurrent_iso8601_timestamp>\"\n       }\n     ]\n   }\n   ```\n\n4. **Chain Deduplication Tagging:**\n\n   - To ensure `\u002Fmantis-dedupe` treats these chains differently than raw\n     findings, ensure the word \"Chain\" is prominently featured in the `\"title\"`\n     and `\"history\"` fields as shown in the schema.\n\nEnsure any newly constructed chain files are written to the\n`workspace\u002Ffindings\u002F` directory. When complete, notify the user.\n",{"name":5,"description":7},"main","f3162c039ecd9c9d5d8bc404dd1373c7ca3152f7","skills\u002Fmantis-chain",237,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis","https:\u002F\u002Fcloud.google.com\u002F","https:\u002F\u002Fgithub.com\u002Fgoogle","https:\u002F\u002Fopensource.google\u002F","Google ❤️ Open Source","2026-11-15 00:33:31",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add google\u002Fmantis --skill mantis-chain",{"tool":57,"command":58},"bunx","bunx skills add google\u002Fmantis --skill mantis-chain",{"tool":60,"command":61},"pnpm","pnpm dlx skills add google\u002Fmantis --skill mantis-chain","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-chain\u002FSKILL.md",true,[],[66,92,119,146,156,171],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":36},"01M6992XJHHV0R5N8E392EHRW3","mantis-threat-model","Synthesizes trust boundaries, attack surfaces, and attacker profiles into a living threat model. Use as Stage B of the Knowledge Base generation process, reading architecture and entity definitions from the KB. Don't use for analyzing source code or extracting raw learnings from JSONL files.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-threat-model\u002FSKILL.md",[],[73,74,75,76,77,34,78,79,80,81,82,83,84,85,86,87,88,89,90,91],"mantis threat model","threat model","model","threat","architecture","analyzing","knowledge","kb","files","surfaces","trust","learnings","knowledge base","as","extracting","reading","jsonl","source","source code",{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":103,"publishedAt":36},"01M6992TR1BPA5HVF13QRM7EP0","mantis-summarize","Pre-processes the repository by generating security-focused summaries (mantis-summary.md) for each directory to make planning and research more efficient. Use when starting a review campaign to map the codebase before threat modeling and planning. Don't use for executing code reviews, writing test scripts, or patching code.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-summarize\u002FSKILL.md",[98],{"categoryNo":99,"categoryName":100,"taxonomyType":101,"taxonomyTypeDesc":102},"01JBSEEDCAT000000000000021","资料检索与研究","SCENARIO","使用场景",[104,105,29,106,107,35,108,34,109,110,111,76,112,113,114,115,116,117,25,118],"summarize","mantis summarize","directory","review","threat modeling","planning","repository","patching","campaign","map","modeling","scripts","make","reviews","when",{"skillNo":120,"name":121,"nameZh":6,"description":122,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":123,"categories":124,"keywords":130,"publishedAt":36},"01M6992QB4DVMDR2AGT6BPSE3N","mantis-structural-index","Builds a content-addressed semantic-unit index from source code for structural context. Use when a pinned or live codebase is available and structural cross-reference data would improve research quality. Don't use for findings analysis, patching, or reporting.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-structural-index\u002FSKILL.md",[125],{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[131,132,133,134,34,135,136,137,138,111,139,140,141,30,142,143,144,145,25,118],"mantis structural index","index","structural","research","content","reporting","data","analysis","improve","quality","context","research quality","reference","live","unit",{"skillNo":147,"name":148,"nameZh":6,"description":149,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":36},"01M6992KRP2XYWEMV12P5M4GPE","mantis-review","Independently reviews findings and filters out false positives. Use when consolidated findings need validation against the actual source code. Don't use for reproducing crashes or patching code.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-review\u002FSKILL.md",[],[107,153,34,33,111,30,154,155,117,25,90,91,118],"mantis review","filters","false",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":36},"01M6992GKVGJ2NXEJWYFVCN01Q","mantis-researcher","Audits production source code files based on the strategy in workspace\u002Fplan.json. Use when a review plan exists and you need to perform static analysis and deep-dive reviews of targeted files. Don't use for planning, deduplicating, or writing patches.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-researcher\u002FSKILL.md",[],[163,164,29,107,165,34,109,138,166,167,30,81,168,169,117,25,90,170,91,118],"mantis researcher","researcher","static analysis","plan","strategy","deep","you","static",{"skillNo":172,"name":173,"nameZh":6,"description":174,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":175,"categories":176,"keywords":177,"publishedAt":36},"01M6992D5WXENF3TW68GM5WPHC","mantis-reproduce","Generates and runs crash reproducers to verify security flaws. Use when viable findings exist and you need to write and execute a script or payload to verify the crash. Don't use for code auditing or patching.","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-reproduce\u002FSKILL.md",[],[178,179,35,34,111,180,181,182,30,183,184,185,169,25,118],"mantis reproduce","reproduce","verify","write","execute","crash","payload","script"]