.maestro/playbooks/2026-03-15-Branch-Memory/2026-03-15-Branch-Parity/BRANCH-PARITY-03-MCP-Output-And-Verification.md
MCP search results (used by the mem-search skill and get_observations tool) filter observations by branch ancestry correctly, but the returned result objects don't include branch or commit_sha fields. The ObservationRow type in src/services/sqlite/types.ts — which ObservationSearchResult extends — lacks these columns. Since SQLite queries use SELECT * or SELECT o.*, the data is already present in query results but gets silently dropped by TypeScript's type system. This phase adds the fields to the type, updates the search result formatter to optionally display branch info, and performs end-to-end verification of all three branch-memory gaps.
Add branch and commit_sha to the ObservationRow interface in src/services/sqlite/types.ts:
ObservationRow interface (line ~204) currently has 16 fields ending with created_at_epochbranch?: string | null and commit_sha?: string | null as optional fieldsObservationSearchResult (extends ObservationRow at line ~275) and all search result consumersAllRecentObservationRow in src/services/sqlite/observations/types.ts already has these fields (lines 86-87), so only the main ObservationRow needs updating Update ResultFormatter.formatObservationSearchRow() in src/services/worker/search/ResultFormatter.ts to include branch info in the display table:
| ID | Time | T | Title | Read | Work || ${id} | ${timeDisplay} | ${icon} | ${title} | ~${readTokens} |obs.branch is present and not null, append a short branch indicator, e.g., format title as ${title} (${obs.branch}) or ${title} [${obs.branch.substring(0, 20)}]Write tests for MCP output metadata:
tests/mcp-output-metadata.test.ts) covering:
ObservationSearchResult objects include branch/commit_sha when present in query resultsResultFormatter.formatObservationSearchRow() includes branch in title when branch is presentResultFormatter.formatObservationSearchRow() displays title unchanged when branch is nullRun the complete test suite and perform full build:
npm test — all tests must pass, including:
tests/branch-memory-integration.test.ts)tests/git-ancestry.test.ts)tests/hook-branch-detection.test.ts)tests/context/branch-filtering.test.ts)tests/sqlite/observations-branch-filter.test.ts)npm run build-and-sync for complete production buildVerify all three branch-memory gaps are closed by reviewing the changes:
StoredObservation has branch/commit_sha, formatObservationDocs adds them to metadata, syncObservation passes them through, and buildWhereFilter can filter by commit_shaObservation type has branch/commit_sha, PaginationHelper selects them, and ObservationCard renders themObservationRow has branch/commit_sha and ResultFormatter includes branch in outputgit diff main...HEAD --stat to see the complete scope of changes across all phases