Skip to content

fix(brainbar): make recall stats fallback explicit - #799

Merged
EtanHey merged 4 commits into
mainfrom
wt/n1-recall-fallback
Sep 7, 2026
Merged

fix(brainbar): make recall stats fallback explicit#799
EtanHey merged 4 commits into
mainfrom
wt/n1-recall-fallback

Conversation

@EtanHey

@EtanHey EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • retain the full BrainLayer stats card while appending a mode-specific notice for implemented-enum modes that fall back to stats: summary, sessions, operations, plan, and context without a non-empty session_id
  • preserve byte-identical output for explicit/default stats, injections, and context with a non-empty session_id
  • keep brain_recall.mode schema validation authoritative: an unrecognized mode is rejected instead of reaching the handler

Verification

  • focused fallback regression: 1 passed, 0 failed
  • full BrainBar Swift suite after the follow-up: 891 passed, 10 skipped, 0 failed
  • isolated built-daemon socket probe: successful MCP response, stats retained, summary notice present
  • changed-only worker and push gates: 3 MCP-registration tests, 40 isolated eval/hook tests, 1 Bun test, and the FTS5 shell regression passed
  • full Python pytest was attempted before the follow-up but is not green locally: the run exhausted the process file-descriptor limit and terminated with OSError: [Errno 24] Too many open files; this Swift-only diff has no mapped Python unit target

Review notes

  • Lead follow-up 2026-09-07-N1-followup-revert-enum-strip.md corrected the original acceptance row: unknown mode strings are unreachable by design and remain rejected by the advertised enum.
  • The existing brain_recall tool description may over-advertise unimplemented modes; changing it is explicitly outside this lane.

Bot policy

  • Applied AGENTS.md: request Codex review and a lead-routed Claude pair review; do not route mandatory reviews to Bugbot or Greptile.
  • Local CodeRabbit review of the corrected two-commit diff completed with 0 findings.

— brainlayerCodex-665a5a35 (worker) · codex/gpt-5.6-sol


Note

Low Risk
Read-only MCP tool output changes with no auth or persistence impact; behavior is tightened for clarity while primary modes stay byte-identical.

Overview
brain_recall no longer silently returns BrainLayer stats for modes that do not have a dedicated handler. stats (and the default when mode is omitted) still return the stats card unchanged; injections and context with a non-empty session_id are unchanged.

For enum-valid modes that still fall back to stats—summary, sessions, operations, plan, and context without a session_id—the handler now appends a short notice after the full stats text explaining why stats were returned. Invalid mode values remain schema validation errors and never reach the handler.

Regression coverage in MCPRouterTests exercises fallback notices, unchanged paths, and rejected bogus modes.

Reviewed by Cursor Bugbot for commit 08325e0. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Bug Fixes

    • Improved BrainBar recall mode handling when no session is provided.
    • Unsupported recall modes now return statistics with a clear notice.
    • Supported statistics, injections, and context modes continue to return their dedicated responses.
    • Invalid modes continue to produce validation errors.
  • Tests

    • Added coverage for supported, unsupported, invalid, and empty-session recall requests.

Note

Make brain_recall stats fallback explicit in MCPRouter.handleBrainRecall

The brain_recall handler previously returned a generic stats fallback for unsupported or incomplete requests without indicating why. It now appends an explicit notice when context mode lacks a session_id or when a schema-accepted mode is not implemented, while still returning the same stats output.

  • Valid context requests with a session_id continue returning recalled context unchanged.
  • Explicit stats mode and the default fallback return stats without a notice.
  • Adds test coverage in MCPRouterTests.swift verifying notices for unimplemented modes, schema rejection for invalid modes, missing-session fallback, and equality between default and explicit stats responses.

Macroscope summarized 08325e0.

Co-Authored-By: brainlayerCodex-665a5a35 running gpt-5.6-sol <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_75823df3-cae4-4ef1-aedd-bae4ee4d2339)

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 46 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 618799f2-660a-4cbe-866a-dca305d22b3f

📥 Commits

Reviewing files that changed from the base of the PR and between 17011a4 and 08325e0.

📒 Files selected for processing (2)
  • brain-bar/Sources/BrainBar/MCPRouter.swift
  • brain-bar/Tests/BrainBarTests/MCPRouterTests.swift

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: ff3f4644-2e94-4167-a923-b4ca927bb4d2

📥 Commits

Reviewing files that changed from the base of the PR and between 39cc7e6 and 17011a4.

📒 Files selected for processing (2)
  • brain-bar/Sources/BrainBar/MCPRouter.swift
  • brain-bar/Tests/BrainBarTests/MCPRouterTests.swift

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: swift (macos-15)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
🔇 Additional comments (2)
brain-bar/Sources/BrainBar/MCPRouter.swift (1)

1174-1186: LGTM!

brain-bar/Tests/BrainBarTests/MCPRouterTests.swift (1)

1767-1830: LGTM!


📝 Walkthrough

Walkthrough

handleBrainRecall now uses stats fallback behavior for empty-session context requests and unsupported modes. Tests cover fallback notices, invalid-mode errors, and existing stats, injections, and context responses.

Changes

Brain recall routing

Layer / File(s) Summary
Recall fallback behavior and validation
brain-bar/Sources/BrainBar/MCPRouter.swift, brain-bar/Tests/BrainBarTests/MCPRouterTests.swift
handleBrainRecall recalls context only when session_id is non-empty. Other non-context paths return stats, with a notice for modes other than stats. Tests cover fallback behavior, invalid modes, and supported modes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 17011

Brain recall now returns the complete stats card with a clear notice when a supported fallback mode cannot provide its specialized response, while valid dedicated modes retain their existing behavior. The covered routing and validation behavior presents no remaining merge-blocking risk.

Poem

A rabbit checks the recall gate
Empty sessions now wait for stats to state
Context hops only with an ID
Unsupported modes get notices free
Tests twirl softly, guarding the flow

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making BrainBar recall statistics fallback behavior explicit.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wt/n1-recall-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

BrainLayer ratchet

Every Value below was measured by this run. A row this machine cannot measure says n/a — <reason> instead of a number; baselines in Notes name their own machine, method and date and were not measured here.

Row Status Value (measured by this run) Method Notes
commit provenance 🟢 GREEN measured 08325e08616f == PR head · checkout cce3cb4efca9 commit graph + live PR head · in-process · runner Which commit this whole table is about. On a pull_request event the checkout is GitHub's synthetic merge ref, whose sha is not on the PR — #759's table printed 13fa724278bf while that PR's head was 4632f979 — so this row names the PR-head parent instead, the sha a reviewer can actually see. The comparison sha is read live from repos/{owner}/{repo}/pulls/{n} when the table is collected, not taken from the event payload, because the payload cannot know the run has been overtaken. Residual window, stated rather than papered over: a push landing between that read and the comment being posted is not caught here — the run for that push refreshes the table.
baseline attestation 🟢 GREEN baseline f421d1a7c5e6 matches the main attestation (run 34107119359 · main 39cc7e6b192b · 2026-09-07T09:38:12Z) main attestation artifact via Actions API · in-process · runner What every comparison is measured AGAINST, and who says so. The baseline fields of tests/fixtures/sprint_gate/corpus.json (queries, latency_baseline_ms, thresholds) are compared to the ratchet-attestation artifact of the latest successful push or (no-input) workflow_dispatch run of ratchet-attest.yml on main, fetched through the Actions API — a PR run cannot write to another run's artifacts. A field that differs is RED unless that main run measured the new value; today no runner-side collector measures any baseline field, so today the baseline cannot move by PR at all, and this row says so instead of a hand edit passing. Boundary: the comparator is this PR's checkout of ci_ratchet_table.py, diff-reviewable, not tamper-proof.
provenance 🟢 GREEN stamped cce3cb4efca9 == HEAD, tree clean wheel stamp · in-process · runner Sha half of #749 keg-mode provenance: a keg built from this wheel can answer __build_sha__. The helper-age and served-process predicates need a running BrainBar and are measured only by scripts/sprint_gate.py on an installed Mac. The sha here is the checkout's — the merge ref on a PR — because that is what publish.yml stamps at release time; the PR-head sha this table describes is the one in commit provenance above.
fallback replay debt ⚪ n/a n/a — no fallback queue on this machine: the pending memories live in ~/Gits/*/docs.local/decisions, and docs.local/ is gitignored, so a runner checkout has no copy of them to count docs.local walk · machine with the fallback queue intended_brain_store: true with no chunk_id means a memory reached disk and never reached the DB, so it answers no brain_search. Budget: 0. Any pending or unparseable file is a finding, never a band -- 122 of these sat from 2026-06-28 to 2026-09-05 because nothing counted them where a reader would look. Measured by walking the tree, so it is only ever measured on a machine that HAS the tree.
mapped bytes ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Baseline 26.2 GB — installed Mac, socket, 2026-09-03, after R2 drained 15,070 → 0. Up from 16.8 GB because the drain left more vectors mapped under the same cap: the change is the drain, not a leak. Not measured by this run.
search p50/p95 ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would socket · installed Mac Margin p50: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin p95: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Calibrated on MacBook-Pro.local at 2026-09-01T08:42:22Z under active_sprint_load (tests/fixtures/sprint_gate/corpus.json). Not measured by this run.
idle CPU ⚪ n/a n/a — no BrainBar daemon at /tmp/brainbar.sock: this row needs the daemon, its hybrid helper and the indexed corpus running together, and no GitHub-hosted runner has them (macOS included) — only a self-hosted Darwin/arm64 runner on an installed Mac would ps sampling · installed Mac Ceiling: average CPU < 30% over a 60 s window (resource_budget in scripts/sprint_gate.py), ratified and kept as a hard budget. Margin daemon: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin helper: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Margin watcher: margin unmeasured — 0 of the 5 attested green main runs it needs; no verdict is rendered from fewer. Needs the BrainBar daemon, helper and watcher actually running. Not measured by this run.
signature_valid ⚪ n/a n/a — the macOS signature-parity job is trigger-gated and did not run on this PR: it touches no release or signing path (pyproject.toml, scripts/release-*, scripts/brainlayer-version-check.sh, publish.yml, ratchet.yml) and carries no ratchet:signatures label — a GitHub macOS runner bills at ~10× Linux minutes and rebuilds the keg venv from source codesign · installed keg scripts/release-verify-signatures.sh <keg> codesign-verifies every *.so/*.dylib under libexec/venv. The macOS parity job installs the published tap formula (etanhey/layers/brainlayer), so this row measures the release path — formula, published sdist and Homebrew's relocation — and not this PR's tree. Release-time baseline for the same keg on a different machine: 442 valid / 0 invalid — installed Mac (M4 Max), brew --prefix brainlayer 1.5.11, 2026-09-03.

🟢 GREEN measured, within budget · 🔴 RED measured, out of budget — a finding to clear before merge · ⚪ n/a not measurable on this machine, never guessed.

No RED rows.

Measured on Linux/x86_64 · measured 08325e08616f · PR head 08325e08616f · checkout cce3cb4efca9 · run · updated 2026-09-07 10:25:52 UTC

@EtanHey EtanHey added the size:S Tight-loop PR size: 51-150 hand-written lines changed label Sep 7, 2026
@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

— brainlayerCodex-665a5a35 (worker) · codex/gpt-5.6-sol

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T10:16:55.077495Z 17011a4 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@deepsource-io

deepsource-io Bot commented Sep 7, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 39cc7e6...08325e0 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Python Sep 7, 2026 10:25a.m. Review ↗
Swift Sep 7, 2026 10:25a.m. Review ↗
JavaScript Sep 7, 2026 10:25a.m. Review ↗
Shell Sep 7, 2026 10:25a.m. Review ↗
Secrets Sep 7, 2026 10:25a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 8559e657c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: brainlayerCodex-665a5a35 running gpt-5.6-sol <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_6a9921f6-fca7-4ecc-8e60-6f6ff10fbf94)

@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Follow-up commit 8e2553c1 restores the advertised brain_recall.mode enum as the router's validation authority and replaces the unreachable unknown-mode fallback expectation with an explicit schema-rejection assertion.

— brainlayerCodex-665a5a35 (worker) · codex/gpt-5.6-sol

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8e2553c1ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a34b195c-3f08-490a-9496-66adc8695001)

@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

@codex review

Current PR head is now 17011a45 after the lead merged main into the branch. The merge changed release-version files only; the N1 source/test diff is unchanged, and the focused regression remains green.

— brainlayerCodex-665a5a35 (worker) · codex/gpt-5.6-sol

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 17011a45a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

Pair review — APPROVE (posted as a comment; see the refusal note at the end)

Reviewed head 17011a45, in a worktree checkout of that exact SHA, against origin/main = 39cc7e6b.

1. The diff is the two files it claims to be

$ git diff origin/main...pr-799 --stat
 brain-bar/Sources/BrainBar/MCPRouter.swift         | 17 +++---
 brain-bar/Tests/BrainBarTests/MCPRouterTests.swift | 65 ++++++++++++++++++++++
 2 files changed, 75 insertions(+), 7 deletions(-)

git log --name-only origin/main..pr-799 across all three commits (8559e657, 8e2553c1, merge
17011a45) touches only those two files. No Python under src/brainlayer/mcp/, no
brain_recall description change (line 1734 of MCPRouter.swift is untouched), no real
summary/sessions/operations/plan semantics implemented. Scope is clean.

(A main...pr-799 diff against a stale local main also shows the 1.5.16→1.5.17 bump in
pyproject.toml/server.json/Info.plist/__init__.py. That is #798 already on origin/main,
not this PR. Against origin/main those files are absent from the diff.)

2. Fallback paths — verified by execution, not by reading

The new test exercises all five and passes:

$ swift test --filter "testBrainRecallMakesStatsFallbackExplicitWithoutChangingWorkingModes"
Test Case '-[BrainBarTests.MCPRouterTests testBrainRecallMakesStatsFallbackExplicitWithoutChangingWorkingModes]' passed (0.018 seconds).
	 Executed 1 test, with 0 failures (0 unexpected) in 0.018 (0.018) seconds
  • summary, sessions, operations, plan → stats card plus the notice, no isError.
  • context with no session_id and with session_id: "" → same, both asserted.
  • Notice text carries no transport/daemon language. Correct — this is an unimplemented mode.

3. The four working paths are unchanged

Reading the single hunk: the returned expressions for injections, context-with-session_id,
and stats are character-identical to origin/main; the change is a control-flow restructure
(if sessionId.isEmpty inverted to if !sessionId.isEmpty, then one shared tail). The
injections branch is not in the hunk at all. The test pins the behaviour from the other end:

  • XCTAssertEqual(defaultStats, explicitStats)mode omitted is byte-equal to mode:"stats",
    which was the easiest thing to break here.
  • XCTAssertFalse(...contains(fallbackNoticeFragment)) on stats, injections, and
    context+session_id. None of the three carries a notice.

4. The validator revert is complete — no residue

8e2553c1 restores let schema = tool["inputSchema"] and deletes the whole
if toolName == "brain_recall" { ...mode.removeValue(forKey: "enum")... } block.
On the head SHA, grep -n "brain_recall" over MCPRouter.swift returns lines
23, 47, 606, 1161, 1185, 1699, 1733 — nothing inside validate(arguments:for:) (1565) or
validate(value:against:fieldPath:) (1576)
. No other validator change anywhere in the diff.
toolDefinitions and the router now agree again: the mode enum is the full seven
(context, sessions, operations, plan, summary, stats, injections), and the test asserts the
rejection rather than a handler round-trip:

XCTAssertEqual(rejectedResult["isError"] as? Bool, true)
XCTAssertTrue(rejectedText.contains("Schema validation error: mode must be one of"))

That passes, so a bogus mode is refused at the schema, exactly as asked.

5. Notice wording — accurate, and the qualifier is load-bearing

brain_recall mode "summary" is not implemented by the served BrainBar handler; returned stats instead.

It renders after the card, outside the box:

┌─ BrainLayer Stats
│ Chunks: …
│ Projects: …
│ Types: …
└─

brain_recall mode "summary" is not implemented by the served BrainBar handler; returned stats instead.

I checked whether "by the served BrainBar handler" is real or filler. It is real: the Python
handlers do implement these modes (src/brainlayer/mcp/search_handler.py:1817-1832 dispatches
sessions, operations, plan, summary). So the sentence is a true narrowing, not hedging, and
it implies no breakage. Ships as-is.

One non-blocking wording nit. The context-without-session_id path reuses the same sentence.
It is defensible — BrainBar implements no session-less "current context" the way Python's
_current_context(hours, project) does — but a caller who merely forgot session_id is told the
mode is unimplemented, when supplying the argument would have worked. A mode-specific string there
(…requires session_id; returned stats instead.) would be strictly more useful. Follow-up, not a
merge condition.

Trivial style nit, take it or leave it: guard mode != "stats" else { return … } reads more
awkwardly than if mode == "stats" { return … } for a plain early return.

6. Tests and CI — checked, not assumed

Local, on 17011a45, full BrainBar suite:

$ swift test
	 Executed 891 tests, with 10 tests skipped and 0 failures (0 unexpected) in 169.964 (170.050) seconds
Test Suite 'All tests' passed at 2026-09-07 13:16:51.855.

(891 = the 890 AGENTS.md records for main plus this PR's one new test; that AGENTS.md line is
now one behind. Cosmetic.)

CI at time of writing (gh pr checks 799): swift (macos-15) pass (4m9s) — the job that
actually covers this change — plus lint, changes, ratchet table, CodeRabbit, and all five
DeepSource contexts passing; Cursor Bugbot / Macroscope / launchd / signature parity (keg)
skipped. test (3.11/3.12/3.13) were still pending; this PR touches no Python, so they are not
gating the change under review, but they are not green yet either — worth a glance before merge.

Deployment note (restating, not a finding)

This is Swift in MCPRouter.swift. It cannot reach agents on a brew bump — it needs a BrainBar app
release
. Merging makes it true in the repo, not on anyone's seat.

Verdict

APPROVE. Nothing corrected, nothing to re-push. The rejected validator special-case is fully
gone, the fallback is explicit on every path the brief named, the four working paths are provably
untouched, and the notice string is accurate.

I could not approve formally. gh pr review --approve refuses with "Can not approve your own
pull request"
— the only GitHub identity on this machine is EtanHey, this PR's author, so an
agent review lands as a self-review. Same constraint hit #798. This comment is the review; the lead
merges on it.

— brainlayerClaude-d16849a1 (pair-reviewer) · claude-code/claude-opus-5

@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

Addendum — live MCP round-trip (before/after over the wire)

My first comment proved this unit-green. That is not contract-green, so I went and exercised the
changed path over a real MCP socket. Verdict unchanged: APPROVE. This is confirmation, not a
new finding.

Sources/BrainBarDaemon/MCPRouter.swift is a symlink to ../BrainBar/MCPRouter.swift, so
BrainBarDaemon serves the exact router under review. I built it from head 17011a45 and ran it
on an isolated socket and an empty throwaway DB (BRAINBAR_SOCKET_PATH / BRAINBAR_DB_PATH) —
the live /tmp/brainbar.sock and the canonical DB were never bound or written by the probe. Client
was a Python AF_UNIX speaker using MCP Content-Length framing: initialize, then ten
tools/call brain_recall requests.

Served build (BrainBar 1.5.9, MCPRouter.swift byte-identical to origin/main) — the defect, live

/tmp/brainbar.sock, read-only calls:

args isError notice
{} no
{"mode":"stats"} no
{"mode":"summary"} no ← silent swap
{"mode":"sessions"} no ← silent swap
{"mode":"operations"} no ← silent swap
{"mode":"plan"} no ← silent swap
{"mode":"context"} no ← silent swap
{"mode":"context","session_id":""} no ← silent swap
{"mode":"injections"} n/a (real events)
{"mode":"bogus"} true Schema validation error: mode must be one of …

All six swap rows returned ┌─ BrainLayer Stats / │ Chunks: 824,736 … with nothing telling the
caller its mode was dropped. That is the reported bug, reproduced on the wire.

PR head 17011a45 — same ten calls, same client

Six fallback rows now return the stats card plus, verbatim off the socket:

┌─ BrainLayer Stats
│ Chunks: 0
│ Projects: 
│ Types: 
└─

brain_recall mode "summary" is not implemented by the served BrainBar handler; returned stats instead.

…and the same for sessions, operations, plan, and both context forms ("context" in the
string, correctly). isError is absent on all six — they are successes carrying a notice, as
specified.

The four working paths, over the same socket:

  • {} and {"mode":"stats"} — identical stats card, no notice on either.
  • {"mode":"injections"}│ No injection events found (empty probe DB), no notice.
  • {"mode":"context","session_id":"d16849a1-…"} — takes the dedicated formatter,
    ## Recalled context for "session:d16849a1-…", no notice. It does not fall through.
  • {"mode":"bogus"}isError: true, Schema validation error: mode must be one of context, sessions, operations, plan, summary, stats, injections. Character-identical to the served
    build's response
    , which is the cleanest available proof that the rejected validator special-case
    left no residue: the schema surface is exactly what it was before the branch.

Cleanup

Probe daemon killed, socket/DB/log/scripts removed. /Applications/BrainBar.app and
/tmp/brainbar.sock verified serving throughout — I answered initialize on the live socket both
before and after the probe.

— brainlayerClaude-d16849a1 (pair-reviewer) · claude-code/claude-opus-5

Co-Authored-By: brainlayerCodex-665a5a35 running gpt-5.6-sol <noreply@anthropic.com>
@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5f071fdb-3f7b-4ef7-a4b7-6faaa78fbfa3)

@EtanHey

EtanHey commented Sep 7, 2026

Copy link
Copy Markdown
Owner Author

Re-review — head moved to 08325e08, verdict still APPROVE

My previous two comments reviewed 17011a45. The head has since advanced to 08325e08
("fix(brainbar): clarify recall context fallback"), which takes the context wording nit I raised.
I re-ran everything against the new SHA rather than carry the old verdict forward.

The delta is exactly the nit, and nothing else

$ git diff 17011a45..08325e08

Two hunks, both minimal:

-        let notice = "brain_recall mode \"\(mode)\" is not implemented by the served BrainBar handler; returned stats instead."
+        let notice = mode == "context"
+            ? "brain_recall mode \"context\" requires session_id; returned stats instead."
+            : "brain_recall mode \"\(mode)\" is not implemented by the served BrainBar handler; returned stats instead."

…and the matching test assertion updated to the new string. No other file, no other line. The
stats guard, the four working paths, and the validator are untouched by this commit.

Live MCP round-trip, re-run on 08325e08

Same method as my addendum: BrainBarDaemon built from this SHA (its MCPRouter.swift is a symlink
to the file under review), isolated BRAINBAR_SOCKET_PATH + throwaway BRAINBAR_DB_PATH, Python
AF_UNIX client with Content-Length framing. Last line of each response off the wire:

mode omitted       isError=None  | └─
stats              isError=None  | └─
summary            isError=None  | brain_recall mode "summary" is not implemented by the served BrainBar handler; returned stats instead.
sessions           isError=None  | brain_recall mode "sessions" is not implemented by the served BrainBar handler; returned stats instead.
operations         isError=None  | brain_recall mode "operations" is not implemented by the served BrainBar handler; returned stats instead.
plan               isError=None  | brain_recall mode "plan" is not implemented by the served BrainBar handler; returned stats instead.
context no sid     isError=None  | brain_recall mode "context" requires session_id; returned stats instead.
context sid=''     isError=None  | brain_recall mode "context" requires session_id; returned stats instead.
context sid=real   isError=None  | No context available.
injections         isError=None  | │ No injection events found
bogus              isError=True  | Error: Schema validation error: mode must be one of context, sessions, operations, plan, summary, stats, injections

context sid=real still takes the dedicated formatter (## Recalled context for "session:…",
empty probe DB → "No context available"), so it does not fall through. bogus is still
character-identical to the served build's rejection. Working paths carry no notice. The new
context string is on the wire exactly as written.

Local swift test on 08325e08: 891 executed, 10 skipped, 0 failures (174.0s).
Probe daemon killed, socket/DB/log/scripts removed, live /tmp/brainbar.sock untouched throughout.

One observation on the test, non-blocking

XCTAssertFalse(context.contains(fallbackNoticeFragment), context) on the context+session_id
path is now vacuous: the context fall-through no longer emits fallbackNoticeFragment, so that
assertion cannot fail regardless of behaviour. It is not a hole — the line immediately above it,
XCTAssertTrue(context.contains("Context result must keep its dedicated response")), still catches a
fall-through regression, and my live probe confirms the real behaviour. Just noting it so nobody
later reads that XCTAssertFalse as the guard it used to be.

Verdict

APPROVE on 08325e08. Wording is now accurate on every path: unimplemented modes say
unimplemented, and the one mode that is implemented-but-underspecified says what it needs.

Still cannot approve formally — gh pr review --approve refuses as own-PR (confirmed by running it;
see my first comment). And unchanged: this is Swift, so it needs a BrainBar app release, not a
brew bump.

— brainlayerClaude-d16849a1 (pair-reviewer) · claude-code/claude-opus-5

@EtanHey
EtanHey merged commit 4b11aca into main Sep 7, 2026
18 checks passed
EtanHey added a commit that referenced this pull request Sep 7, 2026
All six sites: pyproject.toml, src/brainlayer/__init__.py, server.json
(root + packages[0]), brain-bar/bundle/Info.plist (short, bundle, release).

Why: #799 (N1, explicit brain_recall stats fallback) is merged at 4b11aca and
is SERVED NOWHERE. It edits brain-bar/Sources/BrainBar/MCPRouter.swift, and the
BrainBar app on both Macs is 1.5.17 / 39cc7e6 -- cut before #799 merged. A
Swift change can never ride a brew formula bump; it needs an app release.

Casks/brainbar.rb is NOT bumped in this PR and this is NOT a declared lag: the
`v*` tag builds the app artifact, and the cask bump is deliberately held as a
separate step because it is the only one that drops /tmp/brainbar.sock and
forces `/mcp reconnect` across every seat. Tagging costs no seat a restart;
installing does. Under the current fleet load the two are being run apart.

Deploy receipt for this release must carry the loaded-process-version row per
Mac (D1), not just the installed keg: after 1.5.17 the M1's drain/hotlane and
the M4's enrichment kept 1.5.16 mapped in memory because only two labels were
kickstarted. `brainlayer --version` cannot see that; `lsof` mappings can.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S Tight-loop PR size: 51-150 hand-written lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant