Loading...
Loading...
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.
npx skill4agent add google/mantis mantis-critic/mantis-critic [--target_root=<path>] [--snapshot_root=<path>] [--snapshot_id=<id>] [--state_root=<path>]--target_root--snapshot_rootSNAPSHOT_ROOT--target_root--snapshot_idSNAPSHOT_IDactive_snapshot.snapshot_id--state_rootworkspace/.workspace/...--state_root.workspace/workspace/findings/discovery_commitworkspace/kb/THREAT_MODEL.mdkb_snapshot_idworkspace/.mantis_state.jsonactive_snapshot.{root,snapshot_id,snapshot_pinned}snapshot_pinnedcode_paths"production_viability""critic_reasoning"workspace/learnings.jsonlworkspace/findings/workspace/learnings.jsonlLOCATOR RESOLUTION (before reading ANY target code or artifact):
0. ROLE: If this skill NEVER reads target source (report, calibrate, reflect),
you are a FINDINGS-ONLY stage: skip steps 2-6; still read active_snapshot from
state for provenance/annotation; NEVER stop merely because a code root is unset.
1. Determine CODE_ROOT, in this priority order:
a. If --target_root is passed on THIS invocation, CODE_ROOT = --target_root.
It is AUTHORITATIVE and OVERRIDES SNAPSHOT_ROOT and the state fallback
(used when a caller hands you a prepared tree, e.g. a patched shadow).
b. Else if --snapshot_root (or SNAPSHOT_ROOT) is passed, use it.
c. Else read state_root/workspace/.mantis_state.json (state_root from
--state_root if passed, else ./workspace/... relative to the current dir)
-> active_snapshot.root / .snapshot_id / .snapshot_pinned.
d. Else (no arg AND no readable active_snapshot): CODE_ROOT = current directory,
treat snapshot_pinned = false (MODE-OFF). Do NOT stop.
2. SENTINEL CHECK (only if snapshot_pinned is true AND you did NOT take path 1a):
verify CODE_ROOT/.mantis_snapshot_id exists and equals SNAPSHOT_ID. If missing
or different -> STOP "snapshot sentinel mismatch". (A --target_root tree (1a) is
deliberately mutated and is sentinel-EXEMPT.)
3. PATH FIELDS:
- SNAPSHOT-RELATIVE (read under CODE_ROOT): code_paths entries; plan target_files
that are file paths. Strip ONLY a trailing ":<digits>". A code_paths entry
containing "://" is a URL/endpoint, NOT a file read. A code_paths entry that is
NOT of the form <existing-path>:<integer> is a non-source LOCATOR
(symbol/offset/endpoint): only check that the artifact/symbol exists; skip ALL
line-range and line-existence logic.
- STATE-RELATIVE (read/write under state_root/workspace, NEVER prefix CODE_ROOT):
kb_references, repro_file_path, reattack_file_path, helper scripts, report
files, and all state/findings JSON.
4. Never WRITE under CODE_ROOT when snapshot_pinned is true. Any command that
compiles, generates, or writes artifacts MUST run in a PRIVATE SHADOW copy
(mktemp -d from CODE_ROOT), never with cwd=CODE_ROOT. Read-only inspection may
cd into CODE_ROOT.
5. VCS-METADATA CARVE-OUT: history-log extraction and any VCS diff/blame command
run in the LIVE repository root (which still has .git/.hg/.repo), NOT CODE_ROOT
(the snapshot copy strips VCS metadata). Do NOT stop merely because CODE_ROOT
lacks .git/.hg/.repo.
6. Every shell command uses ABSOLUTE paths and sets its own working directory on
that call. Do NOT assume the working directory persists between calls.[!NOTE] CURRENT-PASS CHECK (defensive; the binding guarantee is on the harness perScenario 2): ifmantis-pipeline-adapteris present ANDactive_snapshot, treat the snapshot as STALE for this pass — STOP "stale active_snapshot: pass mismatch" or degrade as HALT (active_snapshot.pass != state.pass_numbereffectively false: no authoritative verdicts, Block B NOT_MATCHED, reproducesnapshot_pinned). This catches a custom harness that preservednot_attemptedacross 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 isactive_snapshot-only, notsnapshot_id-aware).pass
SNAPSHOT_ID--snapshot_idactive_snapshot.snapshot_idworkspace/.mantis_state.json--snapshot_idactive_snapshotactive_snapshotsnapshot_pinnedlive:workspace/findings/"VALID""FALSE_POSITIVE""PROVISIONALLY_VALID""NEEDS_RESEARCH"workspace/kb/THREAT_MODEL.mdKB_SNAPSHOT:workspace/kb/THREAT_MODEL.md<!-- KB_SNAPSHOT: ... -->KB_SNAPSHOT:kb_snapshot_id:Snapshot:kb_snapshot_idworkspace/.mantis_state.json""active_snapshot--syncSAMPLE_OR_TESTactive_snapshotKB_SNAPSHOT:kb_snapshot_idSNAPSHOT_IDSNAPSHOT_IDIntent: SAMPLE_OR_TEST_ONLYSAMPLE_OR_TESTstatus"VALID""PROVISIONALLY_VALID""FALSE_POSITIVE""NEEDS_RESEARCH"code_pathscode_paths:<digits>://<path>:<int>discovery_commitSNAPSHOT_IDSNAPSHOT MATCH CHECK for finding F (decides MATCHED vs NOT_MATCHED):
1. If snapshot_pinned is false -> NOT_MATCHED. Stop.
2. Read F.discovery_commit:
- missing OR empty OR the literal "MIXED" -> NOT_MATCHED.
- not exactly equal to SNAPSHOT_ID -> NOT_MATCHED.
- exactly equal to SNAPSHOT_ID -> MATCHED.
There is no other route to MATCHED; never fuzzy-compare. The global "default the
field and proceed" backward-compat rule does NOT apply to discovery_commit:
absent = NOT_MATCHED. (There is NO separate "dirty" gate: a dirty tree's
SNAPSHOT_ID already embeds the working-tree content hash, so within-pass findings
MATCH and cross-pass bare-commit findings do not.)NON_VIABLENON_VIABLEmantis-calibrateactive_snapshot--snapshot_idactive_snapshotsnapshot_pinned=falseproduction_viabilityCONDITIONAL_VIABLEcritic_reasoning"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)."CONDITIONAL_VIABLErepro_hintshistorymantis-reproducebuild_profilesanitizers_usedassertions_disabledingress_blockedNON_VIABLEassert()debug_abort()NDEBUG#ifdef DEBUGSAMPLE_OR_TESTCONDITIONAL_VIABLEVIABLEjqworkspace/findings/<id>.json"production_viability""VIABLE""NON_VIABLE""SAMPLE_OR_TEST""CONDITIONAL_VIABLE""critic_reasoning""history"{
"stage": "critic",
"action": "evaluated",
"details": "Determined production viability as [VIABLE/NON_VIABLE/SAMPLE_OR_TEST/CONDITIONAL_VIABLE] because [reason]",
"pass_number": <current_pass_number>,
"snapshot": "<SNAPSHOT_ID>",
"timestamp": "<current_iso8601_timestamp>"
}"snapshot"SNAPSHOT_IDSNAPSHOT_ID""NON_VIABLESAMPLE_OR_TESTCONDITIONAL_VIABLEFALSE_POSITIVENEEDS_RESEARCHworkspace/learnings.jsonl{"title": "[security_flaw_title]", "code_paths": ["[path1:line1]"], "status": "[VIABLE / CONDITIONAL_VIABLE / NON_VIABLE / SAMPLE_OR_TEST / FALSE_POSITIVE / NEEDS_RESEARCH]", "snapshot": "[current SNAPSHOT_ID, or omit in MODE-OFF]"}