@bridge_gpt/mcp-server 0.2.79 → 0.2.80

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 CHANGED
@@ -412,7 +412,7 @@ later boot.
412
412
  "mcpServers": {
413
413
  "bridge": {
414
414
  "command": "npx",
415
- "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.79", "serve"],
415
+ "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.80", "serve"],
416
416
  "env": {
417
417
  "BAPI_BASE_URL": "https://bridgegpt-api.com",
418
418
  "BAPI_REPO_NAME": "your-repo",
@@ -434,7 +434,7 @@ later boot.
434
434
  "bridge": {
435
435
  "type": "stdio",
436
436
  "command": "npx",
437
- "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.79", "serve"],
437
+ "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.80", "serve"],
438
438
  "env": {
439
439
  "BAPI_BASE_URL": "https://bridgegpt-api.com",
440
440
  "BAPI_REPO_NAME": "your-repo",
@@ -456,7 +456,7 @@ later boot.
456
456
  "bridge": {
457
457
  "type": "stdio",
458
458
  "command": "npx",
459
- "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.79", "serve"],
459
+ "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.80", "serve"],
460
460
  "env": {
461
461
  "BAPI_BASE_URL": "https://bridgegpt-api.com",
462
462
  "BAPI_REPO_NAME": "your-repo",
@@ -479,7 +479,7 @@ Windsurf only supports global MCP configuration.
479
479
  "mcpServers": {
480
480
  "bridge": {
481
481
  "command": "npx",
482
- "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.79", "serve"],
482
+ "args": ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.80", "serve"],
483
483
  "env": {
484
484
  "BAPI_BASE_URL": "https://bridgegpt-api.com",
485
485
  "BAPI_REPO_NAME": "your-repo",
@@ -498,7 +498,7 @@ Windsurf only supports global MCP configuration.
498
498
  ```toml
499
499
  [mcp_servers.bridge]
500
500
  command = "npx"
501
- args = ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.79", "serve"]
501
+ args = ["-y", "--prefer-offline", "@bridge_gpt/mcp-server@0.2.80", "serve"]
502
502
 
503
503
  [mcp_servers.bridge.env]
504
504
  BAPI_BASE_URL = "https://bridgegpt-api.com"
@@ -1131,6 +1131,12 @@ See [The Epic Implementer](#the-epic-implementer) for what each command is for,
1131
1131
 
1132
1132
  Workers also prune edit-confirmation tests conservatively and report them in the `## Tests removed` and `## Checked once` pull request sections. Details, and how `never delete tests` opts out, are in [Test pruning and checked-once evidence](./docs/EPIC-IMPLEMENTER.md#test-pruning-and-checked-once-evidence).
1133
1133
 
1134
+ ### Worker runtime from the Codex skill
1135
+
1136
+ Which agent runs an epic's child work depends on how you start it. When you start a run through the installed Codex skill (`$bridge-drive-epic-run`), new runs default to Codex workers; pass `--runtime claude` to choose Claude. The direct `drive-epic` CLI and every other host keep their existing default, and an installation without the Codex skill is unchanged. A runtime applies to **new** runs only: attaching to a live run reports its stored runtime pin, the run id, and the executor identity read for that run, and an override you pass is reported as ignored, never applied.
1137
+
1138
+ Unattended Codex execution needs a supported macOS executor host, a supported Codex CLI release, an isolated worker login, an executor binding for the run, and the completion prerequisites. The launch preview reports each of these, role by role, as advisory evidence for this checkout and machine. It cannot prove future admission, and when the executor runs elsewhere it says remote evidence is unavailable. Missing evidence withholds only the affected work. Approving the launch is consent to create and start the run; it does not authorize a helper role.
1139
+
1134
1140
  ## CLI Subcommands
1135
1141
 
1136
1142
  Beyond `--init` / `--upgrade`, the package ships operational subcommands of the **single `bridge-api-mcp-server` bin** (not separate binaries) — so they travel with the package to every consumer. See [Usage Documentation → Start Tickets](#regularly-useful) for *when* to use `start-tickets`; this section is the full CLI reference.
@@ -2111,3 +2117,102 @@ The current default adapter remains unqualified where isolated login and scoped
2111
2117
  worker assets are unavailable. A live executor can still serve independently
2112
2118
  eligible deterministic work. See `docs/BAPI-1840-local-codex-runtime.md` in the
2113
2119
  repository for worker provisioning, local pilot behavior and live-verification limits.
2120
+
2121
+ ### Codex epic driver (operator)
2122
+
2123
+ The Codex epic driver lets an operator leave an approved epic running overnight
2124
+ in Codex. It is a **private, checkout-scoped MCP server**, separate from the
2125
+ general Bridge registration (which stays available for ordinary chat) and from
2126
+ the worker approval profile (`--codex-profile`). Workers and restricted roles
2127
+ never load it.
2128
+
2129
+ **Supported Codex host baseline (verified locally, 2026-12-01).** Codex CLI
2130
+ **0.172.0** (`codex-cli 0.172.0`, macOS arm64) is the only verified version.
2131
+ Its feature table lists `tool_call_mcp_elicitation` as stable and on, and its
2132
+ MCP client declares form elicitation (`elicitation/create`, `form` mode) and
2133
+ roots (`roots/list`). The driver uses that form elicitation as the trusted owner
2134
+ confirmation: the installed server sends the request, the host shows it to a
2135
+ person, and the reply comes straight back to the server over its own stdio
2136
+ connection. The form always has non-empty fields (a decision and the typed epic
2137
+ key), so Codex's automated reviewer, which handles only empty forms, cannot
2138
+ answer it. The driver checks the capability on every session. When the host does
2139
+ not declare form elicitation, **create stays unavailable**. There is no
2140
+ fallback to chat, a terminal prompt, or a caller-supplied flag. Previews and
2141
+ reads keep working. No authoritative, per-operation host permission-prompt
2142
+ signal reaches the server, so host prompt counts are reported as
2143
+ `not observable`, never as zero.
2144
+
2145
+ **Install** (from the published package, in a checkout Codex already trusts):
2146
+
2147
+ ```bash
2148
+ npx -y @bridge_gpt/mcp-server install --tools=codex --codex-epic-driver=on
2149
+ # or, after install:
2150
+ npx -y @bridge_gpt/mcp-server codex-epic-driver install [--base-url <url>] [--repo <name>]
2151
+ ```
2152
+
2153
+ Install checks the hard dependencies first and shows no values: a trusted
2154
+ checkout, a stored `bapi:<repo>` key approved for the target, and an owner-only
2155
+ package entry outside the checkout. It then pins that entry's absolute path and
2156
+ digest. It adds one marker-delimited block to `~/.codex/config.toml` named
2157
+ `bridge_epic_driver_<id>`, with an `approve` grant for each fixed operation and
2158
+ no wildcard. The block is keyed by the canonical worktree path, so sibling
2159
+ worktrees each get their own. A repeat install with nothing changed is a no-op.
2160
+ Driver state (installation, decisions, bindings, recipe, refusals) lives outside
2161
+ the checkout, under `$XDG_STATE_HOME/bridge/codex-epic-driver/` (default
2162
+ `~/.local/state/…`), with owner-only permissions.
2163
+
2164
+ **Fresh-session inspection.** Start a new Codex session in the checkout and call
2165
+ `driver_status`. It reports the configured and observed checkout, the project,
2166
+ the credential's presence, host confirmation and recipe approval. From a shell:
2167
+
2168
+ ```bash
2169
+ npx -y @bridge_gpt/mcp-server codex-epic-driver inspect
2170
+ npx -y @bridge_gpt/mcp-server doctor --agent codex
2171
+ ```
2172
+
2173
+ `doctor` is read-only. It separates Bridge-managed settings, edits made outside
2174
+ Bridge, and observed effects. It reports session behavior as `not yet observed`
2175
+ rather than inferring it from TOML.
2176
+
2177
+ **Launch.** `preview_launch` runs the normal `drive-epic --dry-run` preview with
2178
+ write probes withheld (merge evidence reads "unverified"). `confirm_launch` asks
2179
+ the owner through the host. It shows the checkout, project, epic, effective
2180
+ runtime, mode, plan revision and full selection. `create_run` spends that one
2181
+ decision atomically and sends the create with a fresh attempt identity. If the
2182
+ response is lost, the driver reads the run back **by attempt identity only**. An
2183
+ unresolved outcome is reported as `unconfirmed`, keeps the decision spent, and
2184
+ grants no write authority. It is never retried, because a retry could create a
2185
+ second billable run. A local-plane launch keeps its owner-terminal hand-off.
2186
+
2187
+ **Conflicts.** If you edit the managed block, install and withdraw leave it
2188
+ alone and report `user_edited`. Resolve it by restoring or removing the block,
2189
+ then rerun install. If the pinned executable changes or gains unsafe
2190
+ permissions, doctor and driver startup both report a setup conflict. Rerun
2191
+ install (or `upgrade`) to re-pin.
2192
+
2193
+ **Verification recipe.** Approving a recipe is a separate, explicit setup step:
2194
+
2195
+ ```bash
2196
+ npx -y @bridge_gpt/mcp-server codex-epic-driver approve-recipe --recipe-file ./epic-server-recipe.json \
2197
+ --launcher npm=/opt/homebrew/bin/npm
2198
+ ```
2199
+
2200
+ The recipe is validated, shown verbatim with its checkout and project, and
2201
+ stored with its digest only after you accept. Proof, start and every rebuild
2202
+ check the recipe bytes against that digest, through the helper's environment.
2203
+ A changed recipe or launcher is refused, and the run continues through the
2204
+ verification hand-off. To change the recipe, approve it again.
2205
+
2206
+ **Withdraw.**
2207
+
2208
+ ```bash
2209
+ npx -y @bridge_gpt/mcp-server codex-epic-driver withdraw
2210
+ # or: install --tools=codex --codex-epic-driver=off
2211
+ ```
2212
+
2213
+ Withdrawal revokes driver authority durably first. It expires unspent launch
2214
+ decisions and closes live driver bindings. Only then does it remove Bridge's
2215
+ block from the Codex config. Runs are not cancelled or re-pinned. Your other
2216
+ settings and the general Bridge registration are untouched. Permissions you
2217
+ granted yourself outside the managed block stay in effect and are reported
2218
+ separately.
@@ -105,6 +105,11 @@ export function generateDecisionPageHtml(data, assets = DEFAULT_ASSETS) {
105
105
  const needsForm = hasDecisions || (isPlanning && stanceItemCount > 0);
106
106
  const effectiveLabels = resolveDecisionPageLabels(data.labels);
107
107
  const isFinish = isFinishCheckpointPage(data);
108
+ // BAPI-1897 — GAPS issues render only on a finish page. Refuse rather than
109
+ // render a page with them silently removed.
110
+ if (!isFinish && pageHasGapIssues(data)) {
111
+ throw new Error("GAPS issues (issues / issues_summary) render only on a finish-checkpoint page (page_revision).");
112
+ }
108
113
  const faviconLink = assets.faviconBase64
109
114
  ? `<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,${assets.faviconBase64}">`
110
115
  : "";
@@ -560,7 +565,7 @@ export function generateDecisionPageHtml(data, assets = DEFAULT_ASSETS) {
560
565
  gap: 0.75rem;
561
566
  }
562
567
  }
563
- </style>${isFinish ? FINISH_CHECKPOINT_CSS : ""}
568
+ </style>${isFinish ? FINISH_CHECKPOINT_CSS : ""}${isFinish && pageHasGapIssues(data) ? GAP_ISSUES_CSS : ""}
564
569
  </head>
565
570
  <body${isFinish ? ' class="finish-checkpoint"' : ""}>
566
571
  ${renderHeader(assets)}
@@ -708,6 +713,64 @@ const FINISH_CHECKPOINT_CSS = `
708
713
  body.finish-checkpoint .btn { width: 100%; }
709
714
  }
710
715
  </style>`;
716
+ // BAPI-1897 — GAPS issue styling, emitted only on a finish page that carries
717
+ // issues so every other page stays byte-identical. Labels pair each color with
718
+ // text (all pairs reach at least 4.5:1); identities wrap anywhere; summaries get
719
+ // the finish page's visible focus ring; nothing animates.
720
+ const GAP_ISSUES_CSS = `
721
+ <style>
722
+ body.finish-checkpoint .card.has-gap-issues { padding: 32px; }
723
+ body.finish-checkpoint .gap-issues p { margin: 0 0 8px; }
724
+ body.finish-checkpoint .gap-issues-headline { font-size: 18px; line-height: 24px; font-weight: 600; }
725
+ body.finish-checkpoint .gap-issues-explanation, body.finish-checkpoint .gap-issues-recommendation,
726
+ body.finish-checkpoint .gap-issues-preview { font-size: 16px; line-height: 24px; }
727
+ body.finish-checkpoint .gap-issues-term { font-weight: 600; }
728
+ body.finish-checkpoint .gap-issues-state-note { font-size: 14px; line-height: 20px; color: #374151; border-left: 4px solid var(--border-color); padding-left: 8px; }
729
+ body.finish-checkpoint .gap-issue-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
730
+ body.finish-checkpoint .gap-issue { border: 1px solid var(--border-color); border-radius: 6px; background: var(--surface-color); padding: 8px 16px; }
731
+ body.finish-checkpoint .gap-issue > summary, body.finish-checkpoint .gap-issues-overflow > summary {
732
+ cursor: pointer; padding: 4px 0; list-style: none; display: flex; align-items: flex-start; gap: 8px;
733
+ }
734
+ body.finish-checkpoint .gap-issue > summary::-webkit-details-marker,
735
+ body.finish-checkpoint .gap-issues-overflow > summary::-webkit-details-marker { display: none; }
736
+ body.finish-checkpoint .gap-issue > summary::before, body.finish-checkpoint .gap-issues-overflow > summary::before {
737
+ content: "\\25B6"; flex: none; width: 16px; font-size: 12px; line-height: 24px; text-align: center; color: #a63d28;
738
+ transition: transform 120ms ease-out;
739
+ }
740
+ body.finish-checkpoint .gap-issue[open] > summary::before,
741
+ body.finish-checkpoint .gap-issues-overflow[open] > summary::before { transform: rotate(90deg); }
742
+ body.finish-checkpoint .gap-issue-summary-text { display: block; flex: 1 1 auto; min-width: 0; }
743
+ body.finish-checkpoint .gap-issue-headline { display: block; font-size: 16px; line-height: 24px; font-weight: 600; overflow-wrap: anywhere; }
744
+ body.finish-checkpoint .gap-issue-labels { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; }
745
+ body.finish-checkpoint .gap-label { display: inline-block; padding: 0 8px; border-radius: 4px; font-size: 13px; line-height: 20px; font-weight: 600; }
746
+ body.finish-checkpoint .gap-severity-serious { background: #fef2f2; color: #991b1b; }
747
+ body.finish-checkpoint .gap-severity-unknown { background: #fff7ed; color: #9a3412; }
748
+ body.finish-checkpoint .gap-severity-minor { background: #fef3c7; color: #78350f; }
749
+ body.finish-checkpoint .gap-context { background: #eff6ff; color: #1e3a8a; }
750
+ body.finish-checkpoint .gap-closer { background: #f3f4f6; color: #374151; }
751
+ body.finish-checkpoint .gap-rechecked { background: #dcfce7; color: #166534; }
752
+ body.finish-checkpoint .gap-person { background: #f5f3ff; color: #5b21b6; }
753
+ body.finish-checkpoint .gap-issue-body { margin: 8px 0 0; font-size: 14px; line-height: 20px; }
754
+ body.finish-checkpoint .gap-issue-body dt { font-weight: 600; margin-top: 8px; }
755
+ body.finish-checkpoint .gap-issue-body dd { margin: 4px 0 0; overflow-wrap: anywhere; }
756
+ body.finish-checkpoint .gap-person-checks { margin: 4px 0 0 16px; }
757
+ body.finish-checkpoint .gap-issues-overflow { margin: 8px 0 16px; }
758
+ body.finish-checkpoint .gap-issues-overflow > summary { font-weight: 600; }
759
+ body.finish-checkpoint .gap-technical-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
760
+ body.finish-checkpoint .gap-technical-entry { display: grid; gap: 4px; }
761
+ body.finish-checkpoint .gap-issue-technical code, body.finish-checkpoint .gap-technical-fingerprint code {
762
+ overflow-wrap: anywhere; word-break: break-word;
763
+ }
764
+ @media (max-width: 768px) {
765
+ body.finish-checkpoint .card.has-gap-issues { padding: 16px; }
766
+ body.finish-checkpoint .gap-issue { padding: 8px; }
767
+ body.finish-checkpoint .gap-issue-labels { flex-direction: column; align-items: flex-start; }
768
+ }
769
+ @media (prefers-reduced-motion: reduce) {
770
+ body.finish-checkpoint .gap-issues, body.finish-checkpoint .gap-issue, body.finish-checkpoint .gap-issues-overflow,
771
+ body.finish-checkpoint .gap-issue > summary::before, body.finish-checkpoint .gap-issues-overflow > summary::before { transition: none; animation: none; }
772
+ }
773
+ </style>`;
711
774
  function renderHeader(assets) {
712
775
  const logoImg = assets.logoBase64
713
776
  ? `<img src="data:image/png;base64,${assets.logoBase64}" alt="Bridge">`
@@ -1089,13 +1152,15 @@ function renderDecisionItem(item, isFinish = false, inventory) {
1089
1152
  </details>`
1090
1153
  : "";
1091
1154
  const inventorySection = isFinish ? renderTestInventory(inventory, item.id) : "";
1155
+ const issuesSection = isFinish ? renderGapIssues(item) : "";
1156
+ const issueCardClass = issuesSection ? " has-gap-issues" : "";
1092
1157
  return `
1093
- <section class="card" data-item-id="${id}" data-item-type="decision" data-source="${escapeHtml(item.source ?? "")}" data-labels="${labelsJson}"${optionIdsAttr} data-testid="decision-card" aria-labelledby="${titleId}">
1158
+ <section class="card${issueCardClass}" data-item-id="${id}" data-item-type="decision" data-source="${escapeHtml(item.source ?? "")}" data-labels="${labelsJson}"${optionIdsAttr} data-testid="decision-card" aria-labelledby="${titleId}">
1094
1159
  <h3 class="card-title" id="${titleId}" data-testid="decision-card-title">${escapeHtml(item.question)}</h3>${originalQuestionSection}${renderRequirementClassification(item, requirementClassLabelId)}
1095
1160
  <section class="card-section" data-testid="why-it-matters-section" aria-labelledby="${whyItMattersLabelId}">
1096
1161
  <div class="card-section-label" id="${whyItMattersLabelId}">Why it matters</div>
1097
1162
  <div class="card-section-body" data-testid="why-it-matters-body">${escapeHtml(item.why_it_matters)}</div>
1098
- </section>
1163
+ </section>${issuesSection}
1099
1164
  <section class="radio-group" role="radiogroup" data-testid="decision-radio-group" aria-labelledby="${radioGroupLabelId}">
1100
1165
  <div class="card-section-label" id="${radioGroupLabelId}">Choose an option</div>${optionsHtml}
1101
1166
  </section>
@@ -1109,6 +1174,143 @@ function renderDecisionItem(item, isFinish = false, inventory) {
1109
1174
  </div>${codebaseEvidenceSection}${inventorySection}${technicalSection}
1110
1175
  </section>`;
1111
1176
  }
1177
+ // ---------------------------------------------------------------------------
1178
+ // BAPI-1897 — GAPS issues: three layers
1179
+ // ---------------------------------------------------------------------------
1180
+ /** Issue rows shown before the collapsed "and N more" disclosure. */
1181
+ export const GAP_ISSUE_VISIBLE_ROWS = 8;
1182
+ function pageHasGapIssues(data) {
1183
+ return data.actionable_items.some((item) => item.issues !== undefined || item.issues_summary !== undefined);
1184
+ }
1185
+ const GAP_SUMMARY_STATE_NOTE = {
1186
+ issues: "",
1187
+ empty: "The gap list was read and it is empty. There is nothing to re-check here.",
1188
+ unavailable: "The gap evidence could not be read, so nothing on this card is confirmed.",
1189
+ };
1190
+ function severityLabel(issue) {
1191
+ if (issue.severity === "minor" && issue.severity_agent_assessed)
1192
+ return "minor — agent-assessed";
1193
+ return issue.severity;
1194
+ }
1195
+ /** Layer one row labels: severity, context, who can close it, then status badges. Every color is paired with text. */
1196
+ function renderGapIssueLabels(issue) {
1197
+ const labels = [
1198
+ `<span class="gap-label gap-severity gap-severity-${escapeHtml(issue.severity)}" data-testid="gap-issue-severity">Severity: ${escapeHtml(severityLabel(issue))}</span>`,
1199
+ ];
1200
+ for (const ctx of issue.contexts) {
1201
+ const state = ctx.state === "confirmed" ? "confirmed" : "reported, not confirmed";
1202
+ labels.push(`<span class="gap-label gap-context gap-context-${escapeHtml(ctx.state)}" data-testid="gap-issue-context">${escapeHtml(`${ctx.label} — ${state}`)}</span>`);
1203
+ }
1204
+ labels.push(`<span class="gap-label gap-closer" data-testid="gap-issue-closer">Who can close it: ${escapeHtml(issue.closer)}</span>`);
1205
+ if (issue.rechecked_passed) {
1206
+ labels.push(`<span class="gap-label gap-rechecked" data-testid="gap-issue-rechecked">Re-checked and passed at the final commit</span>`);
1207
+ }
1208
+ if (issue.human_checks.length > 0) {
1209
+ labels.push(`<span class="gap-label gap-person" data-testid="gap-issue-needs-person">Needs a person: ${escapeHtml(issue.human_checks.map((c) => c.check_id).join(", "))}</span>`);
1210
+ }
1211
+ return labels.join("");
1212
+ }
1213
+ /** Layer three: snapshot-derived values only, inside a nested collapsed disclosure. */
1214
+ function renderGapIssueTechnical(issue) {
1215
+ if (issue.technical === undefined)
1216
+ return "";
1217
+ const entries = issue.technical.entries
1218
+ .map((entry) => `
1219
+ <li class="gap-technical-entry" data-testid="gap-issue-technical-entry">
1220
+ <span>Type: <code>${escapeHtml(entry.entry_type)}</code></span>
1221
+ <span>Ticket: <code>${escapeHtml(entry.ticket_key)}</code></span>
1222
+ <span>Step: <code>${entry.step_id === null ? "none" : String(entry.step_id)}</code></span>
1223
+ <span>Exact identity: <code>${escapeHtml(entry.exact_identity)}</code></span>
1224
+ <span>Re-list identity: <code>${entry.relist_identity === null ? "none" : escapeHtml(entry.relist_identity)}</code></span>
1225
+ </li>`)
1226
+ .join("");
1227
+ const fingerprint = issue.technical.fingerprint === null ? "not available" : escapeHtml(issue.technical.fingerprint);
1228
+ return `
1229
+ <details class="finish-technical gap-issue-technical" data-testid="gap-issue-technical">
1230
+ <summary>Technical details</summary>
1231
+ <ul class="gap-technical-list">${entries}
1232
+ </ul>
1233
+ <p class="gap-technical-fingerprint">List fingerprint: <code>${fingerprint}</code></p>
1234
+ </details>`;
1235
+ }
1236
+ /** One issue: a collapsed row (layer one) that expands to the plain explanation (layer two). */
1237
+ function renderGapIssueRow(issue) {
1238
+ const reason = issue.severity_agent_assessed && issue.severity_reason !== null
1239
+ ? `
1240
+ <dt>Why the agent rated it minor</dt>
1241
+ <dd data-testid="gap-issue-severity-reason">${escapeHtml(issue.severity_reason)}</dd>`
1242
+ : "";
1243
+ const checks = issue.human_checks.length > 0
1244
+ ? `
1245
+ <dt>Needs a person</dt>
1246
+ <dd><ul class="gap-person-checks">${issue.human_checks
1247
+ .map((c) => `
1248
+ <li data-testid="gap-issue-human-check"><strong>${escapeHtml(c.check_id)}</strong> (${escapeHtml(c.ticket_key)}): ${escapeHtml(c.text)}</li>`)
1249
+ .join("")}
1250
+ </ul></dd>`
1251
+ : "";
1252
+ return `
1253
+ <li class="gap-issue-item">
1254
+ <details class="gap-issue" data-testid="gap-issue-row" data-issue-id="${escapeHtml(issue.issue_id)}">
1255
+ <summary>
1256
+ <span class="gap-issue-summary-text">
1257
+ <span class="gap-issue-headline" data-testid="gap-issue-headline">${escapeHtml(issue.headline)}</span>
1258
+ <span class="gap-issue-labels">${renderGapIssueLabels(issue)}</span>
1259
+ </span>
1260
+ </summary>
1261
+ <dl class="gap-issue-body" data-testid="gap-issue-body">
1262
+ <dt>What this was meant to prove</dt>
1263
+ <dd data-testid="gap-issue-proves">${escapeHtml(issue.proves)}</dd>
1264
+ <dt>What we know</dt>
1265
+ <dd data-testid="gap-issue-known">${escapeHtml(issue.known)}</dd>
1266
+ <dt>Why it matters</dt>
1267
+ <dd data-testid="gap-issue-why">${escapeHtml(issue.why)}</dd>
1268
+ <dt>What covers it</dt>
1269
+ <dd data-testid="gap-issue-covers">${escapeHtml(issue.covers)}</dd>${reason}${checks}
1270
+ </dl>${renderGapIssueTechnical(issue)}
1271
+ </details>
1272
+ </li>`;
1273
+ }
1274
+ /**
1275
+ * The GAPS card's three layers. Layer one is the summary plus up to eight rows;
1276
+ * the rest sit in a collapsed, keyboard-accessible "and N more" disclosure so
1277
+ * every issue stays reachable. Nothing here is a form control, so none of it
1278
+ * reaches the submitted or copied decision JSON.
1279
+ */
1280
+ function renderGapIssues(item) {
1281
+ if (item.issues === undefined && item.issues_summary === undefined)
1282
+ return "";
1283
+ const summary = item.issues_summary;
1284
+ const issues = item.issues ?? [];
1285
+ const state = summary?.state ?? "issues";
1286
+ const note = GAP_SUMMARY_STATE_NOTE[state];
1287
+ const summaryHtml = summary
1288
+ ? `
1289
+ <p class="gap-issues-headline" data-testid="gap-issues-headline">${escapeHtml(summary.headline)}</p>${summary.explanation ? `
1290
+ <p class="gap-issues-explanation" data-testid="gap-issues-explanation">${escapeHtml(summary.explanation)}</p>` : ""}${note ? `
1291
+ <p class="gap-issues-state-note gap-issues-state-${state}" data-testid="gap-issues-state-note">${escapeHtml(note)}</p>` : ""}
1292
+ <p class="gap-issues-recommendation" data-testid="gap-issues-recommendation"><span class="gap-issues-term">Recommendation:</span> ${escapeHtml(summary.recommendation)}</p>
1293
+ <p class="gap-issues-preview" data-testid="gap-issues-preview"><span class="gap-issues-term">What happens next:</span> ${escapeHtml(summary.preview)}</p>`
1294
+ : "";
1295
+ const visible = issues.slice(0, GAP_ISSUE_VISIBLE_ROWS).map(renderGapIssueRow).join("");
1296
+ const rest = issues.slice(GAP_ISSUE_VISIBLE_ROWS);
1297
+ const list = visible
1298
+ ? `
1299
+ <ol class="gap-issue-list">${visible}
1300
+ </ol>`
1301
+ : "";
1302
+ const overflow = rest.length > 0
1303
+ ? `
1304
+ <details class="gap-issues-overflow" data-testid="gap-issues-overflow">
1305
+ <summary>and ${rest.length} more</summary>
1306
+ <ol class="gap-issue-list" start="${GAP_ISSUE_VISIBLE_ROWS + 1}">${rest.map(renderGapIssueRow).join("")}
1307
+ </ol>
1308
+ </details>`
1309
+ : "";
1310
+ return `
1311
+ <section class="card-section gap-issues" data-testid="gap-issues-summary" data-state="${escapeHtml(state)}" aria-label="Gaps summary">${summaryHtml}
1312
+ </section>${list}${overflow}`;
1313
+ }
1112
1314
  function renderImprovements(improvements, labels) {
1113
1315
  if (improvements.length === 0)
1114
1316
  return "";