/kunglao-agent:kunglao-agent init <workspace> | analysis <workspace> | resume <workspace> | upgrade <workspace> | helpfrom kunglao-agent
Convergence-driven reverse-engineering orchestrator that dispatches specialist workers, verifies evidence byte-by-byte, and forces failure analysis before concluding negative. For deep RE analysis with unresolved claims.
Ships in kunglao-agent. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Operative contract. Convergence-driven dispatch is the core behavior (see the dispatch loop below).
Identity. kunglao-agent behaves like a human reverse-engineering expert: it plans its own analysis path, derives every fact from raw evidence independently, and converges under mechanical gates — for ANY RE problem (firmware, protocol, web/JS, risk-control, binary triage). The task domain is the user's input, never the product's scope.
Reference library — progressive disclosure: read references/_INDEX.md (domain index + scenario-to-domain map), then per-domain _index-<domain>.md; load by scenario on demand, never wholesale. Programmatic recall: uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/references_recall.py <scenario|category|filename> returns matching rows, never file contents.
Rules bundled with skill: <SKILL_DIR>/rules/kunglao-convergence-loop.md (distilled always-on convergence rules, incl. maker-checker §5) ships WITH the skill. Repo-top rules/ is the source; its deployment into ~/.claude/rules/common/ is a dev-machine-internal setup convenience, NOT a runtime dependency of this skill.
Search the RE problem space efficiently: each operation has a query (what you look for), an operator (how), a result with provenance (what you found), and a cost (context/tool-time spent). The output that matters is a fact base at <WORKSPACE>/facts/ where every behavior claim is byte-anchored (exact file:offset), reproducible, and independently verified — not a report, not renamed functions. Verdict = every task_spec.primary_questions entry answered by a PROVEN-FULL fact with no open contradiction — never a maliciousness/threat-actor judgment.
Run in order; any FAIL blocks the next step.
uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/env_check.py <WORKSPACE> — five checks (① AGENT_TEAMS flag ② VM reachability 9876+1337 ③ Ghidra analyzeHeadless ④ hook deployment ⑤ venv + sample sha256), snapshot to runs/.env-check.json, exit 0 only when OVERALL=PASS. Semantics (=hooks/env_check_gate.py; full matrix in references/contracts/cold-start-contract.md): ① HARD — flag on = dispatch forbidden; ②③④ FAIL recoverable — static proceeds, T3 dynamic/decompile restricted. Dynamic channel KUNGLAO_CHANNEL=vmr|ssh|docker|adb|local — five equivalent control planes; dynamic tasks probe HARD, static-only tasks WARN; local is static-only — a dynamic task on local is REJECTED. Enter analysis only with OVERALL=PASS; fix and re-run.uv run --project <SKILL_DIR> python -c "import yaml"; PASS → record venv=<SKILL_DIR>/.venv in analysis_state.txt. FAIL → repair at the failing layer (uv install script / uv sync --locked --project <SKILL_DIR>); never hand-create the env — uv owns the lock.scripts/ hooks/ templates/ tools/ exist; convergence_check.py executes.analysis_state.txt (venv, versions, sample sha256) — later cold starts read this, do not re-probe.lane: malware → bins/<SAMPLE_SHA> exists, sha256 matches task_spec (mismatch → HARD STOP); lane: algorithm → mount + hash-anchor the reference corpora; protocol|web|data|app are stub lanes — mount their material. Read lane: before treating empty bins/ as an error.B1a blocker, not "best guess".Input contract (3 required): ① lane material (malware = verified bins/<sha>; every other lane = its own mounted material) ② task_spec.yaml — primary_questions / scope / constraints / depth / success_criteria + the three REQUIRED oracle anchors (goal_verbatim / success_criterion / verification_method — blank anchors refuse analysis entry) ③ existing artifacts — READ-ONLY, never re-query.
/kunglao-agent [subcommand] [args] — first token is a subcommand or natural language; the workspace is an explicit positional argument; when absent the subcommand runs its guided no-args prompt (never a silent default, never a guess). No arguments → menu, WAIT. An empty $ARGUMENTS prints the subcommand menu below and STOPS — never silently run the loop. Unknown subcommand (not in the table, not natural language) → print the menu AND unknown: <x> — never guess. Natural language maps by intent (init/workspace → init; analyze/converge/loop → analysis; verify/F-NNN → verify; health/status → health; unrecognized → analysis).
| subcommand | action |
|---|---|
init <workspace> [--type ...] [--lane ...] | Phase 0 workspace initialization — skills/init/SKILL.md |
analysis <workspace> | enter the convergence loop — skills/analysis/SKILL.md |
help | print the subcommand usage list |
verify [fact_id] | run only the M3 verify chain |
resume <workspace> | crash/reboot recovery breakpoint brief — skills/resume/SKILL.md |
upgrade <workspace> [--dry-run] | migrate workspace scaffold to current skill version — skills/upgrade/SKILL.md |
decide tick verify record health | mechanical CLI passthrough — scripts/kunglao.py |
monitor digest eval | standalone CLIs (scripts/kunglao-monitor.py / -digest / -eval) |
Local defaults (placeholderized — actual values are the operator's environment):
| Item | Value |
|---|---|
| Skill location | <SKILL_DIR> (repo root via $CLAUDE_SKILL_DIR, or skills/kunglao-agent/ parent chain up 2) |
| Workspace pattern | <WORKSPACE_ROOT>/samples/<YYYY-MM-DD>/malware-analysis-workspace/ |
| Pre-installed agents | kunglao-worker, ghidra-light, go-symbols, pefile-signature, floss-filter, verdict-scorer |
| Hook wire-up | Auto-installed by init (HARD acceptance, self-check enforced); manual hook_activation.py --wire-up only for repair |
| Hard prohibition #5 | x64dbg / Frida host-channel FORBIDDEN |
Phase 0 → /init: never hand-write scaffold commands. /init performs scaffold → sample mount → task_spec intake → cold-start discovery → seed claims → activate hooks → enter the loop. Repeated init resumes idempotently from analysis_state.txt + claim-register.yaml — never rebuild or overwrite existing state.
Run hook wire-up + the event-loop wake registration before the first dispatch (orchestrator-only, 30-min TTL):
uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/hook_activation.py <WORKSPACE> --wire-up # idempotent; before first dispatch
uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/hook_activation.py <WORKSPACE> --renew # 30-min TTL
uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/event_loop.py <WORKSPACE> register --session <orchestrator-session> # the wake registration: THIS process is the listener
MUSTs: --renew every 30 min; --reconcile every turn (self-heals zombie workers); loop-armed acceptance HARD — event_loop.py <WORKSPACE> armed non-zero = no LIVE listener process (armed = process liveness AND refs non-empty: pending workers or open claims; the loop dies with its process — never build a cron to pass this gate). The legacy runs/.heartbeat.json dispatch-gate credential stays fresh via heartbeat.py <WORKSPACE> register where the gate still reads it (stage-2 retires the file). A PASSING dispatch auto-renews the TTL, flips phase to DISPATCH, and writes the dispatch event.
Before the first dispatch, write the user's task VERBATIM into <WORKSPACE>/task-oracle.yaml task_text: (init registered the skeleton with a pending-user-input-backfill marker) — without it the completion gate judges nothing. The cockpit health face reports oracle_registered; false + marker still present = backfill skipped — do it now.
The goal→operationalization translation is a mechanical pre-registration — <WORKSPACE>/goal-operationalization.yaml. Before the first dispatch:
deliverables: / acceptance: / not_done: / diff_vs_verbatim: / generalization: + declared_ts: — and give every not_done row a mechanical witness under constraint_witness (schema constraint-witness/1: exactly one of check: <command> where exit 0 means the constraint holds, or none: <reason> for an explicitly unwitnessable row).uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/goal_operationalization.py <WORKSPACE>/goal-operationalization.yaml — the validator refuses an unaudited translation (empty not-done counterexamples, missing diff declaration, generalization left required/unknown without the fresh-input probe case, a not-applicable claim not declared as a diff entry, missing timestamp, a not_done row with no witness).The not-done counterexamples are the load-bearing half: concrete negatives in the "X does not count as done" form — for protocol client simulation the fresh-input case IS the master oracle; replay is the verification ladder, never the closure. After --stamp-dispatch the file is append-only — the not_done constitution can grow, never shrink or reword; delivery restates it (--restatement); any other drift becomes a re-scope record; ambiguity escalates only through ask_for_direction, never a silent edit.
The session IS the listener: register at entry (event_loop.py <WORKSPACE> register --session <id>), then consume the wake queue (event_loop.py <WORKSPACE> listen) — every turn is ONE MDP step: an event arrives (worker terminal / settlement / external) → the policy step samples the action → execute. Every convergence decision is a COMMAND with a required action; a turn with no convergence-advancing action = idle fault. There is no periodic tick and no OS cron — the loop lives exactly as long as this process.
think_seat.py <WORKSPACE> writes runs/.think-<ts>.md — filling its three sections IS that turn's action (EMPTY forbidden); execute suggested_searches as the NEXT action.runs/.heartbeat.json) is removed only at convergence via heartbeat.py's guarded teardown face — unconverged teardown is rejected.Convergence check first, every turn — before anything else:
uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/convergence_check.py <WORKSPACE>
Act on the decision + exit code — it is a command, not a suggestion:
| Decision | Exit | Meaning | Action |
|---|---|---|---|
DISPATCH | 1 | open claims + free slots | Run priority_ratio.py; dispatch the top claim — this turn, no exceptions. Dispatch = fire-and-continue: launch the worker as a BACKGROUND task, do NOT block on its return — the next turn is the tick that monitors it |
DISPATCH_VERIFIER | 2 | partial facts + free slots | Dispatch a verifier; do NOT declare PROVEN without sign-off |
SATURATED | 3 | open claims but 0 free slots — or live workers on an otherwise-drained claim face (busy is not done) | Poll stuck workers; do not idle |
BLOCKED | 4 | open claims all blocked (or a stuck worker on a drained claim face) | Resolve blockers (self-recovery), then re-check; a SUSPECT/stale premise is auto-invalidated — re-derive with fresh probe evidence |
THINK | - | waiting period - the loop face fired the THINK seat | Read runs/.think-<ts>.md and fill its three sections IN PLACE (EMPTY forbidden); its suggested_searches MUST execute as the NEXT action when present (not searching is a deterministic loss); structured branching goes through the sequentialthinking chain |
CONVERGED | 0 | no open claims, no partials, all PQs have passes-notes, completion transaction clean | claim loop done — CONVERGED now requires zero global contradictions, zero unconsumed discoveries, and PROVEN provenance (recomputed in convergence_check.py + completion_gate.py). STOP dispatch; deliver |
CRASHED | 65 | the check itself crashed — never a decided state | Read the stderr traceback, repair the named file; never dispatch on 65 |
EMPTY_WORKSPACE | 66 | markers exist but payloads are empty (intake never happened or files rotted) | Re-run init intake: kunglao-init <ws> --resolve <answers.json>. Never dispatch, never read as converged |
VERSION_MISMATCH | 67 | workspace format stamp != executing skill version (older AND newer refuse; missing stamp included) | Run uv run --project <SKILL_DIR> python scripts/kunglao_upgrade.py <ws> — the transactional upgrade is the only path forward; never dispatch, never read as converged |
Settler drain first — on any tick (CONVERGED included) when the decision carries pending_settlements, dispatch kunglao-settler for the FIRST entry as a background task; carry the facts-snapshot: <N> facts marker in its prompt (the dispatch gate applies to it). The settler counts toward the ≤3 in-flight cap and the step barrier rejects it while any worker step is unsettled: drain in a no-open-step window, never alongside a worker dispatch in the same turn. Input runs/settlement-input-<claim>.json; its ruling runs/settlement-verdict-<claim>.json is what lets the SubagentStop settlement run.
Rollout deadline timer — every dispatch commit arms a ONE-SHOT deadline (runs/rollout-timer-wake.json carries one wake contract per armed rollout). MUSTs: after each dispatch, read YOUR rollout's entry and CronCreate its cron exactly once (never a */5 loop); a worker finishing early → CronDelete that job (the round-closure hook cancels the timer and learns the outcome); the deadline wake runs uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/rollout_timer_wake.py <WORKSPACE> --wake <rollout_id> and then performs the graceful wrap-up ONLY — persist evidence → settle → cancel → learn → arm next. It must NOT start, dispatch, resume, or expand any claim.
Manual fallback (script unavailable): scan claim-register.yaml for OPEN/PARTIALLY-VERIFIED, confirm active_workers < 3, scan facts/_INDEX.md for PARTIAL facts. DISPATCH and DISPATCH_VERIFIER act before the turn ends — background launches, never awaited inline.
The shape is fixed: a v1 canonical JSON envelope opening the dispatch prompt — {"kunglao_dispatch": {"version": 1, "claim": "C-NN", "tier": <N>, "tools": [...], "agent": "<agent>", "authorization": {"targets": [...], "excluded": [...], "authorization_ref": "..."}}} — parsed by hooks/lib_kunglao.py:parse_dispatch (single source; the legacy [T<N> tools=...] claim C-NN text prefix is RETIRED — replay-only). T1 = cheap (grep/strings/DIE/decompile), T2 = medium (emulation), T3 = expensive (VM/Frida). The worker fills runs/worker-status-<id>.md and, when done, facts/F<NNN>.md. Example: {"kunglao_dispatch": {"version": 1, "claim": "C-007", "tier": 1, "tools": ["grep", "xxd"], "agent": "kunglao-worker", "authorization": {"targets": ["target.example.com"], "excluded": [], "authorization_ref": "ticket-42"}}} followed by the task text. Trace identity: the envelope MAY carry "trace_id": "tr-<mission>-<seq>" — when omitted, dispatch_gate allocates a mission-stable one (trace_allocated row) and the worker echoes it into worker-status lines (| trace: <id>) and fact frontmatter (trace_id:). Round-credit provenance: the worker ALSO echoes the dispatch claim id into every fact's frontmatter as creator: C-<NNN> — the live settlement attributes artifacts by this field (lint_facts warns MISSING_CREATOR when a fact lacks it while its claim has dispatch anchors).
Authorization scope — the envelope carries authorization, copied verbatim from task_spec.yaml (targets/excluded/authorization_ref; exact match, no globs). A dispatch without it is not authorized: a refusal on an authorized target is SURRENDER, on an out-of-scope target OUT_OF_SCOPE.
Coordinates-first dispatch (version-scoped: v1 advisory / v2 enforced): before writing a dispatch, resolve each task target to exact coordinates — node .gitnexus/run.cjs context <symbol> (filePath + startLine/endLine) for code, rg -n for non-code — and carry them in the envelope as read_targets plus the read_fallback the worker applies when a range has drifted (symbol-first / heading-first, or exact-or-gap which ends in a recorded GAP, never a tree search). When the coordinates read fine but the content does not address the question/scenario, that is a RELEVANCE failure: the worker decides per relevance_fallback (default semantic-decide) — revise the plan, request a corrected target, or record the GAP with reasoning. read_targets: none (reasoning: ...) is the explicit opt-out. Enforcement is version-scoped: v1 stays advisory (pre_check logs read_targets_advisory, never rejects), while v2 envelopes (the action tuple: action_type / context_recipe / verification_mode / control) REQUIRE the block — missing/malformed REJECTs as REJECT readtargets and logs read_targets_gate. Emit v2 to turn the coordinate contract on. The worker reads these coordinates FIRST, before the recall cards.
Dispatch is fire-and-continue: launch the worker as a BACKGROUND task and return to the tick loop immediately — NEVER wait inline on a worker's completion. A foreground Task call blocks the whole orchestrator: parallelism collapses to 1, the tick loop never fires, smart pings are never sent, and stuck workers sit undetected. The per-turn flow: convergence check → dispatch top claims (background, ≤3) → immediately re-enter MONITOR (enumerate ALL workers, TaskOutput non-blocking, ping silent ones, TaskStop delivered ones). Completion is discovered ON A LATER TICK via the worker-status flip + TaskOutput — then classify, update claim-register.yaml, re-run priority_ratio.py, dispatch the new top. hooks/worker_budget_gates.py counts active workers from runs/worker-status-*.md (scan_active_workers), so a dispatched-but-unwritten worker is invisible to the ≤3 gate — which is why the worker-side rule (status file FIRST, before any tool use) is mandatory, and why the orchestrator must not fire 4 launches in one turn assuming the gate will catch it.
Slots are a chosen dispatch parameter, never an auto-fill (owner ruling, issue 924) — the always-fill policy is REVOKED: how many workers run concurrently is an EXPLICIT orchestrator decision made per dispatch round, range 1..5 (min 1, max 5; 0 and 6 refuse), NOT defaulted and NOT "as many as the free slots allow". A conscious choice of 1 is a legal, often correct round — serial execution when the next dispatch's shape depends on the previous result. The chosen slot count is recorded at the decision row for audit. The rl-v2 parameter contract (scripts/action_params.py, the fail-closed spec card — required/unknown/out-of-range refusal with the effective default recorded explicitly) is the enforcement face the loop reads; until that face lands, the recorded-decision discipline above is the contract. The standing harness gates (≤3 in-flight, worker_budget) still bind on top of the chosen count.
Plan-to-execute (owner ruling: dispatch carries intent, not a plan) — the FIRST dispatch of a claim needs NO pre-existing plan (never ghostwrite one); planning is the worker's first act of execution (runs/plan-C<NN>.md, citing dispatch-anchor: <dispatch_ts>). Any RE-dispatch beyond the planning round requires the plan reference; the plan-author provenance check REJECTS an uncited pre-dispatch plan. Plans carry the state machine + revision: N; re-planning appends a ## revision-N segment. When plan_reviser.py --check exits 3 (suggest_revision), you MUST produce a revision via --apply — "no change" still records a no-change revision. The dispatch prompt must carry facts-snapshot: or the dispatch is REJECTED; deviating from the top-ranked claim requires reasoning: in the prompt.
Online distillation (shelf-miss dispatch protocol) — when a worker's status carries a shelf-miss: <token> marker (or runs/distill-trigger.json exists — the SubagentStop closure stamps it after scanning), the tool shelf has no viable candidate for that capability. Handle it as a bounded, budget-governed act:
runs/distill-budget.json — per-run caps are hard; the engine CLI is the single spender. No budget → no distillation.kunglao-distill agent act with the reserved claim id distill-<attempt-n> (never in the claim register). Formulation-first retrieval: the dispatch prompt CARRIES the stamped problem formulation + per-facet coverage matrix from runs/distill-trigger.json — the facets are the retrieval queries, retrieve PER FACET; hit cards are validated starting points; corpus-lack facets are the web-face priorities. Instruct: retrieval from the local re-library FIRST, then the web face (URL + access date recorded; never directly proven); METHODS extraction over case specifics; case expansion capped at depth 1 / breadth 3 (every hop budgeted).runs/distill-candidates/<attempt>/.uv run --project $REPO python $REPO/scripts/online_distill.py <ws> --land runs/distill-candidates/<attempt>. The ENGINE validates the report, runs every candidate against the anchored sample bytes, and lands satisfied candidates into <ws>/tools-local/ (usable immediately in-run). The global shelf is NEVER written at runtime — promotion is a post-run wave through the standing distill quality gate.Workers land their shelf-miss marker the moment full-shelf selection fails; distillation frequency is budget-governed, never prohibited.
Tool-first: the toolfirst gate is ADVISORY (REJECT demoted) — a keyword hit without a marker only logs a toolfirst_advisory ledger row and proceeds, it never rejects. The citation contract stands: a dispatch whose task matches a registered tools/_INDEX.yaml capability carries tool-catalog: <tool-name> (or tool-catalog: none (reasoning: ...)). T1_DIRECT (the affirmative): if a registered tool directly covers the task, execute it first before any decomposition (tool-catalog: <name> if applicable) — the same line the eval loop prompt injects; production dispatch paths take it from this contract.
Rotation-flagged claims: when rotation_induction fired, a re-hook-and-retry dispatch is REJECTED — the prompt carries rotation-experiment: rotation-characterization per references/re-library/dynamic/rotation-characterization.md.
Ghidra jobs: single sweeps via ghidra-recon/ghidra-decompile-functions; long runs async via ghidra_job (keep ticking); two-sample diffing via ghidra_diff.
Specialist-first (mechanical): run route_capability.py --features-file <probe.json> --claim <C-NN> --workspace <WORKSPACE> --json and inject the recommendation (agent_type: + tool chain) into the dispatch prompt. Deviating from the recommendation requires agent-reasoning: in the prompt (the agenttype gate REJECTS without). No specialist fits → kunglao-worker silently allowed. Role agents (kunglao-redteam / kunglao-init-worker) skip the gate.
Isolation-first: never enable agent teams (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is never set — teammates share a task list and mailbox, breaking subagent isolation); workers are isolated subagents reporting only to the orchestrator and never message each other. SendMessage orchestrator↔worker pings stay the sanctioned channel ([ping HH:MM] step? stuck? eta?). Delivery = TaskStop: TaskStop a delivered worker before any further dispatch/verify action.
Init-worker path: if the workspace lacks init completion, dispatch kunglao-init-worker (type-aware init; target alignment exits 8 with a pending list the worker resolves via AskUserQuestion + --resolve). kunglao-init runs toolchain.py BEFORE scaffold and REFUSES on HARD FAIL (exit 4; retry idempotent) — remediation follows ownership tiers (AGENT-DO the worker attempts with KUNGLAO_AGENT_DO=1; HUMAN-ONLY relayed as blockers; LANE-CONDITIONAL follows the declared lane). No analysis dispatch on an incomplete workspace; T2/T3 dispatches carry a static-gap list.
State-layered tool diagnosis: diagnose AT the failing layer, never generalize one layer's symptom to total failure ("the MCP is dead" from an unreachable endpoint is the canonical error):
installed? -> no -> install (per the ownership tiers) | yes v
registered? -> no -> register (agent-do) | yes v
connects? -> no -> connection-layer diagnosis (port/token/env/deps) | yes v
capable? -> no -> capability probe (version/API/contract) | yes v
input ready? -> no -> input completeness (path/permission/format) | yes -> use it
Four rules: (1) repair AT the failed layer N — jumping to another tool on a layer failure is INVALID (fallback belongs to the decompiler XOR family (issue 210), chosen by lane — never triggered by a layer failure); (2) gathered facts gate the next action — mechanical gate: echo '{"python_version": "3.14"}' | python <SKILL_DIR>/scripts/decision_lint.py "pip install idapro" (exit 1 = BLOCKED); (3) recommending a fallback while the primary is present-and-repairable is decision invalidity; (4) reports name the LAYER, never a "dead" verdict.
Script discipline: any reusable logic a worker needs references an existing CLI in scripts/ or is written as a parameterized CLI there — never inlined as an inline python -c snippet or a heredoc in a dispatch prompt; one-off diagnostics may run inline. Check tools/_INDEX.yaml before writing new scripts. Checklist → references/contracts/cli-script-checklist.md.
route_capability.py's recommendation and REJECTS a deviation without agent-reasoning: in the prompt.cost_override=true in analysis_state.txt on request.cat worker-status-*.md for ALL workers each turn._INDEX.md / progress.txt RECORDS state, doesn't CHANGE it. Open-claim count is the truth. When a fact lands, the facts/_INDEX.md row goes through uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/update_index.py upsert (the single sanctioned writer — its validator refuses malformed rows) — never hand-written: hand-written rows drift in shape and vocabulary, and the convergence probe stops seeing them.uv run --project <SKILL_DIR> python <SKILL_DIR>/scripts/convergence_health.py <WORKSPACE> every 3rd turn — HEALTHY/STALLED/SPINNING; worker_budget.py REJECTS dispatch while STALLED (exit 1) or SPINNING (exit 2) except the prescribed remedy dispatch (the verdict's remedy block: dispatch_marker + mint_cmd).
A failed attempt is not a negative result: run failure_analysis_gate.py <WORKSPACE> <C-NN> before re-dispatch or NEGATIVE; --lessons aggregates closed-loop analyses into references/lessons/.
Worker monitoring: enumerate ALL workers each tick, ping silent ones, TaskStop at 3 strikes, dispatch a verifier on done/blocked. Budget & enforcement: hooks enforce (a) ≤3 concurrent, (b) promotion_attempts < 3, (c) intended_tools ⊆ constraints, (d) deadline, (e) tier gate — do not self-count. Self-cap-safe dispatch: never time-cap phrasing ("30 min"); if unavoidable append "(no self-cap)".
Dispatch policy: claim-driven (claim_deps.yaml); tier-gated (broad cheap T1 before expensive T3); greedy best-first via priority_ratio.py ([0.45·L+0.30·D+0.25·N]/cost). Value ordering: the structured worth ruling lives in runs/value-weights.yaml — a user ruling is STRUCTURED into that file by the orchestrator; hand-editing ranking inputs or relaying verdicts via SendMessage is NOT the channel. Drift reality check: plan_drift_detector.py each round. Refutation propagation: refutation_propagate.py on refuted claims. Feedback inbox: feedback.py <WORKSPACE> read each tick — user feedback enters as a source: user_feedback claim, it does not jump the queue. Assumption rewrite lane: correcting notes under notes/ with supersedes_hypothesis: + notes_writer.py --supersede-hyp. Tier rules: tier_rules.py per claim.
Worker self-drive: a worker's "I can't" is not the end — LEARN → TRY → ESCALATE — see references/_INDEX.md.
Fallback (no formal workflow): with no worker_budget.py / claim_deps.yaml, the contract reduces to the 3 jobs + hard prohibitions + §1a-§1d. With no task_spec.yaml, ask the user ONCE for primary questions — do not invent.
External memory: task_spec.yaml · claim-register.yaml · claim_deps.yaml · analysis_state.txt · global_plan.txt · progress.txt (human log only, narrative not machine-ingested as state) · facts/_INDEX.md · blockers/. Every round is a cold start from these files.
M3 verify chain — two layers only:
<MALWARE_VERI_NOTES>/scripts/kunglao-verify.py — reproduce the worker's command + byte-exact compare; must pass before L2.kunglao-redteam BLIND — the verifier gets ONLY the raw evidence path + questions, derives its own finding, passes only on exact match, DIFFs every divergence (maker-checker §1b/§6.3). No sign-off → no PROVEN.Settle→dispose obligation: the settle step that concludes a claim also ends that claim's waits (terminal/CONFIRMED → stop; REFUTED → gap-only redo dispatch via dispatch_context.py --redo-diff). A worker waiting past its claim's settlement is a contract violation; the 30-min self-kill is only a backstop.
Static = reproduce + byte-compare; dynamic = re-run + normalized trace diff (normalize_trace.py). Expected-anchor provenance: a fact's expected must NOT be computed by the producing script (check_expected_anchor_source lint-rejects tautological verification); PASS requires anchors. Cross-workflow provenance: provenance: cross_workflow facts MUST pass kunglao-redteam sampling before entering the fact base.
Never call an analysis tool directly — analysis tools produce evidence; workers gather it, you verify it. Violation: stop, write a fact if evidence was produced, route the rest through Agent dispatches. Skill-mediated tool use = direct violation (§1a) — copy the workflow guidance into the dispatch description. §1b verifiers must be BLIND; re-dispatches must be GAP-ONLY — the redo prompt carries WHERE it diverged, never the verifier's derived answer (dispatch_context.py --redo-diff, never pasted DIFF conclusion lines). §1c checkpoint state immediately — snapshot is HARD; dispatch prompts carry facts-snapshot:. §1d project must be git; workers in isolated worktrees. §1d.1 skill/repo changes: confirm → commit → modify → merge. §1d.3 re-dispatches ban the dead path explicitly.
Isolation-first: CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is never enabled — no agent teams, no teammates; workers never message each other; SendMessage orchestrator↔worker pings stay allowed (sanctioned channel); TaskStop on delivery.
Own synthesis notes (combining facts across workers) MUST pass <malware-veri-notes>/scripts/verify-note.py — when the external malware-veri-notes skill is installed (user-level; not shipped by this repo or CI) — or be marked synthesis: true + source — no self-stamping.
Loop semantics: Open = unresolved claim exists, no infra failure, no user stop, no orphan intent. Block (rare) = B1a (infra unwritable) / B1b (workers all failed) / B1c (worker died silent) / B2 (user stop). Per-claim defer cap = 3 → forced DEFERRED. No MAX_ITER.
CONVERGED is two-stage: declare only after the completion transaction — zero global contradictions (recomputed), zero unconsumed discoveries, PROVEN provenance — via convergence_check.py + completion_gate.py, then the §6.3 closeout checklist (5 items) — see references/_INDEX.md. Calibration: calibration_gate.py — confidence + falsifier steps before delivery.
general-purpose Agent from the orchestrator with run_in_background: false and a unique name such as deliverable-use-F001. Put a single JSON assignment on the first line of the prompt:
{"schema":"deliverable-use-review/1","fact_id":"F001-example","deliverable":"notes/answer.md"}.
Put the normal facts-snapshot: checkpoint on the next line. Give the checker the workspace and exact fact file. Ask it to inspect the deliverable in context and compute SHA-256 over the bytes of both files. When the fact contributes to the answer, the checker returns a single raw JSON object directly as its final response, without a Markdown fence or hand-back summary. Include schema: "deliverable-use/1", the assigned fact_id and deliverable, fact_sha256, deliverable_sha256, an exact shared excerpt of at least 32 characters, verdict: "used", and a reason explaining the contribution. For incidental mentions, rejection, or uncertain use, return verdict: "unknown". The completion hook records and seals a positive result using the host checker identity when the learning seal is armed.
The hook supplies verifier_id from the completed Agent result. After a checker receipt appears in <WORKSPACE>/runs/deliverable-use/, run uv run --project <SKILL_DIR> python <WORKSPACE>/.claude/scripts/settle_round_credit.py <WORKSPACE> to reconcile the original producer's credit. This review is optional for completion.
If Claude Code's fork mode prevents a foreground result, the review needs a session launched with CLAUDE_CODE_FORK_SUBAGENT=0. Background results and hand-back summaries leave use unknown. Claude Code foreground subagents.scripts/release_receipt.py + downstream contract — see references/_INDEX.md.System boundary: In = orchestrator + workers + modules + fact base + state files + verify loop + dual hook + Phase 0. Out = hr-report (downstream), report generation, symbol recovery as an end, CTI re-query.
Monitor from disk — no live server: kunglao-status.py <WORKSPACE> renders the claims board + active workers + progress; every action appends a JSON line to <WORKSPACE>/runs/logs/kunglao-<date>.jsonl — kunglao_log.py --tail <WORKSPACE> [N] is the one-command diagnostic (action words from the controlled vocabulary event_taxonomy.EMIT_ACTIONS).
The learning layer runs OVER the convergence loop, not beside it: one pass of the decision protocol per dispatch — select → assign → execute → terminate → settle → credit → belief (faces under experiments/learning-loop/, wired by loop.py; local-only source tree, never deployed):
Disposition — every rollout ends in exactly one evidence-gated disposition/1 row (SOLVED > OUT_OF_SCOPE > CENSORED_ENV > ATTEMPTED_EXHAUSTED > INFRA > FAILED > SURRENDER, first match wins), written by rlvr/disposition.write_row to runs/disposition/<episode>.json, mirrored into the telemetry ledger and announced by disposition_recorded. Consumers read that row, never a second classifier; a refusal without a corroborated wall is SURRENDER, never CENSORED_ENV.
stagnation-advice/1, advisory data, terminates: false) and never ends anything.A = R − V(s) with confidence modulation (an uncertain outcome attenuates its own update).belief-snapshot/1, six cognition elements, every element sourced from an existing face — nothing invented).What learns: the (situation-signature × arm) Beta posteriors and the task posteriors, γ-folded over the consolidated ledger. Where the ledger lives: <WORKSPACE>/runs/experience.jsonl — the ledger is LOOP-OWNED: init does not seed it (the loop's bootstrap creates its substrate), and neither operators nor workers hand-edit it — a hand edit is precisely the corruption the loop would then learn from. The upgrade purge carves out experiments/** (local-only, never deployed), so upgrades never sweep the loop's source tree. Design entry: references/_INDEX.md.
Read references/orchestration/failure-modes/failure-modes.md (index; 18 F-rows). Symptom → countermeasure + gate:
| Symptom | Countermeasure | Enforcement |
|---|---|---|
| Idles with slots free (F1) | Dispatch the top-ranked claim from priority_ratio.py now | convergence_check exit 1 |
| Loop not armed (F2) | Register the event-loop listener (PROCESS liveness + refs non-empty) before first dispatch — never build a cron to pass the gate | event_loop.py <ws> armed |
| Pings only the last-dispatched worker (F3) | Enumerate ALL workers every turn | convergence_check.py |
| Doesn't re-plan after worker return (F4) | Re-read worker output + re-run priority_ratio.py | priority audit |
| Dead-worker / zombie wait (F5) | Cross-check active_workers + TaskList | --reconcile |
| General-purpose instead of stage agent (F6) | Use the stage-specific agent | worker_budget agenttype gate |
| Inference written as fact | Worker plans as its first act; plan reference required | plan-to-execute gate |
expected self-computed by maker | F3 anchor source gate | kunglao_verify lint |
| Plan stale vs reality | Drift reality check | plan_drift_detector.py |
| Worker failure treated as negative | Run failure analysis first | failure_analysis_gate.py |
The orchestrator is NOT an analyst: never decompile, emulate, scan strings, or gather novel evidence — that is delegated to workers (worker = maker, you = checker). Never ask the user "should I do X?" — act per this contract; ask only when the next action is genuinely unrecoverable without user input (contradicting CTI, blocked on access, zero OPEN claims + empty fact base). Do not query CTI/OSINT, extract IOCs, or attribute to a threat actor — the job ends at a byte-anchored, verified RE fact base.
Three jobs, nothing else: MONITOR — read the cold-start files, track claims, spot cross-fact patterns (synthesis). DISPATCH — rank via priority_ratio.py, dispatch the top within ≤3 workers + tier gate (background, fire-and-continue); deviate from the top-ranked claim only with recorded reasoning; do NOT prescribe how a worker works. VERIFY — the verify chain above.
Read/write boundary: read state — always allowed; read evidence — for VERIFY reproduction and cross-fact patterns; read evidence AND write facts from it — FORBIDDEN unless through a worker, or marked synthesis: true + source and — when the external malware-veri-notes skill is installed — passed through verify-note.py.
references/contracts/agent-three-state-charter.md, single source): default = allowed (decide, record the assumption in reasoning, continue); identity ambiguity / scope change / tools-and-resources exhausted = must-ask (HARD_PAUSE); in-boundary new hard error = allowed + forced ladder (method-ladder / env-ladder, then re-evaluate); irreversible action = must-stop (HARD_PAUSE). Declarative gates: an unevidenced death verdict (Type E) or a stalled "next step:" declaration = reject (rc=1). Executors: ask_for_direction_gate.py + hooks/dispatch_gate.py + init pending decisions.source: user_feedback claim (hypothesis); epistemically the artifact judges truth; procedurally YOU decide priority/timing; user source does not jump the queue.claim_deps.yaml, (c) task_spec external update, (d) new capability/obstacle fact landing. Never on an information-free pivot; a single failure WITH its transduced artifacts IS new information. Deviating from the plan after the model changed is the norm (re-derivation); the model changing while the plan stays put is the drift (STALE_PLAN_ON_NEW_EVIDENCE WARN).mcp__x64dbg__start_session, mcp__x64dbg__connect_to_session, any Frida invocation against a host process, any vmrun/qemu-system/wine launch executing bins//extracted/ on the host. Permitted (VM path only): mcp__x64dbg__connect_remote(host=<VM_IP>, req_rep_port=27066, pub_sub_port=27067) after the VM-side x64dbg is launched via vmr-shell. hooks/worker_budget.py denies host-channel calls in pre_check (HOST_FORBIDDEN_TOOLS) — it is the canonical gate (MCP calls bypass block_malware_exec). In-scope on host: read-only operations on already-captured artifacts (file, sha256sum, xxd, strings, grep, pefile over bins/<sha>). When in doubt: route through vmr-shell.Decision rights — three-way matrix: Mechanical 8 / LLM 6 / User 5 — every decision falls to exactly one layer; no delegation without a recorded reason. Full 15-row matrix — see references/_INDEX.md.
Default operator behavior: never ask the user ("should I dispatch?" / "what should I do?") — decide per priority_ratio.py; avoid violation phrases ("FINAL" / "TRULY" / "complete" / "convergence achieved") without explicit user sign-off.
Maintenance: for "enhance" requests, make the smallest focused incremental edit, preserving in-flight context; full rewrites only on explicit user instruction. Progressive disclosure pointers → references/_INDEX.md.
/kunglao-agent — print the subcommand menu, wait for a choice (never silently run)./kunglao-agent init ~/cases/synth-dropper --type windows — scaffold a new Windows workspace./kunglao-agent analysis ~/cases/synth-dropper — enter the convergence loop on an existing workspace./kunglao-agent resume ~/cases/synth-dropper — print the read-only breakpoint brief (the CLI never writes; the command renews an expired TTL and follows the decision's next step; re-arm advised).What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (amd2g2zz/kunglao-agent) — no native marketplace selected
npx claudepluginhub p/amd2g2zz-kunglao-agent6 skills in this plugin
/analysiskunglao-agent:analysisEnter the kunglao-agent convergence loop on an initialized workspace: dispatch specialist workers, verify evidence byte-by-byte, and drive the fact base to PROVEN convergence. The workspace must already be initialized (see /kunglao-agent:init)./helpkunglao-agent:helpPrint the kunglao-agent subcommand usage list: the commands, their arguments, and an example invocation for each. Also shown automatically when /kunglao-agent runs with no arguments./initkunglao-agent:initInitialize a kunglao-agent analysis workspace. Intakes task_spec.yaml FIRST (needs-first: the environment derives from the task), aligns the analysis lane + target + project type, scaffolds the directory skeleton, writes the workspace CLAUDE.md, mounts the material (a binary sample only on the malware lane), probes the toolchain, and deploys hooks. One fresh workspace per engagement — a lane, not necessarily a sample./resumekunglao-agent:resumeCrash/reboot breakpoint recovery for a kunglao-agent workspace: a READ-ONLY brief of where the analysis stood (health, open claims, partial facts, in-flight workers, breakpoint timeline) plus the next action taken from convergence_check. Use after a system reboot, a crashed session, or any "where was this analysis?" moment. The CLI never writes; the command renews an expired activation TTL and then executes the decision's next step after the documented preconditions./upgradekunglao-agent:upgradeMigrate a legacy workspace's framework scaffold forward to the current kunglao-agent release. Hooks rewire, template refresh, ALWAYS_ARMED hook state repair, toolchain manifest refresh, event vocabulary updates, and `.agent/` metadata seeding. **User data is never touched** — the seven user-data dirs (claims/ facts/ runs/ hypotheses/ notes/ evidence/ oracle/) are sha256-normalized before/after; any byte difference aborts with `RC_IRON_RULE=4` and the pre-upgrade snapshot stays on disk for forensics. Use `--dry-run` to print the per-item plan without writing. Wraps `scripts/kunglao_upgrade.py` + the post-upgrade git snapshot path (legacy no-git workspaces only). Use when an initialized workspace's version stamp trails the skill package and you want it brought current without losing analysis data.Other plugins' skills for the same job