Skip to content

fix(pi): match Pi 0.99 stock tool call headers and hidden export rows - #24

Merged
adonis-garcia-git merged 1 commit into
mainfrom
fm/fm-pi-0991-drift
Sep 30, 2026
Merged

adonis-garcia-git merged 1 commit into
mainfrom
fm/fm-pi-0991-drift

Conversation

@agarcia-heva

Copy link
Copy Markdown
Collaborator

Intent

Standing instruction: when you see a lint problem, test failure or flaky test, get it fixed even if your current work didn't cause it.

Context: the firstmate fork's CI (adonis-garcia-git/firstmate) is red on every PR, including unmodified main at 26d8d42. Two checks fail: Behavior portable serial 2, tests/fm-calm-pi-extension.test.sh ("rendered export DOM violated the Calm conversation boundary"), and serial 4, tests/fm-pi-branch-extension.test.sh ("Pi outcomes rendering consumers must preserve stock behavior"). Both reproduce locally with Pi 0.99.1, released 2026-09-29, which CI installs as the latest public Pi. Main's last green CI ran on Pi 0.87.x. This blocks #23 (the Helm send-failure fix) and every other PR.

What Changed

  • .pi/extensions/fm-branch-supervision.ts adds stockToolCallHeader, which reads Pi's VERSION to rebuild the call header for fm_branch_outcomes and fm_branch_processed when Calm is off. Before Pi 0.99 the header is just the bold title. From 0.99 on, a collapsed call adds a muted key=json preview cut at 100 characters, and an expanded call puts one muted key: value line under the title for each argument.
  • tests/fm-pi-branch-extension.test.sh gives the Pi stub a VERSION export and adds a test that checks both tools' collapsed and expanded headers on 0.87.0 and 0.99.0. The existing stock-consumer test now also compares Calm-off fm_branch_processed rendering with Pi's stock ToolExecutionComponent, collapsed and expanded.
  • tests/fm-calm-pi-extension.test.sh now passes if the rendered HTML export either leaves out legacy synthetic custom messages (older Pi) or includes them as hook-message-hidden rows hidden by default CSS (0.99). It still fails if the export opens with hidden messages shown or if any hook or synthetic row shows in the conversation column, and each check now reports its own error. docs/calm.md and docs/calm-mode-feasibility.md are updated to match, including listing fm_branch_processed among the hidden tool calls.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: A small change limited to tests and rendering: it gates the tool call header on Pi's exported VERSION and checks both tools against real Pi's stock renderer. The export check now allows rows that are hidden by default but still fails on any visible synthetic row. The only concern is some unexercised generic formatting code.

Testing

I ran both previously red suites against a temporary install of real Pi 0.99.1. The pi-branch suite fails at the base commit with the exact CI error and passes at the target commit. The Calm suite passes, but its tmux-driven interactive E2E cases were skipped because tmux is not on PATH. To cover the export boundary those cases guard, I exported sessions with real pi --export 0.99.1 and rendered them in headless Chrome, capturing DOM dumps and screenshots. The pre-fix check fails on an export where the synthetic row is correctly hidden (the CI regression). The post-fix check passes on it, and still fails, as it should, when the synthetic row is visible in the conversation. The screenshots show the hidden row appears only in the session tree, and the visible variant shows it in the conversation column. All temp installs and dirs were removed and the worktree is clean.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Pi outcomes rendering stays stock on Pi 0.99.1: the pi-branch suite fails at base and passes at target ✅ pass live before-pi-branch.log (exit=1, 'Calm-off ToolExecutionComponent rendering differs from Pi stock') vs after-pi-branch.log (exit=0, 'fm_branch_outcomes hides through ToolExecutionComponent while Calm-off…
fm_branch_outcomes and fm_branch_processed call headers match Pi's stock header before and from 0.99 ✅ pass live after-pi-branch.log: 'ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99'. The real Pi 0.99.1 ToolExecutionComponent comparison also passed.
A Calm export from real Pi 0.99.1 with a display:false synthetic row keeps it out of the visible conversation and passes the new boundary check (the old check fails, reproducing CI) ✅ pass live export-boundary-transcript.txt and export-hidden.png
Adversarial: a synthetic row that is actually visible in the conversation column is still rejected by the new boundary check ✅ pass live export-boundary-transcript.txt ('a visible hook message leaked into the conversation column') and export-visible.png
Full Calm interactive TUI E2E (/export from a live Calm session in tmux, then the Chrome DOM check) ⏸️ untested no tmux is not on PATH on this host, and installing system packages is not allowed here. Re-run tests/fm-calm-pi-extension.test.sh on a host with tmux (CI serial 2 has it) to drive it.

Pi 0.99.1 export with hidden synthetic row - conversation column shows no synthetic row
Adversarial: Pi 0.99.1 export with display:true synthetic row visible in conversation

Evidence: Export boundary check results, pre-fix vs post-fix

Pi 0.99.1 export, synthetic row hidden: pre-fix 26d8d42 boundary check exit=1 Pi 0.99.1 export, synthetic row hidden: post-fix d2f12e8 boundary check exit=0 Pi 0.99.1 export, synthetic row visible: pre-fix 26d8d42 boundary check exit=1 Pi 0.99.1 export, synthetic row visible: post-fix d2f12e8 boundary check exit=1 Error: a visible hook message leaked into the conversation column

Pi 0.99.1 export, synthetic row hidden: pre-fix 26d8d42 boundary check exit=1 
Pi 0.99.1 export, synthetic row hidden: post-fix d2f12e8 boundary check exit=0 
Pi 0.99.1 export, synthetic row visible: pre-fix 26d8d42 boundary check exit=1 
Pi 0.99.1 export, synthetic row visible: post-fix d2f12e8 boundary check exit=1 Error: a visible hook message leaked into the conversation column
Evidence: Base commit pi-branch suite on Pi 0.99.1 (reproduces CI failure)
not ok - Pi outcomes rendering consumers must preserve stock behavior: file:///private/var/folders/_2/z7jbw6xj5yx_dw_kkzrd332h0000gn/T/fm-pi-branch-extension.6m5EPB/stock-render-consumers/[eval1]:71
  throw new Error("Calm-off ToolExecutionComponent rendering differs from Pi stock");
        ^

Error: Calm-off ToolExecutionComponent rendering differs from Pi stock
    at file:///private/var/folders/_2/z7jbw6xj5yx_dw_kkzrd332h0000gn/T/fm-pi-branch-extension.6m5EPB/stock-render-consumers/[eval1]:71:9
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)

Node.js v24.16.0: expected exit 0, got 1
exit=1
Evidence: Target commit pi-branch suite on Pi 0.99.1 (exit 0)
ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99
ok - fm_branch_outcomes hides through ToolExecutionComponent while Calm-off and HTML export stay stock
ok - the installed Pi still bounds the picker's list and ranks its search
ok - branch owns accepted wakes with a stable prefix and deterministic verdict-driven delivery
ok - a captain outcome reaches main's model as one typed, sequence-keyed processing request while routine notes stay plain
ok - requested and unsolicited healthy outcomes keep distinct delivery and event ownership
ok - captain outcomes are exact and exactly once across crash, reload, busy main, compaction, and an unrelated assistant response
ok - a captain outcome opens one sequence-keyed processing turn, survives empty and unrelated answers, is re-presented at run end and session start, and closes only on its acknowledgement
ok - scopeForUnreadWake excludes every main-only class without vetoing eligible task-local rows, and writes the eligible snapshot
ok - second-mate signal rows route by their new span while crewmate and stale routing stay unchanged
ok - branch prompt_cache_key is stable per home across sessions and distinct between homes
ok - branch default-on eligibility (task-scoped, heartbeat, legacy flag ignored) binds and a broken branch rejects to watcher fallback
ok - under the away-posture record the wake carries the verbatim read-back tail, claims every row, opens no processing turn, cancels a pending request, and presents the accumulated rows after archive
ok - Pi branch: an unchanged held outcome reaches the captain once across cadences, and a later red check on the task still does
ok - an accepted away-only wake rejects after archive, while a drained task-local wake stays a quiet no-op
ok - a claimed heartbeat row on a non-heartbeat away wake lifts task scoping for the fleet report
ok - a heartbeat review survives a check row arriving before its drain
ok - fm_branch_report refuses a task the wake did not name, fleet included, while a heartbeat is unscoped
ok - pre-drain eligibility re-check excludes a newly main-owned row without deferring eligible work
ok - a co-present needs-decision row neither vetoes nor falsely settles routine branch delivery
ok - a settled branch turn without a durable outcome falls back and releases its grant for main replay
ok - provider-error latches cool down, re-probe once with backoff, and recover through a durable report
ok - selection changes preserve in-flight transcript ownership and reset provider-error streaks
ok - a stale main claim returns the durable wake to watcher delivery
ok - pre-drain eligibility re-check no-ops an already-drained wake
ok - dialog mirror filters tool and operational traffic, lands before wakes, and keeps a durable cursor
ok - the dialog mirror re-anchors for each session's new branch conversation and stays incremental within it
ok - every main session start begins a new branch conversation while one session keeps its own
ok - the current pin state binds every branch build, and clearing it returns the branch to main's model
ok - unpinned branches follow main model changes live while pinned branches stay fixed
ok - supervision-model command persists the captain's pick and rebinds the live branch
ok - supervision-model opens a bounded searchable list, follow main first, and pins the branch alone
ok - branch model picker keeps follow main first and filters the eligible catalog
ok - the effort pin binds every branch build, and clearing it returns the branch to main's effort
ok - unpinned branches follow main effort changes live while pinned branches stay fixed
ok - an extension-registered provider resolves in the isolated branch runtime
ok - supervision-model runs an effort picker after the model picker and persists both independently
ok - an unusable model pin rejects to watcher fallback and an unparseable one is treated as no pin
ok - replacement activation cleans old branch leases and retries failed cleanup
ok - branch activates on a cold start once the lock is acquired, never before
ok - queued wakes and mirrors stop mutating branch state after lock ownership is lost
ok - stale reports, shells, mirrors, cursors, leases, and prompts perform no side effects
ok - a Pi session that does not own the lock accepts nothing and mutates no branch state
ok - an extension rebind re-mirrors undelivered dialog instead of dropping it
ok - outcome delivery keeps the event loop running and interleaved reports stay ordered and exactly once
ok - a session replaced mid-delivery cancels cleanly and the stored outcome still arrives exactly once
ok - a failing store script surfaces to the branch and its outcome is neither lost nor delivered twice
ok - a failed cursor write re-delivers a routine note exactly once more while a captain outcome stays deduplicated
exit=0
Evidence: Target commit Calm suite on Pi 0.99.1 (exit 0, tmux cases skipped)
ok - Pi calm resolves its persistent home independently of Pi's launch directory
ok - Pi calm compatibility evidence never rejects a Pi version for being newer than 0.82.0, and still fails closed on a missing or malformed version
ok - a missing collapsed-thinking presentation API degrades only that Calm adapter with a clear skip reason, while the rest of Calm still registers
ok - missing Pi presentation class exports reach the independent adapter degradation path
ok - Calm hides queued Firstmate rows only on a session that can keep them, keeps hidden ones out of the editor on Escape, delivers them once in order, and leaves unsupported sessions and Calm off stock
ok - Calm registers none of its 7 built-in tool wrappers at load while config/calm is off, and all 7 synchronously at load while config/calm is on
ok - Calm's first same-session /calm activation claims every uncontested built-in, leaves a foreign bash tool fully intact and callable, warns prominently and logs the contested name, and only rows constructed before that activation - the documented bound - fail to retroactively collapse
ok - Pi calm centralizes transcript visibility, preserves execution/export data, keeps Pi's stock working row visible while no run is active, and persists its choice across session starts
ok - Pi calm on collapses mid-turn assistant working notes to zero height while Calm off keeps them, leaves streaming, truncated-final, and genuine final replies untouched, never mutates the messages, ignores every /calm argument, and restores a legacy persisted max as ordinary Calm on
skip: pi or tmux not found for Pi operational follow-up E2E
skip: pi or tmux not found for Pi Calm queued-row Escape E2E
skip: pi or tmux not found for Pi Calm hidden-block geometry E2E
ok - Pi Calm working ship keeps its centered two-row asymmetric Unicode boat inside a deterministic long-wave trough, paints all water standard blue and the whole boat standard yellow with balanced resets, keeps ANSI-stripped width exact, reverses cleanly at both edges and every width, clamps visible and hidden resizes, falls back deterministically when narrow, freezes and resumes across settle/start without hidden-time jumps or duplicate timers, resets only on a fresh session, and leaves Calm-off visibility untouched
ok - the rendered-export-DOM guard renders in one pass, retries a bounded number of Chrome start-up failures, and reports the Chrome binary, Chrome version, Pi version, exit status, and Chrome diagnostic when every attempt fails
skip: pi or tmux not found for Pi calm interactive E2E
exit=0
Evidence: Rendered export DOM files
<!DOCTYPE html>
<html lang="en"><head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Session Export</title>
  <style>
    :root {
      --accent: #800080;
      --borderAccent: #800080;
      --customMessageLabel: #800080;
      --mdCode: #800080;
      --mdListBullet: #800080;
      --syntaxType: #800080;
      --border: #000080;
      --mdLink: #000080;
      --syntaxKeyword: #000080;
      --syntaxVariable: #008080;
      --success: #008000;
      --mdCodeBlock: #008000;
      --toolDiffAdded: #008000;
      --bashMode: #008000;
      --syntaxNumber: #800080;
      --error: #800000;
      --toolDiffRemoved: #800000;
      --warning: #808000;
      --mdHeading: #808000;
      --syntaxFunction: #808000;
      --syntaxString: #008000;
      --thinkingMinimal: #000080;
      --thinkingLow: #000080;
      --thinkingMedium: #008080;
      --thinkingHigh: #800080;
      --thinkingXhigh: #ff00ff;
      --thinkingMax: #800000;
      --text: #e5e5e7;
      --userMessageText: #e5e5e7;
      --customMessageText: #727273;
      --toolTitle: #e5e5e7;
      --syntaxOperator: #727273;
      --syntaxPunctuation: #727273;
      --muted: #727273;
      --dim: #727273;
      --thinkingText: #727273;
      --toolOutput: #727273;
      --mdLinkUrl: #727273;
      --mdQuote: #727273;
      --mdQuoteBorder: #727273;
      --mdHr: #727273;
      --mdCodeBlockBorder: #727273;
      --toolDiffContext: #727273;
      --syntaxComment: #727273;
      --scrollbarTrack: #727273;
      --scrollbarThumb: #727273;
      --searchMatchText: #727273;
      --borderMuted: #727273;
      --thinkingOff: #727273;
      --selectedBg: #000000;
      --searchMatchBg: #000000;
      --userMessageBg: #000000;
      --customMessageBg: #000000;
      --toolPendingBg: #000000;
      --toolSuccessBg: #000000;
      --toolErrorBg: #000000;
      --exportPageBg: rgb(0, 0, 0);
      --exportCardBg: rgb(0, 0, 0);
      --exportInfoBg: rgb(20, 15, 0);
      --body-bg: rgb(0, 0, 0);
      --container-bg: rgb(0, 0, 0);
      --info-bg: rgb(20, 15, 0);
    }

    * { margin: 0; padding: 0; box-sizing: border-box; }

    :root {
      --line-height: 18px; /* 12px font * 1.5 */
      --sidebar-width: 400px;
      --sidebar-min-width: 240px;
      --sidebar-max-width: 840px;
      --sidebar-resizer-width: 6px;
    }

    body {
      font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
      font-size: 12px;
      line-height: var(--line-height);
      color: var(--text);
      background: var(--body-bg);
    }

    body.sidebar-resizing {
      cursor: col-resize;
      user-select: none;
    }

    #app {
      display: flex;
      min-height: 100vh;
    }

    /* Sidebar */
    #sidebar {
      width: var(--sidebar-width);
      min-width: var(--sidebar-width);
      max-width: var(--sidebar-width);
      background: var(--container-bg);
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      position: sticky;
      top: 0;
      height: 100vh;
      border-right: 1px solid var(--dim);
    }

    #sidebar-resizer {
      width: var(--sidebar-resizer-width);
      flex-shrink: 0;
      position: sticky;
      top: 0;
      height: 100vh;
      cursor: col-resize;
      touch-action: none;
      background: transparent;
      border-right: 1px solid transparent;
    }

    #sidebar-resizer:hover,
    body.sidebar-resizing #sidebar-resizer {
      background: var(--selectedBg);
      border-right-color: var(--dim);
    }

    .sidebar-header {
      padding: 8px 12px;
      flex-shrink: 0;
    }

    .sidebar-controls {
      padding: 8px 8px 4px 8px;
    }

    .sidebar-search {
      width: 100%;
      box-sizing: border-box;
      padding: 4px 8px;
      font-size: 11px;
      font-family: inherit;
      background: var(--body-bg);
      color: var(--text);
      border: 1px solid var(--dim);
      border-radius: 3px;
    }

    .sidebar-filters {
      display: flex;
      padding: 4px 8px 8px 8px;
      gap: 4px;
      align-items: center;
      flex-wrap: wrap;
    }

    .sidebar-search:focus {
      outline: none;
      border-color: var(--accent);
    }

    .sidebar-search::placeholder {
      color: var(--muted);
    }

    .filter-btn {
      padding: 3px 8px;
      font-size: 10px;
      font-family: inherit;
      background: transparent;
      color: var(--muted);
      border: 1px solid var(--dim);
      border-radius: 3px;
      cursor: pointer;
    }

    .filter-btn:hover {
      color: var(--text);
      border-color: var(--text);
    }

    .filter-btn.active {
      background: var(--accent);
      color: var(--body-bg);
      border-color: var(--accent);
    }

    .sidebar-close {
      display: none;
      padding: 3px 8px;
      font-size: 12px;
      font-family: inherit;
      background: transparent;
      color: var(--muted);
      border: 1px solid var(--dim);
      border-radius: 3px;
      cursor: pointer;
      margin-left: auto;
    }

    .sidebar-close:hover {
      color: var(--text);
      border-color: var(--text);
    }

    .tree-container {
      flex: 1;
      overflow: auto;
      padding: 4px 0;
    }

    .tree-node {
      padding: 0 8px;
      cursor: pointer;
      display: flex;
      align-items: baseline;
      font-size: 11px;
      line-height: 13px;
      white-space: nowrap;
    }

    .tree-node:hover {
      background: var(--selectedBg);
    }

    .tree-node.active {
      background: var(--selectedBg);
    }

    .tree-node.active .tree-content {
      font-weight: bold;
    }

    .tree-node.in-path {
      background: color-mix(in srgb, var(--accent) 10%, transparent);
    }

    .tree-node:not(.in-path) {
      opacity: 0.5;
    }

    .tree-node:not(.in-path):hover {
      opacity: 1;
    }

    .tree-prefix {
      color: var(--muted);
      flex-shrink: 0;
      font-family: monospace;
      white-space: pre;
    }

    .tree-marker {
      color: var(--accent);
      flex-shrink: 0;
    }

    .tree-content {
      color: var(--text);
    }

    .tree-role-user {
      color: var(--accent);
    }

    .tree-role-skill {
      color: var(--customMessageLabel);
    }

    .tree-role-assistant {
      color: var(--success);
    }

    .tree-role-tool {
      color: var(--muted);
    }

    .tree-muted {
      color: var(--muted);
    }

    .tree-error {
      color: var(--error);
    }

    .tree-compaction {
      color: var(--borderAccent);
    }

    .tree-branch-summary {
      color: var(--warning);
    }

    .tree-custom-message {
      color: var(--customMessageLabel);
    }

    .tree-status {
      padding: 4px 12px;
      font-size: 10px;
      color: var(--muted);
      flex-shrink: 0;
    }

    /* Main content */
    #content {
      flex: 1;
      min-width: 0;
      overflow-y: auto;
      padding: var(--line-height) calc(var(--line-height) * 2);
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    #content > * {
      width: 100%;
      max-width: 800px;
    }

    /* Help bar */
    .help-bar {
      font-size: 11px;
      color: var(--warning);
      margin-bottom: var(--line-height);
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 12px;
    }

    .help-hint {
      flex: 1 1 240px;
    }

    .help-actions {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 8px;
    }

    .header-toggle-btn,
    .download-json-btn {
      font-size: 10px;
      padding: 2px 8px;
      background: var(--container-bg);
      border: 1px solid var(--border);
      border-radius: 3px;
      color: var(--text);
      cursor: pointer;
      font-family: inherit;
    }

    .header-toggle-btn:hover,
    .download-json-btn:hover {
      background: var(--hover);
      border-color: var(--borderAccent);
    }

    .header-toggle-btn[aria-pressed="true"] {
      color: var(--accent);
      border-color: var(--accent);
      font-weight: bold;
    }

    /* Header */
    .header {
      background: var(--container-bg);
      border-radius: 4px;
      padding

... [266977 bytes truncated] ...

are:v1:sidebar-width';
      const MIN_CONTENT_WIDTH = 320;

      function isMobileLayout() {
        return window.matchMedia('(max-width: 900px)').matches;
      }

      function getSidebarBounds() {
        const rootStyles = getComputedStyle(document.documentElement);
        const minWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-min-width')) || 240;
        const maxWidth = parseFloat(rootStyles.getPropertyValue('--sidebar-max-width')) || 720;
        const viewportMaxWidth = window.innerWidth - MIN_CONTENT_WIDTH;
        return {
          minWidth,
          maxWidth: Math.max(minWidth, Math.min(maxWidth, viewportMaxWidth))
        };
      }

      function clampSidebarWidth(width) {
        const { minWidth, maxWidth } = getSidebarBounds();
        return Math.max(minWidth, Math.min(maxWidth, width));
      }

      function applySidebarWidth(width) {
        document.documentElement.style.setProperty('--sidebar-width', `${Math.round(clampSidebarWidth(width))}px`);
      }

      function loadSidebarWidth() {
        try {
          const raw = localStorage.getItem(SIDEBAR_WIDTH_STORAGE_KEY);
          if (raw === null) return null;
          const width = Number(raw);
          return Number.isFinite(width) ? width : null;
        } catch {
          return null;
        }
      }

      function saveSidebarWidth(width) {
        try {
          localStorage.setItem(SIDEBAR_WIDTH_STORAGE_KEY, String(Math.round(clampSidebarWidth(width))));
        } catch {
          // Ignore storage failures (e.g. private browsing restrictions)
        }
      }

      function setupSidebarResize() {
        const savedWidth = loadSidebarWidth();
        if (savedWidth !== null) {
          applySidebarWidth(savedWidth);
        }

        if (!sidebarResizer) return;

        let cleanupDrag = null;

        const stopDrag = (pointerId) => {
          if (cleanupDrag) {
            cleanupDrag(pointerId);
            cleanupDrag = null;
          }
        };

        sidebarResizer.addEventListener('pointerdown', (e) => {
          if (isMobileLayout()) return;

          e.preventDefault();
          const startX = e.clientX;
          const startWidth = sidebar.getBoundingClientRect().width;
          document.body.classList.add('sidebar-resizing');
          sidebarResizer.setPointerCapture?.(e.pointerId);

          const onPointerMove = (event) => {
            applySidebarWidth(startWidth + (event.clientX - startX));
          };

          cleanupDrag = (pointerIdToRelease) => {
            document.body.classList.remove('sidebar-resizing');
            sidebarResizer.releasePointerCapture?.(pointerIdToRelease);
            window.removeEventListener('pointermove', onPointerMove);
            window.removeEventListener('pointerup', onPointerUp);
            window.removeEventListener('pointercancel', onPointerCancel);
            saveSidebarWidth(sidebar.getBoundingClientRect().width);
          };

          const onPointerUp = (event) => stopDrag(event.pointerId);
          const onPointerCancel = (event) => stopDrag(event.pointerId);

          window.addEventListener('pointermove', onPointerMove);
          window.addEventListener('pointerup', onPointerUp);
          window.addEventListener('pointercancel', onPointerCancel);
        });

        sidebarResizer.addEventListener('dblclick', () => {
          if (isMobileLayout()) return;
          applySidebarWidth(400);
          saveSidebarWidth(400);
        });

        window.addEventListener('resize', () => {
          if (isMobileLayout()) return;
          applySidebarWidth(sidebar.getBoundingClientRect().width);
        });
      }

      setupSidebarResize();

      hamburger.addEventListener('click', () => {
        sidebar.classList.add('open');
        overlay.classList.add('open');
        hamburger.style.display = 'none';
      });

      const closeSidebar = () => {
        sidebar.classList.remove('open');
        overlay.classList.remove('open');
        hamburger.style.display = '';
      };

      overlay.addEventListener('click', closeSidebar);
      document.getElementById('sidebar-close').addEventListener('click', closeSidebar);

      // Toggle states
      let thinkingExpanded = true;
      let toolOutputsExpanded = false;
      let showHiddenMessages = false;

      function setHiddenMessagesVisible(visible) {
        showHiddenMessages = visible;
        document.body.classList.toggle('show-hidden-messages', visible);
        const button = document.querySelector('[data-action="toggle-hidden-messages"]');
        if (button) {
          button.setAttribute('aria-pressed', String(visible));
          button.textContent = visible ? 'Hide hidden messages' : 'Show hidden messages';
        }
      }

      function setThinkingExpanded(expanded) {
        thinkingExpanded = expanded;
        document.querySelector('[data-action="toggle-thinking"]')?.setAttribute('aria-pressed', String(expanded));
        document.querySelectorAll('.thinking-text').forEach(el => {
          el.style.display = thinkingExpanded ? '' : 'none';
        });
        document.querySelectorAll('.thinking-collapsed').forEach(el => {
          el.style.display = thinkingExpanded ? 'none' : 'block';
        });
      }

      function setToolOutputsExpanded(expanded) {
        toolOutputsExpanded = expanded;
        document.querySelector('[data-action="toggle-tools"]')?.setAttribute('aria-pressed', String(expanded));
        document.querySelectorAll('.tool-output.expandable').forEach(el => {
          el.classList.toggle('expanded', toolOutputsExpanded);
        });
        document.querySelectorAll('.compaction').forEach(el => {
          el.classList.toggle('expanded', toolOutputsExpanded);
        });
        document.querySelectorAll('.skill-invocation').forEach(el => {
          el.classList.toggle('expanded', toolOutputsExpanded);
        });
      }

      const attachHeaderHandlers = () => {
        document.querySelector('[data-action="toggle-thinking"]')?.addEventListener('click', () => {
          setThinkingExpanded(!thinkingExpanded);
        });
        document.querySelector('[data-action="toggle-tools"]')?.addEventListener('click', () => {
          setToolOutputsExpanded(!toolOutputsExpanded);
        });
        document.querySelector('[data-action="toggle-hidden-messages"]')?.addEventListener('click', () => {
          setHiddenMessagesVisible(!showHiddenMessages);
        });
      };

      const isEditableTarget = (element) => {
        if (!element) return false;
        const tagName = element.tagName;
        if (tagName === 'INPUT' || tagName === 'TEXTAREA' || tagName === 'SELECT' || tagName === 'BUTTON') {
          return true;
        }
        return element.isContentEditable || Boolean(element.closest?.('[contenteditable="true"]'));
      };

      // Keyboard shortcuts
      document.addEventListener('keydown', (e) => {
        if (e.key === 'Escape') {
          searchInput.value = '';
          searchQuery = '';
          navigateTo(leafId, 'bottom');
        }

        if (e.ctrlKey || e.metaKey || e.altKey || isEditableTarget(document.activeElement)) {
          return;
        }

        const key = e.key.toLowerCase();
        if (key === 't') {
          e.preventDefault();
          setThinkingExpanded(!thinkingExpanded);
        } else if (key === 'o') {
          e.preventDefault();
          setToolOutputsExpanded(!toolOutputsExpanded);
        } else if (key === 'h') {
          e.preventDefault();
          setHiddenMessagesVisible(!showHiddenMessages);
        }
      });

      // Initial render
      // If URL has targetId, scroll to that specific message; otherwise stay at top
      if (leafId) {
        if (urlTargetId && byId.has(urlTargetId)) {
          // Deep link: navigate to leaf and scroll to target message
          navigateTo(leafId, 'target', urlTargetId);
        } else {
          navigateTo(leafId, 'none');
        }
      } else if (entries.length > 0) {
        // Fallback: use last entry if no leafId
        navigateTo(entries[entries.length - 1].id, 'none');
      }
    })();

  </script>


</body></html>

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ .pi/extensions/fm-branch-supervision.ts:2166 - stockToolCallHeader re-creates Pi 0.99's private formatToolCallWithArgs in general form. It handles non-object and array args by wrapping them as args, cuts collapsed previews at 100 characters with ..., and rewrites tabs, CRs, and multi-line strings in expanded mode. Its only callers are fm_branch_outcomes (recent?: number) and fm_branch_processed (through: number), so real calls never hit the truncation, multi-line, or non-object branches. Neither the stub test (tests/fm-pi-branch-extension.test.sh:4801) nor the real-Pi comparison (:4937 {recent: 2}, :4992 {through: 1}) runs them. If Pi changes its format they can drift from stock without any test failing. The intent (get Pi 0.99.1 CI green) only needs the number-argument path: bold title, plus key=json when collapsed or \n key: value when expanded. Suggested fix: cut the helper down to that narrower form, and keep the generic branches only if the author wants full fidelity with the upstream port.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Pi outcomes rendering stays stock on Pi 0.99.1: the pi-branch suite fails at base and passes at target ✅ pass live before-pi-branch.log (exit=1, 'Calm-off ToolExecutionComponent rendering differs from Pi stock') vs after-pi-branch.log (exit=0, 'fm_branch_outcomes hides through ToolExecutionComponent while Calm-off…
fm_branch_outcomes and fm_branch_processed call headers match Pi's stock header before and from 0.99 ✅ pass live after-pi-branch.log: 'ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99'. The real Pi 0.99.1 ToolExecutionComponent comparison also passed.
A Calm export from real Pi 0.99.1 with a display:false synthetic row keeps it out of the visible conversation and passes the new boundary check (the old check fails, reproducing CI) ✅ pass live export-boundary-transcript.txt and export-hidden.png
Adversarial: a synthetic row that is actually visible in the conversation column is still rejected by the new boundary check ✅ pass live export-boundary-transcript.txt ('a visible hook message leaked into the conversation column') and export-visible.png
Full Calm interactive TUI E2E (/export from a live Calm session in tmux, then the Chrome DOM check) ⏸️ untested no tmux is not on PATH on this host, and installing system packages is not allowed here. Re-run tests/fm-calm-pi-extension.test.sh on a host with tmux (CI serial 2 has it) to drive it.
  • Installed @earendil-works/[email protected] into a throwaway temp prefix (not global); pi --version -> 0.99.1
  • FM_PI_PACKAGE_DIR=&lt;tmp&gt;/pi-coding-agent PATH=&lt;tmp&gt;/.bin:$PATH bash tests/fm-pi-branch-extension.test.sh at d2f12e8 -> exit 0
  • Same suite from git archive 26d8d42 against Pi 0.99.1 -> exit 1, 'Pi outcomes rendering consumers must preserve stock behavior' (reproduces CI)
  • FM_CHROME_BIN=&lt;Google Chrome&gt; bash tests/fm-calm-pi-extension.test.sh at d2f12e8 -> exit 0 (tmux-driven E2E cases skipped: tmux not on PATH)
  • Built a session jsonl with a firstmate-synthetic-input custom_message (display:false, and display:true as the adversarial case), exported it with real pi --export 0.99.1, dumped the DOM and took screenshots with headless Chrome
  • Ran the export-DOM boundary check from each commit's tests/fm-calm-pi-extension.test.sh (26d8d42 and d2f12e8) against both rendered DOMs
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Pi 0.99 shows call arguments on the stock tool header and renders
display:false custom messages into the export conversation column as rows
hidden by default. Match the installed Pi's call header in the supervision
outcome tools, and hold Calm's export boundary to the visible conversation.

Ports the Pi-rendering portion of upstream kunchenguid/firstmate e2668de
(kunchenguid#6162) without its unrelated remote-provisioning, dispatch, and queued-turn
changes.
adonis-garcia-git pushed a commit that referenced this pull request Sep 30, 2026
…rtable serial 8). Serial 2 and 4 fail for a reason outside this PR. **Serial 8** (`tests/fm-precompact-handoff.test.sh`, "a session without the fleet lock wrote over the lock holder's handoff"): the test has a race. It starts the fake lock holder with `"$FAKE_CLAUDE" -c 'sleep 60; :' &`, writes that pid to `state/.lock`, and runs the hook straight away. Until the background child execs the claude-named binary, it is still a plain bash fork. So `fm_harness_pid_alive` does not recognise it as a live owner, the hook treats the lock as stale, and it writes the note. Invariant: the test must run the hook only once the pid named in the lock is a live harness-shaped process. This is the only backgrounded fake-harness holder in the PR's tests. Fix: after starting the holder, the test waits up to 5 s, checking every 0.1 s with the real `fm_harness_pid_alive` from `bin/fm-session-lock-lib.sh`, before writing the lock and running the hook. If the holder never becomes live, the test fails with a clear message. Product code is unchanged. Verified: the full suite passed 3 times in a row locally and `shellcheck -x` is clean. **Serial 2 and 4** (`tests/fm-calm-pi-extension.test.sh` "rendered export DOM violated the Calm conversation boundary"; `tests/fm-pi-branch-extension.test.sh` "Calm-off ToolExecutionComponent rendering differs from Pi stock"): these are caused by Pi 0.99.1, released 2026-09-29, which CI installs as the latest Pi. PR #24 (open, not merged) says both fail the same way on unmodified main at 26d8d42, the base of this branch, and fixes them. This PR does not touch those files, so no change was made for them here. They will stay red until PR #24 is merged
adonis-garcia-git pushed a commit that referenced this pull request Sep 30, 2026
…used by this PR, serial 5 was a flake in an existing test, and serial 2 and 4 come from outside this PR. **Serial 8** (`tests/fm-precompact-handoff.test.sh`, "a session without the fleet lock wrote over the lock holder's handoff"): the previous round's fix, which waited for the lock holder, was not the real cause. Invariant: every hook run that stands in for "Claude runs the hook" must keep the fake claude process alive as an ancestor of the hook. - The non-owner run was `"$FAKE_CLAUDE" -c '"$FM_HOME/bin/fm-precompact-handoff.sh"'`. With a single command, bash replaces itself with the hook script (exec), so the claude-named process disappears. The hook then finds no harness ancestry, the lock check says "no foreign owner", and the hook writes the note. - Locally it passed only because the test process itself runs under a real Claude session, which the ancestry walk found. CI has no such ancestor. - I reproduced the CI failure locally by running the test detached from Claude's process tree. - Fix, applied to both sites that need the fake harness as an ancestor (the non-owner run and the own-lock run, where bash can exec the last command): add a trailing `:` no-op, the same trick the holder already uses. Product code is unchanged. - Verified: passes detached from Claude (the CI-like case) and 3 times in a row in the normal environment. **Serial 5** (`tests/fm-contributions.test.sh`, "generated check did not attempt a read"): this test is not touched by the PR. It passed on this branch's previous run, and the only commit since then changed another test file. The test gives the poll a 1-second budget using whole-second clock readings. If the second ticks between setting the deadline and the reserve check, the poll correctly skips the read, which `bin/fm-contributions.sh` documents as allowed ("may be unmeasured"). The test's check that a read happened was therefore racy. - Invariant: the budget-plumbing assertion must not depend on the wall clock not ticking. - Fix: freeze the fake clock (`/bin/date +%s > "$home/forge/clock"`) as the other small-budget tests in the same file already do. This covers both the configured and inherited modes. The only small-budget test without a frozen clock was this one. - Verified: the full file passes. **Serial 2 and 4** (`tests/fm-calm-pi-extension.test.sh`, `tests/fm-pi-branch-extension.test.sh`): these are the known Pi 0.99.1 drift failures. They also fail on main (26d8d42) and are fixed by open PR #24. This PR doesn't touch those files, so I made no change for them, and they will stay red until PR #24 is merged. `shellcheck -x` is clean on both edited tests
@adonis-garcia-git
adonis-garcia-git merged commit a63cb7a into main Sep 30, 2026
19 checks passed
adonis-garcia-git pushed a commit that referenced this pull request Sep 30, 2026
…t with it (#25)

* feat(bin): write a pre-compaction handoff before every Claude compaction

A compaction keeps the session but replaces its conversation with a summary,
and an automatic compaction fires with no /stow first, so decisions and open
work that existed only in conversation could be lost or blurred.

bin/fm-precompact-handoff.sh is registered as an unmatched Claude PreCompact
hook. Just before every manual and automatic compaction it writes a snapshot
into its own marked block of data/session-handoff.md: the /compact
instructions, the captain's most recent turns verbatim with the reply each
answered, firstmate's last reply, held backlog items, and every task record
with its last status. Lines outside the block, such as /stow's conversation
threads, are preserved. It always exits 0 with empty stdout, so it can never
block the compaction, and records any failure with its reason.

The compact digest prints the fresh block in its fleet-state stage, or says
plainly that none was recorded, it is stale, or it failed, with the
pre-compaction transcript to read instead. The entry stands down under Grok,
Cursor, and pi-code, in task worktrees, and in gate agents; the pi-code
payload predicate moves into fm-hook-host-lib.sh so the Stop auto-arm and
the new hook share it.

* fix(bin): keep the pre-compaction note to the captain's words and identifiers

The pre-compaction snapshot copied firstmate's replies, a reply-context
excerpt per captain turn, worker status lines, and backlog hold reasons, any
of which can quote patient or worker text. It now carries only the captain's
own words (verbatim, clipped) plus identifiers: held backlog item ids and hold
kinds, and each task record's id, kind, and PR URL. The compaction digest
already reprints the work state from its own records.

* no-mistakes(review): Drop origin-less fallback and skip firstmate operational input

* no-mistakes(review): Match doorbells by shape so pruned records stay excluded

* no-mistakes(review): Correct compact digest transcript-naming branches in sessionstart docs

* fix(bin): lead the compaction digest with the handoff and drive the live guard through a pty

The PreCompact hook was committed without its executable bit, so the tracked
settings entry failed with "Permission denied" in a real checkout and no
handoff was ever written. It is now mode 100755.

Claude Code keeps only a 2KB preview of an oversized hook output inline, and
a compaction digest is routinely larger, so the pre-compaction handoff now
leads the compact digest ahead of every other section. Its heading points at
the file the harness names on its "Full output saved to" line, and captain
turns are listed newest first so the latest words fall inside the preview.

The opt-in live guard now drives the real interactive TUI through a Python
pty, because headless `claude -p` transcripts carry no origin field. It copies
the hook at its git index mode instead of chmod-ing it, so a missing
executable bit fails the guard, and it proves a typed firstmate doorbell is
dropped.

* no-mistakes(document): Drop /stow as the session-handoff note writer

* no-mistakes(ci): Fixed the one failure caused by this PR (Behavior portable serial 8). Serial 2 and 4 fail for a reason outside this PR. **Serial 8** (`tests/fm-precompact-handoff.test.sh`, "a session without the fleet lock wrote over the lock holder's handoff"): the test has a race. It starts the fake lock holder with `"$FAKE_CLAUDE" -c 'sleep 60; :' &`, writes that pid to `state/.lock`, and runs the hook straight away. Until the background child execs the claude-named binary, it is still a plain bash fork. So `fm_harness_pid_alive` does not recognise it as a live owner, the hook treats the lock as stale, and it writes the note. Invariant: the test must run the hook only once the pid named in the lock is a live harness-shaped process. This is the only backgrounded fake-harness holder in the PR's tests. Fix: after starting the holder, the test waits up to 5 s, checking every 0.1 s with the real `fm_harness_pid_alive` from `bin/fm-session-lock-lib.sh`, before writing the lock and running the hook. If the holder never becomes live, the test fails with a clear message. Product code is unchanged. Verified: the full suite passed 3 times in a row locally and `shellcheck -x` is clean. **Serial 2 and 4** (`tests/fm-calm-pi-extension.test.sh` "rendered export DOM violated the Calm conversation boundary"; `tests/fm-pi-branch-extension.test.sh` "Calm-off ToolExecutionComponent rendering differs from Pi stock"): these are caused by Pi 0.99.1, released 2026-09-29, which CI installs as the latest Pi. PR #24 (open, not merged) says both fail the same way on unmodified main at 26d8d42, the base of this branch, and fixes them. This PR does not touch those files, so no change was made for them here. They will stay red until PR #24 is merged

* no-mistakes(ci): I changed two test files. The serial 8 failure is caused by this PR, serial 5 was a flake in an existing test, and serial 2 and 4 come from outside this PR. **Serial 8** (`tests/fm-precompact-handoff.test.sh`, "a session without the fleet lock wrote over the lock holder's handoff"): the previous round's fix, which waited for the lock holder, was not the real cause. Invariant: every hook run that stands in for "Claude runs the hook" must keep the fake claude process alive as an ancestor of the hook. - The non-owner run was `"$FAKE_CLAUDE" -c '"$FM_HOME/bin/fm-precompact-handoff.sh"'`. With a single command, bash replaces itself with the hook script (exec), so the claude-named process disappears. The hook then finds no harness ancestry, the lock check says "no foreign owner", and the hook writes the note. - Locally it passed only because the test process itself runs under a real Claude session, which the ancestry walk found. CI has no such ancestor. - I reproduced the CI failure locally by running the test detached from Claude's process tree. - Fix, applied to both sites that need the fake harness as an ancestor (the non-owner run and the own-lock run, where bash can exec the last command): add a trailing `:` no-op, the same trick the holder already uses. Product code is unchanged. - Verified: passes detached from Claude (the CI-like case) and 3 times in a row in the normal environment. **Serial 5** (`tests/fm-contributions.test.sh`, "generated check did not attempt a read"): this test is not touched by the PR. It passed on this branch's previous run, and the only commit since then changed another test file. The test gives the poll a 1-second budget using whole-second clock readings. If the second ticks between setting the deadline and the reserve check, the poll correctly skips the read, which `bin/fm-contributions.sh` documents as allowed ("may be unmeasured"). The test's check that a read happened was therefore racy. - Invariant: the budget-plumbing assertion must not depend on the wall clock not ticking. - Fix: freeze the fake clock (`/bin/date +%s > "$home/forge/clock"`) as the other small-budget tests in the same file already do. This covers both the configured and inherited modes. The only small-budget test without a frozen clock was this one. - Verified: the full file passes. **Serial 2 and 4** (`tests/fm-calm-pi-extension.test.sh`, `tests/fm-pi-branch-extension.test.sh`): these are the known Pi 0.99.1 drift failures. They also fail on main (26d8d42) and are fixed by open PR #24. This PR doesn't touch those files, so I made no change for them, and they will stay red until PR #24 is merged. `shellcheck -x` is clean on both edited tests

* no-mistakes(ci): I fixed all four review findings (F1-F4). Each has a regression test that I confirmed fails on the current head and passes now. I did not touch the Pi/Calm tests; serial 2 and 4 are the known Pi 0.99.1 drift that PR 24 fixes. **F1: captain turns containing `<command-name>` were silently dropped.** The rule that must hold: every captain turn is either rendered as the slash command the captain typed or kept word for word, never dropped. - The cause: jq's `capture` returns nothing at all on a non-match, so `try/catch` never fired and the turn vanished. - Fix in `bin/fm-precompact-handoff.sh`: `command_form` now reads each capture as a single value that is empty when there is no match. A turn is treated as a slash command only when it contains nothing but command tags; anything else, including prose that quotes a tag, is kept word for word. - New test: a bare `/stow` renders as `/stow`, `/bearings fleet now` renders with its arguments, and turns with an unpaired tag or a quoted paired tag keep their decision text. - The opt-in live pty guard now types a lab-local `/stow` before `/compact` and checks that the note quotes it. **F2: a killed hook left temporary files in `data/`.** The rule: a killed hook leaves no temporary files. - All three temporary files the finding named (the turns copy, the block, and the note being assembled) now live in one directory in `data/`, created with `mktemp -d`. That keeps the note's replace a same-filesystem rename. - The results-record temporary file is covered the same way. - An exit trap (with TERM, INT and HUP routed to exit) removes them all, so I deleted the scattered `rm -f` calls. - New test: the hook is held on a FIFO transcript, its process group is sent SIGTERM, and nothing is left in `data/` or `state/`. I also ran it 3 times detached from a terminal, as CI runs. - One limit: a SIGKILL cannot be caught, so nothing can clean up after it. **F3: a long `/compact` argument pushed the newest captain turn out of the 2KB preview.** The argument is now clipped to `TURN_CHARS`, the same limit as a turn. I rewrote the preview test in `tests/fm-session-start.test.sh` to run the real hook, with 10 turns of 1200 characters and a `/compact` argument of about 1500 characters. On the old hook the newest turn started at byte 2367; it now starts before byte 2048. **F4: a stale record from another session was shown as this compaction's handoff.** The rule: the digest shows a handoff only if the record is recent and names this compaction's session. - `bin/fm-sessionstart-run.sh` now reads `session_id` from the payload with the same jq-free parser it uses for `source`, and passes `--session` to `fm-session-start.sh` for both the clear and compact paths. - `bin/fm-session-start.sh` accepts `--session` and forwards it through the timed re-run. To keep that simple, I replaced its four-way branch with a single argument list. - The digest now requires the record's `session=` to match, as well as the age check. On a mismatch, or when either id is missing, it prints the "None recorded for this compaction" warning. - New tests: the block prints for a matching session; the warning prints for another session, for a missing compact id, and for a record with no session; and the run wrapper forwards the payload's `session_id` all the way through. - I updated `docs/sessionstart-nudge.md` and the headers of the three scripts. **Vendor check:** F4 only works if the compact `SessionStart` payload carries the same `session_id` as the `PreCompact` payload. The live guard now checks that. I ran it against the real Claude Code 2.1.285 TUI and both cases passed; the evidence is recorded in `docs/verification/supervision.md`. **Verification:** these suites all pass: `fm-precompact-handoff` (12), `fm-session-start` (58), `fm-sessionstart-nudge` (24), `fm-cursor-primary`, `fm-turnend-guard`, `fm-lint` and `fm-documentation-audiences`. `shellcheck -x` is clean on every edited file. The note still carries only the captain's words plus identifiers

* no-mistakes(review): Gate every compaction handoff branch on a Claude primary

* no-mistakes(test): Run session-forwarding nudge test as a Claude primary

* no-mistakes(document): Note Claude-only handoff gating in session-start header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants