Skip to content
Back to skills

Aqven Loop

ASecurity

Drives the AQVEN hypothesis-driven engineering loop from task decomposition to production: slicing workflows into sequential probes, formulating falsifiable single-variable hypotheses from traces, enforcing smoke and owner approval gates, and preventing semantic hardcoding. Use first when starting or resuming any AQVEN task, planning iterations, or reporting results.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentstypescriptgoexpresstesting

Security analysis

A100/100

Scanned December 5, 2026

npx -y skills add lastonoga/AQVEN --skill aqven-loop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Aqven Loop?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Aqven Loop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lastonoga-aqven-loop/badge)](https://www.skillsdirectory.com/skills/lastonoga-aqven-loop)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: aqven-loop
description: Drives the AQVEN hypothesis-driven engineering loop from task decomposition to production: slicing workflows into sequential probes, formulating falsifiable single-variable hypotheses from traces, enforcing smoke and owner approval gates, and preventing semantic hardcoding. Use first when starting or resuming any AQVEN task, planning iterations, or reporting results.
---

# AQVEN Engineering Loop & Decision Protocol (`aqven-loop`)

## MUST (Non-Negotiable Invariants)

1. **Sequential step discipline:** Decompose a business process into small `Input -> Output` probes, and finish **Step `N` to production quality before starting Step `N+1`**. Downstream steps depend on real upstream output shapes and error modes.
2. **Observe -> Instrument (`$0` recompute) -> Improve (never tune blind):** Start every new probe as **one minimal Level-1 `andAgent` call**, run a small `--smoke`, and **inspect the raw output items** for duplicates, child-array bloat, field echo, verbosity/degeneration noise, ungrounded quotes, and boundary ambiguity. **Attach targeted `metric.*` and `check.*` primitives and run `$0` `aqven evaluate recompute` on that baseline smoke BEFORE editing `prompt.ts`, `schema.ts`, or `workflow.ts`.** Never "fix" a failure mode you cannot measure.
3. **One variable per iteration:** Change **at most one axis** per run (`schema` | `prompt` | `model/provider` | `workflow shape` | `dataset`). Bundled edits make metric deltas unattributable.
4. **Zero deterministic semantic rewriting in AI workflows:** Never write post-processing code that renames canonical entities, strips/inserts domain words, or deduplicates semantic strings by regex/equality to hide model mistakes. Code owns validation, ID conservation, counts, and deterministic math (`remeda`); semantic naming and merge decisions belong to prompts, matchers, and models.
5. **Semantic quality over exact string matching:** Naming variants are acceptable unless downstream code keys on an enum/ID. Optimize for semantic coverage, zero invented/hallucinated entities, and stable keep/drop/merge decisions across runs — never overfit prompts just to mimic exact Golden wording.
6. **Library & reusable helpers stay 100% domain/language agnostic:** Domain rules live only inside the specific probe (`probes/<name>/`), never in shared utilities.
7. **Free checks before paid tokens; smoke gate before scale:** Always run `$0` `probe validate` + `$0` `probe test` (mock) -> small paid `--smoke` (3–10 items). **Never launch `stabilize` or a full dataset run without explicit owner review and approval of the latest smoke** on that exact probe + dataset.
8. **Resume, do not restart:** When a multi-step run aborts on a transient provider/network failure, resume from the failed step checkpoint (`aqven resume <runId> [--step <id> | --restart]`) rather than re-paying completed upstream steps.
9. **Respect scope limits:** When the owner says *"discuss options first"*, *"keep it simple"*, or *"do not edit yet"*, write zero probe changes and launch zero paid runs — present options with trade-offs and wait.

---

## How to Decompose a Process into Probes

Before writing any code, separate **deterministic work** from **irreducible semantic work**:

```text
Raw Business Process
 ├── Deterministic (TypeScript + remeda, $0): parsing, filtering, ID minting, counts, offsets, joins, formatting
 └── Ambiguous / Semantic (AQVEN Probe): classification, extraction, entity resolution, rubric auditing
```

Ask five questions for each candidate LLM step (**Work Contract & Context Hygiene**):
1. **Input contract & Sufficient Context test:** Does every field exist at production runtime (zero benchmark leakage), AND *could a careful human answer using only the provided input*? If not, add missing upstream data/retrieval before touching the prompt.
2. **Context rot minimization:** Are you passing the **smallest set of high-signal tokens**? Strip unused fields and coherent distractors — accuracy degrades with length well before `200K–1M` nominal limits (*Lost in the Middle*).
3. **Decision scope & split boundary:** Split into separate probes **only** when uncertainty type changes (extraction -> classification -> judgment), when a deterministic gate can check the intermediate output, or when error cost / model tier changes (never chain `> 5–7` un-gated steps — Lusser's Law $p^n$).
4. **Output contract:** What is the minimal downstream decision this output feeds, and which error hurts more (missed item vs false alarm vs latency vs cost)?
5. **Simplicity check:** Can a **single Level-1 `andAgent` call** solve this? Start there; multi-step patterns require trace evidence first (`aqven-build`).

### Architectural Code Smells to Reject Immediately
- **Monolith mega-prompt** mixing extraction, classification, and formatting without intermediate gates.
- **Over-decomposition** (`> 5–7` sequential LLM calls) losing holistic context and compounding errors.
- **Self-critique loop without an external signal or asymmetric model** (degrades accuracy via shared blind spots).
- **Divergence (`best-of-N`) against systematic prompt bias** (multiplies cost without fixing correlated errors).
- **"Schema valid = accurate" fallacy** (99% valid JSON regularly hides 10–20% semantic errors without Golden/trace review).

---

## The 6-Stage Engineering Cycle

| Stage | Action | Exit Criterion |
|---|---|---|
| **0. Dataset & Minimal L1 Wire ($0)** | Assemble a representative starter slice (5–20 real cases with edge cases). Write **one minimal Level-1 `andAgent` probe** (`schema.ts`, `prompt.ts`, `inferences.ts`, `workflow.ts`, `probe.ts`) with basic ID/coverage checks. Run `aqven probe validate <id>` and `aqven probe test <id> --dataset <path>`. | Representative starter dataset ready, `0` validation errors, mock selftest green (`$0.00` spent). |
| **1. Single-Call Smoke & Raw Output Audit** | Run `aqven run <id> --dataset <path> --smoke 5`. **Do NOT edit prompts yet.** Inspect rendered prompts, raw model replies, and actual output items (`aqven_step_query`, `aqven_step_content`, `aqven_run_trace`) to catalogue real defects: duplicate/split items, child-array repetition, field echo, optional-field bloat, verbosity/looping, ungrounded quotes, and unstable boundaries. | Every concrete noise pattern, structural violation, and unstable boundary in the L1 output is catalogued from real items (never guessed). |
| **2. Instrument First ($0 Recompute) & Golden v1** | Before changing any prompt/schema/workflow, wire targeted `metric.*` and `check.*` detectors (`polarity`, `target`, clear `desc`) in `probe.ts` for every defect spotted in Stage 1 (`aqven-evaluate`), and run `$0` `aqven evaluate recompute <smokeRunId>` to lock in baseline numbers. Build/approve Golden v1 (`aqven golden queue -> ingest -> build -> approve`) with owner sign-off. | Baseline noise & quality metrics quantified on Run 1 at `$0`; frozen Golden v1 benchmark approved by the owner. |
| **3. Single-Variable Calibration Loop** | Run `aqven_run_conclude({ runId })` + `aqven_history({ probeId })`. Triage disagreements (*pipeline/context bug* vs *Golden gap* vs *over-strict matcher / valid alias* vs *generic prompt rule gap*). Record `aqven_note_add({ runId, text })` -> change **1 variable** -> verify on `--smoke` that target noise/error metrics improve (`improved: true`) without regressing recall/precision. | Every run has a recorded note (`evidence + falsifiable hypothesis + 1 changed variable`); instrumented metrics, Golden, and generic prompt converge cleanly. |
| **4. Smoke Gate & Full Run** | Run `aqven_run_compare({ runA, runB })` / `aqven_run_get({ runId, selectors: ["golden"] })`. Present metric deltas (including noise/redundancy metrics), cost, latency, and concrete item diffs to the owner. Once the owner approves `--smoke`, run `--full` to inspect tail/corpus-wide errors. | Owner explicitly accepts `--smoke`, and `--full` passes all checks and metric targets with clean Golden coverage. |
| **5. Stability, Matrix Compare & Ship** | After `--full` is clean and owner approves, run `aqven stabilize <id> ... -n 10` (compare matrices via `aqven_matrix_compare`). Audit `infra`, `pass^m`, `gap`, `ARI`, `targetMetRuns`, and per-stage losses. If metrics plateau, run **External Research** (below) and iterate until the owner signs off -> import `probe.workflow` into production and unlock Step `N+1`. | Consecutive clean runs, `pass^m`, Golden, and noise targets met across repeats, owner signs off -> unlock Step `N+1`. |

---

## First-Smoke Output Audit: What to Inspect & Instrument Before Editing

After your very first Level-1 `--smoke` run, inspect the emitted items (`aqven_step_query` / `aqven_artifact_get`) across 6 failure axes and **attach `$0` metrics/checks in `probe.ts` before making your first prompt or schema edit**:

1. **Duplicate / split items & redundant child records:** Are two items or child entries (e.g. terms, rules, attributes) expressing the same real-world fact, or is a partial `null` stub emitted alongside a fuller sibling? -> Add `metric.redundancy({ groupBy, key | matcher, nullSubsumes })` + `check.uniqueBy`.
2. **Cross-field echo & optional-field bloat:** Are free-text fields (`notes`, `conditions`, `summary`) repeating numbers, currencies, or labels already captured in structured fields, or filling nullable fields unnecessarily? -> Add `metric.fieldEcho`, `metric.fillRate`, and `check.implication` / `metric.violationRate`.
3. **Verbosity bloat & repetition loops:** Are rationales or descriptions wordy ("keep it short" violated) or repeating phrases? -> Add `metric.verbosity` (`words` / `chars`) and `metric.degeneration` (`rep-n` + compression ratio).
4. **Ungrounded citations:** Are `quote` spans paraphrased or absent from `sourceText`? -> Add `metric.quoteGrounding` and/or `check.groundedQuote`.
5. **Enum / category skew & retry churn:** Is the model collapsing everything into one safe enum bucket or burning schema-repair retries? -> Add `metric.distribution`, `metric.categoryEntropy`, and `metric.retryRate()`.
6. **Boundary ambiguity & flakiness candidates:** Spot items where two categories overlap or phrasing is borderline -> record them as Golden edge cases and verify `fieldStability` / `pass^m` once at the matrix stage.

Run `aqven evaluate recompute <smokeRunId>` (`$0`) immediately after adding these metrics so Run 1 has a complete quantitative baseline before Run 2!

---

## Run-Tier Decision Logic: When to Run `--smoke`, `--full`, Micro-A/B, or Matrix

Choose the **cheapest run tier** that can falsify your current hypothesis — never jump straight to `--full` or `-n 10` when a cheaper check answers the question:

| Run Tier | Cost / Scope | Run When… | Gate / Next Step |
|---|---|---|---|
| **`$0` Validate + Mock** (`probe validate` + `probe test`) | `$0`, seconds | After **every** edit to `schema.ts`, `prompt.ts`, `inferences.ts`, `workflow.ts`, or `probe.ts`. | Must pass with `0` errors before any live LLM call. |
| **Frozen Micro-A/B** (`1` targeted call on a saved failing step) | `~$0.01–0.02` | Testing a surgical prompt/critic/model hypothesis on a specific known failing case from a prior matrix. | If 1-to-1 diff improves the target case without regressions -> verify on `--smoke`. |
| **Smoke Run** (`--smoke 2..10`) | Pennies, `< 1 min` | 1) First cold-start run of a new probe; 2) After **every** single-variable change (`prompt`, `schema`, `model`, `workflow`); 3) Before **any** `--full` or `stabilize` run on a new `probe_hash` or dataset. | Present metrics, cost, and concrete trace diffs -> wait for **explicit owner approval**. |
| **Full Dataset Run** (`--full`, `n = 1`) | `1×` corpus cost | Owner approved `--smoke` on this exact `probe_hash`, and you need to: 1) build or calibrate Golden across real tail cases, 2) verify corpus-wide `Recall / Precision / F1`, or 3) confirm a major change before paying `10×` for a matrix. | Inspect `missing` / `runOnly` / `moved` and per-stage traces. Do **not** launch `stabilize` if `--full` already shows obvious deterministic/prompt bugs. |
| **Variant Matrix** (`--matrix`, `m = 1..3`) | `2–5×` variants | Comparing 2–5 candidate models, reasoning levels, or workflow/prompt variants head-to-head on the exact same dataset slice. | Pick winner on quality × cost × latency -> run `--smoke` / `stabilize` on the winner. |
| **Stability Matrix** (`stabilize -n 10`, `m = 8..12`) | `10×` corpus cost | `--full` is already clean (checks green, Golden & matcher calibrated, no obvious single-run defects) **and** owner approved — to measure true `pass@1`, `pass^m`, `gap`, `ARI`, and hidden flakiness/splits before shipping. | If `pass^m` / `gap` / Golden meet owner's bar -> ship & unlock Step `N+1`. If plateaued -> run Stage Attribution, EDA, or External Research. |

---

## How to Formulate Hypotheses, Diagnose Plateaus & Research Solutions

Never "tweak the prompt and hope." After reading `conclude` + failing attempt traces:

1. **Separate 4 root-cause classes first (`aqven-debug`):**
   - *Wiring / Context bug* (missing item, truncated input, duplicated raw payloads causing context rot) -> fix code immediately; no prompt experiment needed.
   - *Golden or Matcher mismatch* (model found a valid record missing from Golden, or emitted an acceptable synonym/equivalent form) -> propose `golden fork` or relax matcher (`aliasField` / semantic matcher) instead of overfitting the prompt.
   - *Provider / Model bottleneck* (`finish_reason: length`, `429`, `3×+` slow upstream, `int4` drift) -> fix in `aqven-models` (or run a 3–4 upstream mini-benchmark).
   - *Generic specification or architecture gap* (clean input + right matcher, yet model still confuses classes, drops items, or oscillates) -> form an explicit single-variable hypothesis.
2. **Stage-by-Stage Attribution & Deterministic EDA (before adding complexity):**
   - In multi-stage workflows, measure recall/precision **before and after each stage** to see which boundary actually loses quality (e.g., upstream extraction vs merge/bucketing vs critic self-preference bias).
   - Before adding new heuristics or workflow steps, run a **deterministic EDA script** over past run artifacts to test whether structural features (input length, evidence/source count, cluster/bucket size) correlate with `present/m` or `missing`. If confirmed by data, pass the clean deterministic statistic as input context to the LLM — never hardcode semantic drop/rename rules in code.
3. **Plateau -> External Research -> Next Experiment:**
   - When 2–3 targeted generic prompt edits stop moving `F1`, `pass^m`, `gap`, or `ARI`, **stop guessing** and search external literature and engineering case studies for the exact failure class (e.g., *long-list attention dilution / blocking & ordering*, *pairwise vs listwise comparison*, *critic oscillation / scope-lock*, *cross-family judge bias*, *embedding pre-clustering*, *bucket-size bounds*).
   - Translate the strongest candidate approaches into 2–3 ranked, AQVEN-compliant experiment proposals, each naming: **target metric**, **expected mechanism**, **cost/risk trade-off**, and **cheapest validation tier** (micro-A/B -> `--smoke` -> `--full` -> `stabilize`).
4. **Write a falsifiable thesis before editing (`aqven_note_add({ runId, text })` or `aqven note --run <prevRunId>`):**
   > *"In run `<runId>`, 4/12 items (`item-7`, `item-12`, …) merged distinct categories because `categoryEnum` lacked boundary rules between X and Y. Hypothesis: clarifying `categoryEnum` descriptions will eliminate these 4 merges without increasing false splits on the remaining 8 items."*
5. **Prompt-edit preservation rule:** Before modifying `prompt.ts`, diff against the previous version and list every verified constraint carried forward so earlier fixes never silently vanish during rewording.

## Reporting Format to the Owner

Keep updates concise and evidence-first:
1. **Run & setup:** `<runId>` (`probe@vN`, dataset slice, model + pinned provider, `$cost`, duration).
2. **Outcome vs baseline:** Primary metric & Golden diff (`+X / -Y` items), check statuses, any flaky/infra issues.
3. **Root cause from traces:** 1–2 concrete item IDs showing *why* remaining failures happened.
4. **Proposed single next step (or 2–3 options with trade-offs):** Wait for owner approval when crossing a gate (Golden fork, model swap, workflow escalation, or full/stability run).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.