[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M69914Z015N7Z4TTQH3DTCTC":3,"skill-same:01M69914Z015N7Z4TTQH3DTCTC":80},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":56,"commitSha":57,"skillDirectory":58,"forksCount":59,"repositoryHtmlUrl":60,"repositoryHomepageUrl":61,"ownerHtmlUrl":62,"ownerBlogUrl":63,"ownerDescription":64,"updatedAt":65,"install":66,"resources":79},"01M69914Z015N7Z4TTQH3DTCTC","mantis-architecture","架构知识库构建","Synthesizes raw learnings and codebase analysis into an interlinked Markdown Knowledge Base (KB). Use at the beginning of a loop to build or update architecture.md, entities, and vulnerabilities. Don't use for generating threat models or formulating execution plans.","将原始学习成果与代码库分析综合整理为相互链接的 Markdown 知识库（KB）。在循环开始时用于构建或更新 architecture.md、实体与漏洞。不用于生成威胁模型或制定执行计划。","google\u002Fmantis","google","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1342004?v=4","01M698VYEFDM0VJBZDYYJ2T83S","Google","01M6990SDGGFEAP21TJNS7HEG9",2778,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-architecture\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRFRAYBCBW9WKDY9TCSHY3","知识管理与沉淀","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],"architecture","mantis architecture","entities","for","at","codebase analysis","plans","knowledge base","learnings","build","models","threat","use","kb","loop","knowledge","markdown","analysis","execution","update","2026-11-10 10:12:30",false,"---\nname: mantis-architecture\ndescription: >-\n  Synthesizes raw learnings and codebase analysis into an interlinked Markdown Knowledge Base (KB).\n  Use at the beginning of a loop to build or update architecture.md, entities, and vulnerabilities.\n  Don't use for generating threat models or formulating execution plans.\n---\n\n# Architect (\u002Fmantis-architecture)\n\n## System Goal\n\nKnowledge Base Synthesizer. Translates ephemeral insights from the learnings\nqueue (`workspace\u002Flearnings.jsonl`) and structural analysis of the codebase into\na canonical, interlinked Markdown Knowledge Base (`workspace\u002Fkb\u002F`).\n\n## Command Definition\n\n- **Command:** `\u002Fmantis-architecture`\n- **Description:** Builds the foundation of the KB by defining system\n  architecture, mapping specific entities (components), and categorizing\n  historical vulnerability patterns.\n- **Arguments (all optional; resolved by LOCATOR RESOLUTION \u002F Block A):**\n  `--snapshot_root=\u003Cdir>` (or the `SNAPSHOT_ROOT` env var) — the pinned code\n  snapshot to read target source from; `--snapshot_id=\u003Cid>` — the `SNAPSHOT_ID`\n  of that snapshot; `--state_root=\u003Cdir>` — the parent of `workspace\u002F` for all\n  state and KB paths; `--target_root=\u003Cdir>` — an already-prepared tree that\n  OVERRIDES the snapshot (rarely passed to this stage). When none are passed,\n  behavior is byte-for-byte today's (degraded\u002Funpinned): read source from the\n  current directory and treat `snapshot_pinned` as false.\n\n## Input\u002FOutput Contract\n\n- **Reads**:\n  - `workspace\u002Flearnings.jsonl` (raw insights from the current round).\n  - `workspace\u002Fhistorical_learnings.jsonl` (optional, past vulnerability\n    metadata).\n  - Codebase directory structure and key source files.\n  - Existing Markdown files in `workspace\u002Fkb\u002F` (to validate\u002Fdecay check).\n  - `workspace\u002F.mantis_state.json` (to retrieve pass count).\n  - `workspace\u002F.mantis_state.json` → `active_snapshot` (`root`, `snapshot_id`,\n    `snapshot_pinned`) and `snapshot_history` — provenance for the KB freshness\n    gate (step 0b). Read the snapshot from STATE ONLY; NEVER run a live VCS\n    command (`git`\u002F`hg`\u002F`repo`) to decide KB currency.\n  - `workspace\u002F.mantis_state.json` → `kb_snapshot_id` (the `SNAPSHOT_ID` the\n    current KB was last built against; absent on a first\u002Flegacy KB).\n  - `workspace\u002F.mantis_state.json` → `changed_files` and `changed_files_status`\n    (written by mantis-plan's Block E; consumed by the scoped KB invalidation in\n    step 0b outcome 3. Present from pass 2 on, but may be stale (written in a\n    prior pass) — the scoped path checks `changed_files_pass` against\n    `state.pass_number` and falls back to full rebuild if they differ.)\n- **Writes**:\n  - Markdown files under `workspace\u002Fkb\u002F` (`architecture.md`,\n    `entities\u002F[component_name].md`, `vulnerabilities\u002F[CWE-ID].md`, `index.md`).\n  - `workspace\u002Fkb\u002Fdependencies.json` — a JSON map of import\u002Fdependency edges\n    extracted during architectural analysis (keys = source file paths relative\n    to CODE_ROOT; values = arrays of files that import\u002Fdepend on the key file).\n    This is consumed by `mantis-plan`'s dependency-aware fan-out (Phase 2). If\n    the codebase has no parseable import structure, write `{}`. Re-derive only\n    changed entries during scoped invalidation (see outcome 3 below).\n  - Archives `workspace\u002Flearnings.jsonl` to\n    `workspace\u002Farchive\u002Flearnings\u002Flearnings_pass_${N}_${X}.jsonl`.\n  - A `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` marker as the FIRST line of every\n    (re)written KB file (`index.md`, each `entities\u002F*.md`, each\n    `vulnerabilities\u002F*.md`), plus `kb_snapshot_id` = `SNAPSHOT_ID` in\n    `workspace\u002F.mantis_state.json`.\n  - An immutable per-pass copy of the whole KB tree to\n    `workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X}\u002F` (so a later reverted fix cannot\n    silently erase the record of what the KB claimed at pass N).\n- **Preconditions**:\n  - `workspace\u002Flearnings.jsonl` must exist.\n- **Idempotency Guarantee**:\n  - Transactional: moves `workspace\u002Flearnings.jsonl` to archive only after\n    programmatically verifying all KB Markdown updates were written\n    successfully. KB files are overwritten in-place.\n  - Snapshot stamping is part of the same transaction: the `KB_SNAPSHOT`\n    markers, the per-pass `workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X_kb}\u002F` copy, and\n    the `kb_snapshot_id` state write complete before (or together with) the\n    learnings move. On any failure, leave `workspace\u002Flearnings.jsonl` intact.\n\n## Instructions\n\nAnalyze the codebase and pending learnings to construct a permanent,\nMarkdown-based memory for future agents.\n\nExecute the architecture stage as follows:\n\n0. **LOCATOR RESOLUTION (Block A, inlined below):**\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\nThis is a CODE-READING stage (steps 2 and 4 read target source), so Block A\nsteps 1-6 all apply; it is NOT findings-only. Resolve `CODE_ROOT`,\n`SNAPSHOT_ID`, and `snapshot_pinned` from state BEFORE doing anything below. Per\nBlock A step 3, all `workspace\u002Fkb\u002F...` paths are STATE-RELATIVE: read and write\nthem under `state_root\u002Fworkspace`, NEVER under `CODE_ROOT`. Read all target\nsource under `CODE_ROOT`. Do NOT run any VCS command to decide KB freshness\n(Block A step 5's carve-out is only for history\u002Fdiff\u002Fblame, which this stage\ndoes not use).\n\n0b. **KB SNAPSHOT FRESHNESS GATE (mechanical; STATE + KB marker only, NO live\nVCS):**\n\n````\n- `CUR` = `SNAPSHOT_ID` (resolved by Block A; the empty string if\n  `active_snapshot` was absent). `PINNED` = `snapshot_pinned` (false if absent).\n- **MODE-OFF short-circuit (3-state rule):** if `active_snapshot` is ABSENT\n  in state (no `--sync` was requested — MODE-OFF = today's default), SKIP the\n  freshness gate entirely: do a best-effort build\u002Fupdate against `CODE_ROOT`,\n  do NOT prepend any STALE banner, and do\n  NOT stamp `kb_snapshot_id`. This is byte-for-byte today's behavior. (Only\n  HALT and PINNED run the gate below.)\n- `KB_ID` = the `kb_snapshot_id` value in `.mantis_state.json` (primary); else the\n  text after `KB_SNAPSHOT:` on the FIRST line of\n  `state_root\u002Fworkspace\u002Fkb\u002Findex.md` if that file exists (secondary fallback,\n  for legacy runs without state); else `\"\"` (no prior KB). State is primary so\n  the file-marker parsing pitfall (comment-wrapped first line, no `-->`\n  stripping) can never strand `KB_ID` with the comment closer and force BUILD\n  FRESH every pass.\n- Choose EXACTLY ONE outcome by string checks, top to bottom, first match wins:\n  1. `PINNED` is false (HALT mode — `active_snapshot` present but unpinned)\n     ->  **STALE \u002F HALT.** Do a best-effort build\u002Fupdate against `CODE_ROOT`,\n     but PREPEND the STALE banner (below) as the first lines of `index.md`.\n     Do NOT claim currency: leave the\n     banner in place. Set `kb_snapshot_id` = `CUR` (a `live:` id).\n  2. Else `KB_ID` == `CUR` (both non-empty)  ->  **CURRENT.** Do the incremental\n     update + decay-check (step 4) as today. Re-stamp `KB_SNAPSHOT: CUR` on\n     every (re)written file. REMOVE any STALE banner previously prepended to\n     `index.md`.\n  3. Else (`PINNED` true AND (`KB_ID` is empty OR `KB_ID` != `CUR`)) ->\n     **BUILD FRESH (full or scoped re-architecture).** The pinned code advanced\n     since the KB was built (a sync \u002F pass-boundary change), OR the KB is\n     unstamped \u002F legacy. Choose full or scoped:\n     - **Scoped invalidation (Phase 2 incremental efficiency):** If\n       `changed_files_status` is known (not UNKNOWN) AND the KB already has a\n       `KB_SNAPSHOT` stamp (KB_ID was non-empty, just different) AND\n       `changed_files_pass` equals the current `state.pass_number` (the diff\n       is from THIS pass, not a stale prior pass — absent or different →\n       treat as UNKNOWN → full rebuild below), attempt a SCOPED rebuild: only\n       invalidate KB entries whose source files are in `changed_files`, plus\n       their parent-rollup dependents (KB entities that import\u002Freference the\n       changed files). Re-derive ONLY those entries from `CODE_ROOT`; carry\n       forward all other KB entries unchanged (they were built against the\n       same code, just a different snapshot ID). Re-stamp `KB_SNAPSHOT: CUR`\n       on every (re)written file.\n        - **Parent-rollup (2-hop, matching plan's fan-out):** When\n          invalidating a KB entry for changed file F, also invalidate any KB\n          entry that REFERENCES F directly (1-hop) AND any entry that\n          references a 1-hop dependent of F (2-hop). This matches\n          `mantis-plan`'s dependency-aware fan-out (which expands up to 2\n          hops), ensuring that a grandchild entity (H imports G, G imports\n          changed F) is not carried forward stale and later fed as a\n          `kb_reference` while its dependency has changed.\n       - **Guardrail:** If ANY uncertainty arises (can't determine which KB\n         entries map to which source files, the KB structure is ambiguous, or\n         changed_files is empty but KB_ID != CUR), fall back to full rebuild\n         below. Never carry forward a stale entry for a changed file.\n     - **Full rebuild (Phase-1 fallback):** If KB_ID is empty (no prior KB),\n       OR `changed_files_status` is UNKNOWN, OR the scoped invalidation guardrail\n       fired, REBUILD every KB file from scratch against `CODE_ROOT`. Do NOT\n       carry forward any prior assertion you have not re-derived from\n       `CODE_ROOT` this pass. Stamp `KB_SNAPSHOT: CUR`. REMOVE any STALE banner.\n- STALE banner (paste verbatim, substituting `\u003CKB_ID>` and `\u003CCUR>`; keep the\n  leading `>` on every line so it renders as a visible blockquote):\n\n  ```\n  > **STALE KB WARNING — do not trust without re-verifying.**\n  > snapshot_pinned=false, or the KB was built against a different snapshot.\n  > KB_SNAPSHOT=\u003CKB_ID> does not match active_snapshot.snapshot_id=\u003CCUR>.\n  > Every SECURE\u002FFIXED\u002FNON_VIABLE\u002FSAMPLE_OR_TEST claim below is UNVERIFIED\n  > against the current code. Re-verify before trusting; do NOT filter, skip,\n  > or down-prioritize work based on this KB.\n  ```\n````\n\n1. **Read the Inbox (`workspace\u002Flearnings.jsonl` and\n   `workspace\u002Fhistorical_learnings.jsonl`):**\n\n   - Parse the contents of `workspace\u002Flearnings.jsonl` (and\n     `workspace\u002Fhistorical_learnings.jsonl` if it exists). Extract all\n     trajectory insights, discovered vulnerabilities, viable crash paths, and\n     verified patches.\n\n2. **Analyze Source Code Boundaries:**\n\n   - Examine the directory structure and key source files **under `CODE_ROOT`**\n     (the pinned snapshot resolved by Block A; use absolute paths per Block A\n     step 6, and do NOT run a VCS command). Dynamically identify the core\n     components, interfaces, and trust boundaries of the system based on the\n     repository's contents. This applies broadly across domains: whether it is a\n     software system (e.g., identifying parsers, controllers, or network\n     daemons), a hardware\u002FRTL design (e.g., identifying IP blocks, JTAG\n     interfaces, or memory controllers), Infrastructure-as-Code (e.g.,\n     identifying cloud permissions, VPC perimeters, or deployment descriptors),\n     or data\u002FML pipelines (e.g., identifying data ingress points, model\n     serialization mechanisms, or training boundaries).\n\n3. **Build or Update the Knowledge Base (KB):**\n\n   - Create or update files in the `workspace\u002Fkb\u002F` directory using standard\n     Markdown. Follow these strict paths:\n\n     - `workspace\u002Fkb\u002Farchitecture.md`: High-level data flows, zone definitions,\n       system design, and overall availability\u002Fuptime requirements (if\n       documented or inferable from configuration like systemd, kubernetes, or\n       load balancers).\n     - `workspace\u002Fkb\u002Fentities\u002F[component_name].md`: Specific definitions for\n       components (e.g., `auth_module.md`). Must include links to associated\n       vulnerability classes and document known constraints (e.g., \"This module\n       sanitizes input X\"). Document the component's criticality and\n       availability requirements (classify as CRITICAL, STANDARD, or\n       LOW_CRITICALITY if applicable). Incorporate trajectory insights here.\n     - `workspace\u002Fkb\u002Fvulnerabilities\u002F[CWE-ID_or_BugClass].md`: Descriptions of\n       bug classes (e.g., `CWE-79.md` or `Memory-Corruption.md`) that have been\n       historically relevant to this codebase, including examples of what *not*\n       to do.\n     - `workspace\u002Fkb\u002Findex.md`: A root catalog containing links and 1-line\n       summaries to every file created above. This is the map the Planner will\n       read.\n\n   - **Important Formatting Rules:** Use relative links to cross-reference\n     entities and vulnerabilities (e.g.,\n     `[Auth Module](entities\u002Fauth_module.md)`). Ensure all markdown files are\n     concise and focused on actionable security context.\n\n   - **Snapshot stamping (REQUIRED on every (re)written KB file when running the\n     freshness gate, i.e. HALT or PINNED; never in MODE-OFF):** Make the FIRST\n     line of `index.md`, each `entities\u002F*.md`, and each `vulnerabilities\u002F*.md`\n     exactly `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` (substitute `CUR` from step\n     0b; it is an HTML comment so it does not render). This is how the next\n     pass's freshness gate (step 0b) detects drift. **MODE-OFF gate (3-state\n     rule):** if `active_snapshot` is ABSENT (MODE-OFF — no `--sync` was\n     requested), do NOT stamp the per-file `KB_SNAPSHOT` marker: `CUR` is the\n     empty string (`arch:145`: \"the empty string if `active_snapshot` was\n     absent\"), so the mandated marker would be `\u003C!-- KB_SNAPSHOT:  -->` (empty\n     value) — a snapshot-era artifact that did not exist in Phase 1. The\n     per-file marker is ONLY consumed by step 0b's freshness gate, which\n     MODE-OFF skips entirely (`arch:147-152`: \"SKIP the freshness gate\n     entirely... This is byte-for-byte today's behavior. Only HALT and PINNED\n     run the gate below.\"). This MODE-OFF gate mirrors the freshness gate logic\n     below and step 0b's outcome clauses, which mention per-file\n     `KB_SNAPSHOT: CUR` stamping only in HALT\u002FPINNED outcomes (CURRENT `:164`,\n     scoped BUILD FRESH `:178`, full BUILD FRESH `:195`).\n\n   - **Per-file `KB_SNAPSHOT` stamping is the sole provenance mechanism for KB\n     assertions.** Do NOT write per-assertion `(AS_OF:\u003Csnapshot>)` tags — the\n     `AS_OF` re-verification reader was never built, and staleness protection is\n     already provided by the freshness gate (step 0b) comparing `kb_snapshot_id`\n     to `SNAPSHOT_ID`, plus per-finding `discovery_commit` (enforced by\n     `mantis-critic` Block B). A later-reverted fix is caught by these\n     mechanisms, not by per-assertion tags.\n\n4. **Validate and Decay Knowledge (Drift Prevention):**\n\n   - Knowledge becomes stale when code is patched or refactored. Before\n     finalizing the KB updates, spot-check the assertions in the existing\n     `workspace\u002Fkb\u002Fentities\u002F` against the source **under `CODE_ROOT`** (the\n     pinned snapshot — NOT a live VCS query, and NOT the live working tree). In\n     the **BUILD FRESH** outcome (step 0b) do NOT spot-check at all: discard the\n     prior assertions and re-derive every entity from `CODE_ROOT` this pass. In\n     the **STALE \u002F HALT** outcome, spot-check only best-effort and keep the\n     STALE banner regardless of the result.\n   - If an entity file claims a variable is un-sanitized (based on an old\n     learning) but the live code now contains a sanitization function (because a\n     patch landed), **delete or correct that outdated learning** in the KB.\n   - If a learning is repeatedly proven wrong by the current trajectory\n     insights, actively correct it to prevent the \"wrong learning\" from\n     persisting and blinding future agents.\n   - When you correct or re-confirm a finding-derived assertion, re-stamp the\n     `KB_SNAPSHOT` marker on that KB file.\n\n5. **Transactional Inbox Clearing & Archiving:**\n\n   - To prevent infinite loops and token bloat, you must clear the queue and\n     archive the learnings.\n   - **Verify and Finalize:** Programmatically verify that all Markdown KB\n     updates were successfully written to disk and that cross-references are\n     valid. Also verify, before committing, that every (re)written KB file\n     BEGINS with its `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` marker and that every\n     finding-derived verdict is grounded in the current `SNAPSHOT_ID`.\n   - **Commit by Moving:** Only after verifying synthesis success, move\n     `workspace\u002Flearnings.jsonl` to the archive directory:\n     - Ensure the target directory exists (e.g.,\n       `mkdir -p workspace\u002Farchive\u002Flearnings\u002F`).\n     - Determine the loop pass number `N` by reading `\"pass_number\"` from\n       `workspace\u002F.mantis_state.json`. If missing or invalid, scan\n       `workspace\u002Farchive\u002F` for folders matching `findings_pass_N` or\n       `loopN_findings` and resolve `N` to `max_found + 1`, defaulting to 1 if\n       no archives exist.\n     - Determine the sub-index `X` by counting existing files matching\n       `learnings_pass_${N}_*.jsonl` in `workspace\u002Farchive\u002Flearnings\u002F` and\n       adding 1.\n     - Move the file:\n       `mv workspace\u002Flearnings.jsonl workspace\u002Farchive\u002Flearnings\u002Flearnings_pass_${N}_${X}.jsonl`.\n   - **Snapshot the KB (per-pass archive):** After a successful synthesis, copy\n     the whole KB tree to a per-pass archive:\n     - Ensure the directory exists (`mkdir -p workspace\u002Farchive\u002Fkb\u002F`).\n     - Compute sub-index `X_kb` = (count of existing `kb_pass_${N}_*`\n       directories in `workspace\u002Farchive\u002Fkb\u002F`) + 1.\n     - Copy (do NOT move — the live `workspace\u002Fkb\u002F` must persist for the next\n       pass): `cp -a workspace\u002Fkb\u002F. workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X_kb}\u002F`.\n   - **Stamp state:** Write `kb_snapshot_id` = `SNAPSHOT_ID` (`CUR` from step\n     0b) into `workspace\u002F.mantis_state.json`. If `active_snapshot` was absent\n     (MODE-OFF), do NOT write `kb_snapshot_id` and do NOT prepend any STALE\n     banner (the freshness gate was skipped). In HALT mode, write\n     `kb_snapshot_id` = `CUR` and leave the STALE banner in `index.md`.\n   - If synthesis fails or is interrupted, leave `workspace\u002Flearnings.jsonl`\n     intact in its original location to ensure no data is lost.\n   - If `workspace\u002Flearnings.jsonl` is ABSENT on entry (e.g. the Stage-15\n     invocation, because the Stage-2 invocation already archived it this pass),\n     skip ONLY the learnings move; STILL run the freshness gate (step 0b), stamp\n     the `KB_SNAPSHOT` markers, write `kb_snapshot_id`, and copy the per-pass KB\n     archive. KB provenance must be recorded on every invocation.\n\nWhen complete, notify the user.\n","# Architect (\u002Fmantis-architecture)\n\n## System Goal\n\nKnowledge Base Synthesizer. Translates ephemeral insights from the learnings\nqueue (`workspace\u002Flearnings.jsonl`) and structural analysis of the codebase into\na canonical, interlinked Markdown Knowledge Base (`workspace\u002Fkb\u002F`).\n\n## Command Definition\n\n- **Command:** `\u002Fmantis-architecture`\n- **Description:** Builds the foundation of the KB by defining system\n  architecture, mapping specific entities (components), and categorizing\n  historical vulnerability patterns.\n- **Arguments (all optional; resolved by LOCATOR RESOLUTION \u002F Block A):**\n  `--snapshot_root=\u003Cdir>` (or the `SNAPSHOT_ROOT` env var) — the pinned code\n  snapshot to read target source from; `--snapshot_id=\u003Cid>` — the `SNAPSHOT_ID`\n  of that snapshot; `--state_root=\u003Cdir>` — the parent of `workspace\u002F` for all\n  state and KB paths; `--target_root=\u003Cdir>` — an already-prepared tree that\n  OVERRIDES the snapshot (rarely passed to this stage). When none are passed,\n  behavior is byte-for-byte today's (degraded\u002Funpinned): read source from the\n  current directory and treat `snapshot_pinned` as false.\n\n## Input\u002FOutput Contract\n\n- **Reads**:\n  - `workspace\u002Flearnings.jsonl` (raw insights from the current round).\n  - `workspace\u002Fhistorical_learnings.jsonl` (optional, past vulnerability\n    metadata).\n  - Codebase directory structure and key source files.\n  - Existing Markdown files in `workspace\u002Fkb\u002F` (to validate\u002Fdecay check).\n  - `workspace\u002F.mantis_state.json` (to retrieve pass count).\n  - `workspace\u002F.mantis_state.json` → `active_snapshot` (`root`, `snapshot_id`,\n    `snapshot_pinned`) and `snapshot_history` — provenance for the KB freshness\n    gate (step 0b). Read the snapshot from STATE ONLY; NEVER run a live VCS\n    command (`git`\u002F`hg`\u002F`repo`) to decide KB currency.\n  - `workspace\u002F.mantis_state.json` → `kb_snapshot_id` (the `SNAPSHOT_ID` the\n    current KB was last built against; absent on a first\u002Flegacy KB).\n  - `workspace\u002F.mantis_state.json` → `changed_files` and `changed_files_status`\n    (written by mantis-plan's Block E; consumed by the scoped KB invalidation in\n    step 0b outcome 3. Present from pass 2 on, but may be stale (written in a\n    prior pass) — the scoped path checks `changed_files_pass` against\n    `state.pass_number` and falls back to full rebuild if they differ.)\n- **Writes**:\n  - Markdown files under `workspace\u002Fkb\u002F` (`architecture.md`,\n    `entities\u002F[component_name].md`, `vulnerabilities\u002F[CWE-ID].md`, `index.md`).\n  - `workspace\u002Fkb\u002Fdependencies.json` — a JSON map of import\u002Fdependency edges\n    extracted during architectural analysis (keys = source file paths relative\n    to CODE_ROOT; values = arrays of files that import\u002Fdepend on the key file).\n    This is consumed by `mantis-plan`'s dependency-aware fan-out (Phase 2). If\n    the codebase has no parseable import structure, write `{}`. Re-derive only\n    changed entries during scoped invalidation (see outcome 3 below).\n  - Archives `workspace\u002Flearnings.jsonl` to\n    `workspace\u002Farchive\u002Flearnings\u002Flearnings_pass_${N}_${X}.jsonl`.\n  - A `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` marker as the FIRST line of every\n    (re)written KB file (`index.md`, each `entities\u002F*.md`, each\n    `vulnerabilities\u002F*.md`), plus `kb_snapshot_id` = `SNAPSHOT_ID` in\n    `workspace\u002F.mantis_state.json`.\n  - An immutable per-pass copy of the whole KB tree to\n    `workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X}\u002F` (so a later reverted fix cannot\n    silently erase the record of what the KB claimed at pass N).\n- **Preconditions**:\n  - `workspace\u002Flearnings.jsonl` must exist.\n- **Idempotency Guarantee**:\n  - Transactional: moves `workspace\u002Flearnings.jsonl` to archive only after\n    programmatically verifying all KB Markdown updates were written\n    successfully. KB files are overwritten in-place.\n  - Snapshot stamping is part of the same transaction: the `KB_SNAPSHOT`\n    markers, the per-pass `workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X_kb}\u002F` copy, and\n    the `kb_snapshot_id` state write complete before (or together with) the\n    learnings move. On any failure, leave `workspace\u002Flearnings.jsonl` intact.\n\n## Instructions\n\nAnalyze the codebase and pending learnings to construct a permanent,\nMarkdown-based memory for future agents.\n\nExecute the architecture stage as follows:\n\n0. **LOCATOR RESOLUTION (Block A, inlined below):**\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\nThis is a CODE-READING stage (steps 2 and 4 read target source), so Block A\nsteps 1-6 all apply; it is NOT findings-only. Resolve `CODE_ROOT`,\n`SNAPSHOT_ID`, and `snapshot_pinned` from state BEFORE doing anything below. Per\nBlock A step 3, all `workspace\u002Fkb\u002F...` paths are STATE-RELATIVE: read and write\nthem under `state_root\u002Fworkspace`, NEVER under `CODE_ROOT`. Read all target\nsource under `CODE_ROOT`. Do NOT run any VCS command to decide KB freshness\n(Block A step 5's carve-out is only for history\u002Fdiff\u002Fblame, which this stage\ndoes not use).\n\n0b. **KB SNAPSHOT FRESHNESS GATE (mechanical; STATE + KB marker only, NO live\nVCS):**\n\n````\n- `CUR` = `SNAPSHOT_ID` (resolved by Block A; the empty string if\n  `active_snapshot` was absent). `PINNED` = `snapshot_pinned` (false if absent).\n- **MODE-OFF short-circuit (3-state rule):** if `active_snapshot` is ABSENT\n  in state (no `--sync` was requested — MODE-OFF = today's default), SKIP the\n  freshness gate entirely: do a best-effort build\u002Fupdate against `CODE_ROOT`,\n  do NOT prepend any STALE banner, and do\n  NOT stamp `kb_snapshot_id`. This is byte-for-byte today's behavior. (Only\n  HALT and PINNED run the gate below.)\n- `KB_ID` = the `kb_snapshot_id` value in `.mantis_state.json` (primary); else the\n  text after `KB_SNAPSHOT:` on the FIRST line of\n  `state_root\u002Fworkspace\u002Fkb\u002Findex.md` if that file exists (secondary fallback,\n  for legacy runs without state); else `\"\"` (no prior KB). State is primary so\n  the file-marker parsing pitfall (comment-wrapped first line, no `-->`\n  stripping) can never strand `KB_ID` with the comment closer and force BUILD\n  FRESH every pass.\n- Choose EXACTLY ONE outcome by string checks, top to bottom, first match wins:\n  1. `PINNED` is false (HALT mode — `active_snapshot` present but unpinned)\n     ->  **STALE \u002F HALT.** Do a best-effort build\u002Fupdate against `CODE_ROOT`,\n     but PREPEND the STALE banner (below) as the first lines of `index.md`.\n     Do NOT claim currency: leave the\n     banner in place. Set `kb_snapshot_id` = `CUR` (a `live:` id).\n  2. Else `KB_ID` == `CUR` (both non-empty)  ->  **CURRENT.** Do the incremental\n     update + decay-check (step 4) as today. Re-stamp `KB_SNAPSHOT: CUR` on\n     every (re)written file. REMOVE any STALE banner previously prepended to\n     `index.md`.\n  3. Else (`PINNED` true AND (`KB_ID` is empty OR `KB_ID` != `CUR`)) ->\n     **BUILD FRESH (full or scoped re-architecture).** The pinned code advanced\n     since the KB was built (a sync \u002F pass-boundary change), OR the KB is\n     unstamped \u002F legacy. Choose full or scoped:\n     - **Scoped invalidation (Phase 2 incremental efficiency):** If\n       `changed_files_status` is known (not UNKNOWN) AND the KB already has a\n       `KB_SNAPSHOT` stamp (KB_ID was non-empty, just different) AND\n       `changed_files_pass` equals the current `state.pass_number` (the diff\n       is from THIS pass, not a stale prior pass — absent or different →\n       treat as UNKNOWN → full rebuild below), attempt a SCOPED rebuild: only\n       invalidate KB entries whose source files are in `changed_files`, plus\n       their parent-rollup dependents (KB entities that import\u002Freference the\n       changed files). Re-derive ONLY those entries from `CODE_ROOT`; carry\n       forward all other KB entries unchanged (they were built against the\n       same code, just a different snapshot ID). Re-stamp `KB_SNAPSHOT: CUR`\n       on every (re)written file.\n        - **Parent-rollup (2-hop, matching plan's fan-out):** When\n          invalidating a KB entry for changed file F, also invalidate any KB\n          entry that REFERENCES F directly (1-hop) AND any entry that\n          references a 1-hop dependent of F (2-hop). This matches\n          `mantis-plan`'s dependency-aware fan-out (which expands up to 2\n          hops), ensuring that a grandchild entity (H imports G, G imports\n          changed F) is not carried forward stale and later fed as a\n          `kb_reference` while its dependency has changed.\n       - **Guardrail:** If ANY uncertainty arises (can't determine which KB\n         entries map to which source files, the KB structure is ambiguous, or\n         changed_files is empty but KB_ID != CUR), fall back to full rebuild\n         below. Never carry forward a stale entry for a changed file.\n     - **Full rebuild (Phase-1 fallback):** If KB_ID is empty (no prior KB),\n       OR `changed_files_status` is UNKNOWN, OR the scoped invalidation guardrail\n       fired, REBUILD every KB file from scratch against `CODE_ROOT`. Do NOT\n       carry forward any prior assertion you have not re-derived from\n       `CODE_ROOT` this pass. Stamp `KB_SNAPSHOT: CUR`. REMOVE any STALE banner.\n- STALE banner (paste verbatim, substituting `\u003CKB_ID>` and `\u003CCUR>`; keep the\n  leading `>` on every line so it renders as a visible blockquote):\n\n  ```\n  > **STALE KB WARNING — do not trust without re-verifying.**\n  > snapshot_pinned=false, or the KB was built against a different snapshot.\n  > KB_SNAPSHOT=\u003CKB_ID> does not match active_snapshot.snapshot_id=\u003CCUR>.\n  > Every SECURE\u002FFIXED\u002FNON_VIABLE\u002FSAMPLE_OR_TEST claim below is UNVERIFIED\n  > against the current code. Re-verify before trusting; do NOT filter, skip,\n  > or down-prioritize work based on this KB.\n  ```\n````\n\n1. **Read the Inbox (`workspace\u002Flearnings.jsonl` and\n   `workspace\u002Fhistorical_learnings.jsonl`):**\n\n   - Parse the contents of `workspace\u002Flearnings.jsonl` (and\n     `workspace\u002Fhistorical_learnings.jsonl` if it exists). Extract all\n     trajectory insights, discovered vulnerabilities, viable crash paths, and\n     verified patches.\n\n2. **Analyze Source Code Boundaries:**\n\n   - Examine the directory structure and key source files **under `CODE_ROOT`**\n     (the pinned snapshot resolved by Block A; use absolute paths per Block A\n     step 6, and do NOT run a VCS command). Dynamically identify the core\n     components, interfaces, and trust boundaries of the system based on the\n     repository's contents. This applies broadly across domains: whether it is a\n     software system (e.g., identifying parsers, controllers, or network\n     daemons), a hardware\u002FRTL design (e.g., identifying IP blocks, JTAG\n     interfaces, or memory controllers), Infrastructure-as-Code (e.g.,\n     identifying cloud permissions, VPC perimeters, or deployment descriptors),\n     or data\u002FML pipelines (e.g., identifying data ingress points, model\n     serialization mechanisms, or training boundaries).\n\n3. **Build or Update the Knowledge Base (KB):**\n\n   - Create or update files in the `workspace\u002Fkb\u002F` directory using standard\n     Markdown. Follow these strict paths:\n\n     - `workspace\u002Fkb\u002Farchitecture.md`: High-level data flows, zone definitions,\n       system design, and overall availability\u002Fuptime requirements (if\n       documented or inferable from configuration like systemd, kubernetes, or\n       load balancers).\n     - `workspace\u002Fkb\u002Fentities\u002F[component_name].md`: Specific definitions for\n       components (e.g., `auth_module.md`). Must include links to associated\n       vulnerability classes and document known constraints (e.g., \"This module\n       sanitizes input X\"). Document the component's criticality and\n       availability requirements (classify as CRITICAL, STANDARD, or\n       LOW_CRITICALITY if applicable). Incorporate trajectory insights here.\n     - `workspace\u002Fkb\u002Fvulnerabilities\u002F[CWE-ID_or_BugClass].md`: Descriptions of\n       bug classes (e.g., `CWE-79.md` or `Memory-Corruption.md`) that have been\n       historically relevant to this codebase, including examples of what *not*\n       to do.\n     - `workspace\u002Fkb\u002Findex.md`: A root catalog containing links and 1-line\n       summaries to every file created above. This is the map the Planner will\n       read.\n\n   - **Important Formatting Rules:** Use relative links to cross-reference\n     entities and vulnerabilities (e.g.,\n     `[Auth Module](entities\u002Fauth_module.md)`). Ensure all markdown files are\n     concise and focused on actionable security context.\n\n   - **Snapshot stamping (REQUIRED on every (re)written KB file when running the\n     freshness gate, i.e. HALT or PINNED; never in MODE-OFF):** Make the FIRST\n     line of `index.md`, each `entities\u002F*.md`, and each `vulnerabilities\u002F*.md`\n     exactly `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` (substitute `CUR` from step\n     0b; it is an HTML comment so it does not render). This is how the next\n     pass's freshness gate (step 0b) detects drift. **MODE-OFF gate (3-state\n     rule):** if `active_snapshot` is ABSENT (MODE-OFF — no `--sync` was\n     requested), do NOT stamp the per-file `KB_SNAPSHOT` marker: `CUR` is the\n     empty string (`arch:145`: \"the empty string if `active_snapshot` was\n     absent\"), so the mandated marker would be `\u003C!-- KB_SNAPSHOT:  -->` (empty\n     value) — a snapshot-era artifact that did not exist in Phase 1. The\n     per-file marker is ONLY consumed by step 0b's freshness gate, which\n     MODE-OFF skips entirely (`arch:147-152`: \"SKIP the freshness gate\n     entirely... This is byte-for-byte today's behavior. Only HALT and PINNED\n     run the gate below.\"). This MODE-OFF gate mirrors the freshness gate logic\n     below and step 0b's outcome clauses, which mention per-file\n     `KB_SNAPSHOT: CUR` stamping only in HALT\u002FPINNED outcomes (CURRENT `:164`,\n     scoped BUILD FRESH `:178`, full BUILD FRESH `:195`).\n\n   - **Per-file `KB_SNAPSHOT` stamping is the sole provenance mechanism for KB\n     assertions.** Do NOT write per-assertion `(AS_OF:\u003Csnapshot>)` tags — the\n     `AS_OF` re-verification reader was never built, and staleness protection is\n     already provided by the freshness gate (step 0b) comparing `kb_snapshot_id`\n     to `SNAPSHOT_ID`, plus per-finding `discovery_commit` (enforced by\n     `mantis-critic` Block B). A later-reverted fix is caught by these\n     mechanisms, not by per-assertion tags.\n\n4. **Validate and Decay Knowledge (Drift Prevention):**\n\n   - Knowledge becomes stale when code is patched or refactored. Before\n     finalizing the KB updates, spot-check the assertions in the existing\n     `workspace\u002Fkb\u002Fentities\u002F` against the source **under `CODE_ROOT`** (the\n     pinned snapshot — NOT a live VCS query, and NOT the live working tree). In\n     the **BUILD FRESH** outcome (step 0b) do NOT spot-check at all: discard the\n     prior assertions and re-derive every entity from `CODE_ROOT` this pass. In\n     the **STALE \u002F HALT** outcome, spot-check only best-effort and keep the\n     STALE banner regardless of the result.\n   - If an entity file claims a variable is un-sanitized (based on an old\n     learning) but the live code now contains a sanitization function (because a\n     patch landed), **delete or correct that outdated learning** in the KB.\n   - If a learning is repeatedly proven wrong by the current trajectory\n     insights, actively correct it to prevent the \"wrong learning\" from\n     persisting and blinding future agents.\n   - When you correct or re-confirm a finding-derived assertion, re-stamp the\n     `KB_SNAPSHOT` marker on that KB file.\n\n5. **Transactional Inbox Clearing & Archiving:**\n\n   - To prevent infinite loops and token bloat, you must clear the queue and\n     archive the learnings.\n   - **Verify and Finalize:** Programmatically verify that all Markdown KB\n     updates were successfully written to disk and that cross-references are\n     valid. Also verify, before committing, that every (re)written KB file\n     BEGINS with its `\u003C!-- KB_SNAPSHOT: \u003CSNAPSHOT_ID> -->` marker and that every\n     finding-derived verdict is grounded in the current `SNAPSHOT_ID`.\n   - **Commit by Moving:** Only after verifying synthesis success, move\n     `workspace\u002Flearnings.jsonl` to the archive directory:\n     - Ensure the target directory exists (e.g.,\n       `mkdir -p workspace\u002Farchive\u002Flearnings\u002F`).\n     - Determine the loop pass number `N` by reading `\"pass_number\"` from\n       `workspace\u002F.mantis_state.json`. If missing or invalid, scan\n       `workspace\u002Farchive\u002F` for folders matching `findings_pass_N` or\n       `loopN_findings` and resolve `N` to `max_found + 1`, defaulting to 1 if\n       no archives exist.\n     - Determine the sub-index `X` by counting existing files matching\n       `learnings_pass_${N}_*.jsonl` in `workspace\u002Farchive\u002Flearnings\u002F` and\n       adding 1.\n     - Move the file:\n       `mv workspace\u002Flearnings.jsonl workspace\u002Farchive\u002Flearnings\u002Flearnings_pass_${N}_${X}.jsonl`.\n   - **Snapshot the KB (per-pass archive):** After a successful synthesis, copy\n     the whole KB tree to a per-pass archive:\n     - Ensure the directory exists (`mkdir -p workspace\u002Farchive\u002Fkb\u002F`).\n     - Compute sub-index `X_kb` = (count of existing `kb_pass_${N}_*`\n       directories in `workspace\u002Farchive\u002Fkb\u002F`) + 1.\n     - Copy (do NOT move — the live `workspace\u002Fkb\u002F` must persist for the next\n       pass): `cp -a workspace\u002Fkb\u002F. workspace\u002Farchive\u002Fkb\u002Fkb_pass_${N}_${X_kb}\u002F`.\n   - **Stamp state:** Write `kb_snapshot_id` = `SNAPSHOT_ID` (`CUR` from step\n     0b) into `workspace\u002F.mantis_state.json`. If `active_snapshot` was absent\n     (MODE-OFF), do NOT write `kb_snapshot_id` and do NOT prepend any STALE\n     banner (the freshness gate was skipped). In HALT mode, write\n     `kb_snapshot_id` = `CUR` and leave the STALE banner in `index.md`.\n   - If synthesis fails or is interrupted, leave `workspace\u002Flearnings.jsonl`\n     intact in its original location to ensure no data is lost.\n   - If `workspace\u002Flearnings.jsonl` is ABSENT on entry (e.g. the Stage-15\n     invocation, because the Stage-2 invocation already archived it this pass),\n     skip ONLY the learnings move; STILL run the freshness gate (step 0b), stamp\n     the `KB_SNAPSHOT` markers, write `kb_snapshot_id`, and copy the per-pass KB\n     archive. KB provenance must be recorded on every invocation.\n\nWhen complete, notify the user.\n",{"name":5,"description":7},"main","f3162c039ecd9c9d5d8bc404dd1373c7ca3152f7","skills\u002Fmantis-architecture",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":9,"skillName":5,"commands":67,"prompt":77,"zipAvailable":78},[68,71,74],{"tool":69,"command":70},"npx","npx skills add google\u002Fmantis --skill mantis-architecture",{"tool":72,"command":73},"bunx","bunx skills add google\u002Fmantis --skill mantis-architecture",{"tool":75,"command":76},"pnpm","pnpm dlx skills add google\u002Fmantis --skill mantis-architecture","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-architecture\u002FSKILL.md",true,[],[81,110,138,163,178,197],{"skillNo":82,"name":83,"nameZh":84,"description":85,"descriptionZh":86,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":87,"categories":88,"keywords":95,"publishedAt":51},"01M6992XJHHV0R5N8E392EHRW3","mantis-threat-model","Mantis 威胁建模","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.","将信任边界、攻击面和攻击者画像综合成一个持续演进的威胁模型。用作知识库（KB）生成流程的阶段 B，从 KB 中读取架构与实体定义。不用于分析源代码或从 JSONL 文件中提取原始学习成果。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-threat-model\u002FSKILL.md",[89,92],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BR4MYFKGCC4WCWVJ50KJ2C","安全工程师",{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BSJ8FPTACYEEYRWQRNFXKY","安全检测工程",[96,97,98,42,31,99,100,46,44,101,102,103,39,38,104,105,106,107,108,109],"mantis threat model","threat model","model","code","analyzing","files","surfaces","trust","as","extracting","reading","jsonl","source","source code",{"skillNo":111,"name":112,"nameZh":113,"description":114,"descriptionZh":115,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":116,"categories":117,"keywords":120,"publishedAt":51},"01M6992TR1BPA5HVF13QRM7EP0","mantis-summarize","Mantis 代码库安全摘要生成","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.","通过为每个目录生成聚焦安全的摘要（mantis-summary.md）来预处理代码仓库，从而提升规划与研究效率。当启动审查活动、在威胁建模与规划之前梳理代码库时使用。不用于执行代码审查、编写测试脚本或修补代码。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-summarize\u002FSKILL.md",[118,119],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},[121,122,123,124,125,126,127,99,128,129,130,42,131,132,133,134,135,136,34,137],"summarize","mantis summarize","writing","directory","review","security","threat modeling","planning","repository","patching","campaign","map","modeling","scripts","make","reviews","when",{"skillNo":139,"name":140,"nameZh":141,"description":142,"descriptionZh":143,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":144,"categories":145,"keywords":148,"publishedAt":51},"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",[146,147],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},[149,150,151,152,99,153,154,155,48,130,156,157,158,43,159,160,161,162,34,137],"mantis structural index","index","structural","research","content","reporting","data","improve","quality","context","research quality","reference","live","unit",{"skillNo":164,"name":165,"nameZh":166,"description":167,"descriptionZh":168,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":169,"categories":170,"keywords":173,"publishedAt":51},"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",[171,172],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},[125,174,99,175,130,43,176,177,136,34,108,109,137],"mantis review","validation","filters","false",{"skillNo":179,"name":180,"nameZh":181,"description":182,"descriptionZh":183,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":184,"categories":185,"keywords":188,"publishedAt":51},"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.","根据 workspace\u002Fplan.json 中的策略审计生产源代码文件。当存在审查计划且需要对目标文件进行静态分析和深入审查时使用。不用于规划、去重或编写补丁。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-researcher\u002FSKILL.md",[186,187],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},[189,190,123,125,191,99,128,48,192,193,43,101,194,195,136,34,108,196,109,137],"mantis researcher","researcher","static analysis","plan","strategy","deep","you","static",{"skillNo":198,"name":199,"nameZh":200,"description":201,"descriptionZh":202,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":203,"categories":204,"keywords":207,"publishedAt":51},"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.","生成并运行崩溃复现程序以验证安全缺陷。当存在可行的发现且需要编写并执行脚本或 payload 来验证崩溃时使用。不用于代码审计或补丁制作。","https:\u002F\u002Fgithub.com\u002Fgoogle\u002Fmantis\u002Fblob\u002Fmain\u002Fskills\u002Fmantis-reproduce\u002FSKILL.md",[205,206],{"categoryNo":90,"categoryName":91,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":93,"categoryName":94,"taxonomyType":28,"taxonomyTypeDesc":29},[208,209,126,99,130,210,211,212,43,213,214,215,195,34,137],"mantis reproduce","reproduce","verify","write","execute","crash","payload","script"]