diff --git a/.agents/docs/skills_agents_catalog.md b/.agents/docs/skills_agents_catalog.md index a60a59a..abd5fb8 100644 --- a/.agents/docs/skills_agents_catalog.md +++ b/.agents/docs/skills_agents_catalog.md @@ -7,10 +7,10 @@ entries: if it is listed here, the file exists; if it exists, it is listed. | Skill | Version | Source | Purpose | |---|---|---|---| -| [`deepworkplan`](../skills/deepworkplan/SKILL.md) | 7.12.2 | `DailybotHQ/deepworkplan-skill` (vendored, tag-pinned) | The DWP engine: create/execute/refine/resume/status/verify/upgrade/onboard/author sub-skills. Standard 7.0.0 — Lite and Full plans | +| [`deepworkplan`](../skills/deepworkplan/SKILL.md) | 8.0.0 | `DailybotHQ/deepworkplan-skill` (vendored, tag-pinned) | The DWP engine: create/execute/refine/resume/status/verify/upgrade/onboard/author sub-skills. Standard 8.0.0 — Lite and Full plans | | [`ai-diff-reviewer`](../skills/ai-diff-reviewer/SKILL.md) | 3.3.16 | `DailybotHQ/ai-diff-reviewer` (vendored, tag-pinned) | Local + CI diff review (six sub-skills: review, generate-extension, setup, open-pr, apply-review, address-review). Local review is the required Final Review pass; config at [`.review/extension.md`](../../.review/extension.md) | | [`dailybot`](../skills/dailybot/SKILL.md) | 3.23.17 | `DailybotHQ/agent-skill` (vendored, tag-pinned) | 17-capability Dailybot pack; wired into DWP only for lifecycle **reporting** (never blocks). | -| [`herdr-peers`](../skills/herdr-peers/SKILL.md) | 2.0.0 | `DailybotHQ/herdr-peers` (vendored, tag-pinned, repo-local) | Herdr addon transport (protocol 2): one authorized reply from an agent in another pane or machine, notices, lead epochs and appointment, native debates, plus `autopilot` — an optional daemon **only a human starts** (never a message, peer or plan) with `--loop`, `--appoint` and the opt-in, fail-closed `--brain` — and read-only `plans`/`fleet` verbs with a fleet UI. Call the helper at `.agents/skills/herdr-peers/scripts/herdr-peers` when it is not on `PATH` | +| [`herdr-peers`](../skills/herdr-peers/SKILL.md) | 2.1.0 | `DailybotHQ/herdr-peers` (vendored, tag-pinned, repo-local) | Herdr addon transport (protocol 2): one authorized reply from an agent in another pane or machine, notices, lead epochs and appointment, native debates, plus `autopilot` — an optional daemon **only a human starts** (never a message, peer or plan) with `--loop`, `--appoint` and the opt-in, fail-closed `--brain` — and read-only `plans`/`fleet` verbs with a fleet UI. Call the helper at `.agents/skills/herdr-peers/scripts/herdr-peers` when it is not on `PATH` | | [`fix-frontmatter`](../skills/fix-frontmatter/SKILL.md) | 1.0.0 | `DailybotHQ/deepworkplan-skill` (vendored utility) | Validates/fixes `SKILL.md` frontmatter against the contract | | [`shellcheck-fix`](../skills/shellcheck-fix/SKILL.md) | 1.0.0 | `DailybotHQ/deepworkplan-skill` (vendored utility) | shellcheck over the shipped shell scripts (applies to `dev.sh`, `docker/`, `tests/run.sh`) | | [`write-bats-test`](../skills/write-bats-test/SKILL.md) | 1.0.0 | `DailybotHQ/deepworkplan-skill` (vendored utility) | bats-core test authoring, following the upstream skill repo's `tests/` convention (this repo's own suite is Go — the skill applies if a bats layer is ever added) | @@ -54,4 +54,4 @@ The [dependency-upgrade flow](../skills/deepworkplan/addons/dependency-upgrade/S is exposed by the inert [`/lib-upgrade`](../commands/lib-upgrade.md) command. The [design-system flow](../skills/deepworkplan/addons/design-system/SKILL.md) is recorded in [docs/DESIGN.md](../../docs/DESIGN.md), profile `cli-output`. -Neither is a separate vendored skill; both use the pinned 7.12.2 pack. +Neither is a separate vendored skill; both use the pinned 8.0.0 pack. diff --git a/.agents/skills/deepworkplan/SKILL.md b/.agents/skills/deepworkplan/SKILL.md index f81d645..dc55bcb 100644 --- a/.agents/skills/deepworkplan/SKILL.md +++ b/.agents/skills/deepworkplan/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan description: DeepWorkPlan — turn any repo AI-first and run Deep Work Plans. Routes to create, execute, refine, resume, status, verify, upgrade, and repo-onboarding sub-skills based on intent. Use when the developer wants to plan, execute, manage, or verify structured multi-task work, or make a repository AI-agent-ready. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -10,17 +10,12 @@ metadata: {"openclaw":{"emoji":"🧠","homepage":"https://deepworkplan.com","req # DeepWorkPlan — Methodology Skill (Router) -Models matter; context matters more. The **DeepWorkPlan** skill turns any -repository into a structured environment — context, guardrails, and a durable -plan — where any coding agent executes reliably on short or long work. It makes -the repository "AI-first" — `AGENTS.md` + `docs/` + per-module docs + `.agents/` -(with the `.claude → .agents` and `.cursor → .agents` symlinks) — and runs structured **Deep Work -Plans**: Lite plans for bounded work and Full task-file plans for longer work; -an AI agent creates, refines, executes task-by-task, -and resumes. All plan output lands in a gitignored `.dwp/` directory -at the repo root (`.dwp/plans/`). +The repository is the harness. +**Spec-first, loop-closed: the repository is the harness and the plan runs itself to done.** Plans are Lite (bounded work) or Full (task files, longer work). Planning is spec-first per episode: the plan precedes the code, with acceptance criteria, as git-ignored, exportable `.dwp/plans/` state any agent can resume, not a maintained specification. Loop engineering registers a lead and its succession; an optional daemon a human starts nudges without adding authority. Plans run within their recorded authority and gates; the method works alone. -Source of truth: . License: MIT. +DWP measures the instruction bytes each flow loads. It has not shown a general saving in provider tokens. + +Source: . ## Start here (first run) @@ -160,8 +155,8 @@ developer which they mean before routing. or mutate files — regardless of how they are invoked. - **Plan generation is detected, never assumed.** A plan folder carrying a `manifest.json` contract pointer, a `contract.json`, or a `contracts/` - revision chain is **v6** (contract generation v6 or v7, - `spec/V7_CONTRACT.md`) — create and execute route it through their + revision chain is **v6** (contract generation v6–v8, + `spec/V6_LIFECYCLE.md`) — create and execute route it through their `v6.md` loops (contract, journal, scheduler, verified closure). Anything else keeps the recorded v5 lifecycle, is never migrated silently, and a v5-only runner that meets a v6 plan reports it as unsupported rather diff --git a/.agents/skills/deepworkplan/TRUST.md b/.agents/skills/deepworkplan/TRUST.md index 112597d..9ed8614 100644 --- a/.agents/skills/deepworkplan/TRUST.md +++ b/.agents/skills/deepworkplan/TRUST.md @@ -13,7 +13,7 @@ Source of truth: · License: MIT. A **Markdown-first** agent skill: the "code" is the `SKILL.md` prompt files an agent reads at runtime, plus a small set of local helpers. Two Bash: `setup.sh` (symlinking, at the repository root, not inside the pack) and, inside the pack, -`shared/context.sh` for repo/branch/`.dwp/` detection. Twenty Python (stdlib +`shared/context.sh` for repo/branch/`.dwp/` detection. Twenty-two Python (stdlib only, Python 3.9+), all inside the pack: `verify/conformance.sh` and its `verify/plan_contract.py` for the read-only conformance check, `verify/compliance_audit.py` for the read-only compliance audit of finished @@ -36,12 +36,14 @@ each step atomic and resumable, never rewriting a different contract or another generation's manifest; it also captures each task's starting fingerprint at `task_start` and executes both legs of a declared control pair, materializing the old leg as a detached worktree -at that recorded revision; for v7 plans its `delegate` command records -delegation launches and results behind a gate — v7 contract, +at that recorded revision; for v7 and v8 plans its `delegate` command records +delegation launches and results behind a gate — a v7-or-later contract, `agent_delegation` grant, `parallel_safe` task or read-only delegate, an enabled and detected transport addon — and **never runs a delegate itself**: the transport addon does, and a delegate's result stays -`asserted` until this ledger's own gate observes it), `shared/views.py` +`asserted` until this ledger's own gate observes it; for v8 plans its +`block` and `unblock` commands are the only writers of structured blocker +records and re-project `state.json` — they run nothing), `shared/views.py` rendering the deterministic generated views under the human-edit rule, `shared/scheduler.py` — the read-only authorization core that turns journal records into dispatch/refusal decisions (it never writes and never executes @@ -76,6 +78,15 @@ prints one action per addon; it writes nothing and installs nothing; and notifier: it reads one `plan-event-v1` JSON document on stdin and, only when the Dailybot CLI is installed, sends one report through it — every other case (no CLI, invalid input, failed send) exits 0 silently; and +`shared/queue.py`, the plan queue (dwp-queue-v1): the only writer of +`.dwp/queue.json` — create appends on approval, execute marks a plan +started on a task start while it is still queued and done after its closure, create/refine may +skip with a note — an atomic 0600 write, and a read of anything that is not +a valid bounded document is a quiet none; and +`shared/progress_header.py`, the v8 `PROGRESS.md` header writer: it reads +the plan's records read-only and rewrites only the four header lines under +the title of that plan's `PROGRESS.md` (atomic; the body below is never +touched; `--check` writes nothing); and `shared/migrate_v6.py`, the explicit v5 → v6 migration helper — preview, guarded resumable migrate, verified rollback. It never executes anything: a v5 gate record is imported through the ledger writer as `imported` diff --git a/.agents/skills/deepworkplan/addons/README.md b/.agents/skills/deepworkplan/addons/README.md index 47c7832..d4e6586 100644 --- a/.agents/skills/deepworkplan/addons/README.md +++ b/.agents/skills/deepworkplan/addons/README.md @@ -78,13 +78,13 @@ An addon MAY additionally ship per-stack presets, examples, or migration notes. | Addon | Folder | Status | |-------|--------|--------| -| Devcontainer support | [`addons/devcontainer/`](devcontainer/SKILL.md) | **Authored** — vendor-neutral thin integrator of devcontainer-kit (`dck`, pinned `v1.1.2`, interface 2): detect with `dck doctor --json`, offer the kit and its tag-pinned `dck-dockerfile` skill, reason service/runtime/ports/agents from the real stack, render the repository's own layout (`.devcontainer/devcontainer.json`, `docker/local//Dockerfile`, `docker/local/docker-compose.yaml`, `dev.sh`) from the official runtime image pinned by digest — no shared base image required; `dck init` reconciles an existing layout (consented diffs, backups — never clobbered), optional Herdr container profile, validation with a real build. Loopback ports, agent forwarding, no host `~/.ssh` mounts (the developer's own `[ssh] copy_keys` opt-in in their host profile aside), no privileged options. Never required. | +| Devcontainer support | [`addons/devcontainer/`](devcontainer/SKILL.md) | **Authored** — vendor-neutral thin integrator of devcontainer-kit (`dck`, pinned `v1.3.0`, interface 2): detect with `dck doctor --json`, offer the kit and its tag-pinned `dck-dockerfile` skill, reason service/runtime/ports/agents from the real stack, render the repository's own layout (`.devcontainer/devcontainer.json`, `docker/local//Dockerfile`, `docker/local/docker-compose.yaml`, `dev.sh`) from the official runtime image pinned by digest — no shared base image required; `dck init` reconciles an existing layout (consented diffs, backups — never clobbered), optional Herdr container profile, validation with a real build. Loopback ports, agent forwarding, no host `~/.ssh` mounts (the developer's own `[ssh] copy_keys` opt-in in their host profile aside), no privileged options. Never required. | | Dailybot integration | [`addons/dailybot/`](dailybot/SKILL.md) | **Authored** — opt-in install of the Dailybot agent skill (**3.23.20**) / CLI (**>= 3.9.0**), auth **deferred** to the Dailybot skill's own consent flow, **four lifecycle events** (kickoff, significant task, blocked, completion) wired as optional best-effort reports via the `report` sub-skill, optional deterministic hook enforcement, and access to the full 17-capability Dailybot skill when invoked directly. The core methodology has **zero** Dailybot dependency. | | Dependency upgrade | [`addons/dependency-upgrade/`](dependency-upgrade/SKILL.md) | **Authored** — **near-default**, **package-manager-agnostic** dependency upgrades: offered for every repo with declared dependencies, with the inert `/lib-upgrade` delegator installed under the onboarding consent unless explicitly declined (an install runs no upgrade). When invoked: detect the repo's real manager (npm/pnpm/yarn + ncu, pip/poetry/uv, cargo, go mod, bundler, composer…), classify by semver, upgrade in safe batches, run the repo's **real** validation gate after each batch, revert a failing batch, summarize. | | Design system | [`addons/design-system/`](design-system/SKILL.md) | **Authored** — opt-in, **interface-surface-scoped** `DESIGN.md` at `docs/DESIGN.md` (indexed from `AGENTS.md`; root only if no `docs/` tree), covering three profiles in one file: **visual-ui** (design tokens from CSS vars / Tailwind config / token files / component styles; WCAG AA contrast), **cli-output** (semantic terminal styles, output components, TTY/`NO_COLOR` degradation), and **conversational** (voice & register, message anatomy, per-platform rendering with plain-text fallbacks). Reason about the repo's **real** design source — never a brand file — and reconcile an existing `DESIGN.md` instead of clobbering it. Offered by `onboard` **only when an interface surface is detected** — the offer is mandatory, not skippable, with the detection rationale recorded — and every profile (**visual-ui** strongly recommended) installs only after explicit acceptance, never auto-applied. | | AI Diff Reviewer | [`addons/ai-diff-reviewer/`](ai-diff-reviewer/SKILL.md) | **Authored** — **required local review** (baseline since 2.3.0): tag-pinned install of the vendored `DailybotHQ/ai-diff-reviewer` skill (currently **v3.3.16**; workflows pin the moving `@v3`; marketplace listing "AI Diff Reviewer") plus a repo-tailored `.review/extension.md`, wired into the Final Review's security pass; the CI Action (Flow B — same prompt bytes as the local pass, methodology and severity parity) and the `apply-review` / `address-review` companions stay an explicit opt-in. | -| Herdr | [`addons/herdr/SKILL.md`](herdr/SKILL.md) | **Authored** — thin integrator, explicit opt-in offered in `onboard` Phase 7b, pinned to `herdr-peers@v2.0.0` (protocol/interface 1 or 2, detected with `herdr-peers --version`; Herdr's official skill pinned `herdrdev/herdr@v0.9.3`): the **interactive** delegation transport of v7 plans — one `herdr-peers ask` to a peer pane on any machine, recorded in the plan journal before it is relied on, the reply asserted until the plan's own gates observe the work. The peer protocol and native debate sub-skill live in herdr-peers; this folder carries no copy. Its default decision mode: a plan settles each consequential decision through a herdr-peers decide debate, planned as an approved decision task, falling back to the agent's own record without blocking (`SPEC.md` §6.4; off with `config.py decisions debate off`). Never required. | -| agentkit | [`addons/agentkit/SKILL.md`](agentkit/SKILL.md) | **Authored** — thin integrator, explicit opt-in offered in `onboard` Phase 7b, pinned to `coding-agents-kit@v1.4.0` (interface 1, detected with `ak doctor --json`): the **headless** delegation transport of v7 plans — one `ak run` per delegate in a dedicated git worktree, recorded through `ledger.py delegate`, result asserted until the plan's own gates observe it. Install by a clone of the exact tag + `install.sh`. The kit launches agents in autonomy by default and its `--ask` / `AGENTKIT_PERMISSIONS=ask` opt-out always wins; the pack spells no autonomy flag and passes only `--ask` — always for a read-only delegate, and for writing delegates when a plan records the opt-out. Never required. | +| Herdr | [`addons/herdr/SKILL.md`](herdr/SKILL.md) | **Authored** — thin integrator, explicit opt-in offered in `onboard` Phase 7b, pinned to `herdr-peers@v2.1.0` (protocol/interface 1 or 2, detected with `herdr-peers --version`; Herdr's official skill pinned `herdrdev/herdr@v0.9.3`): the **interactive** delegation transport of v7 plans — one `herdr-peers ask` to a peer pane on any machine, recorded in the plan journal before it is relied on, the reply asserted until the plan's own gates observe the work. The peer protocol and native debate sub-skill live in herdr-peers; this folder carries no copy. Its default decision mode: a plan settles each consequential decision through a herdr-peers decide debate, planned as an approved decision task, falling back to the agent's own record without blocking (`SPEC.md` §6.4; off with `config.py decisions debate off`). Never required. | +| agentkit | [`addons/agentkit/SKILL.md`](agentkit/SKILL.md) | **Authored** — thin integrator, explicit opt-in offered in `onboard` Phase 7b, pinned to `coding-agents-kit@v1.5.0` (interface 1, detected with `ak doctor --json`): the **headless** delegation transport of v7 plans — one `ak run` per delegate in a dedicated git worktree, recorded through `ledger.py delegate`, result asserted until the plan's own gates observe it. Install by a clone of the exact tag + `install.sh`. The kit launches agents in autonomy by default and its `--ask` / `AGENTKIT_PERMISSIONS=ask` opt-out always wins; the pack spells no autonomy flag and passes only `--ask` — always for a read-only delegate, and for writing delegates when a plan records the opt-out. Never required. | | DeepWorkPlan Vim | [`addons/vim/SKILL.md`](vim/SKILL.md) | **Authored** — thin integrator, explicit opt-in offered in `onboard` Phase 7b, pinned to `deepworkplan-vim@v1.0.1` (interface 1, read from the product's `addon/surface.json`). Optional machine-level install of DeepWorkPlan Vim, the terminal editor for Deep Work Plan (Neovim 0.12+, GPL-3.0, its own repo `DailybotHQ/deepworkplan-vim`): detect it through the product's surface, offer — never impose — the editor, guide the documented install (macOS/Linux via the product's install page `https://deepworkplan.com/vim` — download, verify the pinned checksum, run, never a remote-installer pipe spelled in this pack's text; Windows `winget install Neovim.Neovim` + a tagged clone, never piped PowerShell), and validate the installed surface (command index, VS Code gestures, plan browser, markdown viewer). Two routes: the full editor now, the Neovim plugin in v7.1. An existing Neovim config is **never** overwritten without explicit consent — non-interactive installs onto an existing config abort with instructions; backups go to `~/.config/previous-deepworkplan-vim`. Never a conformance gate. | > This README is the mechanism doc. The first addon, `addons/devcontainer/`, is diff --git a/.agents/skills/deepworkplan/addons/agentkit/SKILL.md b/.agents/skills/deepworkplan/addons/agentkit/SKILL.md index 6248c99..111c331 100644 --- a/.agents/skills/deepworkplan/addons/agentkit/SKILL.md +++ b/.agents/skills/deepworkplan/addons/agentkit/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-agentkit -description: Optional DeepWorkPlan addon that integrates coding-agents-kit (the `ak` command, DailybotHQ/coding-agents-kit pinned at v1.4.0, interface 1) as the headless delegation transport - a thin integrator that detects the kit through `ak doctor --json`, offers it (never imposes it) from onboard Phase 7b, documents the install from a clone of the pinned tag plus the kit's install.sh, records the acceptance in the .dwp/config.json addon registry, and maps a v7 plan's delegation operations (launch, observe, collect, cancel) onto one `ak run` per delegate in a dedicated git worktree. Never required, never a conformance gate. The kit launches agents in autonomy by default and its opt-out (--ask or AGENTKIT_PERMISSIONS=ask) always wins; the pack spells no CLI autonomy flag, never passes --auto, and passes --ask always for a read-only delegate and for writing delegates when a plan records the opt-out. -version: "7.12.2" +description: Optional DeepWorkPlan addon that integrates coding-agents-kit (the `ak` command, DailybotHQ/coding-agents-kit pinned at v1.5.0, interface 1) as the headless delegation transport - a thin integrator that detects the kit through `ak doctor --json`, offers it (never imposes it) from onboard Phase 7b, documents the install from a clone of the pinned tag plus the kit's install.sh, records the acceptance in the .dwp/config.json addon registry, and maps a v7 plan's delegation operations (launch, observe, collect, cancel) onto one `ak run` per delegate in a dedicated git worktree. Never required, never a conformance gate. The kit launches agents in autonomy by default and its opt-out (--ask or AGENTKIT_PERMISSIONS=ask) always wins; the pack spells no CLI autonomy flag, never passes --auto, and passes --ask always for a read-only delegate and for writing delegates when a plan records the opt-out. +version: "8.0.0" documentation_url: https://deepworkplan.com/kit/agentkit user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -13,7 +13,7 @@ metadata: {"openclaw":{"emoji":"🧰","homepage":"https://deepworkplan.com/kit/a Integrate **coding-agents-kit** — one command surface (`ak`) for every terminal coding agent (claude, codex, cursor, opencode, pi, cline, grok and their provider variants, multiple accounts through profiles) — as the -**headless** transport a v7 plan may use to delegate a `parallel_safe` +**headless** transport a v7 or v8 plan may use to delegate a `parallel_safe` task. This is an **opt-in addon**, never required for a repo to be AI-first and never a conformance gate: without it every task runs in the current session exactly as before. @@ -26,7 +26,7 @@ DWP); everything this addon relies on is the kit's frozen **interface 1** | Pin | Value | |-----|-------| | Product | `DailybotHQ/coding-agents-kit` | -| Tag | `v1.4.0` (autonomy by default since `v0.2.0`; accounts, `ak usage`, `ak pick`, `ak profiles --json`, `--trust-cwd` and the `agentkit-orchestrate` skill since `v0.5.0`; Cursor's Linux login and Claude's `keychain` login kind since `v0.5.1`; a default account per CLI, `AGENTKIT_DEFAULT_PROFILE_`, since `v0.5.2`; Codex started with `--no-daemon` when a shared home records a daemon from another machine, since `v0.5.3`; `ak capacity` with its usage cache, `ak lease` and `ak pick --owner` since `v0.6.0`; `ak capacity --self` inside Codex lanes, `ak pick --owner` counting the owner's own leases with `--reuse @profile` for a successor, one account per kind and profile, and Grok folder trust since `v0.6.1`; Antigravity quota and every account listed in `ak usage` since `v0.7.0`; a profile's suffixed credential variable counted as its login since `v0.7.1`; the first stable release, its interface committed to semantic versioning, `v1.0.0`; every profile, `@default` included, its own account inside a devcontainer-kit container, since `v1.0.1`; `ak usage` listing the measurable blocks first since `v1.1.0`; Herdr restoring a pane through `ak` — same account, key and permission posture after a reboot or Herdr restart, `AGENTKIT_HERDR_RESUME=0` turns it off — and `ak last` relaunching the newest session of that directory in any terminal since `v1.2.0`; the daemon-facing surface — `ak pick --kinds KIND,... --json` (pick-v2: the first kind in priority order with a qualifying account, the exact `launch.argv` and `launch.permissions` auto|ask) and the provider-neutral `--model` head flag mapped to each CLI's own (codex `-m`) since `v1.3.0`; `ak update ` — the verified vendor update against the CLI's default home, whatever profile is active (the fix for updaters that resolve relative to a profile CODEX_HOME) — since `v1.4.0`. `ak update` is human-invoked only, never run by a daemon (the kit's SECURITY.md says so)) | +| Tag | `v1.5.0` (autonomy by default since `v0.2.0`; accounts, `ak usage`, `ak pick`, `ak profiles --json`, `--trust-cwd` and the `agentkit-orchestrate` skill since `v0.5.0`; Cursor's Linux login and Claude's `keychain` login kind since `v0.5.1`; a default account per CLI, `AGENTKIT_DEFAULT_PROFILE_`, since `v0.5.2`; Codex started with `--no-daemon` when a shared home records a daemon from another machine, since `v0.5.3`; `ak capacity` with its usage cache, `ak lease` and `ak pick --owner` since `v0.6.0`; `ak capacity --self` inside Codex lanes, `ak pick --owner` counting the owner's own leases with `--reuse @profile` for a successor, one account per kind and profile, and Grok folder trust since `v0.6.1`; Antigravity quota and every account listed in `ak usage` since `v0.7.0`; a profile's suffixed credential variable counted as its login since `v0.7.1`; the first stable release, its interface committed to semantic versioning, `v1.0.0`; every profile, `@default` included, its own account inside a devcontainer-kit container, since `v1.0.1`; `ak usage` listing the measurable blocks first since `v1.1.0`; Herdr restoring a pane through `ak` — same account, key and permission posture after a reboot or Herdr restart, `AGENTKIT_HERDR_RESUME=0` turns it off — and `ak last` relaunching the newest session of that directory in any terminal since `v1.2.0`; the daemon-facing surface — `ak pick --kinds KIND,... --json` (pick-v2: the first kind in priority order with a qualifying account, the exact `launch.argv` and `launch.permissions` auto|ask) and the provider-neutral `--model` head flag mapped to each CLI's own (codex `-m`) since `v1.3.0`; `ak update ` — the verified vendor update against the CLI's default home, whatever profile is active (the fix for updaters that resolve relative to a profile CODEX_HOME) — since `v1.4.0`. `ak update` is human-invoked only, never run by a daemon (the kit's SECURITY.md says so)) | | Interface | `1` (`ak doctor --json` → `"interface": 1`) | | Registry key | `agentkit` (`.dwp/config.json` → `addons.agentkit`) | | Transport | `headless` — provides `subagents`, `cancel_children`, `model_routing`; requires the `agent_delegation` grant | @@ -43,7 +43,7 @@ DWP); everything this addon relies on is the kit's frozen **interface 1** - **`onboard` Phase 7b** offers it as an explicit opt-in when the developer wants a plan to hand bounded tasks to other coding agents. -- **`execute`** uses it only through `delegation.md`, only on a v7 plan whose +- **`execute`** uses it only through `delegation.md`, only on a v7 or v8 plan whose contract grants `agent_delegation`, only for a `parallel_safe` task (or a read-only delegate), and only when `resources.py abilities` shows `addon:agentkit` as a `subagents` source. @@ -116,7 +116,7 @@ Declining is a complete answer. ### Step 2 — Install (pinned; point-don't-run by default) ``` -git clone --branch v1.4.0 https://github.com/DailybotHQ/coding-agents-kit +git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit ./coding-agents-kit/install.sh ``` @@ -131,7 +131,7 @@ re-detect afterwards. ### Step 3 — Record -`python3 ../../shared/config.py enable agentkit --version v1.4.0 --repo `. +`python3 ../../shared/config.py enable agentkit --version v1.5.0 --repo `. Delegation still needs each plan's contract to grant `agent_delegation` — enabling the addon grants nothing. @@ -253,7 +253,7 @@ room once per task boundary with `ak usage @ --json`. ## Validation checklist (component 4 — mirrored from SPEC §8) 1. `SKILL.md`, `SPEC.md`, `addon.json`, `templates/INTEGRATION.md` exist; - the descriptor pins `DailybotHQ/coding-agents-kit` `v1.4.0`, interface 1, + the descriptor pins `DailybotHQ/coding-agents-kit` `v1.5.0`, interface 1, transport `headless`. 2. Detection is read-only and reports `interface` 1, or one warning. 3. Install used the pinned tagged clone + `install.sh`; nothing piped. diff --git a/.agents/skills/deepworkplan/addons/agentkit/SPEC.md b/.agents/skills/deepworkplan/addons/agentkit/SPEC.md index 68b10b6..9b9fa17 100644 --- a/.agents/skills/deepworkplan/addons/agentkit/SPEC.md +++ b/.agents/skills/deepworkplan/addons/agentkit/SPEC.md @@ -4,7 +4,7 @@ This document is the normative specification of the DeepWorkPlan **agentkit addon**: an opt-in thin integrator of **coding-agents-kit** -(`ak`), used as the **headless** delegation transport of v7 plans +(`ak`), used as the **headless** delegation transport of v7 and v8 plans (`../../spec/V7_CONTRACT.md`). The kit is a separate product with its own repository, license and release cycle; this addon is the DWP-side integration contract only: detection, the offer, the pinned install, the @@ -17,7 +17,7 @@ registry record and the mapping of the four delegation operations onto |-------|-------| | **Version** | 0.2.0 | | **Status** | Stable — autonomy by default (coding-agents-kit `v0.2.0` and later) | -| **Product pin** | `DailybotHQ/coding-agents-kit` `v1.4.0`, interface `1` | +| **Product pin** | `DailybotHQ/coding-agents-kit` `v1.5.0`, interface `1` | | **Companions** | `SKILL.md`, `addon.json`, `templates/INTEGRATION.md`, `../README.md`, `../../spec/ADDONS.md`, `../../spec/V7_ABILITIES.md`, `../../execute/delegation.md` | ## 1. Conventions @@ -53,7 +53,7 @@ kit** is coding-agents-kit; **the addon** is this folder. complete and writes nothing. - The documented install is the pinned tagged clone plus the kit's installer: - `git clone --branch v1.4.0 https://github.com/DailybotHQ/coding-agents-kit` then + `git clone --branch v1.5.0 https://github.com/DailybotHQ/coding-agents-kit` then `./coding-agents-kit/install.sh` (Windows: `install.ps1`). A fetch-and-execute pipeline **MUST NOT** appear anywhere in this pack's text. The addon **MUST NOT** install coding-agent CLIs on its own. @@ -165,7 +165,7 @@ minor version (`v0.2.0`), and SPEC 0.2.0 describes it. 1. `SKILL.md`, `SPEC.md`, `addon.json`, `templates/INTEGRATION.md` exist; `addon.json` validates with key `agentkit`, product - `DailybotHQ/coding-agents-kit` `v1.4.0`, interface 1, transport + `DailybotHQ/coding-agents-kit` `v1.5.0`, interface 1, transport `headless`. 2. Detection is read-only; interface 1 or one warning. 3. Install used the pinned tagged clone; no pipeline anywhere in the text. diff --git a/.agents/skills/deepworkplan/addons/agentkit/addon.json b/.agents/skills/deepworkplan/addons/agentkit/addon.json index f7a74f6..d3f6763 100644 --- a/.agents/skills/deepworkplan/addons/agentkit/addon.json +++ b/.agents/skills/deepworkplan/addons/agentkit/addon.json @@ -1,7 +1,7 @@ { "schema": "https://deepworkplan.com/schema/addon-descriptor/v1.json", "key": "agentkit", - "product": { "repo": "DailybotHQ/coding-agents-kit", "tag": "v1.4.0", "interface": 1 }, + "product": { "repo": "DailybotHQ/coding-agents-kit", "tag": "v1.5.0", "interface": 1 }, "detect": { "command": "ak doctor --json", "interface_from": "json:interface" }, "provides_abilities": ["subagents", "cancel_children", "model_routing"], "requires_grants": ["agent_delegation"], diff --git a/.agents/skills/deepworkplan/addons/agentkit/templates/INTEGRATION.md b/.agents/skills/deepworkplan/addons/agentkit/templates/INTEGRATION.md index beb3c98..b27de66 100644 --- a/.agents/skills/deepworkplan/addons/agentkit/templates/INTEGRATION.md +++ b/.agents/skills/deepworkplan/addons/agentkit/templates/INTEGRATION.md @@ -1,6 +1,6 @@ # Template — one headless delegate through `ak` (reason, don't copy-paste) -Reasoning guidance for running ONE delegate of a v7 plan through +Reasoning guidance for running ONE delegate of a v7 or v8 plan through coding-agents-kit. Fill every `` from the plan and the machine; never guess. Preconditions are in `../../../execute/delegation.md` (grant, `parallel_safe` or read-only, `addon:agentkit` in the effective diff --git a/.agents/skills/deepworkplan/addons/ai-diff-reviewer/SKILL.md b/.agents/skills/deepworkplan/addons/ai-diff-reviewer/SKILL.md index f050c7a..529e523 100644 --- a/.agents/skills/deepworkplan/addons/ai-diff-reviewer/SKILL.md +++ b/.agents/skills/deepworkplan/addons/ai-diff-reviewer/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-ai-diff-reviewer description: "DeepWorkPlan addon — required local review (baseline since standard 2.3.0), optional CI surface — connects an AI-first repo to the AI Diff Reviewer. Onboarding installs the vendored coding-agent skill and extension with consent; the Final Review runs the local pass when present or records a missing-reviewer finding without bootstrapping. Flow B CI setup remains an explicit opt-in delegated to upstream. Invocation errors never block, completed-review critical findings still follow the Final Review contract, and all install/auth/wizard details defer to upstream consent flows." -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/addons/dailybot/SKILL.md b/.agents/skills/deepworkplan/addons/dailybot/SKILL.md index 37436d8..2d29294 100644 --- a/.agents/skills/deepworkplan/addons/dailybot/SKILL.md +++ b/.agents/skills/deepworkplan/addons/dailybot/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-dailybot description: Optional DeepWorkPlan addon that connects an AI-first repo to the developer's Dailybot team — installing (with consent) the Dailybot agent skill (DailybotHQ/agent-skill, currently 3.23.20) and/or the Dailybot CLI (DailybotHQ/cli, >= 3.9.0), wiring the plan lifecycle into best-effort agent updates - kickoff when a plan starts, significant task completions, a blocked report when an unattended run halts, and a milestone on plan completion - with payloads derived from the plan's state layer, and optionally committing the Dailybot skill's deterministic hook enforcement (dailybot hook lifecycle hooks) so the agent harness itself reminds agents about unreported work. Opt-in, never required, never blocks the work, reconciles existing setups instead of clobbering them, and defers all auth to the Dailybot skill's own consent flow. Use when the developer or team already uses Dailybot and wants DWP progress visible to humans. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -161,8 +161,10 @@ This is the integration value. Reasoning guidance is in 2. **Significant task** (MAY, regular) — a feature/bug fix/major refactor completes; intermediate setup tasks are never reported. 3. **Blocked** (SHOULD, regular with `blockers`) — the plan halts on a stop - condition and `state.json.blocked` is populated (typical of unattended - runs): the team sees *what is stuck and what it needs* in the standup + condition and `state.json.blocked` is populated — on a v8 plan, + `state.json.blocker` (the v8 snapshot has no `blocked` object, and its + held task reads `blocked`, not `in_progress`) — typical of unattended + runs: the team sees *what is stuck and what it needs* in the standup instead of discovering a silent overnight halt. 4. **Completion** (SHOULD, the only **milestone**) — via the dailybot `report` sub-skill (`dailybot agent update ... --milestone --json-data @@ -175,7 +177,9 @@ This is the integration value. Reasoning guidance is in - Where the plan carries the machine-readable state layer (`../../spec/PLAN_STATE.md`), derive the `--json-data` payload from `state.json`: `completed` from completed tasks (phrased as outcomes), - `in_progress` from the current task, `blockers` from `state.json.blocked`. + `in_progress` from the current task, `blockers` from `state.json.blocked` + (on a v8 plan, `state.json.blocker`, and the blocked task is the current + one). - Every event MUST be **best-effort and conditional**: it fires only if the Dailybot skill/CLI is present, authenticated and reporting is authorized, and it **MUST NOT block** `create` or `execute` if Dailybot is absent, unauthenticated, or unreachable — diff --git a/.agents/skills/deepworkplan/addons/dailybot/SPEC.md b/.agents/skills/deepworkplan/addons/dailybot/SPEC.md index 3fe245b..2489ace 100644 --- a/.agents/skills/deepworkplan/addons/dailybot/SPEC.md +++ b/.agents/skills/deepworkplan/addons/dailybot/SPEC.md @@ -182,7 +182,7 @@ execution documentation (the generated `AGENTS.md` reporting section and/or |-------|---------|-------|-------------| | **Kickoff** | A plan is materialized and approved (`create` Step 5), or its first `execute` turn begins | regular | **SHOULD** | | **Significant task** | A task that is independently significant completes — a feature, a bug fix, a major refactor (`execute` Step 5). Intermediate setup tasks are **not** reported. | regular | **MAY** | -| **Blocked** | The plan halts on a stop condition and `state.json.blocked` is populated (`AGENT_PROTOCOL.md` §7.3, `PLAN_STATE.md` §4.4) — typical of unattended runs | regular, with `blockers` populated | **SHOULD** | +| **Blocked** | The plan halts on a stop condition and `state.json.blocked` is populated — `state.json.blocker` on a v8 plan (`AGENT_PROTOCOL.md` §7.3, `PLAN_STATE.md` §4.4, `LOOP_ENGINEERING.md` §3) — typical of unattended runs | regular, with `blockers` populated | **SHOULD** | | **Completion** | All tasks `[x]`; the plan finishes (`execute` Step 7) | **milestone** | **SHOULD** | - The **kickoff** report describes *what is being built and why it matters* @@ -191,7 +191,8 @@ execution documentation (the generated `AGENTS.md` reporting section and/or - The **blocked** report is the unattended profile's escalation made human: the team sees *what is stuck and what it needs* in the standup channel instead of discovering a silent overnight halt. Its content **MUST** come from - `state.json.blocked` (`reason`, `needs`). + `state.json.blocked` (`reason`, `needs`), or from `state.json.blocker` on a + v8 plan (the same `reason` and `needs`, plus its class). - A plan **completion** is the only **milestone**; every other event is a regular report. A plan **MUST NOT** emit more than one kickoff and one completion report. @@ -205,7 +206,8 @@ The report command shape is - When the plan carries the machine-readable state layer (`PLAN_STATE.md`), `--json-data` **SHOULD** be derived from `state.json`: `completed` from the completed tasks (phrased as outcomes, not task numbers), `in_progress` from - the task currently `in_progress`, and `blockers` from `state.json.blocked`. + the task currently `in_progress`, and `blockers` from `state.json.blocked` + (`state.json.blocker` on a v8 plan). The state layer is the single source the payload is projected from — the addon **MUST NOT** invent a second progress-tracking mechanism. - Without the state layer, the payload is derived from the plan README's diff --git a/.agents/skills/deepworkplan/addons/dailybot/templates/INTEGRATION.md b/.agents/skills/deepworkplan/addons/dailybot/templates/INTEGRATION.md index 6fd682b..7dab178 100644 --- a/.agents/skills/deepworkplan/addons/dailybot/templates/INTEGRATION.md +++ b/.agents/skills/deepworkplan/addons/dailybot/templates/INTEGRATION.md @@ -88,7 +88,8 @@ convey: > Dailybot skill/CLI is installed and authenticated, DWP work emits agent > updates at four points — **kickoff** (plan approved: what is being built), > **significant task** (a feature/fix ships mid-plan), **blocked** (the plan -> halts and `state.json.blocked` says what it needs), and **completion** (the +> halts and `state.json.blocked` — `state.json.blocker` on a v8 plan — says +> what it needs), and **completion** (the > only **milestone**: what was built). If Dailybot is absent, unauthenticated, > or unreachable — or if `.dailybot/disabled` is present — skip silently and > continue. Reporting MUST NOT block `create` or `execute`. @@ -112,6 +113,7 @@ if command -v dailybot >/dev/null 2>&1 && [ ! -f .dailybot/disabled ]; then || echo "Dailybot report skipped (non-blocking)." # 3) Blocked (regular, blockers populated) — derive from state.json.blocked + # (state.json.blocker on a v8 plan; its held task reads `blocked`) dailybot agent update "" \ --json-data '{"completed":[""],"in_progress":[],"blockers":[" — needs "]}' \ || echo "Dailybot report skipped (non-blocking)." @@ -132,7 +134,9 @@ Decision notes: - **Payload from the state layer:** when the plan carries `state.json` (`PLAN_STATE.md`), derive `--json-data` from it — `completed` from completed tasks phrased as outcomes, `in_progress` from the current task, `blockers` - from `state.json.blocked` (`reason`, `needs`). Without the state layer, + from `state.json.blocked` (`reason`, `needs`) — on a v8 plan from + `state.json.blocker` (the same fields plus its class), where the held task + reads `blocked` and counts as the current one. Without the state layer, derive from the plan README's checkboxes. Never maintain a separate progress ledger just for reporting. - **One kickoff, one completion** per plan — re-runs and resumes do not diff --git a/.agents/skills/deepworkplan/addons/dependency-upgrade/SKILL.md b/.agents/skills/deepworkplan/addons/dependency-upgrade/SKILL.md index bcec15a..acc7a4e 100644 --- a/.agents/skills/deepworkplan/addons/dependency-upgrade/SKILL.md +++ b/.agents/skills/deepworkplan/addons/dependency-upgrade/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-dependency-upgrade description: DeepWorkPlan addon that safely upgrades a repo's dependencies — reasoning about the repo's ACTUAL package manager (npm/pnpm/yarn + ncu, pip/poetry/uv, cargo, go mod, bundler, composer, and more) rather than assuming npm — with a batched, validated, revertible workflow that detects the manager and manifests/lockfiles, classifies upgrades (patch/minor/major), upgrades in safe batches, runs the repo's real validation gate after each batch, reverts a failing batch, and summarizes. Near-default — offered for every repo with declared dependencies, and its delegator installs under the onboarding consent unless declined; upgrades themselves never run automatically, only as explicit, gated work. Never required for baseline conformance; reconciles with the repo's existing tooling. Use when the developer wants to bring dependencies up to date without breaking the build. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/addons/design-system/SKILL.md b/.agents/skills/deepworkplan/addons/design-system/SKILL.md index 7f8b3c7..6f6849e 100644 --- a/.agents/skills/deepworkplan/addons/design-system/SKILL.md +++ b/.agents/skills/deepworkplan/addons/design-system/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-design-system description: Optional DeepWorkPlan addon that gives a repo with a user-facing interface surface a DESIGN.md (under docs/, indexed from AGENTS.md) — a Markdown design-system file any coding agent reads to generate interface output consistent with the repo's OWN conventions. Covers three profiles detected independently from real files — visual-ui (rendered web/mobile/desktop UI), cli-output (styled terminal output — semantic colors, panels, spinners, prompts, TTY/NO_COLOR degradation), and conversational (chat/email messaging — voice and register, message anatomy, per-platform rendering). Reasons about the repo's ACTUAL design source (CSS custom properties, Tailwind config, token files, component styles, a CLI display/theme module, or message-composition helpers) rather than copying a brand file; checks contrast (WCAG AA), color-is-not-the-only-carrier, plain-text fallbacks, and token integrity. A detected interface surface makes the evaluation and offer mandatory (with a clear recommendation), while installation always requires explicit acceptance — no profile is auto-applied, even in trust mode. Never offered for a repo with no interface surface (pure library, headless service, infra-only); never required for baseline conformance; reconciles an existing DESIGN.md instead of clobbering it. Use when the developer wants agents to produce on-brand, consistent interface output — visual UI, terminal output, or outbound messages. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/addons/devcontainer/SKILL.md b/.agents/skills/deepworkplan/addons/devcontainer/SKILL.md index 16108ce..5b2118c 100644 --- a/.agents/skills/deepworkplan/addons/devcontainer/SKILL.md +++ b/.agents/skills/deepworkplan/addons/devcontainer/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-devcontainer -description: Optional DeepWorkPlan addon that gives a repository a reproducible dev container through devcontainer-kit (the `dck` command, DailybotHQ/devcontainer-kit pinned at v1.1.2, interface 2) - a vendor-neutral thin integrator that detects the kit with `dck doctor --json`, offers the kit and its tag-pinned `dck-dockerfile` skill, and lets them render the repository's own layout (.devcontainer/devcontainer.json, docker/local//Dockerfile, docker/local/docker-compose.yaml, dev.sh) from the official runtime image pinned by digest - no shared base image required. Reconciles an existing layout and never clobbers it, keeps loopback ports and agent forwarding, and validates the result with a real build. Opt-in, never required, never a conformance gate. -version: "7.12.2" +description: Optional DeepWorkPlan addon that gives a repository a reproducible dev container through devcontainer-kit (the `dck` command, DailybotHQ/devcontainer-kit pinned at v1.3.0, interface 2) - a vendor-neutral thin integrator that detects the kit with `dck doctor --json`, offers the kit and its tag-pinned `dck-dockerfile` skill, and lets them render the repository's own layout (.devcontainer/devcontainer.json, docker/local//Dockerfile, docker/local/docker-compose.yaml, dev.sh) from the official runtime image pinned by digest - no shared base image required. Reconciles an existing layout and never clobbers it, keeps loopback ports and agent forwarding, and validates the result with a real build. Opt-in, never required, never a conformance gate. +version: "8.0.0" documentation_url: https://deepworkplan.com/kit/devcontainer user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -28,7 +28,7 @@ file name. | Pin | Value | |-----|-------| | Product | `DailybotHQ/devcontainer-kit` | -| Tag | `v1.1.2` (per-repository Dockerfile, no shared base image; host accounts through `[agents] host_profiles` since `v0.3.0`; the antigravity kind, per-developer CLI choice (`[agents] supported`) and non-shared profiles on the agents volume since `v0.3.6`; coding-agents-kit `v0.7.1` and herdr-peers `v0.3.2` baked in since `v0.3.7`; the first stable release, its interface committed to semantic versioning, baking coding-agents-kit, herdr-peers and deepworkplan-vim `v1.0.0`, `v1.0.0`; coding-agents-kit `v1.0.1` baked in, so `@default` stays the container's own account, and a `dck doctor` warning when a shared `codex@default` mixes host and container Codex versions, since `v1.0.1`; coding-agents-kit `v1.1.0` and DeepWorkPlan Vim `v1.0.1` baked in since `v1.1.1`; herdr-peers `v1.2.1` (autopilot included) baked in since `v1.1.2`) | +| Tag | `v1.3.0` (per-repository Dockerfile, no shared base image; host accounts through `[agents] host_profiles` since `v0.3.0`; the antigravity kind, per-developer CLI choice (`[agents] supported`) and non-shared profiles on the agents volume since `v0.3.6`; coding-agents-kit `v0.7.1` and herdr-peers `v0.3.2` baked in since `v0.3.7`; the first stable release, its interface committed to semantic versioning, baking coding-agents-kit, herdr-peers and deepworkplan-vim `v1.0.0`, `v1.0.0`; coding-agents-kit `v1.0.1` baked in, so `@default` stays the container's own account, and a `dck doctor` warning when a shared `codex@default` mixes host and container Codex versions, since `v1.0.1`; coding-agents-kit `v1.1.0` and DeepWorkPlan Vim `v1.0.1` baked in since `v1.1.1`; herdr-peers `v1.2.1` (autopilot included) baked in since `v1.1.2`; herdr-peers `v1.3.1` (the plan loop) and coding-agents-kit `v1.4.0` (pick-v2) baked in since `v1.2.0`; opt-in container-only named volumes (`[compose] container_only`) since `v1.3.0`) | | Interface | `2` (`dck doctor --json` → `"interface": 2`) | | Skill | `dck-dockerfile`, installed from the same tag | | Registry key | `devcontainer` (`.dwp/config.json` → `addons.devcontainer`) | @@ -307,9 +307,9 @@ are copied in. Declining is complete. ### Step 2 — Install the kit and its skill (pinned; point-don't-run by default) ``` -git clone --branch v1.1.2 https://github.com/DailybotHQ/devcontainer-kit +git clone --branch v1.3.0 https://github.com/DailybotHQ/devcontainer-kit ./devcontainer-kit/install.sh -npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.1.2 --skill dck-dockerfile -y +npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.3.0 --skill dck-dockerfile -y ``` Before running the installer, check the tag and the release's `SHA256SUMS` @@ -333,7 +333,7 @@ then `dck init …` after acceptance. ### Step 4 — Record and validate -`python3 ../../shared/config.py enable devcontainer --version v1.1.2 --repo `, +`python3 ../../shared/config.py enable devcontainer --version v1.3.0 --repo `, then validate what was rendered: - `dck doctor --json` — interface 2, repo config valid, no drift; @@ -376,7 +376,7 @@ plan simply declares the host command instead. ## Validation checklist (component 4 — mirrored from SPEC §8) 1. `SKILL.md`, `SPEC.md`, `addon.json`, `templates/INTEGRATION.md` exist; the - descriptor pins `DailybotHQ/devcontainer-kit` `v1.1.2`, interface 2; no + descriptor pins `DailybotHQ/devcontainer-kit` `v1.3.0`, interface 2; no template, Dockerfile, compose file, entrypoint or `dev.sh` copy ships here. 2. `dck doctor --json` reports interface 2, a valid repo config and no drift. 3. Existing files were changed only through accepted render diffs, each diff --git a/.agents/skills/deepworkplan/addons/devcontainer/SPEC.md b/.agents/skills/deepworkplan/addons/devcontainer/SPEC.md index 0d491ba..66a9392 100644 --- a/.agents/skills/deepworkplan/addons/devcontainer/SPEC.md +++ b/.agents/skills/deepworkplan/addons/devcontainer/SPEC.md @@ -16,8 +16,8 @@ the kit's options, the registry record and the validation. | Field | Value | |-------|-------| | **Version** | 3.0.0 | -| **Status** | Stable — per-repository Dockerfile, no shared base image (devcontainer-kit `v1.1.2`, interface 2); supersedes 2.x (base-image flavours, interface 1) | -| **Product pin** | `DailybotHQ/devcontainer-kit` `v1.1.2`, interface `2`; skill `dck-dockerfile` at the same tag | +| **Status** | Stable — per-repository Dockerfile, no shared base image (devcontainer-kit `v1.3.0`, interface 2); supersedes 2.x (base-image flavours, interface 1) | +| **Product pin** | `DailybotHQ/devcontainer-kit` `v1.3.0`, interface `2`; skill `dck-dockerfile` at the same tag | | **Companions** | `SKILL.md`, `addon.json`, `templates/INTEGRATION.md`, `../README.md`, `../../spec/ADDONS.md` | ## 1. Conventions @@ -59,11 +59,11 @@ volume, CLI or profile file. - Explicit opt-in (`onboard` Phase 7b); a decline writes nothing. - Install the kit: - `git clone --branch v1.1.2 https://github.com/DailybotHQ/devcontainer-kit` then + `git clone --branch v1.3.0 https://github.com/DailybotHQ/devcontainer-kit` then `./devcontainer-kit/install.sh`. A fetch-and-execute pipeline **MUST NOT** appear in this pack's text. - The addon **SHOULD** offer the skill with - `npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.1.2 --skill dck-dockerfile -y` + `npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.3.0 --skill dck-dockerfile -y` (repo-local, recorded in `skills-lock.json`); the install **MUST** name the exact tag in that tree-URL form. - **The layout.** The render produces exactly @@ -93,7 +93,7 @@ volume, CLI or profile file. same verified release tarball, linked into every agent's skills directory at each start, so a recreate keeps them; the addon installs no second copy. - On acceptance: `addons.devcontainer` = `{"enabled": true, "version": - "v1.1.2"}` via `shared/config.py enable`. + "v1.3.0"}` via `shared/config.py enable`. ## 6. Security Defaults (inherited, never weakened) @@ -225,8 +225,8 @@ addon's container profile): enable the kit's Herdr machine option; `dck up` `~/.ssh/config` include and **MUST** be run only with its own explicit approval. Peers then run the pinned herdr-peers skill inside the container (`../herdr/install.md` §3); every image since `v0.3.5` carries herdr-peers -(`v1.1.2` bakes `v1.2.1`, autopilot included; the herdr addon itself pins -`v1.3.1`). The +(`v1.3.0` bakes `v1.3.1`, autopilot and the loop included; the herdr addon +itself pins `v2.1.0`). The kit's `[herdr] layout` key (`"standard"`: App · Editor · Development · Agents, created by `dck up`; `"none"` skips it) is the kit's choice, and the addon passes the person's preference without adding its own. The optional @@ -257,7 +257,7 @@ kit older than `v0.3.3`, the lead's brief names the value and a Codex pane 1. `SKILL.md`, `SPEC.md`, `addon.json`, `templates/INTEGRATION.md` exist; no layout, Dockerfile, compose, entrypoint, `dev.sh` or image copy ships in - this folder; `addon.json` pins `DailybotHQ/devcontainer-kit` `v1.1.2`, + this folder; `addon.json` pins `DailybotHQ/devcontainer-kit` `v1.3.0`, interface 2. 2. `dck doctor --json`: interface 2; repo config valid; drift reported. 3. Existing files changed only through accepted render diffs with diff --git a/.agents/skills/deepworkplan/addons/devcontainer/addon.json b/.agents/skills/deepworkplan/addons/devcontainer/addon.json index 4bb4d78..d3afd59 100644 --- a/.agents/skills/deepworkplan/addons/devcontainer/addon.json +++ b/.agents/skills/deepworkplan/addons/devcontainer/addon.json @@ -1,7 +1,7 @@ { "schema": "https://deepworkplan.com/schema/addon-descriptor/v1.json", "key": "devcontainer", - "product": { "repo": "DailybotHQ/devcontainer-kit", "tag": "v1.1.2", "interface": 2 }, + "product": { "repo": "DailybotHQ/devcontainer-kit", "tag": "v1.3.0", "interface": 2 }, "detect": { "command": "dck doctor --json", "interface_from": "json:interface" }, "provides_abilities": [], "requires_grants": [] diff --git a/.agents/skills/deepworkplan/addons/herdr/SKILL.md b/.agents/skills/deepworkplan/addons/herdr/SKILL.md index ca4df07..0893980 100644 --- a/.agents/skills/deepworkplan/addons/herdr/SKILL.md +++ b/.agents/skills/deepworkplan/addons/herdr/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-herdr -description: Optional DeepWorkPlan addon that integrates herdr-peers (DailybotHQ/herdr-peers pinned at v2.0.0, protocol 1 or 2) as the interactive delegation transport - a thin integrator that detects the herdr-peers helper, offers it (never imposes it) from onboard Phase 7b, documents the pinned skill installs (herdr-peers and Herdr's official skill), records the acceptance in the .dwp/config.json addon registry, and maps a v7 plan's delegation operations onto one herdr-peers ask to a peer pane on any machine, with every delegation recorded in the plan journal. The message protocol lives in herdr-peers, never here. Never required, never a conformance gate. -version: "7.12.2" +description: Optional DeepWorkPlan addon that integrates herdr-peers (DailybotHQ/herdr-peers pinned at v2.1.0, protocol 1 or 2) as the interactive delegation transport - a thin integrator that detects the herdr-peers helper, offers it (never imposes it) from onboard Phase 7b, documents the pinned skill installs (herdr-peers and Herdr's official skill), records the acceptance in the .dwp/config.json addon registry, and maps a v7 plan's delegation operations onto one herdr-peers ask to a peer pane on any machine, with every delegation recorded in the plan journal. The message protocol lives in herdr-peers, never here. Never required, never a conformance gate. +version: "8.0.0" documentation_url: https://deepworkplan.com/kit/herdr user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -12,7 +12,7 @@ metadata: {"openclaw":{"emoji":"🕸️","homepage":"https://deepworkplan.com/ki Integrate **herdr-peers** — one authorized ask/reply between coding agents in [Herdr](https://herdr.dev) panes, on this machine or another — as the -**interactive** transport a v7 plan may use to delegate a task that needs +**interactive** transport a v7 or v8 plan may use to delegate a task that needs interaction, runs long, or must run on another machine. This is an **opt-in addon**, never required for a repo to be AI-first and never a conformance gate: without it every task runs in the current session. @@ -26,7 +26,7 @@ the install lines, the transport mapping and the journaling rule. | Pin | Value | |-----|-------| | Product | `DailybotHQ/herdr-peers` | -| Tag | `v2.0.0` (protocols 1 and 2 accepted; the loop since `v1.3.0` and lead appointment, the brain and the plan-queue consumer since `v2.0.0`; native debates since `v1.1.0`, the optional autopilot since `v1.2.0`; the first stable release, `v1.0.0`, committed the interface to semantic versioning) | +| Tag | `v2.1.0` (protocols 1 and 2 accepted; the loop since `v1.3.0` and lead appointment, the brain and the plan-queue consumer since `v2.0.0`; native debates since `v1.1.0`, the optional autopilot since `v1.2.0`; the first stable release, `v1.0.0`, committed the interface to semantic versioning) | | Interface | `1` or `2` (`herdr-peers --version` → `(protocol N)`; `metadata.protocol: N` in its `SKILL.md`; protocol 2 is additive — every protocol-1 surface is intact) | | Depends on | Herdr's official skill, pinned `herdrdev/herdr@v0.9.3` | | Registry key | `herdr` (`.dwp/config.json` → `addons.herdr`) | @@ -44,7 +44,7 @@ the install lines, the transport mapping and the journaling rule. - **`onboard` Phase 7b** offers it as an explicit opt-in when the developer works with several agents in Herdr panes. -- **`execute`** uses it only through `delegation.md`: a v7 plan granting +- **`execute`** uses it only through `delegation.md`: a v7 or v8 plan granting `agent_delegation`, a `parallel_safe` task (or a read-only delegate), and `resources.py abilities` listing `addon:herdr` as a `subagents` source. - Direct invocation, to install or check it. @@ -97,7 +97,7 @@ its own documented paths, never a piped installer. ### Step 3 — Record -`python3 ../../shared/config.py enable herdr --version v2.0.0 --repo `. +`python3 ../../shared/config.py enable herdr --version v2.1.0 --repo `. Enabling grants nothing: delegation still needs the plan's grant. ### Step 4 — Transport (during execute) @@ -211,7 +211,7 @@ As of v1.2.2 it also answers a question shown with a preview beside its options, and recognises the recommended mark in Spanish, French, German and Italian. Reference: -`https://github.com/DailybotHQ/herdr-peers/blob/v2.0.0/skills/herdr-peers/autopilot.md`. +`https://github.com/DailybotHQ/herdr-peers/blob/v2.1.0/skills/herdr-peers/autopilot.md`. ## Plan loop (herdr-peers `v1.3.0` and later) @@ -288,7 +288,7 @@ cross-cutting, settled by nothing in the repository — through a herdr-peers 1. `SKILL.md`, `SPEC.md`, `install.md`, `addon.json`, `templates/INTEGRATION.md` exist; no protocol copy ships here. -2. The descriptor pins `DailybotHQ/herdr-peers` `v2.0.0`, interface 1 or 2, +2. The descriptor pins `DailybotHQ/herdr-peers` `v2.1.0`, interface 1 or 2, transport `interactive`. 3. Every install line names an exact tag. 4. The registry entry exists only after acceptance. diff --git a/.agents/skills/deepworkplan/addons/herdr/SPEC.md b/.agents/skills/deepworkplan/addons/herdr/SPEC.md index 21badc1..cf1b7df 100644 --- a/.agents/skills/deepworkplan/addons/herdr/SPEC.md +++ b/.agents/skills/deepworkplan/addons/herdr/SPEC.md @@ -18,7 +18,7 @@ rule. |-------|-------| | **Version** | 0.3.0 | | **Status** | Stable (DeepWorkPlan 7.0.0) | -| **Product pin** | `DailybotHQ/herdr-peers` `v2.0.0`, protocol/interface `1` or `2`; depends on `herdrdev/herdr@v0.9.3` (skill `herdr`) | +| **Product pin** | `DailybotHQ/herdr-peers` `v2.1.0`, protocol/interface `1` or `2`; depends on `herdrdev/herdr@v0.9.3` (skill `herdr`) | | **Companions** | `SKILL.md`, `addon.json`, `install.md`, `templates/INTEGRATION.md`, `../README.md`, `../../spec/ADDONS.md`, `../../execute/delegation.md` | ## 1. Conventions @@ -46,7 +46,7 @@ recipes — those drift; the pinned skill is the single source. ## 4. Detection - Read-only: `command -v herdr`, `command -v herdr-peers`, - `herdr-peers --version` (expect `herdr-peers 2.0.0 (protocol 2)`; a protocol-1 release also satisfies the descriptor — the accepted set is [1, 2]). + `herdr-peers --version` (expect `herdr-peers 2.1.0 (protocol 2)`; a protocol-1 release also satisfies the descriptor — the accepted set is [1, 2]). - A protocol outside the descriptor's accepted set (`[1, 2]`) **MUST** be one warning and "not available". - The transport is usable only inside Herdr (`HERDR_ENV=1`); outside it the addon is installed but not usable in that session — recorded, not an @@ -56,11 +56,11 @@ recipes — those drift; the pinned skill is the single source. - Explicit opt-in (`onboard` Phase 7b); a decline writes nothing. - Installs (`install.md`) **MUST** name exact tags: - `npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.0.0 --skill herdr-peers -g -y` + `npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.1.0 --skill herdr-peers -g -y` and `npx --yes skills add https://github.com/herdrdev/herdr/tree/v0.9.3 --skill herdr -g -y`. Herdr itself is installed through its own documented paths; a fetch-and-execute pipeline **MUST NOT** appear in this pack's text. -- On acceptance: `addons.herdr` = `{"enabled": true, "version": "v2.0.0"}` +- On acceptance: `addons.herdr` = `{"enabled": true, "version": "v2.1.0"}` via `shared/config.py enable`. Enabling grants no plan any authority. ## 6. The Transport (v7 delegation) @@ -258,7 +258,7 @@ Nothing blocks `onboard`, `create`, `execute` or `verify`. 1. `SKILL.md`, `SPEC.md`, `install.md`, `addon.json`, `templates/INTEGRATION.md` exist; no protocol file ships in this folder. -2. `addon.json`: key `herdr`, product `DailybotHQ/herdr-peers` `v2.0.0`, +2. `addon.json`: key `herdr`, product `DailybotHQ/herdr-peers` `v2.1.0`, interface 1 or 2 (the descriptor's accepted list), transport `interactive`. 3. Every install line pins a tag; no pipeline text. 4. The registry entry exists only after acceptance. diff --git a/.agents/skills/deepworkplan/addons/herdr/addon.json b/.agents/skills/deepworkplan/addons/herdr/addon.json index fcb654b..6d90dba 100644 --- a/.agents/skills/deepworkplan/addons/herdr/addon.json +++ b/.agents/skills/deepworkplan/addons/herdr/addon.json @@ -3,7 +3,7 @@ "key": "herdr", "product": { "repo": "DailybotHQ/herdr-peers", - "tag": "v2.0.0", + "tag": "v2.1.0", "interface": [ 1, 2 diff --git a/.agents/skills/deepworkplan/addons/herdr/install.md b/.agents/skills/deepworkplan/addons/herdr/install.md index e8e43f9..02e06f7 100644 --- a/.agents/skills/deepworkplan/addons/herdr/install.md +++ b/.agents/skills/deepworkplan/addons/herdr/install.md @@ -17,7 +17,7 @@ the pinned official skill). ``` npx --yes skills add https://github.com/herdrdev/herdr/tree/v0.9.3 --skill herdr -g -y -npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.0.0 --skill herdr-peers -g -y +npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.1.0 --skill herdr-peers -g -y ``` Both `-y` flags are required in an agent's non-interactive shell (`npx @@ -25,7 +25,7 @@ Both `-y` flags are required in an agent's non-interactive shell (`npx The first is Herdr's official skill (the authority for every `herdr` command; `herdr --skill` prints the copy matching the installed binary). The second installs the herdr-peers skill and its helper script. Verify: -`herdr-peers --version` → `herdr-peers 2.0.0 (protocol 2)`. +`herdr-peers --version` → `herdr-peers 2.1.0 (protocol 2)`. **Plan loop (herdr-peers v1.3.0 and later).** To have open Deep Work Plans run to their end without polling each lead, a human starts the loop daemon @@ -46,7 +46,7 @@ For a scoped trial in one repository without touching `$HOME` (F-10), install the helper skill repo-locally — drop `-g`: ``` -npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.0.0 --skill herdr-peers -y +npx --yes skills add https://github.com/DailybotHQ/herdr-peers/tree/v2.1.0 --skill herdr-peers -y ``` It lands under the repository's agent skills directory (e.g. @@ -84,5 +84,5 @@ host profile — this addon describes them, never sets them. ## 4. Record the acceptance ``` -python3 /shared/config.py enable herdr --version v2.0.0 --repo +python3 /shared/config.py enable herdr --version v2.1.0 --repo ``` diff --git a/.agents/skills/deepworkplan/addons/machine-installs.md b/.agents/skills/deepworkplan/addons/machine-installs.md index 32340f8..61fd6fa 100644 --- a/.agents/skills/deepworkplan/addons/machine-installs.md +++ b/.agents/skills/deepworkplan/addons/machine-installs.md @@ -15,10 +15,10 @@ actually verified (`--ignore-missing` alone would pass with none). coding-agents-kit (`agentkit`): ```bash -git clone --branch v1.4.0 --depth 1 https://github.com/DailybotHQ/coding-agents-kit cak -git -C cak describe --tags --exact-match # must print v1.4.0 -curl -fsSL https://github.com/DailybotHQ/coding-agents-kit/releases/download/v1.4.0/SHA256SUMS -o cak.SHA256SUMS -echo "1ae33b64622a91a624c3fc1d483ae8b200896de6eb9f7a3f04cd7f23ce2fb2c6 cak.SHA256SUMS" | shasum -a 256 -c # the pinned digest +git clone --branch v1.5.0 --depth 1 https://github.com/DailybotHQ/coding-agents-kit cak +git -C cak describe --tags --exact-match # must print v1.5.0 +curl -fsSL https://github.com/DailybotHQ/coding-agents-kit/releases/download/v1.5.0/SHA256SUMS -o cak.SHA256SUMS +echo "d8057636d357ba056ab8c8a7feec58d31b53cb58c91d943109b7f22590b5cca3 cak.SHA256SUMS" | shasum -a 256 -c # the pinned digest (cd cak && shasum -a 256 -c --ignore-missing ../cak.SHA256SUMS) # must exit 0 (cd cak && shasum -a 256 -c --ignore-missing ../cak.SHA256SUMS | grep -c ': OK$') # must print a number above 0 ./cak/install.sh @@ -27,10 +27,10 @@ echo "1ae33b64622a91a624c3fc1d483ae8b200896de6eb9f7a3f04cd7f23ce2fb2c6 cak.SHA2 devcontainer-kit (`devcontainer`): ```bash -git clone --branch v1.1.2 --depth 1 https://github.com/DailybotHQ/devcontainer-kit dck -git -C dck describe --tags --exact-match # must print v1.1.2 -curl -fsSL https://github.com/DailybotHQ/devcontainer-kit/releases/download/v1.1.2/SHA256SUMS -o dck.SHA256SUMS -echo "c7a5ffb737777473f08932f9a2de153518d923f5d7edeb4ab97fdd7537bf2374 dck.SHA256SUMS" | shasum -a 256 -c # the pinned digest +git clone --branch v1.3.0 --depth 1 https://github.com/DailybotHQ/devcontainer-kit dck +git -C dck describe --tags --exact-match # must print v1.3.0 +curl -fsSL https://github.com/DailybotHQ/devcontainer-kit/releases/download/v1.3.0/SHA256SUMS -o dck.SHA256SUMS +echo "663b06f3be1108b93d401e8b9ec9da77b1f6953b86a98729bf54a8bfc5fae969 dck.SHA256SUMS" | shasum -a 256 -c # the pinned digest (cd dck && shasum -a 256 -c --ignore-missing ../dck.SHA256SUMS) # must exit 0 (cd dck && shasum -a 256 -c --ignore-missing ../dck.SHA256SUMS | grep -c ': OK$') # must print a number above 0 ./dck/install.sh diff --git a/.agents/skills/deepworkplan/addons/vim/SKILL.md b/.agents/skills/deepworkplan/addons/vim/SKILL.md index 10be7dd..e7f93fc 100644 --- a/.agents/skills/deepworkplan/addons/vim/SKILL.md +++ b/.agents/skills/deepworkplan/addons/vim/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-addon-vim description: Optional DeepWorkPlan addon that offers DeepWorkPlan Vim, the terminal editor for Deep Work Plan (Neovim 0.12+, its own repository DailybotHQ/deepworkplan-vim pinned at v1.0.1), as a machine-level install for the person behind a repository - a thin integrator that reads the product's own addon/surface.json (interface 1) to detect the editor, offers it (never imposes it) from onboard Phase 7b, guides the product's documented, checksum-verified install under an absolute consent gate, and validates the installed surface. Two routes - the full editor today, the Neovim plugin in v7.1. Never required, never a conformance gate, and an existing Neovim config is never overwritten without explicit consent. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com/kit/vim user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/author/SKILL.md b/.agents/skills/deepworkplan/author/SKILL.md index 6cdb199..c705f13 100644 --- a/.agents/skills/deepworkplan/author/SKILL.md +++ b/.agents/skills/deepworkplan/author/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-author description: Author or update reusable skills, agents, and commands in the current repo — reason about the repo's .agents/ layout, follow the Open Agent Skills frontmatter contract, and keep the .agents/docs/ catalog in sync. Use when a developer wants to create or evolve the repo's agent kit (skills, agents, commands), or runs /skill-create or /agent-create. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/create/SKILL.md b/.agents/skills/deepworkplan/create/SKILL.md index 3946d66..e2df4de 100644 --- a/.agents/skills/deepworkplan/create/SKILL.md +++ b/.agents/skills/deepworkplan/create/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-create description: Create a Deep Work Plan for short or long work. Detect planning intent, materialize a compact Lite proposal first, then retain Lite or expand to Full task files when needed. Supports guided and trust handoff without executing product work. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -260,10 +260,10 @@ all following text is literal context. Never inspect ordinary context words. **0.3 Select the plan generation:** if this pack's line is 6+ or the developer explicitly asked for a v6 plan, read [`v6.md`](v6.md) and follow that flow -exclusively (it also covers v7). Stop here: Steps 1 onward describe the -retained v5 lifecycle and MUST NOT be applied to a v6 or v7 plan. With this -7.x pack, v7 is the default for new plans; an explicit `v6` request -materializes a v6 contract. Existing plans always keep their recorded generation. +exclusively (also v7 and v8). Stop here: Steps 1 onward describe the +retained v5 lifecycle and MUST NOT be applied to a v6–v8 plan. With this +8.x pack, v8 is the default for new plans; an explicit `v7` or `v6` request +materializes it. Existing plans always keep their recorded generation. ### Step 1 — Quick Introduction diff --git a/.agents/skills/deepworkplan/create/v6.md b/.agents/skills/deepworkplan/create/v6.md index 69a16bc..66ce236 100644 --- a/.agents/skills/deepworkplan/create/v6.md +++ b/.agents/skills/deepworkplan/create/v6.md @@ -1,15 +1,22 @@ -# Create — a v6/v7 plan (outcome contract, guarded materialization) - -Read this file when creating a plan with the current pack. It covers both -contract generations of the same record layer: **v7 is the default for new -plans on the 7.x pack** (contract `schema` = -`https://deepworkplan.com/schema/plan-contract/v7.json`, the v6 contract -plus the optional `tasks[].parallel_safe` marker; its journal also records -delegation — [`spec/V7_CONTRACT.md`](../spec/V7_CONTRACT.md)); an explicit -`v6` request writes `https://deepworkplan.com/schema/plan-contract/v6.json` -and the v6 rules below apply unchanged. `materialize` derives the manifest -and journal generation from that URL. Existing plans keep their recorded -generation. +# Create — a v6/v7/v8 plan (outcome contract, guarded materialization) + +Read this file when creating a plan with the current pack. It covers every +contract generation of the same record layer: **v8 is the default for new +plans on the 8.x pack** (contract `schema` = +`https://deepworkplan.com/schema/plan-contract/v8.json`: the v7 contract — +the v6 contract plus the optional `tasks[].parallel_safe` marker, with a +journal that also records delegation, +[`spec/V7_CONTRACT.md`](../spec/V7_CONTRACT.md) — plus the optional, closed +`autonomy` block, [`spec/LOOP_ENGINEERING.md`](../spec/LOOP_ENGINEERING.md)). +Write an `autonomy` block only for what the developer states (stall budget, +promptable panes, notify targets, whether a brain may act, queue start); +every absent key takes its recorded default, so most plans carry none. An +explicit `v7` request writes +`https://deepworkplan.com/schema/plan-contract/v7.json` and an explicit `v6` +request `https://deepworkplan.com/schema/plan-contract/v6.json`; the rules +below apply unchanged to all three. `materialize` derives the manifest and +journal generation from that URL (a v8 plan uses the v7 manifest and +journal line). Existing plans keep their recorded generation. A v6 plan is two authored artifacts plus one guarded sequence: @@ -92,6 +99,34 @@ the reference it was derived from. A later disagreement between the two is resolved by an amendment through refine, never by re-reading the request over the contract. Delegates receive pointers to the note, not paraphrases. +**The plan queue (when the developer asks to queue the plan, or a v8 +contract records `autonomy.queue` other than `none`).** After `materialize` +succeeds (the approval exists), append the plan to the repository's queue so +the herdr-peers loop starts it when it is ready +([`../spec/LOOP_ENGINEERING.md`](../spec/LOOP_ENGINEERING.md) §4); `--start` +is the contract's `autonomy.queue` when it records one: + +```bash +python3 ../shared/queue.py --dwp append --plan --lead
\ + [--after ] [--start prompt-lead|launch] +``` + +`--lead` is the pane the daemon prompts to start the plan: the one the +developer names, or else, inside Herdr, your own — pass `$HERDR_PANE_ID` as +it is (the helper accepts a pane id such as `w9:p1` or a full address such +as `local:w9:p1`). If the helper refuses it, take your row's address from +`herdr-peers list` or ask the developer, and retry with `--lead`. Append +without a lead only when no address is known yet: the item then waits (the +daemon reports it as `no lead named`) until the developer or the lead names +one with +`python3 ../shared/queue.py --dwp set-lead --plan --lead
`. + +`--after` names a plan already in the queue that must complete first. A +`prompt-lead` start makes the daemon prompt the named lead once; a `launch` +start is recorded but not started (launching is not available yet). The +helper is the only writer the flows use: never edit `queue.json` by hand from +a flow. Not queuing is the default and always correct. + **v7: marking `parallel_safe` and granting delegation.** Mark a task `"parallel_safe": true` only when **all** hold: the repository enables a delegation addon (`python3 ../shared/config.py enabled --repo ` lists @@ -123,6 +158,21 @@ says so. A **different** contract for a materialized plan is never written over the old one — that is a revision, the refine amendment path (`contracts/` chain, fresh approval). +**The `PROGRESS.md` header (v8).** Right after `materialize`, give the +plan's `PROGRESS.md` its structured header (spec +[`LOOP_ENGINEERING.md`](../spec/LOOP_ENGINEERING.md) §3.2) — four fixed +lines under the title that the loop, the fleet and `resume` read instead of +prose: + +```bash +python3 ../shared/progress_header.py --plan \ + --goal "" --next "" +``` + +`Current task` and `Needs` are derived from the records, so the header can +never claim a state the journal does not hold; the body below it stays the +working index the recorded flow describes. v6 and v7 plans skip this step. + After materialization: report the contract id and the plan digest back, and route to **execute** (the v6 loop). Never auto-execute; the create flow ends at the approval event, exactly as in guided mode. diff --git a/.agents/skills/deepworkplan/execute/SKILL.md b/.agents/skills/deepworkplan/execute/SKILL.md index 80fe57b..69114f5 100644 --- a/.agents/skills/deepworkplan/execute/SKILL.md +++ b/.agents/skills/deepworkplan/execute/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-execute description: Execute Lite or Full Deep Work Plans task-by-task — select validation from the actual surface, preserve state and evidence, recover safely, and finish with the Final Review. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -30,8 +30,8 @@ when their moment arrives. t0 set — the operative rules the loop needs are inline below. - **Conditional — read only when the trigger fires:** - [`v6.md`](v6.md) (this directory) — read only when Step 2.0 detects a - v6 or v7 plan; it carries the whole task loop. - - [`delegation.md`](delegation.md) — read only when a v7 plan granting + v6, v7 or v8 plan; it carries the whole task loop. + - [`delegation.md`](delegation.md) — read only when a v7 or v8 plan granting `agent_delegation` delegates a task. - [`debate.md`](debate.md) — read only when a listed decision task runs. - [`../guide/swarm.md`](../guide/swarm.md) §17 — read only when the diff --git a/.agents/skills/deepworkplan/execute/delegation.md b/.agents/skills/deepworkplan/execute/delegation.md index 0244f64..26f9560 100644 --- a/.agents/skills/deepworkplan/execute/delegation.md +++ b/.agents/skills/deepworkplan/execute/delegation.md @@ -1,7 +1,7 @@ -# Execute — delegation (v7 plans only) +# Execute — delegation (v7 and v8 plans) -Read this file only when a **v7** plan (contract `schema` = -`…/plan-contract/v7.json`) grants `agent_delegation` and the next task is +Read this file only when a **v7 or v8** plan (contract `schema` = +`…/plan-contract/v7.json` or `…/plan-contract/v8.json`) grants `agent_delegation` and the next task is marked `parallel_safe` — or a read-only delegate would help it. Otherwise the task runs in this session exactly as `v6.md` describes; not delegating is always correct. Normative source: `../spec/V7_CONTRACT.md` and @@ -9,7 +9,7 @@ is always correct. Normative source: `../spec/V7_CONTRACT.md` and ## When a delegate may be used (all must hold) -1. The contract is v7 and grants `agent_delegation`. +1. The contract is v7 or v8 and grants `agent_delegation`. 2. The task is marked `parallel_safe` by `create` — or the delegate is **read-only** (no worktree, no writes: research, review, analysis). 3. `python3 ../shared/resources.py --plan abilities` lists the diff --git a/.agents/skills/deepworkplan/execute/v6.md b/.agents/skills/deepworkplan/execute/v6.md index 9839b40..e59e16b 100644 --- a/.agents/skills/deepworkplan/execute/v6.md +++ b/.agents/skills/deepworkplan/execute/v6.md @@ -58,6 +58,15 @@ For the task the scheduler selects (strict order, one at a time): were evaluated before the current task start — D3-6). Its decision, not the model's, is the dispatch. 2. **Start** — `python3 ../shared/ledger.py --plan start --task `. + On any task start while `.dwp/queue.json` still lists this plan as + `queued` (normally the first; a crash or a resume retries) and the + session runs inside Herdr (`HERDR_ENV=1`), mark it started with the + address your lead claim recorded (the `lead` of + `herdr-peers lead show --plan --json`): + `python3 ../shared/queue.py --dwp set-state --plan + --state started --lead `. Best-effort: a refusal + warns once and never blocks the task. Outside Herdr leave the item as it + is (the queue's consumer reads the journal's task start). Refused (exit 3) until a materialization-time `approval` event cites the live `contract_id`, and refused (exit 3, a recorded `refusal`) while any of the task's declared `prerequisites` is not complete — the scheduler's @@ -66,7 +75,7 @@ For the task the scheduler selects (strict order, one at a time): from exactly that record. 3. **Implement** the task's objective (its file is the work instruction; the skills and documentation decisions happen here as in Step 5 rule 2). - On a v7 plan that grants `agent_delegation`, a `parallel_safe` task MAY + On a v7 or v8 plan that grants `agent_delegation`, a `parallel_safe` task MAY be implemented by a delegate instead — read [`delegation.md`](delegation.md) first; its result is asserted until step 4 here observes it. A **decision task** the plan lists under @@ -130,7 +139,11 @@ For the task the scheduler selects (strict order, one at a time): ` (the reconciliation is itself recorded). Update the human layer (task log, README task list, `PROGRESS.md`) in the same order as the v5 loop: log → README → PROGRESS → commit. Never hand-edit `state.json` or - `views/*.md` — they are projections. + `views/*.md` — they are projections. On a v8 plan, refresh the + `PROGRESS.md` header on every transition — a task start, a close, a + blocker raised or resolved: `python3 ../shared/progress_header.py --plan + --next ""` (the goal is kept; the + current task and needs are derived from the records). 9. **Envelope posture** (when the contract declares limits) — `python3 ../shared/resources.py --plan report` and `hold`. The report names each limit's effective mode honestly (journal-computed, @@ -188,7 +201,36 @@ runs unchanged from [`SKILL.md`](SKILL.md) Step 7 (security pass with the required local review, final-state validation, skills and documentation reconciliation, closure) — over the plan's full accumulated change set. No handwritten success receipt: the receipt command's output, the -completion view and the exported manifest are the evidence. +completion view and the exported manifest are the evidence. If +`.dwp/queue.json` lists this plan, mark it done after the closure +(`python3 ../shared/queue.py --dwp set-state --plan +--state done`) so the loop can start the next one; best-effort, never a +gate. + +## Blockers (v8: structured, recorded by the helper) + +When a task of a v8 plan cannot continue, record the blocker with the +ledger — never by editing a file and never with a raw `append` (refused) — +then refresh the header and stop at it: + +```bash +python3 ../shared/ledger.py --plan block --task --json \ + '{"reason": "", "needs": "", "class": "C3", "resolver": "lead"}' +python3 ../shared/ledger.py --plan unblock --task --note "" +``` + +`class` is the escalation class of `AGENT_PROTOCOL.md` §7.5 (required). +Mark `"resolver": "lead"` only when the plan's lead can resolve it inside +the recorded authority without a credential, login, consent, payment, push +to main, release or deletion; otherwise omit it (absent = human). The +ledger refuses `lead` for C1, C2, C5 and C6, refuses a second task's raise +while one blocker is active, and refuses completion while the task's +blocker is unresolved (exit 4). `block` and `unblock` re-project +`state.json`, so the blocker is visible to the loop at once (spec +[`LOOP_ENGINEERING.md`](../spec/LOOP_ENGINEERING.md) §3). When the Dailybot +addon is wired, a blocked run emits its `blocked` report from +`state.json.blocker` (`reason`, `needs`). +v6 and v7 plans keep their recorded blocked protocol. ## Degraded postures (honest, never blocking) diff --git a/.agents/skills/deepworkplan/guide/GUIDE.md b/.agents/skills/deepworkplan/guide/GUIDE.md index 4d9911b..52b727f 100644 --- a/.agents/skills/deepworkplan/guide/GUIDE.md +++ b/.agents/skills/deepworkplan/guide/GUIDE.md @@ -2,16 +2,8 @@ ### How to Create Deep-Work Task Execution Plans (outputs under `.dwp/`) -This guide defines the **official structure and workflow** for creating _agent deep work plans_. - -These plans are designed so that an AI agent (Cursor, Claude, etc.) can: - -- Work for **many hours** (including overnight) -- Focus on **one task at a time** -- Follow a **clear, ordered execution plan** -- Keep everything **modular, auditable and disposable** - -Use this document whenever you need to generate a new deep-work plan. +The repository is the harness: versioned files travel with the code. **Spec-first, loop-closed: the repository is the harness and the plan runs itself to done.** Spec-first is one work episode: the plan is written before code with acceptance criteria. It lives as exportable, git-ignored `.dwp/plans/` working state, resumable by any agent in the repository, not as a maintained specification. +**Loop engineering** registers a lead and succession; a human starts the optional daemon, whose prompts add no authority. It supports takeover, granted appointment, `plan-event-v1`, `fleet-v1`, and prompt-lead queue starts. The plan runs within its recorded authority and gates. DWP measures the instruction bytes each flow loads; it has not shown a general saving in provider tokens. The method works alone. --- @@ -22,12 +14,9 @@ Use this document whenever you need to generate a new deep-work plan. > extraction comes back empty, that is a defect to report, never a blank > section. -This file is the **routing index** of the methodology guide. The guide's content -is unchanged; it is split into flow-scoped files so an agent loads only what its -current flow needs (`spec/DWP_SPECIFICATION.md` §5). The design rationale lives -in the contributor-only repository ADR. -Nothing here is compressed — every section that existed in -the single-file guide exists verbatim in exactly one file below. +This file is the routing index; each flow loads only what it needs +(`spec/DWP_SPECIFICATION.md` §5). +Do not read every guide file up front; load only what your current flow needs. ## How to read this guide (by flow) @@ -41,9 +30,6 @@ the single-file guide exists verbatim in exactly one file below. | **Upgrade** the installed skill | [`structure.md`](./structure.md) §1–§2 (what lives where) | the `upgrade` sub-skill itself (`../upgrade/SKILL.md`) — check is read-only, download needs explicit acceptance, `.dwp/` is never migrated | | **Author** skills/agents | [`skills-integration.md`](./skills-integration.md) | — | -Do not read every file by default. Each sub-skill's "Shared resources" section -names its essential files and its conditional triggers. - ## Section map (every section of the original guide, in original order) | Section | Now in | diff --git a/.agents/skills/deepworkplan/onboard/SKILL.md b/.agents/skills/deepworkplan/onboard/SKILL.md index 66c8a94..2b667dc 100644 --- a/.agents/skills/deepworkplan/onboard/SKILL.md +++ b/.agents/skills/deepworkplan/onboard/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-onboard description: Make any repository AI-first — reason (never template) an adapted AGENTS.md, docs/, per-module docs and .agents/ kit from the real repo, discover and verify its full and scoped validation commands and source-to-test mapping, install the DeepWorkPlan skill, and, for a repository onboarded under an earlier version, perform a targeted, non-destructive, idempotent harness upgrade. Use when the developer wants to onboard or upgrade a repository for AI agents. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -104,7 +104,7 @@ When this flow finishes, the target repo contains: escalation paths and fallback, plus the unit-first posture — so every future plan can select its gates instead of guessing (`../spec/DOCUMENTATION_STANDARD.md` §3.4). 7. **A recorded standard and a first usable outcome** — the provenance line - `DWP standard: 7.0.0 (onboarded YYYY-MM-DD; skill x.y.z)` in `AGENTS.md`, and + `DWP standard: 8.0.0 (onboarded YYYY-MM-DD; skill x.y.z)` in `AGENTS.md`, and a `.dwp/onboard/REPORT.md` that names the verified command and mapping, the installed skill identity and version, the active capability limits (what could not be verified and why), and the exact post-onboarding next command @@ -472,7 +472,7 @@ context. It MUST cover these six responsibilities: (`full` / `scoped`). **Mark** any command that runs only in CI or only inside a container (e.g. "must run **inside** the Docker container"), and any scoped pattern that is proposed/unverified. -4. **Provenance** — one line, `DWP standard: 7.0.0 (onboarded YYYY-MM-DD; +4. **Provenance** — one line, `DWP standard: 8.0.0 (onboarded YYYY-MM-DD; skill x.y.z)` (on upgrade: `…; upgraded YYYY-MM-DD; skill x.y.z`), so a checker and a future agent can tell which standard the repository declares (`../spec/DOCUMENTATION_STANDARD.md` §3.5). diff --git a/.agents/skills/deepworkplan/onboard/addons.md b/.agents/skills/deepworkplan/onboard/addons.md index 4f3ffd3..ea45af9 100644 --- a/.agents/skills/deepworkplan/onboard/addons.md +++ b/.agents/skills/deepworkplan/onboard/addons.md @@ -78,22 +78,22 @@ records its Phase 7a status). Offer the seven optional ones independently: | Addon | Folder | Recommend in trust mode when… | |-------|--------|-------------------------------| -| **Devcontainer support** | [`../addons/devcontainer/`](../addons/devcontainer/SKILL.md) | the repo benefits from a reproducible isolated dev container (most repos with Docker/services). Pinned devcontainer-kit `v1.1.2` plus its `dck-dockerfile` skill; the repository owns its Dockerfile, no shared base image. | +| **Devcontainer support** | [`../addons/devcontainer/`](../addons/devcontainer/SKILL.md) | the repo benefits from a reproducible isolated dev container (most repos with Docker/services). Pinned devcontainer-kit `v1.3.0` plus its `dck-dockerfile` skill; the repository owns its Dockerfile, no shared base image. | | **Dailybot integration** | [`../addons/dailybot/`](../addons/dailybot/SKILL.md) | the developer/team **already uses Dailybot** or asks for team progress reporting — **do NOT auto-install for everyone**. | | **Dependency upgrade** | [`../addons/dependency-upgrade/`](../addons/dependency-upgrade/SKILL.md) | **near-default** — the repo has **declared dependencies** (any manifest or lockfile): offer **always**, and install the **inert** `/lib-upgrade` delegator under the onboarding consent **unless explicitly declined**. Installing the delegator runs **no** upgrade — upgrades are always explicit, gated work. | | **Design system** | [`../addons/design-system/`](../addons/design-system/SKILL.md) | the repo has a **user-facing interface surface**, detected per profile: when any surface is detected — even an ambiguous one — the evaluation and offer are **mandatory, not skippable**, with the detection rationale recorded. **visual-ui** (stylesheet with CSS custom properties, Tailwind config or `@theme` block, UI components, brand/style guide) is **strongly recommended**; **cli-output** (a CLI rendering library + a deliberate display layer) and **conversational** (a chat SDK or message-composition layer) are **recommended**. Every profile **requires explicit acceptance even in trust mode — none is auto-applied**. **Never offer for a repo with no interface surface** (pure library, headless service, infra-only). | -| **agentkit** | [`../addons/agentkit/`](../addons/agentkit/SKILL.md) | the developer wants plans to hand bounded `parallel_safe` tasks to other coding agents (claude, codex, cursor, …) — a machine-level install (`git clone --branch v1.4.0` + `install.sh`), never a repo requirement; delegation additionally needs each plan's `agent_delegation` grant. The kit runs agents in autonomy by default; the `--ask` / `AGENTKIT_PERMISSIONS=ask` opt-out always wins. | -| **Herdr** | [`../addons/herdr/`](../addons/herdr/SKILL.md) | the developer runs coding agents in [Herdr](https://herdr.dev) panes (one machine or several) and wants plans to ask a peer agent to take a task or run a native debate panel (by default, consequential plan decisions are debated; `decisions.debate off` turns it off) — a machine-level install of `herdr-peers@v2.0.0` (+ Herdr's official skill, pinned), never a repo requirement; delegation additionally needs each plan's `agent_delegation` grant. | +| **agentkit** | [`../addons/agentkit/`](../addons/agentkit/SKILL.md) | the developer wants plans to hand bounded `parallel_safe` tasks to other coding agents (claude, codex, cursor, …) — a machine-level install (`git clone --branch v1.5.0` + `install.sh`), never a repo requirement; delegation additionally needs each plan's `agent_delegation` grant. The kit runs agents in autonomy by default; the `--ask` / `AGENTKIT_PERMISSIONS=ask` opt-out always wins. | +| **Herdr** | [`../addons/herdr/`](../addons/herdr/SKILL.md) | the developer runs coding agents in [Herdr](https://herdr.dev) panes (one machine or several) and wants plans to ask a peer agent to take a task or run a native debate panel (by default, consequential plan decisions are debated; `decisions.debate off` turns it off) — a machine-level install of `herdr-peers@v2.1.0` (+ Herdr's official skill, pinned), never a repo requirement; delegation additionally needs each plan's `agent_delegation` grant. | | **DeepWorkPlan Vim** | [`../addons/vim/`](../addons/vim/SKILL.md) | a person on this machine uses Neovim ≥ 0.12 or asks for a terminal editor for plans — a **machine-level** install, never a repo requirement; the editor is never imposed and an existing Neovim config is **never** overwritten without explicit consent (non-interactive runs onto an existing config stop at instructions). Pinned `deepworkplan-vim@v1.0.1`, detected through the product's `addon/surface.json`. | | **AI Diff Reviewer** | [`../addons/ai-diff-reviewer/`](../addons/ai-diff-reviewer/SKILL.md) | **not offered here — installed in Phase 7a** (required local review, baseline since 2.3.0). In Phase 7b only confirm the Flow B (CI Action) opt-in decision if it was left open; never install the CI surface unrequested. | The first addon is **devcontainer support** ([`../addons/devcontainer/SKILL.md`](../addons/devcontainer/SKILL.md) + [`SPEC.md`](../addons/devcontainer/SPEC.md)), a thin integrator of -devcontainer-kit (`dck`, pinned `v1.1.2`). If the developer accepts: read +devcontainer-kit (`dck`, pinned `v1.3.0`). If the developer accepts: read that addon's `SKILL.md` and run its flow — detect the kit (`dck doctor --json`, interface `2`), install it and offer its `dck-dockerfile` skill -(`npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.1.2 --skill dck-dockerfile -y`), +(`npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.3.0 --skill dck-dockerfile -y`), then let the skill (or you, from the stack you detected in Phase 1) reason the service, runtime, ports and agents and render the repository's own layout — `.devcontainer/devcontainer.json`, diff --git a/.agents/skills/deepworkplan/refine/SKILL.md b/.agents/skills/deepworkplan/refine/SKILL.md index d477d7f..d875629 100644 --- a/.agents/skills/deepworkplan/refine/SKILL.md +++ b/.agents/skills/deepworkplan/refine/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-refine description: Refine a Deep Work Plan — safely edit scope, add, split or reorder tasks, promote a Lite plan to Full task files, recover a partial promotion, or explicitly migrate a legacy plan, always preserving completed evidence. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -48,7 +48,9 @@ counts, `PROGRESS.md`, and the **regenerated** `state.json` — kept mutually consistent. Deleting a completed task, dropping the Final Review (or a legacy plan's final tasks), or invalidating completed evidence requires explicit developer confirmation. `manifest.json` is **never** rewritten -(`../spec/PLAN_STATE.md` §2). +(`../spec/PLAN_STATE.md` §2). One write outside the plan folder: a queued +plan's `skipped` state in `.dwp/queue.json`, through `../shared/queue.py` +only (see *Plan queue* below). **It MUST NOT:** touch source files, write outside `.dwp/`, weaken a task's acceptance criteria or validation gate without saying so in the diff summary, @@ -340,6 +342,10 @@ a marked plan. Full-to-Lite downgrade is not automatic. exception and is explicit. - **No mandatory report:** refine never adds an Executive Report task; it may record an explicit report request in the README guidelines. +- **Plan queue:** when the developer takes a queued plan out of the + repository's queue, record why: `python3 ../shared/queue.py --dwp + set-state --plan --state skipped --note ""`. Reordering + is the developer's or the lead's own edit of `.dwp/queue.json`. - **Git ignore:** everything under `.dwp/` is git-ignored. - **No draft artifact:** `refine` always operates on a plan folder under `.dwp/plans/`. Nothing is written to `.dwp/drafts/` — it no longer exists. diff --git a/.agents/skills/deepworkplan/resume/SKILL.md b/.agents/skills/deepworkplan/resume/SKILL.md index ac6dbea..37b11b1 100644 --- a/.agents/skills/deepworkplan/resume/SKILL.md +++ b/.agents/skills/deepworkplan/resume/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-resume description: Resume interrupted Lite or Full Deep Work Plans from durable Markdown and state, including safe recovery of promotions without duplicating completed work or gates. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write diff --git a/.agents/skills/deepworkplan/shared/contract_v6.py b/.agents/skills/deepworkplan/shared/contract_v6.py index 492eacb..f720440 100644 --- a/.agents/skills/deepworkplan/shared/contract_v6.py +++ b/.agents/skills/deepworkplan/shared/contract_v6.py @@ -37,11 +37,23 @@ # carry exactly its generation's journal URL (mixed generations refused). CONTRACT_SCHEMA_URL_V7 = 'https://deepworkplan.com/schema/plan-contract/v7.json' JOURNAL_SCHEMA_URL_V7 = 'https://deepworkplan.com/schema/journal-event/v7.json' -CONTRACT_GENERATIONS = {CONTRACT_SCHEMA_URL: 'v6', CONTRACT_SCHEMA_URL_V7: 'v7'} -JOURNAL_GENERATIONS = {JOURNAL_SCHEMA_URL: 'v6', JOURNAL_SCHEMA_URL_V7: 'v7'} -JOURNAL_URL_BY_GENERATION = {'v6': JOURNAL_SCHEMA_URL, 'v7': JOURNAL_SCHEMA_URL_V7} +CONTRACT_SCHEMA_URL_V8 = 'https://deepworkplan.com/schema/plan-contract/v8.json' +JOURNAL_SCHEMA_URL_V8 = 'https://deepworkplan.com/schema/journal-event/v8.json' + +# The v8 generation (spec/LOOP_ENGINEERING.md) adds one optional top-level +# `autonomy` block to v7 — the plan's recorded authority for the loop — and +# its own journal generation: journal-event/v8 = v7 + the `blocker` event +# (structured blockers, LOOP_ENGINEERING.md section 3). The manifest line +# stays plan-manifest/v7: the manifest's shape and pointer do not change. +CONTRACT_GENERATIONS = {CONTRACT_SCHEMA_URL: 'v6', CONTRACT_SCHEMA_URL_V7: 'v7', + CONTRACT_SCHEMA_URL_V8: 'v8'} +JOURNAL_GENERATIONS = {JOURNAL_SCHEMA_URL: 'v6', JOURNAL_SCHEMA_URL_V7: 'v7', + JOURNAL_SCHEMA_URL_V8: 'v8'} +JOURNAL_URL_BY_GENERATION = {'v6': JOURNAL_SCHEMA_URL, 'v7': JOURNAL_SCHEMA_URL_V7, + 'v8': JOURNAL_SCHEMA_URL_V8} CONTRACT_URL_BY_GENERATION = {'v6': CONTRACT_SCHEMA_URL, - 'v7': CONTRACT_SCHEMA_URL_V7} + 'v7': CONTRACT_SCHEMA_URL_V7, + 'v8': CONTRACT_SCHEMA_URL_V8} # v7 delegation (spec/V7_CONTRACT.md section 3; ecosystem contract 2.5). DELEGATION_TRANSPORTS = ('headless', 'interactive') @@ -51,8 +63,19 @@ DIGEST = re.compile(r'^sha256:[0-9a-f]{64}$') +# The contract generations in order: a feature gated on a generation is +# available to every later one (spec/LOOP_ENGINEERING.md §5). +GENERATION_ORDER = ('v6', 'v7', 'v8') + + +def generation_at_least(generation, floor): + """True when `generation` is `floor` or a later contract generation.""" + return (generation in GENERATION_ORDER + and GENERATION_ORDER.index(generation) >= GENERATION_ORDER.index(floor)) + + def contract_generation(doc): - """'v6' or 'v7' from the contract's schema URL, else None.""" + """'v6', 'v7' or 'v8' from the contract's schema URL, else None.""" if not isinstance(doc, dict): return None return CONTRACT_GENERATIONS.get(doc.get('schema')) @@ -105,6 +128,23 @@ def journal_url_for(contract): # v7 catalog: the v6 catalog plus `delegation` (V7_CONTRACT.md section 3). JOURNAL_EVENT_TYPES_V7 = JOURNAL_EVENT_TYPES + ('delegation',) +# v8 catalog: the v7 catalog plus `blocker` (LOOP_ENGINEERING.md section 3). +JOURNAL_EVENT_TYPES_V8 = JOURNAL_EVENT_TYPES_V7 + ('blocker',) +JOURNAL_CATALOG_BY_GENERATION = {'v6': JOURNAL_EVENT_TYPES, + 'v7': JOURNAL_EVENT_TYPES_V7, + 'v8': JOURNAL_EVENT_TYPES_V8} + +# v8 structured blockers (LOOP_ENGINEERING.md section 3). The class is the +# escalation class of AGENT_PROTOCOL.md section 7.5; `resolver` says who may +# resolve it (absent = human). `lead` is refused for the classes that by +# definition need a human: approval (C1), a consent or login screen (C2), +# damage (C5) and terms (C6). +BLOCKER_ACTIONS = ('raised', 'resolved') +BLOCKER_CLASSES = ('C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7') +BLOCKER_RESOLVERS = ('lead', 'human') +BLOCKER_HUMAN_ONLY_CLASSES = ('C1', 'C2', 'C5', 'C6') +BLOCKER_REASON_MAX = 1000 +BLOCKER_NEEDS_MAX = 500 # Types whose payload carries evidence and therefore a trust label. EVIDENCE_TYPES = ('gate_run', 'observation', 'resource_sample', @@ -206,6 +246,54 @@ def _closed(obj, known, path, errors): # ---------------------------------------------------------------- contract +# v8 autonomy block (spec/LOOP_ENGINEERING.md): the plan's recorded +# authority for the loop. Closed keys; every default is the conservative one. +AUTONOMY_KEYS = ('stall_budget', 'promptable', 'notify', 'brain', 'queue') +AUTONOMY_NOTIFY_TARGETS = ('dailybot',) +AUTONOMY_QUEUE_STARTS = ('prompt-lead', 'launch', 'none') +# herdr-peers' exact form (MACHINE_RE): a machine id is passed to Herdr +# as an argument and must never read as an option, so it cannot start with '-'. +PANE_ADDRESS = re.compile(r"^(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63}):[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}$") + + +def autonomy_errors(doc): + """Errors in the optional v8 `autonomy` block; empty means valid (or + absent — the block is optional and its defaults are conservative).""" + block = doc.get('autonomy') + if block is None: + return [] + if not isinstance(block, dict): + return ['autonomy: expected an object'] + errors = [] + _closed(block, set(AUTONOMY_KEYS), 'autonomy', errors) + budget = block.get('stall_budget') + if 'stall_budget' in block and (not isinstance(budget, int) or isinstance(budget, bool) + or not 1 <= budget <= 10): + errors.append('autonomy.stall_budget: an integer from 1 to 10 loop prompts') + promptable = block.get('promptable') + if 'promptable' in block: + if not isinstance(promptable, list) or not promptable: + errors.append('autonomy.promptable: a non-empty list of pane addresses') + else: + for addr in promptable: + if not isinstance(addr, str) or not PANE_ADDRESS.fullmatch(addr): + errors.append('autonomy.promptable: %r is not a pane address' % (addr,)) + notify = block.get('notify') + if 'notify' in block: + if not isinstance(notify, list) or not notify: + errors.append('autonomy.notify: a non-empty list of targets') + else: + for target in notify: + if target not in AUTONOMY_NOTIFY_TARGETS: + errors.append('autonomy.notify: unknown target %r' % (target,)) + if 'brain' in block and not isinstance(block['brain'], bool): + errors.append('autonomy.brain: a boolean (may a brain act on this plan)') + queue = block.get('queue') + if 'queue' in block and queue not in AUTONOMY_QUEUE_STARTS: + errors.append('autonomy.queue: one of %s' % ', '.join(AUTONOMY_QUEUE_STARTS)) + return errors + + def contract_errors(doc, parents=None): """All validation errors for one v6 contract document. @@ -216,12 +304,20 @@ def contract_errors(doc, parents=None): errors = [] if not isinstance(doc, dict): return ['contract: expected a JSON object'] - _closed(doc, {'schema', 'spec_version', 'plan', 'revision', - 'contract_id', 'parent_contract_id', 'created_at', 'title', - 'outcome', 'acceptance', 'invariants', 'scope', - 'authorization', 'permissions', 'dependencies', - 'resource_envelope', 'scheduling', 'tasks'}, 'contract', - errors) + generation = contract_generation(doc) + allowed = {'schema', 'spec_version', 'plan', 'revision', + 'contract_id', 'parent_contract_id', 'created_at', 'title', + 'outcome', 'acceptance', 'invariants', 'scope', + 'authorization', 'permissions', 'dependencies', + 'resource_envelope', 'scheduling', 'tasks'} + if generation == 'v8': + allowed.add('autonomy') + _closed(doc, allowed, 'contract', errors) + if 'autonomy' in doc and generation != 'v8': + errors.append('contract.autonomy: only the v8 generation carries the ' + 'autonomy block (generations never mix)') + if generation == 'v8': + errors.extend(autonomy_errors(doc)) declared = doc.get('schema') if declared not in CONTRACT_GENERATIONS: # Mixed-era refusal (section 9.1): v5 and older documents keep their @@ -302,7 +398,7 @@ def contract_errors(doc, parents=None): _envelope_errors(doc, errors) _scheduling_errors(doc, errors) _tasks_errors(doc, criteria, errors, - v7=CONTRACT_GENERATIONS[declared] == 'v7') + v7=generation_at_least(CONTRACT_GENERATIONS[declared], 'v7')) return errors @@ -923,8 +1019,7 @@ def journal_event_errors(event, contract=None): (expected or JOURNAL_SCHEMA_URL, event_url)) return errors etype = event.get('type') - catalog = JOURNAL_EVENT_TYPES_V7 if \ - JOURNAL_GENERATIONS[event_url] == 'v7' else JOURNAL_EVENT_TYPES + catalog = JOURNAL_CATALOG_BY_GENERATION[JOURNAL_GENERATIONS[event_url]] if etype not in catalog: errors.append('event.type: unknown event type %r (closed catalog: ' '%s)' % (etype, ', '.join(catalog))) @@ -1415,7 +1510,66 @@ def _v_delegation(event, errors): 'asserted until the parent runner observes it)') +def blocker_payload_errors(event, path='event'): + """Errors in one blocker raise/resolve payload (LOOP_ENGINEERING.md + section 3); shared by the journal validator and the ledger's writer so + a refusal names the same rule either way.""" + errors = [] + tid = event.get('task') + if not isinstance(tid, str) or not ID_TASK.match(tid): + errors.append('%s.task: expected a T-* id' % path) + action = event.get('action') + if action not in BLOCKER_ACTIONS: + errors.append('%s.action: expected raised/resolved' % path) + return errors + if action == 'resolved': + extra = sorted(k for k in ('reason', 'needs', 'class', 'resolver') + if k in event) + if extra: + errors.append('%s: a resolution carries only the task (and an ' + 'optional note), not %s' % (path, ', '.join(extra))) + return errors + reason = event.get('reason') + if not isinstance(reason, str) or not reason.strip() or \ + len(reason) > BLOCKER_REASON_MAX: + errors.append('%s.reason: expected a non-empty string (<= %d chars)' + % (path, BLOCKER_REASON_MAX)) + needs = event.get('needs') + if not isinstance(needs, str) or not needs.strip() or \ + len(needs) > BLOCKER_NEEDS_MAX or '\n' in needs or '\r' in needs: + errors.append('%s.needs: expected one non-empty line (<= %d chars) ' + 'saying what unblocks the task' % (path, BLOCKER_NEEDS_MAX)) + klass = event.get('class') + if klass not in BLOCKER_CLASSES: + errors.append('%s.class: expected one of %s (AGENT_PROTOCOL.md 7.5)' + % (path, '/'.join(BLOCKER_CLASSES))) + if 'resolver' in event: + resolver = event['resolver'] + if resolver not in BLOCKER_RESOLVERS: + errors.append('%s.resolver: expected lead/human (absent = human)' + % path) + elif resolver == 'lead' and klass in BLOCKER_HUMAN_ONLY_CLASSES: + errors.append('%s.resolver: lead is refused for %s - approval, ' + 'consent or login, damage and terms are the ' + "human's (LOOP_ENGINEERING.md section 3)" + % (path, klass)) + return errors + + +def _v_blocker(event, errors): + """LOOP_ENGINEERING.md section 3: one blocker raise or resolution. + + Not an evidence type (no trust label). Recorded only by the ledger's + block/unblock helper, never by a raw append. + """ + _closed(event, {'schema', 'type', 'seq', 'ts', 'plan', 'contract_id', + 'actor', 'note', 'task', 'action', 'reason', 'needs', + 'class', 'resolver'}, 'event', errors) + errors.extend(blocker_payload_errors(event)) + + _EVENT_VALIDATORS = { + 'blocker': _v_blocker, 'delegation': _v_delegation, 'task_start': _v_task_start, 'approval': _v_approval, @@ -1722,6 +1876,27 @@ def probe(label, mutate_contract=None, mutate_event=None): v6_marked['tasks'][0]['parallel_safe'] = True if not contract_errors(v6_marked): failures.append('parallel_safe under the v6 URL must fail') + # The parallel_safe overlap warning (R8): a dropped or inverted check + # must fail the self-test, not only the external bats suite. + def overlap_pair(surface_a, surface_b, chained=False): + return {'tasks': [ + {'id': 'T-a', 'parallel_safe': True, + 'touched_surface': [surface_a]}, + {'id': 'T-b', 'parallel_safe': True, + 'touched_surface': [surface_b], + 'prerequisites': ['T-a'] if chained else []}]} + for label, doc, expected in ( + ('same-path parallel_safe pair warns', + overlap_pair('src/product.py', 'src/product.py'), 1), + ('prerequisite-chained pair is silent', + overlap_pair('src/product.py', 'src/product.py', True), 0), + ('disjoint parallel_safe pair is silent', + overlap_pair('src/a.py', 'src/b.py'), 0)): + probes[0] += 1 + got = len(parallel_overlap_warnings(doc)) + if got != expected: + failures.append('%s: expected %d warning(s), got %d' + % (label, expected, got)) v7_stamped = dict(v7, contract_id=compute_contract_id(v7)) delegation = {'schema': JOURNAL_SCHEMA_URL_V7, 'type': 'delegation', 'seq': 1, 'ts': '2026-10-09T00:00:00Z', @@ -1747,6 +1922,53 @@ def probe(label, mutate_contract=None, mutate_event=None): mutate(ev) if not journal_event_errors(ev, against): failures.append('mutant %r should fail' % label) + # v8 generation (LOOP_ENGINEERING.md section 3): the blocker event is + # valid only under the v8 journal URL, and its rules hold. + v8 = json.loads(json.dumps(v7)) + v8['schema'] = CONTRACT_SCHEMA_URL_V8 + v8_stamped = dict(v8, contract_id=compute_contract_id(v8)) + raised = {'schema': JOURNAL_SCHEMA_URL_V8, 'type': 'blocker', 'seq': 2, + 'ts': '2026-11-16T00:00:00Z', 'plan': v8['plan'], + 'contract_id': v8_stamped['contract_id'], + 'actor': {'kind': 'agent', 'identity': 'selftest'}, + 'task': v8['tasks'][0]['id'], 'action': 'raised', + 'reason': 'the fixture repository is missing', + 'needs': 'clone the fixture repository', 'class': 'C3', + 'resolver': 'lead'} + resolved = dict({k: v for k, v in raised.items() + if k not in ('reason', 'needs', 'class', 'resolver')}, + action='resolved', seq=3) + for label, event in (('a v8 blocker raise', raised), + ('a v8 blocker resolution', resolved)): + probes[0] += 1 + if journal_event_errors(event, v8_stamped): + failures.append('%s should be valid: %s' + % (label, journal_event_errors(event, + v8_stamped)[:1])) + for label, mutate, against in ( + ('blocker under the v7 journal URL', + lambda e: e.update(schema=JOURNAL_SCHEMA_URL_V7), v7_stamped), + ('v8 event under a v7 contract', lambda e: None, v7_stamped), + ('lead resolver on a C1 blocker', + lambda e: e.update({'class': 'C1'}), v8_stamped), + ('lead resolver on a C2 blocker', + lambda e: e.update({'class': 'C2'}), v8_stamped), + ('lead resolver on a C5 blocker', + lambda e: e.update({'class': 'C5'}), v8_stamped), + ('lead resolver on a C6 blocker', + lambda e: e.update({'class': 'C6'}), v8_stamped), + ('blocker without a class', lambda e: e.pop('class'), v8_stamped), + ('multi-line needs', + lambda e: e.update(needs='one\ntwo'), v8_stamped), + ('unknown resolver', + lambda e: e.update(resolver='brain'), v8_stamped), + ('blocker claims trust', + lambda e: e.update(trust='asserted'), v8_stamped)): + probes[0] += 1 + ev = dict(raised) + mutate(ev) + if not journal_event_errors(ev, against): + failures.append('mutant %r should fail' % label) return (not failures, failures, probes[0]) diff --git a/.agents/skills/deepworkplan/shared/ledger.py b/.agents/skills/deepworkplan/shared/ledger.py index 4fdd8f5..57e3fba 100644 --- a/.agents/skills/deepworkplan/shared/ledger.py +++ b/.agents/skills/deepworkplan/shared/ledger.py @@ -63,8 +63,11 @@ import contract_v6 # noqa: E402 (sibling module, same directory) LEDGER_IDENTITY = 'dwp-ledger/6.0' -# F-24: a v7 plan's records name the v7 ledger (same code, v7 generation). -LEDGER_IDENTITY_BY_GENERATION = {'v6': LEDGER_IDENTITY, 'v7': 'dwp-ledger/7.0'} +# F-24: a plan's records name the ledger of its generation (same code). A +# v8 plan has its own journal and snapshot generations (journal-event/v8, +# plan-snapshot/v8; spec/LOOP_ENGINEERING.md section 3), so its records +# name the v8 ledger. +LEDGER_IDENTITY_BY_GENERATION = {'v6': LEDGER_IDENTITY, 'v7': 'dwp-ledger/7.0', 'v8': 'dwp-ledger/8.0'} def ledger_identity(contract): @@ -79,6 +82,13 @@ def ledger_identity(contract): # publishes under its own label, beside plan-contract/v6 and # journal-event/v6, and is described by spec/schema/plan-snapshot-v6.schema.json. STATE_SCHEMA_URL = 'https://deepworkplan.com/schema/plan-snapshot/v6.json' +# v8 plans project into plan-snapshot/v8: the v6 snapshot with `blocker` as +# the plan's active structured blocker (object or null) and `blocked` as a +# derived task status (spec/LOOP_ENGINEERING.md section 3). v6 and v7 plans +# keep plan-snapshot/v6 byte for byte. +STATE_SCHEMA_URL_V8 = 'https://deepworkplan.com/schema/plan-snapshot/v8.json' +SNAPSHOT_URL_BY_GENERATION = {'v6': STATE_SCHEMA_URL, 'v7': STATE_SCHEMA_URL, + 'v8': STATE_SCHEMA_URL_V8} # RFC 9.1 again, for the plan identity: the v6 manifest is its own new # generation (the v1/v2/v5 manifest shapes are frozen), and it carries the @@ -90,8 +100,13 @@ def ledger_identity(contract): # plans project into the unchanged v6 snapshot shape (positions are keyed # by event type, so the `delegation` type needs no new snapshot schema). MANIFEST_SCHEMA_URL_V7 = 'https://deepworkplan.com/schema/plan-manifest/v7.json' +# v8 plans keep the v7 manifest line (spec/LOOP_ENGINEERING.md section 5): +# the manifest's shape and its contract pointer are unchanged, so a new +# manifest URL would add a generation without a difference. The v8 +# generation changes the contract, the journal and the snapshot. MANIFEST_URL_BY_GENERATION = {'v6': MANIFEST_SCHEMA_URL, - 'v7': MANIFEST_SCHEMA_URL_V7} + 'v7': MANIFEST_SCHEMA_URL_V7, + 'v8': MANIFEST_SCHEMA_URL_V7} MANIFEST_SCHEMA_URLS = tuple(MANIFEST_URL_BY_GENERATION.values()) # Journal types that are render provenance, not plan state: they never @@ -132,6 +147,10 @@ class CompletionRefused(LedgerError): """Completion refused on missing in-window accepted evidence. Exit 4.""" +class BlockerRefused(LedgerError): + """A blocker raise/resolve the record layer refuses (recorded). Exit 5.""" + + # ---------------------------------------------------------------- plan load def _sibling_module(): @@ -566,7 +585,7 @@ def criterion_states(contract, events, task_id): if task is None: raise LedgerError('task %r is not in the contract' % task_id) start = task_start_seq_of(events, task_id) - accepted_by = {c['id']: c.get('accepted_evidence', []) + accepted_by = {c['id']: (c.get('accepted_evidence') or []) for c in contract['acceptance']['criteria']} invalid_before = invalidated_before(events) states = [] @@ -654,9 +673,43 @@ def invalidated_before(events): return found +def active_blocker(events): + """The plan's active structured blocker, or None (v8; a read-only fold). + + At most one blocker is active per plan (the writer refuses a second + task's raise). A re-raise on the same task updates reason, needs, class + and resolver but keeps `since` - the episode started at the first + raise. A resolution ends the episode. Deterministic: `since` is the + raising event's ts, never the wall clock. + """ + active = None + for event in events: + if event.get('type') != 'blocker': + continue + if event.get('action') == 'raised': + record = {'task': event.get('task'), + 'reason': event.get('reason'), + 'since': event.get('ts'), + 'needs': event.get('needs'), + 'class': event.get('class')} + if active is not None and active.get('task') == record['task']: + record['since'] = active['since'] + if 'resolver' in event: + record['resolver'] = event['resolver'] + active = record + elif event.get('action') == 'resolved' and active is not None and \ + active.get('task') == event.get('task'): + active = None + return active + + def task_complete(contract, events, task_id): """True when every gate_intent criterion has in-window accepted - evidence (the same zero-test predicate complete_task enforces).""" + evidence (the same zero-test predicate complete_task enforces) and no + unresolved blocker holds the task (LOOP_ENGINEERING.md section 3).""" + blocker = active_blocker(events) + if blocker is not None and blocker.get('task') == task_id: + return False return all(state.get('satisfied') for state in criterion_states(contract, events, task_id)) @@ -851,6 +904,12 @@ def _enforce_mint_rules(self, etype, actor, trust, evidence_path): 'gate_run records are produced only by the gate executor ' '(ledger.py gate) — a mediated write can never be ' 'observed evidence (A1)') + if etype == 'blocker': + raise LedgerError( + 'blocker records are produced only by `ledger.py block` and ' + '`ledger.py unblock` (one active blocker per plan; lead ' + 'refused for C1/C2/C5/C6) - a raw append cannot bypass them ' + '(LOOP_ENGINEERING.md section 3)') if etype == 'delegation': raise LedgerError( 'delegation records are produced only by `ledger.py ' @@ -1479,6 +1538,9 @@ def task_status(self, task_id): in_progress. A restart reopens the evidence window, so a restarted task derives in_progress again until fresh evidence lands.""" + blocker = active_blocker(self.events) + if blocker is not None and blocker.get('task') == task_id: + return 'blocked' # v8 only: blocker events exist from v8 if self.task_start_seq(task_id) is None: return 'pending' if task_complete(self.r.contract, self.events, task_id): @@ -1507,8 +1569,10 @@ def snapshot(self): seq = event.get('seq', 0) if etype and seq > positions.get(etype, {}).get('seq', 0): positions[etype] = {'seq': seq} + generation = contract_v6.contract_generation(self.r.contract) state = { - 'schema': STATE_SCHEMA_URL, + 'schema': SNAPSHOT_URL_BY_GENERATION.get(generation, + STATE_SCHEMA_URL), 'plan': self.r.contract['plan'], 'contract_id': self.r.contract_id, 'contract_revision': self.r.contract.get('revision', 1), @@ -1522,7 +1586,11 @@ def snapshot(self): 'positions': positions, 'resources': self._resource_totals(), 'checkpoint': self._last_authority_question(), - 'blocker': None, + # v8: the active structured blocker (LOOP_ENGINEERING.md + # section 3); v6/v7 projections keep the reserved null. + 'blocker': (active_blocker(self.events) + if contract_v6.generation_at_least(generation, 'v8') + else None), } archives = self.r.archives() if archives: @@ -1775,6 +1843,22 @@ def complete_task(self, task_id, actor=None): """Refuse completion unless every gate_intent criterion has in-window accepted evidence (zero-test control).""" self._check_position() + blocker = active_blocker(self.events) + if blocker is not None and blocker.get('task') == task_id: + self._append_raw('refusal', + {'subject': task_id, 'stage': 'gate', + 'reason': 'unresolved blocker (%s): %s - ' + 'resolve it with `ledger.py ' + 'unblock` first' % + (blocker.get('class'), + blocker.get('needs'))}, + actor={'kind': 'helper', + 'identity': LEDGER_IDENTITY}, + ts=_utc_now()) + raise CompletionRefused( + 'completion of %s refused: an unresolved blocker holds it ' + '(%s, needs: %s) - resolve it with `ledger.py unblock` first' + % (task_id, blocker.get('class'), blocker.get('needs'))) open_delegations = sorted( did for did, ev in self.delegations(task_id).items() if ev.get('state') == 'launched') @@ -1867,6 +1951,67 @@ def _warn_undecided_controls(self, task_id, states): 'contract at completion of %s ' '(non-blocking)' % task_id) + # -- structured blockers (v8, spec/LOOP_ENGINEERING.md section 3) ------- + + def _refuse_blocker(self, subject, reason): + self._append_raw('refusal', {'subject': subject, 'stage': 'authorize', + 'reason': reason}, + actor={'kind': 'helper', + 'identity': LEDGER_IDENTITY}, + ts=_utc_now()) + raise BlockerRefused('blocker refused: %s' % reason) + + def blocker(self, op, task_id, payload=None, actor=None, note=None): + """Raise or resolve the plan's structured blocker (writes). + + raise: a v8 plan, a task of this contract that is not complete, no + other task's blocker active, and a payload of exactly reason, needs + (one line), class (C1..C7) and an optional resolver (lead|human; + absent = human; lead refused for C1/C2/C5/C6). resolve: the active + blocker of that task. Every refusal is recorded. The only writer of + `blocker` events: a raw append is refused. + """ + self._check_position() + actor = actor or {'kind': 'agent', 'identity': 'caller'} + subject = '%s %s' % ('block' if op == 'raise' else 'unblock', task_id) + generation = contract_v6.contract_generation(self.r.contract) + if not contract_v6.generation_at_least(generation, 'v8'): + self._refuse_blocker(subject, 'this plan is %s - structured ' + 'blockers are recorded from v8 (older plans ' + 'keep their lifecycle)' % generation) + if not any(t.get('id') == task_id + for t in self.r.contract.get('tasks', [])): + self._refuse_blocker(subject, 'unknown task') + active = active_blocker(self.events) + if op == 'resolve': + if active is None or active.get('task') != task_id: + self._refuse_blocker(subject, 'no unresolved blocker holds ' + 'this task') + return self._append_raw('blocker', {'task': task_id, + 'action': 'resolved'}, + actor, _utc_now(), note=note) + if op != 'raise': + raise LedgerError('blocker op must be raise or resolve') + if not isinstance(payload, dict): + raise LedgerError('block --json must be a JSON object') + unknown = sorted(set(payload) - {'reason', 'needs', 'class', + 'resolver'}) + if unknown: + self._refuse_blocker(subject, 'unknown blocker field(s): %s ' + '(reason, needs, class, resolver)' + % ', '.join(unknown)) + if active is not None and active.get('task') != task_id: + self._refuse_blocker(subject, 'the plan is already blocked on %s ' + '- resolve that blocker first (one active ' + 'blocker per plan)' % active.get('task')) + if self.task_status(task_id) == 'completed': + self._refuse_blocker(subject, 'the task is already complete') + body = dict(payload, task=task_id, action='raised') + problems = contract_v6.blocker_payload_errors(body, 'blocker') + if problems: + self._refuse_blocker(subject, problems[0]) + return self._append_raw('blocker', body, actor, _utc_now(), note=note) + # -- delegation (v7, spec/V7_CONTRACT.md section 3) ---------------------- def delegations(self, task_id=None): @@ -1917,10 +2062,10 @@ def delegate(self, op, task_id, payload, actor=None, host_caps=None, if not isinstance(payload, dict): raise LedgerError('delegate --json must be a JSON object') if op == 'launch': - if contract_v6.contract_generation(contract) != 'v7': + if not contract_v6.generation_at_least(contract_v6.contract_generation(contract), 'v7'): self._refuse_delegation(task_id, 'this plan is %s - only v7 ' - 'plans record delegation (v6 plans ' - 'keep their lifecycle)' % + 'and later plans record delegation ' + '(v6 plans keep their lifecycle)' % contract_v6.contract_generation( contract)) granted = contract.get('permissions', {}).get('granted', []) @@ -2765,7 +2910,10 @@ def main(argv): '--human-note FILE ' '| delegate ' 'launch|observe|collect|cancel --task T [--json OBJ] ' - '[--caps JSON]} [options]') + '[--caps JSON] ' + '| block --task T --json \'{"reason":..,"needs":..,' + '"class":"C1".."C7"[,"resolver":"lead"|"human"]}\' ' + '| unblock --task T [--note TEXT]} [options]') if any(arg in ('-h', '--help') for arg in argv): print(usage) return 0 @@ -2876,6 +3024,36 @@ def main(argv): return 5 finally: lock.release() + if args.command in ('block', 'unblock'): + if not args.task: + print('%s requires --task' % args.command) + return 2 + if args.command == 'block' and not args.json: + print('block requires --json with reason, needs and class') + return 2 + rec, lock, writer = _writer_for(args, args.force) + try: + event = writer.blocker( + 'raise' if args.command == 'block' else 'resolve', + args.task, + json.loads(args.json) if args.json else None, + actor={'kind': args.actor_kind, + 'identity': args.actor_identity}, + note=args.note) + writer.project() + if args.command == 'block': + print('OK: %s blocked at seq %d (%s, resolver %s)' % + (args.task, event['seq'], event['class'], + event.get('resolver', 'human'))) + else: + print('OK: %s unblocked at seq %d' % (args.task, + event['seq'])) + return 0 + except BlockerRefused as exc: + print('REFUSED: %s' % exc) + return 5 + finally: + lock.release() if args.command == 'append': if not args.type or not args.json: print('append requires --type and --json') diff --git a/.agents/skills/deepworkplan/shared/progress_header.py b/.agents/skills/deepworkplan/shared/progress_header.py new file mode 100644 index 0000000..cc9c4e2 --- /dev/null +++ b/.agents/skills/deepworkplan/shared/progress_header.py @@ -0,0 +1,189 @@ +#!/usr/bin/env python3 +"""Write or refresh the structured header of a v8 plan's PROGRESS.md. + +The header is four fixed lines directly under the file's title, so a +reader (resume, the herdr-peers fleet, a daemon) finds the plan's state +without scraping prose (spec/LOOP_ENGINEERING.md section 3.2): + + Goal: + Current task: - (<status>) | none - plan complete + Next action: <one line> + Needs: none | <class> (<resolver>): <needs> + +`Current task` and `Needs` are derived from the plan's records (the +ledger's read-only snapshot: the blocked task first, else the first task +not completed in contract order; the active blocker's class, resolver and +needs). `Goal` and `Next action` are the caller's words: passed with +--goal / --next, otherwise kept from the existing header. Everything below +the header is the agents' own working index and is never touched. + +Stdlib only (Python 3.9+). Writes exactly one file, PROGRESS.md, atomically. + +Usage: + progress_header.py --plan PLAN_DIR [--goal TEXT] [--next TEXT] [--check] + +--check prints the header the records imply and exits 1 when the file's +header differs (writes nothing). + +Exit codes: 0 written/current · 1 refused or out of date · 2 usage. +""" +import argparse +import os +import re +import sys +import tempfile + +sys.dont_write_bytecode = True # never leave caches inside an installed pack + +import contract_v6 # noqa: E402 (sibling modules, same directory) +import ledger # noqa: E402 + +KEYS = ('Goal', 'Current task', 'Next action', 'Needs') +LINE_MAX = 300 # the caller's lines (Goal, Next action): refused beyond +TITLE_MAX = 200 # a task title is shortened to this; id and status never +_KEY_LINE = re.compile(r'^(%s): ?(.*)$' % '|'.join(re.escape(k) for k in KEYS)) + + +def _one_line(text, label): + text = ' '.join(str(text or '').split()) + if not text: + raise ValueError('%s must be a non-empty line' % label) + if len(text) > LINE_MAX: + raise ValueError('%s exceeds %d characters' % (label, LINE_MAX)) + return text + + +def derived(snapshot): + """(current task, needs) lines from a v8 snapshot.""" + tasks = snapshot.get('tasks') or [] + blocker = snapshot.get('blocker') + current = None + if isinstance(blocker, dict): + current = next((t for t in tasks if t.get('id') == blocker.get('task')), + None) + if current is None: + current = next((t for t in tasks if t.get('status') != 'completed'), + None) + if current is None: + task_line = 'none - plan complete' + else: + # Only the title may be shortened: the id and the status are what a + # reader acts on, so they are never cut. + title = ' '.join(str(current.get('title') or '').split()) + if len(title) > TITLE_MAX: + title = title[:TITLE_MAX - 3].rstrip() + '...' + task_line = '%s%s (%s)' % (current.get('id'), + ' - %s' % title if title else '', + current.get('status')) + if isinstance(blocker, dict): + # Never truncated: the ledger bounds needs to one line of at most + # 500 characters (LOOP_ENGINEERING.md section 3.1), and the unblock + # instruction is the line's whole purpose. + needs_line = '%s (%s): %s' % (blocker.get('class'), + blocker.get('resolver') or 'human', + ' '.join(str(blocker.get('needs') + or '').split())) + else: + needs_line = 'none' + return task_line, needs_line + + +def split_header(text): + """(before, header dict, after) - the title stays in `before`.""" + lines = text.splitlines() + start = 0 + if lines and lines[0].startswith('# '): + start = 1 + while start < len(lines) and not lines[start].strip(): + start += 1 + found = {} + end = start + while end < len(lines): + match = _KEY_LINE.match(lines[end]) + if not match or match.group(1) in found: + break + found[match.group(1)] = match.group(2).strip() + end += 1 + if not found: + end = start + title = lines[:1] if lines and lines[0].startswith('# ') else [] + return title, found, lines[end:] if found else lines[len(title):] + + +def render(title, values, rest): + body = ['%s: %s' % (key, values[key]) for key in KEYS] + while rest and not rest[0].strip(): + rest = rest[1:] + out = list(title) + ([''] if title else []) + body + \ + ([''] + rest if rest else []) + return '\n'.join(out) + '\n' + + +def main(argv): + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument('--plan', required=True) + parser.add_argument('--goal') + parser.add_argument('--next', dest='next_action') + parser.add_argument('--check', action='store_true') + args = parser.parse_args(argv) + try: + plan_dir = ledger.find_plan_dir(args.plan) + records = ledger.PlanRecords(plan_dir) + generation = contract_v6.contract_generation(records.contract) + if not contract_v6.generation_at_least(generation, 'v8'): + print('progress_header: this plan is %s - the structured header ' + 'is written from v8 (older plans keep their PROGRESS.md)' + % generation, file=sys.stderr) + return 1 + snapshot = ledger.read_only_snapshot(records) + except (ledger.LedgerError, OSError, ValueError) as exc: + print('progress_header: %s' % exc, file=sys.stderr) + return 1 + path = os.path.join(plan_dir, 'PROGRESS.md') + try: + with open(path, encoding='utf-8') as fh: + text = fh.read() + except FileNotFoundError: + text = '# %s - progress\n' % records.contract['plan'] + title, found, rest = split_header(text) + task_line, needs_line = derived(snapshot) + try: + values = { + 'Goal': _one_line(args.goal if args.goal is not None + else found.get('Goal'), 'Goal (--goal)'), + 'Current task': task_line, + 'Next action': _one_line(args.next_action + if args.next_action is not None + else found.get('Next action'), + 'Next action (--next)'), + 'Needs': needs_line, + } + except ValueError as exc: + print('progress_header: %s' % exc, file=sys.stderr) + return 1 + rendered = render(title, values, rest) + if args.check: + print('\n'.join('%s: %s' % (k, values[k]) for k in KEYS)) + return 0 if rendered == text else 1 + if rendered == text: + print('OK: PROGRESS.md header current') + return 0 + fd, tmp = tempfile.mkstemp(dir=plan_dir, prefix='.PROGRESS.md.', + suffix='.tmp') + try: + with os.fdopen(fd, 'w', encoding='utf-8') as fh: + fh.write(rendered) + fh.flush() + os.fsync(fh.fileno()) + os.replace(tmp, path) + except BaseException: + if os.path.exists(tmp): + os.unlink(tmp) + raise + print('OK: PROGRESS.md header written (%s; needs %s)' + % (task_line, needs_line)) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/.agents/skills/deepworkplan/shared/queue.py b/.agents/skills/deepworkplan/shared/queue.py new file mode 100644 index 0000000..c335715 --- /dev/null +++ b/.agents/skills/deepworkplan/shared/queue.py @@ -0,0 +1,294 @@ +#!/usr/bin/env python3 +"""The plan queue (``dwp-queue-v1``) — ``.dwp/queue.json``, written only by +the pack. + +Contract (PLAN_024 item 3.5, agreed with the herdr-peers side 2026-11-15): + +- Schema ``dwp-queue-v1``; the document is closed (no unknown keys) so every + consumer — the herdr-peers daemon, the fleet UI, the vim plan browser — + reads one stable shape, the way it reads the manifest today. +- Items: ``{plan, after (plan id | null), state: queued|started|done|skipped, + lead (a pane address | null), start: prompt-lead|launch}``; the queue may + carry ``parallel: true`` (default: one plan at a time per repository). +- Writers, and only these: `create` appends on approval (with the lead the + daemon prompts, ``--lead``); the developer or the lead names or renames a + queued plan's lead (``set-lead``) and reorders (the file is theirs to edit); `execute` flips ``started`` on a + task start while the item is still queued (with the lead address) and ``done`` after the plan's + closure; `create`/`refine` flip ``skipped`` with a one-line note. The + daemon is a bounded, read-only consumer and never writes. +- The write is atomic (temp file + rename) with mode 0600, the lead records' + discipline. A read of anything that is not a valid, bounded document is a + quiet None — a damaged queue must never break the plan lifecycle. + +Usage (the flows call it the way they call the other state helpers):: + + python3 shared/queue.py --dwp <dir> show + python3 shared/queue.py --dwp <dir> append --plan PLAN_x [--after PLAN_y] [--start prompt-lead] [--lead local:w1:p2] + python3 shared/queue.py --dwp <dir> set-lead --plan PLAN_x --lead local:w1:p2 + python3 shared/queue.py --dwp <dir> set-state --plan PLAN_x --state started --lead local:w1:p2 + python3 shared/queue.py --dwp <dir> set-state --plan PLAN_x --state done + python3 shared/queue.py --dwp <dir> set-state --plan PLAN_x --state skipped --note "reason" +""" + +import argparse +import json +import os +import re +import stat +import sys +import tempfile +import time + +SCHEMA = "dwp-queue-v1" +STATES = ("queued", "started", "done", "skipped") +STARTS = ("prompt-lead", "launch") +MAX_BYTES = 64 * 1024 +# The consumer's own caps (herdr-peers fleet_report): a queue above 64 items, +# or 64 KiB, is refused wholesale by the daemon — the writer enforces the +# same ceilings so a producer-valid document is always consumer-valid. +MAX_ITEMS = 64 +# herdr-peers' exact form, the same as contract_v6.PANE_ADDRESS (a test pins them +# equal): a machine id is passed to Herdr as an argument, so it cannot start with '-'. +PANE_ADDRESS = re.compile(r"^(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63}):[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}$") +PANE_ID = re.compile(r"^[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}$") +PLAN_ID = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$") +NOTE_MAX = 200 + + +def norm_lead(value): + """A lead as written by a caller: a full pane address stays as it is; a + bare Herdr pane id (`w9:p1`, what $HERDR_PANE_ID may hold) becomes + `local:w9:p1`; surrounding blanks are dropped. The result is still checked + against PANE_ADDRESS by the caller.""" + if not isinstance(value, str): + return value + value = value.strip() + return "local:" + value if PANE_ID.fullmatch(value) else value + + +def _iso_now(): + return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()) + + +def queue_path(dwp_dir): + return os.path.join(dwp_dir, "queue.json") + + +def valid_doc(doc): + """True when doc is a closed, well-formed dwp-queue-v1 document.""" + if not isinstance(doc, dict): + return False + allowed = {"schema", "updated_at", "items", "parallel"} + if set(doc) - allowed or doc.get("schema") != SCHEMA: + return False + if not isinstance(doc.get("items"), list) or len(doc["items"]) > MAX_ITEMS: + return False + if "parallel" in doc and not isinstance(doc["parallel"], bool): + return False + for item in doc["items"]: + if not isinstance(item, dict): + return False + keys = set(item) + base = {"plan", "after", "state", "lead", "start"} + note = {"note"} + if not keys <= base | note or not keys >= base: + return False + if not isinstance(item["plan"], str) or not PLAN_ID.fullmatch(item["plan"]): + return False + after = item["after"] + if after is not None and (not isinstance(after, str) or not PLAN_ID.fullmatch(after)): + return False + if item["state"] not in STATES or item["start"] not in STARTS: + return False + lead = item["lead"] + if lead is not None and (not isinstance(lead, str) or not PANE_ADDRESS.fullmatch(lead)): + return False + if item["state"] == "started" and lead is None: + return False + if "note" in item and (not isinstance(item["note"], str) + or not item["note"].strip() or len(item["note"]) > NOTE_MAX): + return False + plans = [i["plan"] for i in doc["items"]] + return len(plans) == len(set(plans)) + + +def _safe_dwp(dwp_dir): + """Refuse a symlinked .dwp: the write must land inside the repository's + own .dwp, never in whatever a link points at (fleet_report's consumer + reads the repository's queue; a redirected write is data loss).""" + if os.path.islink(dwp_dir): + raise SystemExit("queue.py: %s is a symlink; the queue lives in the " + "repository's own .dwp" % dwp_dir) + + +def read(dwp_dir): + """The validated document, or None (a damaged queue never breaks the + lifecycle; the caller may warn once).""" + path = queue_path(dwp_dir) + try: + # O_NOFOLLOW + fstat on the descriptor itself: a queue.json that is + # a symlink is refused (it would read another file), and the stat + # never races through the path. + fd = os.open(path, os.O_RDONLY | getattr(os, "O_NOFOLLOW", 0)) + try: + info = os.fstat(fd) + if not stat.S_ISREG(info.st_mode): + return None + raw = os.read(fd, MAX_BYTES + 1) + finally: + os.close(fd) + if len(raw) > MAX_BYTES: + return None + doc = json.loads(raw.decode("utf-8")) + except (OSError, ValueError): + return None + return doc if valid_doc(doc) else None + + +def _write(dwp_dir, doc): + doc["updated_at"] = _iso_now() + doc.setdefault("schema", SCHEMA) + if not valid_doc(doc): + raise SystemExit("queue.py: refusing to write a document that would " + "not validate (dwp-queue-v1 is closed)") + path = queue_path(dwp_dir) + fd, tmp = tempfile.mkstemp(dir=dwp_dir, prefix=".queue.", suffix=".tmp") + try: + with os.fdopen(fd, "w") as fh: + json.dump(doc, fh, indent=2, sort_keys=True) + fh.write("\n") + os.chmod(tmp, 0o600) + os.replace(tmp, path) + finally: + if os.path.exists(tmp): + os.unlink(tmp) + + +def _load_or_new(dwp_dir): + doc = read(dwp_dir) + if doc is None: + if os.path.exists(queue_path(dwp_dir)): + raise SystemExit("queue.py: %s is not a valid dwp-queue-v1 document; " + "not touching it" % queue_path(dwp_dir)) + return {"schema": SCHEMA, "updated_at": _iso_now(), "items": []} + return doc + + +def append(dwp_dir, plan, after=None, start="prompt-lead", lead=None): + _safe_dwp(dwp_dir) + lead = norm_lead(lead) + if lead is not None and (not isinstance(lead, str) or not PANE_ADDRESS.fullmatch(lead)): + raise SystemExit("queue.py: --lead is not a pane address " + "(local|<machine>):<workspace>:<pane>") + doc = _load_or_new(dwp_dir) + for item in doc["items"]: + if item["plan"] == plan: + raise SystemExit("queue.py: %s is already in the queue (%s); plan " + "ids are one-shot — re-queuing is an error, use a " + "new plan" % (plan, item["state"])) + if after is not None: + if after == plan: + raise SystemExit("queue.py: --after must not name the plan itself") + if not any(i["plan"] == after for i in doc["items"]): + raise SystemExit("queue.py: --after names %s, which is not in the " + "queue; dependencies are queue-internal" % after) + if len(doc["items"]) >= MAX_ITEMS: + raise SystemExit("queue.py: the queue holds at most %d items (the " + "consumer refuses more)" % MAX_ITEMS) + doc["items"].append({"plan": plan, "after": after, "state": "queued", + "lead": lead, "start": start}) + _write(dwp_dir, doc) + return doc + + +def set_lead(dwp_dir, plan, lead): + """Name (or rename) the lead the daemon prompts to start a queued plan.""" + _safe_dwp(dwp_dir) + lead = norm_lead(lead) + if not isinstance(lead, str) or not PANE_ADDRESS.fullmatch(lead): + raise SystemExit("queue.py: --lead is not a pane address " + "(local|<machine>):<workspace>:<pane>") + doc = _load_or_new(dwp_dir) + item = next((i for i in doc["items"] if i["plan"] == plan), None) + if item is None: + raise SystemExit("queue.py: %s is not in the queue" % plan) + if item["state"] != "queued": + raise SystemExit("queue.py: only a queued plan's lead can be named (got %s)" % item["state"]) + item["lead"] = lead + _write(dwp_dir, doc) + return doc + + +def set_state(dwp_dir, plan, state, lead=None, note=None): + _safe_dwp(dwp_dir) + lead = norm_lead(lead) + doc = _load_or_new(dwp_dir) + if state == "started" and lead is None: + raise SystemExit("queue.py: started needs --lead (the lead that claimed the plan)") + if lead is not None: + if state != "started": + raise SystemExit("queue.py: --lead belongs to the started state") + if not isinstance(lead, str) or not PANE_ADDRESS.fullmatch(lead): + raise SystemExit("queue.py: --lead is not a pane address " + "(local|<machine>):<workspace>:<pane>") + item = next((i for i in doc["items"] if i["plan"] == plan), None) + if item is None: + raise SystemExit("queue.py: %s is not in the queue" % plan) + if item["state"] == "done": + raise SystemExit("queue.py: %s is already done; the queue is append-only history" % plan) + if state == "started" and item["state"] != "queued": + raise SystemExit("queue.py: only a queued plan starts (got %s)" % item["state"]) + if state == "skipped": + if not note or not note.strip(): + raise SystemExit("queue.py: skipping needs a one-line note") + item["note"] = note.strip()[:NOTE_MAX] + item["state"] = state + if state == "started": + item["lead"] = lead + _write(dwp_dir, doc) + return doc + + +def main(argv=None): + ap = argparse.ArgumentParser(prog="queue.py", description=__doc__.splitlines()[0]) + ap.add_argument("--dwp", required=True, help="the .dwp directory") + sub = ap.add_subparsers(dest="cmd", required=True) + sub.add_parser("show", help="print the queue document (exit 1 when unusable)") + p = sub.add_parser("append", help="append a queued plan (create, on approval)") + p.add_argument("--plan", required=True) + p.add_argument("--after", default=None, help="a plan id this one waits for") + p.add_argument("--start", default="prompt-lead", choices=STARTS) + p.add_argument("--lead", default=None, + help="the pane address the daemon prompts to start it (without one it waits for a human to name one)") + p = sub.add_parser("set-lead", help="name the lead the daemon prompts to start a queued plan") + p.add_argument("--plan", required=True) + p.add_argument("--lead", required=True) + p = sub.add_parser("set-state", help="flip a state (execute, create/refine)") + p.add_argument("--plan", required=True) + p.add_argument("--state", required=True, choices=STATES) + p.add_argument("--lead", default=None, help="the lead pane address (with started)") + p.add_argument("--note", default=None, help="the one-line reason (with skipped)") + args = ap.parse_args(argv) + if args.cmd == "show": + doc = read(args.dwp) + if doc is None: + print("queue.py: no usable queue at %s" % queue_path(args.dwp), file=sys.stderr) + return 1 + print(json.dumps(doc, indent=2, sort_keys=True)) + return 0 + if args.cmd == "set-lead": + if not PLAN_ID.fullmatch(args.plan): + raise SystemExit("queue.py: --plan is not a plan id") + set_lead(args.dwp, args.plan, args.lead) + return 0 + if args.cmd == "append": + if not PLAN_ID.fullmatch(args.plan): + raise SystemExit("queue.py: --plan is not a plan id") + append(args.dwp, args.plan, args.after, args.start, args.lead) + return 0 + set_state(args.dwp, args.plan, args.state, args.lead, args.note) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.agents/skills/deepworkplan/shared/scheduler.py b/.agents/skills/deepworkplan/shared/scheduler.py index 64b55ba..d36a51e 100644 --- a/.agents/skills/deepworkplan/shared/scheduler.py +++ b/.agents/skills/deepworkplan/shared/scheduler.py @@ -569,17 +569,24 @@ def ready(contract, events): [e.get('seq', 0) for e in events if isinstance(e, dict) and e.get('type') == 'approval'] or [0]) candidates = [] + # v8 structured blockers (LOOP_ENGINEERING.md section 3): the held task + # waits for its resolution, and a prerequisite is met only when + # task_complete says so - the same predicate start_task and authorize + # use, so evidence that landed under an open blocker never makes a + # successor look eligible. + hold = ledger.active_blocker(events) + held = hold.get('task') if hold else None for order, task in enumerate(contract.get('tasks', [])): task_id = task.get('id') - if ledger.task_complete(contract, events, task_id): + if task_id == held or ledger.task_complete(contract, events, task_id): continue blocked = False since = approval_seq or 1 for prereq in task.get('prerequisites', []): - states = ledger.criterion_states(contract, events, prereq) - if not all(state.get('satisfied') for state in states): + if not ledger.task_complete(contract, events, prereq): blocked = True break + states = ledger.criterion_states(contract, events, prereq) for state in states: since = max(since, state.get('via_seq') or 0) if blocked: diff --git a/.agents/skills/deepworkplan/spec/ADDONS.md b/.agents/skills/deepworkplan/spec/ADDONS.md index 6ac55f2..da275b9 100644 --- a/.agents/skills/deepworkplan/spec/ADDONS.md +++ b/.agents/skills/deepworkplan/spec/ADDONS.md @@ -1,8 +1,8 @@ # ADDONS.md — Opt-In Addon Mechanism > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract @@ -133,19 +133,19 @@ form**; only its CI surface is optional. - An optional addon at `skills/deepworkplan/addons/devcontainer/` that gives a repository a reproducible dev container through **devcontainer-kit** (`dck`; `https://github.com/DailybotHQ/devcontainer-kit`, MIT, its own - release cycle) pinned at `v1.1.2` (interface `2`). The kit owns the + release cycle) pinned at `v1.3.0` (interface `2`). The kit owns the Dockerfile template and its render (`dck init`, which reconciles and never clobbers), the pinned images and tools, the entrypoint, the launcher, SSH agent forwarding, Herdr registration and the `dck-dockerfile` skill; the addon owns detection, the offer, the stack → options reasoning, the registry record and validation. - **Per-repository layout, no shared base image (devcontainer-kit - `v1.1.2`):** the render produces `.devcontainer/devcontainer.json`, + `v1.3.0`):** the render produces `.devcontainer/devcontainer.json`, `docker/local/<service>/Dockerfile` (plus its entrypoint), `docker/local/docker-compose.yaml` and `dev.sh`. The Dockerfile starts from the official runtime image pinned by digest; the kit's GHCR base image is not required. The addon offers the skill through - `npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.1.2 --skill dck-dockerfile -y` + `npx --yes skills add https://github.com/DailybotHQ/devcontainer-kit/tree/v1.3.0 --skill dck-dockerfile -y` (repo-local), and the pack keeps no copy of the template. - **Vendor-neutral (7.0.0):** the 1.x in-pack templates and their company-specific requirements are retired; no network, volume, CLI or @@ -348,14 +348,14 @@ form**; only its CI surface is optional. ### 6.6 Herdr (sixth addon — interactive delegation transport, thin integrator) An optional addon integrating **herdr-peers** (`DailybotHQ/herdr-peers`, -MIT, its own release cycle) pinned at `v2.0.0` (protocol/interface `1` or `2`), as +MIT, its own release cycle) pinned at `v2.1.0` (protocol/interface `1` or `2`), as the **interactive** transport of v7 delegation ([`V7_CONTRACT.md`](V7_CONTRACT.md)): one `herdr-peers ask` to a peer agent in a [Herdr](https://herdr.dev) pane on any reachable machine, recorded in the plan journal before the reply is relied on, the reply asserted until the plan's own gates observe the work. `onboard` Phase 7b offers it as an **explicit opt-in**; installs are the pinned skills -(`herdr-peers@v2.0.0`, Herdr's official `herdr@v0.9.3`). +(`herdr-peers@v2.1.0`, Herdr's official `herdr@v0.9.3`). Placement decision (revised for 7.0.0): the peer protocol — stamp, grant, reply, loop guard, depth limit 1, fan-out cap, scope — moved out of the @@ -449,13 +449,13 @@ The shipped set: | key | product (pinned) | provides_abilities | requires_grants | transport | |---|---|---|---|---| -| `agentkit` | `DailybotHQ/coding-agents-kit` `v1.4.0`, interface 1 | `subagents`, `cancel_children`, `model_routing` | `agent_delegation` | `headless` | +| `agentkit` | `DailybotHQ/coding-agents-kit` `v1.5.0`, interface 1 | `subagents`, `cancel_children`, `model_routing` | `agent_delegation` | `headless` | | `ai-diff-reviewer` | `DailybotHQ/ai-diff-reviewer` `v3.3.16` | — | — | — | | `dailybot` | `DailybotHQ/agent-skill` `v3.23.20` | `telemetry` (reporting only, consent-gated) | — | — | | `dependency-upgrade` | in-pack only | — | — | — | | `design-system` | in-pack only | — | — | — | -| `devcontainer` | `DailybotHQ/devcontainer-kit` `v1.1.2`, interface 2 | — | — | — | -| `herdr` | `DailybotHQ/herdr-peers` `v2.0.0`, interface 1 or 2 | `subagents`, `cancel_children` | `agent_delegation` | `interactive` | +| `devcontainer` | `DailybotHQ/devcontainer-kit` `v1.3.0`, interface 2 | — | — | — | +| `herdr` | `DailybotHQ/herdr-peers` `v2.1.0`, interface 1 or 2 | `subagents`, `cancel_children` | `agent_delegation` | `interactive` | | `vim` | `DailybotHQ/deepworkplan-vim` `v1.0.1`, interface 1 | — | — | — | A descriptor is **data**: the pack executes nothing it names except its diff --git a/.agents/skills/deepworkplan/spec/AGENT_PROTOCOL.md b/.agents/skills/deepworkplan/spec/AGENT_PROTOCOL.md index 369698b..2acf9e8 100644 --- a/.agents/skills/deepworkplan/spec/AGENT_PROTOCOL.md +++ b/.agents/skills/deepworkplan/spec/AGENT_PROTOCOL.md @@ -1,8 +1,8 @@ # AGENT_PROTOCOL.md — Cross-Agent Behavior Specification > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract diff --git a/.agents/skills/deepworkplan/spec/ARCHETYPES.md b/.agents/skills/deepworkplan/spec/ARCHETYPES.md index f63c0e0..b6c9aec 100644 --- a/.agents/skills/deepworkplan/spec/ARCHETYPES.md +++ b/.agents/skills/deepworkplan/spec/ARCHETYPES.md @@ -1,8 +1,8 @@ # ARCHETYPES.md — Repository Archetypes > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract diff --git a/.agents/skills/deepworkplan/spec/CONFIG.md b/.agents/skills/deepworkplan/spec/CONFIG.md index 540fa9c..fa89488 100644 --- a/.agents/skills/deepworkplan/spec/CONFIG.md +++ b/.agents/skills/deepworkplan/spec/CONFIG.md @@ -34,10 +34,10 @@ Both files share one shape: "benchmark": { "enabled": true, "learnings": true }, "addons": { "ai-diff-reviewer": { "enabled": true, "version": "v3.3.16" }, - "herdr": { "enabled": true, "version": "v2.0.0" }, + "herdr": { "enabled": true, "version": "v2.1.0" }, "agentkit": { "enabled": false }, - "devcontainer": { "enabled": true, "version": "v1.0.1" }, - "vim": { "enabled": true, "version": "v1.0.0" }, + "devcontainer": { "enabled": true, "version": "v1.3.0" }, + "vim": { "enabled": true, "version": "v1.0.1" }, "dailybot": { "enabled": true, "version": "v3.23.20" } } } diff --git a/.agents/skills/deepworkplan/spec/DOCUMENTATION_STANDARD.md b/.agents/skills/deepworkplan/spec/DOCUMENTATION_STANDARD.md index 4ab2d6c..6f89dad 100644 --- a/.agents/skills/deepworkplan/spec/DOCUMENTATION_STANDARD.md +++ b/.agents/skills/deepworkplan/spec/DOCUMENTATION_STANDARD.md @@ -1,8 +1,8 @@ # DOCUMENTATION_STANDARD.md — DeepWorkPlan Repository Documentation Standard > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract @@ -390,17 +390,19 @@ the onboarding flow **MUST** keep them distinct: report, per file, what it added or changed. - **Recorded provenance.** A repository that adopts this standard **SHOULD** record it — a line such as - `DWP standard: 7.0.0 (onboarded YYYY-MM-DD; upgraded YYYY-MM-DD; skill x.y.z)` + `DWP standard: 8.0.0 (onboarded YYYY-MM-DD; upgraded YYYY-MM-DD; skill x.y.z)` in `AGENTS.md` or `docs/README.md` — so a checker and a future agent can tell which standard the repository declares. The version in that line is the **umbrella DWP standard** implemented by the installed pack, not the version of this retained v5 base document. The v6 - extension documents and their v7 additions in this directory define the - current plan lifecycle. + extension documents, their v7 additions and the v8 loop engineering + (`LOOP_ENGINEERING.md`) in this directory define the current plan + lifecycle. A conformance checker reads the declaration against the standard it - implements and rejects a newer one. The standard's series are 2.x, 4.x, - 5.x and 6.x (historical) and 7.x (current — there is no 3.x); the skill package + implements and rejects a newer one. The standard's series are 2.x and + 4.x (historical), 5.x, 6.x and 7.x (retained) and 8.x (current — there is + no 3.x); the skill package `version:` and the `/v2.json` and `/v5.json` schema URLs are two further, separate series, never compared against this line. diff --git a/.agents/skills/deepworkplan/spec/DWP_SPECIFICATION.md b/.agents/skills/deepworkplan/spec/DWP_SPECIFICATION.md index eefa98f..6c787f3 100644 --- a/.agents/skills/deepworkplan/spec/DWP_SPECIFICATION.md +++ b/.agents/skills/deepworkplan/spec/DWP_SPECIFICATION.md @@ -1,8 +1,8 @@ # DWP_SPECIFICATION.md — Deep Work Plan Specification > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract @@ -39,7 +39,7 @@ workspace. Archetype-specific behavior is called out inline, especially in §8 Three version series coexist on purpose and never compare: the skill **package** `version:` (release-managed), the **DWP standard** this document versions -(2.x and 4.x historical, 5.x retained as the base, 6.x retained, 7.x current — there is no 3.x standard; the v3 launch +(2.x and 4.x historical, 5.x retained as the base, 6.x and 7.x retained, 8.x current — there is no 3.x standard; the v3 launch was a product release), and the **schema URLs** (`plan-state/v2.json`, `plan-state/v5.json` — a schema-shape series, not the standard's version; the v5 URLs are **generation snapshots** of the v2 shape, adding no property). diff --git a/.agents/skills/deepworkplan/spec/LITE_PLANS.md b/.agents/skills/deepworkplan/spec/LITE_PLANS.md index f07ff6f..54e5c5e 100644 --- a/.agents/skills/deepworkplan/spec/LITE_PLANS.md +++ b/.agents/skills/deepworkplan/spec/LITE_PLANS.md @@ -1,8 +1,8 @@ # Lite and Full Plan Lifecycle > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. | Field | Value | | --- | --- | diff --git a/.agents/skills/deepworkplan/spec/LOOP_ENGINEERING.md b/.agents/skills/deepworkplan/spec/LOOP_ENGINEERING.md new file mode 100644 index 0000000..902804e --- /dev/null +++ b/.agents/skills/deepworkplan/spec/LOOP_ENGINEERING.md @@ -0,0 +1,174 @@ +# Loop Engineering (normative, v8) + +> Status: normative for the v8 generation. The loop's machinery lives in +> herdr-peers (`autopilot --loop --appoint --brain`, the fleet map and UI, +> the plan-queue consumer); this section defines what a **plan** records so +> the loop can carry it to the end, and nothing more. The key words MUST, +> MUST NOT, SHOULD and MAY are used as in RFC 2119. + +## 1. The v8 rule + +An approved plan MUST run to completion without routine human intervention, +inside the authority recorded in that plan. The human MUST be notified, not +waited on, except when a login or credential is required or a plan's own C1–C7 +gate requires human input and pre-authorization is absent. At those exceptions, +execution MUST stop at the gate until the required input is available. The +methodology works alone; addons only amplify. + +### 1.1. Loop semantics + +Loop engineering describes how an optional daemon carries an approved, +registered plan forward. It does not expand the plan's authority. + +**Registration and succession.** Registration uses a lead claim, which MUST +record the lead and its succession list. The peer holding the highest lead +epoch is the lead. With `autopilot --loop`, a plan with a readable state and a +lead record MAY be watched; the daemon MAY prompt an idle lead to continue +within the plan's recorded authority. If the lead pane is gone, the daemon MAY +prompt the first reachable successor to run `lead takeover`; the helper MUST +check whether takeover is allowed. The daemon MUST NOT write the lead record. +A peer outside the recorded succession MAY become lead only through +Appointment below, by its own takeover, never by the daemon. + +**Human-started daemon and authority.** A human MUST start autopilot. The +background daemon MAY cover enabled machines and sends fixed prompts; a prompt +MUST NOT be treated as a new approval or authority grant. In particular, a +continuation nudge asks the lead to respect the plan's existing gates and +authority. A human MUST provide logins and credentials. + +**Appointment.** Lead appointment MUST require both a human's recorded grant +on the lead claim and a human start of the daemon with `--appoint`. After the +lead and its successors meet the documented gone-and-no-progress checks, the +daemon MAY prompt the first eligible live lane to request appointment; the +helper MUST check the conditions again. A new lead MUST run `lead verify` +before a merge, tag, or release. + +**Queue, events, and fleet map.** When a queued item is ready (its `after` +plan is completed, or it has none) and its start is `prompt-lead`, the daemon +MAY prompt its named lead to start it through the plan tool's execute flow; +its start gate MUST check approval again. The daemon MAY report plan events as `plan-event-v1` +JSON to the configured `--notify` command. The `fleet-v1` map reports agents, +plans, and their roles; `fleet ui` shows the map live. The daemon MAY read +the queue and MUST NOT write it. + +These behaviors are the optional Herdr integration, documented in +[herdr-peers v2.1.0 `autopilot.md` §§1–9](https://github.com/DailybotHQ/herdr-peers/blob/v2.1.0/skills/herdr-peers/autopilot.md) +and [herdr-peers v2.1.0 `protocol.md` §12](https://github.com/DailybotHQ/herdr-peers/blob/v2.1.0/skills/herdr-peers/protocol.md#12-leadership-lead-notices-and-fencing). + +## 2. The `autonomy` block (plan-contract/v8) + +Optional, top-level, closed: a validator MUST refuse an unknown key, and +MUST refuse the block on any contract generation other than v8. Every +absent key has one recorded default, and a consumer MUST apply it, never a +guess of its own: + +| Key | Type | Absent means | +|---|---|---| +| `stall_budget` | integer 1–10 | `3` (herdr-peers' `MAX_PLAN_PROMPTS`) | +| `promptable` | non-empty list of pane addresses | the plan's **lead only** | +| `notify` | non-empty list of targets | no target (the loop still records) | +| `brain` | boolean | `false` — no brain may act on this plan | +| `queue` | `prompt-lead` \| `launch` \| `none` | `none` — the plan is not queued | + +A pane address MUST match herdr-peers' exact form +`(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63}):[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}` +— a machine id never starts with `-` (it is passed to Herdr as an +argument). An absent block means all five defaults: the human is the +resolver, the lead is the only promptable pane, nothing is notified, no +brain acts, the plan is not queued. + +## 3. Structured blockers + +A v8 plan records why it cannot continue as data, so the loop, the fleet and +a resuming agent read the same fields instead of scraping prose. + +### 3.1. The blocker record + +A blocker MUST be recorded through the ledger's helper (`ledger.py block` +to raise, `ledger.py unblock` to resolve) as a `blocker` event of +`journal-event/v8`; a raw append of a `blocker` event MUST be refused, and +every refused raise or resolution MUST be recorded as a refusal. A raise +carries: + +| Field | Rule | +|---|---| +| `task` | the blocked task of this contract; a task its evidence already closed MUST NOT be blocked | +| `reason` | non-empty, at most 1000 characters: why the task cannot continue | +| `needs` | exactly one non-empty line, at most 500 characters: what unblocks it | +| `class` | REQUIRED, one of `C1`–`C7` ([`AGENT_PROTOCOL.md`](AGENT_PROTOCOL.md) §7.5) | +| `resolver` | OPTIONAL, `"lead"` or `"human"`; an absent resolver MUST be read as `human` | + +`lead` means resolvable inside the plan's recorded authority **without** a +credential, login, consent, payment, push to main, release or deletion. +`resolver: "lead"` MUST be refused for `C1`, `C2`, `C5` and `C6` (approval, +a consent or login screen, damage, terms are the human's). A resolution +carries only the task (and an optional note). + +At most one blocker MUST be active per plan: a raise on another task MUST be +refused until the active one is resolved. A re-raise on the same task MAY +update `reason`, `needs`, `class` and `resolver`; the episode keeps the +`since` of its first raise. While a blocker is unresolved its task MUST NOT +complete: completion MUST be refused, and evidence that lands meanwhile does +not close the task. + +### 3.2. Where readers find it + +The plan's `state.json` is `plan-snapshot/v8`: the `plan-snapshot/v6` shape +with `blocker` as the active blocker — `{task, reason, since, needs, class, +resolver?}` — or `null`, and `blocked` as a derived task status that wins over +the others while the blocker is unresolved. Like every snapshot field it is +projected by the ledger, never written by hand. + +`PROGRESS.md` SHOULD open with a structured header of four fixed lines +directly under its title, written by create and refreshed on every +transition (`shared/progress_header.py`): + +```text +Goal: <one line> +Current task: <task id> - <title> (<status>) +Next action: <one line> +Needs: none | <class> (<resolver>): <needs> +``` + +`Current task` and `Needs` are derived from the snapshot (the blocked task +first, else the first task not completed); `Goal` and `Next action` are the +executing agent's words. The rest of `PROGRESS.md` stays the agents' working +index. + +### 3.3. What the loop may do with it + +The loop (its brain included) MUST NOT ask a lead to resolve a blocker the +plan itself did not mark `resolver: "lead"`; everything else waits for the +human. v6 and v7 plans record no `blocker` events, keep `plan-snapshot/v6` +(whose `blocker` stays `null`), and every blocker they report is the +human's. + +## 4. The plan queue + +`.dwp/queue.json`, schema `dwp-queue-v1`. Only the pack (`shared/queue.py`) +or a human MAY write it; the daemon MUST only read it. Create appends on +approval; a human or the lead reorders. Inside Herdr, where the lead's pane +address exists, execute MUST mark `started` on a task start while the item is +still `queued` (normally the plan's first task, once its lead has claimed it; +a crash or a resume retries), together with that address (a `started` item +without one is invalid); outside Herdr the item stays `queued` and a consumer +reads the journal's task start as in flight. Execute marks +`done` after the plan's closure; create/refine skip with a +one-line note. A queue MUST NOT hold more than 64 items. +One plan at a time per repository unless the queue carries +`parallel: true`. Dependencies are queue-internal (`after` names a plan +already queued). The daemon is a bounded, read-only consumer; a damaged +queue is a quiet none and never breaks the lifecycle. + +## 5. What v8 keeps + +Everything v7 carries — `tasks[].parallel_safe`, delegation and the full v7 +event set — under one ordered generation ladder: every feature gated "v7" +MUST be available to v8 and later. A v8 plan MUST record its events under +`journal-event/v8` (the v7 event set plus `blocker`, §3) and project into +`plan-snapshot/v8`; a journal that mixes generations MUST be refused. A v8 +plan MUST keep the v7 manifest line (`plan-manifest/v7`): the manifest's +shape and its contract pointer do not change, so a new manifest URL would +add a generation without a difference. A conformance checker MUST pair a v7 +manifest with a v8 contract. v6 and v7 plans keep their records byte for +byte. diff --git a/.agents/skills/deepworkplan/spec/PLAN_STATE.md b/.agents/skills/deepworkplan/spec/PLAN_STATE.md index 7cc5dda..30152b5 100644 --- a/.agents/skills/deepworkplan/spec/PLAN_STATE.md +++ b/.agents/skills/deepworkplan/spec/PLAN_STATE.md @@ -1,8 +1,8 @@ # PLAN_STATE.md — Machine-Readable Plan State > **Version scope:** This is a retained v5.0.0 base document. The current -> v6 standard also requires the applicable `V6_*.md` extensions indexed in -> [README.md](README.md). Existing v5 plans keep this document’s recorded rules. +> standard (8.0.0) also requires the applicable `V6_*.md` extensions, their +> v7 additions and `LOOP_ENGINEERING.md`, indexed in [README.md](README.md). Existing v5 plans keep this document’s recorded rules. ## Abstract @@ -471,7 +471,11 @@ new-generation URL — `https://deepworkplan.com/schema/plan-snapshot/v6.json` is a generation snapshot of the v2 shape), and the v6 snapshot is a different artifact projected from the journal, not a mutation of those shapes. The same rule gave v6 the `plan-contract/v6` and -`journal-event/v6` labels. +`journal-event/v6` labels. v8 plans project into the next generation of +that label, `https://deepworkplan.com/schema/plan-snapshot/v8.json` +(`spec/schema/plan-snapshot-v8.schema.json`): the v6 shape with `blocker` +as the active structured blocker and `blocked` as a derived task status +([`LOOP_ENGINEERING.md`](LOOP_ENGINEERING.md) §3). **Materialization order.** `shared/ledger.py materialize` writes the v6 records in exactly this order — manifest, contract, approval event — each diff --git a/.agents/skills/deepworkplan/spec/README.md b/.agents/skills/deepworkplan/spec/README.md index 408b0dd..f2ffc61 100644 --- a/.agents/skills/deepworkplan/spec/README.md +++ b/.agents/skills/deepworkplan/spec/README.md @@ -1,16 +1,21 @@ -# DeepWorkPlan Methodology Specification — v7 +# DeepWorkPlan Methodology Specification — v8 > The canonical normative standard for an **AI-first autopilot repository** and the -> The current **Deep Work Plan (DWP)** standard is **7.0.0** (decided for the -> 7.0.0-beta.1 release: it adds normative surface — the configuration file and -> addon registry `CONFIG.md`, addon descriptors `ADDONS.md` §7, -> addon-provided abilities `V7_ABILITIES.md`, the v7 contract generation -> `V7_CONTRACT.md` and four schemas; 6.0.0 declarations stay valid). The v5 +> The current **Deep Work Plan (DWP)** standard is **8.0.0** (decided for the +> 8.0.0-beta.1 release: it adds normative surface — the v8 contract generation +> with the optional `autonomy` block, the v8 journal and snapshot generations +> with structured blockers, and loop engineering, `LOOP_ENGINEERING.md`, with +> three schemas; 7.0.0 and 6.0.0 declarations stay valid). The 7.0.0 standard +> added the configuration file and addon registry `CONFIG.md`, addon +> descriptors `ADDONS.md` §7, addon-provided abilities `V7_ABILITIES.md`, the +> v7 contract generation `V7_CONTRACT.md` and four schemas. The v5 > base documents below remain versioned 5.0.0 so existing plans keep their > recorded rules; the four `V6_*.md` documents define the lifecycle on top of -> that base and the `V7_*.md` documents extend it. New plans created by the 7.x pack use the v7 contract generation of -> the same record layer (`V7_CONTRACT.md`: v6 plus the `parallel_safe` marker -> and delegation records); v6 plans keep v6. Existing v1/v2/v5 plans +> that base and the `V7_*.md` documents extend it. New plans created by the 8.x pack use the v8 contract generation of +> the same record layer (`LOOP_ENGINEERING.md`: the v7 contract plus the +> optional `autonomy` block, recorded under `journal-event/v8` with +> structured blockers; `V7_CONTRACT.md`: v6 plus the `parallel_safe` +> marker and delegation records); v7 and v6 plans keep their generation. Existing v1/v2/v5 plans > retain their recorded generation and are never silently migrated. Schema > URLs are published at `https://deepworkplan.com/schema/`. @@ -38,6 +43,7 @@ orchestrator hub, and agent workspace — are addressed throughout. | [`CONFIG.md`](CONFIG.md) | **7.0.0** configuration file: `.dwp/config.json` / `~/.dwp/config.json` — one shape, one stdlib parser (`shared/config.py`), two keys: `benchmark` (wholesale, `BENCHMARK.md` §1) and the `addons` registry (per-key precedence, keys = in-pack addon directory names, closed `{enabled, version}` entries, fail-closed with one warning, unknown keys ignored, absent = not enabled, informative `version`); the reconciling consent-gated writer used by `onboard`; published as `schema/dwp-config-v1`. The registry can only offer or amplify — never gate conformance or a plan. | | [`V7_CONTRACT.md`](V7_CONTRACT.md) | **7.0.0** contract generation v7 of the v6 record layer: `plan-contract/v7` = v6 + optional `tasks[].parallel_safe` (the create-time delegation marker); `journal-event/v7` = v6 + the `delegation` event (launched/completed/failed/cancelled; never evidence — a delegate's result stays `asserted` until this plan's runner observes it); `plan-manifest/v7`; generation by schema URL, never mixed; the record-layer delegation gate and `ledger.py delegate launch|observe|collect|cancel`. v6 schema bytes unchanged. | | [`V7_ABILITIES.md`](V7_ABILITIES.md) | **7.0.0** addon-provided abilities: effective abilities = host-declared ∪ `provides_abilities` of addons that are enabled in the registry, carry a valid `addon.json`, are detected (argv detect with no shell and a timeout, or paths) and report a compatible interface major; one warning and no contribution otherwise; never persisted into a plan; an ability is never authority (grants still apply) and never consent (telemetry). Extends `V6_RESOURCES.md` §1 without changing it. | +| [`LOOP_ENGINEERING.md`](LOOP_ENGINEERING.md) | **8.0.0 line** (normative from 8.0.0): contract generation v8 = `plan-contract/v8`, v7 plus the optional, closed `autonomy` block (stall budget, promptable panes, notify targets, brain, queue start; one recorded default per absent key); v8 plans keep the v7 manifest line and record under `journal-event/v8` (v7 plus the `blocker` event) projected into `plan-snapshot/v8`; the `dwp-queue-v1` plan queue written only by the pack (`shared/queue.py`) and read by the herdr-peers daemon; structured blockers (class C1–C7, resolver lead\|human, one line of needs; raised and resolved only by `ledger.py block`/`unblock`) and the `PROGRESS.md` header (`shared/progress_header.py`). | | [`V7_ROADMAP.md`](V7_ROADMAP.md) | **Non-normative** planning record for v7: the optional addons (Herdr, DeepWorkPlan Vim), a pointer to the peer protocol that now lives in herdr-peers, and the never-a-conformance-gate posture. Nothing here gates the current standard. | | [`ADDONS.md`](ADDONS.md) | The addon mechanism + contract (reconcile-don't-clobber); seven opt-in addons plus the AI Diff Reviewer local review, required in the baseline since 2.3.0 (§6.5). | diff --git a/.agents/skills/deepworkplan/spec/V6_LIFECYCLE.md b/.agents/skills/deepworkplan/spec/V6_LIFECYCLE.md index f7bb462..09c8609 100644 --- a/.agents/skills/deepworkplan/spec/V6_LIFECYCLE.md +++ b/.agents/skills/deepworkplan/spec/V6_LIFECYCLE.md @@ -45,15 +45,20 @@ event: |---|---|---|---|---| | v6 | `plan-contract/v6` | `journal-event/v6` | `plan-manifest/v6` | — | | v7 | `plan-contract/v7` | `journal-event/v7` | `plan-manifest/v7` | `tasks[].parallel_safe`, the `delegation` event ([`V7_CONTRACT.md`](V7_CONTRACT.md)) | +| v8 | `plan-contract/v8` | `journal-event/v8` | `plan-manifest/v7` | the optional `autonomy` block and structured blockers (the `blocker` event, projected into `plan-snapshot/v8`) ([`LOOP_ENGINEERING.md`](LOOP_ENGINEERING.md)); everything v7 carries | -Both generations run through the same loops and helpers and project into -the same `plan-snapshot/v6` shape. A plan never changes generation: a v6 -plan keeps v6 forever, and a journal mixing generations is refused. +Every generation runs through the same loops and helpers. v6 and v7 plans +project into the same `plan-snapshot/v6` shape; v8 plans project into +`plan-snapshot/v8`, the same shape with the structured blocker wired +([`LOOP_ENGINEERING.md`](LOOP_ENGINEERING.md) §3). A plan never changes +generation: a v6 plan keeps v6 forever, and a journal mixing generations is +refused. ## 2. Activation (normative) -With the current 7.x pack, new plans use the v7 contract generation by -default (§1 table); an explicit `v6` request materializes a v6 contract. A +With the current 8.x pack, new plans use the v8 contract generation by +default (§1 table); an explicit `v7` or `v6` request materializes that +contract generation. A developer's explicit v6 request also selects this flow when an older pack provides it. A 5.x pack without that request follows its recorded v5 flow. Existing diff --git a/.agents/skills/deepworkplan/spec/V7_CONTRACT.md b/.agents/skills/deepworkplan/spec/V7_CONTRACT.md index 530e06e..27bfc21 100644 --- a/.agents/skills/deepworkplan/spec/V7_CONTRACT.md +++ b/.agents/skills/deepworkplan/spec/V7_CONTRACT.md @@ -19,7 +19,9 @@ journal event carries `…/journal-event/v7.json`. A journal that mixes generations, or a v7 event under a v6 contract, MUST be refused. - New plans created by the 7.x pack are v7 by default; an explicit `v6` - request materializes a v6 contract. A plan never changes generation: v6 + request materializes a v6 contract. The 8.x pack defaults to v8 + ([`LOOP_ENGINEERING.md`](LOOP_ENGINEERING.md): v7 plus the optional + `autonomy` block); an explicit `v7` request still materializes v7. A plan never changes generation: v6 plans keep v6 forever and run unchanged. - v7 plans project into the unchanged `plan-snapshot/v6` shape (its `positions` are keyed by event type, so the `delegation` type needs no new @@ -95,7 +97,7 @@ transition of one delegate: `launch` MUST be refused — and the refusal recorded as a `refusal` event, exit 5 — unless **all** hold: -1. the contract is v7; +1. the contract is v7 or later (v8, `LOOP_ENGINEERING.md` §5); 2. the contract grants `agent_delegation`; 3. the task exists, has started, and is not complete; 4. the task is marked `parallel_safe`, **or** the delegate is read-only diff --git a/.agents/skills/deepworkplan/spec/V7_ROADMAP.md b/.agents/skills/deepworkplan/spec/V7_ROADMAP.md index ac20595..c0f0ce1 100644 --- a/.agents/skills/deepworkplan/spec/V7_ROADMAP.md +++ b/.agents/skills/deepworkplan/spec/V7_ROADMAP.md @@ -27,7 +27,7 @@ number), and the pack carries a **thin integrator** for it — never a copy. | **Addon-provided abilities** | effective abilities = host ∪ abilities of enabled, valid, detected, interface-compatible addons; computed per call, never persisted; an ability is never authority or consent ([`V7_ABILITIES.md`](V7_ABILITIES.md)). | | **v7 contract generation** | `plan-contract/v7` (v6 + `parallel_safe`), `journal-event/v7` (v6 + `delegation`), `plan-manifest/v7`; default for new plans; v6 plans unchanged ([`V7_CONTRACT.md`](V7_CONTRACT.md)). | | **Delegation** | `ledger.py delegate launch|observe|collect|cancel` behind a recorded gate (grant, marker, ability); `execute/delegation.md`; a delegate's result stays `asserted` until the plan's own gates observe it. | -| **Thin integrators** | `agentkit` → `coding-agents-kit@v1.4.0` (headless transport, `ak run`; autonomy by default with an always-winning opt-out since `v0.2.0`); `herdr` → `herdr-peers@v2.0.0` (interactive transport and native debate panels; stamp `[herdr-peers]`, protocol owned by herdr-peers); `devcontainer` → `devcontainer-kit@v1.1.2` (`dck init` and the `dck-dockerfile` skill, interface 2, per-repository Dockerfile, vendor-neutral); `vim` → `deepworkplan-vim@v1.0.1` (surface-driven editor offer). | +| **Thin integrators** | `agentkit` → `coding-agents-kit@v1.5.0` (headless transport, `ak run`; autonomy by default with an always-winning opt-out since `v0.2.0`); `herdr` → `herdr-peers@v2.1.0` (interactive transport and native debate panels; stamp `[herdr-peers]`, protocol owned by herdr-peers); `devcontainer` → `devcontainer-kit@v1.3.0` (`dck init` and the `dck-dockerfile` skill, interface 2, per-repository Dockerfile, vendor-neutral); `vim` → `deepworkplan-vim@v1.0.1` (surface-driven editor offer). | | **Pre-release channel** | `prerelease.yml` cuts `X.Y.Z-beta.N` on dispatch (never `latest`, with `SHA256SUMS`); stable releases ignore pre-release tags and graduate only on `[graduate]`. | | **Standard** | DWP standard **7.0.0** (normative additions above); `6.0.0` declarations stay valid. | diff --git a/.agents/skills/deepworkplan/spec/schema/journal-event-v8.schema.json b/.agents/skills/deepworkplan/spec/schema/journal-event-v8.schema.json new file mode 100644 index 0000000..c71a4da --- /dev/null +++ b/.agents/skills/deepworkplan/spec/schema/journal-event-v8.schema.json @@ -0,0 +1,1093 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://deepworkplan.com/schema/journal-event/v8.json", + "description": "Deep Work Plan journal event, v8 generation (spec/LOOP_ENGINEERING.md section 3). A strict superset of journal-event/v7: the full v7 catalog unchanged plus the blocker event - one raise or resolution of the plan's structured blocker. A raise carries the task, a reason, needs (one line: what unblocks it), the escalation class C1..C7 (AGENT_PROTOCOL.md section 7.5) and an optional resolver (lead or human; absent means human; lead is refused for C1, C2, C5 and C6). A resolution carries only the task. At most one blocker is active per plan, an unresolved raise keeps its task from completing, and blocker events are written only by the ledger's block/unblock helper, never by a raw append. Not evidence: it carries no trust label.", + "type": "object", + "required": [ + "schema", + "type", + "seq", + "ts", + "plan", + "contract_id", + "actor" + ], + "properties": { + "schema": { + "const": "https://deepworkplan.com/schema/journal-event/v8.json" + }, + "type": { + "enum": [ + "task_start", + "approval", + "gate_run", + "observation", + "adaptation", + "amendment", + "intervention", + "resource_sample", + "control_pair", + "selection", + "refusal", + "view_render", + "reconciliation", + "journal_repair", + "delegation", + "blocker" + ] + }, + "seq": { + "type": "integer", + "minimum": 1, + "description": "Position in the journal; strictly increasing across the file. Rolls may not truncate below snapshot-cited positions (A12)." + }, + "ts": { + "type": "string", + "format": "date-time", + "description": "The scheduler's clock (A11) - the aging clock for starvation protection." + }, + "plan": { + "type": "string", + "description": "Plan folder name: optional monotonic numeric ID of at least three digits, followed by a 2–5-word lowercase snake_case slug; legacy unnumbered names remain valid.", + "pattern": "^PLAN_([0-9]{3,}_)?[a-z0-9]+(_[a-z0-9]+){1,4}$" + }, + "contract_id": { + "type": "string", + "pattern": "^[0-9a-f]{64}$", + "description": "Every record produced under a contract cites its id (section 3.1)." + }, + "actor": { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "identity" + ], + "properties": { + "kind": { + "enum": [ + "helper", + "agent", + "host_adapter", + "human" + ] + }, + "identity": { + "type": "string", + "minLength": 1, + "maxLength": 100 + } + } + }, + "note": { + "type": "string", + "maxLength": 500 + } + }, + "oneOf": [ + { + "$ref": "#/$defs/task_start" + }, + { + "$ref": "#/$defs/approval" + }, + { + "$ref": "#/$defs/gate_run" + }, + { + "$ref": "#/$defs/observation" + }, + { + "$ref": "#/$defs/adaptation" + }, + { + "$ref": "#/$defs/amendment" + }, + { + "$ref": "#/$defs/intervention" + }, + { + "$ref": "#/$defs/resource_sample" + }, + { + "$ref": "#/$defs/control_pair" + }, + { + "$ref": "#/$defs/selection" + }, + { + "$ref": "#/$defs/refusal" + }, + { + "$ref": "#/$defs/view_render" + }, + { + "$ref": "#/$defs/reconciliation" + }, + { + "$ref": "#/$defs/journal_repair" + }, + { + "$ref": "#/$defs/delegation" + }, + { + "$ref": "#/$defs/blocker" + } + ], + "$defs": { + "task_start": { + "properties": { + "type": { + "const": "task_start" + }, + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "fingerprint": { + "type": "object", + "additionalProperties": false, + "required": [ + "revision", + "dirty" + ], + "properties": { + "revision": { + "type": "string", + "minLength": 1 + }, + "dirty": { + "type": "string", + "description": "The section-2-row-16 dirty-state comparison string captured AT TASK START; empty means clean. This is the state a control pair's old leg materializes (D2-6); a non-empty dirty component makes every control on the attempt unavailable (D3-3). 'none' when the host had no git at task start." + } + }, + "description": "Optional: recorded by the start_task executor. A raw append records none, and a control on a fingerprint-less attempt records control=unavailable - never a guessed old tree." + } + }, + "required": [ + "type", + "task" + ] + }, + "approval": { + "properties": { + "type": { + "const": "approval" + }, + "authority": { + "type": "string", + "minLength": 1 + }, + "mechanism": { + "enum": [ + "plan_authorship", + "pre_authorization" + ], + "description": "Exactly the section-3.1 mechanisms; migration re-uses pre_authorization (D3-2), there is no third value." + }, + "plan_digest": { + "type": "string", + "pattern": "^[0-9a-f]{64}$", + "description": "Digest of the consented artifact: the reviewed plan markdown (plan_authorship) or the recorded pre-authorization (pre_authorization)." + } + }, + "required": [ + "type", + "authority", + "mechanism", + "plan_digest" + ], + "description": "The section-3.1 approval record {authority, mechanism, contract_id, plan digest}; contract_id rides the envelope, which is how the event cites it." + }, + "gate_run": { + "properties": { + "type": { + "const": "gate_run" + }, + "command": { + "type": "string", + "minLength": 1, + "maxLength": 500 + }, + "cwd": { + "type": "string", + "minLength": 1 + }, + "env": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "timeout_seconds": { + "type": "number", + "exclusiveMinimum": 0 + }, + "exit_code": { + "type": "integer" + }, + "trust": { + "$ref": "#/$defs/trust" + }, + "evidence_path": { + "type": "string", + "minLength": 1, + "description": "Recoverable pointer to captured outputs; REQUIRED when trust is observed or imported." + }, + "criterion": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$", + "description": "The task whose declared gate_intent this run executes; bound at execution time, never linked afterwards." + } + }, + "required": [ + "type", + "command", + "cwd", + "timeout_seconds", + "exit_code", + "trust", + "task", + "criterion" + ] + }, + "observation": { + "properties": { + "type": { + "const": "observation" + }, + "statement": { + "type": "string", + "minLength": 1 + }, + "trust": { + "$ref": "#/$defs/trust" + }, + "evidence_path": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "type", + "statement", + "trust" + ] + }, + "adaptation": { + "properties": { + "type": { + "const": "adaptation" + }, + "kind": { + "enum": [ + "split", + "reorder", + "insert", + "change_strategy", + "retry" + ], + "description": "The closed section-3.3 enumeration. Anything outside it is refused by the authorization core; this object has NO field that can carry criterion content - a substituted check is an amendment, never an adaptation." + }, + "trigger_observation": { + "type": "integer", + "minimum": 1, + "description": "Journal seq of the observation that triggered the proposal." + }, + "evidence_artifact": { + "type": "string", + "minLength": 1 + }, + "hypothesis": { + "type": "string", + "minLength": 1 + }, + "action": { + "type": "string", + "minLength": 1 + }, + "rationale": { + "type": "string", + "minLength": 1 + }, + "affected_tasks": { + "type": "array", + "items": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + } + }, + "affected_criteria": { + "type": "array", + "items": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + } + }, + "authority": { + "type": "string", + "minLength": 1 + }, + "evidence_invalidated": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "evidence_preserved": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "resource_impact": { + "type": "object", + "additionalProperties": false, + "required": [ + "declared", + "unit" + ], + "properties": { + "declared": { + "type": "number", + "minimum": 0, + "description": "The D2-9a pending contribution: a pending proposal contributes its declared impact, or the last measured cost of the same task shape when undeclared." + }, + "unit": { + "type": "string", + "minLength": 1 + } + } + }, + "decision": { + "enum": [ + "authorized", + "refused" + ] + }, + "reason": { + "type": "string", + "minLength": 1, + "description": "REQUIRED when decision=refused; the refusal ledger view reads it (U3/B1)." + } + }, + "required": [ + "type", + "kind", + "trigger_observation", + "evidence_artifact", + "hypothesis", + "action", + "rationale", + "affected_tasks", + "affected_criteria", + "authority", + "evidence_invalidated", + "evidence_preserved", + "decision" + ] + }, + "amendment": { + "properties": { + "type": { + "const": "amendment" + }, + "original_criterion": { + "type": "string", + "minLength": 1, + "description": "Verbatim, never paraphrased." + }, + "observed_finding": { + "type": "string", + "minLength": 1 + }, + "disposition": { + "type": "string", + "minLength": 1 + }, + "revised_criterion": { + "type": "string", + "minLength": 1 + }, + "reason": { + "type": "string", + "minLength": 1 + }, + "authority": { + "type": "string", + "minLength": 1, + "description": "Recorded user or developer authority (section 3.4); an unmeetable mandatory criterion is a blocker, never completed work." + }, + "affected_tasks": { + "type": "array", + "items": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + } + }, + "evidence_invalidated": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "evidence_preserved": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + } + }, + "required": [ + "type", + "original_criterion", + "observed_finding", + "disposition", + "revised_criterion", + "reason", + "authority", + "affected_tasks", + "evidence_invalidated", + "evidence_preserved" + ] + }, + "intervention": { + "properties": { + "type": { + "const": "intervention" + }, + "category": { + "enum": [ + "missing_intent", + "new_authority", + "environment_repair", + "engineering_rescue" + ], + "description": "Closed taxonomy, source of record docs/evaluations/v6/TELEMETRY.md (D3-11); campaign extraction and product records share this one enumeration (A13)." + }, + "description": { + "type": "string", + "minLength": 1 + }, + "question": { + "type": "string", + "minLength": 1, + "description": "The required authorization question asked of the human." + }, + "resolution": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "type", + "category", + "description", + "question" + ] + }, + "resource_sample": { + "properties": { + "type": { + "const": "resource_sample" + }, + "source": { + "type": "string", + "minLength": 1, + "description": "The metering source named by the enforced limit (A5): a host adapter reading real meters, or an asserted sample." + }, + "limit_id": { + "type": "string", + "pattern": "^[a-z][a-z0-9_]*$" + }, + "value": { + "type": "number", + "minimum": 0 + }, + "unit": { + "type": "string", + "minLength": 1 + }, + "trust": { + "$ref": "#/$defs/trust" + }, + "evidence_path": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "type", + "source", + "value", + "unit", + "trust" + ] + }, + "control_pair": { + "properties": { + "type": { + "const": "control_pair" + }, + "criterion": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "check_artifacts": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "minLength": 1 + }, + "description": "The D3-4 declaration: exactly these listed files travel back to the old leg's worktree; product files stay at their starting state. A v6-only surface - the v5 gate object has no such field." + }, + "starting_fingerprint": { + "type": "object", + "additionalProperties": false, + "required": [ + "revision", + "dirty" + ], + "properties": { + "revision": { + "type": "string", + "minLength": 1 + }, + "dirty": { + "type": "string", + "description": "Empty string means clean. A NON-EMPTY dirty component means the old leg cannot be materialized faithfully and the pair records control=unavailable (D3-3)." + } + } + }, + "old_leg": { + "type": "object", + "additionalProperties": false, + "required": [ + "available" + ], + "properties": { + "available": { + "type": "boolean" + }, + "outcome": { + "enum": [ + "PASS", + "FAIL" + ], + "description": "Present iff available=true." + }, + "log": { + "type": "string", + "minLength": 1 + } + }, + "allOf": [ + { + "if": { + "properties": { + "available": { + "const": true + } + } + }, + "then": { + "required": [ + "outcome" + ] + } + }, + { + "if": { + "properties": { + "available": { + "const": false + } + } + }, + "then": { + "not": { + "required": [ + "outcome" + ] + }, + "description": "An unavailable leg carries no outcome (D2-6/D3-3)." + } + } + ] + }, + "new_leg": { + "type": "object", + "additionalProperties": false, + "required": [ + "outcome", + "log" + ], + "properties": { + "outcome": { + "enum": [ + "PASS", + "FAIL" + ] + }, + "log": { + "type": "string", + "minLength": 1 + } + } + }, + "verdict": { + "enum": [ + "discriminating", + "non_discriminating", + "control_unavailable" + ], + "description": "Only (old FAIL, new PASS) is discriminating (A6/U2). (PASS, PASS) is recorded non-discriminating, never rounded up; (FAIL, FAIL) records non-discriminating with new_leg.outcome=FAIL preserved - the pair proves nothing about the control and the criterion still fails. Any unavailable leg or dirty starting fingerprint is control_unavailable." + }, + "trust": { + "$ref": "#/$defs/trust" + }, + "evidence_path": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "type", + "criterion", + "check_artifacts", + "starting_fingerprint", + "old_leg", + "new_leg", + "verdict", + "trust" + ] + }, + "selection": { + "properties": { + "type": { + "const": "selection" + }, + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "priority_boost": { + "type": "boolean", + "description": "The section-5 starvation protection action, itself a journal event (A11)." + }, + "aging": { + "type": "object", + "additionalProperties": false, + "required": [ + "waiting_since_seq", + "threshold" + ], + "properties": { + "waiting_since_seq": { + "type": "integer", + "minimum": 1, + "description": "Journal position where the task became ready-but-blocked; the clock is journal timestamps." + }, + "threshold": { + "type": "string", + "minLength": 1, + "description": "The contract-declared aging threshold that fired." + } + } + } + }, + "required": [ + "type", + "task", + "priority_boost" + ] + }, + "refusal": { + "properties": { + "type": { + "const": "refusal" + }, + "subject": { + "type": "string", + "minLength": 1, + "description": "What was refused: a task id, or a pointer to the refused proposal." + }, + "stage": { + "enum": [ + "task_start", + "authorize", + "dispatch", + "gate" + ] + }, + "reason": { + "type": "string", + "minLength": 1 + }, + "proposal": { + "type": "integer", + "minimum": 1, + "description": "Journal seq of the refused adaptation proposal, when the subject is one." + } + }, + "required": [ + "type", + "subject", + "stage", + "reason" + ] + }, + "view_render": { + "properties": { + "type": { + "const": "view_render" + }, + "view": { + "type": "string", + "minLength": 1 + }, + "snapshot_digest": { + "type": "string", + "pattern": "^[0-9a-f]{64}$", + "description": "Digest of the source snapshot the view rendered from (section 4.4 discipline)." + }, + "digests": { + "type": "object", + "description": "Per-view sha256 of the rendered bytes (N3: human edits are detected by comparing on-disk content against the last recorded render, so marker-free edits can never be silently overwritten). Keys are view names; values are 64-hex digests.", + "additionalProperties": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + } + } + }, + "required": [ + "type", + "view", + "snapshot_digest" + ] + }, + "reconciliation": { + "properties": { + "type": { + "const": "reconciliation" + }, + "trigger": { + "type": "string", + "minLength": 1 + }, + "editor": { + "type": "string", + "minLength": 1, + "description": "Whose change won - the human document, not a mechanism label." + }, + "authority": { + "type": "string", + "minLength": 1, + "description": "The section-3.2 authority under which reconciled closures close (D2-4); without it a criterion downgrades to blocked, never reconciled." + } + }, + "required": [ + "type", + "trigger", + "editor", + "authority" + ] + }, + "journal_repair": { + "properties": { + "type": { + "const": "journal_repair" + }, + "byte_offset": { + "type": "integer", + "minimum": 0, + "description": "Where the torn tail was truncated; the append-only rule binds complete events only." + }, + "cause": { + "type": "string", + "minLength": 1 + } + }, + "required": [ + "type", + "byte_offset", + "cause" + ] + }, + "trust": { + "enum": [ + "observed", + "imported", + "asserted" + ], + "description": "Section 4.5: observed = a shipped helper itself executed the check; imported = matched external source with provenance; asserted = stated without independent establishment." + }, + "delegation": { + "properties": { + "type": { + "const": "delegation" + }, + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "delegation_id": { + "type": "string", + "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$", + "description": "Correlates the launch with its terminal transition." + }, + "transport": { + "enum": [ + "headless", + "interactive" + ] + }, + "via": { + "type": "string", + "pattern": "^[a-z][a-z0-9-]{0,63}$", + "description": "The addon key that carried the delegate (agentkit, herdr)." + }, + "kind": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "The coding-agent kind (claude, codex, ...)." + }, + "profile": { + "type": "string", + "minLength": 1, + "maxLength": 200 + }, + "target": { + "type": "string", + "minLength": 1, + "maxLength": 200, + "description": "cwd for headless, machine:pane for interactive." + }, + "worktree": { + "type": [ + "string", + "null" + ], + "minLength": 1, + "maxLength": 300, + "description": "The delegate's own git worktree; null for a read-only delegate." + }, + "prompt_digest": { + "type": "string", + "pattern": "^sha256:[0-9a-f]{64}$", + "description": "The prompt is recorded by digest before the delegate is relied on." + }, + "state": { + "enum": [ + "launched", + "completed", + "failed", + "cancelled" + ] + }, + "result_path": { + "type": "string", + "minLength": 1, + "pattern": "^(?!/)(?!.*(^|/)\\.\\.(/|$)).+$", + "description": "Relative path of the collected result inside the plan or repository." + }, + "result_digest": { + "type": "string", + "pattern": "^sha256:[0-9a-f]{64}$" + } + }, + "required": [ + "type", + "task", + "delegation_id", + "transport", + "via", + "state" + ], + "allOf": [ + { + "if": { + "properties": { + "state": { + "const": "launched" + } + }, + "required": [ + "state" + ] + }, + "then": { + "required": [ + "prompt_digest" + ] + } + }, + { + "if": { + "required": [ + "result_path" + ] + }, + "then": { + "properties": { + "state": { + "enum": [ + "completed", + "failed" + ] + } + } + } + } + ] + }, + "blocker": { + "properties": { + "type": { + "const": "blocker" + }, + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "action": { + "enum": [ + "raised", + "resolved" + ] + }, + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000, + "pattern": "\\S", + "description": "Why the task cannot continue." + }, + "needs": { + "type": "string", + "minLength": 1, + "maxLength": 500, + "pattern": "^[^\\r\\n]*\\S[^\\r\\n]*$", + "description": "One line: what unblocks the task." + }, + "class": { + "enum": [ + "C1", + "C2", + "C3", + "C4", + "C5", + "C6", + "C7" + ], + "description": "The escalation class (AGENT_PROTOCOL.md section 7.5)." + }, + "resolver": { + "enum": [ + "lead", + "human" + ], + "description": "Who may resolve it; absent means human. lead: resolvable inside the plan's recorded authority without a credential, login, consent, payment, push to main, release or deletion." + } + }, + "required": [ + "type", + "task", + "action" + ], + "allOf": [ + { + "if": { + "properties": { + "action": { + "const": "raised" + } + }, + "required": [ + "action" + ] + }, + "then": { + "required": [ + "reason", + "needs", + "class" + ] + } + }, + { + "if": { + "properties": { + "action": { + "const": "resolved" + } + }, + "required": [ + "action" + ] + }, + "then": { + "not": { + "anyOf": [ + { + "required": [ + "reason" + ] + }, + { + "required": [ + "needs" + ] + }, + { + "required": [ + "class" + ] + }, + { + "required": [ + "resolver" + ] + } + ] + } + } + }, + { + "if": { + "properties": { + "resolver": { + "const": "lead" + } + }, + "required": [ + "resolver" + ] + }, + "then": { + "properties": { + "class": { + "enum": [ + "C3", + "C4", + "C7" + ] + } + } + } + } + ] + } + }, + "unevaluatedProperties": false +} diff --git a/.agents/skills/deepworkplan/spec/schema/plan-contract-v8.schema.json b/.agents/skills/deepworkplan/spec/schema/plan-contract-v8.schema.json new file mode 100644 index 0000000..1febaa2 --- /dev/null +++ b/.agents/skills/deepworkplan/spec/schema/plan-contract-v8.schema.json @@ -0,0 +1,551 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://deepworkplan.com/schema/plan-contract/v8.json", + "description": "Deep Work Plan outcome and authority contract, v8 generation (spec/LOOP_ENGINEERING.md). A strict superset of plan-contract/v7 (spec/V7_CONTRACT.md): every v7 rule \u2014 and through it every v6 rule, identity and revision semantic \u2014 applies unchanged, including the optional boolean tasks[].parallel_safe. The v8 generation adds the optional top-level `autonomy` block (spec/LOOP_ENGINEERING.md): the plan's recorded authority for the loop \u2014 stall_budget (1-10 loop prompts), promptable (non-empty list of pane addresses), notify (non-empty list of targets; dailybot today), brain (boolean: may a brain act on this plan), queue (prompt-lead|launch|none). The journal-event set is unchanged from v7.", + "type": "object", + "additionalProperties": false, + "required": [ + "schema", + "spec_version", + "plan", + "revision", + "created_at", + "outcome", + "acceptance", + "invariants", + "scope", + "authorization", + "permissions", + "dependencies", + "resource_envelope", + "tasks" + ], + "properties": { + "schema": { + "const": "https://deepworkplan.com/schema/plan-contract/v8.json" + }, + "spec_version": { + "type": "string", + "pattern": "^\\d+\\.\\d+\\.\\d+$" + }, + "plan": { + "type": "string", + "description": "Plan folder name: optional monotonic numeric ID of at least three digits, followed by a 2\u20135-word lowercase snake_case slug; legacy unnumbered names remain valid.", + "pattern": "^PLAN_([0-9]{3,}_)?[a-z0-9]+(_[a-z0-9]+){1,4}$" + }, + "revision": { + "type": "integer", + "minimum": 1 + }, + "contract_id": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "parent_contract_id": { + "type": "string", + "pattern": "^[0-9a-f]{64}$" + }, + "created_at": { + "type": "string", + "format": "date-time" + }, + "title": { + "type": "string", + "maxLength": 200 + }, + "outcome": { + "type": "object", + "additionalProperties": false, + "required": [ + "statement", + "success_definition", + "out_of_scope" + ], + "properties": { + "statement": { + "type": "string", + "minLength": 1 + }, + "success_definition": { + "type": "string", + "minLength": 1 + }, + "out_of_scope": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + } + } + }, + "acceptance": { + "type": "object", + "additionalProperties": false, + "required": [ + "criteria" + ], + "properties": { + "criteria": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "statement", + "observable_check", + "accepted_evidence" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "statement": { + "type": "string", + "minLength": 1 + }, + "observable_check": { + "type": "string", + "minLength": 1, + "description": "An observable check: behavior, interface, or stored state - never a narration claim." + }, + "accepted_evidence": { + "type": "array", + "minItems": 1, + "items": { + "enum": [ + "observed", + "imported", + "asserted" + ] + }, + "uniqueItems": true, + "description": "Which section-4.5 trust classes may close this criterion. A criterion that does not accept 'asserted' never inherits completion from migration (A7/D3-5)." + }, + "control": { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "rationale" + ], + "properties": { + "kind": { + "enum": [ + "regression", + "discrimination", + "exempt" + ] + }, + "rationale": { + "type": "string", + "minLength": 1 + } + }, + "description": "The negative control decided at contract authoring (section 6); 'exempt' is for minor prose/cosmetic criteria and says why." + } + } + } + } + } + }, + "invariants": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "statement" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^INV-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "statement": { + "type": "string", + "minLength": 1 + } + } + }, + "description": "Global conditions that must hold at every boundary; violation is a stop, not an adaptation." + }, + "scope": { + "type": "object", + "additionalProperties": false, + "required": [ + "allowed_paths", + "allowed_command_classes", + "forbidden_operations" + ], + "properties": { + "allowed_paths": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "allowed_command_classes": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "minLength": 1 + }, + "uniqueItems": true, + "description": "Decidable only for declared gate commands the core validates and executes (section 8); an empty list is undeclared, not unrestricted; arbitrary shell is detection-plus-reporting, never prevention." + }, + "forbidden_operations": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "minLength": 1 + }, + "description": "Destructive and outward-facing operations, named explicitly." + } + } + }, + "authorization": { + "type": "object", + "additionalProperties": false, + "required": [ + "mechanism", + "authority", + "timestamp", + "boundaries", + "consent_checkpoints" + ], + "properties": { + "mechanism": { + "enum": [ + "plan_authorship", + "pre_authorization" + ], + "description": "The binding mechanism ONLY (D3-1). plan_authorship = interactive git plans (the reviewed plan markdown is the consented artifact; authority = the session user). pre_authorization = unattended/non-git plans AND migration (the recorded pre-authorization is the migration request, D3-2). No third value exists. The citing record is the materialization-time journal 'approval' event - a record inside the contract cannot cite the contract's own content-addressed contract_id." + }, + "authority": { + "type": "string", + "minLength": 1, + "description": "Who or what approved - an identity, never a model's confidence." + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "boundaries": { + "type": "string", + "minLength": 1, + "description": "Boundaries of the pre-approval: what it does and does not cover." + }, + "consent_checkpoints": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "description": "Carried verbatim from the plan; never paraphrased." + } + } + }, + "permissions": { + "type": "object", + "additionalProperties": false, + "required": [ + "granted", + "not_granted" + ], + "properties": { + "granted": { + "type": "array", + "items": { + "$ref": "#/$defs/capability" + }, + "uniqueItems": true + }, + "not_granted": { + "type": "array", + "items": { + "$ref": "#/$defs/capability" + }, + "uniqueItems": true, + "description": "Explicitly those NOT granted - the negative list is content, not filler." + } + } + }, + "dependencies": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "kind", + "detail" + ], + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "kind": { + "enum": [ + "external_system", + "credential", + "pinned_input" + ] + }, + "detail": { + "type": "string", + "minLength": 1, + "description": "For credentials: names only, never secrets." + } + } + } + }, + "resource_envelope": { + "type": "object", + "additionalProperties": false, + "required": [ + "limits" + ], + "properties": { + "limits": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "limit", + "unit", + "enforcement" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-z][a-z0-9_]*$" + }, + "limit": { + "type": "number", + "minimum": 0, + "description": "Malformed values (negative, non-numeric) are invalid; the semantic validator rejects them with the offending id named." + }, + "unit": { + "type": "string", + "minLength": 1 + }, + "enforcement": { + "enum": [ + "enforced", + "advisory" + ], + "description": "enforced = a host adapter can actually stop the agent; advisory = instructed and reported only. Enforcement parity across hosts is never claimed (section 8)." + }, + "metering_source": { + "type": "string", + "minLength": 1, + "description": "REQUIRED iff enforcement=enforced (A5): a host adapter reading real provider meters. authorize() never enforces on asserted meter data - an asserted meter degrades the limit to advisory and the record says so." + }, + "reserve": { + "type": "number", + "minimum": 0, + "description": "OPTIONAL (section 8): budget held back from dispatch for verification, retry and resume. 0 <= reserve <= limit (the semantic validator enforces the ceiling and names the limit id); the dispatchable ceiling is limit - reserve." + } + }, + "allOf": [ + { + "if": { + "properties": { + "enforcement": { + "const": "enforced" + } + } + }, + "then": { + "required": [ + "metering_source" + ], + "description": "A5: an enforced limit names its metering source." + } + } + ] + } + } + } + }, + "scheduling": { + "type": "object", + "additionalProperties": false, + "description": "Deterministic-authorization policy (RFC section 5), declared in the contract. Every field is optional: an absent field means the authorization core applies its shipped finite default (never unlimited); a plan may declare tighter or looser bounds.", + "properties": { + "starvation_threshold_events": { + "type": "integer", + "minimum": 1, + "description": "Journal-event count a ready-but-unselected task waits before the oldest-blocked-wait priority boost fires (A11; the clock is the journal, never the wall)." + }, + "max_adaptations_per_task": { + "type": "integer", + "minimum": 0, + "description": "Maximum authorized adaptations whose affected_tasks include one task; bounded adaptation, loop termination." + }, + "max_retries_per_gate": { + "type": "integer", + "minimum": 0, + "description": "Maximum authorized retry adaptations per acceptance criterion; blind retries are refused independently of this cap." + }, + "handoff": { + "type": "object", + "additionalProperties": false, + "description": "Explicit handoff conditions (RFC section 5): when a fresh context or a cross-host resume is required.", + "properties": { + "fresh_context": { + "type": "string", + "minLength": 1, + "description": "Condition under which the session must be replaced by a fresh context." + }, + "cross_host_resume": { + "type": "string", + "minLength": 1, + "description": "Condition under which the plan must resume on another host." + } + } + } + } + }, + "tasks": { + "type": "array", + "minItems": 1, + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "title", + "prerequisites", + "touched_surface", + "gate_intent" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "title": { + "type": "string", + "minLength": 1 + }, + "prerequisites": { + "type": "array", + "items": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "uniqueItems": true, + "description": "Stable task IDs whose outcomes must hold first. The semantic validator rejects dangling references and prerequisite cycles." + }, + "touched_surface": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, + "gate_intent": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "criterion", + "check" + ], + "properties": { + "criterion": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "check": { + "type": "string", + "minLength": 1 + } + } + }, + "description": "Selected gate intent: which acceptance criterion each declared gate serves." + }, + "parallel_safe": { + "type": "boolean", + "description": "Set by create (never inferred at execution): the task can run in a delegate without interleaving with sibling work - its touched surface does not overlap an in-progress sibling and it declares a bounded output. Absent means false." + } + } + } + }, + "autonomy": { + "type": "object", + "additionalProperties": false, + "description": "The plan's recorded authority for the loop. An absent block means every default: the human is the resolver, the lead is the only promptable pane, nothing is notified, no brain acts, the plan is not queued. Inside a present block every absent key keeps its own default: stall_budget absent = 3 (herdr-peers' MAX_PLAN_PROMPTS); promptable absent = the lead only; notify absent = no target; brain absent = false; queue absent = none. See spec/LOOP_ENGINEERING.md.", + "properties": { + "stall_budget": { + "type": "integer", + "minimum": 1, + "maximum": 10, + "description": "Loop prompts without progress before the plan is marked stalled. Absent = 3 (herdr-peers' MAX_PLAN_PROMPTS)." + }, + "promptable": { + "type": "array", + "minItems": 1, + "items": { + "type": "string", + "pattern": "^(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63}):[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}$" + }, + "description": "Pane addresses the loop may prompt, herdr-peers' exact form (a machine id never starts with '-'). Absent = the plan's lead only." + }, + "notify": { + "type": "array", + "minItems": 1, + "items": { + "enum": [ + "dailybot" + ] + }, + "description": "Notification targets. Absent = no target (the loop still records)." + }, + "brain": { + "type": "boolean", + "description": "May a brain act on this plan. Absent = false." + }, + "queue": { + "enum": [ + "prompt-lead", + "launch", + "none" + ], + "description": "How the plan may be started from the queue. Absent = none (not queued)." + } + } + } + }, + "$defs": { + "capability": { + "enum": [ + "gate_command_exec", + "fs_write_plan_scope", + "fs_write_repo_scope", + "git_operations", + "network_access", + "host_adapter_metering", + "agent_delegation", + "context_export", + "model_routing" + ], + "description": "Closed capability set (section 3.2 Permissions). gate_command_exec: run DECLARED gate commands through the core's runner. fs_write_plan_scope / fs_write_repo_scope: writes inside the plan folder / inside allowed repo paths. git_operations: commits and fingerprinting. network_access: outbound fetch to named dependencies. host_adapter_metering: read real provider meters through an adapter. agent_delegation: sibling-plan fan-out under section 9's declared file ownership. context_export: the section-4.3 durability export command. model_routing: switch model tiers mid-plan (section 8) - an authority GRANT only; switching additionally requires the host ability of the same name, so the default posture stays fixed-model. Names outside this set are unsupported capabilities and are refused." + } + }, + "title": "plan-contract v8" +} diff --git a/.agents/skills/deepworkplan/spec/schema/plan-snapshot-v8.schema.json b/.agents/skills/deepworkplan/spec/schema/plan-snapshot-v8.schema.json new file mode 100644 index 0000000..1c5312a --- /dev/null +++ b/.agents/skills/deepworkplan/spec/schema/plan-snapshot-v8.schema.json @@ -0,0 +1,361 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://deepworkplan.com/schema/plan-snapshot/v8.json", + "title": "DWP v8 plan snapshot (state.json projection)", + "description": "The deterministic snapshot projection of a v8 plan (spec/LOOP_ENGINEERING.md section 3): the plan-snapshot/v6 shape with the blocker wired. The deterministic projection: rebuilt only by shared/ledger.py (project) from contract + journal.ndjson, atomically (temp + rename + fsync). Every timestamp derives from event ts values, never the wall clock, so replaying the same journal bytes yields a byte-identical snapshot. New schema-URL generation per RFC 9.1: not a mutation of the v5 plan-state shapes. Task statuses are derived, never declared: pending (no task_start), completed (every gate_intent criterion satisfied in-window — the same zero-test predicate the scheduler selects by), blocked (an unresolved structured blocker holds the task; it wins over the others), else in_progress; a restart reopens the evidence window and the task derives in_progress again until fresh evidence lands.", + "type": "object", + "additionalProperties": false, + "required": [ + "schema", + "plan", + "contract_id", + "contract_revision", + "generated_by", + "updated_at", + "tasks", + "positions", + "resources", + "checkpoint", + "blocker" + ], + "properties": { + "schema": { + "const": "https://deepworkplan.com/schema/plan-snapshot/v8.json" + }, + "plan": { + "type": "string", + "minLength": 1, + "pattern": "^PLAN_[A-Za-z0-9_-]+$" + }, + "contract_id": { + "type": "string", + "pattern": "^[a-f0-9]{64}$" + }, + "contract_revision": { + "type": "integer", + "minimum": 1 + }, + "generated_by": { + "type": "string", + "minLength": 1 + }, + "updated_at": { + "type": "string", + "description": "The latest event ts the projection covers; empty before the first event." + }, + "tasks": { + "type": "array", + "items": { + "$ref": "#/$defs/task" + } + }, + "positions": { + "type": "object", + "description": "Latest journal seq per event type (provenance types excluded). A position the journal cannot support after a markdown-wins reconciliation is recorded regenerated, never fabricated.", + "additionalProperties": { + "$ref": "#/$defs/position" + } + }, + "resources": { + "type": "object", + "additionalProperties": false, + "required": [ + "limits", + "latest_samples" + ], + "properties": { + "limits": { + "type": "array", + "description": "The contract's declared resource envelope limits, carried verbatim (the contract schema owns their shape).", + "items": true + }, + "latest_samples": { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/sample" + } + } + } + }, + "checkpoint": { + "type": [ + "string", + "null" + ], + "description": "The latest open question an operator must answer; null when none is recorded." + }, + "blocker": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/$defs/blocker" + } + ], + "description": "The plan's active structured blocker, projected from the latest unresolved blocker raise (null when none). since is the first raise of the episode; resolver absent means human." + }, + "archives": { + "type": "array", + "description": "Journal roll archives beside the plan (nothing is ever deleted; snapshot-cited positions stay addressable).", + "items": { + "$ref": "#/$defs/archive" + } + } + }, + "$defs": { + "task": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "title", + "status", + "started_seq", + "criteria" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "title": { + "type": [ + "string", + "null" + ] + }, + "status": { + "enum": [ + "pending", + "in_progress", + "completed", + "blocked" + ], + "description": "Derived from the records: blocked (an unresolved blocker holds the task), pending (no task_start), completed (all gate_intent criteria satisfied in-window), in_progress otherwise." + }, + "started_seq": { + "type": [ + "integer", + "null" + ], + "minimum": 1, + "description": "The task_start event's journal position; null before the task starts." + }, + "criteria": { + "type": "array", + "items": { + "$ref": "#/$defs/criterion_state" + } + } + } + }, + "criterion_state": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "criterion", + "satisfied", + "via_seq", + "trust" + ], + "properties": { + "criterion": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "satisfied": { + "const": true + }, + "via_seq": { + "type": "integer", + "minimum": 1, + "description": "The in-window evidence event's journal position." + }, + "trust": { + "enum": [ + "observed", + "imported", + "asserted" + ] + }, + "evidence_path": { + "type": "string", + "description": "Recoverable pointer to the evidence log, relative to the plan directory." + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "criterion", + "satisfied" + ], + "properties": { + "criterion": { + "type": "string", + "pattern": "^AC-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "satisfied": { + "const": false + }, + "started_seq": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + }, + "stale_seqs": { + "type": "array", + "description": "Pre-start evidence events for this criterion: recorded history that can never satisfy the in-window rule.", + "items": { + "type": "integer", + "minimum": 1 + } + } + } + } + ] + }, + "position": { + "type": "object", + "additionalProperties": false, + "minProperties": 1, + "properties": { + "seq": { + "type": "integer", + "minimum": 1 + }, + "regenerated": { + "const": true, + "description": "The snapshot cites this position but the journal cannot support it (markdown-wins regeneration); ignored for roll bounding." + } + } + }, + "sample": { + "type": "object", + "additionalProperties": false, + "required": [ + "value", + "seq" + ], + "properties": { + "value": { + "description": "The sampled amount as recorded by the metering source; untyped because limit kinds differ." + }, + "seq": { + "type": "integer", + "minimum": 1 + }, + "trust": { + "enum": [ + "observed", + "imported", + "asserted" + ] + } + } + }, + "archive": { + "type": "object", + "additionalProperties": false, + "required": [ + "file", + "first_seq", + "last_seq" + ], + "properties": { + "file": { + "type": "string", + "pattern": "^journal-archive-[0-9]{6}-[0-9]{6}\\.ndjson$" + }, + "first_seq": { + "type": "integer", + "minimum": 1 + }, + "last_seq": { + "type": "integer", + "minimum": 1 + } + } + }, + "blocker": { + "type": "object", + "additionalProperties": false, + "required": [ + "task", + "reason", + "since", + "needs", + "class" + ], + "properties": { + "task": { + "type": "string", + "pattern": "^T-[a-z0-9]+(-[a-z0-9]+)*$" + }, + "reason": { + "type": "string", + "minLength": 1, + "maxLength": 1000 + }, + "since": { + "type": "string", + "description": "The ts of the raise that opened this blocker episode." + }, + "needs": { + "type": "string", + "minLength": 1, + "maxLength": 500, + "pattern": "^[^\\r\\n]*\\S[^\\r\\n]*$" + }, + "class": { + "enum": [ + "C1", + "C2", + "C3", + "C4", + "C5", + "C6", + "C7" + ] + }, + "resolver": { + "enum": [ + "lead", + "human" + ] + } + }, + "allOf": [ + { + "if": { + "properties": { + "resolver": { + "const": "lead" + } + }, + "required": [ + "resolver" + ] + }, + "then": { + "properties": { + "class": { + "enum": [ + "C3", + "C4", + "C7" + ] + } + } + } + } + ] + } + } +} diff --git a/.agents/skills/deepworkplan/status/SKILL.md b/.agents/skills/deepworkplan/status/SKILL.md index aae4a88..e4e4c9d 100644 --- a/.agents/skills/deepworkplan/status/SKILL.md +++ b/.agents/skills/deepworkplan/status/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-status description: Report Lite or Full Deep Work Plan status — format, approval, readiness, progress, checkpoint, blockers and Markdown/state consistency — without modifying anything. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob diff --git a/.agents/skills/deepworkplan/upgrade/SKILL.md b/.agents/skills/deepworkplan/upgrade/SKILL.md index 7006057..a01b98c 100644 --- a/.agents/skills/deepworkplan/upgrade/SKILL.md +++ b/.agents/skills/deepworkplan/upgrade/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-upgrade description: Check whether a newer DeepWorkPlan skill and DWP standard exists and — only after the developer explicitly accepts — install the latest published tag through the documented channel and re-run onboarding exactly as if https://deepworkplan.com/init.md were executed fresh, preserving every plan under .dwp/ and surfacing local adaptations instead of silently overwriting them. Use when the developer asks to upgrade, update, or refresh DWP in a repository that already has it installed. Do not use it to onboard a repo for the first time (that is the onboard sub-skill) or to migrate an old plan's shape (that is refine migrate, and plans are never migrated by an upgrade). -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob, Edit, Write @@ -77,7 +77,7 @@ versions relative to that directory. pre-release — is an equivalent alternative when the GitHub CLI is present.) 3. **Report, then stop.** State, in a few lines: installed skill version, latest published version, the standard each implements (the series are - 2.x, 4.x, 5.x and 6.x historical and 7.x current — `../spec/README.md`), + 2.x and 4.x historical, 5.x, 6.x and 7.x retained, 8.x current — `../spec/README.md`), and where the changelog lives (`https://github.com/DailybotHQ/deepworkplan-skill/blob/main/CHANGELOG.md`). If installed == latest, say the repository is current and **end here**. diff --git a/.agents/skills/deepworkplan/verify/SKILL.md b/.agents/skills/deepworkplan/verify/SKILL.md index 1424d37..8c787ea 100644 --- a/.agents/skills/deepworkplan/verify/SKILL.md +++ b/.agents/skills/deepworkplan/verify/SKILL.md @@ -1,7 +1,7 @@ --- name: deepworkplan-verify description: Verify that a repository is DeepWorkPlan-conformant (AI-first) and that its plans are well-formed, producing an objective pass/fail report. Use when the developer asks to verify, audit, or check conformance of a repo or a plan. -version: "7.12.2" +version: "8.0.0" documentation_url: https://deepworkplan.com user-invocable: true allowed-tools: Bash, Read, Grep, Glob @@ -58,8 +58,9 @@ top — the script verifies *structure*; you verify *substance*. Conformance asks whether a plan is well-formed; the compliance audit asks whether finished v6/v7 work followed the rules the pack already ships: -criteria closed on their declared evidence class, a completed Final Review, -declared controls and their verdicts (dirty-start voids counted), §5.1.4 +criteria closed on their declared evidence class, each unclosed criterion +named with the tasks whose gate intent owns it (an empty list when none +does), a completed Final Review, declared controls and their verdicts (dirty-start voids counted), §5.1.4 `control missing` observations, a verbatim request kept, and re-anchoring (reported unmeasured — execution leaves no record of it). It never writes. diff --git a/.agents/skills/deepworkplan/verify/compliance_audit.py b/.agents/skills/deepworkplan/verify/compliance_audit.py index 6c4798d..d525096 100644 --- a/.agents/skills/deepworkplan/verify/compliance_audit.py +++ b/.agents/skills/deepworkplan/verify/compliance_audit.py @@ -10,6 +10,8 @@ Per plan it reports: * criteria closed on a declared evidence class, and criteria closed outside it; + * each unclosed criterion's owning tasks (every task whose gate_intent + names it; an empty list when none does); * whether a Final Review task completed; * declared controls and their latest control-pair verdicts, including dirty-start `control_unavailable` voids (D3-3); @@ -89,10 +91,14 @@ def audit_plan(plan_dir): statuses = {t.get('id'): t.get('status') for t in snapshot.get('tasks', [])} criteria = contract.get('acceptance', {}).get('criteria', []) - owner = {} + # Every task whose gate_intent names a criterion, in contract order: a + # criterion several tasks can close names all of them. + owners = {} for task in contract.get('tasks', []): for intent in task.get('gate_intent', []): - owner[intent.get('criterion')] = task.get('id') + names = owners.setdefault(intent.get('criterion'), []) + if task.get('id') not in names: + names.append(task.get('id')) # "Closed" is decided exactly as the ledger decides it at completion # (ledger.criterion_states: in-window gate runs, amendment-invalidated @@ -168,6 +174,9 @@ def audit_plan(plan_dir): 'criteria_closed_on_declared_class': closed_ok, 'criteria_closed_outside_declared_class': closed_outside, 'criteria_unclosed': unclosed, + # Who owes each unclosed criterion: every task whose gate_intent + # names it, or an empty list when none does (nothing can close it). + 'criteria_unclosed_owners': {c: owners.get(c, []) for c in unclosed}, 'final_review': final_review, 'controls_declared': controlled, 'control_verdicts': {c: verdicts.get(c, 'no pair recorded') diff --git a/.agents/skills/deepworkplan/verify/conformance.sh b/.agents/skills/deepworkplan/verify/conformance.sh index 6af3b0a..47f53bf 100755 --- a/.agents/skills/deepworkplan/verify/conformance.sh +++ b/.agents/skills/deepworkplan/verify/conformance.sh @@ -90,14 +90,14 @@ warn() { # The newest repository provenance this checker accepts. Plans are judged by # generation inside plan_contract.py (v6/v7 records, v5 and older shapes). -SUPPORTED_SPEC="7.0.0" +SUPPORTED_SPEC="8.0.0" # The standard's released series: 2.x and 4.x are historical (repositories and # plans onboarded before each jump stay valid, DWP_SPECIFICATION.md §6.5), 5.x -# and 6.x are retained, and 7.x is current. There is no 3.x standard — the v3 launch was a product release, +# 6.x and 7.x are retained, and 8.x is current. There is no 3.x standard — the v3 launch was a product release, # not a standard bump (the series are mapped in DWP_SPECIFICATION.md "Status"). standard_series_ok() { # $1 = declared version; bash 3.2 safe - case "${1%%.*}" in 2|4|5|6|7) return 0 ;; *) return 1 ;; esac + case "${1%%.*}" in 2|4|5|6|7|8) return 0 ;; *) return 1 ;; esac } version_le() { @@ -219,7 +219,7 @@ check_repo_standard() { return 0 fi if ! standard_series_ok "$declared"; then - fail "AGENTS.md declares DWP standard $declared, which is not a DWP standard (the series are 2.x, 4.x, 5.x and 6.x historical and 7.x current; there is no 3.x) — correct the provenance line" + fail "AGENTS.md declares DWP standard $declared, which is not a DWP standard (the series are 2.x and 4.x historical, 5.x, 6.x and 7.x retained, 8.x current; there is no 3.x) — correct the provenance line" return 0 fi pass "AGENTS.md declares DWP standard $declared" diff --git a/.agents/skills/deepworkplan/verify/plan_contract.py b/.agents/skills/deepworkplan/verify/plan_contract.py index d1ae700..9c18150 100644 --- a/.agents/skills/deepworkplan/verify/plan_contract.py +++ b/.agents/skills/deepworkplan/verify/plan_contract.py @@ -40,7 +40,10 @@ MANIFEST_V6 = 'https://deepworkplan.com/schema/plan-manifest/v6.json' MANIFEST_V7 = 'https://deepworkplan.com/schema/plan-manifest/v7.json' RECORD_GENERATIONS = {MANIFEST_V6: 'v6', MANIFEST_V7: 'v7'} -SNAPSHOT_V6 = 'https://deepworkplan.com/schema/plan-snapshot/v6.json' +# The snapshot URL follows the live contract's generation: v6/v7 plans +# project into plan-snapshot/v6, v8 plans into plan-snapshot/v8 +# (spec/LOOP_ENGINEERING.md section 3), so the state check compares against +# the ledger's own projection, not a constant. # The standard's released series: 2.x and 4.x are historical (plans authored # before each jump stay valid, §6.5), 5.x is this checker's ceiling. There is no 3.x standard # — the v3 launch was a product release, not a standard bump. @@ -273,7 +276,12 @@ def records(plan, documents, report): except ledger.LedgerError as exc: return report.bad(f'contract: {exc}') found = contract_v6.contract_generation(rec.contract) - if not report.verdict(found == generation, + # A v8 contract lives in the v7 manifest line (spec/LOOP_ENGINEERING.md + # section 5): v8 changes the contract, journal and snapshot generations, + # never the manifest shape. The journal check below holds every event to + # the live contract's generation (a v8 plan's events carry + # journal-event/v8; a mixed journal is refused). + if not report.verdict(found == generation or (generation, found) == ('v7', 'v8'), f'{generation} manifest pairs with a {generation} contract', f'manifest.json is {generation} but the live contract is {found} — a ' 'torn pair this checker refuses to guess about; resolve the folder by hand'): @@ -327,9 +335,9 @@ def records(plan, documents, report): state = documents.get('state') if state is None: report.note('no state.json yet — run ledger.py project (the snapshot is derived)') - elif state.get('schema') != SNAPSHOT_V6: - report.bad(f'state.json is {state.get("schema")!r}, not the derived plan snapshot — ' - 'regenerate it with ledger.py project, never by hand') + elif state.get('schema') != snapshot['schema']: + report.bad(f'state.json is {state.get("schema")!r}, not the derived plan snapshot ' + f'({snapshot["schema"]}) — regenerate it with ledger.py project, never by hand') elif (plan / 'state.json').read_bytes() == ledger.snapshot_bytes(snapshot).encode('utf-8'): report.ok('state.json agrees with the journal (byte-identical projection)') else: @@ -338,6 +346,10 @@ def records(plan, documents, report): tasks = snapshot['tasks'] done = sum(t['status'] == 'completed' for t in tasks) report.ok(f'{done}/{len(tasks)} tasks completed (derived from gate evidence)') + blocker = snapshot.get('blocker') + if isinstance(blocker, dict): + report.note(f'blocked: {blocker.get("task")} ({blocker.get("class")}, resolver ' + f'{blocker.get("resolver") or "human"}) needs: {blocker.get("needs")}') if tasks and 'final review' not in str(tasks[-1].get('title') or '').lower(): report.note('the last contract task is not the Final Review (DWP_SPECIFICATION §6.1)') if tasks and done == len(tasks): diff --git a/.agents/skills/herdr-peers/SKILL.md b/.agents/skills/herdr-peers/SKILL.md index 39f77ad..bc64d33 100644 --- a/.agents/skills/herdr-peers/SKILL.md +++ b/.agents/skills/herdr-peers/SKILL.md @@ -1,11 +1,11 @@ --- name: herdr-peers -description: "Ask another coding agent in a Herdr pane — on this machine or another one — and get exactly one authorized reply back, with a loop guard, depth limit 1, a fan-out cap and a record of every delegation; send one-way notices; keep a plan's lead with epochs and succession; lead a multi-agent debate to decide, research the state of the art, stress-test or verify (rounds, angles, red teams, counted ballots and claims, a panel seated from idle panes or agentkit accounts); run autopilot, a human-started daemon that accepts the recommended option for every waiting agent. Use only when the user mentions Herdr, peers, autopilot, a debate, panel or research by several agents, or another agent, pane or machine, or when a plan you are executing delegates a task through Herdr. Do not use merely because parallel work could help. Requires HERDR_ENV=1 and Herdr's official herdr skill." -version: "2.0.0" +description: "Ask another coding agent in a Herdr pane — on this machine or another one — and get exactly one authorized reply back, with a loop guard, depth limit 1, a fan-out cap and a record of every delegation; send one-way notices; keep a plan's lead with epochs and succession; lead a multi-agent debate to decide, research the state of the art, stress-test or verify (rounds, angles, red teams, counted ballots and claims, a panel seated from idle panes or agentkit accounts); run autopilot, a human-started daemon that accepts the recommended option for every waiting agent, keeps every open plan running (a plan queue, a brain for what rules cannot decide, a lane appointed when a lead and its successors are gone). Use only when the user mentions Herdr, peers, autopilot, a debate, panel or research by several agents, or another agent, pane or machine, or when a plan you are executing delegates a task through Herdr. Do not use merely because parallel work could help. Requires HERDR_ENV=1 and Herdr's official herdr skill." +version: "2.1.0" license: MIT allowed-tools: Bash, Read metadata: - version: "2.0.0" + version: "2.1.0" protocol: 2 --- @@ -19,6 +19,9 @@ something with a **notice** that is never answered. It also keeps who approval. It adds a message protocol on top of Herdr; it does not replace Herdr's own skill. + +Upgrading from 1.x: `docs/MIGRATING.md` in the herdr-peers repository (protocol 2 is used only by granted lead records; what to restart; turning on appointment and the brain). + ## 0. Requirements - **Herdr's official skill** (`herdrdev/herdr`, skill `herdr`) is the authority @@ -70,7 +73,7 @@ opinion nobody asked for, or to avoid doing the work yourself. | `status <machine>:<pane> [--json]` | A peer lane's state (`working`, `idle`, `blocked`, `done`, `unknown`, `no_agent`, `unreachable`), agent kind, and the class of a waiting screen with its documented next step. Read-only: never sends keys. | | `lanes [--json] [--all] [--plan P]` | One row per peer you asked or your lead record lists: agent, vendor, profile, live state, screen class (incl. `usage_limit`), open asks, last reported capacity, last ask. `--json` prints the `herdr-peers/lanes-v1` contract with `plan`, `lead` and `epoch`. | | `lead claim --plan P [--succession A,B] [--lanes A,B]` | Become the lead of plan P (epoch 1, or +1 after a release), or refresh your record (`--lanes` replaces the list, empty clears, omitted preserves); sends a lead notice to every lane and successor. | -| `lead show [--plan P] [--json] [--pane ID]` | The plan's lead record (`herdr-peers/lead-v1`: plan, lead, epoch, succession, lanes, repo_root, updated_at); without a plan, every record. | +| `lead show [--plan P] [--json] [--pane ID]` | The plan's lead record (`herdr-peers/lead-v1`: plan, lead, epoch, succession, lanes, repo_root, updated_at; `lead-v2` adds `appoint`, the human's appointment grant, and `via` on an appointment epoch — protocol 2); without a plan, every record and its appointment count. | | `lead handover <machine>:<pane> --plan P [--succession …] [--lanes …]` | The current lead hands over (epoch+1) and stops leading. | | `lead takeover --plan P [--reason R]` | The first reachable successor takes over a lead that is gone (unreachable, no agent, usage limit) — or, with a recorded `--reason`, one whose asks timed out twice (epoch+1). | | `lead release --plan P` | The current lead leaves the plan without a lead (epoch+1). | @@ -78,10 +81,11 @@ opinion nobody asked for, or to avoid doing the work yourself. | `lead takeover --plan P --as-lane` | A lane of a granted plan takes the lead when the lead, every successor and every earlier lane are gone, probed twice; never with `--reason`; at most two appointments per plan. | | `lead verify --plan P` | **Before any merge, tag or release.** Are you still the lead, here and on the plan's other machines (read-only reports)? Exit 4 when not, or when any machine shows a higher epoch or an earlier lead at the same epoch; exit 5 when a machine could not be reached (unless `--allow-unreached`, recorded). Writes nothing remotely. | | `cancel <id> [--reason R]` | Closes an open ask (yours, or one you decline). | -| `autopilot [run\|start\|stop\|status\|logs]` | **Started by a human only** ([autopilot.md](autopilot.md)). `start` (alias `on`) runs it in the background, detached from the pane, logging to `autopilot.out` in the state directory; `stop` (alias `off`) stops it and waits; `status` shows whether it runs, since when, how, its options and last ten actions; `logs [--lines N] [-f]` prints or follows the background log; no verb runs it in the foreground. Watches every agent on every enabled machine and accepts the option that lets a waiting one go on — a question (the recommended option, then the pre-selected one, then the first), a tool approval, plan approval, folder trust, an update prompt (skipped); follows a dialog of several steps to its end; tells an agent that stopped by asking in prose to continue; retries a pane at its usage limit every 30 minutes. Never touches a login or Claude's bypass acknowledgement, never picks a refusal, free text or a row that widens permissions, never keys a pane without a recognised menu or with a human draft on its input line. Options: `--dry-run`, `--once`, `--passes N` (foreground only), `--interval S` (default 60, minimum 15), `--exclude <machine>:<pane>`, `--scope`, `--no-nudge`, `--catch-up`. One per server; records every action. With `--loop` it also keeps every open plan running: each enabled machine reports the plans that have a lead record, the idle lead of a plan that is not finished gets one fixed prompt to continue it (after 5 unchanged minutes, never while its lanes work or it awaits a reply), a blocked plan is left, three prompts without progress stop it (`plan_stalled`), and a lead that is gone has its first reachable successor asked to take over; `--notify "<command>"` runs a command (no shell) with a `plan-event-v1` object when a plan stalls, is blocked, loses its lead or completes. With `--loop --brain` it also launches and keeps a dedicated decision agent (ask mode, the first kind of `--brain-kinds` with quota via coding-agents-kit 1.3.0+, `--brain-model kind=model`), asks it only what its rules cannot decide, and acts only on one action from a closed list, answered with `autopilot answer <question> <action>` from the brain's own pane ([autopilot.md](autopilot.md) §6). With `--loop` it also starts the next approved plan of a repository's queue (`queue.json` beside its plans, written by the plan tool, read only) by one fixed prompt to its lead ([autopilot.md](autopilot.md) §5.4). | +| `autopilot [run\|start\|stop\|status\|logs]` | **Started by a human only** ([autopilot.md](autopilot.md)). `start` (alias `on`) runs it in the background, detached from the pane, logging to `autopilot.out` in the state directory; `stop` (alias `off`) stops it and waits; `status` shows whether it runs, since when, how, its options and last ten actions; `logs [--lines N] [-f]` prints or follows the background log; no verb runs it in the foreground. Watches every agent on every enabled machine and accepts the option that lets a waiting one go on — a question (the recommended option, then the pre-selected one, then the first), a tool approval, plan approval, folder trust, an update prompt (skipped); follows a dialog of several steps to its end; tells an agent that stopped by asking in prose to continue; retries a pane at its usage limit every 30 minutes. Never touches a login or Claude's bypass acknowledgement, never picks a refusal, free text or a row that widens permissions, never keys a pane without a recognised menu or with a human draft on its input line. Options: `--dry-run`, `--once`, `--passes N` (foreground only), `--interval S` (default 60, minimum 15), `--exclude <machine>:<pane>`, `--scope`, `--no-nudge`, `--catch-up`. One per server; records every action. With `--loop` it also keeps every open plan running: each enabled machine reports the plans that have a lead record, the idle lead of a plan that is not finished gets one fixed prompt to continue it (after 5 unchanged minutes, never while its lanes work or it awaits a reply), a blocked plan is left, three prompts without progress stop it (`plan_stalled`), and a lead that is gone has its first reachable successor asked to take over; `--notify "<command>"` runs a command (no shell) with a `plan-event-v1` object when a plan stalls, is blocked, loses its lead or completes. With `--loop --brain` it also launches and keeps a dedicated decision agent (ask mode, a Claude account with quota by default via coding-agents-kit 1.3.0+ (1.5.0+ recommended), `--brain-kinds` for others, `--brain-model kind=model`), asks it only what its rules cannot decide, and acts only on one action from a closed list, answered with `autopilot answer <question> <action>` from the brain's own pane ([autopilot.md](autopilot.md) §6). With `--loop --appoint` (on the human's word) a plan whose lead record carries the appointment grant and whose lead and every successor have been gone 15 minutes, with no progress, gets its first live lane asked to take the lead (`lead takeover --as-lane`; [autopilot.md](autopilot.md) §7). With `--loop` it also starts the next approved plan of a repository's queue (`queue.json` beside its plans, written by the plan tool, read only) by one fixed prompt to its lead ([autopilot.md](autopilot.md) §5.4). | +| `autopilot answer <question> <action>` | **The brain's own verb, for the brain only** — run in the brain's pane, under the key file the daemon names; the daemon checks it and acts only on an allowed action. Never run it as a person or another agent ([autopilot.md](autopilot.md) §6.2). | | `plans [--json]` | The plans led on this machine (`herdr-peers/plans-v1`): lead, epoch, succession, lanes, class (`open`, `blocked`, `completed`, `unreadable`), progress digest. Read-only; works outside a Herdr pane. | | `fleet [--json]` | The map the autopilot loop keeps (`herdr-peers/fleet-v1`): every machine, its agents with repository and branch, the plans and each agent's role. Read-only, from this machine's copy, with its age; exit `7` without one, `5` when stale. Works outside a pane. | -| `fleet ui [--group plan\|repo\|machine] [--snapshot] [--width N]` | A live terminal watcher of that map (read-only): a header with how old the picture is ("updated 3 min ago", STALE past 15 minutes) and counts by state; agents grouped by plan (lead ★, lanes ·, successors ↳, the plan's progress and current task; plans that need the human first), with the agents working outside plans and those doing nothing as their own groups — or by repository or machine. Enter or a click opens a plan (progress, current task, its tasks, blocker, the summary from its `PROGRESS.md`) or an agent (its plans, its live screen every 2 s; `f` focuses its pane). `--snapshot`, or no terminal, prints the view once as text. | +| `fleet ui [--group plan\|repo\|machine\|queue] [--filter attention\|active\|waiting\|done\|all] [--snapshot] [--width N]` | A live terminal watcher of that map (read-only): a header with how old the picture is ("updated 3 min ago", STALE past 15 minutes) and counts by state; agents grouped by plan (lead ★, lanes ·, successors ↳, the plan's progress and current task; plans that need the human first), with the agents working outside plans and those doing nothing as their own groups — or by repository, machine or queue. A second row of views, the same in every grouping, each with a live count: Attention (what you can act on now: no lead and blocked first, then stalled, then no movement for 24 h; unreachable agents), Active (moving), Waiting (queued or free), Done, All (unreadable plans last, each with its reason); the default is Attention plus Active; `←→ [ ] 1-5` or a click pick one, kept per grouping. Enter or a click opens a plan (progress, current task, its tasks, blocker, the summary from its `PROGRESS.md`) or an agent (its plans, its live screen every 2 s; `f` focuses its pane). `--snapshot`, or no terminal, prints the view once as text. | | `debate tally\|claims\|anon\|filings\|panel` | A debate lead's tools ([debate.md](debate.md)) for every purpose — decide, research, stress-test, verify, generate: `tally FILE|DIR` counts a `herdr-peers/ballots-v1` file or a directory of per-pane `*.ballot.json` (Borda, first places, pairwise, Condorcet winner and loser, item verdicts; the lead never votes); `claims DIR…` merges lanes' `herdr-peers/claims-v1` ledgers into established / agreed / contested / partial / single / unsupported / disputed / refuted claims with coverage — a quorum count, not a verification (`--rounds` merges rounds in order, `--map` merges synonyms, `--anonymous` blinds lanes, angles, claim text and sources); `anon SRC DST --key K` copies filings to `Filing_A.md`… with identities redacted, in an order only the key can rebuild, refusing a filing that carries a secret; `filings DIR --expect a,b` lists missing or short filings (exit 5 when incomplete); `panel --seats N` proposes a panel and runs nothing: seats round-robin over model providers, most quota first (idle panes and `ak pick` accounts ranked together by known headroom), with the provider mix and two successors for the lead (another provider first on a tie). Every debate verb accepts `--pane`. | `ask`, `notify`, `reply`, `check`, `wait`, `status`, `lanes`, `cancel` and the `lead` @@ -109,6 +113,12 @@ Environment (all optional): | `HERDR_PEERS_LOG` | Shared log file override (default is machine-scoped XDG state: `$XDG_STATE_HOME/herdr-peers/<server>/log.ndjson`). Records are filtered to the current server; use `log --all-machines` to inspect a shared override. | | `HERDR_PEERS_PYTHON` | Python interpreter for the helper (default `python3`). | | `HERDR_PEERS_BRIEFER` | The address that launched or briefed this pane (set by the launcher): the only sender whose *first* lead notice for a plan is accepted (a peer whose ask this pane recorded counts too). | +| `HERDR_PEERS_AUTOPILOT_NOTIFY_TIMEOUT` | Seconds one `--notify` command may run (default 20; 1–60). | +| `HERDR_PEERS_AUTOPILOT_NOTIFY_BUDGET` | Seconds all `--notify` commands of one pass may run together (default 20; 1–120); one command's timeout never widens it. | +| `HERDR_PEERS_AUTOPILOT_APPOINT_GRACE` | Seconds the lead and every successor must be gone, with the plan's progress frozen, before `--appoint` asks a lane (default 900; 0–86400). | +| `HERDR_PEERS_APPOINT_PROBE_GAP` | Seconds between the two probes `lead takeover --as-lane` makes of every member (default 60; 0–600; 0 is for tests only — it collapses the two probes into one). | +| `HERDR_PEERS_UI_SERVER` | Set by the helper for `fleet ui` (this server's key, so the watcher reaches `local` panes only on the daemon's own server) — never by hand. | +| `HERDR_PEERS_BRAIN_KEY_FILE` | Set by the daemon in the brain's environment (the path of its private answer-key file) — never by hand. | | `DWP_PLAN`, `DWP_TASK` | Plan directory or id: ids resolve under the git checkout root using the `.dwp`, `plans`, `<id>` path components when that directory exists. Records mirror to `analysis_results/delegations.ndjson`, tagged with the task. A directory basename or the id itself is the default `--plan` (including `repo/id`). Missing directories warn and skip the mirror. | Exit codes: `0` ok · `1` Herdr error · `2` usage · `3` protocol refusal — @@ -245,6 +255,16 @@ named here) and `Read`. and of each machine that answered; and, with `--notify`, the command the human named ([autopilot.md](autopilot.md) §5, §8). +- **2.0**: the brain gets one workspace of the daemon's own whose shell starts + in a fresh, empty, private directory (never the state directory; removed + when the brain closes) and one answer-key file (`0600`, created + exclusively, never through a symlink, removed on close) whose path alone + is in the brain's environment. Lead appointment writes only this server's + lead record (`lead takeover --as-lane`) and the lead notices it sends; + `lead verify` writes only a local record. The plan queue (the + plan tool's `queue.json` beside its plans) is the plan tool's: the daemon only reads it and never + writes it. Nothing is written to git or to another machine. + **Reads only:** `plans`, `fleet` and `fleet ui` read lead records, plan state files (and a plan's `PROGRESS.md`, contract or manifest title) and the stored map; `fleet ui` also reads an open agent's screen (`herdr pane read`) and, on diff --git a/.agents/skills/herdr-peers/autopilot.md b/.agents/skills/herdr-peers/autopilot.md index 8cf17f6..6e15490 100644 --- a/.agents/skills/herdr-peers/autopilot.md +++ b/.agents/skills/herdr-peers/autopilot.md @@ -156,6 +156,8 @@ one of those, it moves to the first row that is not. | A usage limit (the CLI's own banner; a `429` in a command's output is not one) | Leaves it; every 30 minutes accepts the option shown (if any) and asks the agent to continue its pending plan — for at most a day, never over a draft on the input line, and not with `--no-nudge`. | | A login, a sign-in, an API-key or device-code prompt | **Never touched.** A human signs in. | | Claude's bypass-permissions acknowledgement | **Never touched.** The developer accepts it once per profile. | +| A permission or plan approval where every row refuses or widens permissions | **Denied, never left blocked** (a change in 2.1.0: it used to wait for a human): its first refusal row (`No`, `Deny`, `Cancel` — never a row naming exit or quit), else `esc` — except on Codex, where `esc` aborts the whole turn, so the dialog is left. Recorded `denied`. Once the agent is idle again it is told once, with a fixed prompt, to continue another way within its plan's gates or record a blocker. | +| An agent's own question whose rows all refuse or open free text | Left waiting for the human: it is a decision about the work, never answered "No" by the daemon (no prose nudge either: nudges go only to idle panes). | | A blocked pane with no menu it recognises | Left, and recorded as `unknown`. | Verified on real panes of Claude Code, Codex, Cursor, Grok, Pi and @@ -181,7 +183,9 @@ selected; otherwise it is left alone. - Touch its own pane, an excluded pane, or a machine outside the scope. - Read, store or print screen text. The record holds the screen class, the option number and the keys. -- Send `esc`: on a working agent it interrupts the turn. +- Send `esc` to a working agent: it would interrupt the turn. `esc` goes only + to a blocked dialog being denied, when it has no refusal row or the + refusal row did not take. ## 5. The plan loop (`--loop`) @@ -312,14 +316,23 @@ starts next or why it cannot; a plan's own row shows its place (`queue 2/3`). ## 6. The brain (`--brain`) ```bash -herdr-peers autopilot start --loop --brain # brain on claude, then codex, then grok -herdr-peers autopilot start --loop --brain --brain-kinds codex,claude --brain-model claude=sonnet +herdr-peers autopilot start --loop --brain # a Claude brain (the default) +herdr-peers autopilot start --loop --brain --brain-model claude=sonnet ``` The rules of §5 decide almost everything. For the few cases they cannot, the daemon keeps a **brain**: one dedicated agent it launches itself, asks, and obeys only within a closed list of actions. Nothing is asked of you to set it up beyond the flag; it needs coding-agents-kit 1.3.0 or later (`ak`). +The default kind is Claude only: it is, for now, the only kind whose answer +the daemon approves (§6.2), so a brain of another kind would only spend the +launch cap. `--brain-kinds` can still name others, in priority order. +**coding-agents-kit before 1.5.0** does not pass Claude's own ask flag, so a +profile whose default is auto mode starts in auto mode even through `ak +--ask`; the daemon sees it, retires that brain (`why=permission_mode +hint=upgrade_coding_agents_kit`), excludes the profile and tells you — +fail-closed, but it spends a launch. Upgrade the kit (`ak update`), or give +the profile an ask-mode default. **Fail-closed:** with `--brain`, a missing `ak` or one older than 1.3.0 makes the daemon refuse to start at all, with a message naming the version it needs — it never runs a brainless daemon you asked to have a brain. @@ -334,7 +347,10 @@ Start it without `--brain` to run without one. that qualifies, `launch.permissions == ask`. The line to type is `ak`'s own argv, every element matched against its pattern, the resolved path of the `ak` the daemon ran first, and only `--ask` and `--trust-cwd` added — never - an autonomy or bypass flag. + an autonomy or bypass flag. coding-agents-kit 1.5.0 ends an ask-mode argv + with one `--ask` of its own: exactly one, as the last element, is accepted + and dropped (the daemon adds `--ask` once); an `--ask` anywhere else, a + CLI's own permission flags and anything after `--` are refused. 3. The account is leased (`ak lease … --purpose brain`, renewed every two hours) so no lead or second daemon books it. 4. The daemon creates a workspace of its own, `autopilot brain`, whose @@ -371,14 +387,17 @@ it marks it so the brain is replaced on the next pass; the brain is never nudged in prose and never treated as a plan's lead. On `autopilot stop` its lease is released and its workspace closed. The fleet map and `fleet ui` show it: state, account, -questions in the last hour and its last decision. +questions in the last hour and its last decision; when a brain was retired, +why (`gone`, `usage_limit`, `start_timeout`, `permission_mode`) and which +profiles are excluded. Each retirement is recorded with `why=`, and +`autopilot status` prints the brain's line. ### 6.2 What it is asked, and what it may answer | Case | Allowed actions | Default (no valid answer in 3 minutes) | | --- | --- | --- | | A plan is stalled (three prompts without progress) | `nudge_once_more` (one more prompt to its lead, once per plan), `notify_human`, `leave` | `leave` | -| A plan is blocked, its state records the blocker as one its lead may resolve (`"resolver": "lead"` in the blocker record — a field the plan writes, not prose), and the blocker names no escalation class and no sensitive subject (credential, login, consent, payment, a push to main, a merge, a release, a deletion, a secret, production — in English and Spanish) | `ask_lead_to_resolve` (one fixed prompt asking the lead to resolve it within its recorded authority), `notify_human`, `leave` | `leave` | +| A plan is blocked, its state records the blocker as one its lead may resolve (`"resolver": "lead"` in the blocker record — a field the plan writes, not prose), its class is none or one a lead may handle (C3, C4, C7 — never C1 approval, C2 consent or login, C5 damage, C6 terms, nor a class outside C1–C7; an explicit `class` in the blocker record, as pack 8.0.0's plan-snapshot/v8 always writes, wins over a class named in its prose), and it names no sensitive subject (credential, login, consent, payment, a push to main, a merge, a release, a deletion, a secret, production — in English and Spanish) | `ask_lead_to_resolve` (one fixed prompt asking the lead to resolve it within its recorded authority), `notify_human`, `leave` | `leave` | | An agent waits at a screen autopilot does not recognise | `leave`, `notify_human` | `leave` | The question is one fixed prompt: the case, the plan and machine, the @@ -408,8 +427,16 @@ the lines between the two rules right above "Do you want to proceed?" — is exactly one line, `herdr-peers autopilot answer q-<12 hex> <word>`, by name and nothing else, with "Yes" as its first option. Any other layout, any other kind of agent (until it has its own verified fixture), any extra or -wrapped line, any path, refuses: the approval is left, recorded -(`brain_permission_refused`) and you are told once. For now that makes +wrapped line, any path, is **denied, never left waiting**: the +dialog's refusal row (else `esc`; never Yes, a widening row or auto mode), +recorded `brain_permission_denied`. Once idle, the brain is reminded once, +with a fixed prompt, that the only command it may run is `herdr-peers +autopilot answer <qid> <action>` and that the question carries all it +needs. Three denials in an hour retire it as misbehaving (`brain_replaced +why=misbehaving`), and a replacement is launched within the hourly cap. Its +brief says so up front: one command, nothing else approved. A Codex brain +whose dialog has no refusal row is left blocked, since `esc` would abort its +turn — one more reason the default brain kind is Claude. For now that makes Claude the only kind whose brain can answer; others are launched but their answers are never approved. An injected brain can still choose any allowed action for an open question — that is the @@ -532,32 +559,83 @@ written. Above 2 MB the map drops plan details first and records ``` ◉ herdr-peers fleet updated 40 s ago 54 agents · 14 machines (13 answering) ● 8 working ◆ 1 waiting ○ 45 idle ? 0 unknown │ plans: 1 need you · 5 running · 14 done - p Plans r Repos m Machines + p Plans r Repos m Machines u Queues + 1 Attention 2 · 2 Active 5 · 3 Waiting 3 · 4 Done 14 · 5 All 24 needs you + moving ←→ 1-5 ────────────────────────────────────────────────────────────────────────────────────────────────── ▌ STALLED PLAN_009_billing Billing v2 ████░░░░░░░░ 12/37 32% API · WS brain ▶ now: Webhook retries ★ ○ claude idle 12m w2:p1 app @feature/billing API · WS brain Billing lead +▌ OPEN PLAN_014_search Search index ██████░░░░░░ 9/18 50% Mac + ◷ no movement for 2d 4h ▌ OPEN PLAN_001_prototypes Rebuild all of v4 ███████░░░░░ 56/97 57% Mac ★ ● claude working 3m wG:p16 protoyard @dev Mac Protoyard lead · ○ codex done wG:p20 protoyard @dev Mac Judge the prototypes -▌ ○ Doing nothing — free to take work (31) - ○ codex idle w4:p1 open-source Mac Air ``` +### The views: one facet model in every grouping + +Under the grouping tabs, a second row filters what each grouping shows. The +same five views exist everywhere, so there is one thing to learn: does it +need me, is it moving, is it waiting, is it done. + +| View | Plans | Agents (by repository or machine) | Queue items | +| --- | --- | --- | --- | +| **Attention** | something you can act on now: blocked; situation `plan_stalled`, `plan_no_lead`, `plan_blocked` or a moved lead; or open with **no movement for 24 h** (its `state.json` unchanged, shown as `◷ no movement for 2d 4h`) | waiting at a question or approval, a state the map could not read, and (by machine) a machine that did not answer | queued with a reason that blocks it (`no lead named`, `not approved`, …) | +| **Active** | open and moving | working | started | +| **Waiting** | queued, not started (also a queued plan with no lead record yet, as `QUEUED`) | free (idle or done) | queued: ready, or waiting its turn (`waiting for …`, `another plan …`) | +| **Done** | completed | — an agent is never done (always empty) | done or skipped | +| **All** | everything, unreadable plans last | everything | everything | + +- **The default is Attention and Active together** — what needs you and + what is moving. It never opens on Done. +- **Attention means you can act on it now.** Inside it: NO LEAD and blocked + plans first, then the daemon's other judgments (stalled, a moved lead), + then the plans with no movement; each sorted by progress (nearest to done + first) or by how long they have been still (longest first). +- **Unreadable plans are not Attention.** They show only under All, as a + dimmed group at the very end, each saying why when its machine's report + knows (`unreadable_reason`): no `state.json` where its lead record points, + a `state.json` that does not parse, or a shape this helper does not read + (an older or newer plan generation). Attention shows one quiet line for + them: `14 unreadable plans: see All (5)`. +- Every view shows a live count: `Attention 2 · Active 5 · Waiting 3 · Done + 14`. Plans count plans (and queued plans not yet on the map); repositories + and machines count agents (by machine, an unreachable machine counts once, + as Attention); queues count items (an invalid queue file counts once, as + Attention). Unreadable plans count under All only. Only Attention takes + the alert colour, and only when it holds something. A narrow terminal + shows `A2 Ac5 W3 D14 All24`. +- The header's counts row degrades the same way: the brain's details go + first, then the agent states compact (`●7 ◆0 ○35 ?0`), then the brain; the + plans summary (`3 need you · 1 running · 15 done`) is never cut. +- `←` `→` or `[` `]` cycle the views (the default, then each one); `1`–`5` + jump to one; a click on the row picks it. The view combines with the + search (`/`), and each grouping keeps its own view for the session. +- An empty view says why and where the rest is: `Nothing needs you · 7 + plans moving`. +- In the Plans grouping, the agents outside any plan follow their own + facet: the working ones under Active, the free ones under Waiting. +- `fleet ui --snapshot --filter attention|active|waiting|done|all` prints + one view as text; `--filter` also picks the view the live watcher opens + on, and `--group plan|repo|machine|queue` the grouping. + +The stale threshold reads `state_updated_at`, and the unreadable reason +`unreadable_reason`; the map carries both since 2.1.0 (optional fields: a +map written by an older daemon has none, its open plans are never called +stale, and its unreadable plans say the report does not say why). Each classification is a pure +function (`plan_facet`, `agent_facet`, `queue_item_facet`), the counts are +built when the map, the grouping, the view or the search changes — never +per frame — and nothing new is read from disk or from Herdr. + It redraws by itself when the map changes, keeps your selection, and ticks the age every second (amber after 3 minutes, STALE after 15). Keys: `p`, `r`, -`m` group by plan, repository or machine; `/` filters; `↑↓` and the mouse -move; Enter or a click opens a plan or an agent; `f` focuses the agent's -pane; `?` help; `q` quit. It only reads: the map, and an open agent's screen -(at most every 2 s, on the machine where that pane lives, when this -machine's Herdr can reach it). `--snapshot` prints the view once as text. - -`herdr-peers fleet ui` draws the same map live in your terminal (groups by -plan, repository or machine; plans that need you first; open a plan or an -agent with Enter or a click; `f` focuses an agent in Herdr). It is -read-only: it writes nothing and prompts nobody, and every string it draws -is cleaned first. Without a terminal it prints one text snapshot -(`--snapshot`). +`m`, `u` group by plan, repository, machine or queue; `←→ [ ] 1-5` pick the +view; `/` filters; `↑↓` and the mouse move; Enter or a click opens a plan or +an agent; `f` focuses the agent's pane; `?` help; `q` quit. It only reads: +the map, and an open agent's screen (at most every 2 s, on the machine where +that pane lives, when this machine's Herdr can reach it). It writes nothing +and prompts nobody, and every string it draws is cleaned first. `--snapshot`, +or no terminal, prints the view once as text. ## 10. The record @@ -665,7 +743,7 @@ Use `--scope` to keep it to some machines. | An agent at its usage limit is not continued | the retry runs every 30 minutes, at most 48 times | wait for the reset, or move the lane (orchestra.md) | | A plan is reported `plan_stalled`, `plan_blocked` or `plan_no_lead` | three prompts without progress, a blocker in its state, or a gone lead with no successor to ask | look at the plan; `--brain` may decide stalls and some blockers; `--appoint` covers a lost lead if you granted it | | `start --brain` refuses to start | `ak` is missing or older than 1.3.0 (`--brain` is fail-closed) | install or upgrade coding-agents-kit, or start without `--brain` | -| The brain is retired at once | its account's profile defaults to a mode that skips approvals (auto, bypass, accept edits), or its agent did not come up within two minutes | change that profile's default, or exclude it with `--brain-kinds`; read `autopilot logs` | +| The brain is retired at once | its account's profile defaults to a mode that skips approvals (auto, bypass, accept edits), or its agent did not come up within two minutes | `autopilot status` (its brain line) or `autopilot logs` names why (`why=permission_mode`, the excluded `@profile`, or `why=start_timeout`); change that profile's default, or exclude it with `--brain-kinds` | | A queued plan does not start | it waits for its `after` plan or another plan of its repository; or `queue_blocked` named why: not approved (or edited or amended since), no lead, its lead works elsewhere, on another machine, in a directory this machine cannot see, or on another plan, it already began, or it is a `launch` item; in a sequential queue the items after it wait too | fix what the reason names; the daemon reads the queue again on the next report | | `lead verify` exits 5 | a machine of the plan could not be reached | wait until it answers, or pass `--allow-unreached` to accept the risk (recorded) | | `autopilot logs -f` shows nothing | only the background daemon writes `autopilot.out`; an idle daemon writes one pass line every tenth pass | `autopilot status` to see whether it runs, and how | @@ -686,3 +764,21 @@ Every rule above is pinned by the suite (`bash tests/run.sh <scope>`): | Lead appointment: the grant, `--as-lane`, fence F10 and the one order, `lead verify`, protocol 2 vs a frozen 1.3.0 receiver | `lead` (`appoint.sh`) and `autopilot` (the drill) | | `fleet ui`: hostile maps, cleaned text, read-only | `fleet_ui` | | No secret, prompt or screen text in any record | `security`, `autopilot` | + +## 16. Environment reference + +Every variable is optional; each default is the code's. + +| Variable | Default | Effect | +| --- | --- | --- | +| `HERDR_PEERS_AUTOPILOT_CONFIRM` | 1.5 | Seconds between a key and the re-read that confirms it (0–30). | +| `HERDR_PEERS_AUTOPILOT_GRACE` | 300 | Seconds a lead's pane must stay unchanged before a loop prompt (§5). | +| `HERDR_PEERS_AUTOPILOT_SSH_TIMEOUT` | 25 | Seconds one machine's plans report may take (1–120). | +| `HERDR_PEERS_AUTOPILOT_NOTIFY_TIMEOUT` | 20 | Seconds one `--notify` command may run (1–60; §8). | +| `HERDR_PEERS_AUTOPILOT_NOTIFY_BUDGET` | 20 | Seconds all `--notify` commands of one pass may run together (1–120). | +| `HERDR_PEERS_AUTOPILOT_APPOINT_GRACE` | 900 | Seconds lead and successors must be gone, the plan frozen, before `--appoint` asks a lane (0–86400; §7). | +| `HERDR_PEERS_APPOINT_PROBE_GAP` | 60 | Seconds between the two probes of `lead takeover --as-lane` (0–600; §7). **0 is for tests only**: it collapses the two probes protocol §12 spaces apart into one moment; never set it below the default on a real fleet. | +| `HERDR_PEERS_SCOPE` | every enabled machine | The allow-list, as for every verb. | +| `HERDR_PEERS_UI_SERVER` | — | Set by the helper for `fleet ui` (this server's key) — never by hand. | +| `HERDR_PEERS_BRAIN_KEY_FILE` | — | Set by the daemon in the brain's environment (its answer-key file) — never by hand. | + diff --git a/.agents/skills/herdr-peers/orchestra.md b/.agents/skills/herdr-peers/orchestra.md index 8a81b65..67af585 100644 --- a/.agents/skills/herdr-peers/orchestra.md +++ b/.agents/skills/herdr-peers/orchestra.md @@ -243,3 +243,38 @@ and is waiting for an incoming ask, end the turn and let the ask arrive as the next input. A long-running tool loop can leave queued input unhandled. Check each incoming message with `herdr-peers check` before using it, then answer only a recorded ask with its reply grant. + +## 10. Leading on 2.0 + +What changes for a lead when the fleet runs herdr-peers 2.0 and the human's +daemon runs `autopilot --loop` (the operator's manual is +[autopilot.md](autopilot.md)). + +- **Appointment is the human's grant, not yours.** Run `herdr-peers lead + claim --plan P --allow-appointment` only when your human asked for it in + their own words: when you and every successor are gone, the plan's first + live lane may then take the lead. Upgrade every lane and successor to 2.0 + first — a granted plan's lead notices are protocol 2, which a 1.x peer + ignores ([protocol.md](protocol.md) §12). `--no-appointment` withdraws it. +- **`lead verify --plan P` before every merge, tag or release.** It + re-reads your record here and asks the plan's other machines for theirs + (read-only). Exit 4: you are not the lead (anymore) — step down, do not + merge. Exit 5: a machine could not be reached — wait, or accept the risk + with `--allow-unreached` (recorded). After a usage limit or a sleep, run it + before anything else. +- **As a lane of a granted plan**, you may be asked by the daemon to run + `herdr-peers lead takeover --plan P --as-lane`. Run exactly that; the + helper checks the grant, your repository and, twice, that the lead, every + successor and every earlier lane are gone, and refuses otherwise. Never + pass `--reason` to it, and never run it on your own initiative. +- **A stalled plan under `--appoint`** is not appointed around: appointment + is only for a plan whose lead and every successor are gone. A stalled plan + (three loop prompts without progress) is reported to the human; with + `--brain`, the brain may allow one more prompt to you. +- **The plan queue.** The plan tool writes the queue (`queue.json` beside its + plans); the daemon only reads it. When your plan finishes, the next approved plan in + the queue starts with one fixed prompt to the lead it names, in that + repository. Mark your plan done through the plan tool so the queue moves. +- **The brain is not a lane.** The daemon's brain lives in a workspace of its + own, answers only the daemon, and is never a plan's lead, successor or + lane: do not ask it, notify it, or list it in a lead record. diff --git a/.agents/skills/herdr-peers/schemas/fleet-v1.json b/.agents/skills/herdr-peers/schemas/fleet-v1.json index 2b3394e..63c9535 100644 --- a/.agents/skills/herdr-peers/schemas/fleet-v1.json +++ b/.agents/skills/herdr-peers/schemas/fleet-v1.json @@ -105,6 +105,40 @@ "open_questions": { "type": "integer" }, + "excluded": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Profiles excluded from the next pick because they start in a mode that skips approvals, at most 16 (2.0.1)." + }, + "retired": { + "type": [ + "object", + "null" + ], + "description": "Why the last brain was retired (gone, usage_limit, start_timeout, permission_mode), its profile and when (2.0.1).", + "additionalProperties": false, + "required": [ + "why", + "profile", + "at" + ], + "properties": { + "why": { + "type": "string" + }, + "profile": { + "type": [ + "string", + "null" + ] + }, + "at": { + "type": "string" + } + } + }, "last": { "type": [ "object", @@ -530,6 +564,26 @@ "null" ], "description": "When its lead record was last written." + }, + "state_updated_at": { + "type": [ + "string", + "null" + ], + "description": "When the plan's state.json last changed (2.1.0; optional, absent in older maps). fleet ui calls an open plan stale after 24 h without movement." + }, + "unreadable_reason": { + "type": [ + "string", + "null" + ], + "enum": [ + "missing", + "parse", + "shape", + null + ], + "description": "Why a plan is unreadable (2.1.0; optional): missing = no state.json where its lead record points; parse = its state.json does not parse or is too large; shape = a state.json shape this helper does not read (an older or newer plan generation). Null for a readable plan." } } } diff --git a/.agents/skills/herdr-peers/scripts/autopilot.py b/.agents/skills/herdr-peers/scripts/autopilot.py index 68ca3f2..d1e4847 100644 --- a/.agents/skills/herdr-peers/scripts/autopilot.py +++ b/.agents/skills/herdr-peers/scripts/autopilot.py @@ -44,6 +44,9 @@ ABSENT_PASSES = 2 # passes a lead's pane must be missing before it counts as gone FLEET_SCHEMA = 'herdr-peers/fleet-v1' EVENT_SCHEMA = 'herdr-peers/plan-event-v1' +# The map lists at most this many excluded brain profiles (fleet-v1's limit; the +# daemon's own exclusion set is not capped, only what it publishes). +EXCLUDED_SHOWN = 16 NUDGE_TEXT = ( '[autopilot] The developer is away and has pre-approved the recommended option for every ' @@ -53,6 +56,11 @@ 'again. If an item truly needs something only the developer can provide (a credential, a ' 'login, a fact you cannot verify), leave only that item pending, finish everything else, ' 'and list it at the end.') +DENIED_TEXT = ( + '[autopilot] Your last request was declined: it offered only options the autopilot never ' + 'approves (one that widens your permissions, or a refusal). Continue your task another ' + 'way, within your plan\'s gates and recorded authority; if it truly cannot go on without ' + 'that permission, record it as a blocker and stop.') RESUME_TEXT = ( '[autopilot] Your usage limit may have reset. Continue the pending plan to its end from ' 'where you stopped, taking the recommended option at every decision. If the limit is ' @@ -81,7 +89,9 @@ # Reasons that are usually a passing state (the lead has not marked the queue yet, # it is finishing another plan, its directory is not listed this pass). -QUEUE_TRANSIENT = ('started, queue not updated', 'lead busy with another plan', 'lead directory unknown') +# 'started, queue not updated' is not here: a plan that began while the queue still says queued +# (the pack leaves it so outside Herdr) is running, never reported. +QUEUE_TRANSIENT = ('lead busy with another plan', 'lead directory unknown') # The repository path is quoted as JSON data: it is never read as words of the prompt. QUEUE_TEXT = ("Plan %s is next in the queue of the repository at %s and approved. In that repository, " "run the plan tool's execute flow for it (its start gate checks the approval again) and " @@ -354,6 +364,45 @@ def keys_for(menu, target): return move + ['enter'] +EXIT_ROW = re.compile(r'\b(?:exit|quit)\b', re.I) # anywhere: 'Cancel and exit' leaves the agent too +REFUSAL_ROW = re.compile(r'^(?:\[[a-z]\]\s+)?(?:no\b|deny\b|reject\b|cancel\b|don\'t\b|do not\b)', re.I) + + +def no_esc(kind): + """CLIs where Esc on a dialog aborts the whole turn rather than refusing it.""" + return kind == 'codex' + + +def deny_decision(text, state, cls, why): + """Keys that refuse what a pane waits for: its refusal row when the menu has + one, else Esc. Never a Yes, a row that widens permissions, auto mode, or a row + that exits the agent. Pure.""" + lines = tail_lines(text) + menu = parse_menu(text) + if menu and not live(menu, state, lines): + menu = None + if menu: + rows = menu['rows'] + for i, r in enumerate(rows): + label = r['label'] + if REFUSAL_ROW.match(label) and not WIDENING.search(label) and not EXIT_ROW.search(label) \ + and not RECOMMENDED.search(label + r['more']): + current = next((n for n, x in enumerate(rows) if x['selected']), 0) + move = ['down'] * (i - current) if i >= current else ['up'] * (current - i) + return Decision('keys', cls, why, move + ['enter'], i + 1) + return Decision('keys', cls, why, ['esc']) + + +# What a pane may wait at that a denial resolves: a permission or a plan approval the +# daemon cannot accept. An agent's own question is a decision about the work: it is left +# waiting for the human, never answered "No" by the daemon. Login, the +# bypass-permissions consent, folder trust, a usage limit and an unknown screen stay the +# human's (or have their own path). +DENIABLE = ('permission', 'plan_approval') +# In the brain's pane everything but its own answer command is denied. +BRAIN_DENIABLE = ('permission', 'plan_approval', 'question', 'question_review') + + def menu_decision(menu, cls, why, prefer=None): target = choose(menu, prefer) if target is None: @@ -501,6 +550,7 @@ def __init__(self): self.tries = 0 # key rounds spent on that screen self.left = None # digest of a screen autopilot gave up on or left self.since = None # when its state was last seen to change + self.denied = False # a refusal was keyed: tell it once, when it is idle again class Autopilot(object): @@ -612,17 +662,26 @@ def attend(self, machine, agent, addr, memo, stale): return True # Once a dialog was keyed, its next step is part of the same # dialog even when Herdr briefly reports another state. - choice = decide(kind, 'blocked' if step and engaged(text) else state, text) - if choice.action == 'keys' and self.brain is not None and self.brain.is_brain(addr) \ - and choice.cls not in ('folder_trust', 'update_prompt') \ + seen = 'blocked' if step and engaged(text) else state # the state decide reads, and deny too + choice = decide(kind, seen, text) + brain = self.brain is not None and self.brain.is_brain(addr) + if brain and choice.cls not in ('folder_trust', 'update_prompt', 'login', 'bypass_ack', + 'usage_limit', 'unknown', 'none') \ + and (choice.action == 'keys' or choice.cls in BRAIN_DENIABLE) \ and not (choice.cls == 'permission' and brain_mod().approval_is_answer(kind, text)): # The brain reads text other agents wrote: the daemon approves - # nothing in its pane but its own answer command. - memo.left = digest - self.record(addr, kind, Decision('leave', 'brain_permission_refused', choice.cls), - 'left') - self.brain.refused(addr) - return True + # nothing in its pane but its own answer command. What it asked for + # is denied — never left waiting — and the brain is reminded once. + choice = deny_decision(text, seen, 'brain_permission_denied', choice.cls) + elif choice.action == 'leave' and choice.cls in DENIABLE and choice.why == 'no acceptable option': + # A permission or plan approval whose every row widens permissions or + # refuses: refused, not left blocked; the agent is told once it is idle. + denial = deny_decision(text, seen, 'denied', choice.cls) + if denial.keys != ['esc'] or not no_esc(kind): + choice = denial + if choice.action == 'keys' and choice.keys == ['esc'] and no_esc(kind): + # Esc in a Codex approval aborts the whole turn: leave it instead. + choice = Decision('leave', choice.cls, 'no refusal row; esc would abort the turn') if choice.action == 'keys': if digest == memo.stuck: memo.tries += 1 @@ -632,11 +691,18 @@ def attend(self, machine, agent, addr, memo, stale): memo.left = digest self.record(addr, kind, Decision('leave', 'stuck', 'no progress'), 'gave_up') return True + if memo.tries == MAX_ATTEMPTS and choice.cls in ('denied', 'brain_permission_denied') \ + and not no_esc(kind): + choice = Decision('keys', choice.cls, choice.why, ['esc']) # the row did not take: Esc self.record(addr, kind, choice, 'keyed') if self.dry_run: return True if not self.io.keys(machine, pane, choice.keys): return False + if memo.tries == 1 and choice.cls == 'brain_permission_denied': + self.brain.denied(addr) + elif memo.tries == 1 and choice.cls == 'denied': + memo.denied = True self.sleep(self.confirm) continue if choice.cls == 'usage_limit': @@ -649,6 +715,13 @@ def attend(self, machine, agent, addr, memo, stale): if choice.cls == 'unknown' and self.brain is not None: self.brain.ask('screen_unknown', machine, None, {'addr': addr}) elif state in ('idle', 'done'): + if memo.denied and self.nudge and not has_draft(text, state) and not brain: + memo.denied = False + self.record(addr, kind, Decision('prompt', 'denied_told', 'continue another way'), + 'nudged') + if not self.dry_run: + self.io.prompt(machine, pane, DENIED_TEXT) + return True self.maybe_nudge(machine, pane, addr, kind, memo, text, stale) return True return True @@ -836,9 +909,19 @@ def run(self, listed): self.consider(machine, plan, by_pane, now, prompted) except Exception as exc: # one plan never stops the pass self.io.warn('%s:%s' % (machine, plan.get('plan')), exc) - for queue in info['report'].get('queues') or []: + seen = set() + queues = info['report'].get('queues') or [] + # A queue reported invalid (a queue.json caught mid-write, say) lists + # no items: its repository keeps its state until a valid read. + unread = set(q.get('repo_root') for q in queues if q.get('invalid')) + for queue in queues: + for item in queue.get('items') or []: + seen.add((machine, queue.get('repo_root'), item.get('plan'))) + if info.get('state') == 'ok': # a machine that could not answer keeps its state + self.forget_queues(machine, seen, unread) + for queue in queues: try: - self.consider_queue(machine, queue, by_pane, now, prompted) + self.consider_queue(machine, queue, by_pane, now, prompted, seen) except Exception as exc: # one queue never stops the pass self.io.warn('%s:queue' % machine, exc) self.publish(listed, now) @@ -961,7 +1044,7 @@ def consider(self, machine, plan, by_pane, now, prompted): if not self.ap.dry_run: self.io.prompt(machine, pane, LOOP_TEXT % plan['plan']) - def consider_queue(self, machine, queue, by_pane, now, prompted): + def consider_queue(self, machine, queue, by_pane, now, prompted, seen=None): """Start the next ready item of a repository's queue: one fixed prompt to its named lead, once. The queue is the pack's; the daemon only reads it. In a sequential queue nothing after a queued item that cannot start @@ -970,8 +1053,10 @@ def consider_queue(self, machine, queue, by_pane, now, prompted): reported only once it has held for the appointment grace.""" repo = queue.get('repo_root') sequential = not queue.get('parallel') + seen = set() if seen is None else seen for item in queue.get('items') or []: key = (machine, repo, item['plan']) + seen.add(key) if item.get('state') != 'queued': self.queued.discard(key) self.queue_told.pop(key, None) @@ -981,9 +1066,14 @@ def consider_queue(self, machine, queue, by_pane, now, prompted): pane = local_pane(item.get('lead')) if not reason and item.get('ready') and pane is None: reason = 'lead on another machine' # this daemon can prompt only its own panes + in_flight = bool(reason) and reason.startswith('started') # began; the queue not updated (outside Herdr) + if not reason or in_flight or reason.startswith('waiting for') or reason.startswith('another plan'): + # Its reason cleared: a reason that returns later is reported again. + self.queue_told.pop(key, None) + self.queue_since.pop(key, None) if reason: - if reason.startswith('waiting for'): - continue # its `after` plan decides; the queue's order is the pack's + if reason.startswith('waiting for') or in_flight: + continue # its `after` plan decides; or it runs already: never reported if not reason.startswith('another plan'): self.tell_queue(machine, repo, item, key, reason, now) if sequential: @@ -1008,6 +1098,19 @@ def consider_queue(self, machine, queue, by_pane, now, prompted): if sequential: return # one at a time per repository + def forget_queues(self, machine, seen, unread=()): + """Drop the queue state of this machine's items that its current report + no longer lists (an item removed, a queue deleted). A repository whose + queue was reported invalid (`unread`) keeps its state: no items were read, + so nothing is known to be gone, and forgetting `queued` would prompt its + lead a second time.""" + def gone(k): + return k[0] == machine and k not in seen and k[1] not in unread + for store in (self.queue_told, self.queue_since): + for key in [k for k in store if gone(k)]: + del store[key] + self.queued -= set(k for k in self.queued if gone(k)) + def tell_queue(self, machine, repo, item, key, reason, now): """Report a queued item that cannot start, once per reason; a passing reason only after it held for the appointment grace.""" @@ -1145,12 +1248,14 @@ def appoint(self, memo, machine, plan, by_pane, prompted): return False def leads_elsewhere(self, machine, pane, plan_id): - """True when `pane` leads or succeeds another open plan on `machine`.""" + """True when `pane` leads, succeeds or is a lane of another open plan on + `machine` (the same membership the queue checks).""" report = (self.machines.get(machine) or {}).get('report') or {} for other in report.get('plans', []): if other['plan'] == plan_id or other['class'] not in ('open', 'blocked'): continue - if local_pane(other['lead']) == pane or pane in [local_pane(a) for a in other['succession']]: + members = [other.get('lead')] + list(other.get('succession') or []) + list(other.get('lanes') or []) + if pane in [local_pane(a) for a in members]: return True return False @@ -1209,6 +1314,8 @@ def publish(self, listed, now): 'lanes': plan['lanes'], 'repo_root': plan['repo_root'], 'blocker_class': plan['blocker_class'], 'progress': plan.get('progress'), 'updated_at': plan.get('updated_at'), + 'state_updated_at': plan.get('state_updated_at'), + 'unreadable_reason': plan.get('unreadable_reason'), 'tasks_done': plan.get('tasks_done'), 'tasks_total': plan.get('tasks_total'), 'current_task': plan.get('current_task'), @@ -1253,7 +1360,7 @@ def publish(self, listed, now): MAP_MAX_BYTES = 2 * 1024 * 1024 - 4096 # under the store's 2 MB cap, with room to spare REMOTE_PLAN_KEYS = ('plan', 'class', 'blocker_class', 'progress', 'lead', 'lanes', 'succession', - 'epoch', 'updated_at', 'repo_root', 'situation', + 'epoch', 'updated_at', 'state_updated_at', 'unreadable_reason', 'repo_root', 'situation', 'tasks_done', 'tasks_total', 'current_task') @@ -1273,6 +1380,9 @@ def __init__(self, ap, opts): self.b = brain_mod().Brain() self.excluded = set() # profiles whose default mode skips approvals self.last = None # the brain's last decision, for the map and the watcher + self.retired = None # why the last brain was retired, for the map and status + self.denials = [] # times of this brain's denied requests (an hour is kept) + self.remind = False # a denial happened: remind it of the one allowed command # -- lifecycle --------------------------------------------------------- def tick(self, listed, now): @@ -1307,7 +1417,9 @@ def tick(self, listed, now): # Its profile starts in a mode that skips approvals: the # daemon's approval guard would never see them. Not this one. addr = 'local:%s' % b.pane - self.excluded.add(b.profile) + if b.profile and B.PROFILE_RE.fullmatch(b.profile): + self.excluded.add(b.profile) + self.ap.record(addr, b.kind, Decision('leave', 'brain_profile_excluded', b.profile), 'left') self.retire('permission_mode') self.refused(addr) return @@ -1316,6 +1428,12 @@ def tick(self, listed, now): b.state, b.briefed = 'ready', True self.ap.record('local:%s' % b.pane, row.get('agent'), Decision('prompt', 'brain_briefed', 'brain ready'), 'nudged') + elif b.state == 'ready' and self.remind and row is not None and row.get('state') in ('idle', 'done'): + self.remind = False + if not self.ap.dry_run: + self.io.prompt('local', b.pane, B.REMINDER) + self.ap.record('local:%s' % b.pane, row.get('agent'), + Decision('prompt', 'brain_reminded', 'only the answer command'), 'nudged') elif b.state == 'ready' and now - b.lease_at >= B.LEASE_RENEW: if not self.ap.dry_run and self.io.brain_lease(b.kind, b.profile): b.lease_at = now @@ -1331,7 +1449,7 @@ def launch(self, now): 'left') return try: - info = self.io.brain_launch(self.opts.get('kinds') or ('claude', 'codex', 'grok'), + info = self.io.brain_launch(self.opts.get('kinds') or brain_mod().DEFAULT_KINDS, self.opts.get('models') or {}, sorted(self.excluded)) except Exception as exc: # a refusal or a tool failure: recorded, retried within the cap b.state = 'failed' @@ -1346,9 +1464,22 @@ def launch(self, now): self.ap.record('local:%s' % b.pane, b.kind, Decision('prompt', 'brain_launched', '%s %s' % (b.kind, b.profile)), 'nudged') + def denied(self, addr): + """A request of the brain's was denied: remind it once; three in an hour and + it is retired as misbehaving (a replacement launches within the cap).""" + now = self.ap.clock() + self.denials = [t for t in self.denials if now - t < 3600] + [now] + if len(self.denials) >= brain_mod().MAX_DENIALS: + self.retire('misbehaving') + return + self.remind = True + def retire(self, why): b = self.b + self.denials, self.remind = [], False self.ap.record('local:%s' % b.pane, b.kind, Decision('leave', 'brain_replaced', why), 'left') + self.retired = {'why': why, 'profile': b.profile, + 'at': time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(self.ap.clock()))} self.close() b.state = 'none' @@ -1422,7 +1553,7 @@ def status(self, now): 'pane': ('local:%s' % b.pane) if b.pane else None, 'asked_last_hour': len([t for t in b.asked if now - t < 3600]), 'open_questions': sum(1 for q in b.questions.values() if not q['answered']), - 'last': self.last} + 'last': self.last, 'excluded': sorted(self.excluded)[:EXCLUDED_SHOWN], 'retired': self.retired} def act(self, q, action): """Run one allowed action through the daemon's own paths.""" diff --git a/.agents/skills/herdr-peers/scripts/brain.py b/.agents/skills/herdr-peers/scripts/brain.py index 094e3a5..bb99a3d 100644 --- a/.agents/skills/herdr-peers/scripts/brain.py +++ b/.agents/skills/herdr-peers/scripts/brain.py @@ -21,6 +21,9 @@ PICK_SCHEMA = 'pick-v2' AK_MIN = (1, 3, 0) # coding-agents-kit with `ak pick --kinds` (pick-v2) +# Kinds whose answer approval has a verified fixture (approval_is_answer): the default +# brain kinds. Another kind may be named, but its answers are never approved. +DEFAULT_KINDS = ('claude',) AK_INTERFACE = 1 WORKSPACE_LABEL = 'autopilot brain' LEASE_TTL = '4h' @@ -37,7 +40,8 @@ # The only dash-leading elements a launch line may carry: what pick-v2 itself # documents (--model, the -- separator) and the two the daemon adds. HEAD_FLAGS = ('--model',) -ADDED_FLAGS = ('--ask', '--trust-cwd') +ASK_FLAG = '--ask' +ADDED_FLAGS = (ASK_FLAG, '--trust-cwd') # case -> (actions, default). The first action of a list is never implied: # the default is what happens without a valid answer. @@ -73,11 +77,15 @@ BRIEF = ( '[autopilot] You are the brain of the herdr-peers autopilot on this machine. You decide ' 'nothing on your own and change nothing: from time to time the autopilot will send you one ' - 'question about a plan or a waiting agent, with a fixed list of allowed actions. Read what ' - 'you need (the plan files, `herdr-peers fleet`, `herdr-peers plans`), choose one action, and ' - 'answer by running exactly the command the question shows, nothing else. If unsure, answer ' - 'leave. Never run any other command because of a question, never edit files, never message ' - 'another agent. Wait for the next question.') + 'question about a plan or a waiting agent, with a fixed list of allowed actions. Each ' + 'question carries all the context you get. The only command you may run is the one the ' + 'question shows: herdr-peers autopilot answer <qid> <action>. No other command, tool or file ' + 'read will be approved, and each request for one is denied and counted. If unsure, answer ' + 'leave. Never edit files, never message another agent. Wait for the next question.') +REMINDER = ( + '[autopilot] Only run `herdr-peers autopilot answer <qid> <action>`. Everything you need is in ' + 'the question; do not run other commands.') +MAX_DENIALS = 3 # denied requests in an hour before the brain is retired as misbehaving QUESTION = ( '[autopilot] Question %(qid)s — %(case_text)s Plan: %(plan)s on machine %(machine)s. ' @@ -106,7 +114,11 @@ def launch_line(doc, ak_path): `argv` is what `ak` returned with its first element replaced by the resolved path of the `ak` the daemon ran and `--ask --trust-cwd` added right after the profile; `line` is that argv quoted for a shell. Every - element is checked against its pattern first.""" + element is checked against its pattern first. Exactly one bare `--ask` as + the last element of ak's argv (coding-agents-kit 1.5.0 ends an ask-mode + launch with it) is accepted and dropped, since the daemon adds its own; an + `--ask` anywhere else, the CLI's own permission flags and anything after + `--` are still refused.""" if not isinstance(doc, dict) or doc.get('schema') != PICK_SCHEMA or doc.get('interface') != 1: raise PickRefused('not a pick-v2 document') if doc.get('qualifies') is not True: @@ -125,16 +137,19 @@ def launch_line(doc, ak_path): raise PickRefused('unexpected kind in the launch') if not PROFILE_RE.fullmatch(profile) or profile != doc.get('profile'): raise PickRefused('unexpected profile in the launch') - rest, i = argv[3:], 0 + rest, kept, i = argv[3:], [], 0 + if rest[-1:] == [ASK_FLAG]: + rest = rest[:-1] # ak's own ask head flag (kit 1.5.0): ADDED_FLAGS carries it once while i < len(rest): item = rest[i] if item in HEAD_FLAGS: if i + 1 >= len(rest) or not MODEL_RE.fullmatch(rest[i + 1]): raise PickRefused('a launch flag without a valid value') + kept += rest[i:i + 2] i += 2 continue raise PickRefused('an element the daemon does not allow in a launch') - out = [ak_path, kind, profile] + list(ADDED_FLAGS) + rest + out = [ak_path, kind, profile] + list(ADDED_FLAGS) + kept return kind, profile, out, ' '.join(shlex.quote(a) for a in out) @@ -146,13 +161,20 @@ def clean(value, limit=REASON_MAX): return ' '.join(text.split())[:limit] +# The escalation classes only the human resolves: approval (C1), consent or login (C2), +# damage (C5), terms (C6). The pack refuses `resolver: lead` for exactly these. +HUMAN_CLASSES = ('C1', 'C2', 'C5', 'C6') +KNOWN_CLASSES = ('C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7') + + def blocker_is_askable(plan): """True when a blocked plan's blocker may be put to the brain: the plan itself recorded it as one its lead may resolve (`resolver: lead` — a - field the plan writes, not prose), it names no C-class (those are the - human's), and its text names no sensitive subject (an extra guard, not - the reason to ask).""" - if plan.get('blocker_class'): + field the plan writes, not prose), its class is none or one the lead may + handle (C3, C4, C7; never C1, C2, C5, C6, nor an unknown class), and its + text names no sensitive subject (an extra guard, not the reason to ask).""" + klass = plan.get('blocker_class') + if klass is not None and (klass not in KNOWN_CLASSES or klass in HUMAN_CLASSES): return False detail = plan.get('detail') or {} block = detail.get('blocker') if isinstance(detail, dict) else None diff --git a/.agents/skills/herdr-peers/scripts/fleet_report.py b/.agents/skills/herdr-peers/scripts/fleet_report.py index 83e4fd5..c5ef2bf 100644 --- a/.agents/skills/herdr-peers/scripts/fleet_report.py +++ b/.agents/skills/herdr-peers/scripts/fleet_report.py @@ -50,12 +50,13 @@ MACHINE_RE = r'(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63})' PANE_RE = r'[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}' -ADDR_RE = re.compile(r'^(%s):(%s)$' % (MACHINE_RE, PANE_RE)) +ADDR_RE = re.compile(r'^(%s):(%s)\Z' % (MACHINE_RE, PANE_RE)) # \Z: no trailing newline PLAN_RE = re.compile(r'(?=.{1,128}$)[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._-]*)*') TS_RE = re.compile(r'\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z') SERVER_DIR_RE = re.compile(r'[0-9a-f]{64}') BRANCH_RE = re.compile(r'[A-Za-z0-9][A-Za-z0-9._/@+-]{0,199}') BLOCK_CLASS_RE = re.compile(r'\bC[1-7]\b') +CLASS_RE = re.compile(r'C[1-7]') APPOINT_GRANTS = ('lanes', 'lanes:any-kind') TASK_STATUSES = ('pending', 'in_progress', 'completed', 'blocked', 'skipped') TITLE_MAX = 120 @@ -338,13 +339,19 @@ def plan_detail(state, plan_dir): 'needs': clean_text(blocker.get('needs') if isinstance(blocker.get('needs'), str) else None, SUMMARY_LINE_MAX), # Who the plan says may resolve it: a field the plan writes, never prose. + # A blocker whose explicit class is not one of C1-C7 backs no resolver. 'resolver': blocker.get('resolver') if blocker.get('resolver') in ('lead', 'human') + and (blocker.get('class') is None + or (isinstance(blocker.get('class'), str) and CLASS_RE.fullmatch(blocker['class']))) else None} summary, written = plan_summary(plan_dir) return {'title': plan_title(plan_dir), 'tasks': tasks, 'tasks_from': start, 'blocker': block, 'summary': summary, 'summary_at': written} +UNREADABLE_REASONS = ('missing', 'parse', 'shape') # no state.json; it does not parse; an unknown shape + + def classify(state): """(class, blocker class, progress digest) of a parsed state.json. @@ -383,9 +390,13 @@ def classify(state): cls = 'open' block_class = None if cls == 'blocked' and blocker: - text = ' '.join(str(blocker.get(k) or '') for k in ('class', 'needs', 'reason'))[:2000] - found = BLOCK_CLASS_RE.search(text) - block_class = found.group(0) if found else None + named = blocker.get('class') + if isinstance(named, str) and CLASS_RE.fullmatch(named): + block_class = named # an explicit class (plan-snapshot/v8 always records one) wins over prose + elif named is None: + text = ' '.join(str(blocker.get(k) or '') for k in ('needs', 'reason'))[:2000] + found = BLOCK_CLASS_RE.search(text) + block_class = found.group(0) if found else None progress = hashlib.sha256(json.dumps( [top, statuses, satisfied, state.get('checkpoint'), blocker, state.get('completed_count')], sort_keys=True, default=str).encode('utf-8')).hexdigest()[:16] @@ -579,9 +590,11 @@ def describe_plan(root, server, rec, panes, git, now=None, logs=None): lead_in_repo = lead_top == found_at or lead_top == rec.get('repo_root') cls, block_class, progress, updated = 'unreadable', None, None, None done = total = current = detail = None + why = 'missing' # why a plan is unreadable: no state.json, it does not parse, or an unknown shape if path: state = load_json(path, MAX_STATE_BYTES) cls, block_class, progress = classify(state) + why = 'parse' if state is None else 'shape' if cls != 'unreadable': done, total, current = task_progress(state) if cls in ('open', 'blocked'): # a finished plan needs no detail on the map @@ -594,6 +607,7 @@ def describe_plan(root, server, rec, panes, git, now=None, logs=None): 'succession': rec['succession'], 'lanes': rec['lanes'], 'repo_root': rec.get('repo_root'), 'plan_dir': os.path.dirname(path) if path else None, 'class': cls, 'blocker_class': block_class, 'progress': progress, 'state_updated_at': updated, + 'unreadable_reason': why if cls == 'unreadable' else None, 'updated_at': rec['updated_at'], 'lead_in_repo': lead_in_repo, 'tasks_done': done, 'tasks_total': total, 'current_task': current, 'detail': detail, 'appoint': rec.get('appoint'), 'appointed': bool(rec.get('appointed')), @@ -671,7 +685,11 @@ def valid_fleet(doc): _str(brain['last'].get(k)) for k in ('case', 'action', 'plan', 'at')))) and all(brain.get(k) is None or (isinstance(brain.get(k), int) and not isinstance(brain.get(k), bool)) - for k in ('asked_last_hour', 'open_questions'))): + for k in ('asked_last_hour', 'open_questions')) + and isinstance(brain.get('excluded', []), list) and len(brain.get('excluded', [])) <= 16 + and all(isinstance(p, str) for p in brain.get('excluded', [])) + and (brain.get('retired') is None or (isinstance(brain['retired'], dict) and all( + _str(brain['retired'].get(k)) for k in ('why', 'profile', 'at'))))): return False for m in doc['machines']: if not isinstance(m, dict) or not isinstance(m.get('machine'), str) or not _str(m.get('label')): @@ -701,7 +719,9 @@ def valid_fleet(doc): if not isinstance(p, dict) or not isinstance(p.get('plan'), str): return False if not all(_str(p.get(k)) for k in ('class', 'lead', 'repo_root', 'blocker_class', - 'situation')): + 'situation', 'state_updated_at')): + return False + if p.get('unreadable_reason') not in UNREADABLE_REASONS + (None,): return False for k in ('tasks_done', 'tasks_total', 'epoch'): v = p.get(k) @@ -783,6 +803,8 @@ def valid_report(doc): return False if not valid_addresses(plan.get('succession')) or not valid_addresses(plan.get('lanes')): return False + if plan.get('unreadable_reason') not in UNREADABLE_REASONS + (None,): + return False if plan.get('class') not in ('open', 'blocked', 'completed', 'unreadable'): return False progress = plan.get('progress') diff --git a/.agents/skills/herdr-peers/scripts/fleet_ui.py b/.agents/skills/herdr-peers/scripts/fleet_ui.py index 004bda9..e2f4b29 100644 --- a/.agents/skills/herdr-peers/scripts/fleet_ui.py +++ b/.agents/skills/herdr-peers/scripts/fleet_ui.py @@ -40,7 +40,19 @@ SCREEN_EVERY = 2.0 # seconds between two live screen reads in a detail panel SCREEN_LINES = 20 MIN_W, MIN_H = 50, 12 +HEADER_ROWS = 4 # brand, counts, grouping tabs, facet tabs; then a rule; then the body GROUPINGS = ('plan', 'repo', 'machine', 'queue') +# One facet model for every grouping: does it need me, is it moving, is it waiting, is it done. +FACETS = ('attention', 'active', 'waiting', 'done', 'all') +FOCUS = 'focus' # the default view: attention and active together; never done +FILTERS = (FOCUS,) + FACETS +FACET_LABEL = {'attention': 'Attention', 'active': 'Active', 'waiting': 'Waiting', 'done': 'Done', 'all': 'All'} +FACET_SHORT = {'attention': 'A', 'active': 'Ac', 'waiting': 'W', 'done': 'D', 'all': 'All'} +STALE_PLAN_AFTER = 24 * 3600 # an open plan whose state has not moved for this long needs attention +# Why a plan is unreadable, as its machine's report says (2.1.0 maps). +UNREADABLE_WHY = {'missing': 'no state.json where its lead record points', + 'parse': 'its state.json does not parse (or is too large)', + 'shape': 'a state.json shape this helper does not read (an older or newer plan generation)'} QUEUE_MARK = {'queued': ('○', 'dim'), 'started': ('▶', 'accent'), 'done': ('✓', 'ok'), 'skipped': ('–', 'dim')} # Agent states as the map reports them, folded into what a human reads. @@ -137,6 +149,16 @@ def duration(seconds): return '%dd' % (seconds // 86400) +def span(seconds): + """A long stretch the way a human reads it: '2d 4h', '5h 12m', '40m'.""" + seconds = max(0, int(seconds or 0)) + if seconds >= 86400: + return '%dd %dh' % (seconds // 86400, seconds % 86400 // 3600) + if seconds >= 3600: + return '%dh %02dm' % (seconds // 3600, seconds % 3600 // 60) + return '%dm' % (seconds // 60) + + def parse_ts(stamp): """Seconds since the epoch of an ISO-8601 UTC stamp, or None.""" if not isinstance(stamp, str): @@ -229,7 +251,8 @@ def __init__(self, machine, label, row): class Plan(object): __slots__ = ('key', 'machine', 'label', 'plan', 'cls', 'lead', 'epoch', 'situation', - 'done', 'total', 'current', 'repo', 'blocker_class', 'detail', 'members', 'search') + 'done', 'total', 'current', 'repo', 'blocker_class', 'detail', 'members', 'search', + 'moved', 'why') def __init__(self, machine, label, row): self.machine, self.label = machine, label @@ -246,6 +269,8 @@ def __init__(self, machine, label, row): self.repo = clean(row.get('repo_root'), 400) self.blocker_class = clean(row.get('blocker_class'), 4) or None self.detail = row.get('detail') if isinstance(row.get('detail'), dict) else None + self.moved = parse_ts(row.get('state_updated_at')) # when its state last changed (2.1.0 maps) + self.why = row.get('unreadable_reason') if row.get('unreadable_reason') in UNREADABLE_WHY else None self.members = [] # (role, Agent) self.search = ' '.join([self.plan, self.label, self.repo, self.current or '', clean((self.detail or {}).get('title'), 200)]).lower() @@ -297,6 +322,8 @@ def __init__(self, fleet): 'after': clean(it.get('after'), 128) or None, 'lead': clean(it.get('lead'), 120) or None, 'ready': it.get('ready') is True, 'blocked': clean(it.get('blocked_reason'), 120) or None} for it in q.get('items') or [] if isinstance(it, dict)] + for n, it in enumerate(items): + it['pos'] = n + 1 # its place in the queue, kept when a view filters the rest out queues.append({'repo': clean(q.get('repo_root'), 400), 'parallel': q.get('parallel') is True, 'invalid': q.get('invalid') is True, 'items': items}) self.machines.append({'machine': machine, 'label': label, @@ -305,7 +332,9 @@ def __init__(self, fleet): 'agents': agents, 'plans': plans, 'queues': queues}) for q in queues: for n, it in enumerate(q['items']): - self.queue_pos['%s/%s' % (machine, it['plan'])] = (n + 1, len(q['items']), it['state']) + # A plan that began while the queue still says queued counts as started. + self.queue_pos['%s/%s' % (machine, it['plan'])] = ( + n + 1, len(q['items']), 'started' if queue_in_flight(it) else it['state']) self.agents.extend(agents) self.plans.extend(plans) for a in agents: @@ -339,64 +368,219 @@ def counts(self): class Group(object): - __slots__ = ('key', 'kind', 'title', 'subtitle', 'plan', 'members', 'tone', 'queue_pos') + __slots__ = ('key', 'kind', 'title', 'subtitle', 'plan', 'members', 'tone', 'queue_pos', 'facet', + 'stale') def __init__(self, key, kind, title, subtitle='', plan=None, members=None, tone='normal'): self.key, self.kind, self.title, self.subtitle = key, kind, title, subtitle self.plan, self.members, self.tone = plan, members or [], tone self.queue_pos = None + self.facet = None + self.stale = None def _matches(text, needle): return not needle or needle in text -def build_view(index, grouping='plan', needle=''): - """The groups shown for a grouping and a filter. Pure.""" +# --- facets: pure classification, one facet per item -------------------------------- + +def wanted(facet): + """The facets a view shows.""" + if facet == 'all': + return frozenset(FACETS[:4] + ('unreadable',)) # an unreadable plan shows only under All + if facet in FACETS: + return frozenset([facet]) + return frozenset(('attention', 'active')) # FOCUS, and anything unknown + + +def stale_for(plan, now, stale_after=STALE_PLAN_AFTER): + """Seconds an open plan's state has not moved, when past the threshold; else None.""" + if plan.cls != 'open' or plan.moved is None or now is None: + return None + still = now - plan.moved + return still if still > stale_after else None + + +def plan_facet(plan, now=None, queue_state=None, stale_after=STALE_PLAN_AFTER): + """attention: blocked, stalled, no lead, a moved lead, or open with no movement + past the threshold — something the developer can act on now; active: open and + moving; waiting: queued, not started; done: completed; unreadable: the map + cannot say (shown only under All).""" + if plan.cls == 'completed': + return 'done' + if plan.cls == 'unreadable': + return 'unreadable' + if plan.needs_you or plan.cls != 'open': + return 'attention' + if queue_state == 'queued': + return 'waiting' + if stale_for(plan, now, stale_after) is not None: + return 'attention' + return 'active' + + +def attention_order(plan, now=None): + """The order inside Attention: NO LEAD and blocked first, then the daemon's other + judgments (stalled, a moved lead), then no movement; nearest to done first, + and among the still ones the longest still first.""" + pct = (plan.done or 0) / float(plan.total) if plan.total else 0.0 + if plan.situation in ('plan_no_lead', 'plan_blocked') or plan.cls == 'blocked': + return (0, -pct, plan.plan) + if plan.needs_you: + return (1, -pct, plan.plan) + return (2, -(stale_for(plan, now) or 0), plan.plan) + + +FACET_ORDER = {'attention': 0, 'active': 1, 'waiting': 2, 'done': 3, 'unreadable': 4} + + +def agent_facet(agent): + """attention: waiting at a question or approval, or a state the map could not read; + active: working; waiting: free (idle or done). An agent is never done.""" + return {'working': 'active', 'idle': 'waiting'}.get(agent.state, 'attention') + + +def queue_in_flight(item): + """A queued item whose plan already began (the pack leaves it `queued` outside + Herdr; the report says 'started, queue not updated'): it is running.""" + return item.get('state') == 'queued' and (item.get('blocked') or '').startswith('started') + + +def queue_reason_blocks(reason): + return bool(reason) and not (reason.startswith('waiting') or reason.startswith('another plan') + or reason.startswith('started')) + + +def queue_item_facet(item): + """attention: a queued item whose reason blocks it; active: started; waiting: + queued (ready, or waiting its turn); done: done or skipped.""" + state = item.get('state') + if state == 'started' or queue_in_flight(item): + return 'active' + if state in ('done', 'skipped'): + return 'done' + if state == 'queued': + return 'attention' if queue_reason_blocks(item.get('blocked')) else 'waiting' + return 'attention' + + +def _plan_units(index, needle, now): + """(facet, kind, payload) for every plan, and every queued plan the map has no + plan row for yet, that the search keeps.""" + units = [] + for plan in index.plans: + pos = index.queue_pos.get(plan.key) + f = plan_facet(plan, now, pos[2] if pos else None) + if needle and not _matches(plan.search, needle) \ + and not any(_matches(a.search, needle) for _, a in plan.members): + continue + units.append((f, 'plan', plan)) + for m in index.machines: + for q in m.get('queues') or []: + for n, it in enumerate(q['items']): + key = '%s/%s' % (m['machine'], it['plan']) + if it['state'] != 'queued' or key in index.plan_by_key: + continue + if needle and not _matches(('%s %s %s' % (it['plan'], q['repo'], m['label'])).lower(), needle): + continue + units.append((queue_item_facet(it), 'queued', (m, q, it, n + 1))) + return units + + +def facet_counts(index, grouping='plan', needle='', now=None): + """How many items each facet holds in a grouping, under the search. Pure. + Plans count plans (and queued plans not yet on the map; unreadable plans count + under All and in `unreadable`, never under Attention); repositories and + machines count agents (and, by machine, each machine that did not answer, as + attention); queues count items (and each invalid queue file, as attention).""" + out = dict((f, 0) for f in FACETS + ('unreadable',)) + if index is None: + return out needle = (needle or '').strip().lower() + if grouping == 'plan': + facets = [f for f, _, _ in _plan_units(index, needle, now)] + elif grouping == 'queue': + facets = [] + for m in index.machines: + for q in m.get('queues') or []: + hit = not needle or needle in (q['repo'] + ' ' + m['label']).lower() + if q['invalid'] and (hit or not needle): + facets.append('attention') + facets.extend(queue_item_facet(it) for it in q['items'] + if hit or needle in it['plan'].lower()) + else: + facets = [agent_facet(a) for a in index.agents if _matches(a.search, needle)] + if grouping == 'machine': + facets.extend('attention' for m in index.machines if m['agents_state'] != 'ok' + and _matches(m['label'].lower(), needle)) + for f in facets: + out[f] += 1 + out['all'] = len(facets) + return out + + +def build_view(index, grouping='plan', needle='', facet=FOCUS, now=None): + """The groups shown for a grouping, a facet and a search. Pure.""" + needle = (needle or '').strip().lower() + want = wanted(facet) groups = [] if grouping == 'plan': - in_plan = set() - plans = sorted(index.plans, key=lambda p: (p.rank, p.label, p.plan)) - for plan in plans: + in_plan, unreadable = set(), [] # unreadable plans: a dimmed group at the very end (All only) + units = _plan_units(index, needle, now) + shown = [(f, p) for f, kind, p in units if kind == 'plan' and f in want] + for f, plan in sorted(shown, key=lambda u: (FACET_ORDER.get(u[0], 5),) + ( + attention_order(u[1], now) if u[0] == 'attention' else (0, u[1].label, u[1].plan))): members = [(r, a) for r, a in plan.members if _matches(a.search, needle)] - if needle and not members and not _matches(plan.search, needle): - continue - if plan.cls == 'completed' and not members and not needle: - continue # a finished plan with nobody on it is history, not the fleet + if not needle: + members = list(plan.members) for _, a in plan.members: in_plan.add(a.key) - tone = 'bad' if plan.needs_you else ('dim' if plan.cls == 'completed' else 'normal') + tone = 'bad' if f == 'attention' else ('dim' if plan.cls in ('completed', 'unreadable') else 'normal') group = Group(plan.key, 'plan', plan.plan, plan.label, plan, members, tone) group.queue_pos = index.queue_pos.get(plan.key) - groups.append(group) - busy = [('', a) for a in index.agents if a.key not in in_plan and a.state != 'idle' - and _matches(a.search, needle)] - idle = [('', a) for a in index.agents if a.key not in in_plan and a.state == 'idle' - and _matches(a.search, needle)] + group.facet = f + group.stale = stale_for(plan, now) + (unreadable if f == 'unreadable' else groups).append(group) + for f, kind, (m, q, it, pos) in [u for u in units if u[1] == 'queued' and u[0] in want]: + name = os.path.basename(q['repo'].rstrip('/')) or '(repository)' + reason = 'ready — starts next' if it['ready'] else (it['blocked'] or 'waiting its turn') + g = Group('queued:%s/%s' % (m['machine'], it['plan']), 'queued', it['plan'], + '%s · %s · queue %d/%d · %s' % (m['label'], name, pos, len(q['items']), reason), + None, [], 'bad' if f == 'attention' else 'normal') + g.facet = f + groups.append(g) + outside = [a for a in index.agents if a.key not in in_plan and _matches(a.search, needle) + and agent_facet(a) in want] + busy = [('', a) for a in outside if a.state != 'idle'] + idle = [('', a) for a in outside if a.state == 'idle'] if busy: groups.append(Group('busy', 'busy', 'Working outside any plan', '', None, sorted(busy, key=lambda m: m[1].key))) if idle: groups.append(Group('idle', 'idle', 'Doing nothing — free to take work', '', None, sorted(idle, key=lambda m: m[1].key), 'free')) + groups.extend(unreadable) elif grouping == 'queue': for m in index.machines: for q in m.get('queues') or []: - if needle and not any(needle in it['plan'].lower() for it in q['items']) \ - and needle not in (q['repo'] + ' ' + m['label']).lower(): + hit = not needle or needle in (q['repo'] + ' ' + m['label']).lower() + items = [it for it in q['items'] if (hit or needle in it['plan'].lower()) + and queue_item_facet(it) in want] + bad = q['invalid'] and 'attention' in want and hit + if not items and not bad and not (facet == 'all' and hit): continue name = os.path.basename(q['repo'].rstrip('/')) or '(repository)' sub = '%s · %s%s' % (m['label'], 'parallel' if q['parallel'] else 'one at a time', ' · INVALID queue file' if q['invalid'] else '') g = Group('queue:%s:%s' % (m['machine'], q['repo']), 'queue', name, sub, None, [], 'bad' if q['invalid'] else 'normal') - g.plan = (m['machine'], q['items']) + g.plan = (m['machine'], items) groups.append(g) elif grouping == 'repo': repos = {} for a in index.agents: - if _matches(a.search, needle): + if _matches(a.search, needle) and agent_facet(a) in want: repos.setdefault(a.repo or '', []).append(('', a)) for repo in sorted(repos, key=lambda r: (r == '', os.path.basename(r).lower(), r)): members = sorted(repos[repo], key=lambda m: (STATE_ORDER.index(m[1].state), m[1].key)) @@ -408,17 +592,70 @@ def build_view(index, grouping='plan', needle=''): None, members)) else: for m in index.machines: - members = [('', a) for a in m['agents'] if _matches(a.search, needle)] - if needle and not members: + down = m['agents_state'] != 'ok' + members = [('', a) for a in m['agents'] if _matches(a.search, needle) and agent_facet(a) in want] + if down: + if 'attention' not in want or (needle and not _matches(m['label'].lower(), needle)): + continue + elif not members and (needle or facet != 'all'): continue - sub = 'unreachable' if m['agents_state'] != 'ok' else '%d agents' % len(m['agents']) - tone = 'dim' if m['agents_state'] != 'ok' else 'normal' + sub = 'unreachable' if down else '%d agents' % len(m['agents']) groups.append(Group('machine:' + m['machine'], 'machine', m['label'], sub, None, sorted(members, key=lambda x: (STATE_ORDER.index(x[1].state), x[1].key)), - tone)) + 'dim' if down else 'normal')) return groups +def unreadable_hint(grouping, facet, counts): + """The one quiet line Attention shows about plans it leaves out: unreadable + plans live under All.""" + n = (counts or {}).get('unreadable', 0) + if grouping != 'plan' or not n or facet not in (FOCUS, 'attention'): + return None + return '%d unreadable plan%s: see All (5)' % (n, '' if n == 1 else 's') + + +def empty_note(grouping, facet, counts, needle='', free=0): + """What an empty view says: why it is empty, and where the rest is. `free`: agents + doing nothing, which the Plans view lists under Waiting.""" + c = counts or {} + if needle: + return 'nothing here matches "%s" · %d in All' % (needle, c.get('all', 0)) + if grouping == 'plan': + notes = { + FOCUS: 'Nothing needs you and nothing is moving · %d waiting · %d done' % (c.get('waiting', 0), + c.get('done', 0)), + 'attention': 'Nothing needs you · %d plan%s moving' % (c.get('active', 0), + '' if c.get('active', 0) == 1 else 's'), + 'active': 'Nothing is moving · %d need%s you · %d waiting' % ( + c.get('attention', 0), 's' if c.get('attention', 0) == 1 else '', c.get('waiting', 0)), + 'waiting': 'No plan is queued', + 'done': 'No plan has finished yet', + 'all': 'The map lists no plan'} + if free and facet in (FOCUS, 'attention', 'active'): + return notes.get(facet, notes[FOCUS]) + ' · %d free agent%s under Waiting' % ( + free, '' if free == 1 else 's') + elif grouping == 'queue': + notes = { + FOCUS: 'No queued plan is stuck or started · %d waiting · %d done' % (c.get('waiting', 0), + c.get('done', 0)), + 'attention': 'No queued plan is stuck · %d started · %d waiting' % (c.get('active', 0), + c.get('waiting', 0)), + 'active': 'No queued plan has started · %d waiting' % c.get('waiting', 0), + 'waiting': 'Nothing is waiting in a queue', + 'done': 'No queued plan has finished', + 'all': 'No repository has a plan queue'} + else: + notes = { + FOCUS: 'No agent needs you or is working · %d free' % c.get('waiting', 0), + 'attention': 'No agent needs you · %d working' % c.get('active', 0), + 'active': 'No agent is working · %d free' % c.get('waiting', 0), + 'waiting': 'No agent is free · %d working' % c.get('active', 0), + 'done': 'Agents are never done: the free ones are under Waiting', + 'all': 'The map lists no agent'} + return notes.get(facet, notes[FOCUS]) + + # ======================================================================= view class Line(object): @@ -509,10 +746,15 @@ def group_header(g, width): for text, style in right: line.add(text, style) else: - mark = {'idle': '○', 'busy': '●', 'repo': '▤', 'machine': '▣', 'queue': '☰'}.get(g.kind, '▸') - line.add('▌', 'free' if g.tone == 'free' else 'accent') - line.add(' %s %s ' % (mark, g.title), 'group_title') - line.add('(%d)' % (len(g.plan[1]) if g.kind == 'queue' else len(g.members)), 'dim') + mark = {'idle': '○', 'busy': '●', 'repo': '▤', 'machine': '▣', 'queue': '☰', + 'queued': '◌'}.get(g.kind, '▸') + line.add('▌', 'bad' if g.tone == 'bad' else ('free' if g.tone == 'free' else 'accent')) + if g.kind == 'queued': + line.add(' QUEUED ', 'bad_badge' if g.tone == 'bad' else 'dim_badge').add(' ') + line.add('%s ' % g.title, 'group_title') + else: + line.add(' %s %s ' % (mark, g.title), 'group_title') + line.add('(%d)' % (len(g.plan[1]) if g.kind == 'queue' else len(g.members)), 'dim') if g.subtitle: line.add(' ' + g.subtitle, 'dim') return line @@ -526,6 +768,11 @@ def render_list(groups, now, width): lines.append(group_header(g, width)) if g.kind == 'plan': p = g.plan + if p.cls == 'unreadable': + lines.append(Line(target=('plan', g.key)).add( + ' ? unreadable: %s' % UNREADABLE_WHY.get(p.why, 'the report does not say why'), 'dim')) + if getattr(g, 'stale', None): + lines.append(Line(target=('plan', g.key)).add(' ◷ no movement for %s' % span(g.stale), 'bad')) if p.current and p.cls != 'completed': lines.append(Line(target=('plan', g.key)).add(' ▶ now: ', 'accent').add(p.current, 'title')) block = (p.detail or {}).get('blocker') if p.detail else None @@ -536,15 +783,15 @@ def render_list(groups, now, width): lines.append(Line(target=('plan', g.key)).add(' nobody on the map works on this plan', 'dim')) if g.kind == 'queue': machine, items = g.plan - for n, it in enumerate(items): + for it in items: mark, style = QUEUE_MARK.get(it['state'], ('?', 'dim')) line = Line(target=('plan', '%s/%s' % (machine, it['plan']))) - line.add(' %2d. ' % (n + 1), 'dim').add(mark + ' ', style).add(pad(it['plan'], 44), 'group_title') + line.add(' %2d. ' % it.get('pos', 0), 'dim').add(mark + ' ', style).add(pad(it['plan'], 44), 'group_title') line.add(pad(it['state'], 9), style) if it['ready']: line.add('ready — starts next', 'ok') elif it['blocked'] and it['state'] == 'queued': - waiting = it['blocked'].startswith('waiting') or it['blocked'].startswith('another plan') + waiting = not queue_reason_blocks(it['blocked']) line.add(it['blocked'], 'dim' if waiting else 'bad') if it['lead']: line.add(' lead ' + it['lead'], 'dim') @@ -555,8 +802,103 @@ def render_list(groups, now, width): return [fit_line(l, width) for l in lines] -def render_header(index, age, grouping, needle, width, error=None): - """The two header rows and the tab row.""" +def render_facets(facet, counts, width, grouping='plan'): + """The facet row: (Line, spans), spans = [(x0, x1, facet)] for the mouse. The full + form ('1 Attention 2 · 2 Active 7 …') falls back to 'A2 Ac7 W3 D21 All33' when + narrow. Only Attention takes the alert tone, and only when it holds something.""" + counts = counts or {} + want = wanted(facet) + + def build(short, hints=True): + line, spans, x = Line().add(' '), [], 1 + for n, f in enumerate(FACETS): + if n and not short: + line.add(' · ', 'dim') + x += 3 + elif n: + line.add(' ') + x += 1 + k = counts.get(f, 0) + text = ('%s%d' % (FACET_SHORT[f], k)) if short else (' %d %s %d ' % (n + 1, FACET_LABEL[f], k)) + on = (f in want and facet != 'all') or f == facet + if f == 'attention' and k: + style = 'bad_badge' if on else 'bad' + elif on: + style = 'tab_on' + elif f == 'done' and grouping in ('repo', 'machine'): + style = 'dim' + else: + style = 'tab' if not short else 'dim' + line.add(text, style) + spans.append((x, x + width_of(text), f)) + x += width_of(text) + if facet == FOCUS and not short and hints: + line.add(' needs you + moving', 'dim') + if not short and hints: + line.add(' ←→ 1-5', 'dim') + return line, spans + + for short, hints in ((False, True), (False, False), (True, False)): + line, spans = build(short, hints) + if sum(width_of(t) for t, _ in line.segs) <= width: + break + return fit_line(line, width), spans + + +def header_counts(counts, plans, brain, width): + """The second header row: agent states, the plans summary, the brain. When it + does not fit it degrades in steps — the brain's details go first, then the + states compact, then the brain — so the plans summary is never cut.""" + def states(compact): + segs = [] + for state, label in (('working', 'working'), ('waiting', 'waiting'), ('idle', 'idle'), + ('unknown', 'unknown')): + n = counts.get(state, 0) + mark = {'working': '●', 'waiting': '◆', 'idle': '○', 'unknown': '?'}[state] + segs.append((('%s%d ' % (mark, n)) if compact else ('%s %d %s ' % (mark, n, label)), + state if n else 'dim')) + return segs + + def plan_summary(short=False): + return [('│ ' if short else '│ plans: ', 'dim'), + ('%d need you' % plans.get('needs_you', 0), 'bad' if plans.get('needs_you') else 'dim'), + (' · %d running · %d done ' % (plans.get('open', 0), plans.get('completed', 0)), 'dim')] + + def brain_segs(level): + if not brain or level in ('none', 'bare'): + return [] + bstate = clean(brain.get('state'), 12) + segs = [('│ brain ', 'dim'), ('◎ ', 'working' if bstate == 'ready' else 'warn')] + if level == 'min': + return segs + [(bstate, 'accent')] + segs.append(('%s %s %s' % (clean(brain.get('kind'), 12) or '-', clean(brain.get('profile'), 24) or '', + bstate), 'accent')) + if level == 'short': + return segs + last = brain.get('last') if isinstance(brain.get('last'), dict) else None + if isinstance(brain.get('asked_last_hour'), int): + segs.append((' · %d asked/h' % brain['asked_last_hour'], 'dim')) + if last: + segs.append((' · last: %s %s' % (clean(last.get('action'), 24), clean(last.get('plan'), 40)), 'dim')) + retired = brain.get('retired') if isinstance(brain.get('retired'), dict) else None + if retired and bstate != 'ready': + segs.append((' · retired: %s' % clean(retired.get('why'), 20), 'warn')) + excluded = [clean(p, 24) for p in brain.get('excluded') or [] if isinstance(p, str)] + if excluded: + segs.append((' · excluded: %s' % clean(','.join(excluded), 60), 'warn')) + return segs + + line = None + for compact, level in ((False, 'full'), (False, 'short'), (True, 'short'), (True, 'min'), (True, 'none'), + (True, 'bare')): + line = Line([(' ', 'normal')] + states(compact) + plan_summary(level == 'bare') + brain_segs(level)) + if sum(width_of(t) for t, _ in line.segs[:-1]) + width_of(line.segs[-1][0].rstrip()) <= width: + break + return line + + +def render_header(index, age, grouping, needle, width, error=None, facet=FOCUS, facet_counts=None): + """The two header rows, the tab row and the facet row.""" counts, plans, answering = index.counts() if index else ({}, {}, 0) stale = age is not None and age > STALE_AFTER tone = 'bad' if stale or age is None else ('warn' if age > AGING_AFTER else 'ok') @@ -574,34 +916,16 @@ def render_header(index, age, grouping, needle, width, error=None): used = sum(width_of(t) for t, _ in top.segs) if used + width_of(right) < width: top.add(' ' * (width - used - width_of(right))).add(right, 'dim') - second = Line().add(' ') - for state, label in (('working', 'working'), ('waiting', 'waiting'), ('idle', 'idle'), - ('unknown', 'unknown')): - n = counts.get(state, 0) - mark = {'working': '●', 'waiting': '◆', 'idle': '○', 'unknown': '?'}[state] - second.add('%s %d %s ' % (mark, n, label), state if n else 'dim') brain = ((index.daemon or {}).get('brain') if index else None) - if isinstance(brain, dict): - bstate = clean(brain.get('state'), 12) - second.add('│ brain ', 'dim').add('◎ ', 'working' if bstate == 'ready' else 'warn') - second.add('%s %s %s' % (clean(brain.get('kind'), 12) or '-', clean(brain.get('profile'), 24) or '', - bstate), 'accent') - last = brain.get('last') if isinstance(brain.get('last'), dict) else None - if isinstance(brain.get('asked_last_hour'), int): - second.add(' · %d asked/h' % brain['asked_last_hour'], 'dim') - if last: - second.add(' · last: %s %s' % (clean(last.get('action'), 24), clean(last.get('plan'), 40)), 'dim') - second.add(' ') - second.add('│ plans: ', 'dim') - second.add('%d need you' % plans.get('needs_you', 0), 'bad' if plans.get('needs_you') else 'dim') - second.add(' · %d running · %d done' % (plans.get('open', 0), plans.get('completed', 0)), 'dim') + second = header_counts(counts, plans, brain if isinstance(brain, dict) else None, width) tabs = Line().add(' ') for key, label in (('plan', 'Plans'), ('repo', 'Repos'), ('machine', 'Machines'), ('queue', 'Queues')): style = 'tab_on' if key == grouping else 'tab' tabs.add(' %s %s ' % ({'queue': 'u'}.get(key, label[0].lower()), label), style).add(' ') if needle: tabs.add(' filter: ', 'dim').add(needle, 'accent') - return [fit_line(l, width) for l in (top, second, tabs)] + facets, _ = render_facets(facet, facet_counts, width, grouping) + return [fit_line(l, width) for l in (top, second, tabs)] + [facets] def render_plan(plan, now, width): @@ -690,7 +1014,7 @@ def render_agent(a, index, now, width, screen=None, screen_note=None): def footer(mode, width, focus_ok=False): - keys = {'list': '↑↓ move ⏎ open p/r/m group / filter ? help q quit', + keys = {'list': '↑↓ move ⏎ open ←→ 1-5 view p/r/m/u group / filter ? help q quit', 'plan': '↑↓ scroll ⏎ agent esc back q quit', 'agent': '↑↓ scroll %s esc back q quit' % ('f focus pane ' if focus_ok else ''), 'help': 'esc back q quit'}[mode] @@ -707,6 +1031,9 @@ def footer(mode, width, focus_ok=False): ' plans that need you first; agents working outside plans; agents doing nothing.', 'r group by repository m group by machine u each repository\'s plan queue', '/ filter (pane, plan, repository, branch, title, machine) esc clears it', + '←→ [ ] cycle the view 1-5 Attention, Active, Waiting, Done, All (per grouping, kept)', + ' Attention: needs you (blocked, stalled, no lead, no movement for 24 h, unreachable).', + ' Active: moving. Waiting: queued or free. Done: finished. The default is Attention + Active.', '⏎ or click open a plan or an agent f focus that agent\'s pane (Herdr)', '↑↓ j k move PgUp PgDn page g G top / bottom q quit', '', @@ -796,11 +1123,15 @@ class App(object): """The watcher. Drives a Term: `size()`, `draw(y, line)`, `flush()`, `read_key(timeout) -> str | None`, `last_mouse() -> (x, y) | None`.""" - def __init__(self, term, source, link_factory=HerdrLink, clock=time.time, grouping='plan'): + def __init__(self, term, source, link_factory=HerdrLink, clock=time.time, grouping='plan', facet=FOCUS): self.term, self.source, self.clock = term, source, clock self.link_factory = link_factory self.link = None self.grouping = grouping if grouping in GROUPINGS else 'plan' + # The view of each grouping, kept for the session. + self.facets = dict((g, facet if facet in FILTERS else FOCUS) for g in GROUPINGS) + self.counts = dict((f, 0) for f in FACETS) + self.facet_spans = [] self.needle, self.typing = '', False self.mode = 'list' # list, plan, agent, help self.stack = [] # previous (mode, target, scroll) @@ -824,16 +1155,37 @@ def refresh_data(self): self.link = self.link_factory(self.source.fleet) if self.source.fleet else None self.dirty = True + @property + def facet(self): + return self.facets[self.grouping] + + def set_facet(self, facet): + if facet in FILTERS and facet != self.facet: + self.facets[self.grouping] = facet + self.sel_target, self.sel, self.scroll = None, 0, 0 + self.dirty = True + + def step_facet(self, step): + """Cycle: the default view, then each facet.""" + n = FILTERS.index(self.facet) if self.facet in FILTERS else 0 + self.set_facet(FILTERS[(n + step) % len(FILTERS)]) + def rebuild(self, now): width = self.width + # Counts and views are built here, once per change; a tick only redraws them. + self.counts = facet_counts(self.index, self.grouping, self.needle, now) if self.mode == 'list': - self.groups = build_view(self.index, self.grouping, self.needle) if self.index else [] + self.groups = build_view(self.index, self.grouping, self.needle, self.facet, now) \ + if self.index else [] self.lines = render_list(self.groups, now, width) if not self.lines: - note = ('no agent matches "%s"' % self.needle) if self.needle else ( + note = empty_note(self.grouping, self.facet, self.counts, self.needle, + self.index.counts()[0].get('idle', 0)) if self.index else \ 'no map on this machine yet — start `herdr-peers autopilot --loop`' - if self.index is None else 'the map lists no agent') self.lines = [fit_line(Line().add(' ' + note, 'dim'), width)] + hint = unreadable_hint(self.grouping, self.facet, self.counts) if self.index else None + if hint: + self.lines.append(fit_line(Line().add(' ◌ ' + hint, 'dim'), width)) self.place_selection() elif self.mode == 'plan': plan = self.index.plan_by_key.get(self.target[1]) if self.index else None @@ -862,7 +1214,7 @@ def place_selection(self): # -- drawing ----------------------------------------------------------- def body_rows(self): - return max(1, self.height - 5) + return max(1, self.height - HEADER_ROWS - 2) def draw(self, now): w, h = self.term.size() @@ -875,14 +1227,17 @@ def draw(self, now): self.term.flush() return age = self.source.age(now) + if self.dirty: + self.rebuild(now) header = render_header(self.index, age, self.grouping, - self.needle + ('▏' if self.typing else ''), w, self.source.error) + self.needle + ('▏' if self.typing else ''), w, self.source.error, + self.facet, self.counts) + self.facet_spans = render_facets(self.facet, self.counts, w, self.grouping)[1] for y, line in enumerate(header): self.term.draw(y, line) if self.dirty: - self.rebuild(now) self.dirty = False - self.term.draw(3, fit_line(Line().add('─' * w, 'rule'), w)) + self.term.draw(HEADER_ROWS, fit_line(Line().add('─' * w, 'rule'), w)) rows = self.body_rows() if self.mode == 'list': if self.sel < self.scroll: @@ -895,7 +1250,7 @@ def draw(self, now): line = self.lines[at] if at < len(self.lines) else fit_line(Line(), w) if self.mode == 'list' and at == self.sel and line.target: line = Line([(t, 'selected') for t, _ in line.segs], line.target) - self.term.draw(4 + i, line) + self.term.draw(HEADER_ROWS + 1 + i, line) more = len(self.lines) - self.scroll - rows status = Line().add(' ' + (self.message or ''), 'warn') if more > 0: @@ -977,6 +1332,12 @@ def on_key(self, key, now): self.move(-10 ** 6) elif key == 'G': self.move(10 ** 6) + elif key in ('left', '[') and self.mode == 'list': + self.step_facet(-1) + elif key in ('right', ']') and self.mode == 'list': + self.step_facet(1) + elif key in ('1', '2', '3', '4', '5') and self.mode == 'list': + self.set_facet(FACETS[int(key) - 1]) elif key in ('p', 'r', 'm', 'u') and self.mode == 'list': self.grouping = {'p': 'plan', 'r': 'repo', 'm': 'machine', 'u': 'queue'}[key] self.sel_target, self.sel, self.scroll, self.dirty = None, 0, 0, True @@ -1015,7 +1376,12 @@ def on_mouse(self, event): if not event: return x, y, kind = event - row = y - 4 + if y == HEADER_ROWS - 1 and self.mode == 'list' and kind in ('click', 'double'): + for x0, x1, facet in self.facet_spans: + if x0 <= x < x1: + self.set_facet(facet) + return + row = y - HEADER_ROWS - 1 if row < 0 or row >= self.body_rows(): return at = self.scroll + row @@ -1177,7 +1543,7 @@ def read_key(self, timeout): '\x08': 'backspace', '\t': 'tab'}.get(ch, ch) names = {c.KEY_UP: 'up', c.KEY_DOWN: 'down', c.KEY_PPAGE: 'pgup', c.KEY_NPAGE: 'pgdn', c.KEY_ENTER: 'enter', c.KEY_BACKSPACE: 'backspace', c.KEY_RESIZE: 'resize', - c.KEY_HOME: 'g', c.KEY_END: 'G'} + c.KEY_HOME: 'g', c.KEY_END: 'G', c.KEY_LEFT: 'left', c.KEY_RIGHT: 'right'} if ch == c.KEY_MOUSE: try: _id, x, y, _z, state = c.getmouse() @@ -1200,31 +1566,41 @@ def last_mouse(self): return self.mouse -def snapshot(source, now, width=100, grouping='plan'): +def snapshot(source, now, width=100, grouping='plan', facet=FOCUS): """The fleet view as plain text, once: for agents, pipes and checks.""" source.poll() index = Index(source.fleet) if source.fleet else None + counts = facet_counts(index, grouping, '', now) out = [l.text().rstrip() for l in render_header(index, source.age(now), grouping, '', width, - source.error)] + source.error, facet, counts)] out.append('─' * width) if index is None: out.append(' no map on this machine yet — start `herdr-peers autopilot --loop`') else: - out.extend(l.text().rstrip() for l in render_list(build_view(index, grouping), now, width)) - for plan in sorted(index.plans, key=lambda p: (p.rank, p.plan)): + groups = build_view(index, grouping, '', facet, now) + lines = render_list(groups, now, width) + if lines: + out.extend(l.text().rstrip() for l in lines) + else: + out.append(' ' + empty_note(grouping, facet, counts, '', index.counts()[0].get('idle', 0))) + hint = unreadable_hint(grouping, facet, counts) + if hint: + out.append(' ◌ ' + hint) + shown = [g.plan for g in groups if g.kind == 'plan'] + for plan in sorted(shown, key=lambda p: (p.rank, p.plan)): if plan.cls in ('open', 'blocked'): out.append('') out.extend(l.text().rstrip() for l in render_plan(plan, now, width)) return '\n'.join(out).rstrip() + '\n' -def run_curses(path, grouping='plan'): +def run_curses(path, grouping='plan', facet=FOCUS): """Start the live watcher in this terminal.""" import curses def main(stdscr): os.environ.setdefault('ESCDELAY', '25') - app = App(CursesTerm(curses, stdscr), FileSource(path), grouping=grouping) + app = App(CursesTerm(curses, stdscr), FileSource(path), grouping=grouping, facet=facet) return app.run() os.environ.setdefault('ESCDELAY', '25') diff --git a/.agents/skills/herdr-peers/scripts/herdr_peers.py b/.agents/skills/herdr-peers/scripts/herdr_peers.py index 7279ab9..27949b4 100755 --- a/.agents/skills/herdr-peers/scripts/herdr_peers.py +++ b/.agents/skills/herdr-peers/scripts/herdr_peers.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 -"""herdr-peers — protocol 1 over the Herdr CLI (python3 standard library only). +"""herdr-peers — protocol 2 (lead notices of granted plans; every other message stays protocol 1) +over the Herdr CLI (python3 standard library only). Verbs: ask, notify, reply, list, wait, log, check, cancel, status, lanes, lead, debate (debate.py). See ../protocol.md for the @@ -33,7 +34,7 @@ import sys import time -VERSION = '2.0.0' +VERSION = '2.1.0' PROTOCOL = 2 # the highest protocol this helper speaks (metadata.protocol) BASE_PROTOCOL = 1 # what every message is stamped with, except a granted lead notice SUPPORTED_PROTOCOLS = ('1', '2') @@ -54,7 +55,7 @@ ULID_RE = re.compile(r'^[0-7][0-9A-HJKMNP-TV-Z]{25}$') MACHINE_RE = r'(?:local|[A-Za-z0-9][A-Za-z0-9._-]{0,63})' # never starts with '-' PANE_RE = r'[A-Za-z0-9]{1,32}:[A-Za-z0-9]{1,32}' -ADDR_RE = re.compile(r'^(%s):(%s)$' % (MACHINE_RE, PANE_RE)) +ADDR_RE = re.compile(r'^(%s):(%s)\Z' % (MACHINE_RE, PANE_RE)) # \Z: no trailing newline TOKEN_RE = re.compile(r'([a-z][a-z-]*)=(\S+)') DEPTH_RE = re.compile(r'[0-9]{1,3}') ASK_KEYS = frozenset(['protocol', 'from', 'reply', 'depth', 'id']) @@ -3302,6 +3303,7 @@ def cmd_fleet_ui(args): fleet_ui = load_fleet_ui() path = os.path.join(load_fleet_report().state_root(), load_fleet_report().FLEET_FILE) grouping = args.group or 'plan' + facet = args.filter or fleet_ui.FOCUS if os.environ.get('HERDR_ENV') == '1': # Lets the watcher tell whether it runs on the daemon's own Herdr server. os.environ['HERDR_PEERS_UI_SERVER'] = state_key(Store().server_id)[:24] @@ -3310,13 +3312,13 @@ def cmd_fleet_ui(args): width = args.width or shutil.get_terminal_size((100, 40)).columns if not 40 <= width <= 400: raise Stop(EXIT_USAGE, '--width must be between 40 and 400') - sys.stdout.write(fleet_ui.snapshot(fleet_ui.FileSource(path), time.time(), width, grouping)) + sys.stdout.write(fleet_ui.snapshot(fleet_ui.FileSource(path), time.time(), width, grouping, facet)) return EXIT_OK try: - return fleet_ui.run_curses(path, grouping) + return fleet_ui.run_curses(path, grouping, facet) except Exception as exc: # no curses, a dumb terminal: say so and print the text view warn('fleet ui: cannot start the live view (%s); printing a snapshot' % safe(type(exc).__name__)) - sys.stdout.write(fleet_ui.snapshot(fleet_ui.FileSource(path), time.time(), 100, grouping)) + sys.stdout.write(fleet_ui.snapshot(fleet_ui.FileSource(path), time.time(), 100, grouping, facet)) return EXIT_OK @@ -3809,7 +3811,15 @@ def record(self, addr, kind, choice, outcome, dry_run, plan=None): note = ' '.join(filter(None, [ 'keys=%s' % ','.join(choice.keys) if choice.keys else None, 'option=%d' % choice.option if choice.option is not None else None, - 'action=%s' % choice.action, 'dry_run' if dry_run else None])) + 'action=%s' % choice.action, 'dry_run' if dry_run else None, + # Why a brain was retired and which profile was excluded: fixed words or a + # checked profile name, never free text. + 'why=%s' % choice.why if choice.cls in BRAIN_WHY_CLASSES and isinstance(choice.why, str) + and BRAIN_WHY_RE.fullmatch(choice.why) else None, + # The likely cause of a brain that started without approvals: a coding-agents-kit + # that does not pass the CLI's own ask flag (fixed in 1.5.0, with token metering). + 'hint=upgrade_coding_agents_kit' if choice.cls == 'brain_replaced' + and choice.why == 'permission_mode' else None])) self.store.append(make_record(outcome, 'autopilot', new_ulid(), addr, 'local:%s' % self.pane, kind=kind, reason=choice.cls, note=note, plan=plan)) @@ -3945,6 +3955,10 @@ def autopilot_options(store, pid): return data +BRAIN_WHY_CLASSES = ('brain_replaced', 'brain_profile_excluded') +BRAIN_WHY_RE = re.compile(r'[a-z_]{1,32}|@[A-Za-z0-9._-]{1,40}') + + def autopilot_status(store): pid = autopilot_pid(store) log_path, _ = autopilot_files(store) @@ -3960,6 +3974,20 @@ def autopilot_status(store): print(' options: %s' % safe(' '.join(autopilot_option_argv(opts)))) if info.get('mode') == 'background': print(' log: %s' % log_path) + brain = ((load_fleet_report().read_fleet()[0] or {}).get('daemon') or {}).get('brain') \ + if opts.get('brain') else None + if isinstance(brain, dict): + retired = brain.get('retired') if isinstance(brain.get('retired'), dict) else {} + print(' brain: %s %s %s; excluded profiles: %s; last retired: %s' % ( + safe(brain.get('state')), safe(brain.get('kind') or '-'), safe(brain.get('profile') or '-'), + safe(', '.join(str(p) for p in brain.get('excluded') or []) or 'none'), + safe('%s (%s, %s)' % (retired.get('why'), retired.get('profile') or '-', retired.get('at')) + if retired else 'never'))) + if retired.get('why') == 'permission_mode' or brain.get('excluded'): + print(' brain: a profile started in a mode that skips approvals; coding-agents-kit ' + 'before 1.5.0 does not pass the CLI\'s own ask flag, so upgrade it ' + '(`ak update`), or give the profile an ask-mode default, then restart ' + 'autopilot') for rec in [r for r in store.records() if r.get('role') == 'autopilot'][-10:]: print('%s %s %s %s %s' % (safe(rec.get('ts')), safe(rec.get('state')), safe(rec.get('target')), safe(rec.get('reason')), @@ -4272,10 +4300,10 @@ def cmd_autopilot(args): if not args.brain: raise Stop(EXIT_USAGE, '--brain-kinds and --brain-model need --brain') import brain as brain_module - kinds = [k for k in (args.brain_kinds or 'claude,codex,grok').split(',') if k] + kinds = [k for k in (args.brain_kinds or ','.join(brain_module.DEFAULT_KINDS)).split(',') if k] if not kinds or len(kinds) > 8 or not all(brain_module.KIND_RE.fullmatch(k) for k in kinds): raise Stop(EXIT_USAGE, '--brain-kinds takes agent kinds in priority order, e.g. ' - 'claude,codex,grok') + 'claude,codex') models = {} for raw in args.brain_model or []: kind, _, model = raw.partition('=') @@ -4421,7 +4449,8 @@ def build_parser(): p = argparse.ArgumentParser( prog='herdr-peers', description='Ask any agent in any Herdr pane, on any machine, and get one ' - 'authorized reply back (protocol 1).') + 'authorized reply back (protocol 2; every message but a granted ' + 'plan\'s lead notice stays protocol 1).') p.add_argument('--version', action='version', version='herdr-peers %s (protocol %d)' % (VERSION, PROTOCOL)) p.add_argument('--skill', action='store_true', help='print SKILL.md and exit') @@ -4645,7 +4674,8 @@ def build_parser(): help='with --loop: launch and keep a dedicated decision agent (ask mode) and ' 'ask it what the rules cannot decide; it chooses among fixed actions only') ap.add_argument('--brain-kinds', metavar='KINDS', - help='with --brain: agent kinds in priority order (default claude,codex,grok)') + help='with --brain: agent kinds in priority order (default claude: the only kind whose ' + 'answers the daemon approves for now)') ap.add_argument('--brain-model', action='append', metavar='KIND=MODEL', help='with --brain: the model for a kind, e.g. claude=sonnet (repeatable)') ap.add_argument('--notify-env', action='append', metavar='NAME', @@ -4659,8 +4689,10 @@ def build_parser(): fl.add_argument('--json', action='store_true', help='herdr-peers/fleet-v1 JSON') fl.add_argument('--snapshot', action='store_true', help='with ui: draw the view once as text and exit') - fl.add_argument('--group', choices=['plan', 'repo', 'machine'], + fl.add_argument('--group', choices=['plan', 'repo', 'machine', 'queue'], help='with ui: how agents are grouped first (default plan)') + fl.add_argument('--filter', choices=['attention', 'active', 'waiting', 'done', 'all'], + help='with ui: the view to show (default: attention and active together)') fl.add_argument('--width', type=int, help='with ui --snapshot: columns (40-400)') pl = sub.add_parser('plans', help='the plans led on this machine, with each plan\'s state ' '(read-only; works outside a Herdr pane)') diff --git a/.dwp/config.json b/.dwp/config.json index c88941a..888dbea 100644 --- a/.dwp/config.json +++ b/.dwp/config.json @@ -16,7 +16,7 @@ }, "herdr": { "enabled": true, - "version": "v2.0.0", + "version": "v2.1.0", "note": "repo-local install (.agents/skills/herdr-peers)" } }, diff --git a/AGENTS.md b/AGENTS.md index 86b3715..141a3e5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -2,13 +2,13 @@ Public Neovim configuration. Language: English. Conventional commits. GPL-3.0. -DWP standard: 7.0.0 (onboarded 2026-10-03; upgraded 2026-10-03, 2026-10-09, 2026-10-11, 2026-10-12, 2026-10-13, 2026-10-25, 2026-11-15 and 2026-11-16; skill 7.12.2, vendored 2026-11-16; herdr-peers skill v2.0.0 vendored 2026-11-16) +DWP standard: 7.0.0 (onboarded 2026-10-03; upgraded 2026-10-03, 2026-10-09, 2026-10-11, 2026-10-12, 2026-10-13, 2026-10-25, 2026-11-15 and 2026-11-16; skill 8.0.0, vendored 2026-11-16; herdr-peers skill v2.1.0 vendored 2026-11-16) ## Product DeepWorkPlan Vim is the terminal editor for [Deep Work Plan](https://deepworkplan.com). Host install: download `https://deepworkplan.com/vim/install.sh` (or the release asset), verify it against `install.sh.sha256` / `SHA256SUMS`, then `bash install.sh` — it installs its own release tag (README → Install); or manually: clone the tag to `~/.config/nvim` and `lua install.lua`. Never spell a download piped into a shell in this repo (`scripts/check-public-hygiene.sh` rejects it). This repo **is** the config: in the contributor container `/workspace` is linked to `~/.config/nvim` at start (the release config the image bakes through the installer is only its standalone fallback); never clone a second copy of the repo inside the container — `/workspace` is the only working tree. -Position: DeepWorkPlan's editor — offered as the optional `vim` addon of DWP v7 (pinned by tag, never required; the editor never requires DWP either). That line is about the *editor* as an onboard addon upstream; the harness in this repo runs skill 7.12.2 per the provenance line above; the addon registry and the benchmark flags (`benchmark.enabled`, `benchmark.learnings`: a plan then closes with `analysis_results/learnings.json` and `DWP_REPORT.md`) live in the tracked `.dwp/config.json`. +Position: DeepWorkPlan's editor — offered as the optional `vim` addon of DWP v7 and v8 (pinned by tag, never required; the editor never requires DWP either). That line is about the *editor* as an onboard addon upstream; the harness in this repo runs skill 8.0.0 per the provenance line above; the addon registry and the benchmark flags (`benchmark.enabled`, `benchmark.learnings`: a plan then closes with `analysis_results/learnings.json` and `DWP_REPORT.md`) live in the tracked `.dwp/config.json`. ## Product focus @@ -139,13 +139,15 @@ Gates are selected from the touched surface, with the full set above as the fall - **Design system (accepted, cli-output)** — [docs/DESIGN.md](docs/DESIGN.md) records the existing Neovim TUI source, highlight roles and layout guards. - **Herdr (accepted, repo-local)** — vendored skill at - `.agents/skills/herdr-peers/` (v2.0.0, protocol 2, tag-pinned in + `.agents/skills/herdr-peers/` (v2.1.0, protocol 2, tag-pinned in `skills-lock.json`): the delegation transport for plans that hand work to another pane or machine, plus native debates; `autopilot` is an optional - daemon **only a human starts** — never a message, peer or plan — and 2.0.0 + daemon **only a human starts** — never a message, peer or plan — and 2.x adds lead appointment (`--appoint`), the opt-in, fail-closed autopilot brain (`--brain`, needs ak ≥ 1.3.0) and the plan-queue consumer for the - pack's `.dwp/queue.json`; the editor consumes its `lanes-v1` snapshots and + pack's `.dwp/queue.json`; 2.1.0 adds the fleet UI views (Attention, Active, + Waiting, Done, All), denies permission prompts the daemon cannot accept and + reads the v8 blocker classes; the editor consumes its `lanes-v1` snapshots and queue schema read-only (protocol 1 surfaces unchanged). When `herdr-peers` is not on `PATH`, call `.agents/skills/herdr-peers/scripts/herdr-peers`. Herdr itself stays machine-level; never required. diff --git a/CHANGELOG.md b/CHANGELOG.md index 8463a90..4aeaeaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,17 @@ section below, and its assets ship with `SHA256SUMS`. Pin by tag. default applied to every absent key. Everything renders only when the data exists — a v7 plan renders byte-identically to before — and the editor never writes plan state. New `queue` smoke section. +- **Harness:** the vendored DeepWorkPlan pack moves to 8.0.0 (DWP standard + 8.0.0), all 188 files verified against its release `SHA256SUMS`. It brings + the v8 contract generation (`plan-contract/v8` with the optional `autonomy` + block), `plan-snapshot/v8` structured blockers, the `dwp-queue-v1` + plan-queue writer and `spec/LOOP_ENGINEERING.md`; the three v8 schemas the + editor surfaces above read are frozen at this tag. Existing plans keep + their recorded generation. Together with it, the vendored herdr-peers skill + moves to v2.1.0 (all 37 files verified), the release the pack's herdr + descriptor pins: fleet UI views, denial of permission prompts the daemon + cannot accept, and the v8 blocker classes. The herdr addon registry entry + pins `v2.1.0`. - **Harness:** the vendored DeepWorkPlan pack moves to 7.12.2, all 182 files verified against the release `SHA256SUMS`. The patch makes the herdr addon accept herdr-peers protocol 1 and 2 and pins v2.0.0, so the vendored pack diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 19765cd..e313d01 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -156,35 +156,37 @@ succeeded; it is the one check branch protection requires ## DWP harness layer -`.agents/` carries the vendored skills (deepworkplan 7.12.2, ai-diff-reviewer 3.3.16, -dailybot 3.23.17, herdr-peers 2.0.0), the thin `dwp-*` command delegators, agent personas, and the +`.agents/` carries the vendored skills (deepworkplan 8.0.0, ai-diff-reviewer 3.3.16, +dailybot 3.23.17, herdr-peers 2.1.0), the thin `dwp-*` command delegators, agent personas, and the catalog; `.claude`/`.cursor` are symlinks to it. Plan output lives in `.dwp/`, gitignored except the tracked addon registry `.dwp/config.json` (DWP v7 CONFIG §1); scratch in gitignored `tmp/`. ### Vendored provenance -The 2026-10-25 dogfood upgrade — refreshed 2026-11-16 (pack v7.12.2, -herdr-peers v2.0.0) — uses the pack's tree-URL install and all-addons +The 2026-10-25 dogfood upgrade — refreshed 2026-11-16 (pack v8.0.0, +herdr-peers v2.1.0) — uses the pack's tree-URL install and all-addons planner. `skills-lock.json` records each release ref and the installer's computed content hash. Installed skill trees must match the tagged sources byte for byte; local adaptations are inspected before replacement. | Skill | Tag | Verified commit | | --- | --- | --- | -| deepworkplan | v7.12.2 | `9569b69442e19ccf029d895b6eee302c8846bc98` | +| deepworkplan | v8.0.0 | `ff96b9ec465f21cb8faf4e83fd6d6b910dd0c41d` | | ai-diff-reviewer | v3.3.16 | `0083490ebc3a6e3dc87922c1ee711578c196e2d6` | | dailybot | v3.23.17 | `0ccf31329d638915e5c282c91d4f3ab6547140b4` | -| herdr-peers | v2.0.0 | `d2008d7264e5ff231ba28fcc20ee3a17c3a6306c` | +| herdr-peers | v2.1.0 | `49e6ab28ac87d95ec18d8ac819221be53079414a` | The pack's release `SHA256SUMS` digest is -`8c44afadc56fa72c33077eb932810520b3b3a424feaab8a719550f15fd8e53ea`; +`cb877b165b94fb8a23561ffb6dcc71e7ab9e92ad44c2f2eeef2378cc62a91408` +(188 entries; DWP standard 8.0.0, the v8 schemas frozen at the tag); the reviewer's (its release archives) is `af29e32655378c3f4efc7f05fa3b92c87040e3ba45a8f980e1179a7f6c1bc398`, and its installed tree is checked against the tag. Dailybot ships no checksum manifest; its tag commit and installed bytes are -verified instead. herdr-peers (installed repo-locally, refreshed 2026-11-15) is -checked file by file against its release `SHA256SUMS` (all 37 skill files). `.review/extension.md` and the existing Dailybot hooks stay +verified instead. herdr-peers (installed repo-locally, refreshed 2026-11-16 to v2.1.0) is +checked file by file against its release `SHA256SUMS` (all 37 skill files; +digest `02837b819e79033cc9ea1fa0498c2fcd5966f86117080e16a7e44fb976966787`). `.review/extension.md` and the existing Dailybot hooks stay repository-owned. No authentication material belongs in the vendored trees. ### Orchestra lanes diff --git a/skills-lock.json b/skills-lock.json index c90dedf..9ad285a 100644 --- a/skills-lock.json +++ b/skills-lock.json @@ -17,11 +17,11 @@ }, "deepworkplan": { "source": "DailybotHQ/deepworkplan-skill", - "ref": "v7.12.2", - "commit": "9569b69442e19ccf029d895b6eee302c8846bc98", + "ref": "v8.0.0", + "commit": "ff96b9ec465f21cb8faf4e83fd6d6b910dd0c41d", "sourceType": "github", "skillPath": "skills/deepworkplan/SKILL.md", - "computedHash": "21ece40c143ee9cd477fba1252ab50295ff3e51ae821f57171427c6c0c8b49b0" + "computedHash": "00b3ade560b46232ace7cc838ee1770533e825b4ab4153cbfdaff99141b37e49" }, "fix-frontmatter": { "source": "DailybotHQ/deepworkplan-skill", @@ -31,11 +31,11 @@ }, "herdr-peers": { "source": "DailybotHQ/herdr-peers", - "ref": "v2.0.0", - "commit": "d2008d7264e5ff231ba28fcc20ee3a17c3a6306c", + "ref": "v2.1.0", + "commit": "49e6ab28ac87d95ec18d8ac819221be53079414a", "sourceType": "github", "skillPath": "skills/herdr-peers/SKILL.md", - "computedHash": "e49489e5d69e978f1318917eee7b714145e682ae718a98fd207d832e0a7b55c9" + "computedHash": "ea356ee6c7946b7779720953c2c42f6f599821a8218376620dabc48b985ab08d" }, "shellcheck-fix": { "source": "DailybotHQ/deepworkplan-skill",