Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions skills/arena/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,56 @@ Open a todolist tracking the operational phases:

## Phase A: Frame

1. **Artifact.** Define the target output each candidate must produce.
2. **Rubric.** Formulate 3-6 concrete, gradeable criteria (e.g. `Adds a --dry-run flag that skips writes`).
3. **Runners.** Use `arena runners` from `~/.gemini/config/plugins/agystack/agystack-models.md` if configured, or default across available tiers: `pro`, `flash`, `inherit`.
Every candidate receives the same prompt, so the prompt is the contract.

1. **Artifact.** Define the target output each candidate produces.
2. **Rubric.** Formulate 3 to 6 concrete, gradeable criteria for this task, such as `Adds a --dry-run flag that skips writes`. Candidates see only the task. The picker uses the rubric in Phase D.
3. **Runners.** Read `arena runners` from `~/.gemini/config/plugins/agystack/agystack-models.md` (or `.agents/plugins/agystack/agystack-models.md`), defaulting across `inherit`, `flash`, and `pro`. An `inherit` or `auto` entry runs on the parent session's model (`Model: "inherit"`). If `invoke_subagent` rejects a tier or slot, use the nearest valid tier or drop the seat, keep at least two runners, and note the fallback. Repeat one model tier when the work is generation-bound rather than judgment-sensitive.
4. **Workspaces.** Assign isolated workspaces via `Workspace: "branch"` or scratch paths (`<appDataDir>/brain/<conversation-id>/scratch/arena-<slug>/candidate-<n>/`) per **principle-separate-before-serializing-shared-state**.

## Phase B: Fan out

Spawn all N subagents in one turn via `invoke_subagent` with `Workspace: "branch"` (never simulate in-context), `TypeName: "self"` (or `"poteto-agent"`), the task, grounding, output path, and instructions for producing the artifact and rationale.
Spawn all N subagents in one turn via `invoke_subagent` with `Workspace: "branch"` (never simulate in-context), `TypeName: "self"` (or `"poteto-agent"`), the task, grounding path, output path, and instructions to produce the artifact plus a short rationale naming alternatives considered and rejected. If a candidate produces no output or drops out, proceed with `N-1` and record the dropout.

Provide `{PARENT_CONVERSATION_ID}` in each prompt. Candidates MUST invoke `send_message` with `Recipient: "{PARENT_CONVERSATION_ID}"` upon completion to wake the coordinator reactively.

### Reactive Dispatch & Watchdog Protocol

1. **Turn 1 (Dispatch & Arm):** Launch candidate subagents via `invoke_subagent` and arm a single watchdog deadline:
1. **Turn 1 (Dispatch and Arm).** Launch candidate subagents via `invoke_subagent` and arm a single watchdog deadline:
`schedule(DurationSeconds: 300..600, Prompt="Watchdog: arena candidates timed out", TimerCondition: "never")`
2. **Turn 2 (Mechanical Yield):** Output an update message with ZERO tool calls (`tool_calls: []`). Busy polling via `manage_subagents(list)` is prohibited.
3. **Partial Arrivals:** When a candidate reports via `send_message`, record its artifact and yield immediately with ZERO tool calls if others remain running.
4. **Full Arrival:** When all N candidates report, cancel the watchdog timer via `manage_task(Action: "kill", TaskId: <timer_task_id>)` and proceed to Phase C.
5. **Timeout Fallback:** If the watchdog fires, inspect worker statuses via `manage_subagents(Action: "list")`, terminate hanging candidates (`manage_subagents(Action: "kill", ConversationIds: [<id>])`), and proceed with surviving outputs.
2. **Turn 2 (Mechanical Yield).** Output an update message with ZERO tool calls (`tool_calls: []`). Busy polling via `manage_subagents(list)` is prohibited.
3. **Partial Arrivals.** When a candidate reports via `send_message`, record its artifact and yield immediately with ZERO tool calls if others remain running.
4. **Full Arrival.** When all N candidates report, cancel the watchdog timer via `manage_task(Action: "kill", TaskId: <timer_task_id>)` and proceed to Phase C.
5. **Timeout Fallback.** If the watchdog fires, inspect worker statuses via `manage_subagents(Action: "list")`, terminate hanging candidates (`manage_subagents(Action: "kill", ConversationIds: [<id>])`), and proceed with surviving outputs.

## Phase C: Cross-judge

Spawn one judge subagent via `invoke_subagent` (`TypeName: "research"`, `Role: "Arena Cross-Judge"`). The cross-judge must be selected from a different model family than the candidates. For Antigravity, assign the judge role to `Model: "pro"` (Gemini Pro) to ensure deep comparative judgment over Flash candidate drafts. The judge scores candidates against rubric criteria and recommends a base with rationale.
After Phase B finishes, spawn one judge subagent via `invoke_subagent` (`TypeName: "research"`, `Role: "Arena Cross-Judge"`). Read `arena cross-judge pool` from `~/.gemini/config/plugins/agystack/agystack-models.md` (default `inherit, flash, pro`). Enforce model-tier and family diversity. Select a model from a different family than the parent session when cross-family models are configured, and pick a distinct Antigravity tier (`pro`, `flash`, or `inherit`) from the candidate draft majority (for example, `Model: "pro"` when candidates drafted on `flash`). If the parent model is unknown or `invoke_subagent` rejects a pool entry, fall back to the next pool entry or skip Phase C, and record whether the tier and family diversity check ran or was skipped.

Pass `{PARENT_CONVERSATION_ID}` so the judge wakes the coordinator via `send_message`, using the same `TimerCondition: "never"` watchdog and ZERO tool calls yield while waiting. While you read in Phase D, the judge scores each candidate by path label on every rubric criterion and recommends a base with rationale.

## Phase D: Pick a base

Read every candidate end to end. Score against the rubric, compare against the cross-judge, and select the base that is easiest to extend cleanly per the **principle-laziness-protocol**. Record the choice and rationale.
Read every candidate end to end before picking. Score each against the rubric criterion by criterion rather than on holistic feel, and compare with the cross-judge verdict when Phase C ran. Agreement confirms the pick. Disagreement means one of you is biased or the rubric was ambiguous, so read both rationales before deciding.

Pick the base a future maintainer can extend most easily without breaking invariants. When two feel tied, prefer the cleaner boundary or smaller API per **principle-laziness-protocol**.

## Phase E: Graft

Port winning ideas from losing candidates sequentially (`principle-sequence-verifiable-units`) per **principle-redesign-from-first-principles**:
- Apply each candidate's minimal diff to the base and verify immediately against tests and rubric criteria.
- Accept verified grafts; revert immediately if regressions occur.
- Record accepted grafts and explicit rejection reasons.
First apply the convergence-vs-divergence gate:

- **Convergence.** If candidates converge on one shape, that is strong agreement. Record the convergence and ship the consensus shape with no graft needed.
- **Divergence.** If candidates wildly diverge, Phase A was under-specified. Reframe the artifact and rubric and re-run Phase B instead of averaging the divergence.

When candidates share a clear base with distinct wins elsewhere, walk each losing candidate once more for what is worth porting (usually one or two ideas per candidate, not most of it). Fold each graft into the base sequentially (**principle-sequence-verifiable-units**) and by hand per **principle-redesign-from-first-principles**:

- Apply one minimal diff to the base, verify immediately against tests and rubric criteria, and revert on regression.
- Record accepted grafts, source candidates, and explicit rejection reasons.

## Phase F: Verify

Verify the synthesized artifact per **principle-prove-it-works**. If verification fails, re-frame the task or inspect missed candidate solutions.
Verify the synthesized artifact per **principle-prove-it-works**. If verification finds a problem the arena missed, either Phase A was wrong (reframe and re-run) or a candidate caught it and you missed the graft (return to Phase E). Do not paper over it.

## Outputs

Publish the final synthesis package to `<appDataDir>/brain/<conversation-id>/arena_synthesis.md` with `ArtifactMetadata: { Summary: "...", UserFacing: true, RequestFeedback: false }` and link to it in chat. Candidate drafts remain under `<appDataDir>/brain/<conversation-id>/scratch/arena-<slug>/`.
Publish the final synthesis package to `<appDataDir>/brain/<conversation-id>/arena_synthesis.md` with `ArtifactMetadata: { Summary: "...", UserFacing: true, RequestFeedback: false }` and link to it in chat. Record the base choice and rationale, cross-judge verdict (or why Phase C skipped it, plus tier and family diversity status), convergence or divergence outcomes, any dropouts, each graft with its source candidate, rejected ideas with reasons, and the verification result. Candidate drafts remain under `<appDataDir>/brain/<conversation-id>/scratch/arena-<slug>/`.
12 changes: 8 additions & 4 deletions skills/cloud-swarm/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Open a todolist with one entry per phase before launching anything.
5. Execution routing:
- For 8 or fewer workers (and unless `agystack-runtime.json` specifies `"runtime": "cloud-run"`), use local `invoke_subagent` fan-out (see `skills/poteto-mode/references/antigravity-tools.md`).
- For more than 8 workers or when `agystack-runtime.json` specifies `"runtime": "cloud-run"`, use Cloud Run dispatch.
6. **Exact SHAs and measurement method.** When workers verify or measure commits, name the exact SHAs in each brief. When a worker measures performance or counts, also name the method (sample count, what one sample is, and execution order). Require every worker to echo both in its result.

## Phase B: Fan out (Cloud Run Dispatch)

Expand Down Expand Up @@ -125,14 +126,17 @@ Before launching cloud swarms, match the model to the project's Model Garden ena
- *Dashboard Reflection:* `SwarmDashboardWriter` captures steering dispatches to display `STEER_PENDING: <instruction>` under `Active Phase / Tool` and clears the pending status once `STEER_APPLIED` is acknowledged.
- **Subprocess Timeout Guards:** Shell command execution and verification scripts are bounded by explicit environment timeouts (`COMMAND_TIMEOUT`, `VERIFY_TIMEOUT`), preventing hanging processes from stalling container lifecycle.

Every brief stands alone. Include goal, scope, exact slice, verification command, and expected report format (`[STATUS: PASS]`, `[STATUS: ISSUES]`, or `[STATUS: BLOCKED]` with evidence).
Every brief stands alone. Include goal, scope, exact slice or race arm, exact SHAs and measurement method when applicable, verification command, and expected report format (`[STATUS: PASS]`, `[STATUS: ISSUES]`, or `[STATUS: BLOCKED]` with evidence). A worker that can prove a defect reports `[STATUS: ISSUES]` and lists every issue it can prove, not only the first.

If a worker drops out or fails to report, proceed with `N-1` and note the dropout explicitly.

## Phase C: Aggregate & Early Harvest

1. `cloud_dispatch.py` automatically harvests candidate patches from GCS into `.slices/<session_id>/task-<i>/` and displays candidate patch file locations in the execution summary.
2. Apply selection rule (first pass, rank all, best-of): rank candidates by score delta descending.
3. **Candidate Integration Protocol:** Apply the winning `patch.diff` to a local worktree (`git apply .slices/<session_id>/task-<i>/patch.diff`), run local verification, and commit. If verified, re-baseline and evaluate subsequent candidates sequentially. Never merge or compose multiple candidate patches simultaneously without intermediate verification (`principle-sequence-verifiable-units`).
4. Build a compact result table, one-line evidenced issues, and explicit dropouts.
2. **SHA and measurement-method echo gate.** Inspect terminal results and drop any result that omits the exact SHAs or measurement method named in its brief. Respawn or re-dispatch that slice once. After a second miss, record a gap. A gap never counts as a pass. For coverage sweeps, every required slice needs a result.
3. Apply the selection rule declared up front (`first pass`, `rank all`, or `best-of`): rank candidates by score delta descending. Do not paste raw worker dumps.
4. **Candidate Integration Protocol:** Apply the winning `patch.diff` to a local worktree (`git apply .slices/<session_id>/task-<i>/patch.diff`), run local verification, and commit. If verified, re-baseline and evaluate subsequent candidates sequentially. Never merge or compose multiple candidate patches simultaneously without intermediate verification (`principle-sequence-verifiable-units`).
5. Build a compact result table, one-line evidenced issues, and explicit gaps or `N-1` dropouts.

## Phase D: Report

Expand Down
56 changes: 32 additions & 24 deletions skills/correct/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
---
name: correct
description: Structured repository hardening against agent mistakes. Classifies recurring defects and enforces the fix hierarchy where architecture and structural checks precede rules and prompts.
description: "Find the mistakes agents keep repeating in this repo and make each one impossible. Try architecture first, then types, then a lint or hook whose error names the fix, then behavioral tests, and write docs last. Prove each check fails on a real past mistake. Use for /correct."
---

# Correct

Harden repositories against recurring agent mistakes and systemic defects.
When an agent makes an error, do not simply patch the immediate failure or add an ad-hoc instruction.
Classify the defect and enforce structural defenses at the highest level of the fix hierarchy.
The operator keeps correcting agents in this repo for the same mistakes. Change the repo so the next agent cannot make them.

## Mistake Classification
Assume every contributor is an agent that sees only the files it opened, copies the nearest example, and takes the shortest path that compiles. Design the repo so a change that looks right from one file is right for the whole repo.

Group mistakes into distinct classes to identify appropriate structural countermeasures:
## Find the mistake classes

- **Constraint misunderstanding.** The agent ignores instructions, misinterprets bounds, or violates system constraints.
- **Hallucinated APIs.** The agent invents parameters, functions, flags, or tools that do not exist in the platform or runtime.
- **Fragile patterns.** The agent uses brittle regex parsing, race-prone file operations, unstructured text extraction, or unvalidated assumptions.
- **Regressions.** The agent breaks previously working tests, overwrites unrelated code, or reverts recent fixes.
Read recent commits, reverts, review comments, `rules/AGENTS.md`, and comments that explain workarounds. Group mistakes into classes (`Constraint misunderstanding`, `Hallucinated APIs`, `Fragile patterns`, `Regressions`).

## Fix Hierarchy
**A class counts once it has happened twice.**

When remediating an agent defect, apply solutions at the highest possible layer in the fix hierarchy.
Architecture and structural checks precede rules and prompt instructions:
## Fix each class at the highest level that works

1. **Architecture.** Make illegal states unrepresentable. Enforce structural boundaries, capability restrictions, and invariants by construction.
2. **Type checks.** Statically typed schemas, discriminated unions, and compiler gates that fail immediately on invalid invocations.
3. **Linter and automated tests.** Deterministic static analysis, linters, pre-commit hooks, and behavioral unit tests that catch errors in automated loops.
4. **Instructions and prompts.** Guidelines and prompt instructions are the last line of defense, never the first.
1. **Eliminate it with architecture.** Make illegal states unrepresentable. Give each piece of state one owner and each task one supported way. Hide internals so the wrong import fails, replace hand-synced lists with one source of truth, and delete dead ways an agent would copy.
2. **Enforce it with types and static checks.** Make invalid invocations fail compilation. If bad code still compiles, add a lint or CI check whose error names the file, type, or function to use instead. If the pattern is already common, fail only when a change adds more.
3. **Add hooks, linters, and behavioral tests.** Enforce tool boundaries with Antigravity lifecycle hooks (`hooks.json.example`) and test observable behavior (`tests/`). Fix or delete any test that still passes when the behavior breaks, or fails when only internals change.
4. **Write docs or agent rules last, only for judgment calls.** Nothing fails automatically when an agent skips `rules/AGENTS.md` or skill prose.

## Hardening Process
## Fix and prove

Follow these steps to remediate mistakes:
1. Reproduce and fix the most frequent mistake classes now, one commit each.
2. **Prove each new check fails on a real past mistake.**
3. Run the same verification command locally and in CI (`make ci`).
4. **Exception expiry rule.** Exceptions go on the offending line with a reason, an expiry date, and a human's approval.

1. Reproduce the mistake with an automated test or deterministic reproduction script.
2. Classify the mistake into its category.
3. Determine the highest applicable layer in the fix hierarchy.
4. Implement the structural guard such as a typed interface, lint rule, or architectural boundary.
5. Verify that the failure is blocked before falling back to prompt prose.
## Keep the rule-to-enforcer table

Pair each recurring rule with what enforces it automatically. When the operator corrects you, fix the mistake and add the rule. If the rule already existed without enforcement, that is a repeat, so enforce it at the highest level in the same change. Drop a rule once its mistake cannot happen.

| Rule or Invariant | Automated Enforcer | Verification |
| --- | --- | --- |
| Coordinator delegates code writes `> 50` lines to `poteto-agent` | `hooks.json.example` (`agystack-delegation` -> `pre_tool_delegation.py`) | `tests/test_hooks.py`, `tests/test_reactive_coordination_rules.py` |
| Destructive CLI commands (`rm`, trunk force-push, `drop database`) gated | `hooks.json.example` (`agystack-safety` -> `pre_tool_safety.py`) | `tests/test_hooks.py` |
| Deterministic post-write formatting on `.py`, `.ts`, `.tsx`, `.js`, and `.jsx` | `hooks.json.example` (`agystack-formatter` -> `post_tool_lint.py`) | `tests/test_hooks.py` |
| Zero Cursor leaks and `agystack-models.md` role key parity | Static scanner in `tests/test_antigravity_invariants.py` | `pytest -v tests/test_antigravity_invariants.py` |
| Reactive wakeup (`TimerCondition: "never"`, `ZERO tool calls`, `send_message`) | Contract assertions in `tests/test_reactive_coordination_rules.py` | `pytest -v tests/test_reactive_coordination_rules.py` |
| Skill catalog, principle count, and `/swarm` non-collision (`cloud-swarm`) | Catalog checks in `tests/test_skill_catalog.py` | `pytest -v tests/test_skill_catalog.py` |
| Agent `inheritCustomizations: false` and registered tool list | Frontmatter checks in `tests/test_agent_definitions.py` | `pytest -v tests/test_agent_definitions.py` |
| Manifest semver parity, hook paths, and zip hygiene | `tests/test_plugin_manifest.py` and `scripts/package-plugin.sh --test` | `make package-check` |

**Reply:** list each mistake class with its evidence, the hierarchy level you picked, and why a higher level did not work.
Loading
Loading