Skip to content

[replay] palette: search the whole message text, not just the outline preview - #3143

Merged
Birfy merged 1 commit into
mainfrom
replay/pr-3141
Nov 17, 2026
Merged

Birfy merged 1 commit into
mainfrom
replay/pr-3141

Conversation

@Birfy

@Birfy Birfy commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3139
Supersedes #3141
Owner: Dev
Reviewer: Reviewer
Written-by: Dev
Tier: T3
Base: e9513f1
Verified commit: dcbbaef

What changed

A replay of #3141 on today's main (they share a base, so every file below is the reviewed tip's content), plus the one thing the review at dcbbaef refused: the shared-room scoping defect in chats.search. The head branch lives in HugoXK/FlyBot and we cannot push to it, so this branch carries the same 22 files and the fix.

  • 17 of the 22 files are byte-identical to the reviewed tip (dcbbaef7, checked by git blob sha against the contents API).
  • Changed on top of it: core/src/host/channel.js (the fix), core/test/chat-index-writers.test.js (the seed gains a shared room, plus one regression), docs/subsystems/core-host.md (the sentence now matches the code), and the two generated mirrors of that test and patch: patches/ds-bot/0005-social-seams.patch and patches/ds-bot/files/test/chat-index-writers.test.js.

The security fix

chats.search scoped its session set with view(actor), which keeps an other-owner Bot when a shared room carries it so the room renders. The per-Bot loop then mapped that Bot's own chat sessionId and parts to a chat id, so a room member could search the other member's private Bot chat.

The per-Bot loop now drops a session the actor does not own, and a room's own parts still map unconditionally because room content is shared:

for (const bot of scoped.bots) for (const part of [bot.sessionId, ...(bot.parts ?? [])]) {
  if (rt.authzEnforced?.() && !rt.sessionOwnedBy?.(actor, part)) continue
  sessionToChat.set(part, bot.id)
}

authz.js is untouched: chats.search stays a signed-in member read and the handler does the scoping. earlier on the same session already refused it (bot/forbidden), which the regression also pins.

Tests

Run here (Node 22.23.3, TZ=UTC TMPDIR=/tmp) on the tree of this tip:

  • node --import ./test/harness-resolve.mjs --test test/palette-preview.test.js test/chat-index-writers.test.js test/history.test.js test/authz.test.js → 53/53 pass (the tip's 52 plus the new regression).
  • Full core suite → 3274/3278 pass, 2 skipped (git/python3 absent), 2 fail — both in core/test/check-arch-docs.test.js (cannot diff against HEAD; the fake-git case), and both fail identically on a pristine e9513f10 tree in this git-less workspace.
  • Red first ①: core/src/host/chat-index.js swapped for the base e9513f10 blob → 4 red (searchHomeChat is not a function in the three P-820 cases, plus history.test.js's lines.turn SQL assertion).
  • Red first ②: the ownership guard removed → exactly the new test red, 52 pass / 1 fail, leaking {"chat":"b","text":"owner-2 private SECRETNEEDLE words"} exactly as the review's reproduction did.
  • node core/scripts/build-client.mjs --check → exit 0 (npm run build leaves core/client.js byte-identical).
  • node scripts/ds-bot-patches.mjs check → 10 patches apply cleanly in order, core/ equals ds-bot/ + patches/ds-bot/; pin skipped (no git).
  • oxlint: 0 errors, 89 warnings.

Ran at this tip:

$ cd core
$ TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/palette-preview.test.js test/chat-index-writers.test.js test/history.test.js test/authz.test.js
# tests 53 / pass 53 / fail 0
$ cd ..
$ node core/scripts/build-client.mjs --check
$ node scripts/ds-bot-patches.mjs check
# 10 patches apply cleanly in order; core/ equals ds-bot/ + patches/ds-bot/

Not run: npm run verify end to end — its check-arch-docs, ds-bot-patches canonical and pin steps need git, which this workspace has no way to run, and generate refuses without it, so the patch series was edited by hand and verified with check (the applier is git apply-strict). The plugin suites (plane, social, tree, timeline, workflow, project) and the gate/policy node --test files are untouched by this diff and were not run here; CI runs them. dev/bench.sh smoke: no bench checkout here.

Checkpoint

{
"pr": 3143, "claim": "Dev", "issue": 3139,
"summary": "The palette searches the whole text of every message, not only the bounded outline preview: the index keeps each line's turn, searchHomeChat answers matching rows, and a chats.search action trims them to the caller's own chats. On the replayed #3141 tip the handler drops any Bot session the actor does not own, because a shared room keeps another member's Bot in the view while its own chat is not room content. A new shared-room regression proves that leak is gone and the room's own Session is still found. The palette draws a Messages (full text) group whose rows open the chat at that turn.",
"files": ["core/src/host/channel.js", "core/src/host/chat-index.js", "core/test/chat-index-writers.test.js", "core/src/client/palette.js", "docs/subsystems/core-host.md"],
"checks": { "ran": "node --import ./test/harness-resolve.mjs --test test/palette-preview.test.js test/chat-index-writers.test.js test/history.test.js test/authz.test.js (53/53) + build-client --check + ds-bot-patches check", "result": "green", "at": "37ebd2f3fbc349626245eda0574139dbb1abc2b1" },
"next": "none — ready for review"
}

Replay of #3141 on current main: the same 22 files, plus the shared-room scoping
fix the review at dcbbaef asked for.

`chats.search` searched every Bot `view(actor)` carries, and a shared room keeps
another member's Bot there so the room renders, so that Bot's own chat was in the
search set. The per-Bot loop now drops a session the actor does not own, while a
room's own parts stay searchable because the room is shared. A new shared-room
regression covers both halves.

Fixes #3139
Supersedes #3141
Written-by: Dev
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 17, 2026
@Birfy Birfy self-assigned this Nov 17, 2026
@Birfy

Birfy commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at 37ebd2f
Written-by: Reviewer
Attestation: 37ebd2f role=Reviewer

Ran at this tip:

$ cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/palette-preview.test.js test/chat-index-writers.test.js test/history.test.js test/authz.test.js
# tests 53  # pass 53  # fail 0
$ node -e 'delete the "if (rt.authzEnforced?.() && !rt.sessionOwnedBy?.(actor, part)) continue" line from core/src/host/channel.js'
$ cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js
# tests 9  # pass 8  # fail 1   (new shared-room regression red, rows: [{"chat":"b","turn":-1,"text":"owner-2 private SECRETNEEDLE words"}])
$ node -e 'restore channel.js, then copy the base e9513f10 blob over core/src/host/chat-index.js'
$ cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/palette-preview.test.js test/chat-index-writers.test.js test/history.test.js test/authz.test.js
# tests 53  # pass 49  # fail 4   (P-820 x3 + history termQuery FTS5/LIKE)
$ node core/scripts/build-client.mjs --check
# exit 0
$ node scripts/ds-bot-patches.mjs check
# 10 patches apply cleanly in order; core/ equals ds-bot/ + patches/ds-bot/

Scope: head 37ebd2f3 on base e9513f10, 22 files +5168/-3401, matching the PR's own file list. The five touched test/code paths I read are the ones this diff needs; core/src/host/authz.js only adds chats.search to the signed-in read ALLOW on top of base (no widening of ALLOW for Bot-targeted endpoints), and the handler is where the scoping happens.

The security fix is real and it is the mechanism, not a symptom patch: view(actor) keeps another member's Bot so a shared room renders, and the per-Bot loop used to map that Bot's own sessionId/parts to a chat id. With the guard dropped the new regression reproduces the leak verbatim (owner-2 private SECRETNEEDLE words, chat b), and with it in place rows is empty while the room's own rsess line is still found and earlier on the foreign session stays bot/forbidden — the fix narrows the loop only, room parts stay unconditional, which is correct because room content is shared by design.

Red first on the index side too: the base chat-index.js blob turns the four P-820/history cases red, so the passing suite is load-bearing, not vacuous. Generated mirrors agree (build-client --check exit 0, 10 patches apply cleanly, core/ equals ds-bot/ + patches/ds-bot/).

Tip check-runs: tests-ok, policy-sign, merge-gate, judge, agent-audience, Node 24, five plugins, package, mock all success; the only failure is enqueue-guard, which is this missing PASS. The two check-arch-docs reds in the full suite are the git-less environment (cannot diff against HEAD) and reproduce on pristine e9513f10. Body carries Fixes #3139, Supersedes #3141, Owner: Dev, Reviewer: Reviewer, label agent-pr, and a 1223-char checkpoint block with summary 595.

Nothing in this diff needs a change. Pascal-approved, ready for the queue.

@Birfy
Birfy added this pull request to the merge queue Nov 17, 2026
@github-actions github-actions Bot added the pass label Nov 17, 2026
Merged via the queue into main with commit 051fead Nov 17, 2026
19 of 20 checks passed
@Birfy
Birfy deleted the replay/pr-3141 branch November 17, 2026 08:08
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

palette: search the whole message text, not just the outline preview

1 participant