mantis-critic
Assesses the production viability of findings, filtering out debug-only features and assertion traps. Use when findings have been validated and you need to confirm they are triggerable in production release builds (with assertions disabled). Don't use for writing reproduction scripts or patches.
By google · 1,021 installs
npx skills add google/mantis --skill mantis-critic
Source repository · Upstream listing
Critic (/mantis critic)
System Goal
Production Viability Expert. Filters validated security findings to confirm if
they remain triggerable in standard release and production configurations.
Command Definition
Command:
/mantis critic [ target root=<path ] [ snapshot root=<path ] [ snapshot id=<id ] [ state root=<path ]
Description: Assesses the production viability of findings, filtering out
debug only features and assertion traps.
Parameters:
target root : AUTHORITATIVE path to the target codebase root. Overrides
all other locator sources and is sentinel exempt (Block A path 1a). Defaults
to unset.
snapshot root : Path to the pinned, immutable snapshot copy for this pass
(a.k.a. SNAPSHOT ROOT ). Used as CODE ROOT when target root is unset
(Block A path 1b).
snapshot id : The SNAPSHOT ID the orchestrator computed for this pass.
Used for the Block A sentinel check and for the per finding Block B drift
comparison in Step 3. If omitted, fall back to active snapshot.snapshot id
from state.
state root : Path to the root of the Mantis state directory containing
workspace/ (defaults to . ). Every workspace/... path in this file is
resolved relative to state root ; with the default . this is identical
to today's workspace/ .
Input/Output Contract
Reads :
workspace/findings/ (loads all findings regardless of status; also reads
each finding's optional discovery commit for the per finding snapshot
match check).
workspace/kb/THREAT MODEL.md (if exists, to check deployment intent and
the KB's recorded kb snapshot id ).
workspace/.mantis state.json (to track current loop pass and to read
active snapshot.{root,snapshot id,snapshot pinned} for locator resolution
and provenance).
Target source code files under the resolved CODE ROOT (the pinned snapshot
root when snapshot pinned ), at paths/lines in code paths with contextual
offset.
Writes :
Updates findings in place (sets "production viability" ,
"critic reasoning" , and appends history).
Appends to workspace/learnings.jsonl .
Preconditions :
Findings must exist in workspace/findings/ .
Idempotency Guarantee :
Overwrites viability fields in place. It must check if a critic entry for
the current pass is already recorded in the history array, and check
workspace/learnings.jsonl to ensure it does not write duplicate records if
run again on the same input.
Instructions
Evaluate validated findings to determine if they represent actionable security
flaws in a compiled, optimized release build. Adopt a highly skeptical,
adversarial stance. Do not trust the reasoning of previous stages. Re verify the
code path independently to definitively prove or disprove production
viability.
Locator Resolution (do this first)
Critic is a CODE READING stage (it inspects the target source), so it is NOT a
findings only stage: run all of Block A. Resolve CODE ROOT and the sentinel per
Block A before loading findings.
[!NOTE] CURRENT PASS CHECK (defensive; the binding guarantee is on the
harness per mantis pipeline adapter Scenario 2): if active snapshot is
present AND active snapshot.pass != state.pass number , treat the snapshot as
STALE for this pass — STOP "stale active snapshot: pass mismatch" or degrade
as HALT ( snapshot pinned effectively false: no authoritative verdicts, Block
B NOT MATCHED, reproduce not attempted ). This catches a custom harness that
preserved active snapshot across the Stage 15 pass increment without
re pinning. The reference meta agent re pins every pass, so this check never
fires there. Block B itself cannot detect this (it is snapshot id only, not
pass aware).
SNAPSHOT ID for this stage: let SNAPSHOT ID be the value of
snapshot id if provided, else active snapshot.snapshot id from
workspace/.mantis state.json . If neither is present (no snapshot id AND no
active snapshot in state), OR Block A resolved CODE ROOT via path 1d (no args,
current dir), then SNAPSHOT ID is UNAVAILABLE (MODE OFF = today's default):
treat every Block B check in Step 3 as NOT MATCHED and treat the KB freshness
gate in Step 2 as FAILED. Do NOT stop; degrade as described below. When
active snapshot IS present but snapshot pinned is false (HALT mode),
SNAPSHOT ID is the recorded live: id and IS available — Block B still returns
NOT MATCHED (snapshot pinned is false), but the Step 3c "MODE OFF exception"
below does NOT fire: a NOT MATCHED result is treated as drift →
CONDITIONAL VIABLE, never NON VIABLE (which calibrate drops).
Execute the critic evaluation as follows:
1. Load Findings: Read the JSON files in the workspace/findings/
directory. You must load all findings regardless of status (including
"VALID" , "FALSE POSITIVE" , "PROVISIONALLY VALID" , and
"NEEDS RESEARCH" ) so they can be processed or logged to long term memory.
If none exist, notify the user.
2. Evaluate Global Repository Intent (KB freshness gated): Read
workspace/kb/THREAT MODEL.md (if it exists). Check the Deployment
Intent section.
KB freshness gate — REQUIRED before any blanket mass mark (3 state rule):
Determine the snapshot the KB was built against. Read it from ONE of these
sources (try in order, first match wins):
1. The literal KB SNAPSHOT: token on the FIRST line of
workspace/kb/THREAT MODEL.md (threat model writes this as a bare header;
architecture writes comment wrapped <! KB SNAPSHOT: ... on each KB
file). For architecture files, scan for the KB SNAPSHOT: substring
inside the comment. Do NOT look for kb snapshot id: or Snapshot: —
those tokens are never written and the gate would never match.
2. Else the kb snapshot id value in workspace/.mantis state.json (which
architecture writes in its state stamp step).
3. Else "" (no prior KB provenance). The blanket mass mark below is gated
as follows:
MODE OFF (no active snapshot in state — no sync ): SKIP the
freshness gate entirely. The blanket SAMPLE OR TEST mass mark is
permitted as today (byte for byte today's behavior) — the KB was built
against the live tree and there is no snapshot to compare against.
HALT or PINNED ( active snapshot IS present): the blanket mass mark is
permitted ONLY if the recorded KB SNAPSHOT: (or kb snapshot id ) is
present AND is byte for byte equal to the current SNAPSHOT ID resolved in
Locator Resolution above (no fuzzy compare). If it is missing, empty, or
does not equal SNAPSHOT ID , you MUST NOT mass mark: skip this blanket
action entirely and evaluate every finding individually in Steps 3 5.
Only when the freshness gate passes (or is skipped in MODE OFF): if the
threat model explicitly states the entire repository is exclusively a
tutorial, sample project, or test suite (e.g.,
Intent: SAMPLE OR TEST ONLY ), you MUST mark all findings as
SAMPLE OR TEST regardless of where they are located in the file
structure, and skip the remaining per finding viability checks.
3. Acquire Targeted Code Snippets (snapshot matched): For each finding where
status is "VALID" or "PROVISIONALLY VALID" (skip this and the following
evaluation steps for "FALSE POSITIVE" or "NEEDS RESEARCH" findings):
a. Resolve the target file from the finding's code paths per Block A
step 3: code paths are SNAPSHOT RELATIVE, so read them under CODE ROOT.
Strip a trailing :<digits to get the line number; :// means a URL, not a
file; any entry that is not <path :<int is a non source LOCATOR — do an
existence check only, with no line logic.
b. Snapshot Match Check (Block B): compute MATCHED / NOT MATCHED for this
finding by comparing its discovery commit against the current
SNAPSHOT ID .
c. Drift / missing file / out of range guard (fail safe — NEVER
NON VIABLE): If Block B yields NOT MATCHED , OR the resolved target file
does not exist under CODE ROOT, OR the designated line number is beyond the
end of the file (out of range), then you MUST NOT run the domain specific
viability analysis (Steps 4 5) for this finding and you MUST NOT mark it
NON VIABLE (a missing file is not dead code; NON VIABLE is the value that
mantis calibrate DROPS).
Exception (MODE OFF only — no active snapshot): if SNAPSHOT ID is
UNAVAILABLE (MODE OFF: no active snapshot in state and no snapshot id )
AND the sole cause of NOT MATCHED is the missing/unavailable SNAPSHOT ID (not
a missing file or out of range line), treat it as "cannot compare" and fall
through to normal evaluation (Step 3d). This preserves today's behavior for
non sync runs. In HALT mode ( active snapshot present,
snapshot pinned=false ), this exception does NOT fire: Block B is
NOT MATCHED and the finding is drift → CONDITIONAL VIABLE (the "Otherwise"
branch below), never NON VIABLE (which calibrate drops). The missing file and
out of range conditions still force CONDITIONAL VIABLE regardless of pinning
or mode.
Otherwise (drift, missing file, or out of range): set
production viability = CONDITIONAL VIABLE and write a
critic reasoning drift note naming the cause, e.g.:
"Snapshot drift: discovery commit=<disc != active SNAPSHOT ID=<id (or the target file/line is no longer present at the pinned snapshot); could not re verify viability, defaulting to CONDITIONAL VIABLE (conservative)."
Then record the update via Step 6 and continue to the next finding. (This
finding is still logged to long term memory in Step 7 as
CONDITIONAL VIABLE .)
d. MATCHED, file present, line in range: read the target file from
CODE ROOT and read at least 15 lines of preceding context and 15 lines
of succeeding context around the designated line numbers. This targeted
window is necessary to analyze surrounding structures and macro definitions.
Additionally, inspect repro hints and history for empirical execution
telemetry recorded by mantis reproduce (e.g. build profile ,
sanitizers used , assertions disabled , ingress blocked ). Use this
empirical execution telemetry to corroborate release build viability. Proceed
to Steps 4 5.
4. Evaluate Domain Specific Viability Constraints:
For Memory Safety Flaws: Locate the allocation source of the affected
buffer. Determine if it is allocated with safety margins or trailing
padding. If the out of bounds access is contained within physical padding,
mark it NON VIABLE .
For Logic & Authorization Flaws: Verify that the flawed logic or
bypassed endpoint is actually accessible in standard production
deployments. If the flaw relies on a debug only backdoor, a mock
authentication provider, or a test only route, mark it NON VIABLE .
5. Determine Viability Status: Assign one of the following viability
statuses to the finding to ensure we prioritize correctly:
NON VIABLE : The flaw is unreachable or compiled out in production.
This includes:
Disabled Assertions (Memory Flaws): Bugs that rely on standard
assert() , debug abort() , or development only panics to trigger
crash/DoS states, where NDEBUG strips them and the code returns safely.
Debug Only Features: Conditionally compiled with debug flags (e.g.
ifdef DEBUG ).
Blocked by Environmental Controls: Blocked by standard,
non configurable production environmental controls (e.g., OS level
permissions, kernel level sandboxing, read only filesystems) that cannot
be bypassed.
SAMPLE OR TEST : The issue resides in example code, test suites,
fuzzing harnesses, or validation frameworks.
CONDITIONAL VIA