protocol-456 · diff

git:20260903.5ff2fe3 to git:20260905.4167a43

45 added, 43 removed. Audit A to A.

---
name: protocol-456
- description: 5-phase engineering pipeline triggered by '456' or 'по 456' for executing ONE track from an already-approved plan (e.g. an SDD remediation spec) - core-developer implements, tests prove the fix, one independent reviewer checks code+tests together, doc-sync closes it out. Skips Protocol 123's research/plan-formulation/plan-review-swarm/user-approval-gate phases because the plan already went through its own review before this protocol starts. Once every track in the current batch has landed, a Batch Completion Gate mirrors CI's own full-suite check locally before the branch is reported ready. Trigger only on the literal keyword '456'/'по 456' - never self-invoke.
+ description: 6-phase lightweight engineering pipeline (Phases 0-5) triggered by '456', 'по 456', 'таска по 456', or 'исправь по 456' for fast-track tasks (everyday bugfixes, small features, or pre-scoped tracks). Slashes token and time overhead by 80-85% compared to Protocol 123 via compact SDD planning, on-demand web research, in-session TDD, single-reviewer risk audit, and deterministic runner scripts/protocol-456.mjs. Pre-scoped tracks skip Phases 1 & 2 directly to Phase 3. Never self-invoke.
---
- # The 456 Protocol Skill (v1.2)
+ # The 456 Protocol Skill (v2.0)
## Purpose
- A sibling of Protocol 123 with 5 phases instead of 9: for the specific case where a plan already exists and has already been reviewed, executing one already-decided, already-scoped unit of work (a "track") skips the research, plan-drafting, plan-review-swarm, and user-approval-gate phases that already happened when the plan itself was produced and reviewed - repeating them here would be redundant ceremony, not additional safety. Modeled directly on how EITR's own `master_sdd_remediation_spec.md` Track 10 (MCP command-injection fix) was actually executed end-to-end and confirmed effective by the maintainer.
+ A lightweight sibling of Protocol 123 with a streamlined 6-phase lifecycle (Phases 0-5) designed for 80% of everyday engineering tasks (bugfixes, targeted features, AST adjustments, or pre-scoped tracks). Slashes token consumption and latency by 80-85% compared to Protocol 123 by eliminating multi-agent debate, removing review-arbiter bureaucracy, bounding web searches to high-quality official sources, and relying on a single specialized domain reviewer. Backed by deterministic runner `scripts/protocol-456.mjs`.
- ## Precondition (checked before triggering, not a phase)
+ ## Precondition & Fast-Track Intake (Phase 0)
- 456 requires an already-reviewed plan/track as input, not something drafted in the same breath as the request. A track qualifies when all three are true:
+ Protocol 456 handles both general fast-track tasks and pre-scoped plan tracks:
- 1. It names exact target file(s).
- 2. It gives step-by-step edits, or a concrete before/after code description.
- 3. It states its own verification command (a test file path, a build command, or an equivalent runnable check).
+ 1. **Pre-Scoped Track (Fast-Track Branch)**: If input already names exact target files, step-by-step edits, and a runnable test verification command (e.g. from an SDD remediation spec), Phase 0 verifies the baseline and fast-tracks directly to Phase 3 (In-Session TDD), skipping planning Phases 1 and 2 while strictly retaining Phase 4 (Single-Reviewer Risk Audit).
+ 2. **Standard Fast-Track Task**: If input is an arbitrary request (e.g. "исправь баг в CLI по 456"), Phase 0 verifies working tree cleanliness, Phase 1 formulates a compact SDD plan with on-demand web research, and Phase 2 secures fast human approval before TDD.
- **Good** (qualifies): "Track 10: replace the shell-string `spawnSync` call in `packages/engine/src/plan/templates/mcp-server.ts`'s `executeTestRun` with argv-based execution (`shell: false`); verify via `npx vitest run packages/engine/test/mcp-protocol-system.test.ts`." - names the file, gives the specific edit, states the verification command.
+ ## Activation Rules & Trigger Phrases
- **Bad** (does not qualify): "Fix the MCP injection issue." - no file, no steps, no verification command. All 3 properties fail; this is not 456. Either produce a plan first (`sdd-plan-writer`, `architect`, or Protocol 123 from scratch), or - if small enough not to need a written plan at all - handle it as ordinary Tier 1 direct work per Section 13.
+ - **Strict Trigger Rule (Explicit Activation Only)**: Activated STRICTLY AND ONLY when the user explicitly invokes it via `456`, `по 456`, `таска по 456`, or `исправь по 456` (e.g. "давай по 456", "пофикси баг по 456", "трек 7 по 456"). Never self-triggered on the assistant's own judgment.
+ - Requests without a 456 trigger phrase are executed as ordinary direct work per Section 13.
+ - **Proactive Suggestion (User Decision Gateway)**: For targeted, low-to-medium complexity tasks or ready plan tracks, the assistant may propose Protocol 456 (e.g. _"Хотите выполнить эту задачу по протоколу 456?"_). Launched only upon explicit user consent.
- ## Activation Rules & Trigger Phrases
+ ## 6-Phase Lifecycle (Phases 0-5)
- - **Strict Trigger Rule (Explicit Activation Only)**: activated STRICTLY AND ONLY when the user explicitly invokes it via `456` / `по 456` (e.g. "давай по 456", "трек 7 по 456") - the same explicit-only discipline as Protocol 123. Never self-triggered on the assistant's own judgment that a plan "looks ready."
- - A ready-plan track requested WITHOUT the "456" keyword is executed as ordinary Tier 1/Tier 2 direct work per Section 13 instead - 456 is opt-in, not a silent default just because a plan document happens to exist.
- - **Proactive Suggestion (User Decision Gateway)**: when a plan/track meeting the Precondition above exists and the user asks to implement it, the assistant may propose Protocol 456 (e.g. _"Хотите, чтобы я прогнал этот трек по протоколу 456?"_). Launched only on the user's explicit agreement, same as 123.
+ ### Phase 0: Intake & Quick Baseline Check
- ## 5-Phase Lifecycle
+ - Verify target files fresh with `Read` (Context Freshness - never from memory).
+ - Ensure git working tree is clean via `git status --porcelain`.
+ - Verify build baseline: run `node scripts/protocol-456.mjs verify-phase 0` (or `npm run build`).
+ - If input satisfies the Pre-Scoped Track condition, fast-track directly to Phase 3.
- ### Phase 0: Ready-Plan Intake
+ ### Phase 1: Focused Plan & On-Demand Web Research
- - Read the plan track in full with a fresh `Read` call (Context Freshness - never from memory, even if read minutes ago). Confirm all 3 Precondition properties are present; if any is missing, stop - that is the Precondition failing, not a gap to improvise around.
- - Branch discipline applies in full: sync `main` first (Fetch Before Branching), then a dedicated `fix/`/`feature/` branch matching the track's Conventional Commits type - never stack an unrelated track onto an existing branch.
- - No research phase, no `architect`, no plan-review swarm, no user-approval gate - the plan already carries that authority (Precondition).
- - If reading the track surfaces a genuine contradiction - the plan names a file, line, or API that does not exist in the current codebase, or two of the plan's own steps directly conflict - stop and ask the user rather than guessing. A cosmetic wording issue, or a stale line number the surrounding code still makes unambiguous, is not a contradiction and does not stop the phase.
+ - Author a compact SDD plan (1-2 pages) containing an Executive Summary, concise ACs in EARS format, exact file paths, and test verification commands.
+ - **On-Demand Web Research**: When researching third-party library behaviors, breaking changes, or modern best practices, perform targeted searches via `WebSearch` against official documentation (e.g. `playwright.dev`, `nodejs.org`, `github.com`, `vitest.dev`). Focus on high-quality findings, pitfalls, and concrete code patterns.
+ - Do not spawn multi-agent research swarms, and do not perform heavy ISTQB syllabus taxonomies.
- ### Phase 1: Implementation
+ ### Phase 2: Human Sign-Off Gate
- - `core-developer` implements the track's steps as specified; for a track at or under Section 13's own Tier 1 threshold (at most 5 files, at most 1 new language runner, at most 1 new configuration/generator engine), do it directly in-session instead of spawning a subagent, per this project's standing Claude-Code-direct-work preference.
- - `Read` before every `Edit` (Context Freshness); zero opportunistic refactoring beyond the track's own stated scope (Strict Scope Boundaries).
- - If the track's own steps turn out to be wrong or incomplete once the real code is read (a prerequisite the plan's author didn't know about, a stale line number, a false assumption about current state), fix the plan document itself alongside the code - the plan is a living record of what actually happened, not only an upfront prediction.
+ - Present the compact plan artifact to the user with `RequestFeedback: true`.
+ - Zero code modifications are permitted until the user explicitly confirms approval (e.g. "approve", "делай", "да").
- ### Phase 2: Tests
+ ### Phase 3: In-Session TDD (Red -> Green -> Refactor)
- - Run the track's own stated verification command first. If the track fixes a defect (a bug, a vulnerability, a false positive), also add or extend a targeted regression test that demonstrably fails against the pre-fix code and passes after - proof the specific problem is closed, not just "the existing suite is still green."
- - `test-writer` may be used for test synthesis on a track above Section 13's Tier 1 threshold (Phase 1); at or under that threshold, write the test directly in-session, matching Phase 1's own rule.
- - **If the verification command fails after implementation**: treat this as a defect in the implementation, not a stopping point. Apply the Two-Strike Rule - at most 2 fix attempts on the same failure; if it still fails, `git checkout -- <file>` to roll back and escalate to the user with root-cause analysis, exactly as Section 2 requires everywhere else. Do not proceed to Phase 3 with a failing verification command.
+ - Phase 3a (RED): Write or extend a targeted failing test proving the defect or new capability. Verify failure.
+ - Phase 3b (GREEN): Implement the minimal code edit using `Edit`. Run target test until 100% green.
+ - Phase 3c (REFACTOR): Clean up temporary code, run linter/formatter.
+ - **Two-Strike Rule**: If test verification fails twice consecutively on the same issue, revert modified tracked files (`git checkout -- <file>`) and delete declared new files, then escalate to the user with root-cause analysis. Never use `git clean -fdx` or `git reset --hard`.
- ### Phase 3: Review (code and tests together, one diff)
+ ### Phase 4: Single-Reviewer Risk Audit
- - One independent reviewer, chosen by the track's actual risk shape rather than a fixed default: `security-auditor` for anything touching injection, secrets, auth, or path handling; `code-reviewer` for general correctness; `flake-sentinel` for timing- or concurrency-sensitive test changes; `framework-auditor` for cross-language template/parity changes.
- - No fixed swarm size and no `review-arbiter` - arbiter exists to reconcile conflicting verdicts across multiple reviewers, and with one reviewer there is nothing to reconcile. Reuse Protocol 123's own severity vocabulary for findings (`CRITICAL` / `MAJOR` / `MINOR`) instead of inventing a separate one. Escalate to a second reviewer only if the first reviewer returns at least 1 `CRITICAL` finding, or the maintainer explicitly disputes a `MAJOR` finding - not on a fixed schedule, and not for `MINOR` findings alone.
- - Announce the review agent invocation per the Mandatory Agent Invocation Notification rule, the same as any other agent spawn.
- - Triage every CONFIRMED finding individually: fix it immediately if it is within the track's own scope (Two-Strike Rule still governs), or route it to `TODO.md` with the reviewer's own reasoning attached if it is real but lower-priority or out of the track's scope. Never silently drop a finding, and never fix a finding the review itself judged out of scope without saying so.
+ - Spawn exactly ONE specialized domain reviewer matching the task risk shape:
+ - `security-auditor`: For injection, secrets, authentication, or path traversal.
+ - `flake-sentinel`: For timing races, async promises, or flaky test assertions.
+ - `framework-auditor`: For cross-language generator templates or multi-stack parity.
+ - `code-reviewer`: For general correctness, architecture, and schema alignment.
+ - Zero review-arbiters: A single reviewer produces no multi-agent conflict to adjudicate.
+ - The reviewer tags all findings as `[CONFIRMED_IN_SCOPE]` (must fix now), `[DISMISSED_OUT_OF_SCOPE]` (non-blocking observation), or `[DEFERRED_TO_TODO]` (log to `TODO.md`). Mandatory in both full and fast-track modes.
- ### Phase 4: Doc Sync
+ ### Phase 5: Fast Quality Gate, Doc Sync & Micro-Telemetry
- - `CHANGELOG.md`: one entry, or folded into an existing still-unreleased entry on the same topic rather than narrating a multi-step debugging journey across several bullets - the entry describes the final state, not the path there.
- - Mark the plan document itself with a status note at the top of the track, no more than 5 lines: `Status: DONE`, the actual commit hash(es), the exact verification command(s) run and their result, and what was found in review but deliberately not actioned, with the reason in one clause. No rationale narrative or restated background beyond that.
- - Route any deferred or lower-priority findings from Phase 3 into `TODO.md` per its existing conventions; nothing found in review is allowed to simply evaporate unrecorded.
- - No Telemetry Summary table - that reporting ceremony belongs to Protocol 123.
+ - Verify build gate via `node scripts/protocol-456.mjs verify-phase 5` and re-run the targeted test.
+ - Update `CHANGELOG.md` with exactly one concise, keyword-first line under the active version header.
+ - Execute git commit strictly via `npm run commit -- "<message>"` to enforce mandatory evening 23:00 OpSec timestamps per CLAUDE.md Section 5.
+ - Emit the 4-line micro-telemetry summary table via `node scripts/protocol-456.mjs telemetry`.
## Batch Completion Gate (once per batch, before reporting the branch ready)
- A track's own Phase 2 verification command only proves that track in isolation - it cannot catch a cross-cutting check that spans the whole generated output regardless of which track touched it (e.g. `packages/engine/test/format.test.ts`, which asserts every emitted file across the entire plan is already Prettier-formatted - a real failure discovered in production use of this protocol, on a PR that had cleanly passed every individual track's own Phase 2). CI's `Build & Verify` job runs the full local suite before merge is even considered; discovering a failure there instead of locally means a push -> wait for CI -> diagnose from CI logs -> fix -> push -> wait again round trip, which costs strictly more time and tokens than running the same check once, locally, before the push - directly against 456's own purpose of conserving both.
+ When Protocol 456 is executed across multiple consecutive tracks on the same branch:
- - After the LAST track in the current batch has finished Phase 4 - not after every individual track, since running this per-track would reintroduce the cost 456 exists to avoid - and before telling the user the branch is ready for a PR, run the exact command the `Build & Verify` job's `Run Full Test Suite` step actually runs. Read `.github/workflows/ci.yml` fresh to get that exact command rather than trusting a memorized one - the workflow can change independently of this skill, and a stale cached command would silently stop mirroring CI (at the time of writing: `npx vitest run packages/engine/test packages/cli/test`).
- - This is a narrow, protocol-scoped exception to Section 8's "No Full Test Suite Execution Without Approval": the batch of tracks just executed under this same 456 invocation already carries the user's consent for this one specific check, since it runs nothing CI was not already about to run against the same commits regardless. It is not blanket permission to run full suites for any other purpose.
- - If this surfaces a failure, treat it exactly like a Phase 2 verification failure - root-cause it, fix it as its own small commit (attributed to whichever track actually caused it, or its own standalone `fix` commit if the cause predates this batch), and re-run this same gate command until clean, under the same Two-Strike Rule as Phase 2.
- - Only once this gate is clean does the batch's branch get reported to the user as ready for a PR.
+ - After the LAST track in the batch completes Phase 5, run the full CI test suite command specified in `.github/workflows/ci.yml` (e.g. `npx vitest run packages/engine/test packages/cli/test`) to catch cross-cutting regressions.
+ - If failures occur, fix them under the Two-Strike Rule before declaring the branch ready.