Skip to content

Key threads on their id in the runtime, so a thread that lost its opening message takes replies - #1260

Merged
max-sixty merged 4 commits into
mainfrom
agent-a2789b3cd5118c010
Sep 27, 2026
Merged

max-sixty merged 4 commits into
mainfrom
agent-a2789b3cd5118c010

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

A thread's id is now its one identity in the runtime, and its root is a real message. Before this, the user could not reply to or resolve a thread whose opening log line was torn: the append door refused both with unknown parent.

The bug. When a torn line loses a thread's opening comment, build_threads keeps the thread under the lost id. #1237 made the thread read correctly by giving the surviving reply a copy of the lost id as its root ({**reply, "id": parent} in events.py, and the same fallback in thread/model.js). The runtime keyed threads on root.id, so that made attention and the card id line up. But the root is also what a reply or resolve addresses as its parent, and the lost id names no message. So the panel drew the thread, and then the append door answered 400 to every reply and resolve in it. test_a_panel_reads_a_log_that_lost_the_message_a_reply_answers now replies and resolves in such a thread and checks that both land with parent: "tv-kept". On main the reply is refused.

One identity.

  • build_threads gives each thread an id field. For a torn thread, root is the surviving reply under its own id, the same record as msgs[0]. The served state now carries id from the fold instead of adding it separately, and thread_digest reads it.
  • The runtime keys every thread on thread.id: placement and marks (anchor-paint, drawing-paint, placement, surfaces, thread-list), travel and reveal (anchor-travel, narrowing, margin-projection), attention and workflows (application.ts, thread/model.js), news (semantic-news), frozen message documents (state-application), holds (presentation, heldBy), and card ids. root.id is read only where a message is meant: the parent of a reply or settlement, and a thread's turns.
  • threadNames in thread/model.js maps every name that reaches a thread to it: its id, each message's id, and each pending id this tab sent. foldThreads uses it to attach pending replies and settlements. The publisher uses it to find which thread a local or refused reply belongs to. That replaces message.parent used as a thread id, and the separate PENDING + root.attempt lookup for recovery.
  • The thread card's model carries root (the message that replies and settlements address) beside id. wireReply takes the draft key and a parent reader instead of a stand-in thread object, and settleThread takes parent.

Selectors. thread/selectors.js now exports THREAD (.lf-thread, .lf-page-thread), and SAYS_IN is built from it. thread/replies.js, thread/landing.js and thread/focus.js spelled those selectors out; they now import them.

Contract. references/packages.md now says openThread takes the Thread's id, that heldBy is a Thread id, and that root can differ from id. The Thread-filter widget test from #1257 opens threads by thread.id.

Tests. Thread fixtures in application.test.mjs and tests/runtime/ now carry the served id. A new publisher test covers a torn thread: its Ask attention, the subject of a pending reply's workflow, and recovery after a refused reply, all under the lost id. With threadOf reverted to message.parent, that test fails. The Python torn-thread test checks that id is the lost id and root is msgs[0]. Helpers that looked up served threads by root.id (model_folds.threads, test_read_state, test_interact_session, test_render_pages) now use id.

For every thread whose opening message survives, id == root.id, so nothing moves outside the torn case.

🤖 Generated with Claude Code

@max-sixty
max-sixty merged commit 1fdbe9f into main Sep 27, 2026
5 checks passed
@max-sixty
max-sixty deleted the agent-a2789b3cd5118c010 branch September 27, 2026 01:37
max-sixty added a commit that referenced this pull request Sep 27, 2026
The concept survey's drifted duplicates now each have one owner
(#1214–#1221, #1223, #1228, #1231, #1235, #1244, #1245, #1247, #1250,
#1251, #1254, #1260), so the survey note never lands. What it found and
nobody has taken becomes `TODO.md` entries:

- **Shared definitions** (new section under Next): re-addressing
resource references in one pass instead of `http.py`'s regex scopers and
three head composers; `tests/render_harness.py` `told()` beside
`pageReadiness`'s `data` and `log` stages (#1250), which answer the same
question; Python still naming a thread's identity a root
(`thread_roots`, `FrozenThreadReading.roots`) now that the runtime keys
threads on the served `id` (#1260).
- **Requests**: the existing "Decide whether requests earn their weight"
entry now says kept requests need one owner for seat availability, which
four runtime modules restate.
- **Implementation candidates**: the unresolved-gesture ledger as one
state machine, deferred until a change has to touch it, since nothing
there has drifted and it is the hottest race path.

The survey's small undrifted items and its list of deliberate splits are
dropped: none has drifted, and the splits are intended.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 27, 2026
…by it (#1266)

The runtime keys threads on the served `id` (#1260), but Python still
called
that identity a root: `thread_roots`, `FrozenThreadReading.roots`, and
the
`root`/`root_id` locals and parameters that carried it. For a thread
whose
opening comment a torn line lost, the id is the lost comment's and the
root
(`build_threads`' `root`) is the surviving reply, so the two names meant
different things. Three readings looked a thread up through its opening
comment and so missed a torn thread.

**One relation, named for what it maps.** `thread_roots` becomes
`thread_names`: every name that reaches a thread, mapped to the thread's
id.
Like the runtime's `threadNames`, its keys now include a torn thread's
own id
as well as each message id, so `event_threads` reads a resolve naming
the
lost id by a plain lookup instead of searching the map's values.
`FrozenThreadReading.roots` becomes `thread_by_name`, beside
`thread_by_widget`. Parameters and locals in `read_state`, `history`,
`agent_state`, `asks`, `delivery`, `transcript`, `projection`,
`admission`
and `thread` that held a thread id are renamed to say so. `root` stays
where
it means the opening message: `build_threads`' `root`, `seat_root`, and
`cmd_reply`'s check that the opening comment survives and holds no
command
goal (now `opening`, beside `thread_id`).

**What moved for a torn thread:**

- The history feed (`x-history`) names the thread each row was made in.
It
looked the thread up through its opening comment, so every row in a torn
thread named none. It now reads the thread from the `build_threads` fold
by
  id.
- `comment_ids`, the namespace `lf-suggestion`'s `resolves` and
`data-specimen-threads` are checked against, held the comments in the
log
  and left out a torn thread, whose id the page state serves. It becomes
`thread_ids`, the values of `thread_names`, so a suggestion resolving a
torn
thread validates. The refusal now reads `names no thread in this
document`.
`specimen_events` drops its intersection with that set, which the
membership
  filter below it already applied.
- `leaf thread reply --to <id>` with a torn thread's id, the natural
move for
an agent holding a thread id, was refused as an unknown comment id. The
refusal (`logged_id`) now says the thread lost its opening message and
gives
  the `--to` of the first message it still holds.

`validation.md` and `page-authoring.md` say thread ids where they said
root
ids.

**Tests.**
`test_a_thread_whose_opening_message_was_torn_away_still_reads`
now checks `thread_names`, the history rows of the torn thread, and the
`--to` refusal.
`test_suggestion_resolves_a_thread_whose_opening_comment_was_lost`
covers the namespace. Each new assertion fails with its fix reverted.
Three
tests follow the refusal's new wording.


🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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