Aris meta optimize

From OpenLAIR/dr-claw · View interactive version

Aris meta optimize is an AI agent skill from the GitHub repository OpenLAIR/dr-claw. Analyze ARIS usage logs and propose optimizations to SKILL.md files, reviewer prompts, and workflow defaults. Outer-loop harness optimization inspired by Meta-Harness (Lee et al., 2026). Use when user says \"优化技能\", \"meta optimize\", \"improve skills\", \"分析使用记录\", or wants to optimize ARIS's own h

How to use this skill

Skill file

Meta-Optimize: Outer-Loop Harness Optimization for ARIS

Analyze accumulated usage logs and propose optimizations for: $ARGUMENTS

Privilege boundary — this skill is a READ-ONLY PRODUCER

aris-meta-optimize proposes; it does not land. The mutation of the skill corpus

is the exclusive job of a separate, human-invoked skill: CODE0.

This is a workflow/tool-grant boundary, not an OS sandbox. The skill does

not request Write/Edit and has no apply step. Its legitimate Bash writes are

reports, staged diffs and bookkeeping under .aris/meta/, plus forensic reviewer

traces under .aris/traces/. allowed-tools does not revoke capabilities granted

by the host; do not claim a prompt can prevent every filesystem write.

The optional CODE0

PreToolUse hook filters common Bash corpus-write patterns. It is a blacklist,

NOT a complete sandbox: obfuscated writes, absolute paths, git apply and

other language APIs can escape it. It does not gate Write/Edit. Full prevention

requires host-enforced read-only corpus permissions. No pre-push provenance

integrity verifier is installed; deliberate bypass is not actively detected.

See skill governance.

See CODE0:

a loop can DRIVE (propose, review) same-model, but the ACQUITTAL that lands a change

must be cross-model (fresh landing jury, not Step 4 advisory screen) and the landing must be a separate human-gated

act (/aris-meta-apply).

Context

ARIS is a research harness — a system of skills, bridges, workflows, and artifact contracts that wraps around LLMs to orchestrate research. This skill implements a prototype outer loop that observes how the harness is used and proposes improvements to the harness itself (not to the research artifacts it produces).

Inspired by Meta-Harness (Lee et al., 2026): the key insight is that harness design matters as much as model weights, and harness engineering can be partially automated by logging execution traces and using them to guide improvements.

What This Skill Optimizes (Harness Components)

| Component | Example | Optimizable? |

|-----------|---------|:---:|

| SKILL.md prompts | Reviewer instructions, quality gates, step descriptions | Yes |

| Default parameters | difficulty: medium, MAX_ROUNDS: 4, threshold: 6/10 | Yes |

| Convergence rules | When to stop the review loop, retry counts | Yes |

| Workflow ordering | Skill chain sequence within a workflow | Yes |

| Artifact schemas | What fields go in EXPERIMENT_LOG.md, idea-stage/IDEA_REPORT.md | Cautious |

| MCP bridge config | Which reviewer model, routing rules | No (infra) |

Not optimized: The research artifacts themselves (papers, code, experiments). That's what the regular workflows do.

Prerequisites

  1. Logging is opt-in. Follow Workflow M setup

to preview and explicitly merge hooks, preserving existing .claude/settings.json.

Never copy a template over that file or auto-enable logging.

  1. Sufficient evidence. The readiness heuristic is at least 5 logged skill

invocations, not proof of 5 complete workflows. Check run completeness and

target-specific evidence before proposing changes.

  1. Resolve helpers using integration-contract.md §2.

Before review read reviewer-routing.md

for capability/family gates and review-tracing.md.

Missing/unusable reviewer means REVIEW_UNAVAILABLE, never implicit approval.

Workflow

Step 0: Check Data Availability

EVENTS_FILE=".aris/meta/events.jsonl"
if [ ! -f "$EVENTS_FILE" ]; then
    echo "ERROR: No event log found at $EVENTS_FILE"
    echo "Enable logging only by explicit merge; see docs/aris-self-evolution.md"
    exit 1
fi

EVENT_COUNT=$(wc -l < "$EVENTS_FILE")
SKILL_INVOCATIONS=$(grep -cE '"event": *"skill_invoke"' "$EVENTS_FILE" || true)
SESSIONS=$(grep -cE '"event": *"session_start"' "$EVENTS_FILE" || true)

echo "📊 Event log: $EVENT_COUNT events, $SKILL_INVOCATIONS skill invocations, $SESSIONS sessions"

if [ "$SKILL_INVOCATIONS" -lt 5 ]; then
    echo "⚠️  Insufficient data (<5 skill invocations). Continue using ARIS normally and re-run later."
    exit 0
fi

# Bottleneck succession: what did the LAST cycle say was the limiting stage?
BOTTLENECK_LOG=".aris/meta/bottleneck_log.jsonl"
if [ -f "$BOTTLENECK_LOG" ]; then
    echo "🧭 Prior cycle's bottleneck: $(tail -1 "$BOTTLENECK_LOG")"
fi

If a prior bottleneck entry exists, open the report (Step 5) by stating whether

that named bottleneck was resolved (and by which landed patches) and what it

has now moved to — bottleneck SUCCESSION, not just existence, is the signal

this ledger exists to carry.

Step 1: Analyze Usage Patterns

Read .aris/meta/events.jsonl and compute:

Frequency analysis:

Failure analysis:

Convergence analysis (for aris-auto-review-loop):

Human intervention analysis:

Model-delta analysis (harness diet):

reviewer model changed since a skill's SKILL.md was last touched?

(git log -1 --format=%cs -- skills/<skill>/SKILL.md vs the model-bump date.)

reasoning-scaffolding step or worked example in that SKILL.md, a deletion

proposal must cite TARGET-SPECIFIC evidence that the new model no longer

needs it: a capability-specific release note, or repeated observed behavior

in the event log (e.g. zero failures/interventions in the guarded step since

the bump). "The model got newer" alone never justifies a deletion.

acceptance/review gates, corpus- and provenance-integrity rules, output

contracts, and safety checks. The diet targets model-compensation scaffolding

only — a capability the new model has natively is pure overhead (context

weight, drift surface, reading cost). A harness that only ever grows is a

harness nobody is re-reading.

Trigger-rate analysis (optional, measured — not from the event log):

— the omission failure mode (Claude Code passing over the right skill when the

installed list is long) is invisible to it. skills/aris-infra/tools/meta_opt/trigger_eval.py

measures it directly: claude -p probes with paraphrased-intent queries run

from a neutral cwd (so the realistic long installed corpus is loaded), scored

as trigger / confusion(→which skill) / miss.

run it when a specific skill is suspected of under- or mis-triggering, or as a

before/after check around a description edit:

python3 "$TRIGGER_EVAL" --eval-file "$ARIS_INFRA/tools/meta_opt/trigger_evals.sample.json" --skills <aris-skill-name> --samples 2

landing on a sibling skill means the two descriptions overlap on that intent —

the fix is disambiguation, not "make the description pushier".

Step-2 proposal (which lands only via /aris-meta-apply), never a self-applied

description rewrite. Trigger rate is model-dependent, so compare like with

like (record the probe model) and treat it as a proxy — it measures selection

under a query set, not the full long-list omission problem.

Present findings as a structured summary table.

Step 1.5: Name the Current Bottleneck

Synthesize the Step-1 analyses into **one sentence naming the single

most-limiting pipeline stage right now** — e.g. "planning", "verification

quality", "experiment execution reliability", "writing polish" — with the

supporting evidence. The bottleneck always moves: when coding stops being the

constraint, planning becomes it; when planning is solved, verification; when

verification is automated, taste. This step exists to make the CURRENT

constraint visible, so Step 2's ranked table reads as sub-fixes for one named

constraint instead of scattered tweaks.

Append the verdict to the append-only ledger .aris/meta/bottleneck_log.jsonl

(same never-mutate discipline as .aris/runs/<run_id>.iterations.jsonl):

The values below illustrate the schema; replace cycle, evidence, bottleneck and

patch IDs with this run's observations before appending.

mkdir -p .aris/meta
# json.dumps, NOT hand-interpolated shell strings: bottleneck/evidence are
# natural language — a stray quote must not break the JSONL (or the shell).
python3 - <<'PY'
import json, datetime
entry = {
    "ts": datetime.datetime.now().astimezone().isoformat(timespec="seconds"),
    "cycle": 3,
    "bottleneck": "verification quality",
    "evidence": "review rounds plateau at 6/10 while tool failures are rare",
    "top_patch_ids": ["P1", "P2"],
}
with open(".aris/meta/bottleneck_log.jsonl", "a", encoding="utf-8") as fh:
    fh.write(json.dumps(entry, ensure_ascii=False) + "\n")
PY

Never edit or delete prior lines — succession history is the point.

Step 2: Identify Optimization Targets

Based on Step 1, rank optimization opportunities by expected impact:

## Optimization Opportunities (ranked)

| # | Target | Signal | Proposed Change | Expected Impact |
|---|--------|--------|-----------------|-----------------|
| 1 | aris-auto-review-loop default threshold | Users override to 7/10 in 60% of runs | Change default from 6/10 to 7/10 | Fewer manual overrides |
| 2 | aris-experiment-bridge retry count | 40% of runs hit max retries on OOM | Add OOM-specific recovery (reduce batch size) | Fewer failed experiments |
| 3 | aris-paper-write de-AI patterns | Users manually fix "delve" in 80% of runs | Add "delve" to default watchword list | Fewer manual edits |
| 4 | aris-experiment-bridge Phase-2 hand-holding steps | Model bump (session_start model changed); scaffold untouched since 2 generations ago; zero tool_failures in the steps it guards | **DELETE steps N–M — the new model does this unprompted** | Smaller harness, less drift surface |

The Proposed-Change column is explicitly allowed to be a deletion — "DELETE

step N, new model does this for free" is a first-class optimization, ranked by

the same impact logic as additions.

If $ARGUMENTS specifies a target skill, focus analysis on that skill only.

If $ARGUMENTS is empty or "all", analyze all skills with sufficient data.

Step 3: Generate Patch Proposals

For each optimization target, generate a concrete diff:

--- a/skills/aris-auto-review-loop/SKILL.md
+++ b/skills/aris-auto-review-loop/SKILL.md
@@ -15,7 +15,7 @@
 ## Constants
 
-- **SCORE_THRESHOLD = 6** — Minimum review score to accept.
+- **SCORE_THRESHOLD = 7** — Minimum review score to accept. (Raised based on usage data: 60% of users overrode to 7+.)

Rules for patch generation:

run a proposed patch's rationale through python3 "$CAPTURE_FILTER" <rationale-file>

(resolve per integration-contract §2). NEVER propose a change that encodes a **negative

tool-capability claim ("codex can't…", "gemini is broken") or a one-off /

transient failure** as a durable rule — those harden into self-cited refusals.

Encode the fix / the flag needed / the workaround, not "X can't do Y".

Step 4: Cross-Model Review of Patches (ADVISORY pre-screen)

This review is advisory — it sharpens the Step-5 REPORT so the human can decide

what to stage. It is not the landing verdict. The binding cross-model jury runs

later, at landing, inside CODE0, on the actual staged

diff (a producer-relayed verdict would be forgeable). Record this result as

advisory_screen only.

Send each patch to GPT-6-Astra xhigh for adversarial review:

mcp__codex__codex:
  model: gpt-6-astra
  config: {"model_reasoning_effort": "xhigh"}
  sandbox: read-only
  cwd: <absolute project root>
  prompt: |
    You are reviewing a proposed optimization to an ARIS SKILL.md file.
    
    Read these primary files yourself:
    - Original skill: <absolute corpus path>
    - Proposed patch: <absolute scratch diff path>
    - Usage evidence: <absolute event log path>
    Do not rely on producer-written summaries or prior verdicts.
    
    Review this patch:
    1. Does the evidence support the change?
    2. Could this change hurt other use cases?
    3. Is the change minimal and safe?
    4. Score 1-10: should this be applied?
    
    If score < 7, explain what additional evidence would be needed.

    === SCOPE LIMITS (these bound what you PROPOSE, never what you look for) ===
    Report anything that is actually wrong here — including a rare-looking case, if
    this repo actually produces it. Then keep the fix in scope:
    1. This is a RESEARCH-WORKFLOW tool, not a security paper. Verification is
       welcome; over-defense is not. Assume a cooperating operator on their own
       machine — a malicious local user is NOT in the threat model.
    2. Do NOT propose SHA / hash / content-fingerprint / digest-binding schemes.
       Reporting a real defect in hashing code that already exists is fine.
    3. NO speculative machinery: do not add feature flags, migration frameworks,
       compat layers, wrappers, pins, or similar mechanisms unless evidence shows
       a current repo defect they fix or an explicit existing invariant they must
       preserve. "Load-bearing", "compatibility", and "not scaffolding" are labels,
       not evidence. Point to the failing path/artifact or invariant, and check the
       proposal's factual premises, such as whether a named package version exists.
    4. NO corner-case obsession: exotic encodings, symlink races, RTL text and
       millisecond races are out of scope unless you can show the case arises here.
    5. Where a rubric or checklist is genuinely needed, do not over-mechanize
       judgement. A clear sentence a human reads beats a scored table nobody
       maintains.
    Exception: code that runs remote commands, starts a network service, or installs
    an MCP server runs on the user's machine with their credentials — trust-boundary
    findings there are in scope and the default is strict.
    Say plainly when something is correct. Do not manufacture findings.

Step 5: Present Results

Output a structured report:

# ARIS Meta-Optimization Report

**Date**: [today]
**Data**: [N] events, [M] skill invocations, [K] sessions
**Target**: [skill name or "all"]

## Current Bottleneck

**[one-phrase name]** — [one-line evidence]. Prior cycle's bottleneck: [name —
resolved by <patch ids> / unresolved / first recorded cycle]. (Ledger:
`.aris/meta/bottleneck_log.jsonl`)

## Proposed Changes

### Change 1: [title]
- **Target**: [skill/file:line]
- **Signal**: [what the data shows]
- **Patch**: [diff]
- **Reviewer Score**: [X/10]
- **Reviewer Notes**: [summary]
- **Advisory screen only**: ✅ Recommended / ⚠️ Needs more data / ❌ Rejected

### Change 2: ...

## Changes NOT Made (insufficient evidence)
- [pattern observed but too few samples]

## Recommendations
- [ ] Apply Change 1 (reviewer approved)
- [ ] Collect more data for Change 3 (need N more runs)
- [ ] Consider manual review of Change 2

## Next Steps
This skill only **proposes**. To land changes: tell me which to stage, then run
`/aris-meta-apply` (a separate, human-invoked applier that re-checks the cross-model
verdict before mutating anything). aris-meta-optimize never applies.

Step 6: Stage approved patches for `/aris-meta-apply` (NO in-skill apply)

This skill does not apply anything. After the user has read the Step-5 REPORT and

indicated which changes to land, stage them for the privileged applier:

  1. For each approved change N, write its unified diff to

.aris/meta/pending/<NN>_<skill>.diff and append a row to

.aris/meta/pending/manifest.jsonl:

`{patch: "<NN>_<skill>.diff", target: "<corpus path>", author_model: "<executor>",

advisory_screen: "pass|kill", advisory_reason: "<one line>"}`.

The advisory_screen (your Step-4 codex pre-review) is advisory only — it helps

the human read the REPORT. It is NOT the landing verdict and /aris-meta-apply does not

trust it: a producer-written verdict would be forgeable. The binding cross-model jury

runs at landing, inside /aris-meta-apply, on the actual staged diff.

  1. Tell the user: "Staged M patches. Run /aris-meta-apply to judge & land them."

The backup → fresh jury-at-landing → apply → provenance stamp → log all happen

inside CODE0. aris-meta-optimize never touches the corpus and

never produces the acquittal.

Never apply in this skill. Landing is /aris-meta-apply + a fresh jury + a human, always.

Key Rules

Event Schema Reference

The log at .aris/meta/events.jsonl contains JSONL records with these shapes:

{"ts":"...","session":"...","event":"skill_invoke","skill":"aris-auto-review-loop","args":"difficulty: hard"}
{"ts":"...","session":"...","event":"PostToolUse","tool":"Bash","input_summary":"pdflatex main.tex"}
{"ts":"...","session":"...","event":"codex_call","tool":"mcp__codex__codex","input_summary":"review..."}
{"ts":"...","session":"...","event":"tool_failure","tool":"Bash","input_summary":"python train.py"}
{"ts":"...","session":"...","event":"slash_command","command":"/aris-auto-review-loop","args":""}
{"ts":"...","session":"...","event":"user_prompt","prompt_preview":"change difficulty to hard"}
{"ts":"...","session":"...","event":"session_start","source":"startup","model":"claude-opus-4-6"}
{"ts":"...","session":"...","event":"session_end"}

Triggering

This skill is NOT part of the standard W1→W1.5→W2→W3→W4 pipeline. It is a maintenance workflow with three trigger mechanisms:

  1. Passive logging (only after explicit opt-in): Claude Code hooks record events to .aris/meta/events.jsonl automatically during normal usage. Zero user effort.
  1. Automatic readiness check (SessionEnd hook): When a Claude Code session ends, check_ready.sh counts skill invocations since the last /aris-meta-optimize run. If ≥5 new invocations have accumulated, it prints a reminder:

```

📊 ARIS has logged 8 skill runs since last optimization. Run /aris-meta-optimize to check for improvement opportunities.

```

It ALSO fires — regardless of invocation count — when the session model has

changed since the last optimize (compared against .aris/meta/.last_optimize_model):

```

🔁 Model changed since last optimization (claude-opus-4-6 → claude-opus-4-8). Run /aris-meta-optimize — a model bump makes existing scaffolding a deletion candidate (harness diet).

```

Both are suggestions only — they do not auto-run optimization.

  1. Manual trigger: User runs /aris-meta-optimize when they see the reminder or whenever they want.

After each /aris-meta-optimize run, the skill writes the current timestamp to .aris/meta/.last_optimize and the current session model (latest session_start event's model field) to .aris/meta/.last_optimize_model, so the readiness check can detect both new usage and model bumps. Use UTC YYYY-MM-DDTHH:MM:SSZ for .last_optimize, matching the logger. Do not update either marker when analysis is skipped for insufficient data or fails.

Acknowledgements

Inspired by Meta-Harness (Lee et al., 2026) — end-to-end optimization of model harnesses via filesystem-based experience access and agentic code search.

Output Protocols

Follow these shared protocols for all output files:

- Output Versioning Protocol — write timestamped file first, then copy to fixed name

- Output Manifest Protocol — maintenance-only manifest rules

- Output Language Protocol — respect the project's language setting

Review Tracing

After each mcp__codex__codex or mcp__codex__codex-reply reviewer call, save the trace following ../aris-infra/shared-references/review-tracing.md (Policy C — forensic; never silently skip). Use save_trace.sh (resolved per the chain in ../aris-infra/shared-references/integration-contract.md §2) or write files directly to .aris/traces/<skill>/<date>_run<NN>/. Respect the --- trace: parameter (default: full).

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.