Skill: indigokarasu/ocas-custodian (version 1.0.0)

--- name: ocas-custodian source: https://github.com/indigokarasu/custodian install: openclaw skill install https://github.com/indigokarasu/custodian description: Use when checking system health, fixing log errors, reviewing cron failures, initializing skills, registering missing background tasks, or running overnight maintenance. Trigger phrases: 'check system health', 'fix log errors', 'why is X failing', 'initialize skills', 'clean up errors', 'show open issues', 'what time does custodian run', 'update custodian'. Do not use for skill OKR analysis (use Mentor/Corvus), skill rebuilding (use Forge), knowledge graph queries (use Elephas), social graph queries (use Weave), or research tasks (use Scout/Sift). metadata: {"openclaw":{"emoji":"🧹"}} --- # Custodian Custodian detects, classifies, and repairs OpenClaw operational failures autonomously during quiet hours so the user wakes to clean logs, initialized skills, and registered background tasks -- surfacing only what it could not fix. ## When to use - Asked to check system health, fix log errors, review cron failures - Asked to initialize skills or register missing background tasks - Asked why OpenClaw or a specific skill is failing - Running overnight maintenance or a system audit - Invoked automatically via heartbeat or cron ## Responsibility Boundary **Owns:** gateway log scanning and error fingerprinting, cron job registry health, skill journal completeness, OCAS data directory health, skill initialization, background task conformance, Tier 1 auto-repair, activity model and schedule optimization, escalation signaling, fix effectiveness tracking. **Does not own:** OKR trend analysis (Corvus, Mentor), skill design evaluation or rebuilding (Mentor, Forge), behavioral lesson extraction (Praxis), briefing delivery (Vesper), entity knowledge (Elephas), social graph (Weave). Never modifies any file inside a skill package directory. ## Optional Skill Cooperation - **Vesper** -- writes InsightProposals to `~/openclaw/data/ocas-vesper/intake/` after deep scans. Without Vesper, issues stay in `issues.jsonl`. - **Mentor** -- journals tagged `escalation_needed: true` are readable by Mentor heartbeat. Without Mentor, escalated issues await manual review. - **Corvus** -- if installed, reads Corvus observation journals for `routine_prediction` InsightProposals. Blended 70% Corvus / 30% own model. Functions normally without Corvus. ## Commands - `custodian.init` -- create storage, register background tasks idempotently, copy bundled plan to Mentor plans dir, build initial activity model - `custodian.scan.light` -- tail gateway log (last 100 lines), check cron registry, retry open `fix_attempted_failed` items, check for uninitialized skills, write Observation Journal - `custodian.scan.deep` -- full sweep: all light steps + full JSONL scan, doctor diagnostic, journal health, skill conformance, skill init pass, activity model rebuild, schedule optimization, repair pass, web search pass, escalation pass, report, Vesper signal - `custodian.verify {fix_id}` -- verify fix outcome, update record, escalate if failed twice - `custodian.repair.auto` -- apply all pending Tier 1 fixes from last scan - `custodian.repair.plan` -- generate structured repair plan for Tier 2/3 issues - `custodian.issues.list` -- list open issues with tier, status, age, recurrence - `custodian.issues.resolve {issue_id}` -- mark issue resolved manually - `custodian.status` -- emit SkillStatus JSON - `custodian.schedule.show` -- display current and target scan schedule with optimization confidence - `custodian.update` -- pull latest from GitHub source (preserves journals and data) ## Execution Loop -- Light Scan Runs every heartbeat. Must be fast (seconds). No web search, doctor, or report. 1. Read `~/.openclaw/cron/jobs.json` -- find jobs with `enabled: false` that were previously enabled in `skill_conformance.jsonl`. Re-enable (Tier 1). 2. Tail `/tmp/openclaw/openclaw-YYYY-MM-DD.log` -- last 100 lines. Fingerprint ERROR entries against `references/known_issues.json` then `learned_issues.jsonl`. Apply Tier 1 fixes. Open issues for Tier 3/4. 3. Check `issues.jsonl` for `status: fix_attempted_failed`. Retry Tier 1 up to 3 times before escalating. 4. Check for uninitialized skills (data dir or config.json missing). Initialize immediately. 5. Write Observation Journal. ## Execution Loop -- Deep Scan Runs on optimized 6-hour cron schedule. Isolated session, lightContext. 1. **Load context** -- own journals (7 days), `fix_effectiveness.jsonl`. Identify recurring fingerprints, known-failed fixes, already-searched queries. 2. **Collect** -- full day gateway log, cron run logs, skill journals from scan window, all OCAS data dirs, `openclaw doctor --non-interactive`. 3. **Fingerprint + classify** -- match against `references/known_issues.json` then `learned_issues.jsonl`. Unknowns default Tier 3. 4. **Rebuild activity model** -- parse gateway log `message.processed` events (`source: user` vs `source: cron|heartbeat`). Blend Corvus if present (70/30). Update `activity_model.json`. Determine `current_state`. 5. **Optimize schedule** -- score current schedule against activity model. If score < 6, compute better schedule. Shift max 30 min per slot. Update cron if changed. 6. **Skill conformance** -- scan installed skills, parse `## Background tasks`, cross-reference against `openclaw cron list` and `HEARTBEAT.md`. Register missing (Tier 1). Surface mismatches (Tier 2). 7. **Skill init pass** -- initialize any skill missing data dir, config.json, or journal dir. 8. **Repair pass** -- all Tier 1 fixes. Activity-aware: if active, only urgent fixes (failure in last 5 min); defer rest. Register verify jobs. Execute prior deferred fixes if now quiet. 9. **Web search pass** -- for unknown fingerprints with `recurrence_count >= 1`, run next mutation query (see Web Search Protocol). 10. **Escalation pass** -- Tier 3/4 open issues: write InsightProposal to Vesper intake. Tag journal `escalation_needed: true`. 11. **Report** -- `~/openclaw/data/ocas-custodian/reports/YYYY-MM-DD-HHMM.md`. If all clean and previous cycle also clean: suppress Vesper signal. 12. **Write journal** -- Action (if fixes applied) or Observation (scan-only). ## Fix Safety Envelope Every autonomous fix must satisfy all four: 1. **Non-destructive** -- no delete, overwrite, or permanent alteration 2. **Reversible** -- pre-fix state restorable without backup 3. **Minimal scope** -- smallest surface to address symptom 4. **Functionality-preserving** -- cannot reduce capability Hard constraints: never modify skill package files, never delete files, never modify another skill's data dir, never restart gateway, never change user settings without acknowledgment. ## Tier Classification | Tier | Label | Action | |---|---|---| | 1 | Auto-fix | Apply immediately, register verify job, log fix record | | 2 | Plan | Surface with proposed change, do not apply | | 3 | Escalate | Write to escalation journal + Vesper intake, invoke Mentor plan if available | | 4 | Alert only | Cannot fix -- surface with diagnostics | High-recurrence override: if `recurrence_after_fix / successes > 0.5`, auto-promote next occurrence from Tier 1 to Tier 3. ## Tier 1 Auto-Fix Registry All Tier 1 fixes defined in `references/known_issues.json`. Read at start of every scan. Pre-seeded fingerprints: | Fingerprint | Fix | |---|---| | `oc_cron_disabled_transient` | Re-enable cron job | | `oc_cron_stuck_missed` | Force-run missed job | | `oc_intake_dir_missing` | Create directory | | `oc_journal_dir_missing` | Create directory | | `oc_skill_data_dir_missing` | Create directory + default config.json | | `oc_jsonl_oversized` | Rotate with date suffix | | `oc_jsonl_malformed_lines` | Quarantine to `.error` file | | `oc_gateway_token_missing` | `openclaw doctor --generate-gateway-token` | | `oc_oauth_token_expiring` | OAuth refresh (token still valid, expiry <= 12h) | | `oc_background_task_missing` | Register cron or heartbeat entry per SKILL.md | | `oc_skill_uninitialized` | Create storage dirs, default config, empty JSONL | ## Fix Verification Every Tier 1 fix registers a one-shot cron job `custodian:verify:{fix_id}` with delay per fix type (2-15 min). On verification failure: set `outcome: fix_attempted_failed`. Two consecutive failures: promote to Tier 3. Fix records appended to `fixes.jsonl` with `fix_id`, `issue_id`, `command`, `reversibility`, `pre_fix_state`, `post_fix_state`, `outcome`. ## Post-Fix Cleanup After successful verification, run fix-specific cleanup (check backoff, confirm next run, validate permissions). Record in `cleanup_events.jsonl`. ## Skill Conformance Checking On every deep scan: scan `~/.openclaw/workspace/skills/`, parse each SKILL.md `## Background tasks`, cross-reference against `openclaw cron list` and `HEARTBEAT.md`. Missing tasks: Tier 1 fix. Schedule mismatches: Tier 2. Orphaned `custodian:*` jobs: Tier 2. Write `skill_conformance.jsonl` per skill. ## Skill Initialization Uninitialized when: data dir missing, config.json missing, or journal dir missing. Sequence (additive only, never overwrite): 1. Create `~/openclaw/data/{skill-name}/` if missing 2. Write default config.json with ConfigBase fields -- only if absent 3. Create `~/openclaw/journals/{skill-name}/` if missing 4. Create declared intake dirs if missing 5. Run conformance check for background tasks 6. Register missing tasks (Tier 1, subject to parameter availability) 7. Register verify job (15 min delay) 8. Append DecisionRecord Do not run the skill's own `{skill}.init` command. ## Activity Model Maintained in `activity_model.json`, rebuilt every deep scan from 14-day gateway log window. Confidence per hour: `active_days / total_days` (>= 0.75 high, >= 0.40 med, < 0.40 low). `current_state: active` if hour confidence >= med and in active window, else `quiet`. Repair rules: quiet = all Tier 1; active = urgent only (failure in last 5 min), defer rest; low confidence = execute but suppress noisy effects. Cold start: `01:00, 07:00, 13:00, 19:00 PT`. Optimization begins after 7 days. ## Schedule Optimization Exactly 4 runs/day, min 2h gap, max 30 min shift per cycle. Score each run time against activity model (-2 to +2 per slot, max +8). If score >= 6: no change. If < 6: find candidate maximizing score, shift toward target. Update cron registration. Confidence gate: high = optimize freely, med = only if score <= 2, low = hold. ## Web Search Protocol Fire when: fingerprint unknown, recurrence increased since last search, last search not actionable, not escalated/suppressed, < 5 attempts. Query mutation sequence: (1) `{error} openclaw`, (2) `{error} {tech_context}`, (3) `{error_pattern} fix`, (4) `{component} {failure_mode}`, (5) `{failure_mode} root cause diagnosis`. On actionable result: attempt fix, append to `learned_issues.jsonl` if successful. On no result: record and continue mutation on next recurrence. ## Self-Improvement `fix_effectiveness.jsonl`: per-fingerprint tracking of attempts, successes, failures, recurrence. High-recurrence escalation: `recurrence_after_fix / successes > 0.5` promotes to Tier 3. Custodian OKRs (every journal): `success_rate`, `issues_detected`, `issues_auto_fixed`, `fix_success_rate`, `mean_time_to_fix_ms`, `open_residuals`, `escalations`, `high_recurrence_fingerprints`, `skills_initialized`, `background_tasks_registered`, `schedule_score`, `journal_completeness`. ## Escalation Path Tier 3: append `status: escalated` to `issues.jsonl`, tag journal `escalation_needed: true`, write InsightProposal (`anomaly_alert`) to `~/openclaw/data/ocas-vesper/intake/`. If Mentor present, note `mentor.plan.run custodian-repair --arg issue_id={id}` available. Clean state: zero open issues + previous cycle clean = suppress Vesper signal. First run of day or issues now resolved = emit clean bill of health. ## Journal Outputs - **Observation Journal** -- scan-only runs, no fixes applied - **Action Journal** -- any run with Tier 1 fixes or cron registrations Both include full Custodian OKR block. Path: `~/openclaw/journals/ocas-custodian/YYYY-MM-DD/{run_id}.json` ## Background tasks | Job | Mechanism | Schedule | Command | |---|---|---|---| | `custodian:light` | heartbeat | every heartbeat cycle | `custodian.scan.light` | | `custodian:deep` | cron | optimized 6h (initial: `0 1,7,13,19 * * *` PT) | `custodian.scan.deep` | | `custodian:update` | cron | `0 0 * * *` (midnight daily) | Self-update from GitHub source | Registration during `custodian.init` (idempotent -- check `openclaw cron list` first). ## Storage Layout ``` ~/openclaw/data/ocas-custodian/ config.json -- ConfigBase + scan_window_minutes, optimization settings issues.jsonl -- issue lifecycle records fixes.jsonl -- fix attempt records with pre/post state cleanup_events.jsonl -- post-fix cleanup records fix_effectiveness.jsonl -- per-fingerprint outcome tracking learned_issues.jsonl -- runtime-learned fingerprints from web search skill_conformance.jsonl -- per-skill background task conformance activity_model.json -- rolling 14-day activity pattern (rebuilt each deep scan) deferred_fixes.jsonl -- fixes queued for next quiet window schedule_state.json -- current/target schedule, optimization history decisions.jsonl -- DecisionRecord entries reports/ YYYY-MM-DD-HHMM.md -- deep scan summaries (7-day retention) ~/openclaw/journals/ocas-custodian/ YYYY-MM-DD/{run_id}.json ``` ## Support File Map | File | Purpose | When to read | |---|---|---| | `references/known_issues.json` | Pre-seeded fingerprint registry with tier, fix, reversibility | Start of every scan before classifying errors | | `references/plans/custodian-repair.plan.md` | Mentor Workflow Plan for Tier 3 multi-step repair | Copied to Mentor plans dir during init; referenced in escalation |

path: README.md
content: # 🧹 Custodian

Custodian detects, classifies, and repairs OpenClaw operational failures autonomously during quiet hours so the user wakes to clean logs, initialized skills, and registered background tasks -- surfacing only what it could not fix.

---

## Overview

Custodian monitors the OpenClaw gateway logs, cron job registry, skill journals, and OCAS data directories for operational failures. It fingerprints errors against a known-issues registry, classifies them into tiers (auto-fix, surface with plan, escalate, or alert-only), and applies safe, non-destructive repairs within a strict safety envelope. It initializes uninitialized skills, registers missing background tasks, and maintains an activity model that optimizes its own scan schedule toward quiet hours. Fixes that recur after repair are automatically promoted to escalation tier. Unknown errors trigger a progressive web search protocol that learns new fix patterns over time.

## Commands

| Command | Description |
|---|---|
| `custodian.init` | Create storage directories, register background tasks, copy bundled plan to Mentor |
| `custodian.scan.light` | Quick scan: tail gateway log, check cron health, retry failed fixes |
| `custodian.scan.deep` | Full sweep: all checks, conformance, activity model, repair pass, report |
| `custodian.verify {fix_id}` | Verify outcome of a specific fix |
| `custodian.repair.auto` | Apply all pending Tier 1 fixes from last scan |
| `custodian.repair.plan` | Generate structured repair plan for Tier 2/3 issues |
| `custodian.issues.list` | List open issues with tier, status, age, recurrence |
| `custodian.issues.resolve {issue_id}` | Mark issue resolved manually |
| `custodian.status` | Current health state |
| `custodian.schedule.show` | Display current and target scan schedule |
| `custodian.update` | Pull latest from GitHub source (preserves journals and data) |

## Setup

`custodian.init` runs automatically on first invocation and creates all required directories, config.json, and JSONL files. It registers the `custodian:deep` cron job (6-hour cycle), the `custodian:light` heartbeat entry, and the `custodian:update` midnight cron. It also copies the bundled `custodian-repair.plan.md` workflow plan to Mentor's plans directory. No manual setup is required.

## Dependencies

**OCAS Skills**
- [Vesper](https://github.com/indigokarasu/vesper) -- receives InsightProposal alerts after deep scans
- [Mentor](https://github.com/indigokarasu/mentor) -- reads escalation-tagged journals; runs custodian-repair workflow plan
- [Corvus](https://github.com/indigokarasu/corvus) -- optional activity pattern blending for schedule optimization
- [Sift](https://github.com/indigokarasu/sift) -- used by custodian-repair plan for diagnosis research

**External**
- None

## Scheduled Tasks

| Job | Mechanism | Schedule | Command |
|---|---|---|---|
| `custodian:light` | heartbeat | every heartbeat cycle | `custodian.scan.light` |
| `custodian:deep` | cron | optimized 6h (initial: `0 1,7,13,19 * * *` PT) | `custodian.scan.deep` |
| `custodian:update` | cron | `0 0 * * *` (midnight daily) | Self-update from GitHub source |

## Changelog

### v1.0.0 -- March 27, 2026
- Initial release: gateway log scanning, cron health monitoring, skill journal validation
- Tier 1 auto-fix with 11 pre-seeded fingerprints and verification jobs
- Skill conformance checking and automatic initialization
- Activity model with 14-day rolling window and schedule optimization
- Web search protocol with 5-mutation query sequence and learned-issues accumulation
- Fix effectiveness tracking with high-recurrence auto-escalation
- Bundled custodian-repair workflow plan for Mentor
- Vesper integration for escalation alerts

---

*Custodian is part of the [OpenClaw Agent Suite](https://github.com/indigokarasu) -- a collection of interconnected skills for personal intelligence, autonomous research, and continuous self-improvement. Each skill owns a narrow responsibility and communicates with others through structured signal files, shared journals, and Chronicle, a long-term knowledge graph that accumulates verified facts over time.*


path: references/known_issues.json
content: {
  "oc_cron_disabled_transient": {
    "tier": 1,
    "match_patterns": ["job.*disabled", "enabled.*false"],
    "source": "cron_log",
    "auto_fix": "openclaw cron edit {job_id} --enabled true",
    "reversibility": "openclaw cron edit {job_id} --enabled false",
    "description": "Cron job transiently disabled, likely from a failed run or timeout",
    "technology_context": "Node.js launchd cron scheduler"
  },
  "oc_cron_stuck_missed": {
    "tier": 1,
    "match_patterns": ["missed.*schedule", "stuck.*cron", "overdue.*run"],
    "source": "cron_log",
    "auto_fix": "openclaw cron run {job_id}",
    "reversibility": "No side effects -- run was already missed",
    "description": "Cron job missed its scheduled run window",
    "technology_context": "Node.js launchd cron scheduler"
  },
  "oc_intake_dir_missing": {
    "tier": 1,
    "match_patterns": ["ENOENT.*intake", "intake.*directory.*not found", "cannot write.*intake"],
    "source": "skill_journal",
    "auto_fix": "mkdir -p {intake_path}",
    "reversibility": "rmdir {intake_path}",
    "description": "Skill intake directory missing, blocking inter-skill signal delivery",
    "technology_context": "filesystem POSIX directory"
  },
  "oc_journal_dir_missing": {
    "tier": 1,
    "match_patterns": ["ENOENT.*journals", "journal.*directory.*missing", "cannot write.*journal"],
    "source": "skill_journal",
    "auto_fix": "mkdir -p ~/openclaw/journals/{skill_name}",
    "reversibility": "rmdir ~/openclaw/journals/{skill_name}",
    "description": "Skill journal directory missing, blocking journal writes",
    "technology_context": "filesystem POSIX directory"
  },
  "oc_skill_data_dir_missing": {
    "tier": 1,
    "match_patterns": ["ENOENT.*data/ocas-", "data directory.*missing", "config.json.*not found"],
    "source": "ocas_data",
    "auto_fix": "mkdir -p ~/openclaw/data/{skill_name} && write default config.json",
    "reversibility": "Remove created directory and config.json",
    "description": "Skill data directory or config.json missing, skill uninitialized",
    "technology_context": "filesystem JSON configuration"
  },
  "oc_jsonl_oversized": {
    "tier": 1,
    "match_patterns": ["file size exceeded", "jsonl.*too large", "rotation needed"],
    "source": "ocas_data",
    "auto_fix": "mv {file}.jsonl {file}.{date}.jsonl && touch {file}.jsonl",
    "reversibility": "mv {file}.{date}.jsonl {file}.jsonl",
    "description": "JSONL log file exceeded max_records threshold, needs rotation",
    "technology_context": "JSON Lines append-only log"
  },
  "oc_jsonl_malformed_lines": {
    "tier": 1,
    "match_patterns": ["JSON parse error", "malformed.*jsonl", "invalid JSON.*line"],
    "source": "ocas_data",
    "auto_fix": "Move malformed lines to {file}.error",
    "reversibility": "Move .error lines back to original file",
    "description": "JSONL file contains malformed JSON lines blocking parsing",
    "technology_context": "JSON Lines parsing"
  },
  "oc_gateway_token_missing": {
    "tier": 1,
    "match_patterns": ["gateway token.*missing", "authentication.*gateway.*failed", "no gateway token"],
    "source": "gateway_log",
    "auto_fix": "openclaw doctor --generate-gateway-token",
    "reversibility": "Remove generated token from config",
    "description": "Gateway authentication token missing or invalid",
    "technology_context": "Node.js HTTP authentication token"
  },
  "oc_oauth_token_expiring": {
    "tier": 1,
    "match_patterns": ["token.*expir", "oauth.*refresh needed", "token_state.*expiring"],
    "source": "gateway_log",
    "auto_fix": "OAuth refresh (only when token still valid, expiry <= 12h)",
    "reversibility": "Token was valid before refresh -- no rollback needed",
    "description": "OAuth token approaching expiry, proactive refresh needed",
    "technology_context": "OAuth 2.0 token refresh"
  },
  "oc_background_task_missing": {
    "tier": 1,
    "match_patterns": ["missing.*cron.*job", "heartbeat.*entry.*missing", "background task.*not registered"],
    "source": "ocas_data",
    "auto_fix": "Register missing cron or heartbeat entry per SKILL.md declaration",
    "reversibility": "Remove registered entry",
    "description": "Declared background task not found in cron registry or HEARTBEAT.md",
    "technology_context": "Node.js launchd cron scheduler"
  },
  "oc_skill_uninitialized": {
    "tier": 1,
    "match_patterns": ["skill.*uninitialized", "missing.*data directory.*config", "init required"],
    "source": "ocas_data",
    "auto_fix": "Create storage dirs, default config.json, empty JSONL files",
    "reversibility": "Remove created files and directories",
    "description": "Installed skill has no data directory, config, or journal directory",
    "technology_context": "filesystem JSON configuration"
  },
  "oc_gateway_process_down": {
    "tier": 4,
    "match_patterns": ["gateway.*not running", "ECONNREFUSED.*18789", "gateway process.*dead"],
    "source": "gateway_log",
    "auto_fix": null,
    "reversibility": null,
    "description": "Gateway process is not running -- requires manual restart",
    "technology_context": "Node.js HTTP server process"
  },
  "oc_port_collision": {
    "tier": 4,
    "match_patterns": ["EADDRINUSE.*18789", "port.*18789.*in use", "address already in use"],
    "source": "gateway_log",
    "auto_fix": null,
    "reversibility": null,
    "description": "Port 18789 in use by another process -- requires manual resolution",
    "technology_context": "Node.js TCP port binding"
  },
  "oc_systemd_linger_disabled": {
    "tier": 4,
    "match_patterns": ["linger.*disabled", "systemd.*linger.*not enabled", "user service.*not persistent"],
    "source": "doctor",
    "auto_fix": null,
    "reversibility": null,
    "description": "systemd linger not enabled -- background services will not persist across logout",
    "technology_context": "systemd loginctl linger"
  },
  "oc_node_version_mismatch": {
    "tier": 4,
    "match_patterns": ["node.*version.*mismatch", "unsupported.*node.*version", "requires node"],
    "source": "doctor",
    "auto_fix": null,
    "reversibility": null,
    "description": "Node.js version does not meet OpenClaw requirements",
    "technology_context": "Node.js runtime version"
  }
}


path: references/plans/custodian-repair.plan.md
content: ---
plan_id: custodian-repair
name: Custodian Escalated Issue Repair
version: 1.0.0
description: Multi-step investigation and repair for Tier 3 escalated issues that Custodian could not auto-fix.
parameters:
  issue_id:
    type: string
    required: true
    description: The issue_id from Custodian's issues.jsonl to investigate and repair.
steps:
  - id: read-issue
    name: Read Escalated Issue
    skill: ocas-custodian
    command: custodian.issues.list
    on_failure: abort
  - id: read-fix-history
    name: Read Fix Effectiveness History
    skill: ocas-custodian
    command: custodian.status
    on_failure: skip
  - id: read-search-history
    name: Read Search History
    skill: ocas-custodian
    command: custodian.status
    on_failure: skip
  - id: diagnose
    name: Research and Diagnose Issue
    skill: ocas-sift
    command: sift.research.start
    on_failure: skip
  - id: propose-repair
    name: Propose Structured Repair
    skill: ocas-mentor
    command: mentor.project.create
    on_failure: abort
  - id: notify
    name: Notify User of Proposal
    skill: ocas-dispatch
    command: dispatch.draft
    on_failure: skip
---

## Step 1: read-issue

**Skill:** ocas-custodian
**Command:** custodian.issues.list

**Inputs:**
- Filter `issues.jsonl` at `~/openclaw/data/ocas-custodian/issues.jsonl` for record matching `issue_id: {{params.issue_id}}`

**Outputs:**
- `issue_record`: the full issue object including fingerprint, tier, status, recurrence_count, search_history

**On failure:** abort
**Notes:** If no matching issue_id found, abort with clear error message.

## Step 2: read-fix-history

**Skill:** ocas-custodian
**Command:** custodian.status

**Inputs:**
- Read `~/openclaw/data/ocas-custodian/fix_effectiveness.jsonl` for entries matching `fingerprint: {{steps.read-issue.issue_record.fingerprint}}`

**Outputs:**
- `fix_history`: array of fix effectiveness records for this fingerprint, showing attempts, successes, failures, recurrence

**On failure:** skip
**Notes:** Missing fix history means no prior auto-fix attempts were made for this fingerprint.

## Step 3: read-search-history

**Skill:** ocas-custodian
**Command:** custodian.status

**Inputs:**
- Extract `search_history` from `{{steps.read-issue.issue_record}}`

**Outputs:**
- `search_history`: array of prior web search attempts with queries used and results
- `already_tried_queries`: list of query strings already attempted

**On failure:** skip
**Notes:** Empty search history means no web searches have been attempted for this issue.

## Step 4: diagnose

**Skill:** ocas-sift
**Command:** sift.research.start

**Inputs:**
- Research goal: diagnose root cause of `{{steps.read-issue.issue_record.fingerprint}}`
- Context: issue description from `{{steps.read-issue.issue_record}}`
- Exclude queries already tried: `{{steps.read-search-history.already_tried_queries}}`
- Fix history showing what has already been attempted: `{{steps.read-fix-history.fix_history}}`

**Outputs:**
- `diagnosis`: structured research findings including probable root cause, recommended fix approach, and confidence level
- `sources`: list of sources consulted

**On failure:** skip
**Notes:** If Sift is not installed, this step is skipped. The proposal step will work with available information only.

## Step 5: propose-repair

**Skill:** ocas-mentor
**Command:** mentor.project.create

**Inputs:**
- Issue record: `{{steps.read-issue.issue_record}}`
- Fix history: `{{steps.read-fix-history.fix_history}}`
- Diagnosis: `{{steps.diagnose.diagnosis}}`

**Outputs:**
- `repair_proposal`: structured repair plan written to `~/openclaw/data/ocas-custodian/reports/repair-{{params.issue_id}}.md`

**On failure:** abort
**Notes:** The proposal must include: root cause assessment, recommended repair steps, risk evaluation, and rollback plan. Write the proposal as a Markdown file in the Custodian reports directory.

## Step 6: notify

**Skill:** ocas-dispatch
**Command:** dispatch.draft

**Inputs:**
- Proposal path: `~/openclaw/data/ocas-custodian/reports/repair-{{params.issue_id}}.md`
- Summary: "Custodian repair proposal ready for {{params.issue_id}}"

**Outputs:**
- `notification_sent`: boolean indicating whether the user was notified

**On failure:** skip
**Notes:** If Dispatch is not installed, log to `decisions.jsonl` instead. The proposal file is the primary deliverable regardless of notification.


path: skill.json
content: name: ocas-custodian
version: 1.0.0
description: Monitors OpenClaw gateway logs, cron jobs, skill journals, and OCAS data directories for operational failures. Detects errors, applies safe non-destructive fixes autonomously during quiet hours, initializes uninitialized skills, registers missing background tasks, and escalates issues it cannot fix. Use when asking about system health, log errors, cron failures, skill initialization, or overnight maintenance. Triggers on: 'check system health', 'fix log errors', 'why is X failing', 'initialize skills', 'clean up errors'.
author: Indigo Karasu
email: [REDACTED_SECRET]

Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: stale | SkillSpector: suspicious (CRITICAL)