Skip to content

read_own_chat in a read-only window says where its index stops - #3195

Open
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-readonly-index-stop
Open

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:dev/1-readonly-index-stop

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3194

Written-by: Dev-1
Owner: Dev-1
Reviewer: Reviewer
Tier: T2
Claim-Id: f03c18d9cfb94c20b18270535e7bad41
Base: 0f7e821

What

A second dsh window on one team folder is read-only: chat-index.js catchUp returns at once when the index is not writable, so read_own_chat answers with the rows the writer window indexed. When that writer has not caught up with a part's log — the user is still talking, or it stopped before indexing its last messages — the newest lines are missing, and more: 0 made the read look like the whole chat ("Nothing in your own chat mentions …", "Your own chat is empty.").

The read now checks freshness: indexStop() compares each part's marks.through with the log's own last seq (agent.session.seq - 1) in a non-writable index and returns { at }, built from the newest indexed row time (newestTime over the read's sessions). searchOwnChat, latestOwnChat and aroundOwnChat carry it beside their lines as stop, and read_own_chat appends one sentence to every answer — the bare read, the search (including Nothing in your own chat mentions …), the anchor read and Your own chat is empty. — naming the time the index stops at and saying a message after it is not in this answer. A caught-up window answers byte for byte as before (stop is absent), and the check costs one resolveAgent per part, no log page.

The read-only window does not read the log tail to fill the gap: the index belongs to the writer, and a second read path is out of scope. The write path (catchUp, the mark) is untouched.

Red first (base 0f7e821, only the new assertions, source untouched)

$ cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js

not ok 3 - a read-only window reads the index and leaves it alone (#2711)
not ok 4 - a read-only window reads the index while the writer still holds the home (#2711)
  expected: 'string'
  actual: 'undefined'      (read.stop?.at, test/chat-index-writers.test.js:276 and :302)
# tests 11
# pass 9
# fail 2

Ran (at 9cf96cb, tree e95d983c5b)

The push path rebuilt this head from the local verified commit 1d6f2a3751264e94b94183a5a9a31664945cc506
(the same tree, e95d983c5b); the commands below ran on that tree, and CI runs them again on this head.

  • the same command after the fix → # tests 11 / # pass 11 / # fail 0
  • TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/chat-index-writers.test.js test/own-chat-read-window.test.js test/own-chat-parts-index.test.js test/own-chat-read-parts.test.js test/chat-anchors.test.js test/group-work.test.js → 48/48
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs generate → rewrote 0001/0012 and the test mirror
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs check → 3 lines ok
  • TMPDIR=/tmp node scripts/ds-bot-patches.mjs canonical → ok patches/ds-bot/ is what generate writes (generate is a no-op)
  • ARCH_DOCS_BASE=0f7e8212 node scripts/check-arch-docs.mjs → OK (8 changed file(s))

Verify

TZ=UTC TMPDIR=/tmp npm run verify ends red on this box with exactly two failures, both in
core/test/bench-preflight.test.js: bench.sh refuses before writing the profile when pnpm is missing and bench.sh shows a failed pnpm install and leaves no half-built profile. The same file
fails the same two tests on a clean, unmodified 0f7e8212 tree here — cd core && TZ=UTC TMPDIR=/tmp node --import ./test/harness-resolve.mjs --test test/bench-preflight.test.js → # tests 7 / # pass 5 / # fail 2 — for the documented /usr/bin/pnpm and /bin -> /usr/bin PATH reason, so this change
does not move it. Everything else in verify is green (3341 pass).

Not run

  • the smoke bench: this changes a read answer's sentence and adds a read-side check; no tool registration, channel endpoint, client or write path changed.

Files

core/src/host/chat-index.js, core/src/host/groups.js, core/test/chat-index-writers.test.js, docs/subsystems/core-host.md, changelog.d/3194.fixed.md, patches/ds-bot/0001-core-fixes.patch, patches/ds-bot/0012-room-membership.patch, patches/ds-bot/files/test/chat-index-writers.test.js

Checkpoint

{
  "pr": 3195, "claim": "Dev-1", "issue": 3194,
  "summary": "A read-only window's read_own_chat answered with the rows the writer had indexed, and when the writer lagged the newest messages were missing while more: 0 read as the whole chat. indexStop() now compares each part's mark with the log's last seq, the three reads carry stop: { at }, and read_own_chat appends one sentence naming where the index stops to every answer. A caught-up window answers byte for byte as before, and the write path and the index file are untouched.",
  "files": ["core/src/host/chat-index.js", "core/src/host/groups.js", "core/test/chat-index-writers.test.js", "docs/subsystems/core-host.md", "changelog.d/3194.fixed.md"],
  "checks": { "ran": "TZ=UTC TMPDIR=/tmp npm run verify", "result": "red", "why": "the only two failures are bench-preflight's pnpm/PATH tests, which fail the same way on a clean 0f7e8212 tree here (5 pass / 2 fail)", "at": "9cf96cb202be822ec04ebccb3529d69f3d1f7e09" },
  "next": "none — ready for review"
}

A window another host keeps read-only adds nothing to the chat index, so it answers
with the rows that host indexed. When the writer has not caught up with a part's log —
the user is still talking, or it stopped before indexing its last messages — the newest
lines are missing, and `more: 0` made the read look like the whole chat. The three reads
now carry `stop: { at }` and `read_own_chat` says where the index stops, so a missing
message reads as newer than the cut instead of never said (ThinkFlowLab#3194).

Fixes ThinkFlowLab#3194
@HugoXK
HugoXK marked this pull request as ready for review November 19, 2026 01:04
@HugoXK

HugoXK commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@Birfy review request for a T2 verdict at tip 9cf96cb202be822ec04ebccb3529d69f3d1f7e09 (tree e95d983c5b).

What this slice changes: in a window whose chat index is readable but not writable, chat-index.js catchUp returns at once, so read_own_chat answered with whatever the writer window had indexed. A message already in the log but past that mark simply disappeared from the answer, and more: 0 still made the read look complete (live main: the 4th line was in the log, the mark stopped at seq 2). The read side now compares each part's marks.through with the log's own last seq in a non-writable index and returns a stop point; read_own_chat appends one sentence naming the time and saying a message after it is not in this answer — on the bare read, the search (including the "Nothing in your own chat mentions …" answer), the anchor read and the empty chat. A caught-up window answers byte for byte as before.

At this tip: 15 success + 2 skipped + 1 failure — the failure is enqueue-guard saying no Verdict names this tip yet, which is the T2 gate itself. tests-ok, judge, merge-gate, policy-sign are success.

Red first on base 0f7e8212 (the branch was rebased onto it after #3191 touched the same test file and patches/ds-bot/0001; the earlier 9dc8e9fc reading was discarded):
not ok 3 - a read-only window reads the index and leaves it alone (#2711) and not ok 4 - a read-only window reads the index while the writer still holds the home (#2711), both expected: 'string', actual: 'undefined' (read.stop?.at), # tests 11 / # pass 9 / # fail 2.

Green at this tip: that file 11/11; chat-index-writers + own-chat-read-window + own-chat-parts-index + own-chat-read-parts + chat-anchors + group-work 48/48; ds-bot-patches generate re-run, check three lines ok, canonical no-op.

One honest note on TZ=UTC npm run verify: it exits red, and the two failing cases are bench-preflight's pnpm/PATH environment pair — they fail the same way (5 pass / 2 fail) in a clean 0f7e8212 worktree, so they are unrelated to this change; the other 3341 tests pass.

UI surface: none — this is host answer text, no client change (owner rule wants that stated in the verdict).

Boundaries: the write path is untouched (no index write, catchUp behaviour and the mark unchanged); the read-only window does not read the log tail to fill the gap (that would be a second read path and a separate decision); the searchHomeChat panel's own read is untouched. No gate files, core/client.js or patches/ds-bot/0008 in the diff.

@github-actions github-actions Bot added the risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:T2 Risk tier T2 (host/plugin code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read_own_chat in a read-only window answers more: 0 while its chat index stops at an older point — nothing says the answer stops there

1 participant