@bridge_gpt/mcp-server 0.2.75 → 0.2.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/build/agents.generated.js +5 -5
- package/build/cli-dispatch.js +333 -0
- package/build/codex-auto-recovery.js +25 -7
- package/build/commands.generated.js +8 -8
- package/build/conductor/bridge-api-client.js +193 -13
- package/build/conductor/declare-blocked.js +146 -7
- package/build/conductor/driver-pass.js +8 -0
- package/build/conductor/driver-register.js +8 -2
- package/build/conductor/epic-implementer-cli.js +15 -10
- package/build/conductor/epic-server-journal.js +52 -22
- package/build/conductor/epic-server-recipe.js +15 -5
- package/build/conductor/epic-server-runtime.js +163 -45
- package/build/conductor/epic-server.js +13 -6
- package/build/conductor/install-doctor.js +30 -2
- package/build/conductor/launch-plan.js +28 -7
- package/build/conductor/local-merge.js +55 -13
- package/build/conductor/pr-ci-producer.js +12 -3
- package/build/conductor/readiness-prerequisites.js +89 -2
- package/build/conductor/readiness-sections.js +46 -13
- package/build/conductor/readiness.js +3 -40
- package/build/conductor/recovery-cli.js +14 -12
- package/build/conductor/repository-workflow-remedy.js +147 -7
- package/build/conductor/ui-readiness.js +224 -0
- package/build/conductor/wait-run-attention.js +9 -4
- package/build/conductor/wait-run-cli.js +9 -2
- package/build/docs.generated.js +67 -4
- package/build/doctor.js +97 -1
- package/build/drive-epic.js +625 -33
- package/build/engine-paths.js +10 -0
- package/build/epic-coherence-input-cli.js +105 -10
- package/build/epic-coherence-input.js +877 -4
- package/build/epic-coherence-input.test-fixtures.js +117 -0
- package/build/epic-implementer-bin.js +947 -120
- package/build/epic-implementer-env.js +2 -2
- package/build/epic-launch-context.js +8 -1
- package/build/epic-shared/cut-protocol.js +55 -3
- package/build/executor/completion-contract.js +14 -1
- package/build/executor/failure-reason-codes.js +2 -0
- package/build/executor/guarded-fast-forward-push.js +25 -2
- package/build/executor/integration-job.js +56 -2
- package/build/executor/job-runner.js +87 -28
- package/build/executor/likely-tests.js +78 -6
- package/build/executor/merge-job.js +45 -1
- package/build/executor/permissions.js +187 -2
- package/build/executor/provider-checks.js +101 -5
- package/build/executor/rebase-finalization.js +29 -27
- package/build/executor/reconcile-overlap-job.js +70 -17
- package/build/executor/rename-aside.js +265 -0
- package/build/executor/required-work-ledger.js +89 -6
- package/build/executor/resume-pre-spawn.js +32 -8
- package/build/executor/runner.js +26 -4
- package/build/executor/types.js +121 -0
- package/build/executor/worktree.js +39 -2
- package/build/index.js +2500 -495
- package/build/init.js +16 -0
- package/build/install-bridge-conductor-answers.js +4 -0
- package/build/install-bridge-conductor-apply.js +10 -0
- package/build/install-bridge-conductor-assessment.js +84 -0
- package/build/install-bridge-conductor-contracts.js +9 -1
- package/build/install-bridge-conductor-setup.js +103 -3
- package/build/install-bridge-conductor.js +440 -812
- package/build/install-bridge.js +4 -11
- package/build/language-catalog.generated.js +2649 -0
- package/build/mcp-host-config.js +54 -37
- package/build/phase-context-git-probe.js +16 -0
- package/build/pipelines.generated.js +47 -19
- package/build/plan-execution-ledger.js +35 -0
- package/build/plan-generation.js +34 -0
- package/build/plane/build-freshness.js +6 -0
- package/build/plane/cli.js +12 -5
- package/build/plane/plane-freshness.js +43 -26
- package/build/printed-remedy-commands.js +17 -0
- package/build/readiness-prerequisites.generated.js +28 -0
- package/build/readme.generated.js +1 -1
- package/build/run-unit-tests-launcher.js +3 -1
- package/build/secret-redaction.js +3 -0
- package/build/server.js +7946 -0
- package/build/setup-epic.js +41 -8
- package/build/start-tickets-prereqs.js +3 -6
- package/build/test-support/console-guard.js +30 -0
- package/build/test-support/create-preview-world.js +232 -0
- package/build/test-support/module-imports.js +155 -0
- package/build/test-support/server-client.js +96 -0
- package/build/test-support/stdio-server.js +146 -0
- package/build/ticket-delivery.js +65 -0
- package/build/v2-readiness-requirements.js +39 -5
- package/build/version.generated.js +3 -3
- package/build/worktree-core.js +51 -7
- package/docs/EPIC-IMPLEMENTER.md +150 -2
- package/docs/epic-implementer/getting-started.md +5 -1
- package/package.json +3 -3
- package/pipelines/implement-ticket.json +2 -2
- package/pipelines/learn-repository.json +19 -1
package/build/docs.generated.js
CHANGED
|
@@ -3,15 +3,24 @@
|
|
|
3
3
|
export const DOCS = {
|
|
4
4
|
"docs/mcp-tool-integrations.md": "# MCP tool integrations — the human \"why\" behind the capability report\n\nThis catalog is **explanatory prose only**. It exists so the `/install-bridge`\ncapability report can cite a human-readable \"why\" for each gate. It is **not** a\nsource of truth for gating: the server computes every `locked_tools` /\n`unlocked_tools` membership decision itself and the agent must never recompute a\ntool's dependencies from this document.\n\n**Authoritative source of gating.** The enforced rules — which tools are blocked,\nwhich are degraded, and what each requires — live in\n`api/library/vcs/vcs_route_operations.py`:\n\n- `VCS_ROUTE_REQUIREMENTS` — routes that **BLOCK** (are unavailable) without a\n VCS connection.\n- `VCS_ROUTE_WARNINGS` — routes that **DEGRADE** (stay usable, but without\n codebase context) without a VCS connection.\n- `NEVER_GATED_ROUTE_KEYS` — routes that are never gated on any integration.\n- `INDEX_REQUIRED_ROUTE_KEYS`, `INDEX_REQUIRED_COUNCIL_MODES`,\n `CREATE_DOC_CODEBASE_CONTEXT_DOC_TYPES`, `CREATE_DOC_WARN_DOC_TYPES` — the\n conditional \"requires a successful code index\" dimension.\n- The resolver helpers `get_required_vcs_operation()`, `get_warn_vcs_operation()`,\n and `requires_successful_index()` are the authoritative functions that decide a\n case. The capability report is derived from these; this catalog explains them.\n\n## Reading the capability report\n\nEach tool entry the server returns has the exact shape\n`{tool, effect, missing, semantics}`:\n\n- **`effect`**\n - **`BLOCK`** — the tool is **unavailable** until every listed dependency is\n met. It will refuse to run without them.\n - **`DEGRADE`** — the tool is **usable right now**, but **without codebase\n context** (it cannot ground its output in your repository). Connecting the\n listed dependency upgrades it from \"works blind\" to \"works with full context\".\n A `DEGRADE` tool is never \"failed\".\n- **`missing`** — the server-computed dependency identifiers still needed:\n integration ids such as `github_app` / `vcs_access_token`, and the synthetic\n `code_index` (a successful repository index).\n- **`semantics`**\n - **`all_of`** — every id in `missing` is required.\n - **`any_of`** — the VCS-provider candidates in `missing` are alternatives:\n **either** `github_app` **or** `vcs_access_token` satisfies the VCS\n requirement (this is the \"provider unknown\" case). When `code_index` also\n appears, it remains separately required — `semantics` describes only the VCS\n provider candidates, and a code index is always mandatory in addition.\n\nThe three readiness dimensions `configured` / `learned` / `indexed` are reported\nindependently. `indexed` may be `true`, `false`, or `null` — a `null` means the\nindex status could not be confirmed and must **not** be read as \"indexed\".\n\n## The integrations\n\n| Integration id | What it is | What it unlocks |\n| --- | --- | --- |\n| `jira` | Jira API access | Ticket reads/writes, estimation and review automations, status transitions. |\n| `github_app` | GitHub App installation | Pull requests, code review, and private-repo parsing on GitHub projects. |\n| `vcs_access_token` | VCS access token | Pull requests, code review, and private-repo parsing on Bitbucket projects. |\n| `vcs_webhook` | VCS webhook secret | Merge webhooks and CI follow-up triggers. |\n| `code_index` | A successful repository index | Codebase-grounded planning, architecture, reimplementation, and technical/discovery AI councils. Produced by `/parse-repository`. |\n\nA project's `github_app` **or** `vcs_access_token` provides the VCS connection;\nwhich one applies depends on the project's version-control system. When the\nproject's provider is unknown, either credential satisfies the requirement — the\nreport expresses that as `semantics: any_of`.\n\n## The gates, by capability\n\n### Pull requests and CI (BLOCK on VCS)\n\nTools like `create_pull_request`, `resolve_ci_checks`, `poll_ci_checks`, and\n`fresh_base` are **unavailable** (`BLOCK`) until a VCS connection is\nconfigured. They act directly on the version-control host, so without a\nconnection there is nothing for them to talk to.\n\n### Repository indexing and maps (BLOCK on VCS)\n\n`parse_repository` and `regenerate_directory_map` need a VCS connection to read\nthe repository. They **BLOCK** until VCS is connected.\n\n### Codebase-grounded generation (BLOCK on VCS **and** a code index)\n\nPlanning and architecture tools — `generate_plan_direct`,\n`generate_architecture_direct`, `request_reimplement_context`,\n`code_writer_generate_plan`, `code_writer_generate_architecture`, and\n`create_doc` for **TDD** / **architecture** documents — ground their output in\nyour indexed codebase. They **BLOCK** until BOTH a VCS connection AND a\nsuccessful code index exist (`all_of`, with `code_index` in `missing`).\n\n### AI Council (BLOCK on a code index, mode-dependent)\n\n`request_council` in **technical** or **discovery** mode searches your indexed\ncodebase, so it **BLOCK**s on `code_index`. **Design**-mode AI council requests never\nquery the index and are never gated.\n\n### Document generation that DEGRADEs (usable without codebase context)\n\nTools like `generate_prd_direct`, `generate_fsd_direct`,\n`code_writer_generate_fsd`, `generate_clarifying_questions_direct`,\n`generate_ticket_critique_direct`, `generate_ticket_review_direct`, and\n`create_doc` for **PRD** / **FSD** documents **DEGRADE** rather than block: they\nrun today from the ticket alone, and connecting VCS simply lets them ground their\noutput in your codebase. They always appear under \"Tools you can use now\", with a\nreduced-context caveat when the VCS connection is missing.\n\n### Never gated\n\nSetup and bootstrap tools (`ping`, `config_field`, `get_install_manifest`,\n`apply_install_manifest`, `persist_routing_credential`, and the\nbootstrap-invite exchange) are always available — they\nare how you configure everything else.\n",
|
|
5
5
|
"docs/install/sfcc-integration.md": "# Installing the SFCC Integration (OCAPI)\n\nBridge's Salesforce B2C Commerce (SFCC) tools give an AI coding agent read access to\na sandbox's object model, custom object definitions, and site preferences — plus a\nsmall set of sandbox-only writes — through the **OCAPI Data API**. This guide covers\nsetting up the OCAPI client that those tools authenticate against.\n\n> **Sandbox / local development only.** This integration is intended for a **developer\n> sandbox**, and that restriction is **enforced in code**: before any SFCC tool runs,\n> Bridge validates the hostname your credentials actually resolve to — from `dw.json`\n> or `SFCC_*` — against the sandbox forms listed below. An unrecognized host is refused\n> with a `403` (`error.code: \"TARGET_NOT_SANDBOX\"`) before any request leaves your\n> machine. The check reads the resolved hostname, never the `instance` tool argument,\n> so omitting `instance` or passing `\"sandbox\"` cannot bypass it.\n>\n> Accepted sandbox hostname forms:\n>\n> - `<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com`\n> - `<realm>-<nnn>.dx.commercecloud.salesforce.com`\n>\n> Anything else — a `production-`/`staging-`/`development-` prefixed host, or any\n> `*.demandware.net` host — is rejected.\n>\n> Still do not configure the grants below on an instance that holds real data.\n> Credentials stay local (in `dw.json` or `SFCC_*` env vars) and are never sent to\n> Bridge.\n\nFor the full per-tool list and what each SFCC tool depends on, see\n[MCP Tool Integration Dependencies](./mcp-tool-integrations.md). For the tool reference\nand the `BRIDGE_MCP_PROFILE` gating, see the SFCC section of the\n[package README](../../README.md).\n\n## Prerequisites\n\n- A running SFCC **developer sandbox** and its hostname\n (e.g. `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`).\n- An **Account Manager API client** — a `client-id` and `client-secret`. This is the\n OCAPI client the tools use to obtain an OAuth token. Create one in Account Manager\n (**API Client** → *Add API Client*) if you don't already have it, and note its\n `client_id`.\n- Business Manager access to the sandbox with permission to edit **Open Commerce API\n Settings**.\n\n## 1. Grant the OCAPI client access in Business Manager\n\nIn Business Manager for the sandbox:\n\n**Administration → Site Development → Open Commerce API Settings → Data API** tab.\n\nAdd the client entry below to the `clients` array of the Data API settings, then\n**Save**. It grants only the resource families and HTTP methods Bridge's SFCC tools\nactually call — not a global `/**` grant. `check_permissions` prints the same JSON on\na 401/403, split into the two blocks.\n\n**READ/SEARCH TOOL GRANTS** — required by the `sfcc` read tools. (`post` is OCAPI's\nconvention for its `*_search` endpoints, not a mutation.)\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\n**MUTATION GRANTS** — required **only if you enable `BRIDGE_MCP_PROFILE=sfcc-write`**,\nwhich registers the nine destructive write tools. These are shipped capabilities, not\nfuture work. No `delete` is granted, because no shipped write tool performs one; the\n`get` entries are needed for the If-Match ETag round trip that precedes each `PATCH`.\n\n```json\n{\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"put\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/sites/*/site_preferences/**\", \"methods\": [\"get\", \"patch\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n}\n```\n\nNotes:\n\n- Value writes (`site_preference_values_set`) are site-scoped: they need the mutation\n resource `/sites/*/site_preferences/**`. The read/search grant keeps the org-level\n `/site_preferences/**`. **If you pasted an earlier mutation grant, it lacks the\n site-scoped resource.** Replace `<YOUR_CLIENT_ID>` with your client id in the newly\n printed grant (`check_permissions` prints it) and paste it again before running\n value writes.\n- `check_permissions` probes a GET only. It shows read access, not write access.\n- The `client_id` **must match** the Account Manager API client whose credentials you\n put in `dw.json` / `SFCC_*` below. Replace the value above with your own client id if\n it differs.\n- If the Data API settings are empty, wrap the entries in the standard settings\n envelope. Merge the resource lists from the block(s) above into one `resources`\n array — do not substitute a global `\"resource_id\": \"/**\"` grant:\n\n ```json\n {\n \"_v\": \"23.2\",\n \"clients\": [\n {\n \"client_id\": \"<your-client-id-here>\",\n \"resources\": [\n { \"resource_id\": \"/system_object_definitions\", \"methods\": [\"get\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/system_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/site_preferences/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" },\n { \"resource_id\": \"/custom_object_definitions/**\", \"methods\": [\"get\", \"post\"], \"read_attributes\": \"(**)\", \"write_attributes\": \"(**)\" }\n ]\n }\n ]\n }\n ```\n\n- `check_permissions` (below) prints a ready-to-paste grant JSON on a 401/403, so you can\n also let the tool tell you exactly what to add.\n\n## 2. Provide credentials locally\n\nCreate a `dw.json` in your project root (auto-added to git exclude — never commit it):\n\n```json\n{\n \"hostname\": \"zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com\",\n \"client-id\": \"<your-client-id-here>\",\n \"client-secret\": \"<account-manager-client-secret>\"\n}\n```\n\nAccepted key spellings: `hostname`/`host`, `client-id`/`clientId`/`client_id`,\n`client-secret`/`clientSecret`/`client_secret`. A single config is simplest. With a\nmulti-entry `configs[]` array, pass one of the listed sandbox hostnames as `instance`\nand that config's credentials are used (an unapproved host is refused before any\ncredential lookup); without an `instance` the call fails as `multi-sandbox`. Alternatively, export\n`SFCC_HOSTNAME` / `SFCC_CLIENT_ID` / `SFCC_CLIENT_SECRET` in the MCP server environment.\n\n## 3. Set the repo `version` config field\n\nSet the repo's `version` config to your SFCC project type — one of\n`sfra | pwakit | sitegenesis | storefrontnext | hybrid`. The call-time gate reads this;\na non-SFCC value blocks the OCAPI tools (the eight reads, the nine writes, and\n`check_permissions`). It does not block `sfcc_setup_status` or `sfcc_log_query` — log\nquery has its own backend gate. Set it via your\nnormal config path, the `config_field` MCP tool (operation `update`, field `version`),\nor the `/teach-bridge` skill.\n\n## 4. Enable the SFCC tools\n\nNo SFCC tool is registered by default — a session on the default `core` profile has\nnone. Every SFCC tool sits behind **two independent profile groups**:\n\n| Group | Registers |\n|---|---|\n| `sfcc` | the two diagnostics (`sfcc_setup_status`, `check_permissions`), the 8 OCAPI read tools, and `sfcc_log_query` — read-only |\n| `sfcc-write` | the 9 destructive write tools |\n\nNeither implies the other. An `sfcc-write`-only session has no diagnostics, so it\ncannot run `check_permissions` to print the grant JSON; use `sfcc,sfcc-write` when\nyou need writes. Add what you need to `BRIDGE_MCP_PROFILE` in the MCP server\n`env` block (it is comma-separated), then **restart the MCP client**:\n\n```json\n\"env\": { \"BRIDGE_MCP_PROFILE\": \"sfcc\" }\n```\n\nFor reads plus writes, use `\"sfcc,sfcc-write\"`. `full` expands to every group and is\ntherefore write-capable.\n\n> **Migration.** `sfcc` used to register the nine write tools too. It no longer does.\n> If you were relying on SFCC writes through `BRIDGE_MCP_PROFILE=sfcc`, change it to\n> `BRIDGE_MCP_PROFILE=sfcc,sfcc-write`. `full` users keep write access and need no\n> change.\n\n## 5. Verify\n\nAsk your agent to run:\n\n1. `sfcc_setup_status` — expect all prerequisite checks ✓ (Bridge API key, repo name,\n `version` config, `dw.json` presence/uniqueness, AM/OCAPI token acquisition).\n2. `check_permissions` — probes OCAPI via `GET /system_object_definitions`. A 200 (with\n the OCAPI version) confirms the grant. On 401/403 it prints the exact grant JSON to\n paste back in step 1.\n\nRestart the MCP client after any credential, grant, or env change — a running session\ndoes not pick them up.\n\n## Notes\n\n- **WebDAV logs are separate.** `sfcc_log_query` authenticates with a Business Manager\n username + a 40-character **WebDAV access key** over HTTP Basic auth — *not* the OCAPI\n OAuth token configured here. `sfcc_setup_status` reports OCAPI (step 5) and WebDAV\n (step 6) independently; one can be green while the other is not.\n- **Writes are sandbox-only.** The write tools (attribute/preference create/update) target\n a developer sandbox and echo a paste-ready grant JSON on a 403.\n",
|
|
6
|
-
"docs/bridge-ticket-authoring.md": "# Bridge ticket-authoring posture\n\nBridge has several surfaces that can create a ticket, and `/define-tickets` is the\nsingle entry point for creating them. Without a shared posture\neach one behaves differently, and the most-used surface carries none of the\nmaintainer's preferences at all. This document is the deep reference behind the\nshort posture block that every one of those surfaces carries verbatim.\n\nThe block itself is short on purpose — it competes for attention inside prompts\nthat are already long. Everything that explains *why* lives here.\n\n## The canonical block\n\nThis file **is** the canonical source. The marker-delimited block below is\nduplicated byte-identically onto every carrier — every surface that decides\nticket shape holds these exact bytes, so no surface can quietly drift into its\nown house style.\n\nCarriers (all four hold the block verbatim):\n\n- `agents/src/jira-ticket-writer.md` — the writer itself, plus a compressed\n posture line in its `description:` frontmatter, which is the only coverage a\n bare-chat session gets with no file read and no `tools/list` cost.\n- `commands/src/define-tickets.md` — Stage 9, the most-used authoring surface.\n- `mcp_server/instructions/decompose-epic-candidate.md` — the `idea-to-ticket`\n decomposition step.\n- `mcp_server/instructions/decompose-epic.md` — the `plan-epic` decomposition\n step.\n\nEdit the block here, copy it verbatim to each carrier, and let\n`tests/pytest/mcp_server/test_ticket_authoring_posture_assets.py` prove it\nlanded. That test permits **no** per-surface variation.\n\n<!-- BEGIN BRIDGE TICKET-AUTHORING POSTURE -->\n<!-- Canonical source: docs/bridge-ticket-authoring.md.\n This block is duplicated byte-identically onto every carrier. Never edit a\n copy: edit the canonical source and re-copy it verbatim. A cross-surface\n byte-equality test fails the build if any copy drifts by a single byte. -->\n\n## Ticket-authoring posture\n\nDeep reference: `docs/bridge-ticket-authoring.md`.\n\n**Draft through the writer.** Every ticket body — an epic parent, an epic child,\nand an ordinary sibling alike — is drafted by the `jira-ticket-writer` agent\nbefore `create_ticket` is called. Do not compose a ticket description inline.\n\n**Size the work.** Size each ticket by file-touch breadth and depth plus rough\nlines of code (LOC) changed:\n\n- `S = 1-2 files / <~80 LOC`\n- `M = ~3-8 files / ~80-400 LOC`\n- `L = ~8-15 files / ~400-900 LOC`\n- `XL = >15 files / >~900 LOC`\n\nTarget size priority: **L (target) -> XL (when the work does not fit in L) -> M\n(third choice) -> S (only when unavoidable)**. This applies equally to a\nstandalone ticket and to an epic child.\n\nAim each slice at L. When one will not fit, grow it to XL rather than splitting\nit — split only when the slice is genuinely two independent pieces of work,\nnever merely to land inside a band. Bridge's grooming and implementation process\nhandles a large vertical slice well and is overkill on small ones: every extra\nticket is another worktree, another PR, another rebase, and another chance for\ntwo workers to touch the same file. Reach for M because the work genuinely is\nthat size, not to avoid an XL.\n\nBeyond roughly 40 files or ~3000 LOC, split anyway. Past that point review\nturnaround and rebase cost dominate the run's budget, and a review that wedges\nholds the gate to its full retry ceiling before anyone notices.\n\n**Group at three.** Three or more implementable tickets is an epic: propose an\nepic parent plus an ordered child manifest, and resolve this surface's own\napproval gate before anything is created. One or two tickets are ordinary\nsiblings — no epic parent, no manifest. The threshold is exactly three.\n\n**Hand off once.** An epic handoff names exactly one conductor entry point,\n`drive-epic`, which selects the runnable path itself. Never present a choice\nbetween conductors.\n\n**Departure is closed-list only.** These three exceptions, and no others, permit\ndeparting from the rules above. Invoking one requires no announcement.\n\n- **E1 External-tracker mirroring** — a recorded upstream identifier exists and\n its granularity is contractual. Bypasses sizing and the epic threshold.\n- **E2 Discovery-only spike** — no committed production-code deliverable.\n Bypasses sizing only; does not bypass drafting through the writer.\n- **E3 Authorized incident containment** — tied to an active incident record,\n not to schedule pressure. Bypasses sizing and the epic threshold.\n\nThe list is closed. Anything outside it is an escalation to the operator, not a\njudgement call. Explicitly refused as grounds for departure: a single-file\ntrivial fix (that is `S` reached through the normal path, not an exception),\ngeneric time pressure, \"already well specified\", \"faster without the writer\",\ndeveloper discretion, minor refactor, unattended mode, context limits, and \"hard\nto decompose\" (XL is the normal overflow, so that is the ordinary path and not a\ndeparture). Writer unavailability escalates; it never silently authorizes inline\ndrafting.\n\n<!-- END BRIDGE TICKET-AUTHORING POSTURE -->\n\n## Open-decision phrases\n\nA ticket body states settled facts. An unsettled choice that is needed to define\nor authorize the work belongs in the writer's reply, in the terminal\n`open-questions` block, and never in the ticket body. A validated `open-questions`\nblock is the authority. The phrase list below is only a backstop: it flags body\ntext that still reads like a request to settle a decision.\n\n<!-- BEGIN OPEN-DECISION PHRASES -->\n- must settle\n- settle this before\n- before planning\n- the caller must\n- owner confirms\n- owner must confirm\n- confirm with the owner\n- stop if not met\n- check the precondition first\n- TBD\n- to be decided\n<!-- END OPEN-DECISION PHRASES -->\n\nMatching semantics (warning only):\n\n- Match case-insensitively, as whole phrases with word boundaries.\n- Before scanning, drop fenced code blocks and `{noformat}` regions.\n- Report one warning per matching line, not one per phrase. Quote from the start\n of the sentence that holds the line's first match through the end of the line.\n- A phrase match is an advisory signal for a person to review. It never halts\n drafting, never hides an upload gate, and never refuses a launch.\n- Keep the full list out of routine reports. Report only the matching lines.\n\nCarriers (`commands/src/define-tickets.md`, `commands/src/draft-ticket.md`,\n`.claude/commands/write-ticket.md`, `mcp_server/instructions/draft-and-critique.md`,\nand `mcp_server/instructions/render-ticket-manifest.md`) quote the marked list and\nthese semantics exactly. `tests/pytest/static/test_open_decision_phrases_parity.py`\nproves they match.\n\nThe rest of this document is the rationale the block is deliberately too short to\ncarry.\n\n## Decision: Jira ticket authoring ships through the Jira Ticket Writer (BAPI-900)\n\nBridge ships two very different kinds of ticket-authoring surface, and customers\nneed to know which one they actually have.\n\n**Shipped customer surface.** A customer project gets the `jira-ticket-writer`\nagent — the same writer this posture requires every ticket body to go through —\nplus the agent-directed capability to revise an existing ticket's description.\nAsk your agent to draft a ticket with the Jira Ticket Writer, and ask your agent\nto update an existing ticket's description when it needs revising. Both reach a\ncustomer project because they are packaged: the writer through `AGENTS`\n(`mcp_server/src/agents.generated.ts`) and the description-update path through\nthe registered `update_ticket_description` / `request_ticket_update` MCP tools.\n\n**Repository-local workflows.** `.claude/commands/write-ticket.md` and\n`.claude/commands/update-ticket.md` are bridge-api's own repository-maintenance\ncommands. They are **not** scaffolded into a customer project by `--init`, have\nno `commands/src/` source, and have no generated Cursor or `mcp_server/`\nmirror — deliberately, not by omission. A customer asking their agent to run\nthe write-ticket or update-ticket slash command will not find either one,\nbecause neither ships.\n\n**Why (Option B, not a promotion to shipped status).** The Jira Ticket Writer is\nalready the packaged drafting surface this posture mandates, so shipping\n`write-ticket.md` as a second drafting entry point would duplicate it. More\nimportantly, `write-ticket.md` is today an autonomous, single-ticket, no-halt\npipeline (\"No human confirmation gates — run end-to-end\") with no decomposition\nstep and no approval gate — it cannot honor the \"group at three\" epic rule or\nthe epic approval gate this posture requires, because it was never built to\npropose an epic at all. Promoting it to a shipped surface without that redesign\nwould ship a customer-facing command that silently violates this file's own\nposture. Until that redesign happens, `write-ticket.md` and `update-ticket.md`\nstay repository-local, and every packaged surface directs customers to the Jira\nTicket Writer and to agent-directed description updates instead.\n\n\n## The four rules\n\n### 1. Draft through `jira-ticket-writer`\n\nEvery ticket body is drafted by the `jira-ticket-writer` agent before\n`create_ticket` is called — an epic parent, an epic child, and an ordinary\nsibling alike. Nothing composes a ticket description inline.\n\nThe writer is not a formatter. It runs a codebase-research pass first, so its\ntickets cite the files, functions, and extension points a change actually\ntouches. A description written inline skips that pass, and the difference shows\nup two steps later: plan generation and implementation both ground themselves in\nthe ticket body, so a body with no code references produces a plan with no code\nreferences.\n\n\"The ticket is already well specified\" is not a reason to skip the writer. A\nwell-specified *request* is the writer's input, not a substitute for its output.\n\n### 2. Size toward L\n\nSize each ticket by file-touch breadth and depth plus rough lines of code\nchanged:\n\n| Band | Files | LOC |\n| --- | --- | --- |\n| `S` | 1–2 | `<~80` |\n| `M` | ~3–8 | ~80–400 |\n| `L` | ~8–15 | ~400–900 |\n| `XL` | >15 | `>~900` |\n\nPriority: **L (target) → XL (when the work does not fit in L) → M (third choice)\n→ S (only when unavoidable)**.\n\nThe target is L because the Bridge implementation tooling works best on\nindependently implementable vertical slices. What matters as much as the target\nis the **direction you move when a slice misses it**: upward, not downward.\n\nA slice that will not fit in L becomes **one XL ticket**, not two L ones. Split\nonly when the slice is genuinely two independent pieces of work — never merely to\nland inside a band. Fragmenting a coherent slice to fit is the failure this\nladder exists to prevent: every extra ticket is another worktree, another PR,\nanother rebase, and another chance for two workers to touch the same file, and\nBridge's grooming process is overkill on small tickets. Fewer, larger slices\nspend less of the run's budget on coordination.\n\nThis applies equally to a standalone ticket and to an epic child. There is no\nsize ceiling on a child that a lone ticket does not also have.\n\n`M` is where you land when the work genuinely is three to eight files — not\nsomewhere to retreat to in order to avoid an XL. `S` is likewise not forbidden:\nit is simply what you reach when the work genuinely is one or two files. A\nsingle-file trivial fix is `S` arrived at through the normal path. It is not an\nexception to anything, and it does not license skipping the writer.\n\n**Beyond roughly 40 files or ~3000 LOC, split anyway.** XL is the preferred\noverflow, not an unbounded one. Past that point review turnaround and rebase cost\ndominate the run's budget, and a review that wedges holds the gate to its full\nretry ceiling before anyone notices. That is a real bound, not a preference — and\nit is high enough that reaching it means the work really is two things.\n\n### 3. Group at three\n\nThree or more implementable tickets is an epic. The surface proposes an epic\nparent plus an **ordered child manifest**, and resolves its own approval gate\nbefore anything is created.\n\nOne or two tickets are ordinary siblings: no epic parent, no manifest. The\nthreshold is exactly three — not \"several\", not \"a lot\".\n\nThe manifest carries, per child: the boundary of its scope, its size band,\n`depends_on` (hard prerequisites that must land first), `recommended_after` (soft\nsequencing preferences that are not blockers), and a one-line order rationale.\nHard prerequisites and soft sequencing stay strictly separate, because the\nrecommended implementation order is derived from them and conflating the two\nproduces a serialized order where a parallel one was available.\n\n**The epic body carries the manifest in one fixed shape.** The epic parent holds a\nsingle `## Ordered child manifest` section. Each child is one compact line, with\ncomma-separated hard prerequisites and an explicit `depends_on: none` for a child\nwith none:\n\n```markdown\n## Ordered child manifest\n\n- BAPI-101 depends_on: none\n- BAPI-102 depends_on: BAPI-101\n- BAPI-103 depends_on: BAPI-101, BAPI-102\n```\n\nUntil every child exists, the section holds one fixed pending line,\n`- pending: child keys are written here after the children are created.`\n`/define-tickets` replaces it only after every child exists, using real child keys\nand never a placeholder. Updates are built from the Markdown the command retained\nlocally; text fetched from Jira is read-only. If the write is unavailable, the\ncommand warns in its Final Report and the handoff continues. The pending line is\nintentionally unreadable as a manifest, so the plan falls back to ascending\nticket-key order.\n\nApproval follows each surface's **existing** attended/unattended rule. Nothing\nhere introduces a new gate policy: `/define-tickets` requires an explicit\naffirmative because creation is irreversible, and the recipe path gates on the\npipeline's own auto-approval variable. What is *not* conditional is the grouping\nitself — an unattended run still produces the epic; only the gate's behavior\nvaries.\n\nDecomposition happens **once**. The pass that decides the split freezes the\nmanifest; body rendering then fans out one writer invocation per entry against\nthat frozen manifest. A rendering invocation may not re-split, merge, reorder,\nrenumber, or rescope. Two independent decisions about the same split disagree,\nand the disagreement surfaces as children that overlap or contradict their\nparent.\n\n### 4. Hand off to exactly one conductor\n\nAn epic handoff names exactly one conductor entry point: `drive-epic`.\n\nBridge currently has two conductors — the v2 server-side engine and the LLM\nconductor pilot — and a standing rule that they must never operate on the same\nepic, because two transition authorities on one epic wedge it permanently. Asking\na model to pick correctly every time is not a control. `drive-epic` makes the\nchoice structural instead: it reads conductor readiness and routes to the one\npath the project can actually run, so no prompt names either underlying conductor\nand no prompt can present both.\n\nTwo conductors is a transitional state. When one is eliminated, `drive-epic` is\nthe only thing that changes — no prompt, bundled doc, command mirror, or posture\ntest moves.\n\n## Epic coherence check before creation\n\nBefore an epic's tickets are created or its plan approved, its children are\nchecked **as a set** against the epic's own acceptance criteria. The check asks\nwhether every epic criterion has a child that carries out its verification, and\nwhether each cross-child hand-off is owned at both ends. It runs through one\nshared procedure, [`review-epic-coherence.md`](../mcp_server/instructions/review-epic-coherence.md),\nwhich writes `epic-coherence.json` (the record) and `epic-coherence.md` (a short\nsummary) beside the frozen manifest.\n\n**Where it runs.** Four call sites run the check:\n\n- `/define-tickets` Stage 9 (attended) — after the epic split is frozen, before\n drafting and the upload gate.\n- `/define-tickets --auto` Stage 9 (unattended) — after the split is frozen and\n capped by `--max-children`, before any writer runs. It has no upload gate: an\n independently cleared record is what allows creation.\n- `idea-to-ticket` (the still-bundled legacy recipe) — in the Epic path of\n `upload-and-track.md`, after `decomposition-plan.json` and before rendering and\n the external approval gate. `/idea-to-pr` no longer runs it: it reaches the\n coherence check through `/define-tickets` Stage 9 under `--auto`.\n- `plan-epic` — in `decompose-epic.md`, after the plan artifacts are written and\n before the decomposition is presented for approval.\n\nEvery decomposition pass fills in each child's `owns_verifications`: which epic\ncriterion it proves, and the concrete part of that criterion's verification it\ncarries out. When a criterion is proven by an owner-run step a person runs\noutside the conductor — a release-checklist step, say — the pass declares a\n`non_child_owners` entry naming who runs it, the step, its verbatim text, and\nwhere the result is recorded, instead of forcing a child to own it. Owner-run\nowners count toward coverage only; hand-offs stay child-owned.\n\n**The render preflight.** `render-ticket-manifest.md` refuses to render an epic\nunless the record exists beside the manifest, all three of its digests\n(`manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`) match\nwhat is being rendered, those digests equal the last reviewer round's, and\nits verdict is `pass`, `accepted_with_gaps`, or `not_checked` with a recorded\nbypass. A missing record, a mismatch, `blocked`, or an un-bypassed `not_checked`\nstops the flow before any writer runs or any ticket is created. `/define-tickets`\nstates the same rule in its own creation step.\n\n**Attended runs: fix or accept, at one gate.** The gate comes after the drafts\nexist. Each remaining blocking finding is either fixed — the manifest is amended, re-frozen, and checked again — or\naccepted with a non-empty reason, which is recorded and turns the verdict into\n`accepted_with_gaps`. The fix budget is bounded: after the first confirmation\npass, the operator may direct one fix and one further whole-manifest\nconfirmation pass, counted across re-runs in the same attended `/define-tickets`\nrun. After that, a blocker is accepted or stays `blocked`.\n\n`/define-tickets` runs its optional checks in a fixed order: design and split,\nincluding any after-design review; the gap check, when the drafting plan calls\nfor it and the work is an epic; one writer draft per ticket, all started at once\nwhere the host can run them in parallel; then one upload gate. The gap check\nnever runs after drafting. Before the writers start, an attended run checks the\nrecord more narrowly than full clearance: the only items it may leave uncleared\nare foundation gaps listed under `Known gaps that will be recorded on the epic`.\nEach is a pending acceptance, held in working state with its finding, its\nagent-drafted reason, and its round. Nothing is saved as an operator acceptance\nbefore approval, and the full clearance rule still applies before the first\nticket is created.\n\nThe upload gate shows, in plain words, the gap-check result, who covers each\nrequirement, the plan outline, the chosen drafting-plan policies, any review\nfailure, the known gaps with their pending acceptances, and the path of every\ncompleted draft. The closing question is\n`Upload these N drafts to Jira? (yes / change something)`, or its singular form.\n\nUpload is authorized by clear intent, not by an exact word. A clear \"yes\" or\n\"go ahead\" authorizes uploading the displayed drafts and records exactly the\ndisplayed pending acceptances. It never changes the split and never spends the\nfix budget. Every unresolved gap keeps creation blocked. Empty, negative,\nambiguous, and mixed replies upload nothing; if the operator declines, the\nexploration document and the drafts directory are the artifacts. Changing an\nitem, a target, a recommendation, or a reason means the affected drafts are\nredone and the gate is shown again. A changed requirement or goal goes back\nthrough requirements and the drafting plan instead.\n\n**Implications, then the drafting plan.** After requirements are ratified,\n`/define-tickets` Stage 6 shows the implications and waits for the operator to\nconfirm them, ask a question, request a change, or proceed. Questions keep this\ncheckpoint open. A change causes a fresh implications review before the plan is\nshown in a later turn. If the review is unavailable, the operator still sees a\nwarning and must clearly request to proceed. The plan recommends a council\nbefore the design, a review after the design (a council, or a second opinion for one or two separate\nquestions), or no council, and it records the gap-check policy for a possible\nepic. Choosing a council option also covers the later review of how an epic's\ntickets are split, so that decision is not asked again. An unclear reply starts\nnothing and the plan is shown again. Unattended runs take the recommended option\nand keep the epic gap check required. The attended flow has four ordinary stops:\nthe requirements page, implications checkpoint, drafting plan, and upload gate.\nThe attended short path, chosen for likely 1-2 ticket work with a precedent and\nno forced-full area, normally has two: the requirements page and the upload gate.\nIt shows the implications review and the drafting plan together in one message.\nSee [the short-path decision record](BAPI-1660-define-tickets-short-path.md).\nThe initial high-risk coherence council is offered\nby the shared procedure itself, in an attended run, after the epic is classified\nhigh risk and before round 1, with its cost and a recommendation. Declining it\nis final: the record stores `council_outcome: \"declined_by_operator\"`, shows\n`Council: skipped, your choice`, and needs no `accept` override. A legacy\noverride that targets `council: \"declined_by_operator\"` stays valid and is\nignored for clearance. Declining a council offered for an uncertain or disputed\nfinding is also final for that council decision, but the finding stays blocking\nuntil it is amended or accepted. An unfinished required council still needs an\nattended acceptance that names its `council_id`.\n\n**What counts as high risk.** Six or more children, or one child editing\n`db/alembic/`, `db/migrations/`, `api/library/billing/`,\n`api/routes/setup/auth.py`, or `api/library/auth/`. A child editing\n`api/library/db/` or another executor-containment path is high risk only when at\nleast two distinct children edit such paths; the procedure's case table is the\nsingle statement of this rule. Reads never count. A lone such child still gets\nthe low-risk reviewer rounds, is promoted to high risk if a blocking finding is\nuncertain, and reaches the upload gate with any remaining blockers.\n\nWhen the reviewer cannot run, the verdict is `not_checked`. The operator can\nretry, or bypass with a typed reason. A bypass is recorded, and the verdict stays\n`not_checked`; it is never shown as a pass.\n\n**Unattended runs: the risk-scaled round limit, then halt.** An unattended\n`idea-to-ticket` run or `/define-tickets --auto` run amends and re-checks within maximum ordinary rounds: two for a low-risk epic and three for a high-risk\none, ending early when a round has zero foundation blockers. If a foundation blocking finding remains, it halts with `blocked` before any ticket is\ncreated. A fix made after the last round gets one confirmation pass. An unavailable reviewer, or a check\nthat could not run independently, halts with `not_checked`.\n\nUnattended runs have no bypass; an operator who needs one reruns attended.\n`/define-tickets --auto` follows the same rule.\n\n**Siblings skip it.** A one- or two-ticket outcome runs no check, writes no\nrecord, and costs nothing extra. The residual risk — a pair that really needed a\nset-level check — is contained by the existing manifest-identity and\nwriter-draft gates. If the work is really epic-shaped, regroup it as an epic\nbefore creation. `plan-epic` is the one exception: the epic already exists, so it\nchecks even a one- or two-sub-task decomposition.\n\n**What lands in the tickets.** Each epic child carries its obligations verbatim\nas acceptance criteria. The epic parent carries a `## Epic coverage map`\nsection: the verdict, one bullet per epic criterion naming its owning child and\nobligation, and any accepted findings or bypasses with their reasons.\n\n## The closed exception list\n\nExactly three exceptions permit departing from the rules above. Invoking one\nrequires **no announcement** — the departure is silent by design, because a\nmandatory announcement would be one more instruction to drift from, and the cost\nof silence was weighed and accepted.\n\n| Id | Exception | Objective trigger | Bypasses |\n| --- | --- | --- | --- |\n| **E1** | External-tracker mirroring | A recorded upstream identifier exists and its granularity is contractual | Sizing and the epic threshold |\n| **E2** | Discovery-only spike | No committed production-code deliverable | Sizing only — **not** drafting through the writer |\n| **E3** | Authorized incident containment | Tied to an active incident record, not to schedule pressure | Sizing and the epic threshold |\n\nEach trigger is objective: an identifier that exists, a deliverable that is\nabsent, an incident record that is open. None of them is a judgement about how\nthe work feels.\n\n### The list is closed\n\nAnything outside the three rows above is an **escalation to the operator**, not a\njudgement call. The following are explicitly refused as grounds for departure:\n\n- a single-file trivial fix — that is `S` reached through the normal path;\n- generic time pressure;\n- \"the request is already well specified\";\n- \"it would be faster without the writer\";\n- developer discretion;\n- \"it's just a minor refactor\";\n- running unattended;\n- context limits;\n- \"this is hard to decompose\" — XL is the normal overflow, so that is the\n ordinary path and not a departure.\n\n**Writer unavailability escalates.** It never silently authorizes inline\ndrafting. A surface that cannot reach `jira-ticket-writer` stops and says so.\n\n## The spike ticket format (BAPI-986)\n\nA spike ticket defines a finding to be produced, not code to be written, so it\ngets its own body shape. This is a second **format**, not a fourth exception:\nthe writer still drafts it, the sizing ladder still applies, and E2 still governs\nwhether the posture's sizing rule is bypassed at all.\n\n### Who chooses, and on what\n\nThe run manifest's `scope` chooses, and it is resolved once, upstream, in\n`mcp_server/instructions/preflight-and-readiness.md`. The writer receives that\nvalue and never decides it. Only `scope: spike` selects the spike format.\n\nThe trigger is E2's exact objective condition — **no committed production-code\ndeliverable**. A deliverable that is absent, not a judgement about how the work\nfeels. Every other case produces the ordinary code-ticket format:\n\n- `scope: task` and `scope: epic_candidate`;\n- a missing scope value;\n- a malformed or unrecognized scope value;\n- a standalone writer invocation with no resolved spike scope;\n- any ambiguity.\n\nCode is the default **in code, not in prose**: it is what every unresolved path\nalready produces, so no one has to remember a rule to get it.\n\n### The five body sections\n\nA spike draft's substantive body is exactly these five, in order:\n\n1. `## Question` — the single question the investigation must answer.\n2. `## Scope` — the systems, code paths, data, and behavior in bounds.\n3. `## Out-of-scope` — what it will not examine, stated explicitly.\n4. `## What the findings must answer (the deliverable)` — names an inspectable\n findings artifact at a specific repository path, and states what that artifact\n must contain: the decisions it settles, the evidence it cites, the\n recommendations it makes, and the unresolved risks it records. This is the\n spike's analogue of Acceptance Criteria — a reviewer holds the finished\n artifact against it to tell whether the spike is done.\n5. `## Which related tickets consume the finding` — names real consumer tickets\n by key, or the literal `none yet`. Never an invented key.\n\nThose five are the spike-specific **body** sections. They are not the whole\ndraft. The following remain mandatory structural metadata, identical to a code\ndraft, and are not additional spike sections:\n\n- the `# [Title]` heading;\n- the execution-class marker line (below);\n- a `## Regression Completeness Notes` block when the gated regression pass\n applies;\n- the trailing `## Materials & Access` section, always last.\n\nThe code-ticket structure — Summary, Requirements, Acceptance Criteria,\nMaterials & Access — is unchanged, and a code draft carries no execution-class\nmarker.\n\n### The execution-class marker\n\nA spike draft carries exactly one canonical marker line, alone on its own line,\nimmediately after the title and before `## Question`:\n\n```markdown\n# [Concise Title Describing the Investigation]\n<!-- bridge:execution-class=investigation -->\n\n## Question\n```\n\nIt appears **exactly once**, never in a code-format ticket, and never\nillustratively inside a generated ticket body — not in prose, not in a fence,\nnot in backticks. Duplicates do not reinforce it: a second occurrence makes the\ndescription ambiguous and the parser discards the whole thing, leaving no signal.\n\n**It renders as visible text.** Bridge converts the description from Markdown to\nAtlassian Document Format, and ADF has no comment node, so the marker becomes one\nvisible line in the Jira description rather than a hidden comment. The exact\ntoken survives conversion and stays parseable from the stored description, which\nis what it is for. The placement immediately after the title is therefore an\neditorial choice as much as a parsing one.\n\n**It is a weak hint.** One non-authoritative input alongside the existing weak\nJira issue-type signal. It never overrides the five-way ticket-type\nclassification and never bypasses a human gate. A classifier verdict that\ncontradicts it wins, and the disagreement is reported rather than reconciled.\n\nThe marker's shape lives in exactly one runtime place —\n`parse_execution_class_marker` in\n`src/python/llms/agents/planner_agent/ticket_evaluator/execution_class_marker_utils.py`,\nwhich imports the `code`/`investigation` vocabulary from BAPI-980's constants in\n`api/models/epic_run.py` rather than redeclaring it. The literal in this document\nand in `agents/src/jira-ticket-writer.md` is pinned against that runtime constant\nby test, because Markdown cannot import a Python value.\n\n### The marker survives to the ticket record\n\nThe single-ticket path creates the Jira issue from `slim_description`; the full\ndraft is only an attachment. A marker preserved solely in the attachment would\nleave the ticket record with no signal at all. Two rules close that:\n\n- `mcp_server/instructions/draft-and-critique.md` carries the title and marker\n into `slim_description` in their original order, exactly once, and exempts that\n one literal from the forbidden-raw-HTML hygiene rule that would otherwise strip\n it. A `task` draft has no exemption, and slimming must not synthesize a marker.\n- `mcp_server/instructions/upload-and-track.md` passes `slim_description`\n unchanged as `create_ticket`'s `description`, without stripping, reconstructing,\n relocating, duplicating, or validating the marker.\n\n`create_ticket` gains no execution-class parameter and the MCP tool schema is\nunchanged: the marker rides in `description` and nowhere else.\n\n### Post-creation marker loss is out of scope\n\nA later description rewrite can drop the marker. `ticket_store_lib.update_ticket`\nforwards a full replacement description and the Jira backend re-renders all of it\nthrough `render_adf`, so anything a rewrite omits is simply gone — there is no\nmerge. Preserving the marker across rewrites would mean auditing every\ndescription-rewriting surface, which is excluded here.\n\nThis is a named, owned gap rather than an unstated one: preservation belongs to\nthe downstream slice that enables investigation routing. No local design record\nnames that slice yet, so its ownership is recorded here as an unresolved\ndownstream discovery rather than assigned to an invented slice name.\n\n## The plan-route marker\n\nA code-format ticket whose requested changes are entirely test code or test\ntooling may declare its plan route with one marker line:\n\n```markdown\n<!-- bridge:plan-route=test -->\n```\n\nThe runtime owner of the literal is `plan_route_marker_utils.py` in\n`src/python/llms/agents/planner_agent/ticket_evaluator/`\n(`PLAN_ROUTE_MARKER_TEMPLATE`); the writer copies it, never redefines it.\n\n### Writer rules\n\n- **Scope.** Stamp it only when all requested work is test code or test tooling:\n tests, flaky-test fixes, fixtures, fakes, harnesses, test configuration,\n runners, development/test dependencies, test-running CI workflows, and\n documentation about those tests.\n- **Placement.** Exactly once, alone, immediately after the title line.\n Otherwise stamp nothing and let the classifier decide.\n- **Test only.** The writer never authors an `implementation` or `bug`\n declaration, and never puts a plan-route declaration on a spike draft.\n- **Never illustratively.** The marker does not appear anywhere else in a\n generated ticket body.\n\n### Parser validity is broader than writer placement\n\nThe parser accepts one canonical literal alone on an unfenced, unindented line\nanywhere in the body. A malformed, inline, indented, fenced, or duplicated\noccurrence is no declaration.\n\n### Consequences\n\nJira renders the marker as one visible line. Unlike the weak-hint\nexecution-class marker, a valid plan-route declaration **binds** plan routing.\nMisused on production-code work, planning fails visibly, and ticket review\nrecommends a split or removal of the declaration (the critic's\n`Split recommended (unrelated test changes):` finding). The marker and the\nspike-only execution-class marker are the two limited exceptions to the\nno-raw-HTML and `{placeholder}` output rules.\n\n## Residual risks and their operational contracts\n\nFour limitations ship with the spike format. Each is stated as detection,\ncontainment, and escalation, because a residual-risk note without those three\nreads as coverage while providing none.\n\n### Incorrect E1/E2/E3 invocation\n\n- **Detection**: manual ticket review only. There is no log, counter, or report\n (see the accepted trade-off below).\n- **Containment**: the objective selection rule — any ambiguity produces a code\n ticket — plus the marker's non-authority over classification and every human\n gate.\n- **Escalation**: suspected misuse goes to the authoring-workflow owner.\n\n### Class observability does not cover departure invocation\n\nThe marker makes a spike's intended execution **class** observable. It does not\nmake E1/E2/E3 posture-departure **invocation** observable; that remains silent by\naccepted design, and the accepted trade-off below is unchanged by this slice.\n\n- **Detection**: none for invocation, by design. Ticket review is the only signal.\n- **Containment**: the closed exception list itself — anything outside those\n three rows is an escalation, not a judgement call.\n- **Escalation**: the authoring-workflow owner, as above.\n\n### Premature routing on the marker\n\nMarker-bearing tickets exist before any consumer does. Nothing routes on the\nmarker yet, and the guard for that is **structural, not a feature flag** — no\nsuch flag exists, and naming an imaginary control would be exactly the failure\nthe accepted trade-off below warns about.\n\n- **Detection**: the absence of any marker reader outside the parse/normalize\n helper and the disagreement observer. A static test pins that set, so the first\n premature consumer fails at review time.\n- **Containment**: BAPI-980 seeds every run node `execution_class = 'code'` and\n exposes no caller-controlled `investigation` override anywhere — not on the DAL\n seed signature, not on a Pydantic request model, not on an MCP input. No code\n path writes `investigation`.\n- **Escalation**: any proposal to consume the field in runtime conductor behavior\n goes to the Conductor owner before implementation, per BAPI-980's decision D10;\n any discovered marker-based routing is a release-blocking regression on that\n same path. Enabling investigation routing belongs to the downstream epic\n rollout owner, once the complete path and its human gate exist.\n\n### Marker/classifier disagreement\n\n- **Detection**: the reserved structured-log event\n `ticket_classification_event=execution_class_marker_disagreement`, emitted at\n warning level when an investigation marker meets a code-facing classifier\n verdict. Every `evaluate_ticket_type` entry point compares, so the signal\n covers the ordinary Bridge classification path and not only the estimator\n backfill; a cached verdict is not a classification and is not compared.\n Persistent or high-volume disagreement is surfaced by querying that reserved\n key through the existing logging/Sentry workflow.\n- **Containment**: the comparison is non-authoritative. The classifier verdict is\n persisted and returned exactly as produced, whether or not an event fires.\n- **Escalation**: the event is **diagnostic-only** and the Bridge platform team\n owns it operationally. No alert rule, threshold, or paging behavior ships with\n it; that is net-new work belonging to the slice that enables routing. The field\n and redaction contract lives in\n `docs/claude/jira-optional-ticket-storage.md`, not here.\n\n## Isolation binding for shared-state test support\n\nA ticket that builds or changes test support which resets shared state — a\nharness, a fixture, a reset helper, anything that truncates, drops, or\nreinitializes state another process or another run can also read or write —\nmust state its isolation binding as a requirement: which database, directory,\nor other shared resource the reset targets, and how the ticket's own\ndeliverable proves that target's identity before it destroys anything.\n\nThis doctrine exists because BAPI-1006 shipped a conductor integration-test\nharness with nothing in its ticket stating what the harness's destructive\nreset was bound to, and a v2 worker dispatched to build it truncated the\noperator's operational `bridgeapi` database (Architecture Miss 28). The\ncontainment-hazard classifier this repository runs at planning time\n(`api/library/github/workflow_planning_prediction.py`) can flag such a ticket\nfrom its text, but the flag is advisory — it surfaces the hazard before\ndispatch, it does not prevent a destructive worker on its own. Stating the\nisolation binding in the ticket itself is the durable requirement; treat this\nas an authoring-posture rule, not as runtime enforcement.\n\n## Accepted trade-off: silent departure is unobservable\n\nObservability was deliberately dropped when this posture was ratified. A model\nmay invoke E1, E2, or E3 without recording that it did, so posture drift is only\ndetectable through ticket quality — not through a log, a counter, or a report.\n\nThis is known and accepted. The alternative was another mandatory instruction on\nevery surface, and an instruction that is skipped silently is worse than one that\ndoes not exist: it reads as coverage while providing none.\n\n## Why duplication, not a shared include\n\nCommands, agents, instructions, and docs have four separate build paths in this\nrepository and no shared compiler. Introducing a generated include step to share\none block would mean a fifth build path, a placeholder that can go unresolved,\nand a failure mode where a carrier ships with the placeholder text still in it.\n\nMarker-delimited duplication plus one byte-equality test is the right mechanism\nat this scale. The test reads the canonical sources directly — never the\ngenerated command mirrors, whose byte-identity the command tests already cover —\nand permits **no** per-surface variation. Any drift, down to a single byte, fails.\n\n## A fresh install inherits this\n\nNo configuration step, no server call. The posture reaches a new project through\nthe packaged bundles that `--init` scaffolds:\n\n- `COMMANDS` (`mcp_server/src/commands.generated.ts`) — carries\n `commands/src/define-tickets.md`;\n- `AGENTS` (`mcp_server/src/agents.generated.ts`) — carries\n `agents/src/jira-ticket-writer.md`, including the compressed posture line in\n its `description:` frontmatter;\n- `INSTRUCTIONS` (`mcp_server/src/pipelines.generated.ts`) — carries the\n canonical source and both decomposition instructions;\n- `DOCS` (`mcp_server/src/docs.generated.ts`) — carries this document.\n\nThe compressed frontmatter line matters more than its size suggests: agent\ndescriptions land in every session's system prompt with no file read and no\n`tools/list` cost, so it is the entire bare-chat coverage story.\n\n## Worked examples\n\n**One ticket.** \"Add a `--json` flag to `doctor`.\" Two files and a test, ~90 LOC.\nThat is `M`. One ticket, drafted by the writer, no epic, no manifest, no\nconductor handoff.\n\n**Two tickets.** \"Add rate limiting to the LLM client, and surface the limit in\nthe config UI.\" Backend and frontend are independently implementable and land\nseparately: two ordinary siblings. Still no epic — the threshold is three.\n\n**Four tickets → an epic.** \"Make local ticket mode a first-class system.\"\nDecomposition freezes a parent plus four children, each `L`, with `depends_on`\nnaming the one child that must land first. The full manifest goes to the approval\ngate; on approval, four writer invocations render four bodies against their\nfrozen entries; creation follows `upload-epic-hierarchy.md`; the handoff names\n`drive-epic` and nothing else.\n\n**A child that outgrows `L`.** A proposed child comes out at 19 files. It ships\nas one `XL` child. Do not split it into two `L` children to make it fit — the\nslice is one coherent piece of work, and halving it buys a second worktree, a\nsecond PR, and a rebase between them in exchange for nothing. Split only if the\n19 files really are two independent deliverables.\n\n**Past the ceiling.** A proposed ticket comes out at 60 files and ~5000 LOC.\nThat is over the bound, so it splits — but into the largest coherent pieces\navailable, not into a swarm. Two `XL` tickets is the right answer here; six `M`\nones is not.\n",
|
|
7
|
-
".bridge/procedures/review-epic-coherence-procedure.md": "# Review Epic Coherence\n\nThis is the shared procedure for checking an epic's children **as a set**. It answers two\nquestions no per-ticket review asks: does every epic acceptance criterion have a child that\ncarries out its verification, and is everything one child produces wired to whatever consumes\nit? Drafting surfaces and the on-demand `/review-epic-coherence` command run this same text.\n\nThe check fails **visibly**. A run that cannot finish is `not_checked`. It is never `pass`.\n\n**Enforcement status.** The three drafting surfaces — `define-tickets`, `plan-epic`, and\n`idea-to-ticket` — call this procedure in drafting mode before creation or approval, and\n`render-ticket-manifest.md` refuses to render an epic without a clearing record. A\nreport-mode result from the on-demand command is a diagnostic, not a gate: it clears nothing.\n\n## What the user sees\n\nEverything this procedure says to a person in attended chat, progress messages, and screens\nuses the plain words in this table, never the internal term. Callers that show a result to a\nperson use the same words.\n\n| Internal concept | User-facing wording |\n|---|---|\n| coherence check | gap check |\n| coverage | a requirement no ticket owns |\n| handoff | a broken hand-off between tickets |\n| fit | a plan that doesn't match the code |\n| e2e_proof | no end-to-end test |\n| `pass` | No gaps found |\n| `accepted_with_gaps` | Accepted with known gaps |\n| `blocked` | Needs your decision |\n| `not_checked` | Couldn't check |\n| foundation blocker | a gap in how the work is split |\n| ticket-local carried finding | a note added to ticket N |\n| `independent: false` | this check ran in my own session, not by a separate reviewer, so it's less independent |\n| coverage map | Who covers each requirement |\n| accept override | Create anyway, and record the gap on the epic |\n| fix | Change how the tickets are split |\n\n- **Qualified pass.** In drafting mode, a passing record that carries ticket-local findings is\n shown as `No gaps found (N notes added to tickets)`.\n- **Report mode.** A ticket-local finding is described prospectively, as `a note that would be\n added to ticket N`, and the report says the check changed no ticket.\n- **Scope of the vocabulary.** It covers attended chat, progress messages, and screens only.\n `epic-coherence.md`, the JSON fields and verdict values in `epic-coherence.json`, the agent\n name, and the parent ticket's `## Epic coverage map` section keep their technical wording.\n- Write new passages with words such as `ticket N` and angle-bracket paths. Do not add any\n new brace-wrapped identifier token.\n\n## Inputs\n\nState these four values before starting:\n\n1. **Input document path** — the path to `epic-coherence-input.json`.\n2. **Output directory** — a directory beneath the `docs_dir` that the `ping` tool returned.\n3. **Mode** — `drafting` or `report`.\n4. **Unattended** — true only when `auto_approve_external == \"true\"`. Otherwise the run is\n attended.\n\nIf any of the four is missing, stop and report which one. Do not guess a default.\n\nAn optional fifth input, **`council_preapproval`**, carries a `value` (`approved` or\n`declined`) and its `source`. It records a council decision the caller already got from the\noperator, so the procedure asks no council question of its own; see \"Council call\". Attended\n`define-tickets` supplies it from its drafting plan. It is not one of the required\ninputs, so its absence never stops the run. When it is absent, the attended asks in \"Council\ncall\" apply.\n\nAn optional sixth input, **`auto_amend`**, is `true` only when the caller asks for it. In an\nattended drafting run it makes the caller amend the manifest between rounds with no question,\nas an unattended run does. Any foundation gap still left after the bound goes to the caller's\ncreate screen with an agent-drafted accept reason; it does not halt. See \"Drafting mode\".\n\n## The input document\n\nThe document carries artifacts only. It never carries the drafting conversation.\n\n```json\n{\n \"epic\": {\n \"key\": \"EPIC-1\",\n \"title\": \"Short epic title\",\n \"acceptance_criteria\": [\n { \"id\": \"AC-1\", \"text\": \"What must be true\", \"verification\": \"How it is proven\" }\n ]\n },\n \"design_text\": \"Goals and design text: the exploration's Goals & NFRs followed by its Proposed Design, the epic parent body, or equivalent.\",\n \"manifest\": [\n {\n \"id\": \"1\",\n \"title\": \"Child title\",\n \"scope\": \"What the child does\",\n \"size_band\": \"L\",\n \"depends_on\": [],\n \"recommended_after\": [],\n \"touched_files\": [\"path/relative/to/repo.py\"],\n \"read_files\": [\"path/the/child/only/reads.py\"],\n \"owns_verifications\": [\n { \"epic_ac\": \"AC-1\", \"obligation\": \"The concrete part of AC-1's verification this child carries out\" }\n ]\n }\n ],\n \"child_evidence\": [\n {\n \"id\": \"1\",\n \"acceptance_criteria\": [\"Each acceptance criterion of the child, verbatim\"],\n \"body\": \"The child ticket body, if available\"\n }\n ],\n \"non_child_owners\": [\n {\n \"id\": \"OR-1\",\n \"kind\": \"owner_run\",\n \"who\": \"Release owner\",\n \"step_ref\": \"Release checklist step 6\",\n \"step_text\": \"Release checklist step 6: the release owner runs the smoke test against production and posts the output as a comment on the epic.\",\n \"records_result_in\": \"a comment on the epic\",\n \"owns_verifications\": [\n { \"epic_ac\": \"AC-2\", \"obligation\": \"Run the production smoke test and post its output on the epic\" }\n ]\n }\n ]\n}\n```\n\nField rules:\n\n- `epic` carries either `key` or `slug` (one is enough), plus `title` and\n `acceptance_criteria`. Each acceptance criterion has `id`, `text`, and `verification`. When\n an epic AC has no verification sentence, coverage is judged against its text, the basis is\n `text_only`, and the reviewer raises an advisory input finding naming the missing sentence.\n- `design_text` is the goals and design text. When the caller has the epic's goals and\n non-functional requirements (NFRs), they open `design_text` verbatim, and the reviewer checks\n the split against each NFR as well as against the acceptance criteria. When there are none,\n that check is skipped and nothing is raised about their absence.\n- `manifest` is the **complete, ordered** child list. Each entry carries `id` (a placeholder\n index or a real ticket key), `title`, `scope`, `size_band`, `depends_on`, and\n `recommended_after`. These are the same field names `decompose-epic.md` and\n `decompose-epic-candidate.md` already use.\n- `touched_files` is optional. It lists the files the child **edits or creates**. When absent,\n the fit check uses the file paths the child's scope and body name. A `touched_files` path that\n does not exist yet can be a planned creation; that alone is not a problem.\n- `read_files` is optional. It lists files the child **only reads**. It lives in the manifest,\n so it is hashed. Reads inform the fit check. Only edits (`touched_files`) count toward edit\n overlap between children and toward the high-risk path check in \"Escalation rule\". A path\n must not appear in both lists. A `read_files` path that does not exist is an `input` problem,\n because a child cannot read a file that is not there. When `read_files` is absent, behavior is\n unchanged.\n- `owns_verifications` is optional. It is a list of entries with `epic_ac` (an epic AC id) and\n `obligation` (the concrete part of that AC's *verification* this child will carry out, in\n words a reviewer can hold against the verification sentence). It is a **claim** the reviewer\n checks. It is never proof by itself. When it is absent (older epics, the on-demand path), the\n reviewer derives candidate owners from each child's own acceptance criteria, and the record\n says `owns_verifications_source: derived`. When it is present, the record says `declared`.\n- `child_evidence` is a **separate top-level array**, keyed by child `id`. Each entry may carry\n `acceptance_criteria` and `body`. It lives **outside** the hashed manifest, so evidence can be\n refreshed without changing manifest identity. Derived ownership counts only when a child's\n acceptance criteria contain a concrete commitment to the obligation. When the material needed\n to establish ownership is absent, that is an explicit `input` gap, not coverage.\n- `non_child_owners` is an optional **top-level array** beside `child_evidence`. It names the\n owners of epic AC verifications that no child carries out, such as a step in an owner-run\n release checklist. Each entry has:\n - `id` — for example `OR-1`. It is unique across the array and never equal to any child `id`.\n - `kind` — a closed vocabulary with one value: `owner_run`.\n - `who` — a named person or role, for example \"Release owner\".\n - `step_ref` — the step it points at, for example \"Release checklist step 6\".\n - `step_text` — the step's text, copied **verbatim** from `design_text`.\n - `records_result_in` — where the result is recorded, for example \"a comment on the epic\".\n - `owns_verifications` — a list of `epic_ac` plus `obligation` entries, the same shape\n children use.\n\n `step_text` is copied into the entry on purpose. `design_text` is not hashed, so a step that\n lived only there could change without changing the review's identity. The copied, hashed\n `step_text` is the reviewed commitment. An owner-run owner owns **coverage only**: it never\n fills a hand-off grid cell. When the array is absent, no AC has a non-child owner.\n\n**Local markdown drafts.** When an epic is drafted as local markdown files outside a drafting\nsurface, build this document with the packaged `epic-coherence-input build` subcommand of the\nBridge MCP package: `epic-coherence-input build --outline <outline-path> --out <output-path>`.\nDo not assemble it by hand. The outline names the epic draft, each child's draft, its\ndependencies, size band, `edits` (which become `touched_files`), `reads` (which become\n`read_files`), and `owns_verifications`, plus any `non_child_owners`. Every epic AC bullet in the\nepic draft must start with an explicit id such as `AC-3:`; the builder never numbers ACs by\nposition or matches them by keyword. `epic-coherence-input check <input-path>` validates an\nexisting document against the structural rules in \"Validation\" and prints the three digests. It\nnever judges coverage; that stays the reviewer's job. The three drafting surfaces keep their\nstructured normalization, and the on-demand `/review-epic-coherence` command keeps building its\ninput from ticket data.\n\n## Identities\n\nThree digests identify what was reviewed. All three use the same canonical JSON encoding.\n\n- `manifest_sha256` is the SHA-256 hex digest of\n `json.dumps(manifest, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")`,\n computed over the `manifest` array only. Compute it locally with this one line:\n\n ```bash\n python3 -c 'import hashlib,json,sys; manifest=json.load(open(sys.argv[1], encoding=\"utf-8\"))[\"manifest\"]; print(hashlib.sha256(json.dumps(manifest, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")).hexdigest())' <input-path>\n ```\n\n- `child_evidence_sha256` is the SHA-256 hex digest of the same encoding applied to the\n `child_evidence` array (an absent array hashes as an empty array).\n- `non_child_owners_sha256` is the SHA-256 hex digest of the same encoding applied to the\n `non_child_owners` array. An absent array hashes as an empty array, as `child_evidence`\n does. Compute it locally with this one line:\n\n ```bash\n python3 -c 'import hashlib,json,sys; owners=json.load(open(sys.argv[1], encoding=\"utf-8\")).get(\"non_child_owners\", []); print(hashlib.sha256(json.dumps(owners, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")).hexdigest())' <input-path>\n ```\n\nRecord **all three** digests, at the top level and in every round. A caller that wants to\nreuse a prior review must compare **all three** identities against the manifest, evidence,\nand non-child owners it is about to use. A matching manifest with changed evidence or changed\nowners is not the same review. The sibling integration's preflight must compare all three.\n\n`design_text` deliberately stays **outside** identity. The copied and hashed `step_text` is\nthe reviewed commitment of an owner-run step. There is no fourth digest, and no render-time\ncheck that `design_text` still contains the step.\n\n## Validation\n\nBefore any reviewer run, validate the input document. Every problem becomes a visible `input`\nfinding. Nothing is silently dropped.\n\n- Child ids are unique. Epic AC ids are unique. Every `owns_verifications.epic_ac` names a real\n epic AC, and every `child_evidence.id` names a real manifest child.\n- The document shapes and the key or slug syntax are valid.\n- Every `non_child_owners` entry is well formed. Its `id` is unique across the array and never\n collides with a child id. Its `kind` is `owner_run`. Its `who`, `step_ref`, `step_text`, and\n `records_result_in` are non-empty. Every one of its `owns_verifications.epic_ac` values names\n a real epic AC. A malformed entry, a colliding id, an invalid AC reference, and a missing\n required field are each a visible `input` finding.\n- Every named file path is repository-relative. Reject absolute paths and any path that\n traverses upward. A path listed in both `touched_files` and `read_files` of the same child is\n an `input` finding.\n- The output directory is beneath the `docs_dir` that `ping` resolved. Refuse to write anywhere\n else.\n- A missing, invalid, or unreadable named file is an `input` finding. So is inaccessible child\n material and a missing set of epic acceptance criteria. A nonexistent `touched_files` path can\n be a planned creation and is not, by itself, a finding. A nonexistent `read_files` path is an\n `input` finding.\n- A missing verification sentence alone is **advisory**. Any problem that prevents a meaningful\n review (no epic acceptance criteria, an empty manifest, an unreadable input document) makes\n the verdict `not_checked`. It never produces a complete-looking coverage map.\n\nDescribe variable paths in words or angle brackets, such as `<output-directory>`. Do not write\nany literal brace-wrapped identifier other than `docs_dir`, including in examples.\n\n## Reviewer run\n\nInvoke the `epic-coherence-reviewer` agent in a **fresh context**. Pass it only the input\ndocument path. Run it **once per round over the whole frozen manifest** — never per child and\nnever over a subset. The reviewer must not receive the drafting conversation.\n\nResolve the agent the way `draft-ticket.md` resolves `jira-ticket-writer`: through the Task tool\nor a host equivalent you have confirmed can resolve it. Cursor has no agent mirror for this\nagent, so on Cursor resolution normally fails.\n\n**Fresh-context fallback.** If no fresh context can be obtained, read the agent file\n`agents/src/epic-coherence-reviewer.md` (or its installed mirror) and execute its methodology\ninline. Set `independent: false` in the record and say so in the report. An inline run is never\na silent independent pass.\n\n- In an **attended** run, tell the person in plain words: \"this check ran in my own session, not\n by a separate reviewer, so it's less independent.\" Offer a fresh-context rerun when one\n becomes available.\n- In an **unattended drafting** run, an inline `pass` is not the independent gate. Halt.\n\n## Escalation rule\n\nEscalate to a council **only** when at least one of these is true:\n\n1. Any blocking finding has `confidence: uncertain`.\n2. The caller **disputes** a blocking finding instead of amending it. The caller is the drafting\n agent in drafting mode and the operator in report mode.\n3. The epic is **high risk**.\n\nHigh risk means one of the following. Count **children**, never edited files: a single child\nthat edits ten files under one prefix is still one child.\n\n- The epic has **six or more children**.\n- **One** child's `touched_files` falls under one of these paths. A single editing child is\n enough:\n - `db/migrations/` and `db/alembic/` (the design says `db/migrations/`; this repository's\n migrations live in `db/alembic/`, so match both)\n - `api/library/billing/`\n - `api/routes/setup/auth.py`\n - `api/library/auth/`\n- **Two or more distinct** children each edit under the same kind of path from the list below.\n One editing child alone does **not** make the epic high risk. This list is every remaining\n prefix in `_CONTAINMENT_HAZARD_PATHS` in `api/library/github/workflow_planning_prediction.py`\n (the list also carries `db/alembic/`, which is already a single-trigger path above):\n `mcp_server/src/executor/`, `mcp_server/src/agent-launchers/`,\n `mcp_server/src/claude-settings.ts`, `.github/workflows/`,\n `tests/integration/conductor_harness/`, and `api/library/db/`\n\n| Edits under the path | Risk tier |\n| --- | --- |\n| One child edits `api/library/db/` | low |\n| Two children each edit `api/library/db/` | high |\n| One child edits an executor prefix such as `mcp_server/src/executor/` | low |\n| Two children each edit executor-prefix paths | high |\n| One child edits `db/alembic/`, `api/library/billing/`, or auth paths | high |\n| Six or more children, whatever they edit | high |\n\nOnly edits count. A path a child lists in `read_files` never makes the epic high risk, even\nunder one of these prefixes, so a child that only reads `api/library/db/` does not trigger\nthis rule. Reads do not count toward the two-child threshold either.\n\nA low-risk epic with one child editing `api/library/db/` or an executor prefix still receives\nthe low-risk reviewer rounds in \"Drafting mode\". If a round raises a blocking finding with\n`confidence: uncertain`, the epic is promoted to high risk and the council flow starts. Any\nblocking findings that remain go to the operator at the create gate. This adds no other\nmitigation.\n\nWhen `touched_files` is absent for a child, apply the same path check to the concrete paths its\nscope and body name. When a child's file ownership is unknown, record **uncertainty**. Do not\ndeclare the epic low risk.\n\n**Classify the risk before round 1.** Decide the initial risk tier from the input alone,\nbefore the first reviewer run, using the child count and the edit paths. The tier is `high`\nwhen this rule matches, and also when unknown file ownership leaves the question open. It is\n`low` otherwise. Record it as `risk_tier` with its `risk_reasons`, for example \"Children 1 and 3\nboth edit `api/library/db/`\". Trigger 3 therefore fires **before round 1**. Triggers 1 and 2 still fire\nafter any later round.\n\nAn uncompleted required escalation leaves the result unresolved. It is never a quiet pass.\n\n## Council call\n\nBefore **every** billable council request, state:\n\n- the cost: **26–65 credits and about 15 minutes** (26 credits for standard models, 65 credits\n for frontier models; state the applicable tier if providers are pinned). The source is\n `api/library/billing/pricing.py`;\n- the escalation reason (which of the three triggers fired);\n- that council output cannot itself clear a blocker.\n\nAn **attended** run asks the operator to approve before proceeding, using the decision card\nbelow. An **unattended** run states the cost in its output and proceeds. This holds for every\nrequest, including a `mode: general` retry.\n\n**The decision card.** Every attended council offer is one card, shown in this order:\n\n1. A plain-language question ending in `?`, such as \"Would you like several other AI models to\n review how the work is split before I create the tickets?\"\n2. One sentence saying what a council is: \"a panel of several AI models that each review the\n plan separately.\" It carries the cost (`26–65 credits`) and `about 15 minutes`, and says\n the gap check runs either way.\n3. A recommendation, with a reason of one or two sentences grounded in what is uncertain.\n4. Bulleted concrete questions the council would check, each followed by the AI's current\n answer, or an explicit statement that it is not sure.\n5. Exactly these three options, with `(as recommended)` on the recommended one only:\n\n ```text\n 1. Yes, run the council\n 2. No, continue without it\n 3. Yes, but change what it checks, or ask me something first\n ```\n\n**Reading the reply.** Judge the reply by intent, not by exact words. A clear number or a clear\nverbal choice selects that option. An unclear reply authorizes nothing: say what you could not\ntell and show the card again.\n\n- **Option 3 with a new focus.** Echo the revised checklist back in one or two lines, run the\n council with it, and do not ask again.\n- **Option 3 with a question.** Answer the question first, then show the three options again in\n a compact form.\n- **A reply that picks an option and also asks to change the split.** The change comes first:\n amend the manifest, re-freeze it, and start no council from that reply.\n- Added focus never removes a mandatory check, never waives the gap check, and never changes\n how a record clears.\n\n**When the council starts.**\n\n- **High-risk trigger.** After the epic is classified high risk before round 1, an attended run\n shows the decision card **before** round 1 starts. It explains the high-risk reason in plain\n words from `risk_reasons`, for example \"two tickets both change the database layer\", without\n changing any threshold or classification. The mandatory checks on the card are concurrent\n writers, migration and rollback order, and rollout that runs ahead of the code, each with the\n AI's current answer or stated uncertainty. On option 1, or option 3 with a focus, request the\n council and start the round-1 reviewer run **in parallel**. Do not wait for a later round.\n - **Decline.** On option 2, request no council. Record `council_id: null` and\n `council_outcome: \"declined_by_operator\"`, omit `council_preapproval`, and continue the\n reviewer run. The decline is final and is shown as `Council: skipped, your choice`.\n - **Caller preapproval.** If the caller supplied `council_preapproval`, its `value` and\n `source` are recorded. `approved` starts the initial council alongside round 1 after\n stating the cost, with no further ask. `declined` skips it and records the same\n `declined_by_operator` outcome.\n - If the technical request needs the `mode: general` retry, state the cost again, with the\n disclosure and approval that retry already requires.\n- **Uncertain or disputed trigger.** Request the council after the round that raised the\n finding. An attended run shows the same decision card with its own cost statement, a\n recommendation, and questions about that finding, each with the AI's current answer. The task\n text stays limited to the input document's artifacts and the relevant findings.\n - **Decline.** On option 2, request no council and append no `councils` entry. The triggering\n finding keeps its identity, severity, evidence, and blocking status. Keep the finding id in\n the run state as declined, so no later round offers a council for the same finding again.\n No new record field is added for this.\n - A genuinely new qualifying finding may still get an offer, within the limit below.\n - **Caller preapproval.** When the caller supplied `council_preapproval`, show no card for\n this trigger either. `approved` states the cost and requests the council with no ask,\n within the limit below. `declined` requests none, exactly as a decline on the card does.\n- **How many.** One council per drafting run for the initial high-risk trigger. A later\n qualifying trigger (an uncertain or disputed blocking finding) may start **at most one more**\n council, with its own cost statement and approval.\n\nCall `request_council` with:\n\n- `mode`: `technical`\n- `wait_for_result`: `false`\n- no `repo_name`\n- task text containing **only** the input document's artifacts and the contested findings.\n The early high-risk council has no reviewer findings yet, so its task text holds **only** the\n input document's artifacts. Never invent findings for it. Ask it to look for cross-child and\n release-level risks, such as concurrent writers, migration and rollback order, and rollout\n that runs ahead of the code.\n\nThen poll `get_council` for a bounded period. Call it with `wait_for_result: true`: it returns\nwhen the council finishes, so you see the result within about 30 seconds. If it times out, call\nit again; that is safe and never starts a second council. Never sleep a fixed time between\nchecks. If technical mode cannot run because the repository is not indexed, repeat the request with `mode: general`, and state the cost again\nbefore that request too.\n\n**The amendment freeze.** The round-1 amendment freezes at the moment the caller begins writing\nthe amended input document after collecting the round-1 findings. Poll `get_council` while the\nround-1 reviewer runs. Council conclusions received before the freeze join that **same**\namendment pass. Conclusions received after it join the next pass. A frozen round is never\nchanged after the fact.\n\nCouncil conclusions join the finding list as **separate** findings with `source: council`. The\noriginal reviewer finding is kept unchanged. It is never edited, downgraded, or removed because\na council failed, timed out, is still running, left the dispute unresolved, or concluded.\nRecord the `council_id` and the council outcome. Record still-running and failed outcomes as\nunresolved.\n\n**An unfinished required council.** A required council that is `still_running`, `failed`, or\n`timed_out` when the last round or confirmation pass ends is unresolved. The verdict is never\n`pass`. An **attended** operator, after being shown the council's id, cost, and elapsed time,\nmay accept it with a typed override of kind `accept` that names its `council_id`. An\n**unattended** run records `blocked` and halts before any ticket is created.\n\nA council outcome of `declined_by_operator` is resolved and needs no `accept` override, whether it was declined at the pre-round-1 ask or through legacy `council_preapproval: declined`. A legacy `accept` override targeting `council: \"declined_by_operator\"` remains valid but is ignored for clearance.\n\n**Declining an escalation council.** Declining a council offered for an uncertain or disputed\nfinding resolves the council decision only. The finding itself stays blocking until it is\namended or accepted by its own `finding_id`.\n\n## Drafting mode\n\nDrafting mode is for a drafting surface that can still change the manifest.\n\n- **Attended progress.** After every completed reviewer round, an attended run says one short\n line with the number of gaps in how the work is split that still need a decision. Use the\n real ordinary-round ceiling for this epic (the low-risk or the high-risk limit below), for\n example: `Gap check, round 1 of up to 3: 2 gaps need a decision.` A confirmation pass is\n named as a confirmation pass. It is never counted as an extra ordinary round. Unattended runs\n print no such line.\n- **Amend and recheck.** The reviewer only describes amendments. The **caller** amends the\n manifest (adds or rescopes children), re-freezes it, and writes a **new** input document. The\n procedure then reruns the reviewer in a fresh context. Record each round with its own\n `manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`, blocking and\n advisory counts, whether a council ran, and whether it was a confirmation pass.\n- **Foundation readiness and carry.** A round with zero foundation blockers is ready and exits the ordinary loop immediately. Carry unresolved ticket-local blockers without amending or rechecking merely because they remain. `pass` requires zero unresolved foundation blockers and may retain carried ticket-local findings; `accepted_with_gaps` is reserved for accepted remaining foundation blockers.\n- **Risk-scaled round limit.** The number of ordinary reviewer runs, `round_limit`, depends on\n the risk tier from \"Escalation rule\":\n - **Low risk** (the epic is not high risk and no blocking finding is `uncertain`):\n `round_limit` is **2**. These are maximum ordinary rounds; exit earlier when a round has zero foundation blockers.\n That is at most **2 reviewer runs**.\n - **High risk**: `round_limit` is **3**. Allow at most **2 re-checks**, which is\n **3 reviewer runs in total**, with the same zero-foundation early exit.\n - **Promotion.** A low-risk epic whose round produces a blocking finding with\n `confidence: uncertain` becomes high risk from that point. It gets the high-risk limit, and\n trigger 1 fires. Promotion raises the ceiling to three total ordinary rounds, including rounds already completed.\n\n If a round with foundation blockers has a foundation count greater than or equal to the preceding round's count, stop automatic looping with `non_convergence`; route attended findings to the create gate or halt unattended as `blocked`.\n\n Record the final `risk_tier`, `risk_reasons`, and `round_limit`. A confirmation pass is not an\n ordinary run and does not count toward `round_limit`.\n- **Confirmation pass.** Run a confirmation only after a caller amendment targeting foundation findings and when the ordinary-round rule calls for it. Derive `confirmation_passes_used` from `rounds[].confirmation`; the budget is two attended passes or one unattended pass, and refuse another at the budget.\n\n When the caller changes the input after the last allowed ordinary\n round, run **one confirmation pass**. It is a fresh-context reviewer run over the **whole**\n amended manifest, never a subset. Its requested focus is narrower: the amended children, the\n hand-offs they touch, and whether the findings the amendment targeted are closed. It must\n still report **any** blocking finding it observes anywhere in the manifest; the narrower\n focus never suppresses one. When it cannot establish where an amendment's impact ends, it\n raises that as a blocking finding with `confidence: uncertain` instead of calling the\n amendment confirmed. Record it in `rounds[]` with `\"confirmation\": true`.\n - A confirmation pass **never** starts another automatic amendment loop. A new blocking\n finding goes to attended fix-or-accept, or to the unattended halt.\n - In an **attended** run, after the first confirmation pass, the operator may direct **at\n most one** fix of a confirmation blocker. Then run **one** further whole-manifest\n confirmation pass, so the last round bears the final digests. That is the whole budget\n across re-runs in the same attended `define-tickets` run.\n - Once that budget is spent, a remaining blocker is accepted with a non-empty reason or stays\n `blocked`. Do not add an \"unconfirmed fixed\" state, and do not start another automatic\n amendment loop. A typed acceptance stays available instead of the fix at any point.\n- **Final identity.** The top-level `manifest_sha256`, `child_evidence_sha256`, and\n `non_child_owners_sha256` equal the digests of the **last** entry in `rounds[]`. A record\n whose top-level digests no round saw does not clear. The sole exception is a confirmation\n pass that cannot run: an **attended** operator may record `amended_after_final_round: true`\n with an override of kind `bypass` carrying a typed reason. The verdict is then\n `not_checked`, never `pass` or `accepted_with_gaps`, and the top-level digests still describe\n the amended input. An **unattended** run halts instead.\n- **Automatic amendment.** When the caller passed `auto_amend: true`, an attended run amends\n and rechecks within the same round and confirmation bounds with no question, as an unattended\n run does. After the bound, each remaining foundation blocking finding goes to the caller's\n create screen with an agent-drafted reason. The operator's approval there records it as an\n `accept` override. It is never a halt.\n- **Attended resolution.** After the bound, each remaining **foundation** blocking finding must be\n fixed within the same one-fix, one-further-confirmation-pass budget, or accepted with a non-empty reason.\n Ticket-local blockers are carried to their child ticket; they do not require a foundation amendment\n or acceptance to clear the epic record.\n The reason may be typed by the operator or drafted by the agent and shown at the create gate\n where that gate applies. An accepted finding is an override with `kind: accept`, plus\n `finding_id`, `reason`, `accepted_by`, and `round`. Declining a foundation finding keeps the verdict `blocked`.\n When **every** remaining foundation blocking finding is accepted, the verdict is `accepted_with_gaps`.\n- **Unattended halt.** If any foundation blocking finding remains after the bound, the verdict is\n `blocked`. Return an explicit halt signal: **do not call `create_ticket`**. The caller must\n stop.\n\n## When the review cannot run\n\nIf the reviewer cannot run (a tool error, a timeout, or a host that lacks the capability while\ninline execution also fails), or the material prevents a meaningful review, the verdict is\n`not_checked`. It is never `pass`.\n\n- **Attended:** tell the person \"Couldn't check\", then offer a retry, or a bypass with a typed\n reason. A bypass is recorded as an override with `kind: bypass`. The verdict stays\n `not_checked`.\n- **Unattended:** halt.\n\n## Report mode\n\nReport mode is diagnostic. It runs the reviewer **once**. There is no amendment loop and no halt\nsignal. Escalation still applies, with the cost stated and confirmation asked. It splits blocking counts and the verdict by scope: ticket-local blockers are labelled “would be carried into child N”, are not carried, and edit no ticket. The verdict is `pass`, `blocked`, or `not_checked` from foundation blockers only.\n\nA `blocked` or `not_checked` report is **diagnostic and not a clearance**.\n\nWhen showing a report-mode result to a person, use the words in \"What the user sees\". Describe\neach ticket-local finding as `a note that would be added to ticket N`, keep the result\ndiagnostic rather than clearing, and say plainly that the check changed no ticket.\n\n## The record: epic-coherence.json\n\nWrite `epic-coherence.json` into the output directory:\n\n```json\n{\n \"schema_version\": 3,\n \"checked_at\": \"2026-01-01T00:00:00Z\",\n \"mode\": \"drafting\",\n \"unattended\": false,\n \"manifest_sha256\": \"<64 hex characters, or null>\",\n \"child_evidence_sha256\": \"<64 hex characters, or null>\",\n \"non_child_owners_sha256\": \"<64 hex characters, or null>\",\n \"owns_verifications_source\": \"declared\",\n \"verdict\": \"pass\",\n \"independent\": true,\n \"risk_tier\": \"low\",\n \"risk_reasons\": [\"Three children; no child edits a high-risk path\"],\n \"round_limit\": 2,\n \"confirmation_passes_used\": 0,\n \"confirmation_budget\": 2,\n \"stop_reason\": \"ready\",\n \"carried_ticket_local\": [],\n \"amended_after_final_round\": false,\n \"rounds\": [\n {\n \"manifest_sha256\": \"<64 hex characters>\",\n \"child_evidence_sha256\": \"<64 hex characters>\",\n \"non_child_owners_sha256\": \"<64 hex characters>\",\n \"blocking_count\": 0,\n \"foundation_blocking_count\": 0,\n \"ticket_local_blocking_count\": 0,\n \"findings_snapshot\": [],\n \"advisory_count\": 0,\n \"council_ran\": false,\n \"confirmation\": false\n }\n ],\n \"owner_run_acs\": [\"AC-2\"],\n \"coverage_map\": [\n {\n \"epic_ac\": \"AC-1\",\n \"judgment_basis\": \"verification\",\n \"status\": \"covered\",\n \"owners\": [\n {\n \"owner_kind\": \"child\",\n \"child\": \"1\",\n \"obligation\": \"Concrete obligation\",\n \"child_ac\": \"The child AC id or a quoted child AC\",\n \"source\": \"declared\"\n }\n ]\n },\n {\n \"epic_ac\": \"AC-2\",\n \"judgment_basis\": \"verification\",\n \"status\": \"covered\",\n \"owners\": [\n {\n \"owner_kind\": \"owner_run\",\n \"child\": null,\n \"owner\": \"OR-1\",\n \"who\": \"Release owner\",\n \"step_ref\": \"Release checklist step 6\",\n \"records_result_in\": \"a comment on the epic\",\n \"obligation\": \"Run the production smoke test and post its output on the epic\",\n \"source\": \"declared\"\n }\n ]\n }\n ],\n \"handoff_grid\": [\n {\n \"thing\": \"The stored field, endpoint, flag, event, job payload, or scope\",\n \"consumer\": \"The consuming piece\",\n \"write_path\": \"child id or null\",\n \"read_path\": \"child id or null\",\n \"caller\": \"child id or null\",\n \"start\": \"child id or null\",\n \"steady_state\": \"child id or null\",\n \"wind_down\": \"child id or null\"\n }\n ],\n \"findings\": [\n {\n \"id\": \"F-1\",\n \"kind\": \"coverage\",\n \"severity\": \"blocking\",\n \"confidence\": \"certain\",\n \"concerns\": \"AC-1\",\n \"evidence\": \"What was observed, with file and line where code was read\",\n \"smallest_amendment\": \"The smallest change that would close it\",\n \"source\": \"reviewer\", \"scope\": \"foundation\"\n }\n ],\n \"overrides\": [\n { \"kind\": \"accept\", \"finding_id\": \"F-1\", \"reason\": \"Typed reason\", \"accepted_by\": \"Operator\", \"round\": 3 }\n ],\n \"council_preapproval\": { \"value\": \"approved\", \"source\": \"legacy caller input\" },\n \"council_id\": null,\n \"council_outcome\": \"not_run\",\n \"councils\": []\n}\n```\n\nRules:\n\n- `schema_version` is `3`. Readers also accept versions `1` and `2`; interpret every legacy blocking finding as `foundation`.\n- In version 3, validate every blocking finding's closed `scope` and every `ticket_local` child against the final manifest before counting, clearing, or carrying. Invalid or orphaned ownership fails closed; reclassify an ambiguously owned former carry as foundation explicitly.\n- `blocking_count` is the sum of `foundation_blocking_count` and `ticket_local_blocking_count`; count every blocking finding regardless of confidence.\n- `pass` requires zero unresolved foundation blockers.\n- `carried_ticket_local` holds one unresolved entry per stable identity with its finding id, child id, evidence, and smallest amendment. Preserve the latest snapshot and close an identity only when a later review explicitly establishes correction or supersession.\n- `stop_reason` is one of `ready`, `round_limit`, `non_convergence`, or `confirmation_budget_spent`.\n- `verdict` is one of `pass`, `accepted_with_gaps`, `blocked`, `not_checked`.\n- A `pass` with `independent: false` is allowed but flagged prominently in both files.\n- An `accept` override accepts a known gap. A `bypass` override skips a review that could not\n run. Keep the two distinct.\n- `kind` on a finding is one of `coverage`, `handoff`, `fit`, `e2e_proof`, `input`.\n `severity` is `blocking` or `advisory`. `confidence` is `certain` or `uncertain`. `source`\n is `reviewer` or `council`.\n- Digests may be `null` **only** when unreadable input makes computing them impossible. Then\n add an explicit `input` finding and set the verdict to `not_checked`.\n- The top-level digests equal the last round's digests. The only record allowed to differ is\n an attended one with `amended_after_final_round: true`, a `bypass` override with a typed\n reason, and verdict `not_checked` (see \"Drafting mode\"). The skip record below is the one\n record with no rounds at all.\n- **Skip record.** When an attended caller's operator chose not to run the check, the caller\n writes the record itself and no reviewer runs. It carries `skipped_by_operator: true`,\n `rounds: []`, verdict `not_checked`, the three digests of the current input, an empty\n coverage map, and one `bypass` override with a non-empty reason. It clears only for that\n attended caller, never for an unattended run. `skipped_by_operator` is absent on every other\n record.\n- `rounds[].confirmation` is `true` only for a confirmation pass. `risk_tier` is `low` or\n `high`, `risk_reasons` lists why, and `round_limit` is the ordinary-run limit that applied\n (`2` or `3`; report mode runs once).\n- Each coverage owner carries `owner_kind`, which is `child` or `owner_run`. A child owner\n carries `child`, `obligation`, `child_ac`, and `source`. An owner-run owner carries\n `child: null`, `owner` (its `non_child_owners` id), `who`, `step_ref`, `records_result_in`,\n `obligation`, and `source: declared`.\n- `owner_run_acs` lists the id of every epic AC with at least one owner-run owner. It is empty\n when there are none. Owner-run coverage is always visible, never silently passed.\n- `council_id` is `null` when no council ran. `council_outcome` is one of `not_run`,\n `concluded`, `failed`, `timed_out`, `still_running`, or `declined_by_operator`. These two fields describe the first\n council. When a second council runs, `councils` lists **every** council in order, each with\n `council_id`, `trigger` (`uncertain`, `disputed`, or `high_risk`), and `outcome`. An override\n that accepts an unfinished council carries `council_id` in place of `finding_id`.\n An initial council declined at the pre-round-1 ask, or through legacy `council_preapproval`,\n is stored in `council_outcome` as `declined_by_operator` with `council_id: null`, and is\n retained there when a later council also needs an entry in `councils`. It needs no override.\n Older records may carry an override with `council: \"declined_by_operator\"` in place of\n `finding_id` or `council_id`; it stays valid and is ignored for clearance.\n- `council_preapproval` is present only when a caller supplied it. It persists its\n `value` and `source`, and the record omits the field otherwise, including after an attended\n decline at the pre-round-1 ask.\n- Unknown fields, such as a historical `council_note`, are outside this schema. Readers ignore\n them. They never authorize clearance.\n- A `not_checked` record must **never** carry a coverage map that looks complete. Leave the map\n empty, or mark every entry as not assessed.\n- Keep this schema in this file. Do not copy it into the ticket-authoring posture block.\n\n## The record: epic-coherence.md\n\nWrite `epic-coherence.md` into the same directory as a short human summary. Use **no tables**.\nIn this order:\n\n1. The **verdict**, as the very first line of the file (after the title heading). Nothing else comes\n before it.\n2. **Independent: yes** or **Independent: no**, prominently, on the line directly after the\n verdict, then the **next action**.\n3. The round count, the risk tier, and the round limit. Say which round, if any, was a\n confirmation pass.\n4. Directly after the round count, one line: \"Owner-run coverage: N of M epic ACs depend on\n steps a person runs outside the Epic Implementer.\"\n5. One **bullet per epic AC**: its id, the judgment basis (`verification` or `text only`), the\n status, the owning child or the absence of one, the obligation, and the cited child AC\n evidence. Mark derived ownership as derived. For an owner-run owner, say \"owner-run\" in\n words, with the person or role, the step reference, and where the result is recorded, for\n example: AC-4: covered, owner-run (Release owner, checklist step 5; result recorded in an\n epic comment).\n6. **Blocking findings**, each labelled `blocking` with its `certain` or `uncertain` label.\n Write each hand-off gap as a sentence naming the shared thing, the affected consumer, the\n missing lifecycle end, and the smallest amendment.\n7. **Advisory and input findings.**\n8. **Council state.**\n9. **Overrides**, each with its typed reason.\n\nState every meaning in words, never by color alone.\n\nIn both files:\n\n- Label a report-mode `blocked` or `not_checked` result as **diagnostic and not a clearance**.\n- In report mode, state that the result gates no drafting surface: each drafting surface runs\n its own drafting-mode check before creation.\n- Put `independent: false` at the top, directly after the verdict line, and offer an attended\n fresh-context rerun.\n\n## Writing the records safely\n\n- Render both files to temporary files first. Replace the real files from the temporary files\n where the host supports it. Both files must carry the same run identity (`checked_at` and\n all three final digests), and both describe the same final round.\n- Report a write failure explicitly. A write failure is an **incomplete review**.\n- When a newer attempt fails or is incomplete, **invalidate or remove** any older successful\n artifact in the output directory. Never leave an older `pass` beside a newer failed outcome.\n An incomplete newer attempt must not leave an older clearing record in place.\n\n## Return\n\nReport to the caller:\n\n- the verdict and whether the run was independent;\n- the next action;\n- the paths of `epic-coherence.json` and `epic-coherence.md`;\n- for drafting mode, the halt signal (`do not call create_ticket`) when one applies, and the\n amendments the caller must make before the next round.\n\nDo not describe a `blocked` or `not_checked` report-mode result as a clearance.\n",
|
|
6
|
+
"docs/bridge-ticket-authoring.md": "# Bridge ticket-authoring posture\n\nBridge has several surfaces that can create a ticket, and `/define-tickets` is the\nsingle entry point for creating them. Without a shared posture\neach one behaves differently, and the most-used surface carries none of the\nmaintainer's preferences at all. This document is the deep reference behind the\nshort posture block that every one of those surfaces carries verbatim.\n\nThe block itself is short on purpose — it competes for attention inside prompts\nthat are already long. Everything that explains *why* lives here.\n\n## The canonical block\n\nThis file **is** the canonical source. The marker-delimited block below is\nduplicated byte-identically onto every carrier — every surface that decides\nticket shape holds these exact bytes, so no surface can quietly drift into its\nown house style.\n\nCarriers (all four hold the block verbatim):\n\n- `agents/src/jira-ticket-writer.md` — the writer itself, plus a compressed\n posture line in its `description:` frontmatter, which is the only coverage a\n bare-chat session gets with no file read and no `tools/list` cost.\n- `commands/src/define-tickets.md` — Stage 9, the most-used authoring surface.\n- `mcp_server/instructions/decompose-epic-candidate.md` — the `idea-to-ticket`\n decomposition step.\n- `mcp_server/instructions/decompose-epic.md` — the `plan-epic` decomposition\n step.\n\nEdit the block here, copy it verbatim to each carrier, and let\n`tests/pytest/mcp_server/test_ticket_authoring_posture_assets.py` prove it\nlanded. That test permits **no** per-surface variation.\n\n<!-- BEGIN BRIDGE TICKET-AUTHORING POSTURE -->\n<!-- Canonical source: docs/bridge-ticket-authoring.md.\n This block is duplicated byte-identically onto every carrier. Never edit a\n copy: edit the canonical source and re-copy it verbatim. A cross-surface\n byte-equality test fails the build if any copy drifts by a single byte. -->\n\n## Ticket-authoring posture\n\nDeep reference: `docs/bridge-ticket-authoring.md`.\n\n**Draft through the writer.** Every ticket body — an epic parent, an epic child,\nand an ordinary sibling alike — is drafted by the `jira-ticket-writer` agent\nbefore `create_ticket` is called. Do not compose a ticket description inline.\n\n**Size the work.** Size each ticket by file-touch breadth and depth plus rough\nlines of code (LOC) changed:\n\n- `S = 1-2 files / <~80 LOC`\n- `M = ~3-8 files / ~80-400 LOC`\n- `L = ~8-15 files / ~400-900 LOC`\n- `XL = >15 files / >~900 LOC`\n\nTarget size priority: **L (target) -> XL (when the work does not fit in L) -> M\n(third choice) -> S (only when unavoidable)**. This applies equally to a\nstandalone ticket and to an epic child.\n\nAim each slice at L. When one will not fit, grow it to XL rather than splitting\nit — split only when the slice is genuinely two independent pieces of work,\nnever merely to land inside a band. Bridge's grooming and implementation process\nhandles a large vertical slice well and is overkill on small ones: every extra\nticket is another worktree, another PR, another rebase, and another chance for\ntwo workers to touch the same file. Reach for M because the work genuinely is\nthat size, not to avoid an XL.\n\nBeyond roughly 40 files or ~3000 LOC, split anyway. Past that point review\nturnaround and rebase cost dominate the run's budget, and a review that wedges\nholds the gate to its full retry ceiling before anyone notices.\n\n**Group at three.** Three or more implementable tickets is an epic: propose an\nepic parent plus an ordered child manifest, and resolve this surface's own\napproval gate before anything is created. One or two tickets are ordinary\nsiblings — no epic parent, no manifest. The threshold is exactly three.\n\n**Hand off once.** An epic handoff names exactly one conductor entry point,\n`drive-epic`, which selects the runnable path itself. Never present a choice\nbetween conductors.\n\n**Planted placeholders hand over.** A ticket that plants a placeholder test or\nstub for a later ticket says so, and the later ticket's body gives explicit\npermission to replace that placeholder. A rule such as \"never edit existing\nassertions\" never covers a planted placeholder.\n\n**Departure is closed-list only.** These three exceptions, and no others, permit\ndeparting from the rules above. Invoking one requires no announcement.\n\n- **E1 External-tracker mirroring** — a recorded upstream identifier exists and\n its granularity is contractual. Bypasses sizing and the epic threshold.\n- **E2 Discovery-only spike** — no committed production-code deliverable.\n Bypasses sizing only; does not bypass drafting through the writer.\n- **E3 Authorized incident containment** — tied to an active incident record,\n not to schedule pressure. Bypasses sizing and the epic threshold.\n\nThe list is closed. Anything outside it is an escalation to the operator, not a\njudgement call. Explicitly refused as grounds for departure: a single-file\ntrivial fix (that is `S` reached through the normal path, not an exception),\ngeneric time pressure, \"already well specified\", \"faster without the writer\",\ndeveloper discretion, minor refactor, unattended mode, context limits, and \"hard\nto decompose\" (XL is the normal overflow, so that is the ordinary path and not a\ndeparture). Writer unavailability escalates; it never silently authorizes inline\ndrafting.\n\n<!-- END BRIDGE TICKET-AUTHORING POSTURE -->\n\n## Open-decision phrases\n\nA ticket body states settled facts. An unsettled choice that is needed to define\nor authorize the work belongs in the writer's reply, in the terminal\n`open-questions` block, and never in the ticket body. A validated `open-questions`\nblock is the authority. The phrase list below is only a backstop: it flags body\ntext that still reads like a request to settle a decision.\n\n<!-- BEGIN OPEN-DECISION PHRASES -->\n- must settle\n- settle this before\n- before planning\n- the caller must\n- owner confirms\n- owner must confirm\n- confirm with the owner\n- stop if not met\n- check the precondition first\n- TBD\n- to be decided\n<!-- END OPEN-DECISION PHRASES -->\n\nMatching semantics (warning only):\n\n- Match case-insensitively, as whole phrases with word boundaries.\n- Before scanning, drop fenced code blocks and `{noformat}` regions.\n- Report one warning per matching line, not one per phrase. Quote from the start\n of the sentence that holds the line's first match through the end of the line.\n- A phrase match is an advisory signal for a person to review. It never halts\n drafting, never hides an upload gate, and never refuses a launch.\n- Keep the full list out of routine reports. Report only the matching lines.\n\nCarriers (`commands/src/define-tickets.md`, `commands/src/draft-ticket.md`,\n`.claude/commands/write-ticket.md`, `mcp_server/instructions/draft-and-critique.md`,\nand `mcp_server/instructions/render-ticket-manifest.md`) quote the marked list and\nthese semantics exactly. `tests/pytest/static/test_open_decision_phrases_parity.py`\nproves they match.\n\nThe rest of this document is the rationale the block is deliberately too short to\ncarry.\n\n## Decision: Jira ticket authoring ships through the Jira Ticket Writer (BAPI-900)\n\nBridge ships two very different kinds of ticket-authoring surface, and customers\nneed to know which one they actually have.\n\n**Shipped customer surface.** A customer project gets the `jira-ticket-writer`\nagent — the same writer this posture requires every ticket body to go through —\nplus the agent-directed capability to revise an existing ticket's description.\nAsk your agent to draft a ticket with the Jira Ticket Writer, and ask your agent\nto update an existing ticket's description when it needs revising. Both reach a\ncustomer project because they are packaged: the writer through `AGENTS`\n(`mcp_server/src/agents.generated.ts`) and the description-update path through\nthe registered `update_ticket_description` / `request_ticket_update` MCP tools.\n\n**Repository-local workflows.** `.claude/commands/write-ticket.md` and\n`.claude/commands/update-ticket.md` are bridge-api's own repository-maintenance\ncommands. They are **not** scaffolded into a customer project by `--init`, have\nno `commands/src/` source, and have no generated Cursor or `mcp_server/`\nmirror — deliberately, not by omission. A customer asking their agent to run\nthe write-ticket or update-ticket slash command will not find either one,\nbecause neither ships.\n\n**Why (Option B, not a promotion to shipped status).** The Jira Ticket Writer is\nalready the packaged drafting surface this posture mandates, so shipping\n`write-ticket.md` as a second drafting entry point would duplicate it. More\nimportantly, `write-ticket.md` is today an autonomous, single-ticket, no-halt\npipeline (\"No human confirmation gates — run end-to-end\") with no decomposition\nstep and no approval gate — it cannot honor the \"group at three\" epic rule or\nthe epic approval gate this posture requires, because it was never built to\npropose an epic at all. Promoting it to a shipped surface without that redesign\nwould ship a customer-facing command that silently violates this file's own\nposture. Until that redesign happens, `write-ticket.md` and `update-ticket.md`\nstay repository-local, and every packaged surface directs customers to the Jira\nTicket Writer and to agent-directed description updates instead.\n\n\n## The four rules\n\n### 1. Draft through `jira-ticket-writer`\n\nEvery ticket body is drafted by the `jira-ticket-writer` agent before\n`create_ticket` is called — an epic parent, an epic child, and an ordinary\nsibling alike. Nothing composes a ticket description inline.\n\nThe writer is not a formatter. It runs a codebase-research pass first, so its\ntickets cite the files, functions, and extension points a change actually\ntouches. A description written inline skips that pass, and the difference shows\nup two steps later: plan generation and implementation both ground themselves in\nthe ticket body, so a body with no code references produces a plan with no code\nreferences.\n\n\"The ticket is already well specified\" is not a reason to skip the writer. A\nwell-specified *request* is the writer's input, not a substitute for its output.\n\n### 2. Size toward L\n\nSize each ticket by file-touch breadth and depth plus rough lines of code\nchanged:\n\n| Band | Files | LOC |\n| --- | --- | --- |\n| `S` | 1–2 | `<~80` |\n| `M` | ~3–8 | ~80–400 |\n| `L` | ~8–15 | ~400–900 |\n| `XL` | >15 | `>~900` |\n\nPriority: **L (target) → XL (when the work does not fit in L) → M (third choice)\n→ S (only when unavoidable)**.\n\nThe target is L because the Bridge implementation tooling works best on\nindependently implementable vertical slices. What matters as much as the target\nis the **direction you move when a slice misses it**: upward, not downward.\n\nA slice that will not fit in L becomes **one XL ticket**, not two L ones. Split\nonly when the slice is genuinely two independent pieces of work — never merely to\nland inside a band. Fragmenting a coherent slice to fit is the failure this\nladder exists to prevent: every extra ticket is another worktree, another PR,\nanother rebase, and another chance for two workers to touch the same file, and\nBridge's grooming process is overkill on small tickets. Fewer, larger slices\nspend less of the run's budget on coordination.\n\nThis applies equally to a standalone ticket and to an epic child. There is no\nsize ceiling on a child that a lone ticket does not also have.\n\n`M` is where you land when the work genuinely is three to eight files — not\nsomewhere to retreat to in order to avoid an XL. `S` is likewise not forbidden:\nit is simply what you reach when the work genuinely is one or two files. A\nsingle-file trivial fix is `S` arrived at through the normal path. It is not an\nexception to anything, and it does not license skipping the writer.\n\n**Beyond roughly 40 files or ~3000 LOC, split anyway.** XL is the preferred\noverflow, not an unbounded one. Past that point review turnaround and rebase cost\ndominate the run's budget, and a review that wedges holds the gate to its full\nretry ceiling before anyone notices. That is a real bound, not a preference — and\nit is high enough that reaching it means the work really is two things.\n\n### 3. Group at three\n\nThree or more implementable tickets is an epic. The surface proposes an epic\nparent plus an **ordered child manifest**, and resolves its own approval gate\nbefore anything is created.\n\nOne or two tickets are ordinary siblings: no epic parent, no manifest. The\nthreshold is exactly three — not \"several\", not \"a lot\".\n\nThe manifest carries, per child: the boundary of its scope, its size band,\n`depends_on` (hard prerequisites that must land first), `recommended_after` (soft\nsequencing preferences that are not blockers), and a one-line order rationale.\nHard prerequisites and soft sequencing stay strictly separate, because the\nrecommended implementation order is derived from them and conflating the two\nproduces a serialized order where a parallel one was available.\n\n**The epic body carries the manifest in one fixed shape.** The epic parent holds a\nsingle `## Ordered child manifest` section. Each child is one compact line, with\ncomma-separated hard prerequisites and an explicit `depends_on: none` for a child\nwith none:\n\n```markdown\n## Ordered child manifest\n\n- BAPI-101 depends_on: none\n- BAPI-102 depends_on: BAPI-101\n- BAPI-103 depends_on: BAPI-101, BAPI-102\n```\n\nUntil every child exists, the section holds one fixed pending line,\n`- pending: child keys are written here after the children are created.`\n`/define-tickets` replaces it only after every child exists, using real child keys\nand never a placeholder. Updates are built from the Markdown the command retained\nlocally; text fetched from Jira is read-only. If the write is unavailable, the\ncommand warns in its Final Report and the handoff continues. The pending line is\nintentionally unreadable as a manifest, so the plan falls back to ascending\nticket-key order.\n\nApproval follows each surface's **existing** attended/unattended rule. Nothing\nhere introduces a new gate policy: `/define-tickets` requires an explicit\naffirmative because creation is irreversible, and the recipe path gates on the\npipeline's own auto-approval variable. What is *not* conditional is the grouping\nitself — an unattended run still produces the epic; only the gate's behavior\nvaries.\n\nDecomposition happens **once**. The pass that decides the split freezes the\nmanifest; body rendering then fans out one writer invocation per entry against\nthat frozen manifest. A rendering invocation may not re-split, merge, reorder,\nrenumber, or rescope. Two independent decisions about the same split disagree,\nand the disagreement surfaces as children that overlap or contradict their\nparent.\n\n### 4. Hand off to exactly one conductor\n\nAn epic handoff names exactly one conductor entry point: `drive-epic`.\n\nBridge currently has two conductors — the v2 server-side engine and the LLM\nconductor pilot — and a standing rule that they must never operate on the same\nepic, because two transition authorities on one epic wedge it permanently. Asking\na model to pick correctly every time is not a control. `drive-epic` makes the\nchoice structural instead: it reads conductor readiness and routes to the one\npath the project can actually run, so no prompt names either underlying conductor\nand no prompt can present both.\n\nTwo conductors is a transitional state. When one is eliminated, `drive-epic` is\nthe only thing that changes — no prompt, bundled doc, command mirror, or posture\ntest moves.\n\n## Epic coherence check before creation\n\nBefore an epic's tickets are created or its plan approved, its children are\nchecked **as a set** against the epic's own acceptance criteria. The check asks\nwhether every epic criterion has a child that carries out its verification, and\nwhether each cross-child hand-off is owned at both ends. It runs through one\nshared procedure, [`review-epic-coherence.md`](../mcp_server/instructions/review-epic-coherence.md),\nwhich writes `epic-coherence.json` (the record) and `epic-coherence.md` (a short\nsummary) beside the frozen manifest.\n\n**Where it runs.** Four call sites run the check:\n\n- `/define-tickets` Stage 9 (attended) — after the epic split is frozen, before\n drafting and the upload gate.\n- `/define-tickets --auto` Stage 9 (unattended) — after the split is frozen and\n capped by `--max-children`, before any writer runs. It has no upload gate: an\n independently cleared record is what allows creation.\n- `idea-to-ticket` (the still-bundled legacy recipe) — in the Epic path of\n `upload-and-track.md`, after `decomposition-plan.json` and before rendering and\n the external approval gate. `/idea-to-pr` no longer runs it: it reaches the\n coherence check through `/define-tickets` Stage 9 under `--auto`.\n- `plan-epic` — in `decompose-epic.md`, after the plan artifacts are written and\n before the decomposition is presented for approval.\n\nEvery decomposition pass fills in each child's `owns_verifications`: which epic\ncriterion it proves, and the concrete part of that criterion's verification it\ncarries out. When a criterion is proven by an owner-run step a person runs\noutside the conductor — a release-checklist step, say — the pass declares a\n`non_child_owners` entry naming who runs it, the step, its verbatim text, and\nwhere the result is recorded, instead of forcing a child to own it. Owner-run\nowners count toward coverage only; hand-offs stay child-owned.\n\nWhen one child adds a value or placeholder test that another child reads or changes, state the shape the consumer needs. An epic-wide \"existing assertions stay unchanged\" criterion never covers a placeholder assertion added by an earlier child; the child retiring the placeholder owns its wind-down.\n\n**The render preflight.** `render-ticket-manifest.md` refuses to render an epic\nunless the record exists beside the manifest, all three of its digests\n(`manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`) match\nwhat is being rendered, those digests equal the last reviewer round's, and\nits verdict is `pass`, `accepted_with_gaps`, or `not_checked` with a recorded\nbypass. A missing record, a mismatch, `blocked`, or an un-bypassed `not_checked`\nstops the flow before any writer runs or any ticket is created. `/define-tickets`\nstates the same rule in its own creation step.\n\n**Attended runs: fix or accept, at one gate.** The gate comes after the drafts\nexist. Each remaining blocking finding is either fixed — the manifest is amended, re-frozen, and checked again — or\naccepted with a non-empty reason, which is recorded and turns the verdict into\n`accepted_with_gaps`. The fix budget is bounded: after the first confirmation\npass, the operator may direct one fix and one further whole-manifest\nconfirmation pass, counted across re-runs in the same attended `/define-tickets`\nrun. After that, a blocker is accepted or stays `blocked`.\n\n`/define-tickets` runs its optional checks in a fixed order: design and split,\nincluding any after-design review; the gap check, when the drafting plan calls\nfor it and the work is an epic; one writer draft per ticket, all started at once\nwhere the host can run them in parallel; then one upload gate. The gap check\nnever runs after drafting. Before the writers start, an attended run checks the\nrecord more narrowly than full clearance: the only items it may leave uncleared\nare foundation gaps listed under `Known gaps that will be recorded on the epic`.\nEach is a pending acceptance, held in working state with its finding, its\nagent-drafted reason, and its round. Nothing is saved as an operator acceptance\nbefore approval, and the full clearance rule still applies before the first\nticket is created.\n\nThe upload gate shows, in plain words, the gap-check result, who covers each\nrequirement, the plan outline, the chosen drafting-plan policies, any review\nfailure, the known gaps with their pending acceptances, and the path of every\ncompleted draft. The closing question is\n`Upload these N drafts to Jira? (yes / change something)`, or its singular form.\n\nUpload is authorized by clear intent, not by an exact word. A clear \"yes\" or\n\"go ahead\" authorizes uploading the displayed drafts and records exactly the\ndisplayed pending acceptances. It never changes the split and never spends the\nfix budget. Every unresolved gap keeps creation blocked. Empty, negative,\nambiguous, and mixed replies upload nothing; if the operator declines, the\nexploration document and the drafts directory are the artifacts. Changing an\nitem, a target, a recommendation, or a reason means the affected drafts are\nredone and the gate is shown again. A changed requirement or goal goes back\nthrough requirements and the drafting plan instead.\n\n**Implications, then the drafting plan.** After requirements are ratified,\n`/define-tickets` Stage 6 shows the implications review and the recommended\ndrafting plan together in one output-only message, on the full and short paths\nalike, and then continues without waiting (BAPI-1768). If the review is\nunavailable, the message says so at the top. The plan recommends a council\nbefore the design, a review after the design (a council, or a second opinion for one or two separate\nquestions), or no council, and it records the gap-check policy for a possible\nepic. A paid review in the plan runs because the message states it with its\ncredits first. Choosing a council option also covers the later review of how an epic's\ntickets are split, so that decision is not asked again. Unattended runs take the recommended option\nand keep the epic gap check required. The attended flow has two ordinary stops\non both paths: the requirements page and the upload gate. A per-repository\nsetting, `define_tickets_plan_stop`, will restore one combined implications-and-plan\nstop when set to `ask`; until that setting is read, every run is automatic.\nEvery decision the agent makes after ratification is recorded in the exploration\ndocument's `## Decisions made for you` section and shown at the upload gate,\nwhere the owner can reverse it before anything is created. See\n[the short-path decision record](BAPI-1660-define-tickets-short-path.md) and\n[the BAPI-1768 record](BAPI-1768-define-tickets-leaner-command.md).\nThe initial high-risk coherence council is offered\nby the shared procedure itself, in an attended run, after the epic is classified\nhigh risk and before round 1, with its cost and a recommendation. Declining it\nis final: the record stores `council_outcome: \"declined_by_operator\"`, shows\n`Council: skipped, your choice`, and needs no `accept` override. A legacy\noverride that targets `council: \"declined_by_operator\"` stays valid and is\nignored for clearance. Declining a council offered for an uncertain or disputed\nfinding is also final for that council decision, but the finding stays blocking\nuntil it is amended or accepted. An unfinished required council still needs an\nattended acceptance that names its `council_id`.\n\n**What counts as high risk.** Six or more children, or one child editing\n`db/alembic/`, `db/migrations/`, `api/library/billing/`,\n`api/routes/setup/auth.py`, or `api/library/auth/`. A child editing\n`api/library/db/` or another executor-containment path is high risk only when at\nleast two distinct children edit such paths; the procedure's case table is the\nsingle statement of this rule. Reads never count. A lone such child still gets\nthe low-risk reviewer rounds, is promoted to high risk if a blocking finding is\nuncertain, and reaches the upload gate with any remaining blockers.\n\nWhen the reviewer cannot run, the verdict is `not_checked`. The operator can\nretry, or bypass with a typed reason. A bypass is recorded, and the verdict stays\n`not_checked`; it is never shown as a pass.\n\n**Unattended runs: the risk-scaled round limit, then halt.** An unattended\n`idea-to-ticket` run or `/define-tickets --auto` run amends and re-checks within maximum ordinary rounds: two for a low-risk epic and three for a high-risk\none, ending early when a round has zero foundation blockers. If a foundation blocking finding remains, it halts with `blocked` before any ticket is\ncreated. A fix made after the last round gets one confirmation pass. An unavailable reviewer, or a check\nthat could not run independently, halts with `not_checked`.\n\nUnattended runs have no bypass; an operator who needs one reruns attended.\n`/define-tickets --auto` follows the same rule.\n\n**Siblings skip it.** A one- or two-ticket outcome runs no check, writes no\nrecord, and costs nothing extra. The residual risk — a pair that really needed a\nset-level check — is contained by the existing manifest-identity and\nwriter-draft gates. If the work is really epic-shaped, regroup it as an epic\nbefore creation. `plan-epic` is the one exception: the epic already exists, so it\nchecks even a one- or two-sub-task decomposition.\n\n**What lands in the tickets.** Each epic child carries its obligations verbatim\nas acceptance criteria. The epic parent carries a `## Epic coverage map`\nsection: the verdict, one bullet per epic criterion naming its owning child and\nobligation, and any accepted findings or bypasses with their reasons.\n\n## The closed exception list\n\nExactly three exceptions permit departing from the rules above. Invoking one\nrequires **no announcement** — the departure is silent by design, because a\nmandatory announcement would be one more instruction to drift from, and the cost\nof silence was weighed and accepted.\n\n| Id | Exception | Objective trigger | Bypasses |\n| --- | --- | --- | --- |\n| **E1** | External-tracker mirroring | A recorded upstream identifier exists and its granularity is contractual | Sizing and the epic threshold |\n| **E2** | Discovery-only spike | No committed production-code deliverable | Sizing only — **not** drafting through the writer |\n| **E3** | Authorized incident containment | Tied to an active incident record, not to schedule pressure | Sizing and the epic threshold |\n\nEach trigger is objective: an identifier that exists, a deliverable that is\nabsent, an incident record that is open. None of them is a judgement about how\nthe work feels.\n\n### The list is closed\n\nAnything outside the three rows above is an **escalation to the operator**, not a\njudgement call. The following are explicitly refused as grounds for departure:\n\n- a single-file trivial fix — that is `S` reached through the normal path;\n- generic time pressure;\n- \"the request is already well specified\";\n- \"it would be faster without the writer\";\n- developer discretion;\n- \"it's just a minor refactor\";\n- running unattended;\n- context limits;\n- \"this is hard to decompose\" — XL is the normal overflow, so that is the\n ordinary path and not a departure.\n\n**Writer unavailability escalates.** It never silently authorizes inline\ndrafting. A surface that cannot reach `jira-ticket-writer` stops and says so.\n\n## The spike ticket format (BAPI-986)\n\nA spike ticket defines a finding to be produced, not code to be written, so it\ngets its own body shape. This is a second **format**, not a fourth exception:\nthe writer still drafts it, the sizing ladder still applies, and E2 still governs\nwhether the posture's sizing rule is bypassed at all.\n\n### Who chooses, and on what\n\nThe run manifest's `scope` chooses, and it is resolved once, upstream, in\n`mcp_server/instructions/preflight-and-readiness.md`. The writer receives that\nvalue and never decides it. Only `scope: spike` selects the spike format.\n\nThe trigger is E2's exact objective condition — **no committed production-code\ndeliverable**. A deliverable that is absent, not a judgement about how the work\nfeels. Every other case produces the ordinary code-ticket format:\n\n- `scope: task` and `scope: epic_candidate`;\n- a missing scope value;\n- a malformed or unrecognized scope value;\n- a standalone writer invocation with no resolved spike scope;\n- any ambiguity.\n\nCode is the default **in code, not in prose**: it is what every unresolved path\nalready produces, so no one has to remember a rule to get it.\n\n### The five body sections\n\nA spike draft's substantive body is exactly these five, in order:\n\n1. `## Question` — the single question the investigation must answer.\n2. `## Scope` — the systems, code paths, data, and behavior in bounds.\n3. `## Out-of-scope` — what it will not examine, stated explicitly.\n4. `## What the findings must answer (the deliverable)` — names an inspectable\n findings artifact at a specific repository path, and states what that artifact\n must contain: the decisions it settles, the evidence it cites, the\n recommendations it makes, and the unresolved risks it records. This is the\n spike's analogue of Acceptance Criteria — a reviewer holds the finished\n artifact against it to tell whether the spike is done.\n5. `## Which related tickets consume the finding` — names real consumer tickets\n by key, or the literal `none yet`. Never an invented key.\n\nThose five are the spike-specific **body** sections. They are not the whole\ndraft. The following remain mandatory structural metadata, identical to a code\ndraft, and are not additional spike sections:\n\n- the `# [Title]` heading;\n- the execution-class marker line (below);\n- a `## Regression Completeness Notes` block when the gated regression pass\n applies;\n- the trailing `## Materials & Access` section, always last.\n\nThe code-ticket structure — Summary, Requirements, Acceptance Criteria,\nMaterials & Access — is unchanged, and a code draft carries no execution-class\nmarker.\n\n### The execution-class marker\n\nA spike draft carries exactly one canonical marker line, alone on its own line,\nimmediately after the title and before `## Question`:\n\n```markdown\n# [Concise Title Describing the Investigation]\n<!-- bridge:execution-class=investigation -->\n\n## Question\n```\n\nIt appears **exactly once**, never in a code-format ticket, and never\nillustratively inside a generated ticket body — not in prose, not in a fence,\nnot in backticks. Duplicates do not reinforce it: a second occurrence makes the\ndescription ambiguous and the parser discards the whole thing, leaving no signal.\n\n**It renders as visible text.** Bridge converts the description from Markdown to\nAtlassian Document Format, and ADF has no comment node, so the marker becomes one\nvisible line in the Jira description rather than a hidden comment. The exact\ntoken survives conversion and stays parseable from the stored description, which\nis what it is for. The placement immediately after the title is therefore an\neditorial choice as much as a parsing one.\n\n**It is a weak hint.** One non-authoritative input alongside the existing weak\nJira issue-type signal. It never overrides the five-way ticket-type\nclassification and never bypasses a human gate. A classifier verdict that\ncontradicts it wins, and the disagreement is reported rather than reconciled.\n\nThe marker's shape lives in exactly one runtime place —\n`parse_execution_class_marker` in\n`src/python/llms/agents/planner_agent/ticket_evaluator/execution_class_marker_utils.py`,\nwhich imports the `code`/`investigation` vocabulary from BAPI-980's constants in\n`api/models/epic_run.py` rather than redeclaring it. The literal in this document\nand in `agents/src/jira-ticket-writer.md` is pinned against that runtime constant\nby test, because Markdown cannot import a Python value.\n\n### The marker survives to the ticket record\n\nThe single-ticket path creates the Jira issue from `slim_description`; the full\ndraft is only an attachment. A marker preserved solely in the attachment would\nleave the ticket record with no signal at all. Two rules close that:\n\n- `mcp_server/instructions/draft-and-critique.md` carries the title and marker\n into `slim_description` in their original order, exactly once, and exempts that\n one literal from the forbidden-raw-HTML hygiene rule that would otherwise strip\n it. A `task` draft has no exemption, and slimming must not synthesize a marker.\n- `mcp_server/instructions/upload-and-track.md` passes `slim_description`\n unchanged as `create_ticket`'s `description`, without stripping, reconstructing,\n relocating, duplicating, or validating the marker.\n\n`create_ticket` gains no execution-class parameter and the MCP tool schema is\nunchanged: the marker rides in `description` and nowhere else.\n\n### Post-creation marker loss is out of scope\n\nA later description rewrite can drop the marker. `ticket_store_lib.update_ticket`\nforwards a full replacement description and the Jira backend re-renders all of it\nthrough `render_adf`, so anything a rewrite omits is simply gone — there is no\nmerge. Preserving the marker across rewrites would mean auditing every\ndescription-rewriting surface, which is excluded here.\n\nThis is a named, owned gap rather than an unstated one: preservation belongs to\nthe downstream slice that enables investigation routing. No local design record\nnames that slice yet, so its ownership is recorded here as an unresolved\ndownstream discovery rather than assigned to an invented slice name.\n\n## The plan-route marker\n\nA code-format ticket whose requested changes are entirely test code or test\ntooling may declare its plan route with one marker line:\n\n```markdown\n<!-- bridge:plan-route=test -->\n```\n\nThe runtime owner of the literal is `plan_route_marker_utils.py` in\n`src/python/llms/agents/planner_agent/ticket_evaluator/`\n(`PLAN_ROUTE_MARKER_TEMPLATE`); the writer copies it, never redefines it.\n\n### Writer rules\n\n- **Scope.** Stamp it only when all requested work is test code or test tooling:\n tests, flaky-test fixes, fixtures, fakes, harnesses, test configuration,\n runners, development/test dependencies, test-running CI workflows, and\n documentation about those tests.\n- **Placement.** Exactly once, alone, immediately after the title line.\n Otherwise stamp nothing and let the classifier decide.\n- **Test only.** The writer never authors an `implementation` or `bug`\n declaration, and never puts a plan-route declaration on a spike draft.\n- **Never illustratively.** The marker does not appear anywhere else in a\n generated ticket body.\n\n### Parser validity is broader than writer placement\n\nThe parser accepts one canonical literal alone on an unfenced, unindented line\nanywhere in the body. A malformed, inline, indented, fenced, or duplicated\noccurrence is no declaration.\n\n### Consequences\n\nJira renders the marker as one visible line. Unlike the weak-hint\nexecution-class marker, a valid plan-route declaration **binds** plan routing.\nMisused on production-code work, planning fails visibly, and ticket review\nrecommends a split or removal of the declaration (the critic's\n`Split recommended (unrelated test changes):` finding). The marker and the\nspike-only execution-class marker are the two limited exceptions to the\nno-raw-HTML and `{placeholder}` output rules.\n\n## Residual risks and their operational contracts\n\nFour limitations ship with the spike format. Each is stated as detection,\ncontainment, and escalation, because a residual-risk note without those three\nreads as coverage while providing none.\n\n### Incorrect E1/E2/E3 invocation\n\n- **Detection**: manual ticket review only. There is no log, counter, or report\n (see the accepted trade-off below).\n- **Containment**: the objective selection rule — any ambiguity produces a code\n ticket — plus the marker's non-authority over classification and every human\n gate.\n- **Escalation**: suspected misuse goes to the authoring-workflow owner.\n\n### Class observability does not cover departure invocation\n\nThe marker makes a spike's intended execution **class** observable. It does not\nmake E1/E2/E3 posture-departure **invocation** observable; that remains silent by\naccepted design, and the accepted trade-off below is unchanged by this slice.\n\n- **Detection**: none for invocation, by design. Ticket review is the only signal.\n- **Containment**: the closed exception list itself — anything outside those\n three rows is an escalation, not a judgement call.\n- **Escalation**: the authoring-workflow owner, as above.\n\n### Premature routing on the marker\n\nMarker-bearing tickets exist before any consumer does. Nothing routes on the\nmarker yet, and the guard for that is **structural, not a feature flag** — no\nsuch flag exists, and naming an imaginary control would be exactly the failure\nthe accepted trade-off below warns about.\n\n- **Detection**: the absence of any marker reader outside the parse/normalize\n helper and the disagreement observer. A static test pins that set, so the first\n premature consumer fails at review time.\n- **Containment**: BAPI-980 seeds every run node `execution_class = 'code'` and\n exposes no caller-controlled `investigation` override anywhere — not on the DAL\n seed signature, not on a Pydantic request model, not on an MCP input. No code\n path writes `investigation`.\n- **Escalation**: any proposal to consume the field in runtime conductor behavior\n goes to the Conductor owner before implementation, per BAPI-980's decision D10;\n any discovered marker-based routing is a release-blocking regression on that\n same path. Enabling investigation routing belongs to the downstream epic\n rollout owner, once the complete path and its human gate exist.\n\n### Marker/classifier disagreement\n\n- **Detection**: the reserved structured-log event\n `ticket_classification_event=execution_class_marker_disagreement`, emitted at\n warning level when an investigation marker meets a code-facing classifier\n verdict. Every `evaluate_ticket_type` entry point compares, so the signal\n covers the ordinary Bridge classification path and not only the estimator\n backfill; a cached verdict is not a classification and is not compared.\n Persistent or high-volume disagreement is surfaced by querying that reserved\n key through the existing logging/Sentry workflow.\n- **Containment**: the comparison is non-authoritative. The classifier verdict is\n persisted and returned exactly as produced, whether or not an event fires.\n- **Escalation**: the event is **diagnostic-only** and the Bridge platform team\n owns it operationally. No alert rule, threshold, or paging behavior ships with\n it; that is net-new work belonging to the slice that enables routing. The field\n and redaction contract lives in\n `docs/claude/jira-optional-ticket-storage.md`, not here.\n\n## Isolation binding for shared-state test support\n\nA ticket that builds or changes test support which resets shared state — a\nharness, a fixture, a reset helper, anything that truncates, drops, or\nreinitializes state another process or another run can also read or write —\nmust state its isolation binding as a requirement: which database, directory,\nor other shared resource the reset targets, and how the ticket's own\ndeliverable proves that target's identity before it destroys anything.\n\nThis doctrine exists because BAPI-1006 shipped a conductor integration-test\nharness with nothing in its ticket stating what the harness's destructive\nreset was bound to, and a v2 worker dispatched to build it truncated the\noperator's operational `bridgeapi` database (Architecture Miss 28). The\ncontainment-hazard classifier this repository runs at planning time\n(`api/library/github/workflow_planning_prediction.py`) can flag such a ticket\nfrom its text, but the flag is advisory — it surfaces the hazard before\ndispatch, it does not prevent a destructive worker on its own. Stating the\nisolation binding in the ticket itself is the durable requirement; treat this\nas an authoring-posture rule, not as runtime enforcement.\n\n## Accepted trade-off: silent departure is unobservable\n\nObservability was deliberately dropped when this posture was ratified. A model\nmay invoke E1, E2, or E3 without recording that it did, so posture drift is only\ndetectable through ticket quality — not through a log, a counter, or a report.\n\nThis is known and accepted. The alternative was another mandatory instruction on\nevery surface, and an instruction that is skipped silently is worse than one that\ndoes not exist: it reads as coverage while providing none.\n\n## Why duplication, not a shared include\n\nCommands, agents, instructions, and docs have four separate build paths in this\nrepository and no shared compiler. Introducing a generated include step to share\none block would mean a fifth build path, a placeholder that can go unresolved,\nand a failure mode where a carrier ships with the placeholder text still in it.\n\nMarker-delimited duplication plus one byte-equality test is the right mechanism\nat this scale. The test reads the canonical sources directly — never the\ngenerated command mirrors, whose byte-identity the command tests already cover —\nand permits **no** per-surface variation. Any drift, down to a single byte, fails.\n\n## A fresh install inherits this\n\nNo configuration step, no server call. The posture reaches a new project through\nthe packaged bundles that `--init` scaffolds:\n\n- `COMMANDS` (`mcp_server/src/commands.generated.ts`) — carries\n `commands/src/define-tickets.md`;\n- `AGENTS` (`mcp_server/src/agents.generated.ts`) — carries\n `agents/src/jira-ticket-writer.md`, including the compressed posture line in\n its `description:` frontmatter;\n- `INSTRUCTIONS` (`mcp_server/src/pipelines.generated.ts`) — carries the\n canonical source and both decomposition instructions;\n- `DOCS` (`mcp_server/src/docs.generated.ts`) — carries this document.\n\nThe compressed frontmatter line matters more than its size suggests: agent\ndescriptions land in every session's system prompt with no file read and no\n`tools/list` cost, so it is the entire bare-chat coverage story.\n\n## Worked examples\n\n**One ticket.** \"Add a `--json` flag to `doctor`.\" Two files and a test, ~90 LOC.\nThat is `M`. One ticket, drafted by the writer, no epic, no manifest, no\nconductor handoff.\n\n**Two tickets.** \"Add rate limiting to the LLM client, and surface the limit in\nthe config UI.\" Backend and frontend are independently implementable and land\nseparately: two ordinary siblings. Still no epic — the threshold is three.\n\n**Four tickets → an epic.** \"Make local ticket mode a first-class system.\"\nDecomposition freezes a parent plus four children, each `L`, with `depends_on`\nnaming the one child that must land first. The full manifest goes to the approval\ngate; on approval, four writer invocations render four bodies against their\nfrozen entries; creation follows `upload-epic-hierarchy.md`; the handoff names\n`drive-epic` and nothing else.\n\n**A child that outgrows `L`.** A proposed child comes out at 19 files. It ships\nas one `XL` child. Do not split it into two `L` children to make it fit — the\nslice is one coherent piece of work, and halving it buys a second worktree, a\nsecond PR, and a rebase between them in exchange for nothing. Split only if the\n19 files really are two independent deliverables.\n\n**Past the ceiling.** A proposed ticket comes out at 60 files and ~5000 LOC.\nThat is over the bound, so it splits — but into the largest coherent pieces\navailable, not into a swarm. Two `XL` tickets is the right answer here; six `M`\nones is not.\n",
|
|
7
|
+
".bridge/procedures/review-epic-coherence-procedure.md": "# Review Epic Coherence\n\nThis is the shared procedure for checking an epic's children **as a set**. It answers two\nquestions no per-ticket review asks: does every epic acceptance criterion have a child that\ncarries out its verification, and is everything one child produces wired to whatever consumes\nit? Drafting surfaces and the on-demand `/review-epic-coherence` command run this same text.\n\nThe check fails **visibly**. A run that cannot finish is `not_checked`. It is never `pass`.\n\n**Enforcement status.** The three drafting surfaces — `define-tickets`, `plan-epic`, and\n`idea-to-ticket` — call this procedure in drafting mode before creation or approval, and\n`render-ticket-manifest.md` refuses to render an epic without a clearing record. A\nreport-mode result from the on-demand command is a diagnostic, not a gate: it clears nothing.\n\n## What the user sees\n\nEverything this procedure says to a person in attended chat, progress messages, and screens\nuses the plain words in this table, never the internal term. Callers that show a result to a\nperson use the same words.\n\n| Internal concept | User-facing wording |\n|---|---|\n| coherence check | gap check |\n| coverage | a requirement no ticket owns |\n| handoff | a broken hand-off between tickets |\n| fit | a plan that doesn't match the code |\n| e2e_proof | no end-to-end test |\n| `pass` | No gaps found |\n| `accepted_with_gaps` | Accepted with known gaps |\n| `blocked` | Needs your decision |\n| `not_checked` | Couldn't check |\n| foundation blocker | a gap in how the work is split |\n| ticket-local carried finding | a note added to ticket N |\n| `independent: false` | this check ran in my own session, not by a separate reviewer, so it's less independent |\n| coverage map | Who covers each requirement |\n| accept override | Create anyway, and record the gap on the epic |\n| fix | Change how the tickets are split |\n| assign | Give this requirement to ticket N |\n| needs-owner item | Needs your answer: name a ticket, or remove it from scope |\n| `covered_by_design_council` | Council: already covered by the design council |\n\n- **Qualified pass.** In drafting mode, a passing record that carries ticket-local findings is\n shown as `No gaps found (N notes added to tickets)`.\n- **Report mode.** A ticket-local finding is described prospectively, as `a note that would be\n added to ticket N`, and the report says the check changed no ticket.\n- **Scope of the vocabulary.** It covers attended chat, progress messages, and screens only.\n `epic-coherence.md`, the JSON fields and verdict values in `epic-coherence.json`, the agent\n name, and the parent ticket's `## Epic coverage map` section keep their technical wording.\n- Write new passages with words such as `ticket N` and angle-bracket paths. Do not add any\n new brace-wrapped identifier token.\n\n## Inputs\n\nState these four values before starting:\n\n1. **Input document path** — the path to `epic-coherence-input.json`.\n2. **Output directory** — a directory beneath the `docs_dir` that the `ping` tool returned.\n3. **Mode** — `drafting` or `report`.\n4. **Unattended** — true only when `auto_approve_external == \"true\"`. Otherwise the run is\n attended.\n\nIf any of the four is missing, stop and report which one. Do not guess a default.\n\nAn optional fifth input, **`council_preapproval`**, carries a `value` (`approved` or\n`declined`) and its `source`. It records a council decision the caller already got from the\noperator, so the procedure asks no council question of its own; see \"Council call\". Attended\n`define-tickets` supplies it from its drafting plan. It is not one of the required\ninputs, so its absence never stops the run. When it is absent, the attended asks in \"Council\ncall\" apply.\n\nAn optional sixth input, **`auto_amend`**, is `true` only when the caller asks for it. In an\nattended drafting run it makes the caller amend the manifest between rounds with no question,\nas an unattended run does. Any foundation gap still left after the bound goes to the caller's\ncreate screen with an agent-drafted accept reason; it does not halt. See \"Drafting mode\".\n\n## The input document\n\nThe document carries artifacts only. It never carries the drafting conversation.\n\n```json\n{\n \"epic\": {\n \"key\": \"EPIC-1\",\n \"title\": \"Short epic title\",\n \"acceptance_criteria\": [\n { \"id\": \"AC-1\", \"text\": \"What must be true\", \"verification\": \"How it is proven\" }\n ]\n },\n \"design_text\": \"Goals and design text: the exploration's Goals & NFRs followed by its Proposed Design, the epic parent body, or equivalent.\",\n \"manifest\": [\n {\n \"id\": \"1\",\n \"title\": \"Child title\",\n \"scope\": \"What the child does\",\n \"size_band\": \"L\",\n \"depends_on\": [],\n \"recommended_after\": [],\n \"touched_files\": [\"path/relative/to/repo.py\"],\n \"read_files\": [\"path/the/child/only/reads.py\"],\n \"owns_verifications\": [\n { \"epic_ac\": \"AC-1\", \"obligation\": \"The concrete part of AC-1's verification this child carries out\", \"e2e\": true }\n ],\n \"handoff_roles\": [\n { \"thing\": \"H-1\", \"role\": \"write\" }\n ]\n }\n ],\n \"child_evidence\": [\n {\n \"id\": \"1\",\n \"acceptance_criteria\": [\"Each acceptance criterion of the child, verbatim\"],\n \"body\": \"The child ticket body, if available\"\n }\n ],\n \"non_child_owners\": [\n {\n \"id\": \"OR-1\",\n \"kind\": \"owner_run\",\n \"who\": \"Release owner\",\n \"step_ref\": \"Release checklist step 6\",\n \"step_text\": \"Release checklist step 6: the release owner runs the smoke test against production and posts the output as a comment on the epic.\",\n \"records_result_in\": \"a comment on the epic\",\n \"owns_verifications\": [\n { \"epic_ac\": \"AC-2\", \"obligation\": \"Run the production smoke test and post its output on the epic\" }\n ]\n }\n ],\n \"design_council\": {\n \"council_id\": \"<the completed design council id>\",\n \"design_revision\": \"<the design revision it reviewed>\",\n \"split_reviewed\": true,\n \"materiality\": {\n \"requirements\": \"unchanged\",\n \"interfaces_or_contracts\": \"unchanged\",\n \"ownership\": \"unchanged\",\n \"dependencies\": \"unchanged\",\n \"end_to_end_proof\": \"unchanged\",\n \"blast_radius\": \"unchanged\"\n }\n }\n}\n```\n\nField rules:\n\n- `epic` carries either `key` or `slug` (one is enough), plus `title` and\n `acceptance_criteria`. Each acceptance criterion has `id`, `text`, and `verification`. When\n an epic AC has no verification sentence, coverage is judged against its text, the basis is\n `text_only`, and the reviewer raises an advisory input finding naming the missing sentence.\n- `design_text` is the goals and design text. When the caller has the epic's goals and\n non-functional requirements (NFRs), they open `design_text` verbatim, and the reviewer checks\n the split against each NFR as well as against the acceptance criteria. When there are none,\n that check is skipped and nothing is raised about their absence.\n- `manifest` is the **complete, ordered** child list. Each entry carries `id` (a placeholder\n index or a real ticket key), `title`, `scope`, `size_band`, `depends_on`, and\n `recommended_after`. These are the same field names `decompose-epic.md` and\n `decompose-epic-candidate.md` already use.\n- `touched_files` is optional. It lists the files the child **edits or creates**. When absent,\n the fit check uses the file paths the child's scope and body name. A `touched_files` path that\n does not exist yet can be a planned creation; that alone is not a problem.\n- `read_files` is optional. It lists files the child **only reads**. It lives in the manifest,\n so it is hashed. Reads inform the fit check. Only edits (`touched_files`) count toward edit\n overlap between children and toward the high-risk path check in \"Escalation rule\". A path\n must not appear in both lists. A `read_files` path that does not exist is an `input` problem,\n because a child cannot read a file that is not there. When `read_files` is absent, behavior is\n unchanged.\n- `owns_verifications` is optional. It is a list of entries with `epic_ac` (an epic AC id) and\n `obligation` (the concrete part of that AC's *verification* this child will carry out, in\n words a reviewer can hold against the verification sentence). It is a **claim** the reviewer\n checks. It is never proof by itself. When it is absent (older epics, the on-demand path), the\n reviewer derives candidate owners from each child's own acceptance criteria, and the record\n says `owns_verifications_source: derived`. When it is present, the record says `declared`.\n- `child_evidence` is a **separate top-level array**, keyed by child `id`. Each entry may carry\n `acceptance_criteria` and `body`. It lives **outside** the hashed manifest, so evidence can be\n refreshed without changing manifest identity. Derived ownership counts only when a child's\n acceptance criteria contain a concrete commitment to the obligation. When the material needed\n to establish ownership is absent, that is an explicit `input` gap, not coverage.\n- `non_child_owners` is an optional **top-level array** beside `child_evidence`. It names the\n owners of epic AC verifications that no child carries out, such as a step in an owner-run\n release checklist. Each entry has:\n - `id` — for example `OR-1`. It is unique across the array and never equal to any child `id`.\n - `kind` — a closed vocabulary with one value: `owner_run`.\n - `who` — a named person or role, for example \"Release owner\".\n - `step_ref` — the step it points at, for example \"Release checklist step 6\".\n - `step_text` — the step's text, copied **verbatim** from `design_text`.\n - `records_result_in` — where the result is recorded, for example \"a comment on the epic\".\n - `owns_verifications` — a list of `epic_ac` plus `obligation` entries, the same shape\n children use.\n\n `step_text` is copied into the entry on purpose. `design_text` is not hashed, so a step that\n lived only there could change without changing the review's identity. The copied, hashed\n `step_text` is the reviewed commitment. An owner-run owner owns **coverage only**: it never\n fills a hand-off grid cell. When the array is absent, no AC has a non-child owner.\n- `handoff_roles` is optional on a manifest entry. It is a list of `{thing, role}` entries the\n drafting caller declares. `thing` is a stable id matching `^[A-Z]+-\\d+$`, for example `H-1`,\n shared by every child that touches the same value. `role` is one of `write`, `read`, `caller`,\n `start`, `steady_state`, `wind_down`, or `consumer`. It sits inside `manifest`, so it is\n hashed: moving a role to another child changes `manifest_sha256` and invalidates a record\n bound to the old digest, with no change to the identity rules.\n- `e2e` is optional on an `owns_verifications` entry. `e2e: true` marks the child that owns the\n end-to-end test of the epic's cross-child flow. It is hashed with the manifest. Only a child\n can own it; on a `non_child_owners` entry it never counts.\n- A `design_text` line starting `no_cross_child_flow:` followed by a non-empty reason declares\n that no value passes between children. It must start the line. `design_text` is not hashed.\n- `design_council` is an optional **top-level** object. A drafting caller writes it only when a\n design council already completed for this design. It carries `council_id` and\n `design_revision` (non-empty strings), `split_reviewed` (a boolean: the council reviewed this\n ticket split), and `materiality`, an object with exactly the keys `requirements`,\n `interfaces_or_contracts`, `ownership`, `dependencies`, `end_to_end_proof`, and\n `blast_radius`. Each value is `\"unchanged\"` or a short note saying what the split changed\n since that council. It sits **outside every digest**; \"High-risk trigger\" below reads it, and\n clearance checks it directly through `design_council_basis`.\n\nAll four are **declarations** and **claims**. The reviewer verifies them against\n`child_evidence` and never treats one as proof. They are optional for every caller:\n`/plan-epic`, `/idea-to-ticket`, and `/review-epic-coherence` need not supply them, and a\nmanifest without them is reviewed exactly as before.\n\n**Local markdown drafts.** When an epic is drafted as local markdown files outside a drafting\nsurface, build this document with the packaged `epic-coherence-input build` subcommand of the\nBridge MCP package: `epic-coherence-input build --outline <outline-path> --out <output-path>`.\nDo not assemble it by hand. The outline names the epic draft, each child's draft, its\ndependencies, size band, `edits` (which become `touched_files`), `reads` (which become\n`read_files`), and `owns_verifications`, plus any `non_child_owners`. Every epic AC bullet in the\nepic draft must start with an explicit id such as `AC-3:`; the builder never numbers ACs by\nposition or matches them by keyword. `epic-coherence-input check <input-path>` validates an\nexisting document against the structural rules in \"Validation\" and prints the three digests. It\nnever judges coverage; that stays the reviewer's job. `epic-coherence-input check --structural\n<input-path>` adds the declaration checks in \"Validation\"; only `/define-tickets` requires it. The three drafting surfaces keep their\nstructured normalization, and the on-demand `/review-epic-coherence` command keeps building its\ninput from ticket data.\n\n## Identities\n\nThree digests identify what was reviewed. All three use the same canonical JSON encoding.\n\n- `manifest_sha256` is the SHA-256 hex digest of\n `json.dumps(manifest, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")`,\n computed over the `manifest` array only. Compute it locally with this one line:\n\n ```bash\n python3 -c 'import hashlib,json,sys; manifest=json.load(open(sys.argv[1], encoding=\"utf-8\"))[\"manifest\"]; print(hashlib.sha256(json.dumps(manifest, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")).hexdigest())' <input-path>\n ```\n\n- `child_evidence_sha256` is the SHA-256 hex digest of the same encoding applied to the\n `child_evidence` array (an absent array hashes as an empty array).\n- `non_child_owners_sha256` is the SHA-256 hex digest of the same encoding applied to the\n `non_child_owners` array. An absent array hashes as an empty array, as `child_evidence`\n does. Compute it locally with this one line:\n\n ```bash\n python3 -c 'import hashlib,json,sys; owners=json.load(open(sys.argv[1], encoding=\"utf-8\")).get(\"non_child_owners\", []); print(hashlib.sha256(json.dumps(owners, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=False).encode(\"utf-8\")).hexdigest())' <input-path>\n ```\n\nRecord **all three** digests, at the top level and in every round. A caller that wants to\nreuse a prior review must compare **all three** identities against the manifest, evidence,\nand non-child owners it is about to use. A matching manifest with changed evidence or changed\nowners is not the same review. The sibling integration's preflight must compare all three.\n\n`design_text` deliberately stays **outside** identity. The copied and hashed `step_text` is\nthe reviewed commitment of an owner-run step. There is no fourth digest, and no render-time\ncheck that `design_text` still contains the step.\n\n## Validation\n\nBefore any reviewer run, validate the input document. Every problem becomes a visible `input`\nfinding. Nothing is silently dropped.\n\n- Child ids are unique. Epic AC ids are unique. Every `owns_verifications.epic_ac` names a real\n epic AC, and every `child_evidence.id` names a real manifest child.\n- The document shapes and the key or slug syntax are valid.\n- Every `non_child_owners` entry is well formed. Its `id` is unique across the array and never\n collides with a child id. Its `kind` is `owner_run`. Its `who`, `step_ref`, `step_text`, and\n `records_result_in` are non-empty. Every one of its `owns_verifications.epic_ac` values names\n a real epic AC. A malformed entry, a colliding id, an invalid AC reference, and a missing\n required field are each a visible `input` finding.\n- Every named file path is repository-relative. Reject absolute paths and any path that\n traverses upward. A path listed in both `touched_files` and `read_files` of the same child is\n an `input` finding.\n- The output directory is beneath the `docs_dir` that `ping` resolved. Refuse to write anywhere\n else.\n- A missing, invalid, or unreadable named file is an `input` finding. So is inaccessible child\n material and a missing set of epic acceptance criteria. A nonexistent `touched_files` path can\n be a planned creation and is not, by itself, a finding. A nonexistent `read_files` path is an\n `input` finding.\n- A missing verification sentence alone is **advisory**. Any problem that prevents a meaningful\n review (no epic acceptance criteria, an empty manifest, an unreadable input document) makes\n the verdict `not_checked`. It never produces a complete-looking coverage map.\n\n**Plain and structural checking.** The rules above are the plain check every caller runs,\nmechanically through `epic-coherence-input check <input-path>` where the caller uses the\npackaged subcommand. `/define-tickets` also runs `epic-coherence-input check --structural\n<input-path>`, which checks the declarations: every epic AC is claimed by a child or a\nnon-child owner (`unclaimed_epic_ac`), every declared `thing` that spans two children has\nwrite, read, and caller owners (`handoff_missing_role`), every read or consumed `thing` has a\nwrite and a caller owner whatever its span (`handoff_missing_write_or_caller`), every role is\nwell formed (`malformed_handoff_role`), a cross-child flow has a child `e2e` owner\n(`missing_e2e_owner`), two or more children either share a `thing` or give a\n`no_cross_child_flow:` reason (`no_cross_child_declaration`, `no_cross_child_flow_contradicted`),\n`depends_on` names known children and forms no cycle (`depends_on_unknown_child`,\n`depends_on_self`, `depends_on_cycle`), `recommended_after` names known children\n(`recommended_after_unknown_child`, `recommended_after_self`), and any `design_council` is well\nformed (`malformed_design_council`). On success it prints `design_council_covers_high_risk`.\nA clean structural result proves the declarations are complete and consistent; it never proves\nthey are true, so the reviewer still runs. Other callers never run structural mode: callers that\ndeclare no hand-off roles would fail every manifest of two or more children on\n`no_cross_child_declaration`.\n\nDescribe variable paths in words or angle brackets, such as `<output-directory>`. Do not write\nany literal brace-wrapped identifier other than `docs_dir`, including in examples.\n\n## Reviewer run\n\nInvoke the `epic-coherence-reviewer` agent in a **fresh context**. Pass it only the input\ndocument path. Run it **once per round over the whole frozen manifest** — never per child and\nnever over a subset. The reviewer must not receive the drafting conversation.\n\nResolve the agent the way `draft-ticket.md` resolves `jira-ticket-writer`: through the Task tool\nor a host equivalent you have confirmed can resolve it. Cursor has no agent mirror for this\nagent, so on Cursor resolution normally fails.\n\n**Fresh-context fallback.** If no fresh context can be obtained, read the agent file\n`agents/src/epic-coherence-reviewer.md` (or its installed mirror) and execute its methodology\ninline. Set `independent: false` in the record and say so in the report. An inline run is never\na silent independent pass.\n\n- In an **attended** run, tell the person in plain words: \"this check ran in my own session, not\n by a separate reviewer, so it's less independent.\" Offer a fresh-context rerun when one\n becomes available.\n- In an **unattended drafting** run, an inline `pass` is not the independent gate. Halt.\n\n## Escalation rule\n\nEscalate to a council **only** when at least one of these is true:\n\n1. Any blocking finding has `confidence: uncertain`.\n2. The caller **disputes** a blocking finding instead of amending it. The caller is the drafting\n agent in drafting mode and the operator in report mode.\n3. The epic is **high risk**.\n\nHigh risk means one of the following. Count **children**, never edited files: a single child\nthat edits ten files under one prefix is still one child.\n\n- The epic has **six or more children**.\n- **One** child's `touched_files` falls under one of these paths. A single editing child is\n enough:\n - `db/migrations/` and `db/alembic/` (the design says `db/migrations/`; this repository's\n migrations live in `db/alembic/`, so match both)\n - `api/library/billing/`\n - `api/routes/setup/auth.py`\n - `api/library/auth/`\n- **Two or more distinct** children each edit under the same kind of path from the list below.\n One editing child alone does **not** make the epic high risk. This list is every remaining\n prefix in `_CONTAINMENT_HAZARD_PATHS` in `api/library/github/workflow_planning_prediction.py`\n (the list also carries `db/alembic/`, which is already a single-trigger path above):\n `mcp_server/src/executor/`, `mcp_server/src/agent-launchers/`,\n `mcp_server/src/claude-settings.ts`, `.github/workflows/`,\n `tests/integration/conductor_harness/`, and `api/library/db/`\n\n| Edits under the path | Risk tier |\n| --- | --- |\n| One child edits `api/library/db/` | low |\n| Two children each edit `api/library/db/` | high |\n| One child edits an executor prefix such as `mcp_server/src/executor/` | low |\n| Two children each edit executor-prefix paths | high |\n| One child edits `db/alembic/`, `api/library/billing/`, or auth paths | high |\n| Six or more children, whatever they edit | high |\n\nOnly edits count. A path a child lists in `read_files` never makes the epic high risk, even\nunder one of these prefixes, so a child that only reads `api/library/db/` does not trigger\nthis rule. Reads do not count toward the two-child threshold either.\n\nA low-risk epic with one child editing `api/library/db/` or an executor prefix still receives\nthe low-risk reviewer rounds in \"Drafting mode\". If a round raises a blocking finding with\n`confidence: uncertain`, the epic is promoted to high risk and the council flow starts. Any\nblocking findings that remain go to the operator at the create gate. This adds no other\nmitigation.\n\nWhen `touched_files` is absent for a child, apply the same path check to the concrete paths its\nscope and body name. When a child's file ownership is unknown, record **uncertainty**. Do not\ndeclare the epic low risk.\n\n**Classify the risk before round 1.** Decide the initial risk tier from the input alone,\nbefore the first reviewer run, using the child count and the edit paths. The tier is `high`\nwhen this rule matches, and also when unknown file ownership leaves the question open. It is\n`low` otherwise. Record it as `risk_tier` with its `risk_reasons`, for example \"Children 1 and 3\nboth edit `api/library/db/`\". Trigger 3 therefore fires **before round 1**. Triggers 1 and 2 still fire\nafter any later round.\n\nAn uncompleted required escalation leaves the result unresolved. It is never a quiet pass.\n\n## Council call\n\nBefore **every** billable council request, state:\n\n- the cost: **26–65 credits and about 15 minutes** (26 credits for standard models, 65 credits\n for frontier models; state the applicable tier if providers are pinned). The source is\n `api/library/billing/pricing.py`;\n- the escalation reason (which of the three triggers fired);\n- that council output cannot itself clear a blocker.\n\nAn **attended** run asks the operator to approve before proceeding, using the decision card\nbelow. An **unattended** run states the cost in its output and proceeds. This holds for every\nrequest, including a `mode: general` retry.\n\n**The decision card.** Every attended council offer is one card, shown in this order:\n\n1. A plain-language question ending in `?`, such as \"Would you like several other AI models to\n review how the work is split before I create the tickets?\"\n2. One sentence saying what a council is: \"a panel of several AI models that each review the\n plan separately.\" It carries the cost (`26–65 credits`) and `about 15 minutes`, and says\n the gap check runs either way.\n3. A recommendation, with a reason of one or two sentences grounded in what is uncertain.\n4. Bulleted concrete questions the council would check, each followed by the AI's current\n answer, or an explicit statement that it is not sure.\n5. Exactly these three options, with `(as recommended)` on the recommended one only:\n\n ```text\n 1. Yes, run the council\n 2. No, continue without it\n 3. Yes, but change what it checks, or ask me something first\n ```\n\n**Reading the reply.** Judge the reply by intent, not by exact words. A clear number or a clear\nverbal choice selects that option. An unclear reply authorizes nothing: say what you could not\ntell and show the card again.\n\n- **Option 3 with a new focus.** Echo the revised checklist back in one or two lines, run the\n council with it, and do not ask again.\n- **Option 3 with a question.** Answer the question first, then show the three options again in\n a compact form.\n- **A reply that picks an option and also asks to change the split.** The change comes first:\n amend the manifest, re-freeze it, and start no council from that reply.\n- Added focus never removes a mandatory check, never waives the gap check, and never changes\n how a record clears.\n\n**When the council starts.**\n\n- **High-risk trigger: already covered by a design council.** Before any card or request for\n the high-risk trigger, read the input's `design_council`. Evaluate the skip predicate exactly\n as `epic-coherence-input check --structural` reports it in `design_council_covers_high_risk`:\n it is true only when `design_council` is present and well formed (non-empty `council_id` and\n `design_revision`, a boolean `split_reviewed`, and a `materiality` object with exactly the keys\n `requirements`, `interfaces_or_contracts`, `ownership`, `dependencies`, `end_to_end_proof`,\n and `blast_radius`, each a non-empty string) **and** either `split_reviewed` is `true` or every\n `materiality` value is exactly `\"unchanged\"`. When it is true, request **no** council for the\n high-risk trigger, show no card, and record `council_id: null`, `council_outcome:\n \"covered_by_design_council\"`, and `design_council_basis: { \"council_id\": <the design council\n id>, \"design_revision\": <its design_revision> }`. Say in the report why the council was not\n started: the design council already reviewed this design, and the split did not materially\n change it. This skips only the initial high-risk council. It removes neither the reviewer\n rounds, the high-risk round limit, nor the uncertain and disputed triggers below, which keep\n their cards, costs, preapproval, and limits unchanged. When the predicate is false, or\n `design_council` is absent or malformed, the high-risk trigger behaves exactly as below.\n- **High-risk trigger.** After the epic is classified high risk before round 1, an attended run\n shows the decision card **before** round 1 starts. It explains the high-risk reason in plain\n words from `risk_reasons`, for example \"two tickets both change the database layer\", without\n changing any threshold or classification. The mandatory checks on the card are concurrent\n writers, migration and rollback order, and rollout that runs ahead of the code, each with the\n AI's current answer or stated uncertainty. On option 1, or option 3 with a focus, request the\n council and start the round-1 reviewer run **in parallel**. Do not wait for a later round.\n - **Decline.** On option 2, request no council. Record `council_id: null` and\n `council_outcome: \"declined_by_operator\"`, omit `council_preapproval`, and continue the\n reviewer run. The decline is final and is shown as `Council: skipped, your choice`.\n - **Caller preapproval.** If the caller supplied `council_preapproval`, its `value` and\n `source` are recorded. `approved` starts the initial council alongside round 1 after\n stating the cost, with no further ask. `declined` skips it and records the same\n `declined_by_operator` outcome.\n - If the technical request needs the `mode: general` retry, state the cost again, with the\n disclosure and approval that retry already requires.\n- **Uncertain or disputed trigger.** Request the council after the round that raised the\n finding. An attended run shows the same decision card with its own cost statement, a\n recommendation, and questions about that finding, each with the AI's current answer. The task\n text stays limited to the input document's artifacts and the relevant findings.\n - **Decline.** On option 2, request no council and append no `councils` entry. The triggering\n finding keeps its identity, severity, evidence, and blocking status. Keep the finding id in\n the run state as declined, so no later round offers a council for the same finding again.\n No new record field is added for this.\n - A genuinely new qualifying finding may still get an offer, within the limit below.\n - **Caller preapproval.** When the caller supplied `council_preapproval`, show no card for\n this trigger either. `approved` states the cost and requests the council with no ask,\n within the limit below. `declined` requests none, exactly as a decline on the card does.\n- **How many.** One council per drafting run for the initial high-risk trigger. A later\n qualifying trigger (an uncertain or disputed blocking finding) may start **at most one more**\n council, with its own cost statement and approval.\n\nCall `request_council` with:\n\n- `mode`: `technical`\n- `wait_for_result`: `false`\n- no `repo_name`\n- task text containing **only** the input document's artifacts and the contested findings.\n The early high-risk council has no reviewer findings yet, so its task text holds **only** the\n input document's artifacts. Never invent findings for it. Ask it to look for cross-child and\n release-level risks, such as concurrent writers, migration and rollback order, and rollout\n that runs ahead of the code.\n\nThen poll `get_council` for a bounded period. Call it with `wait_for_result: true`: it returns\nwhen the council finishes, so you see the result within about 30 seconds. If it times out, call\nit again; that is safe and never starts a second council. Never sleep a fixed time between\nchecks. If technical mode cannot run because the repository is not indexed, repeat the request with `mode: general`, and state the cost again\nbefore that request too.\n\n**The amendment freeze.** The round-1 amendment freezes at the moment the caller begins writing\nthe amended input document after collecting the round-1 findings. Poll `get_council` while the\nround-1 reviewer runs. Council conclusions received before the freeze join that **same**\namendment pass. Conclusions received after it join the next pass. A frozen round is never\nchanged after the fact.\n\nCouncil conclusions join the finding list as **separate** findings with `source: council`. The\noriginal reviewer finding is kept unchanged. It is never edited, downgraded, or removed because\na council failed, timed out, is still running, left the dispute unresolved, or concluded.\nRecord the `council_id` and the council outcome. Record still-running and failed outcomes as\nunresolved.\n\n**An unfinished required council.** A required council that is `still_running`, `failed`, or\n`timed_out` when the last round or confirmation pass ends is unresolved. The verdict is never\n`pass`. An **attended** operator, after being shown the council's id, cost, and elapsed time,\nmay accept it with a typed override of kind `accept` that names its `council_id`. An\n**unattended** run records `blocked` and halts before any ticket is created.\n\nA council outcome of `declined_by_operator` is resolved and needs no `accept` override, whether it was declined at the pre-round-1 ask or through legacy `council_preapproval: declined`. A legacy `accept` override targeting `council: \"declined_by_operator\"` remains valid but is ignored for clearance.\n\nA council outcome of `covered_by_design_council` is also resolved and needs no `accept` override: no council request was made, because recorded design-council evidence already covered the high-risk trigger. It stays resolved only while its basis still matches the input:\n\nRefuse clearance for a `covered_by_design_council` record unless its `design_council_basis.council_id` and `design_council_basis.design_revision` match the corresponding members of the current input’s `design_council`, and that `design_council` is still well formed and satisfies the skip predicate: `split_reviewed` is `true` or every `materiality` value is `\"unchanged\"`.\n\n**Declining an escalation council.** Declining a council offered for an uncertain or disputed\nfinding resolves the council decision only. The finding itself stays blocking until it is\namended or accepted by its own `finding_id`.\n\n## Drafting mode\n\nDrafting mode is for a drafting surface that can still change the manifest.\n\n- **Attended progress.** After every completed reviewer round, an attended run says one short\n line with the number of gaps in how the work is split that still need a decision. Use the\n real ordinary-round ceiling for this epic (the low-risk or the high-risk limit below), for\n example: `Gap check, round 1 of up to 3: 2 gaps need a decision.` A confirmation pass is\n named as a confirmation pass. It is never counted as an extra ordinary round. Unattended runs\n print no such line.\n- **Amend and recheck.** The reviewer only describes amendments. The **caller** amends the\n manifest (adds or rescopes children), re-freezes it, and writes a **new** input document. The\n procedure then reruns the reviewer in a fresh context. Record each round with its own\n `manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`, blocking and\n advisory counts, whether a council ran, and whether it was a confirmation pass.\n- **Foundation readiness and carry.** A round with zero foundation blockers is ready and exits the ordinary loop immediately. Carry unresolved ticket-local blockers without amending or rechecking merely because they remain. `pass` requires zero unresolved foundation blockers and may retain carried ticket-local findings; `accepted_with_gaps` is reserved for accepted remaining foundation blockers.\n- **Risk-scaled round limit.** The number of ordinary reviewer runs, `round_limit`, depends on\n the risk tier from \"Escalation rule\":\n - **Low risk** (the epic is not high risk and no blocking finding is `uncertain`):\n `round_limit` is **2**. These are maximum ordinary rounds; exit earlier when a round has zero foundation blockers.\n That is at most **2 reviewer runs**.\n - **High risk**: `round_limit` is **3**. Allow at most **2 re-checks**, which is\n **3 reviewer runs in total**, with the same zero-foundation early exit.\n - **Promotion.** A low-risk epic whose round produces a blocking finding with\n `confidence: uncertain` becomes high risk from that point. It gets the high-risk limit, and\n trigger 1 fires. Promotion raises the ceiling to three total ordinary rounds, including rounds already completed.\n\n If a round with foundation blockers has a foundation count greater than or equal to the preceding round's count, stop automatic looping with `non_convergence`; route attended findings to the create gate or halt unattended as `blocked`.\n\n Record the final `risk_tier`, `risk_reasons`, and `round_limit`. A confirmation pass is not an\n ordinary run and does not count toward `round_limit`.\n- **Confirmation pass.** Run a confirmation only after a caller amendment targeting foundation findings and when the ordinary-round rule calls for it. Derive `confirmation_passes_used` from `rounds[].confirmation`; the budget is two attended passes or one unattended pass, and refuse another at the budget.\n\n When the caller changes the input after the last allowed ordinary\n round, run **one confirmation pass**. It is a fresh-context reviewer run over the **whole**\n amended manifest, never a subset. Its requested focus is narrower: the amended children, the\n hand-offs they touch, and whether the findings the amendment targeted are closed. It must\n still report **any** blocking finding it observes anywhere in the manifest; the narrower\n focus never suppresses one. When it cannot establish where an amendment's impact ends, it\n raises that as a blocking finding with `confidence: uncertain` instead of calling the\n amendment confirmed. Record it in `rounds[]` with `\"confirmation\": true`.\n - A confirmation pass **never** starts another automatic amendment loop. A new blocking\n finding goes to attended fix-or-accept, or to the unattended halt.\n - **A new foundation finding in a later round stays blocking**, wherever it lands in the\n manifest, including on a child that did not change since the earlier round. Every round and\n confirmation pass is a whole-manifest review; only a caller's draft reuse may be selective.\n A proposed acceptance from an earlier round may be carried to a re-raised finding only when\n the gap, the evidence, the kind, and the affected entries are substantively unchanged; the\n carried proposal then rebinds to the new round and identities. Changed or uncertain\n equivalence needs a fresh settlement.\n - In an **attended** run, after the first confirmation pass, the operator may direct **at\n most one** fix of a confirmation blocker. Then run **one** further whole-manifest\n confirmation pass, so the last round bears the final digests. That is the whole budget\n across re-runs in the same attended `define-tickets` run.\n - Once that budget is spent, a remaining blocker is accepted with a non-empty reason or stays\n `blocked`. Do not add an \"unconfirmed fixed\" state, and do not start another automatic\n amendment loop. A typed acceptance stays available instead of the fix at any point.\n- **Final identity.** The top-level `manifest_sha256`, `child_evidence_sha256`, and\n `non_child_owners_sha256` equal the digests of the **last** entry in `rounds[]`. A record\n whose top-level digests no round saw does not clear. The sole exception is a confirmation\n pass that cannot run: an **attended** operator may record `amended_after_final_round: true`\n with an override of kind `bypass` carrying a typed reason. The verdict is then\n `not_checked`, never `pass` or `accepted_with_gaps`, and the top-level digests still describe\n the amended input. An **unattended** run halts instead.\n- **Acceptance by effect.** A foundation blocking finding of kind `coverage` (a requirement no\n ticket owns) or `e2e_proof` (no end-to-end test) can **never** be cleared by an `accept`\n override. It has exactly two resolutions: **assign** it, by amending the manifest so a\n ticket, existing or new, owns the requirement or the end-to-end test; or an **explicit\n requirement change the owner makes**, removing the requirement from scope. Every other\n foundation finding (`handoff`, `fit`, `input`) may still be accepted with a non-empty reason.\n- **Removing a requirement is the owner's decision.** Removing a ratified requirement from scope\n is a requirement change, never an amendment. Only the owner's answer at the caller's existing\n approval surface (the `/define-tickets` upload gate, or the caller's own approval or create\n screen) can make it. The agent never removes a requirement to clear a gap. The change updates\n the ratified set and invalidates the affected coverage, the review evidence bound to the old\n input, and the affected drafts; the caller rebuilds the input and reviews it again before a\n fresh approval.\n- **Automatic amendment.** When the caller passed `auto_amend: true`, an attended run amends\n and rechecks within the same round and confirmation bounds with no question, as an unattended\n run does. The caller assigns a remaining `coverage` or `e2e_proof` finding to a ticket. When\n no ticket can own it, the create screen shows it as needing the owner's answer (name a\n ticket, or remove it from scope), never with an accept reason, and nothing clears until the\n owner answers. After the bound, each other remaining foundation blocking finding goes to the\n caller's create screen with an agent-drafted reason. The operator's approval there records it\n as an `accept` override. It is never a halt.\n- **Attended resolution.** After the bound, each remaining **foundation** blocking finding must be\n fixed within the same one-fix, one-further-confirmation-pass budget, or resolved by the effect\n rule above: a `coverage` or `e2e_proof` finding is assigned to a ticket or removed from scope\n by the owner's explicit requirement change; any other foundation finding may be accepted with\n a non-empty reason.\n Ticket-local blockers are carried to their child ticket; they do not require a foundation amendment\n or acceptance to clear the epic record.\n The reason may be typed by the operator or drafted by the agent and shown at the create gate\n where that gate applies. An accepted finding is an override with `kind: accept`, plus\n `finding_id`, `reason`, `accepted_by`, and `round`. Declining a foundation finding keeps the verdict `blocked`.\n When **every** remaining foundation blocking finding is accepted, and none of them is of kind\n `coverage` or `e2e_proof`, the verdict is `accepted_with_gaps`.\n- **Unattended halt.** If any foundation blocking finding remains after the bound, the verdict is\n `blocked`. Return an explicit halt signal: **do not call `create_ticket`**. The caller must\n stop.\n\n## When the review cannot run\n\nIf the reviewer cannot run (a tool error, a timeout, or a host that lacks the capability while\ninline execution also fails), or the material prevents a meaningful review, the verdict is\n`not_checked`. It is never `pass`.\n\n- **Attended:** tell the person \"Couldn't check\", then offer a retry, or a bypass with a typed\n reason. A bypass is recorded as an override with `kind: bypass`. The verdict stays\n `not_checked`. A caller may instead retry within its existing round bounds and defer this\n question to its own approval surface: `/define-tickets` keeps drafting and shows \"Couldn't\n check\" at the upload gate as an item needing the owner's answer. The deferral never weakens\n the rule: creation still needs the owner's typed bypass reason, and nothing clears without\n it. Other callers keep asking where they ask today.\n- **Unattended:** halt.\n\n## Report mode\n\nReport mode is diagnostic. It runs the reviewer **once**. There is no amendment loop and no halt\nsignal. Escalation still applies, with the cost stated and confirmation asked. It splits blocking counts and the verdict by scope: ticket-local blockers are labelled “would be carried into child N”, are not carried, and edit no ticket. The verdict is `pass`, `blocked`, or `not_checked` from foundation blockers only.\n\nA `blocked` or `not_checked` report is **diagnostic and not a clearance**.\n\nWhen showing a report-mode result to a person, use the words in \"What the user sees\". Describe\neach ticket-local finding as `a note that would be added to ticket N`, keep the result\ndiagnostic rather than clearing, and say plainly that the check changed no ticket.\n\n## The record: epic-coherence.json\n\nWrite `epic-coherence.json` into the output directory:\n\n```json\n{\n \"schema_version\": 3,\n \"checked_at\": \"2026-01-01T00:00:00Z\",\n \"mode\": \"drafting\",\n \"unattended\": false,\n \"manifest_sha256\": \"<64 hex characters, or null>\",\n \"child_evidence_sha256\": \"<64 hex characters, or null>\",\n \"non_child_owners_sha256\": \"<64 hex characters, or null>\",\n \"owns_verifications_source\": \"declared\",\n \"verdict\": \"pass\",\n \"independent\": true,\n \"risk_tier\": \"low\",\n \"risk_reasons\": [\"Three children; no child edits a high-risk path\"],\n \"round_limit\": 2,\n \"confirmation_passes_used\": 0,\n \"confirmation_budget\": 2,\n \"stop_reason\": \"ready\",\n \"carried_ticket_local\": [],\n \"amended_after_final_round\": false,\n \"rounds\": [\n {\n \"manifest_sha256\": \"<64 hex characters>\",\n \"child_evidence_sha256\": \"<64 hex characters>\",\n \"non_child_owners_sha256\": \"<64 hex characters>\",\n \"blocking_count\": 0,\n \"foundation_blocking_count\": 0,\n \"ticket_local_blocking_count\": 0,\n \"findings_snapshot\": [],\n \"advisory_count\": 0,\n \"council_ran\": false,\n \"confirmation\": false\n }\n ],\n \"owner_run_acs\": [\"AC-2\"],\n \"coverage_map\": [\n {\n \"epic_ac\": \"AC-1\",\n \"judgment_basis\": \"verification\",\n \"status\": \"covered\",\n \"owners\": [\n {\n \"owner_kind\": \"child\",\n \"child\": \"1\",\n \"obligation\": \"Concrete obligation\",\n \"child_ac\": \"The child AC id or a quoted child AC\",\n \"source\": \"declared\"\n }\n ]\n },\n {\n \"epic_ac\": \"AC-2\",\n \"judgment_basis\": \"verification\",\n \"status\": \"covered\",\n \"owners\": [\n {\n \"owner_kind\": \"owner_run\",\n \"child\": null,\n \"owner\": \"OR-1\",\n \"who\": \"Release owner\",\n \"step_ref\": \"Release checklist step 6\",\n \"records_result_in\": \"a comment on the epic\",\n \"obligation\": \"Run the production smoke test and post its output on the epic\",\n \"source\": \"declared\"\n }\n ]\n }\n ],\n \"handoff_grid\": [\n {\n \"thing\": \"The stored field, endpoint, flag, event, job payload, or scope\",\n \"consumer\": \"The consuming piece\",\n \"write_path\": \"child id or null\",\n \"read_path\": \"child id or null\",\n \"caller\": \"child id or null\",\n \"start\": \"child id or null\",\n \"steady_state\": \"child id or null\",\n \"wind_down\": \"child id or null\"\n }\n ],\n \"findings\": [\n {\n \"id\": \"F-1\",\n \"kind\": \"coverage\",\n \"severity\": \"blocking\",\n \"confidence\": \"certain\",\n \"concerns\": \"AC-1\",\n \"evidence\": \"What was observed, with file and line where code was read\",\n \"smallest_amendment\": \"The smallest change that would close it\",\n \"source\": \"reviewer\", \"scope\": \"foundation\"\n }\n ],\n \"overrides\": [\n { \"kind\": \"accept\", \"finding_id\": \"F-1\", \"reason\": \"Typed reason\", \"accepted_by\": \"Operator\", \"round\": 3 }\n ],\n \"council_preapproval\": { \"value\": \"approved\", \"source\": \"legacy caller input\" },\n \"council_id\": null,\n \"council_outcome\": \"not_run\",\n \"councils\": []\n}\n```\n\nWhen the high-risk council was skipped on design-council evidence, the record instead carries\n`\"council_outcome\": \"covered_by_design_council\"`, `\"council_id\": null`, and\n`\"design_council_basis\": { \"council_id\": \"<design council id>\", \"design_revision\": \"<its revision>\" }`.\n\nRules:\n\n- `schema_version` is `3`. Readers also accept versions `1` and `2`; interpret every legacy blocking finding as `foundation`.\n- **The effect rule applies to every schema version.** In versions `1`, `2`, and `3`, an\n `accept` override never clears a foundation blocking finding of kind `coverage` or\n `e2e_proof`. A historical record that accepted one stays readable, and its override stays\n visible as history, but it does not clear: the finding still needs an owner or the owner's\n requirement change. An `accept` of any other foundation finding clears as before.\n- In version 3, validate every blocking finding's closed `scope` and every `ticket_local` child against the final manifest before counting, clearing, or carrying. Invalid or orphaned ownership fails closed; reclassify an ambiguously owned former carry as foundation explicitly.\n- `blocking_count` is the sum of `foundation_blocking_count` and `ticket_local_blocking_count`; count every blocking finding regardless of confidence.\n- `pass` requires zero unresolved foundation blockers.\n- `carried_ticket_local` holds one unresolved entry per stable identity with its finding id, child id, evidence, and smallest amendment. Preserve the latest snapshot and close an identity only when a later review explicitly establishes correction or supersession.\n- `stop_reason` is one of `ready`, `round_limit`, `non_convergence`, or `confirmation_budget_spent`.\n- `verdict` is one of `pass`, `accepted_with_gaps`, `blocked`, `not_checked`.\n- A `pass` with `independent: false` is allowed but flagged prominently in both files.\n- An `accept` override accepts a known gap. A `bypass` override skips a review that could not\n run. Keep the two distinct.\n- `kind` on a finding is one of `coverage`, `handoff`, `fit`, `e2e_proof`, `input`.\n `severity` is `blocking` or `advisory`. `confidence` is `certain` or `uncertain`. `source`\n is `reviewer` or `council`.\n- Digests may be `null` **only** when unreadable input makes computing them impossible. Then\n add an explicit `input` finding and set the verdict to `not_checked`.\n- The top-level digests equal the last round's digests. The only record allowed to differ is\n an attended one with `amended_after_final_round: true`, a `bypass` override with a typed\n reason, and verdict `not_checked` (see \"Drafting mode\"). The skip record below is the one\n record with no rounds at all.\n- **Skip record.** When an attended caller's operator chose not to run the check, the caller\n writes the record itself and no reviewer runs. It carries `skipped_by_operator: true`,\n `rounds: []`, verdict `not_checked`, the three digests of the current input, an empty\n coverage map, and one `bypass` override with a non-empty reason. It clears only for that\n attended caller, never for an unattended run. `skipped_by_operator` is absent on every other\n record.\n- `rounds[].confirmation` is `true` only for a confirmation pass. `risk_tier` is `low` or\n `high`, `risk_reasons` lists why, and `round_limit` is the ordinary-run limit that applied\n (`2` or `3`; report mode runs once).\n- Each coverage owner carries `owner_kind`, which is `child` or `owner_run`. A child owner\n carries `child`, `obligation`, `child_ac`, and `source`. An owner-run owner carries\n `child: null`, `owner` (its `non_child_owners` id), `who`, `step_ref`, `records_result_in`,\n `obligation`, and `source: declared`.\n- `owner_run_acs` lists the id of every epic AC with at least one owner-run owner. It is empty\n when there are none. Owner-run coverage is always visible, never silently passed.\n- `council_id` is `null` when no council ran. `council_outcome` is one of `not_run`,\n `concluded`, `failed`, `timed_out`, `still_running`, `declined_by_operator`, or\n `covered_by_design_council`. These two fields describe the first\n council. When a second council runs, `councils` lists **every** council in order, each with\n `council_id`, `trigger` (`uncertain`, `disputed`, or `high_risk`), and `outcome`. An override\n that accepts an unfinished council carries `council_id` in place of `finding_id`.\n An initial council declined at the pre-round-1 ask, or through legacy `council_preapproval`,\n is stored in `council_outcome` as `declined_by_operator` with `council_id: null`, and is\n retained there when a later council also needs an entry in `councils`. It needs no override.\n Older records may carry an override with `council: \"declined_by_operator\"` in place of\n `finding_id` or `council_id`; it stays valid and is ignored for clearance.\n- `covered_by_design_council` means no initial council was requested because the input's\n `design_council` satisfied the skip predicate in \"Council call\". It is resolved without an\n `accept` override. The record then carries `design_council_basis` with exactly the\n `council_id` and `design_revision` it relied on, and `council_id` stays `null` because no\n council ran. `design_council_basis` is absent on every other record. A later uncertain or\n disputed council still gets its own `councils` entry.\n- `council_preapproval` is present only when a caller supplied it. It persists its\n `value` and `source`, and the record omits the field otherwise, including after an attended\n decline at the pre-round-1 ask.\n- Unknown fields, such as a historical `council_note`, are outside this schema. Readers ignore\n them. They never authorize clearance.\n- A `not_checked` record must **never** carry a coverage map that looks complete. Leave the map\n empty, or mark every entry as not assessed.\n- Keep this schema in this file. Do not copy it into the ticket-authoring posture block.\n\n## The record: epic-coherence.md\n\nWrite `epic-coherence.md` into the same directory as a short human summary. Use **no tables**.\nIn this order:\n\n1. The **verdict**, as the very first line of the file (after the title heading). Nothing else comes\n before it.\n2. **Independent: yes** or **Independent: no**, prominently, on the line directly after the\n verdict, then the **next action**.\n3. The round count, the risk tier, and the round limit. Say which round, if any, was a\n confirmation pass.\n4. Directly after the round count, one line: \"Owner-run coverage: N of M epic ACs depend on\n steps a person runs outside the Epic Implementer.\"\n5. One **bullet per epic AC**: its id, the judgment basis (`verification` or `text only`), the\n status, the owning child or the absence of one, the obligation, and the cited child AC\n evidence. Mark derived ownership as derived. For an owner-run owner, say \"owner-run\" in\n words, with the person or role, the step reference, and where the result is recorded, for\n example: AC-4: covered, owner-run (Release owner, checklist step 5; result recorded in an\n epic comment).\n6. **Blocking findings**, each labelled `blocking` with its `certain` or `uncertain` label.\n Write each hand-off gap as a sentence naming the shared thing, the affected consumer, the\n missing lifecycle end, and the smallest amendment.\n7. **Advisory and input findings.**\n8. **Council state.**\n9. **Overrides**, each with its typed reason.\n\nState every meaning in words, never by color alone.\n\nIn both files:\n\n- Label a report-mode `blocked` or `not_checked` result as **diagnostic and not a clearance**.\n- In report mode, state that the result gates no drafting surface: each drafting surface runs\n its own drafting-mode check before creation.\n- Put `independent: false` at the top, directly after the verdict line, and offer an attended\n fresh-context rerun.\n\n## Writing the records safely\n\n- Render both files to temporary files first. Replace the real files from the temporary files\n where the host supports it. Both files must carry the same run identity (`checked_at` and\n all three final digests), and both describe the same final round.\n- Report a write failure explicitly. A write failure is an **incomplete review**.\n- When a newer attempt fails or is incomplete, **invalidate or remove** any older successful\n artifact in the output directory. Never leave an older `pass` beside a newer failed outcome.\n An incomplete newer attempt must not leave an older clearing record in place.\n\n## Return\n\nReport to the caller:\n\n- the verdict and whether the run was independent;\n- the next action;\n- the paths of `epic-coherence.json` and `epic-coherence.md`;\n- for drafting mode, the halt signal (`do not call create_ticket`) when one applies, and the\n amendments the caller must make before the next round.\n\nDo not describe a `blocked` or `not_checked` report-mode result as a clearance.\n",
|
|
8
8
|
".bridge/procedures/preflight-and-readiness-procedure.md": "Initialize the idea-to-ticket run directory and classify the idea's readiness and scope.\n\n## Inputs\n\n- Idea: `{idea}`\n- Slug: `{slug}`\n- Run ID: `{run_id}`\n- Docs directory: `{docs_dir}`\n- Project standards: response from the immediately preceding `get_project_standards` step. If that step returned an error envelope or a 404, treat the project standards as unavailable and proceed; do not halt.\n\n## Callers\n\nTwo callers use this procedure. Everything below is the **recipe path** and applies unchanged when the `idea-to-ticket` recipe runs it.\n\n**Define-tickets path.** When `/define-tickets --auto` runs this procedure, the command names the artifact directory and a unique local run id in its invocation. Use that directory in place of the recipe run directory, and write the readiness artifact there. Do not write `run-manifest.json`, do not compute or look up any label, and do not query Jira. Classify readiness and scope exactly as below and report both axes to the command. Scope is recorded only; it does not choose the eventual ticket shape. A `too_vague_to_ticket` result is reported to the command, which halts before it explores the codebase.\n\n## Instructions\n\n1. Create the run directory:\n ```\n mkdir -p {docs_dir}/idea-to-ticket/{slug}-{run_id}\n ```\n Every artifact produced by this pipeline run lives under this run directory. No Jira mutation may occur in any later step until `run-manifest.json` has been written to this directory.\n\n2. Classify the idea on two independent axes:\n\n **Readiness** (one of):\n - `ready_to_draft` — the idea is concrete enough that a clear ticket draft can be produced.\n - `needs_clarification` — the idea is reasonable but missing key answers; clarifying questions must be raised in `open-questions.md` later.\n - `research_first` — drafting is blocked on external/codebase research; deep or narrow research must come first.\n - `too_vague_to_ticket` — the idea is not actionable yet; do not produce a ticket.\n\n **Scope** (one of):\n - `task` — a single Jira Task (default when ambiguous).\n - `spike` — a single Jira Spike. Resolve `spike` only on the objective\n condition that the idea has **no committed production-code deliverable** —\n the same trigger as exception E2 in `docs/bridge-ticket-authoring.md`. This\n is a deliverable that is absent, not a judgement about whether the work\n feels investigative. **Any uncertainty resolves to `task`.** This decision\n is made HERE and only here: the `scope` you write into the manifest is what\n selects the spike ticket format downstream, and `jira-ticket-writer` is\n explicitly forbidden from deciding it for itself.\n - `epic_candidate` — the idea decomposes into a Jira Epic plus multiple child tickets.\n\n3. Halt locally if readiness is `too_vague_to_ticket`. Write the manifest anyway (see step 4) so the local artifacts record the halt; then stop without continuing the rest of the pipeline. Do not attempt any Jira mutation.\n\n4. Write `run-manifest.json` to `{docs_dir}/idea-to-ticket/{slug}-{run_id}/run-manifest.json`. Required fields:\n - `idea` — the original `{idea}` text.\n - `idea_hash` — `{idea_hash}`; informational run identity only, never a ticket label or search filter.\n - `slug` — `{slug}`.\n - `run_id` — `{run_id}`.\n - `run_dir` — `{docs_dir}/idea-to-ticket/{slug}-{run_id}/`.\n - `readiness` — one of the four readiness values above.\n - `scope` — one of the three scope values above.\n - `project_standards_available` — `true` if `get_project_standards` returned a usable result, `false` otherwise.\n - `created_at` — ISO 8601 timestamp.\n\n5. The manifest is the resumability artifact for the whole run. Do not include secrets or raw credentials. Keep the file under a few KB.\n\n## Return\n\nConfirm the run directory and `run-manifest.json` were created, and report the classified `readiness` and `scope`. If readiness is `too_vague_to_ticket`, also report that the pipeline must stop without Jira mutation.\n",
|
|
9
9
|
".bridge/procedures/duplicate-and-context-scan-procedure.md": "Detect existing tickets that duplicate or relate to this idea before any ticket mutation.\n\n## Inputs\n\n- Run manifest: `{docs_dir}/idea-to-ticket/{slug}-{run_id}/run-manifest.json`.\n- Research pack: `{docs_dir}/idea-to-ticket/{slug}-{run_id}/research-pack.md` (if produced).\n- Pipeline variable `allow_duplicate` controls override behavior (for this run, `allow_duplicate` = `{allow_duplicate}`). Treat the literal string `\"true\"` as override; any other value (including `\"false\"`, missing, or empty) is non-override.\n\n## Callers\n\nTwo callers use this procedure. The **recipe path** is everything under Instructions below and uses label-free searches. The **define-tickets path** is the separate branch at the end of that section; it is used only by `/define-tickets --auto`, and both paths omit labels.\n\n## Instructions\n\n> **Orchestrator-directed step.** This agent task is part of the full-automation chain and is authorized to call `get_tickets` as directed below — performing an orchestrator-directed tool call is not \"re-orchestrating\".\n\n1. Build at least two ticket searches from the manifest using the `query` parameter:\n - **Title/keyword query**: use the most salient nouns from `idea` and `slug` as title/text keywords. Prefer 2-4 concrete terms over long natural-language sentences. Run via `get_tickets`.\n - **Candidate-title query**: run `get_tickets` with a concise candidate ticket title. Compare returned scope with the idea rather than treating a text match as proof.\n - Never pass `labels`. Cross-run duplicate detection is a title/text assessment in both Jira and local mode, not a stable idea-hash guarantee. Same-run creation recovery uses confirmed real keys in `upload-state.json`; never use a search result to reconcile an uncertain create automatically.\n\n2. For each returned ticket, capture: ticket key, summary, status, and a short reason it matched (which query, which keyword).\n\n3. Classify the overall verdict as one of:\n - `duplicate` — at least one returned ticket clearly describes the same work as `idea`.\n - `related` — returned tickets are adjacent or partial overlaps but not the same work.\n - `none_found` — no meaningful matches.\n - `unable_to_check` — the ticket search itself failed (network error, auth error, JQL rejection). Record the failure and pick this verdict.\n\n4. Write `{docs_dir}/idea-to-ticket/{slug}-{run_id}/duplicate-assessment.json` with at minimum:\n - `verdict` — one of the four values above.\n - `matches` — array of `{ticket_key, summary, status, reason}` objects (may be empty).\n - `queries_used` — array of the actual JQL/search strings sent.\n - `allow_duplicate` — the resolved value of `{allow_duplicate}` for this run.\n\n5. Halt behavior:\n - If `verdict` is `duplicate` and `allow_duplicate` is not `\"true\"`, halt locally. Do not continue the pipeline. Tell the user that the duplicate halt is strict and that re-running with `--allow-duplicate` overrides it.\n - If `verdict` is `duplicate` and `allow_duplicate` is `\"true\"`, continue the pipeline but keep the duplicate evidence in the assessment file so downstream steps can reference it (e.g., to add a \"supersedes\" note to the draft).\n - For `related`, `none_found`, and `unable_to_check`, continue without halting.\n\n### Define-tickets path\n\nUsed only when `/define-tickets --auto` runs this procedure. The command names the artifact directory, a unique local run id, and the resolved `allow_duplicate` literal in its invocation. There is no run manifest and no label.\n\n1. Run at least two `get_tickets` searches using its `query` parameter: one keyword search built from the salient nouns of the task, and one search on the candidate ticket title. Never pass `labels`; both caller paths use label-free queries.\n2. Capture each returned ticket's key, summary, status, and a short reason it matched. Classify the verdict as `duplicate`, `related`, `none_found`, or `unable_to_check`, using the same definitions as above.\n3. Write `duplicate-assessment.json` to the named artifact directory with `verdict`, `matches`, `queries_used`, and the resolved `allow_duplicate` value.\n4. Halt behavior for this path: a `duplicate` verdict halts the command unless `allow_duplicate` is the literal string `\"true\"`. That override applies only to a known `duplicate` verdict. An `unable_to_check` verdict is never overridden. The command halts as `stage_failed` and names the duplicate scan. Matches found here were not created by this run.\n\n## Return\n\nConfirm `duplicate-assessment.json` was written, report `verdict`, and report whether the run is halting or continuing.\n",
|
|
10
10
|
".bridge/procedures/comp-analysis-procedure.md": "Perceive any attached/referenced design comp with your OWN vision and map it to the existing codebase BEFORE the `jira-ticket-writer` drafts. This is the pre-writer perception step: the orchestrating recipe agent (already a frontier vision model) opens the comp, classifies it against the shared fidelity taxonomy, researches the code, and writes a structured comp→codebase map the writer consumes. The writer stays text-only and never opens images — it only reads the map you produce here.\n\nThis step is gated and backend-safe. It runs the perception with the ORCHESTRATING agent's own vision — a local image via the Read tool, or an already-attached Jira comp fetched as raw bytes via the BAPI-562 binary-safe `attachment` download (operation `download`) into a worktree `file_path`. It does NOT call `describe_image()`, does NOT depend on `src/python/llms/vision.py`, and does NOT require the `CHEAP_MODEL` vision path or any vision-model upgrade or procurement. The heavy visual reasoning is done for free by the agent that already runs the recipe.\n\n## Inputs\n\n- Run manifest: `{docs_dir}/idea-to-ticket/{slug}-{run_id}/run-manifest.json` (source of truth for `idea`, `scope`, `readiness`). Read whichever prior artifacts exist under `{docs_dir}/idea-to-ticket/{slug}-{run_id}/` (research pack, resolved uncertainties, goals-and-nfrs, standards checklist) and proceed without the ones that do not.\n- Output artifact (this step writes it): `{docs_dir}/idea-to-ticket/{slug}-{run_id}/comp-analysis.json` — the structured comp→codebase map the drafting step reads.\n\n## Callers\n\nThe steps below are the **recipe path** and are unchanged for the `idea-to-ticket` recipe.\n\n**Define-tickets path.** When `/define-tickets --auto` runs this procedure, the command names an exploration-adjacent artifact directory. Read the exploration document and any materials the task references instead of run-manifest artifacts, and write `comp-analysis.json` in that named directory. Assume no run manifest and no label. Apply the same gate, classification, and mapping rules. If the analysis is degraded for any reason, write `applicable: false`, a degradation `reason`, and `warnings` that identify the material needing manual review. When no qualifying comp exists, write the clean not-applicable artifact with no degradation warning. Degraded analysis never blocks the command.\n\n## Instructions\n\n1. **Gate first — evaluate only text/material metadata, never open an image yet.** Proceed to any image work ONLY when BOTH conditions hold:\n - a design comp is **referenced or attached** (a local image path in the idea/materials, or an already-attached Jira comp with an `attachment_id`), AND\n - the requested work is **design/UI work** (a frontend/fullstack change with a visual surface).\n\n This gate is deliberately conservative. A **backend-only** request, a **no-comp** request, or a **non-design** request fails the gate.\n\n2. **Not-applicable branch (gate fails) — short-circuit immediately.** When either gate condition is not met, write `comp-analysis.json` with `applicable: false`, a short `reason`, and the `gate` evidence fields, then **return immediately** — do NOT open any image, do NOT download any attachment, do NOT inject any fidelity/comp/visual language, and add no measurable latency. A backend-only or no-comp authoring input must be byte-for-byte unaffected downstream. Concretely, the not-applicable artifact is:\n\n ```json\n { \"applicable\": false, \"reason\": \"backend-only work; no design comp referenced\", \"gate\": { \"comp_referenced\": false, \"design_ui_work\": false }, \"warnings\": [] }\n ```\n\n3. **Applicable branch — obtain and OPEN the comp with your own vision.** When the gate passes:\n - **Local image path** → open it directly with the Read tool.\n - **Already-attached Jira comp** → fetch it as raw bytes using the BAPI-562 binary-safe `attachment` capability with operation `download`, passing the comp's `attachment_id` and a worktree `file_path`; the download saves the PNG/JPEG bytes to that `file_path` inside the project root, then open the saved file with the Read tool.\n - You are the orchestrating vision model — reason over the actual pixels yourself. Do NOT call `describe_image()`, do NOT use `src/python/llms/vision.py` / `CHEAP_MODEL`, and do NOT delegate perception to the text-only `jira-ticket-writer` subagent.\n\n4. **Degraded paths are skip-clean and warn-not-halt.** If the comp is missing, unreadable, an unsupported format, external-only (an `http(s)` URL you cannot fetch into a worktree `file_path`), or turns out not to be a usable design comp, write a valid `comp-analysis.json` with `applicable: false`, a `reason`, and a populated `warnings` array describing what failed, then return. A missing, unreadable, or non-comp image NEVER blocks downstream drafting and NEVER requires further image work after the failure.\n\n5. **Classify the opened comp using the shared fidelity taxonomy (do not fork it).** Using your own vision, classify the comp as exactly one of these four classes — the same labels the downstream final plan reviewer uses (`src/python/llms/agents/planner_agent/final_plan_review_agent.py`, `_get_runtime_verification_instructions`), so authoring, planning, and implementation all agree:\n - `full comp`\n - `wireframe`\n - `annotated-screenshot-of-existing-UI`\n - `unknown`\n\n Record `fidelity_classification` with a `class` (one of the four), a `confidence` value, and a short `reasoning` string.\n\n6. **Apply class-appropriate mapping depth — no over-specification.** Match the per-class rules exactly:\n - **full comp** (confident) → map exact existing components, Jinja2 templates, SCSS/CSS tokens, and routes; strict/exact component + token depth is used ONLY here.\n - **wireframe** → map layout and structure only (regions, order, rough proportions, responsive behavior); defer color, type, spacing, and component polish to the repo design system, NOT to the wireframe.\n - **annotated-screenshot-of-existing-UI** → map ONLY the delta against the current UI; preserve everything outside the annotated region and do not reproduce the screenshot wholesale.\n - **unknown / low confidence** → fall back to the design-system floor rather than mapping pixels.\n\n **Hard rule:** strict/exact mapping depth is enabled ONLY for a confidently-classified full comp. Fail toward the design system, never toward reproducing an ambiguous image.\n\n7. **Research the codebase and map each region/element to concrete existing code.** Inspect the working tree (search, grep, file reads) for the existing UI implementation surfaces: reusable components, Jinja2 templates, plain CSS/SCSS tokens and design-system styles, routes, and reusable frontend patterns. Only cite files you actually inspected — do not invent file paths, component names, tokens, or routes. For each region/element of the comp, produce a `mappings[]` entry containing:\n - `region` — the comp region or element name.\n - `visual_description` — a short description of what it looks like.\n - `components` — mapped existing component file(s).\n - `templates` — mapped existing Jinja2 template(s).\n - `tokens` — style/token references (SCSS/CSS tokens or design-system styles).\n - `routes` — route reference(s) where the element lives or should wire.\n - `confidence` — confidence for this mapping.\n - `implementation_guidance` — concrete guidance (e.g. \"reuse component X\", \"extend template Y\", \"use token Z\", \"wire route R\").\n\n8. **Write the structured map to a stable schema.** Write `comp-analysis.json` at `{docs_dir}/idea-to-ticket/{slug}-{run_id}/comp-analysis.json` with these fields:\n - `applicable` — boolean; `true` only after a comp was both detected AND successfully opened.\n - `reason` — short string explaining the applicability decision.\n - `gate` — the two-condition gate evidence (`comp_referenced`, `design_ui_work`).\n - `comp` — provenance of the opened comp (source kind, path or `attachment_id`, filename, MIME type when known).\n - `fidelity_classification` — `{ class, confidence, reasoning }`, present only when `applicable` is true.\n - `mappings` — array of the per-region entries defined in step 7 (present only when `applicable` is true).\n - `design_system_floor` — the design-system fallback guidance to use for wireframe/unknown/low-confidence regions.\n - `warnings` — array of degraded-path notes (may be empty).\n - `writer_guidance` — instructions for the downstream drafting step: when `applicable` is `true`, Requirements must cite the mapped components/templates/tokens/routes as concrete implementation guidance; when `applicable` is `false` or the map is missing, the writer must ignore this artifact and mention no comp analysis, design comp, or visual-fidelity language unless the original request independently requires it.\n\n9. **Never over-write.** Write the artifact exactly once at the path above. Downstream steps (`draft-and-critique.md`) read it; do not move it.\n\n## Return\n\nConfirm the path written (`{docs_dir}/idea-to-ticket/{slug}-{run_id}/comp-analysis.json`), whether the analysis was `applicable`, the fidelity `class` when applicable, and any `warnings`.\n",
|
|
11
11
|
".bridge/procedures/gather-and-attach-materials-procedure.md": "Post-create materials-completeness step. Gather the phase-eligible local materials a freshly-created ticket references and attach them via `attachment` (operations: `\"list\"`, `\"upload\"`, `\"delete\"`), while recording everything that is record-only. This is the POST-CREATE half of the upload-time materials-completeness pass (BAPI-423, phase-tagged since BAPI-643); the PRE-CREATE half — inventorying and writing the `## Materials & Access` section into the draft — already ran in the `jira-ticket-writer` agent.\n\n## Inputs\n\n- `{ticket_number}` — the real Jira key of the already-created ticket (e.g. `BAPI-423`). Attachment is a POST-CREATE step; never attempt to attach before the key exists.\n- `{draft_file_path}` — path to the draft markdown that carries the trailing `## Materials & Access` section.\n- `{auto_approve_external}` — the unattended-vs-interactive signal (named for consistency with `upload-and-track.md`). **Polarity is counter-intuitive: `\"true\"` means UNATTENDED, which is the MORE restrictive mode here** — skip all prompts AND keep external/auth-gated materials record-only (never auto-attach them). It does NOT grant permission to attach external materials. Any other value (including `\"false\"`, missing, or empty) means an interactive invocation that MAY prompt for external/auth-gated materials. Invocations from `write-ticket`, `idea-to-pr`, and `/define-tickets` (attended or `--auto`) are always unattended (`\"true\"`) for this step, so it never prompts there.\n\n## Instructions\n\n> **Orchestrator-directed step.** This agent task is authorized to call `attachment` (operations: `list`, `upload`, `delete`) and `update_ticket_description` and `config_field` as directed below.\n\nBefore selecting tool behavior, call `config_field` once with `operation: \"get\"` and `field_name: \"ticket_backend_mode\"`. Only a positively recognized `local` selects the local branch; absent, null, unreadable, and unrecognized results retain Jira behavior.\n\n**Local branch:** read the draft's `## Materials & Access` record and retain every phase-tagged material, its sanitized path/reference, and its access limitation in the ticket description. Use `update_ticket_description` only if a record needs preserving or updating. Skip every attachment `list`, `upload`, and `delete` operation, including deduplication and supersession. Report the retained materials under **Local-only records**. Distinguish intentional local records from missing-access warnings; warn the plan owner about each access limitation that affects implementation. Redact secrets using step 9. Return after recording this outcome.\n\n**Unsupported-mode backstop:** only a terminal HTTP `409` with error `UNSUPPORTED_IN_LOCAL_MODE` from an attachment operation selects the same local-only reporting outcome. Stop subsequent attachment operations and preserve the record as above. All other errors retain step 10's existing handling.\n\n1. **Read the record.** Read `{draft_file_path}` and parse its trailing `## Materials & Access` section. Collect the inventoried items grouped under *Planning Assets*, *Downloadable Assets*, *Planning & Downloadable Assets* (each phase-eligible; present only when a material of that phase exists), *External/Auth-Gated Links*, and *Binary/Image Materials (Record-Only)*. If there is no `## Materials & Access` section, there is nothing to gather — return a no-op success.\n\n2. **Canonical phase-token mapping.** Every phase-eligible bullet maps to exactly one filename token:\n - *Planning Assets* → `planasset`\n - *Downloadable Assets* → `implasset`\n - *Planning & Downloadable Assets* → `bothasset`\n\n *External/Auth-Gated Links* and *Binary/Image Materials (Record-Only)* are **never** phase-tagged and are behaviorally unchanged by this step — they stay record-only, exactly as before.\n\n3. **Source classification (scheme-based, no network probe).** Honor the classification already recorded in the draft:\n - **Planning Assets / Downloadable Assets / Planning & Downloadable Assets** — a local filesystem path that is **NOT tracked in version control** is a **low-risk** material eligible for auto-attach — proceed to step 5. The pre-create inventory already excluded version-controlled files (source code and in-repo docs are already available in the repository and are never attached — they are cited inline as *Relevant code*). As a safety net, this step must **never attach a file that is available in version control**: if any phase-tagged item is a code file or otherwise clearly version-controlled, skip it and treat it as record-only. A bullet under *Planning & Downloadable Assets* recorded via an existing `attachment_id` (not a local file — e.g. a design comp already attached on this or another ticket) is **not** re-uploaded by this step; leave it recorded with its `attachment_id`/path so a later implementation agent can download it into its worktree via the Jira attachment download capability.\n - **External/Auth-Gated Links** (every `http(s)` URI, even if explicitly linked) are **record-only** on unattended paths. If `{auto_approve_external}` is `\"true\"` (or the invocation is from `write-ticket` / `idea-to-pr`), leave them record-only and never auto-attach. (Mind the polarity: `auto_approve_external = \"true\"` means we are in unattended mode, so external materials must stay record-only — `\"true\"` is NOT permission to attach them.) Only an explicitly interactive invocation (`auto_approve_external` is any non-`\"true\"` value) may prompt the user to confirm before attaching.\n - **Binary/Image Materials (Record-Only)** — ordinary/unrelated binaries (arbitrary screenshots, PDFs, ZIPs, and other binaries not design-relevant) stay **record-only** in this step; never attempt to upload them.\n\n4. **Deduplicate and detect stale phase reclassification.** Call the `attachment` MCP tool with `operation` set to `\"list\"` and `ticket_number` set to `{ticket_number}` BEFORE uploading anything, so a resumed or re-run invocation does not re-attach a material that is already present.\n - Compute each candidate's deterministic filename first (step 6), then compare the listed attachments by **`{ticket_number}/{hash}`** (the ticket prefix plus the 8-hex-char hash segment) against the phase-tagged filenames already on the ticket, using the exact grammar `{ticket}-{planasset|implasset|bothasset}-{hash}{ext}` — this comparison spans all three phase tokens for the same source.\n - If a listed attachment shares the same `{ticket_number}/{hash}` as a candidate but carries a **different phase token**, treat it as a **stale classification for the same source** — the material was reclassified to a different phase since it was last gathered.\n - If a listed attachment's filename **exactly matches** the candidate's newly computed filename (same ticket, same phase token, same hash, same extension), it is already attached — skip re-uploading it.\n - Legacy `{ticket_number}-material-{hash}{ext}` attachments (pre-BAPI-643) are a distinct, valid, untouched naming form — never treat them as stale phase-tagged attachments, and never delete or supersede them here.\n\n5. **Supersede a stale phase-tagged attachment before uploading the reclassified filename.** When step 4 identifies a stale same-source attachment under a different phase token:\n - Call the `attachment` MCP tool with `operation` set to `\"delete\"`, `ticket_number` set to `{ticket_number}`, and `file_name` set to the stale attachment's exact filename. This is a genuine removal (not `replace_existing`, which only matches an upload's *own* filename) — the stale filename differs from the new filename whenever the phase token changed, so `replace_existing` alone cannot supersede it.\n - **If the delete call fails** (or reports `deleted: false` for a reason other than \"already absent\" — e.g. a transient Jira error), **skip the replacement upload for that material entirely** this run, preserving the one-active-attachment invariant rather than leaving two phase-tagged copies of the same source live at once. Record the failure (see step 9) and continue with the next material; never halt the run.\n - **If the delete succeeds** (or the stale attachment was already absent), proceed to upload the newly classified filename in step 7.\n\n6. **Gather and size-tier each phase-eligible local material; compute deterministic filenames.**\n - For each phase-eligible local **text** material:\n - Read the local file from disk.\n - If the content exceeds **200,000 characters**, SKIP the upload and RECORD it (note the path and that it was skipped for size) — do not attach it.\n - If the content is **<= 200,000 characters**, upload it RAW via `attachment` (operation: `\"upload\"`). Do NOT summarize locally: the backend already summarizes attached text at plan time, so the size tiers are backend behavior this step defers to. The agent performs NO local summarization.\n - **Extension rule by phase**: a **planning-only** (`planasset`) text material normalizes to `.md` regardless of its original extension — the planner only needs prose content, not the original format. A **downloadable or both-phase** (`implasset`/`bothasset`) text material instead **preserves its lowercased original source extension** (e.g. `.json`, `.csv`, `.py`, `.yml`/`.yaml`) — the implementing agent needs the file back in its original, directly usable format. There is no blanket \"all text becomes `.md`\" rule; the extension is phase-dependent.\n - Use a deterministic, sanitized filename of the form `{ticket_number}-{phase-token}-{hash}{ext}` (using the `{ticket_number}` input from the Inputs section and the phase token from step 2), where `{hash}` is the first 8 lowercase hex characters of the SHA-256 digest of the sanitized absolute source path, and `{ext}` follows the extension rule above.\n - For each eligible local design/UI comp image (or other phase-tagged image, extension mapping to an allowlisted MIME type — `image/png`, `image/jpeg`, `image/webp`, `image/gif`), eligible for the allowlist-guarded binary upload path (distinct from the text upload path above):\n - Use a deterministic filename of the form `{ticket_number}-{phase-token}-{hash}{ext}`, where `{hash}` is computed the same way (first 8 lowercase hex characters of the SHA-256 digest of the sanitized absolute source path) and `{ext}` is the lowercased allowlisted source extension (`.png`, `.jpg`, `.jpeg`, `.webp`, `.gif`) — the existing image-extension behavior is unchanged by phase.\n - Pin the hash algorithm exactly (SHA-256, first 8 lowercase hex chars, of the sanitized absolute path) — do NOT substitute another hash — so the same source always maps to the same `{ticket}/{hash}` identity and the dedup/stale-detection in step 4 works across separate sessions, re-runs, and phase reclassification. Compute filenames before the step 4 dedup/stale comparison is applied. Keep the sanitized source provenance inside the text attachment body (not applicable to binary comp uploads), not only in the filename.\n\n7. **`attachment` upload parameter discipline (Zod).**\n - For text materials, call `attachment` with `operation: \"upload\"`, `ticket_number`, the deterministic phase-tagged attachment filename, and the text `content`.\n - For design comp image uploads, call `attachment` with `operation: \"upload\"`, `ticket_number`, `file_path` (the local source path), and `file_name` set to the deterministic phase-tagged comp filename from step 6 — pass `file_path` rather than reading and UTF-8-encoding the bytes yourself, so `resolveUploadAttachment()` performs binary detection, the MIME allowlist check, and base64 encoding. Never UTF-8-encode image bytes locally.\n - In both cases, OMIT the optional parameters `link_type` and `replace_existing` entirely when they are unused — do NOT pass `null` or empty strings for them. The Zod schemas reject `null`/empty values, so an unused optional parameter must be omitted rather than nulled.\n\n8. **Persist destination provenance after successful uploads (one batched update).** For every material successfully uploaded in this run, record a stable, sanitized mapping from its generated Jira filename to the bullet's original repository-relative destination path (as recorded in the draft's `## Materials & Access` section). Write these mappings as bulleted lines under a dedicated trailing `### Asset Destinations` subsection of `## Materials & Access`, one line per mapping, in the exact form:\n ```markdown\n ### Asset Destinations\n\n - `{jira-filename}` → `{original/repo/relative/destination.ext}`\n ```\n This is the canonical, machine-parsed contract consumed by `extract_asset_destination_paths()` (`api/agent_flows/code_writer/library/ticket_asset_lib.py`) — do not vary the arrow character (`→`), the backtick wrapping, or the bullet form. Append new mappings to this subsection (creating it if absent) rather than replacing prior mappings from earlier gather runs. Apply **all** of this run's successful-upload provenance updates in **one single batched call** to `update_ticket_description` — never one Jira description update per asset. If the provenance update call fails, **retain the original bullet unchanged** in the ticket description and record a non-blocking warning that the destination mapping could not be persisted; this does not fail the run, and the filename token itself is still enough for plan generation to classify the asset even without a fully actionable destination.\n\n9. **Redact secrets everywhere.** Before writing any URL or access note ANYWHERE — the Jira `## Materials & Access` record, any warning or final-report output, and any local intermediate file — sanitize and redact embedded credentials, SAS tokens, API keys, and basic-auth secrets using a high-visibility placeholder such as `[REDACTED_TOKEN]`. Mirror the backend `_redact_forge_fields()` / `_sanitize_jira_error_message()` patterns. A location/access note must never expose a plaintext secret.\n\n10. **Warn, never halt (error handling).** This step must NEVER halt, prompt-to-fail, or fail the overarching command because a material could not be gathered, attached, or superseded. Follow the warn-not-halt convention:\n - If an `attachment` upload call fails (or a file disappeared between inventory and upload), warn gracefully and continue with the next material.\n - If a stale-attachment `delete` call fails, skip only that material's replacement upload (step 5) and continue with the rest — never halt the run.\n - This includes design comp image uploads: an unsupported/disallowed MIME type, an oversize image (`> 10 MB`), a missing local file, a malformed upload payload, or a Jira upload failure must all be warned and skipped, never halting the run.\n - On such a post-create attach/delete failure, call `update_ticket_description` to record the failure in the issue's `## Materials & Access` record (the material became unavailable, or its stale copy could not be superseded, only after the issue existed). `update_ticket_description` is an existing MCP tool, not a backend change.\n - Everything knowable PRE-CREATE was already written into the description at create time, so `update_ticket_description` is reserved for these rarer post-create attach/delete/provenance failures. This complements the existing `partial_success` recording convention in `upload-and-track.md`.\n - Apply the step 9 redaction to every warning and recorded note.\n\n## Return\n\nConfirm the outcome, reporting each category **by its user-facing phase name and original path** (not by the internal filename token, which is implementation metadata): which Planning Assets, Downloadable Assets, and Planning & Downloadable Assets were attached (noting their deterministic Jira filenames for cross-reference only), which stale phase-tagged attachments were superseded (and which supersession attempts failed and were skipped), which materials were skipped/recorded as record-only (over-size text, external/auth-gated links, ordinary/unrelated binaries, or non-local design references), whether the destination-provenance batched update succeeded, any attach/delete/provenance failures recorded via `update_ticket_description`, and that no failure halted the run.\n",
|
|
12
|
-
".bridge/procedures/define-tickets-epic-handoff-procedure.md": "# `/define-tickets` epic hand-off procedure\n\nThis procedure carries the epic-only parts of `/define-tickets` Stage 9. The command\nreads it once per run, after it has frozen a split of three or more slices, and then\nfollows one section of it at each epic-only pointer in Stage 9. Do not run every\nsection right after loading it. Each section uses the working state the command\nalready holds: the frozen manifest, the exploration document, the drafting plan, and\nthe run mode. Sections that mention \"the command\" mean `/define-tickets`. Nothing in\nthis file changes the command-owned steps: the split rules, the `--max-children`\ncap, the writer fan-out, the upload gate, Handling changes, creation, tracking, the\nmaterials pass, and the Final Report all stay in the command.\n\n## Step 2 — Epic gap check (frozen manifest)\n\n**For an epic, check the frozen manifest before any writer runs.** This runs only for an epic, after the split is frozen and before drafting:\n\n1. Write the frozen manifest as JSON to `{docs_dir}/epic-plans/{slug}/epic-manifest.json`, the same directory step 4 of this procedure uses for `epic-plan.dag.json`. It holds the arrays in the input field names `review-epic-coherence.md` defines. `manifest` is the complete, ordered child list (`id` as the 1-based position, `title`, `scope`, `size_band`, `depends_on`, `recommended_after`, `touched_files` from the design's file list — the files the child edits or creates — `read_files` for files it only reads, when known, and `owns_verifications`). `child_evidence` has one entry per child with its planned acceptance criteria: the ratified criteria text the child satisfies plus each of its `owns_verifications` obligations word for word. `non_child_owners`, when the epic has any, sits beside `manifest` and `child_evidence`.\n2. Write the review input to `{docs_dir}/epic-plans/{slug}/epic-coherence-input.json`. `epic` carries the `slug`, the epic title, and the ratified acceptance criteria from the exploration doc, each with its `id`, its text, and its verification sentence. `design_text` is the doc's `## Goals & NFRs` section, verbatim, followed by its `## Proposed Design`; the reviewer checks the split against the NFRs as well as the criteria. `manifest`, `child_evidence`, and `non_child_owners` (when present) are copied unchanged from `epic-manifest.json`.\n3. **Apply the recorded gap-check policy.** An attended run asks no gap-check question: Stage 6 already recorded `drafting_plan.gap_check_policy`, and this step executes it before any writer runs. It also asks no council question: the Stage 6 plan already decided that, and no further split-review question is needed.\n - **Epic, `run_if_epic`.** Run the procedure as described next, in `drafting` mode, attended.\n - **Epic, `skip`.** Run no reviewer. Write a skip record to `{docs_dir}/epic-plans/{slug}/epic-coherence.json`: `schema_version` `3`, verdict `not_checked`, `skipped_by_operator: true`, `rounds: []`, the three current digests computed from `epic-manifest.json`, an empty coverage map, and one override of kind `bypass` with reason `Operator chose to skip the gap check` and `accepted_by: \"operator\"`. Then go on to drafting.\n - **Siblings.** Run no epic reviewer, write no coherence record, show no extra outline line, and ask no extra prompt. The conditional policy stays recorded in the plan.\n\n Follow `review-epic-coherence.md` in `drafting` mode, attended, with that input path and `{docs_dir}/epic-plans/{slug}/` as the output directory. Pass `council_preapproval` with `value` set to the legacy `council_choice` recorded from the drafting plan (`approved` for `before` and `after`, `declined` for `none`) and `source` set to the exact string `define-tickets council answer`, so the procedure asks no council question of its own. Also pass `auto_amend: true`: the procedure fixes gaps by amending the manifest within its existing round and confirmation bounds, with no question, and any foundation gap still left after the bound goes to the upload gate with an agent-drafted reason instead of a question. It computes `manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`, applies its risk-scaled round limit, and writes `epic-coherence.json` and `epic-coherence.md` there. Read the coherence procedure through the command-owned lookup in `/define-tickets` Stage 9 (the paragraph headed \"Coherence procedure lookup\"), which keeps the installed, legacy `docs/install/`, and checkout locations in order, the unreadable-file failure rule, and the repair guidance. Never improvise a substitute review.\n\n**Only under --auto:** the coherence run is unattended. Execute the recommended plan recorded in Stage 6, which always includes the gap check for an epic. Pass the literal `auto_approve_external = \"true\"` and no `council_preapproval`, never write a skip record, and use the procedure's bounded amend-and-recheck behavior instead of the operator-directed fix loop below. It clears only with no foundation blockers and every ticket-local blocker carried; it halts as `epic_coherence` with verdict `blocked` when foundation blockers remain after the bound or non-convergence. Clearance is independent: `independent: false` fails even on `pass`, `not_checked` fails, and an attended-only bypass or accept cannot clear an auto run. Halt before any writer or `create_ticket` on `blocked`, `not_checked`, `independent: false`, an unresolved required council, or any other non-clearing record. Name the specific cause in prose and halt as `epic_coherence` with the record path and a `coherence_verdict` of only `blocked` or `not_checked`. If the procedure is unavailable or cannot be invoked, halt as `stage_failed` naming Stage 9; never fabricate a coherence result. Siblings keep their no-coherence path. For an epic, skip the pending-acceptance list, the upload gate, and its reply parsing in the command's Stage 9 step 3: drafting and creation proceed only once the record clears, with no prompt. For siblings, skip the upload gate and its reply parsing in the command's Stage 9 step 3: creation proceeds with no prompt once every auto gate and draft-completeness requirement has cleared.\n\n**Resolve the result at the gate.** Every remaining **foundation** blocking finding (a gap in how the work is split) must be fixed or accepted before creation. Ticket-local blockers are carried into their child ticket, shown as \"a note added to ticket N\", and do not require acceptance at this epic gate. There is no separate fix-or-accept question: the upload gate below is the one surface that resolves foundation findings (the upload gate in the command's Stage 9 step 3). Use the plain words in \"What the user sees\" in `review-epic-coherence.md` for everything the user reads; the record keeps its technical values.\n- **Fixed automatically.** Under `auto_amend: true`, the procedure amends the manifest between rounds within its existing bounds, with no question. Each amendment re-freezes it: rewrite `epic-manifest.json` and the input before the next round.\n- **Change how the tickets are split** (fix) — only when the user explicitly asks for it by replying \"change something\" at the command's upload gate. Amend the manifest (add or rescope a child, or reassign an obligation). That re-freezes it: rewrite `epic-manifest.json` and the input, re-run the check within the existing bounds, redraft the affected entries as described under Handling changes in the command's Stage 9 step 3, and return to the updated upload gate. The budget is one operator-directed fix plus one additional whole-manifest confirmation pass, counted across every coherence-check re-run in the same attended define-tickets run. A fix made after the procedure's last allowed round gets its one confirmation pass, so the record's last round still bears the final digests. Once the budget is spent, only accept or `blocked` remain.\n- **Create anyway, and record the gap on the epic** (accept) — the default for every foundation gap still left after the bound. The reason is agent-drafted, non-empty, and shown on the upload gate. Record it in `epic-coherence.json` as an override of kind `accept` with the `finding_id`, the `reason`, `accepted_by`, and the `round`. When every remaining foundation blocking finding is accepted, the verdict is `accepted_with_gaps`.\n- A finding that is declined, or left without a reason, keeps the verdict `blocked` and keeps creation blocked.\n- **Couldn't check** (reviewer unavailable) — say \"Couldn't check\" and offer to try again or to create without it. Creating without it needs a reason the operator types, recorded as an override of kind `bypass`. The internal verdict stays `not_checked`. Never show or treat it as a pass. This exception stays outside the ordinary upload gate. It fails closed: retries are operator-initiated, and neither creation preflight clears it without the recorded typed bypass.\n\n**Enforce ticket scope after amendments (attended only).** Re-check the implementation-ticket count against `ticket_scope` after every coherence amendment or operator-requested split change, before any writer or ticket creation. If the count differs, use the Stage 8 scope-change agreement and implications checkpoint before proceeding; rebuild and revalidate the frozen split and any affected coherence record, and regenerate any affected drafts. Count only children or ordinary tickets; show an epic parent as additional. The upload approval never substitutes for agreement to a changed count. This does not add an attended scope gate under `--auto`.\n\n## Step 3 — Record check and full clearance\n\n**Check the record before any writer.** For an epic, the coherence record is validated before drafting, but attended pre-writer validation is narrower than full clearance. Attended pre-writer validation checks frozen-entry identity, sizing, readable recognized records, all three current digests, last-round identity or the existing attended exceptions, finding scopes, child references, carry completeness, confirmation budgets, and required-council resolution. The single attended exception: the only uncleared items may be foundation gaps that are each listed individually under `Known gaps that will be recorded on the epic`. Keep each proposed acceptance in working state, bound to its finding id, its exact non-empty agent-drafted reason, its round, and the manifest and evidence identities. Do not persist it as an operator acceptance before approval. Under `--auto`, full clearance applies before any writer, exactly as below.\n\n**Full clearance, before the first `create_ticket` call (and before any writer under `--auto`).** Refuse to create an epic unless all of these hold, with actual persisted acceptances for every remaining foundation blocker:\n- `epic-coherence.json` exists in `{docs_dir}/epic-plans/{slug}/` and is readable;\n- its `schema_version` is `1`, `2`, or `3`; legacy blocking findings are foundation findings. For version `3`, validate scope, child references, carry completeness, confirmation budget, and the foundation-only verdict before any writer call;\n- its `manifest_sha256` matches the frozen manifest shown at the gate, its `child_evidence_sha256` matches the current child evidence, **and** its `non_child_owners_sha256` matches the current non-child owners, all computed from `epic-manifest.json` with the encoding `review-epic-coherence.md` specifies (an absent array hashes as an empty array; a version `1` record without the third digest matches only when there are no non-child owners);\n- its `rounds` array is non-empty and its top-level digests equal its last round's digests. The only exception is an attended record with `amended_after_final_round: true`, a typed `bypass` override, and verdict `not_checked`, whose top-level digests still match the current input. A second exception is the attended skip record: `skipped_by_operator: true`, an empty `rounds` array, verdict `not_checked`, a `bypass` override with a non-empty reason, and top-level digests that match the current input;\n- no required council is left `still_running`, `failed`, or `timed_out` unless an attended `accept` override with a typed reason names its `council_id`;\n- its verdict is `pass`, including a version 3 record with carried ticket-local blockers, or `accepted_with_gaps` with every remaining foundation blocking finding accepted with a non-empty reason, or `not_checked` with a recorded override of kind `bypass` carrying a non-empty reason.\n\nFor a skip record, the parent writer's coverage map is derived from manifest ownership, and the parent's `## Epic coverage map` is built from the manifest's `owns_verifications` and `non_child_owners`, and says plainly that the gap check was skipped by the operator.\n\nA council outcome of `declined_by_operator` is resolved and needs no `accept` override, whether it was declined at the pre-round-1 ask or through legacy `council_preapproval: declined`. A legacy `accept` override targeting `council: \"declined_by_operator\"` remains valid but is ignored for clearance.\n\nThe displayed reasons and override targets must stay unchanged between approval and creation. If either changed, show the gate again rather than treating the earlier reply as authorization. Unknown record fields are ignored and never authorize anything. A missing or unreadable record, an unrecognized schema version, a digest mismatch, top-level digests that differ from the last round's, an unresolved required council, `blocked`, or an un-bypassed `not_checked` stops here: report which one, and create nothing. This is the same rule as the epic coherence preflight in `render-ticket-manifest.md`, which holds its canonical wording; this command adds only the attended pre-writer timing exception above, and the canonical instruction is unchanged. This command does not route through that instruction, so the rule is stated here too.\n\n## Step 3 — Epic outline items 1–3\n\nThese three lines come first in an epic's plan outline. The command's outline then\ncontinues with its own items 4 through 9.\n\n1. **Gap check** (epic only, first) — the outcome in plain words: `No gaps found` (or `No gaps found (N notes added to tickets)` when ticket-local findings are carried), `Accepted with known gaps`, `Needs your decision`, `Skipped, your choice`, or `Couldn't check`. When the initial council was declined, add the information line `Council: skipped, your choice`. That line is not a warning, not an unresolved item, and not something to accept.\n2. **Independence and notes** (epic only) — when the record says `independent: false`, say: this check ran in my own session, not by a separate reviewer, so it's less independent. List each carried ticket-local finding as \"a note added to ticket N\" with a short summary. An attended operator may discuss or fix a carried finding.\n3. **Who covers each requirement** (epic only) — one plain bullet per epic AC: the AC id, the owning child (or, for an owner-run owner, \"owner-run\" with the person or role and the step reference), then the obligation that proves it.\n\n## Step 3 — Known gaps (epic only)\n\n**Known gaps (epic only).** After the outline, list under `Known gaps that will be recorded on the epic` each foundation gap still left after the automatic fixes. For each, give a plain-language description of what is wrong and the non-empty, agent-drafted reason that would be recorded, so the operator reads it before approving. This is a list, not a question: there are no per-gap options. A \"yes\" at the upload question records them; \"change something\" lets the operator ask for a split change instead. A declined initial council is not a gap and is never an acceptance target. An unfinished required council (`still_running`, `failed`, or `timed_out`) is shown as its own unresolved item.\n\n## Step 4 — Write the plan DAG\n\nIn local mode, retain every confirmed minted epic/child key in the manifest immediately and emit neither plan file while a required key is missing or creation is uncertain; use those real keys rather than `TBD-N` placeholders. After an epic's tickets are created, write the Epic Implementer's plan sidecar to `{docs_dir}/epic-plans/{slug}/epic-plan.dag.json`. You already hold everything it needs: the frozen manifest carries each child's `depends_on`, and Stage 8's design named the files each slice touches. Nothing downstream derives this from an epic key, so if you skip it the handoff dead-ends. The epic-body manifest uses the same child order and hard `depends_on` relationships as `epic-plan.dag.json`.\n\n```json\n{\n \"plan_version\": 1,\n \"nodes\": [\n {\n \"ticket_key\": \"KEY-2\",\n \"status\": \"planned\",\n \"depends_on\": [],\n \"touched_files\": [\"src/example/service.py\", \"src/example/handler.py\"]\n }\n ],\n \"edges\": []\n}\n```\n\nOne node per child, in manifest order, using the **real** keys just created — never a `TBD-N` placeholder, since the tickets already exist. `depends_on` carries the manifest's hard prerequisites only; leave `recommended_after` out, because soft sequencing is not a dependency and encoding it there serializes work that could run in parallel. `edges` may be `[]` when `depends_on` already expresses the graph. The graph must be acyclic and every `depends_on` entry must name a node in the file.\n\nPopulate `touched_files` on every node from the design's file list, as repository-relative POSIX paths — concrete files only, never a directory or a glob. It is what lets the Epic Implementer serialize two children that would otherwise collide, and it matters more the larger the slices are. An omitted list is accepted by the server as an explicit opt-out, so leaving it off does not fail — it silently turns plan-time overlap protection off. Use `[]` only when a ticket genuinely touches no repository files. Which overlaps get an ordering edge is decided by the server, not by you: on runs created from a repository with a confirmed gate profile, only children whose files both fall under one of the repository's must-order paths (for example a migrations directory, declared in the gate profile and confirmed by the owner) are ordered, and ordinary shared files run in parallel and are resolved at merge time. Do not add `depends_on` entries just because two children share an ordinary file.\n\nThen write the plan's epic key beside it, at `{docs_dir}/epic-plans/{slug}/epic-plan.meta.json`, holding exactly:\n\n```json\n{\"epic_key\": \"<EPIC-KEY>\"}\n```\n\nUse the real epic key just created. This path runs no `finalize` step, so it writes the file itself. It is how `drive-epic` finds this epic's plan without being handed a path.\n\nInclude the files that are easy to forget, because those are the ones that actually collided: **anticipated tests, fixtures, golden files, guard allowlists, and policy files**, not only the production modules. Both known misses were exactly this class — two children shared `ticket_type_evaluator.py` *and its test*, and another pair shared golden files and a `save_repo_to_db` test — and in each case nobody predicted the shared file, so no ordering edge was synthesized and both PRs merged over each other. Paths are compared as exact strings after normalization, so name concrete files: a directory or a glob matches nothing.\n\n**Save the plan to the Bridge server.** After `epic-plan.meta.json` is written, and after `epic-coherence.json` from the gap check, save the plan so anyone with access to the repository can run the epic with no local plan folder. Resolve the trusted launcher prefix once, quote each argument on its own, and run:\n\n```bash\n<launcher> epic-plan save --epic-key '<EPIC-KEY>' --plan-dir '{docs_dir}/epic-plans/{slug}' --json\n```\n\nIt saves the DAG, the eligibility advisory, and the gap-check record together, and prints the server's `authored_version`. Saving an unchanged plan again reuses the stored version. The local files stay as a readable copy. A failed save is a **warning, not a failure**: the tickets already exist and stay created, so never report `create_failed` for it. Report the epic and the exact `retry_command` the command printed, and continue.\n\n## Step 5 — Hand off once\n\nPresent these sections in order:\n\n- **Plan/tickets saved** — confirm the epic, real child keys, and saved DAG/metadata. Name the server copy: `Plan saved on the Bridge server as authored version <N>`, or, when the save failed, `Plan NOT saved on the Bridge server` with the epic and the exact retry command. Saved work remains successful even when launch readiness is refused or unconfirmed, and even when the server save failed.\n- **Readiness preview** — only when the concrete epic key, finalized child keys, `epic-plan.dag.json`, and `epic-plan.meta.json` exist and you recommend launch, use the Completion advisory section at the end of this procedure. Resolve the trusted multiword launcher prefix once, quote dynamic arguments independently, and run `drive-epic '<EPIC>' --dry-run --json` at most once with a 60-second command timeout/cancellation. Parse valid authoritative JSON regardless of exit status. Render selected target, returned reason/remedy, and any `availability_text` verbatim; retain conditional cold-start distinctions. State **ready at preview time**, refusal, or **readiness not confirmed**, never an execution guarantee. If the bounded seam or preview is unavailable, offer the same command for a later user-initiated retry and continue the saved-work report. No automatic rerun on later turns, no second readiness call, and no create/start/approve/provision/index/schedule action.\n- **Launch next step** — point at exactly one launch, by host, conditional on the preview result. Ticket creation does not establish executor, policy, VCS, or indexing readiness. Missing keys, unresolved `TBD-N` entries, or unfinished artifacts receive neutral finalization guidance without probing a nonexistent epic. Ordinary ticket-definition and sibling/lone-ticket requests require no completion readiness call.\n\nPreserve these canonical host routes:\n\n- **Claude Code or Cursor:** `/drive-epic-run {EPIC-KEY}`\n- **Codex or Copilot:** `npx -y @bridge_gpt/mcp-server drive-epic {EPIC-KEY}`\n\nBoth launch through `drive-epic`, and both find the plan through `epic-plan.meta.json`. **The one command both creates and drives the run:** `/drive-epic-run` previews the launch, asks for an explicit yes, creates the run through `drive-epic`, starts its executor, and then drives it. On Codex or Copilot, `drive-epic` creates the run and starts its executor, and the first-run steps are in `docs/install/epic-implementer-install.md` (write or refresh it with `npx -y @bridge_gpt/mcp-server install`).\n\nWith no target flag, `drive-epic` targets production and uses this repository's stored Bridge credential, so no `BAPI_BASE_URL` export or temporary notification terminal is needed when the authoritative preview confirms readiness. A fresh project may still have the returned unmet requirements; planning success does not remove them. For a local or other non-production target, `drive-epic --help-advanced` lists the owner options. A conflicting target, or a stored key approved for a different server, refuses before any authenticated request.\n\n`drive-epic` defaults to the unattended posture. Escalations go to the account's email address; a `--policy-file` is needed only when the account has no email for escalations. Pass `--attended` to opt out of the unattended default. `drive-epic` reads Epic Implementer readiness and selects the runnable path itself. Do not name an underlying launch path, and never present a choice between two of them — two transition authorities on one epic is the failure this single entry point exists to remove. A sibling pair or a lone ticket gets no Epic Implementer handoff at all.\n\n**Only under --auto:** render this handoff as a report line and never invoke it.\n\nEvery unattended epic-branch run so far has needed operator recoveries within minutes of a trigger, and the reconciler never applies them. That is why the one command both creates and drives the run: the session that launched it stays to apply the sanctioned recovery verbs.\n\n## Completion advisory — saved epic plans and tickets\n\nThis pattern is for a completion handoff that recommends launch, outside\n`/drive-epic-run`'s Stage 0. It is read-only and adds no mandatory launch gate.\n\nEligibility requires a concrete epic key, finalized real child keys (no `TBD-N`),\nand the actual `epic-plan.dag.json` and `epic-plan.meta.json` artifacts. Free-form\nplans, missing keys, and unfinished artifacts receive boundary guidance only.\nRun at most one eligible preview per completion; do not automatically rerun it on\nlater turns of that completion. Ordinary ticket definition needs no preview.\n\nResolve `<launcher>` once using `/drive-epic-run` Stage 0 operation 3's trusted\ncommand-prefix convention. Preserve multiword prefixes such as\n`node /absolute/path/to/mcp_server/build/index.js`; never quote the entire prefix\nas one executable. Independently escape and single-quote every dynamic argument:\n\n```bash\n<launcher> drive-epic '<EPIC>' --dry-run --json\n```\n\nRetain `--plan-file '<path>'` only when actual plan selection requires it. Use the\nhost's command timeout seam to impose a **60-second** wall-clock limit and cancel\nthe read-only child where supported. If bounded execution is unavailable, report\n**readiness not confirmed** without starting an unbounded operation.\n\nParse authoritative JSON regardless of exit status, including nonzero refusals.\nValidate it using `/drive-epic-run` Stage 0 operation 4's existing schema and\ncontradictions checks.\nReport the selected `target.kind` and `target.base_url`; render `refusal.reason_id`\nand `refusal.remedy` verbatim, falling back to `readiness.reason_id` and\n`readiness.remedy` when refusal is null. Relay any supplied `availability_text`\nverbatim without substituting generic VCS/indexing advice. A `stop` decision\nreports the returned plan status/candidates and finalization remedy. Never invent\nfields or an independent readiness rule.\n\nAn ordinary successful `create` or `attach` preview is **ready at preview time**.\nA `cold_start` create is conditional: `summary.server_validation` is partial, and\nguarded startup and live validation must still succeed. A generated-plan cold\nstart (`cold_start.live_run_checked` is `true`) confirmed no live run during\ngeneration; any other cold start did not check live-run existence. It is never a promise of launch readiness. Malformed, unavailable,\nthrowing, or timed-out previews mean **readiness not confirmed**. Retain planning\nsuccess and offer the same preview command for a later user-initiated retry.\n\nPresent **Plan/tickets saved → Readiness preview → Launch next step**. Planning\nand ticket creation establish neither executor, policy, VCS, nor indexing\nreadiness. Reproduce only actual unmet dependencies and returned remedies.\nNever create, start, approve, provision, index, or schedule anything from this\nadvisory. Preserve actual launch consent and `drive-epic` admission; do not invoke\n`/drive-epic-run` Stage 0's launch, health check, or second advisory-read\noperations here.\n\n## Return\n\nThis procedure returns nothing on its own. After each section, go back to the\n`/define-tickets` Stage 9 pointer that sent you here and continue from that point.\nReport the outcome of the section you just followed in the command's own terms: the\ngap-check outcome and record path, the clearance result, the saved DAG and metadata\npaths, or the hand-off sections shown. A halt keeps the command's halt reason and\nterminal contract; this procedure adds no halt reason and no terminal field.\n",
|
|
12
|
+
".bridge/procedures/define-tickets-epic-handoff-procedure.md": "# `/define-tickets` epic hand-off procedure\n\nThis procedure carries the epic-only parts of `/define-tickets` Stage 9. The command\nreads it once per run, after it has frozen an epic split (the command's own epic\ntrigger decides this, and an E1 contractual epic may have fewer than three children), and then\nfollows one section of it at each epic-only pointer in Stage 9. Do not run every\nsection right after loading it. Each section uses the working state the command\nalready holds: the frozen manifest, the exploration document, the drafting plan, and\nthe run mode. Sections that mention \"the command\" mean `/define-tickets`. Nothing in\nthis file changes the command-owned steps: the split rules, the `--max-children`\ncap, the writer fan-out, the upload gate, Handling changes, creation, tracking, the\nmaterials pass, and the Final Report all stay in the command.\n\n## Step 2 — Epic gap check (frozen manifest)\n\n**For an epic, check the frozen manifest before any writer runs.** This runs only for an epic, after the split is frozen and before drafting. The order is fixed: freeze → structural check → fresh whole-manifest review → agent settlement (Step 2b) → when settlement amended the manifest, re-freeze, structural check, and the next whole-manifest review → writers → draft check (`check-drafts`) → upload gate.\n\n1. Write the frozen manifest as JSON to `{docs_dir}/epic-plans/{slug}/epic-manifest.json`, the same directory step 4 of this procedure uses for `epic-plan.dag.json`. It holds the arrays in the input field names `review-epic-coherence.md` defines. `manifest` is the complete, ordered child list (`id` as the 1-based position, `title`, `scope`, `size_band`, `depends_on`, `recommended_after`, `touched_files` from the design's file list — the files the child edits or creates — `read_files` for files it only reads, when known, `owns_verifications`, and `handoff_roles`). Write the hand-off grid as `handoff_roles` on each child: one `{thing, role}` entry for every role the child plays for a value passed between children, with a stable `thing` id (`H-1`, `H-2`, …) shared by every child that touches that value, and a `role` from `write`, `read`, `caller`, `start`, `steady_state`, `wind_down`, and `consumer`. Every read or consumed thing needs a child holding `write` and a child holding `caller`, and a thing two children share needs `write`, `read`, and `caller` owners. Mark the child that owns the end-to-end test of the cross-child flow with `e2e: true` on the `owns_verifications` entry carrying that test, with the concrete test as its obligation. Only a child owns it, never a `non_child_owners` entry. `child_evidence` has one entry per child with its planned acceptance criteria: the ratified criteria text the child satisfies plus each of its `owns_verifications` obligations word for word. `non_child_owners`, when the epic has any, sits beside `manifest` and `child_evidence`.\n2. Write the review input to `{docs_dir}/epic-plans/{slug}/epic-coherence-input.json`. `epic` carries the `slug`, the epic title, and the ratified acceptance criteria from the exploration doc, each with its `id`, its text, and its verification sentence. `design_text` is the doc's `## Goals & NFRs` section, verbatim, followed by its `## Proposed Design`; the reviewer checks the split against the NFRs as well as the criteria. When the design passes no value between children, append one line starting `no_cross_child_flow:` with the reason. `manifest`, `child_evidence`, and `non_child_owners` (when present) are copied unchanged from `epic-manifest.json`.\n\n **Design-council evidence (attended only).** When the command's `design_council_evidence` working state records a design council that **completed** in Stage 7 or Stage 8 (see \"Record the design-council evidence\" in those stages), also write it as the optional top-level `design_council`: `council_id` and `design_revision` copied from that working state, `split_reviewed` (`true` only when the recorded council was the Stage 8 after-design council whose task text held these same sized slices), and `materiality`, with exactly the keys `requirements`, `interfaces_or_contracts`, `ownership`, `dependencies`, `end_to_end_proof`, and `blast_radius`. For each key, compare the frozen split with what that council reviewed and write `\"unchanged\"` only when the split did not materially change it; otherwise write a short note saying what changed. When you are unsure, write a note. When no council completed, a second opinion ran instead, or the council failed or timed out, omit `design_council` entirely: never manufacture evidence to earn a skip. `design_council` sits outside every digest; the high-risk trigger in `review-epic-coherence.md` reads it with the same names. Under `--auto`, write no `design_council`.\n3. **Run the structural check.** Refresh blast-radius evidence first. Every re-freeze follows one shared sequence: rewrite the manifest and the input, refresh and write `blast-radius.json` as the blast-radius procedure describes, run the structural check, and only then run the next fresh whole-manifest review. When an amendment only moves already-discovered files between children, refresh dispositions only. When it adds new symbols, literals, contracts, or trap triggers, run incremental discovery for them and merge the results into the existing rows, keeping earlier rows and their discovery reasons unless a recorded correction explains a removal. Rebuild each affected child's research packet from the refreshed rows before its writer runs. Resolve the trusted launcher prefix once and run:\n\n ```bash\n <launcher> epic-coherence-input check --structural '{docs_dir}/epic-plans/{slug}/epic-coherence-input.json'\n ```\n\n Run it before round 1 and again after **every** re-freeze, before the next review. Fix every error you can in the manifest or the input first (add a missing role or owner, name the e2e owner, correct an id or a dependency, or give a file a child or a specific unaffected reason) and re-freeze with the shared sequence above. Then route what remains:\n - **Ownership errors you cannot fix.** Only `unclaimed_epic_ac` and `missing_e2e_owner` may stay, and only when no child can own the requirement or the end-to-end test (for example, the pinned children of an E1 contract cannot own an epic AC). Attended, keep the error as a blocker, continue to the whole-manifest review, and take it to Step 2b as a `needs-owner` item. It stays a creation blocker whatever the reviewer's verdict says. Never give it a nominal owner and never weaken an obligation to make the check pass.\n - **Every other structural error** (`handoff_missing_role`, `handoff_missing_write_or_caller`, `malformed_handoff_role`, `malformed_e2e_marker`, `non_child_e2e_owner`, `no_cross_child_declaration`, `no_cross_child_flow_contradicted`, `depends_on_unknown_child`, `depends_on_self`, `depends_on_cycle`, `recommended_after_unknown_child`, `recommended_after_self`, `malformed_design_council`, any `blast_radius_*` error, and any shape or file error) must be corrected before any writer runs. It is never accepted and never deferred. If an attended run cannot correct it, stop before any writer, create nothing, and report the error with the local artifacts.\n - **Only under --auto:** any structural error that remains after your corrections halts as `stage_failed` naming Stage 9 before any writer, with the error codes in the reason. This adds no halt reason and no terminal field.\n4. **Apply the recorded gap-check policy.** An attended run asks no gap-check question: Stage 6 already recorded `drafting_plan.gap_check_policy`, and this step executes it before any writer runs. It also asks no council question: the Stage 6 plan already decided that, and no further split-review question is needed.\n - **Epic, `run_if_epic`.** Run the procedure as described next, in `drafting` mode, attended.\n - **Epic, `skip`.** Run no reviewer. Write a skip record to `{docs_dir}/epic-plans/{slug}/epic-coherence.json`: `schema_version` `3`, verdict `not_checked`, `skipped_by_operator: true`, `rounds: []`, the three current digests computed from `epic-manifest.json`, an empty coverage map, and one override of kind `bypass` with reason `Operator chose to skip the gap check` and `accepted_by: \"operator\"`. Then go on to drafting. The structural check above still runs, and its errors still block creation.\n - **Siblings.** Run no epic reviewer, write no coherence record, show no extra outline line, and ask no extra prompt. The conditional policy stays recorded in the plan.\n\n Follow `review-epic-coherence.md` in `drafting` mode, attended, with that input path and `{docs_dir}/epic-plans/{slug}/` as the output directory. Pass `council_preapproval` with `value` set to the legacy `council_choice` recorded from the drafting plan (`approved` for `before` and `after`, `declined` for `none`) and `source` set to the exact string `define-tickets council answer`, so the procedure asks no council question of its own. When `design_council` satisfies the procedure's skip predicate, the high-risk trigger records `covered_by_design_council` and requests no council; the uncertain and disputed triggers are unchanged. Also pass `auto_amend: true`: the procedure fixes gaps by amending the manifest within its existing round and confirmation bounds, with no question. Any foundation gap still left after the bound goes to Step 2b, never to an owner question. It computes `manifest_sha256`, `child_evidence_sha256`, and `non_child_owners_sha256`, applies its risk-scaled round limit, and writes `epic-coherence.json` and `epic-coherence.md` there. Run the review over the whole manifest even when the structural check left only ownership errors: those errors stay blockers on their own, independently of the review's verdict. Read the coherence procedure through the command-owned lookup in `/define-tickets` Stage 9 (the paragraph headed \"Coherence procedure lookup\"), which keeps the installed, legacy `docs/install/`, and checkout locations in order, the unreadable-file failure rule, and the repair guidance. Never improvise a substitute review.\n\n**Only under --auto:** the coherence run is unattended. Execute the recommended plan recorded in Stage 6, which always includes the gap check for an epic. Pass the literal `auto_approve_external = \"true\"` and no `council_preapproval`, never write a skip record, and use the procedure's bounded amend-and-recheck behavior instead of the agent settlement below. It clears only with no foundation blockers and every ticket-local blocker carried; it halts as `epic_coherence` with verdict `blocked` when foundation blockers remain after the bound or non-convergence. Clearance is independent: `independent: false` fails even on `pass`, `not_checked` fails, and an attended-only bypass or accept cannot clear an auto run. Halt before any writer or `create_ticket` on `blocked`, `not_checked`, `independent: false`, an unresolved required council, or any other non-clearing record. Name the specific cause in prose and halt as `epic_coherence` with the record path and a `coherence_verdict` of only `blocked` or `not_checked`. An unfixable structural error halts as `stage_failed` naming Stage 9 (item 3 above). If the procedure is unavailable or cannot be invoked, halt as `stage_failed` naming Stage 9; never fabricate a coherence result. Under `--auto`, write no decisions catalogue entry. Siblings keep their no-coherence path. For an epic, skip the pending-acceptance list, the upload gate, and its reply parsing in the command's Stage 9 step 3: drafting and creation proceed only once the record clears, with no prompt. For siblings, skip the upload gate and its reply parsing in the command's Stage 9 step 3: creation proceeds with no prompt once every auto gate and draft-completeness requirement has cleared.\n\n**Resolve the result at the gate.** Every remaining **foundation** blocking finding (a gap in how the work is split) is settled by the agent in Step 2b before any writer runs, and the upload gate shows the settlements. Ticket-local blockers are carried into their child ticket, shown as \"a note added to ticket N\", and do not require acceptance at this epic gate. There is no separate fix-or-accept question: the upload gate in the command's Stage 9 step 3 is the one surface where the owner sees and can reverse the settlements. Use the plain words in \"What the user sees\" in `review-epic-coherence.md` for everything the user reads; the record keeps its technical values.\n- **Fixed automatically.** Under `auto_amend: true`, the procedure amends the manifest between rounds within its existing bounds, with no question. Each amendment re-freezes it: follow the shared re-freeze sequence in item 3 (rewrite `epic-manifest.json` and the input, refresh `blast-radius.json`, rerun the structural check) inside the reviewer-round loop, after every `auto_amend` amendment and before the next round, rather than once after the review returns.\n- **Settled by the agent.** After the bound, Step 2b settles each remaining foundation finding: assigned to a ticket, fixed by an amendment, accepted with an agent-drafted reason (never a `coverage` or `e2e_proof` finding), or left as a `needs-owner` item.\n- **Change how the tickets are split** (fix) — only when the user explicitly asks for it by replying \"change something\" at the command's upload gate. \"Change something\" can reverse any settlement. Amend the manifest (add or rescope a child, or reassign an obligation). That re-freezes it: follow the shared re-freeze sequence in item 3 (rewrite `epic-manifest.json` and the input, refresh `blast-radius.json`), rerun the structural check and the review within the existing bounds, settle any new foundation finding in Step 2b, redraft only the affected entries as described under Handling changes in the command's Stage 9 step 3, rerun the draft check, and return to the updated upload gate. The budget is one operator-directed fix plus one additional whole-manifest confirmation pass, counted across every coherence-check re-run in the same attended define-tickets run. A fix made after the procedure's last allowed round gets its one confirmation pass, so the record's last round still bears the final digests. Once the budget is spent, only an eligible accept, a `needs-owner` item, or `blocked` remain.\n- **Create anyway, and record the gap on the epic** (accept) — the settlement for an eligible foundation gap (`handoff`, `fit`, or `input`) the agent chose to accept. The reason is agent-drafted, non-empty, and shown on the upload gate with its catalogue id. The upload \"yes\" records it in `epic-coherence.json` as an override of kind `accept` with the `finding_id`, the `reason`, `accepted_by`, and the `round`. A `coverage` or `e2e_proof` finding is never accepted. When every remaining foundation blocking finding is accepted, the verdict is `accepted_with_gaps`.\n- A finding that is declined, or left without a reason, keeps the verdict `blocked` and keeps creation blocked.\n- **Couldn't check** (reviewer unavailable) — there is no mid-run stop. Retry the review within the existing round bounds. If it is still unavailable, keep drafting and record a `needs-owner` item in Step 2b. The upload gate shows \"Couldn't check\" as needing the owner's answer: creating without the check needs a reason the operator types, recorded as an override of kind `bypass`. The internal verdict stays `not_checked`. Never show or treat it as a pass. A plain \"yes\" is not that typed reason. It fails closed: neither creation preflight clears it without the recorded typed bypass.\n\n**Enforce ticket scope after amendments (attended only).** Re-check the implementation-ticket count against `ticket_scope` after every coherence amendment or settlement, before any writer or ticket creation. The agent makes a needed ticket-count or scope change itself, with no owner question, and records it as a `gap-settlement` entry in the decisions catalogue (Step 2b) with the old and new count and the reason. The change still respects the contractual boundaries (an E1 contract's pinned children), the sizing ladder, and the child-count rules; rebuild and revalidate the frozen split and any affected coherence record, follow the shared re-freeze sequence in Step 2 item 3 (refresh `blast-radius.json`, then rerun the structural check), and redraft only the affected entries. Count only children or ordinary tickets; show an epic parent as additional. The upload gate shows the changed count, and \"change something\" can reverse it. This does not add an attended scope gate under `--auto`.\n\n## Step 2b — Settle leftover gaps\n\n**The agent settles every foundation gap left after the automatic amendments, before any writer and with no owner question.** This runs only for an attended epic, after the whole-manifest review of Step 2 and before the first ticket-writer launch. Under `--auto` it never runs: the unattended rules in Step 2 apply unchanged.\n\n**Options.** Settle each remaining foundation blocking finding, and each ownership error the structural check left, by the effect rule in `review-epic-coherence.md`, within the existing round, fix, and confirmation budgets:\n\n- **Assign** a `coverage` or `e2e_proof` gap, or an `unclaimed_epic_ac` or `missing_e2e_owner` error, to a child, existing or new: amend that child's `owns_verifications` (and `e2e` marker) and scope. Never accept it.\n- **Fix** any other gap by amending the manifest.\n- **Accept** any other gap (`handoff`, `fit`, or `input`) with a non-empty, agent-drafted reason that names why the gap is acceptable.\n- **Cannot assign** (`needs-owner`). When no child can own a requirement or the end-to-end test, leave it unassigned. Drafting continues, and the upload gate shows it as the one item needing the owner's answer: name a ticket, or remove the requirement from scope. Nothing is created until the owner answers. Never give it a nominal owner, never weaken its obligation, and never remove a ratified requirement from scope yourself. A reviewer still unavailable after retries is also a `needs-owner` item.\n\nWhen a settlement amends the manifest, re-freeze it: rewrite `epic-manifest.json` and the input, refresh `blast-radius.json` as Step 2 item 3 describes, rerun the structural check, then run the next whole-manifest review. Reviewer rounds are never selective. A new foundation finding raised in that pass blocks wherever it lands, including on an unchanged child, and comes back here for settlement. This does not expand the ordinary-round, fix, or confirmation budgets; once they are spent, only an eligible accept or a `needs-owner` item remains.\n\n**The decisions catalogue (attended only).** Append each settlement, as you make it, to a `## Decisions made for you` section in `{docs_dir}/explorations/{slug}.md`. Create the section on the first entry. It survives context compaction and every later document rewrite. Write one `-` bullet per settlement, holding:\n\n- the id: the next `D-N` (`D-1`, `D-2`, …);\n- the kind: `gap-settlement`, or `needs-owner` for an item only the owner can settle;\n- the decision: the finding id (or structural code) and the gap in plain language;\n- the option chosen and the alternatives considered;\n- a one-line reason (for an accept, the exact reason that will be recorded);\n- the affected entries (`parent`, `child-N`).\n\nThe catalogue is append-only. A changed settlement is a new entry that names the entry it replaces (for example `replaces D-2`); never rewrite or delete an earlier entry. Under `--auto`, write no catalogue entry.\n\n**Proposed acceptances stay proposals until the upload \"yes\".** Keep each proposed acceptance in working state, bound to its finding id, its catalogue id, its exact reason, its round, and the current manifest and evidence identities. Do not persist it as an operator acceptance before approval. When a later pass re-raises the same finding, keep the proposal, its reason, and its catalogue id only when the gap, the evidence, the finding kind, and the affected entries are substantively unchanged; rebind it to the new round and identities. When any of them changed, or you are unsure, settle it again with a new catalogue entry that names the one it replaces. The upload \"yes\" persists exactly the shown acceptances as `accept` overrides.\n\n## Step 3 — Record check and full clearance\n\n**Check the record before any writer.** For an epic, the coherence record is validated before drafting, but attended pre-writer validation is narrower than full clearance. Attended pre-writer validation checks frozen-entry identity, sizing, readable recognized records, all three current digests, last-round identity or the existing attended exceptions, finding scopes, child references, carry completeness, confirmation budgets, and required-council resolution. Beyond records that already clear, attended pre-writer validation allows exactly these uncleared items, each listed individually at the upload gate: foundation gaps of kind `handoff`, `fit`, or `input` with a proposed acceptance bound as Step 2b describes; and `needs-owner` items (an unassigned requirement or end-to-end test, kept as the structural check's `unclaimed_epic_ac` or `missing_e2e_owner`, or an un-bypassed `not_checked` from a reviewer that stayed unavailable). Neither passes full clearance. Keep each proposed acceptance in working state, bound to its finding id, its catalogue id, its exact non-empty agent-drafted reason, its round, and the manifest and evidence identities. Do not persist it as an operator acceptance before approval. Every other structural error must already be corrected. Under `--auto`, full clearance applies before any writer, exactly as below.\n\n**Full clearance, before the first `create_ticket` call (and before any writer under `--auto`).** Refuse to create an epic unless all of these hold, with actual persisted acceptances for every remaining foundation blocker:\n- `epic-coherence.json` exists in `{docs_dir}/epic-plans/{slug}/` and is readable;\n- its `schema_version` is `1`, `2`, or `3`; legacy blocking findings are foundation findings. For version `3`, validate scope, child references, carry completeness, confirmation budget, and the foundation-only verdict before any writer call;\n- its `manifest_sha256` matches the frozen manifest shown at the gate, its `child_evidence_sha256` matches the current child evidence, **and** its `non_child_owners_sha256` matches the current non-child owners, all computed from `epic-manifest.json` with the encoding `review-epic-coherence.md` specifies (an absent array hashes as an empty array; a version `1` record without the third digest matches only when there are no non-child owners);\n- its `rounds` array is non-empty and its top-level digests equal its last round's digests. The only exception is an attended record with `amended_after_final_round: true`, a typed `bypass` override, and verdict `not_checked`, whose top-level digests still match the current input. A second exception is the attended skip record: `skipped_by_operator: true`, an empty `rounds` array, verdict `not_checked`, a `bypass` override with a non-empty reason, and top-level digests that match the current input;\n- no required council is left `still_running`, `failed`, or `timed_out` unless an attended `accept` override with a typed reason names its `council_id`;\n- an `accept` override never clears a foundation blocking finding of kind `coverage` or `e2e_proof`, whatever the schema version (`1`, `2`, or `3`) or a historical verdict says. Such a finding clears only when the manifest assigns it to a ticket or the owner removed the requirement from scope at the upload gate, and the record was rebuilt and reviewed again. A historical accept of one stays visible but never clears;\n- the current input passes `epic-coherence-input check --structural`. No `accept` or `bypass` override clears while it reports `unclaimed_epic_ac` or `missing_e2e_owner`, or any other structural error;\n- its verdict is `pass`, including a version 3 record with carried ticket-local blockers, or `accepted_with_gaps` with every remaining foundation blocking finding accepted with a non-empty reason, or `not_checked` with a recorded override of kind `bypass` carrying a non-empty reason.\n\nFor a skip record, the parent writer's coverage map is derived from manifest ownership, and the parent's `## Epic coverage map` is built from the manifest's `owns_verifications` and `non_child_owners`, and says plainly that the gap check was skipped by the operator.\n\nA council outcome of `declined_by_operator` is resolved and needs no `accept` override, whether it was declined at the pre-round-1 ask or through legacy `council_preapproval: declined`. A legacy `accept` override targeting `council: \"declined_by_operator\"` remains valid but is ignored for clearance.\n\nA council outcome of `covered_by_design_council` is resolved and needs no `accept` override: no council was requested. Refuse clearance for a `covered_by_design_council` record unless its `design_council_basis.council_id` and `design_council_basis.design_revision` match the corresponding members of the current input’s `design_council`, and that `design_council` is still well formed and satisfies the skip predicate: `split_reviewed` is `true` or every `materiality` value is `\"unchanged\"`.\n\nThe displayed reasons and override targets must stay unchanged between approval and creation. If either changed, show the gate again rather than treating the earlier reply as authorization. Unknown record fields are ignored and never authorize anything. A missing or unreadable record, an unrecognized schema version, a digest mismatch, top-level digests that differ from the last round's, an unresolved required council, `blocked`, or an un-bypassed `not_checked` stops here: report which one, and create nothing. This is the same rule as the epic coherence preflight in `render-ticket-manifest.md`, which holds its canonical wording; this command adds only the attended pre-writer timing exception above, and the canonical instruction is unchanged. This command does not route through that instruction, so the rule is stated here too.\n\n## Step 3 — Epic outline items 1–3\n\nThese three lines come first in an epic's plan outline. The command's outline then\ncontinues with its own items 4 through 9.\n\n1. **Gap check** (epic only, first) — the outcome in plain words: `No gaps found` (or `No gaps found (N notes added to tickets)` when ticket-local findings are carried), `Accepted with known gaps`, `Needs your decision`, `Skipped, your choice`, or `Couldn't check`. When the initial council was declined, add the information line `Council: skipped, your choice`. When the record says `covered_by_design_council`, add the information line `Council: already covered by the design council`, naming the design council it relied on. Neither line is a warning, an unresolved item, or something to accept.\n2. **Independence and notes** (epic only) — when the record says `independent: false`, say: this check ran in my own session, not by a separate reviewer, so it's less independent. List each carried ticket-local finding as \"a note added to ticket N\" with a short summary. An attended operator may discuss or fix a carried finding.\n3. **Who covers each requirement** (epic only) — one plain bullet per epic AC: the AC id, the owning child (or, for an owner-run owner, \"owner-run\" with the person or role and the step reference), then the obligation that proves it.\n\n## Step 3 — Known gaps (epic only)\n\n**Known gaps (epic only).** After the outline, show the settlements from Step 2b in this order. This is a list, not a question: there are no per-gap options.\n\n1. **Creation blockers and items needing your answer.** List every `needs-owner` item first, each with its catalogue id: an epic requirement or the end-to-end test that no ticket owns (ask the owner to name a ticket, or to remove the requirement from scope), and \"Couldn't check\" when the reviewer stayed unavailable (creating without the check needs a typed reason). Also list an unfinished required council (`still_running`, `failed`, or `timed_out`) as its own unresolved item. Say plainly that nothing will be created until each one is answered.\n2. **Known gaps that will be recorded on the epic.** Then list, read-only, each proposed acceptance: its catalogue id, a plain-language description of what is wrong, and the exact non-empty, agent-drafted reason that would be recorded, so the operator reads it before approving. A \"yes\" at the upload question records them; \"change something\" lets the operator reverse any settlement instead. Never list an unowned requirement or a missing end-to-end test here: a `coverage` or `e2e_proof` gap is never an acceptable gap.\n3. **Supporting evidence.** Last, the other settlements (assignments, fixes, and scope changes) by catalogue id, the review verdict and independence, and the council state.\n\nA historical record's accept of a `coverage` or `e2e_proof` finding is shown as history only. It is not an acceptable gap and never clears. A declined initial council and a `covered_by_design_council` outcome are not gaps and are never acceptance targets.\n\n## Step 4 — Write the plan DAG\n\nIn local mode, retain every confirmed minted epic/child key in the manifest immediately and emit neither plan file while a required key is missing or creation is uncertain; use those real keys rather than `TBD-N` placeholders. After an epic's tickets are created, write the Epic Implementer's plan sidecar to `{docs_dir}/epic-plans/{slug}/epic-plan.dag.json`. You already hold everything it needs: the frozen manifest carries each child's `depends_on`, and Stage 8's design named the files each slice touches. Nothing downstream derives this from an epic key, so if you skip it the handoff dead-ends. The epic-body manifest uses the same child order and hard `depends_on` relationships as `epic-plan.dag.json`.\n\n```json\n{\n \"plan_version\": 1,\n \"nodes\": [\n {\n \"ticket_key\": \"KEY-2\",\n \"status\": \"planned\",\n \"depends_on\": [],\n \"touched_files\": [\"src/example/service.py\", \"src/example/handler.py\"]\n }\n ],\n \"edges\": []\n}\n```\n\nOne node per child, in manifest order, using the **real** keys just created — never a `TBD-N` placeholder, since the tickets already exist. `depends_on` carries the manifest's hard prerequisites only; leave `recommended_after` out, because soft sequencing is not a dependency and encoding it there serializes work that could run in parallel. `edges` may be `[]` when `depends_on` already expresses the graph. The graph must be acyclic and every `depends_on` entry must name a node in the file.\n\nPopulate `touched_files` on every node from the design's file list, as repository-relative POSIX paths — concrete files only, never a directory or a glob. It is what lets the Epic Implementer serialize two children that would otherwise collide, and it matters more the larger the slices are. An omitted list is accepted by the server as an explicit opt-out, so leaving it off does not fail — it silently turns plan-time overlap protection off. Use `[]` only when a ticket genuinely touches no repository files. Which overlaps get an ordering edge is decided by the server, not by you: on runs created from a repository with a confirmed gate profile, only children whose files both fall under one of the repository's must-order paths (for example a migrations directory, declared in the gate profile and confirmed by the owner) are ordered, and ordinary shared files run in parallel and are resolved at merge time. Do not add `depends_on` entries just because two children share an ordinary file.\n\nThen write the plan's epic key beside it, at `{docs_dir}/epic-plans/{slug}/epic-plan.meta.json`, holding exactly:\n\n```json\n{\"epic_key\": \"<EPIC-KEY>\"}\n```\n\nUse the real epic key just created. This path runs no `finalize` step, so it writes the file itself. It is how `drive-epic` finds this epic's plan without being handed a path.\n\nInclude the files that are easy to forget, because those are the ones that actually collided: **anticipated tests, fixtures, golden files, guard allowlists, and policy files**, not only the production modules. Both known misses were exactly this class — two children shared `ticket_type_evaluator.py` *and its test*, and another pair shared golden files and a `save_repo_to_db` test — and in each case nobody predicted the shared file, so no ordering edge was synthesized and both PRs merged over each other. Paths are compared as exact strings after normalization, so name concrete files: a directory or a glob matches nothing.\n\n**Save the plan to the Bridge server.** After `epic-plan.meta.json` is written, and after `epic-coherence.json` from the gap check, save the plan so anyone with access to the repository can run the epic with no local plan folder. Resolve the trusted launcher prefix once, quote each argument on its own, and run:\n\n```bash\n<launcher> epic-plan save --epic-key '<EPIC-KEY>' --plan-dir '{docs_dir}/epic-plans/{slug}' --json\n```\n\nIt saves the DAG, the eligibility advisory, and the gap-check record together, and prints the server's `authored_version`. Saving an unchanged plan again reuses the stored version. The local files stay as a readable copy. A failed save is a **warning, not a failure**: the tickets already exist and stay created, so never report `create_failed` for it. Report the epic and the exact `retry_command` the command printed, and continue.\n\n## Step 5 — Hand off once\n\nPresent these sections in order:\n\n- **Plan/tickets saved** — confirm the epic, real child keys, and saved DAG/metadata. Name the server copy: `Plan saved on the Bridge server as authored version <N>`, or, when the save failed, `Plan NOT saved on the Bridge server` with the epic and the exact retry command. Saved work remains successful even when launch readiness is refused or unconfirmed, and even when the server save failed.\n- **Readiness preview** — only when the concrete epic key, finalized child keys, `epic-plan.dag.json`, and `epic-plan.meta.json` exist and you recommend launch, use the Completion advisory section at the end of this procedure. Resolve the trusted multiword launcher prefix once, quote dynamic arguments independently, and run `drive-epic '<EPIC>' --dry-run --json` at most once with a 60-second command timeout/cancellation. Parse valid authoritative JSON regardless of exit status. Render selected target, returned reason/remedy, and any `availability_text` verbatim; retain conditional cold-start distinctions. State **ready at preview time**, refusal, or **readiness not confirmed**, never an execution guarantee. If the bounded seam or preview is unavailable, offer the same command for a later user-initiated retry and continue the saved-work report. No automatic rerun on later turns, no second readiness call, and no create/start/approve/provision/index/schedule action.\n- **Launch next step** — point at exactly one launch, by host, conditional on the preview result. Ticket creation does not establish executor, policy, VCS, or indexing readiness. Missing keys, unresolved `TBD-N` entries, or unfinished artifacts receive neutral finalization guidance without probing a nonexistent epic. Ordinary ticket-definition and sibling/lone-ticket requests require no completion readiness call.\n\nPreserve these canonical host routes:\n\n- **Claude Code or Cursor:** `/drive-epic-run {EPIC-KEY}`\n- **Codex or Copilot:** `npx -y @bridge_gpt/mcp-server drive-epic {EPIC-KEY}`\n\nBoth launch through `drive-epic`, and both find the plan through `epic-plan.meta.json`. **The one command both creates and drives the run:** `/drive-epic-run` previews the launch, asks for an explicit yes, creates the run through `drive-epic`, starts its executor, and then drives it. On Codex or Copilot, `drive-epic` creates the run and starts its executor, and the first-run steps are in `docs/install/epic-implementer-install.md` (write or refresh it with `npx -y @bridge_gpt/mcp-server install`).\n\nWith no target flag, `drive-epic` targets production and uses this repository's stored Bridge credential, so no `BAPI_BASE_URL` export or temporary notification terminal is needed when the authoritative preview confirms readiness. A fresh project may still have the returned unmet requirements; planning success does not remove them. For a local or other non-production target, `drive-epic --help-advanced` lists the owner options. A conflicting target, or a stored key approved for a different server, refuses before any authenticated request.\n\n`drive-epic` defaults to the unattended posture. Escalations go to the account's email address; a `--policy-file` is needed only when the account has no email for escalations. Pass `--attended` to opt out of the unattended default. `drive-epic` reads Epic Implementer readiness and selects the runnable path itself. Do not name an underlying launch path, and never present a choice between two of them — two transition authorities on one epic is the failure this single entry point exists to remove. A sibling pair or a lone ticket gets no Epic Implementer handoff at all.\n\n**Only under --auto:** render this handoff as a report line and never invoke it.\n\nEvery unattended epic-branch run so far has needed operator recoveries within minutes of a trigger, and the reconciler never applies them. That is why the one command both creates and drives the run: the session that launched it stays to apply the sanctioned recovery verbs.\n\n## Completion advisory — saved epic plans and tickets\n\nThis pattern is for a completion handoff that recommends launch, outside\n`/drive-epic-run`'s Stage 0. It is read-only and adds no mandatory launch gate.\n\nEligibility requires a concrete epic key, finalized real child keys (no `TBD-N`),\nand the actual `epic-plan.dag.json` and `epic-plan.meta.json` artifacts. Free-form\nplans, missing keys, and unfinished artifacts receive boundary guidance only.\nRun at most one eligible preview per completion; do not automatically rerun it on\nlater turns of that completion. Ordinary ticket definition needs no preview.\n\nResolve `<launcher>` once using `/drive-epic-run` Stage 0 operation 3's trusted\ncommand-prefix convention. Preserve multiword prefixes such as\n`node /absolute/path/to/mcp_server/build/index.js`; never quote the entire prefix\nas one executable. Independently escape and single-quote every dynamic argument:\n\n```bash\n<launcher> drive-epic '<EPIC>' --dry-run --json\n```\n\nRetain `--plan-file '<path>'` only when actual plan selection requires it. Use the\nhost's command timeout seam to impose a **60-second** wall-clock limit and cancel\nthe read-only child where supported. If bounded execution is unavailable, report\n**readiness not confirmed** without starting an unbounded operation.\n\nParse authoritative JSON regardless of exit status, including nonzero refusals.\nValidate it using `/drive-epic-run` Stage 0 operation 4's existing schema and\ncontradictions checks.\nReport the selected `target.kind` and `target.base_url`; render `refusal.reason_id`\nand `refusal.remedy` verbatim, falling back to `readiness.reason_id` and\n`readiness.remedy` when refusal is null. Relay any supplied `availability_text`\nverbatim without substituting generic VCS/indexing advice. A `stop` decision\nreports the returned plan status/candidates and finalization remedy. Never invent\nfields or an independent readiness rule.\n\nAn ordinary successful `create` or `attach` preview is **ready at preview time**.\nA `cold_start` create is conditional: `summary.server_validation` is partial, and\nguarded startup and live validation must still succeed. A generated-plan cold\nstart (`cold_start.live_run_checked` is `true`) confirmed no live run during\ngeneration; any other cold start did not check live-run existence. It is never a promise of launch readiness. Malformed, unavailable,\nthrowing, or timed-out previews mean **readiness not confirmed**. Retain planning\nsuccess and offer the same preview command for a later user-initiated retry.\n\nPresent **Plan/tickets saved → Readiness preview → Launch next step**. Planning\nand ticket creation establish neither executor, policy, VCS, nor indexing\nreadiness. Reproduce only actual unmet dependencies and returned remedies.\nNever create, start, approve, provision, index, or schedule anything from this\nadvisory. Preserve actual launch consent and `drive-epic` admission; do not invoke\n`/drive-epic-run` Stage 0's launch, health check, or second advisory-read\noperations here.\n\n## Return\n\nThis procedure returns nothing on its own. After each section, go back to the\n`/define-tickets` Stage 9 pointer that sent you here and continue from that point.\nReport the outcome of the section you just followed in the command's own terms: the\ngap-check outcome and record path, the clearance result, the saved DAG and metadata\npaths, or the hand-off sections shown. A halt keeps the command's halt reason and\nterminal contract; this procedure adds no halt reason and no terminal field.\n",
|
|
13
|
+
".bridge/procedures/define-tickets-blast-radius-procedure.md": "# `/define-tickets` blast-radius procedure\n\nThis procedure finds the files a proposed epic split would affect, before the split\nfreezes. It carries callers, mirrors, generated outputs, and pinned references into\nthe manifest, so that no affected file is left without an owner. The command reads it\non demand, at the end of Stage 8, and follows it once per prepass or refresh. Sections\nthat mention \"the command\" mean `/define-tickets`. Nothing here changes the\ncommand-owned split rules, the `--max-children` cap, the writer fan-out, the upload\ngate, creation, or the Final Report.\n\nUse host-neutral capabilities only: \"run a shell command\", \"read a file\", \"write a\nfile\". Do not depend on one client's tool names.\n\n## Applicability\n\nRun this procedure whenever the command's existing epic trigger fires for the run,\nthat is, whenever the run will freeze an epic split. That includes an E1 contractual\nepic with fewer than three children. Do not add a separate three-slice threshold, and\ndo not change the normal split threshold or its contractual exceptions.\n\nSiblings (one or two ordinary tickets) treat this procedure as **advisory**. A sibling\nrun may use it to find affected files, but it requires no artifact and no check, and\nno sibling step fails because the artifact is missing.\n\n## When it runs\n\nThe ordinary execution point is the end of Stage 8, after the slices and their file\nlists are recorded and before the epic split freezes. It runs the same way in\nattended and `--auto` runs. Discoveries amend the provisional slice file lists before\nthe freeze. The completed artifact is written beside the manifest and the input, and\nit exists before the first `epic-coherence-input check --structural` invocation.\n\nA run that becomes an epic later, in Stage 9, runs the prepass then (late\nescalation). It reuses discoveries that still apply and writes the artifact before its\nfirst epic structural check.\n\nRe-freeze loops refresh the artifact. The epic hand-off procedure defines each loop.\n\n## Resolve the launcher\n\nResolve the trusted launcher prefix the same way the epic hand-off procedure does,\nonce per run. A prefix may have several words, for example\n`node /absolute/path/to/mcp_server/build/index.js`. Keep it as written: never quote the\nwhole prefix as one executable. Independently escape and single-quote every dynamic\nargument.\n\n## Discovery\n\n### 1. Build the symbol inventory\n\nList every name the design changes or introduces. The inventory must not be empty. It\nincludes functions, classes, constants, subcommands, flags, field names, contract\nphrases, reworded strings, and new file or function names. Record each as a string.\n\nSplit the inventory into two groups:\n\n- **Supported design symbols**: identifier-like names that the regression check can\n search for.\n- **Literals**: strings with spaces or regular-expression metacharacters, such as a\n reworded sentence. These never go through `regression-check --symbols`.\n\n### 2. Run regression discovery for supported symbols\n\n`MAX_SYMBOLS_PER_RUN` is 40. If the eligible inventory holds more than 40 symbols,\nsplit it into complete batches of at most 40 and run every batch. Run each batch:\n\n```bash\n<launcher> regression-check --mode lightweight --symbols '<a,b,c>' --json\n```\n\nRead the actual JSON. Extract every file named as a call site and every file named as a\nbroad mention, using the output structure as `formatRegressionCheckJson()` produces\nit. Record the `truncated` flag and the `degraded` flags each run reports.\n\n### 3. Search for literals with fixed strings\n\nFor a literal with spaces or regex metacharacters, run a fixed-string search instead\nof passing it to `regression-check --symbols`:\n\n```bash\ngit grep -l -F -w -e '<literal>' --\n```\n\nEscape the literal correctly for the shell. Drop `-w` for a multi-word string, because\nword-boundary matching does not apply to it. Keep default ignore behavior (see\nRepair).\n\n### 4. Apply the trap rules\n\nSome files are affected through a source, not through a symbol. Add these files from\nthe checklist even when they are untracked or do not exist yet. Name the concrete\ngenerated path:\n\n- An `mcp_server/instructions/*.md` change affects `mcp_server/src/pipelines.generated.ts`.\n When the source is registered in `DOC_ASSETS` (in `mcp_server/scripts/bundle-docs.js`),\n it also affects `mcp_server/src/docs.generated.ts`.\n- A `commands/src/*.md` change affects `.claude/commands/`, `.cursor/commands/`,\n `mcp_server/.claude/commands/`, and `mcp_server/src/commands.generated.ts`.\n- An `agents/src/*.md` change affects `.claude/agents/`, `mcp_server/.claude/agents/`,\n and the matching `.github/agents/*.agent.md` files.\n- A change to a writer-contract passage affects\n `tests/pytest/agents/test_jira_ticket_writer_standard.py` and its\n `CONTRACT_AMENDMENTS` mapping. That file is the pinned consumer of changed passages.\n- A change to a string that another file pins literally affects that pinning file.\n- A change to the count of MCP tools, profiles, or package bins affects the files that\n pin those counts.\n- A change to text embedded in a golden or fixture file affects that file.\n\n### 5. Normalize and merge\n\nFile identity is a normalized repository-relative POSIX path: use `/` separators and\nstrip a leading `./` (ripgrep prints one). When the same file is found more than once,\nkeep one row and merge the findings by set union of `discovery_reasons`.\n\n`revision` is the full `HEAD` SHA captured when discovery runs. Searches inspect the\nworking tree as it stands at that moment, including uncommitted edits.\n\n## Repair\n\nDiscovery can be degraded or truncated. Repair it. Never lose coverage silently.\n\n- For every batch whose result is degraded or truncated, record at least one targeted\n search for **each** affected symbol. This includes symbols omitted by truncation.\n- A recorded search is its actual `query`, the coverage problem that required it as\n `reason`, and its complete normalized `files` list. An empty list is a valid\n zero-result search.\n- Limit repair searches to tracked-file `git grep` or ordinary `rg`. Never pass\n `--no-ignore` or `-u`: default ignore rules stay in force.\n- Across all calls, `truncated` is the logical OR of every run's value, and\n `degraded_flags` is the set union of every run's flags. Never clear either after a\n repair.\n- When any contributing run was degraded or truncated, write `coverage` as\n `degraded_repaired`. Otherwise write `complete`.\n\nA zero-result search is a success. An execution failure is not. Degradation by itself\nnever halts the run. If a repair search cannot be run, or the artifact cannot be\nwritten, use the command's existing `stage_failed` handling and name the stage that is\ndoing the work (Stage 8 for the ordinary prepass, Stage 9 for a late escalation or a\nre-freeze refresh). This procedure adds no halt reason.\n\n## Dispositions\n\nEvery discovered file gets exactly one disposition:\n\n- `child`: the manifest ID of the accountable owner. The concrete normalized path must\n appear in that child's `touched_files` or `read_files`. Ownership is accountable, not\n exclusive: a shared file may be owned through two children, and sharing adds no\n `depends_on` edge.\n- `unaffected_reason`: a reason specific to this file that says why the change does not\n affect it. A bare classification is not a reason. These blanket values, compared\n after trimming and ignoring case, are rejected: `generated`, `test-only`,\n `tests only`, `n/a`, `unaffected`.\n\nWhen a file needs an owner, amend the provisional slice file lists first. A file with\nno owner and no specific reason blocks the check.\n\n## Artifact\n\nWrite the artifact to `{docs_dir}/epic-plans/{slug}/blast-radius.json`, beside\n`epic-manifest.json` and `epic-coherence-input.json`. It carries every discovered file,\neven when the summary shown to the owner abbreviates the long tail. Version 1:\n\n```text\nschema_version: 1\nrevision: non-empty string # full HEAD SHA at discovery time\nsymbols: non-empty array of strings\nregression_check:\n truncated: boolean\n degraded_flags: array of strings\ntargeted_searches:\n array of {query, reason, files}\ncoverage: complete | degraded_repaired\nfiles:\n array of {path, discovery_reasons, child}\n or {path, discovery_reasons, unaffected_reason}\n```\n\n`discovery_reasons` is a non-empty array of non-empty strings. Unknown extra fields are\nignored and never authorize anything. `epic-coherence-input check` and\n`check --structural` read this file when it exists and report named errors for a\nmalformed envelope, an invalid path, a duplicate path, a missing or doubled\ndisposition, an unknown or non-owning child, a blanket reason, and a `complete`\ncoverage that contradicts a truncated or degraded run. Siblings need no artifact.\n\n## Refresh\n\nRefresh the artifact inside every re-freeze loop, before the structural check:\n\n- When an amendment only moves already-discovered files between children, update the\n dispositions and rewrite the artifact.\n- When an amendment introduces new symbols, literals, contracts, or trap triggers, run\n incremental discovery for just those, then merge the results with the existing rows.\n Keep earlier rows and their discovery reasons unless a recorded correction explains\n why one is removed.\n\nRebuild each affected child's research packet from the refreshed rows before its\nwriter runs.\n\n## Owner-facing report\n\nShow the owner a short summary: the file count, the coverage value, and, when\ndegraded, the degraded flags in plain words. A degraded run is reported as degraded and\nstill proceeds. The summary may abbreviate the long tail of files. The artifact never\ndoes.\n\n## Return\n\nThis procedure returns nothing on its own. After the artifact is written, go back to\nthe `/define-tickets` pointer that sent you here and continue from that point. Report\nthe artifact path, its file count, its coverage value, and any degraded flags in the\ncommand's own terms. A halt keeps the command's halt reason and terminal contract; this\nprocedure adds no halt reason and no terminal field.\n",
|
|
14
|
+
".bridge/procedures/define-tickets-auto-mode-procedure.md": "# `/define-tickets` auto-mode procedure\n\nThis procedure carries the unattended-only instructions of `/define-tickets`. Only an\n`--auto` run reads it. The command reads it once in Stage 0, right after flag parsing,\nand then follows one section of it at each `**Only under --auto:**` pointer. Each\nsection below is headed by the command location it came from, and its text is the\ncommand's original `--auto` instruction, moved here word for word. Sections that mention\n\"this stage\", \"item 5\", \"the attended instructions below\", and similar mean that\nlocation in `/define-tickets`.\n\nAn attended run never reads this procedure. The command keeps inline everything a run\nneeds to stop correctly when this file cannot be read: the \"Auto mode (--auto)\"\nsection, Stage 0 flag parsing and its load step, and the whole Final Report terminal\ncontract (the halt-reason list, each halt's fields, and the `create_failed` shape).\n\n**Reread after a break.** A resumed or compacted `--auto` run reads this procedure\nagain before its next `--auto` step.\n\n## Stage 0 item 5 — Project standards\n\ncreate a unique local run id (for example the current epoch seconds) and the artifact directory `{docs_dir}/explorations/{slug}-{run_id}/`, then call `get_project_standards` once, before readiness. Treat a 404, an error envelope, a missing response, or an onboarding placeholder as unavailable: warn and continue. Retain the result, or an explicit `standards unavailable` state, for every writer and for the Final Report.\n\n## Stage 0 item 6 — Readiness\n\nimmediately after standards, read the readiness procedure at `.bridge/procedures/preflight-and-readiness-procedure.md` in this project, where the Bridge installer scaffolds it. Only if that file does not exist, read `docs/install/preflight-and-readiness-procedure.md` (the location older installs used). Only if that file does not exist either, read `mcp_server/instructions/preflight-and-readiness.md` in this checkout. A file that exists but cannot be read is a failure: never fall back to a later location. If it is unreadable or none of the three exists, halt as `stage_failed` naming Stage 0. Follow its define-tickets path, naming the slug, the run id, and the artifact directory in the invocation. If readiness is `too_vague_to_ticket`, halt before Stage 1 as `too_vague`. Record the scope axis only; it does not decide the eventual ticket shape.\n\nAt this procedure-read failure, follow Procedure read failure for `.bridge/procedures/preflight-and-readiness-procedure.md` (`repair-assets`).\n\n## Stage 2 — Duplicate scan\n\nafter this stage, run the duplicate scan. Read `.bridge/procedures/duplicate-and-context-scan-procedure.md` in this project first. Only if that file does not exist, read `docs/install/duplicate-and-context-scan-procedure.md`; only if that file does not exist either, read `mcp_server/instructions/duplicate-and-context-scan.md` in this checkout. A file that exists but cannot be read is a failure: never fall back to a later location. If it is unreadable or none of the three exists, halt as `stage_failed` naming Stage 2. Follow its define-tickets path, naming the slug, the run id, the resolved `allow_duplicate` literal, and the artifact directory in the invocation. Halt as `duplicate` on a known duplicate unless `allow_duplicate` is `\"true\"`. Halt an `unable_to_check` result as `stage_failed` naming the duplicate scan; `--allow-duplicate` never overrides it. This is the one halting check in this stage.\n\nAt this procedure-read failure, follow Procedure read failure for `.bridge/procedures/duplicate-and-context-scan-procedure.md` (`repair-assets`).\n\n## Stage 3 — Open requirements halt\n\nat the end of this stage, halt as `open_requirements` if any acceptance criterion or NFR is still `open`, and list those items. Rely on the Stage 1 evidence and the conservative `confirmed` / `assumed` rubric in step 4. Do not add a minimum-evidence halt. Do not run a separate screening procedure.\n\n## Stage 4 — Proposed, unratified labels\n\nlabel every acceptance criterion and every NFR `proposed, unratified` in the document, and use `Requirements proposed, unratified (--auto)` as the Status line instead of the attended status. No one has ratified them.\n\n## Stage 4 — Comp analysis\n\nafter the document is written, and before Stage 8, run the comp analysis. Read `.bridge/procedures/comp-analysis-procedure.md` in this project first. Only if that file does not exist, read `docs/install/comp-analysis-procedure.md`; only if that file does not exist either, read `mcp_server/instructions/comp-analysis.md` in this checkout. A file that exists but cannot be read is a failure: never fall back to a later location. If it is unreadable or none of the three exists, halt as `stage_failed` naming Stage 4. Follow its define-tickets path, naming the artifact directory in the invocation; it writes `comp-analysis.json` there. Continue on a degraded analysis, which records `applicable: false`, a reason, and warnings; carry those warnings and the material needing manual review to the Final Report.\n\nAt this procedure-read failure, follow Procedure read failure for `.bridge/procedures/comp-analysis-procedure.md` (`repair-assets`).\n\n## Stage 5 — Skip the page\n\nskip this stage entirely. Do not call `generate_decision_page`, and go to Stage 6. The attended instructions below are unchanged.\n\n## Stage 6 — No page and no operator\n\nthere is no page and no operator. Skip items 1 through 4, the page-commit loop, the implications confirmation prompt, and the drafting plan display. Produce the item 5 implications review from the proposed set and write it under `## Implications`. Compute the recommended drafting plan with the item 5 rules and record it in working state without showing it, then state the option taken in the Final Report. Pass no coherence `council_preapproval`, and never record `declined_by_operator`. Never record an attended acceptance or bypass override either. Map `--auto` to the literal `auto_approve = true` path in item 5. In item 6, keep the criteria `proposed, unratified`, set the Status line to `Requirements proposed, unratified (--auto)`, and never set \"Requirements ratified\". The attended instructions below are unchanged.\n\n## Stage 7 item 2 — Run the recorded plan\n\nexecute the deterministic plan recorded by Stage 6, with no question. For `before`, first state the council cost and the approximately 15-minute poll, then call `request_council`. For `after`, state nothing here: Stage 8 runs it and states its cost before the paid call. For `none`, run no council. The task description names the criteria as proposed, unratified.\n\n## Stage 8 item 4 — Unmeetable criterion\n\nhalt before any writer or `create_ticket` call as `open_requirements`, listing the criterion in `open_items` and explaining the review-derived cause in prose. The halt-reason list does not change.\n\n## Stage 8 item 6 — Design pushback is output-only\n\nthe invitation for design pushback in item 6 is output-only. Do not wait for a reply.\n\n## Stage 9 item 1 — Readiness follow-ups\n\ndo not pause or halt on these recommendations. Write each one as a `Readiness follow-ups` line in the Final Report. They are not `open` requirements, which halt earlier. Auto-mode readiness and every later reference to the criteria use the **proposed, unratified** set, never a settled or ratified one.\n\n## Stage 9 item 2 — Child cap and open requirements\n\nimmediately after the split freezes, and before writing `epic-manifest.json`, count the implementable epic children or siblings. If the count is above the resolved `--max-children` cap, halt as `max_children` with both counts and a \"split first\" message. Never truncate the split. Apply the same cap again if an unattended coherence amendment re-freezes a changed split, before writing its replacement manifest or going further toward creation. Just before any writer or ticket-creation call, re-check for `open` acceptance criteria or NFRs and halt as `open_requirements` if any remain.\n\n## Stage 9 item 3 — No upload gate\n\nthere is no upload gate. Clearance of every auto gate and draft completeness replace the affirmative, for siblings and an epic alike, and the upload prompt is never shown.\n\n## Stage 9 item 3 — Writer contradictions\n\nabsorb a factual citation or line-number correction and continue; halt an unmeetable ratified obligation as `open_requirements`, but only when a draft exists and its report is a valid non-empty block; keep `stage_failed` for a writer that cannot produce its draft (it stops without a draft), and carry that writer's questions in the failure reason. This adds no halt reason and no pause.\n\n## Stage 9 item 3 — Writer inputs\n\npass into **each** `jira-ticket-writer` invocation, whether epic parent, child, or sibling, the applicable `comp-analysis.json` path when it records `applicable: true`, the project-standards result or a `standards unavailable` note, and an instruction to label its criteria `proposed, unratified`. Keep the entry's criteria and manifest obligations verbatim. A degraded comp is never described as reviewed, and tickets are never described as standards-checked when standards were unavailable. A writer failure or any other critical failure before the first `create_ticket` call is a `stage_failed` halt.\n\n## Stage 9 item 3 — Draft check failure\n\nan unresolved failure takes the existing `stage_failed` writer-failure path, naming Stage 9 and the draft, before any Jira creation.\n\n## Stage 9 item 3 — Writer report failure\n\nunresolved failure halts as `stage_failed` before any Jira creation, naming Stage 9 and the affected entry. A report that is still invalid after its one revision follows this same writer-failure path.\n\n## Stage 9 item 3 — Open writer questions\n\nfirst answer each question the sources already settle. The sources are the frozen requirements and any contract they cite, the entry's research packet, and code evidence. A question is settled only when a source states the answer or rules out every other option. Never pick between options the sources leave open, and never answer by removing or weakening a ratified requirement. Re-invoke only the affected writer as a revision with the answer and its existing inputs, at most once per entry, and list each answer with its source in the Final Report. If any question remains, including one the writer returns again, halt as `open_requirements` before any `create_ticket` call. Put every remaining question in `open_items`, qualified by its entry (for example `child-2: {question}`). The halt-reason list does not change.\n\n## Stage 9 item 3 — Changed epic split\n\nhalt as `epic_coherence`.\n\n## Stage 9 item 3 — Tracking and creation failures\n\na `track_ticket` error warns and never halts: keep each confirmed key, name every untracked key in the report for reconciliation, and neither retry creation nor delete a ticket. A failed `create_ticket` attempt, even one with no key confirmed, is a `create_failed` halt. So is a failed post-create write of `epic-plan.dag.json` or `epic-plan.meta.json`. Report `created_keys` in creation order, which may be empty, and a precise `failed_entry`: the parent title, a child's manifest position and title, the failed sibling, or the failed filename. Tell a later run to reconcile those keys and that entry rather than replay creation.\n\n## Return\n\nThis procedure returns nothing on its own. After each section, go back to the\n`/define-tickets` pointer that sent you here and continue from that point. A halt\nkeeps the command's halt reason and terminal contract, written in its Final Report;\nthis procedure adds no halt reason and no terminal field.\n",
|
|
15
|
+
".bridge/procedures/procedure-read-failure-procedure.md": "# Procedure read failure\n\nA command reads this procedure only when another procedure it needs cannot be read:\nthe file is missing from every location the command names, or it exists but cannot be\nread. It tells you how to report the failure and how the owner can repair the\ninstallation. It never gives permission to continue past the failure.\n\n## What stays the same\n\n- **The lookup order.** The command's own lookup still decides where to read. Fall back\n to a later location only when the earlier file does not exist. A file that exists but\n cannot be read is a failure, never a reason to read the source-checkout copy instead.\n- **The stage's own behavior.** Keep the refusal, halt, warning, or skip that the\n command writes at the failing read. A stage that stops still stops, a stage that\n halts an `--auto` run still halts with its own halt reason, and a stage that warns\n and skips still warns and skips. This procedure adds no halt reason and no stop.\n\n## Report it\n\nName the exact procedure that failed, using its `.bridge/procedures/…-procedure.md`\npath, and the affected stage and ticket keys. Say whether the file was missing or\ncould not be read.\n\n## Repair\n\n- **Linux.** From the established project root, give the owner the version-pinned\n `repair-assets` terminal command that the command's \"Procedure read failure\"\n paragraph names, with the root quoted for the shell and the host set to the one in\n use (`claude`, `cursor`, `codex`, or `copilot`).\n- **macOS and Windows.** In-place repair is unsupported. Re-run start-tickets for\n worktrees, or the existing Bridge `--init`/install workflow for project scaffolds.\n- **Fill-only.** Repair fills missing packaged files only. It never overwrites a file\n that exists, so it never repairs or replaces a customer's own instruction override.\n Resolve permission problems, a path that is not a file, or an unsafe link separately.\n- **After a repair.** Refresh or reconnect, then reread that same procedure. Resume only\n if the original stage allows it.\n\n## Return\n\nGo back to the command at the read that failed and apply that stage's own outcome:\nits refusal, its halt, or its warning and skip. Nothing in this procedure lets the run\ncontinue where the stage would stop.\n",
|
|
16
|
+
".bridge/procedures/define-tickets-decision-page-procedure.md": "# `/define-tickets` decision-page procedure\n\nAn attended `/define-tickets` run reads this procedure in Stage 5, immediately before it\ncalls `generate_decision_page`. It holds the shape of the `content` object and one\nexample call. The rules for the page stay in the command: the routing fields, the rule\nthat `system_goals` is always passed, the mandatory `SCOPE-1` card, and the rule that\ncards ask about requirements, never about implementation. An `--auto` run never reads\nthis procedure, because it skips Stage 5.\n\n## Content shape\n\n```typescript\ninterface ExploreTicketContent {\n system_goals?: {\n business_goal: string;\n desired_end_state: string;\n system_behavior: string;\n acceptance_criteria?: Array<{\n id: string; // e.g. \"AC-1\"; must be unique\n criterion: string; // what the system must do\n verification: string; // how we would confirm it holds\n status: \"confirmed\" | \"assumed\" | \"open\";\n }>;\n nfrs?: Array<{\n category: string;\n requirement: string;\n implication: string;\n status: \"confirmed\" | \"assumed\" | \"open\";\n }>;\n };\n actionable_items?: Array<{\n id: string; // \"SCOPE-1\" for ticket count; \"R-1\", etc. for requirement questions\n question: string;\n why_it_matters: string;\n recommendation_explanation: string;\n options: string[]; // 2-4 candidate answers (no \"None of these\" or \"Ask about this\")\n option_consequences: string[]; // same length as options\n recommendation_index: number; // 0-based within options\n codebase_evidence?: string; // optional: assessment + file:line citations\n original_question?: string; // optional: only when item maps to a verbatim question\n }>;\n // clear_improvements: not used by this command — it captures requirements, not findings\n // implementation_order: for epic surfaces only — do NOT include for single task explorations\n // depends_on: hard prerequisites (titles/keys that must land first)\n // recommended_after: soft sequencing preferences, not hard blockers\n}\n```\n\n## Example call\n\n```json\n{\n \"ticket_key\": \"revoke-api-keys\",\n \"artifact_type\": \"pre_ticket_planning\",\n \"output_subdir\": \"explorations\",\n \"output_filename\": \"revoke-api-keys-requirements.html\",\n \"labels\": { \"title\": \"Requirements & Ticket Scope\", \"section_heading\": \"Requirements & Scope Questions\" },\n \"content\": {\n \"system_goals\": {\n \"business_goal\": \"Operators can cut off a leaked key immediately.\",\n \"desired_end_state\": \"Revocation is self-serve and takes effect at once.\",\n \"system_behavior\": \"Rejects revoked credentials without a restart.\",\n \"acceptance_criteria\": [\n { \"id\": \"AC-1\", \"criterion\": \"An operator who revokes a key sees the next request with it rejected.\", \"verification\": \"The following call to the protected route returns 401.\", \"status\": \"confirmed\" },\n { \"id\": \"AC-2\", \"criterion\": \"Revocation is recorded with actor and timestamp.\", \"verification\": \"An audit row names the operator and the revoked key id.\", \"status\": \"open\" }\n ],\n \"nfrs\": [\n { \"category\": \"security/privacy\", \"requirement\": \"The raw key is never logged on the revoke path.\", \"implication\": \"Log the key id, never the secret.\", \"status\": \"open\" }\n ]\n },\n \"actionable_items\": [\n {\n \"id\": \"SCOPE-1\",\n \"question\": \"Scope: How many implementation tickets should encompass these requirements?\",\n \"why_it_matters\": \"Sets the agreed ticket count while preserving every requirement. An epic parent is additional for three or more implementation tickets.\",\n \"recommendation_explanation\": \"One ticket keeps this cohesive revocation change and its verification together within the existing sizing guidance.\",\n \"options\": [\"1 implementation ticket: revocation behavior and verification\", \"Discuss a different ticket count\"],\n \"option_consequences\": [\"Cover every requirement in one implementation ticket, with no epic parent.\", \"Agree a concrete count and coverage boundaries in chat before design work begins.\"],\n \"recommendation_index\": 0\n },\n {\n \"id\": \"R-1\",\n \"question\": \"Must revocation take effect immediately, or is eventual acceptable?\",\n \"why_it_matters\": \"Sets the hard bound AC-1 has to meet.\",\n \"recommendation_explanation\": \"A leaked key is an active incident; eventual leaves a usable window.\",\n \"options\": [\"Immediately (under 5s)\", \"Eventually (under 60s is acceptable)\"],\n \"option_consequences\": [\"AC-1 gains a 5s bound.\", \"AC-1 gains a 60s bound.\"],\n \"recommendation_index\": 0\n }\n ]\n }\n}\n```\n\n## Return\n\nGo back to Stage 5 item 3 of `/define-tickets`, make the `generate_decision_page` call,\nand handle its response `status` as item 4 describes.\n",
|
|
17
|
+
".bridge/procedures/define-tickets-drafting-plan-estimates-procedure.md": "# `/define-tickets` drafting-plan estimates procedure\n\nAn attended `/define-tickets` run reads this procedure in Stage 6 item 5, immediately\nbefore it composes the message that shows the recommended drafting plan. It holds the\nstatic time and credit guidance for that message. An `--auto` run never reads it.\n\n## Static guidance for the estimates\n\nUse this table and no other source for time and credits. It is **rough, static guidance - not measured duration or usage**. Label writer, reviewer, and every other unspecified credit cost as unknown, and never present an all-inclusive credit total. Separate the expected review credits from possible additional council charges and from the existing technical-to-general retry.\n\n| Step | Rough time | Rough credits |\n| --- | --- | --- |\n| Council before the design, or after the design with `request_council` | about 15 minutes | 26 credits for standard models to 65 for frontier models |\n| `second_opinion` | a few minutes per question | 5 credits per question, at most two questions |\n| Gap check (epic only) | a few minutes per reviewer round: up to two ordinary rounds for a low-risk epic or three for a high-risk one, plus any confirmation passes | unknown |\n| Gap-check councils (epic only) | an initial high-risk council and at most one additional qualifying council, each about 15 minutes | 26-65 credits each |\n| Parallel writer pass | about as long as the slowest single draft | unknown |\n| Upload | about one minute per ticket | unknown |\n\nThe credit range is the design council's own price for standard and frontier models, from `request_council` pricing in `api/library/billing/pricing.py`; the `second_opinion` fee is 5 credits.\n\n## Return\n\nGo back to Stage 6 item 5 of `/define-tickets` and compose the plan message with these\nfigures. They are rough guidance. Never present them as measured, and never invent a\nfigure this table does not give.\n",
|
|
18
|
+
".bridge/procedures/define-tickets-discovery-procedure.md": "# `/define-tickets` discovery procedure\n\n`/define-tickets` reads this procedure at the start of Stage 1, in attended and `--auto`\nruns alike. It holds the detail for exploring the codebase, researching unknowns,\nframing the acceptance criteria, the Stage 4 document skeleton, and the six\nsignals Stage 6 assesses to recommend the drafting plan. The command keeps inline the Stage 1 stop rule and\npath choice, the canonical NFR categories, the `SCOPE-1` scope question, every\n`--auto` pointer, and every halt. Each section below is followed at its pointer in\nStages 1 to 3. Step numbers inside a section match the command's item numbers.\n\n## Stage 1 items 1–6 — Explore\n\n1. **Analyze the prompt** to identify which areas of the codebase are relevant: route files, agent flows, database models, library utilities, LLM integration, MCP server, unit and E2E suites, etc.\n\n2. **Search for files** matching patterns related to the task (e.g., `api/routes/**/*.py`, `src/python/llms/agents/**/*.py`, `db/models/*.py`).\n\n3. **Search for content** — relevant function names, class names, patterns, and keywords across the codebase.\n\n4. **Read the most relevant files** in detail — understand existing implementations, conventions, and patterns that relate to the task.\n\n5. **Build a mental model** of:\n - What exists today that relates to the task\n - What patterns and conventions are used in similar features\n - What dependencies, data flows, and integration points are involved\n - What gaps or unknowns remain that need external research\n - Whether there is an established precedent for this kind of work, or none at all — Stage 7 depends on this judgement\n\nExplore to understand the problem and its constraints. Resist designing a solution while you read — you do not yet know what the system is required to do, and Stage 8 is where the design gets written.\n\n6. **Track all significant files** examined in `key_files_examined`.\n\n## Stage 1 item 7 — Choose the path\n\n7. **Choose the path (attended only).** Under `--auto`, skip this item: there is no path, so set `run_path` to `auto`. In an attended run, decide whether the run takes the short path or the full path, using the evidence from this stage and the Attended path contract above.\n- **Short path** only when all three hold: the work is likely 1-2 implementation tickets; an established precedent exists in this codebase for this kind of work; and the work touches none of the forced-full areas.\n- **Full path** whenever any of the three conditions is unmet or you are unsure. Uncertainty always resolves to full.\n- **The five forced-full areas:** security/auth; data model or migrations; billing; public API or MCP tool contracts; irreversible operations.\n- If the owner asked for the \"full path\" earlier in this conversation, honor that request in this initial selection.\n- Announce the choice in one line with its reason, for example `Path: short — one ticket, follows the existing <precedent>, no forced-full area.` or `Path: full — touches billing.` Record it in working state as `run_path` (`short` or `full`) and keep `escalated` as `false`. The owner can say \"full path\" at any point; see Switch to the full path in Stage 6.\n\n## Stage 2 — Research unknowns\n\nBased on gaps identified in Stage 1, decide what research is needed. Apply these decision rules:\n\n- **No research needed**: The codebase exploration answered all questions. Skip directly to Stage 3.\n- **Web search**: For quick factual lookups — library API signatures, configuration syntax, small \"how to\" questions. Examples: \"FastAPI dependency injection with custom headers\", \"Alembic batch migration syntax\". Do web searches inline and capture relevant findings.\n- **Deep research** (via `request_deep_research` MCP tool): For large, multi-faceted unknowns that require synthesizing information from multiple sources. Examples: \"Best practices for implementing WebSocket connection pooling in Python asyncio\", \"Tradeoffs between different approaches to real-time notification delivery in FastAPI applications\". Only use deep research when the question genuinely needs a multi-source investigation.\n\n**If deep research is needed:**\n\n1. Call `request_deep_research` with `wait_for_result` set to `true`, `save_locally` set to `true`, a descriptive `query`, and `context` describing the Bridge API tech stack and the specific task.\n2. If deep research fails, note the failure and fall back to web searches for the same topic. Do NOT halt the pipeline.\n\nTrack all research performed in `research_queries` and `web_searches`.\n\n## Stage 3 items 1–2 — Frame and criteria\n\n1. **State the frame plainly (required).**\n - **Business goal** — the value this work delivers and why it matters.\n - **Desired end-state** — the concrete state the system should reach once this work is done.\n - **System behavior** — how the system must behave to complete its task (the quality attributes in prose, not a feature list).\n\n2. **Derive the acceptance criteria — what the system must do (required).** Write 3-8 criteria. Each one gets:\n - An `id` (`AC-1`, `AC-2`, …).\n - A `criterion` — a single obligation stated concretely enough to be checked. Write it as observable behavior (\"an operator who revokes a key sees the next request rejected\"), not as a task (\"add a revocation endpoint\").\n - A `verification` — how we would confirm it holds. Name the observable signal: a response code on a specific route, a row state, a log line, a rendered element, a user-visible outcome. **A criterion nobody can check is not yet a criterion** — sharpen it or drop it.\n - A `status`, using the rubric in step 4.\n\n Cover the failure and edge behavior, not just the happy path. If the work changes something that already exists, at least one criterion should pin down what must **not** regress.\n\n## Stage 3 items 4–6 — Classify, questions, and tensions\n\n4. **Classify every acceptance criterion and every NFR** with this rubric: `confirmed` only if explicitly stated or observable in code; `assumed` only if a low-risk, reversible default; `open` if it touches architecture, the data model, security, user-visible behavior, migration, or irreversible creation and is not settled. When a criterion or an NFR is genuinely unclear, prefer marking it `open` and asking. Clear criteria make everything downstream more accurate, so surfacing an unclear one is a success, not a delay.\n\n5. **Frame the open requirement questions.** Where a requirement is unsettled **and** has discrete candidate answers, express it as a question the user can answer by clicking (e.g. \"Must revocation take effect immediately, or is eventual acceptable?\"). These become cards in Stage 5. They are questions about *what the system must do* — never about how to build it. If a question has no discrete answers, leave it as prose in the doc instead.\n\n6. **Sanity-check the frame against itself.** Do any two criteria conflict? Does a criterion conflict with an NFR (e.g. an auditability requirement against a latency budget)? Note every tension you find — Stage 7 treats these as a council trigger, and Stage 8 must resolve them explicitly rather than quietly favouring one side.\n\n## Stage 7 item 1 — The six signals\n\nStage 6 item 5 assesses these signals to recommend the drafting plan; Stage 7 runs only the plan Stage 6 recorded.\n\n1. **The six signals.** A signal fires when **any** of these hold:\n - More than one materially different approach could satisfy a criterion, and the codebase evidence you gathered cannot separate them.\n - A criterion has no obvious implementation path in the existing code.\n - Meeting one criterion appears to trade off against another criterion or against an NFR (any tension noted in Stage 3 step 6, or created by a correction in Stage 6).\n - The work touches an area with no established pattern — Stage 1 found no precedent to follow.\n - Ratification materially changed the problem — the user tightened a bound, rejected a criterion, or added an obligation you had not framed.\n - Stage 2 research surfaced competing approaches with no clear winner.\n\n No signal fires when every ratified criterion maps cleanly onto a well-trodden pattern already used in this codebase and you can point to the precedent.\n\n## Stage 4 — Document skeleton\n\nWrite the exploration document with this structure. The command adds the attended `## Decisions made for you` section after it.\n\n```markdown\n# Exploration: {concise summary of the prompt}\n\n**Date**: {current date}\n**Prompt**: {original prompt text}\n**Status**: Requirements drafted — awaiting ratification (under `--auto`: Requirements proposed, unratified)\n\n## Context\n\n{Brief description of the task and what areas of the codebase are relevant. Attended only: the chosen path (short or full) and the reason from Stage 1; add any later switch to the full path with its trigger. Under --auto, omit the path.}\n\n## Acceptance Criteria\n\n{The criteria from Stage 3 — what the system must do. One entry per criterion: its id, the criterion itself, how it is verified, and its status (confirmed / assumed / open).}\n\n## Goals & NFRs\n\n{The business goal, desired end-state, and required system behavior from Stage 3. Then the non-functional requirements — the standards the system must meet: each with its category, requirement, implication, and status (confirmed / assumed / open). Note any tension between criteria or between a criterion and an NFR.}\n\n## Ticket Scope\n\n{Attended only: the proposed implementation-ticket count, its rationale, each ticket's approximate responsibility, and the alternatives for SCOPE-1. Mark it proposed until explicitly agreed; disclose any additional epic parent. Under --auto, omit this section.}\n\n## Open Questions\n\n{Requirement questions that are still unsettled. Mark which ones are going onto the decision page as cards and which are open-ended prose.}\n\n## Codebase Findings\n\n{Key discoveries from Stage 1, organized under the four stop-rule categories: the affected behavior, the files to change, the relevant callers and tests, and the risks. Name each with concrete file_path:line_number citations, and note the precedent to follow. Also note what exists today and which patterns are used.}\n\n## Research Findings\n\n{Findings from web searches and deep research, if any. If no research was performed, state \"No external research was needed.\"}\n\n## Key Files\n\n{Bulleted list of the most important files examined, with one-line descriptions of their relevance.}\n\n```\n\n## Return\n\nGo back to the `/define-tickets` pointer that sent you here and continue from that\npoint. This procedure adds no stop, no halt reason, and no terminal field.\n",
|
|
19
|
+
".bridge/procedures/define-tickets-design-procedure.md": "# `/define-tickets` design procedure\n\n`/define-tickets` reads this procedure at the start of Stage 8, in attended and `--auto`\nruns alike. It holds the detail for working out, recording, and presenting the design.\nThe command keeps inline the agreed ticket count, the path check after the split, the\nafter-design review, the document rewrite, the blast-radius prepass, every `--auto`\npointer, and every halt. Each section below is followed at its pointer in Stage 8.\n\n## Stage 8 items 1–3 — Work out and commit to the design\n\n1. **Work out the design against the ratified criteria.** Consider the approaches you know plus anything the council surfaced. For each candidate, establish which criteria it satisfies and at what cost. An approach that cannot meet a ratified criterion is not a candidate — discard it and say why.\n\n2. **Resolve any tension explicitly.** Where meeting one criterion costs another, or costs an NFR, state which obligation your design privileges and what that costs the other. Do not let a tension pass silently.\n\n3. **Commit to a single proposed design.** You are recommending, not offering a menu. Name the approach, describe how it works, list the files to create or modify, and map each ratified criterion to the part of the design that satisfies it. Where you seriously considered an alternative, record it and why you rejected it — as history, not as an open choice.\n\n **State how SFCC browser checks are verified.** For a Salesforce B2C Commerce repository, `## Criteria Coverage` states how each browser-checked criterion is verified. When an approved SFCC sandbox is configured, in any mode, changed cartridge files are uploaded first with `epic-implementer epic-server sfcc-upload`. The check then runs through the local dev server in `local` mode, or on the shared sandbox storefront in `sfcc_shared_active`. Storefront Next React-only changes need no upload and are checked through the local dev server in `local` mode. In `none` or `unknown` mode, the verification is a visible recorded hand-off. Never claim the sandbox storefront proves React-only changes. When a needed sandbox capability is unavailable, follow the ticket writer's rule for a requirement that defers what a criterion needs, and add no new prerequisite or stop. Never design a verification around a whole-cartridge upload, a Managed Runtime (MRT) push, a per-ticket code version, a code-version switch, or the repository deploy workflow.\n\n## Stage 8 item 3 — Record the slices with a size band\n\n**Record the implementation slices with a size band.** The design's sequence of work is also the proposed ticket split, so name each slice and size it with the ladder in the posture block below — `S` / `M` / `L` / `XL`, by file-touch breadth and rough LOC. Size the slices here, in the design, rather than at the handoff gate: the split is a design decision, and deciding it under the pressure of an approval prompt is how a coherent design turns into a swarm of tiny tickets. A slice that will not fit in `L` becomes one `XL` slice — do not split it to fit a band. Split only when it is genuinely two independent pieces of work, or when it runs past roughly 40 files / ~3000 LOC.\n\n## Stage 8 item 6 — Present the design\n\n6. **Present the design in chat and invite pushback.** Summarize the proposal in at most six bullets — the approach, the files it creates or modifies, the order of the work, and any ratified criterion the design only partially meets — and state clearly that it is a proposal. If the user objects, revise the design — but if their objection actually changes what the system must do rather than how it is built, say so: that is a criteria change, and it means reopening the criteria rather than quietly bending the design around it.\n\n## Stage 8 item 4 — Second opinion calls\n\nmake one call per recorded question, at most two calls and 10 credits. Each call sends a self-contained `prompt` holding the finished design, its slices, the unchanged requirements, and that one question, with a `model` tier and a `provider` family different from the one you run on. The reply text is returned synchronously.\n\n## Stage 9 item 1 — Readiness follow-ups\n\nWhen something is still open at the Stage 9 readiness check, recommend the follow-up that would close it rather than creating a ticket on a soft foundation:\n\n- A **wider council** (`request_council`) when the design would benefit from a broad review before implementation. If Stage 7 or Stage 8 already ran one, only suggest another when something material changed since.\n- A **second opinion** (`second_opinion`) when a few specific contested points need an independent check.\n- **Web or deep research** (`request_deep_research`) when the design still rests on technical unknowns that need grounding.\n\n## Return\n\nGo back to the `/define-tickets` Stage 8 pointer that sent you here and continue from\nthat point. This procedure adds no stop, no halt reason, and no terminal field.\n",
|
|
20
|
+
".bridge/procedures/define-tickets-writer-output-procedure.md": "# `/define-tickets` writer-output procedure\n\n`/define-tickets` reads this procedure in Stage 9, in attended and `--auto` runs alike,\nonce, before it launches the first `jira-ticket-writer` invocation. It holds the details\nof what every writer receives and how each writer's output is handled before the upload\ngate. The command keeps inline the split, the writer fan-out, the research packet, the\ndraft check, the open-question rules, the phrase backstop, the upload gate, creation,\nand every halt. Each section below is followed at its pointer in Stage 9.\n\n## Invocation inputs\n\nFor the epic parent, pass the prospective verdict and proposals together: the verdict `accepted_with_gaps` when proposed acceptances exist, the exact proposed overrides with their reasons, the existing recorded overrides, and the record's coverage map.\n\nPass into every invocation, verbatim: the ratified acceptance criteria that entry satisfies, the proposed design for its slice, the entry's own manifest fields, and the doc's ratified `## Goals & NFRs` section — the business goal, desired end-state, system behavior, and every NFR with its requirement and implication. Pass the whole section to every entry, not a subset you picked: the writer decides which NFRs bear on its entry, and an NFR whose implication applies to every ticket (for example \"each ticket carries a producer-and-exit table\") is lost if it reaches only the parent. Do not restate or reinterpret the criteria or the NFRs — they were ratified in that wording, and they go to the writer unchanged. For an epic, also pass:\n- to each **child** invocation, that child's `owns_verifications` entries, word for word. The draft's acceptance criteria must keep each obligation verbatim, so the created child still carries the evidence that was reviewed. Check each child draft for this before the upload gate;\n- to the **parent** invocation, the record's coverage map — taken from the record, including each owner-run owner with its person or role and step reference — its exact verdict, and every override with its recorded reason, for the parent's `## Epic coverage map` section. Owner-run obligations go to the parent's map only, never to a child invocation.\n\n## Draft paths, standard warnings, and the terminal report\n\n**Give every writer invocation an explicit draft path, and record it for that entry.** Without one the writer falls back to its own default location and the command never learns the path, which the materials pass below needs. Use one draft directory per run: attended, `{docs_dir}/explorations/{slug}-drafts/`; under `--auto`, `{docs_dir}/explorations/{slug}-{run_id}/drafts/` (the artifact directory Stage 0 step 5 creates). Use fixed file names so a file maps to its entry: `parent.md`, `child-{N}.md` (`{N}` is the 1-based manifest position), and `sibling-{N}.md`. A draft file that is missing after a writer run is a writer failure; under `--auto` that is the `stage_failed` halt above.\n\n**Keep each writer's standard warning.** A writer adds one only when its lookup failed or a configured instruction conflicted: a fenced code block with info string `ticket-standard`, holding `Ticket standard: …` and `Standard conflicts: …`, just before the terminal `open-questions` block. No block is normal: no note, no revision. Find it by its info string, never by line position. Classify each block under the canonical contract in `docs/bridge-ticket-standard.md`. A block is malformed when the reply has more than one `ticket-standard` block, when its content is not exactly the two lines of one permitted form, or when it comes after the terminal `open-questions` block. For each entry, retain either the exact valid pair next to the draft path you assigned to the same entry, or a malformed marker when the block is malformed, as a separate record for the parent, each child, or each sibling. A malformed block is a warning only: quote none of its content, request no revision because of it, and fail neither the draft nor the run. Never keep one run-wide source, never merge the conflict lists of different entries, and never write a pair the writer did not return. When an existing workflow redrafts an entry, replace that entry's retained pair or marker with the new draft's state, if any, so a stale pair or marker cannot survive a revision. Neither line belongs in the draft, the exploration document, or the uploaded description. This command does not read `ticket_correctness_standards` and does not forward a resolved ticket standard: each writer resolves it for itself, and the project-standards gathering and the regression gate stay owned here as before.\n\n**Require the terminal writer report on every invocation.** Every writer invocation, whether the initial call, a retry, or a revision, must end its reply with the writer's `open-questions` report, after the draft path. The contract is:\n\n> Exactly one fenced code block with info string `open-questions` must end the writer's reply, with no trailing prose. Its content is either the literal `none` alone or one entry per unsettled choice in the form `- question: … / why it blocks: … / options: …`, with all three fields non-empty. Empty, duplicate, mixed, incomplete, or non-terminal blocks are malformed. Missing or malformed blocks require writer revision and never mean \"settled.\" The block is reply-only and never belongs in the ticket body.\n\nThe report is reply-only. Never copy it into a draft or a Jira body.\n\n## Parent manifest section\n\n**Normalize the epic parent's manifest section (epic only, automatic, no stop).** Ask the epic-parent writer for exactly this section, a peer-level `##` heading:\n\n```markdown\n## Ordered child manifest\n\n- pending: child keys are written here after the children are created.\n```\n\nThen, before the upload gate, normalize the local parent draft (`parent.md`) yourself so it holds exactly one canonical `## Ordered child manifest` section with that fixed pending line. A manifest-section span runs from its heading through the line before the next `#` or `##` heading, or through the end of the body. Replace the first such span, remove every other manifest span (duplicates), and preserve every byte outside those spans. Place the normalized section immediately before `## Materials & Access`; when that heading is absent, append the section at the end of the body with a preceding blank line. The manifest stays a peer-level `##` section, so `## Materials & Access` remains the final major section when present. Normalization is idempotent: running it on an already-normalized draft changes nothing. It adds no approval, stop, owner question, or change to the frozen child split. The normalized local Markdown is the **parent Markdown source**: it is the initial parent body, and any later parent materials update advances the source to the last Markdown actually submitted for the parent. Fetched Jira text is never that source.\n\n## Two-sibling overlap check\n\n**Two-sibling overlap check (attended only).** When the shape is exactly two ordinary siblings, and after both drafts exist and pass the checks above, the main agent reads both finished drafts and assesses their scope boundaries, shared files, and criterion coverage. A shared file is a finding to assess; it is not automatic proof of overlap and not a reason to create an epic. Render exactly one outline line: `Overlap check: none`, or `Overlap check: {overlapping files, scope, or uncovered criteria}`. Recompute the line after any affected draft changes. This check adds no reviewer invocation, persisted record, extra prompt, or stop, and it never applies under `--auto` or to a lone ticket.\n\n## Carried-finding repair\n\nCopy each carried finding passed to a writer from `carried_ticket_local` in `epic-coherence.json`. Never retype it. When every `check-drafts` failure for a draft is `draft_missing_carried_finding`, repair that draft without a writer: rewrite the finding's bullet under `## Carried from epic coherence review` from the record's exact strings, then run the check again. Any other failure is a writer defect.\n\n## Return\n\nGo back to the Stage 9 pointer that sent you here and continue from that point. A\nfailure keeps the command's own writer-failure path, its `stage_failed` halt under\n`--auto`, and its terminal contract; this procedure adds no halt reason, no stop, and\nno terminal field.\n",
|
|
21
|
+
".bridge/procedures/define-tickets-post-create-procedure.md": "# `/define-tickets` post-create procedure\n\n`/define-tickets` reads this procedure in Stage 9, in attended and `--auto` runs alike,\nonce, before its first `create_ticket` call. It holds the per-ticket materials\npre-check and inputs and the advisory real-key manifest write that follow creation.\nThe command keeps inline the creation authorization, the creation order, tracking, the\nmaterials procedure lookup, the partial-failure stop, and every halt. Each section\nbelow is followed at its pointer in Stage 9.\n\n## Materials pre-check and inputs\n\n**Materials pre-check, before resolving or reading the procedure.** Read the draft at the path recorded for this entry. If it is readable, classify it as having no materials when its `## Materials & Access` section is absent, or when that section holds no real eligible item under `Planning Assets`, `Downloadable Assets`, or `Planning & Downloadable Assets`. Headings alone, `none`, placeholders, the writer's line `No external materials are referenced`, and record-only references are not eligible items. For a confirmed-empty key, skip the procedure read, the materials `config_field` lookup, and every attachment operation, and record the per-key outcome as `no materials`. If the draft cannot be read, warn and fall through to the materials procedure below; never classify an unread draft as empty. For a ticket that does have materials, continue as written below.\n\nFor a ticket that does have eligible materials (or whose draft could not be read), run the procedure. Pass three inputs: `ticket_number` (the created key), `draft_file_path` (that entry's draft path from above), and `auto_approve_external`. Pass the literal `\"true\"` in every run, attended or `--auto`: external and auth-gated links stay record-only and nothing prompts, so the materials pass never adds a question. Mind the polarity: in that procedure `\"true\"` means unattended, the more restrictive mode. It is not permission to attach external links.\n\n## No idempotency labels\n\nIdempotency labels are deliberately not used. They ride on `create_ticket`'s `labels` argument and are read back through `get_tickets(labels=...)`, and **both are Jira-only**: against the local ticket backend each returns a terminal `409 UNSUPPORTED_IN_LOCAL_MODE`, and the create rejects without making a ticket. A resume protocol built on them would work on one backend and silently fail on the other.\n\n## Real-key manifest\n\n**Write the real-key manifest (epic only, advisory, after every child exists).** After the complete child-creation loop and every materials pass, and before the plan DAG step, replace the parent's pending manifest with the frozen run order, using real keys. This is a command-owned operation; the epic hand-off procedure does not do it.\n\n- **Entry template.** One line per child, in frozen manifest order:\n\n ```text\n - {CHILD-KEY} depends_on: {KEY, KEY}\n ```\n\n The dependency value is `none` when the child has no hard prerequisites (`depends_on: none`). List hard `depends_on` prerequisites only, comma-separated. Never list `recommended_after`.\n- **Keys.** Resolve every child and every hard prerequisite through the confirmed `create_ticket` result mapping. Never infer a key from a child number or title. If any child or dependency has no confirmed real key, skip only this write. Never submit `TBD-N`, `CHILD-N`, or any other placeholder key.\n- **Read-only check.** Read the epic's current description with the existing ticket read and require exactly one parser-counted manifest heading: a Markdown `##` or a Jira `h2.` heading beginning \"Ordered child manifest\". The fetched text is read-only evidence. It is never used as update content and never patched.\n- **Body.** Build the outgoing body only from the parent Markdown source: replace its manifest span (heading through the next `#`/`##` heading or end of body) with the new section, and preserve all remaining local Markdown byte for byte. Submit it with `update_ticket_description` using that Markdown, and keep it as the new parent Markdown source. An identical repeat operation resends the same body. Never fall back to an older draft when a newer parent Markdown submission exists but its local source is unreadable.\n- **Failure is a warning.** An unreadable local source, a failed description read, a heading count other than one, a failed update, or a held update is a warning that names the epic key in the Final Report prose. Submit nothing when a precondition is unavailable. Do not retry, ask for approval, ask the owner, halt, park, or classify it as `create_failed`. Continue to the plan DAG step.\n- **Partial creation.** If child creation stopped partway, skip this operation entirely and leave the pending manifest untouched.\n- **Report.** Add the outcome (`written`, `skipped`, or `warning: <reason>`) to the Final Report line below. It adds no terminal JSON field.\n\n## Why track\n\nBridge's workflow state lives in its own database, not in the ticket backend, and an untracked ticket is invisible to it — `update_ticket_state` and `get_ticket_state` both return 404 until something registers the key. Tracking works against either ticket backend and is a safe no-op when the key is already tracked.\n\n## Return\n\nGo back to the Stage 9 pointer that sent you here and continue from that point. Both\noperations are warn, not halt: a failure is reported in the Final Report and never\nchanges a halt reason or adds a terminal field.\n",
|
|
13
22
|
".bridge/README.md": "# The `.bridge/` directory\n\nThis directory holds Bridge's files for this project. Bridge owns this README\nand refreshes it every time you run install or upgrade, so do not edit it.\n\n## What is in here\n\n| Path | What it is | Commit it? |\n|---|---|---|\n| `config` | Records the project identity. It has no secrets. | Yes |\n| `pipelines/` | Your own pipeline JSON files. | Yes |\n| `instructions/` | Your own instruction files used by pipelines. Bridge creates the directory empty and never writes files into it. | Yes |\n| `procedures/` | Bridge-owned procedures that commands read directly. | Yes |\n| `README.md` | This file. | Yes |\n| `install-state.json` | Machine-local install state. Git-ignored. | No |\n| `bridge-permissions.json` | Machine-local permission state. Git-ignored. | No |\n\n## Customizing pipelines\n\nA pipeline step can load an instruction file. If you put a file with the same\nname in `instructions/`, your file replaces the bundled instruction for the\npipelines that load that instruction.\n\nThis does not change the procedures in `procedures/`. Commands read those files\ndirectly, not through a pipeline, so an instruction override never reaches them.\n\n## Procedures\n\n`procedures/` holds command procedures that Bridge owns. Bridge refreshes them on\ninstall and upgrade. Do not edit them. There is no supported way to customize\nthese procedures today.\n\nOlder Bridge versions put these files under `docs/install/`. If you still have\ncopies there, they are old fallback copies. Bridge now reads `procedures/`\nfirst. You can delete the old copies once the new `procedures/` files are\ncommitted.\n\n## Moving the pipelines directory\n\n`BAPI_PIPELINES_DIR` moves the pipelines directory and its sibling instructions\ndirectory. It does not move `procedures/`, which always stays at\n`.bridge/procedures/`.\n\n## Committing and repair\n\nCommit this README and the files in `procedures/` so every teammate and every\nworktree has them. If a package-managed file goes missing, `repair-assets`\nrestores it without overwriting files that already exist.\n",
|
|
14
|
-
"docs/install/epic-implementer-install.md": "# Run your first epic with the Epic Implementer\n\nThe Epic Implementer takes a planned epic, hands each child ticket to an agent on your computer, waits for CI and review, and merges each child pull request into an `epic/<EPIC>` branch. A person merges the final pull request into your default branch.\n\nYou do four things, in this order: install, set up, define the epic, launch it. The same steps work with Bridge's own ticket storage and with Jira.\n\nIn every command below, `npx -y @bridge_gpt/mcp-server` is the launcher. Keep the `-y`; without it, `npx` stops to ask before it installs the package.\n\n## Prerequisites\n\nSetup checks every item below for you, fixes what it can, and prints the one step it cannot fix. Read this list only when setup reports an item. Each bullet gives the item's name, its id, what it means, and the fix.\n\n- **Unattended posture (Setup page)** (`server.unattended-posture`) — Bridge allows unattended runs for this repository. Fix: Turn on **Allow unattended Epic Implementer runs** on the repository Setup page, or launch with `--attended`.\n- **Resolved merge mode** (`server.resolved-merge-mode`) — Bridge knows how child pull requests will be merged (your computer, a machine token, or GitHub Actions). Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Provider repository** (`server.provider-repository`) — Bridge knows the GitHub `owner/name` of this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **Supervisor setup** (`server.supervisor-setup`) — The repository has a stored supervisor record. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor configuration** (`server.supervisor-config`) — The supervisor record is complete: the test gate and the safe defaults are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor required CI checks** (`server.supervisor-required-checks`) — The CI checks a child pull request must pass before it merges are stored. Fix: Run setup and confirm the gate it proposes, or name a check with `--required-check <name>`.\n- **Review policy** (`server.review-policy`) — The review policy for child pull requests is known. AI review is an opt-in choice by the repository admin. Fix: Nothing is needed unless you want AI review. Choose a policy at launch with `--review-policy`.\n- **GitHub App credentials** (`server.github-credentials`) — Bridge's GitHub App is connected and can read this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **Provider default branch readable** (`server.provider-default-branch-readable`) — Bridge can read this repository's default branch from GitHub. Fix: Reconnect the GitHub App with `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **GitHub App actions permission** (`server.github-actions-permission`) — The GitHub App may start workflow runs. Only needed when merges go through GitHub Actions. Fix: Accept the updated permission on the GitHub App's installation page, then run setup again.\n- **Merge workflow eligibility** (`server.merge-execution-workflow`) — The merge workflow file is on the default branch and current. Only needed when merges go through GitHub Actions. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer --merge-workflow --codeowner <@org/team|@user>`, merge the pull request it opens, then run setup again.\n- **Merge branch policy** (`server.merge-execution-branch-policy`) — The default branch rules let the merge workflow do its job. Only needed when merges go through GitHub Actions. Fix: Adjust the branch rule or ruleset as setup describes, then run setup again.\n- **Executor server observation** (`server.executor-readiness`) — Bridge has seen a heartbeat from an executor for this repository. Before your first run this can be missing: `drive-epic` starts the executor for each run. Fix: Launch the epic with `npx -y @bridge_gpt/mcp-server drive-epic <EPIC>`.\n- **Review workflow protocol** (`server.review-workflow`) — The review workflow on the default branch matches the review policy. Only needed with AI review. Fix: Run setup; it names the workflow change to make.\n- **Conductor CI migration guard** (`server.conductor-ci-workflow`) — The CI workflow file `epic-implementer-ci.yml` is on the default branch and runs the migration guard where needed. Fix: Run setup, merge the setup pull request it opens, then run setup again.\n- **Escalation channel (webhook or email)** (`server.unattended-notify-default`) — Bridge has somewhere to send an escalation: a verified notify webhook, or your account email. Fix: Declare a notify webhook, or verify your account email.\n- **Escalation webhook reachable** (`server.escalation-webhook-reachable`) — A declared notify webhook answers Bridge's test request. Only checked for unattended runs that declare a webhook. Fix: Start or fix the notify sink so it answers with a 2xx status, or launch with `--attended`.\n- **Repository workflow readiness** (`server.repository-workflow-readiness`) — The CI and review workflows are confirmed on the default branch. Fix: Run setup, merge the setup pull request, then run setup again.\n- **Workflows at indexed commit** (`server.indexed-workflows`) — The repository index includes the workflow files on the default branch. Fix: Merge the setup pull request, then run setup again. It starts the re-index and reports this item as pending until the index reaches that commit.\n- **Integration branch configured** (`server.integration-branch-unset`) — The repository has an integration branch set. This is a note only and never blocks a launch. Fix: Nothing is needed. Set the repository's base branch to clear the note.\n- **Service availability** (`server.service-availability`) — Bridge could read this repository's readiness from the server. Fix: Retry in a few minutes. If it keeps failing, email info@bridgegpt.ai.\n- **Claude login** (`install.claude-login`) — Claude Code is signed in on this computer. Fix: Run `claude` and sign in, then run setup again.\n- **Repository identity** (`install.identity`) — Bridge knows which repository this folder is. Fix: Run setup from the repository root, or pass `--repo <name>`.\n- **Bridge API credential** (`install.credential`) — A Bridge API key is stored for this repository. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **Server connectivity** (`install.connectivity`) — This computer can reach the Bridge server. Fix: Check your network and any `BAPI_BASE_URL` setting, then run setup again.\n- **Bootstrap config fields** (`install.bootstrap`) — The repository's Bridge configuration fields are filled in. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **Integration credentials** (`install.integrations`) — The integration credentials this repository uses, such as Jira or GitHub, are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **GitHub connection** (`install.github`) — Bridge's GitHub App is connected to this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`.\n- **Repository indexing** (`install.indexing`) — The repository has been indexed by Bridge. Fix: Run `/parse-repository`, or let setup queue the index.\n- **Conductor event ledger** (`conductor.ledger`) — The local Epic Implementer event ledger can be read. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Conductor git hooks** (`conductor.git-hooks`) — Optional: the git hooks that feed the local event ledger are installed. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer install-git-hooks`.\n- **Epic Implementer MCP profile** (`conductor.mcp-profile`) — The `epic_implementer` tool profile is on in your MCP host. Fix: Let setup add it (it asks first), then restart your MCP client.\n- **GitHub CLI availability** (`conductor.gh-cli`) — The GitHub CLI (`gh`) is installed and signed in. Fix: Install `gh` and run `gh auth login`.\n- **Configured merge credential** (`conductor.merge-credential`) — A GitHub token for merging child pull requests is available on this computer. Fix: Let setup store one (it asks first), or set `GITHUB_MERGE_TOKEN`.\n- **Native ledger binding** (`conductor.native-ledger`) — The ledger's native component loads on this computer. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Worker MCP registration form** (`conductor.mcp-registration-form`) — Workers register the Bridge tools in the form the executor expects. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Expected Node engine** (`conductor.node-engine`) — The Node.js version meets the package's engine range. Fix: Install a supported Node.js (18 or newer; 20 or newer for the git hooks).\n- **Deny-layer enforcement** (`conductor.deny-enforcement`) — Claude Code enforces the permission denials that keep workers inside the repository. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` to see why the check could not confirm it.\n- **Claude login** (`conductor.claude-login`) — Claude Code is signed in for the workers. Fix: Run `claude` and sign in, then run setup again.\n- **Merge credential capability** (`conductor.merge-credential-capability`) — The merge token can push to the repository and read pull requests. Fix: Replace the token (setup offers to), then run setup again.\n- **Worktree preparation** (`conductor.worktree-preparation`) — The executor's clone can keep its working files out of git (`.git/info/exclude` exists or can be written). Fix: Make `.git/info/exclude` writable in this clone.\n- **Supervisor gate profile** (`conductor.install-section-supervisor-gate-profile`) — The repository's test gate profile is stored and valid. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor required CI checks** (`conductor.install-section-supervisor-required-checks`) — The required CI checks in the gate match checks the provider reports. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor review-policy alignment** (`conductor.install-section-supervisor-review-alignment`) — The review policy and the review workflow agree. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **GitHub App actions permission** (`conductor.install-section-github-actions-permission`) — The GitHub App may start workflow runs. Only needed when merges go through GitHub Actions. Fix: Accept the updated permission on the GitHub App's installation page.\n- **Merge execution eligibility** (`conductor.install-section-merge-execution-eligibility`) — This repository can use GitHub Actions merges. Only needed for that merge mode. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer --merge-workflow --codeowner <@org/team|@user>` and merge its pull request.\n- **Epic Implementer MCP profile token** (`conductor.install-section-epic-implementer-profile-token`) — The Bridge key used by the Epic Implementer tool profile is stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Conductor hook targets** (`conductor.install-section-conductor-hook-targets`) — The git hook targets are in place for this clone. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer install-git-hooks`.\n- **GitHub Actions merge: local observation prerequisites** (`conductor.install-section-gh-actions-merge-auth`) — This computer can observe GitHub Actions merges. Only needed for that merge mode. Fix: Sign in with `gh auth login` and rerun setup.\n- **GitHub Actions merge: capability observability** (`conductor.install-section-gh-actions-merge-observable`) — Bridge can observe the outcome of GitHub Actions merges. Only needed for that merge mode. Fix: Rerun setup and follow the step it prints.\n- **Epic Implementer ledger loadability** (`conductor.install-section-epic-implementer-ledger-loadability`) — The local ledger can be loaded by the tools that read it. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Launch evidence** (`server.admission-evidence`) — Bridge has the evidence it needs to admit a launch. Fix: Run setup, then launch again.\n- **Launch evidence: unattended consent** (`server.admission-unattended-consent`) — Launch check: unattended runs are allowed. Fix: Turn on **Allow unattended Epic Implementer runs** on the Setup page, or launch with `--attended`.\n- **Launch evidence: notification destination** (`server.admission-notify-webhook`) — Launch check: an escalation destination is verified. Fix: Declare a notify webhook, or verify your account email.\n- **Launch evidence: repository workflows** (`server.admission-repository-readiness`) — Launch check: the CI and review workflows are confirmed. Fix: Run setup, merge the setup pull request, then run setup again.\n- **Launch evidence: required CI checks** (`server.admission-required-checks`) — Launch check: the required CI checks are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Launch evidence: indexed repository** (`server.admission-index-provenance`) — Launch check: the index reaches the commit that holds the workflows. Fix: Merge the setup pull request, then run setup again.\n- **Repository test gate** (`server.gate-profile`) — The repository's test gate is stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Repository test gate warnings** (`server.gate-profile-warnings`) — The stored test gate has no unresolved warnings. Fix: Read the warnings setup prints and confirm or edit the gate.\n- **Effective review mode** (`server.effective-review-mode`) — Bridge shows which review mode child pull requests will use. Fix: Choose a review policy at launch with `--review-policy` if you want a different one.\n- **Epic branch CI** (`server.epic-branch-ci-decision`) — Someone has decided whether CI runs on pull requests into the epic branch. Fix: Run setup and answer the epic-branch CI question, or pass `--epic-branch-ci-decision include|decline`.\n- **Epic branch CI coverage** (`server.epic-branch-ci-coverage-warning`) — Your CI covers pull requests into the epic branch. Fix: Add `epic/**` to the branches your CI workflow runs on.\n- **Additional readiness diagnostics** (`server.diagnostics`) — Extra readiness diagnostics from the server are clear. Fix: Read the diagnostic text; each names its own fix.\n- **Command versions** (`conductor.command-drift`) — The installed Epic Implementer commands match this package's version. Fix: Run `npx -y @bridge_gpt/mcp-server install` to refresh them.\n- **Escalation delivery** (`escalation-reachability`) — An escalation can actually be delivered. Fix: Verify your account email or fix the webhook, then run setup again.\n\n## 1. Install\n\nRun this once per project. Skip it when Bridge is already installed.\n\n```bash\nnpx -y @bridge_gpt/mcp-server install\n```\n\nIt writes this guide to `docs/install/epic-implementer-install.md` in your project. Run it again any time to refresh that file.\n\n## 2. Set up\n\nRun this once per repository, from the repository root, in your own terminal:\n\n```bash\nnpx -y @bridge_gpt/mcp-server install epic-implementer\n```\n\n`install-bridge conductor` is the same command with another spelling. Setup checks everything first (read-only), fixes only what is missing, checks again, and ends with one verdict: \"Ready for your first epic\" or \"Not ready: N steps left\", with the fix for each step. It asks before anything that writes, and without a terminal every question is a \"no\".\n\nWhen setup reports that its setup pull request is waiting, it prints `merge the setup PR` with the pull request's address. Merge that pull request, then run setup again. Setup starts the re-index, and reports the item as pending (\"indexing is running; re-run setup when it finishes\", or \"indexing was queued; re-run setup when it finishes\") until the index reaches the merged commit. Run setup again until it says \"Ready for your first epic\".\n\n### View or change the test command\n\nSetup prints the stored test command on every run:\n\n```text\nTest command: `npm test` (stored). Change it with --test-command \"...\".\n```\n\nTo save or replace it, pass the command yourself:\n\n```bash\nnpx -y @bridge_gpt/mcp-server install epic-implementer --test-command \"npm run lint && npm run build\"\n```\n\nThe flag is your consent for that one write, so setup asks no command question. It checks the command first (one line, no `${{`, at most 500 characters), saves it once, and reads it back. It reports success only when the stored value matches. Passing the same command again says \"Test command unchanged\" and writes nothing. With `--dry-run`, nothing is saved.\n\nTwo things stay separate from the flag. Setup still asks you to confirm the Bridge URL, so the command needs a terminal. And opening the setup pull request asks for its own consent: after you replace the command, setup offers the update pull request in the same run, and a command you declined to ship stays saved.\n\nDo not put a credential in the test command. Setup prints it, and the workflow file contains it.\n\n### What CI installs automatically\n\nThe setup pull request adds `.github/workflows/epic-implementer-ci.yml`. Before it runs your test command, the workflow installs your dependencies from the files in your repository root. Bridge reads those files on your computer when it generates the workflow, and it never runs a package manager to decide.\n\n| Language | Dependency file, first match wins | What CI runs |\n| --- | --- | --- |\n| JavaScript | `pnpm-lock.yaml`, `yarn.lock`, `npm-shrinkwrap.json`, `package-lock.json`, `bun.lock`, `bun.lockb` | `pnpm install`, `yarn install` (Yarn classic or Berry), `npm ci`, or `bun install`, each in its frozen form so the lockfile is used exactly as committed |\n| Python | `uv.lock`, `poetry.lock`, `requirements.txt` | `uv sync` (frozen), `poetry install`, or `pip install` from `requirements.txt` |\n| Go | `go.mod` | Go is set up from `go.mod`. |\n\n- **Mixed repositories** get every language they have, in the order JavaScript, Python, Go.\n- **Versions.** Node comes from `.nvmrc`, then `.node-version`, otherwise Node 24. Python comes from `.python-version`, otherwise Python 3.12. pnpm uses the version in `package.json` `packageManager` when it is valid, otherwise pnpm 10. Yarn is classic or Berry according to `.yarnrc.yml`, `packageManager`, and the lockfile; Berry runs through Corepack, which uses the Yarn version your `package.json` declares, otherwise Yarn 4. Poetry is installed at a fixed version, and Bun at the latest 1.x release. Every action is pinned to a fixed major version.\n- **uv and Poetry** projects must declare development dependencies such as `pytest` in the project. Their environments are put on `PATH`, so your stored command runs unchanged inside the project environment.\n- **If Bridge cannot read a file it needs**, or `package.json` contradicts the lockfile (for example a `packageManager` for a different tool), setup reports the dependency setup as unknown and blocks the workflow. It does not guess.\n- **Upgrades are reviewed.** An older Bridge-written workflow is replaced through a pull request you merge, never silently. If a setup pull request from an earlier release is still open, merge or close it first; setup names it and leaves it alone.\n\n### When your command must be self-contained\n\nSome repositories get no automatic installation, and setup says so in plain words:\n\n- **Python with no `uv.lock`, `poetry.lock`, or `requirements.txt`** (for example only `pyproject.toml` or `Pipfile`) gets no Python installation. Add a supported file, or make the command install what it needs.\n- **Rust** uses the toolchain the CI runner already has. If that is not enough, install what you need inside the command.\n- **No lockfile, or a Make-only project**, shows as `none`: Bridge installs no dependencies, so the command must install them itself.\n\nA command that installs its own dependencies is always allowed. Nothing in the workflow adds to your command, wraps it, or sets a prefix in front of it.\n\n### Recover from a stale CLI\n\nAn old copy of the command line tool can print old wording or miss a flag such as `--test-command`. Bridge checks the npm registry for a newer release about once a day and says so at the start of a session. That notice only reports that a newer version exists; it cannot tell you which copy `npx` actually ran. Likely causes are a cached `npx` download or a project-local install that `npx` picked first. Neither is proven for any one machine.\n\n1. See which version ran: `npx -y @bridge_gpt/mcp-server doctor`. Its `Bridge MCP version:` line gives the installed version and the latest one, and says when an upgrade is available.\n2. Fetch the newest release by running through `@latest`: `npx -y @bridge_gpt/mcp-server@latest doctor`. The `Bridge MCP version:` line should now show the latest version.\n3. Refresh the installed command files: `npx -y @bridge_gpt/mcp-server@latest install`.\n4. Run setup again: `npx -y @bridge_gpt/mcp-server@latest install epic-implementer`.\n5. If the output is still wrong, email info@bridgegpt.ai with the `Bridge MCP version:` line from step 1 and the setup output, with any secret removed.\n\n## 3. Define the epic\n\nIn Claude Code, run:\n\n```text\n/define-tickets\n```\n\nIt writes real child ticket keys, `epic-plan.dag.json`, and `epic-plan.meta.json`, then hands off to `/drive-epic-run`. The meta file is how the launch finds the plan from the epic key.\n\n## 4. Launch\n\nIn Claude Code, run:\n\n```text\n/drive-epic-run <EPIC> [<plan path>]\n```\n\nIt previews the launch, asks you once, creates the run through `drive-epic`, and drives the run to the end. From a shell, run the same launch yourself:\n\n```bash\nnpx -y @bridge_gpt/mcp-server drive-epic <EPIC>\n```\n\nAdd `--dry-run` for a read-only preview, or `--attended` to opt out of unattended merging. `drive-epic --help` lists the common options, and `drive-epic --help-advanced` lists the rest.\n\n## Advanced: the planner\n\n`/plan-epic` is the advanced planner. It writes placeholder `TBD-N` keys instead of real ones. You create the child tickets yourself, run `emit-epic-implementer-bundle finalize` to replace the placeholders and write the plan files, then run `/drive-epic-run`. Planning never creates or approves a run.\n\n## If something goes wrong\n\nEvery refusal names the missing item and its fix, and creates nothing. Run setup again after you fix an item. To stop a run that is already active, run `npx -y @bridge_gpt/mcp-server epic-implementer abandon-run --epic-run-id <id>`, replacing `<id>` with the run ID that `drive-epic` printed when it started the run. Abandoning a run is final. For a read-only report of every item, run `npx -y @bridge_gpt/mcp-server epic-implementer readiness --json`. If you are stuck, email info@bridgegpt.ai.\n# Uninstall / clean up\n\nInspect before removing local resources:\n\n```bash\nnpx -y @bridge_gpt/mcp-server executor uninstall-service\nnpx -y @bridge_gpt/mcp-server executor uninstall-service --executor-id builder-01 --dry-run\nepic-implementer uninstall-git-hooks --dry-run\nnpx -y @bridge_gpt/mcp-server worktrees\nnpx -y @bridge_gpt/mcp-server worktrees --prune --dry-run\n```\n\nRemove `--dry-run` to approve the displayed plan at an interactive `(y/N)` prompt. Declined and noninteractive requests remove nothing. Executor service removal affects this user's home-scoped service; install-state locator cleanup affects only the current repository. Stopping may interrupt jobs and does not certify termination of all child processes: finish or stop work through the supported executor or plane workflow first. Darwin stdout/stderr logs are retained at `~/Library/Logs/com.bridge-gpt.executor.<id>.{out,err}.log`; Linux logs remain in the user journald journal. If a later phase fails, the command reports completed and retained stages; retry the same command after correcting the reported condition, then confirm with `doctor`.\n\nHook removal targets only Bridge's managed text in the common hooks directory shared by linked worktrees. Mixed user hook bytes and modes are preserved; unsafe or ambiguous content is retained for owner repair.\n\nWorktree observations use local refs as of the last fetch. `worktrees --fetch` explicitly performs one `git fetch --prune origin`; it cannot be combined with `--dry-run`. `--base <branch>` selects the comparison base. Pruning retains protected, dirty, active, locked, or uncertain worktrees. Unknown and partial sizes are labelled explicitly; incomplete inspection offers no candidates. A remote-gone branch needs prior origin-upstream and surviving-tip evidence. Partial cleanup reports retained resources; reconcile them with the repository owner or support. Avoid forced removal or deletion.\n\nFor the other local permissions surfaces use `npx -y @bridge_gpt/mcp-server install --remove-bridge-permissions` and `npx -y @bridge_gpt/mcp-server install epic-implementer --remove-merge-token`.\n\n## “Already checked out at” troubleshooting\n\nStart with `npx -y @bridge_gpt/mcp-server worktrees`. Git holds a branch in the checkout named in the error and refuses a second checkout until that holding worktree is removed. Use `worktrees --prune` only for proven eligible resources; preserve retained work and reconcile it with the repository owner.\n\nFor unexpected commits, use `npx -y @bridge_gpt/mcp-server doctor --stale-branch PROJ-123 --stale-branch-base main`. Opt into prevention with `start-tickets --guard-stale-branch`. Those diagnose or prevent stale reuse; neither releases a branch held by another worktree.\n",
|
|
23
|
+
"docs/install/epic-implementer-install.md": "# Run your first epic with the Epic Implementer\n\nThe Epic Implementer takes a planned epic, hands each child ticket to an agent on your computer, waits for CI and review, and merges each child pull request into an `epic/<EPIC>` branch. A person merges the final pull request into your default branch.\n\nYou do four things, in this order: install, set up, define the epic, launch it. The same steps work with Bridge's own ticket storage and with Jira.\n\nIn every command below, `npx -y @bridge_gpt/mcp-server` is the launcher. Keep the `-y`; without it, `npx` stops to ask before it installs the package.\n\n## Prerequisites\n\nSetup checks every item below for you, fixes what it can, and prints the one step it cannot fix. Read this list only when setup reports an item. Each bullet gives the item's name, its id, what it means, and the fix.\n\n- **Unattended posture (Setup page)** (`server.unattended-posture`) — Bridge allows unattended runs for this repository. Fix: Turn on **Allow unattended Epic Implementer runs** on the repository Setup page, or launch with `--attended`.\n- **Resolved merge mode** (`server.resolved-merge-mode`) — Bridge knows how child pull requests will be merged (your computer, a machine token, or GitHub Actions). Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Provider repository** (`server.provider-repository`) — Bridge knows the GitHub `owner/name` of this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **Supervisor setup** (`server.supervisor-setup`) — The repository has a stored supervisor record. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor configuration** (`server.supervisor-config`) — The supervisor record is complete: the test gate and the safe defaults are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor required CI checks** (`server.supervisor-required-checks`) — The CI checks a child pull request must pass before it merges are stored. Fix: Run setup and confirm the gate it proposes, or name a check with `--required-check <name>`.\n- **Review policy** (`server.review-policy`) — The review policy for child pull requests is known. AI review is an opt-in choice by the repository admin. Fix: Nothing is needed unless you want AI review. Choose a policy at launch with `--review-policy`.\n- **GitHub App credentials** (`server.github-credentials`) — Bridge's GitHub App is connected and can read this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **Provider default branch readable** (`server.provider-default-branch-readable`) — Bridge can read this repository's default branch from GitHub. Fix: Reconnect the GitHub App with `npx -y @bridge_gpt/mcp-server connect-github`, then run setup again.\n- **GitHub App actions permission** (`server.github-actions-permission`) — The GitHub App may start workflow runs. Only needed when merges go through GitHub Actions. Fix: Accept the updated permission on the GitHub App's installation page, then run setup again.\n- **Merge workflow eligibility** (`server.merge-execution-workflow`) — The merge workflow file is on the default branch and current. Only needed when merges go through GitHub Actions. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer --merge-workflow --codeowner <@org/team|@user>`, merge the pull request it opens, then run setup again.\n- **Merge branch policy** (`server.merge-execution-branch-policy`) — The default branch rules let the merge workflow do its job. Only needed when merges go through GitHub Actions. Fix: Adjust the branch rule or ruleset as setup describes, then run setup again.\n- **Executor server observation** (`server.executor-readiness`) — Bridge has seen a heartbeat from an executor for this repository. Before your first run this can be missing: `drive-epic` starts the executor for each run. Fix: Launch the epic with `npx -y @bridge_gpt/mcp-server drive-epic <EPIC>`.\n- **Review workflow protocol** (`server.review-workflow`) — The review workflow on the default branch matches the review policy. Only needed with AI review. Fix: Run setup; it names the workflow change to make.\n- **Conductor CI migration guard** (`server.conductor-ci-workflow`) — The CI workflow file `epic-implementer-ci.yml` is on the default branch and runs the migration guard where needed. Fix: Run setup, merge the setup pull request it opens, then run setup again.\n- **Escalation channel (webhook or email)** (`server.unattended-notify-default`) — Bridge has somewhere to send an escalation: a verified notify webhook, or your account email. Fix: Declare a notify webhook, or verify your account email.\n- **Escalation webhook reachable** (`server.escalation-webhook-reachable`) — A declared notify webhook answers Bridge's test request. Only checked for unattended runs that declare a webhook. Fix: Start or fix the notify sink so it answers with a 2xx status, or launch with `--attended`.\n- **Repository workflow readiness** (`server.repository-workflow-readiness`) — The CI and review workflows are confirmed on the default branch. Fix: Run setup, merge the setup pull request, then run setup again.\n- **Workflows at indexed commit** (`server.indexed-workflows`) — The repository index includes the workflow files on the default branch. Fix: Merge the setup pull request, then run setup again. It starts the re-index and reports this item as pending until the index reaches that commit.\n- **Integration branch configured** (`server.integration-branch-unset`) — The repository has an integration branch set. This is a note only and never blocks a launch. Fix: Nothing is needed. Set the repository's base branch to clear the note.\n- **CI status readable by the run** (`server.ci-poll-readable`) — The run can poll CI: the CI check configuration is stored, so the MCP server shows the `poll_ci_checks` and `wait_for_ci_checks` tools, and Bridge can read CI for the default-branch head. A warning only; it never blocks a launch. Fix: Run the `resolve_ci_checks` MCP tool for this repository.\n- **Watched checks run on epic branches** (`server.epic-branch-check-triggers`) — Every required or watched check (for example `claude-review`) runs for pull requests into `epic/**` branches. It names each check whose workflow does not, and each check it could not map to one workflow. A warning only. Fix: Add `epic/**` to the `pull_request` branches of each named check's workflow and merge that change.\n- **Worker environment declarations** (`server.worker-environment`) — Workers will start with the database and environment variables they need: a worker database is declared when CI provides one, and a profile with local test commands declares its worker variables (without them, workers start with none of the default variables). Names and counts only, never values. A warning only. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer` and declare the worker database and worker variables for the test gate.\n- **Service availability** (`server.service-availability`) — Bridge could read this repository's readiness from the server. Fix: Retry in a few minutes. If it keeps failing, email info@bridgegpt.ai.\n- **Claude login** (`install.claude-login`) — Claude Code is signed in on this computer. Fix: Run `claude` and sign in, then run setup again.\n- **Repository identity** (`install.identity`) — Bridge knows which repository this folder is. Fix: Run setup from the repository root, or pass `--repo <name>`.\n- **Bridge API credential** (`install.credential`) — A Bridge API key is stored for this repository. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **Server connectivity** (`install.connectivity`) — This computer can reach the Bridge server. Fix: Check your network and any `BAPI_BASE_URL` setting, then run setup again.\n- **Bootstrap config fields** (`install.bootstrap`) — The repository's Bridge configuration fields are filled in. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **Integration credentials** (`install.integrations`) — The integration credentials this repository uses, such as Jira or GitHub, are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install`.\n- **GitHub connection** (`install.github`) — Bridge's GitHub App is connected to this repository. Fix: Run `npx -y @bridge_gpt/mcp-server connect-github`.\n- **Repository indexing** (`install.indexing`) — The repository has been indexed by Bridge. Fix: Run `/parse-repository`, or let setup queue the index.\n- **Run tools visible in MCP sessions** (`install.run-tools-visible`) — The MCP session this computer starts loads the Epic Implementer run tools (the `full` or `epic_implementer` group). Checked on this computer only; the server reports it as unknown. A warning only; it never blocks a launch. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`, accept the tool-visibility fix, then restart your MCP client.\n- **Conductor event ledger** (`conductor.ledger`) — The local Epic Implementer event ledger can be read. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Conductor git hooks** (`conductor.git-hooks`) — Optional: the git hooks that feed the local event ledger are installed. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer install-git-hooks`.\n- **Epic Implementer MCP profile** (`conductor.mcp-profile`) — The `epic_implementer` tool profile is on in your MCP host. Fix: Let setup add it (it asks first), then restart your MCP client.\n- **GitHub CLI availability** (`conductor.gh-cli`) — The GitHub CLI (`gh`) is installed and signed in. Fix: Install `gh` and run `gh auth login`.\n- **Configured merge credential** (`conductor.merge-credential`) — A GitHub token for merging child pull requests is available on this computer. Fix: Let setup store one (it asks first), or set `GITHUB_MERGE_TOKEN`.\n- **Native ledger binding** (`conductor.native-ledger`) — The ledger's native component loads on this computer. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Worker MCP registration form** (`conductor.mcp-registration-form`) — Workers register the Bridge tools in the form the executor expects. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Expected Node engine** (`conductor.node-engine`) — The Node.js version meets the package's engine range. Fix: Install a supported Node.js (18 or newer; 20 or newer for the git hooks).\n- **Deny-layer enforcement** (`conductor.deny-enforcement`) — Claude Code enforces the permission denials that keep workers inside the repository. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` to see why the check could not confirm it.\n- **Claude login** (`conductor.claude-login`) — Claude Code is signed in for the workers. Fix: Run `claude` and sign in, then run setup again.\n- **Merge credential capability** (`conductor.merge-credential-capability`) — The merge token can push to the repository and read pull requests. Fix: Replace the token (setup offers to), then run setup again.\n- **Worktree preparation** (`conductor.worktree-preparation`) — The executor's clone can keep its working files out of git (`.git/info/exclude` exists or can be written). Fix: Make `.git/info/exclude` writable in this clone.\n- **Supervisor gate profile** (`conductor.install-section-supervisor-gate-profile`) — The repository's test gate profile is stored and valid. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor required CI checks** (`conductor.install-section-supervisor-required-checks`) — The required CI checks in the gate match checks the provider reports. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Supervisor review-policy alignment** (`conductor.install-section-supervisor-review-alignment`) — The review policy and the review workflow agree. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **GitHub App actions permission** (`conductor.install-section-github-actions-permission`) — The GitHub App may start workflow runs. Only needed when merges go through GitHub Actions. Fix: Accept the updated permission on the GitHub App's installation page.\n- **Merge execution eligibility** (`conductor.install-section-merge-execution-eligibility`) — This repository can use GitHub Actions merges. Only needed for that merge mode. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer --merge-workflow --codeowner <@org/team|@user>` and merge its pull request.\n- **Epic Implementer MCP profile token** (`conductor.install-section-epic-implementer-profile-token`) — The Bridge entries in your project's supported MCP configuration files (`.mcp.json`, `.vscode/mcp.json`, `.cursor/mcp.json`) load the `epic_implementer` group, so your editor can see the Epic Implementer tools. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; setup adds the group to your existing Bridge entry after you approve it (it keeps your other groups and creates no file), then restart your MCP client.\n- **Conductor hook targets** (`conductor.install-section-conductor-hook-targets`) — The git hook targets are in place for this clone. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer install-git-hooks`.\n- **GitHub Actions merge: local observation prerequisites** (`conductor.install-section-gh-actions-merge-auth`) — This computer can observe GitHub Actions merges. Only needed for that merge mode. Fix: Sign in with `gh auth login` and rerun setup.\n- **GitHub Actions merge: capability observability** (`conductor.install-section-gh-actions-merge-observable`) — Bridge can observe the outcome of GitHub Actions merges. Only needed for that merge mode. Fix: Rerun setup and follow the step it prints.\n- **Epic Implementer ledger loadability** (`conductor.install-section-epic-implementer-ledger-loadability`) — The local ledger can be loaded by the tools that read it. Fix: Run `npx -y @bridge_gpt/mcp-server epic-implementer doctor` and follow what it prints.\n- **Launch evidence** (`server.admission-evidence`) — Bridge has the evidence it needs to admit a launch. Fix: Run setup, then launch again.\n- **Launch evidence: unattended consent** (`server.admission-unattended-consent`) — Launch check: unattended runs are allowed. Fix: Turn on **Allow unattended Epic Implementer runs** on the Setup page, or launch with `--attended`.\n- **Launch evidence: notification destination** (`server.admission-notify-webhook`) — Launch check: an escalation destination is verified. Fix: Declare a notify webhook, or verify your account email.\n- **Launch evidence: repository workflows** (`server.admission-repository-readiness`) — Launch check: the CI and review workflows are confirmed. Fix: Run setup, merge the setup pull request, then run setup again.\n- **Launch evidence: required CI checks** (`server.admission-required-checks`) — Launch check: the required CI checks are stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Launch evidence: indexed repository** (`server.admission-index-provenance`) — Launch check: the index reaches the commit that holds the workflows. Fix: Merge the setup pull request, then run setup again.\n- **Repository test gate** (`server.gate-profile`) — The repository's test gate is stored. Fix: Run `npx -y @bridge_gpt/mcp-server install epic-implementer`; it fixes what it can and prints the one step it cannot.\n- **Repository test gate warnings** (`server.gate-profile-warnings`) — The stored test gate has no unresolved warnings. Fix: Read the warnings setup prints and confirm or edit the gate.\n- **Effective review mode** (`server.effective-review-mode`) — Bridge shows which review mode child pull requests will use. Fix: Choose a review policy at launch with `--review-policy` if you want a different one.\n- **Epic branch CI** (`server.epic-branch-ci-decision`) — Someone has decided whether CI runs on pull requests into the epic branch. Fix: Run setup and answer the epic-branch CI question, or pass `--epic-branch-ci-decision include|decline`.\n- **Epic branch CI coverage** (`server.epic-branch-ci-coverage-warning`) — Your CI covers pull requests into the epic branch. Fix: Add `epic/**` to the branches your CI workflow runs on.\n- **Additional readiness diagnostics** (`server.diagnostics`) — Extra readiness diagnostics from the server are clear. Fix: Read the diagnostic text; each names its own fix.\n- **Command versions** (`conductor.command-drift`) — The installed Epic Implementer commands match this package's version. Fix: Run `npx -y @bridge_gpt/mcp-server install` to refresh them.\n- **Escalation delivery** (`escalation-reachability`) — An escalation can actually be delivered. Fix: Verify your account email or fix the webhook, then run setup again.\n\n## 1. Install\n\nRun this once per project. Skip it when Bridge is already installed.\n\n```bash\nnpx -y @bridge_gpt/mcp-server install\n```\n\nIt writes this guide to `docs/install/epic-implementer-install.md` in your project. Run it again any time to refresh that file.\n\n## 2. Set up\n\nRun this once per repository, from the repository root, in your own terminal:\n\n```bash\nnpx -y @bridge_gpt/mcp-server install epic-implementer\n```\n\n`install-bridge conductor` is the same command with another spelling. Setup checks everything first (read-only), fixes only what is missing, checks again, and ends with one verdict: \"Ready for your first epic\" or \"Not ready: N steps left\", with the fix for each step. It asks before anything that writes, and without a terminal every question is a \"no\".\n\nWhen setup reports that its setup pull request is waiting, it prints `merge the setup PR` with the pull request's address. Merge that pull request, then run setup again. Setup starts the re-index, and reports the item as pending (\"indexing is running; re-run setup when it finishes\", or \"indexing was queued; re-run setup when it finishes\") until the index reaches the merged commit. Run setup again until it says \"Ready for your first epic\".\n\n### View or change the test command\n\nSetup prints the stored test command on every run:\n\n```text\nTest command: `npm test` (stored). Change it with --test-command \"...\".\n```\n\nTo save or replace it, pass the command yourself:\n\n```bash\nnpx -y @bridge_gpt/mcp-server install epic-implementer --test-command \"npm run lint && npm run build\"\n```\n\nThe flag is your consent for that one write, so setup asks no command question. It checks the command first (one line, no `${{`, at most 500 characters), saves it once, and reads it back. It reports success only when the stored value matches. Passing the same command again says \"Test command unchanged\" and writes nothing. With `--dry-run`, nothing is saved.\n\nTwo things stay separate from the flag. Setup still asks you to confirm the Bridge URL, so the command needs a terminal. And opening the setup pull request asks for its own consent: after you replace the command, setup offers the update pull request in the same run, and a command you declined to ship stays saved.\n\nDo not put a credential in the test command. Setup prints it, and the workflow file contains it.\n\n### What CI installs automatically\n\nThe setup pull request adds `.github/workflows/epic-implementer-ci.yml`. Before it runs your test command, the workflow installs your dependencies from the files in your repository root. Bridge reads those files on your computer when it generates the workflow, and it never runs a package manager to decide.\n\n| Language | Dependency file, first match wins | What CI runs |\n| --- | --- | --- |\n| JavaScript | `pnpm-lock.yaml`, `yarn.lock`, `npm-shrinkwrap.json`, `package-lock.json`, `bun.lock`, `bun.lockb` | `pnpm install`, `yarn install` (Yarn classic or Berry), `npm ci`, or `bun install`, each in its frozen form so the lockfile is used exactly as committed |\n| Python | `uv.lock`, `poetry.lock`, `requirements.txt` | `uv sync` (frozen), `poetry install`, or `pip install` from `requirements.txt` |\n| Go | `go.mod` | Go is set up from `go.mod`. |\n\n- **Mixed repositories** get every language they have, in the order JavaScript, Python, Go.\n- **Versions.** Node comes from `.nvmrc`, then `.node-version`, otherwise Node 24. Python comes from `.python-version`, otherwise Python 3.12. pnpm uses the version in `package.json` `packageManager` when it is valid, otherwise pnpm 10. Yarn is classic or Berry according to `.yarnrc.yml`, `packageManager`, and the lockfile; Berry runs through Corepack, which uses the Yarn version your `package.json` declares, otherwise Yarn 4. Poetry is installed at a fixed version, and Bun at the latest 1.x release. Every action is pinned to a fixed major version.\n- **uv and Poetry** projects must declare development dependencies such as `pytest` in the project. Their environments are put on `PATH`, so your stored command runs unchanged inside the project environment.\n- **If Bridge cannot read a file it needs**, or `package.json` contradicts the lockfile (for example a `packageManager` for a different tool), setup reports the dependency setup as unknown and blocks the workflow. It does not guess.\n- **Upgrades are reviewed.** An older Bridge-written workflow is replaced through a pull request you merge, never silently. If a setup pull request from an earlier release is still open, merge or close it first; setup names it and leaves it alone.\n\n### When your command must be self-contained\n\nSome repositories get no automatic installation, and setup says so in plain words:\n\n- **Python with no `uv.lock`, `poetry.lock`, or `requirements.txt`** (for example only `pyproject.toml` or `Pipfile`) gets no Python installation. Add a supported file, or make the command install what it needs.\n- **Rust** uses the toolchain the CI runner already has. If that is not enough, install what you need inside the command.\n- **No lockfile, or a Make-only project**, shows as `none`: Bridge installs no dependencies, so the command must install them itself.\n\nA command that installs its own dependencies is always allowed. Nothing in the workflow adds to your command, wraps it, or sets a prefix in front of it.\n\n### Recover from a stale CLI\n\nAn old copy of the command line tool can print old wording or miss a flag such as `--test-command`. Bridge checks the npm registry for a newer release about once a day and says so at the start of a session. That notice only reports that a newer version exists; it cannot tell you which copy `npx` actually ran. Likely causes are a cached `npx` download or a project-local install that `npx` picked first. Neither is proven for any one machine.\n\n1. See which version ran: `npx -y @bridge_gpt/mcp-server doctor`. Its `Bridge MCP version:` line gives the installed version and the latest one, and says when an upgrade is available.\n2. Fetch the newest release by running through `@latest`: `npx -y @bridge_gpt/mcp-server@latest doctor`. The `Bridge MCP version:` line should now show the latest version.\n3. Refresh the installed command files: `npx -y @bridge_gpt/mcp-server@latest install`.\n4. Run setup again: `npx -y @bridge_gpt/mcp-server@latest install epic-implementer`.\n5. If the output is still wrong, email info@bridgegpt.ai with the `Bridge MCP version:` line from step 1 and the setup output, with any secret removed.\n\n## 3. Define the epic\n\nIn Claude Code, run:\n\n```text\n/define-tickets\n```\n\nIt writes real child ticket keys, `epic-plan.dag.json`, and `epic-plan.meta.json`, then hands off to `/drive-epic-run`. The meta file is how the launch finds the plan from the epic key.\n\n## 4. Launch\n\nIn Claude Code, run:\n\n```text\n/drive-epic-run <EPIC> [<plan path>]\n```\n\nIt previews the launch, asks you once, creates the run through `drive-epic`, and drives the run to the end. From a shell, run the same launch yourself:\n\n```bash\nnpx -y @bridge_gpt/mcp-server drive-epic <EPIC>\n```\n\nAdd `--dry-run` for a read-only preview, or `--attended` to opt out of unattended merging. `drive-epic --help` lists the common options, and `drive-epic --help-advanced` lists the rest.\n\n## Advanced: the planner\n\n`/plan-epic` is the advanced planner. It writes placeholder `TBD-N` keys instead of real ones. You create the child tickets yourself, run `emit-epic-implementer-bundle finalize` to replace the placeholders and write the plan files, then run `/drive-epic-run`. Planning never creates or approves a run.\n\n## If something goes wrong\n\nEvery refusal names the missing item and its fix, and creates nothing. Run setup again after you fix an item. To stop a run that is already active, run `npx -y @bridge_gpt/mcp-server epic-implementer abandon-run --epic-run-id <id>`, replacing `<id>` with the run ID that `drive-epic` printed when it started the run. Abandoning a run is final. For a read-only report of every item, run `npx -y @bridge_gpt/mcp-server epic-implementer readiness --json`. If you are stuck, email info@bridgegpt.ai.\n# Uninstall / clean up\n\nInspect before removing local resources:\n\n```bash\nnpx -y @bridge_gpt/mcp-server executor uninstall-service\nnpx -y @bridge_gpt/mcp-server executor uninstall-service --executor-id builder-01 --dry-run\nepic-implementer uninstall-git-hooks --dry-run\nnpx -y @bridge_gpt/mcp-server worktrees\nnpx -y @bridge_gpt/mcp-server worktrees --prune --dry-run\n```\n\nRemove `--dry-run` to approve the displayed plan at an interactive `(y/N)` prompt. Declined and noninteractive requests remove nothing. Executor service removal affects this user's home-scoped service; install-state locator cleanup affects only the current repository. Stopping may interrupt jobs and does not certify termination of all child processes: finish or stop work through the supported executor or plane workflow first. Darwin stdout/stderr logs are retained at `~/Library/Logs/com.bridge-gpt.executor.<id>.{out,err}.log`; Linux logs remain in the user journald journal. If a later phase fails, the command reports completed and retained stages; retry the same command after correcting the reported condition, then confirm with `doctor`.\n\nHook removal targets only Bridge's managed text in the common hooks directory shared by linked worktrees. Mixed user hook bytes and modes are preserved; unsafe or ambiguous content is retained for owner repair.\n\nWorktree observations use local refs as of the last fetch. `worktrees --fetch` explicitly performs one `git fetch --prune origin`; it cannot be combined with `--dry-run`. `--base <branch>` selects the comparison base. Pruning retains protected, dirty, active, locked, or uncertain worktrees. Unknown and partial sizes are labelled explicitly; incomplete inspection offers no candidates. A remote-gone branch needs prior origin-upstream and surviving-tip evidence. Partial cleanup reports retained resources; reconcile them with the repository owner or support. Avoid forced removal or deletion.\n\nFor the other local permissions surfaces use `npx -y @bridge_gpt/mcp-server install --remove-bridge-permissions` and `npx -y @bridge_gpt/mcp-server install epic-implementer --remove-merge-token`.\n\n## “Already checked out at” troubleshooting\n\nStart with `npx -y @bridge_gpt/mcp-server worktrees`. Git holds a branch in the checkout named in the error and refuses a second checkout until that holding worktree is removed. Use `worktrees --prune` only for proven eligible resources; preserve retained work and reconcile it with the repository owner.\n\nFor unexpected commits, use `npx -y @bridge_gpt/mcp-server doctor --stale-branch PROJ-123 --stale-branch-base main`. Opt into prevention with `start-tickets --guard-stale-branch`. Those diagnose or prevent stale reuse; neither releases a branch held by another worktree.\n",
|
|
15
24
|
".bridge/procedures/install-bridge-conductor-gate.md": "# Repository gate: what the agent may and may not do\n\nThis note is for a coding agent helping a human run `install epic-implementer`\n(legacy `install conductor` and `install-bridge conductor` inputs remain accepted silently). It covers the **repository gate**: what must\npass before the Epic Implementer merges a child pull request.\n\nBridge copies this file into every installed project at\n`.bridge/procedures/install-bridge-conductor-gate.md`.\n\n## The one rule\n\n**You may explain gate candidates. You never confirm, clear, or write a gate.**\n\nThe gate decides what an unattended run may merge on its own. Only the\nrepository owner decides it. Concretely, you must not:\n\n- run `install epic-implementer` with `--confirm-gate`, `--clear-gate`,\n `--provider-check`, `--required-check`, `--local-command`, `--gate-none`,\n `--migration-guard`, or `--customized-command` on the human's behalf;\n- answer the installer's gate prompts (\"Gate members\", \"Store this repository\n gate?\", \"Clear the confirmed repository gate?\");\n- call the gate-profile API (`PUT .../supervisor-setup/gate-profile/`) yourself.\n\nThese commands ask questions on a terminal. A shell you run has no terminal, so\nthe installer treats every question as \"no\" and stores nothing. Ask the human to\nrun them in their own terminal, then read what they paste back.\n\n## What a gate can be\n\n| Kind | What gates each child merge |\n|---|---|\n| `provider` | Named checks a CI provider reports (GitHub Actions, or any external CI that reports a check run or commit status). |\n| `local` | Commands the executor runs itself on the merge head. |\n| `mixed` | Both: every provider check AND every local command. |\n| `none` | Nothing. An unattended run is still admitted, but every child merge waits for approval. |\n\n## How the installer proposes a gate\n\nWith no gate flags and no confirmed gate stored, the installer prints a\n**Proposed repository gate** section. It comes from a deterministic scan of the\nworking tree plus the provider's real check history. It never guesses:\n\n- A provider check is proposed only when that exact name has actually reported\n on a recent default-branch commit or merged pull request.\n- A matrix job's reported name includes its matrix values, so it is listed as\n \"name may vary\" and never proposed. The human can type the exact reported\n name at the prompt.\n- CircleCI, Jenkins, and Buildkite configuration and Git hooks are evidence\n only. Hooks are never run as gate commands.\n- Local candidates come from `package.json` scripts, `Makefile` targets, and the\n Python test configuration. They run as plain argument lists, never through a\n shell.\n- \"Provider history unavailable\" means unknown, not absent. Say so plainly.\n- An empty repository gets an explicit `none` proposal.\n\nDiscovery saves nothing. A gate is stored only after the human confirms it.\n\n## How to help\n\n1. Read the proposal with the human. Explain each candidate's evidence and what\n the gate kind means for unattended merges.\n2. If they want a check that has not reported yet, tell them admission refuses\n it until it really reports, so they should run CI once.\n3. If the stored gate is shown beside a proposal that removes members, point out\n the removals. Fewer members means unattended runs merge with fewer checks.\n Gate flags the human typed are their consent, so setup applies a removal\n without asking a removal question. After applying, setup reports the removed\n members and restoration guidance, including a restore command when one can be\n written safely. Read that back to the human.\n4. For a `local` or `mixed` gate, the commands must pass once under the\n executor before an unattended run is admitted. The installer offers this\n (\"Qualify gate now?\"). Later, the human runs\n `npx -y @bridge_gpt/mcp-server install epic-implementer --qualify-gate`.\n A failed qualification does not fail the install. The gate simply stays\n unqualified, and readiness shows `local_command_unqualified` until a run\n passes.\n5. If the installer prints \"Bridge API update required\", the Bridge API server\n is too old to store a gate. Nothing was written. Tell the human; do not look\n for a workaround.\n\n## Combined setup policy (BAPI-1567)\n\nThe final selected checks must be identical in proposal, comparison, consent,\natomic application, coherent read-back, and reporting. Managed CI is included\nbefore display unless explicit gate input supplies the complete selection.\nPurpose, evidence, named options, concrete consequences, and deferral/recovery\nmust precede consequential owner consent. Install invocation authorizes only\nroutine effects after trust checks. A reported name proves reporting, not test\ncoverage or reliability; failed/unseen/unavailable evidence remains visible.\n\nConverging setup uses `bridge.setup-policy.v1` preview/apply/read-back. Unsupported\nservers defer coupled writes, with no sequential legacy fallback. A stale\npreview requires fresh effects and a new answer; uncertain writes are read back\nonce and never blindly retried. Enter/EOF/no terminal defer. This supersedes\nper-write-consent guidance for routine effects; owner authorization for gate\nchanges, qualification execution, credentials, services, and replacement remains.\n\n## Repeat installation and identity preservation\n\nRun `npx -y @bridge_gpt/mcp-server install` to refresh an existing installation.\nThe installer reads project and host identity before onboarding. A saved credential\ncan resume the installed project without another token prompt. Equal credentials\nare a no-op. A different candidate is validated before an explained replacement\nquestion; refusal, EOF, and noninteractive input preserve the installed identity.\nGeneric `--force` is not credential replacement or endpoint transfer permission.\n\nProduction is the default destination and is displayed without another URL\nconfirmation. Explicit development destinations require credentials authorized for\nthat endpoint. Credential-store read and parse failures require repair; they do\nnot select signup. To stop a declined environment candidate from recurring, unset\n`BAPI_API_KEY` in future shells. Secret values never belong in diagnostic output.\nDry-run previews defer credential validation and authorization and do not read\ncredentials, write notes, or persist preferences.\n\nRepeat installation preserves valid tool selections and optimization posture.\nIndependent completed maintenance is retained when an optional replacement or\nlaunch is declined. Operational failures and blocked requested capabilities return\nstatus 1; completed maintenance with a usable retained identity returns status 0.\n\nEpic Implementer setup uses `npx -y @bridge_gpt/mcp-server install epic-implementer`.\nIt requires a supported github.com repository, GitHub CLI sign-in, and Claude Code\nsign-in before dependent mutations. Fix the prerequisite and rerun setup; general\nBridge maintenance remains available. Local token removal does not require a new\nnetwork sign-in.\n\nAgent notes are planned by canonical physical target. Shared AGENTS.md/CLAUDE.md\nfiles receive full guidance once. Valid marker lines and unowned bytes survive;\nbroken links, outside-root targets, malformed regions, and stale observations are\nrefused. Existing files are updated in place to preserve links. A separate Claude\npointer waits for canonical guidance. These checks cover ordinary concurrent\nchanges and do not claim a transactional or adversarial filesystem guarantee.\n\n## Return\n\nReport back to the human in plain words: the gate the installer proposed or\nstored, its kind, any removals it showed, and the qualification state it\nreported. Never report a gate as confirmed or qualified unless the installer's\nown output said so.\n"
|
|
16
25
|
};
|
|
17
26
|
export const DOC_METADATA = {
|
|
@@ -64,6 +73,60 @@ export const DOC_METADATA = {
|
|
|
64
73
|
"define-tickets"
|
|
65
74
|
]
|
|
66
75
|
},
|
|
76
|
+
".bridge/procedures/define-tickets-blast-radius-procedure.md": {
|
|
77
|
+
"classification": "procedure",
|
|
78
|
+
"workflows": [
|
|
79
|
+
"define-tickets"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
".bridge/procedures/define-tickets-auto-mode-procedure.md": {
|
|
83
|
+
"classification": "procedure",
|
|
84
|
+
"workflows": [
|
|
85
|
+
"define-tickets"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
".bridge/procedures/procedure-read-failure-procedure.md": {
|
|
89
|
+
"classification": "procedure",
|
|
90
|
+
"workflows": [
|
|
91
|
+
"define-tickets"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
".bridge/procedures/define-tickets-decision-page-procedure.md": {
|
|
95
|
+
"classification": "procedure",
|
|
96
|
+
"workflows": [
|
|
97
|
+
"define-tickets"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
".bridge/procedures/define-tickets-drafting-plan-estimates-procedure.md": {
|
|
101
|
+
"classification": "procedure",
|
|
102
|
+
"workflows": [
|
|
103
|
+
"define-tickets"
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
".bridge/procedures/define-tickets-discovery-procedure.md": {
|
|
107
|
+
"classification": "procedure",
|
|
108
|
+
"workflows": [
|
|
109
|
+
"define-tickets"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
".bridge/procedures/define-tickets-design-procedure.md": {
|
|
113
|
+
"classification": "procedure",
|
|
114
|
+
"workflows": [
|
|
115
|
+
"define-tickets"
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
".bridge/procedures/define-tickets-writer-output-procedure.md": {
|
|
119
|
+
"classification": "procedure",
|
|
120
|
+
"workflows": [
|
|
121
|
+
"define-tickets"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
".bridge/procedures/define-tickets-post-create-procedure.md": {
|
|
125
|
+
"classification": "procedure",
|
|
126
|
+
"workflows": [
|
|
127
|
+
"define-tickets"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
67
130
|
".bridge/README.md": {
|
|
68
131
|
"classification": "reference",
|
|
69
132
|
"workflows": []
|