Yesresearch

From carsteneu/yesmem · View interactive version

Yesresearch is an AI agent skill from the GitHub repository carsteneu/yesmem. Autonomous research loop — read plan, decompose, dispatch research agents, integrate, deliver wiki. For research tasks instead of coding. Runs as visible TUI agents in git worktree. Use when user says "yesresearch", "research <topic>", "recherchiere <thema>". Spawns cluster agents that use opencode

How to use this skill

Skill file

Autonomous Research Loop

You are an orchestrator for autonomous research. Decompose a research topic into clusters, spawn parallel research agents, integrate results into a cited wiki.

CRITICAL: Two-Tier Architecture

You are the Orchestrator (this session). You do NOT do research yourself. You spawn Bereichs-Agents (cluster agents) that do the actual research work. Each Bereichs-Agent runs autonomously in its own worktree and reports progress via scratchpad.

Orchestrator (this session, light)
  │
  ├─ READ master-plan (##  headings = clusters)
  ├─ DECOMPOSE into 5-8 file groups
  ├─ DISPATCH yesmem_spawn_agent × ≤6 (opencode TUI agents)
  ├─ MONITOR list_agents + scratchpad polling
  ├─ INTEGRATE cross-links + INDEX.md + citation audit
  ├─ DAEMON-VERIFY yesmem verify-claims, verdict accepted
  └─ DELIVER commit + DONE
            │
            ▼ yesmem_spawn_agent (TUI; 12h and 6 concurrent are orchestrator conventions, not daemon limits)
            │
   Bereichs-Agent (full TUI, autonomous)
     ├─ CONTEXT read master plan + cluster files
     ├─ PLAN set_plan, per-file strategy
     ├─ EXECUTE task(general) fetch+search+write
     │         task(explore) read-only citation review
     │         bash+curl+pdftotext for PDFs
     ├─ VERIFY min 2 sources/file, every claim cited
     ├─ COMMIT write files to worktree
     ├─ DAEMON-VERIFY yesmem verify-claims, verdict accepted
     └─ DELIVER scratchpad DONE + send_to orchestrator

Why two-tier: Sawtooth would compress the master plan if one agent did everything. Cluster-scope agents keep context small. Plan lives in DB (scratchpad + set_plan), survives collapse.

CRITICAL: Always spawn in a worktree

When invoked from an interactive session, the user's session only does setup — it does NOT run the orchestrator pipeline inline. Setup creates the worktree, writes the master plan + scratchpad briefing, then spawns the Orchestrator as a TUI agent which takes over all 7 phases.

Setup steps (user's interactive session):

  1. Create worktree: git worktree add -b yesresearch/<topic-slug> <repo>/.worktrees/yesresearch-<topic-slug> (fresh-create) OR git worktree add -b yesresearch/<topic-slug>-update-N <repo>/.worktrees/yesresearch-<topic-slug>-update-N (update mode, branching from previous wiki commit)
  2. Write master plan to <worktree>/yesdocs/<topic>/PLAN.md (or pass existing path)
  3. Detect model & backend: Read ~/.config/opencode/opencode.json → extract model key (e.g. deepseek/deepseek-reasoner). If absent, detect from opencode's default (first entry in models.json). Backend defaults to "opencode" — override via scratchpad briefing backend: claude|codex|opencode or master plan frontmatter. Both model and backend are passed to ALL spawns (Orchestrator + Bereichs-Agents).
  4. Write Orchestrator briefing to scratchpad section yesresearch-<topic-slug>-orchestrator: worktree path, master plan path, output target, hard constraints, resolved model, mode (fresh-create or update). The briefing MUST start with the skill-read mandate: YOU ARE A YESRESEARCH-ORCHESTRATOR. MANDATORY - YOU MUST READ THE YESRESEARCH SKILL AND YOU MUST FOLLOW THE INSTRUCTIONS IN THIS SKILL. The spawned Orchestrator has NOT auto-loaded this skill — the mandate prefix is mandatory.
  5. Spawn Orchestrator: yesmem_spawn_agent(project="<project>", section="yesresearch-<topic-slug>-orchestrator", backend="<resolved-backend>", work_dir="<worktree-path>", model="<resolved-model>")
  6. Wait 15s, then relay kick: yesmem_relay_agent(to="<orchestrator-id>", content="Read scratchpad section yesresearch-<topic-slug>-orchestrator AND load the yesresearch skill (skill tool or ~/.claude/skills/yesresearch/SKILL.md). MANDATORY - YOU MUST READ THE YESRESEARCH SKILL AND YOU MUST FOLLOW THE INSTRUCTIONS IN THIS SKILL. Begin Orchestrator Phase 1 READ.") — backup if PTY is slow
  7. User's session polls list_agents + scratchpad_read until Orchestrator reports DONE.

Only run inline if: the user EXPLICITLY says --inline. There is NO trivial-task exception — "< 5 min" is not a license to skip the worktree and orchestrator pipeline.

Model & Backend Configuration

Nothing is hardcoded. Both model and backend are configurable via scratchpad briefing, master plan frontmatter, or auto-detected from the environment. Resolution order (first match wins):

  1. Scratchpad briefing model: / backend: fields (highest priority — per-run override)
  2. Master plan frontmatter default_model: / default_backend: (per-topic default)
  3. Auto-detection — model: read from ~/.config/opencode/opencode.json → model key; backend: defaults to "opencode"

How to detect (user's session, step 3 of setup):

# Extract the default model from opencode's config
MODEL=$(python3 -c "import json; print(json.load(open('$HOME/.config/opencode/opencode.json')).get('model',''))")
# If empty, opencode uses models.json first-entry
if [ -z "$MODEL" ]; then
  MODEL=$(python3 -c "import json; d=json.load(open('$HOME/.cache/opencode/models.json')); print(list(d.keys())[0] + '/' + list(d[list(d.keys())[0]]['models'].keys())[0])")
fi

Why no daemon default: The daemon returns "" when model is empty — same as all other backends. Opencode picks from its own config. The skill bridges this by detecting and passing the model explicitly.

Example master plan frontmatter (override):

---
default_model: zai-coding-plan/glm-5.2
default_max_runtime: 1h
update_age_days: 60
---

Example scratchpad briefing override:

model: zai/deepseek-chat

Model selection rules (MANDATORY once model is chosen)

Correct model strings:

WRONG — do not use:

Why slash-qualified works: resolveSpawnModel() in internal/daemon/spawn_model.go:38-42 looks up bare names against a providerMap that excludes coding variants. Slash-qualified strings pass through verbatim (line 35-36), so the full provider/model reaches opencode's --model flag directly. Opencode's auto-discovery (from ~/.cache/opencode/models.json) then routes to the correct endpoint URL.

Other configurable defaults

| Parameter | Default | Override via |

|---|---|---|

| max_runtime per Bereichs-Agent | 2h (orchestrator convention) | master plan default_max_runtime; the daemon's max_runtime is a GLOBAL config value (set_config), not a spawn parameter |

| max_concurrent_agents | 6 (cap: 8) | master plan max_concurrent_agents |

| min_sources_per_file | 2 | master plan min_sources_per_file |

| update_age_days (UPDATE MODE) | 90 | master plan update_age_days |

| saturation_limit (empty searches per file) | 3 | master plan saturation_limit |

Master plan frontmatter is the single source of truth for per-topic configuration. Scratchpad briefing overrides for per-run adjustments.

max_runtime

The daemon's max_runtime is a global config value, not a spawn parameter: yesmem_spawn_agent does not accept it, and a call that passes it is silently ignored. It bounds every agent equally (config.yaml, or set_config("agents.max_runtime", "2h"); a new value takes effect on the next daemon start, there is no hot reload). Empty means the daemon default of 48h. For a per-agent ceiling at spawn time use token_budget or max_turns. To end one research agent early, relay it to wrap up and stop it.

The 2h per Bereichs-Agent below is an orchestrator convention, not an enforced limit: it defines when the orchestrator expects a cluster to be done and how long it waits before intervening. An agent that needs longer gets a relay to continue. The absolute ceiling this skill asks the orchestrator to enforce is 12h per agent (dispatch a fresh batch beyond that), independent of the daemon's global limit.

Orchestrator Contract (what to prescribe vs. delegate)

The Orchestrator is itself a spawned agent — invoked via /yesresearch <topic>, it spawns itself as a TUI agent via yesmem_spawn_agent and that agent runs the 6-phase pipeline below. The user's interactive session only creates the worktree + scratchpad + spawns the Orchestrator agent. From there the Orchestrator owns all downstream work.

Prescribe (orchestrator's job):

Delegate (Bereichs-Agent's job):

Calibration test: Before writing the scratchpad, ask: "If the agent came back with the files, would I be surprised by the content?" If yes (wrong sources, wrong language, wrong depth), prescribe more. If bored (matches what you'd write), delegate more.

Temp file discipline

NEVER write to /tmp/ or ~/.claude/yesmem/tmp/ in autonomous operations. Use <worktree>/.yesmem/tmp/ instead. mkdir -p .yesmem/tmp at session start.

Concurrency: File Locking & Git Mutex

Multiple Bereichs-Agents share one worktree. Without coordination, two failure classes emerge: git index.lock races and silent Edit-overwrites. Both are solved with simple filesystem locks.

File lock protocol (per-file mutation safety)

MANDATORY before any Edit on existing file:

LOCKDIR=".yesmem/locks"
mkdir -p "$LOCKDIR"
LOCKFILE="$LOCKDIR/<file-slug>.lock"

# Try to acquire lock (atomic — only one writer wins)
if ! ( set -o noclobber; echo "$AGENT_ID $(date -Is)" > "$LOCKFILE" ) 2>/dev/null; then
  # Lock held by another agent — wait up to 5 min, then fail-fast
  for i in $(seq 1 60); do
    sleep 5
    if ( set -o noclobber; echo "$AGENT_ID $(date -Is)" > "$LOCKFILE" ) 2>/dev/null; then
      break
    fi
    if [ $i -eq 60 ]; then
      echo "LOCK_TIMEOUT: $LOCKFILE held >5min, aborting edit on <file>"
      exit 1
    fi
  done
fi

# CRITICAL: Read file AFTER acquiring lock, not before
Read "<file>"

# ... perform Edit ...

# Release lock
rm -f "$LOCKFILE"

This guarantees: 1 file → 1 writer at a time, even if multiple Bereichs-Agents target the same file (e.g. UPDATE MODE: Agent A does add_visuals, Agent B does refresh_sources on same file). Second writer waits, then sees A's changes, then builds on them.

Lock dir cleanup: Orchestrator in DELIVER removes stale locks (>2h old) from .yesmem/locks/.

Git index mutex (commit serialization)

Git's index.lock lives at .git/worktrees/<name>/index.lock — shared across ALL agents in the worktree. Concurrent git commit → index.lock existiert bereits error .

Commit mutex (MANDATORY for all Bereichs-Agents):

GIT_LOCK=".yesmem/locks/git-commit.lock"

acquire_git_lock() {
  for i in $(seq 1 120); do
    if ( set -o noclobber; echo "$AGENT_ID $(date -Is)" > "$GIT_LOCK" ) 2>/dev/null; then
      return 0
    fi
    sleep 5
  done
  echo "GIT_LOCK_TIMEOUT: held >10min, aborting commit"
  return 1
}

# Before commit:
acquire_git_lock || exit 1
git add <files>
git commit -m "..."
EXIT_CODE=$?
rm -f "$GIT_LOCK"
exit $EXIT_CODE

This serializes commits. Slow (one at a time) but reliable. Bereichs-Agent retries on lock failure instead of crashing.

Mutation contract for UPDATE MODE (scoped to action)

| Action | May Read | May Write | May Delete |

|---|---|---|---|

| add_visuals | existing prose | new assets/*, new ![...](...) + caption blocks | nothing |

| add_mermaid | existing prose | new `mermaid block at section | nothing |

| run_persona_review | full file | append to frontmatter persona_review only | nothing |

| refresh_sources | existing citations | append new citations to existing bibliography list | never (broken 404 citations stay as history) |

| verify_status | frontmatter | frontmatter status field only | nothing |

| expand_content | full file | append new sections at end | nothing |

NEVER use Write on existing files. Write overwrites; Edit mutates. Lock + Read + Edit is the only safe path. Use Write only for new files (no lock needed — file doesn't exist yet, no collision possible).

Orchestrator frontmatter-union (INTEGRATE phase)

After all Bereichs-Agents complete, the Orchestrator merges frontmatter across files for cross-links and tags. Union, not overwrite (#3 fix):

For each file's frontmatter, read tags and related arrays. Build a union per file:

Write the merged frontmatter back via Read+Edit. One pass over all files in INTEGRATE.

Temp file discipline (original)

NEVER write to /tmp/ or ~/.claude/yesmem/tmp/ in autonomous operations. Use <worktree>/.yesmem/tmp/ instead. mkdir -p .yesmem/tmp at session start.

Execution Modes

tui-agent (DEFAULT) — Bereichs-Agents spawned via yesmem_spawn_agent → gnome-terminal, visible, non-blocking.

inline — User explicitly requested inline. Run in current context.

scheduled — User asked for recurring research. Use yesmem_schedule.

Definition of DONE

DONE is a contract. A Bereichs-Agent is DONE only when ALL seven phase sections exist in its scratchpad section AND each carries **Status:** COMPLETE.

Valid Status values per phase:

Phase status update mandatory at every transition:

update_agent_status(phase="Phase N/7 NAME")
update_agent_status(phase="Phase N/7 NAME (file M/K)")
update_agent_status(phase="Phase N/7 NAME (blocked: <why>)")

SCRATCHPAD DISCIPLINE (MANDATORY — prevents briefing clobber):

scratchpad_write is an UPSERT — it REPLACES the entire section. Use the RIGHT tool:

| Tool | When to use | Who calls it |

|---|---|---|

| scratchpad_write | Write/replace FULL section content (briefing, DONE report) | Orchestrator only (setup), Bereichs-Agent Phase 5+6 DONE report |

| scratchpad_append | Append progress update, phase result, partial status | Bereichs-Agent, ALL phases (EXCEPT when writing full Phase blocks) |

| scratchpad_read | Read current section content | Any time |

MANDATORY rule: The FIRST tool call after spawn MUST be scratchpad_read. Never call scratchpad_write before scratchpad_read — it will overwrite the orchestrator's briefing with your status text (#80063).

For Bereichs-Agents reporting phase progress:

For Orchestrator:

Orchestrator validates DONE:

Der Prüfbericht (`<section>-verify`)

Die Phasenblöcke sind die Form, der Bericht ist die Behauptung. Der Daemon leitet jede

Behauptung selbst her und glaubt keinem Bericht. Lege deshalb neben dem Pipeline-Abschnitt

den Abschnitt <section>-verify an. Ohne ihn ist nichts zu prüfen und DONE blockiert.

[COMMIT: <vollständiger Hash>]
[BRANCH: <Branch, der gepusht wurde>]
[DEPLOY: yes|no]
Tests run: <Befehl> -> exit <N>
Files in scope: <pfad>, <pfad>
[EVIDENCE: cold-review=ses_…, consequence=ses_…, security=ses_…]
[PLAN: <projekt>]

Regeln:

Testsummarium. Ein Exit-Code allein zählt nicht.

einer grünen Suite, die es nicht gibt.

Der Daemon prüft den Bericht nicht mehr selbst. Er liest ein Urteil, das vor der

DONE-Meldung entstand: yesmem verify-claims mit `--profile yesloop-done --policy

yesloop-done --strict` (Section, Report-Session und Plan-Thread wie in der yesloop-Skill).

Exit 0 heißt accepted, dann setzt du das DONE ab; Exit 1 heißt blocked, dann

korrigierst du und prüfst erneut. Ein DONE ohne frisches Urteil blockt der Daemon als

Defekt und druckt den vollständigen Befehl. Danach meldet er DONE-VERIFIED oder

DONE-VERIFY-BLOCKED mit einer Findings-Tabelle.

DONE-Gate Hardening (Section 11)

Bereichs-Agent DONE-claims fail the gate when ANY of these deterministic checks fail. Orchestrator INTEGRATE runs all checks before accepting DONE.

Per-File Checks (Orchestrator INTEGRATE, after all Bereichs-Agents DONE)

| # | Check | Detection Regex/Pattern | Failure Action |

|---|---|---|---|

| F1 | Frontmatter exists + valid YAML | ^---\n[\s\S]*?\n---\n at file start | Reject file, dispatch fix |

| F2 | Frontmatter has required fields | topic, cluster, status, last_updated, sources_count, language all present | Dispatch fix |

| F3 | sources_count ≥ min_sources_per_file | YAML parse sources_count ≥ config | Mark partial |

| F4 | Every factual claim has inline citation | Grep \[[^\]]+\]\(https?://[^)]+,\s*\d{4}-\d{2}-\d{2}\) — count per paragraph | Dispatch fix |

| F5 | persona_review frontmatter block exists (UPDATE MODE) | persona_review:\s*\n\s+personas_tested: regex | Re-dispatch VERIFY |

| F6 | persona_review.gaps_fixed ≥ gaps_found | YAML compare | Mark partial |

| F7 | No Write-style wholesale replacement in git log (UPDATE MODE) | git show --stat each commit, flag commits with >90% line change on existing files | Reject commit, dispatch fix |

| F8 | images_count > 0 OR documented skip per MANDATORY source type | frontmatter images_count or scratchpad skip list | Mark partial if missing + undocumented |

Wiki-Wide Checks (Orchestrator INTEGRATE, before DELIVER)

| # | Check | Detection | Failure Action |

|---|---|---|---|

| W1 | INDEX.md exists | ls INDEX.md exit 0 | Dispatch INTEGRATE-Subtask |

| W2 | INDEX.md contains Mermaid block | grep `mermaid in INDEX.md | Dispatch INTEGRATE-Subtask |

| W3 | INDEX.md Mermaid ≥1 subgraph | grep subgraph in Mermaid block | Dispatch fix |

| W4 | INDEX.md Mermaid ≥3 edges | grep - or = connections in Mermaid block, count ≥3 | Dispatch fix |

| W5 | BIBLIOGRAPHY.md exists | ls 99-sources/bibliography.md exit 0 | Generate from scratch |

| W6 | Bibliography in UPDATE MODE preserves existing entries | git diff old vs new bibliography — old entries must all be present | Re-do read-merge-write |

| W7 | No broken git index.lock files in worktree | ls .yesmem/locks/*.lock empty after DELIVER | Manual cleanup |

| W8 | Frontmatter Union applied (UPDATE MODE) | spot-check: tags from prior version preserved in ≥80% of files | Re-do INTEGRATE frontmatter-merge |

| W9 | No concurrent Bereichs-Agents exceeded cap | list_agents(project) and count the rows with status == "running" client-side (the tool takes only project); historical max ≤ cap | Log warning |

| W10 | All Bereichs-Agent scratchpad DONE blocks complete | Each has ### Phase 1 through ### Phase 7 + all **Status:** COMPLETE | Re-dispatch incomplete Bereichs-Agents |

Orchestrator Self-Checks (before DELIVER complete)

| # | Check | Detection | Failure Action |

|---|---|---|---|

| O1 | Orchestrator plan persisted | get_plan() returns non-empty with mode flag | Restore from scratchpad |

| O2 | All clusters either DONE or explicitly aborted | plan state shows terminal status per cluster | Dispatch missing |

| O3 | No orphan locks >2h old | find .yesmem/locks -mmin +120 empty | Cleanup |

| O4 | send_to caller_session sent | scratchpad has send_to orchestrator: line | Send |

Rejection Protocol

When a check fails:

  1. Orchestrator marks affected file/section as partial in INDEX.md
  2. Dispatches fix task to Bereichs-Agent: task(general, "Fix failing check <ID> on <file>: <details>")
  3. Re-runs check after fix
  4. Max 5 fix cycles per check — after that, file stays partial and user is notified via send_to

Validation Snippet (Bash, used by Orchestrator)

# Run all per-file checks for one file
validate_file() {
  local FILE="$1"
  local FAILS=0

  # F1: Frontmatter exists
  head -1 "$FILE" | grep -q '^---$' || { echo "F1 FAIL: $FILE"; FAILS=$((FAILS+1)); }

  # F2: Required fields
  for field in topic cluster status last_updated sources_count language; do
    grep -q "^${field}:" "$FILE" || { echo "F2 FAIL: $FILE missing $field"; FAILS=$((FAILS+1)); }
  done

  # F3: sources_count ≥ 2 (default min)
  SOURCES=$(awk -F': ' '/^sources_count:/ {print $2}' "$FILE")
  [ "${SOURCES:-0}" -ge 2 ] || { echo "F3 FAIL: $FILE sources_count=$SOURCES"; FAILS=$((FAILS+1)); }

  # F4: Every paragraph has at least 1 citation (rough heuristic)
  CITES=$(grep -cE '\[[^]]+\]\(https?://[^)]+,\s*[0-9]{4}-[0-9]{2}-[0-9]{2}\)' "$FILE")
  [ "$CITES" -ge 2 ] || { echo "F4 FAIL: $FILE only $CITES citations"; FAILS=$((FAILS+1)); }

  return $FAILS
}

# Wiki-wide W2-W4
validate_index_mermaid() {
  local INDEX="yesdocs/<topic>/wiki/INDEX.md"
  awk '/```mermaid/,/^```$/' "$INDEX" > /tmp/mermaid-block.txt
  grep -q 'subgraph' /tmp/mermaid-block.txt || echo "W3 FAIL: no subgraph"
  EDGES=$(grep -cE '(-|=.*>)' /tmp/mermaid-block.txt)
  [ "$EDGES" -ge 3 ] || echo "W4 FAIL: only $EDGES edges"
}

This mirrors the deterministic DONE-Guard pattern from yesloop — no LLM judgment involved in validation, pure regex/parseable checks.

Orchestrator Phase Pipeline

Phase 1/7: READ

update_agent_status(phase="Phase 1/7 READ")

```

wiki_exists = (yesdocs/<topic>/wiki/ contains ≥1 .md file)

mode_flag = scratchpad briefing "mode:" field // "update" | "force-fresh" | unset

if NOT wiki_exists:

MODE = FRESH // no existing wiki, build from scratch

elif wiki_exists AND mode_flag == "force-fresh":

MODE = FRESH // overwrite — user accepts data loss

elif wiki_exists AND mode_flag == "update":

MODE = UPDATE // delta-only extension

elif wiki_exists AND mode_flag unset:

// AMBIGUOUS — refuse to guess, ask user

send_to caller_session: "AMBIGUITY: wiki exists at yesdocs/<topic>/wiki/.

Use --update to extend or --force-fresh to overwrite. Current state: <file count> files."

WAIT for user decision (poll check_messages every 5 min)

On user reply: re-evaluate decision tree with new mode_flag

else:

MODE = FRESH // defensive default (shouldn't reach)

```

Hard rules:

UPDATE MODE — Delta Scan delegated to task(explore) per cluster:

Delta-Scan is expensive (7 conditions × N files, including websearches). Orchestrator does NOT do it inline — would bloat context and trigger Sawtooth.

Instead: dispatch one task(explore) per cluster with prompt:

"Scan cluster '<name>' at yesdocs/<topic>/wiki/<cluster-slug>/. For each .md file:
1. Read frontmatter
2. Check: images_count=0/missing? 3+ entities but no ```mermaid block? persona_review missing or gaps_found>gaps_fixed? last_updated > <update_age_days>d ago? status=Entwurf? sources_count < <min_sources>?
3. Run websearch for '<file-topic>' — any new sources not in existing citations?
Return JSON: [{file, reasons: [list], suggested_actions: [add_visuals|add_mermaid|run_persona_review|refresh_sources|verify_status|expand_content]}]"

Parallel task(explore) calls (one per cluster) complete in ~2-5 min. Orchestrator collects results, builds delta-plan.

A file is update-worthy if ANY of:

Delta-plan output: list of {file, reason, action} tuples.

Files not update-worthy stay untouched. This is delta-only — avoid the "rebuild all on every tick" anti-pattern .

Phase 2/7: DECOMPOSE

update_agent_status(phase="Phase 2/7 DECOMPOSE")

Phase 3/7: DISPATCH

update_agent_status(phase="Phase 3/7 DISPATCH")

Phase 4/7: MONITOR

update_agent_status(phase="Phase 4/7 MONITOR")

PATIENCE IS THE JOB. Research agents work slower than coding agents — often by an order of magnitude. A single file may take 10-15 minutes: webfetch roundtrips, PDF download+pdftotext, draft writing, citation verification via task(explore), revision. A 5-file cluster typically takes 30-90 minutes; a large cluster 2-4 hours. This is normal, not a stall.

Monitoring cadence (DO NOT over-poll):

Primary vs secondary indicators (clarification):

What counts as "working" (not stalled):

stream_active is the primary liveness signal . It's set true by the proxy at SSE-stream start and false at stream end, via track_stream_state RPC . last_activity_at alone is unreliable — agents that block on long tool calls may not update it for 10+ min while still working.

What counts as stalled (recovery needed):

Recovery actions:

Anti-pattern — the anxious orchestrator:

Phase 5/7: INTEGRATE

update_agent_status(phase="Phase 5/7 INTEGRATE")

Triggers after all Bereichs-Agents report DONE (or aborted).

Phase 6/7: DAEMON-VERIFY

update_agent_status(phase="Phase 6/7 DAEMON-VERIFY")

The verification is its own phase, between the finished wiki and the handoff. Nothing

leaves the worktree before its report has a verdict.

yesloop skill prescribes (commit, branch, tests run, files in scope, evidence, plan).

yesmem verify-claims --repo <worktree> --project <project> --section <orchestrator-section>-verify --profile yesloop-done --policy yesloop-done --strict

Phase 7. Exit 1 means blocked. The class decides: refuted and defect send you back

into INTEGRATE or a cluster, environment, limit and error belong to the

orchestrator's caller.

prints.

Phase 7/7: DELIVER

update_agent_status(phase="Phase 7/7 DELIVER")

Bereichs-Agent Contract (spawned agent's pipeline)

When you are spawned as a yesresearch Bereichs-Agent, you receive via scratchpad:

SESSION TITLE (MANDATORY at Phase 1 start, opencode backend): opencode_session_rename(title="[<agent-id>] <session title>") (Code Mode: tools.opencode.session_rename) — omit sessionID (renames the current session); the bare session_rename does not exist. <agent-id> comes from the relay kick; the session title from your briefing (or derive it from the cluster name). Record **Session title set:** <final title> in the Phase 1 block. Rename failure or non-opencode backend: non-blocking — note it and continue.

Phase 1/7: CONTEXT

update_agent_status(phase="Phase 1/7 CONTEXT")

### Phase 1: CONTEXT
**Status:** COMPLETE
**Session id:** <opencode_session_id from whoami()>
**Session title set:** [<agent-id from relay kick>] <session title>
**Mode:** FRESH | UPDATE
**Cluster:** <name>
**Files in scope:** <list with one-line description each>
**UPDATE-mode actions (if UPDATE):** <per-file action list: add_visuals, add_mermaid, run_persona_review, refresh_sources, verify_status, expand_content>
**Source hints:** <from plan, or "discover via websearch">
**Language:** <DE/EN/etc>
**Constraints:** <list>
**Risks:** <e.g. paywalled sources, language availability>

UPDATE MODE — Read existing content first (MANDATORY):

Before any Edit on existing files, Read the current file + its frontmatter. Preserve all existing content unless the action explicitly replaces it. Anti-pattern : blind overwrite of existing file → content loss.

Allowed mutations per action:

Phase 2/7: PLAN

update_agent_status(phase="Phase 2/7 PLAN")

### Phase 2: PLAN
**Status:** COMPLETE
**Plan stored via set_plan:** yes
**Per-file strategy:** <which sources, which subagent approach>
**Subagent allocation:** <e.g. "all files: task(general) for fetch+write, task(explore) for verify">
**Saturation plan:** 3 empty searches = abort file, document
**Files in scope:** <list>

Phase 3/7: EXECUTE

update_agent_status(phase="Phase 3/7 EXECUTE (file M/K)")

### Phase 3: EXECUTE
**Status:** IN PROGRESS
**Files:** N total

#### File 1: <name>
**Status:** COMPLETE
**Sources gathered:** <count>
**Draft written:** yes — <word count> words
**Citations inline:** yes — <count>
**Saturation hits:** 0/3
**Subagent calls:** task(general) ×N, task(explore) ×1 for review
**Commits:** <hash> <msg>

**Total progress:** M/N files
**Uncommitted work:** none | <list>

Per-file discipline:

Phase 4/7: VERIFY

update_agent_status(phase="Phase 4/7 VERIFY")

### Phase 4: VERIFY
**Status:** COMPLETE
**Citations verified:** yes — sampled <N>/<total> files
**Min sources met:** yes — all files have ≥<min> sources
**Claims cited:** yes — every factual claim has inline [Title](URL, accessed YYYY-MM-DD)
**Conflicts dual-position:** yes — <count> conflict points, both sides presented
**PDFs handled:** <count> via curl+pdftotext
**Visual assets captured:** <count> screenshots/PDFs in assets/, linked from MD
**Persona Review:** yes — <persona set used>, gaps found: <count>
**Partial files:** none | <list with reason>
**VERIFY cycles used:** N/5

Two-layer VERIFY (MANDATORY — both layers required for COMPLETE status):

⓪ HARD RULE — Phase 4 is ONLY COMPLETE when BOTH layers have produced evidence:

  1. Citation Check via task(explore) (MANDATORY): read-only review of every factual claim. Missing/weak citations → fix or strike. Required evidence: subagent ID + list of claims checked + missing-citation actions taken, in scratchpad.
  1. Persona Review via task(explore) (MANDATORY, distinct from Citation Check): simulate a reader with a specific persona trying to answer a question using only this wiki file. Find concept gaps, not just missing sources. Required evidence: persona_review block in frontmatter with personas_tested, gaps_found, gaps_fixed. Missing block = Phase 4 INCOMPLETE.

Persona Review prompt pattern:

Du bist <persona>. Frage: <question the file should answer>.
Lies <file>.md. Beantworte die Frage aus dem Inhalt — OHNE externes Wissen.
Für jede Information, die du aus dem File beziehen kannst, zitiere die Section.
Für jede fehlende Information (die du für die Antwort bräuchtest, aber nicht im File findest), markiere als GAP.
Return: { answered: true/false, gaps: [list of missing concepts], weak_sections: [list of sections needing expansion] }

Suggested persona sets (agent picks 2-3 most relevant per file):

If Persona Review returns gaps → add content addressing the gap (re-dispatch task(general) for that section) and re-run both Citation Check and Persona Review. Max 5 VERIFY cycles total (combined for both layers) — if still gaps after 5 cycles, mark file partial with persona_review.gaps_fixed < gaps_found in frontmatter and proceed. Don't loop endlessly.

If verify fails on citation layer only → fix and re-verify (also counts against the 5-cycle budget).

Phase 5/7: COMMIT

update_agent_status(phase="Phase 5/7 COMMIT")

### Phase 5: COMMIT
**Status:** COMPLETE
**Files written:** <list with paths>
**Total word count:** <sum>
**Total citations:** <count>
**Cross-links added:** yes — <count>
**Status badges:** Entwurf|Verifiziert|Aktualisiert per file
**Commits:** <hashes>

Phase 6/7: DAEMON-VERIFY

update_agent_status(phase="Phase 6/7 DAEMON-VERIFY")

### Phase 6: DAEMON-VERIFY
**Status:** COMPLETE
**Vorab-Prüfung:** yesmem verify-claims -> exit 0 (accepted)
**Findings:** none | <what the run said and what you did about it>

citations) and run:

yesmem verify-claims --repo <worktree> --project <project> --section <your-section>-verify --profile yesloop-done --policy yesloop-done --strict

send you back into VERIFY or EXECUTE, environment, limit and error go to the

orchestrator. A DONE without a fresh accepted verdict is withheld by the daemon, and the

orchestrator is told about the hold.

Phase 7/7: DELIVER

update_agent_status(phase="Phase 7/7 DELIVER")

### Phase 7: DELIVER
**Status:** COMPLETE
**Files complete:** N/N
**Citations:** M total
**Partial/failed:** none | <list with reason>
**send_to orchestrator:** yes — <timestamp>
**Scratchpad complete:** yes
**Citations for bibliography aggregation:** <list>

Citation Rule (replaces Cold Review)

Research has no code review. Instead, every factual claim must be sourced. This is the primary quality gate.

Format: [Title](URL, accessed YYYY-MM-DD) inline at the claim.

Min sources per file: 2 (default). Override via master plan frontmatter or orchestrator scratchpad entry.

Every factual claim needs a citation. If you cannot source a claim:

Conflict policy: When sources disagree, present BOTH positions neutrally. Do not resolve. Example:

Die Frist für die Umsetzung wird unterschiedlich gesehen:
- Nach Ansicht von Kanzlei A beträgt sie 24 Monate [A](url, 2026-06-30).
- Kanzlei B argumentiert für 30 Monate [B](url, 2026-06-30).

Citation check via task(explore): Before Phase 5 COMMIT, dispatch task(explore, "Review <file>.md. List every factual claim. For each: does it have an inline citation? Is the source accessible? Report missing or weak citations."). explore is read-only — perfect for verification.

Web Research Rules

webfetch

websearch

PDFs

Always via bash pipeline:

curl -sL "<pdf-url>" -o /tmp/file.pdf && pdftotext /tmp/file.pdf - | head -500

Document the PDF URL + accessed date as citation.

Cloudflare 403 / Paywall

Saturation

After 3 empty searches (websearch returns no new relevant sources) for a single file, stop searching. Document in scratchpad: Saturation hit at source N. Proceeding with N-K sources, min-sources met: yes/no.

Visual Content Rules

Research wikis without visuals lose readers. Text-only citations are weaker than visual evidence. Each Bereichs-Agent should capture visual assets where they add value.

When to capture visuals (per file) — MANDATORY for marked rows

| Source type | Capture? | What to capture | Where |

|---|---|---|---|

| Vendor website with architecture diagram | MANDATORY | Screenshot or download SVG/PNG | assets/<file>-<source-slug>.png |

| PDF report with charts/tables | MANDATORY | Render relevant page as image OR extract page as separate PDF | assets/<file>-<source>-p<N>.png or .pdf |

| UI screenshots (tools, dashboards) | MANDATORY | Headless browser screenshot | assets/<file>-ui-<component>.png |

| Law firm blog post (text only) | skip | — | — |

| Academic paper | Optional | Abstract page, key figure | assets/<file>-figure-<N>.png |

| Market research analyst page | MANDATORY | Chart/table screenshot | assets/<file>-chart-<topic>.png |

Compliance rule (enforced by Orchestrator INTEGRATE):

Rule of thumb: if the source has a visual element (chart, diagram, screenshot, table) that strengthens the claim, MANDATORY capture. Pure text sources skip — but document the skip.

How to capture

PDFs → image:

# Download PDF
curl -sL "<url>" -o .yesmem/tmp/source.pdf
# Extract specific page as PNG (requires poppler-utils)
pdftoppm -png -f <page> -l <page> -r 150 .yesmem/tmp/source.pdf assets/<file>-<source>-p<page>

Website → screenshot (Fallback-Kaskade):

Try each tool in order. First success wins. If all fail: document screenshot_failed: no tool available, proceed without visual.

# Try 1: Chromium (most common on Linux)
if command -v chromium >/dev/null 2>&1; then
  chromium --headless --disable-gpu --no-sandbox \
    --window-size=1280,900 \
    --screenshot=assets/<file>-<source>.png \
    "<url>" 2>/dev/null

# Try 2: Google Chrome
elif command -v google-chrome >/dev/null 2>&1; then
  google-chrome --headless --disable-gpu --no-sandbox \
    --window-size=1280,900 \
    --screenshot=assets/<file>-<source>.png \
    "<url>" 2>/dev/null

# Try 3: Firefox (headless mode)
elif command -v firefox >/dev/null 2>&1; then
  firefox --screenshot --window-size=1280,900 \
    assets/<file>-<source>.png \
    "<url>" 2>/dev/null

# Try 4: wkhtmltoimage (simpler, no JS)
elif command -v wkhtmltoimage >/dev/null 2>&1; then
  wkhtmltoimage --width 1280 --height 900 "<url>" assets/<file>-<source>.png 2>/dev/null

# Try 5: Safari (macOS)
elif command -v safari >/dev/null 2>&1 || [ -d /Applications/Safari.app ]; then
  # Safari has no headless CLI — use screencapture via AppleScript
  osascript -e 'tell application "Safari" to open location "<url>"' 2>/dev/null
  sleep 3
  screencapture -R 0,0,1280,900 assets/<file>-<source>.png 2>/dev/null

# All failed
else
  echo "screenshot_failed: no browser tool available (chromium/google-chrome/firefox/wkhtmltoimage/safari)"
fi

Verify file exists and has size >1KB before linking. Empty/placeholder PNGs get rejected.

If chromium not available, document in scratchpad screenshot_failed: chromium missing, proceed without visual.

Direct image download (vendor provides PNG/SVG):

curl -sL "<image-url>" -o assets/<file>-<source>.png

Linking visuals from MD

Die Marktprognose von Grand View sieht ein Wachstum von 30% p.a. bis 2030 
[GrandView](https://grandview.com/..., accessed 2026-07-01).

![GrandView Marktprognose 2025-2030](assets/marktgroesse-grandview-prognose.png)
*Abbildung 1: GrandView Marktprognose (Quelle: [GrandView](https://..., 2026-07-01))*

Captions are mandatory under each image: source attribution + brief context. The image without a caption is not a citation — the caption + link is.

Wayback-Fallback for visuals

If a source URL is likely to disappear (paywalled blog, fast-moving vendor page), also capture via Wayback Machine:

curl -sL "https://web.archive.org/web/2/<url>" -o .yesmem/tmp/wayback.html
# Extract image URLs from wayback HTML, download to assets/

Document in scratchpad which assets were captured from Wayback vs live source.

Asset naming convention

<file-name-slug>-<source-slug>-<descriptor>.<ext>

Examples:

All lowercase, kebab-case, no spaces, no special chars. Slug-based, not arbitrary names.

Mermaid Diagrams

Mermaid is text-based diagramming — the diagram source lives in the .md file as a fenced code block, rendered by the publishing tool (GitHub, MkDocs Material, Docusaurus, Obsidian). Same single-source principle as the rest of the wiki: text in, rendering happens elsewhere.

When to use Mermaid

| Page type | Diagram type | Why |

|---|---|---|

| INDEX.md | graph TD or mindmap | Cluster-overview visualization, navigational anchor |

| Architecture pages | flowchart, sequenceDiagram, graph | Show component relationships, data flows |

| Timeline pages | timeline | Chronological events (regulatory timeline, funding history) |

| Comparison pages | classDiagram or gitGraph | Entity relationships, branching histories |

| Decision/strategy pages | flowchart with decision nodes | Decision trees, workflow visualizations |

| Stakeholder pages | graph with subgraphs | Stakeholder map, influence diagram |

Rule: if the page has 3+ entities or events with relationships, add a Mermaid diagram. Pure prose without structure → no diagram needed.

Mermaid syntax in MD

## Architektur-Patterns im Vergleich

Die drei dominanten Memory-Architekturen unterscheiden sich in der Zuständigkeit für Memory-Management:

graph LR

subgraph "Memory-as-a-Service"

A[Agent] -->|store/recall| B[(Memory SaaS)]

B --> C[Mem0, Zep, Supermemory]

end

subgraph "Stateful-Agent-Runtime"

D[Agent Runtime] -->|owns| E[(In-Process Memory)]

E --> F[Letta/MemGPT]

end

subgraph "MCP-Server"

G[Agent] -->|MCP tool calls| H[(Memory MCP Server)]

H --> I[claude-mem, YesMem]

end

Mermaid source files for complex diagrams

For diagrams with 15+ nodes (cluster overview, multi-stakeholder maps), store the source separately:

INDEX.md mandatory Mermaid (DONE-Gate-enforced)

Every INDEX.md MUST contain a Mermaid cluster-map. Orchestrator INTEGRATE regenerates it from file frontmatter (see Section 11 DONE-Gate for validation).

Minimum requirements (all MUST be met, else DONE rejected):

Validation pattern (Orchestrator checks via grep/regex):

# Extract Mermaid block from INDEX.md
MERMAID_BLOCK=$(awk '/```mermaid/,/^```$/' yesdocs/<topic>/wiki/INDEX.md)

# Hard checks
echo "$MERMAID_BLOCK" | grep -q 'subgraph'         || echo "FAIL: no subgraph"
echo "$MERMAID_BLOCK" | grep -qE '[-=]>.*[-=]>'    || echo "FAIL: no edges"
echo "$MERMAID_BLOCK" | grep -cE '^\s+[A-Za-z]'    # node count — must be ≥ cluster_count + file_count
EDGE_COUNT=$(echo "$MERMAID_BLOCK" | grep -cE '(-|=.*>|---)')
[ "$EDGE_COUNT" -ge 3 ]                              || echo "FAIL: <3 edges"

Any FAIL = Orchestrator refuses to DELIVER, dispatches fix task to Bereichs-Agent.

This is the navigational anchor. Without it, INDEX.md is just a bullet list.

Diagram citation

If a diagram is derived from a source (not original work), cite it:

*Abbildung 2: Architektur-Übersicht adaptiert von [Mem0 Architecture](https://docs.mem0.com/architecture, 2026-07-01)*

Original diagrams (synthesis by the agent from multiple sources) marked as *Eigene Darstellung basierend auf N Quellen*.

Output Target Structure

yesdocs/<topic>/wiki/
├── INDEX.md                          # Orchestrator-generated, navigation + status
├── <cluster-1-slug>/
│   ├── file-1.md
│   ├── file-2.md
│   └── assets/                       # Visual citations, screenshots, PDFs, diagrams
│       ├── file-1-source-a.png
│       └── file-2-architecture.mmd   # Mermaid source (optional, for editability)
├── <cluster-2-slug>/
│   └── ...
└── 99-sources/
    └── bibliography.md               # Orchestrator-aggregated from all agents

Each file carries extended YAML frontmatter:

---
# Identity
topic: <topic>
cluster: <cluster-name>
title: <Human-readable title>
language: DE | EN | ...

# Lifecycle
status: Entwurf | Verifiziert | Aktualisiert
last_updated: YYYY-MM-DD
created_at: YYYY-MM-DD

# Provenance
sources_count: N
citations_count: N
images_count: N
diagrams_count: N

# Navigation
related:
  - <cluster>/<other-file>.md
  - <cluster>/<other-file>.md
tags:
  - <tag-1>
  - <tag-2>

# Persona review (filled by Phase 4 VERIFY)
persona_review:
  personas_tested: [executive, engineer, researcher]
  gaps_found: N
  gaps_fixed: N
---

Frontmatter is the single source of truth for status, navigation, and searchability. Orchestrator INTEGRATE-Phase uses it to generate INDEX.md cross-links, tag pages, and status badges.

Failure Recovery

First, rule out "normal slow": Before declaring failure, confirm the agent is actually stuck, not just taking a long time. A research agent doing webfetch+PDF+draft+verify on a 5-file cluster may legitimately run 60+ minutes without producing a commit.

| Situation | Action |

|---|---|

| Bereichs-Agent crashed (PID dead) | Orchestrator respawns with identical task, scratchpad section preserved. Max 3 respawns. |

| Socket collision on spawn | rm -f ~/.claude/yesmem/agent-<id>.sock before respawn |

| Stalled agent (stream_active==false from get_agent AND no activity >20min AND subagent_streams==0) | relay_agent kick: "Status check — current phase? Blockers?" Wait 10 min. If still flat, respawn. |

| stopped: max_runtime exceeded but PID alive | Rare false positive: the limit only stops a row whose PID holds no verified process. Relay to continue; max_runtime is a global config, so raising it affects every agent. |

| webfetch 403 / timeout | Subagent documents, tries Wayback/Google cache. If all fail: file marked partial, proceed. |

| Master plan ambiguous | Orchestrator resolves via inline decomposition. If unresolvable: send_to caller_session: "AMBIGUITY: <description>" and wait. |

| All Bereichs-Agents fail | Orchestrator documents, aborts, escalates: send_to caller_session: "ABORT: all agents failed. <details>" |

Anti-Patterns (DONE-Gate-enforced — see Section 11)

Each violation triggers DONE-Gate failure: Orchestrator rejects DONE-claim, dispatches fix task.

| # | Anti-Pattern | DONE-Gate Check |

|---|---|---|

| 1 | Orchestrator doing research inline instead of delegating | Orchestrator scratchpad must NOT contain task(general) for source-fetch |

| 2 | Skipping Citation Check (Phase 4 VERIFY) | Scratchpad must contain **Citations verified:** yes + subagent ID |

| 3 | Skipping Persona Review (Phase 4 VERIFY) | Frontmatter must contain persona_review block with personas_tested |

| 4 | Resolving conflicts unilaterally | Content audit must show both positions for every conflict point |

| 5 | Claims without sources | Every factual claim must have inline citation (grep pattern) |

| 6 | Bereichs-Agent running >12h | Orchestrator aborts and redispatches; the daemon's global max_runtime (48h default) is the hard stop, the 12h here is an orchestrator convention |

| 7 | More than 6 concurrent Bereichs-Agents | list_agents(project) and count status == "running" rows client-side |

| 8 | Push or merge without user approval | git log origin/<branch> must be empty in DELIVER |

| 9 | Reporting DONE with missing phase sections | Section 11 validation regex |

| 10 | Using Write on existing files (instead of Edit+Lock) | Worktree git log must NOT show wholesale file replacements >100% line change |

| 11 | Missing visuals on MANDATORY source types | images_count > 0 OR documented skip per source |

| 12 | Missing Mermaid in INDEX.md | grep `mermaid + ≥3 edges in INDEX.md |

Soft anti-patterns (advisory, not DONE-blocking):

DRIFT CHECK — Before each FILE in EXECUTE

  1. Re-read cluster scope from scratchpad
  2. Compare current file's content against original file description in master plan
  3. Drift indicators:
  1. Minor drift → MANDATORY fix immediately — correct course NOW, document what drifted and how you corrected it in scratchpad, then continue.
  2. Major drift → scratchpad_write("⚠️ DRIFT: <description>") + send_to orchestrator: "DRIFT in <file>. <details>". Wait.

PROOF BURDEN (BEWEISLAST) for scratchpad claims

Before writing "DONE", "complete", "verified" to scratchpad, confirm the artifact matches the claim.

| Claim | Required independent check |

|---|---|

| "N files written" | ls yesdocs/<topic>/wiki/<cluster>/ shows N .md files |

| "citation verified" | task(explore) review output in scratchpad, with missing-citation list empty |

| "min sources met" | per-file source count in scratchpad ≥ min |

| "PDF parsed" | pdftotext output snippet in scratchpad |

| "commit pushed" | git log origin/<branch> --oneline -1 shows hash (only if push was requested) |

| "file edited" | Read the file (not just git show) |

Apply to consequential claims only: file counts, citation completeness, commit state. Routine per-file todowrite updates don't need this.

Orchestrator Crash Recovery

If the Orchestrator agent itself crashes (daemon restart, OOM, manual kill), the run is recoverable because state lives in yesmem, not in volatile context.

On Orchestrator respawn (via yesmem_resume_agent):

  1. get_plan() — restore phase + cluster list + mode flag
  2. scratchpad_read(project, "yesresearch-<topic-slug>-orchestrator") — restore detailed state
  3. list_agents(project) and keep the rows with status == "running"; the tool takes only project — check which Bereichs-Agents are still alive
  4. Reconstruct: which phase was I in? Which batches dispatched? Which agents completed?
  5. update_agent_status(phase="Phase N/7 NAME (recovered)") — re-assert state
  6. Continue from the right point:

Plan persistence contract (Orchestrator writes this via set_plan):

Phase: <current phase>
Mode: FRESH | UPDATE
Clusters: [{name, status: pending|dispatched|done|failed, agent_id, batch: N}]
Batch progress: batch N of M complete
Files expected: <count>
Files complete: <count>

Orchestrator updates this after every phase transition + every batch completion. On respawn, plan is the source of truth — context is rebuildable from it.

User interrupt: If user wants to abort a running orchestrator, send relay_agent with ABORT: stop after current batch, do not start new dispatches. Orchestrator honors this at the next batch boundary.

Communication

Mini Example (filled Phase 3, others stubbed)

### Phase 1: CONTEXT
**Status:** COMPLETE
**Session id:** ses_abc123
**Cluster:** Primärrecht
**Files in scope:** eu-directive.md, ucpd.md, uwg.md
**Source hints:** eur-lex.europa.eu, gesetze-im-internet.de
**Language:** DE
**Constraints:** min 2 sources/file, conflict dual
**Risks:** EU-Trilog-Versionen können abweichen

### Phase 2: PLAN
**Status:** COMPLETE
**Plan stored via set_plan:** yes
**Per-file strategy:** eu-directive via EUR-Lex + cms-lawnow, ucpd via EUR-Lex + Noerr, uwg via BMJ + Beck
**Subagent allocation:** task(general) pro file für fetch+write, task(explore) nach Draft
**Saturation plan:** 3 leere websearch-Calls = Stopp
**Files in scope:** 3

### Phase 3: EXECUTE
**Status:** COMPLETE
**Files:** 3 total

#### File 1: eu-directive.md
**Status:** COMPLETE
**Sources gathered:** 4
**Draft written:** yes — 720 words
**Citations inline:** yes — 6
**Saturation hits:** 0/3
**Subagent calls:** task(general) ×2, task(explore) ×1
**Commits:** a1b2c3d feat(wiki): eu-directive.md

#### File 2: ucpd.md
**Status:** COMPLETE
...

#### File 3: uwg.md
**Status:** COMPLETE
...

**Total progress:** 3/3 files
**Uncommitted work:** none

### Phase 4: VERIFY
**Status:** COMPLETE
**Citations verified:** yes — sampled 2/3 files (explore subagent)
**Min sources met:** yes — all ≥2
**Claims cited:** yes — every claim sourced
**Conflicts dual-position:** yes — 1 conflict (Trilog-Frist)
**PDFs handled:** 1 (EUR-Lex PDF via curl+pdftotext)
**Partial files:** none
**VERIFY cycles used:** 1/5

### Phase 5: COMMIT
**Status:** COMPLETE
**Files written:** primärrecht/eu-directive.md, primärrecht/ucpd.md, primärrecht/uwg.md
**Total word count:** 2140
**Total citations:** 17
**Cross-links added:** yes — 5
**Status badges:** Verifiziert ×3
**Commits:** a1b2c3d, e4f5g6h, i7j8k9l

### Phase 6: DAEMON-VERIFY
**Status:** COMPLETE
**Vorab-Prüfung:** yesmem verify-claims -> exit 0 (accepted)
**Findings:** none

### Phase 7: DELIVER
**Status:** COMPLETE
**Files complete:** 3/3
**Citations:** 17 total
**Partial/failed:** none
**send_to orchestrator:** yes — 2026-06-30T23:50
**Scratchpad complete:** yes
**Citations for bibliography:** [EUR-Lex 2024/825](...), [UCPD](...), [BMJ UWG](...), ...

Decision Gates (Autonomous, Bereichs-Agent)

| Situation | Action |

|---|---|

| Source easy to find | Fetch directly via webfetch |

| 2-3 source candidates, unclear best | Pick most authoritative (official > law firm > media), document rationale |

| Need to expand scope within file | MANDATORY fix immediately — stop the drift, correct course NOW, document it. Escalate only if the correction itself is impossible or blocking |

| Source unverifiable (404, paywall) | Try Wayback/Google cache; if all fail, mark *[unkenntlich]*, proceed |

| 3 consecutive saturation hits | Stop searching for this file, document, proceed with what's gathered |

| Citation check fails | Fix missing citations, re-run explore review, max 5 cycles |

| Irreversible action (delete, overwrite existing wiki) | Pause, send_to orchestrator: "IRREVERSIBLE: <description>", wait |

Decision Gates (Orchestrator)

| Situation | Action |

|---|---|

| Bereichs-Agent reports BLOCKED | Read scratchpad, resolve or abort that cluster |

| Bereichs-Agent crashed 3× | Abort cluster, document gap in INDEX.md |

| Citation audit finds systematic gaps | Re-dispatch fix task to affected Bereichs-Agent |

| Integration conflicts (cross-links broken) | Orchestrator fixes inline, documents |

| User sends new instructions via check_messages | Pause, eval, integrate or escalate |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.